当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_View_Helper_Placeholder_Container_Standalone::getContainer方法代码示例

本文整理汇总了PHP中Zend_View_Helper_Placeholder_Container_Standalone::getContainer方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_View_Helper_Placeholder_Container_Standalone::getContainer方法的具体用法?PHP Zend_View_Helper_Placeholder_Container_Standalone::getContainer怎么用?PHP Zend_View_Helper_Placeholder_Container_Standalone::getContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_View_Helper_Placeholder_Container_Standalone的用法示例。


在下文中一共展示了Zend_View_Helper_Placeholder_Container_Standalone::getContainer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: headMin

 /**
  * Main view helper function
  * 
  * @param Zend_View_Helper_Placeholder_Container_Standalone $headScript
  * @param array $options
  * @return Zend_View_Helper_Placeholder_Container_Standalone
  */
 public function headMin(Zend_View_Helper_Placeholder_Container_Standalone $headScript, array $options)
 {
     //read all options
     if (isset($options['disabled']) && $options['disabled']) {
         return $headScript;
     }
     if ($headScript instanceof Zend_View_Helper_HeadScript) {
         $this->_type = 'script';
     } else {
         if ($headScript instanceof Zend_View_Helper_HeadLink) {
             $this->_type = 'link';
         } else {
             throw new Zend_Exception("{$headScript} must be Zend_View_Helper_HeadScript or Zend_View_Helper_HeadLink");
         }
     }
     if (isset($options['public_dir'])) {
         $this->_publicDir = $options['public_dir'];
     }
     if (isset($options['content_dir'])) {
         $this->_contentDir = $options['content_dir'];
     }
     if (isset($options['content_web'])) {
         $this->_contentWeb = $options['content_web'];
     }
     if (isset($options['minify_cmd'])) {
         $this->_minifyCmd = $options['minify_cmd'];
     }
     if (isset($options['version'])) {
         $this->_version = $options['version'];
     }
     //get items for minification
     $items = array();
     $headScript->getContainer()->ksort();
     $unsetKeys = array();
     foreach ($headScript as $key => $item) {
         //Zend_Debug::dump($item);
         $itemDesc = $this->_getItemDesc($item);
         if ($itemDesc === false) {
             continue;
         }
         //include only local paths
         if (!isset($itemDesc['path']) || substr($itemDesc['path'], 0, 7) != 'http://' && substr($itemDesc['path'], 0, 8) != 'https://') {
             $items[] = $itemDesc;
             $unsetKeys[] = $key;
         }
     }
     //unset items to be minified
     foreach ($unsetKeys as $key) {
         unset($headScript[$key]);
     }
     $cacheId = $this->_calculateHash($items);
     $cacheFileName = $this->_contentDir . '/' . $cacheId . $this->_getCacheExt();
     if (!file_exists($cacheFileName)) {
         //create minified cache file
         $content = '';
         foreach ($items as $key => $itemDesc) {
             if (isset($itemDesc['content'])) {
                 $content .= PHP_EOL . $itemDesc['content'];
             } elseif (isset($itemDesc['path'])) {
                 $content .= PHP_EOL . file_get_contents($this->_publicDir . '/' . $itemDesc['path']);
             }
         }
         //save bundled content
         file_put_contents($cacheFileName, $content);
         //minify
         if (isset($this->_minifyCmd)) {
             $this->_execMinifyCmd($cacheFileName);
         }
     }
     //append cache file
     $cacheFileWeb = $this->_contentWeb . '/' . $cacheId . $this->_getCacheExt();
     //print_r($headScript->getContainer());
     if ($this->_type == 'script') {
         $headScript->appendFile($cacheFileWeb);
     } else {
         $headScript->appendStylesheet($cacheFileWeb);
     }
     return $headScript;
 }
开发者ID:bokultis,项目名称:kardiomedika,代码行数:86,代码来源:HeadMin.php


注:本文中的Zend_View_Helper_Placeholder_Container_Standalone::getContainer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。