<?php /** * Uses the new single-domain API */ class GoogleAnalyticsParser { function parse($html = null, $blockName = 'document', $blockParams = null) { if (empty($html)) { $id = SlConfigure::read('Api.google.analytics.id'); } if (empty($html)) { return; } SlConfigure::write("Asset.js.footer.{$html}", array('weight' => 1000, 'after' => <<<end var _gaq = _gaq || []; _gaq.push(['_setAccount', '{$html}']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); end )); } } Pheme::register('GoogleAnalytics', new GoogleAnalyticsParser(), null, true);
function XFBML($name, $params) { SL::config()->JS->Link->FacebookJavaScriptSDK = 'http://connect.facebook.net/en_US/all.js'; $paramsStr = ""; foreach ($params as $key => $value) { if (empty($value)) { continue; } $value = h($value); $paramsStr .= "{$key}='{$value}' "; } $result = "<fb:{$name} {$paramsStr}></fb:{$name}.>"; return $result; } } Pheme::register('Facebook', new FacebookParser(), null, true); // ----------------------------------------------------------------------------- /** * Facebook Activity Feed * @param int $width activity feed width * @param int $height activity feed height * @param bool $header show/hide header * @param string $colorScheme light or dark * @param string $font arial, lucida grande, segoie ui, tahoma, verdana, trebuchet ms * @param string $border_color */ ?> <iframe src="http://www.facebook.com/plugins/activity.php?site={$site}&width={$width}&height={$height}&header={$header}&colorscheme={$colorscheme}&font={$font}&border_color={$border_color}" scrolling="no" frameborder="0"
{if("var":"Node.teaser")} <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');
<?php /** * Colorbox jQuery plugin */ SlConfigure::write("Asset.js.footer.colorbox", 'colorbox/colorbox/jquery.colorbox-min'); SlConfigure::write("Asset.css.colorbox", "colorbox/example2/colorbox"); class JqueryColorboxParser extends PhemeNullParser { function parse($html = null, $blockName = 'document', $blockParams = null) { $blockParams = (array) $blockParams; if (empty($html)) { $html = 'a[rel^="colorbox"]'; } $blockParams += array('skin' => null); if ($blockParams['skin']) { SlConfigure::write("Asset.css.colorbox", "colorbox/{$blockParams['skin']}/colorbox"); } unset($blockParams['skin']); $options = $blockParams ? json_encode($blockParams) : ''; $key = "colorbox_" . Inflector::slug($html); SlConfigure::write("Asset.js.ready.{$key}", "\$('{$html}').colorbox({$options});"); } } Pheme::register('JqueryColorbox', new JqueryColorboxParser(), null, true);
public static function registerOutputBuffer($blockName, $parser = null, $globalContext = true) { if (is_object($blockName)) { $globalContext = $parser; $parser = $blockName; $trace = debug_backtrace(); $blockName = Inflector::camelize(preg_replace('/\\.[^.]+$/', '', basename($trace[0]['file']))); } $result = Pheme::register($blockName, $parser, ob_get_clean(), $globalContext); ob_start(); return $result; }
function parse($html = null, $blockName = 'document', $blockParams = null) { if (empty($html)) { return; } $images = Set::normalize($html, false); foreach ($images as &$image) { if (!strpos($image, '://') && $image[0] != '/') { $image = "img/{$image}"; } $image = $this->_getHelper('SlHtml')->webroot($image); SlConfigure::append("Asset.js.ready", "\$.preloadImages({$images})"); } SlConfigure::write('Asset.js.footer.imagePreloader.after', <<<end jQuery.preLoadImagesCache = []; // Arguments are image paths relative to the current page. jQuery.preLoadImages = function() { var args_len = arguments.length; for (var i = args_len; i--;) { var cacheImage = document.createElement('img'); cacheImage.src = arguments[i]; jQuery.preLoadImagesCache.push(cacheImage); } } end ); } } Pheme::register('PreloadImage', new PreloadImageParser(), null, true);
</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; } if (empty($html) && $blockParams['id']) { $html = $blockParams['id'] == 'Content' ? '{SiteContent/}' : "{Blocks(\"id\":\"{$blockParams['id']}\")/}"; } if ($html) { $uid = SL::uniqid(); $this->referrer()->columns[$uid] = array(parent::parse($html, $blockName), $blockParams); return $uid; } } } Pheme::register('Column', new ColumnParser(), null, 'Columns');
<?php /** * Blend jQuery plugin: smooth animation of :hover actions * * Note: Requires user to define an extra <element>.href css class */ class JqueryBlendParser extends PhemeNullParser { function parse($html = null, $blockName = 'document', $blockParams = null) { $blockParams = (array) $blockParams; if (empty($html)) { $html = '.blend'; } $blockParams += array(); $options = $blockParams ? json_encode($blockParams) : ''; $key = "blend_" . Inflector::slug($html); SlConfigure::write("Asset.js.footer.blend", 'blend/jquery.blend-min'); SlConfigure::write("Asset.js.ready.{$key}", "\$('{$html}').blend({$options});"); } } Pheme::register('JqueryBlend', new JqueryBlendParser(), null, true);
} $this->blocks["loop"]->params[0] =& $nodes; if ($skin != $blockName) { PhemeParser::$parseCallStack[] = Pheme::get($skin); } PhemeParser::$parseCallStack[] = Pheme::get('NodeView'); $html = parent::parse($html, $skin); array_pop(PhemeParser::$parseCallStack); if ($skin != $blockName) { array_pop(PhemeParser::$parseCallStack); } return $html; } } } Pheme::register('NodeIndex', new NodeIndexParser(), null, true); // ----------------------------------------------------------------------------- // Default: shows node teasers with thumbs and admin. actions separated by <hr>s (with ajax pagination) ?> <div id="{$ajaxId}"> {loop} {NodeActions/} {if("var":"CmsNode.title")} <h3><a href="{$href}">{e}{$CmsNode.title}{/e}</a></h3> {/if} {Image("align":"auto")/} {NodeTeaser/} {!sep:loop} <hr class="sl-node-separator" /> {/loop} </div>