[18997] | 1 | <?php |
---|
| 2 | /* |
---|
[31378] | 3 | Version: 1.2.3 |
---|
[18997] | 4 | Plugin Name: Evil_Blog |
---|
| 5 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=611 |
---|
| 6 | Author: EvilKant |
---|
| 7 | Description: Small blog for your gallery. |
---|
| 8 | */ |
---|
| 9 | |
---|
| 10 | // Chech whether we are indeed included by Piwigo. |
---|
| 11 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 12 | |
---|
| 13 | global $prefixeTable; |
---|
| 14 | // Определяем директорию плагина |
---|
| 15 | define('Evil_Blog_PATH', PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); |
---|
| 16 | define('Evil_Blog_Admin', get_root_url() . 'admin.php?page=plugin-' . basename(dirname(__FILE__))); |
---|
| 17 | define('Evil_Blog_Table', $prefixeTable."evil_blog"); |
---|
| 18 | //Включаем перевод плагина |
---|
[31378] | 19 | add_event_handler('loading_lang', 'Evil_Blog_loading_lang'); |
---|
| 20 | function Evil_Blog_loading_lang() |
---|
| 21 | { |
---|
| 22 | load_language('plugin.lang', Evil_Blog_PATH); |
---|
| 23 | } |
---|
[18997] | 24 | |
---|
| 25 | //Делаем пункт меню в админке |
---|
| 26 | add_event_handler('get_admin_plugin_menu_links', 'Evil_Blog_admin_menu'); |
---|
| 27 | |
---|
| 28 | function Evil_Blog_admin_menu($menu) { |
---|
| 29 | array_push( |
---|
| 30 | $menu, |
---|
| 31 | array( |
---|
| 32 | 'NAME' => 'Evil_Blog', |
---|
| 33 | 'URL' => get_admin_plugin_menu_link(dirname(__FILE__)).'/admin.php' |
---|
| 34 | ) |
---|
| 35 | ); |
---|
| 36 | return $menu; |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | |
---|
| 40 | function Evil_Blog_main () { |
---|
| 41 | global $template, $tokens, $conf, $page; |
---|
| 42 | |
---|
| 43 | //выковыриваем из базы настройки блога |
---|
| 44 | $page['evil_blog'] = @unserialize($conf['evil_blog']); |
---|
| 45 | |
---|
[19304] | 46 | //включаем Extended Description для пунктов меню |
---|
[18997] | 47 | $ExDesc = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ExtendedDescription';")); |
---|
| 48 | if($ExDesc['state'] == 'active') { |
---|
| 49 | $page['evil_blog']['blog_name'] = get_user_language_desc($page['evil_blog']['blog_name']); |
---|
| 50 | $page['evil_blog']['blog_description'] = get_user_language_desc($page['evil_blog']['blog_description']); |
---|
| 51 | } |
---|
| 52 | |
---|
[19049] | 53 | //вызываем добавление пункта меню |
---|
| 54 | add_event_handler('blockmanager_apply', 'add_blog_to_menu'); |
---|
[18997] | 55 | |
---|
[19049] | 56 | //RSS |
---|
[19048] | 57 | if ((!empty($tokens[1])) and ($tokens[1]=="feed")) { |
---|
| 58 | include_once (Evil_Blog_PATH.'feed.php'); |
---|
[18997] | 59 | } |
---|
| 60 | |
---|
[19304] | 61 | if (((empty($tokens[0])) and ($page['evil_blog']['show_on_main_page'])) or |
---|
| 62 | (($tokens[0]=='categories') and ($page['evil_blog']['show_on_category_page'])) or |
---|
[19049] | 63 | (($tokens[0]=='blog') and ((empty($tokens[1]) or ($tokens[1]!='id'))))) { |
---|
| 64 | include_once (Evil_Blog_PATH.'blog.php'); |
---|
| 65 | }else{ |
---|
| 66 | if ( ($tokens[0]=='blog') and (!empty($tokens[1])) and ($tokens[1]=='id') and (!empty($tokens[2])) ) { |
---|
| 67 | include_once (Evil_Blog_PATH.'post.php'); |
---|
[18997] | 68 | } |
---|
[19049] | 69 | } |
---|
[18997] | 70 | } |
---|
| 71 | |
---|
| 72 | //описываем действия во время собырия loc_begin_index, ну тобишь выводим плагин на странице |
---|
| 73 | add_event_handler('loc_begin_index', 'Evil_Blog_main'); |
---|
| 74 | |
---|
| 75 | //функция добавления пункта меню |
---|
| 76 | function add_blog_to_menu($aMenuRefArray) { |
---|
| 77 | global $conf, $page; |
---|
| 78 | |
---|
| 79 | //хрен его знает что это, какаято проверка на существование меню |
---|
| 80 | $menu = &$aMenuRefArray[0]; |
---|
| 81 | $block_mbMenu = $menu->get_block('mbMenu'); |
---|
| 82 | if (null == $block_mbMenu) { |
---|
| 83 | return; |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | if (!isset($block_mbMenu->data['evil_blog'])) { |
---|
| 87 | $blog_menu = array( |
---|
| 88 | 'TITLE' => $page['evil_blog']['blog_description'], |
---|
| 89 | 'NAME' => $page['evil_blog']['blog_name'], |
---|
| 90 | 'URL' => make_index_url(array('section' => 'blog')), |
---|
| 91 | ); |
---|
| 92 | $block_mbMenu->data['evil_blog'] = $blog_menu; |
---|
| 93 | } |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | function section_init_evil_blog() |
---|
| 97 | { |
---|
[19049] | 98 | global $page, $tokens; |
---|
[18997] | 99 | |
---|
[19048] | 100 | if ($tokens[0]=='blog') { |
---|
[18997] | 101 | $page['section'] = 'blog'; |
---|
| 102 | } |
---|
| 103 | } |
---|
| 104 | //инициация страницы блога, без этого на ней появляется список с категориями. |
---|
| 105 | add_event_handler('loc_end_section_init', 'section_init_evil_blog'); |
---|
| 106 | |
---|
| 107 | ?> |
---|