public function getClasses($options = null) { if ($options == null) { return $this->classes; } else { if (is_array($options)) { $default_options = array(); $available_options = array('visibility', 'tags'); $parameters = array('available_options' => $available_options); Ak::parseOptions($options, $default_options, $parameters); $returnClasses = array(); foreach ($this->classes as $class) { if (isset($options['visibility']) && $class->getVisibility() != $options['visibility']) { continue; } if (isset($options['tags'])) { $options['tags'] = !is_array($options['tags']) ? array($options['tags']) : $options['tags']; $docBlock = $method->getDocBlock(); foreach ($options['tags'] as $tag) { if ($docBlock->getTag($tag) == false) { continue; } } } $returnClasses[] = $class; } return $returnClasses; } } }
function toSentence($options = array()) { $default_options = array('skip_last_comma'=>true,'connector'=>'and'); Ak::parseOptions($options,$default_options); $parts = array(); for($i=0;$i<count($this->value);$i++) { $separator = ', '; if ($i==0) { $separator = ''; } else if ($i+1==count($this->value)) { $separator = $options['skip_last_comma']?' ':', '; $separator.= $options['connector'].' '; } $parts[]=$separator.$this->value[$i]; } return implode('',$parts); }
/** * * @param array $options * @param array $default_options * @param array $available_options * @param boolean $walk_keys */ function parseOptions(&$options, $default_options = array(), $parameters = array(), $walk_keys = false) { if ($walk_keys) { foreach ($options as $key => $value) { if (!is_array($value)) { unset($options[$key]); $options[$value] = $default_options; } else { Ak::parseOptions($value, $default_options, $parameters); $options[$key] = $value; } } return; } $options = array_merge($default_options, $options); foreach ($options as $key => $value) { if (isset($parameters['available_options'])) { if (!isset($parameters['available_options'][$key])) { continue; } } $options[$key] = $value; } }
function getMethods($options = null) { if ($options == null) { return $this->methods; } else { if (is_array($options)) { $default_options = array(); $available_options = array('visibility', 'static', 'tags', 'returnByReference'); $parameters = array('available_options' => $available_options); Ak::parseOptions(&$options, $default_options, $parameters); $returnMethods = array(); foreach ($this->methods as $method) { if (isset($options['visibility']) && $method->getVisibility() != $options['visibility']) { continue; } if (isset($options['returnByReference']) && $method->returnByReference() != $options['returnByReference']) { continue; } if (isset($options['static']) && $method->isStatic() != $options['static']) { continue; } if (isset($options['tags'])) { $options['tags'] = !is_array($options['tags']) ? array($options['tags']) : $options['tags']; $docBlock = $method->getDocBlock(); $broke = false; foreach ($options['tags'] as $tag => $value) { $res = $docBlock->getTag($tag); if (!@preg_match('/' . $value . '/', $res) || $value !== false && $res === false) { $broke = true; break; } } if ($broke) { continue; } } $returnMethods[] = $method; } //echo "Return methods:\n"; //var_dump($returnMethods); return $returnMethods; } } }
function xml_instruct($type, $options = array()) { $default_options = array('version' => '1.0'); $config = array('available_options' => array('version')); Ak::parseOptions($options, $default_options, $config); return $this->_renderTag(false, $type, '', $options, '<?', '?>', '?>'); }
function _setCachesAction($options) { if (!$this->_perform_caching) { $this->_enableGzippedOutput(); return; } if (is_string($options)) { $options = Ak::toArray($options); } $default_options = array( 'include_get_parameters'=>array(), 'cache_path'=>'' ); Ak::parseOptions($options, $default_options,array(),true); $this->_caches_action = $options; $actionName = $this->_controller->getActionName(); if ($this->_caching_type == null && isset($this->_caches_action[$actionName])) { if (isset($this->_caches_page[$actionName]['format']) && $format !=$this->_caches_page[$actionName]['format']) { $this->_enableGzippedOutput(); return; } $this->_caching_type = 'action'; $this->_action_include_get_parameters = $this->_caches_action[$actionName]['include_get_parameters']; if(!empty($this->_caches_action[$actionName]['host'])) { $this->_action_cache_host = $this->_caches_action[$actionName]['host']; } $path = $this->_caches_action[$actionName]['cache_path']; $parts = parse_url($path); if (isset($parts['host'])) { $this->_action_cache_host = $parts['host']; $this->_action_cache_path = $parts['path']; } else { $this->_action_cache_path = $path; } if (!isset($this->_action_cache_host)) { $this->_action_cache_host = $this->_controller->Request->getHost(); } $this->_action_cache_path = $this->_actionPath($this->_action_cache_path); $this->_controller->beforeFilter(array(&$this,'beforeActionCache')); $this->_controller->appendAfterFilter(array(&$this,'afterActionCache')); } else { $this->_enableGzippedOutput(); } }