예제 #1
0
파일: Plugin.php 프로젝트: ssrsfs/blg
 public function output(Pagemill_Data $data, Pagemill_Stream $stream)
 {
     $db = Typeframe::Database();
     if ($this->hasAttribute('rules') && !Typeframe_Tag_Socket::ProcessRules($this->getAttribute('rules'))) {
         return '';
     }
     /*
      * Rules for loading the plugin:
      * 1. The plugid overrides other load settings.
      * 2. Load a plugin from the table if the name attribute matches an
      *    an admin-specified name.
      * 3. Create a generic plugin from a signature.
      * 4. If the plugin was loaded from the database, attribute settings
      *    override database settings.
      */
     $p = null;
     if ($this->getAttribute('plugid')) {
         $plugin = Model_Plug::Get($data->parseVariables($this->getAttribute('plugid')));
         if ($plugin->exists()) {
             $p = Typeframe::Registry()->getPluginSignature($plugin['plug']);
         }
     } else {
         if ($this->getAttribute('name')) {
             $plugins = new Model_Plug();
             $plugins->where('name = ?', $data->parseVariables($this->getAttribute('name')));
             $plugin = $plugins->getFirst();
             if ($plugin->exists()) {
                 $p = Typeframe::Registry()->getPluginSignature($plugin['plug']);
             } else {
                 $p = Typeframe::Registry()->getPluginSignature($this->getAttribute('name'));
             }
         }
     }
     if ($p) {
         $cls = $p->className();
         if (class_exists($cls)) {
             $settings = $this->settings;
             foreach ($this->attributes() as $k => $v) {
                 $settings[$k] = $data->parseVariables($v);
             }
             //$obj = new $cls($settings);
             $obj = new $cls('plugin', $settings, null);
             foreach ($this->children() as $child) {
                 $obj->appendChild($child);
             }
             $obj->process($data, $stream);
             foreach ($obj->children() as $child) {
                 $this->appendChild($child);
             }
             $obj->detach();
         } else {
             throw new Exception("Class '{$cls}' does not exist");
         }
     } else {
         throw new Exception("Plugin does not have a signature");
     }
 }
예제 #2
0
파일: integration.php 프로젝트: ssrsfs/blg
 public function testContentPluginAdmin()
 {
     $this->logIn();
     $plugs = new Model_Plug();
     $plugs->where('plug = ?', 'Content');
     foreach ($plugs->getAll() as $plug) {
         $this->get(TYPEF_WEB_DIR . '/admin/content/plug?plugid=' . $plug['plugid']);
         $this->getAssets();
     }
 }
예제 #3
0
파일: Submenu.php 프로젝트: ssrsfs/blg
 public function admin(Pagemill_Data $data, Pagemill_Stream $stream)
 {
     $this->adminTemplate = '/admin/navigation/submenu.plug.html';
     $menus = new Model_Plug();
     $menus->where('plug = ?', 'Navigation');
     // TODO: Clone it or find some other way to manage data conflicts
     $data = $data->fork();
     $data['menus'] = $menus;
     parent::admin($data, $stream);
 }
예제 #4
0
파일: index.php 프로젝트: ssrsfs/blg
	$template = TYPEF_SOURCE_DIR . '/templates/content/' . (!empty($settings['template']) ? $settings['template'] : 'generic.html');
	if (!file_exists($template))
	{
		$page->set('dead_template', $settings['template']);
		$template = (TYPEF_SOURCE_DIR . '/templates/content/generic.html');
	}
	$elements = Insertable::ElementsFrom($template);
	$groups   = Insertable::GroupsFrom($template);
	if ((count($elements) > 0) || (count($groups) > 0))
	{
		$garray = array();
		foreach ($groups as $group)
		{
			if (empty($group['admin']) || (Typeframe::User()->get('usergroupid') == TYPEF_ADMIN_USERGROUPID) || inGroup($group['admin']))
				$garray[] = $group;
		}
		$page->set('groups', $garray);
		$pm->addLoop('pages', $page->getAsArray());
	}
}*/
$pm->setVariable('pages', $pages);
// add plugins
$plugs = new Model_Plug();
//$plugs->where('plug = ?', 'Content');
$plugs->where('siteid = ?', Typeframe::CurrentPage()->siteid());
$plugs->order('name');
$pm->setVariable('plugins', $plugs);
/*$all_pages = new Model_Page();
$all_pages->where('siteid = ?', Typeframe::CurrentPage()->siteid());
$all_pages->order('nickname, uri');
$pm->setVariable('all_pages', $all_pages);*/