コード例 #1
0
ファイル: Block.php プロジェクト: sunel/laravel-layout
    /**
     * Retrieve block view from file (template).
     *
     * @param string $fileName
     *
     * @return string
     */
    public function fetchView($fileName)
    {
        start_profile($fileName);
        $html = '';
        // EXTR_SKIP protects from overriding
        // already defined variables
        extract($this->_viewVars, EXTR_SKIP);
        if ($this->getShowTemplateHints()) {
            $html .= <<<HTML
<div style="position:relative; border:1px dotted red; margin:6px 2px; padding:18px 2px 2px 2px; zoom:1;">
<div style="position:absolute; left:0; top:0; padding:2px 5px; background:red; color:white; font:normal 11px Arial;
text-align:left !important; z-index:998;" onmouseover="this.style.zIndex='999'"
onmouseout="this.style.zIndex='998'" title="{$fileName}">{$fileName}</div>
HTML;
            $thisClass = get_class($this);
            $html .= <<<HTML
<div style="position:absolute; right:0; top:0; padding:2px 5px; background:red; color:blue; font:normal 11px Arial;
text-align:left !important; z-index:998;" onmouseover="this.style.zIndex='999'" onmouseout="this.style.zIndex='998'"
title="{$thisClass}">{$thisClass}</div>
HTML;
        }
        try {
            $this->assign('_this', $this);
            $html .= app('view')->make($fileName, $this->_viewVars)->render();
        } catch (Exception $e) {
            throw $e;
        }
        if ($this->getShowTemplateHints()) {
            $html .= '</div>';
        }
        stop_profile($fileName);
        return $html;
    }
コード例 #2
0
ファイル: Update.php プロジェクト: sunel/laravel-layout
 public function fetchPackageLayoutUpdates($handle)
 {
     $_profilerKey = 'layout_update: ' . $handle;
     start_profile($_profilerKey);
     if (empty($this->_moduleLayout)) {
         $this->fetchFileLayoutUpdates();
     }
     foreach ($this->_moduleLayout->{$handle} as $updateXml) {
         #echo '<textarea style="width:600px; height:400px;">'.$handle.':'.print_r($updateXml,1).'</textarea>';
         /* @var Mage_Core_Model_Layout_Element $updateXml */
         $handle = $updateXml->getAttribute('ifhandle');
         if ($handle) {
             $handle = explode(' ', $handle);
             $handle = array_diff($handle, $this->getHandles());
             if (!empty($handle)) {
                 continue;
             }
         }
         $this->fetchRecursiveUpdates($updateXml);
         $this->addUpdate($updateXml->innerXml());
     }
     stop_profile($_profilerKey);
     return true;
 }
コード例 #3
0
ファイル: Layout.php プロジェクト: sunel/laravel-layout
 /**
  * Enter description here...
  *
  * @param \Layout\Layout\Element $node
  * @param \Layout\Layout\Element $parent
  *
  * @return \Layout\Layout
  */
 protected function _generateAction($node, $parent)
 {
     if (isset($node['ifconfig']) && ($configPath = (string) $node['ifconfig'])) {
         if (config($configPath, false)) {
             return $this;
         }
     }
     $method = (string) $node['method'];
     if (!empty($node['block'])) {
         $parentName = (string) $node['block'];
     } else {
         $parentName = $parent->getBlockName();
     }
     $_profilerKey = 'BLOCK ACTION: ' . $parentName . ' -> ' . $method;
     start_profile($_profilerKey);
     if (!empty($parentName)) {
         $block = $this->getBlock($parentName);
     }
     if (!empty($block)) {
         $args = (array) $node->children();
         unset($args['@attributes']);
         foreach ($args as $key => $arg) {
             if ($arg instanceof \Layout\Layout\Element) {
                 if (isset($arg['helper'])) {
                     $args[$key] = $this->runHelper((string) $arg['helper']);
                 } else {
                     /*
                      * if there is no helper we hope that this is assoc array
                      */
                     $arr = [];
                     foreach ($arg as $subkey => $value) {
                         $arr[(string) $subkey] = $value->asArray();
                     }
                     if (!empty($arr)) {
                         $args[$key] = $arr;
                     }
                 }
             }
         }
         if (isset($node['json'])) {
             $json = explode(' ', (string) $node['json']);
             foreach ($json as $arg) {
                 $args[$arg] = json_decode($args[$arg]);
             }
         }
         $this->_translateLayoutNode($node, $args);
         call_user_func_array([$block, $method], $args);
     }
     stop_profile($_profilerKey);
     return $this;
 }
コード例 #4
0
ファイル: Factory.php プロジェクト: sunel/laravel-layout
 /**
  * Rendering layout.
  *
  * @param string $output
  */
 public function renderLayout($output = '')
 {
     $_profilerKey = self::PROFILER_KEY . '::' . $this->routeHandler();
     $this->_renderTitles();
     $this->_renderHeadOptions();
     $this->_renderBreadcrumbs();
     start_profile("{$_profilerKey}::layout_render");
     if ('' !== $output) {
         $this->getLayout()->addOutputBlock($output);
     }
     $this->events->fire('route.layout.render.before');
     $this->events->fire('route.layout.render.before.' . $this->routeHandler());
     $this->getLayout()->setDirectOutput(false);
     $output = $this->getLayout()->getOutput();
     stop_profile("{$_profilerKey}::layout_render");
     return $output;
 }