oembed = oembed.replace("<embed ", "<param name=\\"wmode\\" value=\\"transparent\\"></param><embed "); oembed = oembed.replace("<embed ", "<embed wmode=\\"transparent\\""); } el.addClass('sl-oembedded').removeClass('sl-oembed').html(oembed); }); } else { \$(this).remove(); } }); end ); ?> <div class="sl-oembed">{$url}</div> <?php class JqueryOembedParser extends PhemeParser { function parse($html = null, $blockName = 'document', $blockParams = null) { $blockParams = (array) $blockParams; // $blockParams += array( // ); if ($html && !preg_match('/[\\n]/', $html)) { $blockParams['url'] = $html; $html = null; } $this->vars = $blockParams; return parent::parse($html, $blockName); } } Pheme::registerOutputBuffer('JqueryOembed', new JqueryOembedParser(), true);
Pheme::registerOutputBuffer('Attachments', new AttachmentsParser(), true); // ----------------------------------------------------------------------------- ?> <a class="sl-node-attachment" href="{$mediaPath}/{$dirname}/{$basename}">{$title}</a> <?php /** * Show download link for an attachment */ class AttachmentParser extends PhemeParser { function parse($html = null, $blockName = 'document', $blockParams = null, $noCycle = false) { $blockParams = (array) $blockParams; $blockParams += array('var' => 'CmsAttachment'); if (!empty($blockParams['id'])) { $attachment = ClassRegistry::init('CmsAttachment'); list($data) = $attachment->find('first', array('conditions' => array('id' => $blockParams['id']), 'recursive' => -1)); } elseif (!empty($blockParams['index'])) { $data = $this->_getVar("CmsAttachment.{$blockParams['index']}"); } else { $data = $this->_getVar($blockParams["var"]); } if (empty($data['filename'])) { return; } $this->vars = $data; return parent::parse($html, $blockName); } } Pheme::registerOutputBuffer('Attachment', new AttachmentParser(), true);
<div class="sl-node-teaser"> {var}CmsNode.markdown_teaser{/var} </div> <p class="sl-node-more"><a href="{$href}">{t}Read more...{/t}</a></p> {elseIf("var":"CmsNode.body")} <div class="sl-node-teaser"> {var}CmsNode.markdown_body{/var} </div> {else} {NodeChildren("skin":"list")/} {/if} <?php Pheme::registerOutputBuffer('NodeTeaserDefault', 'NodeTeaser', 'NodeView'); // ================================ NodeBody =================================== class NodeBodyParser extends NodeTeaserParser { } Pheme::register('NodeBody', new NodeBodyParser(), null, 'NodeView'); // ----------------------------------------------------------------------------- // Default node body: Body field or child nodes (if body is empty) ?> <div class="sl-node-body"> {if("var":"CmsNode.body")} {var}CmsNode.markdown_body{/var} {else} {NodeChildren/} {/if} </div> <?php Pheme::registerOutputBuffer('NodeBodyDefault', 'NodeBody', 'NodeView');
if (strpos($result['subItems'], 'sl-active')) { $result['itemClass'] .= ' sl-child-active'; } } // is this a link? if ($url) { $args['escape'] = false; $args['class'] = $result['itemClass']; $result['link'] = $this->_getHelper('SlHtml')->link('%s', $url, $args); $result['href'] = $this->_getHelper('SlHtml')->url($url); if (strpos($result['subItems'], 'sl-active')) { $result['itemClass'] .= ' sl-active'; } } $results[] = $result; } if (empty($results)) { return; } $this->blocks["loop"]->params[0] = $results; $this->vars['class'] = $blockParams['class']; $this->vars['level'] = $blockParams['level']; if ($blockParams['menuClass']) { $this->vars['class'] .= ' ' . $blockParams['menuClass']; } $this->vars['id'] = empty($blockParams['id']) ? false : $blockParams['id']; return parent::parse($html, $blockName); } } Pheme::registerOutputBuffer('Menu', new MenuParser(), true);
public function parse($html = null, $blockName = 'document', $blockParams = null, $noCycle = false) { $blockParams['var'] = 'message'; return parent::parse($html, $blockName, $blockParams, $noCycle); } } class MessagesParser extends PhemeParser { function __construct($rules = array(), $options = array()) { $this->blocks["loop"] = new MessagesLoopParser(); parent::__construct($rules, $options); } function parse($html = null, $blockName = 'document', $blockParams = null, $noCycle = false) { $messages = SlConfigure::read2('Message'); if ($messages) { SlSession::delete('Message'); } else { $messages = array(); } $this->vars['bufferedOutput'] = SlConfigure::read('View.bufferedOutput'); SlConfigure::delete('View.bufferedOutput'); if ($messages || $this->vars['bufferedOutput']) { $this->blocks["loop"]->params[0] = $messages; return parent::parse($html, $blockName); } } } Pheme::registerOutputBuffer(new MessagesParser(), true);
?> <div id="{$id}"> {t}This page uses flash. To load it, please enable JavaScript!{/t} </div> <script type="text/javascript"> $(function() { $("#{$id}").html('<a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a>'); swfobject.embedSWF("{webroot}{$src}{/webroot}", "{$id}", "{$width}", "{$height}", "{$version}", "{$path.vendors}/swfobject/expressInstall.swf", {$flashvars}, {$params}, {$attributes}); }); $("#{$id}").html('{t}Please wait. Loading flash content...{/t}'); </script> <?php class FlashParser extends PhemeParser { function parse($html = null, $blockName = 'document', $blockParams = null) { $blockParams = (array) $blockParams; $blockParams += array('width' => 300, 'height' => 120, 'version' => '9.0.0.0', 'src' => 'swfobject/test.swf', 'id' => SL::uniqid(), 'flashvars' => array(), 'params' => array(), 'attributes' => array()); if ($html && !preg_match('/[\\n]/', $html)) { $blockParams['src'] = $html; $html = null; } foreach (array('flashvars', 'params', 'attributes') as $key) { $blockParams[$key] = json_encode($blockParams[$key]); } $this->vars = $blockParams; return parent::parse($html, $blockName); } } Pheme::registerOutputBuffer('Swfobject', new FlashParser(), true);
// dynamic block (from custom controller) if (!empty($block['url'])) { $block['body'] = Sl::requestAction($block['url']); if (!isset($block['title'])) { $block['title'] = SlConfigure::read('View.lastRenderTitle'); } } elseif (!empty($block['body'])) { $block['body'] = parent::parse($block['body']); } else { continue; } $blocks[] = $block; // update cache if (!empty($block['cache']['time'])) { // we don't wanna cache administrative stuff if (!strpos($block['body'], 'sl-node-actions')) { cache($cacheFile, serialize($block), $block['cache']['time']); } } } } if (empty($blocks)) { return; } $this->blocks["loop"]->params[0] = $blocks; return parent::parse($html, $blockName); } } } Pheme::registerOutputBuffer('Blocks', new BlocksParser(), true);
<?php /** * Jquery UI */ SlConfigure::write('Asset.js.footer.jqueryUi', array('weight' => -50, 'url' => 'jquery-ui/js/jquery-ui-1.8.4.custom.min')); SlConfigure::write('Asset.css.jqueryUi', 'jquery-ui/css/smoothness/jquery-ui-1.8.4.custom'); ?> <div id="{$domId}"></div> <?php class JqueryUiSliderParser extends PhemeParser { function parse($html = null, $blockName = 'document', $blockParams = null) { $blockParams = (array) $blockParams; $blockParams += array('range' => true, 'min' => 0, 'max' => 100, 'values' => array(0, 100), 'domId' => SL::uniqid()); $options = $blockParams; unset($options['domId']); $key = "jqueryUiSlider-{$blockParams['domId']}"; SlConfigure::write("Asset.js.ready.{$key}", "\$('#{$blockParams['domId']}').slider(" . json_encode($options) . ')'); return parent::parse($html, $blockName); } } Pheme::registerOutputBuffer('JqueryUiSlider', new JqueryUiSliderParser(), null, true);
<?php class ContactFormParser extends PhemeParser { function __construct($rules = array(), $options = array()) { $this->blocks["loop"] = new PhemeLoopParser(); parent::__construct($rules, $options); } function parse($html = null, $blockName = 'document', $blockParams = null) { $blockParams = (array) $blockParams; $blockParams += array('fields' => $this->_getVar('fields'), 'domId' => Sl::uniqid()); if (!is_array($blockParams['fields'])) { return; } $form = $this->_getHelper('SlForm'); $fields = array(); $form->create('CmsContactForm'); foreach ($blockParams['fields'] as $f => $o) { $fields[] = array('inputName' => $f, 'inputOptions' => $o, 'inputHtml' => $form->input($f, $o)); } if ($fields) { $this->blocks['loop']->params[0] = $fields; $this->vars['domId'] = $blockParams['domId']; $this->vars['actionUrl'] = Sl::url(); return parent::parse($html, $blockName); } } } Pheme::registerOutputBuffer('ContactForm', new ContactFormParser(), 'NodeBodyCmsContactForm');
<p> {config}Site.mission{/config} </p> </div> <?php Pheme::registerOutputBuffer('SiteMission', new PhemeParser(), true); ?> <div class="sl-site-footer"> <p class="sl-footer-menu"> {require}SimpleMenu{/require} {SimpleMenu("id":0)/} </p> <p class="sl-copyright"> {config}Site.copyright{/config} </p> </div> <?php Pheme::registerOutputBuffer('SiteFooter', new PhemeParser(), true); ?> <div class="sl-site-search"> <form action="{url}/{$lang}/cms/cms_nodes{/url}" method="GET"> <input type="text" name="q" /> <button>{t}Search{/t}</button> </form> </div> {require}Api.GoogleAnalytics{/require} {GoogleAnalytics/} <?php Pheme::registerOutputBuffer('SiteSearch', new PhemeParser(), true);
$blockParams = (array) $blockParams; return Pheme::get('Image')->parse($html, 'Image', am($this->params[0], $blockParams)); } } /** * Show a gellery of images */ class ImageGalleryParser extends PhemeParser { function __construct($rules = array(), $options = array()) { $this->blocks["loop"] = new ImageGalleryLoopParser(); $this->blocks["loop"]->blocks['GalleryImage'] = new ImageGalleryItemParser(); parent::__construct($rules, $options); } function parse($html = null, $blockName = 'document', $blockParams = null, $noCycle = false) { if (!empty($blockParams['nodeId'])) { $image = ClassRegistry::init('Image'); $data = $image->find('all', array('conditions' => array('node_id' => $blockParams['nodeId'], 'publish' => true), 'recursive' => -1)); $this->blocks["loop"]->params[0] =& $data; } else { $this->blocks["loop"]->params[0] = $this->_getVar('ExtraImages'); } // {GalleryImage/} blocks will use {ImageGallery/}'s parameters as defaults $this->blocks["loop"]->blocks['GalleryImage']->params[0] = $blockParams; return parent::parse($html, $blockName); } } Pheme::registerOutputBuffer('ImageGallery', new ImageGalleryParser(), true);
$html = r($uid, '', $html); } } return $html; } } Pheme::registerOutputBuffer('Columns', new ColumnsParser(), true); // ----------------------------------------------------------------------------- ?> <div style='{if("var":"width")} width: {$width} {/if}' class='sl-column sl-column-{$id} {if("var":"colspan")} sl-colspan-{$colspan} {/if}'> <div class='sl-column-inner sl-column-inner-{$id} {if("var":"first")} sl-column-first {/if}{if("var":"last")} sl-column-last {/if}'> {$html} </div> </div> <?php Pheme::registerOutputBuffer('ColumnWrapper'); // ----------------------------------------------------------------------------- class ColumnParser extends PhemeParser { function __construct($rules = array(), $options = array()) { $this->blocks["Column"] = new PhemeLoopParser(); } function parse($html = null, $blockName = 'document', $blockParams = null) { $blockParams = (array) $blockParams; $blockParams += array('id' => false, 'width' => 0, 'colspan' => 1); if (empty($blockParams['id']) && preg_match('/^[a-z0-9]+$/i', $html)) { $blockParams['id'] = $html; $html = null; }
SlConfigure::write('Asset.js.footer.emailDefuscator.after', <<<end jQuery.fn.defuscate = function(settings) { settings = jQuery.extend({link: true}, settings); regex = /\\b([A-Z0-9._%-]+)\\([^)]+\\)((?:[A-Z0-9-]+\\.?))+\\([^)]+\\)([A-Z]{2,6})\\b/gi; mailto = '<a href="mailto:\$1@\$2.\$3">\$1@\$2.\$3</a>'; plain = "\$1@\$2.\$3"; return this.each(function() { defuscated = jQuery(this).html().replace(regex, settings.link ? mailto : plain) jQuery(this).html(defuscated); }); } jQuery(function() { jQuery('.sl-email').defuscate(); }); end ); if (empty($html)) { $html = $this->_getVar('CmsContactForm.email'); } if (empty($html)) { return; } list($user, $domain) = explode('@', $html, 2); $parts = explode('.', $domain); $zone = array_pop($parts); $domain = implode('.', $parts); $params = isset($blockParams['params']) ? $blockParams['params'] : null; $this->vars = compact('user', 'domain', 'zone', 'params'); return parent::parse(null, $blockName); } } Pheme::registerOutputBuffer('Email', new EmailParser(), true);
* Facebook Recommendations * @param int $width activity feed width * @param int $height activity feed height * @param string $font arial, lucida grande, segoie ui, tahoma, verdana, trebuchet ms * @param string $border_color */ ?> <iframe src="http://www.facebook.com/plugins/recommendations.php?site={$site}&width={$width}&height={$height}&header={$header}&colorscheme={$colorscheme}&font={$font}&border_color={$border_color}" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:{$width}px; height:{$height}px;" allowTransparency="true"> </iframe> <?php class FacebookRecommendationsParser extends FacebookParser { public function parse($html, $blockName = 'document', $blockParams = null) { $blockParams = (array) $blockParams; $blockParams += array('XFBML' => false, 'name' => 'recommendations', 'site' => SL::url(SL::nodeUrl($this->_getVar('Node'))), 'width' => 300, 'height' => 300, 'header' => false, 'colorscheme' => 'light', 'font' => 'tahoma', 'border_color' => '#fff'); if (empty($blockParams['XFBML'])) { $blockParams['border_color'] = urlencode($blockParams['border_color']); $blockParams['site'] = urlencode($blockParams['site']); $blockParams['font'] = urlencode($blockParams['font']); } return parent::parse($html, $blockName, $blockParams); } } Pheme::registerOutputBuffer('FacebookRecommendations', new FacebookRecommendationsParser(), true);
$ssOptions = json_encode($blockParams['supersubs']); $ssKey = "supersubs_{$id}"; SlConfigure::write("Asset.js.footer.supersubs", 'superfish/js/supersubs'); SlConfigure::write("Asset.js.ready.{$ssKey}", "\$('ul.{$id}').supersubs({$ssOptions});"); } // load & configure superfish $sfOptions = $blockParams['options'] ? json_encode($blockParams['options']) : ''; $sfKey = "superfish_{$id}"; SlConfigure::write("Asset.css.superfish", 'superfish/css/superfish'); SlConfigure::write("Asset.js.footer.superfish", 'superfish/js/superfish'); SlConfigure::write("Asset.js.ready.{$sfKey}", "\$('ul.{$id}').superfish({$sfOptions});"); // alternative styles switch ($blockParams['type']) { case 'vertical': $blockParams['menuClass'] .= " sf-vertical"; SlConfigure::write("Asset.css.superfishVertical", 'superfish/js/superfish-vertical'); break; case 'navbar': $blockParams['menuClass'] .= " sf-navbar"; SlConfigure::write("Asset.css.superfishNavbar", 'superfish/js/superfish-navbar'); break; } unset($blockParams['type']); unset($blockParams['supersubs']); unset($blockParams['options']); // construct DOM return Pheme::init('Menu')->parse($html, $blockName, $blockParams); } } Pheme::registerOutputBuffer('SuperfishMenu', new SuperfishMenuParser(), true);
{loop} {if("var":"link")} {MenuLink}{$text}{/MenuLink} {else} {$text} {/if} {!sep:loop} | {/loop} <?php Pheme::init('Menu'); Pheme::registerOutputBuffer('SimpleMenu', 'Menu', true);
</ul> {/loop} <div class="sl-clear"> </div> <?php class JqueryLavalampParser extends PhemeParser { function parse($html = null, $blockName = 'document', $blockParams = null) { // set defaults $blockParams = (array) $blockParams; $blockParams += array('options' => array('fx' => 'backout'), 'menuClass' => 'lavaLampNoImage', 'domId' => Sl::uniqid(), 'recursive' => 0); $this->vars['domId'] = $id = $blockParams['domId']; // load & configure lavalamp $options = $blockParams['options'] ? json_encode($blockParams['options']) : ''; SlConfigure::write('Asset.css.lavalamp', 'lavalamp/lavalamp_test'); SlConfigure::write('Asset.js.footer.lavalamp', 'lavalamp/jquery.lavalamp.min'); SlConfigure::write("Asset.js.ready.{$id}", "\$('#{$id}').lavaLamp({$options});"); // custom fx easing effects if (!in_array($blockParams['options']['fx'], array('swing', 'linear'))) { SlConfigure::write('Asset.js.footer.easing', 'lavalamp/jquery.easing.min'); } unset($blockParams['options']); // construct DOM self::$parseCallStack[] = $this; $html = Pheme::init('Menu')->parse($html, $blockName, $blockParams); array_pop(self::$parseCallStack); return $html; } } Pheme::registerOutputBuffer('JqueryLavalamp', new JqueryLavalampParser(), true);
{ function parse($html = null, $blockName = 'document', $blockParams = null) { $blockParams = (array) $blockParams; $blockParams += array('url' => SL::url(SL::nodeUrl($this->_getVar('Node'))), 'style' => null, 'source' => 'tweetmeme'); $this->vars = $blockParams; return parent::parse($html, $blockName); } } Pheme::registerOutputBuffer('TweetmemeRetweetButton', new TweetmemeRetweetButtonParser(), true); // ----------------------------------------------------------------------------- ?> <script type="text/javascript"> tweetmeme_size = '{$size}'; {if("var":"style")}tweetmeme_style = '{$style}';{/if} tweetmeme_screen_name = '{$source}'; </script> <script type="text/javascript" src="http://tweetmeme.com/i/scripts/follow.js"></script> <?php class TweetmemeFollowButtonParser extends PhemeParser { function parse($html = null, $blockName = 'document', $blockParams = null) { $blockParams = (array) $blockParams; $blockParams += array('size' => 32, 'style' => null, 'source' => 'tweetmeme'); $this->vars = $blockParams; return parent::parse($html, $blockName); } } Pheme::registerOutputBuffer('TweetmemeFollowButton', new TweetmemeFollowButtonParser(), true);
{/loop} </div> {require}Pagination{/require} {Pagination("ajax":true)/} <?php Pheme::registerOutputBuffer('NodeIndexGallery', 'NodeIndex', true); // ----------------------------------------------------------------------------- // Blog: same as default index, but with author/publishing details and continuous pagination ?> {loop} {NodeActions/} {if("var":"CmsNode.title")} <h3><a href="{$href}">{e}{$CmsNode.title}{/e}</a></h3> {/if} {if("var":"CmsNode.created","value":"{$CmsNode.modified}")} <div class="sl-node-modified"><span>{t}Writted on{/t}:</span> {$CmsNode.modified}</div> {else} <div class="sl-node-modified"><span>{t}Updated on{/t}:</span> {$CmsNode.modified}</div> {/if} {Image("align":"auto")/} {NodeTeaser/} {!sep:loop} <hr class="sl-node-separator" /> {/loop} <div id="{$ajaxId}"></div> {require}Pagination{/require} {PaginationLink("text":"{t}Show more...{/t}", "ajax":true, "page":"next")/} <?php Pheme::registerOutputBuffer('NodeIndexBlog', 'NodeIndex', true);