repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
koala-framework/koala-framework
Kwf/Exception.php
Kwf_Exception.logOrThrow
public function logOrThrow() { $this->log(); if (!self::isDebug()) { if (PHP_SAPI == 'cli') { file_put_contents('php://stderr', $this->__toString()."\n"); } return; } throw $this; }
php
public function logOrThrow() { $this->log(); if (!self::isDebug()) { if (PHP_SAPI == 'cli') { file_put_contents('php://stderr', $this->__toString()."\n"); } return; } throw $this; }
[ "public", "function", "logOrThrow", "(", ")", "{", "$", "this", "->", "log", "(", ")", ";", "if", "(", "!", "self", "::", "isDebug", "(", ")", ")", "{", "if", "(", "PHP_SAPI", "==", "'cli'", ")", "{", "file_put_contents", "(", "'php://stderr'", ",", "$", "this", "->", "__toString", "(", ")", ".", "\"\\n\"", ")", ";", "}", "return", ";", "}", "throw", "$", "this", ";", "}" ]
Online: Schreibt die Exception nur ins log Lokal: wirft die exception
[ "Online", ":", "Schreibt", "die", "Exception", "nur", "ins", "log", "Lokal", ":", "wirft", "die", "exception" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Exception.php#L27-L37
koala-framework/koala-framework
Kwf/Model/Row/Data/Abstract.php
Kwf_Model_Row_Data_Abstract.setData
public function setData($data) { foreach (array_keys($this->_cleanData) as $k) { if (!isset($this->_data[$k]) || $this->_cleanData[$k] === $this->_data[$k]) { //nicht ge�ndert if (isset($data[$k])) { $this->_data[$k] = $data[$k]; } else { unset($this->_data[$k]); } } } $this->_cleanData = $data; }
php
public function setData($data) { foreach (array_keys($this->_cleanData) as $k) { if (!isset($this->_data[$k]) || $this->_cleanData[$k] === $this->_data[$k]) { //nicht ge�ndert if (isset($data[$k])) { $this->_data[$k] = $data[$k]; } else { unset($this->_data[$k]); } } } $this->_cleanData = $data; }
[ "public", "function", "setData", "(", "$", "data", ")", "{", "foreach", "(", "array_keys", "(", "$", "this", "->", "_cleanData", ")", "as", "$", "k", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_data", "[", "$", "k", "]", ")", "||", "$", "this", "->", "_cleanData", "[", "$", "k", "]", "===", "$", "this", "->", "_data", "[", "$", "k", "]", ")", "{", "//nicht ge�ndert", "if", "(", "isset", "(", "$", "data", "[", "$", "k", "]", ")", ")", "{", "$", "this", "->", "_data", "[", "$", "k", "]", "=", "$", "data", "[", "$", "k", "]", ";", "}", "else", "{", "unset", "(", "$", "this", "->", "_data", "[", "$", "k", "]", ")", ";", "}", "}", "}", "$", "this", "->", "_cleanData", "=", "$", "data", ";", "}" ]
internal
[ "internal" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Model/Row/Data/Abstract.php#L19-L32
koala-framework/koala-framework
Kwc/Basic/LinkTag/Intern/Events.php
Kwc_Basic_LinkTag_Intern_Events._getPageIdsFromRecursiveEvent
private function _getPageIdsFromRecursiveEvent(Kwf_Component_Event_Component_RecursiveAbstract $event) { $c = $event->component; $ids = array(); if ($c->isPage) { $ids[] = (string)$c->dbId; } if (isset($c->generator) && $c->generator instanceof Kwc_Root_Category_Generator) { foreach ($c->generator->getRecursivePageChildIds($c->dbId) as $id) { $ids[] = (string)$id; } } return $ids; }
php
private function _getPageIdsFromRecursiveEvent(Kwf_Component_Event_Component_RecursiveAbstract $event) { $c = $event->component; $ids = array(); if ($c->isPage) { $ids[] = (string)$c->dbId; } if (isset($c->generator) && $c->generator instanceof Kwc_Root_Category_Generator) { foreach ($c->generator->getRecursivePageChildIds($c->dbId) as $id) { $ids[] = (string)$id; } } return $ids; }
[ "private", "function", "_getPageIdsFromRecursiveEvent", "(", "Kwf_Component_Event_Component_RecursiveAbstract", "$", "event", ")", "{", "$", "c", "=", "$", "event", "->", "component", ";", "$", "ids", "=", "array", "(", ")", ";", "if", "(", "$", "c", "->", "isPage", ")", "{", "$", "ids", "[", "]", "=", "(", "string", ")", "$", "c", "->", "dbId", ";", "}", "if", "(", "isset", "(", "$", "c", "->", "generator", ")", "&&", "$", "c", "->", "generator", "instanceof", "Kwc_Root_Category_Generator", ")", "{", "foreach", "(", "$", "c", "->", "generator", "->", "getRecursivePageChildIds", "(", "$", "c", "->", "dbId", ")", "as", "$", "id", ")", "{", "$", "ids", "[", "]", "=", "(", "string", ")", "$", "id", ";", "}", "}", "return", "$", "ids", ";", "}" ]
this method returns all child ids needed for deleting recursively
[ "this", "method", "returns", "all", "child", "ids", "needed", "for", "deleting", "recursively" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Basic/LinkTag/Intern/Events.php#L66-L79
koala-framework/koala-framework
Kwc/Basic/LinkTag/Intern/Events.php
Kwc_Basic_LinkTag_Intern_Events.getComponentsForTarget
public static function getComponentsForTarget($componentClass, $targetIds, $includeSubpages) { $ret = array(); foreach (self::_getComponentDbIdsForTarget($componentClass, $targetIds, $includeSubpages) as $dbId) { $ret = array_merge($ret, Kwf_Component_Data_Root::getInstance()->getComponentsByDbId($dbId)); } return $ret; }
php
public static function getComponentsForTarget($componentClass, $targetIds, $includeSubpages) { $ret = array(); foreach (self::_getComponentDbIdsForTarget($componentClass, $targetIds, $includeSubpages) as $dbId) { $ret = array_merge($ret, Kwf_Component_Data_Root::getInstance()->getComponentsByDbId($dbId)); } return $ret; }
[ "public", "static", "function", "getComponentsForTarget", "(", "$", "componentClass", ",", "$", "targetIds", ",", "$", "includeSubpages", ")", "{", "$", "ret", "=", "array", "(", ")", ";", "foreach", "(", "self", "::", "_getComponentDbIdsForTarget", "(", "$", "componentClass", ",", "$", "targetIds", ",", "$", "includeSubpages", ")", "as", "$", "dbId", ")", "{", "$", "ret", "=", "array_merge", "(", "$", "ret", ",", "Kwf_Component_Data_Root", "::", "getInstance", "(", ")", "->", "getComponentsByDbId", "(", "$", "dbId", ")", ")", ";", "}", "return", "$", "ret", ";", "}" ]
used in trl
[ "used", "in", "trl" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Basic/LinkTag/Intern/Events.php#L147-L154
koala-framework/koala-framework
Kwf/Benchmark/Profile.php
Kwf_Benchmark_Profile.stop
public function stop() { $this->_stop = microtime(true); $this->duration = $this->_stop - $this->_start; if (function_exists('memory_get_usage')) { $this->_memoryStop = memory_get_usage(); $this->memory = $this->_memoryStop - $this->_memoryStart; } if (Zend_Registry::get('db') && Zend_Registry::get('db')->getProfiler() instanceof Kwf_Db_Profiler) { $this->_queriesStop = Zend_Registry::get('db')->getProfiler()->getQueryCount(); $this->queries = $this->_queriesStop - $this->_queriesStart; } if (Zend_Registry::get('config')->debug->firephp && class_exists('FirePHP') && FirePHP::getInstance() && FirePHP::getInstance()->detectClientExtension()) { p($this->identifier.': '.$this->addInfo.' '.implode('; ', $this->getOutput())); } $this->stopped = true; }
php
public function stop() { $this->_stop = microtime(true); $this->duration = $this->_stop - $this->_start; if (function_exists('memory_get_usage')) { $this->_memoryStop = memory_get_usage(); $this->memory = $this->_memoryStop - $this->_memoryStart; } if (Zend_Registry::get('db') && Zend_Registry::get('db')->getProfiler() instanceof Kwf_Db_Profiler) { $this->_queriesStop = Zend_Registry::get('db')->getProfiler()->getQueryCount(); $this->queries = $this->_queriesStop - $this->_queriesStart; } if (Zend_Registry::get('config')->debug->firephp && class_exists('FirePHP') && FirePHP::getInstance() && FirePHP::getInstance()->detectClientExtension()) { p($this->identifier.': '.$this->addInfo.' '.implode('; ', $this->getOutput())); } $this->stopped = true; }
[ "public", "function", "stop", "(", ")", "{", "$", "this", "->", "_stop", "=", "microtime", "(", "true", ")", ";", "$", "this", "->", "duration", "=", "$", "this", "->", "_stop", "-", "$", "this", "->", "_start", ";", "if", "(", "function_exists", "(", "'memory_get_usage'", ")", ")", "{", "$", "this", "->", "_memoryStop", "=", "memory_get_usage", "(", ")", ";", "$", "this", "->", "memory", "=", "$", "this", "->", "_memoryStop", "-", "$", "this", "->", "_memoryStart", ";", "}", "if", "(", "Zend_Registry", "::", "get", "(", "'db'", ")", "&&", "Zend_Registry", "::", "get", "(", "'db'", ")", "->", "getProfiler", "(", ")", "instanceof", "Kwf_Db_Profiler", ")", "{", "$", "this", "->", "_queriesStop", "=", "Zend_Registry", "::", "get", "(", "'db'", ")", "->", "getProfiler", "(", ")", "->", "getQueryCount", "(", ")", ";", "$", "this", "->", "queries", "=", "$", "this", "->", "_queriesStop", "-", "$", "this", "->", "_queriesStart", ";", "}", "if", "(", "Zend_Registry", "::", "get", "(", "'config'", ")", "->", "debug", "->", "firephp", "&&", "class_exists", "(", "'FirePHP'", ")", "&&", "FirePHP", "::", "getInstance", "(", ")", "&&", "FirePHP", "::", "getInstance", "(", ")", "->", "detectClientExtension", "(", ")", ")", "{", "p", "(", "$", "this", "->", "identifier", ".", "': '", ".", "$", "this", "->", "addInfo", ".", "' '", ".", "implode", "(", "'; '", ",", "$", "this", "->", "getOutput", "(", ")", ")", ")", ";", "}", "$", "this", "->", "stopped", "=", "true", ";", "}" ]
Beendet eine Sequenz
[ "Beendet", "eine", "Sequenz" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Benchmark/Profile.php#L90-L107
koala-framework/koala-framework
Kwc/Legacy/Columns/Layout.php
Kwc_Legacy_Columns_Layout.getChildContentWidth
public function getChildContentWidth(Kwf_Component_Data $data, Kwf_Component_Data $child) { $ownWidth = parent::getChildContentWidth($data, $child); $w = $this->_getWidth($data, $child, $ownWidth); if (is_int($w)) { return $w; //fix with } $sumUsedWith = 0; $columns = 0; $noWidthColumns = 0; foreach ($data->getChildComponents($data->getComponent()->getSelect()) as $c) { $columns++; $w = $this->_getWidth($data, $c, $ownWidth); if ($w) { $sumUsedWith += $w; } else { $noWidthColumns++; } } $ownWidth -= $this->_getSetting('contentMargin')*($columns-1) + $sumUsedWith; if ($noWidthColumns == 0) $noWidthColumns = 1; return round($ownWidth / $noWidthColumns); }
php
public function getChildContentWidth(Kwf_Component_Data $data, Kwf_Component_Data $child) { $ownWidth = parent::getChildContentWidth($data, $child); $w = $this->_getWidth($data, $child, $ownWidth); if (is_int($w)) { return $w; //fix with } $sumUsedWith = 0; $columns = 0; $noWidthColumns = 0; foreach ($data->getChildComponents($data->getComponent()->getSelect()) as $c) { $columns++; $w = $this->_getWidth($data, $c, $ownWidth); if ($w) { $sumUsedWith += $w; } else { $noWidthColumns++; } } $ownWidth -= $this->_getSetting('contentMargin')*($columns-1) + $sumUsedWith; if ($noWidthColumns == 0) $noWidthColumns = 1; return round($ownWidth / $noWidthColumns); }
[ "public", "function", "getChildContentWidth", "(", "Kwf_Component_Data", "$", "data", ",", "Kwf_Component_Data", "$", "child", ")", "{", "$", "ownWidth", "=", "parent", "::", "getChildContentWidth", "(", "$", "data", ",", "$", "child", ")", ";", "$", "w", "=", "$", "this", "->", "_getWidth", "(", "$", "data", ",", "$", "child", ",", "$", "ownWidth", ")", ";", "if", "(", "is_int", "(", "$", "w", ")", ")", "{", "return", "$", "w", ";", "//fix with", "}", "$", "sumUsedWith", "=", "0", ";", "$", "columns", "=", "0", ";", "$", "noWidthColumns", "=", "0", ";", "foreach", "(", "$", "data", "->", "getChildComponents", "(", "$", "data", "->", "getComponent", "(", ")", "->", "getSelect", "(", ")", ")", "as", "$", "c", ")", "{", "$", "columns", "++", ";", "$", "w", "=", "$", "this", "->", "_getWidth", "(", "$", "data", ",", "$", "c", ",", "$", "ownWidth", ")", ";", "if", "(", "$", "w", ")", "{", "$", "sumUsedWith", "+=", "$", "w", ";", "}", "else", "{", "$", "noWidthColumns", "++", ";", "}", "}", "$", "ownWidth", "-=", "$", "this", "->", "_getSetting", "(", "'contentMargin'", ")", "*", "(", "$", "columns", "-", "1", ")", "+", "$", "sumUsedWith", ";", "if", "(", "$", "noWidthColumns", "==", "0", ")", "$", "noWidthColumns", "=", "1", ";", "return", "round", "(", "$", "ownWidth", "/", "$", "noWidthColumns", ")", ";", "}" ]
- keine breitenangabe (restliche breite wird aufgezeilt)
[ "-", "keine", "breitenangabe", "(", "restliche", "breite", "wird", "aufgezeilt", ")" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Legacy/Columns/Layout.php#L27-L51
koala-framework/koala-framework
Kwf/Util/RtrList.php
Kwf_Util_RtrList.getBadKeys
static public function getBadKeys(array $emails) { $cfg = Kwf_Registry::get('config'); $client = new Kwf_Srpc_Client(array( 'serverUrl' => $cfg->service->rtrlist->url )); return $client->getBadKeys($emails); }
php
static public function getBadKeys(array $emails) { $cfg = Kwf_Registry::get('config'); $client = new Kwf_Srpc_Client(array( 'serverUrl' => $cfg->service->rtrlist->url )); return $client->getBadKeys($emails); }
[ "static", "public", "function", "getBadKeys", "(", "array", "$", "emails", ")", "{", "$", "cfg", "=", "Kwf_Registry", "::", "get", "(", "'config'", ")", ";", "$", "client", "=", "new", "Kwf_Srpc_Client", "(", "array", "(", "'serverUrl'", "=>", "$", "cfg", "->", "service", "->", "rtrlist", "->", "url", ")", ")", ";", "return", "$", "client", "->", "getBadKeys", "(", "$", "emails", ")", ";", "}" ]
Checks mail addresses against the rtr-ecg list TODO: make this an implementation of an interface @param array $emails The emails that should be checked @return array $result The clean array without the rtr-matched addresses
[ "Checks", "mail", "addresses", "against", "the", "rtr", "-", "ecg", "list" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Util/RtrList.php#L12-L19
koala-framework/koala-framework
Kwf/Cache/Simple.php
Kwf_Cache_Simple._getFileNameForCacheId
public static function _getFileNameForCacheId($cacheId) { $cacheId = str_replace('/', '_', base64_encode($cacheId)); if (strlen($cacheId) > 50) { $cacheId = substr($cacheId, 0, 50).md5($cacheId); } return "cache/simple/".$cacheId; }
php
public static function _getFileNameForCacheId($cacheId) { $cacheId = str_replace('/', '_', base64_encode($cacheId)); if (strlen($cacheId) > 50) { $cacheId = substr($cacheId, 0, 50).md5($cacheId); } return "cache/simple/".$cacheId; }
[ "public", "static", "function", "_getFileNameForCacheId", "(", "$", "cacheId", ")", "{", "$", "cacheId", "=", "str_replace", "(", "'/'", ",", "'_'", ",", "base64_encode", "(", "$", "cacheId", ")", ")", ";", "if", "(", "strlen", "(", "$", "cacheId", ")", ">", "50", ")", "{", "$", "cacheId", "=", "substr", "(", "$", "cacheId", ",", "0", ",", "50", ")", ".", "md5", "(", "$", "cacheId", ")", ";", "}", "return", "\"cache/simple/\"", ".", "$", "cacheId", ";", "}" ]
for 'file' backend
[ "for", "file", "backend" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Cache/Simple.php#L126-L133
koala-framework/koala-framework
Kwf/Cache/Simple.php
Kwf_Cache_Simple._clear
public static function _clear() { if (self::getBackend() == 'memcache') { if (!Kwf_Config::getValue('cacheSimpleNamespace')) { //increment namespace $mc = Kwf_Cache_Simple::getMemcache(); if ($mc->get(Kwf_Cache_Simple::$uniquePrefix.'cache_namespace')) { $mc->increment(Kwf_Cache_Simple::$uniquePrefix.'cache_namespace'); } } else { $mc = Kwf_Cache_Simple::getMemcache(); $mc->flush(); } } else if (self::getBackend() == 'redis') { $prefixLength = strlen(self::getRedis()->_prefix('')); $it = null; while ($keys = self::getRedis()->scan($it, self::getRedis()->_prefix('simple:*'))) { foreach ($keys as $k=>$i) { $keys[$k] = substr($i, $prefixLength); } self::getRedis()->delete($keys); } } else if (self::getBackend() == 'file') { foreach(glob('cache/simple/*') as $i) { unlink($i); } } else if (self::getBackend() == 'apc' || self::getBackend() == 'apcu') { //those are cleared using their own clear-cache type } else { if (!isset(self::$_zendCache)) self::getZendCache(); $r = self::$_zendCache->clean(Zend_Cache::CLEANING_MODE_ALL); } }
php
public static function _clear() { if (self::getBackend() == 'memcache') { if (!Kwf_Config::getValue('cacheSimpleNamespace')) { //increment namespace $mc = Kwf_Cache_Simple::getMemcache(); if ($mc->get(Kwf_Cache_Simple::$uniquePrefix.'cache_namespace')) { $mc->increment(Kwf_Cache_Simple::$uniquePrefix.'cache_namespace'); } } else { $mc = Kwf_Cache_Simple::getMemcache(); $mc->flush(); } } else if (self::getBackend() == 'redis') { $prefixLength = strlen(self::getRedis()->_prefix('')); $it = null; while ($keys = self::getRedis()->scan($it, self::getRedis()->_prefix('simple:*'))) { foreach ($keys as $k=>$i) { $keys[$k] = substr($i, $prefixLength); } self::getRedis()->delete($keys); } } else if (self::getBackend() == 'file') { foreach(glob('cache/simple/*') as $i) { unlink($i); } } else if (self::getBackend() == 'apc' || self::getBackend() == 'apcu') { //those are cleared using their own clear-cache type } else { if (!isset(self::$_zendCache)) self::getZendCache(); $r = self::$_zendCache->clean(Zend_Cache::CLEANING_MODE_ALL); } }
[ "public", "static", "function", "_clear", "(", ")", "{", "if", "(", "self", "::", "getBackend", "(", ")", "==", "'memcache'", ")", "{", "if", "(", "!", "Kwf_Config", "::", "getValue", "(", "'cacheSimpleNamespace'", ")", ")", "{", "//increment namespace", "$", "mc", "=", "Kwf_Cache_Simple", "::", "getMemcache", "(", ")", ";", "if", "(", "$", "mc", "->", "get", "(", "Kwf_Cache_Simple", "::", "$", "uniquePrefix", ".", "'cache_namespace'", ")", ")", "{", "$", "mc", "->", "increment", "(", "Kwf_Cache_Simple", "::", "$", "uniquePrefix", ".", "'cache_namespace'", ")", ";", "}", "}", "else", "{", "$", "mc", "=", "Kwf_Cache_Simple", "::", "getMemcache", "(", ")", ";", "$", "mc", "->", "flush", "(", ")", ";", "}", "}", "else", "if", "(", "self", "::", "getBackend", "(", ")", "==", "'redis'", ")", "{", "$", "prefixLength", "=", "strlen", "(", "self", "::", "getRedis", "(", ")", "->", "_prefix", "(", "''", ")", ")", ";", "$", "it", "=", "null", ";", "while", "(", "$", "keys", "=", "self", "::", "getRedis", "(", ")", "->", "scan", "(", "$", "it", ",", "self", "::", "getRedis", "(", ")", "->", "_prefix", "(", "'simple:*'", ")", ")", ")", "{", "foreach", "(", "$", "keys", "as", "$", "k", "=>", "$", "i", ")", "{", "$", "keys", "[", "$", "k", "]", "=", "substr", "(", "$", "i", ",", "$", "prefixLength", ")", ";", "}", "self", "::", "getRedis", "(", ")", "->", "delete", "(", "$", "keys", ")", ";", "}", "}", "else", "if", "(", "self", "::", "getBackend", "(", ")", "==", "'file'", ")", "{", "foreach", "(", "glob", "(", "'cache/simple/*'", ")", "as", "$", "i", ")", "{", "unlink", "(", "$", "i", ")", ";", "}", "}", "else", "if", "(", "self", "::", "getBackend", "(", ")", "==", "'apc'", "||", "self", "::", "getBackend", "(", ")", "==", "'apcu'", ")", "{", "//those are cleared using their own clear-cache type", "}", "else", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "_zendCache", ")", ")", "self", "::", "getZendCache", "(", ")", ";", "$", "r", "=", "self", "::", "$", "_zendCache", "->", "clean", "(", "Zend_Cache", "::", "CLEANING_MODE_ALL", ")", ";", "}", "}" ]
only call from Kwf_Util_ClearCache_Types_SimpleCache!
[ "only", "call", "from", "Kwf_Util_ClearCache_Types_SimpleCache!" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Cache/Simple.php#L255-L287
koala-framework/koala-framework
KwfBundle/Serializer/SubmitHandlerErrorNormalizer.php
SubmitHandlerErrorNormalizer.normalize
public function normalize($object, $format = null, array $context = array()) { $errors = array(); foreach ($object->getErrors() as $error) { $errors[] = array( 'field' => $error['field'], 'message' => $this->getErrorMessage($error['violation']) ); } return array( 'code' => isset($context['status_code']) ? $context['status_code'] : null, 'message' => 'Validation Failed', 'errors' => $errors, ); }
php
public function normalize($object, $format = null, array $context = array()) { $errors = array(); foreach ($object->getErrors() as $error) { $errors[] = array( 'field' => $error['field'], 'message' => $this->getErrorMessage($error['violation']) ); } return array( 'code' => isset($context['status_code']) ? $context['status_code'] : null, 'message' => 'Validation Failed', 'errors' => $errors, ); }
[ "public", "function", "normalize", "(", "$", "object", ",", "$", "format", "=", "null", ",", "array", "$", "context", "=", "array", "(", ")", ")", "{", "$", "errors", "=", "array", "(", ")", ";", "foreach", "(", "$", "object", "->", "getErrors", "(", ")", "as", "$", "error", ")", "{", "$", "errors", "[", "]", "=", "array", "(", "'field'", "=>", "$", "error", "[", "'field'", "]", ",", "'message'", "=>", "$", "this", "->", "getErrorMessage", "(", "$", "error", "[", "'violation'", "]", ")", ")", ";", "}", "return", "array", "(", "'code'", "=>", "isset", "(", "$", "context", "[", "'status_code'", "]", ")", "?", "$", "context", "[", "'status_code'", "]", ":", "null", ",", "'message'", "=>", "'Validation Failed'", ",", "'errors'", "=>", "$", "errors", ",", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/KwfBundle/Serializer/SubmitHandlerErrorNormalizer.php#L19-L33
koala-framework/koala-framework
KwfBundle/Serializer/SubmitHandlerErrorNormalizer.php
SubmitHandlerErrorNormalizer.supportsNormalization
public function supportsNormalization($data, $format = null) { return $data instanceof SubmitHandler && $data->isSubmitted() && !$data->isValid(); }
php
public function supportsNormalization($data, $format = null) { return $data instanceof SubmitHandler && $data->isSubmitted() && !$data->isValid(); }
[ "public", "function", "supportsNormalization", "(", "$", "data", ",", "$", "format", "=", "null", ")", "{", "return", "$", "data", "instanceof", "SubmitHandler", "&&", "$", "data", "->", "isSubmitted", "(", ")", "&&", "!", "$", "data", "->", "isValid", "(", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/KwfBundle/Serializer/SubmitHandlerErrorNormalizer.php#L38-L41
koala-framework/koala-framework
Kwf/Cache/Backend/Apcu.php
Kwf_Cache_Backend_Apcu.getIds
public function getIds() { $ids = array(); $iterator = new APCUIterator('user', null, APCU_ITER_KEY); foreach ($iterator as $item) { $ids[] = $item['key']; } return $ids; }
php
public function getIds() { $ids = array(); $iterator = new APCUIterator('user', null, APCU_ITER_KEY); foreach ($iterator as $item) { $ids[] = $item['key']; } return $ids; }
[ "public", "function", "getIds", "(", ")", "{", "$", "ids", "=", "array", "(", ")", ";", "$", "iterator", "=", "new", "APCUIterator", "(", "'user'", ",", "null", ",", "APCU_ITER_KEY", ")", ";", "foreach", "(", "$", "iterator", "as", "$", "item", ")", "{", "$", "ids", "[", "]", "=", "$", "item", "[", "'key'", "]", ";", "}", "return", "$", "ids", ";", "}" ]
Return an array of stored cache ids @return array array of stored cache ids (string)
[ "Return", "an", "array", "of", "stored", "cache", "ids" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Cache/Backend/Apcu.php#L258-L267
koala-framework/koala-framework
Kwc/Advanced/Team/Member/Data/Vcard/ContentSender.php
Kwc_Advanced_Team_Member_Data_Vcard_ContentSender._getDefaultValues
protected function _getDefaultValues() { $teamComponent = $this->_data->parent->parent->parent; if (Kwc_Abstract::hasSetting($teamComponent->componentClass, 'defaultVcardValues')) { $setting = Kwc_Abstract::getSetting($teamComponent->componentClass, 'defaultVcardValues'); } if (isset($setting)) { return $setting; } else { return Kwc_Abstract::getSetting($this->_data->componentClass, 'defaultVcardValues'); } }
php
protected function _getDefaultValues() { $teamComponent = $this->_data->parent->parent->parent; if (Kwc_Abstract::hasSetting($teamComponent->componentClass, 'defaultVcardValues')) { $setting = Kwc_Abstract::getSetting($teamComponent->componentClass, 'defaultVcardValues'); } if (isset($setting)) { return $setting; } else { return Kwc_Abstract::getSetting($this->_data->componentClass, 'defaultVcardValues'); } }
[ "protected", "function", "_getDefaultValues", "(", ")", "{", "$", "teamComponent", "=", "$", "this", "->", "_data", "->", "parent", "->", "parent", "->", "parent", ";", "if", "(", "Kwc_Abstract", "::", "hasSetting", "(", "$", "teamComponent", "->", "componentClass", ",", "'defaultVcardValues'", ")", ")", "{", "$", "setting", "=", "Kwc_Abstract", "::", "getSetting", "(", "$", "teamComponent", "->", "componentClass", ",", "'defaultVcardValues'", ")", ";", "}", "if", "(", "isset", "(", "$", "setting", ")", ")", "{", "return", "$", "setting", ";", "}", "else", "{", "return", "Kwc_Abstract", "::", "getSetting", "(", "$", "this", "->", "_data", "->", "componentClass", ",", "'defaultVcardValues'", ")", ";", "}", "}" ]
Set default vCard settings here or in Team_Component
[ "Set", "default", "vCard", "settings", "here", "or", "in", "Team_Component" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Advanced/Team/Member/Data/Vcard/ContentSender.php#L18-L30
koala-framework/koala-framework
Kwc/Advanced/Team/Member/Data/Vcard/ContentSender.php
Kwc_Advanced_Team_Member_Data_Vcard_ContentSender._getVcardContent
protected function _getVcardContent($dataRow, $imageData) { $defaults = $this->_getDefaultValues(); require_once Kwf_Config::getValue('externLibraryPath.pearContactVcardBuild').'/Contact/Vcard/Build.php'; $vcard = new Contact_Vcard_Build('2.1'); $vcard->setName(utf8_decode($dataRow->lastname), utf8_decode($dataRow->firstname), '', utf8_decode($dataRow->title), ''); $vcard->addParam('CHARSET', 'ISO-8859-1'); $vcard->setFormattedName(utf8_decode($dataRow->firstname).' '.utf8_decode($dataRow->lastname)); $vcard->addParam('CHARSET', 'ISO-8859-1'); if (isset($defaults['ORG'])) { $vcard->addOrganization(utf8_decode($defaults['ORG'])); $vcard->addParam('CHARSET', 'ISO-8859-1'); } if (!empty($dataRow->working_position)) { $vcard->setRole(utf8_decode($dataRow->working_position)); $vcard->addParam('CHARSET', 'ISO-8859-1'); } if (!empty($dataRow->phone)) { $vcard->addTelephone(utf8_decode($dataRow->phone)); $vcard->addParam('TYPE', 'WORK'); $vcard->addParam('TYPE', 'PREF'); $vcard->addParam('CHARSET', 'ISO-8859-1'); } if (!empty($dataRow->mobile)) { $vcard->addTelephone(utf8_decode($dataRow->mobile), 'mobile'); $vcard->addParam('TYPE', 'WORK'); $vcard->addParam('CHARSET', 'ISO-8859-1'); } $fax = null; if (!empty($dataRow->fax)) { $fax = $dataRow->fax; } else if (isset($defaults['TEL;WORK;FAX'])) { $fax = $defaults['TEL;WORK;FAX']; } if ($fax) { $vcard->addTelephone(utf8_decode($fax), 'fax'); $vcard->addParam('TYPE', 'WORK'); $vcard->addParam('CHARSET', 'ISO-8859-1'); } if (!empty($dataRow->email)) { $vcard->addEmail(utf8_decode($dataRow->email)); $vcard->addParam('TYPE', 'WORK'); $vcard->addParam('CHARSET', 'ISO-8859-1'); } if (isset($defaults['URL;WORK'])) { $vcard->setURL(utf8_decode($defaults['URL;WORK'])); $vcard->addParam('TYPE', 'WORK'); $vcard->addParam('CHARSET', 'ISO-8859-1'); } if (isset($defaults['NOTE'])) { $vcard->setNote(utf8_decode($defaults['NOTE'])); $vcard->addParam('CHARSET', 'ISO-8859-1'); } if (isset($defaults['ADR;WORK']) || !empty($dataRow->street) || !empty($dataRow->city) || !empty($dataRow->zip) || !empty($dataRow->country)) { /** * muss ein array mit folgenden werten liefern: * 0 => '' * 1 => '' * 2 => street * 3 => city * 4 => province * 5 => zip * 6 => country */ $values = array(); if (!empty($defaults['ADR;WORK'])) { $values = explode(';', utf8_decode($defaults['ADR;WORK'])); } for ($i=0; $i<=6; $i++) { if (!isset($values[$i])) $values[$i] = ''; } if (!empty($dataRow->street)) $values[2] = utf8_decode($dataRow->street); if (!empty($dataRow->city)) $values[3] = utf8_decode($dataRow->city); if (!empty($dataRow->country)) $values[4] = utf8_decode($dataRow->country); if (!empty($dataRow->zip)) $values[5] = utf8_decode($dataRow->zip); if (!empty($dataRow->country)) $values[6] = utf8_decode($dataRow->country); $vcard->addAddress($values[0], $values[1], $values[2], $values[3], $values[4], $values[5], $values[6]); $vcard->addParam('TYPE', 'WORK'); $vcard->addParam('CHARSET', 'ISO-8859-1'); } if ($imageData && $imageData->hasContent()) { $data = call_user_func_array( array($imageData->componentClass, 'getMediaOutput'), array($imageData->componentId, 'default', $imageData->componentClass) ); $type = explode('/', $data['mimeType']); $type[1] = strtoupper($type[1]); if ($type[1] == 'PJPEG') $type[1] = 'JPEG'; if ($type[1] == 'JPEG') { $vcard->setPhoto(base64_encode($data['contents'])); $vcard->addParam('TYPE', $type[1]); $vcard->addParam('ENCODING', 'BASE64'); } } $vcard->setRevision(date('Y-m-d').'T'.date('H:i:s').'Z'); return $vcard->fetch(); }
php
protected function _getVcardContent($dataRow, $imageData) { $defaults = $this->_getDefaultValues(); require_once Kwf_Config::getValue('externLibraryPath.pearContactVcardBuild').'/Contact/Vcard/Build.php'; $vcard = new Contact_Vcard_Build('2.1'); $vcard->setName(utf8_decode($dataRow->lastname), utf8_decode($dataRow->firstname), '', utf8_decode($dataRow->title), ''); $vcard->addParam('CHARSET', 'ISO-8859-1'); $vcard->setFormattedName(utf8_decode($dataRow->firstname).' '.utf8_decode($dataRow->lastname)); $vcard->addParam('CHARSET', 'ISO-8859-1'); if (isset($defaults['ORG'])) { $vcard->addOrganization(utf8_decode($defaults['ORG'])); $vcard->addParam('CHARSET', 'ISO-8859-1'); } if (!empty($dataRow->working_position)) { $vcard->setRole(utf8_decode($dataRow->working_position)); $vcard->addParam('CHARSET', 'ISO-8859-1'); } if (!empty($dataRow->phone)) { $vcard->addTelephone(utf8_decode($dataRow->phone)); $vcard->addParam('TYPE', 'WORK'); $vcard->addParam('TYPE', 'PREF'); $vcard->addParam('CHARSET', 'ISO-8859-1'); } if (!empty($dataRow->mobile)) { $vcard->addTelephone(utf8_decode($dataRow->mobile), 'mobile'); $vcard->addParam('TYPE', 'WORK'); $vcard->addParam('CHARSET', 'ISO-8859-1'); } $fax = null; if (!empty($dataRow->fax)) { $fax = $dataRow->fax; } else if (isset($defaults['TEL;WORK;FAX'])) { $fax = $defaults['TEL;WORK;FAX']; } if ($fax) { $vcard->addTelephone(utf8_decode($fax), 'fax'); $vcard->addParam('TYPE', 'WORK'); $vcard->addParam('CHARSET', 'ISO-8859-1'); } if (!empty($dataRow->email)) { $vcard->addEmail(utf8_decode($dataRow->email)); $vcard->addParam('TYPE', 'WORK'); $vcard->addParam('CHARSET', 'ISO-8859-1'); } if (isset($defaults['URL;WORK'])) { $vcard->setURL(utf8_decode($defaults['URL;WORK'])); $vcard->addParam('TYPE', 'WORK'); $vcard->addParam('CHARSET', 'ISO-8859-1'); } if (isset($defaults['NOTE'])) { $vcard->setNote(utf8_decode($defaults['NOTE'])); $vcard->addParam('CHARSET', 'ISO-8859-1'); } if (isset($defaults['ADR;WORK']) || !empty($dataRow->street) || !empty($dataRow->city) || !empty($dataRow->zip) || !empty($dataRow->country)) { /** * muss ein array mit folgenden werten liefern: * 0 => '' * 1 => '' * 2 => street * 3 => city * 4 => province * 5 => zip * 6 => country */ $values = array(); if (!empty($defaults['ADR;WORK'])) { $values = explode(';', utf8_decode($defaults['ADR;WORK'])); } for ($i=0; $i<=6; $i++) { if (!isset($values[$i])) $values[$i] = ''; } if (!empty($dataRow->street)) $values[2] = utf8_decode($dataRow->street); if (!empty($dataRow->city)) $values[3] = utf8_decode($dataRow->city); if (!empty($dataRow->country)) $values[4] = utf8_decode($dataRow->country); if (!empty($dataRow->zip)) $values[5] = utf8_decode($dataRow->zip); if (!empty($dataRow->country)) $values[6] = utf8_decode($dataRow->country); $vcard->addAddress($values[0], $values[1], $values[2], $values[3], $values[4], $values[5], $values[6]); $vcard->addParam('TYPE', 'WORK'); $vcard->addParam('CHARSET', 'ISO-8859-1'); } if ($imageData && $imageData->hasContent()) { $data = call_user_func_array( array($imageData->componentClass, 'getMediaOutput'), array($imageData->componentId, 'default', $imageData->componentClass) ); $type = explode('/', $data['mimeType']); $type[1] = strtoupper($type[1]); if ($type[1] == 'PJPEG') $type[1] = 'JPEG'; if ($type[1] == 'JPEG') { $vcard->setPhoto(base64_encode($data['contents'])); $vcard->addParam('TYPE', $type[1]); $vcard->addParam('ENCODING', 'BASE64'); } } $vcard->setRevision(date('Y-m-d').'T'.date('H:i:s').'Z'); return $vcard->fetch(); }
[ "protected", "function", "_getVcardContent", "(", "$", "dataRow", ",", "$", "imageData", ")", "{", "$", "defaults", "=", "$", "this", "->", "_getDefaultValues", "(", ")", ";", "require_once", "Kwf_Config", "::", "getValue", "(", "'externLibraryPath.pearContactVcardBuild'", ")", ".", "'/Contact/Vcard/Build.php'", ";", "$", "vcard", "=", "new", "Contact_Vcard_Build", "(", "'2.1'", ")", ";", "$", "vcard", "->", "setName", "(", "utf8_decode", "(", "$", "dataRow", "->", "lastname", ")", ",", "utf8_decode", "(", "$", "dataRow", "->", "firstname", ")", ",", "''", ",", "utf8_decode", "(", "$", "dataRow", "->", "title", ")", ",", "''", ")", ";", "$", "vcard", "->", "addParam", "(", "'CHARSET'", ",", "'ISO-8859-1'", ")", ";", "$", "vcard", "->", "setFormattedName", "(", "utf8_decode", "(", "$", "dataRow", "->", "firstname", ")", ".", "' '", ".", "utf8_decode", "(", "$", "dataRow", "->", "lastname", ")", ")", ";", "$", "vcard", "->", "addParam", "(", "'CHARSET'", ",", "'ISO-8859-1'", ")", ";", "if", "(", "isset", "(", "$", "defaults", "[", "'ORG'", "]", ")", ")", "{", "$", "vcard", "->", "addOrganization", "(", "utf8_decode", "(", "$", "defaults", "[", "'ORG'", "]", ")", ")", ";", "$", "vcard", "->", "addParam", "(", "'CHARSET'", ",", "'ISO-8859-1'", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "dataRow", "->", "working_position", ")", ")", "{", "$", "vcard", "->", "setRole", "(", "utf8_decode", "(", "$", "dataRow", "->", "working_position", ")", ")", ";", "$", "vcard", "->", "addParam", "(", "'CHARSET'", ",", "'ISO-8859-1'", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "dataRow", "->", "phone", ")", ")", "{", "$", "vcard", "->", "addTelephone", "(", "utf8_decode", "(", "$", "dataRow", "->", "phone", ")", ")", ";", "$", "vcard", "->", "addParam", "(", "'TYPE'", ",", "'WORK'", ")", ";", "$", "vcard", "->", "addParam", "(", "'TYPE'", ",", "'PREF'", ")", ";", "$", "vcard", "->", "addParam", "(", "'CHARSET'", ",", "'ISO-8859-1'", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "dataRow", "->", "mobile", ")", ")", "{", "$", "vcard", "->", "addTelephone", "(", "utf8_decode", "(", "$", "dataRow", "->", "mobile", ")", ",", "'mobile'", ")", ";", "$", "vcard", "->", "addParam", "(", "'TYPE'", ",", "'WORK'", ")", ";", "$", "vcard", "->", "addParam", "(", "'CHARSET'", ",", "'ISO-8859-1'", ")", ";", "}", "$", "fax", "=", "null", ";", "if", "(", "!", "empty", "(", "$", "dataRow", "->", "fax", ")", ")", "{", "$", "fax", "=", "$", "dataRow", "->", "fax", ";", "}", "else", "if", "(", "isset", "(", "$", "defaults", "[", "'TEL;WORK;FAX'", "]", ")", ")", "{", "$", "fax", "=", "$", "defaults", "[", "'TEL;WORK;FAX'", "]", ";", "}", "if", "(", "$", "fax", ")", "{", "$", "vcard", "->", "addTelephone", "(", "utf8_decode", "(", "$", "fax", ")", ",", "'fax'", ")", ";", "$", "vcard", "->", "addParam", "(", "'TYPE'", ",", "'WORK'", ")", ";", "$", "vcard", "->", "addParam", "(", "'CHARSET'", ",", "'ISO-8859-1'", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "dataRow", "->", "email", ")", ")", "{", "$", "vcard", "->", "addEmail", "(", "utf8_decode", "(", "$", "dataRow", "->", "email", ")", ")", ";", "$", "vcard", "->", "addParam", "(", "'TYPE'", ",", "'WORK'", ")", ";", "$", "vcard", "->", "addParam", "(", "'CHARSET'", ",", "'ISO-8859-1'", ")", ";", "}", "if", "(", "isset", "(", "$", "defaults", "[", "'URL;WORK'", "]", ")", ")", "{", "$", "vcard", "->", "setURL", "(", "utf8_decode", "(", "$", "defaults", "[", "'URL;WORK'", "]", ")", ")", ";", "$", "vcard", "->", "addParam", "(", "'TYPE'", ",", "'WORK'", ")", ";", "$", "vcard", "->", "addParam", "(", "'CHARSET'", ",", "'ISO-8859-1'", ")", ";", "}", "if", "(", "isset", "(", "$", "defaults", "[", "'NOTE'", "]", ")", ")", "{", "$", "vcard", "->", "setNote", "(", "utf8_decode", "(", "$", "defaults", "[", "'NOTE'", "]", ")", ")", ";", "$", "vcard", "->", "addParam", "(", "'CHARSET'", ",", "'ISO-8859-1'", ")", ";", "}", "if", "(", "isset", "(", "$", "defaults", "[", "'ADR;WORK'", "]", ")", "||", "!", "empty", "(", "$", "dataRow", "->", "street", ")", "||", "!", "empty", "(", "$", "dataRow", "->", "city", ")", "||", "!", "empty", "(", "$", "dataRow", "->", "zip", ")", "||", "!", "empty", "(", "$", "dataRow", "->", "country", ")", ")", "{", "/**\n * muss ein array mit folgenden werten liefern:\n * 0 => ''\n * 1 => ''\n * 2 => street\n * 3 => city\n * 4 => province\n * 5 => zip\n * 6 => country\n */", "$", "values", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "defaults", "[", "'ADR;WORK'", "]", ")", ")", "{", "$", "values", "=", "explode", "(", "';'", ",", "utf8_decode", "(", "$", "defaults", "[", "'ADR;WORK'", "]", ")", ")", ";", "}", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<=", "6", ";", "$", "i", "++", ")", "{", "if", "(", "!", "isset", "(", "$", "values", "[", "$", "i", "]", ")", ")", "$", "values", "[", "$", "i", "]", "=", "''", ";", "}", "if", "(", "!", "empty", "(", "$", "dataRow", "->", "street", ")", ")", "$", "values", "[", "2", "]", "=", "utf8_decode", "(", "$", "dataRow", "->", "street", ")", ";", "if", "(", "!", "empty", "(", "$", "dataRow", "->", "city", ")", ")", "$", "values", "[", "3", "]", "=", "utf8_decode", "(", "$", "dataRow", "->", "city", ")", ";", "if", "(", "!", "empty", "(", "$", "dataRow", "->", "country", ")", ")", "$", "values", "[", "4", "]", "=", "utf8_decode", "(", "$", "dataRow", "->", "country", ")", ";", "if", "(", "!", "empty", "(", "$", "dataRow", "->", "zip", ")", ")", "$", "values", "[", "5", "]", "=", "utf8_decode", "(", "$", "dataRow", "->", "zip", ")", ";", "if", "(", "!", "empty", "(", "$", "dataRow", "->", "country", ")", ")", "$", "values", "[", "6", "]", "=", "utf8_decode", "(", "$", "dataRow", "->", "country", ")", ";", "$", "vcard", "->", "addAddress", "(", "$", "values", "[", "0", "]", ",", "$", "values", "[", "1", "]", ",", "$", "values", "[", "2", "]", ",", "$", "values", "[", "3", "]", ",", "$", "values", "[", "4", "]", ",", "$", "values", "[", "5", "]", ",", "$", "values", "[", "6", "]", ")", ";", "$", "vcard", "->", "addParam", "(", "'TYPE'", ",", "'WORK'", ")", ";", "$", "vcard", "->", "addParam", "(", "'CHARSET'", ",", "'ISO-8859-1'", ")", ";", "}", "if", "(", "$", "imageData", "&&", "$", "imageData", "->", "hasContent", "(", ")", ")", "{", "$", "data", "=", "call_user_func_array", "(", "array", "(", "$", "imageData", "->", "componentClass", ",", "'getMediaOutput'", ")", ",", "array", "(", "$", "imageData", "->", "componentId", ",", "'default'", ",", "$", "imageData", "->", "componentClass", ")", ")", ";", "$", "type", "=", "explode", "(", "'/'", ",", "$", "data", "[", "'mimeType'", "]", ")", ";", "$", "type", "[", "1", "]", "=", "strtoupper", "(", "$", "type", "[", "1", "]", ")", ";", "if", "(", "$", "type", "[", "1", "]", "==", "'PJPEG'", ")", "$", "type", "[", "1", "]", "=", "'JPEG'", ";", "if", "(", "$", "type", "[", "1", "]", "==", "'JPEG'", ")", "{", "$", "vcard", "->", "setPhoto", "(", "base64_encode", "(", "$", "data", "[", "'contents'", "]", ")", ")", ";", "$", "vcard", "->", "addParam", "(", "'TYPE'", ",", "$", "type", "[", "1", "]", ")", ";", "$", "vcard", "->", "addParam", "(", "'ENCODING'", ",", "'BASE64'", ")", ";", "}", "}", "$", "vcard", "->", "setRevision", "(", "date", "(", "'Y-m-d'", ")", ".", "'T'", ".", "date", "(", "'H:i:s'", ")", ".", "'Z'", ")", ";", "return", "$", "vcard", "->", "fetch", "(", ")", ";", "}" ]
Gibt vCard Daten zurück. Statisch weil es auch von der Trl_Component aufgerufen wird.
[ "Gibt", "vCard", "Daten", "zurück", ".", "Statisch", "weil", "es", "auch", "von", "der", "Trl_Component", "aufgerufen", "wird", "." ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Advanced/Team/Member/Data/Vcard/ContentSender.php#L58-L163
koala-framework/koala-framework
Kwf/Db/Table/Rowset.php
Kwf_Db_Table_Rowset.seek
public function seek($position) { $position = (int) $position; if ($position < 0 || $position >= $this->_count) { throw new Kwf_Exception("Illegal index $position"); } $this->_pointer = $position; return $this; }
php
public function seek($position) { $position = (int) $position; if ($position < 0 || $position >= $this->_count) { throw new Kwf_Exception("Illegal index $position"); } $this->_pointer = $position; return $this; }
[ "public", "function", "seek", "(", "$", "position", ")", "{", "$", "position", "=", "(", "int", ")", "$", "position", ";", "if", "(", "$", "position", "<", "0", "||", "$", "position", ">=", "$", "this", "->", "_count", ")", "{", "throw", "new", "Kwf_Exception", "(", "\"Illegal index $position\"", ")", ";", "}", "$", "this", "->", "_pointer", "=", "$", "position", ";", "return", "$", "this", ";", "}" ]
Take the Iterator to position $position Required by interface SeekableIterator. @param int $position the position to seek to @return Kwf_Db_Table_Rowset @throws Kwf_Exception
[ "Take", "the", "Iterator", "to", "position", "$position", "Required", "by", "interface", "SeekableIterator", "." ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Db/Table/Rowset.php#L189-L197
koala-framework/koala-framework
Kwf/Db/Table/Rowset.php
Kwf_Db_Table_Rowset.offsetGet
public function offsetGet($offset) { $offset = (int) $offset; if ($offset < 0 || $offset >= $this->_count) { throw new Kwf_Exception("Illegal index $offset"); } $this->_pointer = $offset; return $this->current(); }
php
public function offsetGet($offset) { $offset = (int) $offset; if ($offset < 0 || $offset >= $this->_count) { throw new Kwf_Exception("Illegal index $offset"); } $this->_pointer = $offset; return $this->current(); }
[ "public", "function", "offsetGet", "(", "$", "offset", ")", "{", "$", "offset", "=", "(", "int", ")", "$", "offset", ";", "if", "(", "$", "offset", "<", "0", "||", "$", "offset", ">=", "$", "this", "->", "_count", ")", "{", "throw", "new", "Kwf_Exception", "(", "\"Illegal index $offset\"", ")", ";", "}", "$", "this", "->", "_pointer", "=", "$", "offset", ";", "return", "$", "this", "->", "current", "(", ")", ";", "}" ]
Get the row for the given offset Required by the ArrayAccess implementation @param string $offset @return Kwf_Db_Table_Row_Abstract
[ "Get", "the", "row", "for", "the", "given", "offset", "Required", "by", "the", "ArrayAccess", "implementation" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Db/Table/Rowset.php#L218-L227
koala-framework/koala-framework
Kwf/Db/Table/Rowset.php
Kwf_Db_Table_Rowset.getRow
public function getRow($position, $seek = false) { try { $row = $this->_loadAndReturnRow($position); } catch (Kwf_Exception $e) { throw new Kwf_Exception('No row could be found at position ' . (int) $position, 0, $e); } if ($seek == true) { $this->seek($position); } return $row; }
php
public function getRow($position, $seek = false) { try { $row = $this->_loadAndReturnRow($position); } catch (Kwf_Exception $e) { throw new Kwf_Exception('No row could be found at position ' . (int) $position, 0, $e); } if ($seek == true) { $this->seek($position); } return $row; }
[ "public", "function", "getRow", "(", "$", "position", ",", "$", "seek", "=", "false", ")", "{", "try", "{", "$", "row", "=", "$", "this", "->", "_loadAndReturnRow", "(", "$", "position", ")", ";", "}", "catch", "(", "Kwf_Exception", "$", "e", ")", "{", "throw", "new", "Kwf_Exception", "(", "'No row could be found at position '", ".", "(", "int", ")", "$", "position", ",", "0", ",", "$", "e", ")", ";", "}", "if", "(", "$", "seek", "==", "true", ")", "{", "$", "this", "->", "seek", "(", "$", "position", ")", ";", "}", "return", "$", "row", ";", "}" ]
Returns a Kwf_Db_Table_Row from a known position into the Iterator @param int $position the position of the row expected @param bool $seek wether or not seek the iterator to that position after @return Kwf_Db_Table_Row @throws Kwf_Exception
[ "Returns", "a", "Kwf_Db_Table_Row", "from", "a", "known", "position", "into", "the", "Iterator" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Db/Table/Rowset.php#L258-L271
koala-framework/koala-framework
Kwf/Form/Field/GoogleMapsField.php
Kwf_Form_Field_GoogleMapsField.setCoordinateFieldnames
public function setCoordinateFieldnames($latitudeFieldname = 'latitude', $longitudeFieldname = 'longitude') { $this->_latitudeFieldname = $latitudeFieldname; $this->_longitudeFieldname = $longitudeFieldname; return $this; }
php
public function setCoordinateFieldnames($latitudeFieldname = 'latitude', $longitudeFieldname = 'longitude') { $this->_latitudeFieldname = $latitudeFieldname; $this->_longitudeFieldname = $longitudeFieldname; return $this; }
[ "public", "function", "setCoordinateFieldnames", "(", "$", "latitudeFieldname", "=", "'latitude'", ",", "$", "longitudeFieldname", "=", "'longitude'", ")", "{", "$", "this", "->", "_latitudeFieldname", "=", "$", "latitudeFieldname", ";", "$", "this", "->", "_longitudeFieldname", "=", "$", "longitudeFieldname", ";", "return", "$", "this", ";", "}" ]
if called, coordinates will be saved into two seperate fields (necessary if you want to use Kwc_Directories_List_ViewMap_Component)
[ "if", "called", "coordinates", "will", "be", "saved", "into", "two", "seperate", "fields", "(", "necessary", "if", "you", "want", "to", "use", "Kwc_Directories_List_ViewMap_Component", ")" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Form/Field/GoogleMapsField.php#L17-L22
koala-framework/koala-framework
Kwf/Util/Gearman/Client.php
Kwf_Util_Gearman_Client.doKwf
public function doKwf($function_name, $workload, $unique=null) { $function_name = $this->_processFunctionName($function_name); if (method_exists($this, 'doNormal')) { return $this->doNormal($function_name, $workload, $unique); } else { //older versions of gearman extension return $this->do($function_name, $workload, $unique); } }
php
public function doKwf($function_name, $workload, $unique=null) { $function_name = $this->_processFunctionName($function_name); if (method_exists($this, 'doNormal')) { return $this->doNormal($function_name, $workload, $unique); } else { //older versions of gearman extension return $this->do($function_name, $workload, $unique); } }
[ "public", "function", "doKwf", "(", "$", "function_name", ",", "$", "workload", ",", "$", "unique", "=", "null", ")", "{", "$", "function_name", "=", "$", "this", "->", "_processFunctionName", "(", "$", "function_name", ")", ";", "if", "(", "method_exists", "(", "$", "this", ",", "'doNormal'", ")", ")", "{", "return", "$", "this", "->", "doNormal", "(", "$", "function_name", ",", "$", "workload", ",", "$", "unique", ")", ";", "}", "else", "{", "//older versions of gearman extension", "return", "$", "this", "->", "do", "(", "$", "function_name", ",", "$", "workload", ",", "$", "unique", ")", ";", "}", "}" ]
ACHTUNG immer doKwf statt do verwenden! (do kann leider nicht überschrieben werden)
[ "ACHTUNG", "immer", "doKwf", "statt", "do", "verwenden!", "(", "do", "kann", "leider", "nicht", "überschrieben", "werden", ")" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Util/Gearman/Client.php#L90-L99
koala-framework/koala-framework
Kwf/Util/SessionHandler.php
Kwf_Util_SessionHandler.open
public function open($savePath, $sessionName) { if (!isset($this->_lifeTime)) $this->_lifeTime = intval(ini_get("session.gc_maxlifetime")); if (!isset($this->_refreshTime)) $this->_refreshTime = ceil($this->_lifeTime / 3); $this->_initSessionData = null; $this->_memcache = new Memcache(); if (Kwf_Cache_Simple::$memcacheHost) { $servers = array( array( 'host' => Kwf_Cache_Simple::$memcacheHost, 'port' => Kwf_Cache_Simple::$memcachePort ) ); } else { throw new Kwf_Exception("no memcache configured"); } foreach ($servers as $s) { if (version_compare(phpversion('memcache'), '2.1.0') == -1 || phpversion('memcache')=='2.2.4') { // < 2.1.0 $this->_memcache->addServer($s['host'], $s['port'], true, 1, 1, 1); } else if (version_compare(phpversion('memcache'), '3.0.0') == -1) { // < 3.0.0 $this->_memcache->addServer($s['host'], $s['port'], true, 1, 1, 1, true, null, 10000); } else { $this->_memcache->addServer($s['host'], $s['port'], true, 1, 1, 1); } } return true; }
php
public function open($savePath, $sessionName) { if (!isset($this->_lifeTime)) $this->_lifeTime = intval(ini_get("session.gc_maxlifetime")); if (!isset($this->_refreshTime)) $this->_refreshTime = ceil($this->_lifeTime / 3); $this->_initSessionData = null; $this->_memcache = new Memcache(); if (Kwf_Cache_Simple::$memcacheHost) { $servers = array( array( 'host' => Kwf_Cache_Simple::$memcacheHost, 'port' => Kwf_Cache_Simple::$memcachePort ) ); } else { throw new Kwf_Exception("no memcache configured"); } foreach ($servers as $s) { if (version_compare(phpversion('memcache'), '2.1.0') == -1 || phpversion('memcache')=='2.2.4') { // < 2.1.0 $this->_memcache->addServer($s['host'], $s['port'], true, 1, 1, 1); } else if (version_compare(phpversion('memcache'), '3.0.0') == -1) { // < 3.0.0 $this->_memcache->addServer($s['host'], $s['port'], true, 1, 1, 1, true, null, 10000); } else { $this->_memcache->addServer($s['host'], $s['port'], true, 1, 1, 1); } } return true; }
[ "public", "function", "open", "(", "$", "savePath", ",", "$", "sessionName", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_lifeTime", ")", ")", "$", "this", "->", "_lifeTime", "=", "intval", "(", "ini_get", "(", "\"session.gc_maxlifetime\"", ")", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "_refreshTime", ")", ")", "$", "this", "->", "_refreshTime", "=", "ceil", "(", "$", "this", "->", "_lifeTime", "/", "3", ")", ";", "$", "this", "->", "_initSessionData", "=", "null", ";", "$", "this", "->", "_memcache", "=", "new", "Memcache", "(", ")", ";", "if", "(", "Kwf_Cache_Simple", "::", "$", "memcacheHost", ")", "{", "$", "servers", "=", "array", "(", "array", "(", "'host'", "=>", "Kwf_Cache_Simple", "::", "$", "memcacheHost", ",", "'port'", "=>", "Kwf_Cache_Simple", "::", "$", "memcachePort", ")", ")", ";", "}", "else", "{", "throw", "new", "Kwf_Exception", "(", "\"no memcache configured\"", ")", ";", "}", "foreach", "(", "$", "servers", "as", "$", "s", ")", "{", "if", "(", "version_compare", "(", "phpversion", "(", "'memcache'", ")", ",", "'2.1.0'", ")", "==", "-", "1", "||", "phpversion", "(", "'memcache'", ")", "==", "'2.2.4'", ")", "{", "// < 2.1.0", "$", "this", "->", "_memcache", "->", "addServer", "(", "$", "s", "[", "'host'", "]", ",", "$", "s", "[", "'port'", "]", ",", "true", ",", "1", ",", "1", ",", "1", ")", ";", "}", "else", "if", "(", "version_compare", "(", "phpversion", "(", "'memcache'", ")", ",", "'3.0.0'", ")", "==", "-", "1", ")", "{", "// < 3.0.0", "$", "this", "->", "_memcache", "->", "addServer", "(", "$", "s", "[", "'host'", "]", ",", "$", "s", "[", "'port'", "]", ",", "true", ",", "1", ",", "1", ",", "1", ",", "true", ",", "null", ",", "10000", ")", ";", "}", "else", "{", "$", "this", "->", "_memcache", "->", "addServer", "(", "$", "s", "[", "'host'", "]", ",", "$", "s", "[", "'port'", "]", ",", "true", ",", "1", ",", "1", ",", "1", ")", ";", "}", "}", "return", "true", ";", "}" ]
opening of the session - mandatory arguments won't be needed @param string $savePath @param string $sessionName @return bool
[ "opening", "of", "the", "session", "-", "mandatory", "arguments", "won", "t", "be", "needed" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Util/SessionHandler.php#L57-L86
koala-framework/koala-framework
Kwf/Util/SessionHandler.php
Kwf_Util_SessionHandler.read
function read($sessionId) { $this->_initSessionData = ''; $d = $this->_memcache->get(Kwf_Cache_Simple::getUniquePrefix().'sess-'.$sessionId); if ($d === false) { Kwf_Benchmark::count('sessionhdl', 'load from db'); //the record could not be found in the Memcache, loading from the db $this->_initSessionData = Kwf_Registry::get('db')->query("SELECT data FROM kwf_sessions WHERE sessionId=?", $sessionId)->fetchColumn(); if ($this->_initSessionData) { //record found in the db, cache in memcache self::_updateDbExpiration($sessionId); } else { //record not in the db $this->_initSessionData = ''; } } else { $expiration = $d['expiration']; if ($expiration+$this->_refreshTime < time()) { //expired; nothing to do } else { $this->_initSessionData = $d['data']; //if we didn't write into the db for at least //$this->_refreshTime (5 minutes), we need to refresh the expiration time in the db $ttl = $expiration - time(); if ($ttl < $this->_refreshTime) { self::_updateDbExpiration($sessionId); } } } return $this->_initSessionData; }
php
function read($sessionId) { $this->_initSessionData = ''; $d = $this->_memcache->get(Kwf_Cache_Simple::getUniquePrefix().'sess-'.$sessionId); if ($d === false) { Kwf_Benchmark::count('sessionhdl', 'load from db'); //the record could not be found in the Memcache, loading from the db $this->_initSessionData = Kwf_Registry::get('db')->query("SELECT data FROM kwf_sessions WHERE sessionId=?", $sessionId)->fetchColumn(); if ($this->_initSessionData) { //record found in the db, cache in memcache self::_updateDbExpiration($sessionId); } else { //record not in the db $this->_initSessionData = ''; } } else { $expiration = $d['expiration']; if ($expiration+$this->_refreshTime < time()) { //expired; nothing to do } else { $this->_initSessionData = $d['data']; //if we didn't write into the db for at least //$this->_refreshTime (5 minutes), we need to refresh the expiration time in the db $ttl = $expiration - time(); if ($ttl < $this->_refreshTime) { self::_updateDbExpiration($sessionId); } } } return $this->_initSessionData; }
[ "function", "read", "(", "$", "sessionId", ")", "{", "$", "this", "->", "_initSessionData", "=", "''", ";", "$", "d", "=", "$", "this", "->", "_memcache", "->", "get", "(", "Kwf_Cache_Simple", "::", "getUniquePrefix", "(", ")", ".", "'sess-'", ".", "$", "sessionId", ")", ";", "if", "(", "$", "d", "===", "false", ")", "{", "Kwf_Benchmark", "::", "count", "(", "'sessionhdl'", ",", "'load from db'", ")", ";", "//the record could not be found in the Memcache, loading from the db", "$", "this", "->", "_initSessionData", "=", "Kwf_Registry", "::", "get", "(", "'db'", ")", "->", "query", "(", "\"SELECT data FROM kwf_sessions WHERE sessionId=?\"", ",", "$", "sessionId", ")", "->", "fetchColumn", "(", ")", ";", "if", "(", "$", "this", "->", "_initSessionData", ")", "{", "//record found in the db, cache in memcache", "self", "::", "_updateDbExpiration", "(", "$", "sessionId", ")", ";", "}", "else", "{", "//record not in the db", "$", "this", "->", "_initSessionData", "=", "''", ";", "}", "}", "else", "{", "$", "expiration", "=", "$", "d", "[", "'expiration'", "]", ";", "if", "(", "$", "expiration", "+", "$", "this", "->", "_refreshTime", "<", "time", "(", ")", ")", "{", "//expired; nothing to do", "}", "else", "{", "$", "this", "->", "_initSessionData", "=", "$", "d", "[", "'data'", "]", ";", "//if we didn't write into the db for at least", "//$this->_refreshTime (5 minutes), we need to refresh the expiration time in the db", "$", "ttl", "=", "$", "expiration", "-", "time", "(", ")", ";", "if", "(", "$", "ttl", "<", "$", "this", "->", "_refreshTime", ")", "{", "self", "::", "_updateDbExpiration", "(", "$", "sessionId", ")", ";", "}", "}", "}", "return", "$", "this", "->", "_initSessionData", ";", "}" ]
reading of the session data if the data couldn't be found in the Memcache, we try to load it from the DB we have to update the time of data expiration in the db using _updateDbExpiration() the life time in Memcache is updated automatically by write operation @param string $sessionId @return string
[ "reading", "of", "the", "session", "data", "if", "the", "data", "couldn", "t", "be", "found", "in", "the", "Memcache", "we", "try", "to", "load", "it", "from", "the", "DB", "we", "have", "to", "update", "the", "time", "of", "data", "expiration", "in", "the", "db", "using", "_updateDbExpiration", "()", "the", "life", "time", "in", "Memcache", "is", "updated", "automatically", "by", "write", "operation" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Util/SessionHandler.php#L108-L138
koala-framework/koala-framework
Kwf/Util/SessionHandler.php
Kwf_Util_SessionHandler._updateDbExpiration
private function _updateDbExpiration($sessionId) { Kwf_Benchmark::count('sessionhdl', '_updateDbExpiration'); $expiration = $this->_lifeTime + time(); Kwf_Registry::get('db')->query("UPDATE kwf_sessions SET expiration=? WHERE sessionId=?", array($expiration, $sessionId)); //we store the time of the new expiration into the Memcache $this->_memcacheSet($sessionId, $this->_initSessionData); }
php
private function _updateDbExpiration($sessionId) { Kwf_Benchmark::count('sessionhdl', '_updateDbExpiration'); $expiration = $this->_lifeTime + time(); Kwf_Registry::get('db')->query("UPDATE kwf_sessions SET expiration=? WHERE sessionId=?", array($expiration, $sessionId)); //we store the time of the new expiration into the Memcache $this->_memcacheSet($sessionId, $this->_initSessionData); }
[ "private", "function", "_updateDbExpiration", "(", "$", "sessionId", ")", "{", "Kwf_Benchmark", "::", "count", "(", "'sessionhdl'", ",", "'_updateDbExpiration'", ")", ";", "$", "expiration", "=", "$", "this", "->", "_lifeTime", "+", "time", "(", ")", ";", "Kwf_Registry", "::", "get", "(", "'db'", ")", "->", "query", "(", "\"UPDATE kwf_sessions SET expiration=? WHERE sessionId=?\"", ",", "array", "(", "$", "expiration", ",", "$", "sessionId", ")", ")", ";", "//we store the time of the new expiration into the Memcache", "$", "this", "->", "_memcacheSet", "(", "$", "sessionId", ",", "$", "this", "->", "_initSessionData", ")", ";", "}" ]
update of the expiration time of the db record @param string $sessionId
[ "update", "of", "the", "expiration", "time", "of", "the", "db", "record" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Util/SessionHandler.php#L145-L153
koala-framework/koala-framework
Kwf/Util/SessionHandler.php
Kwf_Util_SessionHandler.write
public function write($sessionId, $data) { $t = microtime(true); $expiration = $this->_lifeTime + time(); //we store time of the db record expiration in the Memcache if ($this->_initSessionData !== $data) { Kwf_Registry::get('db')->query("REPLACE INTO kwf_sessions (sessionId, expiration, data) VALUES(?, ?, ?)", array($sessionId, $expiration, $data)); $this->_memcacheSet($sessionId, $data); } Kwf_Benchmark::count('sessionhdl', 'read: '.((microtime(true)-$t)*1000).'ms'); return true; }
php
public function write($sessionId, $data) { $t = microtime(true); $expiration = $this->_lifeTime + time(); //we store time of the db record expiration in the Memcache if ($this->_initSessionData !== $data) { Kwf_Registry::get('db')->query("REPLACE INTO kwf_sessions (sessionId, expiration, data) VALUES(?, ?, ?)", array($sessionId, $expiration, $data)); $this->_memcacheSet($sessionId, $data); } Kwf_Benchmark::count('sessionhdl', 'read: '.((microtime(true)-$t)*1000).'ms'); return true; }
[ "public", "function", "write", "(", "$", "sessionId", ",", "$", "data", ")", "{", "$", "t", "=", "microtime", "(", "true", ")", ";", "$", "expiration", "=", "$", "this", "->", "_lifeTime", "+", "time", "(", ")", ";", "//we store time of the db record expiration in the Memcache", "if", "(", "$", "this", "->", "_initSessionData", "!==", "$", "data", ")", "{", "Kwf_Registry", "::", "get", "(", "'db'", ")", "->", "query", "(", "\"REPLACE INTO kwf_sessions (sessionId, expiration, data) VALUES(?, ?, ?)\"", ",", "array", "(", "$", "sessionId", ",", "$", "expiration", ",", "$", "data", ")", ")", ";", "$", "this", "->", "_memcacheSet", "(", "$", "sessionId", ",", "$", "data", ")", ";", "}", "Kwf_Benchmark", "::", "count", "(", "'sessionhdl'", ",", "'read: '", ".", "(", "(", "microtime", "(", "true", ")", "-", "$", "t", ")", "*", "1000", ")", ".", "'ms'", ")", ";", "return", "true", ";", "}" ]
cache write - this is called when the script is about to finish, or when session_write_close() is called data are written only when something has changed @param string $sessionId @param string $data @return bool
[ "cache", "write", "-", "this", "is", "called", "when", "the", "script", "is", "about", "to", "finish", "or", "when", "session_write_close", "()", "is", "called", "data", "are", "written", "only", "when", "something", "has", "changed" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Util/SessionHandler.php#L177-L189
koala-framework/koala-framework
Kwf/Util/SessionHandler.php
Kwf_Util_SessionHandler.destroy
public function destroy($sessionId) { $this->_memcache->delete(Kwf_Cache_Simple::getUniquePrefix().'sess-'.$sessionId); $this->_memcache->delete(Kwf_Cache_Simple::getUniquePrefix().'sess-db-'.$sessionId); Kwf_Registry::get('db')->query("DELETE FROM kwf_sessions WHERE sessionId=?", $sessionId); return true; }
php
public function destroy($sessionId) { $this->_memcache->delete(Kwf_Cache_Simple::getUniquePrefix().'sess-'.$sessionId); $this->_memcache->delete(Kwf_Cache_Simple::getUniquePrefix().'sess-db-'.$sessionId); Kwf_Registry::get('db')->query("DELETE FROM kwf_sessions WHERE sessionId=?", $sessionId); return true; }
[ "public", "function", "destroy", "(", "$", "sessionId", ")", "{", "$", "this", "->", "_memcache", "->", "delete", "(", "Kwf_Cache_Simple", "::", "getUniquePrefix", "(", ")", ".", "'sess-'", ".", "$", "sessionId", ")", ";", "$", "this", "->", "_memcache", "->", "delete", "(", "Kwf_Cache_Simple", "::", "getUniquePrefix", "(", ")", ".", "'sess-db-'", ".", "$", "sessionId", ")", ";", "Kwf_Registry", "::", "get", "(", "'db'", ")", "->", "query", "(", "\"DELETE FROM kwf_sessions WHERE sessionId=?\"", ",", "$", "sessionId", ")", ";", "return", "true", ";", "}" ]
destroy of the session @param string $sessionId @return bool
[ "destroy", "of", "the", "session" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Util/SessionHandler.php#L197-L203
koala-framework/koala-framework
Kwf/Util/SessionHandler.php
Kwf_Util_SessionHandler.gc
public function gc($maxlifetime) { foreach (Kwf_Registry::get('db')->query("SELECT sessionId FROM kwf_sessions WHERE expiration < ?", time())->fetchAll() as $r) { $this->destroy($r['sessionId']); } return true; }
php
public function gc($maxlifetime) { foreach (Kwf_Registry::get('db')->query("SELECT sessionId FROM kwf_sessions WHERE expiration < ?", time())->fetchAll() as $r) { $this->destroy($r['sessionId']); } return true; }
[ "public", "function", "gc", "(", "$", "maxlifetime", ")", "{", "foreach", "(", "Kwf_Registry", "::", "get", "(", "'db'", ")", "->", "query", "(", "\"SELECT sessionId FROM kwf_sessions WHERE expiration < ?\"", ",", "time", "(", ")", ")", "->", "fetchAll", "(", ")", "as", "$", "r", ")", "{", "$", "this", "->", "destroy", "(", "$", "r", "[", "'sessionId'", "]", ")", ";", "}", "return", "true", ";", "}" ]
called by the garbage collector @param int $maxlifetime @return bool
[ "called", "by", "the", "garbage", "collector" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Util/SessionHandler.php#L211-L217
koala-framework/koala-framework
Kwf/Component/Abstract/Events.php
Kwf_Component_Abstract_Events._getCreatingClasses
protected function _getCreatingClasses($createdClass, $createClass = null) { $ret = array(); foreach (Kwc_Abstract::getComponentClasses() as $c) { if (!$createClass || in_array($createClass, Kwc_Abstract::getParentClasses($c))) { if (Kwc_Abstract::getChildComponentClasses($c, array('componentClass'=>$createdClass))) { $ret[] = $c; } } } return $ret; }
php
protected function _getCreatingClasses($createdClass, $createClass = null) { $ret = array(); foreach (Kwc_Abstract::getComponentClasses() as $c) { if (!$createClass || in_array($createClass, Kwc_Abstract::getParentClasses($c))) { if (Kwc_Abstract::getChildComponentClasses($c, array('componentClass'=>$createdClass))) { $ret[] = $c; } } } return $ret; }
[ "protected", "function", "_getCreatingClasses", "(", "$", "createdClass", ",", "$", "createClass", "=", "null", ")", "{", "$", "ret", "=", "array", "(", ")", ";", "foreach", "(", "Kwc_Abstract", "::", "getComponentClasses", "(", ")", "as", "$", "c", ")", "{", "if", "(", "!", "$", "createClass", "||", "in_array", "(", "$", "createClass", ",", "Kwc_Abstract", "::", "getParentClasses", "(", "$", "c", ")", ")", ")", "{", "if", "(", "Kwc_Abstract", "::", "getChildComponentClasses", "(", "$", "c", ",", "array", "(", "'componentClass'", "=>", "$", "createdClass", ")", ")", ")", "{", "$", "ret", "[", "]", "=", "$", "c", ";", "}", "}", "}", "return", "$", "ret", ";", "}" ]
Returns all component classes that can create $createdClass. Optionally filtering instances of $createClass.
[ "Returns", "all", "component", "classes", "that", "can", "create", "$createdClass", ".", "Optionally", "filtering", "instances", "of", "$createClass", "." ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Abstract/Events.php#L14-L25
koala-framework/koala-framework
Kwf/Form/Container/Cards.php
Kwf_Form_Container_Cards.setCombobox
public function setCombobox($box) { $this->_combobox = $box; $this->_combobox->setFormName($this->fields->getFormName()); return $this; }
php
public function setCombobox($box) { $this->_combobox = $box; $this->_combobox->setFormName($this->fields->getFormName()); return $this; }
[ "public", "function", "setCombobox", "(", "$", "box", ")", "{", "$", "this", "->", "_combobox", "=", "$", "box", ";", "$", "this", "->", "_combobox", "->", "setFormName", "(", "$", "this", "->", "fields", "->", "getFormName", "(", ")", ")", ";", "return", "$", "this", ";", "}" ]
um zB die combobox durch radios zu ersetzen
[ "um", "zB", "die", "combobox", "durch", "radios", "zu", "ersetzen" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Form/Container/Cards.php#L62-L67
koala-framework/koala-framework
Kwf/Form/Container/Cards.php
Kwf_Form_Container_Cards._processChildren
protected function _processChildren($method, $childField, $row, $postData) { if ($method == 'load') return true; if ($childField === $this->_combobox) return true; //wenn card nicht gewählt, nicht aufrufen $value = isset($postData[$this->_combobox->getFieldName()]) ? $postData[$this->_combobox->getFieldName()] : $this->_combobox->getDefaultValue(); return $childField->getName() == $value; }
php
protected function _processChildren($method, $childField, $row, $postData) { if ($method == 'load') return true; if ($childField === $this->_combobox) return true; //wenn card nicht gewählt, nicht aufrufen $value = isset($postData[$this->_combobox->getFieldName()]) ? $postData[$this->_combobox->getFieldName()] : $this->_combobox->getDefaultValue(); return $childField->getName() == $value; }
[ "protected", "function", "_processChildren", "(", "$", "method", ",", "$", "childField", ",", "$", "row", ",", "$", "postData", ")", "{", "if", "(", "$", "method", "==", "'load'", ")", "return", "true", ";", "if", "(", "$", "childField", "===", "$", "this", "->", "_combobox", ")", "return", "true", ";", "//wenn card nicht gewählt, nicht aufrufen", "$", "value", "=", "isset", "(", "$", "postData", "[", "$", "this", "->", "_combobox", "->", "getFieldName", "(", ")", "]", ")", "?", "$", "postData", "[", "$", "this", "->", "_combobox", "->", "getFieldName", "(", ")", "]", ":", "$", "this", "->", "_combobox", "->", "getDefaultValue", "(", ")", ";", "return", "$", "childField", "->", "getName", "(", ")", "==", "$", "value", ";", "}" ]
verhindert aufrufen von validate/prepareSave/save etc fuer kinder wenn card nicht ausgewählt
[ "verhindert", "aufrufen", "von", "validate", "/", "prepareSave", "/", "save", "etc", "fuer", "kinder", "wenn", "card", "nicht", "ausgewählt" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Form/Container/Cards.php#L121-L129
koala-framework/koala-framework
Kwc/Form/Field/DateField/Component.php
Kwc_Form_Field_DateField_Component.getSubmitMessage
public function getSubmitMessage($row) { $message = ''; if ($this->getFormField()->getFieldLabel()) { $message .= $this->getFormField()->getFieldLabel().': '; } $t = strtotime($row->{$this->getFormField()->getName()}); $message .= date($this->getData()->trlKwf('Y-m-d'), $t); return $message; }
php
public function getSubmitMessage($row) { $message = ''; if ($this->getFormField()->getFieldLabel()) { $message .= $this->getFormField()->getFieldLabel().': '; } $t = strtotime($row->{$this->getFormField()->getName()}); $message .= date($this->getData()->trlKwf('Y-m-d'), $t); return $message; }
[ "public", "function", "getSubmitMessage", "(", "$", "row", ")", "{", "$", "message", "=", "''", ";", "if", "(", "$", "this", "->", "getFormField", "(", ")", "->", "getFieldLabel", "(", ")", ")", "{", "$", "message", ".=", "$", "this", "->", "getFormField", "(", ")", "->", "getFieldLabel", "(", ")", ".", "': '", ";", "}", "$", "t", "=", "strtotime", "(", "$", "row", "->", "{", "$", "this", "->", "getFormField", "(", ")", "->", "getName", "(", ")", "}", ")", ";", "$", "message", ".=", "date", "(", "$", "this", "->", "getData", "(", ")", "->", "trlKwf", "(", "'Y-m-d'", ")", ",", "$", "t", ")", ";", "return", "$", "message", ";", "}" ]
This function is used to return a human-readable string for this field depending on submited data. @param Kwc_Form_Dynamic_Form_MailRow $row @return string
[ "This", "function", "is", "used", "to", "return", "a", "human", "-", "readable", "string", "for", "this", "field", "depending", "on", "submited", "data", "." ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Form/Field/DateField/Component.php#L33-L42
koala-framework/koala-framework
Kwf/Srpc/Handler/Model.php
Kwf_Srpc_Handler_Model.rowSave
public function rowSave($id, $data) { if (!$data || !is_array($data)) return false; if (is_null($id)) { $row = $this->getModel()->createRow(); } else { $row = $this->getModel()->getRow($id); } if (!$row) return false; foreach ($data as $col => $value) { $row->$col = $value; } $row->save(); if ($this->_columns) { $ret = array(); foreach ($this->_columns as $c) { $ret[$c] = $row->$c; } return $ret; } else { return $row->toArray(); } }
php
public function rowSave($id, $data) { if (!$data || !is_array($data)) return false; if (is_null($id)) { $row = $this->getModel()->createRow(); } else { $row = $this->getModel()->getRow($id); } if (!$row) return false; foreach ($data as $col => $value) { $row->$col = $value; } $row->save(); if ($this->_columns) { $ret = array(); foreach ($this->_columns as $c) { $ret[$c] = $row->$c; } return $ret; } else { return $row->toArray(); } }
[ "public", "function", "rowSave", "(", "$", "id", ",", "$", "data", ")", "{", "if", "(", "!", "$", "data", "||", "!", "is_array", "(", "$", "data", ")", ")", "return", "false", ";", "if", "(", "is_null", "(", "$", "id", ")", ")", "{", "$", "row", "=", "$", "this", "->", "getModel", "(", ")", "->", "createRow", "(", ")", ";", "}", "else", "{", "$", "row", "=", "$", "this", "->", "getModel", "(", ")", "->", "getRow", "(", "$", "id", ")", ";", "}", "if", "(", "!", "$", "row", ")", "return", "false", ";", "foreach", "(", "$", "data", "as", "$", "col", "=>", "$", "value", ")", "{", "$", "row", "->", "$", "col", "=", "$", "value", ";", "}", "$", "row", "->", "save", "(", ")", ";", "if", "(", "$", "this", "->", "_columns", ")", "{", "$", "ret", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_columns", "as", "$", "c", ")", "{", "$", "ret", "[", "$", "c", "]", "=", "$", "row", "->", "$", "c", ";", "}", "return", "$", "ret", ";", "}", "else", "{", "return", "$", "row", "->", "toArray", "(", ")", ";", "}", "}" ]
TODO: stattdessen insertRow und updateRow verwenden
[ "TODO", ":", "stattdessen", "insertRow", "und", "updateRow", "verwenden" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Srpc/Handler/Model.php#L91-L117
koala-framework/koala-framework
Kwf/Component/View/Helper/IncludeTemplate.php
Kwf_Component_View_Helper_IncludeTemplate.includeTemplate
public function includeTemplate($name = null, $module = null, $model = null) { $name = Kwc_Abstract::getTemplateFile($this->view->data->componentClass, $name); if (!$module) { $module = $this->view; } return $this->partial($name, $module, $model); }
php
public function includeTemplate($name = null, $module = null, $model = null) { $name = Kwc_Abstract::getTemplateFile($this->view->data->componentClass, $name); if (!$module) { $module = $this->view; } return $this->partial($name, $module, $model); }
[ "public", "function", "includeTemplate", "(", "$", "name", "=", "null", ",", "$", "module", "=", "null", ",", "$", "model", "=", "null", ")", "{", "$", "name", "=", "Kwc_Abstract", "::", "getTemplateFile", "(", "$", "this", "->", "view", "->", "data", "->", "componentClass", ",", "$", "name", ")", ";", "if", "(", "!", "$", "module", ")", "{", "$", "module", "=", "$", "this", "->", "view", ";", "}", "return", "$", "this", "->", "partial", "(", "$", "name", ",", "$", "module", ",", "$", "model", ")", ";", "}" ]
Includes Template for current Component @param string $name Template Name without path and .tpl (e.g. "Mail.html") @param string $module @param string $model
[ "Includes", "Template", "for", "current", "Component" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/View/Helper/IncludeTemplate.php#L11-L16
koala-framework/koala-framework
Kwc/Basic/LinkTag/Phone/Admin.php
Kwc_Basic_LinkTag_Phone_Admin.componentToString
public function componentToString(Kwf_Component_Data $data) { $ret = parent::componentToString($data); $punycode = new Kwf_Util_Punycode(); return $punycode->decode($ret); }
php
public function componentToString(Kwf_Component_Data $data) { $ret = parent::componentToString($data); $punycode = new Kwf_Util_Punycode(); return $punycode->decode($ret); }
[ "public", "function", "componentToString", "(", "Kwf_Component_Data", "$", "data", ")", "{", "$", "ret", "=", "parent", "::", "componentToString", "(", "$", "data", ")", ";", "$", "punycode", "=", "new", "Kwf_Util_Punycode", "(", ")", ";", "return", "$", "punycode", "->", "decode", "(", "$", "ret", ")", ";", "}" ]
wird bei linklist verwendet, damit url richtig ausgegeben wird
[ "wird", "bei", "linklist", "verwendet", "damit", "url", "richtig", "ausgegeben", "wird" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Basic/LinkTag/Phone/Admin.php#L5-L10
koala-framework/koala-framework
Kwf/Assets/Package/Default.php
Kwf_Assets_Package_Default.getInstance
public static function getInstance($dependencyName) { if (!isset(self::$_instances[$dependencyName])) { self::$_instances[$dependencyName] = new self($dependencyName); } return self::$_instances[$dependencyName]; }
php
public static function getInstance($dependencyName) { if (!isset(self::$_instances[$dependencyName])) { self::$_instances[$dependencyName] = new self($dependencyName); } return self::$_instances[$dependencyName]; }
[ "public", "static", "function", "getInstance", "(", "$", "dependencyName", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "_instances", "[", "$", "dependencyName", "]", ")", ")", "{", "self", "::", "$", "_instances", "[", "$", "dependencyName", "]", "=", "new", "self", "(", "$", "dependencyName", ")", ";", "}", "return", "self", "::", "$", "_instances", "[", "$", "dependencyName", "]", ";", "}" ]
Returns a Default Asset Package (using Kwf_Assets_ProviderList_Default) Very fast, as all expensive operations are done lazily @return self
[ "Returns", "a", "Default", "Asset", "Package", "(", "using", "Kwf_Assets_ProviderList_Default", ")" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Assets/Package/Default.php#L13-L19
koala-framework/koala-framework
Kwf/Form/Field/Abstract.php
Kwf_Form_Field_Abstract.setProperty
public function setProperty($name, $value) { if (is_null($value)) { unset($this->_properties[$name]); } else { $this->_properties[$name] = $value; } return $this; }
php
public function setProperty($name, $value) { if (is_null($value)) { unset($this->_properties[$name]); } else { $this->_properties[$name] = $value; } return $this; }
[ "public", "function", "setProperty", "(", "$", "name", ",", "$", "value", ")", "{", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "unset", "(", "$", "this", "->", "_properties", "[", "$", "name", "]", ")", ";", "}", "else", "{", "$", "this", "->", "_properties", "[", "$", "name", "]", "=", "$", "value", ";", "}", "return", "$", "this", ";", "}" ]
Set any property supported by ExtJS for this field Alternatively use setFooBar() to set property fooBar
[ "Set", "any", "property", "supported", "by", "ExtJS", "for", "this", "field" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Form/Field/Abstract.php#L97-L105
koala-framework/koala-framework
Kwf/Form/Field/Abstract.php
Kwf_Form_Field_Abstract.getFieldName
public function getFieldName() { $ret = $this->getName(); if ($this->getNamePrefix()) { $ret = $this->getNamePrefix() . '_' . $ret; } return $ret; }
php
public function getFieldName() { $ret = $this->getName(); if ($this->getNamePrefix()) { $ret = $this->getNamePrefix() . '_' . $ret; } return $ret; }
[ "public", "function", "getFieldName", "(", ")", "{", "$", "ret", "=", "$", "this", "->", "getName", "(", ")", ";", "if", "(", "$", "this", "->", "getNamePrefix", "(", ")", ")", "{", "$", "ret", "=", "$", "this", "->", "getNamePrefix", "(", ")", ".", "'_'", ".", "$", "ret", ";", "}", "return", "$", "ret", ";", "}" ]
returns the fully qualified field name, different to getName when using form in form @return string
[ "returns", "the", "fully", "qualified", "field", "name", "different", "to", "getName", "when", "using", "form", "in", "form" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Form/Field/Abstract.php#L251-L258
koala-framework/koala-framework
Kwf/Util/Model/Feed/Feeds.php
Kwf_Util_Model_Feed_Feeds.findFeeds
public function findFeeds($uri) { $client = new Zend_Http_Client($uri); $response = $client->request(); if ($response->getStatus() != 200) { throw new Kwf_Exception("invalid status response"); } $contents = $response->getBody(); // Parse the contents for appropriate <link ... /> tags @ini_set('track_errors', 1); $pattern = '~(<link[^>]+)/?>~i'; $result = @preg_match_all($pattern, $contents, $matches); @ini_restore('track_errors'); if ($result === false) { throw new Zend_Feed_Exception("Internal error: $php_errormsg"); } // Try to fetch a feed for each link tag that appears to refer to a feed $feeds = array(); if (isset($matches[1]) && count($matches[1]) > 0) { foreach ($matches[1] as $link) { // force string to be an utf-8 one if (!mb_check_encoding($link, 'UTF-8')) { $link = mb_convert_encoding($link, 'UTF-8'); } $link = html_entity_decode($link, ENT_QUOTES, "utf-8"); $entityLoaderWasDisabled = libxml_disable_entity_loader(true); $xml = @simplexml_load_string(rtrim($link, ' /') . ' />'); libxml_disable_entity_loader($entityLoaderWasDisabled); if ($xml === false) { $link = preg_replace('#&(?=[a-z_0-9]+=)#', '&amp;', $link); $link = str_replace('& ', '&amp; ', $link); $entityLoaderWasDisabled = libxml_disable_entity_loader(true); $xml = @simplexml_load_string(rtrim($link, ' /') . ' />'); libxml_disable_entity_loader($entityLoaderWasDisabled); if ($xml === false) { continue; } } $attributes = $xml->attributes(); if (!isset($attributes['rel']) || !@preg_match('~^(?:alternate|service\.feed)~i', $attributes['rel'])) { continue; } $type = false; if (isset($attributes['type'])) { $type = $attributes['type']; } else if (isset($attributes['TYPE'])) { $type = $attributes['TYPE']; } if (!$type || !@preg_match('~^application/(?:atom|rss|rdf)\+xml~', $type)) { continue; } if (!isset($attributes['href'])) { continue; } try { // checks if we need to canonize the given uri try { $uri = Zend_Uri::factory((string) $attributes['href']); } catch (Zend_Uri_Exception $e) { // canonize the uri $pageUri = Zend_Uri::factory($uri); $path = (string) $attributes['href']; $query = $fragment = ''; if (substr($path, 0, 1) != '/') { // add the current root path to this one $path = rtrim($pageUri->getPath(), '/') . '/' . $path; } if (strpos($path, '?') !== false) { list($path, $query) = explode('?', $path, 2); } if (strpos($query, '#') !== false) { list($query, $fragment) = explode('#', $query, 2); } $uri = Zend_Uri::factory($pageUri->__toString()); $uri->setPath($path); $uri->setQuery($query); $uri->setFragment($fragment); } } catch (Exception $e) { continue; } $title = ''; if (isset($attributes['title'])) { $title = (string)$attributes['title']; } $feeds[(string)$uri] = $title; } } // Return the fetched feeds return $feeds; }
php
public function findFeeds($uri) { $client = new Zend_Http_Client($uri); $response = $client->request(); if ($response->getStatus() != 200) { throw new Kwf_Exception("invalid status response"); } $contents = $response->getBody(); // Parse the contents for appropriate <link ... /> tags @ini_set('track_errors', 1); $pattern = '~(<link[^>]+)/?>~i'; $result = @preg_match_all($pattern, $contents, $matches); @ini_restore('track_errors'); if ($result === false) { throw new Zend_Feed_Exception("Internal error: $php_errormsg"); } // Try to fetch a feed for each link tag that appears to refer to a feed $feeds = array(); if (isset($matches[1]) && count($matches[1]) > 0) { foreach ($matches[1] as $link) { // force string to be an utf-8 one if (!mb_check_encoding($link, 'UTF-8')) { $link = mb_convert_encoding($link, 'UTF-8'); } $link = html_entity_decode($link, ENT_QUOTES, "utf-8"); $entityLoaderWasDisabled = libxml_disable_entity_loader(true); $xml = @simplexml_load_string(rtrim($link, ' /') . ' />'); libxml_disable_entity_loader($entityLoaderWasDisabled); if ($xml === false) { $link = preg_replace('#&(?=[a-z_0-9]+=)#', '&amp;', $link); $link = str_replace('& ', '&amp; ', $link); $entityLoaderWasDisabled = libxml_disable_entity_loader(true); $xml = @simplexml_load_string(rtrim($link, ' /') . ' />'); libxml_disable_entity_loader($entityLoaderWasDisabled); if ($xml === false) { continue; } } $attributes = $xml->attributes(); if (!isset($attributes['rel']) || !@preg_match('~^(?:alternate|service\.feed)~i', $attributes['rel'])) { continue; } $type = false; if (isset($attributes['type'])) { $type = $attributes['type']; } else if (isset($attributes['TYPE'])) { $type = $attributes['TYPE']; } if (!$type || !@preg_match('~^application/(?:atom|rss|rdf)\+xml~', $type)) { continue; } if (!isset($attributes['href'])) { continue; } try { // checks if we need to canonize the given uri try { $uri = Zend_Uri::factory((string) $attributes['href']); } catch (Zend_Uri_Exception $e) { // canonize the uri $pageUri = Zend_Uri::factory($uri); $path = (string) $attributes['href']; $query = $fragment = ''; if (substr($path, 0, 1) != '/') { // add the current root path to this one $path = rtrim($pageUri->getPath(), '/') . '/' . $path; } if (strpos($path, '?') !== false) { list($path, $query) = explode('?', $path, 2); } if (strpos($query, '#') !== false) { list($query, $fragment) = explode('#', $query, 2); } $uri = Zend_Uri::factory($pageUri->__toString()); $uri->setPath($path); $uri->setQuery($query); $uri->setFragment($fragment); } } catch (Exception $e) { continue; } $title = ''; if (isset($attributes['title'])) { $title = (string)$attributes['title']; } $feeds[(string)$uri] = $title; } } // Return the fetched feeds return $feeds; }
[ "public", "function", "findFeeds", "(", "$", "uri", ")", "{", "$", "client", "=", "new", "Zend_Http_Client", "(", "$", "uri", ")", ";", "$", "response", "=", "$", "client", "->", "request", "(", ")", ";", "if", "(", "$", "response", "->", "getStatus", "(", ")", "!=", "200", ")", "{", "throw", "new", "Kwf_Exception", "(", "\"invalid status response\"", ")", ";", "}", "$", "contents", "=", "$", "response", "->", "getBody", "(", ")", ";", "// Parse the contents for appropriate <link ... /> tags", "@", "ini_set", "(", "'track_errors'", ",", "1", ")", ";", "$", "pattern", "=", "'~(<link[^>]+)/?>~i'", ";", "$", "result", "=", "@", "preg_match_all", "(", "$", "pattern", ",", "$", "contents", ",", "$", "matches", ")", ";", "@", "ini_restore", "(", "'track_errors'", ")", ";", "if", "(", "$", "result", "===", "false", ")", "{", "throw", "new", "Zend_Feed_Exception", "(", "\"Internal error: $php_errormsg\"", ")", ";", "}", "// Try to fetch a feed for each link tag that appears to refer to a feed", "$", "feeds", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "matches", "[", "1", "]", ")", "&&", "count", "(", "$", "matches", "[", "1", "]", ")", ">", "0", ")", "{", "foreach", "(", "$", "matches", "[", "1", "]", "as", "$", "link", ")", "{", "// force string to be an utf-8 one", "if", "(", "!", "mb_check_encoding", "(", "$", "link", ",", "'UTF-8'", ")", ")", "{", "$", "link", "=", "mb_convert_encoding", "(", "$", "link", ",", "'UTF-8'", ")", ";", "}", "$", "link", "=", "html_entity_decode", "(", "$", "link", ",", "ENT_QUOTES", ",", "\"utf-8\"", ")", ";", "$", "entityLoaderWasDisabled", "=", "libxml_disable_entity_loader", "(", "true", ")", ";", "$", "xml", "=", "@", "simplexml_load_string", "(", "rtrim", "(", "$", "link", ",", "' /'", ")", ".", "' />'", ")", ";", "libxml_disable_entity_loader", "(", "$", "entityLoaderWasDisabled", ")", ";", "if", "(", "$", "xml", "===", "false", ")", "{", "$", "link", "=", "preg_replace", "(", "'#&(?=[a-z_0-9]+=)#'", ",", "'&amp;'", ",", "$", "link", ")", ";", "$", "link", "=", "str_replace", "(", "'& '", ",", "'&amp; '", ",", "$", "link", ")", ";", "$", "entityLoaderWasDisabled", "=", "libxml_disable_entity_loader", "(", "true", ")", ";", "$", "xml", "=", "@", "simplexml_load_string", "(", "rtrim", "(", "$", "link", ",", "' /'", ")", ".", "' />'", ")", ";", "libxml_disable_entity_loader", "(", "$", "entityLoaderWasDisabled", ")", ";", "if", "(", "$", "xml", "===", "false", ")", "{", "continue", ";", "}", "}", "$", "attributes", "=", "$", "xml", "->", "attributes", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "attributes", "[", "'rel'", "]", ")", "||", "!", "@", "preg_match", "(", "'~^(?:alternate|service\\.feed)~i'", ",", "$", "attributes", "[", "'rel'", "]", ")", ")", "{", "continue", ";", "}", "$", "type", "=", "false", ";", "if", "(", "isset", "(", "$", "attributes", "[", "'type'", "]", ")", ")", "{", "$", "type", "=", "$", "attributes", "[", "'type'", "]", ";", "}", "else", "if", "(", "isset", "(", "$", "attributes", "[", "'TYPE'", "]", ")", ")", "{", "$", "type", "=", "$", "attributes", "[", "'TYPE'", "]", ";", "}", "if", "(", "!", "$", "type", "||", "!", "@", "preg_match", "(", "'~^application/(?:atom|rss|rdf)\\+xml~'", ",", "$", "type", ")", ")", "{", "continue", ";", "}", "if", "(", "!", "isset", "(", "$", "attributes", "[", "'href'", "]", ")", ")", "{", "continue", ";", "}", "try", "{", "// checks if we need to canonize the given uri", "try", "{", "$", "uri", "=", "Zend_Uri", "::", "factory", "(", "(", "string", ")", "$", "attributes", "[", "'href'", "]", ")", ";", "}", "catch", "(", "Zend_Uri_Exception", "$", "e", ")", "{", "// canonize the uri", "$", "pageUri", "=", "Zend_Uri", "::", "factory", "(", "$", "uri", ")", ";", "$", "path", "=", "(", "string", ")", "$", "attributes", "[", "'href'", "]", ";", "$", "query", "=", "$", "fragment", "=", "''", ";", "if", "(", "substr", "(", "$", "path", ",", "0", ",", "1", ")", "!=", "'/'", ")", "{", "// add the current root path to this one", "$", "path", "=", "rtrim", "(", "$", "pageUri", "->", "getPath", "(", ")", ",", "'/'", ")", ".", "'/'", ".", "$", "path", ";", "}", "if", "(", "strpos", "(", "$", "path", ",", "'?'", ")", "!==", "false", ")", "{", "list", "(", "$", "path", ",", "$", "query", ")", "=", "explode", "(", "'?'", ",", "$", "path", ",", "2", ")", ";", "}", "if", "(", "strpos", "(", "$", "query", ",", "'#'", ")", "!==", "false", ")", "{", "list", "(", "$", "query", ",", "$", "fragment", ")", "=", "explode", "(", "'#'", ",", "$", "query", ",", "2", ")", ";", "}", "$", "uri", "=", "Zend_Uri", "::", "factory", "(", "$", "pageUri", "->", "__toString", "(", ")", ")", ";", "$", "uri", "->", "setPath", "(", "$", "path", ")", ";", "$", "uri", "->", "setQuery", "(", "$", "query", ")", ";", "$", "uri", "->", "setFragment", "(", "$", "fragment", ")", ";", "}", "}", "catch", "(", "Exception", "$", "e", ")", "{", "continue", ";", "}", "$", "title", "=", "''", ";", "if", "(", "isset", "(", "$", "attributes", "[", "'title'", "]", ")", ")", "{", "$", "title", "=", "(", "string", ")", "$", "attributes", "[", "'title'", "]", ";", "}", "$", "feeds", "[", "(", "string", ")", "$", "uri", "]", "=", "$", "title", ";", "}", "}", "// Return the fetched feeds", "return", "$", "feeds", ";", "}" ]
und so umgebaut dass kein Http_Client verwendet wird
[ "und", "so", "umgebaut", "dass", "kein", "Http_Client", "verwendet", "wird" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Util/Model/Feed/Feeds.php#L60-L152
koala-framework/koala-framework
Kwf/Util/Model/Feed/Entries.php
Kwf_Util_Model_Feed_Entries._getFeedEntries
public function _getFeedEntries($parentRow, $xml, $select = array()) { $select = $this->select($select); $pId = $parentRow->getInternalId(); $this->_data[$pId] = array(); if ($parentRow->format == Kwf_Util_Model_Feed_Row_Feed::FORMAT_RSS) { if (in_array('http://purl.org/rss/1.0/', $xml->getNamespaces(true))) { $xml->registerXPathNamespace('rss', 'http://purl.org/rss/1.0/'); foreach ($xml->xpath('//rss:item') as $item) { $this->_data[$pId][] = $item; if (($l = $select->getPart(Kwf_Model_Select::LIMIT_COUNT)) && count($this->_data[$pId]) == $l) { break; } } } else { foreach ($xml->channel->item as $item) { $this->_data[$pId][] = $item; if (($l = $select->getPart(Kwf_Model_Select::LIMIT_COUNT)) && count($this->_data[$pId]) == $l) { break; } } } } else { foreach ($xml->entry as $item) { $this->_data[$pId][] = $item; if (($l = $select->getPart(Kwf_Model_Select::LIMIT_COUNT)) && count($this->_data[$pId]) == $l) { break; } } } return new $this->_rowsetClass(array( 'model' => $this, 'dataKeys' => array_keys($this->_data[$pId]), 'parentRow' => $parentRow )); }
php
public function _getFeedEntries($parentRow, $xml, $select = array()) { $select = $this->select($select); $pId = $parentRow->getInternalId(); $this->_data[$pId] = array(); if ($parentRow->format == Kwf_Util_Model_Feed_Row_Feed::FORMAT_RSS) { if (in_array('http://purl.org/rss/1.0/', $xml->getNamespaces(true))) { $xml->registerXPathNamespace('rss', 'http://purl.org/rss/1.0/'); foreach ($xml->xpath('//rss:item') as $item) { $this->_data[$pId][] = $item; if (($l = $select->getPart(Kwf_Model_Select::LIMIT_COUNT)) && count($this->_data[$pId]) == $l) { break; } } } else { foreach ($xml->channel->item as $item) { $this->_data[$pId][] = $item; if (($l = $select->getPart(Kwf_Model_Select::LIMIT_COUNT)) && count($this->_data[$pId]) == $l) { break; } } } } else { foreach ($xml->entry as $item) { $this->_data[$pId][] = $item; if (($l = $select->getPart(Kwf_Model_Select::LIMIT_COUNT)) && count($this->_data[$pId]) == $l) { break; } } } return new $this->_rowsetClass(array( 'model' => $this, 'dataKeys' => array_keys($this->_data[$pId]), 'parentRow' => $parentRow )); }
[ "public", "function", "_getFeedEntries", "(", "$", "parentRow", ",", "$", "xml", ",", "$", "select", "=", "array", "(", ")", ")", "{", "$", "select", "=", "$", "this", "->", "select", "(", "$", "select", ")", ";", "$", "pId", "=", "$", "parentRow", "->", "getInternalId", "(", ")", ";", "$", "this", "->", "_data", "[", "$", "pId", "]", "=", "array", "(", ")", ";", "if", "(", "$", "parentRow", "->", "format", "==", "Kwf_Util_Model_Feed_Row_Feed", "::", "FORMAT_RSS", ")", "{", "if", "(", "in_array", "(", "'http://purl.org/rss/1.0/'", ",", "$", "xml", "->", "getNamespaces", "(", "true", ")", ")", ")", "{", "$", "xml", "->", "registerXPathNamespace", "(", "'rss'", ",", "'http://purl.org/rss/1.0/'", ")", ";", "foreach", "(", "$", "xml", "->", "xpath", "(", "'//rss:item'", ")", "as", "$", "item", ")", "{", "$", "this", "->", "_data", "[", "$", "pId", "]", "[", "]", "=", "$", "item", ";", "if", "(", "(", "$", "l", "=", "$", "select", "->", "getPart", "(", "Kwf_Model_Select", "::", "LIMIT_COUNT", ")", ")", "&&", "count", "(", "$", "this", "->", "_data", "[", "$", "pId", "]", ")", "==", "$", "l", ")", "{", "break", ";", "}", "}", "}", "else", "{", "foreach", "(", "$", "xml", "->", "channel", "->", "item", "as", "$", "item", ")", "{", "$", "this", "->", "_data", "[", "$", "pId", "]", "[", "]", "=", "$", "item", ";", "if", "(", "(", "$", "l", "=", "$", "select", "->", "getPart", "(", "Kwf_Model_Select", "::", "LIMIT_COUNT", ")", ")", "&&", "count", "(", "$", "this", "->", "_data", "[", "$", "pId", "]", ")", "==", "$", "l", ")", "{", "break", ";", "}", "}", "}", "}", "else", "{", "foreach", "(", "$", "xml", "->", "entry", "as", "$", "item", ")", "{", "$", "this", "->", "_data", "[", "$", "pId", "]", "[", "]", "=", "$", "item", ";", "if", "(", "(", "$", "l", "=", "$", "select", "->", "getPart", "(", "Kwf_Model_Select", "::", "LIMIT_COUNT", ")", ")", "&&", "count", "(", "$", "this", "->", "_data", "[", "$", "pId", "]", ")", "==", "$", "l", ")", "{", "break", ";", "}", "}", "}", "return", "new", "$", "this", "->", "_rowsetClass", "(", "array", "(", "'model'", "=>", "$", "this", ",", "'dataKeys'", "=>", "array_keys", "(", "$", "this", "->", "_data", "[", "$", "pId", "]", ")", ",", "'parentRow'", "=>", "$", "parentRow", ")", ")", ";", "}" ]
"darf" nur von Kwf_Util_Model_Feed_Row_Feed aufgerufen werden!
[ "darf", "nur", "von", "Kwf_Util_Model_Feed_Row_Feed", "aufgerufen", "werden!" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Util/Model/Feed/Entries.php#L37-L81
koala-framework/koala-framework
Kwf/Form/Field/Radio.php
Kwf_Form_Field_Radio.getMetaData
public function getMetaData($model) { $ret = parent::getMetaData($model); unset($ret['store']); unset($ret['editable']); unset($ret['triggerAction']); if (isset($ret['outputType']) && $ret['outputType'] == 'vertical') { unset($ret['outputType']); if (!$this->getColumns()) { //set the default value for columns to 1, otherwise the radio buttons would be displayed in a row $ret['columns'] = 1; } $ret['vertical'] = true; } else { $ret['vertical'] = false; } $store = $this->_getStoreData(); if (!isset($store['data'])) { throw new Kwf_Exception("No data set for radio field '{$this->getName()}'"); } foreach ($store['data'] as $d) { $id = $d[0]; $value = $d[1]; $ret['items'][] = array( 'name' => $this->getFieldName(), 'boxLabel' => $value, 'inputValue' => $id ); } return $ret; }
php
public function getMetaData($model) { $ret = parent::getMetaData($model); unset($ret['store']); unset($ret['editable']); unset($ret['triggerAction']); if (isset($ret['outputType']) && $ret['outputType'] == 'vertical') { unset($ret['outputType']); if (!$this->getColumns()) { //set the default value for columns to 1, otherwise the radio buttons would be displayed in a row $ret['columns'] = 1; } $ret['vertical'] = true; } else { $ret['vertical'] = false; } $store = $this->_getStoreData(); if (!isset($store['data'])) { throw new Kwf_Exception("No data set for radio field '{$this->getName()}'"); } foreach ($store['data'] as $d) { $id = $d[0]; $value = $d[1]; $ret['items'][] = array( 'name' => $this->getFieldName(), 'boxLabel' => $value, 'inputValue' => $id ); } return $ret; }
[ "public", "function", "getMetaData", "(", "$", "model", ")", "{", "$", "ret", "=", "parent", "::", "getMetaData", "(", "$", "model", ")", ";", "unset", "(", "$", "ret", "[", "'store'", "]", ")", ";", "unset", "(", "$", "ret", "[", "'editable'", "]", ")", ";", "unset", "(", "$", "ret", "[", "'triggerAction'", "]", ")", ";", "if", "(", "isset", "(", "$", "ret", "[", "'outputType'", "]", ")", "&&", "$", "ret", "[", "'outputType'", "]", "==", "'vertical'", ")", "{", "unset", "(", "$", "ret", "[", "'outputType'", "]", ")", ";", "if", "(", "!", "$", "this", "->", "getColumns", "(", ")", ")", "{", "//set the default value for columns to 1, otherwise the radio buttons would be displayed in a row", "$", "ret", "[", "'columns'", "]", "=", "1", ";", "}", "$", "ret", "[", "'vertical'", "]", "=", "true", ";", "}", "else", "{", "$", "ret", "[", "'vertical'", "]", "=", "false", ";", "}", "$", "store", "=", "$", "this", "->", "_getStoreData", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "store", "[", "'data'", "]", ")", ")", "{", "throw", "new", "Kwf_Exception", "(", "\"No data set for radio field '{$this->getName()}'\"", ")", ";", "}", "foreach", "(", "$", "store", "[", "'data'", "]", "as", "$", "d", ")", "{", "$", "id", "=", "$", "d", "[", "0", "]", ";", "$", "value", "=", "$", "d", "[", "1", "]", ";", "$", "ret", "[", "'items'", "]", "[", "]", "=", "array", "(", "'name'", "=>", "$", "this", "->", "getFieldName", "(", ")", ",", "'boxLabel'", "=>", "$", "value", ",", "'inputValue'", "=>", "$", "id", ")", ";", "}", "return", "$", "ret", ";", "}" ]
setColumns()
[ "setColumns", "()" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Form/Field/Radio.php#L22-L52
koala-framework/koala-framework
Kwf/Collection.php
Kwf_Collection.offsetExists
public function offsetExists($offset) { foreach ($this->_array as $v) { if ($ret = $v->getByName($offset)) { return true; } } return false; }
php
public function offsetExists($offset) { foreach ($this->_array as $v) { if ($ret = $v->getByName($offset)) { return true; } } return false; }
[ "public", "function", "offsetExists", "(", "$", "offset", ")", "{", "foreach", "(", "$", "this", "->", "_array", "as", "$", "v", ")", "{", "if", "(", "$", "ret", "=", "$", "v", "->", "getByName", "(", "$", "offset", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
ArrayAccess
[ "ArrayAccess" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Collection.php#L31-L39
koala-framework/koala-framework
Kwf/Collection.php
Kwf_Collection.offsetUnset
public function offsetUnset($offset) { foreach ($this->_array as $k=>$v) { if ($ret = $v->getByName($offset)) { unset($this->_array[$k]); $this->_array = array_values($this->_array); return; } } throw new Kwf_Exception("Offset '$offset' not found"); }
php
public function offsetUnset($offset) { foreach ($this->_array as $k=>$v) { if ($ret = $v->getByName($offset)) { unset($this->_array[$k]); $this->_array = array_values($this->_array); return; } } throw new Kwf_Exception("Offset '$offset' not found"); }
[ "public", "function", "offsetUnset", "(", "$", "offset", ")", "{", "foreach", "(", "$", "this", "->", "_array", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "$", "ret", "=", "$", "v", "->", "getByName", "(", "$", "offset", ")", ")", "{", "unset", "(", "$", "this", "->", "_array", "[", "$", "k", "]", ")", ";", "$", "this", "->", "_array", "=", "array_values", "(", "$", "this", "->", "_array", ")", ";", "return", ";", "}", "}", "throw", "new", "Kwf_Exception", "(", "\"Offset '$offset' not found\"", ")", ";", "}" ]
ArrayAccess
[ "ArrayAccess" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Collection.php#L75-L85
koala-framework/koala-framework
Kwc/Basic/ImageEnlarge/EnlargeTag/Trl/Component.php
Kwc_Basic_ImageEnlarge_EnlargeTag_Trl_Component.getImageDimensions
public function getImageDimensions() { $dimension = $this->getData()->chained->getComponent()->_getSetting('dimension'); if ($this->getData()->chained->getComponent()->getRow()->use_crop) { $parentDimensions = $this->_getImageEnlargeComponent()->getImageDimensions(); $dimension['crop'] = $parentDimensions['crop']; } $data = $this->getImageData(); return Kwf_Media_Image::calculateScaleDimensions($data['file'], $dimension); }
php
public function getImageDimensions() { $dimension = $this->getData()->chained->getComponent()->_getSetting('dimension'); if ($this->getData()->chained->getComponent()->getRow()->use_crop) { $parentDimensions = $this->_getImageEnlargeComponent()->getImageDimensions(); $dimension['crop'] = $parentDimensions['crop']; } $data = $this->getImageData(); return Kwf_Media_Image::calculateScaleDimensions($data['file'], $dimension); }
[ "public", "function", "getImageDimensions", "(", ")", "{", "$", "dimension", "=", "$", "this", "->", "getData", "(", ")", "->", "chained", "->", "getComponent", "(", ")", "->", "_getSetting", "(", "'dimension'", ")", ";", "if", "(", "$", "this", "->", "getData", "(", ")", "->", "chained", "->", "getComponent", "(", ")", "->", "getRow", "(", ")", "->", "use_crop", ")", "{", "$", "parentDimensions", "=", "$", "this", "->", "_getImageEnlargeComponent", "(", ")", "->", "getImageDimensions", "(", ")", ";", "$", "dimension", "[", "'crop'", "]", "=", "$", "parentDimensions", "[", "'crop'", "]", ";", "}", "$", "data", "=", "$", "this", "->", "getImageData", "(", ")", ";", "return", "Kwf_Media_Image", "::", "calculateScaleDimensions", "(", "$", "data", "[", "'file'", "]", ",", "$", "dimension", ")", ";", "}" ]
This function is called by Kwc_Basic_ImageEnlarge_EnlargeTag_ImagePage_Trl_Component
[ "This", "function", "is", "called", "by", "Kwc_Basic_ImageEnlarge_EnlargeTag_ImagePage_Trl_Component" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Basic/ImageEnlarge/EnlargeTag/Trl/Component.php#L49-L58
koala-framework/koala-framework
Kwc/Basic/ImageEnlarge/EnlargeTag/Trl/Component.php
Kwc_Basic_ImageEnlarge_EnlargeTag_Trl_Component.getImageUrl
public function getImageUrl() { $dimensions = $this->getImageDimensions(); $baseUrl = $this->getBaseImageUrl(); if ($baseUrl) { return str_replace('{width}', $dimensions['width'], $this->getBaseImageUrl()); } return null; }
php
public function getImageUrl() { $dimensions = $this->getImageDimensions(); $baseUrl = $this->getBaseImageUrl(); if ($baseUrl) { return str_replace('{width}', $dimensions['width'], $this->getBaseImageUrl()); } return null; }
[ "public", "function", "getImageUrl", "(", ")", "{", "$", "dimensions", "=", "$", "this", "->", "getImageDimensions", "(", ")", ";", "$", "baseUrl", "=", "$", "this", "->", "getBaseImageUrl", "(", ")", ";", "if", "(", "$", "baseUrl", ")", "{", "return", "str_replace", "(", "'{width}'", ",", "$", "dimensions", "[", "'width'", "]", ",", "$", "this", "->", "getBaseImageUrl", "(", ")", ")", ";", "}", "return", "null", ";", "}" ]
This function is called by Kwc_Basic_ImageEnlarge_EnlargeTag_ImagePage_Trl_Component
[ "This", "function", "is", "called", "by", "Kwc_Basic_ImageEnlarge_EnlargeTag_ImagePage_Trl_Component" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Basic/ImageEnlarge/EnlargeTag/Trl/Component.php#L73-L81
koala-framework/koala-framework
Kwf/Controller/Action/Cli/Web/ComponentPagesMetaController.php
Kwf_Controller_Action_Cli_Web_ComponentPagesMetaController.rebuildWorkerAction
public function rebuildWorkerAction() { set_time_limit(0); Kwf_Util_MemoryLimit::set(512); $queueFile = 'temp/pagemetaRebuildQueue'; $statsFile = 'temp/pagemetaRebuildStats'; $stats = unserialize(file_get_contents($statsFile)); while (true) { //child process //echo "memory_usage (child): ".(memory_get_usage()/(1024*1024))."MB\n"; if (memory_get_usage() > 128*1024*1024) { if ($this->_getParam('debug')) echo "new process...\n"; break; } $queue = file_get_contents($queueFile); if (!$queue) break; $queue = explode("\n", $queue); if ($this->_getParam('debug')) echo "queued: ".count($queue).' :: '.round(memory_get_usage()/1024/1024, 2)."MB\n"; $componentId = array_pop($queue); file_put_contents($queueFile, implode("\n", $queue)); $stats['pages']++; if ($this->_getParam('debug')) echo "==> ".$componentId; $page = Kwf_Component_Data_Root::getInstance()->getComponentById($componentId); if (!$page) { if ($this->_getParam('debug')) echo "$componentId not found!\n"; continue; } if ($this->_getParam('debug')) echo " :: $page->url\n"; if ($this->_getParam('verbose')) echo "getting child pages..."; $childPages = $page->getChildPseudoPages( array('pageGenerator' => false), array('pseudoPage'=>false, 'unique'=>false) //don't recurse into unique boxes, causes endless recursion if box creates page ); $childPages = array_merge($childPages, $page->getChildPseudoPages( array('pageGenerator' => true), array('pseudoPage'=>false) )); if ($this->_getParam('verbose')) echo " done\n"; foreach ($childPages as $c) { if ($this->_getParam('verbose')) echo "queued $c->componentId\n"; $queue[] = $c->componentId; file_put_contents($queueFile, implode("\n", $queue)); } unset($c); $pageId = $page->componentId; unset($page); if ($this->_getParam('debug')) { //echo round(memory_get_usage()/1024/1024, 2)."MB"; //echo " gen: ".Kwf_Component_Generator_Abstract::$objectsCount.', '; //echo " data: ".Kwf_Component_Data::$objectsCount.', '; //echo " row: ".Kwf_Model_Row_Abstract::$objectsCount.''; } //Kwf_Component_Data_Root::getInstance()->freeMemory(); if ($this->_getParam('debug')) { //echo ' / '.round(memory_get_usage()/1024/1024, 2)."MB"; //echo " gen: ".Kwf_Component_Generator_Abstract::$objectsCount.', '; //echo " data: ".Kwf_Component_Data::$objectsCount.', '; //echo " row: ".Kwf_Model_Row_Abstract::$objectsCount.''; //var_dump(Kwf_Model_Row_Abstract::$objectsByModel); //var_dump(Kwf_Component_Data::$objectsById); //echo "\n"; } $page = Kwf_Component_Data_Root::getInstance()->getComponentById($pageId); if (!$page->isPage) continue; $model = Kwf_Component_PagesMetaModel::getInstance(); $row = $model->getRow($page->componentId); if (!$row) { $row = $model->createRow(); $row->changed_date = date('Y-m-d H:i:s'); } $row->updateFromPage($page); $row->rebuilt = true; $row->changed_recursive = false; $row->save(); $stats['addedPages']++; unset($page); } file_put_contents($statsFile, serialize($stats)); if ($this->_getParam('debug')) echo "child finished\n"; exit(0); }
php
public function rebuildWorkerAction() { set_time_limit(0); Kwf_Util_MemoryLimit::set(512); $queueFile = 'temp/pagemetaRebuildQueue'; $statsFile = 'temp/pagemetaRebuildStats'; $stats = unserialize(file_get_contents($statsFile)); while (true) { //child process //echo "memory_usage (child): ".(memory_get_usage()/(1024*1024))."MB\n"; if (memory_get_usage() > 128*1024*1024) { if ($this->_getParam('debug')) echo "new process...\n"; break; } $queue = file_get_contents($queueFile); if (!$queue) break; $queue = explode("\n", $queue); if ($this->_getParam('debug')) echo "queued: ".count($queue).' :: '.round(memory_get_usage()/1024/1024, 2)."MB\n"; $componentId = array_pop($queue); file_put_contents($queueFile, implode("\n", $queue)); $stats['pages']++; if ($this->_getParam('debug')) echo "==> ".$componentId; $page = Kwf_Component_Data_Root::getInstance()->getComponentById($componentId); if (!$page) { if ($this->_getParam('debug')) echo "$componentId not found!\n"; continue; } if ($this->_getParam('debug')) echo " :: $page->url\n"; if ($this->_getParam('verbose')) echo "getting child pages..."; $childPages = $page->getChildPseudoPages( array('pageGenerator' => false), array('pseudoPage'=>false, 'unique'=>false) //don't recurse into unique boxes, causes endless recursion if box creates page ); $childPages = array_merge($childPages, $page->getChildPseudoPages( array('pageGenerator' => true), array('pseudoPage'=>false) )); if ($this->_getParam('verbose')) echo " done\n"; foreach ($childPages as $c) { if ($this->_getParam('verbose')) echo "queued $c->componentId\n"; $queue[] = $c->componentId; file_put_contents($queueFile, implode("\n", $queue)); } unset($c); $pageId = $page->componentId; unset($page); if ($this->_getParam('debug')) { //echo round(memory_get_usage()/1024/1024, 2)."MB"; //echo " gen: ".Kwf_Component_Generator_Abstract::$objectsCount.', '; //echo " data: ".Kwf_Component_Data::$objectsCount.', '; //echo " row: ".Kwf_Model_Row_Abstract::$objectsCount.''; } //Kwf_Component_Data_Root::getInstance()->freeMemory(); if ($this->_getParam('debug')) { //echo ' / '.round(memory_get_usage()/1024/1024, 2)."MB"; //echo " gen: ".Kwf_Component_Generator_Abstract::$objectsCount.', '; //echo " data: ".Kwf_Component_Data::$objectsCount.', '; //echo " row: ".Kwf_Model_Row_Abstract::$objectsCount.''; //var_dump(Kwf_Model_Row_Abstract::$objectsByModel); //var_dump(Kwf_Component_Data::$objectsById); //echo "\n"; } $page = Kwf_Component_Data_Root::getInstance()->getComponentById($pageId); if (!$page->isPage) continue; $model = Kwf_Component_PagesMetaModel::getInstance(); $row = $model->getRow($page->componentId); if (!$row) { $row = $model->createRow(); $row->changed_date = date('Y-m-d H:i:s'); } $row->updateFromPage($page); $row->rebuilt = true; $row->changed_recursive = false; $row->save(); $stats['addedPages']++; unset($page); } file_put_contents($statsFile, serialize($stats)); if ($this->_getParam('debug')) echo "child finished\n"; exit(0); }
[ "public", "function", "rebuildWorkerAction", "(", ")", "{", "set_time_limit", "(", "0", ")", ";", "Kwf_Util_MemoryLimit", "::", "set", "(", "512", ")", ";", "$", "queueFile", "=", "'temp/pagemetaRebuildQueue'", ";", "$", "statsFile", "=", "'temp/pagemetaRebuildStats'", ";", "$", "stats", "=", "unserialize", "(", "file_get_contents", "(", "$", "statsFile", ")", ")", ";", "while", "(", "true", ")", "{", "//child process", "//echo \"memory_usage (child): \".(memory_get_usage()/(1024*1024)).\"MB\\n\";", "if", "(", "memory_get_usage", "(", ")", ">", "128", "*", "1024", "*", "1024", ")", "{", "if", "(", "$", "this", "->", "_getParam", "(", "'debug'", ")", ")", "echo", "\"new process...\\n\"", ";", "break", ";", "}", "$", "queue", "=", "file_get_contents", "(", "$", "queueFile", ")", ";", "if", "(", "!", "$", "queue", ")", "break", ";", "$", "queue", "=", "explode", "(", "\"\\n\"", ",", "$", "queue", ")", ";", "if", "(", "$", "this", "->", "_getParam", "(", "'debug'", ")", ")", "echo", "\"queued: \"", ".", "count", "(", "$", "queue", ")", ".", "' :: '", ".", "round", "(", "memory_get_usage", "(", ")", "/", "1024", "/", "1024", ",", "2", ")", ".", "\"MB\\n\"", ";", "$", "componentId", "=", "array_pop", "(", "$", "queue", ")", ";", "file_put_contents", "(", "$", "queueFile", ",", "implode", "(", "\"\\n\"", ",", "$", "queue", ")", ")", ";", "$", "stats", "[", "'pages'", "]", "++", ";", "if", "(", "$", "this", "->", "_getParam", "(", "'debug'", ")", ")", "echo", "\"==> \"", ".", "$", "componentId", ";", "$", "page", "=", "Kwf_Component_Data_Root", "::", "getInstance", "(", ")", "->", "getComponentById", "(", "$", "componentId", ")", ";", "if", "(", "!", "$", "page", ")", "{", "if", "(", "$", "this", "->", "_getParam", "(", "'debug'", ")", ")", "echo", "\"$componentId not found!\\n\"", ";", "continue", ";", "}", "if", "(", "$", "this", "->", "_getParam", "(", "'debug'", ")", ")", "echo", "\" :: $page->url\\n\"", ";", "if", "(", "$", "this", "->", "_getParam", "(", "'verbose'", ")", ")", "echo", "\"getting child pages...\"", ";", "$", "childPages", "=", "$", "page", "->", "getChildPseudoPages", "(", "array", "(", "'pageGenerator'", "=>", "false", ")", ",", "array", "(", "'pseudoPage'", "=>", "false", ",", "'unique'", "=>", "false", ")", "//don't recurse into unique boxes, causes endless recursion if box creates page", ")", ";", "$", "childPages", "=", "array_merge", "(", "$", "childPages", ",", "$", "page", "->", "getChildPseudoPages", "(", "array", "(", "'pageGenerator'", "=>", "true", ")", ",", "array", "(", "'pseudoPage'", "=>", "false", ")", ")", ")", ";", "if", "(", "$", "this", "->", "_getParam", "(", "'verbose'", ")", ")", "echo", "\" done\\n\"", ";", "foreach", "(", "$", "childPages", "as", "$", "c", ")", "{", "if", "(", "$", "this", "->", "_getParam", "(", "'verbose'", ")", ")", "echo", "\"queued $c->componentId\\n\"", ";", "$", "queue", "[", "]", "=", "$", "c", "->", "componentId", ";", "file_put_contents", "(", "$", "queueFile", ",", "implode", "(", "\"\\n\"", ",", "$", "queue", ")", ")", ";", "}", "unset", "(", "$", "c", ")", ";", "$", "pageId", "=", "$", "page", "->", "componentId", ";", "unset", "(", "$", "page", ")", ";", "if", "(", "$", "this", "->", "_getParam", "(", "'debug'", ")", ")", "{", "//echo round(memory_get_usage()/1024/1024, 2).\"MB\";", "//echo \" gen: \".Kwf_Component_Generator_Abstract::$objectsCount.', ';", "//echo \" data: \".Kwf_Component_Data::$objectsCount.', ';", "//echo \" row: \".Kwf_Model_Row_Abstract::$objectsCount.'';", "}", "//Kwf_Component_Data_Root::getInstance()->freeMemory();", "if", "(", "$", "this", "->", "_getParam", "(", "'debug'", ")", ")", "{", "//echo ' / '.round(memory_get_usage()/1024/1024, 2).\"MB\";", "//echo \" gen: \".Kwf_Component_Generator_Abstract::$objectsCount.', ';", "//echo \" data: \".Kwf_Component_Data::$objectsCount.', ';", "//echo \" row: \".Kwf_Model_Row_Abstract::$objectsCount.'';", "//var_dump(Kwf_Model_Row_Abstract::$objectsByModel);", "//var_dump(Kwf_Component_Data::$objectsById);", "//echo \"\\n\";", "}", "$", "page", "=", "Kwf_Component_Data_Root", "::", "getInstance", "(", ")", "->", "getComponentById", "(", "$", "pageId", ")", ";", "if", "(", "!", "$", "page", "->", "isPage", ")", "continue", ";", "$", "model", "=", "Kwf_Component_PagesMetaModel", "::", "getInstance", "(", ")", ";", "$", "row", "=", "$", "model", "->", "getRow", "(", "$", "page", "->", "componentId", ")", ";", "if", "(", "!", "$", "row", ")", "{", "$", "row", "=", "$", "model", "->", "createRow", "(", ")", ";", "$", "row", "->", "changed_date", "=", "date", "(", "'Y-m-d H:i:s'", ")", ";", "}", "$", "row", "->", "updateFromPage", "(", "$", "page", ")", ";", "$", "row", "->", "rebuilt", "=", "true", ";", "$", "row", "->", "changed_recursive", "=", "false", ";", "$", "row", "->", "save", "(", ")", ";", "$", "stats", "[", "'addedPages'", "]", "++", ";", "unset", "(", "$", "page", ")", ";", "}", "file_put_contents", "(", "$", "statsFile", ",", "serialize", "(", "$", "stats", ")", ")", ";", "if", "(", "$", "this", "->", "_getParam", "(", "'debug'", ")", ")", "echo", "\"child finished\\n\"", ";", "exit", "(", "0", ")", ";", "}" ]
internal
[ "internal" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Controller/Action/Cli/Web/ComponentPagesMetaController.php#L5-L95
koala-framework/koala-framework
Kwc/Abstract/Image/Trl/Component.php
Kwc_Abstract_Image_Trl_Component.getMediaOutput
public static function getMediaOutput($id, $type, $className) { $c = Kwf_Component_Data_Root::getInstance()->getComponentById($id, array('ignoreVisible' => true)); return call_user_func( array(get_class($c->chained->getComponent()), 'getMediaOutput'), $c->chained->componentId, $type, $c->chained->componentClass ); }
php
public static function getMediaOutput($id, $type, $className) { $c = Kwf_Component_Data_Root::getInstance()->getComponentById($id, array('ignoreVisible' => true)); return call_user_func( array(get_class($c->chained->getComponent()), 'getMediaOutput'), $c->chained->componentId, $type, $c->chained->componentClass ); }
[ "public", "static", "function", "getMediaOutput", "(", "$", "id", ",", "$", "type", ",", "$", "className", ")", "{", "$", "c", "=", "Kwf_Component_Data_Root", "::", "getInstance", "(", ")", "->", "getComponentById", "(", "$", "id", ",", "array", "(", "'ignoreVisible'", "=>", "true", ")", ")", ";", "return", "call_user_func", "(", "array", "(", "get_class", "(", "$", "c", "->", "chained", "->", "getComponent", "(", ")", ")", ",", "'getMediaOutput'", ")", ",", "$", "c", "->", "chained", "->", "componentId", ",", "$", "type", ",", "$", "c", "->", "chained", "->", "componentClass", ")", ";", "}" ]
if own_image getMediaOutput of image child component is used
[ "if", "own_image", "getMediaOutput", "of", "image", "child", "component", "is", "used" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Abstract/Image/Trl/Component.php#L140-L147
koala-framework/koala-framework
Kwf/Util/Update/Runner.php
Kwf_Util_Update_Runner.checkUpdatesSettings
public function checkUpdatesSettings() { $ret = true; foreach ($this->_updates as $update) { $e = false; try { $update->checkSettings(); } catch (Exception $e) { throw $e; //no special handling for now, maybe something better should be done $ret = false; } } return $ret; }
php
public function checkUpdatesSettings() { $ret = true; foreach ($this->_updates as $update) { $e = false; try { $update->checkSettings(); } catch (Exception $e) { throw $e; //no special handling for now, maybe something better should be done $ret = false; } } return $ret; }
[ "public", "function", "checkUpdatesSettings", "(", ")", "{", "$", "ret", "=", "true", ";", "foreach", "(", "$", "this", "->", "_updates", "as", "$", "update", ")", "{", "$", "e", "=", "false", ";", "try", "{", "$", "update", "->", "checkSettings", "(", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "$", "e", ";", "//no special handling for now, maybe something better should be done", "$", "ret", "=", "false", ";", "}", "}", "return", "$", "ret", ";", "}" ]
Executes checkSettings method for all update scripts which should check if everything is set up correctly to execute the update script
[ "Executes", "checkSettings", "method", "for", "all", "update", "scripts", "which", "should", "check", "if", "everything", "is", "set", "up", "correctly", "to", "execute", "the", "update", "script" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Util/Update/Runner.php#L88-L101
koala-framework/koala-framework
Kwf/Events/Dispatcher.php
Kwf_Events_Dispatcher.addListeners
public static function addListeners($objOrClass) { self::getAllListeners(); //fill cache if ($objOrClass instanceof Kwf_Events_Subscriber) { self::_addListenersFromSubscribers(self::$_listeners, array($objOrClass)); } else if (is_string($objOrClass)) { if (is_instance_of($objOrClass, 'Kwf_Model_Interface')) { self::_addListenersFromSubscribers(self::$_listeners, self::_getSubscribersFromModel($objOrClass) ); } else if (is_instance_of($objOrClass, 'Kwf_Component_Abstract')) { self::_addListenersFromSubscribers(self::$_listeners, self::_getSubscribersFromComponent($objOrClass) ); } } }
php
public static function addListeners($objOrClass) { self::getAllListeners(); //fill cache if ($objOrClass instanceof Kwf_Events_Subscriber) { self::_addListenersFromSubscribers(self::$_listeners, array($objOrClass)); } else if (is_string($objOrClass)) { if (is_instance_of($objOrClass, 'Kwf_Model_Interface')) { self::_addListenersFromSubscribers(self::$_listeners, self::_getSubscribersFromModel($objOrClass) ); } else if (is_instance_of($objOrClass, 'Kwf_Component_Abstract')) { self::_addListenersFromSubscribers(self::$_listeners, self::_getSubscribersFromComponent($objOrClass) ); } } }
[ "public", "static", "function", "addListeners", "(", "$", "objOrClass", ")", "{", "self", "::", "getAllListeners", "(", ")", ";", "//fill cache", "if", "(", "$", "objOrClass", "instanceof", "Kwf_Events_Subscriber", ")", "{", "self", "::", "_addListenersFromSubscribers", "(", "self", "::", "$", "_listeners", ",", "array", "(", "$", "objOrClass", ")", ")", ";", "}", "else", "if", "(", "is_string", "(", "$", "objOrClass", ")", ")", "{", "if", "(", "is_instance_of", "(", "$", "objOrClass", ",", "'Kwf_Model_Interface'", ")", ")", "{", "self", "::", "_addListenersFromSubscribers", "(", "self", "::", "$", "_listeners", ",", "self", "::", "_getSubscribersFromModel", "(", "$", "objOrClass", ")", ")", ";", "}", "else", "if", "(", "is_instance_of", "(", "$", "objOrClass", ",", "'Kwf_Component_Abstract'", ")", ")", "{", "self", "::", "_addListenersFromSubscribers", "(", "self", "::", "$", "_listeners", ",", "self", "::", "_getSubscribersFromComponent", "(", "$", "objOrClass", ")", ")", ";", "}", "}", "}" ]
Add an additional event subscriber, can be used by unit tests obj
[ "Add", "an", "additional", "event", "subscriber", "can", "be", "used", "by", "unit", "tests" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Events/Dispatcher.php#L34-L50
koala-framework/koala-framework
Kwc/Directories/List/View/Component.php
Kwc_Directories_List_View_Component._getSearchSelect
protected function _getSearchSelect($ret, $searchRow) { $values = $searchRow->toArray(); unset($values['id']); $ret->where(new Kwf_Model_Select_Expr_SearchLike($values, $this->_getSetting('searchQueryFields'))); return $ret; }
php
protected function _getSearchSelect($ret, $searchRow) { $values = $searchRow->toArray(); unset($values['id']); $ret->where(new Kwf_Model_Select_Expr_SearchLike($values, $this->_getSetting('searchQueryFields'))); return $ret; }
[ "protected", "function", "_getSearchSelect", "(", "$", "ret", ",", "$", "searchRow", ")", "{", "$", "values", "=", "$", "searchRow", "->", "toArray", "(", ")", ";", "unset", "(", "$", "values", "[", "'id'", "]", ")", ";", "$", "ret", "->", "where", "(", "new", "Kwf_Model_Select_Expr_SearchLike", "(", "$", "values", ",", "$", "this", "->", "_getSetting", "(", "'searchQueryFields'", ")", ")", ")", ";", "return", "$", "ret", ";", "}" ]
rewrite this function if you want a specific search form select
[ "rewrite", "this", "function", "if", "you", "want", "a", "specific", "search", "form", "select" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Directories/List/View/Component.php#L85-L91
koala-framework/koala-framework
Kwc/Directories/List/View/Component.php
Kwc_Directories_List_View_Component.getItemIds
public final function getItemIds($count = null, $offset = null) { $select = $this->_getSelect(); if (!$select) return array(); if ($count) { if ($select->hasPart(Kwf_Model_Select::LIMIT_COUNT)) { $ex = new Kwf_Exception("Can't use getItemIds with limit in select when \$count paramter is given. You probably should disable paging for {$this->getData()->componentClass}."); $ex->logOrThrow(); } $select->limit($count, $offset); } return $this->getData()->parent->getComponent()->getItemIds($select); }
php
public final function getItemIds($count = null, $offset = null) { $select = $this->_getSelect(); if (!$select) return array(); if ($count) { if ($select->hasPart(Kwf_Model_Select::LIMIT_COUNT)) { $ex = new Kwf_Exception("Can't use getItemIds with limit in select when \$count paramter is given. You probably should disable paging for {$this->getData()->componentClass}."); $ex->logOrThrow(); } $select->limit($count, $offset); } return $this->getData()->parent->getComponent()->getItemIds($select); }
[ "public", "final", "function", "getItemIds", "(", "$", "count", "=", "null", ",", "$", "offset", "=", "null", ")", "{", "$", "select", "=", "$", "this", "->", "_getSelect", "(", ")", ";", "if", "(", "!", "$", "select", ")", "return", "array", "(", ")", ";", "if", "(", "$", "count", ")", "{", "if", "(", "$", "select", "->", "hasPart", "(", "Kwf_Model_Select", "::", "LIMIT_COUNT", ")", ")", "{", "$", "ex", "=", "new", "Kwf_Exception", "(", "\"Can't use getItemIds with limit in select when \\$count paramter is given. You probably should disable paging for {$this->getData()->componentClass}.\"", ")", ";", "$", "ex", "->", "logOrThrow", "(", ")", ";", "}", "$", "select", "->", "limit", "(", "$", "count", ",", "$", "offset", ")", ";", "}", "return", "$", "this", "->", "getData", "(", ")", "->", "parent", "->", "getComponent", "(", ")", "->", "getItemIds", "(", "$", "select", ")", ";", "}" ]
override in List if needed
[ "override", "in", "List", "if", "needed" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Directories/List/View/Component.php#L99-L113
koala-framework/koala-framework
Kwc/Directories/List/View/Component.php
Kwc_Directories_List_View_Component._getItems
protected final function _getItems($select = null) { if (!$select) $select = $this->_getSelect(); if (!$select) return array(); return $this->getData()->parent->getComponent()->getItems($select); }
php
protected final function _getItems($select = null) { if (!$select) $select = $this->_getSelect(); if (!$select) return array(); return $this->getData()->parent->getComponent()->getItems($select); }
[ "protected", "final", "function", "_getItems", "(", "$", "select", "=", "null", ")", "{", "if", "(", "!", "$", "select", ")", "$", "select", "=", "$", "this", "->", "_getSelect", "(", ")", ";", "if", "(", "!", "$", "select", ")", "return", "array", "(", ")", ";", "return", "$", "this", "->", "getData", "(", ")", "->", "parent", "->", "getComponent", "(", ")", "->", "getItems", "(", "$", "select", ")", ";", "}" ]
override in List if needed
[ "override", "in", "List", "if", "needed" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Directories/List/View/Component.php#L116-L122
koala-framework/koala-framework
Kwc/Directories/List/View/Component.php
Kwc_Directories_List_View_Component.getPartialParams
public function getPartialParams() { $select = $this->_getSelect(); $ret = array(); $ret['componentId'] = $this->getData()->componentId; $ret['count'] = $this->getPagingCount($select); $ret['disableCache'] = false; $ret['cacheLifetime'] = $this->getViewCacheLifetime(); $ret['disableCacheParams'] = array(); $paging = $this->_getPagingComponent(); if ($paging) { $ret['paging'] = $paging->getComponent()->getPartialParams(); $ret['disableCacheParams'][] = $ret['paging']['paramName']; } $search = $this->_getSearchForm(); if ($search) { $ret['disableCacheParams'][] = $search->componentId.'-post'; } $ret['noEntriesFound'] = $this->_getPlaceholder('noEntriesFound'); return $ret; }
php
public function getPartialParams() { $select = $this->_getSelect(); $ret = array(); $ret['componentId'] = $this->getData()->componentId; $ret['count'] = $this->getPagingCount($select); $ret['disableCache'] = false; $ret['cacheLifetime'] = $this->getViewCacheLifetime(); $ret['disableCacheParams'] = array(); $paging = $this->_getPagingComponent(); if ($paging) { $ret['paging'] = $paging->getComponent()->getPartialParams(); $ret['disableCacheParams'][] = $ret['paging']['paramName']; } $search = $this->_getSearchForm(); if ($search) { $ret['disableCacheParams'][] = $search->componentId.'-post'; } $ret['noEntriesFound'] = $this->_getPlaceholder('noEntriesFound'); return $ret; }
[ "public", "function", "getPartialParams", "(", ")", "{", "$", "select", "=", "$", "this", "->", "_getSelect", "(", ")", ";", "$", "ret", "=", "array", "(", ")", ";", "$", "ret", "[", "'componentId'", "]", "=", "$", "this", "->", "getData", "(", ")", "->", "componentId", ";", "$", "ret", "[", "'count'", "]", "=", "$", "this", "->", "getPagingCount", "(", "$", "select", ")", ";", "$", "ret", "[", "'disableCache'", "]", "=", "false", ";", "$", "ret", "[", "'cacheLifetime'", "]", "=", "$", "this", "->", "getViewCacheLifetime", "(", ")", ";", "$", "ret", "[", "'disableCacheParams'", "]", "=", "array", "(", ")", ";", "$", "paging", "=", "$", "this", "->", "_getPagingComponent", "(", ")", ";", "if", "(", "$", "paging", ")", "{", "$", "ret", "[", "'paging'", "]", "=", "$", "paging", "->", "getComponent", "(", ")", "->", "getPartialParams", "(", ")", ";", "$", "ret", "[", "'disableCacheParams'", "]", "[", "]", "=", "$", "ret", "[", "'paging'", "]", "[", "'paramName'", "]", ";", "}", "$", "search", "=", "$", "this", "->", "_getSearchForm", "(", ")", ";", "if", "(", "$", "search", ")", "{", "$", "ret", "[", "'disableCacheParams'", "]", "[", "]", "=", "$", "search", "->", "componentId", ".", "'-post'", ";", "}", "$", "ret", "[", "'noEntriesFound'", "]", "=", "$", "this", "->", "_getPlaceholder", "(", "'noEntriesFound'", ")", ";", "return", "$", "ret", ";", "}" ]
for helper partialPaging
[ "for", "helper", "partialPaging" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Directories/List/View/Component.php#L143-L163
koala-framework/koala-framework
Kwc/Directories/List/View/Component.php
Kwc_Directories_List_View_Component.moreItemsAvailable
public function moreItemsAvailable() { $select = $this->_getSelect(); if ($this->_hasSetting('limit')) { $select->unsetPart('limitCount'); } return $this->getPagingCount($select) > $this->_getSetting('limit'); }
php
public function moreItemsAvailable() { $select = $this->_getSelect(); if ($this->_hasSetting('limit')) { $select->unsetPart('limitCount'); } return $this->getPagingCount($select) > $this->_getSetting('limit'); }
[ "public", "function", "moreItemsAvailable", "(", ")", "{", "$", "select", "=", "$", "this", "->", "_getSelect", "(", ")", ";", "if", "(", "$", "this", "->", "_hasSetting", "(", "'limit'", ")", ")", "{", "$", "select", "->", "unsetPart", "(", "'limitCount'", ")", ";", "}", "return", "$", "this", "->", "getPagingCount", "(", "$", "select", ")", ">", "$", "this", "->", "_getSetting", "(", "'limit'", ")", ";", "}" ]
if setting limit is set, it will return hidden elements with paging
[ "if", "setting", "limit", "is", "set", "it", "will", "return", "hidden", "elements", "with", "paging" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Directories/List/View/Component.php#L211-L218
koala-framework/koala-framework
Kwf/Filter/Row/Numberize.php
Kwf_Filter_Row_Numberize._getWhere
private function _getWhere($row) { $where = array(); foreach ($this->_groupBy as $k=>$field) { if (is_array($field)) { $values = $field; $field = $k; $valueFound = false; foreach ($values as $value) { if ($row->$field == $value) { $valueFound = true; if (is_null($value)) { $where[] = "ISNULL($field)"; } else { $where["$field = ?"] = $value; } break; } } if (!$valueFound) { $in = array(); foreach ($values as $value) { $in[] = $row->getTable()->getAdapter()->quote($value); } $in = implode(',', $in); $where[] = "$field NOT IN ($in)"; } } else { if (is_null($row->$field)) { $where[] = "ISNULL($field)"; } else { $where["$field = ?"] = $row->$field; } } } return $where; }
php
private function _getWhere($row) { $where = array(); foreach ($this->_groupBy as $k=>$field) { if (is_array($field)) { $values = $field; $field = $k; $valueFound = false; foreach ($values as $value) { if ($row->$field == $value) { $valueFound = true; if (is_null($value)) { $where[] = "ISNULL($field)"; } else { $where["$field = ?"] = $value; } break; } } if (!$valueFound) { $in = array(); foreach ($values as $value) { $in[] = $row->getTable()->getAdapter()->quote($value); } $in = implode(',', $in); $where[] = "$field NOT IN ($in)"; } } else { if (is_null($row->$field)) { $where[] = "ISNULL($field)"; } else { $where["$field = ?"] = $row->$field; } } } return $where; }
[ "private", "function", "_getWhere", "(", "$", "row", ")", "{", "$", "where", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_groupBy", "as", "$", "k", "=>", "$", "field", ")", "{", "if", "(", "is_array", "(", "$", "field", ")", ")", "{", "$", "values", "=", "$", "field", ";", "$", "field", "=", "$", "k", ";", "$", "valueFound", "=", "false", ";", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "if", "(", "$", "row", "->", "$", "field", "==", "$", "value", ")", "{", "$", "valueFound", "=", "true", ";", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "$", "where", "[", "]", "=", "\"ISNULL($field)\"", ";", "}", "else", "{", "$", "where", "[", "\"$field = ?\"", "]", "=", "$", "value", ";", "}", "break", ";", "}", "}", "if", "(", "!", "$", "valueFound", ")", "{", "$", "in", "=", "array", "(", ")", ";", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "$", "in", "[", "]", "=", "$", "row", "->", "getTable", "(", ")", "->", "getAdapter", "(", ")", "->", "quote", "(", "$", "value", ")", ";", "}", "$", "in", "=", "implode", "(", "','", ",", "$", "in", ")", ";", "$", "where", "[", "]", "=", "\"$field NOT IN ($in)\"", ";", "}", "}", "else", "{", "if", "(", "is_null", "(", "$", "row", "->", "$", "field", ")", ")", "{", "$", "where", "[", "]", "=", "\"ISNULL($field)\"", ";", "}", "else", "{", "$", "where", "[", "\"$field = ?\"", "]", "=", "$", "row", "->", "$", "field", ";", "}", "}", "}", "return", "$", "where", ";", "}" ]
legacy für Db_Table
[ "legacy", "für", "Db_Table" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Filter/Row/Numberize.php#L51-L87
koala-framework/koala-framework
Kwf/User/EditRow.php
Kwf_User_EditRow.sendGlobalUserActivated
public function sendGlobalUserActivated() { if ($this->_sendMails) { $row = $this->getModel()->getKwfUserRowById($this->id); $mail = new Kwf_User_Mail_GlobalUserActivated($row); $mail->send(); $this->writeLog('user_mail_GlobalUserActivation'); } }
php
public function sendGlobalUserActivated() { if ($this->_sendMails) { $row = $this->getModel()->getKwfUserRowById($this->id); $mail = new Kwf_User_Mail_GlobalUserActivated($row); $mail->send(); $this->writeLog('user_mail_GlobalUserActivation'); } }
[ "public", "function", "sendGlobalUserActivated", "(", ")", "{", "if", "(", "$", "this", "->", "_sendMails", ")", "{", "$", "row", "=", "$", "this", "->", "getModel", "(", ")", "->", "getKwfUserRowById", "(", "$", "this", "->", "id", ")", ";", "$", "mail", "=", "new", "Kwf_User_Mail_GlobalUserActivated", "(", "$", "row", ")", ";", "$", "mail", "->", "send", "(", ")", ";", "$", "this", "->", "writeLog", "(", "'user_mail_GlobalUserActivation'", ")", ";", "}", "}" ]
a global user that exists already in service, but not in web
[ "a", "global", "user", "that", "exists", "already", "in", "service", "but", "not", "in", "web" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/User/EditRow.php#L278-L286
koala-framework/koala-framework
Kwf/Config/Web.php
Kwf_Config_Web.mergeConfigs
public static function mergeConfigs(Zend_Config $main, Zend_Config $merge) { // check if all keys are of type 'integer' and if so, only use merge config $everyKeyIsInteger = true; foreach($merge as $key => $item) { if (!is_int($key)) { $everyKeyIsInteger = false; break; } } if ($everyKeyIsInteger) { return $merge; } foreach($merge as $key => $item) { if(isset($main->$key)) { if($item instanceof Zend_Config && $main->$key instanceof Zend_Config) { $main->$key = Kwf_Config_Web::mergeConfigs( $main->$key, new Zend_Config($item->toArray(), !$main->readOnly()) ); } else { $main->$key = $item; } } else { if($item instanceof Zend_Config) { $main->$key = new Zend_Config($item->toArray(), !$main->readOnly()); } else { $main->$key = $item; } } } return $main; }
php
public static function mergeConfigs(Zend_Config $main, Zend_Config $merge) { // check if all keys are of type 'integer' and if so, only use merge config $everyKeyIsInteger = true; foreach($merge as $key => $item) { if (!is_int($key)) { $everyKeyIsInteger = false; break; } } if ($everyKeyIsInteger) { return $merge; } foreach($merge as $key => $item) { if(isset($main->$key)) { if($item instanceof Zend_Config && $main->$key instanceof Zend_Config) { $main->$key = Kwf_Config_Web::mergeConfigs( $main->$key, new Zend_Config($item->toArray(), !$main->readOnly()) ); } else { $main->$key = $item; } } else { if($item instanceof Zend_Config) { $main->$key = new Zend_Config($item->toArray(), !$main->readOnly()); } else { $main->$key = $item; } } } return $main; }
[ "public", "static", "function", "mergeConfigs", "(", "Zend_Config", "$", "main", ",", "Zend_Config", "$", "merge", ")", "{", "// check if all keys are of type 'integer' and if so, only use merge config", "$", "everyKeyIsInteger", "=", "true", ";", "foreach", "(", "$", "merge", "as", "$", "key", "=>", "$", "item", ")", "{", "if", "(", "!", "is_int", "(", "$", "key", ")", ")", "{", "$", "everyKeyIsInteger", "=", "false", ";", "break", ";", "}", "}", "if", "(", "$", "everyKeyIsInteger", ")", "{", "return", "$", "merge", ";", "}", "foreach", "(", "$", "merge", "as", "$", "key", "=>", "$", "item", ")", "{", "if", "(", "isset", "(", "$", "main", "->", "$", "key", ")", ")", "{", "if", "(", "$", "item", "instanceof", "Zend_Config", "&&", "$", "main", "->", "$", "key", "instanceof", "Zend_Config", ")", "{", "$", "main", "->", "$", "key", "=", "Kwf_Config_Web", "::", "mergeConfigs", "(", "$", "main", "->", "$", "key", ",", "new", "Zend_Config", "(", "$", "item", "->", "toArray", "(", ")", ",", "!", "$", "main", "->", "readOnly", "(", ")", ")", ")", ";", "}", "else", "{", "$", "main", "->", "$", "key", "=", "$", "item", ";", "}", "}", "else", "{", "if", "(", "$", "item", "instanceof", "Zend_Config", ")", "{", "$", "main", "->", "$", "key", "=", "new", "Zend_Config", "(", "$", "item", "->", "toArray", "(", ")", ",", "!", "$", "main", "->", "readOnly", "(", ")", ")", ";", "}", "else", "{", "$", "main", "->", "$", "key", "=", "$", "item", ";", "}", "}", "}", "return", "$", "main", ";", "}" ]
Diesen Merge sollte eigentlich das Zend machen, aber das merged nicht so wie wir das erwarten. Beispiel: Main Config: bla.blubb[] = x bla.blubb[] = y bla.blubb[] = z Merge Config: bla.blubb[] = a bla.blubb[] = b Nach den Config-Section regeln würde man erwarten, dass nach dem mergen nur mehr a und b drin steht. Tatsächlich merget Zend aber so, dass a, b, z überbleibt. Zend überschreibt die Werte, was wir nicht wollen, deshalb dieses händische mergen hier.
[ "Diesen", "Merge", "sollte", "eigentlich", "das", "Zend", "machen", "aber", "das", "merged", "nicht", "so", "wie", "wir", "das", "erwarten", ".", "Beispiel", ":" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Config/Web.php#L229-L262
koala-framework/koala-framework
Kwf/Component/Cache/Fnf/Model.php
Kwf_Component_Cache_Fnf_Model.getContent
public function getContent($select = array()) { $ret = array(); foreach ($this->getRows($select) as $row) { $ret[] = $row->component_id . '(' . $row->type . ' - ' . $row->value . ') ' . $row->component_class . ': ' . $row->deleted; } return $ret; }
php
public function getContent($select = array()) { $ret = array(); foreach ($this->getRows($select) as $row) { $ret[] = $row->component_id . '(' . $row->type . ' - ' . $row->value . ') ' . $row->component_class . ': ' . $row->deleted; } return $ret; }
[ "public", "function", "getContent", "(", "$", "select", "=", "array", "(", ")", ")", "{", "$", "ret", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getRows", "(", "$", "select", ")", "as", "$", "row", ")", "{", "$", "ret", "[", "]", "=", "$", "row", "->", "component_id", ".", "'('", ".", "$", "row", "->", "type", ".", "' - '", ".", "$", "row", "->", "value", ".", "') '", ".", "$", "row", "->", "component_class", ".", "': '", ".", "$", "row", "->", "deleted", ";", "}", "return", "$", "ret", ";", "}" ]
zum Testen
[ "zum", "Testen" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Cache/Fnf/Model.php#L16-L23
koala-framework/koala-framework
Kwc/Feedback/Form/Controller.php
Kwc_Feedback_Form_Controller._getSelect
protected function _getSelect() { $ret = parent::_getSelect(); $componentId = $this->_getParam('componentId'); $component = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($componentId, array('ignoreVisible' => true)); if (isset($component->parent->chained)) { $component = $component->parent->chained; } $dbIds = array($component->dbId); foreach (Kwc_Chained_Abstract_Component::getAllChainedByMaster($component, 'Trl') as $c) { $dbIds[] = $c->dbId; } $ret->whereEquals('component_id', $dbIds); return $ret; }
php
protected function _getSelect() { $ret = parent::_getSelect(); $componentId = $this->_getParam('componentId'); $component = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($componentId, array('ignoreVisible' => true)); if (isset($component->parent->chained)) { $component = $component->parent->chained; } $dbIds = array($component->dbId); foreach (Kwc_Chained_Abstract_Component::getAllChainedByMaster($component, 'Trl') as $c) { $dbIds[] = $c->dbId; } $ret->whereEquals('component_id', $dbIds); return $ret; }
[ "protected", "function", "_getSelect", "(", ")", "{", "$", "ret", "=", "parent", "::", "_getSelect", "(", ")", ";", "$", "componentId", "=", "$", "this", "->", "_getParam", "(", "'componentId'", ")", ";", "$", "component", "=", "Kwf_Component_Data_Root", "::", "getInstance", "(", ")", "->", "getComponentByDbId", "(", "$", "componentId", ",", "array", "(", "'ignoreVisible'", "=>", "true", ")", ")", ";", "if", "(", "isset", "(", "$", "component", "->", "parent", "->", "chained", ")", ")", "{", "$", "component", "=", "$", "component", "->", "parent", "->", "chained", ";", "}", "$", "dbIds", "=", "array", "(", "$", "component", "->", "dbId", ")", ";", "foreach", "(", "Kwc_Chained_Abstract_Component", "::", "getAllChainedByMaster", "(", "$", "component", ",", "'Trl'", ")", "as", "$", "c", ")", "{", "$", "dbIds", "[", "]", "=", "$", "c", "->", "dbId", ";", "}", "$", "ret", "->", "whereEquals", "(", "'component_id'", ",", "$", "dbIds", ")", ";", "return", "$", "ret", ";", "}" ]
shows all feedbacks in all languages
[ "shows", "all", "feedbacks", "in", "all", "languages" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Feedback/Form/Controller.php#L17-L31
koala-framework/koala-framework
Kwf/Validate/Time.php
Kwf_Validate_Time.isValid
public function isValid($value) { $valueString = (string) $value; $this->_setValue($valueString); if (!preg_match('/^\d{2}:\d{2}$/', $valueString)) { $this->_error(self::NOT_HH_MM); return false; } list($hour, $minute) = sscanf($valueString, '%d:%d'); if ($hour > 23 || $minute > 59) { $this->_error(self::INVALID); return false; } return true; }
php
public function isValid($value) { $valueString = (string) $value; $this->_setValue($valueString); if (!preg_match('/^\d{2}:\d{2}$/', $valueString)) { $this->_error(self::NOT_HH_MM); return false; } list($hour, $minute) = sscanf($valueString, '%d:%d'); if ($hour > 23 || $minute > 59) { $this->_error(self::INVALID); return false; } return true; }
[ "public", "function", "isValid", "(", "$", "value", ")", "{", "$", "valueString", "=", "(", "string", ")", "$", "value", ";", "$", "this", "->", "_setValue", "(", "$", "valueString", ")", ";", "if", "(", "!", "preg_match", "(", "'/^\\d{2}:\\d{2}$/'", ",", "$", "valueString", ")", ")", "{", "$", "this", "->", "_error", "(", "self", "::", "NOT_HH_MM", ")", ";", "return", "false", ";", "}", "list", "(", "$", "hour", ",", "$", "minute", ")", "=", "sscanf", "(", "$", "valueString", ",", "'%d:%d'", ")", ";", "if", "(", "$", "hour", ">", "23", "||", "$", "minute", ">", "59", ")", "{", "$", "this", "->", "_error", "(", "self", "::", "INVALID", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Defined by Zend_Validate_Interface Returns true if and only if $value is a valid date of the format YYYY-MM-DD @param string $value @return boolean
[ "Defined", "by", "Zend_Validate_Interface" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Validate/Time.php#L35-L54
koala-framework/koala-framework
Kwf/Media/Output/Component.php
Kwf_Media_Output_Component.getResponsiveImageVars
public static function getResponsiveImageVars($dimensions, $imageFile) { $ret = array(); $width = 0; $aspectRatio = 0; $ret['minWidth'] = 0; $ret['maxWidth'] = 0; if (isset($dimensions['width']) && $dimensions['width'] > 0) { $aspectRatio = $dimensions['height'] / $dimensions['width'] * 100; $width = $dimensions['width']; $ret['widthSteps'] = Kwf_Media_Image::getResponsiveWidthSteps($dimensions, $imageFile); } $ret['width'] = $width; $ret['aspectRatio'] = $aspectRatio; return $ret; }
php
public static function getResponsiveImageVars($dimensions, $imageFile) { $ret = array(); $width = 0; $aspectRatio = 0; $ret['minWidth'] = 0; $ret['maxWidth'] = 0; if (isset($dimensions['width']) && $dimensions['width'] > 0) { $aspectRatio = $dimensions['height'] / $dimensions['width'] * 100; $width = $dimensions['width']; $ret['widthSteps'] = Kwf_Media_Image::getResponsiveWidthSteps($dimensions, $imageFile); } $ret['width'] = $width; $ret['aspectRatio'] = $aspectRatio; return $ret; }
[ "public", "static", "function", "getResponsiveImageVars", "(", "$", "dimensions", ",", "$", "imageFile", ")", "{", "$", "ret", "=", "array", "(", ")", ";", "$", "width", "=", "0", ";", "$", "aspectRatio", "=", "0", ";", "$", "ret", "[", "'minWidth'", "]", "=", "0", ";", "$", "ret", "[", "'maxWidth'", "]", "=", "0", ";", "if", "(", "isset", "(", "$", "dimensions", "[", "'width'", "]", ")", "&&", "$", "dimensions", "[", "'width'", "]", ">", "0", ")", "{", "$", "aspectRatio", "=", "$", "dimensions", "[", "'height'", "]", "/", "$", "dimensions", "[", "'width'", "]", "*", "100", ";", "$", "width", "=", "$", "dimensions", "[", "'width'", "]", ";", "$", "ret", "[", "'widthSteps'", "]", "=", "Kwf_Media_Image", "::", "getResponsiveWidthSteps", "(", "$", "dimensions", ",", "$", "imageFile", ")", ";", "}", "$", "ret", "[", "'width'", "]", "=", "$", "width", ";", "$", "ret", "[", "'aspectRatio'", "]", "=", "$", "aspectRatio", ";", "return", "$", "ret", ";", "}" ]
Helper function that calculates vars needed by components with responsive images
[ "Helper", "function", "that", "calculates", "vars", "needed", "by", "components", "with", "responsive", "images" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Media/Output/Component.php#L7-L22
koala-framework/koala-framework
Kwf/Media/Output/Component.php
Kwf_Media_Output_Component.getMediaOutputForDimension
public static function getMediaOutputForDimension($data, $dim, $type) { if (isset($data['url'])) { $file = Kwf_Config::getValue('mediaCacheDir').'/remotefile_' . md5($data['url']); if (!is_file($file)) { $httpClientConfig = array( 'timeout' => 20, 'persistent' => false ); if (extension_loaded('curl')) { $httpClientConfig['adapter'] = 'Zend_Http_Client_Adapter_Curl'; } else if (Kwf_Config::getValue('http.proxy.host')) { $httpClientConfig['adapter'] = 'Zend_Http_Client_Adapter_Proxy'; } if (Kwf_Config::getValue('http.proxy.host')) { $httpClientConfig['proxy_host'] = Kwf_Config::getValue('http.proxy.host'); $httpClientConfig['proxy_port'] = Kwf_Config::getValue('http.proxy.port'); } $httpClient = new Zend_Http_Client($data['url'], $httpClientConfig); $request = $httpClient->request(); if ($request->getStatus() == 200) { file_put_contents($file, $request->getBody()); if (!getimagesize($file)) { unlink($file); throw new Kwf_Exception('File is no image: ' . $data['url']); } } else { throw new Kwf_Exception('Could not download file: ' . $data['url']); } } $data['file'] = $file; } $sourceSize = null; if (isset($data['dimensions'])) { $sourceSize = $data['dimensions']; } else if (isset($data['image'])) { $sourceSize = array( 'width' => $data['image']->getImageWidth(), 'height' => $data['image']->getImageHeight() ); } else if (isset($data['file'])) { if (!is_string($data['file'])) { throw new Kwf_Exception("file must be a string (filename) or dimensions must be passed"); } $s = @getimagesize($data['file']); $sourceSize = array( 'width' => $s[0], 'height' => $s[1], ); unset($s); } // calculate output width/height on base of getImageDimensions and given width $width = substr($type, strlen(Kwf_Media::DONT_HASH_TYPE_PREFIX)); $width = substr($width, 0, strpos($width, '-')); if ($width) { $width = Kwf_Media_Image::getResponsiveWidthStep($width, Kwf_Media_Image::getResponsiveWidthSteps($dim, $sourceSize)); $dim['height'] = $width / $dim['width'] * $dim['height']; $dim['width'] = $width; } $ret = array(); if (isset($data['image'])) { $output = Kwf_Media_Image::scale($data['image'], $dim); $ret['contents'] = $output; } else { $scalingNeeded = true; $resultingSize = Kwf_Media_Image::calculateScaleDimensions($sourceSize, $dim); if ($sourceSize && array($resultingSize['crop']['width'], $resultingSize['crop']['height']) == array($sourceSize['width'], $sourceSize['height']) && array($resultingSize['width'], $resultingSize['height']) == array($sourceSize['width'], $sourceSize['height']) ) { $scalingNeeded = false; } if ($scalingNeeded) { //NOTE: don't pass actual size of the resulting image, scale() will calculate that on it's own //else size is calculated twice and we get rounding errors $uploadId = isset($data['uploadId']) ? $data['uploadId'] : null; $output = Kwf_Media_Image::scale($data['file'], $dim, $uploadId, $sourceSize, $data['mimeType']); $ret['contents'] = $output; } else { $ret['file'] = $data['file']; } } $ret['mimeType'] = $data['mimeType']; if ($data['file'] instanceof Kwf_Uploads_Row) { $file = $data['file']->getFileSource(); } else { $file = $data['file']; } $ret['mtime'] = filemtime($file); return $ret; }
php
public static function getMediaOutputForDimension($data, $dim, $type) { if (isset($data['url'])) { $file = Kwf_Config::getValue('mediaCacheDir').'/remotefile_' . md5($data['url']); if (!is_file($file)) { $httpClientConfig = array( 'timeout' => 20, 'persistent' => false ); if (extension_loaded('curl')) { $httpClientConfig['adapter'] = 'Zend_Http_Client_Adapter_Curl'; } else if (Kwf_Config::getValue('http.proxy.host')) { $httpClientConfig['adapter'] = 'Zend_Http_Client_Adapter_Proxy'; } if (Kwf_Config::getValue('http.proxy.host')) { $httpClientConfig['proxy_host'] = Kwf_Config::getValue('http.proxy.host'); $httpClientConfig['proxy_port'] = Kwf_Config::getValue('http.proxy.port'); } $httpClient = new Zend_Http_Client($data['url'], $httpClientConfig); $request = $httpClient->request(); if ($request->getStatus() == 200) { file_put_contents($file, $request->getBody()); if (!getimagesize($file)) { unlink($file); throw new Kwf_Exception('File is no image: ' . $data['url']); } } else { throw new Kwf_Exception('Could not download file: ' . $data['url']); } } $data['file'] = $file; } $sourceSize = null; if (isset($data['dimensions'])) { $sourceSize = $data['dimensions']; } else if (isset($data['image'])) { $sourceSize = array( 'width' => $data['image']->getImageWidth(), 'height' => $data['image']->getImageHeight() ); } else if (isset($data['file'])) { if (!is_string($data['file'])) { throw new Kwf_Exception("file must be a string (filename) or dimensions must be passed"); } $s = @getimagesize($data['file']); $sourceSize = array( 'width' => $s[0], 'height' => $s[1], ); unset($s); } // calculate output width/height on base of getImageDimensions and given width $width = substr($type, strlen(Kwf_Media::DONT_HASH_TYPE_PREFIX)); $width = substr($width, 0, strpos($width, '-')); if ($width) { $width = Kwf_Media_Image::getResponsiveWidthStep($width, Kwf_Media_Image::getResponsiveWidthSteps($dim, $sourceSize)); $dim['height'] = $width / $dim['width'] * $dim['height']; $dim['width'] = $width; } $ret = array(); if (isset($data['image'])) { $output = Kwf_Media_Image::scale($data['image'], $dim); $ret['contents'] = $output; } else { $scalingNeeded = true; $resultingSize = Kwf_Media_Image::calculateScaleDimensions($sourceSize, $dim); if ($sourceSize && array($resultingSize['crop']['width'], $resultingSize['crop']['height']) == array($sourceSize['width'], $sourceSize['height']) && array($resultingSize['width'], $resultingSize['height']) == array($sourceSize['width'], $sourceSize['height']) ) { $scalingNeeded = false; } if ($scalingNeeded) { //NOTE: don't pass actual size of the resulting image, scale() will calculate that on it's own //else size is calculated twice and we get rounding errors $uploadId = isset($data['uploadId']) ? $data['uploadId'] : null; $output = Kwf_Media_Image::scale($data['file'], $dim, $uploadId, $sourceSize, $data['mimeType']); $ret['contents'] = $output; } else { $ret['file'] = $data['file']; } } $ret['mimeType'] = $data['mimeType']; if ($data['file'] instanceof Kwf_Uploads_Row) { $file = $data['file']->getFileSource(); } else { $file = $data['file']; } $ret['mtime'] = filemtime($file); return $ret; }
[ "public", "static", "function", "getMediaOutputForDimension", "(", "$", "data", ",", "$", "dim", ",", "$", "type", ")", "{", "if", "(", "isset", "(", "$", "data", "[", "'url'", "]", ")", ")", "{", "$", "file", "=", "Kwf_Config", "::", "getValue", "(", "'mediaCacheDir'", ")", ".", "'/remotefile_'", ".", "md5", "(", "$", "data", "[", "'url'", "]", ")", ";", "if", "(", "!", "is_file", "(", "$", "file", ")", ")", "{", "$", "httpClientConfig", "=", "array", "(", "'timeout'", "=>", "20", ",", "'persistent'", "=>", "false", ")", ";", "if", "(", "extension_loaded", "(", "'curl'", ")", ")", "{", "$", "httpClientConfig", "[", "'adapter'", "]", "=", "'Zend_Http_Client_Adapter_Curl'", ";", "}", "else", "if", "(", "Kwf_Config", "::", "getValue", "(", "'http.proxy.host'", ")", ")", "{", "$", "httpClientConfig", "[", "'adapter'", "]", "=", "'Zend_Http_Client_Adapter_Proxy'", ";", "}", "if", "(", "Kwf_Config", "::", "getValue", "(", "'http.proxy.host'", ")", ")", "{", "$", "httpClientConfig", "[", "'proxy_host'", "]", "=", "Kwf_Config", "::", "getValue", "(", "'http.proxy.host'", ")", ";", "$", "httpClientConfig", "[", "'proxy_port'", "]", "=", "Kwf_Config", "::", "getValue", "(", "'http.proxy.port'", ")", ";", "}", "$", "httpClient", "=", "new", "Zend_Http_Client", "(", "$", "data", "[", "'url'", "]", ",", "$", "httpClientConfig", ")", ";", "$", "request", "=", "$", "httpClient", "->", "request", "(", ")", ";", "if", "(", "$", "request", "->", "getStatus", "(", ")", "==", "200", ")", "{", "file_put_contents", "(", "$", "file", ",", "$", "request", "->", "getBody", "(", ")", ")", ";", "if", "(", "!", "getimagesize", "(", "$", "file", ")", ")", "{", "unlink", "(", "$", "file", ")", ";", "throw", "new", "Kwf_Exception", "(", "'File is no image: '", ".", "$", "data", "[", "'url'", "]", ")", ";", "}", "}", "else", "{", "throw", "new", "Kwf_Exception", "(", "'Could not download file: '", ".", "$", "data", "[", "'url'", "]", ")", ";", "}", "}", "$", "data", "[", "'file'", "]", "=", "$", "file", ";", "}", "$", "sourceSize", "=", "null", ";", "if", "(", "isset", "(", "$", "data", "[", "'dimensions'", "]", ")", ")", "{", "$", "sourceSize", "=", "$", "data", "[", "'dimensions'", "]", ";", "}", "else", "if", "(", "isset", "(", "$", "data", "[", "'image'", "]", ")", ")", "{", "$", "sourceSize", "=", "array", "(", "'width'", "=>", "$", "data", "[", "'image'", "]", "->", "getImageWidth", "(", ")", ",", "'height'", "=>", "$", "data", "[", "'image'", "]", "->", "getImageHeight", "(", ")", ")", ";", "}", "else", "if", "(", "isset", "(", "$", "data", "[", "'file'", "]", ")", ")", "{", "if", "(", "!", "is_string", "(", "$", "data", "[", "'file'", "]", ")", ")", "{", "throw", "new", "Kwf_Exception", "(", "\"file must be a string (filename) or dimensions must be passed\"", ")", ";", "}", "$", "s", "=", "@", "getimagesize", "(", "$", "data", "[", "'file'", "]", ")", ";", "$", "sourceSize", "=", "array", "(", "'width'", "=>", "$", "s", "[", "0", "]", ",", "'height'", "=>", "$", "s", "[", "1", "]", ",", ")", ";", "unset", "(", "$", "s", ")", ";", "}", "// calculate output width/height on base of getImageDimensions and given width", "$", "width", "=", "substr", "(", "$", "type", ",", "strlen", "(", "Kwf_Media", "::", "DONT_HASH_TYPE_PREFIX", ")", ")", ";", "$", "width", "=", "substr", "(", "$", "width", ",", "0", ",", "strpos", "(", "$", "width", ",", "'-'", ")", ")", ";", "if", "(", "$", "width", ")", "{", "$", "width", "=", "Kwf_Media_Image", "::", "getResponsiveWidthStep", "(", "$", "width", ",", "Kwf_Media_Image", "::", "getResponsiveWidthSteps", "(", "$", "dim", ",", "$", "sourceSize", ")", ")", ";", "$", "dim", "[", "'height'", "]", "=", "$", "width", "/", "$", "dim", "[", "'width'", "]", "*", "$", "dim", "[", "'height'", "]", ";", "$", "dim", "[", "'width'", "]", "=", "$", "width", ";", "}", "$", "ret", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "data", "[", "'image'", "]", ")", ")", "{", "$", "output", "=", "Kwf_Media_Image", "::", "scale", "(", "$", "data", "[", "'image'", "]", ",", "$", "dim", ")", ";", "$", "ret", "[", "'contents'", "]", "=", "$", "output", ";", "}", "else", "{", "$", "scalingNeeded", "=", "true", ";", "$", "resultingSize", "=", "Kwf_Media_Image", "::", "calculateScaleDimensions", "(", "$", "sourceSize", ",", "$", "dim", ")", ";", "if", "(", "$", "sourceSize", "&&", "array", "(", "$", "resultingSize", "[", "'crop'", "]", "[", "'width'", "]", ",", "$", "resultingSize", "[", "'crop'", "]", "[", "'height'", "]", ")", "==", "array", "(", "$", "sourceSize", "[", "'width'", "]", ",", "$", "sourceSize", "[", "'height'", "]", ")", "&&", "array", "(", "$", "resultingSize", "[", "'width'", "]", ",", "$", "resultingSize", "[", "'height'", "]", ")", "==", "array", "(", "$", "sourceSize", "[", "'width'", "]", ",", "$", "sourceSize", "[", "'height'", "]", ")", ")", "{", "$", "scalingNeeded", "=", "false", ";", "}", "if", "(", "$", "scalingNeeded", ")", "{", "//NOTE: don't pass actual size of the resulting image, scale() will calculate that on it's own", "//else size is calculated twice and we get rounding errors", "$", "uploadId", "=", "isset", "(", "$", "data", "[", "'uploadId'", "]", ")", "?", "$", "data", "[", "'uploadId'", "]", ":", "null", ";", "$", "output", "=", "Kwf_Media_Image", "::", "scale", "(", "$", "data", "[", "'file'", "]", ",", "$", "dim", ",", "$", "uploadId", ",", "$", "sourceSize", ",", "$", "data", "[", "'mimeType'", "]", ")", ";", "$", "ret", "[", "'contents'", "]", "=", "$", "output", ";", "}", "else", "{", "$", "ret", "[", "'file'", "]", "=", "$", "data", "[", "'file'", "]", ";", "}", "}", "$", "ret", "[", "'mimeType'", "]", "=", "$", "data", "[", "'mimeType'", "]", ";", "if", "(", "$", "data", "[", "'file'", "]", "instanceof", "Kwf_Uploads_Row", ")", "{", "$", "file", "=", "$", "data", "[", "'file'", "]", "->", "getFileSource", "(", ")", ";", "}", "else", "{", "$", "file", "=", "$", "data", "[", "'file'", "]", ";", "}", "$", "ret", "[", "'mtime'", "]", "=", "filemtime", "(", "$", "file", ")", ";", "return", "$", "ret", ";", "}" ]
Helper function that returns scaled and croped images for media output Used by image components in getMediaOutput. Tries to avoid scaling if not required (to keep gif animation intact)
[ "Helper", "function", "that", "returns", "scaled", "and", "croped", "images", "for", "media", "output" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Media/Output/Component.php#L30-L127
koala-framework/koala-framework
Kwf/Media/Output/Component.php
Kwf_Media_Output_Component.isValidImage
public static function isValidImage($id, $type, $className) { $isValid = Kwf_Media_Output_Component::isValid($id); if ($isValid == Kwf_Media_Output_IsValidInterface::VALID || $isValid == Kwf_Media_Output_IsValidInterface::VALID_DONT_CACHE ) { // Can be searched with ignore-visible because if it is invisble and // not allowed to show Kwf_Media_Output_Component::isValid would return // invalid or access_denied $c = Kwf_Component_Data_Root::getInstance()->getComponentById($id, array('ignoreVisible' => true)); if (!$c) return Kwf_Media_Output_IsValidInterface::INVALID; if ($c->componentClass != $className) return Kwf_Media_Output_IsValidInterface::INVALID; $baseType = $c->getComponent()->getBaseType(); $dim = $c->getComponent()->getImageDimensions(); $imageData = $c->getComponent()->getImageDataOrEmptyImageData(); $widths = Kwf_Media_Image::getResponsiveWidthSteps($dim, $imageData['dimensions']); $ok = false; foreach ($widths as $w) { if (str_replace('{width}', $w, $baseType) == $type) { $ok = true; break; } } if (!$ok) { $isValid = Kwf_Media_Output_IsValidInterface::INVALID; } } return $isValid; }
php
public static function isValidImage($id, $type, $className) { $isValid = Kwf_Media_Output_Component::isValid($id); if ($isValid == Kwf_Media_Output_IsValidInterface::VALID || $isValid == Kwf_Media_Output_IsValidInterface::VALID_DONT_CACHE ) { // Can be searched with ignore-visible because if it is invisble and // not allowed to show Kwf_Media_Output_Component::isValid would return // invalid or access_denied $c = Kwf_Component_Data_Root::getInstance()->getComponentById($id, array('ignoreVisible' => true)); if (!$c) return Kwf_Media_Output_IsValidInterface::INVALID; if ($c->componentClass != $className) return Kwf_Media_Output_IsValidInterface::INVALID; $baseType = $c->getComponent()->getBaseType(); $dim = $c->getComponent()->getImageDimensions(); $imageData = $c->getComponent()->getImageDataOrEmptyImageData(); $widths = Kwf_Media_Image::getResponsiveWidthSteps($dim, $imageData['dimensions']); $ok = false; foreach ($widths as $w) { if (str_replace('{width}', $w, $baseType) == $type) { $ok = true; break; } } if (!$ok) { $isValid = Kwf_Media_Output_IsValidInterface::INVALID; } } return $isValid; }
[ "public", "static", "function", "isValidImage", "(", "$", "id", ",", "$", "type", ",", "$", "className", ")", "{", "$", "isValid", "=", "Kwf_Media_Output_Component", "::", "isValid", "(", "$", "id", ")", ";", "if", "(", "$", "isValid", "==", "Kwf_Media_Output_IsValidInterface", "::", "VALID", "||", "$", "isValid", "==", "Kwf_Media_Output_IsValidInterface", "::", "VALID_DONT_CACHE", ")", "{", "// Can be searched with ignore-visible because if it is invisble and", "// not allowed to show Kwf_Media_Output_Component::isValid would return", "// invalid or access_denied", "$", "c", "=", "Kwf_Component_Data_Root", "::", "getInstance", "(", ")", "->", "getComponentById", "(", "$", "id", ",", "array", "(", "'ignoreVisible'", "=>", "true", ")", ")", ";", "if", "(", "!", "$", "c", ")", "return", "Kwf_Media_Output_IsValidInterface", "::", "INVALID", ";", "if", "(", "$", "c", "->", "componentClass", "!=", "$", "className", ")", "return", "Kwf_Media_Output_IsValidInterface", "::", "INVALID", ";", "$", "baseType", "=", "$", "c", "->", "getComponent", "(", ")", "->", "getBaseType", "(", ")", ";", "$", "dim", "=", "$", "c", "->", "getComponent", "(", ")", "->", "getImageDimensions", "(", ")", ";", "$", "imageData", "=", "$", "c", "->", "getComponent", "(", ")", "->", "getImageDataOrEmptyImageData", "(", ")", ";", "$", "widths", "=", "Kwf_Media_Image", "::", "getResponsiveWidthSteps", "(", "$", "dim", ",", "$", "imageData", "[", "'dimensions'", "]", ")", ";", "$", "ok", "=", "false", ";", "foreach", "(", "$", "widths", "as", "$", "w", ")", "{", "if", "(", "str_replace", "(", "'{width}'", ",", "$", "w", ",", "$", "baseType", ")", "==", "$", "type", ")", "{", "$", "ok", "=", "true", ";", "break", ";", "}", "}", "if", "(", "!", "$", "ok", ")", "{", "$", "isValid", "=", "Kwf_Media_Output_IsValidInterface", "::", "INVALID", ";", "}", "}", "return", "$", "isValid", ";", "}" ]
Checks if given type (starting with Kwf_Media::DONT_HASH_TYPE_PREFIX) should return an image by checking Kwf_Media_Image::getResponsiveWidthSteps of image
[ "Checks", "if", "given", "type", "(", "starting", "with", "Kwf_Media", "::", "DONT_HASH_TYPE_PREFIX", ")", "should", "return", "an", "image", "by", "checking", "Kwf_Media_Image", "::", "getResponsiveWidthSteps", "of", "image" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Media/Output/Component.php#L133-L161
koala-framework/koala-framework
Kwf/Media/Output/Component.php
Kwf_Media_Output_Component.isValid
public static function isValid($id) { $writeCache = false; $cacheId = 'media-isvalid-component-'.$id; $plugins = Kwf_Cache_Simple::fetch($cacheId, $success); if ($success) { //success means it's VALID and we successfully fetched the $plugins $ret = Kwf_Media_Output_IsValidInterface::VALID; } else { $ret = Kwf_Media_Output_IsValidInterface::VALID; $c = Kwf_Component_Data_Root::getInstance()->getComponentById($id); if (!$c) { $c = Kwf_Component_Data_Root::getInstance()->getComponentById($id, array('ignoreVisible'=>true)); if (!$c) return Kwf_Media_Output_IsValidInterface::INVALID; if (Kwf_Component_Data_Root::getShowInvisible()) { //preview im frontend $ret = Kwf_Media_Output_IsValidInterface::VALID_DONT_CACHE; } else if (Kwf_Registry::get('acl')->isAllowedComponentById($id, $c->componentClass, Kwf_Registry::get('userModel')->getAuthedUser())) { //paragraphs preview in backend $ret = Kwf_Media_Output_IsValidInterface::VALID_DONT_CACHE; } else if (Kwf_Registry::get('acl')->isAllowedUser(Kwf_Registry::get('userModel')->getAuthedUser(), 'kwf_component_preview', 'view')) { //perview user in frontend $ret = Kwf_Media_Output_IsValidInterface::VALID_DONT_CACHE; } else { return Kwf_Media_Output_IsValidInterface::ACCESS_DENIED; } } //$ret can be VALID or VALID_DONT_CACHE at this point $plugins = array(); $onlyInherit = false; while ($c) { $p = Kwc_Abstract::getSetting($c->componentClass, 'pluginsInherit'); if (!$onlyInherit) { $p = array_merge($p, Kwc_Abstract::getSetting($c->componentClass, 'plugins')); } foreach ($p as $plugin) { if (is_instance_of($plugin, 'Kwf_Component_Plugin_Interface_Login')) { $plugins[] = array( 'plugin' => $plugin, 'id' => $c->componentId ); } } if ($c->isPage) { $onlyInherit = true; } $c = $c->parent; } if ($ret == Kwf_Media_Output_IsValidInterface::VALID) { //only cache VALID, VALID_DONT_CACHE can't be cached $writeCache = true; } } foreach ($plugins as $p) { $plugin = $p['plugin']; $plugin = new $plugin($p['id']); if ($plugin->isLoggedIn()) { $ret = Kwf_Media_Output_IsValidInterface::VALID_DONT_CACHE; } else { $c = Kwf_Component_Data_Root::getInstance()->getComponentById($id); $userModel = Kwf_Registry::get('userModel'); if (Kwf_Registry::get('acl')->isAllowedComponentById($id, $c->componentClass, $userModel ? $userModel->getAuthedUser() : null)) { //allow preview in backend always $ret = Kwf_Media_Output_IsValidInterface::VALID_DONT_CACHE; } else { $ret = Kwf_Media_Output_IsValidInterface::ACCESS_DENIED; break; } } } if ($writeCache && $ret == Kwf_Media_Output_IsValidInterface::VALID_DONT_CACHE) { //only cache VALID_DONT_CACHE, not VALID as it will be cached in Kwf_Media::getOutput //this cache doesn't need to be cleared, because of it's lifetime Kwf_Cache_Simple::add($cacheId, $plugins, 60*60-1); //one second less than isValid cache in Kwf_Media } return $ret; }
php
public static function isValid($id) { $writeCache = false; $cacheId = 'media-isvalid-component-'.$id; $plugins = Kwf_Cache_Simple::fetch($cacheId, $success); if ($success) { //success means it's VALID and we successfully fetched the $plugins $ret = Kwf_Media_Output_IsValidInterface::VALID; } else { $ret = Kwf_Media_Output_IsValidInterface::VALID; $c = Kwf_Component_Data_Root::getInstance()->getComponentById($id); if (!$c) { $c = Kwf_Component_Data_Root::getInstance()->getComponentById($id, array('ignoreVisible'=>true)); if (!$c) return Kwf_Media_Output_IsValidInterface::INVALID; if (Kwf_Component_Data_Root::getShowInvisible()) { //preview im frontend $ret = Kwf_Media_Output_IsValidInterface::VALID_DONT_CACHE; } else if (Kwf_Registry::get('acl')->isAllowedComponentById($id, $c->componentClass, Kwf_Registry::get('userModel')->getAuthedUser())) { //paragraphs preview in backend $ret = Kwf_Media_Output_IsValidInterface::VALID_DONT_CACHE; } else if (Kwf_Registry::get('acl')->isAllowedUser(Kwf_Registry::get('userModel')->getAuthedUser(), 'kwf_component_preview', 'view')) { //perview user in frontend $ret = Kwf_Media_Output_IsValidInterface::VALID_DONT_CACHE; } else { return Kwf_Media_Output_IsValidInterface::ACCESS_DENIED; } } //$ret can be VALID or VALID_DONT_CACHE at this point $plugins = array(); $onlyInherit = false; while ($c) { $p = Kwc_Abstract::getSetting($c->componentClass, 'pluginsInherit'); if (!$onlyInherit) { $p = array_merge($p, Kwc_Abstract::getSetting($c->componentClass, 'plugins')); } foreach ($p as $plugin) { if (is_instance_of($plugin, 'Kwf_Component_Plugin_Interface_Login')) { $plugins[] = array( 'plugin' => $plugin, 'id' => $c->componentId ); } } if ($c->isPage) { $onlyInherit = true; } $c = $c->parent; } if ($ret == Kwf_Media_Output_IsValidInterface::VALID) { //only cache VALID, VALID_DONT_CACHE can't be cached $writeCache = true; } } foreach ($plugins as $p) { $plugin = $p['plugin']; $plugin = new $plugin($p['id']); if ($plugin->isLoggedIn()) { $ret = Kwf_Media_Output_IsValidInterface::VALID_DONT_CACHE; } else { $c = Kwf_Component_Data_Root::getInstance()->getComponentById($id); $userModel = Kwf_Registry::get('userModel'); if (Kwf_Registry::get('acl')->isAllowedComponentById($id, $c->componentClass, $userModel ? $userModel->getAuthedUser() : null)) { //allow preview in backend always $ret = Kwf_Media_Output_IsValidInterface::VALID_DONT_CACHE; } else { $ret = Kwf_Media_Output_IsValidInterface::ACCESS_DENIED; break; } } } if ($writeCache && $ret == Kwf_Media_Output_IsValidInterface::VALID_DONT_CACHE) { //only cache VALID_DONT_CACHE, not VALID as it will be cached in Kwf_Media::getOutput //this cache doesn't need to be cleared, because of it's lifetime Kwf_Cache_Simple::add($cacheId, $plugins, 60*60-1); //one second less than isValid cache in Kwf_Media } return $ret; }
[ "public", "static", "function", "isValid", "(", "$", "id", ")", "{", "$", "writeCache", "=", "false", ";", "$", "cacheId", "=", "'media-isvalid-component-'", ".", "$", "id", ";", "$", "plugins", "=", "Kwf_Cache_Simple", "::", "fetch", "(", "$", "cacheId", ",", "$", "success", ")", ";", "if", "(", "$", "success", ")", "{", "//success means it's VALID and we successfully fetched the $plugins", "$", "ret", "=", "Kwf_Media_Output_IsValidInterface", "::", "VALID", ";", "}", "else", "{", "$", "ret", "=", "Kwf_Media_Output_IsValidInterface", "::", "VALID", ";", "$", "c", "=", "Kwf_Component_Data_Root", "::", "getInstance", "(", ")", "->", "getComponentById", "(", "$", "id", ")", ";", "if", "(", "!", "$", "c", ")", "{", "$", "c", "=", "Kwf_Component_Data_Root", "::", "getInstance", "(", ")", "->", "getComponentById", "(", "$", "id", ",", "array", "(", "'ignoreVisible'", "=>", "true", ")", ")", ";", "if", "(", "!", "$", "c", ")", "return", "Kwf_Media_Output_IsValidInterface", "::", "INVALID", ";", "if", "(", "Kwf_Component_Data_Root", "::", "getShowInvisible", "(", ")", ")", "{", "//preview im frontend", "$", "ret", "=", "Kwf_Media_Output_IsValidInterface", "::", "VALID_DONT_CACHE", ";", "}", "else", "if", "(", "Kwf_Registry", "::", "get", "(", "'acl'", ")", "->", "isAllowedComponentById", "(", "$", "id", ",", "$", "c", "->", "componentClass", ",", "Kwf_Registry", "::", "get", "(", "'userModel'", ")", "->", "getAuthedUser", "(", ")", ")", ")", "{", "//paragraphs preview in backend", "$", "ret", "=", "Kwf_Media_Output_IsValidInterface", "::", "VALID_DONT_CACHE", ";", "}", "else", "if", "(", "Kwf_Registry", "::", "get", "(", "'acl'", ")", "->", "isAllowedUser", "(", "Kwf_Registry", "::", "get", "(", "'userModel'", ")", "->", "getAuthedUser", "(", ")", ",", "'kwf_component_preview'", ",", "'view'", ")", ")", "{", "//perview user in frontend", "$", "ret", "=", "Kwf_Media_Output_IsValidInterface", "::", "VALID_DONT_CACHE", ";", "}", "else", "{", "return", "Kwf_Media_Output_IsValidInterface", "::", "ACCESS_DENIED", ";", "}", "}", "//$ret can be VALID or VALID_DONT_CACHE at this point", "$", "plugins", "=", "array", "(", ")", ";", "$", "onlyInherit", "=", "false", ";", "while", "(", "$", "c", ")", "{", "$", "p", "=", "Kwc_Abstract", "::", "getSetting", "(", "$", "c", "->", "componentClass", ",", "'pluginsInherit'", ")", ";", "if", "(", "!", "$", "onlyInherit", ")", "{", "$", "p", "=", "array_merge", "(", "$", "p", ",", "Kwc_Abstract", "::", "getSetting", "(", "$", "c", "->", "componentClass", ",", "'plugins'", ")", ")", ";", "}", "foreach", "(", "$", "p", "as", "$", "plugin", ")", "{", "if", "(", "is_instance_of", "(", "$", "plugin", ",", "'Kwf_Component_Plugin_Interface_Login'", ")", ")", "{", "$", "plugins", "[", "]", "=", "array", "(", "'plugin'", "=>", "$", "plugin", ",", "'id'", "=>", "$", "c", "->", "componentId", ")", ";", "}", "}", "if", "(", "$", "c", "->", "isPage", ")", "{", "$", "onlyInherit", "=", "true", ";", "}", "$", "c", "=", "$", "c", "->", "parent", ";", "}", "if", "(", "$", "ret", "==", "Kwf_Media_Output_IsValidInterface", "::", "VALID", ")", "{", "//only cache VALID, VALID_DONT_CACHE can't be cached", "$", "writeCache", "=", "true", ";", "}", "}", "foreach", "(", "$", "plugins", "as", "$", "p", ")", "{", "$", "plugin", "=", "$", "p", "[", "'plugin'", "]", ";", "$", "plugin", "=", "new", "$", "plugin", "(", "$", "p", "[", "'id'", "]", ")", ";", "if", "(", "$", "plugin", "->", "isLoggedIn", "(", ")", ")", "{", "$", "ret", "=", "Kwf_Media_Output_IsValidInterface", "::", "VALID_DONT_CACHE", ";", "}", "else", "{", "$", "c", "=", "Kwf_Component_Data_Root", "::", "getInstance", "(", ")", "->", "getComponentById", "(", "$", "id", ")", ";", "$", "userModel", "=", "Kwf_Registry", "::", "get", "(", "'userModel'", ")", ";", "if", "(", "Kwf_Registry", "::", "get", "(", "'acl'", ")", "->", "isAllowedComponentById", "(", "$", "id", ",", "$", "c", "->", "componentClass", ",", "$", "userModel", "?", "$", "userModel", "->", "getAuthedUser", "(", ")", ":", "null", ")", ")", "{", "//allow preview in backend always", "$", "ret", "=", "Kwf_Media_Output_IsValidInterface", "::", "VALID_DONT_CACHE", ";", "}", "else", "{", "$", "ret", "=", "Kwf_Media_Output_IsValidInterface", "::", "ACCESS_DENIED", ";", "break", ";", "}", "}", "}", "if", "(", "$", "writeCache", "&&", "$", "ret", "==", "Kwf_Media_Output_IsValidInterface", "::", "VALID_DONT_CACHE", ")", "{", "//only cache VALID_DONT_CACHE, not VALID as it will be cached in Kwf_Media::getOutput", "//this cache doesn't need to be cleared, because of it's lifetime", "Kwf_Cache_Simple", "::", "add", "(", "$", "cacheId", ",", "$", "plugins", ",", "60", "*", "60", "-", "1", ")", ";", "//one second less than isValid cache in Kwf_Media", "}", "return", "$", "ret", ";", "}" ]
Helper function that can be used in Component implementing Kwf_Media_Output_IsValidInterface to check if the component is visible to the current user
[ "Helper", "function", "that", "can", "be", "used", "in", "Component", "implementing", "Kwf_Media_Output_IsValidInterface", "to", "check", "if", "the", "component", "is", "visible", "to", "the", "current", "user" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Media/Output/Component.php#L167-L247
koala-framework/koala-framework
Kwf/Model/Select.php
Kwf_Model_Select.whereEquals
public function whereEquals($field, $value = null) { if (is_array($field)) { foreach ($field as $f=>$v) { $this->whereEquals($f, $v); } return $this; } if (is_null($value)) { throw new Kwf_Exception("value is required"); } $this->_parts[self::WHERE_EQUALS][$field] = $value; return $this; }
php
public function whereEquals($field, $value = null) { if (is_array($field)) { foreach ($field as $f=>$v) { $this->whereEquals($f, $v); } return $this; } if (is_null($value)) { throw new Kwf_Exception("value is required"); } $this->_parts[self::WHERE_EQUALS][$field] = $value; return $this; }
[ "public", "function", "whereEquals", "(", "$", "field", ",", "$", "value", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "field", ")", ")", "{", "foreach", "(", "$", "field", "as", "$", "f", "=>", "$", "v", ")", "{", "$", "this", "->", "whereEquals", "(", "$", "f", ",", "$", "v", ")", ";", "}", "return", "$", "this", ";", "}", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "throw", "new", "Kwf_Exception", "(", "\"value is required\"", ")", ";", "}", "$", "this", "->", "_parts", "[", "self", "::", "WHERE_EQUALS", "]", "[", "$", "field", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
/* interface Kwf_Model_Select_Expr_Interface {} class Kwf_Model_Select_Expr_CompareField_Abstract implements Kwf_Model_Select_Expr_Interface { __construct($field, $value) getField getValue } class Kwf_Model_Select_Expr_Not implements Kwf_Model_Select_Expr_Interface { __construct(Kwf_Model_Select_Expr_Interface $expr); } class Kwf_Model_Select_Expr_Equal extends Kwf_Model_Select_Expr_CompareField_Abstract {} class Kwf_Model_Select_Expr_Lower extends Kwf_Model_Select_Expr_CompareField_Abstract {} class Kwf_Model_Select_Expr_Higher extends Kwf_Model_Select_Expr_CompareField_Abstract {} class Kwf_Model_Select_Expr_NotEquals implements Kwf_Model_Select_Expr_Not { __construct($field, $value) { parent::__construct(new Kwf_Model_Select_Expr_Equal($field, $value); } } class Kwf_Model_Select_Expr_LowerEquals implements Kwf_Model_Select_Expr_Or { __construct($field, $value) { parent::__construct(array(new Kwf_Model_Select_Expr_Lower($field, $value), new Kwf_Model_Select_Expr_Equal($field, $value)); } } return $this->where(new Kwf_Model_Select_Expr_Equal($field, $value)); return $this->where(new Kwf_Model_Select_Expr_Not(new Kwf_Model_Select_Expr_Equal($field, $value))); return $this->where(new Kwf_Model_Select_Expr_Or(array(new Kwf_Model_Select_Expr_Equal($field, $value), new Kwf_Model_Select_Expr_Higher($field, $value)));
[ "/", "*", "interface", "Kwf_Model_Select_Expr_Interface", "{}", "class", "Kwf_Model_Select_Expr_CompareField_Abstract", "implements", "Kwf_Model_Select_Expr_Interface", "{", "__construct", "(", "$field", "$value", ")", "getField", "getValue", "}", "class", "Kwf_Model_Select_Expr_Not", "implements", "Kwf_Model_Select_Expr_Interface", "{", "__construct", "(", "Kwf_Model_Select_Expr_Interface", "$expr", ")", ";", "}", "class", "Kwf_Model_Select_Expr_Equal", "extends", "Kwf_Model_Select_Expr_CompareField_Abstract", "{}", "class", "Kwf_Model_Select_Expr_Lower", "extends", "Kwf_Model_Select_Expr_CompareField_Abstract", "{}", "class", "Kwf_Model_Select_Expr_Higher", "extends", "Kwf_Model_Select_Expr_CompareField_Abstract", "{}", "class", "Kwf_Model_Select_Expr_NotEquals", "implements", "Kwf_Model_Select_Expr_Not", "{", "__construct", "(", "$field", "$value", ")", "{", "parent", "::", "__construct", "(", "new", "Kwf_Model_Select_Expr_Equal", "(", "$field", "$value", ")", ";", "}", "}", "class", "Kwf_Model_Select_Expr_LowerEquals", "implements", "Kwf_Model_Select_Expr_Or", "{", "__construct", "(", "$field", "$value", ")", "{", "parent", "::", "__construct", "(", "array", "(", "new", "Kwf_Model_Select_Expr_Lower", "(", "$field", "$value", ")", "new", "Kwf_Model_Select_Expr_Equal", "(", "$field", "$value", "))", ";", "}", "}", "return", "$this", "-", ">", "where", "(", "new", "Kwf_Model_Select_Expr_Equal", "(", "$field", "$value", "))", ";", "return", "$this", "-", ">", "where", "(", "new", "Kwf_Model_Select_Expr_Not", "(", "new", "Kwf_Model_Select_Expr_Equal", "(", "$field", "$value", ")))", ";", "return", "$this", "-", ">", "where", "(", "new", "Kwf_Model_Select_Expr_Or", "(", "array", "(", "new", "Kwf_Model_Select_Expr_Equal", "(", "$field", "$value", ")", "new", "Kwf_Model_Select_Expr_Higher", "(", "$field", "$value", ")))", ";" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Model/Select.php#L96-L109
koala-framework/koala-framework
Kwf/Model/Tree/Row.php
Kwf_Model_Tree_Row.getTreePathRows
public function getTreePathRows() { $parts = array($this); $upperRow = $this; while (!is_null($upperRow = $upperRow->getParentNode())) { $parts[] = $upperRow; } return array_reverse($parts); }
php
public function getTreePathRows() { $parts = array($this); $upperRow = $this; while (!is_null($upperRow = $upperRow->getParentNode())) { $parts[] = $upperRow; } return array_reverse($parts); }
[ "public", "function", "getTreePathRows", "(", ")", "{", "$", "parts", "=", "array", "(", "$", "this", ")", ";", "$", "upperRow", "=", "$", "this", ";", "while", "(", "!", "is_null", "(", "$", "upperRow", "=", "$", "upperRow", "->", "getParentNode", "(", ")", ")", ")", "{", "$", "parts", "[", "]", "=", "$", "upperRow", ";", "}", "return", "array_reverse", "(", "$", "parts", ")", ";", "}" ]
Kann überschrieben werden um bestimmte Kategorien auszublenden, zB ProSalzburg die Root-Kategorie
[ "Kann", "überschrieben", "werden", "um", "bestimmte", "Kategorien", "auszublenden", "zB", "ProSalzburg", "die", "Root", "-", "Kategorie" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Model/Tree/Row.php#L36-L44
koala-framework/koala-framework
Kwc/Shop/Cart/Orders.php
Kwc_Shop_Cart_Orders.getCartOrderId
public static function getCartOrderId() { if (isset(self::$_cartOrderId)) { return self::$_cartOrderId; } $session = new Kwf_Session_Namespace('kwcShopCart'); return $session->orderId; }
php
public static function getCartOrderId() { if (isset(self::$_cartOrderId)) { return self::$_cartOrderId; } $session = new Kwf_Session_Namespace('kwcShopCart'); return $session->orderId; }
[ "public", "static", "function", "getCartOrderId", "(", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "_cartOrderId", ")", ")", "{", "return", "self", "::", "$", "_cartOrderId", ";", "}", "$", "session", "=", "new", "Kwf_Session_Namespace", "(", "'kwcShopCart'", ")", ";", "return", "$", "session", "->", "orderId", ";", "}" ]
Gibt die cart order id zurück, auch wenn sie in diesem request schon per resetCartOrderId zurück gesetzt wurde.
[ "Gibt", "die", "cart", "order", "id", "zurück", "auch", "wenn", "sie", "in", "diesem", "request", "schon", "per", "resetCartOrderId", "zurück", "gesetzt", "wurde", "." ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Shop/Cart/Orders.php#L87-L94
koala-framework/koala-framework
Kwf/Form.php
Kwf_Form.hideForValue
public function hideForValue(Kwf_Form_Field_Abstract $field, $value, Kwf_Form_Field_Abstract $hideField) { $this->_hideForValue[] = array('field' => $field, 'value' => $value, 'hide' => $hideField); return $this; }
php
public function hideForValue(Kwf_Form_Field_Abstract $field, $value, Kwf_Form_Field_Abstract $hideField) { $this->_hideForValue[] = array('field' => $field, 'value' => $value, 'hide' => $hideField); return $this; }
[ "public", "function", "hideForValue", "(", "Kwf_Form_Field_Abstract", "$", "field", ",", "$", "value", ",", "Kwf_Form_Field_Abstract", "$", "hideField", ")", "{", "$", "this", "->", "_hideForValue", "[", "]", "=", "array", "(", "'field'", "=>", "$", "field", ",", "'value'", "=>", "$", "value", ",", "'hide'", "=>", "$", "hideField", ")", ";", "return", "$", "this", ";", "}" ]
Hide a field has a specific value, hide other fields ATM only implemented in Frontend Form
[ "Hide", "a", "field", "has", "a", "specific", "value", "hide", "other", "fields" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Form.php#L38-L42
koala-framework/koala-framework
Kwf/Form.php
Kwf_Form._getRowByParentRow
protected function _getRowByParentRow($parentRow) { if ($parentRow && $this->_model instanceof Kwf_Model_Field) { $ret = $this->_model->getRowByParentRow($parentRow); } else { $ret = $this->getRow($parentRow); } if (is_null($ret)) return $ret; return (object)$ret; }
php
protected function _getRowByParentRow($parentRow) { if ($parentRow && $this->_model instanceof Kwf_Model_Field) { $ret = $this->_model->getRowByParentRow($parentRow); } else { $ret = $this->getRow($parentRow); } if (is_null($ret)) return $ret; return (object)$ret; }
[ "protected", "function", "_getRowByParentRow", "(", "$", "parentRow", ")", "{", "if", "(", "$", "parentRow", "&&", "$", "this", "->", "_model", "instanceof", "Kwf_Model_Field", ")", "{", "$", "ret", "=", "$", "this", "->", "_model", "->", "getRowByParentRow", "(", "$", "parentRow", ")", ";", "}", "else", "{", "$", "ret", "=", "$", "this", "->", "getRow", "(", "$", "parentRow", ")", ";", "}", "if", "(", "is_null", "(", "$", "ret", ")", ")", "return", "$", "ret", ";", "return", "(", "object", ")", "$", "ret", ";", "}" ]
aber besser getRow überschreiben!!!
[ "aber", "besser", "getRow", "überschreiben!!!" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Form.php#L79-L88
koala-framework/koala-framework
Kwf/Form.php
Kwf_Form._rowIsParentRow
protected final function _rowIsParentRow($parentRow) { $id = $this->_getIdByParentRow($parentRow); if ($parentRow && !$parentRow->{$parentRow->getModel()->getPrimaryKey()}) { //remember _createdRows, because once it is saved it will have an id and we can't compare it to $id anymore $this->_createdRows[] = $parentRow; } if ($parentRow && !$parentRow instanceof Kwf_Model_FnF_Row && $parentRow->getModel()->isEqual($this->_model) ) { if ($parentRow->{$parentRow->getModel()->getPrimaryKey()} == $id) { return true; } if (!$id && in_array($parentRow, $this->_createdRows, true)) { return true; } } return false; }
php
protected final function _rowIsParentRow($parentRow) { $id = $this->_getIdByParentRow($parentRow); if ($parentRow && !$parentRow->{$parentRow->getModel()->getPrimaryKey()}) { //remember _createdRows, because once it is saved it will have an id and we can't compare it to $id anymore $this->_createdRows[] = $parentRow; } if ($parentRow && !$parentRow instanceof Kwf_Model_FnF_Row && $parentRow->getModel()->isEqual($this->_model) ) { if ($parentRow->{$parentRow->getModel()->getPrimaryKey()} == $id) { return true; } if (!$id && in_array($parentRow, $this->_createdRows, true)) { return true; } } return false; }
[ "protected", "final", "function", "_rowIsParentRow", "(", "$", "parentRow", ")", "{", "$", "id", "=", "$", "this", "->", "_getIdByParentRow", "(", "$", "parentRow", ")", ";", "if", "(", "$", "parentRow", "&&", "!", "$", "parentRow", "->", "{", "$", "parentRow", "->", "getModel", "(", ")", "->", "getPrimaryKey", "(", ")", "}", ")", "{", "//remember _createdRows, because once it is saved it will have an id and we can't compare it to $id anymore", "$", "this", "->", "_createdRows", "[", "]", "=", "$", "parentRow", ";", "}", "if", "(", "$", "parentRow", "&&", "!", "$", "parentRow", "instanceof", "Kwf_Model_FnF_Row", "&&", "$", "parentRow", "->", "getModel", "(", ")", "->", "isEqual", "(", "$", "this", "->", "_model", ")", ")", "{", "if", "(", "$", "parentRow", "->", "{", "$", "parentRow", "->", "getModel", "(", ")", "->", "getPrimaryKey", "(", ")", "}", "==", "$", "id", ")", "{", "return", "true", ";", "}", "if", "(", "!", "$", "id", "&&", "in_array", "(", "$", "parentRow", ",", "$", "this", "->", "_createdRows", ",", "true", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Damit bei verschachtelten Forms die das selben Model verwenden nicht zwei unterschiedliche rows verwendet werden, was beim hinzufügen ein problem ist. Wird aufgerufen von getRow, in Kwc_User_Edit_Form_Form wirds auch verwendet
[ "Damit", "bei", "verschachtelten", "Forms", "die", "das", "selben", "Model", "verwenden", "nicht", "zwei", "unterschiedliche", "rows", "verwendet", "werden", "was", "beim", "hinzufügen", "ein", "problem", "ist", "." ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Form.php#L196-L214
koala-framework/koala-framework
Kwf/Form.php
Kwf_Form.formatValidationErrors
public static function formatValidationErrors($errors) { $msg = array(); foreach ($errors as $i) { if (!is_array($i)) { throw new Kwf_Exception('Form errors must be of type array'); } $name = ''; if (isset($i['field'])) { $name = $i['field']->getFieldLabel(); if (!$name) $name = $i['field']->getName(); } if (isset($i['message'])) { $i['messages'] = array($i['message']); } foreach ($i['messages'] as $m) { $msg[] = ($name ? ($name.': ') : '').Kwf_Util_HtmlSpecialChars::filter($m); } } return $msg; }
php
public static function formatValidationErrors($errors) { $msg = array(); foreach ($errors as $i) { if (!is_array($i)) { throw new Kwf_Exception('Form errors must be of type array'); } $name = ''; if (isset($i['field'])) { $name = $i['field']->getFieldLabel(); if (!$name) $name = $i['field']->getName(); } if (isset($i['message'])) { $i['messages'] = array($i['message']); } foreach ($i['messages'] as $m) { $msg[] = ($name ? ($name.': ') : '').Kwf_Util_HtmlSpecialChars::filter($m); } } return $msg; }
[ "public", "static", "function", "formatValidationErrors", "(", "$", "errors", ")", "{", "$", "msg", "=", "array", "(", ")", ";", "foreach", "(", "$", "errors", "as", "$", "i", ")", "{", "if", "(", "!", "is_array", "(", "$", "i", ")", ")", "{", "throw", "new", "Kwf_Exception", "(", "'Form errors must be of type array'", ")", ";", "}", "$", "name", "=", "''", ";", "if", "(", "isset", "(", "$", "i", "[", "'field'", "]", ")", ")", "{", "$", "name", "=", "$", "i", "[", "'field'", "]", "->", "getFieldLabel", "(", ")", ";", "if", "(", "!", "$", "name", ")", "$", "name", "=", "$", "i", "[", "'field'", "]", "->", "getName", "(", ")", ";", "}", "if", "(", "isset", "(", "$", "i", "[", "'message'", "]", ")", ")", "{", "$", "i", "[", "'messages'", "]", "=", "array", "(", "$", "i", "[", "'message'", "]", ")", ";", "}", "foreach", "(", "$", "i", "[", "'messages'", "]", "as", "$", "m", ")", "{", "$", "msg", "[", "]", "=", "(", "$", "name", "?", "(", "$", "name", ".", "': '", ")", ":", "''", ")", ".", "Kwf_Util_HtmlSpecialChars", "::", "filter", "(", "$", "m", ")", ";", "}", "}", "return", "$", "msg", ";", "}" ]
Static helper function that formats form errors @return string[]
[ "Static", "helper", "function", "that", "formats", "form", "errors" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Form.php#L308-L328
koala-framework/koala-framework
Kwf/Form/Field/TreeSelect.php
Kwf_Form_Field_TreeSelect.load
public function load($row, $postData = array()) { $ret = parent::load($row, $postData); $ref = $this->getReference(); if ($ref && $row && !empty($ret[$this->getFieldName()])) { $id = $ret[$this->getFieldName()]; $parentRow = $row->getParentRow($ref); if ($parentRow) { $displayField = $this->getDisplayField(); if ($displayField) { $ret[$this->getFieldName()] = array( 'id' => $id, 'name' => $parentRow->{$displayField} ); } else if ($parentRow instanceof Kwf_Model_Tree_Row_Interface) { $ret[$this->getFieldName()] = array( 'id' => $id, 'name' => $parentRow->getTreePath() ); } else { $ret[$this->getFieldName()] = array( 'id' => $id, 'name' => $parentRow->__toString() ); } } else { $ret[$this->getFieldName()] = array( 'id' => $id, 'name' => '' ); } } return $ret; }
php
public function load($row, $postData = array()) { $ret = parent::load($row, $postData); $ref = $this->getReference(); if ($ref && $row && !empty($ret[$this->getFieldName()])) { $id = $ret[$this->getFieldName()]; $parentRow = $row->getParentRow($ref); if ($parentRow) { $displayField = $this->getDisplayField(); if ($displayField) { $ret[$this->getFieldName()] = array( 'id' => $id, 'name' => $parentRow->{$displayField} ); } else if ($parentRow instanceof Kwf_Model_Tree_Row_Interface) { $ret[$this->getFieldName()] = array( 'id' => $id, 'name' => $parentRow->getTreePath() ); } else { $ret[$this->getFieldName()] = array( 'id' => $id, 'name' => $parentRow->__toString() ); } } else { $ret[$this->getFieldName()] = array( 'id' => $id, 'name' => '' ); } } return $ret; }
[ "public", "function", "load", "(", "$", "row", ",", "$", "postData", "=", "array", "(", ")", ")", "{", "$", "ret", "=", "parent", "::", "load", "(", "$", "row", ",", "$", "postData", ")", ";", "$", "ref", "=", "$", "this", "->", "getReference", "(", ")", ";", "if", "(", "$", "ref", "&&", "$", "row", "&&", "!", "empty", "(", "$", "ret", "[", "$", "this", "->", "getFieldName", "(", ")", "]", ")", ")", "{", "$", "id", "=", "$", "ret", "[", "$", "this", "->", "getFieldName", "(", ")", "]", ";", "$", "parentRow", "=", "$", "row", "->", "getParentRow", "(", "$", "ref", ")", ";", "if", "(", "$", "parentRow", ")", "{", "$", "displayField", "=", "$", "this", "->", "getDisplayField", "(", ")", ";", "if", "(", "$", "displayField", ")", "{", "$", "ret", "[", "$", "this", "->", "getFieldName", "(", ")", "]", "=", "array", "(", "'id'", "=>", "$", "id", ",", "'name'", "=>", "$", "parentRow", "->", "{", "$", "displayField", "}", ")", ";", "}", "else", "if", "(", "$", "parentRow", "instanceof", "Kwf_Model_Tree_Row_Interface", ")", "{", "$", "ret", "[", "$", "this", "->", "getFieldName", "(", ")", "]", "=", "array", "(", "'id'", "=>", "$", "id", ",", "'name'", "=>", "$", "parentRow", "->", "getTreePath", "(", ")", ")", ";", "}", "else", "{", "$", "ret", "[", "$", "this", "->", "getFieldName", "(", ")", "]", "=", "array", "(", "'id'", "=>", "$", "id", ",", "'name'", "=>", "$", "parentRow", "->", "__toString", "(", ")", ")", ";", "}", "}", "else", "{", "$", "ret", "[", "$", "this", "->", "getFieldName", "(", ")", "]", "=", "array", "(", "'id'", "=>", "$", "id", ",", "'name'", "=>", "''", ")", ";", "}", "}", "return", "$", "ret", ";", "}" ]
korrekt darstellt
[ "korrekt", "darstellt" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Form/Field/TreeSelect.php#L27-L63
koala-framework/koala-framework
Kwf/Model/ProxyCache.php
Kwf_Model_ProxyCache.getRow
public function getRow($select) { if (!is_object($select)) { $select = $this->select($select); } $select->limit(1); return $this->getRows($select)->current(); }
php
public function getRow($select) { if (!is_object($select)) { $select = $this->select($select); } $select->limit(1); return $this->getRows($select)->current(); }
[ "public", "function", "getRow", "(", "$", "select", ")", "{", "if", "(", "!", "is_object", "(", "$", "select", ")", ")", "{", "$", "select", "=", "$", "this", "->", "select", "(", "$", "select", ")", ";", "}", "$", "select", "->", "limit", "(", "1", ")", ";", "return", "$", "this", "->", "getRows", "(", "$", "select", ")", "->", "current", "(", ")", ";", "}" ]
(und nicht wie Model_Proxy)
[ "(", "und", "nicht", "wie", "Model_Proxy", ")" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Model/ProxyCache.php#L21-L28
koala-framework/koala-framework
Kwc/Shop/Cart/Checkout/Payment/PayPal/ConfirmLink/Trl/Controller.php
Kwc_Shop_Cart_Checkout_Payment_PayPal_ConfirmLink_Trl_Controller.jsonConfirmOrderAction
public function jsonConfirmOrderAction() { $component = Kwf_Component_Data_Root::getInstance() ->getComponentById($this->_getParam('paymentComponentId')); $order = Kwf_Model_Abstract::getInstance(Kwc_Abstract::getSetting($component->chained->getParentByClass('Kwc_Shop_Cart_Component')->componentClass, 'childModel')) ->getReferencedModel('Order')->getCartOrder(); if ($order && $component && is_instance_of($component->componentClass, 'Kwc_Shop_Cart_Checkout_Payment_PayPal_Trl_Component') ) { $order->payment_component_id = $component->componentId; $order->checkout_component_id = $component->parent->componentId; $order->cart_component_class = $component->parent->parent->componentClass; $order->status = 'processing'; $order->date = date('Y-m-d H:i:s'); $order->save(); $session = new Kwf_Session_Namespace('kwcShopCart'); $session->paypalCartId = $order->id; } }
php
public function jsonConfirmOrderAction() { $component = Kwf_Component_Data_Root::getInstance() ->getComponentById($this->_getParam('paymentComponentId')); $order = Kwf_Model_Abstract::getInstance(Kwc_Abstract::getSetting($component->chained->getParentByClass('Kwc_Shop_Cart_Component')->componentClass, 'childModel')) ->getReferencedModel('Order')->getCartOrder(); if ($order && $component && is_instance_of($component->componentClass, 'Kwc_Shop_Cart_Checkout_Payment_PayPal_Trl_Component') ) { $order->payment_component_id = $component->componentId; $order->checkout_component_id = $component->parent->componentId; $order->cart_component_class = $component->parent->parent->componentClass; $order->status = 'processing'; $order->date = date('Y-m-d H:i:s'); $order->save(); $session = new Kwf_Session_Namespace('kwcShopCart'); $session->paypalCartId = $order->id; } }
[ "public", "function", "jsonConfirmOrderAction", "(", ")", "{", "$", "component", "=", "Kwf_Component_Data_Root", "::", "getInstance", "(", ")", "->", "getComponentById", "(", "$", "this", "->", "_getParam", "(", "'paymentComponentId'", ")", ")", ";", "$", "order", "=", "Kwf_Model_Abstract", "::", "getInstance", "(", "Kwc_Abstract", "::", "getSetting", "(", "$", "component", "->", "chained", "->", "getParentByClass", "(", "'Kwc_Shop_Cart_Component'", ")", "->", "componentClass", ",", "'childModel'", ")", ")", "->", "getReferencedModel", "(", "'Order'", ")", "->", "getCartOrder", "(", ")", ";", "if", "(", "$", "order", "&&", "$", "component", "&&", "is_instance_of", "(", "$", "component", "->", "componentClass", ",", "'Kwc_Shop_Cart_Checkout_Payment_PayPal_Trl_Component'", ")", ")", "{", "$", "order", "->", "payment_component_id", "=", "$", "component", "->", "componentId", ";", "$", "order", "->", "checkout_component_id", "=", "$", "component", "->", "parent", "->", "componentId", ";", "$", "order", "->", "cart_component_class", "=", "$", "component", "->", "parent", "->", "parent", "->", "componentClass", ";", "$", "order", "->", "status", "=", "'processing'", ";", "$", "order", "->", "date", "=", "date", "(", "'Y-m-d H:i:s'", ")", ";", "$", "order", "->", "save", "(", ")", ";", "$", "session", "=", "new", "Kwf_Session_Namespace", "(", "'kwcShopCart'", ")", ";", "$", "session", "->", "paypalCartId", "=", "$", "order", "->", "id", ";", "}", "}" ]
is called by js, so it might be that this code isn't called at all
[ "is", "called", "by", "js", "so", "it", "might", "be", "that", "this", "code", "isn", "t", "called", "at", "all" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Shop/Cart/Checkout/Payment/PayPal/ConfirmLink/Trl/Controller.php#L5-L23
koala-framework/koala-framework
Kwc/Menu/Abstract/Component.php
Kwc_Menu_Abstract_Component.getMenuData
public function getMenuData($parentData = null, $select = array(), $editableClass = 'Kwc_Menu_EditableItems_Component') { return $this->_getMenuData($parentData, $select, $editableClass); }
php
public function getMenuData($parentData = null, $select = array(), $editableClass = 'Kwc_Menu_EditableItems_Component') { return $this->_getMenuData($parentData, $select, $editableClass); }
[ "public", "function", "getMenuData", "(", "$", "parentData", "=", "null", ",", "$", "select", "=", "array", "(", ")", ",", "$", "editableClass", "=", "'Kwc_Menu_EditableItems_Component'", ")", "{", "return", "$", "this", "->", "_getMenuData", "(", "$", "parentData", ",", "$", "select", ",", "$", "editableClass", ")", ";", "}" ]
Used by chained and Events
[ "Used", "by", "chained", "and", "Events" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Menu/Abstract/Component.php#L167-L170
koala-framework/koala-framework
Kwc/Abstract/Image/Events.php
Kwc_Abstract_Image_Events._onOwnRowUpdateNotVisible
protected function _onOwnRowUpdateNotVisible(Kwf_Component_Data $c, Kwf_Events_Event_Row_Abstract $event) { parent::_onOwnRowUpdateNotVisible($c, $event); if ($event->isDirty(array('kwf_upload_id', 'width', 'height', 'dimension', 'crop_x', 'crop_y', 'crop_width', 'crop_height')) ) { $this->_fireMediaChanged($c); } }
php
protected function _onOwnRowUpdateNotVisible(Kwf_Component_Data $c, Kwf_Events_Event_Row_Abstract $event) { parent::_onOwnRowUpdateNotVisible($c, $event); if ($event->isDirty(array('kwf_upload_id', 'width', 'height', 'dimension', 'crop_x', 'crop_y', 'crop_width', 'crop_height')) ) { $this->_fireMediaChanged($c); } }
[ "protected", "function", "_onOwnRowUpdateNotVisible", "(", "Kwf_Component_Data", "$", "c", ",", "Kwf_Events_Event_Row_Abstract", "$", "event", ")", "{", "parent", "::", "_onOwnRowUpdateNotVisible", "(", "$", "c", ",", "$", "event", ")", ";", "if", "(", "$", "event", "->", "isDirty", "(", "array", "(", "'kwf_upload_id'", ",", "'width'", ",", "'height'", ",", "'dimension'", ",", "'crop_x'", ",", "'crop_y'", ",", "'crop_width'", ",", "'crop_height'", ")", ")", ")", "{", "$", "this", "->", "_fireMediaChanged", "(", "$", "c", ")", ";", "}", "}" ]
gets called when own row gets updated, weather component is visible or not
[ "gets", "called", "when", "own", "row", "gets", "updated", "weather", "component", "is", "visible", "or", "not" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Abstract/Image/Events.php#L60-L69
koala-framework/koala-framework
Kwf/Model/Data/Abstract.php
Kwf_Model_Data_Abstract._selectDataKeys
protected function _selectDataKeys(Kwf_Model_Select $select, array &$inData) { $dataKeys = array(); foreach ($inData as $key=>$d) { if ($this->_matchSelect($d, $select)) { $dataKeys[] = $key; } } if ($order = $select->getPart(Kwf_Model_Select::ORDER)) { if (count($order) > 1) { //TODO: implement Multiple Order fields } $order = current($order); $orderData = array(); foreach ($dataKeys as $key) { if ($order['field'] instanceof Zend_Db_Expr) { //can't be done in FnF $orderData[$inData[$key][$this->_primaryKey]] = 0; } else if ($order['field'] == Kwf_Model_Select::ORDER_RAND) { $orderData[$inData[$key][$this->_primaryKey]] = rand(); } else { $orderData[$inData[$key][$this->_primaryKey]] = strtolower($this->_rowValue($order['field'], $inData[$key])); } } if ($order['direction'] == 'ASC') { asort($orderData); } else if ($order['direction'] == 'DESC') { arsort($orderData); } else { throw new Kwf_Exception("Invalid order direction: {$order['direction']}"); } $sortedDataKeys = array(); foreach (array_keys($orderData) as $id) { foreach ($dataKeys as $key) { if ($inData[$key][$this->_primaryKey] == $id) { $sortedDataKeys[] = $key; } } } $dataKeys = $sortedDataKeys; } if ($select->hasPart(Kwf_Model_Select::LIMIT_OFFSET)) { $limitOffset = $select->getPart(Kwf_Model_Select::LIMIT_OFFSET); $dataKeys = array_slice($dataKeys, $limitOffset); } if ($select->hasPart(Kwf_Model_Select::LIMIT_COUNT)) { $limitCount = $select->getPart(Kwf_Model_Select::LIMIT_COUNT); $dataKeys = array_slice($dataKeys, 0, $limitCount); } if ($select->hasPart(Kwf_Model_Select::UNION)) { foreach ($select->getPart(Kwf_Model_Select::UNION) as $unionSel) { $dataKeys = array_merge($dataKeys, $this->_selectDataKeys($unionSel, $inData)); } } return $dataKeys; }
php
protected function _selectDataKeys(Kwf_Model_Select $select, array &$inData) { $dataKeys = array(); foreach ($inData as $key=>$d) { if ($this->_matchSelect($d, $select)) { $dataKeys[] = $key; } } if ($order = $select->getPart(Kwf_Model_Select::ORDER)) { if (count($order) > 1) { //TODO: implement Multiple Order fields } $order = current($order); $orderData = array(); foreach ($dataKeys as $key) { if ($order['field'] instanceof Zend_Db_Expr) { //can't be done in FnF $orderData[$inData[$key][$this->_primaryKey]] = 0; } else if ($order['field'] == Kwf_Model_Select::ORDER_RAND) { $orderData[$inData[$key][$this->_primaryKey]] = rand(); } else { $orderData[$inData[$key][$this->_primaryKey]] = strtolower($this->_rowValue($order['field'], $inData[$key])); } } if ($order['direction'] == 'ASC') { asort($orderData); } else if ($order['direction'] == 'DESC') { arsort($orderData); } else { throw new Kwf_Exception("Invalid order direction: {$order['direction']}"); } $sortedDataKeys = array(); foreach (array_keys($orderData) as $id) { foreach ($dataKeys as $key) { if ($inData[$key][$this->_primaryKey] == $id) { $sortedDataKeys[] = $key; } } } $dataKeys = $sortedDataKeys; } if ($select->hasPart(Kwf_Model_Select::LIMIT_OFFSET)) { $limitOffset = $select->getPart(Kwf_Model_Select::LIMIT_OFFSET); $dataKeys = array_slice($dataKeys, $limitOffset); } if ($select->hasPart(Kwf_Model_Select::LIMIT_COUNT)) { $limitCount = $select->getPart(Kwf_Model_Select::LIMIT_COUNT); $dataKeys = array_slice($dataKeys, 0, $limitCount); } if ($select->hasPart(Kwf_Model_Select::UNION)) { foreach ($select->getPart(Kwf_Model_Select::UNION) as $unionSel) { $dataKeys = array_merge($dataKeys, $this->_selectDataKeys($unionSel, $inData)); } } return $dataKeys; }
[ "protected", "function", "_selectDataKeys", "(", "Kwf_Model_Select", "$", "select", ",", "array", "&", "$", "inData", ")", "{", "$", "dataKeys", "=", "array", "(", ")", ";", "foreach", "(", "$", "inData", "as", "$", "key", "=>", "$", "d", ")", "{", "if", "(", "$", "this", "->", "_matchSelect", "(", "$", "d", ",", "$", "select", ")", ")", "{", "$", "dataKeys", "[", "]", "=", "$", "key", ";", "}", "}", "if", "(", "$", "order", "=", "$", "select", "->", "getPart", "(", "Kwf_Model_Select", "::", "ORDER", ")", ")", "{", "if", "(", "count", "(", "$", "order", ")", ">", "1", ")", "{", "//TODO: implement Multiple Order fields", "}", "$", "order", "=", "current", "(", "$", "order", ")", ";", "$", "orderData", "=", "array", "(", ")", ";", "foreach", "(", "$", "dataKeys", "as", "$", "key", ")", "{", "if", "(", "$", "order", "[", "'field'", "]", "instanceof", "Zend_Db_Expr", ")", "{", "//can't be done in FnF", "$", "orderData", "[", "$", "inData", "[", "$", "key", "]", "[", "$", "this", "->", "_primaryKey", "]", "]", "=", "0", ";", "}", "else", "if", "(", "$", "order", "[", "'field'", "]", "==", "Kwf_Model_Select", "::", "ORDER_RAND", ")", "{", "$", "orderData", "[", "$", "inData", "[", "$", "key", "]", "[", "$", "this", "->", "_primaryKey", "]", "]", "=", "rand", "(", ")", ";", "}", "else", "{", "$", "orderData", "[", "$", "inData", "[", "$", "key", "]", "[", "$", "this", "->", "_primaryKey", "]", "]", "=", "strtolower", "(", "$", "this", "->", "_rowValue", "(", "$", "order", "[", "'field'", "]", ",", "$", "inData", "[", "$", "key", "]", ")", ")", ";", "}", "}", "if", "(", "$", "order", "[", "'direction'", "]", "==", "'ASC'", ")", "{", "asort", "(", "$", "orderData", ")", ";", "}", "else", "if", "(", "$", "order", "[", "'direction'", "]", "==", "'DESC'", ")", "{", "arsort", "(", "$", "orderData", ")", ";", "}", "else", "{", "throw", "new", "Kwf_Exception", "(", "\"Invalid order direction: {$order['direction']}\"", ")", ";", "}", "$", "sortedDataKeys", "=", "array", "(", ")", ";", "foreach", "(", "array_keys", "(", "$", "orderData", ")", "as", "$", "id", ")", "{", "foreach", "(", "$", "dataKeys", "as", "$", "key", ")", "{", "if", "(", "$", "inData", "[", "$", "key", "]", "[", "$", "this", "->", "_primaryKey", "]", "==", "$", "id", ")", "{", "$", "sortedDataKeys", "[", "]", "=", "$", "key", ";", "}", "}", "}", "$", "dataKeys", "=", "$", "sortedDataKeys", ";", "}", "if", "(", "$", "select", "->", "hasPart", "(", "Kwf_Model_Select", "::", "LIMIT_OFFSET", ")", ")", "{", "$", "limitOffset", "=", "$", "select", "->", "getPart", "(", "Kwf_Model_Select", "::", "LIMIT_OFFSET", ")", ";", "$", "dataKeys", "=", "array_slice", "(", "$", "dataKeys", ",", "$", "limitOffset", ")", ";", "}", "if", "(", "$", "select", "->", "hasPart", "(", "Kwf_Model_Select", "::", "LIMIT_COUNT", ")", ")", "{", "$", "limitCount", "=", "$", "select", "->", "getPart", "(", "Kwf_Model_Select", "::", "LIMIT_COUNT", ")", ";", "$", "dataKeys", "=", "array_slice", "(", "$", "dataKeys", ",", "0", ",", "$", "limitCount", ")", ";", "}", "if", "(", "$", "select", "->", "hasPart", "(", "Kwf_Model_Select", "::", "UNION", ")", ")", "{", "foreach", "(", "$", "select", "->", "getPart", "(", "Kwf_Model_Select", "::", "UNION", ")", "as", "$", "unionSel", ")", "{", "$", "dataKeys", "=", "array_merge", "(", "$", "dataKeys", ",", "$", "this", "->", "_selectDataKeys", "(", "$", "unionSel", ",", "$", "inData", ")", ")", ";", "}", "}", "return", "$", "dataKeys", ";", "}" ]
& für performance
[ "&", "für", "performance" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Model/Data/Abstract.php#L158-L216
koala-framework/koala-framework
Kwf/Controller/Action/Auto/Synctree.php
Kwf_Controller_Action_Auto_Synctree._getSelect
protected function _getSelect() { $select = $this->_model->select(); if ($this->_hasPosition) { $select->order('pos'); } else if (!$select->hasPart('order') && $this->_defaultOrder) { $select->order( $this->_defaultOrder['field'], $this->_defaultOrder['direction'] ); } return $select; }
php
protected function _getSelect() { $select = $this->_model->select(); if ($this->_hasPosition) { $select->order('pos'); } else if (!$select->hasPart('order') && $this->_defaultOrder) { $select->order( $this->_defaultOrder['field'], $this->_defaultOrder['direction'] ); } return $select; }
[ "protected", "function", "_getSelect", "(", ")", "{", "$", "select", "=", "$", "this", "->", "_model", "->", "select", "(", ")", ";", "if", "(", "$", "this", "->", "_hasPosition", ")", "{", "$", "select", "->", "order", "(", "'pos'", ")", ";", "}", "else", "if", "(", "!", "$", "select", "->", "hasPart", "(", "'order'", ")", "&&", "$", "this", "->", "_defaultOrder", ")", "{", "$", "select", "->", "order", "(", "$", "this", "->", "_defaultOrder", "[", "'field'", "]", ",", "$", "this", "->", "_defaultOrder", "[", "'direction'", "]", ")", ";", "}", "return", "$", "select", ";", "}" ]
override this method to handle the output of this view. Just return the select statement which serves your needs.
[ "override", "this", "method", "to", "handle", "the", "output", "of", "this", "view", ".", "Just", "return", "the", "select", "statement", "which", "serves", "your", "needs", "." ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Controller/Action/Auto/Synctree.php#L372-L384
koala-framework/koala-framework
Kwc/Abstract/Image/Update/20150309Legacy40002.php
Kwc_Abstract_Image_Update_20150309Legacy40002.update
public function update() { parent::update(); $select = new Kwf_Model_Select(); $select->where(new Kwf_Model_Select_Expr_Or(array( new Kwf_Model_Select_Expr_Equals('dimension', 'customcrop'), new Kwf_Model_Select_Expr_Equals('dimension', 'custombestfit') ))); $select->order('dimension', 'ASC'); $rows = Kwf_Model_Abstract::getInstance('Kwc_Abstract_Image_Model')->getRows($select); foreach ($rows as $row) { if ($row->dimension == 'customcrop') { $row->dimension = 'custom'; $row->crop_x = null; $row->crop_y = null; $row->crop_width = null; $row->crop_heigth = null; } else if ($row->dimension == 'custombestfit') { $row->dimension = 'custom'; if ($row->imageExists()) { $targetSize = array( 'width' => $row->width, 'height' => $row->height, 'cover' => false, ); $outputSize = Kwf_Media_Image::calculateScaleDimensions( $row->getParentRow('Image')->getImageDimensions(), $targetSize); $row->width = $outputSize['width']; $row->height = $outputSize['height']; $row->crop_x = $outputSize['crop']['x']; $row->crop_y = $outputSize['crop']['y']; $row->crop_width = $outputSize['crop']['width']; $row->crop_height = $outputSize['crop']['height']; } } $row->save(); } }
php
public function update() { parent::update(); $select = new Kwf_Model_Select(); $select->where(new Kwf_Model_Select_Expr_Or(array( new Kwf_Model_Select_Expr_Equals('dimension', 'customcrop'), new Kwf_Model_Select_Expr_Equals('dimension', 'custombestfit') ))); $select->order('dimension', 'ASC'); $rows = Kwf_Model_Abstract::getInstance('Kwc_Abstract_Image_Model')->getRows($select); foreach ($rows as $row) { if ($row->dimension == 'customcrop') { $row->dimension = 'custom'; $row->crop_x = null; $row->crop_y = null; $row->crop_width = null; $row->crop_heigth = null; } else if ($row->dimension == 'custombestfit') { $row->dimension = 'custom'; if ($row->imageExists()) { $targetSize = array( 'width' => $row->width, 'height' => $row->height, 'cover' => false, ); $outputSize = Kwf_Media_Image::calculateScaleDimensions( $row->getParentRow('Image')->getImageDimensions(), $targetSize); $row->width = $outputSize['width']; $row->height = $outputSize['height']; $row->crop_x = $outputSize['crop']['x']; $row->crop_y = $outputSize['crop']['y']; $row->crop_width = $outputSize['crop']['width']; $row->crop_height = $outputSize['crop']['height']; } } $row->save(); } }
[ "public", "function", "update", "(", ")", "{", "parent", "::", "update", "(", ")", ";", "$", "select", "=", "new", "Kwf_Model_Select", "(", ")", ";", "$", "select", "->", "where", "(", "new", "Kwf_Model_Select_Expr_Or", "(", "array", "(", "new", "Kwf_Model_Select_Expr_Equals", "(", "'dimension'", ",", "'customcrop'", ")", ",", "new", "Kwf_Model_Select_Expr_Equals", "(", "'dimension'", ",", "'custombestfit'", ")", ")", ")", ")", ";", "$", "select", "->", "order", "(", "'dimension'", ",", "'ASC'", ")", ";", "$", "rows", "=", "Kwf_Model_Abstract", "::", "getInstance", "(", "'Kwc_Abstract_Image_Model'", ")", "->", "getRows", "(", "$", "select", ")", ";", "foreach", "(", "$", "rows", "as", "$", "row", ")", "{", "if", "(", "$", "row", "->", "dimension", "==", "'customcrop'", ")", "{", "$", "row", "->", "dimension", "=", "'custom'", ";", "$", "row", "->", "crop_x", "=", "null", ";", "$", "row", "->", "crop_y", "=", "null", ";", "$", "row", "->", "crop_width", "=", "null", ";", "$", "row", "->", "crop_heigth", "=", "null", ";", "}", "else", "if", "(", "$", "row", "->", "dimension", "==", "'custombestfit'", ")", "{", "$", "row", "->", "dimension", "=", "'custom'", ";", "if", "(", "$", "row", "->", "imageExists", "(", ")", ")", "{", "$", "targetSize", "=", "array", "(", "'width'", "=>", "$", "row", "->", "width", ",", "'height'", "=>", "$", "row", "->", "height", ",", "'cover'", "=>", "false", ",", ")", ";", "$", "outputSize", "=", "Kwf_Media_Image", "::", "calculateScaleDimensions", "(", "$", "row", "->", "getParentRow", "(", "'Image'", ")", "->", "getImageDimensions", "(", ")", ",", "$", "targetSize", ")", ";", "$", "row", "->", "width", "=", "$", "outputSize", "[", "'width'", "]", ";", "$", "row", "->", "height", "=", "$", "outputSize", "[", "'height'", "]", ";", "$", "row", "->", "crop_x", "=", "$", "outputSize", "[", "'crop'", "]", "[", "'x'", "]", ";", "$", "row", "->", "crop_y", "=", "$", "outputSize", "[", "'crop'", "]", "[", "'y'", "]", ";", "$", "row", "->", "crop_width", "=", "$", "outputSize", "[", "'crop'", "]", "[", "'width'", "]", ";", "$", "row", "->", "crop_height", "=", "$", "outputSize", "[", "'crop'", "]", "[", "'height'", "]", ";", "}", "}", "$", "row", "->", "save", "(", ")", ";", "}", "}" ]
Test update: vps update --class=Update_19
[ "Test", "update", ":", "vps", "update", "--", "class", "=", "Update_19" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Abstract/Image/Update/20150309Legacy40002.php#L5-L43
koala-framework/koala-framework
Kwf/Util/Aws/ElastiCache/CacheClusterEndpoints.php
Kwf_Util_Aws_ElastiCache_CacheClusterEndpoints.get
public static function get($cacheClusterId) { if (!$cacheClusterId) throw new Kwf_Exception("cacheClusterId is requried"); $ec = new Kwf_Util_Aws_ElastiCache(); $r = $ec->describe_cache_clusters(array( 'ShowCacheNodeInfo' => true, 'CacheClusterId' => $cacheClusterId )); if (!$r->isOk()) { if (isset($r->body->Error->Message)) { throw new Kwf_Exception($r->body->Error->Message); } else { throw new Kwf_Exception("Getting CacheClusters failed"); } } $servers = array(); foreach ($r->body->DescribeCacheClustersResult->CacheClusters->CacheCluster->CacheNodes->CacheNode as $node) { $servers[] = array( 'host' => (string)$node->Endpoint->Address, 'port' => (int)$node->Endpoint->Port, ); } return $servers; }
php
public static function get($cacheClusterId) { if (!$cacheClusterId) throw new Kwf_Exception("cacheClusterId is requried"); $ec = new Kwf_Util_Aws_ElastiCache(); $r = $ec->describe_cache_clusters(array( 'ShowCacheNodeInfo' => true, 'CacheClusterId' => $cacheClusterId )); if (!$r->isOk()) { if (isset($r->body->Error->Message)) { throw new Kwf_Exception($r->body->Error->Message); } else { throw new Kwf_Exception("Getting CacheClusters failed"); } } $servers = array(); foreach ($r->body->DescribeCacheClustersResult->CacheClusters->CacheCluster->CacheNodes->CacheNode as $node) { $servers[] = array( 'host' => (string)$node->Endpoint->Address, 'port' => (int)$node->Endpoint->Port, ); } return $servers; }
[ "public", "static", "function", "get", "(", "$", "cacheClusterId", ")", "{", "if", "(", "!", "$", "cacheClusterId", ")", "throw", "new", "Kwf_Exception", "(", "\"cacheClusterId is requried\"", ")", ";", "$", "ec", "=", "new", "Kwf_Util_Aws_ElastiCache", "(", ")", ";", "$", "r", "=", "$", "ec", "->", "describe_cache_clusters", "(", "array", "(", "'ShowCacheNodeInfo'", "=>", "true", ",", "'CacheClusterId'", "=>", "$", "cacheClusterId", ")", ")", ";", "if", "(", "!", "$", "r", "->", "isOk", "(", ")", ")", "{", "if", "(", "isset", "(", "$", "r", "->", "body", "->", "Error", "->", "Message", ")", ")", "{", "throw", "new", "Kwf_Exception", "(", "$", "r", "->", "body", "->", "Error", "->", "Message", ")", ";", "}", "else", "{", "throw", "new", "Kwf_Exception", "(", "\"Getting CacheClusters failed\"", ")", ";", "}", "}", "$", "servers", "=", "array", "(", ")", ";", "foreach", "(", "$", "r", "->", "body", "->", "DescribeCacheClustersResult", "->", "CacheClusters", "->", "CacheCluster", "->", "CacheNodes", "->", "CacheNode", "as", "$", "node", ")", "{", "$", "servers", "[", "]", "=", "array", "(", "'host'", "=>", "(", "string", ")", "$", "node", "->", "Endpoint", "->", "Address", ",", "'port'", "=>", "(", "int", ")", "$", "node", "->", "Endpoint", "->", "Port", ",", ")", ";", "}", "return", "$", "servers", ";", "}" ]
uncached, use getCached to use cache
[ "uncached", "use", "getCached", "to", "use", "cache" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Util/Aws/ElastiCache/CacheClusterEndpoints.php#L24-L47
koala-framework/koala-framework
Kwf/Util/Aws/ElastiCache/CacheClusterEndpoints.php
Kwf_Util_Aws_ElastiCache_CacheClusterEndpoints.getCached
public static function getCached($cacheClusterId) { $cacheId = self::_getCacheId($cacheClusterId); $servers = self::_getCache()->load($cacheId); if ($servers === false) { $servers = self::refreshCache($cacheClusterId); } return $servers; }
php
public static function getCached($cacheClusterId) { $cacheId = self::_getCacheId($cacheClusterId); $servers = self::_getCache()->load($cacheId); if ($servers === false) { $servers = self::refreshCache($cacheClusterId); } return $servers; }
[ "public", "static", "function", "getCached", "(", "$", "cacheClusterId", ")", "{", "$", "cacheId", "=", "self", "::", "_getCacheId", "(", "$", "cacheClusterId", ")", ";", "$", "servers", "=", "self", "::", "_getCache", "(", ")", "->", "load", "(", "$", "cacheId", ")", ";", "if", "(", "$", "servers", "===", "false", ")", "{", "$", "servers", "=", "self", "::", "refreshCache", "(", "$", "cacheClusterId", ")", ";", "}", "return", "$", "servers", ";", "}" ]
if used you need to refresh this cache yourself
[ "if", "used", "you", "need", "to", "refresh", "this", "cache", "yourself" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Util/Aws/ElastiCache/CacheClusterEndpoints.php#L57-L65
koala-framework/koala-framework
Kwf/Db/Table/Select.php
Kwf_Db_Table_Select.searchLike
public function searchLike($searchValues = array(), $searchFields = '*') { if (is_string($searchValues)) $searchValues = array('query' => $searchValues); if (is_string($searchFields)) $searchFields = array($searchFields); foreach ($searchValues as $column => $value) { if (empty($value) || ($column != 'query' && !in_array($column, $this->_table()->getColumns())) ) { continue; } $searchWords = preg_split('/[\s-+,;*]/', $value); foreach ($searchWords as $searchWord) { $searchWord = trim($searchWord); if (empty($searchWord)) continue; if ($column == 'query') { if (!$searchFields) { throw new Kwf_Exception("Search field 'query' was found, " ."but no 'searchFields' were given as second argument in " ."'searchLike' method of Kwf_Db_Table_Select object"); } if (in_array('*', $searchFields)) { $searchFields = array_merge($searchFields, $this->_table()->getColumns()); foreach ($searchFields as $sfk => $sfv) { if ($sfv == '*') unset($searchFields[$sfk]); if (substr($sfv, 0, 1) == '!') { unset($searchFields[$sfk]); unset($searchFields[array_search(substr($sfv, 1), $searchFields)]); } } } $wheres = array(); foreach ($searchFields as $field) { if (strpos($field, '.') === false) { $field = $this->_table->getTableName().'.'.$field; } $wheres[] = Kwf_Registry::get('db')->quoteInto( $field.' LIKE ?', "%$searchWord%" ); } $this->where(implode(' OR ', $wheres)); } else { $this->where($column.' LIKE ?', "%".$searchWord."%"); } } } return $this; }
php
public function searchLike($searchValues = array(), $searchFields = '*') { if (is_string($searchValues)) $searchValues = array('query' => $searchValues); if (is_string($searchFields)) $searchFields = array($searchFields); foreach ($searchValues as $column => $value) { if (empty($value) || ($column != 'query' && !in_array($column, $this->_table()->getColumns())) ) { continue; } $searchWords = preg_split('/[\s-+,;*]/', $value); foreach ($searchWords as $searchWord) { $searchWord = trim($searchWord); if (empty($searchWord)) continue; if ($column == 'query') { if (!$searchFields) { throw new Kwf_Exception("Search field 'query' was found, " ."but no 'searchFields' were given as second argument in " ."'searchLike' method of Kwf_Db_Table_Select object"); } if (in_array('*', $searchFields)) { $searchFields = array_merge($searchFields, $this->_table()->getColumns()); foreach ($searchFields as $sfk => $sfv) { if ($sfv == '*') unset($searchFields[$sfk]); if (substr($sfv, 0, 1) == '!') { unset($searchFields[$sfk]); unset($searchFields[array_search(substr($sfv, 1), $searchFields)]); } } } $wheres = array(); foreach ($searchFields as $field) { if (strpos($field, '.') === false) { $field = $this->_table->getTableName().'.'.$field; } $wheres[] = Kwf_Registry::get('db')->quoteInto( $field.' LIKE ?', "%$searchWord%" ); } $this->where(implode(' OR ', $wheres)); } else { $this->where($column.' LIKE ?', "%".$searchWord."%"); } } } return $this; }
[ "public", "function", "searchLike", "(", "$", "searchValues", "=", "array", "(", ")", ",", "$", "searchFields", "=", "'*'", ")", "{", "if", "(", "is_string", "(", "$", "searchValues", ")", ")", "$", "searchValues", "=", "array", "(", "'query'", "=>", "$", "searchValues", ")", ";", "if", "(", "is_string", "(", "$", "searchFields", ")", ")", "$", "searchFields", "=", "array", "(", "$", "searchFields", ")", ";", "foreach", "(", "$", "searchValues", "as", "$", "column", "=>", "$", "value", ")", "{", "if", "(", "empty", "(", "$", "value", ")", "||", "(", "$", "column", "!=", "'query'", "&&", "!", "in_array", "(", "$", "column", ",", "$", "this", "->", "_table", "(", ")", "->", "getColumns", "(", ")", ")", ")", ")", "{", "continue", ";", "}", "$", "searchWords", "=", "preg_split", "(", "'/[\\s-+,;*]/'", ",", "$", "value", ")", ";", "foreach", "(", "$", "searchWords", "as", "$", "searchWord", ")", "{", "$", "searchWord", "=", "trim", "(", "$", "searchWord", ")", ";", "if", "(", "empty", "(", "$", "searchWord", ")", ")", "continue", ";", "if", "(", "$", "column", "==", "'query'", ")", "{", "if", "(", "!", "$", "searchFields", ")", "{", "throw", "new", "Kwf_Exception", "(", "\"Search field 'query' was found, \"", ".", "\"but no 'searchFields' were given as second argument in \"", ".", "\"'searchLike' method of Kwf_Db_Table_Select object\"", ")", ";", "}", "if", "(", "in_array", "(", "'*'", ",", "$", "searchFields", ")", ")", "{", "$", "searchFields", "=", "array_merge", "(", "$", "searchFields", ",", "$", "this", "->", "_table", "(", ")", "->", "getColumns", "(", ")", ")", ";", "foreach", "(", "$", "searchFields", "as", "$", "sfk", "=>", "$", "sfv", ")", "{", "if", "(", "$", "sfv", "==", "'*'", ")", "unset", "(", "$", "searchFields", "[", "$", "sfk", "]", ")", ";", "if", "(", "substr", "(", "$", "sfv", ",", "0", ",", "1", ")", "==", "'!'", ")", "{", "unset", "(", "$", "searchFields", "[", "$", "sfk", "]", ")", ";", "unset", "(", "$", "searchFields", "[", "array_search", "(", "substr", "(", "$", "sfv", ",", "1", ")", ",", "$", "searchFields", ")", "]", ")", ";", "}", "}", "}", "$", "wheres", "=", "array", "(", ")", ";", "foreach", "(", "$", "searchFields", "as", "$", "field", ")", "{", "if", "(", "strpos", "(", "$", "field", ",", "'.'", ")", "===", "false", ")", "{", "$", "field", "=", "$", "this", "->", "_table", "->", "getTableName", "(", ")", ".", "'.'", ".", "$", "field", ";", "}", "$", "wheres", "[", "]", "=", "Kwf_Registry", "::", "get", "(", "'db'", ")", "->", "quoteInto", "(", "$", "field", ".", "' LIKE ?'", ",", "\"%$searchWord%\"", ")", ";", "}", "$", "this", "->", "where", "(", "implode", "(", "' OR '", ",", "$", "wheres", ")", ")", ";", "}", "else", "{", "$", "this", "->", "where", "(", "$", "column", ".", "' LIKE ?'", ",", "\"%\"", ".", "$", "searchWord", ".", "\"%\"", ")", ";", "}", "}", "}", "return", "$", "this", ";", "}" ]
Adds the needed wheres for a search @deprecated use Kwf_Model_Select_Expr_SearchLike instead @param string|array $searchValues An array with the db-field in the key and the search value as value. Field query means to search in all given fields for this value (see the second argument). If a string is given, it is interpreted like array('query' => $searchValues). @param string|array $searchFields The fields that should be searched with search field 'query'. If a string is given, it is treated like array($string). Value '*' means to search in all fields in the table. @return object $this The select object itself
[ "Adds", "the", "needed", "wheres", "for", "a", "search" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Db/Table/Select.php#L53-L102
koala-framework/koala-framework
Kwf/Db/Table/Select.php
Kwf_Db_Table_Select.from
public function from($name, $cols = self::SQL_WILDCARD, $schema = null) { if ($name instanceof Kwf_Db_Table) { $schema = $name->getTableName(); $schema = $name->getSchemaName(); } return $this->joinInner($name, null, $cols, $schema); }
php
public function from($name, $cols = self::SQL_WILDCARD, $schema = null) { if ($name instanceof Kwf_Db_Table) { $schema = $name->getTableName(); $schema = $name->getSchemaName(); } return $this->joinInner($name, null, $cols, $schema); }
[ "public", "function", "from", "(", "$", "name", ",", "$", "cols", "=", "self", "::", "SQL_WILDCARD", ",", "$", "schema", "=", "null", ")", "{", "if", "(", "$", "name", "instanceof", "Kwf_Db_Table", ")", "{", "$", "schema", "=", "$", "name", "->", "getTableName", "(", ")", ";", "$", "schema", "=", "$", "name", "->", "getSchemaName", "(", ")", ";", "}", "return", "$", "this", "->", "joinInner", "(", "$", "name", ",", "null", ",", "$", "cols", ",", "$", "schema", ")", ";", "}" ]
Adds a FROM table and optional columns to the query. The table name can be expressed @param array|string|Zend_Db_Expr|Kwf_Db_Table $name The table name or an associative array relating table name to correlation name. @param array|string|Zend_Db_Expr $cols The columns to select from this table. @param string $schema The schema name to specify, if any. @return Kwf_Db_Table_Select This Kwf_Db_Table_Select object.
[ "Adds", "a", "FROM", "table", "and", "optional", "columns", "to", "the", "query", "." ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Db/Table/Select.php#L196-L204
koala-framework/koala-framework
Kwf/Db/Table/Select.php
Kwf_Db_Table_Select.assemble
public function assemble() { $fields = $this->getPart(Kwf_Db_Table_Select::COLUMNS); $primary = $this->_table->getTableName(); $schema = $this->_table->getSchemaName(); if (count($this->_parts[self::UNION]) == 0) { // If no fields are specified we assume all fields from primary table if (!count($fields)) { $this->from($primary, self::SQL_WILDCARD, $schema); $fields = $this->getPart(Kwf_Db_Table_Select::COLUMNS); } $from = $this->getPart(Kwf_Db_Table_Select::FROM); if ($this->_integrityCheck !== false) { foreach ($fields as $columnEntry) { list($table, $column) = $columnEntry; // Check each column to ensure it only references the primary table if ($column) { if (!isset($from[$table]) || $from[$table]['tableName'] != $primary) { throw new Kwf_Exception('Select query cannot join with another table'); } } } } } return parent::assemble(); }
php
public function assemble() { $fields = $this->getPart(Kwf_Db_Table_Select::COLUMNS); $primary = $this->_table->getTableName(); $schema = $this->_table->getSchemaName(); if (count($this->_parts[self::UNION]) == 0) { // If no fields are specified we assume all fields from primary table if (!count($fields)) { $this->from($primary, self::SQL_WILDCARD, $schema); $fields = $this->getPart(Kwf_Db_Table_Select::COLUMNS); } $from = $this->getPart(Kwf_Db_Table_Select::FROM); if ($this->_integrityCheck !== false) { foreach ($fields as $columnEntry) { list($table, $column) = $columnEntry; // Check each column to ensure it only references the primary table if ($column) { if (!isset($from[$table]) || $from[$table]['tableName'] != $primary) { throw new Kwf_Exception('Select query cannot join with another table'); } } } } } return parent::assemble(); }
[ "public", "function", "assemble", "(", ")", "{", "$", "fields", "=", "$", "this", "->", "getPart", "(", "Kwf_Db_Table_Select", "::", "COLUMNS", ")", ";", "$", "primary", "=", "$", "this", "->", "_table", "->", "getTableName", "(", ")", ";", "$", "schema", "=", "$", "this", "->", "_table", "->", "getSchemaName", "(", ")", ";", "if", "(", "count", "(", "$", "this", "->", "_parts", "[", "self", "::", "UNION", "]", ")", "==", "0", ")", "{", "// If no fields are specified we assume all fields from primary table", "if", "(", "!", "count", "(", "$", "fields", ")", ")", "{", "$", "this", "->", "from", "(", "$", "primary", ",", "self", "::", "SQL_WILDCARD", ",", "$", "schema", ")", ";", "$", "fields", "=", "$", "this", "->", "getPart", "(", "Kwf_Db_Table_Select", "::", "COLUMNS", ")", ";", "}", "$", "from", "=", "$", "this", "->", "getPart", "(", "Kwf_Db_Table_Select", "::", "FROM", ")", ";", "if", "(", "$", "this", "->", "_integrityCheck", "!==", "false", ")", "{", "foreach", "(", "$", "fields", "as", "$", "columnEntry", ")", "{", "list", "(", "$", "table", ",", "$", "column", ")", "=", "$", "columnEntry", ";", "// Check each column to ensure it only references the primary table", "if", "(", "$", "column", ")", "{", "if", "(", "!", "isset", "(", "$", "from", "[", "$", "table", "]", ")", "||", "$", "from", "[", "$", "table", "]", "[", "'tableName'", "]", "!=", "$", "primary", ")", "{", "throw", "new", "Kwf_Exception", "(", "'Select query cannot join with another table'", ")", ";", "}", "}", "}", "}", "}", "return", "parent", "::", "assemble", "(", ")", ";", "}" ]
Performs a validation on the select query before passing back to the parent class. Ensures that only columns from the primary Kwf_Db_Table are returned in the result. @return string|null This object as a SELECT string (or null if a string cannot be produced)
[ "Performs", "a", "validation", "on", "the", "select", "query", "before", "passing", "back", "to", "the", "parent", "class", ".", "Ensures", "that", "only", "columns", "from", "the", "primary", "Kwf_Db_Table", "are", "returned", "in", "the", "result", "." ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Db/Table/Select.php#L212-L244
koala-framework/koala-framework
Kwf/Acl.php
Kwf_Acl.loadKwcResources
public function loadKwcResources() { if (!Kwf_Registry::get('db')) return; //if we don't have a db configured yet skip kwc resources. required to be able to build assets without db if ($this->_kwcResourcesLoaded) return; $this->_kwcResourcesLoaded = true; $t = microtime(true); $menuConfigs = array(); foreach (Kwc_Abstract::getComponentClasses() as $c) { if (Kwc_Abstract::getFlag($c, 'hasResources')) { Kwc_Admin::getInstance($c)->addResources($this); } if (Kwc_Abstract::hasSetting($c, 'menuConfig') && Kwc_Abstract::getSetting($c, 'menuConfig')) { $menuConfigs[] = Kwf_Component_Abstract_MenuConfig_Abstract::getInstance($c); } } usort($menuConfigs, array(get_class($this), '_compareMenuConfig')); foreach ($menuConfigs as $cfg) { $cfg->addResources($this); } Kwf_Benchmark::subCheckpoint('kwc resources', microtime(true)-$t); }
php
public function loadKwcResources() { if (!Kwf_Registry::get('db')) return; //if we don't have a db configured yet skip kwc resources. required to be able to build assets without db if ($this->_kwcResourcesLoaded) return; $this->_kwcResourcesLoaded = true; $t = microtime(true); $menuConfigs = array(); foreach (Kwc_Abstract::getComponentClasses() as $c) { if (Kwc_Abstract::getFlag($c, 'hasResources')) { Kwc_Admin::getInstance($c)->addResources($this); } if (Kwc_Abstract::hasSetting($c, 'menuConfig') && Kwc_Abstract::getSetting($c, 'menuConfig')) { $menuConfigs[] = Kwf_Component_Abstract_MenuConfig_Abstract::getInstance($c); } } usort($menuConfigs, array(get_class($this), '_compareMenuConfig')); foreach ($menuConfigs as $cfg) { $cfg->addResources($this); } Kwf_Benchmark::subCheckpoint('kwc resources', microtime(true)-$t); }
[ "public", "function", "loadKwcResources", "(", ")", "{", "if", "(", "!", "Kwf_Registry", "::", "get", "(", "'db'", ")", ")", "return", ";", "//if we don't have a db configured yet skip kwc resources. required to be able to build assets without db", "if", "(", "$", "this", "->", "_kwcResourcesLoaded", ")", "return", ";", "$", "this", "->", "_kwcResourcesLoaded", "=", "true", ";", "$", "t", "=", "microtime", "(", "true", ")", ";", "$", "menuConfigs", "=", "array", "(", ")", ";", "foreach", "(", "Kwc_Abstract", "::", "getComponentClasses", "(", ")", "as", "$", "c", ")", "{", "if", "(", "Kwc_Abstract", "::", "getFlag", "(", "$", "c", ",", "'hasResources'", ")", ")", "{", "Kwc_Admin", "::", "getInstance", "(", "$", "c", ")", "->", "addResources", "(", "$", "this", ")", ";", "}", "if", "(", "Kwc_Abstract", "::", "hasSetting", "(", "$", "c", ",", "'menuConfig'", ")", "&&", "Kwc_Abstract", "::", "getSetting", "(", "$", "c", ",", "'menuConfig'", ")", ")", "{", "$", "menuConfigs", "[", "]", "=", "Kwf_Component_Abstract_MenuConfig_Abstract", "::", "getInstance", "(", "$", "c", ")", ";", "}", "}", "usort", "(", "$", "menuConfigs", ",", "array", "(", "get_class", "(", "$", "this", ")", ",", "'_compareMenuConfig'", ")", ")", ";", "foreach", "(", "$", "menuConfigs", "as", "$", "cfg", ")", "{", "$", "cfg", "->", "addResources", "(", "$", "this", ")", ";", "}", "Kwf_Benchmark", "::", "subCheckpoint", "(", "'kwc resources'", ",", "microtime", "(", "true", ")", "-", "$", "t", ")", ";", "}" ]
Lädt Resourcen die von Komponenten kommen. Muss extra aufgerufen werden wenn diese Resourcen benötigt werden, aus performance gründen
[ "Lädt", "Resourcen", "die", "von", "Komponenten", "kommen", ".", "Muss", "extra", "aufgerufen", "werden", "wenn", "diese", "Resourcen", "benötigt", "werden", "aus", "performance", "gründen" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Acl.php#L261-L283
koala-framework/koala-framework
Kwf/Assets/GoogleMapsApiKey.php
Kwf_Assets_GoogleMapsApiKey.getConfigDomain
public static function getConfigDomain($host) { if (!$host) return null; $longDomainEndings = array('or.at', 'co.at', 'gv.at', 'co.uk'); // cleaning out the dots of long domain endings foreach ($longDomainEndings as $k => $v) { $longDomainEndings[$k] = str_replace('.', '', $v); } $hostParts = explode('.', $host); if (count($hostParts) <= 1) { $ret = $host; } else { $ret = $hostParts[count($hostParts)-2] // zB 'vivid-planet' .$hostParts[count($hostParts)-1]; // zB 'com' } if (in_array($ret, $longDomainEndings)) { $ret = $hostParts[count($hostParts)-3].$ret; } return $ret; }
php
public static function getConfigDomain($host) { if (!$host) return null; $longDomainEndings = array('or.at', 'co.at', 'gv.at', 'co.uk'); // cleaning out the dots of long domain endings foreach ($longDomainEndings as $k => $v) { $longDomainEndings[$k] = str_replace('.', '', $v); } $hostParts = explode('.', $host); if (count($hostParts) <= 1) { $ret = $host; } else { $ret = $hostParts[count($hostParts)-2] // zB 'vivid-planet' .$hostParts[count($hostParts)-1]; // zB 'com' } if (in_array($ret, $longDomainEndings)) { $ret = $hostParts[count($hostParts)-3].$ret; } return $ret; }
[ "public", "static", "function", "getConfigDomain", "(", "$", "host", ")", "{", "if", "(", "!", "$", "host", ")", "return", "null", ";", "$", "longDomainEndings", "=", "array", "(", "'or.at'", ",", "'co.at'", ",", "'gv.at'", ",", "'co.uk'", ")", ";", "// cleaning out the dots of long domain endings", "foreach", "(", "$", "longDomainEndings", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "longDomainEndings", "[", "$", "k", "]", "=", "str_replace", "(", "'.'", ",", "''", ",", "$", "v", ")", ";", "}", "$", "hostParts", "=", "explode", "(", "'.'", ",", "$", "host", ")", ";", "if", "(", "count", "(", "$", "hostParts", ")", "<=", "1", ")", "{", "$", "ret", "=", "$", "host", ";", "}", "else", "{", "$", "ret", "=", "$", "hostParts", "[", "count", "(", "$", "hostParts", ")", "-", "2", "]", "// zB 'vivid-planet'", ".", "$", "hostParts", "[", "count", "(", "$", "hostParts", ")", "-", "1", "]", ";", "// zB 'com'", "}", "if", "(", "in_array", "(", "$", "ret", ",", "$", "longDomainEndings", ")", ")", "{", "$", "ret", "=", "$", "hostParts", "[", "count", "(", "$", "hostParts", ")", "-", "3", "]", ".", "$", "ret", ";", "}", "return", "$", "ret", ";", "}" ]
for unit testing only
[ "for", "unit", "testing", "only" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Assets/GoogleMapsApiKey.php#L20-L42
koala-framework/koala-framework
Kwc/Abstract.php
Kwc_Abstract.getSettings
public static function getSettings() { $ret = parent::getSettings(); $ret['viewCache'] = true; $ret['contentSender'] = 'Kwf_Component_Abstract_ContentSender_Default'; $ret['layoutClass'] = 'Kwf_Component_Layout_Default'; $ret['plugins'] = array(); return $ret; }
php
public static function getSettings() { $ret = parent::getSettings(); $ret['viewCache'] = true; $ret['contentSender'] = 'Kwf_Component_Abstract_ContentSender_Default'; $ret['layoutClass'] = 'Kwf_Component_Layout_Default'; $ret['plugins'] = array(); return $ret; }
[ "public", "static", "function", "getSettings", "(", ")", "{", "$", "ret", "=", "parent", "::", "getSettings", "(", ")", ";", "$", "ret", "[", "'viewCache'", "]", "=", "true", ";", "$", "ret", "[", "'contentSender'", "]", "=", "'Kwf_Component_Abstract_ContentSender_Default'", ";", "$", "ret", "[", "'layoutClass'", "]", "=", "'Kwf_Component_Layout_Default'", ";", "$", "ret", "[", "'plugins'", "]", "=", "array", "(", ")", ";", "return", "$", "ret", ";", "}" ]
Returns static settings of this component Override to change settings @return array
[ "Returns", "static", "settings", "of", "this", "component" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Abstract.php#L105-L113
koala-framework/koala-framework
Kwc/Abstract.php
Kwc_Abstract.getChildComponentClasses
public static function getChildComponentClasses($class, $select = array()) { $selectType = gettype($select); if ($selectType == 'string' && is_string($class)) { //simple case no. 1: get from specific generator $g = Kwc_Abstract::getSetting($class, 'generators'); if (!isset($g[$select])) return array(); return $g[$select]['component']; } else if (!$select && is_string($class)) { //simple case no. 2: get 'em all $ret = array(); foreach (Kwc_Abstract::getSetting($class, 'generators') as $g) { $ret = array_merge($ret, array_values($g['component'])); } return array_unique($ret); } else if ($selectType == 'array' && is_string($class) && count($select) == 1 && isset($select['componentClass']) && is_string($select['componentClass']) ) { //simple case no 3: looking for a single comopnentClass foreach (Kwc_Abstract::getSetting($class, 'generators') as $g) { foreach ($g['component'] as $c) { if ($c == $select['componentClass']) return array($c); } } return array(); } else if ($selectType == 'array' && is_string($class) && count($select) == 1 && isset($select['generatorFlags']) && $select['generatorFlags'] == array('static'=>true) ) { //simple case no 4: looking for a generator by flag $ret = array(); foreach (Kwc_Abstract::getSetting($class, 'generators') as $key=>$gSettings) { $g = Kwf_Component_Generator_Abstract::getInstance($class, $key, $gSettings); if ($g->getGeneratorFlag('static')) { foreach ($gSettings['component'] as $c) { $ret[] = $c; } } } return array_unique($ret); } else if ($selectType == 'array' && is_string($class) && count($select) == 2 && isset($select['generator']) && isset($select['componentKey']) ) { //simple case no 5: looking for a generator plus componentKey $ret = array(); $generators = Kwc_Abstract::getSetting($class, 'generators'); if (isset($generators[$select['generator']]['component'][$select['componentKey']])) { $ret[] = $generators[$select['generator']]['component'][$select['componentKey']]; } return $ret; } else if ($selectType == 'array') { $select = new Kwf_Component_Select($select); } //not so simple, else we ask Generator_Abstract::getInstances for help $ret = array(); $generators = Kwf_Component_Generator_Abstract::getInstances($class, $select); if (!$generators) { return $ret; } foreach ($generators as $generator) { $c = $generator->getChildComponentClasses($select); if (!$select->hasPart(Kwf_Component_Select::WHERE_GENERATOR)) { $c = array_values($c); } $ret = array_merge($ret, $c); } if (!$select->hasPart(Kwf_Component_Select::WHERE_GENERATOR)) { $ret = array_unique($ret); } return $ret; }
php
public static function getChildComponentClasses($class, $select = array()) { $selectType = gettype($select); if ($selectType == 'string' && is_string($class)) { //simple case no. 1: get from specific generator $g = Kwc_Abstract::getSetting($class, 'generators'); if (!isset($g[$select])) return array(); return $g[$select]['component']; } else if (!$select && is_string($class)) { //simple case no. 2: get 'em all $ret = array(); foreach (Kwc_Abstract::getSetting($class, 'generators') as $g) { $ret = array_merge($ret, array_values($g['component'])); } return array_unique($ret); } else if ($selectType == 'array' && is_string($class) && count($select) == 1 && isset($select['componentClass']) && is_string($select['componentClass']) ) { //simple case no 3: looking for a single comopnentClass foreach (Kwc_Abstract::getSetting($class, 'generators') as $g) { foreach ($g['component'] as $c) { if ($c == $select['componentClass']) return array($c); } } return array(); } else if ($selectType == 'array' && is_string($class) && count($select) == 1 && isset($select['generatorFlags']) && $select['generatorFlags'] == array('static'=>true) ) { //simple case no 4: looking for a generator by flag $ret = array(); foreach (Kwc_Abstract::getSetting($class, 'generators') as $key=>$gSettings) { $g = Kwf_Component_Generator_Abstract::getInstance($class, $key, $gSettings); if ($g->getGeneratorFlag('static')) { foreach ($gSettings['component'] as $c) { $ret[] = $c; } } } return array_unique($ret); } else if ($selectType == 'array' && is_string($class) && count($select) == 2 && isset($select['generator']) && isset($select['componentKey']) ) { //simple case no 5: looking for a generator plus componentKey $ret = array(); $generators = Kwc_Abstract::getSetting($class, 'generators'); if (isset($generators[$select['generator']]['component'][$select['componentKey']])) { $ret[] = $generators[$select['generator']]['component'][$select['componentKey']]; } return $ret; } else if ($selectType == 'array') { $select = new Kwf_Component_Select($select); } //not so simple, else we ask Generator_Abstract::getInstances for help $ret = array(); $generators = Kwf_Component_Generator_Abstract::getInstances($class, $select); if (!$generators) { return $ret; } foreach ($generators as $generator) { $c = $generator->getChildComponentClasses($select); if (!$select->hasPart(Kwf_Component_Select::WHERE_GENERATOR)) { $c = array_values($c); } $ret = array_merge($ret, $c); } if (!$select->hasPart(Kwf_Component_Select::WHERE_GENERATOR)) { $ret = array_unique($ret); } return $ret; }
[ "public", "static", "function", "getChildComponentClasses", "(", "$", "class", ",", "$", "select", "=", "array", "(", ")", ")", "{", "$", "selectType", "=", "gettype", "(", "$", "select", ")", ";", "if", "(", "$", "selectType", "==", "'string'", "&&", "is_string", "(", "$", "class", ")", ")", "{", "//simple case no. 1: get from specific generator", "$", "g", "=", "Kwc_Abstract", "::", "getSetting", "(", "$", "class", ",", "'generators'", ")", ";", "if", "(", "!", "isset", "(", "$", "g", "[", "$", "select", "]", ")", ")", "return", "array", "(", ")", ";", "return", "$", "g", "[", "$", "select", "]", "[", "'component'", "]", ";", "}", "else", "if", "(", "!", "$", "select", "&&", "is_string", "(", "$", "class", ")", ")", "{", "//simple case no. 2: get 'em all", "$", "ret", "=", "array", "(", ")", ";", "foreach", "(", "Kwc_Abstract", "::", "getSetting", "(", "$", "class", ",", "'generators'", ")", "as", "$", "g", ")", "{", "$", "ret", "=", "array_merge", "(", "$", "ret", ",", "array_values", "(", "$", "g", "[", "'component'", "]", ")", ")", ";", "}", "return", "array_unique", "(", "$", "ret", ")", ";", "}", "else", "if", "(", "$", "selectType", "==", "'array'", "&&", "is_string", "(", "$", "class", ")", "&&", "count", "(", "$", "select", ")", "==", "1", "&&", "isset", "(", "$", "select", "[", "'componentClass'", "]", ")", "&&", "is_string", "(", "$", "select", "[", "'componentClass'", "]", ")", ")", "{", "//simple case no 3: looking for a single comopnentClass", "foreach", "(", "Kwc_Abstract", "::", "getSetting", "(", "$", "class", ",", "'generators'", ")", "as", "$", "g", ")", "{", "foreach", "(", "$", "g", "[", "'component'", "]", "as", "$", "c", ")", "{", "if", "(", "$", "c", "==", "$", "select", "[", "'componentClass'", "]", ")", "return", "array", "(", "$", "c", ")", ";", "}", "}", "return", "array", "(", ")", ";", "}", "else", "if", "(", "$", "selectType", "==", "'array'", "&&", "is_string", "(", "$", "class", ")", "&&", "count", "(", "$", "select", ")", "==", "1", "&&", "isset", "(", "$", "select", "[", "'generatorFlags'", "]", ")", "&&", "$", "select", "[", "'generatorFlags'", "]", "==", "array", "(", "'static'", "=>", "true", ")", ")", "{", "//simple case no 4: looking for a generator by flag", "$", "ret", "=", "array", "(", ")", ";", "foreach", "(", "Kwc_Abstract", "::", "getSetting", "(", "$", "class", ",", "'generators'", ")", "as", "$", "key", "=>", "$", "gSettings", ")", "{", "$", "g", "=", "Kwf_Component_Generator_Abstract", "::", "getInstance", "(", "$", "class", ",", "$", "key", ",", "$", "gSettings", ")", ";", "if", "(", "$", "g", "->", "getGeneratorFlag", "(", "'static'", ")", ")", "{", "foreach", "(", "$", "gSettings", "[", "'component'", "]", "as", "$", "c", ")", "{", "$", "ret", "[", "]", "=", "$", "c", ";", "}", "}", "}", "return", "array_unique", "(", "$", "ret", ")", ";", "}", "else", "if", "(", "$", "selectType", "==", "'array'", "&&", "is_string", "(", "$", "class", ")", "&&", "count", "(", "$", "select", ")", "==", "2", "&&", "isset", "(", "$", "select", "[", "'generator'", "]", ")", "&&", "isset", "(", "$", "select", "[", "'componentKey'", "]", ")", ")", "{", "//simple case no 5: looking for a generator plus componentKey", "$", "ret", "=", "array", "(", ")", ";", "$", "generators", "=", "Kwc_Abstract", "::", "getSetting", "(", "$", "class", ",", "'generators'", ")", ";", "if", "(", "isset", "(", "$", "generators", "[", "$", "select", "[", "'generator'", "]", "]", "[", "'component'", "]", "[", "$", "select", "[", "'componentKey'", "]", "]", ")", ")", "{", "$", "ret", "[", "]", "=", "$", "generators", "[", "$", "select", "[", "'generator'", "]", "]", "[", "'component'", "]", "[", "$", "select", "[", "'componentKey'", "]", "]", ";", "}", "return", "$", "ret", ";", "}", "else", "if", "(", "$", "selectType", "==", "'array'", ")", "{", "$", "select", "=", "new", "Kwf_Component_Select", "(", "$", "select", ")", ";", "}", "//not so simple, else we ask Generator_Abstract::getInstances for help", "$", "ret", "=", "array", "(", ")", ";", "$", "generators", "=", "Kwf_Component_Generator_Abstract", "::", "getInstances", "(", "$", "class", ",", "$", "select", ")", ";", "if", "(", "!", "$", "generators", ")", "{", "return", "$", "ret", ";", "}", "foreach", "(", "$", "generators", "as", "$", "generator", ")", "{", "$", "c", "=", "$", "generator", "->", "getChildComponentClasses", "(", "$", "select", ")", ";", "if", "(", "!", "$", "select", "->", "hasPart", "(", "Kwf_Component_Select", "::", "WHERE_GENERATOR", ")", ")", "{", "$", "c", "=", "array_values", "(", "$", "c", ")", ";", "}", "$", "ret", "=", "array_merge", "(", "$", "ret", ",", "$", "c", ")", ";", "}", "if", "(", "!", "$", "select", "->", "hasPart", "(", "Kwf_Component_Select", "::", "WHERE_GENERATOR", ")", ")", "{", "$", "ret", "=", "array_unique", "(", "$", "ret", ")", ";", "}", "return", "$", "ret", ";", "}" ]
Returns child component classes of a componentclass or a componentData @param string|Kwf_Component_Data if data inherited generators are returned as well @param array Optional filtering (string to get for one generator)
[ "Returns", "child", "component", "classes", "of", "a", "componentclass", "or", "a", "componentData" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Abstract.php#L121-L192
koala-framework/koala-framework
Kwc/Abstract.php
Kwc_Abstract.getIndirectChildComponentClasses
public static function getIndirectChildComponentClasses($class, $select = array()) { if (is_array($select)) { $select = new Kwf_Component_Select($select); } $cacheId = $select->getHash(); $ret = self::_getIndirectChildComponentClasses($class, $select, $cacheId); return $ret; }
php
public static function getIndirectChildComponentClasses($class, $select = array()) { if (is_array($select)) { $select = new Kwf_Component_Select($select); } $cacheId = $select->getHash(); $ret = self::_getIndirectChildComponentClasses($class, $select, $cacheId); return $ret; }
[ "public", "static", "function", "getIndirectChildComponentClasses", "(", "$", "class", ",", "$", "select", "=", "array", "(", ")", ")", "{", "if", "(", "is_array", "(", "$", "select", ")", ")", "{", "$", "select", "=", "new", "Kwf_Component_Select", "(", "$", "select", ")", ";", "}", "$", "cacheId", "=", "$", "select", "->", "getHash", "(", ")", ";", "$", "ret", "=", "self", "::", "_getIndirectChildComponentClasses", "(", "$", "class", ",", "$", "select", ",", "$", "cacheId", ")", ";", "return", "$", "ret", ";", "}" ]
Returns indirect child component classes of a componentclass or a componentData @param string|Kwf_Component_Data if data inherited generators are returned as well @param array Optional filtering (string to get for one generator)
[ "Returns", "indirect", "child", "component", "classes", "of", "a", "componentclass", "or", "a", "componentData" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Abstract.php#L200-L208
koala-framework/koala-framework
Kwc/Abstract.php
Kwc_Abstract.getChildComponentClass
public static function getChildComponentClass($class, $generator, $componentKey = null) { $constraints = array( 'generator' => $generator, ); if ($componentKey) $constraints['componentKey'] = $componentKey; $classes = array_values(self::getChildComponentClasses($class, $constraints)); if (!isset($classes[0])) { if (!$componentKey) { throw new Kwf_Exception("no component for generator '$generator' not set for '$class'"); } else { throw new Kwf_Exception("childComponentClass '$componentKey' for generator '$generator' not set for '$class'"); } } return $classes[0]; }
php
public static function getChildComponentClass($class, $generator, $componentKey = null) { $constraints = array( 'generator' => $generator, ); if ($componentKey) $constraints['componentKey'] = $componentKey; $classes = array_values(self::getChildComponentClasses($class, $constraints)); if (!isset($classes[0])) { if (!$componentKey) { throw new Kwf_Exception("no component for generator '$generator' not set for '$class'"); } else { throw new Kwf_Exception("childComponentClass '$componentKey' for generator '$generator' not set for '$class'"); } } return $classes[0]; }
[ "public", "static", "function", "getChildComponentClass", "(", "$", "class", ",", "$", "generator", ",", "$", "componentKey", "=", "null", ")", "{", "$", "constraints", "=", "array", "(", "'generator'", "=>", "$", "generator", ",", ")", ";", "if", "(", "$", "componentKey", ")", "$", "constraints", "[", "'componentKey'", "]", "=", "$", "componentKey", ";", "$", "classes", "=", "array_values", "(", "self", "::", "getChildComponentClasses", "(", "$", "class", ",", "$", "constraints", ")", ")", ";", "if", "(", "!", "isset", "(", "$", "classes", "[", "0", "]", ")", ")", "{", "if", "(", "!", "$", "componentKey", ")", "{", "throw", "new", "Kwf_Exception", "(", "\"no component for generator '$generator' not set for '$class'\"", ")", ";", "}", "else", "{", "throw", "new", "Kwf_Exception", "(", "\"childComponentClass '$componentKey' for generator '$generator' not set for '$class'\"", ")", ";", "}", "}", "return", "$", "classes", "[", "0", "]", ";", "}" ]
Returns a single child component class of a componentClass throws an exception if not found @param string componentClass @param string generator key @param string component key @param string
[ "Returns", "a", "single", "child", "component", "class", "of", "a", "componentClass" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Abstract.php#L257-L272
koala-framework/koala-framework
Kwc/Abstract.php
Kwc_Abstract.hasChildComponentClass
public static function hasChildComponentClass($class, $generator, $componentKey = null) { $constraints = array( 'generator' => $generator, 'componentKey' => $componentKey ); $classes = self::getChildComponentClasses($class, $constraints); return count($classes) > 0; }
php
public static function hasChildComponentClass($class, $generator, $componentKey = null) { $constraints = array( 'generator' => $generator, 'componentKey' => $componentKey ); $classes = self::getChildComponentClasses($class, $constraints); return count($classes) > 0; }
[ "public", "static", "function", "hasChildComponentClass", "(", "$", "class", ",", "$", "generator", ",", "$", "componentKey", "=", "null", ")", "{", "$", "constraints", "=", "array", "(", "'generator'", "=>", "$", "generator", ",", "'componentKey'", "=>", "$", "componentKey", ")", ";", "$", "classes", "=", "self", "::", "getChildComponentClasses", "(", "$", "class", ",", "$", "constraints", ")", ";", "return", "count", "(", "$", "classes", ")", ">", "0", ";", "}" ]
Return if a child component class with a given generator key and componentKey exists if returnf false getChildComponentClass will give an exception. @param string componentClass @param string generator key @param string component key @param bool
[ "Return", "if", "a", "child", "component", "class", "with", "a", "given", "generator", "key", "and", "componentKey", "exists" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Abstract.php#L284-L292
koala-framework/koala-framework
Kwc/Abstract.php
Kwc_Abstract._getRow
protected function _getRow() { if (!isset($this->_row)) { $model = $this->getOwnModel(); if (!$model) return null; $dbId = $this->getData()->dbId; $sharedDataClass = self::getFlag($this->getData()->componentClass, 'sharedDataClass'); if ($sharedDataClass) { $component = $this->getData(); while ($component) { if (is_instance_of($component->componentClass, $sharedDataClass)) $dbId = $component->dbId; $component = $component->parent; } } $this->_row = $model->getRow($dbId); if (!$this->_row) { $this->_row = $model->createRow(); $this->_row->component_id = $dbId; } } return $this->_row; }
php
protected function _getRow() { if (!isset($this->_row)) { $model = $this->getOwnModel(); if (!$model) return null; $dbId = $this->getData()->dbId; $sharedDataClass = self::getFlag($this->getData()->componentClass, 'sharedDataClass'); if ($sharedDataClass) { $component = $this->getData(); while ($component) { if (is_instance_of($component->componentClass, $sharedDataClass)) $dbId = $component->dbId; $component = $component->parent; } } $this->_row = $model->getRow($dbId); if (!$this->_row) { $this->_row = $model->createRow(); $this->_row->component_id = $dbId; } } return $this->_row; }
[ "protected", "function", "_getRow", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_row", ")", ")", "{", "$", "model", "=", "$", "this", "->", "getOwnModel", "(", ")", ";", "if", "(", "!", "$", "model", ")", "return", "null", ";", "$", "dbId", "=", "$", "this", "->", "getData", "(", ")", "->", "dbId", ";", "$", "sharedDataClass", "=", "self", "::", "getFlag", "(", "$", "this", "->", "getData", "(", ")", "->", "componentClass", ",", "'sharedDataClass'", ")", ";", "if", "(", "$", "sharedDataClass", ")", "{", "$", "component", "=", "$", "this", "->", "getData", "(", ")", ";", "while", "(", "$", "component", ")", "{", "if", "(", "is_instance_of", "(", "$", "component", "->", "componentClass", ",", "$", "sharedDataClass", ")", ")", "$", "dbId", "=", "$", "component", "->", "dbId", ";", "$", "component", "=", "$", "component", "->", "parent", ";", "}", "}", "$", "this", "->", "_row", "=", "$", "model", "->", "getRow", "(", "$", "dbId", ")", ";", "if", "(", "!", "$", "this", "->", "_row", ")", "{", "$", "this", "->", "_row", "=", "$", "model", "->", "createRow", "(", ")", ";", "$", "this", "->", "_row", "->", "component_id", "=", "$", "dbId", ";", "}", "}", "return", "$", "this", "->", "_row", ";", "}" ]
Returns the row from the ownModel of this component @return Kwf_Model_Row_Abstract
[ "Returns", "the", "row", "from", "the", "ownModel", "of", "this", "component" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Abstract.php#L307-L330
koala-framework/koala-framework
Kwc/Abstract.php
Kwc_Abstract.getPdfWriter
public function getPdfWriter($pdf) { if (!isset($this->_pdfWriter)) { $class = Kwc_Admin::getComponentFile(get_class($this), 'Pdf', 'php', true); $this->_pdfWriter = new $class($this, $pdf); } return $this->_pdfWriter; }
php
public function getPdfWriter($pdf) { if (!isset($this->_pdfWriter)) { $class = Kwc_Admin::getComponentFile(get_class($this), 'Pdf', 'php', true); $this->_pdfWriter = new $class($this, $pdf); } return $this->_pdfWriter; }
[ "public", "function", "getPdfWriter", "(", "$", "pdf", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_pdfWriter", ")", ")", "{", "$", "class", "=", "Kwc_Admin", "::", "getComponentFile", "(", "get_class", "(", "$", "this", ")", ",", "'Pdf'", ",", "'php'", ",", "true", ")", ";", "$", "this", "->", "_pdfWriter", "=", "new", "$", "class", "(", "$", "this", ",", "$", "pdf", ")", ";", "}", "return", "$", "this", "->", "_pdfWriter", ";", "}" ]
Returns the Pdf Writer object associated with this component.
[ "Returns", "the", "Pdf", "Writer", "object", "associated", "with", "this", "component", "." ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Abstract.php#L347-L354
koala-framework/koala-framework
Kwc/Abstract.php
Kwc_Abstract.getTemplateVars
public function getTemplateVars(Kwf_Component_Renderer_Abstract $renderer) { $ret = array(); $ret['placeholder'] = $this->_getPlaceholder(); $ret['rootElementClass'] = self::getRootElementClass($this); $ret['bemClass'] = $this->_getBemClass(''); $ret['data'] = $this->getData(); $ret['row'] = $this->_getRow(); $supportedContexts = Kwf_Component_Layout_Abstract::getInstance($this->getData()->componentClass)->getSupportedContexts(); if ($supportedContexts) { $contexts = Kwf_Component_Layout_Abstract::getInstance($this->getData()->componentClass)->getContexts($this->getData()); if (is_null($contexts)) { $e = new Kwf_Exception("Didn't get layout contexts for ".$this->getData()->componentId); $e->logOrThrow(); } foreach ($contexts as $ctx) { if (!in_array($ctx, $supportedContexts)) { $e = new Kwf_Exception("Master Layout Context ".json_encode($ctx)." is not supported by ".$this->getData()->componentClass." for '".$this->getData()->componentId."'"); $e->logOrThrow(); } } } return $ret; }
php
public function getTemplateVars(Kwf_Component_Renderer_Abstract $renderer) { $ret = array(); $ret['placeholder'] = $this->_getPlaceholder(); $ret['rootElementClass'] = self::getRootElementClass($this); $ret['bemClass'] = $this->_getBemClass(''); $ret['data'] = $this->getData(); $ret['row'] = $this->_getRow(); $supportedContexts = Kwf_Component_Layout_Abstract::getInstance($this->getData()->componentClass)->getSupportedContexts(); if ($supportedContexts) { $contexts = Kwf_Component_Layout_Abstract::getInstance($this->getData()->componentClass)->getContexts($this->getData()); if (is_null($contexts)) { $e = new Kwf_Exception("Didn't get layout contexts for ".$this->getData()->componentId); $e->logOrThrow(); } foreach ($contexts as $ctx) { if (!in_array($ctx, $supportedContexts)) { $e = new Kwf_Exception("Master Layout Context ".json_encode($ctx)." is not supported by ".$this->getData()->componentClass." for '".$this->getData()->componentId."'"); $e->logOrThrow(); } } } return $ret; }
[ "public", "function", "getTemplateVars", "(", "Kwf_Component_Renderer_Abstract", "$", "renderer", ")", "{", "$", "ret", "=", "array", "(", ")", ";", "$", "ret", "[", "'placeholder'", "]", "=", "$", "this", "->", "_getPlaceholder", "(", ")", ";", "$", "ret", "[", "'rootElementClass'", "]", "=", "self", "::", "getRootElementClass", "(", "$", "this", ")", ";", "$", "ret", "[", "'bemClass'", "]", "=", "$", "this", "->", "_getBemClass", "(", "''", ")", ";", "$", "ret", "[", "'data'", "]", "=", "$", "this", "->", "getData", "(", ")", ";", "$", "ret", "[", "'row'", "]", "=", "$", "this", "->", "_getRow", "(", ")", ";", "$", "supportedContexts", "=", "Kwf_Component_Layout_Abstract", "::", "getInstance", "(", "$", "this", "->", "getData", "(", ")", "->", "componentClass", ")", "->", "getSupportedContexts", "(", ")", ";", "if", "(", "$", "supportedContexts", ")", "{", "$", "contexts", "=", "Kwf_Component_Layout_Abstract", "::", "getInstance", "(", "$", "this", "->", "getData", "(", ")", "->", "componentClass", ")", "->", "getContexts", "(", "$", "this", "->", "getData", "(", ")", ")", ";", "if", "(", "is_null", "(", "$", "contexts", ")", ")", "{", "$", "e", "=", "new", "Kwf_Exception", "(", "\"Didn't get layout contexts for \"", ".", "$", "this", "->", "getData", "(", ")", "->", "componentId", ")", ";", "$", "e", "->", "logOrThrow", "(", ")", ";", "}", "foreach", "(", "$", "contexts", "as", "$", "ctx", ")", "{", "if", "(", "!", "in_array", "(", "$", "ctx", ",", "$", "supportedContexts", ")", ")", "{", "$", "e", "=", "new", "Kwf_Exception", "(", "\"Master Layout Context \"", ".", "json_encode", "(", "$", "ctx", ")", ".", "\" is not supported by \"", ".", "$", "this", "->", "getData", "(", ")", "->", "componentClass", ".", "\" for '\"", ".", "$", "this", "->", "getData", "(", ")", "->", "componentId", ".", "\"'\"", ")", ";", "$", "e", "->", "logOrThrow", "(", ")", ";", "}", "}", "}", "return", "$", "ret", ";", "}" ]
Returns variables that can be used in Component.tpl @param e.g. for accessing recipient in Mail_Renderer @return array
[ "Returns", "variables", "that", "can", "be", "used", "in", "Component", ".", "tpl" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Abstract.php#L361-L386
koala-framework/koala-framework
Kwc/Abstract.php
Kwc_Abstract.getMasterTemplateVars
public function getMasterTemplateVars(Kwf_Component_Data $innerComponent, Kwf_Component_Renderer_Abstract $renderer) { $ret = array(); $ret['component'] = $innerComponent; $ret['data'] = $innerComponent; $ret['template'] = self::getMasterTemplateFile($this->getData()->componentClass); $ret['pageLanguage'] = $innerComponent->getLanguage(); $ret['boxes'] = array(); foreach ($innerComponent->getPageOrRoot()->getChildBoxes() as $box) { $ret['boxes'][$box->box] = $box; } $ret['multiBoxes'] = array(); foreach ($innerComponent->getPageOrRoot()->getRecursiveChildComponents(array('multiBox'=>true)) as $box) { $ret['multiBoxes'][$box->box][] = $box; } //sort by priority foreach ($ret['multiBoxes'] as $box=>$components) { usort($ret['multiBoxes'][$box], array('Kwf_Component_View_Helper_ComponentWithMaster', '_sortByPriority')); } $up = Kwf_Config::getValue('application.uniquePrefix'); if (!$up) { $ret['bemClass'] = ''; } else { $ret['bemClass'] = Kwf_Component_Abstract::formatRootElementClass($this->getData()->componentClass, '').'Master__'; } $ret['rootElementClass'] = 'kwfUp-frontend '.Kwf_Component_Abstract::formatRootElementClass($this->getData()->componentClass, '').'Master'; return $ret; }
php
public function getMasterTemplateVars(Kwf_Component_Data $innerComponent, Kwf_Component_Renderer_Abstract $renderer) { $ret = array(); $ret['component'] = $innerComponent; $ret['data'] = $innerComponent; $ret['template'] = self::getMasterTemplateFile($this->getData()->componentClass); $ret['pageLanguage'] = $innerComponent->getLanguage(); $ret['boxes'] = array(); foreach ($innerComponent->getPageOrRoot()->getChildBoxes() as $box) { $ret['boxes'][$box->box] = $box; } $ret['multiBoxes'] = array(); foreach ($innerComponent->getPageOrRoot()->getRecursiveChildComponents(array('multiBox'=>true)) as $box) { $ret['multiBoxes'][$box->box][] = $box; } //sort by priority foreach ($ret['multiBoxes'] as $box=>$components) { usort($ret['multiBoxes'][$box], array('Kwf_Component_View_Helper_ComponentWithMaster', '_sortByPriority')); } $up = Kwf_Config::getValue('application.uniquePrefix'); if (!$up) { $ret['bemClass'] = ''; } else { $ret['bemClass'] = Kwf_Component_Abstract::formatRootElementClass($this->getData()->componentClass, '').'Master__'; } $ret['rootElementClass'] = 'kwfUp-frontend '.Kwf_Component_Abstract::formatRootElementClass($this->getData()->componentClass, '').'Master'; return $ret; }
[ "public", "function", "getMasterTemplateVars", "(", "Kwf_Component_Data", "$", "innerComponent", ",", "Kwf_Component_Renderer_Abstract", "$", "renderer", ")", "{", "$", "ret", "=", "array", "(", ")", ";", "$", "ret", "[", "'component'", "]", "=", "$", "innerComponent", ";", "$", "ret", "[", "'data'", "]", "=", "$", "innerComponent", ";", "$", "ret", "[", "'template'", "]", "=", "self", "::", "getMasterTemplateFile", "(", "$", "this", "->", "getData", "(", ")", "->", "componentClass", ")", ";", "$", "ret", "[", "'pageLanguage'", "]", "=", "$", "innerComponent", "->", "getLanguage", "(", ")", ";", "$", "ret", "[", "'boxes'", "]", "=", "array", "(", ")", ";", "foreach", "(", "$", "innerComponent", "->", "getPageOrRoot", "(", ")", "->", "getChildBoxes", "(", ")", "as", "$", "box", ")", "{", "$", "ret", "[", "'boxes'", "]", "[", "$", "box", "->", "box", "]", "=", "$", "box", ";", "}", "$", "ret", "[", "'multiBoxes'", "]", "=", "array", "(", ")", ";", "foreach", "(", "$", "innerComponent", "->", "getPageOrRoot", "(", ")", "->", "getRecursiveChildComponents", "(", "array", "(", "'multiBox'", "=>", "true", ")", ")", "as", "$", "box", ")", "{", "$", "ret", "[", "'multiBoxes'", "]", "[", "$", "box", "->", "box", "]", "[", "]", "=", "$", "box", ";", "}", "//sort by priority", "foreach", "(", "$", "ret", "[", "'multiBoxes'", "]", "as", "$", "box", "=>", "$", "components", ")", "{", "usort", "(", "$", "ret", "[", "'multiBoxes'", "]", "[", "$", "box", "]", ",", "array", "(", "'Kwf_Component_View_Helper_ComponentWithMaster'", ",", "'_sortByPriority'", ")", ")", ";", "}", "$", "up", "=", "Kwf_Config", "::", "getValue", "(", "'application.uniquePrefix'", ")", ";", "if", "(", "!", "$", "up", ")", "{", "$", "ret", "[", "'bemClass'", "]", "=", "''", ";", "}", "else", "{", "$", "ret", "[", "'bemClass'", "]", "=", "Kwf_Component_Abstract", "::", "formatRootElementClass", "(", "$", "this", "->", "getData", "(", ")", "->", "componentClass", ",", "''", ")", ".", "'Master__'", ";", "}", "$", "ret", "[", "'rootElementClass'", "]", "=", "'kwfUp-frontend '", ".", "Kwf_Component_Abstract", "::", "formatRootElementClass", "(", "$", "this", "->", "getData", "(", ")", "->", "componentClass", ",", "''", ")", ".", "'Master'", ";", "return", "$", "ret", ";", "}" ]
Returns variables that can be used in Master.tpl @param e.g. for accessing recipient in Mail_Renderer @return array
[ "Returns", "variables", "that", "can", "be", "used", "in", "Master", ".", "tpl" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Abstract.php#L436-L468
koala-framework/koala-framework
Kwc/Abstract.php
Kwc_Abstract._getPlaceholder
protected function _getPlaceholder($placeholder = null) { $ret = $this->_getSetting('placeholder'); if ($placeholder) { return $this->getData()->trlStaticExecute($ret[$placeholder]); } foreach ($ret as $k => $v) { $ret[$k] = $this->getData()->trlStaticExecute($v); } return $ret; }
php
protected function _getPlaceholder($placeholder = null) { $ret = $this->_getSetting('placeholder'); if ($placeholder) { return $this->getData()->trlStaticExecute($ret[$placeholder]); } foreach ($ret as $k => $v) { $ret[$k] = $this->getData()->trlStaticExecute($v); } return $ret; }
[ "protected", "function", "_getPlaceholder", "(", "$", "placeholder", "=", "null", ")", "{", "$", "ret", "=", "$", "this", "->", "_getSetting", "(", "'placeholder'", ")", ";", "if", "(", "$", "placeholder", ")", "{", "return", "$", "this", "->", "getData", "(", ")", "->", "trlStaticExecute", "(", "$", "ret", "[", "$", "placeholder", "]", ")", ";", "}", "foreach", "(", "$", "ret", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "ret", "[", "$", "k", "]", "=", "$", "this", "->", "getData", "(", ")", "->", "trlStaticExecute", "(", "$", "v", ")", ";", "}", "return", "$", "ret", ";", "}" ]
Returns a placeholder text, placeholders are set in settings @return string
[ "Returns", "a", "placeholder", "text", "placeholders", "are", "set", "in", "settings" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Abstract.php#L475-L485
koala-framework/koala-framework
Kwc/Abstract.php
Kwc_Abstract.getRootElementClass
static public function getRootElementClass($component) { if (!is_string($component)) $component = $component->getData()->componentClass; $ret = ''; if (self::hasSetting($component, 'rootElementClass')) { $ret .= self::getSetting($component, 'rootElementClass').' '; } $ret .= Kwf_Component_Abstract::formatRootElementClass($component, ''); return $ret; }
php
static public function getRootElementClass($component) { if (!is_string($component)) $component = $component->getData()->componentClass; $ret = ''; if (self::hasSetting($component, 'rootElementClass')) { $ret .= self::getSetting($component, 'rootElementClass').' '; } $ret .= Kwf_Component_Abstract::formatRootElementClass($component, ''); return $ret; }
[ "static", "public", "function", "getRootElementClass", "(", "$", "component", ")", "{", "if", "(", "!", "is_string", "(", "$", "component", ")", ")", "$", "component", "=", "$", "component", "->", "getData", "(", ")", "->", "componentClass", ";", "$", "ret", "=", "''", ";", "if", "(", "self", "::", "hasSetting", "(", "$", "component", ",", "'rootElementClass'", ")", ")", "{", "$", "ret", ".=", "self", "::", "getSetting", "(", "$", "component", ",", "'rootElementClass'", ")", ".", "' '", ";", "}", "$", "ret", ".=", "Kwf_Component_Abstract", "::", "formatRootElementClass", "(", "$", "component", ",", "''", ")", ";", "return", "$", "ret", ";", "}" ]
Returns the processed rootElementClass used in various places for a component @param string|Kwf_Component_Data @return string
[ "Returns", "the", "processed", "rootElementClass", "used", "in", "various", "places", "for", "a", "component" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Abstract.php#L529-L538
koala-framework/koala-framework
Kwc/Abstract.php
Kwc_Abstract.getComponentClassesByParentClass
public static function getComponentClassesByParentClass($class) { if (!is_array($class)) $class = array($class); static $prefix; $cacheId = 'cclsbpc-'.implode('-', $class).'-'.Kwf_Component_Data_Root::getComponentClass(); $ret = Kwf_Cache_SimpleStatic::fetch($cacheId, $success); if ($success) { return $ret; } $ret = array(); foreach (Kwc_Abstract::getComponentClasses() as $c) { if (in_array($c, $class) || in_array((strpos($c, '.') ? substr($c, 0, strpos($c, '.')) : $c), $class)) { $ret[] = $c; continue; } foreach (Kwc_Abstract::getParentClasses($c) as $p) { if (in_array($p, $class)) { $ret[] = $c; break; } } } Kwf_Cache_SimpleStatic::add($cacheId, $ret); return $ret; }
php
public static function getComponentClassesByParentClass($class) { if (!is_array($class)) $class = array($class); static $prefix; $cacheId = 'cclsbpc-'.implode('-', $class).'-'.Kwf_Component_Data_Root::getComponentClass(); $ret = Kwf_Cache_SimpleStatic::fetch($cacheId, $success); if ($success) { return $ret; } $ret = array(); foreach (Kwc_Abstract::getComponentClasses() as $c) { if (in_array($c, $class) || in_array((strpos($c, '.') ? substr($c, 0, strpos($c, '.')) : $c), $class)) { $ret[] = $c; continue; } foreach (Kwc_Abstract::getParentClasses($c) as $p) { if (in_array($p, $class)) { $ret[] = $c; break; } } } Kwf_Cache_SimpleStatic::add($cacheId, $ret); return $ret; }
[ "public", "static", "function", "getComponentClassesByParentClass", "(", "$", "class", ")", "{", "if", "(", "!", "is_array", "(", "$", "class", ")", ")", "$", "class", "=", "array", "(", "$", "class", ")", ";", "static", "$", "prefix", ";", "$", "cacheId", "=", "'cclsbpc-'", ".", "implode", "(", "'-'", ",", "$", "class", ")", ".", "'-'", ".", "Kwf_Component_Data_Root", "::", "getComponentClass", "(", ")", ";", "$", "ret", "=", "Kwf_Cache_SimpleStatic", "::", "fetch", "(", "$", "cacheId", ",", "$", "success", ")", ";", "if", "(", "$", "success", ")", "{", "return", "$", "ret", ";", "}", "$", "ret", "=", "array", "(", ")", ";", "foreach", "(", "Kwc_Abstract", "::", "getComponentClasses", "(", ")", "as", "$", "c", ")", "{", "if", "(", "in_array", "(", "$", "c", ",", "$", "class", ")", "||", "in_array", "(", "(", "strpos", "(", "$", "c", ",", "'.'", ")", "?", "substr", "(", "$", "c", ",", "0", ",", "strpos", "(", "$", "c", ",", "'.'", ")", ")", ":", "$", "c", ")", ",", "$", "class", ")", ")", "{", "$", "ret", "[", "]", "=", "$", "c", ";", "continue", ";", "}", "foreach", "(", "Kwc_Abstract", "::", "getParentClasses", "(", "$", "c", ")", "as", "$", "p", ")", "{", "if", "(", "in_array", "(", "$", "p", ",", "$", "class", ")", ")", "{", "$", "ret", "[", "]", "=", "$", "c", ";", "break", ";", "}", "}", "}", "Kwf_Cache_SimpleStatic", "::", "add", "(", "$", "cacheId", ",", "$", "ret", ")", ";", "return", "$", "ret", ";", "}" ]
Returns componentClasses that match a given class in their inheritance chain Fast, as the result is static and will be cached @param string @return string[]
[ "Returns", "componentClasses", "that", "match", "a", "given", "class", "in", "their", "inheritance", "chain" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Abstract.php#L548-L573
koala-framework/koala-framework
Kwc/Abstract.php
Kwc_Abstract.getComponentClassByParentClass
public static function getComponentClassByParentClass($class) { $ret = self::getComponentClassesByParentClass($class); if (count($ret) != 1) { if (!$ret) { throw new Kwf_Exception("No Component with class '$class' found"); } throw new Kwf_Exception("More then one component with class '$class' found, there should exist only one"); } return $ret[0]; }
php
public static function getComponentClassByParentClass($class) { $ret = self::getComponentClassesByParentClass($class); if (count($ret) != 1) { if (!$ret) { throw new Kwf_Exception("No Component with class '$class' found"); } throw new Kwf_Exception("More then one component with class '$class' found, there should exist only one"); } return $ret[0]; }
[ "public", "static", "function", "getComponentClassByParentClass", "(", "$", "class", ")", "{", "$", "ret", "=", "self", "::", "getComponentClassesByParentClass", "(", "$", "class", ")", ";", "if", "(", "count", "(", "$", "ret", ")", "!=", "1", ")", "{", "if", "(", "!", "$", "ret", ")", "{", "throw", "new", "Kwf_Exception", "(", "\"No Component with class '$class' found\"", ")", ";", "}", "throw", "new", "Kwf_Exception", "(", "\"More then one component with class '$class' found, there should exist only one\"", ")", ";", "}", "return", "$", "ret", "[", "0", "]", ";", "}" ]
Returns a componentClass that match a given class in their inheritance chain Fast, as the result is static and will be cached will throw an error if multiple are found @param string @return string
[ "Returns", "a", "componentClass", "that", "match", "a", "given", "class", "in", "their", "inheritance", "chain" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Abstract.php#L585-L595
koala-framework/koala-framework
Kwc/Abstract.php
Kwc_Abstract.getActiveViewPlugins
public function getActiveViewPlugins() { $ret = $this->_getSetting('plugins'); $d = $this->getData(); if ($d->isPage) { while ($d) { foreach (Kwc_Abstract::getSetting($d->componentClass, 'pluginsInherit') as $i) { if (!in_array($i, $ret)) $ret[] = $i; } $d = $d->parent; } } return $ret; }
php
public function getActiveViewPlugins() { $ret = $this->_getSetting('plugins'); $d = $this->getData(); if ($d->isPage) { while ($d) { foreach (Kwc_Abstract::getSetting($d->componentClass, 'pluginsInherit') as $i) { if (!in_array($i, $ret)) $ret[] = $i; } $d = $d->parent; } } return $ret; }
[ "public", "function", "getActiveViewPlugins", "(", ")", "{", "$", "ret", "=", "$", "this", "->", "_getSetting", "(", "'plugins'", ")", ";", "$", "d", "=", "$", "this", "->", "getData", "(", ")", ";", "if", "(", "$", "d", "->", "isPage", ")", "{", "while", "(", "$", "d", ")", "{", "foreach", "(", "Kwc_Abstract", "::", "getSetting", "(", "$", "d", "->", "componentClass", ",", "'pluginsInherit'", ")", "as", "$", "i", ")", "{", "if", "(", "!", "in_array", "(", "$", "i", ",", "$", "ret", ")", ")", "$", "ret", "[", "]", "=", "$", "i", ";", "}", "$", "d", "=", "$", "d", "->", "parent", ";", "}", "}", "return", "$", "ret", ";", "}" ]
Returns the view plugins that should be used for this component instance Must only return plugins defined in 'plugins' setting. Can also return non-view plugins, those will silently be ignored. Default implementation returns 'plugins' setting.
[ "Returns", "the", "view", "plugins", "that", "should", "be", "used", "for", "this", "component", "instance" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Abstract.php#L644-L657
koala-framework/koala-framework
Kwf/Util/Build/Types/Assets.php
Kwf_Util_Build_Types_Assets._build
protected function _build($options) { $cmd = 'NODE_PATH=vendor/koala-framework/koala-framework/node_modules_build ./vendor/bin/node node_modules/.bin/webpack --colors'; if (!isset($_SERVER['NO_PROGRESS'])) $cmd .= ' --progress'; passthru($cmd, $retVal); if ($retVal) { throw new Kwf_Exception("webpack failed"); } /* if (!file_exists('build/assets')) { mkdir('build/assets'); } Kwf_Assets_BuildCache::getInstance()->building = true; Kwf_Assets_BuildCache::getInstance()->clean(); Kwf_Assets_BuildCache::getInstance()->save(time(), 'assetsVersion'); $langs = $this->getAllLanguages(); $packages = $this->getAllPackages(); $exts = array('js', 'defer.js', 'css'); $providers = array(); foreach ($packages as $p) { foreach ($p->getProviderList()->getProviders() as $provider) { if (!in_array($provider, $providers)) { $providers[] = $provider; } } } echo "\ninitializing providers...\n"; $steps = count($providers); $c = new Zend_ProgressBar_Adapter_Console(); $c->setElements(array(Zend_ProgressBar_Adapter_Console::ELEMENT_PERCENT, Zend_ProgressBar_Adapter_Console::ELEMENT_BAR, Zend_ProgressBar_Adapter_Console::ELEMENT_TEXT)); $c->setTextWidth(80); $progress = new Zend_ProgressBar($c, 0, $steps); foreach ($providers as $provider) { $progress->next(1, get_class($provider)); $provider->initialize(); } $progress->finish(); echo "calculating dependencies...\n"; $steps = count($packages) * count($exts); $c = new Zend_ProgressBar_Adapter_Console(); $c->setElements(array(Zend_ProgressBar_Adapter_Console::ELEMENT_PERCENT, Zend_ProgressBar_Adapter_Console::ELEMENT_BAR, Zend_ProgressBar_Adapter_Console::ELEMENT_TEXT)); $c->setTextWidth(80); $progress = new Zend_ProgressBar($c, 0, $steps); $countDependencies = 0; foreach ($packages as $p) { $depName = $p->getDependencyName(); foreach ($exts as $extension) { $progress->next(1, "$depName $extension"); $p->getFilteredUniqueDependencies(self::$_mimeTypeByExtension[$extension]); } $it = new RecursiveIteratorIterator(new Kwf_Assets_Dependency_Iterator_UniqueFilter(new Kwf_Assets_Dependency_Iterator_Recursive($p->getDependency(), Kwf_Assets_Dependency_Abstract::DEPENDENCY_TYPE_ALL)), RecursiveIteratorIterator::CHILD_FIRST); foreach ($it as $i) { $countDependencies++; } } $progress->finish(); echo "compiling assets...\n"; $c = new Zend_ProgressBar_Adapter_Console(); $c->setElements(array(Zend_ProgressBar_Adapter_Console::ELEMENT_ETA, Zend_ProgressBar_Adapter_Console::ELEMENT_BAR, Zend_ProgressBar_Adapter_Console::ELEMENT_TEXT)); $c->setTextWidth(80); $progress = new Zend_ProgressBar($c, 0, $countDependencies); foreach ($packages as $p) { $it = new RecursiveIteratorIterator(new Kwf_Assets_Dependency_Iterator_UniqueFilter(new Kwf_Assets_Dependency_Iterator_Recursive($p->getDependency(), Kwf_Assets_Dependency_Abstract::DEPENDENCY_TYPE_ALL)), RecursiveIteratorIterator::CHILD_FIRST); foreach ($it as $dep) { $progress->next(1, "$dep"); if ($dep->getMimeType()) { $mimeType = $dep->getMimeType(); $p->warmupDependencyCaches($dep, $mimeType, $progress); } } } $progress->finish(); echo "generating package urls...\n"; $steps = count($packages) * count($langs) * count($exts); $c = new Zend_ProgressBar_Adapter_Console(); $c->setElements(array(Zend_ProgressBar_Adapter_Console::ELEMENT_PERCENT, Zend_ProgressBar_Adapter_Console::ELEMENT_BAR, Zend_ProgressBar_Adapter_Console::ELEMENT_TEXT)); $c->setTextWidth(80); $progress = new Zend_ProgressBar($c, 0, $steps); $allUrls = array(); foreach ($packages as $p) { $depName = $p->getDependencyName(); foreach ($langs as $language) { foreach ($exts as $extension) { $progress->next(1, "$depName $extension $language"); $urls = $p->getPackageUrls(self::$_mimeTypeByExtension[$extension], $language); if (Kwf_Setup::getBaseUrl()) { foreach ($urls as $k=>$i) { $urls[$k] = substr($i, strlen(Kwf_Setup::getBaseUrl())); } } $cacheId = $p->getPackageUrlsCacheId(self::$_mimeTypeByExtension[$extension], $language); Kwf_Assets_BuildCache::getInstance()->save($urls, $cacheId); foreach ($urls as $url) { if (!in_array($url, $allUrls)) { $allUrls[] = $url; } } } } } echo "generating package contents...\n"; $steps = count($allUrls)*2; $c = new Zend_ProgressBar_Adapter_Console(); $c->setElements(array(Zend_ProgressBar_Adapter_Console::ELEMENT_PERCENT, Zend_ProgressBar_Adapter_Console::ELEMENT_BAR, Zend_ProgressBar_Adapter_Console::ELEMENT_TEXT)); $c->setTextWidth(80); $progress = new Zend_ProgressBar($c, 0, $steps); foreach ($allUrls as $url) { if (substr($url, 0, 8) != '/assets/') continue; $param = explode('/', $url); if (count($param) != 7) continue; $dependencyClass = $param[3]; $dependencyParams = $param[4]; $urlLanguage = $param[5]; $urlExtension = $param[6]; $urlExtension = substr($urlExtension, 0, strpos($urlExtension, '?')); if (!class_exists($dependencyClass)) { throw new Kwf_Exception(); } if (!is_instance_of($dependencyClass, 'Kwf_Assets_Interface_UrlResolvable')) { throw new Kwf_Exception(); } $p = call_user_func(array($dependencyClass, 'fromUrlParameter'), $dependencyClass, $dependencyParams); if (!$p instanceof Kwf_Assets_Package) { throw new Kwf_Exception(); } $contents = $p->getUrlContents($urlExtension, $urlLanguage); $progress->next(1, "{$p->getDependencyName()} $urlExtension $urlLanguage source"); $cacheId = Kwf_Assets_Dispatcher::getInstance()->getCacheIdByPackage($p, $urlExtension, $urlLanguage); Kwf_Assets_BuildCache::getInstance()->save($contents, $cacheId); //save generated caches for clear-cache-watcher $fileName = 'build/assets/output-cache-ids-'.$urlExtension; if (!file_exists($fileName) || strpos(file_get_contents($fileName), $cacheId."\n") === false) { file_put_contents($fileName, $cacheId."\n", FILE_APPEND); } $contents = $p->getUrlContents($urlExtension.'.map', $urlLanguage); $progress->next(1, "{$p->getDependencyName()} $urlExtension $urlLanguage map"); $cacheId = Kwf_Assets_Dispatcher::getInstance()->getCacheIdByPackage($p, $urlExtension.'.map', $urlLanguage); Kwf_Assets_BuildCache::getInstance()->save($contents, $cacheId); } Kwf_Assets_Cache::getInstance()->clean(); Kwf_Assets_BuildCache::getInstance()->building = false; */ }
php
protected function _build($options) { $cmd = 'NODE_PATH=vendor/koala-framework/koala-framework/node_modules_build ./vendor/bin/node node_modules/.bin/webpack --colors'; if (!isset($_SERVER['NO_PROGRESS'])) $cmd .= ' --progress'; passthru($cmd, $retVal); if ($retVal) { throw new Kwf_Exception("webpack failed"); } /* if (!file_exists('build/assets')) { mkdir('build/assets'); } Kwf_Assets_BuildCache::getInstance()->building = true; Kwf_Assets_BuildCache::getInstance()->clean(); Kwf_Assets_BuildCache::getInstance()->save(time(), 'assetsVersion'); $langs = $this->getAllLanguages(); $packages = $this->getAllPackages(); $exts = array('js', 'defer.js', 'css'); $providers = array(); foreach ($packages as $p) { foreach ($p->getProviderList()->getProviders() as $provider) { if (!in_array($provider, $providers)) { $providers[] = $provider; } } } echo "\ninitializing providers...\n"; $steps = count($providers); $c = new Zend_ProgressBar_Adapter_Console(); $c->setElements(array(Zend_ProgressBar_Adapter_Console::ELEMENT_PERCENT, Zend_ProgressBar_Adapter_Console::ELEMENT_BAR, Zend_ProgressBar_Adapter_Console::ELEMENT_TEXT)); $c->setTextWidth(80); $progress = new Zend_ProgressBar($c, 0, $steps); foreach ($providers as $provider) { $progress->next(1, get_class($provider)); $provider->initialize(); } $progress->finish(); echo "calculating dependencies...\n"; $steps = count($packages) * count($exts); $c = new Zend_ProgressBar_Adapter_Console(); $c->setElements(array(Zend_ProgressBar_Adapter_Console::ELEMENT_PERCENT, Zend_ProgressBar_Adapter_Console::ELEMENT_BAR, Zend_ProgressBar_Adapter_Console::ELEMENT_TEXT)); $c->setTextWidth(80); $progress = new Zend_ProgressBar($c, 0, $steps); $countDependencies = 0; foreach ($packages as $p) { $depName = $p->getDependencyName(); foreach ($exts as $extension) { $progress->next(1, "$depName $extension"); $p->getFilteredUniqueDependencies(self::$_mimeTypeByExtension[$extension]); } $it = new RecursiveIteratorIterator(new Kwf_Assets_Dependency_Iterator_UniqueFilter(new Kwf_Assets_Dependency_Iterator_Recursive($p->getDependency(), Kwf_Assets_Dependency_Abstract::DEPENDENCY_TYPE_ALL)), RecursiveIteratorIterator::CHILD_FIRST); foreach ($it as $i) { $countDependencies++; } } $progress->finish(); echo "compiling assets...\n"; $c = new Zend_ProgressBar_Adapter_Console(); $c->setElements(array(Zend_ProgressBar_Adapter_Console::ELEMENT_ETA, Zend_ProgressBar_Adapter_Console::ELEMENT_BAR, Zend_ProgressBar_Adapter_Console::ELEMENT_TEXT)); $c->setTextWidth(80); $progress = new Zend_ProgressBar($c, 0, $countDependencies); foreach ($packages as $p) { $it = new RecursiveIteratorIterator(new Kwf_Assets_Dependency_Iterator_UniqueFilter(new Kwf_Assets_Dependency_Iterator_Recursive($p->getDependency(), Kwf_Assets_Dependency_Abstract::DEPENDENCY_TYPE_ALL)), RecursiveIteratorIterator::CHILD_FIRST); foreach ($it as $dep) { $progress->next(1, "$dep"); if ($dep->getMimeType()) { $mimeType = $dep->getMimeType(); $p->warmupDependencyCaches($dep, $mimeType, $progress); } } } $progress->finish(); echo "generating package urls...\n"; $steps = count($packages) * count($langs) * count($exts); $c = new Zend_ProgressBar_Adapter_Console(); $c->setElements(array(Zend_ProgressBar_Adapter_Console::ELEMENT_PERCENT, Zend_ProgressBar_Adapter_Console::ELEMENT_BAR, Zend_ProgressBar_Adapter_Console::ELEMENT_TEXT)); $c->setTextWidth(80); $progress = new Zend_ProgressBar($c, 0, $steps); $allUrls = array(); foreach ($packages as $p) { $depName = $p->getDependencyName(); foreach ($langs as $language) { foreach ($exts as $extension) { $progress->next(1, "$depName $extension $language"); $urls = $p->getPackageUrls(self::$_mimeTypeByExtension[$extension], $language); if (Kwf_Setup::getBaseUrl()) { foreach ($urls as $k=>$i) { $urls[$k] = substr($i, strlen(Kwf_Setup::getBaseUrl())); } } $cacheId = $p->getPackageUrlsCacheId(self::$_mimeTypeByExtension[$extension], $language); Kwf_Assets_BuildCache::getInstance()->save($urls, $cacheId); foreach ($urls as $url) { if (!in_array($url, $allUrls)) { $allUrls[] = $url; } } } } } echo "generating package contents...\n"; $steps = count($allUrls)*2; $c = new Zend_ProgressBar_Adapter_Console(); $c->setElements(array(Zend_ProgressBar_Adapter_Console::ELEMENT_PERCENT, Zend_ProgressBar_Adapter_Console::ELEMENT_BAR, Zend_ProgressBar_Adapter_Console::ELEMENT_TEXT)); $c->setTextWidth(80); $progress = new Zend_ProgressBar($c, 0, $steps); foreach ($allUrls as $url) { if (substr($url, 0, 8) != '/assets/') continue; $param = explode('/', $url); if (count($param) != 7) continue; $dependencyClass = $param[3]; $dependencyParams = $param[4]; $urlLanguage = $param[5]; $urlExtension = $param[6]; $urlExtension = substr($urlExtension, 0, strpos($urlExtension, '?')); if (!class_exists($dependencyClass)) { throw new Kwf_Exception(); } if (!is_instance_of($dependencyClass, 'Kwf_Assets_Interface_UrlResolvable')) { throw new Kwf_Exception(); } $p = call_user_func(array($dependencyClass, 'fromUrlParameter'), $dependencyClass, $dependencyParams); if (!$p instanceof Kwf_Assets_Package) { throw new Kwf_Exception(); } $contents = $p->getUrlContents($urlExtension, $urlLanguage); $progress->next(1, "{$p->getDependencyName()} $urlExtension $urlLanguage source"); $cacheId = Kwf_Assets_Dispatcher::getInstance()->getCacheIdByPackage($p, $urlExtension, $urlLanguage); Kwf_Assets_BuildCache::getInstance()->save($contents, $cacheId); //save generated caches for clear-cache-watcher $fileName = 'build/assets/output-cache-ids-'.$urlExtension; if (!file_exists($fileName) || strpos(file_get_contents($fileName), $cacheId."\n") === false) { file_put_contents($fileName, $cacheId."\n", FILE_APPEND); } $contents = $p->getUrlContents($urlExtension.'.map', $urlLanguage); $progress->next(1, "{$p->getDependencyName()} $urlExtension $urlLanguage map"); $cacheId = Kwf_Assets_Dispatcher::getInstance()->getCacheIdByPackage($p, $urlExtension.'.map', $urlLanguage); Kwf_Assets_BuildCache::getInstance()->save($contents, $cacheId); } Kwf_Assets_Cache::getInstance()->clean(); Kwf_Assets_BuildCache::getInstance()->building = false; */ }
[ "protected", "function", "_build", "(", "$", "options", ")", "{", "$", "cmd", "=", "'NODE_PATH=vendor/koala-framework/koala-framework/node_modules_build ./vendor/bin/node node_modules/.bin/webpack --colors'", ";", "if", "(", "!", "isset", "(", "$", "_SERVER", "[", "'NO_PROGRESS'", "]", ")", ")", "$", "cmd", ".=", "' --progress'", ";", "passthru", "(", "$", "cmd", ",", "$", "retVal", ")", ";", "if", "(", "$", "retVal", ")", "{", "throw", "new", "Kwf_Exception", "(", "\"webpack failed\"", ")", ";", "}", "/*\n if (!file_exists('build/assets')) {\n mkdir('build/assets');\n }\n\n\n Kwf_Assets_BuildCache::getInstance()->building = true;\n Kwf_Assets_BuildCache::getInstance()->clean();\n\n Kwf_Assets_BuildCache::getInstance()->save(time(), 'assetsVersion');\n\n $langs = $this->getAllLanguages();\n $packages = $this->getAllPackages();\n $exts = array('js', 'defer.js', 'css');\n\n $providers = array();\n foreach ($packages as $p) {\n foreach ($p->getProviderList()->getProviders() as $provider) {\n if (!in_array($provider, $providers)) {\n $providers[] = $provider;\n }\n }\n }\n echo \"\\ninitializing providers...\\n\";\n $steps = count($providers);\n $c = new Zend_ProgressBar_Adapter_Console();\n $c->setElements(array(Zend_ProgressBar_Adapter_Console::ELEMENT_PERCENT,\n Zend_ProgressBar_Adapter_Console::ELEMENT_BAR,\n Zend_ProgressBar_Adapter_Console::ELEMENT_TEXT));\n $c->setTextWidth(80);\n $progress = new Zend_ProgressBar($c, 0, $steps);\n foreach ($providers as $provider) {\n $progress->next(1, get_class($provider));\n $provider->initialize();\n }\n $progress->finish();\n\n echo \"calculating dependencies...\\n\";\n $steps = count($packages) * count($exts);\n $c = new Zend_ProgressBar_Adapter_Console();\n $c->setElements(array(Zend_ProgressBar_Adapter_Console::ELEMENT_PERCENT,\n Zend_ProgressBar_Adapter_Console::ELEMENT_BAR,\n Zend_ProgressBar_Adapter_Console::ELEMENT_TEXT));\n $c->setTextWidth(80);\n $progress = new Zend_ProgressBar($c, 0, $steps);\n\n $countDependencies = 0;\n foreach ($packages as $p) {\n $depName = $p->getDependencyName();\n foreach ($exts as $extension) {\n $progress->next(1, \"$depName $extension\");\n $p->getFilteredUniqueDependencies(self::$_mimeTypeByExtension[$extension]);\n }\n $it = new RecursiveIteratorIterator(new Kwf_Assets_Dependency_Iterator_UniqueFilter(new Kwf_Assets_Dependency_Iterator_Recursive($p->getDependency(), Kwf_Assets_Dependency_Abstract::DEPENDENCY_TYPE_ALL)), RecursiveIteratorIterator::CHILD_FIRST);\n foreach ($it as $i) {\n $countDependencies++;\n }\n }\n $progress->finish();\n\n echo \"compiling assets...\\n\";\n $c = new Zend_ProgressBar_Adapter_Console();\n $c->setElements(array(Zend_ProgressBar_Adapter_Console::ELEMENT_ETA,\n Zend_ProgressBar_Adapter_Console::ELEMENT_BAR,\n Zend_ProgressBar_Adapter_Console::ELEMENT_TEXT));\n $c->setTextWidth(80);\n $progress = new Zend_ProgressBar($c, 0, $countDependencies);\n\n foreach ($packages as $p) {\n $it = new RecursiveIteratorIterator(new Kwf_Assets_Dependency_Iterator_UniqueFilter(new Kwf_Assets_Dependency_Iterator_Recursive($p->getDependency(), Kwf_Assets_Dependency_Abstract::DEPENDENCY_TYPE_ALL)), RecursiveIteratorIterator::CHILD_FIRST);\n foreach ($it as $dep) {\n $progress->next(1, \"$dep\");\n if ($dep->getMimeType()) {\n $mimeType = $dep->getMimeType();\n $p->warmupDependencyCaches($dep, $mimeType, $progress);\n }\n }\n }\n $progress->finish();\n\n echo \"generating package urls...\\n\";\n $steps = count($packages) * count($langs) * count($exts);\n $c = new Zend_ProgressBar_Adapter_Console();\n $c->setElements(array(Zend_ProgressBar_Adapter_Console::ELEMENT_PERCENT,\n Zend_ProgressBar_Adapter_Console::ELEMENT_BAR,\n Zend_ProgressBar_Adapter_Console::ELEMENT_TEXT));\n $c->setTextWidth(80);\n $progress = new Zend_ProgressBar($c, 0, $steps);\n $allUrls = array();\n foreach ($packages as $p) {\n $depName = $p->getDependencyName();\n foreach ($langs as $language) {\n\n foreach ($exts as $extension) {\n\n $progress->next(1, \"$depName $extension $language\");\n $urls = $p->getPackageUrls(self::$_mimeTypeByExtension[$extension], $language);\n if (Kwf_Setup::getBaseUrl()) {\n foreach ($urls as $k=>$i) {\n $urls[$k] = substr($i, strlen(Kwf_Setup::getBaseUrl()));\n }\n }\n $cacheId = $p->getPackageUrlsCacheId(self::$_mimeTypeByExtension[$extension], $language);\n Kwf_Assets_BuildCache::getInstance()->save($urls, $cacheId);\n\n foreach ($urls as $url) {\n if (!in_array($url, $allUrls)) {\n $allUrls[] = $url;\n }\n }\n }\n\n }\n }\n\n echo \"generating package contents...\\n\";\n $steps = count($allUrls)*2;\n $c = new Zend_ProgressBar_Adapter_Console();\n $c->setElements(array(Zend_ProgressBar_Adapter_Console::ELEMENT_PERCENT,\n Zend_ProgressBar_Adapter_Console::ELEMENT_BAR,\n Zend_ProgressBar_Adapter_Console::ELEMENT_TEXT));\n $c->setTextWidth(80);\n $progress = new Zend_ProgressBar($c, 0, $steps);\n foreach ($allUrls as $url) {\n if (substr($url, 0, 8) != '/assets/') continue;\n $param = explode('/', $url);\n if (count($param) != 7) continue;\n $dependencyClass = $param[3];\n $dependencyParams = $param[4];\n $urlLanguage = $param[5];\n $urlExtension = $param[6];\n $urlExtension = substr($urlExtension, 0, strpos($urlExtension, '?'));\n if (!class_exists($dependencyClass)) {\n throw new Kwf_Exception();\n }\n if (!is_instance_of($dependencyClass, 'Kwf_Assets_Interface_UrlResolvable')) {\n throw new Kwf_Exception();\n }\n $p = call_user_func(array($dependencyClass, 'fromUrlParameter'), $dependencyClass, $dependencyParams);\n if (!$p instanceof Kwf_Assets_Package) {\n throw new Kwf_Exception();\n }\n\n $contents = $p->getUrlContents($urlExtension, $urlLanguage);\n\n $progress->next(1, \"{$p->getDependencyName()} $urlExtension $urlLanguage source\");\n $cacheId = Kwf_Assets_Dispatcher::getInstance()->getCacheIdByPackage($p, $urlExtension, $urlLanguage);\n Kwf_Assets_BuildCache::getInstance()->save($contents, $cacheId);\n\n //save generated caches for clear-cache-watcher\n $fileName = 'build/assets/output-cache-ids-'.$urlExtension;\n if (!file_exists($fileName) || strpos(file_get_contents($fileName), $cacheId.\"\\n\") === false) {\n file_put_contents($fileName, $cacheId.\"\\n\", FILE_APPEND);\n }\n\n\n $contents = $p->getUrlContents($urlExtension.'.map', $urlLanguage);\n $progress->next(1, \"{$p->getDependencyName()} $urlExtension $urlLanguage map\");\n $cacheId = Kwf_Assets_Dispatcher::getInstance()->getCacheIdByPackage($p, $urlExtension.'.map', $urlLanguage);\n Kwf_Assets_BuildCache::getInstance()->save($contents, $cacheId);\n }\n\n\n Kwf_Assets_Cache::getInstance()->clean();\n Kwf_Assets_BuildCache::getInstance()->building = false;\n */", "}" ]
/* private static $_mimeTypeByExtension = array( 'js' => 'text/javascript', 'defer.js' => 'text/javascript; defer', 'css' => 'text/css', ); public function getAllPackages() { $packages = array(); foreach (Kwf_Config::getValueArray('assets.packageFactories') as $i) { if (!$i) continue; if (!is_instance_of($i, 'Kwf_Assets_Package_FactoryInterface')) { throw new Kwf_Exception("'$i' doesn't implement Kwf_Assets_Package_FactoryInterface"); } $packages = array_merge($packages, call_user_func(array($i, 'createPackages'))); } return $packages; } public function getAllLanguages() { $config = Zend_Registry::get('config'); $langs = array(); if ($config->webCodeLanguage) $langs[] = $config->webCodeLanguage; if ($config->languages) { foreach ($config->languages as $lang=>$name) { $langs[] = $lang; } } if (Kwf_Component_Data_Root::getComponentClass()) { foreach (Kwc_Abstract::getComponentClasses() as $c) { if (Kwc_Abstract::getFlag($c, 'hasAvailableLanguages')) { foreach (call_user_func(array($c, 'getAvailableLanguages'), $c) as $i) { if (!in_array($i, $langs)) $langs[] = $i; } } } } $langs = array_unique($langs); return $langs; } public function flagAllPackagesOutdated($extension) { Don't change assetsVersion by clear-cache-watcher that would require clearing js cache when only css change Kwf_Assets_BuildCache::getInstance()->remove('assetsVersion'); //remove and save as remove will also remove cache in apc Kwf_Assets_BuildCache::getInstance()->save(time(), 'assetsVersion'); $langs = $this->getAllLanguages(); $packages = $this->getAllPackages(); foreach ($packages as $p) { foreach ($langs as $language) { $cacheId = Kwf_Assets_Dispatcher::getInstance()->getCacheIdByPackage($p, $extension, $language); if (Kwf_Assets_BuildCache::getInstance()->load($cacheId) !== false) { Kwf_Assets_BuildCache::getInstance()->save('outdated', $cacheId); } $cacheId = Kwf_Assets_Dispatcher::getInstance()->getCacheIdByPackage($p, $extension.'.map', $language); if (Kwf_Assets_BuildCache::getInstance()->load($cacheId) !== false) { Kwf_Assets_BuildCache::getInstance()->save('outdated', $cacheId); } } } }
[ "/", "*", "private", "static", "$_mimeTypeByExtension", "=", "array", "(", "js", "=", ">", "text", "/", "javascript", "defer", ".", "js", "=", ">", "text", "/", "javascript", ";", "defer", "css", "=", ">", "text", "/", "css", ")", ";" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Util/Build/Types/Assets.php#L73-L248
koala-framework/koala-framework
Kwf/Util/Component.php
Kwf_Util_Component.duplicate
public static function duplicate(Kwf_Component_Data $source, Kwf_Component_Data $parentTarget, Zend_ProgressBar $progressBar = null) { $new = $source->generator->duplicateChild($source, $parentTarget, $progressBar); if (!$new) { throw new Kwf_Exception("Failed duplicating '$source->componentId'"); } Kwf_Component_Generator_Abstract::clearInstances(); Kwf_Component_Data_Root::reset(); //TODO: schöner wär ein flag bei den komponenten ob es diese fkt im admin //gibt und dann für alle admins aufrufen //ändern sobald es für mehrere benötigt wird Kwc_Root_TrlRoot_Chained_Admin::duplicated($source, $new); return $new; }
php
public static function duplicate(Kwf_Component_Data $source, Kwf_Component_Data $parentTarget, Zend_ProgressBar $progressBar = null) { $new = $source->generator->duplicateChild($source, $parentTarget, $progressBar); if (!$new) { throw new Kwf_Exception("Failed duplicating '$source->componentId'"); } Kwf_Component_Generator_Abstract::clearInstances(); Kwf_Component_Data_Root::reset(); //TODO: schöner wär ein flag bei den komponenten ob es diese fkt im admin //gibt und dann für alle admins aufrufen //ändern sobald es für mehrere benötigt wird Kwc_Root_TrlRoot_Chained_Admin::duplicated($source, $new); return $new; }
[ "public", "static", "function", "duplicate", "(", "Kwf_Component_Data", "$", "source", ",", "Kwf_Component_Data", "$", "parentTarget", ",", "Zend_ProgressBar", "$", "progressBar", "=", "null", ")", "{", "$", "new", "=", "$", "source", "->", "generator", "->", "duplicateChild", "(", "$", "source", ",", "$", "parentTarget", ",", "$", "progressBar", ")", ";", "if", "(", "!", "$", "new", ")", "{", "throw", "new", "Kwf_Exception", "(", "\"Failed duplicating '$source->componentId'\"", ")", ";", "}", "Kwf_Component_Generator_Abstract", "::", "clearInstances", "(", ")", ";", "Kwf_Component_Data_Root", "::", "reset", "(", ")", ";", "//TODO: schöner wär ein flag bei den komponenten ob es diese fkt im admin", "//gibt und dann für alle admins aufrufen", "//ändern sobald es für mehrere benötigt wird", "Kwc_Root_TrlRoot_Chained_Admin", "::", "duplicated", "(", "$", "source", ",", "$", "new", ")", ";", "return", "$", "new", ";", "}" ]
Recursively duplicate components You need to call afterDuplicate afterwards!
[ "Recursively", "duplicate", "components" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Util/Component.php#L47-L64
koala-framework/koala-framework
Kwf/Util/Component.php
Kwf_Util_Component.afterDuplicate
public static function afterDuplicate(Kwf_Component_Data $rootSource, Kwf_Component_Data $rootTarget) { foreach (Kwf_Component_Abstract::getComponentClasses() as $c) { $admin = Kwf_Component_Abstract_Admin::getInstance($c); $admin->afterDuplicate($rootSource, $rootTarget); } }
php
public static function afterDuplicate(Kwf_Component_Data $rootSource, Kwf_Component_Data $rootTarget) { foreach (Kwf_Component_Abstract::getComponentClasses() as $c) { $admin = Kwf_Component_Abstract_Admin::getInstance($c); $admin->afterDuplicate($rootSource, $rootTarget); } }
[ "public", "static", "function", "afterDuplicate", "(", "Kwf_Component_Data", "$", "rootSource", ",", "Kwf_Component_Data", "$", "rootTarget", ")", "{", "foreach", "(", "Kwf_Component_Abstract", "::", "getComponentClasses", "(", ")", "as", "$", "c", ")", "{", "$", "admin", "=", "Kwf_Component_Abstract_Admin", "::", "getInstance", "(", "$", "c", ")", ";", "$", "admin", "->", "afterDuplicate", "(", "$", "rootSource", ",", "$", "rootTarget", ")", ";", "}", "}" ]
Needs to be called after (multiple) duplicate() calls with a common root
[ "Needs", "to", "be", "called", "after", "(", "multiple", ")", "duplicate", "()", "calls", "with", "a", "common", "root" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Util/Component.php#L69-L75