本文整理汇总了PHP中Zend_View_Helper_Placeholder_Container_Standalone类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_View_Helper_Placeholder_Container_Standalone类的具体用法?PHP Zend_View_Helper_Placeholder_Container_Standalone怎么用?PHP Zend_View_Helper_Placeholder_Container_Standalone使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_View_Helper_Placeholder_Container_Standalone类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: __call
/**
* Overload method access
*
* Allows the following method calls:
* - appendFile($src, $type = 'text/javascript', $attrs = array())
* - offsetSetFile($index, $src, $type = 'text/javascript', $attrs = array())
* - prependFile($src, $type = 'text/javascript', $attrs = array())
* - setFile($src, $type = 'text/javascript', $attrs = array())
* - appendScript($script, $type = 'text/javascript', $attrs = array())
* - offsetSetScript($index, $src, $type = 'text/javascript', $attrs = array())
* - prependScript($script, $type = 'text/javascript', $attrs = array())
* - setScript($script, $type = 'text/javascript', $attrs = array())
*
* @param string $method
* @param array $args
* @return Zend_View_Helper_HeadScript
* @throws Zend_View_Exception if too few arguments or invalid method
*/
public function __call($method, $args)
{
if (preg_match('/^(?P<action>set|(ap|pre)pend|offsetSet)(?P<mode>File|Script)$/', $method, $matches)) {
if (1 > count($args)) {
// require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception(sprintf('Method "%s" requires at least one argument', $method));
}
$action = $matches['action'];
$mode = strtolower($matches['mode']);
$type = 'text/javascript';
$attrs = array();
if ('offsetSet' == $action) {
$index = array_shift($args);
if (1 > count($args)) {
// require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception(sprintf('Method "%s" requires at least two arguments, an index and source', $method));
}
}
$content = $args[0];
if (isset($args[1])) {
$type = (string) $args[1];
}
if (isset($args[2])) {
$attrs = (array) $args[2];
}
switch ($mode) {
case 'script':
$item = $this->createData($type, $attrs, $content);
if ('offsetSet' == $action) {
$this->offsetSet($index, $item);
} else {
$this->{$action}($item);
}
break;
case 'file':
default:
if (!$this->_isDuplicate($content)) {
$attrs['src'] = $content;
$item = $this->createData($type, $attrs);
if ('offsetSet' == $action) {
$this->offsetSet($index, $item);
} else {
$this->{$action}($item);
}
}
break;
}
return $this;
}
return parent::__call($method, $args);
}
示例3: __call
/**
* Overload method access
*
* Creates the following virtual methods:
* - appendStylesheet($href, $media, $conditionalStylesheet, $extras)
* - offsetSetStylesheet($index, $href, $media, $conditionalStylesheet, $extras)
* - prependStylesheet($href, $media, $conditionalStylesheet, $extras)
* - setStylesheet($href, $media, $conditionalStylesheet, $extras)
* - appendAlternate($href, $type, $title, $extras)
* - offsetSetAlternate($index, $href, $type, $title, $extras)
* - prependAlternate($href, $type, $title, $extras)
* - setAlternate($href, $type, $title, $extras)
*
* Items that may be added in the future:
* - Navigation? need to find docs on this
* - public function appendStart()
* - public function appendContents()
* - public function appendPrev()
* - public function appendNext()
* - public function appendIndex()
* - public function appendEnd()
* - public function appendGlossary()
* - public function appendAppendix()
* - public function appendHelp()
* - public function appendBookmark()
* - Other?
* - public function appendCopyright()
* - public function appendChapter()
* - public function appendSection()
* - public function appendSubsection()
*
* @param mixed $method
* @param mixed $args
* @return void
*/
public function __call($method, $args)
{
if (preg_match('/^(?P<action>set|(ap|pre)pend|offsetSet)(?P<type>Stylesheet|Alternate)$/', $method, $matches)) {
$argc = count($args);
$action = $matches['action'];
$type = $matches['type'];
$index = null;
if ('offsetSet' == $action) {
if (0 < $argc) {
$index = array_shift($args);
--$argc;
}
}
if (1 > $argc) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception(sprintf('%s requires at least one argument', $method));
}
if (is_array($args[0])) {
$item = $this->createData($args[0]);
} else {
$dataMethod = 'createData' . $type;
$item = $this->{$dataMethod}($args);
}
if ($item) {
if ('offsetSet' == $action) {
$this->offsetSet($index, $item);
} else {
$this->{$action}($item);
}
}
return $this;
}
return parent::__call($method, $args);
}
示例4: __call
/**
* Overload method calls
*
* Allows the following method calls:
* - appendStyle($content, $attributes = array())
* - offsetSetStyle($index, $content, $attributes = array())
* - prependStyle($content, $attributes = array())
* - setStyle($content, $attributes = array())
*
* @param string $method
* @param array $args
* @return void
* @throws Zend_View_Exception When no $content provided or invalid method
*/
public function __call($method, $args)
{
if (preg_match('/^(?P<action>set|(ap|pre)pend|offsetSet)(Style)$/', $method, $matches)) {
$index = null;
$argc = count($args);
$action = $matches['action'];
if ('offsetSet' == $action) {
if (0 < $argc) {
$index = array_shift($args);
--$argc;
}
}
if (1 > $argc) {
// require_once 'Zend/View/Exception.php';
$e = new Zend_View_Exception(sprintf('Method "%s" requires minimally content for the stylesheet', $method));
$e->setView($this->view);
throw $e;
}
$content = $args[0];
$attrs = array();
if (isset($args[1])) {
$attrs = (array) $args[1];
}
$item = $this->createData($content, $attrs);
if ('offsetSet' == $action) {
$this->offsetSet($index, $item);
} else {
$this->{$action}($item);
}
return $this;
}
return parent::__call($method, $args);
}
示例5: __construct
/**
* Constructor
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
示例6: __call
/**
* Overload method access
*
* Allows the following 'virtual' methods:
* - appendName($keyValue, $content, $modifiers = array())
* - offsetGetName($index, $keyValue, $content, $modifers = array())
* - prependName($keyValue, $content, $modifiers = array())
* - setName($keyValue, $content, $modifiers = array())
* - appendHttpEquiv($keyValue, $content, $modifiers = array())
* - offsetGetHttpEquiv($index, $keyValue, $content, $modifers = array())
* - prependHttpEquiv($keyValue, $content, $modifiers = array())
* - setHttpEquiv($keyValue, $content, $modifiers = array())
* - appendProperty($keyValue, $content, $modifiers = array())
* - offsetGetProperty($index, $keyValue, $content, $modifiers = array())
* - prependProperty($keyValue, $content, $modifiers = array())
* - setProperty($keyValue, $content, $modifiers = array())
*
* @param string $method
* @param array $args
* @return Zend_View_Helper_HeadMeta
*/
public function __call($method, $args)
{
if (preg_match('/^(?P<action>set|(pre|ap)pend|offsetSet)(?P<type>Name|HttpEquiv|Property)$/', $method, $matches)) {
$action = $matches['action'];
$type = $this->_normalizeType($matches['type']);
$argc = count($args);
$index = null;
if ('offsetSet' == $action) {
if (0 < $argc) {
$index = array_shift($args);
--$argc;
}
}
if (2 > $argc) {
#require_once 'Zend/View/Exception.php';
$e = new Zend_View_Exception('Too few arguments provided; requires key value, and content');
$e->setView($this->view);
throw $e;
}
if (3 > $argc) {
$args[] = array();
}
$item = $this->createData($type, $args[0], $args[1], $args[2]);
if ('offsetSet' == $action) {
return $this->offsetSet($index, $item);
}
$this->{$action}($item);
return $this;
}
return parent::__call($method, $args);
}
示例7: captureStart
/**
* Start capture action
*
* @param mixed $captureType
* @param string $typeOrAttrs
* @return void
*/
public function captureStart($type = Zend_View_Helper_Placeholder_Container_Abstract::APPEND, $attrs = null)
{
$this->_captureAttrs = $attrs;
return parent::captureStart($type);
}
示例8: offsetSet
/**
* Override offsetSet
*
* @param string|int $index
* @param mixed $value
* @return void
*/
public function offsetSet($index, $value)
{
if (!$this->_isValid($value)) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('Invalid argument passed to offsetSet(); please use one of the helper methods, offsetSetScript() or offsetSetFile()');
}
$this->_isValid($value);
return parent::offsetSet($index, $value);
}
示例9: set
/**
* set()
*
* @param array $value
* @return Zend_Layout_ViewHelper_HeadLink
*/
public function set($value)
{
if (!$this->_isValid($value)) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('set() expects a data token; please use one of the custom set*() methods');
}
return parent::set($value);
}
示例10: set
/**
* Set
*
* @param string $value
* @return void
* @throws Zend_View_Exception
*/
public function set($value)
{
if (!$this->_isValid($value)) {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception('Invalid value passed to set; please use setMeta()');
}
return parent::set($value);
}