addItem(__('Templates'), 'plugin.php?p=templator','index.php?pf=templator/icon.png', preg_match('/plugin.php\?p=templator(&.*)?$/',$_SERVER['REQUEST_URI']), $core->auth->check('contentadmin,templator',$core->blog->id)); $core->auth->setPermissionType('templator',__('manage templates')); if ($core->auth->check('templator,contentadmin',$core->blog->id)) { $core->addBehavior('adminPostFormSidebar',array('templatorBehaviors','adminPostFormSidebar')); $core->addBehavior('adminPageFormSidebar',array('templatorBehaviors','adminPostFormSidebar')); $core->addBehavior('adminAfterPostCreate',array('templatorBehaviors','adminBeforePostUpdate')); $core->addBehavior('adminBeforePostUpdate',array('templatorBehaviors','adminBeforePostUpdate')); $core->addBehavior('adminAfterPageCreate',array('templatorBehaviors','adminBeforePostUpdate')); $core->addBehavior('adminBeforePageUpdate',array('templatorBehaviors','adminBeforePostUpdate')); $core->addBehavior('adminPostsActionsCombo',array('templatorBehaviors','adminPostsActionsCombo')); $core->addBehavior('adminPostsActions',array('templatorBehaviors','adminPostsActions')); $core->addBehavior('adminPostsActionsContent',array('templatorBehaviors','adminPostsActionsContent')); $core->addBehavior('adminPagesActionsCombo',array('templatorBehaviors','adminPostsActionsCombo')); $core->addBehavior('adminPagesActions',array('templatorBehaviors','adminPostsActions')); $core->addBehavior('adminPagesActionsContent',array('templatorBehaviors','adminPostsActionsContent')); } class templatorBehaviors { public static function adminPostFormSidebar($post) { global $core; $tpl = array(' ' => ''); $tpl_post = array(); $selected = ''; foreach ($core->templator->tpl as $k => $v) { if (!preg_match('/^category-(.+)$/',$k)) { $tpl_post= array_merge($tpl_post, array($k => $k)); } } $tpl = array_merge($tpl,$tpl_post); if ($post) { $params['meta_type'] = 'template'; $params['post_id'] = $post->post_id; $post_meta = $core->meta->getMetadata($params); $selected = $post_meta->isEmpty()? '' : $post_meta->meta_id ; } echo '