本文整理匯總了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;
}