of different Piwigo page
Plugin URI: http://piwigo.org/ext/extension_view.php?eid=507
Author: ddtddt
Author URI: http://piwigo.org/
*/
if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
global $prefixeTable, $template;
define('TITLE_DIR' , basename(dirname(__FILE__)));
define('TITLE_PATH' , PHPWG_PLUGINS_PATH . TITLE_DIR . '/');
define('TITLE_TABLE' , $prefixeTable . 'title');
define('TITLE_PHOTO_TABLE' , $prefixeTable . 'title_photo');
define('TITLE_ALBUM_TABLE' , $prefixeTable . 'title_album');
//prefiltre for change
add_event_handler('loc_begin_page_header', 'plug_Title', 56 );
function plug_Title()
{
global $template;
$template->set_prefilter('header', 'plug_TitleP');
$PAED = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ExtendedDescription';"));
if($PAED['state'] == 'active') add_event_handler('AP_render_content', 'get_user_language_desc');
}
function plug_TitleP($content, &$smarty)
{
$search = '#.*?#';
$replacement = '{$PERSO_TITLE}
';
return preg_replace($search, $replacement, $content);
}
// Plugin for admin
if (script_basename() == 'admin')
{
include_once(dirname(__FILE__).'/initadmin.php');
}
// no empty !
add_event_handler('loc_begin_page_header', 'plugTitle', 61 );
function plugTitle()
{
global $template, $conf;
$titlegen = & $conf['gallery_title'];
if (!empty($titlegen))
{
$template->assign('PERSO_TITLE', $titlegen);
}
}
//use title on photo page
add_event_handler('loc_begin_page_header', 'TitlePhoto', 76 );
function TitlePhoto()
{
global $template, $page;
if ( !empty($page['image_id']) )
{
$query = '
select id,title
FROM ' . TITLE_PHOTO_TABLE . '
WHERE id = \''.$page['image_id'].'\'
;';
$result = pwg_query($query);
$row = pwg_db_fetch_assoc($result);
$titleP=$row['title'];
$titlePED=trigger_event('AP_render_content', $titleP);
if (!empty($titlePED))
{
$template->assign('PERSO_TITLE', $titlePED);
}
}
}
// use title on album page
add_event_handler('loc_begin_page_header', 'Titlealbum', 71 );
function Titlealbum()
{
global $template, $page;
if (!empty($page['category']['id']) )
{
$query = '
select id,title
FROM ' . TITLE_ALBUM_TABLE . '
WHERE id = \''.$page['category']['id'].'\'
;';
$result = pwg_query($query);
$row = pwg_db_fetch_assoc($result);
$titleA=$row['title'];
$titleAED=trigger_event('AP_render_content', $titleA);
if (!empty($titleAED))
{
$template->assign('PERSO_TITLE', $titleAED);
}
}
}
//other pages
add_event_handler('loc_begin_page_header', 'Titleother', 66 );
function Titleother()
{
global $template, $page;
$query = '
select id,page,title
FROM ' . TITLE_TABLE . '
WHERE page IN (\'home\', \'best_rated\', \'most_visited\', \'recent_pics\', \'recent_cats\', \'favorites\', \'tags\', \'comments\', \'about\', \'search\', \'random\', \'notification\')
;';
$result = pwg_query($query);
$titlespecial = array();
while ($row = pwg_db_fetch_assoc($result))
{
$titlespecial[$row['page']] = $row['title'];
$titlespecialED[$row['page']]=trigger_event('AP_render_content', $titlespecial[$row['page']]);
}
if (isset($page['section']) and $page['section'] == 'categories' and empty($page['category']['id']) and !empty($titlespecialED['home']))
{
$template->assign('PERSO_TITLE', $titlespecialED['home']);
}
if (isset($page['section']) and $page['section'] == 'best_rated' and !empty($titlespecialED['best_rated']))
{
$template->assign('PERSO_TITLE', $titlespecialED['best_rated']);
}
if (isset($page['section']) and $page['section'] == 'most_visited' and !empty($titlespecialED['most_visited']))
{
$template->assign('PERSO_TITLE', $titlespecialED['most_visited']);
}
if (isset($page['section']) and $page['section'] == 'recent_pics' and !empty($titlespecialED['recent_pics']))
{
$template->assign('PERSO_TITLE', $titlespecialED['recent_pics']);
}
if (isset($page['section']) and $page['section'] == 'recent_cats' and !empty($titlespecialED['recent_cats']))
{
$template->assign('PERSO_TITLE', $titlespecialED['recent_cats']);
}
if (isset($page['section']) and $page['section'] == 'favorites' and !empty($titlespecialED['favorites']))
{
$template->assign('PERSO_TITLE', $titlespecialED['favorites']);
}
if (script_basename() == 'tags' and !empty($titlespecialED['tags']))
{
$template->assign('PERSO_TITLE', $titlespecialED['tags']);
}
if (script_basename() == 'comments' and !empty($titlespecialED['comments']))
{
$template->assign('PERSO_TITLE', $titlespecialED['comments']);
}
if (script_basename() == 'about' and !empty($titlespecialED['about']))
{
$template->assign('PERSO_TITLE', $titlespecialED['about']);
}
if (script_basename() == 'search' and !empty($titlespecialED['search']))
{
$template->assign('PERSO_TITLE', $titlespecialED['search']);
}
if (isset($page['section']) and $page['section'] == 'list' and !empty($titlespecialED['random']))
{
$template->assign('PERSO_TITLE', $titlespecialED['random']);
}
if (script_basename() == 'notification' and !empty($titlespecialED['notification']))
{
$template->assign('PERSO_TITLE', $titlespecialED['notification']);
}
}
?>