예제 #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
파일: Content.php 프로젝트: ssrsfs/blg
 public function admin(\Pagemill_Data $data, \Pagemill_Stream $stream)
 {
     $this->adminTemplate = '/admin/content/settings.plug.html';
     $data = $data->fork();
     $data->setArray($this->attributes());
     $templates = array();
     $dh = opendir(self::GetTemplateDirectory());
     $dh = opendir(TYPEF_SOURCE_DIR . '/templates/content');
     while (($file = readdir($dh)) !== false) {
         if ($file != "." && $file != "..") {
             if (is_file(self::GetTemplateDirectory() . $file)) {
                 if (preg_match('/.plug./', $file)) {
                     $source = file_get_contents(TYPEF_SOURCE_DIR . '/templates/content/' . $file);
                     preg_match('/pm:tmplname="([\\w\\W\\s\\S]*?)"/', $source, $matches);
                     if ($matches) {
                         $label = $matches[1];
                     } else {
                         $label = $file;
                     }
                     $templates[] = array('template' => $file, 'label' => $label);
                 }
             }
         }
     }
     closedir($dh);
     $data['templates'] = $templates;
     $plugin = Model_Plug::Get($_REQUEST['plugid']);
     if ($plugin->exists()) {
         $data['plugin'] = $plugin;
         $data['settings'] = $plugin['settings'];
         parent::admin($data, $stream);
     }
 }
예제 #5
0
파일: Plugin.php 프로젝트: ssrsfs/blg
 /**
  * Update the plugin settings.
  * @param array $input An associative array of settings.
  */
 public function update(array $input)
 {
     $plugin = Model_Plug::Get($input['plugid']);
     if ($plugin->exists()) {
         $plugin['name'] = isset($input['name']) ? $input['name'] : (isset($input['settings']) && isset($input['settings']['name']) ? $input['settings']['name'] : '');
         $plugin['settings'] = $input['settings'];
         $plugin->save();
     } else {
         throw new Exception("Plugin not found");
     }
 }
예제 #6
0
파일: PluginAdmin.php 프로젝트: ssrsfs/blg
 public function output(\Pagemill_Data $data, \Pagemill_Stream $stream)
 {
     $plugid = $data->parseVariables($this->getAttribute('plugid'));
     $plug = Model_Plug::Get($plugid);
     if ($plug->exists()) {
         $name = $plug['plug'];
         $sig = Typeframe::Registry()->getPluginSignature($name);
         $cls = $sig->className();
         if (is_subclass_of($cls, 'Plugin')) {
             $plug['settings']['plugid'] = $plugid;
             $plug = new $cls('', $plug['settings'], $this);
             $plug->admin($data, $stream);
         } else {
             throw new Exception("Invalid plugin type specified");
         }
     } else {
         throw new Exception("Invalid plugin specified");
     }
 }
예제 #7
0
파일: plug.php 프로젝트: ssrsfs/blg
<?php

/**
 * Typeframe Content application
 *
 * admin-side plug controller
 */
Plugin_Breadcrumbs::Add('Edit Plugin');
// save typing below
$typef_app_dir = Typeframe::CurrentPage()->applicationUri();
// validate plug id (must be 'Content' plug)
$plugid = @$_REQUEST['plugid'];
$plug = Model_Plug::Get($plugid);
//if (!$plug->exists() || ('Content' != $plug->get('plug')))
if (!$plug->exists()) {
    Typeframe::Redirect('Invalid plugin.', $typef_app_dir, -1);
    return;
}
// get template from settings; expand to its full value
$settings = $plug['settings'];
$template = isset($settings['template']) ? $settings['template'] : 'generic.plug.html';
$full_template = TYPEF_SOURCE_DIR . '/templates/content/' . $template;
// cannot edit content if template does not exist
if (!file_exists($full_template)) {
    Typeframe::Redirect("Unable to find plugin template ({$template}).", $typef_app_dir, -1);
    return;
}
// load inserts and groups for template
$inserts = Insertable::ElementsFrom($full_template);
$groups = Insertable::GroupsFrom($full_template);
// get revision id, if any
예제 #8
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);*/
예제 #9
0
파일: add.php 프로젝트: ssrsfs/blg
<?php

/**
 * Create a new plugin.
 */
Plugin_Breadcrumbs::Add('Add');
// save typing below
$typef_app_dir = Typeframe::CurrentPage()->applicationUri();
// process form
if ('POST' == $_SERVER['REQUEST_METHOD']) {
    $plug = Model_Plug::Create();
    $plug->set('plug', $_POST['plug']);
    //$plug->set('settings', json_encode((isset($_POST['settings']) && is_array($_POST['settings'])) ? $_POST['settings'] : array()));
    $plug->set('settings', isset($_POST['settings']) && is_array($_POST['settings']) ? $_POST['settings'] : array());
    $plug['siteid'] = Typeframe::CurrentPage()->siteid();
    $plug->save();
    // done
    $skin = isset($_REQUEST['skin']) ? "&skin={$_REQUEST['skin']}" : '';
    Typeframe::Redirect('Plugin created.', "{$typef_app_dir}/edit?plugid=" . $plug->get('plugid') . $skin);
    return;
}
// load plugins; add to template; sort by name
foreach (Typeframe::Registry()->plugins() as $plugin) {
    $pm->addLoop('plugins', array('name' => $plugin->name()));
}
$pm->sortLoop('plugins', 'name');
예제 #10
0
파일: Menu.php 프로젝트: ssrsfs/blg
 public function update(array $input = null)
 {
     //gimme life!
     //$item = isset($_POST['itemid']) ? new Navigation_Item($_POST['itemid']) : new Navigation_Item();
     $item = isset($_POST['itemid']) && !is_array($_POST['itemid']) ? Model_Nav::Get($_POST['itemid']) : Model_Nav::Create();
     if ($_REQUEST['cmd'] != 'delete' && $_REQUEST['cmd'] != 'name' && $_REQUEST['cmd'] != 'sort') {
         $item->set('pageid', 0);
         switch ($_POST['type']) {
             case 'none':
                 // Heh, these have no extra attributes, so null just about everything.
                 $item->set('label', $_POST['label']);
                 $item->set('url', '');
                 $item->set('onclick', '');
                 $item->set('visibility', 'always');
                 $item->set('method', '');
                 $item->set('target', '');
                 break;
             case 'int':
                 $item->set('label', $_POST['label']);
                 $item->set('pageid', $_POST['pageid']);
                 $item->set('url', '');
                 $item->set('onclick', '');
                 $item->set('visibility', 'permitted');
                 $item->set('method', $_POST['method']);
                 $item->set('target', $_POST['target']);
                 break;
             case 'arbint':
                 $item->set('label', $_POST['label']);
                 $item->set('url', $_POST['url']);
                 $item->set('onclick', '');
                 $item->set('visibility', $_POST['visibility']);
                 $item->set('method', $_POST['method']);
                 $item->set('target', $_POST['target']);
                 break;
             case 'ext':
                 $item->set('label', $_POST['label']);
                 $item->set('url', $_POST['url']);
                 $item->set('onclick', '');
                 $item->set('visibility', $_POST['visibility']);
                 $item->set('method', $_POST['method']);
                 $item->set('target', $_POST['target']);
                 break;
             case 'mailto':
                 $item->set('label', $_POST['label']);
                 $item->set('url', 'mailto:' . $_POST['url']);
                 $item->set('onclick', '');
                 $item->set('visibility', $_POST['visibility']);
                 $item->set('method', '');
                 $item->set('target', '');
                 break;
         }
     }
     switch ($_REQUEST['cmd']) {
         case 'add':
             $item->set('parent', $_POST['parent']);
             $item->set('plugid', $_POST['plugid']);
             $result = Typeframe::Database()->execute('SELECT MAX(sortnum) AS maxsort FROM #__nav WHERE plugid = ' . (int) $_POST['plugid']);
             $max = $result[0];
             $item->set('sortnum', $max['maxsort'] + 1);
             $item->save();
             $msg = " Added";
             break;
         case 'edit':
             $item->save();
             $msg = " Saved";
             break;
         case 'delete':
             $item->delete();
             $msg = " Deleted";
             break;
         case 'name':
             $plug = Model_Plug::Get($_POST['plugid']);
             $plug['name'] = $_POST['name'];
             $plug->save();
             Typeframe::Redirect('Name updated.', Typeframe::CurrentPage()->applicationUri() . '/edit?plugid=' . $_POST['plugid'] . '&parentid=' . (isset($_POST['parentid']) ? $_POST['parentid'] : '0'));
             return;
         case 'sort':
             $sortnum = 1;
             for ($i = 0; $i < count($_POST['itemid']); $i++) {
                 $item = Model_Nav::Get($_POST['itemid'][$i]);
                 $item['parent'] = $_POST['parent'][$i];
                 $item['sortnum'] = $sortnum;
                 $item->save();
                 $sortnum++;
             }
             Typeframe::Redirect('Items sorted.', Typeframe::CurrentPage()->applicationUri() . '/edit?plugid=' . $_POST['plugid'] . '&parentid=' . (isset($_POST['parentid']) ? $_POST['parentid'] : '0'));
             return;
     }
     Typeframe::Redirect('Item' . $msg, Typeframe::CurrentPage()->applicationUri() . '/edit?plugid=' . $_POST['plugid'] . '&parentid=' . (isset($_POST['parentid']) ? $_POST['parentid'] : '0'));
 }