Esempio n. 1
0
 public function output(\Pagemill_Data $data, \Pagemill_Stream $stream)
 {
     if ($this->hasAttribute('template')) {
         $template = Typeframe_Skin::TemplatePath($data->parseVariables($this->getAttribute('template')));
         $this->setAttribute('file', $template);
     }
     if ($this->getAttribute('select')) {
         $select = $this->getAttribute('select');
         $temp = new Pagemill_Stream(true);
         parent::output($data, $temp);
         $xml = Pagemill_SimpleXmlElement::LoadString($temp->clean());
         $parts = $xml->select($select);
         foreach ($parts as $part) {
             $stream->puts($part->asXml());
         }
     } else {
         parent::output($data, $stream);
     }
 }
Esempio n. 2
0
 private static function _GetPluginsFor($for)
 {
     $locs = new Model_PlugLoc();
     $locs->where('skin = ?', Typeframe_Skin::Current());
     $locs->where('socket = ?', $for);
     $locs->where('plugin.siteid = ?', Typeframe::CurrentPage()->siteid());
     $locs->order('sortnum');
     $result = array();
     foreach ($locs->select() as $loc) {
         $show = true;
         if ($loc['rules']) {
             $show = self::ProcessRules($loc['rules']);
         }
         if ($show) {
             $plug = $loc['plugin'];
             $result[] = $plug;
         }
     }
     return $result;
 }
Esempio n. 3
0
File: Html.php Progetto: ssrsfs/blg
 public function output(\Pagemill_Data $data, \Pagemill_Stream $stream)
 {
     $this->name = 'html';
     $pm = new Pagemill($data);
     $skin = $data->parseVariables($this->getAttribute('skin'));
     $oldskin = null;
     if ($skin) {
         $oldskin = Typeframe_Skin::Current();
         Typeframe_Skin::Set($skin);
     } else {
         $skin = Typeframe_Skin::Current();
     }
     if (file_exists(TYPEF_DIR . '/skins/' . $skin . '/skin.html')) {
         $skinTree = $pm->parseFile(TYPEF_DIR . '/skins/' . $skin . '/skin.html');
     } else {
         $skinTree = $pm->parseFile(TYPEF_DIR . '/skins/default/skin.html');
     }
     $skinTree->process($data, $stream);
     if (!is_null($oldskin)) {
         Typeframe_Skin::Set($oldskin);
     }
 }
Esempio n. 4
0
 public static function FindTemplate($template)
 {
     return Typeframe_Skin::TemplatePath($template);
 }
Esempio n. 5
0
function skin_path($path)
{
    $path = (string) $path;
    $uri = Typeframe::CurrentPage()->uri();
    if (substr($path, 0, 1) != '/') {
        $path = '/' . $path;
    }
    if (file_exists(TYPEF_DIR . '/skins/' . Typeframe_Skin::Current() . $path)) {
        return TYPEF_ROOT_WEB_DIR . '/skins/' . Typeframe_Skin::Current() . $path;
        /*} else if (file_exists(TYPEF_DIR . '/skins/default' . $path)) {
        		return TYPEF_ROOT_WEB_DIR . '/skins/default' . $path;
        	} else if (file_exists(TYPEF_DIR . '/files/static' . $path)) {
        		return TYPEF_ROOT_WEB_DIR . '/files/static' . $path;
        	} else {
        		// TODO: This might not be the best default.  Should it trigger an error?
        		return TYPEF_ROOT_WEB_DIR . $path;
        	}*/
    } else {
        if (Typeframe_Skin::Current() != TYPEF_SITE_SKIN && $uri != TYPEF_WEB_DIR . '/admin' && substr($uri, 0, strlen(TYPEF_WEB_DIR . '/admin/')) != TYPEF_WEB_DIR . '/admin/') {
            if (file_exists(TYPEF_DIR . '/skins/' . TYPEF_SITE_SKIN . $path)) {
                return TYPEF_ROOT_WEB_DIR . '/skins/' . TYPEF_SITE_SKIN . $path;
            }
        } else {
            return TYPEF_ROOT_WEB_DIR . '/skins/default' . $path;
        }
    }
}
Esempio n. 6
0
 private function _resolveTemplate($path)
 {
     $skin = Typeframe_Skin::Current();
     if (file_exists(TYPEF_DIR . '/skins/' . $skin . '/templates' . $path) && is_file(TYPEF_DIR . '/skins/' . $skin . '/templates' . $path)) {
         return TYPEF_DIR . '/skins/' . $skin . '/templates' . $path;
     }
     /*if (file_exists(TYPEF_DIR . '/skins/default/templates' . $path) && is_file(TYPEF_DIR . '/skins/default/templates' . $path)) {
     			return TYPEF_DIR . '/skins/default/templates' . $path;
     		}*/
     if (file_exists(TYPEF_SOURCE_DIR . '/templates' . $path) && is_file(TYPEF_SOURCE_DIR . '/templates' . $path)) {
         return TYPEF_SOURCE_DIR . '/templates' . $path;
     }
     return false;
 }
Esempio n. 7
0
File: form.php Progetto: ssrsfs/blg
 * Typeframe Content application
 *
 * admin-side groups form controller
 */
// save typing below
$typef_app_dir = Typeframe::CurrentPage()->applicationUri();
// break up incoming base
$base = $_REQUEST['base'];
if (preg_match_all('/\\[?([a-z0-9_]*)\\]?\\[[\\d]*\\]/i', $base, $matches)) {
    // use the matches to shape an xpath query identifying the group
    $full_template = TYPEF_SOURCE_DIR . '/templates/' . $_REQUEST['template'];
    //$skin = Typeframe_Skin::At(TYPEF_WEB_DIR . $page['uri']);
    if (!empty($_REQUEST['pageid'])) {
        $page = Model_Page::Get($_REQUEST['pageid']);
        if ($page->exists()) {
            $skin = Typeframe_Skin::At(TYPEF_WEB_DIR . $page['uri']);
            if (CONTENT_USE_PAGE_STYLE) {
                //$stylesheets = Pagemill_Tag_Stylesheets::GetStylesheetsAt(TYPEF_WEB_DIR . $page['uri']);
                $stylesheets = array();
                if (!empty($stylesheets)) {
                    $pm->setVariable('editor_stylesheets', "['" . implode("','", $stylesheets) . "']");
                }
            }
        } else {
            $skin = 'default';
        }
    } else {
        $skin = 'default';
    }
    $groups = Insertable::GroupsFrom($full_template, $matches[1], $skin);
    $group = $groups[0];
Esempio n. 8
0
File: Skin.php Progetto: ssrsfs/blg
 public static function StylesheetsFor($template, $uri = null)
 {
     $stylesheets = array();
     $tmplXml = Pagemill_SimpleXmlElement::LoadFile(Typeframe_Skin::TemplatePath($template, $uri));
     if (strpos($tmplXml->asXml(), '<pm:html') !== false) {
         if (is_null($uri)) {
             $skin = self::Current();
         } else {
             $skin = self::At($uri);
         }
         $skinXml = Pagemill_SimpleXmlElement::LoadFile(TYPEF_DIR . '/skins/' . $skin . '/skin.html');
         self::_GetStylesheetsFromElement($skinXml, $stylesheets);
     }
     self::_GetStylesheetsFromElement($tmplXml, $stylesheets);
     return $stylesheets;
 }
Esempio n. 9
0
File: page.php Progetto: ssrsfs/blg
if (!file_exists($full_template)) {
    Typeframe::Redirect("Unable to find page template ({$template}).", $typef_app_dir, -1);
    return;
}
$skin = Typeframe_Skin::At(TYPEF_WEB_DIR . $page['uri']);
$stylesheets = Typeframe_Skin::StylesheetsFor($template, TYPEF_WEB_DIR . $page['uri']);
$pm->setVariable('stylesheets', $stylesheets);
// load inserts and groups for template
$inserts = Insertable::ElementsFrom($full_template, TYPEF_WEB_DIR . $page['uri']);
$groups = Insertable::GroupsFrom($full_template, null, $skin);
// get revision id, if any
$revisionid = @$_REQUEST['revisionid'];
// process form
if ('POST' == $_SERVER['REQUEST_METHOD']) {
    if (!empty($_POST['cmd']) && $_POST['cmd'] == 'Preview') {
        Typeframe_Skin::Set(Typeframe_Skin::At(TYPEF_WEB_DIR . $page['uri']));
        Typeframe::CurrentPage()->setPageTemplate('/content/' . $page['settings']['template']);
        return;
    }
    // build content array from post
    $content = Content::ProcessPost($inserts, $groups);
    // add/edit content
    //$content_page = new Content_Page($pageid, $revisionid);
    $content_page = Model_Content_Page::Get($pageid);
    if (!$content_page->exists()) {
        $content_page = Model_Content_Page::Create();
        $content_page['pageid'] = $pageid;
    }
    $content_page['content'] = $content;
    //$content_page->set('content', json_encode($content));
    $content_page->save();
Esempio n. 10
0
File: index.php Progetto: ssrsfs/blg
 * client-side index controller
 */
// save typing below
$pathinfo = Typeframe::CurrentPage()->pathInfo();
$settings = Typeframe::CurrentPage()->settings();
$typef_app_dir = Typeframe::CurrentPage()->uri();
// set template
if (empty($settings['template'])) {
    $settings['template'] = 'generic.html';
}
Typeframe::SetPageTemplate("/content/{$settings['template']}");
// if given path information
if ($pathinfo) {
    $pm->setVariable('pathinfo', $pathinfo);
    // find out which skin to use; derive appropriate template from that
    $skin = Typeframe_Skin::At($typef_app_dir);
    $skin_template = TYPEF_DIR . "/skins/{$skin}/templates/content/" . $settings['template'];
    $base_template = TYPEF_DIR . "/source/templates/content/" . $settings['template'];
    $source = file_get_contents(file_exists($skin_template) ? $skin_template : $base_template);
    // look for groups and subpages
    if (is_int(strpos($source, 'pm:group')) && is_int(strpos($source, 'subpage'))) {
        // convert all entities in source into spaces, except for &, ", >, and <
        //$invalidEntities = array_diff(array_values(Pagemill::GetExtendedEntityTable()),
        //									array('&amp;', '&quot;', '&gt;', '&lt;'));
        //$source = str_replace($invalidEntities, ' ', $source);
        // get page id
        $pageid = Typeframe::CurrentPage()->pageid();
        // load groups from source as XML; loop over them
        $xml = Pagemill_SimpleXmlElement::LoadString($source);
        $groups = $xml->xpath('//pm:group');
        foreach ($groups as $group) {
Esempio n. 11
0
 public static function ElementsFrom($template, $uri = null)
 {
     /*if (!is_null($uri)) {
     			$skin = Typeframe_Skin::At($uri);
     			$stylesheets = Typeframe_Tag_Stylesheets::GetStylesheetsAt($uri);
     		} else {
     			$skin = 'default';
     			$stylesheets = Typeframe_Tag_Stylesheets::GetStylesheetsAt(TYPEF_WEB_DIR . '/');
     		}*/
     $skin = Typeframe_Skin::At($uri);
     $array = null;
     if (file_exists($template) && is_file($template)) {
         $source = file_get_contents($template);
         /*foreach (Pagemill::GetExtendedEntityTable() as $character => $entity) {
         			if ( ($entity != '&amp;') && ($entity != '&quot;') && ($entity != '&gt;') && ($entity != '&lt;') ) {
         				$source = str_replace($entity, ' ', $source);
         			}
         		}*/
         $xml = Pagemill_SimpleXmlElement::LoadString($source);
         $array = array();
         $elements = $xml->xpath('//pm:insert|//pm:include');
         foreach ($elements as $e) {
             if ($e->getName() == 'insert') {
                 $name = Insertable::_NameToSymbol((string) $e['name']);
                 if ($name !== (string) $e['name']) {
                     trigger_error("Insertable element name '{$e['name']}' has invalid characters (should be letters, numbers, and underscores only) in template '{$template}'");
                     return null;
                 }
                 $label = (string) $e['label'];
                 if (!$label) {
                     $label = $name;
                 }
                 $type = (string) $e['type'];
                 $admin = (string) $e['admin'];
                 $selector = '';
                 if ($type == 'html') {
                     if (count($e->children())) {
                         foreach ($e->children() as $c) {
                             if (preg_match('/@{[\\w\\W\\s\\S]*?' . $name . '[\\w\\W\\s\\S]*?}@/', $c->asXml())) {
                                 $selector = Insertable::_InsertSelector($c, $skin);
                                 break;
                             }
                         }
                     } else {
                         $stack = $e->xpath('parent::*');
                         if (count($stack)) {
                             $element = array_pop($stack);
                             $selector = Insertable::_InsertSelector($element, $skin);
                         }
                     }
                 } else {
                     if ($type == 'select') {
                         $options = array();
                         foreach ($e->option as $option) {
                             $options[] = array('label' => "{$option}", 'value' => !is_null($option['value']) ? "{$option['value']}" : "{$option}");
                         }
                     } else {
                         if ($type == 'model') {
                             $options = array();
                             if (class_exists($e['model'])) {
                                 $model = (string) $e['model'];
                                 $values = new $model();
                                 foreach ($values->getAll() as $value) {
                                     $options[] = array('label' => $value->get((string) $e['modellabel']), 'value' => $model . ':' . $value->get('id'));
                                 }
                             }
                             $type = 'select';
                         }
                     }
                 }
                 $i = array('name' => $name, 'label' => $label, 'type' => $type, 'admin' => $admin, 'selector' => $selector);
                 if ($type == 'select') {
                     $i['options'] = $options;
                 }
                 $array[] = $i;
             } else {
                 $included = Insertable::ElementsFrom(TYPEF_DIR . '/source/templates/' . $e['template']);
                 if (is_array($included)) {
                     $array = array_merge($array, $included);
                 }
             }
         }
     } else {
         trigger_error("File '{$template}' does not exist");
     }
     return $array;
 }