1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Perso About |
---|
4 | Version: auto |
---|
5 | Description: Add bloc perso on about page |
---|
6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=480 |
---|
7 | Author: ddtddt |
---|
8 | Author URI: http://piwigo.org/ |
---|
9 | */ |
---|
10 | |
---|
11 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
12 | |
---|
13 | define('PPA_DIR' , basename(dirname(__FILE__))); |
---|
14 | define('PPA_PATH' , PHPWG_PLUGINS_PATH . PPA_DIR . '/'); |
---|
15 | |
---|
16 | add_event_handler('get_admin_plugin_menu_links', 'PA_admin_menu'); |
---|
17 | function PA_admin_menu($menu) |
---|
18 | { |
---|
19 | array_push($menu, array( |
---|
20 | 'NAME' => 'Perso About', |
---|
21 | 'URL' => get_admin_plugin_menu_link(PPA_PATH . 'admin/admin.php'))); |
---|
22 | return $menu; |
---|
23 | } |
---|
24 | |
---|
25 | if (script_basename() == 'about') |
---|
26 | { |
---|
27 | add_event_handler('loc_end_page_header', 'ppa'); |
---|
28 | } |
---|
29 | |
---|
30 | function ppa() |
---|
31 | { |
---|
32 | global $template; |
---|
33 | $template->set_prefilter('about', 'ppaT'); |
---|
34 | |
---|
35 | $PAED = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ExtendedDescription';")); |
---|
36 | if($PAED['state'] == 'active') add_event_handler('AP_render_content', 'get_user_language_desc'); |
---|
37 | |
---|
38 | $query = ' |
---|
39 | select param,value |
---|
40 | FROM ' . CONFIG_TABLE . ' |
---|
41 | WHERE param = "persoAbout" |
---|
42 | ;'; |
---|
43 | $result = pwg_query($query); |
---|
44 | $row = mysql_fetch_array($result); |
---|
45 | $pat=trigger_event('AP_render_content', $row['value']); |
---|
46 | if (!empty($pat)) |
---|
47 | { |
---|
48 | $template->assign('PERSO_ABOUT', $pat); |
---|
49 | } |
---|
50 | |
---|
51 | } |
---|
52 | |
---|
53 | function ppaT($content, &$smarty) |
---|
54 | { |
---|
55 | |
---|
56 | $search = '#<div id="piwigoAbout">#'; |
---|
57 | |
---|
58 | $replacement = '<div id="piwigoAbout"><div id="persoabout">{$PERSO_ABOUT}</div>'; |
---|
59 | |
---|
60 | return preg_replace($search, $replacement, $content); |
---|
61 | } |
---|
62 | ?> |
---|