public function meioImage($filename, $options = array()) { $options += array('folder' => 'cms_images', 'thumb' => 'icon', 'title' => null, 'link' => null); $image = $this->Html->image("/files/{$options['folder']}/thumb/{$options['thumb']}/{$filename}", array('alt' => $options['thumb'], 'title' => $options['title'])); if (isset($options['link'])) { return $options['link'] ? $this->link($image, $options['link']) : $image; } return Pheme::parse('JqueryColorbox') . $this->link($image, "/files/{$options['folder']}/{$filename}", array('rel' => 'colorbox', 'webroot' => true)); }
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; }
function parse($html = null, $blockName = 'document', $blockParams = null) { // set defaults $blockParams = (array) $blockParams; $blockParams += array('type' => 'default', 'supersubs' => array('extraWidth' => 1.5), 'options' => array(), 'menuClass' => 'sf-menu', 'domId' => Sl::uniqid()); $id = $blockParams['domId']; $blockParams['menuClass'] .= " {$id}"; // load & configure supersubs if ($blockParams['supersubs']) { $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); }
function parse($html = null, $blockName = 'document', $blockParams = null) { $blockParams = (array) $blockParams; $blockParams += array('id' => false, 'skin' => null); if ($blockName === 'NodeIndex') { $skin = empty(SL::getInstance()->view->params['named']['skin']) ? Inflector::camelize($blockParams['skin']) : Inflector::camelize(SL::getInstance()->view->params['named']['skin']); $skin = $skin && Pheme::init("NodeIndex{$skin}") ? "NodeIndex{$skin}" : "NodeIndexDefault"; } else { $skin = $blockName; } $this->vars['ajaxId'] = SL::uniqid(); if ($blockParams['id'] === false) { $nodes = $this->_getVar('nodes'); } else { if ($blockParams['id'] === 0) { $blockParams['id'] = null; } $nodes = SlNode::find('all', array('conditions' => array('CmsNode.parent_id' => $blockParams['id'], 'CmsNode.visible' => true), 'order' => array('CmsNode.lft' => 'asc'), 'auth' => 'index')); } if ($nodes) { foreach ($nodes as &$node) { $node['href'] = h(SlNode::url($node)); } $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; } }
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);
<?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);
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);
function parse($html = null, $blockName = 'document', $blockParams = null) { if ($blockName == 'NodeTeaser' || $blockName == 'NodeBody') { $skin = $this->_getVar('CmsNode.model'); if ($skin) { $plugin = $this->_getVar('CmsNode.plugin'); } if (!empty($plugin)) { $skin = Pheme::init("{$plugin}.{$blockName}{$skin}") ? "{$blockName}{$skin}" : "{$blockName}Default"; } else { $skin = $skin && Pheme::init("{$blockName}{$skin}") ? "{$blockName}{$skin}" : "{$blockName}Default"; } } else { $skin = $blockName; } if ($skin != $blockName) { PhemeParser::$parseCallStack[] = Pheme::get($skin); $result = parent::parse($html, $skin); array_pop(PhemeParser::$parseCallStack); return $result; } else { return parent::parse($html, $skin); } }
* 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);
<?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);
<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);
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);
function parse($html) { $items = explode(',', parent::parse($html)); foreach ($items as $item) { Pheme::init(trim($item)); } }
<?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');
public function parse($html, $blockName = 'document', $blockParams = null) { $blockParams = (array) $blockParams; return Pheme::get('Image')->parse($html, 'Image', am($this->params[0], $blockParams)); }
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');
/** * Renders view for given action and layout. If $file is given, that is used * for a view filename (e.g. customFunkyView.ctp). * * @param string $action Name of action to render for * @param string $layout Layout to use * @param string $file Custom filename for view * @return string Rendered Element */ public function render($action = null, $layout = null, $file = null) { if ($layout === null) { $layout = $this->layout; } if ($layout && $this->autoLayout) { Pheme::push("layouts/pheme/{$layout}"); } $data = parent::render($action, $layout, $file); if ($layout && $this->autoLayout) { Pheme::pop(); } // Save title for cross-request manipulations SlConfigure::write('View.lastRenderTitle', empty($this->viewVars['title']) ? null : $this->viewVars['title']); return $data; }
// 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);
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);
<?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);
<?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);
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);
{loop} {if("var":"link")} {MenuLink}{$text}{/MenuLink} {else} {$text} {/if} {!sep:loop} | {/loop} <?php Pheme::init('Menu'); Pheme::registerOutputBuffer('SimpleMenu', 'Menu', 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);
{ 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);
public function input($fieldName, $options = array()) { $view = ClassRegistry::getObject('view'); $this->setEntity($fieldName); $modelKey = $this->model(); $fieldKey = $this->field(); if ($modelKey[0] >= 'A' && $modelKey[0] <= 'Z') { $model = ClassRegistry::init($modelKey); $schema = $model->schema($fieldKey); $options += array('meioUpload' => $model->Behaviors->enabled('MeioUpload') && isset($model->Behaviors->MeioUpload->__fields[$model->alias][$fieldKey]), 'before' => '', 'after' => '', 'translate' => $model->Behaviors->enabled('Translate') && in_array($fieldKey, $model->Behaviors->Translate->settings[$model->alias])); if ($schema['type'] == 'boolean') { $options += array('checkedByDefault' => (bool) $schema['default']); } else { $options += array('default' => $schema['default']); } // if this is a MeioUpload field and a file has been uploaded, then show it if ($options['meioUpload'] && !empty($view->data[$modelKey][$fieldKey]) && is_string($view->data[$modelKey][$fieldKey])) { $meioUploadOptions = $model->Behaviors->MeioUpload->__fields[$model->alias][$fieldKey]; $filename = r(DS, '/', "{$meioUploadOptions['dir']}/{$view->data[$modelKey][$fieldKey]}"); if (isset($meioUploadOptions['thumbsizes']['icon'])) { $iconFilename = r(DS, '/', "{$meioUploadOptions['dir']}/thumb/icon/{$view->data[$modelKey][$fieldKey]}"); $options['before'] .= sprintf('<a class="sl-uploaded-image" href="%s" rel="colorbox" target="_blank"><img src="%s" /></a>', $this->assetUrl($filename), $this->assetUrl($iconFilename)); Pheme::parse('JqueryColorbox'); } else { $options['after'] .= sprintf('<a class="sl-uploaded-file" href="%s" target="_blank">%s</a>', $this->assetUrl($filename), __t('View uploaded file')); } } unset($options['meioUpload']); if (in_array($schema['type'], array('datetime', 'date', 'time'))) { $options += array('dateFormat' => SlConfigure::read2('I18n.options.dateFormat'), 'timeFormat' => SlConfigure::read2('I18n.options.timeFormat')); } } $prefix = SlConfigure::read2('View.options.modelPrefix'); if (empty($prefix)) { $prefix = $this->plugin; } $options += array('label' => __t(Inflector::humanize(r('.', ' ', preg_replace("/^{$prefix}_|_id\$/", '', $fieldName)))), 'translate' => false); if (isset($options['checkedByDefault'])) { if (!isset($view->data[$modelKey][$fieldKey])) { $options['checked'] = $options['checkedByDefault']; } unset($options['checkedByDefault']); } $translate = $options['translate']; unset($options['translate']); if ($translate) { $fields = array(); $catalogs = SlConfigure::read('I18n.catalogs'); $options2 = $options; foreach ($catalogs as $catalog) { $options2['label'] = $catalog['language']; if (isset($options['value']) && is_array($options['value'])) { if (isset($options['value'][$catalog['locale']])) { $options2['value'] = $options['value'][$catalog['locale']]; } else { unset($options2['value']); } } else { unset($options2['value']); } $fields["{$fieldName}_{$catalog['locale']}"] = $options2; } if (count($fields) == 1) { return parent::input(key($fields), array('label' => $options['label']) + $options2); } return $this->inputs(array('legend' => $options['label']) + $fields); } else { return parent::input($fieldName, $options); } }