Esempio n. 1
0
    function parse($html = null, $blockName = 'document', $blockParams = 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);
    }
Esempio n. 2
0
 public static function write($name, $value = null, $encrypt = true, $expires = null, $path = null, $domain = null, $secure = null)
 {
     self::ready();
     SlConfigure::write($name, $value, false, 'cookie');
     self::$_cookies[] = $name;
     self::$_cookies = array_unique(self::$_cookies);
     if (empty($path)) {
         $path = SlConfigure::read('Sl.cookie.path');
     }
     if ($domain === null) {
         $domain = SlConfigure::read('Sl.cookie.domain');
     }
     if ($secure === null) {
         $secure = SlConfigure::read('Sl.cookie.secure');
     }
     $now = time();
     if (is_int($expires) || is_numeric($expires)) {
         $expires = $now + intval($expires);
     } elseif (is_string($expires)) {
         $expires = strtotime($expires, $now);
     }
     $value = serialize($value);
     if ($encrypt) {
         App::import('core', 'security');
         $value = "?" . base64_encode(Security::cipher($value, self::$_key));
     } else {
         $value = base64_encode($value);
     }
     setcookie(self::$_cookieName . "[{$name}]", $value, $expires, $path, $domain, $secure);
 }
Esempio n. 3
0
    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
);
    }
Esempio n. 4
0
 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);
 }
Esempio n. 5
0
 public function admin_index($activeSection = null)
 {
     $this->set('sections', $sections = SlConfigure::read2("Config.sections"));
     foreach ($sections as $section => $settings) {
         if (!SlAuth::isAuthorized('config' . Inflector::camelize($section))) {
             unset($sections[$i]);
         }
     }
     if (isset($this->data['_section'])) {
         $activeSection = $this->data['_section'];
     }
     if (empty($activeSection) || !isset($sections[$activeSection])) {
         $activeSection = reset(array_keys($sections));
     }
     $settings = $this->_getSettings($activeSection);
     $this->set('title', __t(SlConfigure::read2("Config.sections.{$activeSection}")));
     if ($this->data) {
         $locales = SlConfigure::read('I18n.locales');
         foreach ($settings as $name => &$setting) {
             if (is_int($name)) {
                 $name = "setting_{$name}";
             }
             if ($setting['collection'] == 'user') {
                 $setting['collection'] = 'User' . SlAuth::user('id');
             }
             if (empty($setting['translate'])) {
                 if (isset($this->data[$name])) {
                     $value = $this->data[$name];
                     if (isset($setting['type']) && $setting['type'] == 'json') {
                         $value = json_decode($value, true);
                     } elseif (isset($setting['type']) && $setting['type'] == 'array') {
                         $value = Set::normalize($value, false);
                     }
                     SlConfigure::write($setting['name'], $value, true, $setting['collection']);
                 }
             } else {
                 foreach ($locales as $locale) {
                     if (isset($this->data["{$name}_{$locale}"])) {
                         $value = $this->data["{$name}_{$locale}"];
                         if (isset($setting['type']) && $setting['type'] == 'json') {
                             $value = json_decode($value, true);
                         } elseif (isset($setting['type']) && $setting['type'] == 'array') {
                             $value = Set::normalize($value, false);
                         }
                         SlConfigure::write($setting['name'], $value, true, "{$setting['collection']}.{$locale}");
                     }
                 }
             }
         }
         $settings = $this->_getSettings($activeSection);
         $this->Session->setFlash(__t('Configuration saved'), array('class' => 'success'));
     }
     $this->data['_section'] = $activeSection;
     $this->set('settings', $settings);
 }
Esempio n. 6
0
 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});");
 }
Esempio n. 7
0
 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});");
 }
Esempio n. 8
0
    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
));
    }
 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;
 }
Esempio n. 10
0
 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);
 }
 public function admin_set_as_homepage($id)
 {
     SlConfigure::write('Cms.homeNodeId', $id, true);
     SlConfigure::write('Routing.home', array('admin' => null, '!merge' => false) + SlNode::url($id, array('route' => false, 'slug' => false)), true);
     $this->redirect(array('action' => 'index'));
 }
Esempio n. 12
0
 public function beforeRender()
 {
     //Sl::krumo($this->params);
     if ($this->RequestHandler->isAjax()) {
         if (is_array($this->output)) {
             SlConfigure::write('Sl.debug.requestTime', false);
             Configure::write('debug', 0);
             echo json_encode($this->output);
             die;
         }
     }
     if ($this->layout == 'default') {
         $this->layout = SlConfigure::read('View.layout');
     }
     if (empty($this->layout)) {
         $this->layout = empty($this->params['prefix']) || $this instanceof CakeErrorController && $this->params['prefix'] != 'admin' ? 'default' : $this->params['prefix'];
     }
     $this->theme = SlConfigure::read2('View.theme');
     if (empty($this->viewVars['title'])) {
         $model = $this->_humanizedModelClass();
         switch ($this->action) {
             case 'index':
             case 'admin_index':
                 $this->set('title', __t(Inflector::pluralize($model)));
                 break;
             case 'admin_add':
                 $this->set('title', __t($this->id ? 'Clone {$model}' : 'Add {$model}', array('model' => __t($model))));
                 break;
             case 'admin_edit':
                 $this->set('title', __t('Edit {$model}', array('model' => __t($model))));
                 break;
             default:
                 $this->set('title', null);
         }
     } elseif (empty($this->viewVars['title_for_layout'])) {
         $this->viewVars['title_for_layout'] = $this->viewVars['title'];
     }
     // merge 'site title' and 'view title'
     if (empty($this->viewVars['title_for_layout'])) {
         $this->viewVars['title_for_layout'] = SlConfigure::read2('Site.title');
     } else {
         $this->viewVars['title_for_layout'] .= SlConfigure::read('View.options.titleSep') . SlConfigure::read2('Site.title');
     }
     if (Sl::getInstance()->main && ob_get_level()) {
         SlConfigure::write('View.bufferedOutput', ob_get_clean());
     }
     if (class_exists('Debugger')) {
         Debugger::output('js');
     }
 }
Esempio n. 13
0
<?php

/**
 * Flash embeds support
 */
SlConfigure::write('Asset.js.ready.oembed', <<<end
\$('.sl-oembed').each(function() {
    var el = \$(this);
    var url = el.html();
    if (url) {
        var width = \$(this).parent().width();
        var apiUrl = 'http://api.embed.ly/v1/api/oembed?url=' + url + '&callback=?&maxwidth=' + width;
        \$.getJSON(apiUrl, function(json) {
            var oembed = json.html;
            if (oembed.indexOf("wmode") < 0) {
                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
{
Esempio n. 14
0
 function end($options = null)
 {
     $view = Sl::getInstance()->view;
     $options2 = is_array($options) ? $options : array();
     $options2 += array('validation' => true);
     if ($options2['validation'] && $view->model && isset($view->Validation)) {
         SlConfigure::write('Asset.js.jquery', 'head');
         SlConfigure::write('Asset.js.head.jqueryValidation', 'jquery.validation.min');
         $html = $view->Validation->bind($view->model);
     } else {
         $html = '';
     }
     return parent::end($options) . $html;
 }
Esempio n. 15
0
 /**
  * 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;
 }
Esempio n. 16
0
 /**
  * Set current language
  *
  * @param string $lang
  * @return bool Success
  */
 public static function setLocale($lang = null, $setCookie = false)
 {
     $locales = SlConfigure::read('I18n.locales');
     if (empty($locales)) {
         $languages = SlConfigure::read1('I18n.languages');
         $langs = array_keys($languages);
         $locales = array();
         $catalogs = array();
         if (!$langs) {
             $langs = array('en');
         }
         App::import('Core', 'l10n');
         $l10n = new L10n();
         foreach ($langs as $lang_) {
             $catalog = $l10n->catalog($lang_);
             if ($catalog) {
                 $catalogs[$lang_] = $catalog;
                 $locales[$lang_] = $catalog['locale'];
             }
         }
         $langs = array_keys($locales);
         SlConfigure::write('I18n.langs', $langs);
         SlConfigure::write('I18n.catalogs', $catalogs);
         SlConfigure::write('I18n.locales', $locales);
         if (empty($lang)) {
             $lang = SlCookie::read('I18n.lang');
             // guess language based on Accept-Language header
             if (empty($lang)) {
                 $envLangs = explode(',', env('HTTP_ACCEPT_LANGUAGE'));
                 foreach ($envLangs as $envLang) {
                     list($envLang) = explode(';', $envLang);
                     if (isset($locales[$envLang])) {
                         $lang = $envLang;
                         break;
                     }
                 }
                 if (empty($lang)) {
                     $lang = SlConfigure::read('I18n.lang');
                 }
             }
             // convert locale_id to lang_id
             $lang_ = array_search($lang, $locales);
             if ($lang_) {
                 $lang = $lang_;
             }
             if (empty($lang) || !isset($locales[$lang])) {
                 $lang = $langs[0];
             }
         }
     } else {
         $catalogs = SlConfigure::read('I18n.catalogs');
     }
     if ($lang) {
         // convert locale_id to lang_id
         $lang_ = array_search($lang, $locales);
         if ($lang_) {
             $lang = $lang_;
         }
         if (isset($locales[$lang])) {
             SlConfigure::write('I18n.lang', $lang);
             SlConfigure::write('I18n.catalog', $catalogs[$lang]);
             SlConfigure::write('I18n.locale', $locales[$lang]);
             Configure::write('Config.language', $locales[$lang]);
             if ($setCookie) {
                 SlCookie::write('I18n.lang', $lang, false, "+1 year");
             }
             SlConfigure::localeChanged();
             return true;
         }
     }
     return false;
 }
Esempio n. 17
0
<?php

/**
 * Flash embeds support
 */
SlConfigure::write('Asset.js.footer.swfobject', 'swfobject/swfobject');
SlConfigure::write('Asset.js.jquery', 'head');
?>
<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]);
Esempio n. 18
0
 public function done()
 {
     SlConfigure::write('Sl.installPending', false, true);
     $this->set('title', __t('StarLight installation: Finished successfully'));
 }
Esempio n. 19
0
 * @copyright     Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @package       cake
 * @subpackage    cake.app.config
 * @since         CakePHP(tm) v 0.2.9
 * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
/**
 * Here, we are connecting '/' (base path) to controller called 'Pages',
 * its action called 'display', and we pass a param to select the view file
 * to use (in this case, /app/views/pages/home.ctp)...
 */
// check installation
if (Sl::version() != SlConfigure::read('Sl.version')) {
    if (!preg_match('!/install|/users/login!', Sl::url(false))) {
        SlConfigure::write('Message.migrate', array('message' => __t('System files have been recently updated. Proceeding to database migration...'), 'params' => array('class' => 'message')));
        Router::connect(Sl::url(false), array('controller' => 'install', 'action' => 'migrate'));
    }
}
// localized routes
$langRules = array('lang' => implode('|', SlConfigure::read('I18n.langs')));
// home
$home = SlConfigure::read1('Routing.home');
Router::connect('/', $home);
Router::connect('/:lang', $home, $langRules);
// prefixed homes
$prefixedRoutes = SlConfigure::read('Routing.prefixes');
foreach ($prefixedRoutes as $prefix => $route) {
    Router::connect("/{$prefix}", $route);
}
// custom routes
Esempio n. 20
0
 protected function _write($name, $data, $locale = null)
 {
     foreach ($data as $collection => $items) {
         SlConfigure::write($name, $items, true, $locale ? "{$collection}.{$locale}" : $collection);
     }
 }
<?php

/** 
 * PrettyLoader
 */
if (false) {
    //$this = new SlView(); // for IDE
}
$imgSrc = $this->SlHtml->assetUrl('prettyLoader/images/prettyLoader/ajax-loader.gif');
SlConfigure::write('Asset.css.prettyLoader', 'prettyLoader/css/prettyLoader');
SlConfigure::write('Asset.js.footer.prettyLoader', 'prettyLoader/js/jquery.prettyLoader');
SlConfigure::write('Asset.js.ready.prettyLoader', "\$.prettyLoader({loader:'{$imgSrc}'})");