コード例 #1
0
ファイル: email.php プロジェクト: sandulungu/StarLight
    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);
    }
コード例 #2
0
ファイル: tweetmeme.php プロジェクト: sandulungu/StarLight
 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);
 }
コード例 #3
0
ファイル: jquery_ui.php プロジェクト: sandulungu/StarLight
 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);
 }
コード例 #4
0
ファイル: facebook.php プロジェクト: sandulungu/StarLight
 function parse($html = null, $blockName = 'document', $blockParams = null)
 {
     $blockParams = (array) $blockParams;
     $blockParams += array('XFBML' => true, 'name' => '');
     if ($blockParams['name'] && $blockParams['XFBML']) {
         $name = $blockParams['name'];
         return $this->XFBML($name, array_diff_key($blockParams, array('name' => 1, 'XFBML' => 1)));
     }
     $this->vars = $blockParams;
     return parent::parse($html, $blockName);
 }
コード例 #5
0
 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);
 }
コード例 #6
0
ファイル: swfobject.php プロジェクト: sandulungu/StarLight
 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);
 }
コード例 #7
0
ファイル: messages.php プロジェクト: sandulungu/StarLight
 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);
     }
 }
コード例 #8
0
ファイル: attachment.php プロジェクト: sandulungu/StarLight
 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);
 }
コード例 #9
0
 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);
     }
 }
コード例 #10
0
ファイル: node_index.php プロジェクト: sandulungu/StarLight
 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;
     }
 }
コード例 #11
0
ファイル: columns.php プロジェクト: sandulungu/StarLight
 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;
     }
 }
コード例 #12
0
ファイル: parser.php プロジェクト: sandulungu/StarLight
 /**
  * Escapes content, equivalent to htmlentities(...)
  *
  * @param string $html Input
  * @param string $blockName
  * @param string $blockParams
  * @return string
  */
 public function parse($html, $blockName = 'document', $blockParams = null)
 {
     $blockParams = (array) $blockParams;
     $blockParams += array('inc' => null, 'parse' => true, 'max' => false);
     $value = $this->_getVar(trim(parent::parse($html)));
     if (is_numeric($blockParams['inc'])) {
         $value += $blockParams['inc'];
         return $value;
     }
     if ($blockParams['max'] && mb_strlen($value) > $blockParams['max']) {
         $value = mb_substr($value, 0, $blockParams['max']) . '...';
     }
     return $blockParams['parse'] ? parent::parse($value, '_var') : $value;
 }
コード例 #13
0
ファイル: image.php プロジェクト: sandulungu/StarLight
 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);
 }
コード例 #14
0
ファイル: bridge.php プロジェクト: sandulungu/StarLight
 function parse($html, $blockName = 'document', $blockParams = null)
 {
     $html = parent::parse($html);
     if (!empty($blockParams['ajax'])) {
         return $html;
     }
     return "<div id='sl-viewport'>{$html}</div>";
 }
コード例 #15
0
ファイル: blocks.php プロジェクト: sandulungu/StarLight
 function parse($html = null, $blockName = 'document', $blockParams = null)
 {
     if (empty($blockParams['id'])) {
         if (preg_match('/^[a-zA-Z0-9_.-]+$/', $html)) {
             $blockParams['id'] = parent::parse($html);
             $html = null;
         } else {
             return;
         }
     }
     $id = $blockParams['id'];
     $cacheKey = empty($blockParams['cacheKey']) ? 'default' : $blockParams['cacheKey'];
     $data = SlConfigure::read2("Block.{$id}");
     if ($data) {
         $id = r('.', '-', $id);
         $this->vars = array('id' => $id, 'title' => false);
         $defaults = SlConfigure::read2('Block.defaults');
         $blocks = array();
         foreach ($data as $key => $block) {
             if ($block) {
                 if (!is_array($block)) {
                     $block = array('body' => $block);
                 }
                 $block = Set::merge($defaults, $block);
                 if (empty($block['id'])) {
                     $block['id'] = "{$id}-{$key}";
                 }
                 if (!empty($block['cache']) && !is_array($block['cache'])) {
                     $block['cache'] = array('time' => $block['cache']);
                 }
                 if (!empty($block['cache_time'])) {
                     $block['cache']['time'] = $block['cache_time'];
                 }
                 if (isset($block['cache']['time']) && is_numeric($block['cache']['time'])) {
                     $block['cache']['time'] += time();
                 }
                 if (!empty($block['cache']['spread'])) {
                     if (!is_numeric($block['cache']['time'])) {
                         $block['cache']['time'] = strtotime($block['cache']['time'], time());
                     }
                     $block['cache']['time'] += mt_rand(-$block['cache']['spread'], $block['cache']['spread']);
                 }
                 if (!empty($block['cache']) && empty($block['cache']['key'])) {
                     $block['cache']['key'] = $block['id'] . '-' . md5(serialize($block) . SlConfigure::read('I18n.lang'));
                 }
                 if (!empty($block['cache']['time'])) {
                     $cacheFile = 'views/block_' . $cacheKey . '_' . $block['cache']['key'];
                     $cache = cache($cacheFile, null, $block['cache']['time']);
                     if (is_string($cache)) {
                         $blocks[] = unserialize($cache);
                         continue;
                     }
                 }
                 // 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);
     }
 }
コード例 #16
0
ファイル: menu.php プロジェクト: sandulungu/StarLight
 function parse($html = null, $blockName = 'document', $blockParams = null)
 {
     $blockParams = (array) $blockParams;
     $blockParams += array('recursive' => $blockName !== 'SimpleMenu' ? -1 : 0, 'level' => 1, 'itemClass' => 'sl-menu-item', 'menuClass' => null, 'class' => 'sl-menu');
     // get menu items
     if (!isset($blockParams['items'])) {
         if (!isset($blockParams['id'])) {
             if (preg_match('/^[a-zA-Z0-9_.{}\\/-]+$/', $html)) {
                 $name = parent::parse($html);
                 $html = null;
             } else {
                 $name = 'cms';
             }
         } elseif (preg_match('/^[0-9]+(-[0-9]+)*$/', $blockParams['id'])) {
             $name = 'cms.' . r('-', '.children.', $blockParams['id']) . '.children';
         } else {
             $name = $blockParams['id'];
         }
         $blockParams['items'] = SlConfigure::read2("Navigation.{$name}");
     }
     $parentId = empty($blockParams['id']) ? '' : $blockParams['id'] . '-';
     if (!is_array($blockParams['items']) || !is_array(reset($blockParams['items']))) {
         return;
     }
     $keys = array_keys($blockParams['items']);
     $first = reset($keys);
     $last = end($keys);
     $results = array();
     foreach ($blockParams['items'] as $key => $item) {
         $id = $key;
         $args = array();
         // default template vars values
         $result = array('itemClass' => "{$blockParams['itemClass']}-child {$blockParams['itemClass']}-{$id}", 'link' => false, 'subItems' => false, 'href' => false, 'id' => $parentId . $id);
         if ($key == $first) {
             $result['itemClass'] .= ' ' . $blockParams['itemClass'] . '-first';
         }
         if ($key == $last) {
             $result['itemClass'] .= ' ' . $blockParams['itemClass'] . '-last';
         }
         // text items
         if (!is_array($item) && $item) {
             $item = array('title' => $item);
         }
         // get link text
         if (!empty($item['title'])) {
             $result['text'] = h(__t($item['title']));
         }
         if (empty($result['text'])) {
             continue;
         }
         // check permissions
         /*if (!SlAuth::isAuthorized($item, null, null, true)) {
               continue;
           }
           unset($item['allow']);
           unset($item['deny']);*/
         // get link url
         $url = empty($item['url']) ? false : $item['url'];
         // set class attributte
         if (!empty($item['class'])) {
             $result['itemClass'] .= ' ' . $item['class'];
         }
         // set hint attribute
         if (!empty($item['hint'])) {
             $args['title'] = __t($item['hint']);
         }
         // set onclick attribute
         if (!empty($item['onclick'])) {
             $args['onclick'] = $item['onclick'];
         }
         // set rel attribute
         if (!empty($item['rel'])) {
             $args['rel'] = $item['rel'];
         }
         // set target attribute
         if (!empty($item['target'])) {
             $args['target'] = $item['target'];
         }
         // children?
         if (!empty($item['children']) && $blockParams['recursive'] != 0) {
             $result['subItems'] = $this->parse($html, $blockName, array('recursive' => $blockParams['recursive'] - 1, 'class' => $blockParams['class'] . '-' . $id, 'itemClass' => $blockParams['itemClass'] . '-' . $id, 'items' => $item['children'], 'id' => $parentId . $id, 'level' => $blockParams['level'] + 1));
             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);
 }
コード例 #17
0
ファイル: node_view.php プロジェクト: sandulungu/StarLight
 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);
     }
 }