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