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
oat-sa/tao-core
models/classes/security/xsrf/TokenService.php
TokenService.revokeToken
public function revokeToken($token) { $revoked = false; $store = $this->getStore(); $pool = $store->getTokens(); if(!is_null($pool)){ foreach($pool as $key => $savedToken){ if($savedToken['token'] == $token){ unset($pool[$key]); $revoked = true; break; } } } $store->setTokens($pool); return $revoked; }
php
public function revokeToken($token) { $revoked = false; $store = $this->getStore(); $pool = $store->getTokens(); if(!is_null($pool)){ foreach($pool as $key => $savedToken){ if($savedToken['token'] == $token){ unset($pool[$key]); $revoked = true; break; } } } $store->setTokens($pool); return $revoked; }
[ "public", "function", "revokeToken", "(", "$", "token", ")", "{", "$", "revoked", "=", "false", ";", "$", "store", "=", "$", "this", "->", "getStore", "(", ")", ";", "$", "pool", "=", "$", "store", "->", "getTokens", "(", ")", ";", "if", "(", "!"...
Revokes the given token @return true if the revokation succeed (if the token was found)
[ "Revokes", "the", "given", "token" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/security/xsrf/TokenService.php#L130-L147
oat-sa/tao-core
models/classes/security/xsrf/TokenService.php
TokenService.getTokenName
public function getTokenName() { $session = \PHPSession::singleton(); if ($session->hasAttribute(TokenStore::TOKEN_NAME)) { $name = $session->getAttribute(TokenStore::TOKEN_NAME); } else { $name = 'tao_' . substr(md5(microtime()), rand(0, 25), 7); $session->setAttribute(TokenStore::TOKEN_NAME, $name); } return $name; }
php
public function getTokenName() { $session = \PHPSession::singleton(); if ($session->hasAttribute(TokenStore::TOKEN_NAME)) { $name = $session->getAttribute(TokenStore::TOKEN_NAME); } else { $name = 'tao_' . substr(md5(microtime()), rand(0, 25), 7); $session->setAttribute(TokenStore::TOKEN_NAME, $name); } return $name; }
[ "public", "function", "getTokenName", "(", ")", "{", "$", "session", "=", "\\", "PHPSession", "::", "singleton", "(", ")", ";", "if", "(", "$", "session", "->", "hasAttribute", "(", "TokenStore", "::", "TOKEN_NAME", ")", ")", "{", "$", "name", "=", "$"...
Gets this session's name for token @return {String}
[ "Gets", "this", "session", "s", "name", "for", "token" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/security/xsrf/TokenService.php#L153-L165
oat-sa/tao-core
models/classes/security/xsrf/TokenService.php
TokenService.invalidate
protected function invalidate($pool) { $actualTime = microtime(true); $timeLimit = $this->getTimeLimit(); $reduced = array_filter($pool, function($token) use($actualTime, $timeLimit){ if(!isset($token['ts']) || !isset($token['token'])){ return false; } if($timeLimit > 0){ return $token['ts'] + $timeLimit > $actualTime; } return true; }); if($this->getPoolSize() > 0 && count($reduced) > 0){ usort($reduced, function($a, $b){ if($a['ts'] == $b['ts']){ return 0; } return $a['ts'] < $b['ts'] ? -1 : 1; }); //remove the elements at the begining to fit the pool size while(count($reduced) >= $this->getPoolSize()){ array_shift($reduced); } } return $reduced; }
php
protected function invalidate($pool) { $actualTime = microtime(true); $timeLimit = $this->getTimeLimit(); $reduced = array_filter($pool, function($token) use($actualTime, $timeLimit){ if(!isset($token['ts']) || !isset($token['token'])){ return false; } if($timeLimit > 0){ return $token['ts'] + $timeLimit > $actualTime; } return true; }); if($this->getPoolSize() > 0 && count($reduced) > 0){ usort($reduced, function($a, $b){ if($a['ts'] == $b['ts']){ return 0; } return $a['ts'] < $b['ts'] ? -1 : 1; }); //remove the elements at the begining to fit the pool size while(count($reduced) >= $this->getPoolSize()){ array_shift($reduced); } } return $reduced; }
[ "protected", "function", "invalidate", "(", "$", "pool", ")", "{", "$", "actualTime", "=", "microtime", "(", "true", ")", ";", "$", "timeLimit", "=", "$", "this", "->", "getTimeLimit", "(", ")", ";", "$", "reduced", "=", "array_filter", "(", "$", "pool...
Invalidate the tokens in the pool : - remove the oldest if the pool raises it's size limit - remove the expired tokens @return array the invalidated pool
[ "Invalidate", "the", "tokens", "in", "the", "pool", ":", "-", "remove", "the", "oldest", "if", "the", "pool", "raises", "it", "s", "size", "limit", "-", "remove", "the", "expired", "tokens" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/security/xsrf/TokenService.php#L173-L202
oat-sa/tao-core
models/classes/security/xsrf/TokenService.php
TokenService.getPoolSize
protected function getPoolSize() { $poolSize = self::DEFAULT_POOL_SIZE; if($this->hasOption(self::POOL_SIZE_OPT)){ $poolSize = (int)$this->getOption(self::POOL_SIZE_OPT); } return $poolSize; }
php
protected function getPoolSize() { $poolSize = self::DEFAULT_POOL_SIZE; if($this->hasOption(self::POOL_SIZE_OPT)){ $poolSize = (int)$this->getOption(self::POOL_SIZE_OPT); } return $poolSize; }
[ "protected", "function", "getPoolSize", "(", ")", "{", "$", "poolSize", "=", "self", "::", "DEFAULT_POOL_SIZE", ";", "if", "(", "$", "this", "->", "hasOption", "(", "self", "::", "POOL_SIZE_OPT", ")", ")", "{", "$", "poolSize", "=", "(", "int", ")", "$...
Get the configured pool size @return int the pool size, 10 by default
[ "Get", "the", "configured", "pool", "size" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/security/xsrf/TokenService.php#L208-L215
oat-sa/tao-core
models/classes/security/xsrf/TokenService.php
TokenService.getTimeLimit
protected function getTimeLimit() { $timeLimit = self::DEFAULT_TIME_LIMIT; if($this->hasOption(self::TIME_LIMIT_OPT)){ $timeLimit = (int)$this->getOption(self::TIME_LIMIT_OPT); } return $timeLimit; }
php
protected function getTimeLimit() { $timeLimit = self::DEFAULT_TIME_LIMIT; if($this->hasOption(self::TIME_LIMIT_OPT)){ $timeLimit = (int)$this->getOption(self::TIME_LIMIT_OPT); } return $timeLimit; }
[ "protected", "function", "getTimeLimit", "(", ")", "{", "$", "timeLimit", "=", "self", "::", "DEFAULT_TIME_LIMIT", ";", "if", "(", "$", "this", "->", "hasOption", "(", "self", "::", "TIME_LIMIT_OPT", ")", ")", "{", "$", "timeLimit", "=", "(", "int", ")",...
Get the configured time limit in seconds @return int the limit
[ "Get", "the", "configured", "time", "limit", "in", "seconds" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/security/xsrf/TokenService.php#L221-L228
oat-sa/tao-core
models/classes/security/xsrf/TokenService.php
TokenService.getStore
protected function getStore() { $store = null; if($this->hasOption(self::STORE_OPT)){ $store = $this->getOption(self::STORE_OPT); } return $store; }
php
protected function getStore() { $store = null; if($this->hasOption(self::STORE_OPT)){ $store = $this->getOption(self::STORE_OPT); } return $store; }
[ "protected", "function", "getStore", "(", ")", "{", "$", "store", "=", "null", ";", "if", "(", "$", "this", "->", "hasOption", "(", "self", "::", "STORE_OPT", ")", ")", "{", "$", "store", "=", "$", "this", "->", "getOption", "(", "self", "::", "STO...
Get the configured store @return TokenStore the store
[ "Get", "the", "configured", "store" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/security/xsrf/TokenService.php#L234-L241
oat-sa/tao-core
helpers/dateFormatter/AbstractDateFormatter.php
AbstractDateFormatter.format
public function format($timestamp, $format, DateTimeZone $timeZone = null) { // Creates DateTime with microseconds. $dateTime = DateTime::createFromFormat('U.u', sprintf('%.f', $timestamp)); if ($timeZone === null) { $timeZone = new DateTimeZone(SessionManager::getSession()->getTimeZone()); } $dateTime->setTimezone($timeZone); return $dateTime->format($this->getFormat($format)); }
php
public function format($timestamp, $format, DateTimeZone $timeZone = null) { // Creates DateTime with microseconds. $dateTime = DateTime::createFromFormat('U.u', sprintf('%.f', $timestamp)); if ($timeZone === null) { $timeZone = new DateTimeZone(SessionManager::getSession()->getTimeZone()); } $dateTime->setTimezone($timeZone); return $dateTime->format($this->getFormat($format)); }
[ "public", "function", "format", "(", "$", "timestamp", ",", "$", "format", ",", "DateTimeZone", "$", "timeZone", "=", "null", ")", "{", "// Creates DateTime with microseconds.", "$", "dateTime", "=", "DateTime", "::", "createFromFormat", "(", "'U.u'", ",", "spri...
{@inheritdoc}
[ "{" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/dateFormatter/AbstractDateFormatter.php#L80-L90
oat-sa/tao-core
helpers/dateFormatter/AbstractDateFormatter.php
AbstractDateFormatter.getFormat
public function getFormat($format) { if (!isset($this->datetimeFormats[$format])) { if (!isset($this->datetimeFormats[DateHelper::FORMAT_FALLBACK])) { Logger::w('Unknown date format ' . $format . ' for ' . __FUNCTION__, 'TAO'); return ''; } $format = DateHelper::FORMAT_FALLBACK; } return $this->datetimeFormats[$format]; }
php
public function getFormat($format) { if (!isset($this->datetimeFormats[$format])) { if (!isset($this->datetimeFormats[DateHelper::FORMAT_FALLBACK])) { Logger::w('Unknown date format ' . $format . ' for ' . __FUNCTION__, 'TAO'); return ''; } $format = DateHelper::FORMAT_FALLBACK; } return $this->datetimeFormats[$format]; }
[ "public", "function", "getFormat", "(", "$", "format", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "datetimeFormats", "[", "$", "format", "]", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "datetimeFormats", "[", "D...
{@inheritdoc}
[ "{" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/dateFormatter/AbstractDateFormatter.php#L95-L107
oat-sa/tao-core
helpers/dateFormatter/AbstractDateFormatter.php
AbstractDateFormatter.convertPhpToJavascriptFormat
public function convertPhpToJavascriptFormat($phpFormat) { // Converts all the meaningful characters. $replacements = self::REPLACEMENTS; // Converts all the escaped meaningful characters. foreach (self::REPLACEMENTS as $from => $to) { $replacements['\\' . $from] = '[' . $from . ']'; } return strtr($phpFormat, $replacements); }
php
public function convertPhpToJavascriptFormat($phpFormat) { // Converts all the meaningful characters. $replacements = self::REPLACEMENTS; // Converts all the escaped meaningful characters. foreach (self::REPLACEMENTS as $from => $to) { $replacements['\\' . $from] = '[' . $from . ']'; } return strtr($phpFormat, $replacements); }
[ "public", "function", "convertPhpToJavascriptFormat", "(", "$", "phpFormat", ")", "{", "// Converts all the meaningful characters.", "$", "replacements", "=", "self", "::", "REPLACEMENTS", ";", "// Converts all the escaped meaningful characters.", "foreach", "(", "self", "::"...
Converts php DateTime format to Javascript Moment format. @param string $phpFormat @return string
[ "Converts", "php", "DateTime", "format", "to", "Javascript", "Moment", "format", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/dateFormatter/AbstractDateFormatter.php#L124-L135
oat-sa/tao-core
helpers/class.Uri.php
tao_helpers_Uri.getBaseUrl
public static function getBaseUrl() { if (empty(self::$base) && defined('BASE_URL')) { self::$base = BASE_URL; if (!preg_match("/\/$/", self::$base)) { self::$base .= '/'; } } return self::$base; }
php
public static function getBaseUrl() { if (empty(self::$base) && defined('BASE_URL')) { self::$base = BASE_URL; if (!preg_match("/\/$/", self::$base)) { self::$base .= '/'; } } return self::$base; }
[ "public", "static", "function", "getBaseUrl", "(", ")", "{", "if", "(", "empty", "(", "self", "::", "$", "base", ")", "&&", "defined", "(", "'BASE_URL'", ")", ")", "{", "self", "::", "$", "base", "=", "BASE_URL", ";", "if", "(", "!", "preg_match", ...
get the project base url @access public @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> @return string
[ "get", "the", "project", "base", "url" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Uri.php#L78-L88
oat-sa/tao-core
helpers/class.Uri.php
tao_helpers_Uri.getRootUrl
public static function getRootUrl() { if (empty(self::$root) && defined('ROOT_URL')) { self::$root = ROOT_URL; if (!preg_match("/\/$/", self::$root)) { self::$root .= '/'; } } return self::$root; }
php
public static function getRootUrl() { if (empty(self::$root) && defined('ROOT_URL')) { self::$root = ROOT_URL; if (!preg_match("/\/$/", self::$root)) { self::$root .= '/'; } } return self::$root; }
[ "public", "static", "function", "getRootUrl", "(", ")", "{", "if", "(", "empty", "(", "self", "::", "$", "root", ")", "&&", "defined", "(", "'ROOT_URL'", ")", ")", "{", "self", "::", "$", "root", "=", "ROOT_URL", ";", "if", "(", "!", "preg_match", ...
Short description of method getRootUrl @access public @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> @return string
[ "Short", "description", "of", "method", "getRootUrl" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Uri.php#L97-L107
oat-sa/tao-core
helpers/class.Uri.php
tao_helpers_Uri.url
public static function url($action = null, $module = null, $extension = null, $params = array()) { if (is_null($module)) { $module = Context::getInstance()->getModuleName(); } if (is_null($action)) { $action = Context::getInstance()->getActionName(); } if (is_null($extension)) { $extension = Context::getInstance()->getExtensionName(); } $returnValue = self::getRootUrl() . $extension . '/' . $module . '/' . $action; if (is_string($params) && strlen($params) > 0) { $returnValue .= '?' . $params; } if (is_array($params) && count($params) ) { $returnValue .= '?'; foreach ($params as $key => $value) { $returnValue .= $key . '=' . rawurlencode($value) . '&'; } $returnValue = substr($returnValue, 0, -1); } return $returnValue; }
php
public static function url($action = null, $module = null, $extension = null, $params = array()) { if (is_null($module)) { $module = Context::getInstance()->getModuleName(); } if (is_null($action)) { $action = Context::getInstance()->getActionName(); } if (is_null($extension)) { $extension = Context::getInstance()->getExtensionName(); } $returnValue = self::getRootUrl() . $extension . '/' . $module . '/' . $action; if (is_string($params) && strlen($params) > 0) { $returnValue .= '?' . $params; } if (is_array($params) && count($params) ) { $returnValue .= '?'; foreach ($params as $key => $value) { $returnValue .= $key . '=' . rawurlencode($value) . '&'; } $returnValue = substr($returnValue, 0, -1); } return $returnValue; }
[ "public", "static", "function", "url", "(", "$", "action", "=", "null", ",", "$", "module", "=", "null", ",", "$", "extension", "=", "null", ",", "$", "params", "=", "array", "(", ")", ")", "{", "if", "(", "is_null", "(", "$", "module", ")", ")",...
conveniance method to create urls based on the current MVC context and it for the used kind of url resolving @access public @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> @param string action @param string module @param string extension @param array|string params @return string
[ "conveniance", "method", "to", "create", "urls", "based", "on", "the", "current", "MVC", "context", "and", "it", "for", "the", "used", "kind", "of", "url", "resolving" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Uri.php#L121-L149
oat-sa/tao-core
helpers/class.Uri.php
tao_helpers_Uri.encode
public static function encode($uri, $dotMode = true) { if (0 === strpos($uri, 'http')) { //return base64_encode($uri); if ($dotMode) { //order matters here don't change the _4_ position $returnValue = str_replace(['#', '://', '/', '.', ':'], ['_3_', '_2_', '_1_', '_0_', '_4_'], $uri); } else { $returnValue = str_replace(['#', '://', '/', ':'], ['_3_', '_2_', '_1_', '_4_'], $uri); } } else { $returnValue = $uri; } return $returnValue; }
php
public static function encode($uri, $dotMode = true) { if (0 === strpos($uri, 'http')) { //return base64_encode($uri); if ($dotMode) { //order matters here don't change the _4_ position $returnValue = str_replace(['#', '://', '/', '.', ':'], ['_3_', '_2_', '_1_', '_0_', '_4_'], $uri); } else { $returnValue = str_replace(['#', '://', '/', ':'], ['_3_', '_2_', '_1_', '_4_'], $uri); } } else { $returnValue = $uri; } return $returnValue; }
[ "public", "static", "function", "encode", "(", "$", "uri", ",", "$", "dotMode", "=", "true", ")", "{", "if", "(", "0", "===", "strpos", "(", "$", "uri", ",", "'http'", ")", ")", "{", "//return base64_encode($uri);", "if", "(", "$", "dotMode", ")", "{...
encode an URI @access public @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> @param string uri @param boolean dotMode @return string
[ "encode", "an", "URI" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Uri.php#L174-L189
oat-sa/tao-core
helpers/class.Uri.php
tao_helpers_Uri.encodeRelativeUrl
public static function encodeRelativeUrl($url) { $url = str_replace(DIRECTORY_SEPARATOR, '/', $url); $parts = explode('/', $url); foreach (array_keys($parts) as $key) { $parts[$key] = rawurlencode($parts[$key]); } return implode('/', $parts); }
php
public static function encodeRelativeUrl($url) { $url = str_replace(DIRECTORY_SEPARATOR, '/', $url); $parts = explode('/', $url); foreach (array_keys($parts) as $key) { $parts[$key] = rawurlencode($parts[$key]); } return implode('/', $parts); }
[ "public", "static", "function", "encodeRelativeUrl", "(", "$", "url", ")", "{", "$", "url", "=", "str_replace", "(", "DIRECTORY_SEPARATOR", ",", "'/'", ",", "$", "url", ")", ";", "$", "parts", "=", "explode", "(", "'/'", ",", "$", "url", ")", ";", "f...
encode a relative URL @access public @param string uri @param boolean dotMode @return string
[ "encode", "a", "relative", "URL" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Uri.php#L199-L207
oat-sa/tao-core
helpers/class.Uri.php
tao_helpers_Uri.decode
public static function decode($uri, $dotMode = true) { if (0 === strpos($uri, 'http')) { //return base64_decode($uri); if ($dotMode) { //$returnValue = urldecode(str_replace('__', '.', $uri)); //$returnValue = str_replace('w_org', 'w3.org', $returnValue); $returnValue = str_replace(['_0_', '_1_', '_2_', '_3_', '_4_'], ['.', '/', '://', '#', ':'], $uri); } else { $returnValue = str_replace(['_1_', '_2_', '_3_', '_4_'], ['/', '://', '#', ':'], $uri); } } else { $returnValue = $uri; } return (string)$returnValue; }
php
public static function decode($uri, $dotMode = true) { if (0 === strpos($uri, 'http')) { //return base64_decode($uri); if ($dotMode) { //$returnValue = urldecode(str_replace('__', '.', $uri)); //$returnValue = str_replace('w_org', 'w3.org', $returnValue); $returnValue = str_replace(['_0_', '_1_', '_2_', '_3_', '_4_'], ['.', '/', '://', '#', ':'], $uri); } else { $returnValue = str_replace(['_1_', '_2_', '_3_', '_4_'], ['/', '://', '#', ':'], $uri); } } else { $returnValue = $uri; } return (string)$returnValue; }
[ "public", "static", "function", "decode", "(", "$", "uri", ",", "$", "dotMode", "=", "true", ")", "{", "if", "(", "0", "===", "strpos", "(", "$", "uri", ",", "'http'", ")", ")", "{", "//return base64_decode($uri);", "if", "(", "$", "dotMode", ")", "{...
decode an URI @access public @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> @param string $uri @param boolean $dotMode @return string
[ "decode", "an", "URI" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Uri.php#L218-L235
oat-sa/tao-core
helpers/class.Uri.php
tao_helpers_Uri.encodeArray
public static function encodeArray($uris, $encodeMode = self::ENCODE_ARRAY_ALL, $dotMode = true, $uniqueMode = false) { $returnValue = []; if (is_array($uris)) { foreach ($uris as $key => $value) { if ($encodeMode == self::ENCODE_ARRAY_KEYS || $encodeMode == self::ENCODE_ARRAY_ALL) { $key = self::encode($key, $dotMode); } if ($encodeMode == self::ENCODE_ARRAY_VALUES || $encodeMode == self::ENCODE_ARRAY_ALL) { $value = self::encode($value, $dotMode); } $returnValue[$key] = $value; } } if ($uniqueMode) { $returnValue = array_unique($returnValue); } return $returnValue; }
php
public static function encodeArray($uris, $encodeMode = self::ENCODE_ARRAY_ALL, $dotMode = true, $uniqueMode = false) { $returnValue = []; if (is_array($uris)) { foreach ($uris as $key => $value) { if ($encodeMode == self::ENCODE_ARRAY_KEYS || $encodeMode == self::ENCODE_ARRAY_ALL) { $key = self::encode($key, $dotMode); } if ($encodeMode == self::ENCODE_ARRAY_VALUES || $encodeMode == self::ENCODE_ARRAY_ALL) { $value = self::encode($value, $dotMode); } $returnValue[$key] = $value; } } if ($uniqueMode) { $returnValue = array_unique($returnValue); } return $returnValue; }
[ "public", "static", "function", "encodeArray", "(", "$", "uris", ",", "$", "encodeMode", "=", "self", "::", "ENCODE_ARRAY_ALL", ",", "$", "dotMode", "=", "true", ",", "$", "uniqueMode", "=", "false", ")", "{", "$", "returnValue", "=", "[", "]", ";", "i...
Encode the uris composing either the keys or the values of the array in @access public @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> @param array uris @param int encodeMode @param boolean dotMode @param boolean uniqueMode @return array
[ "Encode", "the", "uris", "composing", "either", "the", "keys", "or", "the", "values", "of", "the", "array", "in" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Uri.php#L258-L279
oat-sa/tao-core
helpers/class.Uri.php
tao_helpers_Uri.getUniqueId
public static function getUniqueId($uriResource) { $returnValue = ''; if (stripos($uriResource, "#") > 0) { $returnValue = substr($uriResource, stripos($uriResource, "#") + 1); } return $returnValue; }
php
public static function getUniqueId($uriResource) { $returnValue = ''; if (stripos($uriResource, "#") > 0) { $returnValue = substr($uriResource, stripos($uriResource, "#") + 1); } return $returnValue; }
[ "public", "static", "function", "getUniqueId", "(", "$", "uriResource", ")", "{", "$", "returnValue", "=", "''", ";", "if", "(", "stripos", "(", "$", "uriResource", ",", "\"#\"", ")", ">", "0", ")", "{", "$", "returnValue", "=", "substr", "(", "$", "...
generate a semi unique id, that is used in folder names. @todo Remove the need for this function @access public @author sam@taotesting.com @param string uriResource @return string
[ "generate", "a", "semi", "unique", "id", "that", "is", "used", "in", "folder", "names", ".", "@todo", "Remove", "the", "need", "for", "this", "function" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Uri.php#L291-L300
oat-sa/tao-core
helpers/class.Uri.php
tao_helpers_Uri.getPath
public static function getPath($uri) { if (preg_match("/^[A-Za-z0-9]*$/", $uri)) { // no '.', no '/', ... does not look good. return null; } $returnValue = parse_url($uri, PHP_URL_PATH); if (empty($returnValue)) { return null; } return $returnValue; }
php
public static function getPath($uri) { if (preg_match("/^[A-Za-z0-9]*$/", $uri)) { // no '.', no '/', ... does not look good. return null; } $returnValue = parse_url($uri, PHP_URL_PATH); if (empty($returnValue)) { return null; } return $returnValue; }
[ "public", "static", "function", "getPath", "(", "$", "uri", ")", "{", "if", "(", "preg_match", "(", "\"/^[A-Za-z0-9]*$/\"", ",", "$", "uri", ")", ")", "{", "// no '.', no '/', ... does not look good.", "return", "null", ";", "}", "$", "returnValue", "=", "pars...
Returns the path from a URI. In other words, it returns what comes after domain but before the query string. If is given as a parameter value, '/path/to/something' is returned. If an occurs, null will be returned. @access public @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> @param string uri A Uniform Resource Identifier (URI). @return string|null
[ "Returns", "the", "path", "from", "a", "URI", ".", "In", "other", "words", "it", "returns", "what", "comes", "after", "domain", "but", "before", "the", "query", "string", ".", "If", "is", "given", "as", "a", "parameter", "value", "/", "path", "/", "to"...
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Uri.php#L313-L326
oat-sa/tao-core
helpers/class.Uri.php
tao_helpers_Uri.getDomain
public static function getDomain($uri) { $returnValue = parse_url($uri, PHP_URL_HOST); if (empty($returnValue)) { return null; } return $returnValue; }
php
public static function getDomain($uri) { $returnValue = parse_url($uri, PHP_URL_HOST); if (empty($returnValue)) { return null; } return $returnValue; }
[ "public", "static", "function", "getDomain", "(", "$", "uri", ")", "{", "$", "returnValue", "=", "parse_url", "(", "$", "uri", ",", "PHP_URL_HOST", ")", ";", "if", "(", "empty", "(", "$", "returnValue", ")", ")", "{", "return", "null", ";", "}", "ret...
Returns the domain extracted from a given URI. If the domain cannot be null is returned. @access public @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> @param string uri A Uniform Resource Identifier (URI). @return string|null
[ "Returns", "the", "domain", "extracted", "from", "a", "given", "URI", ".", "If", "the", "domain", "cannot", "be", "null", "is", "returned", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Uri.php#L337-L345
oat-sa/tao-core
helpers/class.Uri.php
tao_helpers_Uri.isValidAsCookieDomain
public static function isValidAsCookieDomain($uri) { $domain = self::getDomain($uri); if (!empty($domain)) { if (preg_match("/^[a-z0-9\-]+(?:[a-z0-9\-]\.)+/iu", $domain) > 0) { $returnValue = true; } else { $returnValue = false; } } else { $returnValue = false; } return $returnValue; }
php
public static function isValidAsCookieDomain($uri) { $domain = self::getDomain($uri); if (!empty($domain)) { if (preg_match("/^[a-z0-9\-]+(?:[a-z0-9\-]\.)+/iu", $domain) > 0) { $returnValue = true; } else { $returnValue = false; } } else { $returnValue = false; } return $returnValue; }
[ "public", "static", "function", "isValidAsCookieDomain", "(", "$", "uri", ")", "{", "$", "domain", "=", "self", "::", "getDomain", "(", "$", "uri", ")", ";", "if", "(", "!", "empty", "(", "$", "domain", ")", ")", "{", "if", "(", "preg_match", "(", ...
To be used to know if a given URI is valid as a cookie domain. Usually, domain such as 'mytaoplatform', 'localhost' make issues with @access public @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> @param string uri @return boolean
[ "To", "be", "used", "to", "know", "if", "a", "given", "URI", "is", "valid", "as", "a", "cookie", "domain", ".", "Usually", "domain", "such", "as", "mytaoplatform", "localhost", "make", "issues", "with" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Uri.php#L356-L370
oat-sa/tao-core
helpers/translation/class.POFile.php
tao_helpers_translation_POFile.getByFlag
public function getByFlag($flag) { $returnValue = array(); foreach ($this->getTranslationUnits() as $tu){ if ($tu->hasFlag($flag)){ $returnValue[] = $tu; } } return (array) $returnValue; }
php
public function getByFlag($flag) { $returnValue = array(); foreach ($this->getTranslationUnits() as $tu){ if ($tu->hasFlag($flag)){ $returnValue[] = $tu; } } return (array) $returnValue; }
[ "public", "function", "getByFlag", "(", "$", "flag", ")", "{", "$", "returnValue", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getTranslationUnits", "(", ")", "as", "$", "tu", ")", "{", "if", "(", "$", "tu", "->", "hasFlag", "(...
Get a collection of POTranslationUnits based on the $flag argument If no Translation Units are found, an empty array is returned. @access public @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> @param string flag A PO compliant string flag. @return array
[ "Get", "a", "collection", "of", "POTranslationUnits", "based", "on", "the", "$flag", "argument", "If", "no", "Translation", "Units", "are", "found", "an", "empty", "array", "is", "returned", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/translation/class.POFile.php#L106-L119
oat-sa/tao-core
helpers/translation/class.POFile.php
tao_helpers_translation_POFile.getByFlags
public function getByFlags($flags) { $returnValue = array(); foreach ($this->getTranslationUnits() as $tu){ $matching = true; foreach ($flags as $f){ if (!$tu->hasFlag($f)){ $matching = false; break; } } if ($matching == true){ $returnValue[] = $tu; } else{ // Prepare next iteration. $matching = true; } } return (array) $returnValue; }
php
public function getByFlags($flags) { $returnValue = array(); foreach ($this->getTranslationUnits() as $tu){ $matching = true; foreach ($flags as $f){ if (!$tu->hasFlag($f)){ $matching = false; break; } } if ($matching == true){ $returnValue[] = $tu; } else{ // Prepare next iteration. $matching = true; } } return (array) $returnValue; }
[ "public", "function", "getByFlags", "(", "$", "flags", ")", "{", "$", "returnValue", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getTranslationUnits", "(", ")", "as", "$", "tu", ")", "{", "$", "matching", "=", "true", ";", "forea...
Get a collection of POTranslationUnits that have all the flags referenced the $flags array. If no TranslationUnits are found, an empty array is @access public @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> @param array flags An array of PO compliant string flags. @return array
[ "Get", "a", "collection", "of", "POTranslationUnits", "that", "have", "all", "the", "flags", "referenced", "the", "$flags", "array", ".", "If", "no", "TranslationUnits", "are", "found", "an", "empty", "array", "is" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/translation/class.POFile.php#L130-L155
oat-sa/tao-core
scripts/class.TaoInstall.php
tao_scripts_TaoInstall.preRun
public function preRun() { $root_path = realpath(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..').DIRECTORY_SEPARATOR; $this->options = array ( 'db_driver' => 'mysql', 'db_host' => 'localhost', 'db_name' => null, 'db_pass' => '', 'db_user' => 'tao', 'install_sent' => '1', 'module_host' => 'tao.local', 'module_lang' => 'en-US', 'module_mode' => 'debug', 'module_name' => 'mytao', 'module_namespace' => '', 'module_url' => '', 'submit' => 'Install', 'user_email' => '', 'user_firstname' => '', 'user_lastname' => '', 'user_login' => '', 'user_pass' => '', 'import_local' => true, 'instance_name' => null, 'extensions' => null, 'timezone' => date_default_timezone_get(), 'file_path' => $root_path . 'data' . DIRECTORY_SEPARATOR, 'operated_by_name' => null, 'operated_by_email' => null, 'extra_persistences' => [] ); $this->options = array_merge($this->options, $this->parameters); // Feature #1789: default db_name is module_name if not specified. $this->options['db_name'] = (empty($this->options['db_name']) ? $this->options['module_name'] : $this->options['db_name']); // If no instance_name given, it takes the value of module_name. $this->options['instance_name'] = (empty($this->options['instance_name']) ? $this->options['module_name'] : $this->options['instance_name']); // user password treatment $this->options["user_pass1"] = $this->options['user_pass']; // module namespace generation if (empty ($this->options["module_namespace"])){ $this->options['module_namespace'] = 'http://'.$this->options['module_host'].'/'.$this->options['module_name'].'.rdf'; } if (empty ($this->options['module_url'])){ $this->options['module_url'] = 'http://' . $this->options['module_host']; } $this->logDebug('Install was started with the given parameters: ' . PHP_EOL . var_export($this->options, true)); }
php
public function preRun() { $root_path = realpath(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..').DIRECTORY_SEPARATOR; $this->options = array ( 'db_driver' => 'mysql', 'db_host' => 'localhost', 'db_name' => null, 'db_pass' => '', 'db_user' => 'tao', 'install_sent' => '1', 'module_host' => 'tao.local', 'module_lang' => 'en-US', 'module_mode' => 'debug', 'module_name' => 'mytao', 'module_namespace' => '', 'module_url' => '', 'submit' => 'Install', 'user_email' => '', 'user_firstname' => '', 'user_lastname' => '', 'user_login' => '', 'user_pass' => '', 'import_local' => true, 'instance_name' => null, 'extensions' => null, 'timezone' => date_default_timezone_get(), 'file_path' => $root_path . 'data' . DIRECTORY_SEPARATOR, 'operated_by_name' => null, 'operated_by_email' => null, 'extra_persistences' => [] ); $this->options = array_merge($this->options, $this->parameters); // Feature #1789: default db_name is module_name if not specified. $this->options['db_name'] = (empty($this->options['db_name']) ? $this->options['module_name'] : $this->options['db_name']); // If no instance_name given, it takes the value of module_name. $this->options['instance_name'] = (empty($this->options['instance_name']) ? $this->options['module_name'] : $this->options['instance_name']); // user password treatment $this->options["user_pass1"] = $this->options['user_pass']; // module namespace generation if (empty ($this->options["module_namespace"])){ $this->options['module_namespace'] = 'http://'.$this->options['module_host'].'/'.$this->options['module_name'].'.rdf'; } if (empty ($this->options['module_url'])){ $this->options['module_url'] = 'http://' . $this->options['module_host']; } $this->logDebug('Install was started with the given parameters: ' . PHP_EOL . var_export($this->options, true)); }
[ "public", "function", "preRun", "(", ")", "{", "$", "root_path", "=", "realpath", "(", "dirname", "(", "__FILE__", ")", ".", "DIRECTORY_SEPARATOR", ".", "'..'", ".", "DIRECTORY_SEPARATOR", ".", "'..'", ")", ".", "DIRECTORY_SEPARATOR", ";", "$", "this", "->",...
Short description of method preRun @access public @author firstname and lastname of author, <author@example.org> @return mixed
[ "Short", "description", "of", "method", "preRun" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoInstall.php#L50-L103
oat-sa/tao-core
scripts/class.TaoInstall.php
tao_scripts_TaoInstall.run
public function run() { $this->logNotice("TAO is being installed. Please wait..."); try{ $rootDir = dir(dirname(__FILE__) . '/../../'); $root = isset($this->parameters["root_path"]) ? $this->parameters["root_path"] : realpath($rootDir->path) . DIRECTORY_SEPARATOR; // Setting the installator dependencies. $this->getContainer()->offsetSet(tao_install_Installator::CONTAINER_INDEX, array( 'root_path' => $root, 'install_path' => $root.'tao/install/' ) ); $options = array_merge($this->options, $this->argv); $installator = new tao_install_Installator($this->getContainer()); // mod rewrite cannot be detected in CLI Mode. $installator->escapeCheck('custom_tao_ModRewrite'); $installator->install($options); } catch (Exception $e){ $this->logError("A fatal error has occurred during installation: " . $e->getMessage()); $this->handleError($e); } }
php
public function run() { $this->logNotice("TAO is being installed. Please wait..."); try{ $rootDir = dir(dirname(__FILE__) . '/../../'); $root = isset($this->parameters["root_path"]) ? $this->parameters["root_path"] : realpath($rootDir->path) . DIRECTORY_SEPARATOR; // Setting the installator dependencies. $this->getContainer()->offsetSet(tao_install_Installator::CONTAINER_INDEX, array( 'root_path' => $root, 'install_path' => $root.'tao/install/' ) ); $options = array_merge($this->options, $this->argv); $installator = new tao_install_Installator($this->getContainer()); // mod rewrite cannot be detected in CLI Mode. $installator->escapeCheck('custom_tao_ModRewrite'); $installator->install($options); } catch (Exception $e){ $this->logError("A fatal error has occurred during installation: " . $e->getMessage()); $this->handleError($e); } }
[ "public", "function", "run", "(", ")", "{", "$", "this", "->", "logNotice", "(", "\"TAO is being installed. Please wait...\"", ")", ";", "try", "{", "$", "rootDir", "=", "dir", "(", "dirname", "(", "__FILE__", ")", ".", "'/../../'", ")", ";", "$", "root", ...
Short description of method run @access public @author firstname and lastname of author, <author@example.org> @return mixed
[ "Short", "description", "of", "method", "run" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoInstall.php#L112-L140
oat-sa/tao-core
models/classes/import/class.CsvImporter.php
tao_models_classes_import_CsvImporter.getForm
public function getForm() { $form = empty($_POST['source']) && empty($_POST['importFile']) ? new tao_models_classes_import_CsvUploadForm() : $this->createImportFormContainer(); return $form->getForm(); }
php
public function getForm() { $form = empty($_POST['source']) && empty($_POST['importFile']) ? new tao_models_classes_import_CsvUploadForm() : $this->createImportFormContainer(); return $form->getForm(); }
[ "public", "function", "getForm", "(", ")", "{", "$", "form", "=", "empty", "(", "$", "_POST", "[", "'source'", "]", ")", "&&", "empty", "(", "$", "_POST", "[", "'importFile'", "]", ")", "?", "new", "tao_models_classes_import_CsvUploadForm", "(", ")", ":"...
(non-PHPdoc) @see tao_models_classes_import_ImportHandler::getForm()
[ "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/import/class.CsvImporter.php#L58-L64
oat-sa/tao-core
models/classes/import/class.CsvImporter.php
tao_models_classes_import_CsvImporter.createImportFormContainer
private function createImportFormContainer() { $sourceContainer = new tao_models_classes_import_CsvUploadForm(); $sourceForm = $sourceContainer->getForm(); /** @var tao_helpers_form_FormElement $element */ foreach ($sourceForm->getElements() as $element) { $element->feed(); } $sourceForm->getElement('source')->feed(); $fileInfo = $sourceForm->getValue('source'); if (isset($_POST['importFile'])) { $serial = $_POST['importFile']; } else { $serial = $fileInfo['uploaded_file']; } if (!is_string($serial)) { throw new InvalidArgumentException('Import file has to be a valid file serial.'); } /** @var UploadService $uploadService */ $uploadService = $this->getServiceManager()->get(UploadService::SERVICE_ID); $file = $uploadService->getUploadedFlyFile($serial); $properties = array(tao_helpers_Uri::encode(OntologyRdfs::RDFS_LABEL) => __('Label')); $rangedProperties = array(); $classUri = \tao_helpers_Uri::decode($_POST['classUri']); $class = new core_kernel_classes_Class($classUri); $classProperties = $this->getClassProperties($class); foreach($classProperties as $property){ if(!in_array($property->getUri(), $this->getExludedProperties())){ //@todo manage the properties with range $range = $property->getRange(); $properties[tao_helpers_Uri::encode($property->getUri())] = $property->getLabel(); if($range instanceof core_kernel_classes_Resource && $range->getUri() != OntologyRdfs::RDFS_LITERAL){ $rangedProperties[tao_helpers_Uri::encode($property->getUri())] = $property->getLabel(); } } } //load the csv data from the file (uploaded in the upload form) to get the columns $csv_data = new tao_helpers_data_CsvFile($sourceForm->getValues()); $csv_data->load($file); $values = $sourceForm->getValues(); $values[tao_helpers_data_CsvFile::FIRST_ROW_COLUMN_NAMES] = !empty($values[tao_helpers_data_CsvFile::FIRST_ROW_COLUMN_NAMES]); $values['importFile'] = $serial; $myFormContainer = new tao_models_classes_import_CSVMappingForm($values, array( 'class_properties' => $properties, 'ranged_properties' => $rangedProperties, 'csv_column' => $this->getColumnMapping($csv_data, $sourceForm->getValue(tao_helpers_data_CsvFile::FIRST_ROW_COLUMN_NAMES)), tao_helpers_data_CsvFile::FIRST_ROW_COLUMN_NAMES => $sourceForm->getValue(tao_helpers_data_CsvFile::FIRST_ROW_COLUMN_NAMES), )); return $myFormContainer; }
php
private function createImportFormContainer() { $sourceContainer = new tao_models_classes_import_CsvUploadForm(); $sourceForm = $sourceContainer->getForm(); /** @var tao_helpers_form_FormElement $element */ foreach ($sourceForm->getElements() as $element) { $element->feed(); } $sourceForm->getElement('source')->feed(); $fileInfo = $sourceForm->getValue('source'); if (isset($_POST['importFile'])) { $serial = $_POST['importFile']; } else { $serial = $fileInfo['uploaded_file']; } if (!is_string($serial)) { throw new InvalidArgumentException('Import file has to be a valid file serial.'); } /** @var UploadService $uploadService */ $uploadService = $this->getServiceManager()->get(UploadService::SERVICE_ID); $file = $uploadService->getUploadedFlyFile($serial); $properties = array(tao_helpers_Uri::encode(OntologyRdfs::RDFS_LABEL) => __('Label')); $rangedProperties = array(); $classUri = \tao_helpers_Uri::decode($_POST['classUri']); $class = new core_kernel_classes_Class($classUri); $classProperties = $this->getClassProperties($class); foreach($classProperties as $property){ if(!in_array($property->getUri(), $this->getExludedProperties())){ //@todo manage the properties with range $range = $property->getRange(); $properties[tao_helpers_Uri::encode($property->getUri())] = $property->getLabel(); if($range instanceof core_kernel_classes_Resource && $range->getUri() != OntologyRdfs::RDFS_LITERAL){ $rangedProperties[tao_helpers_Uri::encode($property->getUri())] = $property->getLabel(); } } } //load the csv data from the file (uploaded in the upload form) to get the columns $csv_data = new tao_helpers_data_CsvFile($sourceForm->getValues()); $csv_data->load($file); $values = $sourceForm->getValues(); $values[tao_helpers_data_CsvFile::FIRST_ROW_COLUMN_NAMES] = !empty($values[tao_helpers_data_CsvFile::FIRST_ROW_COLUMN_NAMES]); $values['importFile'] = $serial; $myFormContainer = new tao_models_classes_import_CSVMappingForm($values, array( 'class_properties' => $properties, 'ranged_properties' => $rangedProperties, 'csv_column' => $this->getColumnMapping($csv_data, $sourceForm->getValue(tao_helpers_data_CsvFile::FIRST_ROW_COLUMN_NAMES)), tao_helpers_data_CsvFile::FIRST_ROW_COLUMN_NAMES => $sourceForm->getValue(tao_helpers_data_CsvFile::FIRST_ROW_COLUMN_NAMES), )); return $myFormContainer; }
[ "private", "function", "createImportFormContainer", "(", ")", "{", "$", "sourceContainer", "=", "new", "tao_models_classes_import_CsvUploadForm", "(", ")", ";", "$", "sourceForm", "=", "$", "sourceContainer", "->", "getForm", "(", ")", ";", "/** @var tao_helpers_form_...
Constructs the Import form container In need of a major refactoring, which will probably involve refactoring the Form engine as well @return tao_models_classes_import_CSVMappingForm @throws \oat\generis\model\fileReference\FileSerializerException @throws common_exception_NotAcceptable
[ "Constructs", "the", "Import", "form", "container", "In", "need", "of", "a", "major", "refactoring", "which", "will", "probably", "involve", "refactoring", "the", "Form", "engine", "as", "well" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/import/class.CsvImporter.php#L75-L135
oat-sa/tao-core
models/classes/import/class.CsvImporter.php
tao_models_classes_import_CsvImporter.import
public function import($class, $form, $userId = null) { // for backward compatibility $options = $form instanceof \tao_helpers_form_Form ? $form->getValues() : $form; $options['file'] = $this->fetchUploadedFile($form); // Clean "csv_select" values from form view. // Transform any "csv_select" in "csv_null" in order to // have the same importation behaviour for both because // semantics are the same. // for backward compatibility $map = $form instanceof \tao_helpers_form_Form ? $form->getValues('property_mapping') : $form['property_mapping']; $newMap = array(); foreach ($map as $k => $m) { if ($m !== 'csv_select') { $newMap[$k] = $map[$k]; } else { $newMap[$k] = 'csv_null'; } $newMap[$k] = str_replace(self::OPTION_POSTFIX, '', $newMap[$k]); common_Logger::d('map: ' . $k . ' => ' . $newMap[$k]); } $options['map'] = $newMap; $staticMap = array(); // for backward compatibility $rangedProperties = $form instanceof \tao_helpers_form_Form ? $form->getValues('ranged_property') : $form['ranged_property']; foreach ($rangedProperties as $propUri => $value) { if (strpos($propUri, tao_models_classes_import_CSVMappingForm::DEFAULT_VALUES_SUFFIX) !== false) { $cleanUri = str_replace(tao_models_classes_import_CSVMappingForm::DEFAULT_VALUES_SUFFIX, '', $propUri); $staticMap[$cleanUri] = $value; } } $options['staticMap'] = array_merge($staticMap, $this->getStaticData()); $report = parent::importFile($class, $options, $userId); if ($report->getType() == common_report_Report::TYPE_SUCCESS) { $this->getEventManager()->trigger(new CsvImportEvent($report)); } return $report; }
php
public function import($class, $form, $userId = null) { // for backward compatibility $options = $form instanceof \tao_helpers_form_Form ? $form->getValues() : $form; $options['file'] = $this->fetchUploadedFile($form); // Clean "csv_select" values from form view. // Transform any "csv_select" in "csv_null" in order to // have the same importation behaviour for both because // semantics are the same. // for backward compatibility $map = $form instanceof \tao_helpers_form_Form ? $form->getValues('property_mapping') : $form['property_mapping']; $newMap = array(); foreach ($map as $k => $m) { if ($m !== 'csv_select') { $newMap[$k] = $map[$k]; } else { $newMap[$k] = 'csv_null'; } $newMap[$k] = str_replace(self::OPTION_POSTFIX, '', $newMap[$k]); common_Logger::d('map: ' . $k . ' => ' . $newMap[$k]); } $options['map'] = $newMap; $staticMap = array(); // for backward compatibility $rangedProperties = $form instanceof \tao_helpers_form_Form ? $form->getValues('ranged_property') : $form['ranged_property']; foreach ($rangedProperties as $propUri => $value) { if (strpos($propUri, tao_models_classes_import_CSVMappingForm::DEFAULT_VALUES_SUFFIX) !== false) { $cleanUri = str_replace(tao_models_classes_import_CSVMappingForm::DEFAULT_VALUES_SUFFIX, '', $propUri); $staticMap[$cleanUri] = $value; } } $options['staticMap'] = array_merge($staticMap, $this->getStaticData()); $report = parent::importFile($class, $options, $userId); if ($report->getType() == common_report_Report::TYPE_SUCCESS) { $this->getEventManager()->trigger(new CsvImportEvent($report)); } return $report; }
[ "public", "function", "import", "(", "$", "class", ",", "$", "form", ",", "$", "userId", "=", "null", ")", "{", "// for backward compatibility", "$", "options", "=", "$", "form", "instanceof", "\\", "tao_helpers_form_Form", "?", "$", "form", "->", "getValues...
(non-PHPdoc) @see tao_models_classes_import_ImportHandler::import() @param core_kernel_classes_Class $class @param tao_helpers_form_Form|array $form @param string|null $userId owner of the resource @return common_report_Report @throws \oat\oatbox\service\ServiceNotFoundException @throws \common_Exception
[ "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/import/class.CsvImporter.php#L147-L194
oat-sa/tao-core
models/classes/import/class.CsvImporter.php
tao_models_classes_import_CsvImporter.getTaskParameters
public function getTaskParameters(tao_helpers_form_Form $form) { return array_merge( $form->getValues(), [ 'property_mapping' => $form->getValues('property_mapping'), 'ranged_property' => $form->getValues('ranged_property') ], $this->getDefaultTaskParameters($form) ); }
php
public function getTaskParameters(tao_helpers_form_Form $form) { return array_merge( $form->getValues(), [ 'property_mapping' => $form->getValues('property_mapping'), 'ranged_property' => $form->getValues('ranged_property') ], $this->getDefaultTaskParameters($form) ); }
[ "public", "function", "getTaskParameters", "(", "tao_helpers_form_Form", "$", "form", ")", "{", "return", "array_merge", "(", "$", "form", "->", "getValues", "(", ")", ",", "[", "'property_mapping'", "=>", "$", "form", "->", "getValues", "(", "'property_mapping'...
Defines the task parameters to be stored for later use. @param tao_helpers_form_Form $form @return array
[ "Defines", "the", "task", "parameters", "to", "be", "stored", "for", "later", "use", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/import/class.CsvImporter.php#L202-L212
oat-sa/tao-core
actions/class.Breadcrumbs.php
tao_actions_Breadcrumbs.parseRoute
protected function parseRoute($route) { $parsedRoute = parse_url($route); if (isset($parsedRoute['query'])) { parse_str($parsedRoute['query'], $parsedRoute['params']); } else { $parsedRoute['params'] = []; } $resolvedRoute = new Resolver(new \common_http_Request($route)); $this->propagate($resolvedRoute); $parsedRoute['extension'] = $resolvedRoute->getExtensionId(); $parsedRoute['controller'] = $resolvedRoute->getControllerShortName(); $parsedRoute['controller_class'] = $resolvedRoute->getControllerClass(); $parsedRoute['action'] = $resolvedRoute->getMethodName(); return $parsedRoute; }
php
protected function parseRoute($route) { $parsedRoute = parse_url($route); if (isset($parsedRoute['query'])) { parse_str($parsedRoute['query'], $parsedRoute['params']); } else { $parsedRoute['params'] = []; } $resolvedRoute = new Resolver(new \common_http_Request($route)); $this->propagate($resolvedRoute); $parsedRoute['extension'] = $resolvedRoute->getExtensionId(); $parsedRoute['controller'] = $resolvedRoute->getControllerShortName(); $parsedRoute['controller_class'] = $resolvedRoute->getControllerClass(); $parsedRoute['action'] = $resolvedRoute->getMethodName(); return $parsedRoute; }
[ "protected", "function", "parseRoute", "(", "$", "route", ")", "{", "$", "parsedRoute", "=", "parse_url", "(", "$", "route", ")", ";", "if", "(", "isset", "(", "$", "parsedRoute", "[", "'query'", "]", ")", ")", "{", "parse_str", "(", "$", "parsedRoute"...
Parses the provided context route @param string $route @return array
[ "Parses", "the", "provided", "context", "route" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.Breadcrumbs.php#L47-L65
oat-sa/tao-core
actions/class.Breadcrumbs.php
tao_actions_Breadcrumbs.getRoutes
protected function getRoutes() { $route = $this->getRequestParameter('route'); if (empty($route)) { throw new \common_exception_MissingParameter('You must specify a route'); } if (!is_array($route)) { $route = [$route]; } return $route; }
php
protected function getRoutes() { $route = $this->getRequestParameter('route'); if (empty($route)) { throw new \common_exception_MissingParameter('You must specify a route'); } if (!is_array($route)) { $route = [$route]; } return $route; }
[ "protected", "function", "getRoutes", "(", ")", "{", "$", "route", "=", "$", "this", "->", "getRequestParameter", "(", "'route'", ")", ";", "if", "(", "empty", "(", "$", "route", ")", ")", "{", "throw", "new", "\\", "common_exception_MissingParameter", "("...
Gets the provided context route @return array|mixed|null|string @throws common_exception_MissingParameter
[ "Gets", "the", "provided", "context", "route" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.Breadcrumbs.php#L72-L84
oat-sa/tao-core
actions/class.Breadcrumbs.php
tao_actions_Breadcrumbs.returnData
protected function returnData($data) { if (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false) { $this->returnJson([ 'success' => true, 'data' => $data, ]); } else { $this->setData('breadcrumbs', $data); $this->setView('blocks/breadcrumbs.tpl', 'tao'); } }
php
protected function returnData($data) { if (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false) { $this->returnJson([ 'success' => true, 'data' => $data, ]); } else { $this->setData('breadcrumbs', $data); $this->setView('blocks/breadcrumbs.tpl', 'tao'); } }
[ "protected", "function", "returnData", "(", "$", "data", ")", "{", "if", "(", "isset", "(", "$", "_SERVER", "[", "'HTTP_ACCEPT'", "]", ")", "&&", "strpos", "(", "$", "_SERVER", "[", "'HTTP_ACCEPT'", "]", ",", "'application/json'", ")", "!==", "false", ")...
Sends the data to the client using the preferred format @param $data
[ "Sends", "the", "data", "to", "the", "client", "using", "the", "preferred", "format" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.Breadcrumbs.php#L90-L101
oat-sa/tao-core
actions/class.Breadcrumbs.php
tao_actions_Breadcrumbs.requestService
protected function requestService($route, $parsedRoute) { $serviceName = null; if ($parsedRoute['extension'] && $parsedRoute['controller'] && $parsedRoute['action']) { $serviceName = $parsedRoute['extension'] . '/' . $parsedRoute['controller'] . '/breadcrumbs'; } if ($serviceName && $this->getServiceLocator()->has($serviceName)) { $service = $this->getServiceLocator()->get($serviceName); } else { $service = $this; } if ($service instanceof Breadcrumbs) { return $service->breadcrumbs($route, $parsedRoute); } else { throw new common_exception_NoImplementation('Class ' . get_class($service) . ' does not implement the Breadcrumbs interface!'); } }
php
protected function requestService($route, $parsedRoute) { $serviceName = null; if ($parsedRoute['extension'] && $parsedRoute['controller'] && $parsedRoute['action']) { $serviceName = $parsedRoute['extension'] . '/' . $parsedRoute['controller'] . '/breadcrumbs'; } if ($serviceName && $this->getServiceLocator()->has($serviceName)) { $service = $this->getServiceLocator()->get($serviceName); } else { $service = $this; } if ($service instanceof Breadcrumbs) { return $service->breadcrumbs($route, $parsedRoute); } else { throw new common_exception_NoImplementation('Class ' . get_class($service) . ' does not implement the Breadcrumbs interface!'); } }
[ "protected", "function", "requestService", "(", "$", "route", ",", "$", "parsedRoute", ")", "{", "$", "serviceName", "=", "null", ";", "if", "(", "$", "parsedRoute", "[", "'extension'", "]", "&&", "$", "parsedRoute", "[", "'controller'", "]", "&&", "$", ...
Calls a service to get the breadcrumbs for a particular route. To provide a breadcrumbs service you must register a class that implements `oat\tao\model\mvc\Breadcrumbs`, and use a service identifier with respect to this format: `<extension>/<controller>/breadcrumbs`. Hence this service will be invoked each time a breadcrumbs request is made against an action under `<extension>/<controller>`. You can also override the Breadcrumbs controller and provide your own `breadcrumbs()` method, in order to provide default values. By default there is no default breadcrumbs. @param string $route @param array $parsedRoute @return array @throws common_exception_NoImplementation
[ "Calls", "a", "service", "to", "get", "the", "breadcrumbs", "for", "a", "particular", "route", ".", "To", "provide", "a", "breadcrumbs", "service", "you", "must", "register", "a", "class", "that", "implements", "oat", "\\", "tao", "\\", "model", "\\", "mvc...
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.Breadcrumbs.php#L115-L133
oat-sa/tao-core
actions/class.Breadcrumbs.php
tao_actions_Breadcrumbs.load
public function load() { $data = []; $routes = $this->getRoutes(); foreach($routes as $route) { $parsedRoute = $this->parseRoute($route); $routeData = $this->requestService($route, $parsedRoute); if ($routeData !== null) { // When the routeData contains more entry. (if it's a numeric array) if (array_values($routeData) === $routeData) { $data = array_merge($data, $routeData); } else { $data[] = $routeData; } } } $this->returnData($data); }
php
public function load() { $data = []; $routes = $this->getRoutes(); foreach($routes as $route) { $parsedRoute = $this->parseRoute($route); $routeData = $this->requestService($route, $parsedRoute); if ($routeData !== null) { // When the routeData contains more entry. (if it's a numeric array) if (array_values($routeData) === $routeData) { $data = array_merge($data, $routeData); } else { $data[] = $routeData; } } } $this->returnData($data); }
[ "public", "function", "load", "(", ")", "{", "$", "data", "=", "[", "]", ";", "$", "routes", "=", "$", "this", "->", "getRoutes", "(", ")", ";", "foreach", "(", "$", "routes", "as", "$", "route", ")", "{", "$", "parsedRoute", "=", "$", "this", ...
Loads all the breadcrumbs for a particular context route
[ "Loads", "all", "the", "breadcrumbs", "for", "a", "particular", "context", "route" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.Breadcrumbs.php#L154-L173
oat-sa/tao-core
helpers/form/elements/xhtml/class.Submit.php
tao_helpers_form_elements_xhtml_Submit.render
public function render() { $returnValue = (string) ''; if (is_null($this->value) || empty($this->value)) { $this->value = __('Save'); } $returnValue = "<input type='submit' id='{$this->name}' name='{$this->name}' "; $returnValue .= $this->renderAttributes(); $returnValue .= ' value="' . _dh($this->value) . '" />'; return (string) $returnValue; }
php
public function render() { $returnValue = (string) ''; if (is_null($this->value) || empty($this->value)) { $this->value = __('Save'); } $returnValue = "<input type='submit' id='{$this->name}' name='{$this->name}' "; $returnValue .= $this->renderAttributes(); $returnValue .= ' value="' . _dh($this->value) . '" />'; return (string) $returnValue; }
[ "public", "function", "render", "(", ")", "{", "$", "returnValue", "=", "(", "string", ")", "''", ";", "if", "(", "is_null", "(", "$", "this", "->", "value", ")", "||", "empty", "(", "$", "this", "->", "value", ")", ")", "{", "$", "this", "->", ...
Short description of method render @access public @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> @return string
[ "Short", "description", "of", "method", "render" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/elements/xhtml/class.Submit.php#L41-L53
oat-sa/tao-core
helpers/grid/class.Grid.php
tao_helpers_grid_Grid.addColumn
public function addColumn($id, $title, $options = array()) { $returnValue = null; $replace = false; if(isset($options['replace'])){ $replace = $options['replace']; unset($options['replace']); } if(!$replace && isset($this->columns[$id])){ throw new common_Exception('the column with the id '.$id.' already exists'); }else{ $this->columns[$id] = new tao_helpers_grid_Column($id, $title, $options); //set order as well: $returnValue = true; } return $returnValue; }
php
public function addColumn($id, $title, $options = array()) { $returnValue = null; $replace = false; if(isset($options['replace'])){ $replace = $options['replace']; unset($options['replace']); } if(!$replace && isset($this->columns[$id])){ throw new common_Exception('the column with the id '.$id.' already exists'); }else{ $this->columns[$id] = new tao_helpers_grid_Column($id, $title, $options); //set order as well: $returnValue = true; } return $returnValue; }
[ "public", "function", "addColumn", "(", "$", "id", ",", "$", "title", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "returnValue", "=", "null", ";", "$", "replace", "=", "false", ";", "if", "(", "isset", "(", "$", "options", "[", "'...
Short description of method addColumn @access public @author Cédric Alfonsi, <cedric.alfonsi@tudor.lu> @param string id @param string title @param array options @return tao_helpers_grid_Column
[ "Short", "description", "of", "method", "addColumn" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/grid/class.Grid.php#L114-L134
oat-sa/tao-core
helpers/grid/class.Grid.php
tao_helpers_grid_Grid.removeColumn
public function removeColumn($id) { $returnValue = (bool) false; unset($this->columns[$id]); $returnValue = true; return (bool) $returnValue; }
php
public function removeColumn($id) { $returnValue = (bool) false; unset($this->columns[$id]); $returnValue = true; return (bool) $returnValue; }
[ "public", "function", "removeColumn", "(", "$", "id", ")", "{", "$", "returnValue", "=", "(", "bool", ")", "false", ";", "unset", "(", "$", "this", "->", "columns", "[", "$", "id", "]", ")", ";", "$", "returnValue", "=", "true", ";", "return", "(",...
Short description of method removeColumn @access public @author Cédric Alfonsi, <cedric.alfonsi@tudor.lu> @param string id @return boolean
[ "Short", "description", "of", "method", "removeColumn" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/grid/class.Grid.php#L144-L154
oat-sa/tao-core
helpers/grid/class.Grid.php
tao_helpers_grid_Grid.addRow
public function addRow($id, $cells = array(), $replace = false) { $returnValue = (bool) false; if(!$replace && isset($this->rows[$id])){ throw new common_Exception('the row with the id '.$id.' already exists'); }else{ $this->rows[$id] = $cells; //@TODO: implement a sort funciton? $returnValue = true; } return (bool) $returnValue; }
php
public function addRow($id, $cells = array(), $replace = false) { $returnValue = (bool) false; if(!$replace && isset($this->rows[$id])){ throw new common_Exception('the row with the id '.$id.' already exists'); }else{ $this->rows[$id] = $cells; //@TODO: implement a sort funciton? $returnValue = true; } return (bool) $returnValue; }
[ "public", "function", "addRow", "(", "$", "id", ",", "$", "cells", "=", "array", "(", ")", ",", "$", "replace", "=", "false", ")", "{", "$", "returnValue", "=", "(", "bool", ")", "false", ";", "if", "(", "!", "$", "replace", "&&", "isset", "(", ...
Short description of method addRow @access public @author Cédric Alfonsi, <cedric.alfonsi@tudor.lu> @param string id @param array cells @param boolean replace @return boolean
[ "Short", "description", "of", "method", "addRow" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/grid/class.Grid.php#L166-L182
oat-sa/tao-core
helpers/grid/class.Grid.php
tao_helpers_grid_Grid.removeRow
public function removeRow($id) { $returnValue = (bool) false; unset($this->rows[$id]); $returnValue = true; return (bool) $returnValue; }
php
public function removeRow($id) { $returnValue = (bool) false; unset($this->rows[$id]); $returnValue = true; return (bool) $returnValue; }
[ "public", "function", "removeRow", "(", "$", "id", ")", "{", "$", "returnValue", "=", "(", "bool", ")", "false", ";", "unset", "(", "$", "this", "->", "rows", "[", "$", "id", "]", ")", ";", "$", "returnValue", "=", "true", ";", "return", "(", "bo...
Short description of method removeRow @access public @author Cédric Alfonsi, <cedric.alfonsi@tudor.lu> @param string id @return boolean
[ "Short", "description", "of", "method", "removeRow" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/grid/class.Grid.php#L192-L202
oat-sa/tao-core
helpers/grid/class.Grid.php
tao_helpers_grid_Grid.setCellValue
public function setCellValue($columnId, $rowId, $content, $forceCreation = false) { $returnValue = (bool) false; //TODO: for creating row and column if not exists? if(isset($this->columns[$columnId])){ if(isset($this->rows[$rowId])){ $this->rows[$rowId][$columnId] = $content; $returnValue = true; } } return (bool) $returnValue; }
php
public function setCellValue($columnId, $rowId, $content, $forceCreation = false) { $returnValue = (bool) false; //TODO: for creating row and column if not exists? if(isset($this->columns[$columnId])){ if(isset($this->rows[$rowId])){ $this->rows[$rowId][$columnId] = $content; $returnValue = true; } } return (bool) $returnValue; }
[ "public", "function", "setCellValue", "(", "$", "columnId", ",", "$", "rowId", ",", "$", "content", ",", "$", "forceCreation", "=", "false", ")", "{", "$", "returnValue", "=", "(", "bool", ")", "false", ";", "//TODO: for creating row and column if not exists?", ...
Short description of method setCellValue @access public @author Cédric Alfonsi, <cedric.alfonsi@tudor.lu> @param string columnId @param string rowId @param string content string or Grid @param boolean forceCreation @return boolean
[ "Short", "description", "of", "method", "setCellValue" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/grid/class.Grid.php#L215-L230
oat-sa/tao-core
helpers/grid/class.Grid.php
tao_helpers_grid_Grid.setColumnsAdapter
public function setColumnsAdapter($columnIds, tao_helpers_grid_Cell_Adapter $adapter) { $returnValue = (bool) false; if(is_string($columnIds)){ $columnIds = array($columnIds); } if(is_array($columnIds)){ foreach($columnIds as $colId){ if (!isset($this->columns[$colId]) || !$this->columns[$colId] instanceof tao_helpers_grid_Column) { throw new common_Exception('cannot set the column\'s adapter : the column with the id ' . $colId . ' does not exist'); } else { $returnValue = $this->columns[$colId]->setAdapter($adapter); } } } return (bool) $returnValue; }
php
public function setColumnsAdapter($columnIds, tao_helpers_grid_Cell_Adapter $adapter) { $returnValue = (bool) false; if(is_string($columnIds)){ $columnIds = array($columnIds); } if(is_array($columnIds)){ foreach($columnIds as $colId){ if (!isset($this->columns[$colId]) || !$this->columns[$colId] instanceof tao_helpers_grid_Column) { throw new common_Exception('cannot set the column\'s adapter : the column with the id ' . $colId . ' does not exist'); } else { $returnValue = $this->columns[$colId]->setAdapter($adapter); } } } return (bool) $returnValue; }
[ "public", "function", "setColumnsAdapter", "(", "$", "columnIds", ",", "tao_helpers_grid_Cell_Adapter", "$", "adapter", ")", "{", "$", "returnValue", "=", "(", "bool", ")", "false", ";", "if", "(", "is_string", "(", "$", "columnIds", ")", ")", "{", "$", "c...
Short description of method setColumnsAdapter @access public @author Cédric Alfonsi, <cedric.alfonsi@tudor.lu> @param array columnIds @param Adapter adapter @return boolean
[ "Short", "description", "of", "method", "setColumnsAdapter" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/grid/class.Grid.php#L241-L261
oat-sa/tao-core
helpers/grid/class.Grid.php
tao_helpers_grid_Grid.toArray
public function toArray() { $returnValue = array(); //sort columns: $this->sortColumns(); foreach($this->rows as $rowId => $cells){ $returnValue[$rowId] = array(); foreach($this->columns as $columnId => $column){ if($column->hasAdapter()){ //fill content with adapter: $data = null; if(isset($returnValue[$rowId][$columnId])){ $data = $returnValue[$rowId][$columnId]; }else if(isset($cells[$columnId])){ $data = $cells[$columnId]; } $returnValue[$rowId][$columnId] = $column->getAdaptersData($rowId, $data); }else if(isset($cells[$columnId])){ if($cells[$columnId] instanceof tao_helpers_grid_Grid){ $returnValue[$rowId][$columnId] = $cells[$columnId]->toArray(); }else{ $returnValue[$rowId][$columnId] = $cells[$columnId]; } }else{ $returnValue[$rowId][$columnId] = null;//empty cell } } } return (array) $returnValue; }
php
public function toArray() { $returnValue = array(); //sort columns: $this->sortColumns(); foreach($this->rows as $rowId => $cells){ $returnValue[$rowId] = array(); foreach($this->columns as $columnId => $column){ if($column->hasAdapter()){ //fill content with adapter: $data = null; if(isset($returnValue[$rowId][$columnId])){ $data = $returnValue[$rowId][$columnId]; }else if(isset($cells[$columnId])){ $data = $cells[$columnId]; } $returnValue[$rowId][$columnId] = $column->getAdaptersData($rowId, $data); }else if(isset($cells[$columnId])){ if($cells[$columnId] instanceof tao_helpers_grid_Grid){ $returnValue[$rowId][$columnId] = $cells[$columnId]->toArray(); }else{ $returnValue[$rowId][$columnId] = $cells[$columnId]; } }else{ $returnValue[$rowId][$columnId] = null;//empty cell } } } return (array) $returnValue; }
[ "public", "function", "toArray", "(", ")", "{", "$", "returnValue", "=", "array", "(", ")", ";", "//sort columns:", "$", "this", "->", "sortColumns", "(", ")", ";", "foreach", "(", "$", "this", "->", "rows", "as", "$", "rowId", "=>", "$", "cells", ")...
Short description of method toArray @access public @author Cédric Alfonsi, <cedric.alfonsi@tudor.lu> @return array
[ "Short", "description", "of", "method", "toArray" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/grid/class.Grid.php#L270-L311
oat-sa/tao-core
helpers/grid/class.Grid.php
tao_helpers_grid_Grid.getColumn
public function getColumn($id) { $returnValue = null; if(isset($this->columns[$id]) && $this->columns[$id] instanceof tao_helpers_grid_Column){ $returnValue = $this->columns[$id]; } return $returnValue; }
php
public function getColumn($id) { $returnValue = null; if(isset($this->columns[$id]) && $this->columns[$id] instanceof tao_helpers_grid_Column){ $returnValue = $this->columns[$id]; } return $returnValue; }
[ "public", "function", "getColumn", "(", "$", "id", ")", "{", "$", "returnValue", "=", "null", ";", "if", "(", "isset", "(", "$", "this", "->", "columns", "[", "$", "id", "]", ")", "&&", "$", "this", "->", "columns", "[", "$", "id", "]", "instance...
Short description of method getColumn @access public @author Cédric Alfonsi, <cedric.alfonsi@tudor.lu> @param string id @return tao_helpers_grid_Column
[ "Short", "description", "of", "method", "getColumn" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/grid/class.Grid.php#L356-L367
oat-sa/tao-core
helpers/grid/class.Grid.php
tao_helpers_grid_Grid.getColumnsModel
public function getColumnsModel($rebuild = false) { $returnValue = array(); foreach($this->columns as $column){ if($column instanceof tao_helpers_grid_Column){ $returnValue[$column->getId()] = array( 'id' => $column->getId(), 'title' => $column->getTitle(), 'type' => $column->getType() ); foreach($column->getOptions() as $optionsName=>$optionValue){ $returnValue[$column->getId()][$optionsName] = $optionValue; } if($column->hasAdapter('tao_helpers_grid_Cell_SubgridAdapter')){ $subGridAdapter = null; $adapters = $column->getAdapters(); $adaptersLength = count($adapters); for($i=$adaptersLength-1; $i>=0; $i--){ if($adapters[$i] instanceof tao_helpers_grid_Cell_SubgridAdapter){ $subGridAdapter = $adapters[$i]; break; } } $returnValue[$column->getId()]['subgrids'] = $subGridAdapter->getGridContainer()->getGrid()->getColumnsModel(); } } } return (array) $returnValue; }
php
public function getColumnsModel($rebuild = false) { $returnValue = array(); foreach($this->columns as $column){ if($column instanceof tao_helpers_grid_Column){ $returnValue[$column->getId()] = array( 'id' => $column->getId(), 'title' => $column->getTitle(), 'type' => $column->getType() ); foreach($column->getOptions() as $optionsName=>$optionValue){ $returnValue[$column->getId()][$optionsName] = $optionValue; } if($column->hasAdapter('tao_helpers_grid_Cell_SubgridAdapter')){ $subGridAdapter = null; $adapters = $column->getAdapters(); $adaptersLength = count($adapters); for($i=$adaptersLength-1; $i>=0; $i--){ if($adapters[$i] instanceof tao_helpers_grid_Cell_SubgridAdapter){ $subGridAdapter = $adapters[$i]; break; } } $returnValue[$column->getId()]['subgrids'] = $subGridAdapter->getGridContainer()->getGrid()->getColumnsModel(); } } } return (array) $returnValue; }
[ "public", "function", "getColumnsModel", "(", "$", "rebuild", "=", "false", ")", "{", "$", "returnValue", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "columns", "as", "$", "column", ")", "{", "if", "(", "$", "column", "instanceof", ...
Short description of method getColumnsModel @access public @author Cédric Alfonsi, <cedric.alfonsi@tudor.lu> @param boolean rebuild @return array
[ "Short", "description", "of", "method", "getColumnsModel" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/grid/class.Grid.php#L377-L415
oat-sa/tao-core
helpers/grid/class.Grid.php
tao_helpers_grid_Grid.setData
public function setData($data = array()) { //empty local data $this->rows = array(); //fill the local data foreach($data as $rowId => $cells){ if(is_array($cells)){ $this->addRow($rowId, $cells); }else if(is_string($cells)){ $this->addRow($cells); } } }
php
public function setData($data = array()) { //empty local data $this->rows = array(); //fill the local data foreach($data as $rowId => $cells){ if(is_array($cells)){ $this->addRow($rowId, $cells); }else if(is_string($cells)){ $this->addRow($cells); } } }
[ "public", "function", "setData", "(", "$", "data", "=", "array", "(", ")", ")", "{", "//empty local data", "$", "this", "->", "rows", "=", "array", "(", ")", ";", "//fill the local data", "foreach", "(", "$", "data", "as", "$", "rowId", "=>", "$", "cel...
Short description of method setData @access public @author Cédric Alfonsi, <cedric.alfonsi@tudor.lu> @param array data @return mixed
[ "Short", "description", "of", "method", "setData" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/grid/class.Grid.php#L425-L441
oat-sa/tao-core
helpers/form/elements/xhtml/class.Combobox.php
tao_helpers_form_elements_xhtml_Combobox.render
public function render() { $returnValue = $this->renderLabel(); $returnValue .= "<select name='{$this->name}' id='{$this->name}' "; $returnValue .= $this->renderAttributes(); $returnValue .= ">"; if (! empty($this->emptyOption)) { $this->options = array_merge(array( ' ' => $this->emptyOption), $this->options); } foreach ($this->options as $optionId => $optionLabel) { $returnValue .= "<option value='{$optionId}' "; if ($this->value === $optionId) { $returnValue .= " selected='selected' "; } $returnValue .= ">" . _dh($optionLabel) . "</option>"; } $returnValue .= "</select>"; return (string) $returnValue; }
php
public function render() { $returnValue = $this->renderLabel(); $returnValue .= "<select name='{$this->name}' id='{$this->name}' "; $returnValue .= $this->renderAttributes(); $returnValue .= ">"; if (! empty($this->emptyOption)) { $this->options = array_merge(array( ' ' => $this->emptyOption), $this->options); } foreach ($this->options as $optionId => $optionLabel) { $returnValue .= "<option value='{$optionId}' "; if ($this->value === $optionId) { $returnValue .= " selected='selected' "; } $returnValue .= ">" . _dh($optionLabel) . "</option>"; } $returnValue .= "</select>"; return (string) $returnValue; }
[ "public", "function", "render", "(", ")", "{", "$", "returnValue", "=", "$", "this", "->", "renderLabel", "(", ")", ";", "$", "returnValue", ".=", "\"<select name='{$this->name}' id='{$this->name}' \"", ";", "$", "returnValue", ".=", "$", "this", "->", "renderAt...
Short description of method render @access public @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> @return string
[ "Short", "description", "of", "method", "render" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/elements/xhtml/class.Combobox.php#L41-L62
oat-sa/tao-core
helpers/class.Mode.php
tao_helpers_Mode.is
public static function is($mode){ if(is_int($mode) && self::get() == $mode){ return true; } if(is_string($mode) && self::get() == self::getModeByName($mode)){ return true; } return false; }
php
public static function is($mode){ if(is_int($mode) && self::get() == $mode){ return true; } if(is_string($mode) && self::get() == self::getModeByName($mode)){ return true; } return false; }
[ "public", "static", "function", "is", "(", "$", "mode", ")", "{", "if", "(", "is_int", "(", "$", "mode", ")", "&&", "self", "::", "get", "(", ")", "==", "$", "mode", ")", "{", "return", "true", ";", "}", "if", "(", "is_string", "(", "$", "mode"...
Check the TAO instance current mode @example tao_helpers_Mode::is('production') @param int|string $mode @return boolean
[ "Check", "the", "TAO", "instance", "current", "mode" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Mode.php#L59-L69
oat-sa/tao-core
helpers/class.Mode.php
tao_helpers_Mode.get
public static function get(){ if(empty(self::$currentMode)){ self::$currentMode = self::getCurrentMode(); } return self::$currentMode; }
php
public static function get(){ if(empty(self::$currentMode)){ self::$currentMode = self::getCurrentMode(); } return self::$currentMode; }
[ "public", "static", "function", "get", "(", ")", "{", "if", "(", "empty", "(", "self", "::", "$", "currentMode", ")", ")", "{", "self", "::", "$", "currentMode", "=", "self", "::", "getCurrentMode", "(", ")", ";", "}", "return", "self", "::", "$", ...
Get the current mode @example (tao_helpers_Mode::get() == tao_helpers_Mode::DEVELOPMENT) @return int matching the constants
[ "Get", "the", "current", "mode" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Mode.php#L76-L81
oat-sa/tao-core
scripts/class.TaoHardify.php
tao_scripts_TaoHardify.run
public function run() { $this->outVerbose("Connecting..."); if ($this->connect($this->options['user'], $this->options['password'])){ $this->outVerbose("Connected to TAO API."); switch ($this->options['action']){ case 'hardify': $this->setCurrentAction($this->options['action']); $this->actionHardify(); break; case 'unhardify': $this->setCurrentAction($this->options['action']); $this->actionUnhardify(); break; } $this->disconnect(); } else{ $this->error("Could not connect to TAO API. Please check your user name and password.", true); } }
php
public function run() { $this->outVerbose("Connecting..."); if ($this->connect($this->options['user'], $this->options['password'])){ $this->outVerbose("Connected to TAO API."); switch ($this->options['action']){ case 'hardify': $this->setCurrentAction($this->options['action']); $this->actionHardify(); break; case 'unhardify': $this->setCurrentAction($this->options['action']); $this->actionUnhardify(); break; } $this->disconnect(); } else{ $this->error("Could not connect to TAO API. Please check your user name and password.", true); } }
[ "public", "function", "run", "(", ")", "{", "$", "this", "->", "outVerbose", "(", "\"Connecting...\"", ")", ";", "if", "(", "$", "this", "->", "connect", "(", "$", "this", "->", "options", "[", "'user'", "]", ",", "$", "this", "->", "options", "[", ...
Instructions to execute to handle the action to perform. @access public @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> @return void
[ "Instructions", "to", "execute", "to", "handle", "the", "action", "to", "perform", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoHardify.php#L89-L112
oat-sa/tao-core
scripts/class.TaoHardify.php
tao_scripts_TaoHardify.checkInput
public function checkInput() { $this->options = array('verbose' => false, 'action' => null, 'user' => null, 'password' => null); $this->options = array_merge($this->options, $this->parameters); // Check common inputs. if ($this->options['user'] == null){ $this->error("Please provide a Generis 'user'.", true); } else{ if ($this->options['password'] == null){ $this->error("Please provide a Generis 'password'.", true); } else{ if ($this->options['action'] == null){ $this->error("Please provide the 'action' parameter.", true); } else{ switch ($this->options['action']){ case 'hardify': $this->checkHardifyInput(); break; case 'unhardify': $this->checkUnhardifyInput(); break; default: $this->error("Please provide a valid 'action' parameter.", true); break; } } } } }
php
public function checkInput() { $this->options = array('verbose' => false, 'action' => null, 'user' => null, 'password' => null); $this->options = array_merge($this->options, $this->parameters); // Check common inputs. if ($this->options['user'] == null){ $this->error("Please provide a Generis 'user'.", true); } else{ if ($this->options['password'] == null){ $this->error("Please provide a Generis 'password'.", true); } else{ if ($this->options['action'] == null){ $this->error("Please provide the 'action' parameter.", true); } else{ switch ($this->options['action']){ case 'hardify': $this->checkHardifyInput(); break; case 'unhardify': $this->checkUnhardifyInput(); break; default: $this->error("Please provide a valid 'action' parameter.", true); break; } } } } }
[ "public", "function", "checkInput", "(", ")", "{", "$", "this", "->", "options", "=", "array", "(", "'verbose'", "=>", "false", ",", "'action'", "=>", "null", ",", "'user'", "=>", "null", ",", "'password'", "=>", "null", ")", ";", "$", "this", "->", ...
Checks the input parameters when the script is called from the CLI. It check parameters common to any action (user, password, action) and to the appropriate checking method for the other parameters. @access public @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> @return void
[ "Checks", "the", "input", "parameters", "when", "the", "script", "is", "called", "from", "the", "CLI", ".", "It", "check", "parameters", "common", "to", "any", "action", "(", "user", "password", "action", ")", "and", "to", "the", "appropriate", "checking", ...
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoHardify.php#L135-L173
oat-sa/tao-core
scripts/class.TaoHardify.php
tao_scripts_TaoHardify.actionHardify
public function actionHardify() { // Retrieve parameter values. $class = $this->options['class']; $topClass = $this->options['topClass']; $createForeigns = $this->options['createForeigns']; $recursive = $this->options['recursive']; $classUri = $class->getUri(); $additionalProperties = array(); $blackList = array('http://www.tao.lu/middleware/wfEngine.rdf#ClassProcessVariables'); if (!empty($this->options['additionalProperties'])){ $additionalProperties = $this->options['additionalProperties']; } $optionsHardify = array('recursive' => $recursive, 'append' => true, 'createForeigns' => $createForeigns, 'referencesAllTypes' => true, 'rmSources' => true, 'topClass' => $topClass, 'additionalProperties' => $additionalProperties); try{ $this->outVerbose("Hardifying class '${classUri}'..."); $switcher = new core_kernel_persistence_Switcher($blackList); $switcher->hardify($class, $optionsHardify); $hardenedClasses = $switcher->getHardenedClasses(); if (array_key_exists($classUri, $hardenedClasses)){ $count = $hardenedClasses[$classUri]; $this->outVerbose("Class '${classUri}' successfully hardified: ${count} instance(s) compiled."); if (true == $optionsHardify['createForeigns']){ unset($hardenedClasses[$classUri]); if (true == empty($hardenedClasses)){ $this->outVerbose("No foreign classes were compiled."); } else{ foreach ($hardenedClasses as $uri => $count){ $this->outVerbose("Foreign class '${uri} successfully hardified: ${count} instance(s) compiled.'"); } } } } } catch (Exception $e){ $msg = "A fatal error occured while hardifying class '${classUri}': " . $e->getMessage(); $this->error($msg, true); } }
php
public function actionHardify() { // Retrieve parameter values. $class = $this->options['class']; $topClass = $this->options['topClass']; $createForeigns = $this->options['createForeigns']; $recursive = $this->options['recursive']; $classUri = $class->getUri(); $additionalProperties = array(); $blackList = array('http://www.tao.lu/middleware/wfEngine.rdf#ClassProcessVariables'); if (!empty($this->options['additionalProperties'])){ $additionalProperties = $this->options['additionalProperties']; } $optionsHardify = array('recursive' => $recursive, 'append' => true, 'createForeigns' => $createForeigns, 'referencesAllTypes' => true, 'rmSources' => true, 'topClass' => $topClass, 'additionalProperties' => $additionalProperties); try{ $this->outVerbose("Hardifying class '${classUri}'..."); $switcher = new core_kernel_persistence_Switcher($blackList); $switcher->hardify($class, $optionsHardify); $hardenedClasses = $switcher->getHardenedClasses(); if (array_key_exists($classUri, $hardenedClasses)){ $count = $hardenedClasses[$classUri]; $this->outVerbose("Class '${classUri}' successfully hardified: ${count} instance(s) compiled."); if (true == $optionsHardify['createForeigns']){ unset($hardenedClasses[$classUri]); if (true == empty($hardenedClasses)){ $this->outVerbose("No foreign classes were compiled."); } else{ foreach ($hardenedClasses as $uri => $count){ $this->outVerbose("Foreign class '${uri} successfully hardified: ${count} instance(s) compiled.'"); } } } } } catch (Exception $e){ $msg = "A fatal error occured while hardifying class '${classUri}': " . $e->getMessage(); $this->error($msg, true); } }
[ "public", "function", "actionHardify", "(", ")", "{", "// Retrieve parameter values.\r", "$", "class", "=", "$", "this", "->", "options", "[", "'class'", "]", ";", "$", "topClass", "=", "$", "this", "->", "options", "[", "'topClass'", "]", ";", "$", "creat...
Hardify a class. @access public @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> @return void
[ "Hardify", "a", "class", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoHardify.php#L208-L262
oat-sa/tao-core
scripts/class.TaoHardify.php
tao_scripts_TaoHardify.checkHardifyInput
public function checkHardifyInput() { $defaults = array('class' => null, 'createForeigns' => false, 'recursive' => false, 'additionalProperties' => null, 'topClass' => null); $this->options = array_merge($defaults, $this->options); if (empty($this->options['class'])){ $this->error("Please provide the 'class' parameter.", true); } else{ $classUri = trim($this->options['class']); if (common_Utils::isUri($classUri)){ // We are OK with the class to Hardify $class = new core_kernel_classes_Class($classUri); $this->options['class'] = $class; if (!empty($this->options['additionalProperties'])){ $additionalProperties = explode(',', $this->options['additionalProperties']); if (empty($additionalProperties)){ $this->error("The 'additionalProperties' parameter value is invalid.", true); } else{ foreach ($additionalProperties as $k => $aP){ $uri = trim($aP); if (true == common_Utils::isUri($uri)){ // store clean uri. $additionalProperties[$k] = new core_kernel_classes_Property($uri); } else{ $this->error("'${uri}' is not a valid URI in 'additionalProperties'.", true); } } $this->options['additionalProperties'] = $additionalProperties; if ($this->options['topClass'] == null){ $this->options['topClass'] = new core_kernel_classes_Class(GenerisRdf::CLASS_GENERIS_RESOURCE); } else{ $topClassUri = trim($this->options['topClass']); if (true == common_Utils::isUri($topClassUri)){ $this->options['topClass'] = new core_kernel_classes_Class($topClassUri); } else { $this->error("'${topClassUri}' is not a valid URI in 'topClass'.", true); } } } } } else{ $this->error("The 'class' parameter value is not a valid URI.", true); } } }
php
public function checkHardifyInput() { $defaults = array('class' => null, 'createForeigns' => false, 'recursive' => false, 'additionalProperties' => null, 'topClass' => null); $this->options = array_merge($defaults, $this->options); if (empty($this->options['class'])){ $this->error("Please provide the 'class' parameter.", true); } else{ $classUri = trim($this->options['class']); if (common_Utils::isUri($classUri)){ // We are OK with the class to Hardify $class = new core_kernel_classes_Class($classUri); $this->options['class'] = $class; if (!empty($this->options['additionalProperties'])){ $additionalProperties = explode(',', $this->options['additionalProperties']); if (empty($additionalProperties)){ $this->error("The 'additionalProperties' parameter value is invalid.", true); } else{ foreach ($additionalProperties as $k => $aP){ $uri = trim($aP); if (true == common_Utils::isUri($uri)){ // store clean uri. $additionalProperties[$k] = new core_kernel_classes_Property($uri); } else{ $this->error("'${uri}' is not a valid URI in 'additionalProperties'.", true); } } $this->options['additionalProperties'] = $additionalProperties; if ($this->options['topClass'] == null){ $this->options['topClass'] = new core_kernel_classes_Class(GenerisRdf::CLASS_GENERIS_RESOURCE); } else{ $topClassUri = trim($this->options['topClass']); if (true == common_Utils::isUri($topClassUri)){ $this->options['topClass'] = new core_kernel_classes_Class($topClassUri); } else { $this->error("'${topClassUri}' is not a valid URI in 'topClass'.", true); } } } } } else{ $this->error("The 'class' parameter value is not a valid URI.", true); } } }
[ "public", "function", "checkHardifyInput", "(", ")", "{", "$", "defaults", "=", "array", "(", "'class'", "=>", "null", ",", "'createForeigns'", "=>", "false", ",", "'recursive'", "=>", "false", ",", "'additionalProperties'", "=>", "null", ",", "'topClass'", "=...
Check additional inputs for the 'setConfig' action. @access public @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> @return void
[ "Check", "additional", "inputs", "for", "the", "setConfig", "action", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoHardify.php#L339-L399
oat-sa/tao-core
models/classes/stream/StreamRange.php
StreamRange.createFromRequest
public static function createFromRequest(StreamInterface $stream, ServerRequestInterface $request = null) { $result = []; if ($request === null) { $headers = \tao_helpers_Http::getHeaders(); $rangeHeader = isset($headers['Range']) ? [$headers['Range']] : null; } else { $rangeHeader = $request->hasHeader('Range') ? $request->getHeader('Range') : null; } if ($rangeHeader) { $ranges = explode(',', $rangeHeader[0]); foreach($ranges as $range) { $range = str_replace('bytes=', '', $range); $result[] = new StreamRange($stream, $range); } } return $result; }
php
public static function createFromRequest(StreamInterface $stream, ServerRequestInterface $request = null) { $result = []; if ($request === null) { $headers = \tao_helpers_Http::getHeaders(); $rangeHeader = isset($headers['Range']) ? [$headers['Range']] : null; } else { $rangeHeader = $request->hasHeader('Range') ? $request->getHeader('Range') : null; } if ($rangeHeader) { $ranges = explode(',', $rangeHeader[0]); foreach($ranges as $range) { $range = str_replace('bytes=', '', $range); $result[] = new StreamRange($stream, $range); } } return $result; }
[ "public", "static", "function", "createFromRequest", "(", "StreamInterface", "$", "stream", ",", "ServerRequestInterface", "$", "request", "=", "null", ")", "{", "$", "result", "=", "[", "]", ";", "if", "(", "$", "request", "===", "null", ")", "{", "$", ...
Create array of StreamRange instances based on current request range headers @param StreamInterface $stream @param ServerRequestInterface $request @throws StreamRangeException @return StreamRange[]
[ "Create", "array", "of", "StreamRange", "instances", "based", "on", "current", "request", "range", "headers" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/stream/StreamRange.php#L89-L106
oat-sa/tao-core
helpers/form/xhtml/class.TagWrapper.php
tao_helpers_form_xhtml_TagWrapper.preRender
public function preRender() { $returnValue = (string) ''; if(!empty($this->tag)){ $returnValue .= "<{$this->tag}"; if (isset($this->attributes['cssClass'])) { // legacy $this->attributes['class'] = $this->attributes['cssClass']. (isset($this->attributes['class']) ? ' '.$this->attributes['class'] : ''); unset($this->attributes['cssClass']); } foreach ($this->attributes as $key => $value) { $returnValue .= ' '.$key.'=\''.$value.'\' '; } $returnValue .= ">"; } return (string) $returnValue; }
php
public function preRender() { $returnValue = (string) ''; if(!empty($this->tag)){ $returnValue .= "<{$this->tag}"; if (isset($this->attributes['cssClass'])) { // legacy $this->attributes['class'] = $this->attributes['cssClass']. (isset($this->attributes['class']) ? ' '.$this->attributes['class'] : ''); unset($this->attributes['cssClass']); } foreach ($this->attributes as $key => $value) { $returnValue .= ' '.$key.'=\''.$value.'\' '; } $returnValue .= ">"; } return (string) $returnValue; }
[ "public", "function", "preRender", "(", ")", "{", "$", "returnValue", "=", "(", "string", ")", "''", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "tag", ")", ")", "{", "$", "returnValue", ".=", "\"<{$this->tag}\"", ";", "if", "(", "isset", ...
Short description of method preRender @access public @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> @return string
[ "Short", "description", "of", "method", "preRender" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/xhtml/class.TagWrapper.php#L55-L74
oat-sa/tao-core
helpers/form/xhtml/class.TagWrapper.php
tao_helpers_form_xhtml_TagWrapper.getOption
public function getOption($key) { if ($key == 'tag') { return $this->tag; } elseif (isset($this->attributes[$key])) { return $this->attributes[$key]; } else { return ''; } }
php
public function getOption($key) { if ($key == 'tag') { return $this->tag; } elseif (isset($this->attributes[$key])) { return $this->attributes[$key]; } else { return ''; } }
[ "public", "function", "getOption", "(", "$", "key", ")", "{", "if", "(", "$", "key", "==", "'tag'", ")", "{", "return", "$", "this", "->", "tag", ";", "}", "elseif", "(", "isset", "(", "$", "this", "->", "attributes", "[", "$", "key", "]", ")", ...
Short description of method getOption @access public @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> @param string key @return string
[ "Short", "description", "of", "method", "getOption" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/xhtml/class.TagWrapper.php#L104-L113
oat-sa/tao-core
helpers/form/xhtml/class.TagWrapper.php
tao_helpers_form_xhtml_TagWrapper.setOption
public function setOption($key, $value) { if ($key == 'tag') { $this->tag = $value; } else { $this->attributes[$key] = $value; } return true; }
php
public function setOption($key, $value) { if ($key == 'tag') { $this->tag = $value; } else { $this->attributes[$key] = $value; } return true; }
[ "public", "function", "setOption", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "$", "key", "==", "'tag'", ")", "{", "$", "this", "->", "tag", "=", "$", "value", ";", "}", "else", "{", "$", "this", "->", "attributes", "[", "$", "key...
Short description of method setOption @access public @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> @param string key @param string value @return boolean
[ "Short", "description", "of", "method", "setOption" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/xhtml/class.TagWrapper.php#L124-L132
oat-sa/tao-core
actions/form/class.AdvancedProperty.php
tao_actions_form_AdvancedProperty.initElements
public function initElements() { $property = $this->getPropertyInstance(); (isset($this->options['index'])) ? $index = $this->options['index'] : $index = 1; $propertyProperties = array_merge( tao_helpers_form_GenerisFormFactory::getDefaultProperties(), array( new core_kernel_classes_Property(GenerisRdf::PROPERTY_IS_LG_DEPENDENT), new core_kernel_classes_Property(WidgetRdf::PROPERTY_WIDGET), new core_kernel_classes_Property(OntologyRdfs::RDFS_RANGE), ) ); $elementNames = array(); foreach($propertyProperties as $propertyProperty){ //map properties widgets to form elements $element = tao_helpers_form_GenerisFormFactory::elementMap($propertyProperty); if(!is_null($element)){ //take property values to populate the form $values = $property->getPropertyValuesCollection($propertyProperty); foreach($values->getIterator() as $value){ if(!is_null($value)){ if($value instanceof core_kernel_classes_Resource){ $element->setValue($value->getUri()); } if($value instanceof core_kernel_classes_Literal){ $element->setValue((string)$value); } } } $element->setName("property_{$index}_{$element->getName()}"); $element->addClass('property'); if ($propertyProperty->getUri() == OntologyRdfs::RDFS_LABEL){ $element->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty')); } $this->form->addElement($element); $elementNames[] = $element->getName(); } } $encodedUri = tao_helpers_Uri::encode($property->getUri()); $modeElt = tao_helpers_form_FormFactory::getElement("{$index}_uri", 'Hidden'); $modeElt->setValue($encodedUri); $modeElt->addClass('property'); $this->form->addElement($modeElt); $elementNames[] = $modeElt->getName(); if(count($elementNames) > 0){ $groupTitle = $this->getGroupTitle($property); $this->form->createGroup("property_{$encodedUri}", $groupTitle, $elementNames); } }
php
public function initElements() { $property = $this->getPropertyInstance(); (isset($this->options['index'])) ? $index = $this->options['index'] : $index = 1; $propertyProperties = array_merge( tao_helpers_form_GenerisFormFactory::getDefaultProperties(), array( new core_kernel_classes_Property(GenerisRdf::PROPERTY_IS_LG_DEPENDENT), new core_kernel_classes_Property(WidgetRdf::PROPERTY_WIDGET), new core_kernel_classes_Property(OntologyRdfs::RDFS_RANGE), ) ); $elementNames = array(); foreach($propertyProperties as $propertyProperty){ //map properties widgets to form elements $element = tao_helpers_form_GenerisFormFactory::elementMap($propertyProperty); if(!is_null($element)){ //take property values to populate the form $values = $property->getPropertyValuesCollection($propertyProperty); foreach($values->getIterator() as $value){ if(!is_null($value)){ if($value instanceof core_kernel_classes_Resource){ $element->setValue($value->getUri()); } if($value instanceof core_kernel_classes_Literal){ $element->setValue((string)$value); } } } $element->setName("property_{$index}_{$element->getName()}"); $element->addClass('property'); if ($propertyProperty->getUri() == OntologyRdfs::RDFS_LABEL){ $element->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty')); } $this->form->addElement($element); $elementNames[] = $element->getName(); } } $encodedUri = tao_helpers_Uri::encode($property->getUri()); $modeElt = tao_helpers_form_FormFactory::getElement("{$index}_uri", 'Hidden'); $modeElt->setValue($encodedUri); $modeElt->addClass('property'); $this->form->addElement($modeElt); $elementNames[] = $modeElt->getName(); if(count($elementNames) > 0){ $groupTitle = $this->getGroupTitle($property); $this->form->createGroup("property_{$encodedUri}", $groupTitle, $elementNames); } }
[ "public", "function", "initElements", "(", ")", "{", "$", "property", "=", "$", "this", "->", "getPropertyInstance", "(", ")", ";", "(", "isset", "(", "$", "this", "->", "options", "[", "'index'", "]", ")", ")", "?", "$", "index", "=", "$", "this", ...
Short description of method initElements @access public @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> @return mixed
[ "Short", "description", "of", "method", "initElements" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/form/class.AdvancedProperty.php#L51-L106
oat-sa/tao-core
helpers/form/elements/xhtml/class.Versionedfile.php
tao_helpers_form_elements_xhtml_Versionedfile.render
public function render() { if (array_key_exists('class', $this->attributes)) { if (strstr($this->attributes['class'], self::CSS_CLASS) !== false) { $this->attributes['class'] .= ' ' . self::CSS_CLASS; } } else { $this->attributes['class'] = self::CSS_CLASS; } $returnValue = $this->renderLabel(); $returnValue .= "<input type='button' for='{$this->name}' value='" . __('Manage Versioned File') . "' "; $returnValue .= $this->renderAttributes(); $returnValue .= " />"; $returnValue .= "<span for='{$this->name}' " . $this->renderAttributes() . "></span>"; return (string) $returnValue; }
php
public function render() { if (array_key_exists('class', $this->attributes)) { if (strstr($this->attributes['class'], self::CSS_CLASS) !== false) { $this->attributes['class'] .= ' ' . self::CSS_CLASS; } } else { $this->attributes['class'] = self::CSS_CLASS; } $returnValue = $this->renderLabel(); $returnValue .= "<input type='button' for='{$this->name}' value='" . __('Manage Versioned File') . "' "; $returnValue .= $this->renderAttributes(); $returnValue .= " />"; $returnValue .= "<span for='{$this->name}' " . $this->renderAttributes() . "></span>"; return (string) $returnValue; }
[ "public", "function", "render", "(", ")", "{", "if", "(", "array_key_exists", "(", "'class'", ",", "$", "this", "->", "attributes", ")", ")", "{", "if", "(", "strstr", "(", "$", "this", "->", "attributes", "[", "'class'", "]", ",", "self", "::", "CSS...
Short description of method render @access public @author Somsack Sipasseuth, <somsack.sipasseuth@tudor.lu> @return string
[ "Short", "description", "of", "method", "render" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/elements/xhtml/class.Versionedfile.php#L50-L69
oat-sa/tao-core
models/classes/export/class.RdfExporter.php
tao_models_classes_export_RdfExporter.export
public function export($formValues, $destination) { if (isset($formValues['filename'], $formValues['resource'])) { $class = new core_kernel_classes_Class($formValues['resource']); $adapter = new tao_helpers_data_GenerisAdapterRdf(); $rdf = $adapter->export($class); if (!empty($rdf)) { $name = $formValues['filename'] . '_' . time() . '.rdf'; $path = tao_helpers_File::concat([$destination, $name]); if (!tao_helpers_File::securityCheck($path, true)) { throw new Exception('Unauthorized file name'); } if (file_put_contents($path, $rdf)) { $this->getEventManager()->trigger(new RdfExportEvent($class)); return $path; } } } return ''; }
php
public function export($formValues, $destination) { if (isset($formValues['filename'], $formValues['resource'])) { $class = new core_kernel_classes_Class($formValues['resource']); $adapter = new tao_helpers_data_GenerisAdapterRdf(); $rdf = $adapter->export($class); if (!empty($rdf)) { $name = $formValues['filename'] . '_' . time() . '.rdf'; $path = tao_helpers_File::concat([$destination, $name]); if (!tao_helpers_File::securityCheck($path, true)) { throw new Exception('Unauthorized file name'); } if (file_put_contents($path, $rdf)) { $this->getEventManager()->trigger(new RdfExportEvent($class)); return $path; } } } return ''; }
[ "public", "function", "export", "(", "$", "formValues", ",", "$", "destination", ")", "{", "if", "(", "isset", "(", "$", "formValues", "[", "'filename'", "]", ",", "$", "formValues", "[", "'resource'", "]", ")", ")", "{", "$", "class", "=", "new", "c...
Run the export process. @param array $formValues @param string $destination @return string @throws EasyRdf_Exception @throws common_exception_Error @throws Exception
[ "Run", "the", "export", "process", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/export/class.RdfExporter.php#L76-L100
oat-sa/tao-core
models/classes/export/class.RdfExporter.php
tao_models_classes_export_RdfExporter.getRdfString
public function getRdfString($instances) { $api = core_kernel_impl_ApiModelOO::singleton(); $rdf = ''; $xmls = []; foreach ($instances as $instance) { $xmls[] = $api->getResourceDescriptionXML($instance->getUri()); } if (count($xmls) === 1) { $rdf = $xmls[0]; } elseif (count($xmls) > 1) { $baseDom = new DomDocument(); $baseDom->formatOutput = true; $baseDom->loadXML($xmls[0]); for ($i = 1, $iMax = count($xmls); $i < $iMax; $i++) { $xmlDoc = new SimpleXMLElement($xmls[$i]); foreach ($xmlDoc->getNamespaces() as $nsName => $nsUri) { if (!$baseDom->documentElement->hasAttribute('xmlns:' . $nsName)) { $baseDom->documentElement->setAttribute('xmlns:' . $nsName, $nsUri); } } $newDom = new DOMDocument(); $newDom->loadXML($xmls[$i]); foreach ($newDom->getElementsByTagNameNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'Description') as $desc) { $newNode = $baseDom->importNode($desc, true); $baseDom->documentElement->appendChild($newNode); } } $rdf = $baseDom->saveXML(); } return $rdf; }
php
public function getRdfString($instances) { $api = core_kernel_impl_ApiModelOO::singleton(); $rdf = ''; $xmls = []; foreach ($instances as $instance) { $xmls[] = $api->getResourceDescriptionXML($instance->getUri()); } if (count($xmls) === 1) { $rdf = $xmls[0]; } elseif (count($xmls) > 1) { $baseDom = new DomDocument(); $baseDom->formatOutput = true; $baseDom->loadXML($xmls[0]); for ($i = 1, $iMax = count($xmls); $i < $iMax; $i++) { $xmlDoc = new SimpleXMLElement($xmls[$i]); foreach ($xmlDoc->getNamespaces() as $nsName => $nsUri) { if (!$baseDom->documentElement->hasAttribute('xmlns:' . $nsName)) { $baseDom->documentElement->setAttribute('xmlns:' . $nsName, $nsUri); } } $newDom = new DOMDocument(); $newDom->loadXML($xmls[$i]); foreach ($newDom->getElementsByTagNameNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'Description') as $desc) { $newNode = $baseDom->importNode($desc, true); $baseDom->documentElement->appendChild($newNode); } } $rdf = $baseDom->saveXML(); } return $rdf; }
[ "public", "function", "getRdfString", "(", "$", "instances", ")", "{", "$", "api", "=", "core_kernel_impl_ApiModelOO", "::", "singleton", "(", ")", ";", "$", "rdf", "=", "''", ";", "$", "xmls", "=", "[", "]", ";", "foreach", "(", "$", "instances", "as"...
Exports an array of instances into an rdf string. @param array $instances @return string
[ "Exports", "an", "array", "of", "instances", "into", "an", "rdf", "string", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/export/class.RdfExporter.php#L108-L145
oat-sa/tao-core
install/class.Installator.php
tao_install_Installator.install
public function install(array $installData) { try { /** * It's a quick hack for solving reinstall issue. * Should be a better option. */ @unlink($this->options['root_path'].'config/generis.conf.php'); /* * 0 - Check input parameters. */ $this->log('i', "Checking install data"); self::checkInstallData($installData); $this->log('i', "Starting TAO install"); // Sanitize $installData if needed. if(!preg_match("/\/$/", $installData['module_url'])){ $installData['module_url'] .= '/'; } if(isset($installData['extensions'])) { $extensionIDs = is_array($installData['extensions']) ? $installData['extensions'] : explode(',',$installData['extensions']); } else { $extensionIDs = array('taoCe'); } $this->log('d', 'Extensions to be installed: ' . var_export($extensionIDs, true)); $installData['file_path'] = rtrim($installData['file_path'], DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; /* * 1 - Check configuration with checks described in the manifest. */ $configChecker = tao_install_utils_ChecksHelper::getConfigChecker($extensionIDs); // Silence checks to have to be escaped. foreach ($configChecker->getComponents() as $c){ if (method_exists($c, 'getName') && in_array($c->getName(), $this->getEscapedChecks())){ $configChecker->silent($c); } } $reports = $configChecker->check(); foreach ($reports as $r){ $msg = $r->getMessage(); $component = $r->getComponent(); $this->log('i', $msg); if ($r->getStatus() !== common_configuration_Report::VALID && !$component->isOptional()){ throw new tao_install_utils_Exception($msg); } } /* * X - Setup Oatbox */ $this->log('d', 'Removing old config'); $consistentOptions = array_merge($installData, $this->options); $consistentOptions['config_path'] = $this->getConfigPath(); $this->oatBoxInstall->setOptions($consistentOptions); $this->oatBoxInstall->install(); $this->log('d', 'Oatbox was installed!'); ServiceManager::setServiceManager($this->getServiceManager()); /* * 2 - Test DB connection (done by the constructor) */ $this->log('i', "Spawning DbCreator"); $dbName = $installData['db_name']; if($installData['db_driver'] == 'pdo_oci'){ $installData['db_name'] = $installData['db_host']; $installData['db_host'] = ''; } $dbConfiguration = array( 'driver' => $installData['db_driver'], 'host' => $installData['db_host'], 'dbname' => $installData['db_name'], 'user' => $installData['db_user'], 'password' => $installData['db_pass'], ); $hostParts = explode(':', $installData['db_host']); if (count($hostParts) == 2) { $dbConfiguration['host'] = $hostParts[0]; $dbConfiguration['port'] = $hostParts[1]; } if($installData['db_driver'] == 'pdo_mysql'){ $dbConfiguration['dbname'] = ''; } if($installData['db_driver'] == 'pdo_oci'){ $dbConfiguration['wrapperClass'] = 'Doctrine\DBAL\Portability\Connection'; $dbConfiguration['portability'] = \Doctrine\DBAL\Portability\Connection::PORTABILITY_ALL; $dbConfiguration['fetch_case'] = PDO::CASE_LOWER; } $dbCreator = new tao_install_utils_DbalDbCreator($dbConfiguration); $this->log('d', "DbCreator spawned"); /* * 3 - Load the database schema */ // If the database already exists, drop all tables if ($dbCreator->dbExists($dbName)) { try { //If the target Sgbd is mysql select the database after creating it if ($installData['db_driver'] == 'pdo_mysql'){ $dbCreator->setDatabase($installData['db_name']); } $dbCreator->cleanDb($dbName); } catch (Exception $e){ $this->log('i', 'Problem cleaning db will try to erase the whole db: '.$e->getMessage()); try { $dbCreator->destroyTaoDatabase($dbName); } catch (Exception $e){ $this->log('i', 'isssue during db cleaning : ' . $e->getMessage()); } } $this->log('i', "Dropped all tables"); } // Else create it else { try { $dbCreator->createDatabase($installData['db_name']); $this->log('i', "Created database ".$installData['db_name']); } catch (Exception $e){ throw new tao_install_utils_Exception('Unable to create the database, make sure that '.$installData['db_user'].' is granted to create databases. Otherwise create the database with your super user and give to '.$installData['db_user'].' the right to use it.'); } //If the target Sgbd is mysql select the database after creating it if ($installData['db_driver'] == 'pdo_mysql'){ $dbCreator->setDatabase($installData['db_name']); } } // reset db name for mysql if ($installData['db_driver'] == 'pdo_mysql'){ $dbConfiguration['dbname'] = $installData['db_name']; } // Create tao tables $dbCreator->initTaoDataBase(); $this->log('i', 'Created tables'); $storedProcedureFile = __DIR__ . DIRECTORY_SEPARATOR . 'db' . DIRECTORY_SEPARATOR . 'tao_stored_procedures_' . str_replace('pdo_', '', $installData['db_driver']) . '.sql'; if (file_exists($storedProcedureFile) && is_readable($storedProcedureFile)){ $this->log('i', 'Installing stored procedures for ' . $installData['db_driver'] . ' from file: ' . $storedProcedureFile); $dbCreator->loadProc($storedProcedureFile); } else { $this->log('e', 'Could not find storefile : ' . $storedProcedureFile); } /* * 4 - Create the generis config files */ $this->log('d', 'Writing generis config'); $generisConfigWriter = new tao_install_utils_ConfigWriter( $this->options['root_path'].'generis/config/sample/generis.conf.php', $this->getGenerisConfig() ); $session_name = (isset($installData['session_name']))?$installData['session_name']:self::generateSessionName(); $generisConfigWriter->createConfig(); $constants = array( 'LOCAL_NAMESPACE' => $installData['module_namespace'], 'GENERIS_INSTANCE_NAME' => $installData['instance_name'], 'GENERIS_SESSION_NAME' => $session_name, 'ROOT_PATH' => $this->options['root_path'], 'FILES_PATH' => $installData['file_path'], 'ROOT_URL' => $installData['module_url'], 'DEFAULT_LANG' => $installData['module_lang'], 'DEBUG_MODE' => ($installData['module_mode'] == 'debug') ? true : false, 'TIME_ZONE' => $installData['timezone'] ); $constants['DEFAULT_ANONYMOUS_INTERFACE_LANG'] = (isset($installData['anonymous_lang'])) ? $installData['anonymous_lang'] : $installData['module_lang']; $generisConfigWriter->writeConstants($constants); $this->log('d', 'The following constants were written in generis config:' . PHP_EOL . var_export($constants, true)); /* * 4b - Prepare the file/cache folder (FILES_PATH) not yet defined) * @todo solve this more elegantly */ $file_path = $installData['file_path']; if (is_dir($file_path)) { $this->log('i', 'Data from previous install found and will be removed'); if (!helpers_File::emptyDirectory($file_path, true)) { throw new common_exception_Error('Unable to empty ' . $file_path . ' folder.'); } } else { if (mkdir($file_path, 0700, true)) { $this->log('d', $file_path . ' directory was created!'); } else { throw new Exception($file_path . ' directory creation was failed!'); } } $cachePath = $file_path . 'generis' . DIRECTORY_SEPARATOR . 'cache'; if (mkdir($cachePath, 0700, true)) { $this->log('d', $cachePath . ' directory was created!'); } else { throw new Exception($cachePath . ' directory creation was failed!'); } foreach ((array)$installData['extra_persistences'] as $k => $persistence) { common_persistence_Manager::addPersistence($k, $persistence); } /* * 5 - Run the extensions bootstrap */ $this->log('d', 'Running the extensions bootstrap'); common_Config::load($this->getGenerisConfig()); /* * 5b - Create cache persistence */ $this->log('d', 'Creating cache persistence..'); common_persistence_Manager::addPersistence('cache', array( 'driver' => 'phpfile' )); common_persistence_KeyValuePersistence::getPersistence('cache')->purge(); /* * 5c - Create generis persistence */ $this->log('d', 'Creating generis persistence..'); common_persistence_Manager::addPersistence('default', $dbConfiguration); /* * 5d - Create generis user */ // Init model creator and create the Generis User. $this->log('d', 'Creating generis user..'); $modelCreator = new tao_install_utils_ModelCreator(LOCAL_NAMESPACE); $modelCreator->insertGenerisUser(helpers_Random::generateString(8)); /* * 6 - Add languages */ $this->log('d', 'Adding languages..'); $models = $modelCreator->getLanguageModels(); foreach ($models as $ns => $modelFiles){ foreach ($modelFiles as $file){ $this->log('d', "Inserting language description model '".$file."'"); $modelCreator->insertLocalModel($file); } } /* * 7 - Finish Generis Install */ $this->log('d', 'Finishing generis install..'); $generis = common_ext_ExtensionsManager::singleton()->getExtensionById('generis'); $generisInstaller = new common_ext_GenerisInstaller($generis, true); $generisInstaller->initContainer($this->getContainer()); $generisInstaller->install(); /* * 8 - Install the extensions */ InstallHelper::initContainer($this->container); $installed = InstallHelper::installRecursively($extensionIDs, $installData); $this->log('ext', $installed); /* * 8b - Generates client side translation bundles (depends on extension install) */ $this->log('i', 'Generates client side translation bundles'); $files = tao_models_classes_LanguageService::singleton()->generateAll(); /* * 9 - Insert Super User */ $this->log('i', 'Spawning SuperUser '.$installData['user_login']); $modelCreator->insertSuperUser(array( 'login' => $installData['user_login'], 'password' => core_kernel_users_Service::getPasswordHash()->encrypt($installData['user_pass1']), 'userLastName' => $installData['user_lastname'], 'userFirstName' => $installData['user_firstname'], 'userMail' => $installData['user_email'], 'userDefLg' => 'http://www.tao.lu/Ontologies/TAO.rdf#Lang'.$installData['module_lang'], 'userUILg' => 'http://www.tao.lu/Ontologies/TAO.rdf#Lang'.$installData['module_lang'], 'userTimezone' => TIME_ZONE )); /* * 10 - Secure the install for production mode */ if($installData['module_mode'] == 'production'){ $extensions = common_ext_ExtensionsManager::singleton()->getInstalledExtensions(); $this->log('i', 'Securing tao for production'); // 11.1 Remove Generis User $dbCreator->removeGenerisUser(); // 11.2 Protect TAO dist $shield = new tao_install_utils_Shield(array_keys($extensions)); $shield->disableRewritePattern(array("!/test/", "!/doc/")); $shield->denyAccessTo(array( 'views/sass', 'views/js/test', 'views/build' )); $shield->protectInstall(); } /* * 11 - Create the version file */ $this->log('d', 'Creating TAO version file'); file_put_contents($installData['file_path'].'version', TAO_VERSION); /* * 12 - Register Information about organization operating the system */ $this->log('t', 'Registering information about the organization operating the system'); $operatedByService = $this->getServiceManager()->get(OperatedByService::SERVICE_ID); if (!empty($installData['operated_by_name'])) { $operatedByService->setName($installData['operated_by_name']); } if (!empty($installData['operated_by_email'])) { $operatedByService->setEmail($installData['operated_by_email']); } $this->getServiceManager()->register(OperatedByService::SERVICE_ID, $operatedByService); } catch(Exception $e){ if ($this->retryInstallation($e)) { return; } // In any case, we transmit a single exception type (at the moment) // for a clearer API for client code. $this->log('e', 'Error Occurs : ' . $e->getMessage() . PHP_EOL . $e->getTraceAsString()); throw new tao_install_utils_Exception($e->getMessage(), 0, $e); } }
php
public function install(array $installData) { try { /** * It's a quick hack for solving reinstall issue. * Should be a better option. */ @unlink($this->options['root_path'].'config/generis.conf.php'); /* * 0 - Check input parameters. */ $this->log('i', "Checking install data"); self::checkInstallData($installData); $this->log('i', "Starting TAO install"); // Sanitize $installData if needed. if(!preg_match("/\/$/", $installData['module_url'])){ $installData['module_url'] .= '/'; } if(isset($installData['extensions'])) { $extensionIDs = is_array($installData['extensions']) ? $installData['extensions'] : explode(',',$installData['extensions']); } else { $extensionIDs = array('taoCe'); } $this->log('d', 'Extensions to be installed: ' . var_export($extensionIDs, true)); $installData['file_path'] = rtrim($installData['file_path'], DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; /* * 1 - Check configuration with checks described in the manifest. */ $configChecker = tao_install_utils_ChecksHelper::getConfigChecker($extensionIDs); // Silence checks to have to be escaped. foreach ($configChecker->getComponents() as $c){ if (method_exists($c, 'getName') && in_array($c->getName(), $this->getEscapedChecks())){ $configChecker->silent($c); } } $reports = $configChecker->check(); foreach ($reports as $r){ $msg = $r->getMessage(); $component = $r->getComponent(); $this->log('i', $msg); if ($r->getStatus() !== common_configuration_Report::VALID && !$component->isOptional()){ throw new tao_install_utils_Exception($msg); } } /* * X - Setup Oatbox */ $this->log('d', 'Removing old config'); $consistentOptions = array_merge($installData, $this->options); $consistentOptions['config_path'] = $this->getConfigPath(); $this->oatBoxInstall->setOptions($consistentOptions); $this->oatBoxInstall->install(); $this->log('d', 'Oatbox was installed!'); ServiceManager::setServiceManager($this->getServiceManager()); /* * 2 - Test DB connection (done by the constructor) */ $this->log('i', "Spawning DbCreator"); $dbName = $installData['db_name']; if($installData['db_driver'] == 'pdo_oci'){ $installData['db_name'] = $installData['db_host']; $installData['db_host'] = ''; } $dbConfiguration = array( 'driver' => $installData['db_driver'], 'host' => $installData['db_host'], 'dbname' => $installData['db_name'], 'user' => $installData['db_user'], 'password' => $installData['db_pass'], ); $hostParts = explode(':', $installData['db_host']); if (count($hostParts) == 2) { $dbConfiguration['host'] = $hostParts[0]; $dbConfiguration['port'] = $hostParts[1]; } if($installData['db_driver'] == 'pdo_mysql'){ $dbConfiguration['dbname'] = ''; } if($installData['db_driver'] == 'pdo_oci'){ $dbConfiguration['wrapperClass'] = 'Doctrine\DBAL\Portability\Connection'; $dbConfiguration['portability'] = \Doctrine\DBAL\Portability\Connection::PORTABILITY_ALL; $dbConfiguration['fetch_case'] = PDO::CASE_LOWER; } $dbCreator = new tao_install_utils_DbalDbCreator($dbConfiguration); $this->log('d', "DbCreator spawned"); /* * 3 - Load the database schema */ // If the database already exists, drop all tables if ($dbCreator->dbExists($dbName)) { try { //If the target Sgbd is mysql select the database after creating it if ($installData['db_driver'] == 'pdo_mysql'){ $dbCreator->setDatabase($installData['db_name']); } $dbCreator->cleanDb($dbName); } catch (Exception $e){ $this->log('i', 'Problem cleaning db will try to erase the whole db: '.$e->getMessage()); try { $dbCreator->destroyTaoDatabase($dbName); } catch (Exception $e){ $this->log('i', 'isssue during db cleaning : ' . $e->getMessage()); } } $this->log('i', "Dropped all tables"); } // Else create it else { try { $dbCreator->createDatabase($installData['db_name']); $this->log('i', "Created database ".$installData['db_name']); } catch (Exception $e){ throw new tao_install_utils_Exception('Unable to create the database, make sure that '.$installData['db_user'].' is granted to create databases. Otherwise create the database with your super user and give to '.$installData['db_user'].' the right to use it.'); } //If the target Sgbd is mysql select the database after creating it if ($installData['db_driver'] == 'pdo_mysql'){ $dbCreator->setDatabase($installData['db_name']); } } // reset db name for mysql if ($installData['db_driver'] == 'pdo_mysql'){ $dbConfiguration['dbname'] = $installData['db_name']; } // Create tao tables $dbCreator->initTaoDataBase(); $this->log('i', 'Created tables'); $storedProcedureFile = __DIR__ . DIRECTORY_SEPARATOR . 'db' . DIRECTORY_SEPARATOR . 'tao_stored_procedures_' . str_replace('pdo_', '', $installData['db_driver']) . '.sql'; if (file_exists($storedProcedureFile) && is_readable($storedProcedureFile)){ $this->log('i', 'Installing stored procedures for ' . $installData['db_driver'] . ' from file: ' . $storedProcedureFile); $dbCreator->loadProc($storedProcedureFile); } else { $this->log('e', 'Could not find storefile : ' . $storedProcedureFile); } /* * 4 - Create the generis config files */ $this->log('d', 'Writing generis config'); $generisConfigWriter = new tao_install_utils_ConfigWriter( $this->options['root_path'].'generis/config/sample/generis.conf.php', $this->getGenerisConfig() ); $session_name = (isset($installData['session_name']))?$installData['session_name']:self::generateSessionName(); $generisConfigWriter->createConfig(); $constants = array( 'LOCAL_NAMESPACE' => $installData['module_namespace'], 'GENERIS_INSTANCE_NAME' => $installData['instance_name'], 'GENERIS_SESSION_NAME' => $session_name, 'ROOT_PATH' => $this->options['root_path'], 'FILES_PATH' => $installData['file_path'], 'ROOT_URL' => $installData['module_url'], 'DEFAULT_LANG' => $installData['module_lang'], 'DEBUG_MODE' => ($installData['module_mode'] == 'debug') ? true : false, 'TIME_ZONE' => $installData['timezone'] ); $constants['DEFAULT_ANONYMOUS_INTERFACE_LANG'] = (isset($installData['anonymous_lang'])) ? $installData['anonymous_lang'] : $installData['module_lang']; $generisConfigWriter->writeConstants($constants); $this->log('d', 'The following constants were written in generis config:' . PHP_EOL . var_export($constants, true)); /* * 4b - Prepare the file/cache folder (FILES_PATH) not yet defined) * @todo solve this more elegantly */ $file_path = $installData['file_path']; if (is_dir($file_path)) { $this->log('i', 'Data from previous install found and will be removed'); if (!helpers_File::emptyDirectory($file_path, true)) { throw new common_exception_Error('Unable to empty ' . $file_path . ' folder.'); } } else { if (mkdir($file_path, 0700, true)) { $this->log('d', $file_path . ' directory was created!'); } else { throw new Exception($file_path . ' directory creation was failed!'); } } $cachePath = $file_path . 'generis' . DIRECTORY_SEPARATOR . 'cache'; if (mkdir($cachePath, 0700, true)) { $this->log('d', $cachePath . ' directory was created!'); } else { throw new Exception($cachePath . ' directory creation was failed!'); } foreach ((array)$installData['extra_persistences'] as $k => $persistence) { common_persistence_Manager::addPersistence($k, $persistence); } /* * 5 - Run the extensions bootstrap */ $this->log('d', 'Running the extensions bootstrap'); common_Config::load($this->getGenerisConfig()); /* * 5b - Create cache persistence */ $this->log('d', 'Creating cache persistence..'); common_persistence_Manager::addPersistence('cache', array( 'driver' => 'phpfile' )); common_persistence_KeyValuePersistence::getPersistence('cache')->purge(); /* * 5c - Create generis persistence */ $this->log('d', 'Creating generis persistence..'); common_persistence_Manager::addPersistence('default', $dbConfiguration); /* * 5d - Create generis user */ // Init model creator and create the Generis User. $this->log('d', 'Creating generis user..'); $modelCreator = new tao_install_utils_ModelCreator(LOCAL_NAMESPACE); $modelCreator->insertGenerisUser(helpers_Random::generateString(8)); /* * 6 - Add languages */ $this->log('d', 'Adding languages..'); $models = $modelCreator->getLanguageModels(); foreach ($models as $ns => $modelFiles){ foreach ($modelFiles as $file){ $this->log('d', "Inserting language description model '".$file."'"); $modelCreator->insertLocalModel($file); } } /* * 7 - Finish Generis Install */ $this->log('d', 'Finishing generis install..'); $generis = common_ext_ExtensionsManager::singleton()->getExtensionById('generis'); $generisInstaller = new common_ext_GenerisInstaller($generis, true); $generisInstaller->initContainer($this->getContainer()); $generisInstaller->install(); /* * 8 - Install the extensions */ InstallHelper::initContainer($this->container); $installed = InstallHelper::installRecursively($extensionIDs, $installData); $this->log('ext', $installed); /* * 8b - Generates client side translation bundles (depends on extension install) */ $this->log('i', 'Generates client side translation bundles'); $files = tao_models_classes_LanguageService::singleton()->generateAll(); /* * 9 - Insert Super User */ $this->log('i', 'Spawning SuperUser '.$installData['user_login']); $modelCreator->insertSuperUser(array( 'login' => $installData['user_login'], 'password' => core_kernel_users_Service::getPasswordHash()->encrypt($installData['user_pass1']), 'userLastName' => $installData['user_lastname'], 'userFirstName' => $installData['user_firstname'], 'userMail' => $installData['user_email'], 'userDefLg' => 'http://www.tao.lu/Ontologies/TAO.rdf#Lang'.$installData['module_lang'], 'userUILg' => 'http://www.tao.lu/Ontologies/TAO.rdf#Lang'.$installData['module_lang'], 'userTimezone' => TIME_ZONE )); /* * 10 - Secure the install for production mode */ if($installData['module_mode'] == 'production'){ $extensions = common_ext_ExtensionsManager::singleton()->getInstalledExtensions(); $this->log('i', 'Securing tao for production'); // 11.1 Remove Generis User $dbCreator->removeGenerisUser(); // 11.2 Protect TAO dist $shield = new tao_install_utils_Shield(array_keys($extensions)); $shield->disableRewritePattern(array("!/test/", "!/doc/")); $shield->denyAccessTo(array( 'views/sass', 'views/js/test', 'views/build' )); $shield->protectInstall(); } /* * 11 - Create the version file */ $this->log('d', 'Creating TAO version file'); file_put_contents($installData['file_path'].'version', TAO_VERSION); /* * 12 - Register Information about organization operating the system */ $this->log('t', 'Registering information about the organization operating the system'); $operatedByService = $this->getServiceManager()->get(OperatedByService::SERVICE_ID); if (!empty($installData['operated_by_name'])) { $operatedByService->setName($installData['operated_by_name']); } if (!empty($installData['operated_by_email'])) { $operatedByService->setEmail($installData['operated_by_email']); } $this->getServiceManager()->register(OperatedByService::SERVICE_ID, $operatedByService); } catch(Exception $e){ if ($this->retryInstallation($e)) { return; } // In any case, we transmit a single exception type (at the moment) // for a clearer API for client code. $this->log('e', 'Error Occurs : ' . $e->getMessage() . PHP_EOL . $e->getTraceAsString()); throw new tao_install_utils_Exception($e->getMessage(), 0, $e); } }
[ "public", "function", "install", "(", "array", "$", "installData", ")", "{", "try", "{", "/**\n * It's a quick hack for solving reinstall issue.\n * Should be a better option.\n */", "@", "unlink", "(", "$", "this", "->", "options", "[", "'...
Run the TAO install from the given data @throws tao_install_utils_Exception @param $installData data coming from the install form @see tao_install_form_Settings
[ "Run", "the", "TAO", "install", "from", "the", "given", "data" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/install/class.Installator.php#L82-L443
oat-sa/tao-core
install/class.Installator.php
tao_install_Installator.checkInstallData
public static function checkInstallData(array $installData){ // instance name if (empty($installData['instance_name'])){ $msg = "Missing install parameter 'instance_name'."; throw new tao_install_utils_MalformedParameterException($msg); } else if (!is_string($installData['instance_name'])){ $msg = "Malformed install parameter 'instance_name'. It must be a string."; throw new tao_install_utils_MalformedParameterException($msg); } else if (1 === preg_match('/\s/u', $installData['instance_name'])){ $msg = "Malformed install parameter 'instance_name'. It cannot contain spacing characters (tab, backspace)."; throw new tao_install_utils_MalformedParameterException($msg); } }
php
public static function checkInstallData(array $installData){ // instance name if (empty($installData['instance_name'])){ $msg = "Missing install parameter 'instance_name'."; throw new tao_install_utils_MalformedParameterException($msg); } else if (!is_string($installData['instance_name'])){ $msg = "Malformed install parameter 'instance_name'. It must be a string."; throw new tao_install_utils_MalformedParameterException($msg); } else if (1 === preg_match('/\s/u', $installData['instance_name'])){ $msg = "Malformed install parameter 'instance_name'. It cannot contain spacing characters (tab, backspace)."; throw new tao_install_utils_MalformedParameterException($msg); } }
[ "public", "static", "function", "checkInstallData", "(", "array", "$", "installData", ")", "{", "// instance name", "if", "(", "empty", "(", "$", "installData", "[", "'instance_name'", "]", ")", ")", "{", "$", "msg", "=", "\"Missing install parameter 'instance_nam...
Check the install data information such as - instance name - database driver - ... If a parameter of the $installData is not valid regarding the install business rules, an MalformedInstall @param array $installData
[ "Check", "the", "install", "data", "information", "such", "as", "-", "instance", "name", "-", "database", "driver", "-", "..." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/install/class.Installator.php#L503-L517
oat-sa/tao-core
install/class.Installator.php
tao_install_Installator.escapeCheck
public function escapeCheck($id){ $checks = $this->getEscapedChecks(); array_push($checks, $id); $checks = array_unique($checks); $this->setEscapedChecks($checks); }
php
public function escapeCheck($id){ $checks = $this->getEscapedChecks(); array_push($checks, $id); $checks = array_unique($checks); $this->setEscapedChecks($checks); }
[ "public", "function", "escapeCheck", "(", "$", "id", ")", "{", "$", "checks", "=", "$", "this", "->", "getEscapedChecks", "(", ")", ";", "array_push", "(", "$", "checks", ",", "$", "id", ")", ";", "$", "checks", "=", "array_unique", "(", "$", "checks...
Tell the Installator instance to not take into account a Configuration Check with ID = $id. @param string $id The identifier of the check to escape.
[ "Tell", "the", "Installator", "instance", "to", "not", "take", "into", "account", "a", "Configuration", "Check", "with", "ID", "=", "$id", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/install/class.Installator.php#L525-L530
oat-sa/tao-core
install/class.Installator.php
tao_install_Installator.log
public function log($logLevel, $message, $tags = array()) { if (!is_array($tags)) { $tags = [$tags]; } if ($this->getLogger() instanceof \Psr\Log\LoggerInterface) { if ($logLevel === 'ext') { $this->logNotice('Installed extensions: ' . implode(', ', $message)); } else { $this->getLogger()->log( common_log_Logger2Psr::getPsrLevelFromCommon($logLevel), $message ); } } if (method_exists('common_Logger', $logLevel)) { call_user_func('common_Logger::' . $logLevel, $message, $tags); } if(is_array($message)){ $this->log[$logLevel] = (isset($this->log[$logLevel])) ? array_merge($this->log[$logLevel], $message) : $message; } else{ $this->log[$logLevel][] = $message; } }
php
public function log($logLevel, $message, $tags = array()) { if (!is_array($tags)) { $tags = [$tags]; } if ($this->getLogger() instanceof \Psr\Log\LoggerInterface) { if ($logLevel === 'ext') { $this->logNotice('Installed extensions: ' . implode(', ', $message)); } else { $this->getLogger()->log( common_log_Logger2Psr::getPsrLevelFromCommon($logLevel), $message ); } } if (method_exists('common_Logger', $logLevel)) { call_user_func('common_Logger::' . $logLevel, $message, $tags); } if(is_array($message)){ $this->log[$logLevel] = (isset($this->log[$logLevel])) ? array_merge($this->log[$logLevel], $message) : $message; } else{ $this->log[$logLevel][] = $message; } }
[ "public", "function", "log", "(", "$", "logLevel", ",", "$", "message", ",", "$", "tags", "=", "array", "(", ")", ")", "{", "if", "(", "!", "is_array", "(", "$", "tags", ")", ")", "{", "$", "tags", "=", "[", "$", "tags", "]", ";", "}", "if", ...
Log message and add it to $this->log array; @see common_Logger class @param string $logLevel <ul> <li>'w' - warning</li> <li>'t' - trace</li> <li>'d' - debug</li> <li>'i' - info</li> <li>'e' - error</li> <li>'f' - fatal</li> <li>'ext' - installed extensions</li> </ul> @param string $message @param array $tags
[ "Log", "message", "and", "add", "it", "to", "$this", "-", ">", "log", "array", ";" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/install/class.Installator.php#L577-L602
oat-sa/tao-core
models/classes/security/ActionProtector.php
ActionProtector.setFrameAncestorsHeader
public function setFrameAncestorsHeader() { /** @var SettingsStorage $settingsStorage */ $settingsStorage = $this->getServiceLocator()->get(SettingsStorage::SERVICE_ID); $whitelistedSources = $settingsStorage->get(CspHeaderSettingsInterface::CSP_HEADER_SETTING); if ($whitelistedSources === null) { $whitelistedSources = ["'none'"]; } // Wrap directives in quotes if (in_array($whitelistedSources, ['self', 'none'])) { $whitelistedSources = ["'" . $whitelistedSources . "'"]; } if ($whitelistedSources === 'list') { $whitelistedSources = json_decode($settingsStorage->get(CspHeaderSettingsInterface::CSP_HEADER_LIST), true); } if (!is_array($whitelistedSources)) { $whitelistedSources = [$whitelistedSources]; } header(sprintf( 'Content-Security-Policy: frame-ancestors %s', implode(' ', $whitelistedSources) )); }
php
public function setFrameAncestorsHeader() { /** @var SettingsStorage $settingsStorage */ $settingsStorage = $this->getServiceLocator()->get(SettingsStorage::SERVICE_ID); $whitelistedSources = $settingsStorage->get(CspHeaderSettingsInterface::CSP_HEADER_SETTING); if ($whitelistedSources === null) { $whitelistedSources = ["'none'"]; } // Wrap directives in quotes if (in_array($whitelistedSources, ['self', 'none'])) { $whitelistedSources = ["'" . $whitelistedSources . "'"]; } if ($whitelistedSources === 'list') { $whitelistedSources = json_decode($settingsStorage->get(CspHeaderSettingsInterface::CSP_HEADER_LIST), true); } if (!is_array($whitelistedSources)) { $whitelistedSources = [$whitelistedSources]; } header(sprintf( 'Content-Security-Policy: frame-ancestors %s', implode(' ', $whitelistedSources) )); }
[ "public", "function", "setFrameAncestorsHeader", "(", ")", "{", "/** @var SettingsStorage $settingsStorage */", "$", "settingsStorage", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "SettingsStorage", "::", "SERVICE_ID", ")", ";", "$", "wh...
Set the header that defines which sources are allowed to embed the pages. @return void
[ "Set", "the", "header", "that", "defines", "which", "sources", "are", "allowed", "to", "embed", "the", "pages", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/security/ActionProtector.php#L42-L69
oat-sa/tao-core
helpers/form/elements/class.GenerisAsyncFile.php
tao_helpers_form_elements_GenerisAsyncFile.setValue
public function setValue($value) { if ($value instanceof tao_helpers_form_data_UploadFileDescription){ // The file is being uploaded. $this->value = $value; } elseif (!is_null($value)) { // The file has already been uploaded $this->value = new tao_helpers_form_data_StoredFileDescription($value); } else{ // Empty file upload description, nothing was uploaded. $this->value = new tao_helpers_form_data_UploadFileDescription('', 0, '', ''); } }
php
public function setValue($value) { if ($value instanceof tao_helpers_form_data_UploadFileDescription){ // The file is being uploaded. $this->value = $value; } elseif (!is_null($value)) { // The file has already been uploaded $this->value = new tao_helpers_form_data_StoredFileDescription($value); } else{ // Empty file upload description, nothing was uploaded. $this->value = new tao_helpers_form_data_UploadFileDescription('', 0, '', ''); } }
[ "public", "function", "setValue", "(", "$", "value", ")", "{", "if", "(", "$", "value", "instanceof", "tao_helpers_form_data_UploadFileDescription", ")", "{", "// The file is being uploaded.", "$", "this", "->", "value", "=", "$", "value", ";", "}", "elseif", "(...
Short description of method setValue @access public @author Jerome Bogaerts, <jerome@taotesting.com> @param value @return mixed
[ "Short", "description", "of", "method", "setValue" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/elements/class.GenerisAsyncFile.php#L56-L71
oat-sa/tao-core
helpers/form/validators/class.PasswordStrength.php
tao_helpers_form_validators_PasswordStrength.evaluate
public function evaluate($values) { $returnValue = PasswordConstraintsService::singleton()->validate($values); if( !$returnValue && !$this->hasOption('message') ){ $this->setMessage(implode( ', ', PasswordConstraintsService::singleton()->getErrors())); } return (bool) $returnValue; }
php
public function evaluate($values) { $returnValue = PasswordConstraintsService::singleton()->validate($values); if( !$returnValue && !$this->hasOption('message') ){ $this->setMessage(implode( ', ', PasswordConstraintsService::singleton()->getErrors())); } return (bool) $returnValue; }
[ "public", "function", "evaluate", "(", "$", "values", ")", "{", "$", "returnValue", "=", "PasswordConstraintsService", "::", "singleton", "(", ")", "->", "validate", "(", "$", "values", ")", ";", "if", "(", "!", "$", "returnValue", "&&", "!", "$", "this"...
Short description of method evaluate @access public @param values @return boolean
[ "Short", "description", "of", "method", "evaluate" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/validators/class.PasswordStrength.php#L36-L45
oat-sa/tao-core
models/classes/accessControl/func/FuncHelper.php
FuncHelper.getClassName
public static function getClassName($extension, $shortName) { $url = _url('index', $shortName, $extension); return self::getClassNameByUrl($url); }
php
public static function getClassName($extension, $shortName) { $url = _url('index', $shortName, $extension); return self::getClassNameByUrl($url); }
[ "public", "static", "function", "getClassName", "(", "$", "extension", ",", "$", "shortName", ")", "{", "$", "url", "=", "_url", "(", "'index'", ",", "$", "shortName", ",", "$", "extension", ")", ";", "return", "self", "::", "getClassNameByUrl", "(", "$"...
Get the controller className from extension and controller shortname @param string $extension @param string $shortname @return string the full class name (as defined in PHP) @throws \ResolverException::
[ "Get", "the", "controller", "className", "from", "extension", "and", "controller", "shortname" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/accessControl/func/FuncHelper.php#L40-L43
oat-sa/tao-core
models/classes/accessControl/func/FuncHelper.php
FuncHelper.getClassNameByUrl
public static function getClassNameByUrl($url){ $class = null; if(!empty($url)){ try{ $route = new Resolver(new common_http_Request($url)); $route->setServiceLocator(ServiceManager::getServiceManager()); $class = $route->getControllerClass(); } catch(\ResolverException $re){ throw new common_exception_Error('The url "'.$url.'" could not be mapped to a controller : ' . $re->getMessage()); } } if (is_null($class)) { throw new common_exception_Error('The url "'.$url.'" could not be mapped to a controller'); } return $class; }
php
public static function getClassNameByUrl($url){ $class = null; if(!empty($url)){ try{ $route = new Resolver(new common_http_Request($url)); $route->setServiceLocator(ServiceManager::getServiceManager()); $class = $route->getControllerClass(); } catch(\ResolverException $re){ throw new common_exception_Error('The url "'.$url.'" could not be mapped to a controller : ' . $re->getMessage()); } } if (is_null($class)) { throw new common_exception_Error('The url "'.$url.'" could not be mapped to a controller'); } return $class; }
[ "public", "static", "function", "getClassNameByUrl", "(", "$", "url", ")", "{", "$", "class", "=", "null", ";", "if", "(", "!", "empty", "(", "$", "url", ")", ")", "{", "try", "{", "$", "route", "=", "new", "Resolver", "(", "new", "common_http_Reques...
Helps you to get the name of the class for a given URL. The controller class name is used in privileges definition. @param string $url @throws \ResolverException @return string the className
[ "Helps", "you", "to", "get", "the", "name", "of", "the", "class", "for", "a", "given", "URL", ".", "The", "controller", "class", "name", "is", "used", "in", "privileges", "definition", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/accessControl/func/FuncHelper.php#L51-L66
oat-sa/tao-core
models/classes/session/restSessionFactory/builder/HttpBasicAuthBuilder.php
HttpBasicAuthBuilder.getSession
public function getSession(\common_http_Request $request) { $authAdapter = new \tao_models_classes_HttpBasicAuthAdapter($request); $user = $authAdapter->authenticate(); return new \common_session_RestSession($user); }
php
public function getSession(\common_http_Request $request) { $authAdapter = new \tao_models_classes_HttpBasicAuthAdapter($request); $user = $authAdapter->authenticate(); return new \common_session_RestSession($user); }
[ "public", "function", "getSession", "(", "\\", "common_http_Request", "$", "request", ")", "{", "$", "authAdapter", "=", "new", "\\", "tao_models_classes_HttpBasicAuthAdapter", "(", "$", "request", ")", ";", "$", "user", "=", "$", "authAdapter", "->", "authentic...
Create a rest session based on request credentials @param \common_http_Request $request @return \common_session_RestSession|\common_session_Session @throws LoginFailedException
[ "Create", "a", "rest", "session", "based", "on", "request", "credentials" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/session/restSessionFactory/builder/HttpBasicAuthBuilder.php#L46-L51
oat-sa/tao-core
models/classes/mvc/DefaultUrlService.php
DefaultUrlService.getRoute
public function getRoute($name) { if (! $this->hasOption($name)) { throw new \common_Exception('Route ' . $name . ' not found into UrlService config'); } return $this->getOption($name); }
php
public function getRoute($name) { if (! $this->hasOption($name)) { throw new \common_Exception('Route ' . $name . ' not found into UrlService config'); } return $this->getOption($name); }
[ "public", "function", "getRoute", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "hasOption", "(", "$", "name", ")", ")", "{", "throw", "new", "\\", "common_Exception", "(", "'Route '", ".", "$", "name", ".", "' not found into UrlService ...
Get the config associated to given $name @param $name @return mixed @throws \common_Exception
[ "Get", "the", "config", "associated", "to", "given", "$name" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/mvc/DefaultUrlService.php#L73-L79
oat-sa/tao-core
helpers/form/validators/class.Numeric.php
tao_helpers_form_validators_Numeric.evaluate
public function evaluate($values) { $returnValue = (bool) false; $rowValue = $values; $value = tao_helpers_Numeric::parseFloat($rowValue); if (empty($rowValue)) { $returnValue = true; // no need to go further. To check if not empty, use the NotEmpty validator return $returnValue; } if (! is_numeric($rowValue) || $value != $rowValue) { $this->setMessage(__('The value of this field must be numeric')); $returnValue = false; } else { if ($this->hasOption('min') || $this->hasOption('max')) { if ($this->hasOption('min') && $this->hasOption('max')) { if ($this->getOption('min') <= $value && $value <= $this->getOption('max')) { $returnValue = true; } else { $this->setMessage(__('Invalid field range (minimum value: %1$s, maximum value: %2$s)', $this->getOption('min'), $this->getOption('max'))); } } elseif ($this->hasOption('min') && ! $this->hasOption('max')) { if ($this->getOption('min') <= $value) { $returnValue = true; } else { $this->setMessage(__('Invalid field range (minimum value: %s)',$this->getOption('min'))); } } elseif (! $this->hasOption('min') && $this->hasOption('max')) { if ($value <= $this->getOption('max')) { $returnValue = true; } else { $this->setMessage(__('Invalid field range (maximum value: %s)', $this->getOption('max'))); } } } else { $returnValue = true; } } // Test less, greater, equal to another if ($returnValue && $this->hasOption('integer2_ref') && $this->getOption('integer2_ref') instanceof tao_helpers_form_FormElement) { $secondElement = $this->getOption('integer2_ref'); switch ($this->getOption('comparator')) { case '>': case 'sup': if ($value > $secondElement->getRawValue()) { $returnValue = true; } else { $returnValue = false; } break; case '<': case 'inf': if ($value < $secondElement->getRawValue()) { $returnValue = true; } else { $returnValue = false; } break; case '=': case 'equal': if ($value == $secondElement->getRawValue()) { $returnValue = true; } else { $returnValue = false; } break; } } return (bool) $returnValue; }
php
public function evaluate($values) { $returnValue = (bool) false; $rowValue = $values; $value = tao_helpers_Numeric::parseFloat($rowValue); if (empty($rowValue)) { $returnValue = true; // no need to go further. To check if not empty, use the NotEmpty validator return $returnValue; } if (! is_numeric($rowValue) || $value != $rowValue) { $this->setMessage(__('The value of this field must be numeric')); $returnValue = false; } else { if ($this->hasOption('min') || $this->hasOption('max')) { if ($this->hasOption('min') && $this->hasOption('max')) { if ($this->getOption('min') <= $value && $value <= $this->getOption('max')) { $returnValue = true; } else { $this->setMessage(__('Invalid field range (minimum value: %1$s, maximum value: %2$s)', $this->getOption('min'), $this->getOption('max'))); } } elseif ($this->hasOption('min') && ! $this->hasOption('max')) { if ($this->getOption('min') <= $value) { $returnValue = true; } else { $this->setMessage(__('Invalid field range (minimum value: %s)',$this->getOption('min'))); } } elseif (! $this->hasOption('min') && $this->hasOption('max')) { if ($value <= $this->getOption('max')) { $returnValue = true; } else { $this->setMessage(__('Invalid field range (maximum value: %s)', $this->getOption('max'))); } } } else { $returnValue = true; } } // Test less, greater, equal to another if ($returnValue && $this->hasOption('integer2_ref') && $this->getOption('integer2_ref') instanceof tao_helpers_form_FormElement) { $secondElement = $this->getOption('integer2_ref'); switch ($this->getOption('comparator')) { case '>': case 'sup': if ($value > $secondElement->getRawValue()) { $returnValue = true; } else { $returnValue = false; } break; case '<': case 'inf': if ($value < $secondElement->getRawValue()) { $returnValue = true; } else { $returnValue = false; } break; case '=': case 'equal': if ($value == $secondElement->getRawValue()) { $returnValue = true; } else { $returnValue = false; } break; } } return (bool) $returnValue; }
[ "public", "function", "evaluate", "(", "$", "values", ")", "{", "$", "returnValue", "=", "(", "bool", ")", "false", ";", "$", "rowValue", "=", "$", "values", ";", "$", "value", "=", "tao_helpers_Numeric", "::", "parseFloat", "(", "$", "rowValue", ")", ...
Short description of method evaluate @access public @author Jehan Bihin, <jehan.bihin@tudor.lu> @param values @return boolean
[ "Short", "description", "of", "method", "evaluate" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/validators/class.Numeric.php#L41-L116
oat-sa/tao-core
helpers/translation/TranslationBundle.php
TranslationBundle.getSerial
public function getSerial(){ $ids = $this->extensions; sort($ids); return md5($this->langCode . '_' . implode('-', $ids)); }
php
public function getSerial(){ $ids = $this->extensions; sort($ids); return md5($this->langCode . '_' . implode('-', $ids)); }
[ "public", "function", "getSerial", "(", ")", "{", "$", "ids", "=", "$", "this", "->", "extensions", ";", "sort", "(", "$", "ids", ")", ";", "return", "md5", "(", "$", "this", "->", "langCode", ".", "'_'", ".", "implode", "(", "'-'", ",", "$", "id...
Get a deterministic identifier from bundle data: one id for same langCode and extensions @return string the identifier
[ "Get", "a", "deterministic", "identifier", "from", "bundle", "data", ":", "one", "id", "for", "same", "langCode", "and", "extensions" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/translation/TranslationBundle.php#L97-L101
oat-sa/tao-core
helpers/translation/TranslationBundle.php
TranslationBundle.generateTo
public function generateTo($directory){ $translations = array(); foreach($this->extensions as $extension){ $jsFilePath = $this->basePath . '/' . $extension . '/locales/' . $this->langCode . '/messages_po.js'; if(file_exists($jsFilePath)){ $translate = json_decode(file_get_contents($jsFilePath),false); if($translate != null){ $translations = array_merge($translations, (array)$translate); } } } //the bundle contains as well some translations $content = array( 'serial' => $this->getSerial(), 'date' => time(), 'translations' => $translations ); if (!empty($this->taoVersion)) { $content['version'] = $this->taoVersion; } if(is_dir($directory)){ if(!is_dir($directory. '/' . $this->langCode)){ mkdir($directory. '/' . $this->langCode); } $file = $directory. '/' . $this->langCode . '/messages.json'; if(@file_put_contents($file, json_encode($content))){ return $file; } } return false; }
php
public function generateTo($directory){ $translations = array(); foreach($this->extensions as $extension){ $jsFilePath = $this->basePath . '/' . $extension . '/locales/' . $this->langCode . '/messages_po.js'; if(file_exists($jsFilePath)){ $translate = json_decode(file_get_contents($jsFilePath),false); if($translate != null){ $translations = array_merge($translations, (array)$translate); } } } //the bundle contains as well some translations $content = array( 'serial' => $this->getSerial(), 'date' => time(), 'translations' => $translations ); if (!empty($this->taoVersion)) { $content['version'] = $this->taoVersion; } if(is_dir($directory)){ if(!is_dir($directory. '/' . $this->langCode)){ mkdir($directory. '/' . $this->langCode); } $file = $directory. '/' . $this->langCode . '/messages.json'; if(@file_put_contents($file, json_encode($content))){ return $file; } } return false; }
[ "public", "function", "generateTo", "(", "$", "directory", ")", "{", "$", "translations", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "extensions", "as", "$", "extension", ")", "{", "$", "jsFilePath", "=", "$", "this", "->", "basePa...
Generates the bundle to the given directory. It will create a json file, named with the langCode: {$directory}/{$langCode}.json @param string $directory the path @return string|false the path of the generated bundle or false
[ "Generates", "the", "bundle", "to", "the", "given", "directory", ".", "It", "will", "create", "a", "json", "file", "named", "with", "the", "langCode", ":", "{", "$directory", "}", "/", "{", "$langCode", "}", ".", "json" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/translation/TranslationBundle.php#L108-L141
oat-sa/tao-core
actions/class.RestController.php
tao_actions_RestController.getClassFromRequest
protected function getClassFromRequest(\core_kernel_classes_Class $rootClass) { $class = null; if ($this->hasRequestParameter(self::CLASS_URI_PARAM) && $this->hasRequestParameter(self::CLASS_LABEL_PARAM)) { throw new \common_exception_RestApi( self::CLASS_URI_PARAM . ' and ' . self::CLASS_LABEL_PARAM . ' parameters do not supposed to be used simultaneously.' ); } if (!$this->hasRequestParameter(self::CLASS_URI_PARAM) && !$this->hasRequestParameter(self::CLASS_LABEL_PARAM)) { $class = $rootClass; } if ($this->hasRequestParameter(self::CLASS_URI_PARAM)) { $classUriParam = $this->getRequestParameter(self::CLASS_URI_PARAM); if (!$classUriParam) { throw new \common_exception_RestApi( self::CLASS_URI_PARAM . ' is not valid.' ); } $class = $this->getClass($classUriParam); } if ($this->hasRequestParameter(self::CLASS_LABEL_PARAM)) { $label = $this->getRequestParameter(self::CLASS_LABEL_PARAM); foreach ($rootClass->getSubClasses(true) as $subClass) { if ($subClass->getLabel() === $label) { $class = $subClass; break; } } } if ($class === null || !$class->exists()) { throw new \common_exception_RestApi( 'Class does not exist. Please use valid '.self::CLASS_URI_PARAM . ' or '.self::CLASS_LABEL_PARAM ); } return $class; }
php
protected function getClassFromRequest(\core_kernel_classes_Class $rootClass) { $class = null; if ($this->hasRequestParameter(self::CLASS_URI_PARAM) && $this->hasRequestParameter(self::CLASS_LABEL_PARAM)) { throw new \common_exception_RestApi( self::CLASS_URI_PARAM . ' and ' . self::CLASS_LABEL_PARAM . ' parameters do not supposed to be used simultaneously.' ); } if (!$this->hasRequestParameter(self::CLASS_URI_PARAM) && !$this->hasRequestParameter(self::CLASS_LABEL_PARAM)) { $class = $rootClass; } if ($this->hasRequestParameter(self::CLASS_URI_PARAM)) { $classUriParam = $this->getRequestParameter(self::CLASS_URI_PARAM); if (!$classUriParam) { throw new \common_exception_RestApi( self::CLASS_URI_PARAM . ' is not valid.' ); } $class = $this->getClass($classUriParam); } if ($this->hasRequestParameter(self::CLASS_LABEL_PARAM)) { $label = $this->getRequestParameter(self::CLASS_LABEL_PARAM); foreach ($rootClass->getSubClasses(true) as $subClass) { if ($subClass->getLabel() === $label) { $class = $subClass; break; } } } if ($class === null || !$class->exists()) { throw new \common_exception_RestApi( 'Class does not exist. Please use valid '.self::CLASS_URI_PARAM . ' or '.self::CLASS_LABEL_PARAM ); } return $class; }
[ "protected", "function", "getClassFromRequest", "(", "\\", "core_kernel_classes_Class", "$", "rootClass", ")", "{", "$", "class", "=", "null", ";", "if", "(", "$", "this", "->", "hasRequestParameter", "(", "self", "::", "CLASS_URI_PARAM", ")", "&&", "$", "this...
@OA\Schema( schema="tao.GenerisClass.Search", type="object", @OA\Property( property="class-uri", type="string", description="Target class uri" ), @OA\Property( property="class-label", type="string", description="Target class label. If label is not unique first match will be used" ) ) Get class instance from request parameters If more than one class with given label exists the first open will be picked up. @param core_kernel_classes_Class $rootClass @return core_kernel_classes_Class|null @throws common_exception_RestApi
[ "@OA", "\\", "Schema", "(", "schema", "=", "tao", ".", "GenerisClass", ".", "Search", "type", "=", "object", "@OA", "\\", "Property", "(", "property", "=", "class", "-", "uri", "type", "=", "string", "description", "=", "Target", "class", "uri", ")", "...
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.RestController.php#L75-L112
oat-sa/tao-core
actions/class.RestController.php
tao_actions_RestController.createSubClass
protected function createSubClass(\core_kernel_classes_Class $rootClass) { if (!$this->hasRequestParameter(static::CLASS_LABEL_PARAM)) { throw new \common_exception_RestApi('Missed required parameter: ' . static::CLASS_LABEL_PARAM); } $label = $this->getRequestParameter(static::CLASS_LABEL_PARAM); if ($this->hasRequestParameter(static::PARENT_CLASS_URI_PARAM)) { $parentClass = $this->getClass($this->getRequestParameter(static::PARENT_CLASS_URI_PARAM)); if ($parentClass->getUri() !== $rootClass->getUri() && !$parentClass->isSubClassOf($rootClass)) { throw new \common_Exception(__('Class uri provided is not a valid class.')); } $rootClass = $parentClass; } $comment = $this->hasRequestParameter(static::CLASS_COMMENT_PARAM) ? $this->getRequestParameter(static::CLASS_COMMENT_PARAM) : ''; $class = null; /** @var \core_kernel_classes_Class $subClass */ foreach ($rootClass->getSubClasses() as $subClass) { if ($subClass->getLabel() === $label) { throw new \common_exception_ClassAlreadyExists($subClass); } } if (!$class) { $class = $rootClass->createSubClass($label, $comment); } return $class; }
php
protected function createSubClass(\core_kernel_classes_Class $rootClass) { if (!$this->hasRequestParameter(static::CLASS_LABEL_PARAM)) { throw new \common_exception_RestApi('Missed required parameter: ' . static::CLASS_LABEL_PARAM); } $label = $this->getRequestParameter(static::CLASS_LABEL_PARAM); if ($this->hasRequestParameter(static::PARENT_CLASS_URI_PARAM)) { $parentClass = $this->getClass($this->getRequestParameter(static::PARENT_CLASS_URI_PARAM)); if ($parentClass->getUri() !== $rootClass->getUri() && !$parentClass->isSubClassOf($rootClass)) { throw new \common_Exception(__('Class uri provided is not a valid class.')); } $rootClass = $parentClass; } $comment = $this->hasRequestParameter(static::CLASS_COMMENT_PARAM) ? $this->getRequestParameter(static::CLASS_COMMENT_PARAM) : ''; $class = null; /** @var \core_kernel_classes_Class $subClass */ foreach ($rootClass->getSubClasses() as $subClass) { if ($subClass->getLabel() === $label) { throw new \common_exception_ClassAlreadyExists($subClass); } } if (!$class) { $class = $rootClass->createSubClass($label, $comment); } return $class; }
[ "protected", "function", "createSubClass", "(", "\\", "core_kernel_classes_Class", "$", "rootClass", ")", "{", "if", "(", "!", "$", "this", "->", "hasRequestParameter", "(", "static", "::", "CLASS_LABEL_PARAM", ")", ")", "{", "throw", "new", "\\", "common_except...
@OA\Schema( schema="tao.GenerisClass.New", type="object", @OA\Property( property="class-label", type="string", description="Class label" ), @OA\Property( property="class-comment", type="string", description="Class comment" ), @OA\Property( property="parent-class-uri", type="string", description="Parent class uri, root class by default" ) ) Create sub class of given root class. @param core_kernel_classes_Class $rootClass @throws \common_Exception @throws \common_exception_InconsistentData @throws \common_exception_ClassAlreadyExists @return \core_kernel_classes_Class
[ "@OA", "\\", "Schema", "(", "schema", "=", "tao", ".", "GenerisClass", ".", "New", "type", "=", "object", "@OA", "\\", "Property", "(", "property", "=", "class", "-", "label", "type", "=", "string", "description", "=", "Class", "label", ")", "@OA", "\\...
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.RestController.php#L143-L176
oat-sa/tao-core
helpers/form/class.GenerisFormFactory.php
tao_helpers_form_GenerisFormFactory.elementMap
public static function elementMap( core_kernel_classes_Property $property) { $returnValue = null; //create the element from the right widget $property->feed(); $widgetResource = $property->getWidget(); if (is_null($widgetResource)) { return null; } //authoring widget is not used in standalone mode if ($widgetResource->getUri() === 'http://www.tao.lu/datatypes/WidgetDefinitions.rdf#Authoring' && tao_helpers_Context::check('STANDALONE_MODE')) { return null; } // horrible hack to fix file widget if ($widgetResource->getUri() === 'http://www.tao.lu/datatypes/WidgetDefinitions.rdf#AsyncFile') { $widgetResource = new core_kernel_classes_Resource('http://www.tao.lu/datatypes/WidgetDefinitions.rdf#GenerisAsyncFile'); } $element = tao_helpers_form_FormFactory::getElementByWidget(tao_helpers_Uri::encode($property->getUri()), $widgetResource); if(!is_null($element)){ if($element->getWidget() !== $widgetResource->getUri()){ common_Logger::w('Widget definition differs from implementation: '.$element->getWidget().' != '.$widgetResource->getUri()); return null; } //use the property label as element description $propDesc = (strlen(trim($property->getLabel())) > 0) ? $property->getLabel() : str_replace(LOCAL_NAMESPACE, '', $property->getUri()); $element->setDescription($propDesc); //multi elements use the property range as options if(method_exists($element, 'setOptions')){ $range = $property->getRange(); if($range !== null){ $options = array(); if($element instanceof TreeAware){ $sortedOptions = $element->rangeToTree( $property->getUri() === OntologyRdfs::RDFS_RANGE ? new core_kernel_classes_Class( OntologyRdfs::RDFS_RESOURCE ) : $range ); } else{ /** @var core_kernel_classes_Resource $rangeInstance */ foreach ($range->getInstances(true) as $rangeInstance) { $level = $rangeInstance->getOnePropertyValue(new core_kernel_classes_Property(TaoOntology::PROPERTY_LIST_LEVEL)); if (is_null($level)) { $options[tao_helpers_Uri::encode($rangeInstance->getUri())] = array(tao_helpers_Uri::encode($rangeInstance->getUri()), $rangeInstance->getLabel()); } else { $level = ($level instanceof core_kernel_classes_Resource) ? $level->getUri() : (string)$level; $options[$level] = array(tao_helpers_Uri::encode($rangeInstance->getUri()), $rangeInstance->getLabel()); } } ksort($options); $sortedOptions = array(); foreach ($options as $id => $values) { $sortedOptions[$values[0]] = $values[1]; } //set the default value to an empty space if(method_exists($element, 'setEmptyOption')){ $element->setEmptyOption(' '); } } //complete the options listing $element->setOptions($sortedOptions); } } foreach (ValidationRuleRegistry::getRegistry()->getValidators($property) as $validator) { $element->addValidator($validator); } $returnValue = $element; } return $returnValue; }
php
public static function elementMap( core_kernel_classes_Property $property) { $returnValue = null; //create the element from the right widget $property->feed(); $widgetResource = $property->getWidget(); if (is_null($widgetResource)) { return null; } //authoring widget is not used in standalone mode if ($widgetResource->getUri() === 'http://www.tao.lu/datatypes/WidgetDefinitions.rdf#Authoring' && tao_helpers_Context::check('STANDALONE_MODE')) { return null; } // horrible hack to fix file widget if ($widgetResource->getUri() === 'http://www.tao.lu/datatypes/WidgetDefinitions.rdf#AsyncFile') { $widgetResource = new core_kernel_classes_Resource('http://www.tao.lu/datatypes/WidgetDefinitions.rdf#GenerisAsyncFile'); } $element = tao_helpers_form_FormFactory::getElementByWidget(tao_helpers_Uri::encode($property->getUri()), $widgetResource); if(!is_null($element)){ if($element->getWidget() !== $widgetResource->getUri()){ common_Logger::w('Widget definition differs from implementation: '.$element->getWidget().' != '.$widgetResource->getUri()); return null; } //use the property label as element description $propDesc = (strlen(trim($property->getLabel())) > 0) ? $property->getLabel() : str_replace(LOCAL_NAMESPACE, '', $property->getUri()); $element->setDescription($propDesc); //multi elements use the property range as options if(method_exists($element, 'setOptions')){ $range = $property->getRange(); if($range !== null){ $options = array(); if($element instanceof TreeAware){ $sortedOptions = $element->rangeToTree( $property->getUri() === OntologyRdfs::RDFS_RANGE ? new core_kernel_classes_Class( OntologyRdfs::RDFS_RESOURCE ) : $range ); } else{ /** @var core_kernel_classes_Resource $rangeInstance */ foreach ($range->getInstances(true) as $rangeInstance) { $level = $rangeInstance->getOnePropertyValue(new core_kernel_classes_Property(TaoOntology::PROPERTY_LIST_LEVEL)); if (is_null($level)) { $options[tao_helpers_Uri::encode($rangeInstance->getUri())] = array(tao_helpers_Uri::encode($rangeInstance->getUri()), $rangeInstance->getLabel()); } else { $level = ($level instanceof core_kernel_classes_Resource) ? $level->getUri() : (string)$level; $options[$level] = array(tao_helpers_Uri::encode($rangeInstance->getUri()), $rangeInstance->getLabel()); } } ksort($options); $sortedOptions = array(); foreach ($options as $id => $values) { $sortedOptions[$values[0]] = $values[1]; } //set the default value to an empty space if(method_exists($element, 'setEmptyOption')){ $element->setEmptyOption(' '); } } //complete the options listing $element->setOptions($sortedOptions); } } foreach (ValidationRuleRegistry::getRegistry()->getValidators($property) as $validator) { $element->addValidator($validator); } $returnValue = $element; } return $returnValue; }
[ "public", "static", "function", "elementMap", "(", "core_kernel_classes_Property", "$", "property", ")", "{", "$", "returnValue", "=", "null", ";", "//create the element from the right widget", "$", "property", "->", "feed", "(", ")", ";", "$", "widgetResource", "="...
Enable you to map an rdf property to a form element using the Widget @access public @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> @param core_kernel_classes_Property $property @return tao_helpers_form_FormElement
[ "Enable", "you", "to", "map", "an", "rdf", "property", "to", "a", "form", "element", "using", "the", "Widget" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/class.GenerisFormFactory.php#L61-L145
oat-sa/tao-core
helpers/form/class.GenerisFormFactory.php
tao_helpers_form_GenerisFormFactory.getClassProperties
public static function getClassProperties( core_kernel_classes_Class $clazz, core_kernel_classes_Class $topLevelClazz = null) { $returnValue = array(); if(is_null($topLevelClazz)){ $topLevelClazz = new core_kernel_classes_Class(TaoOntology::CLASS_URI_OBJECT ); } if($clazz->getUri() == $topLevelClazz->getUri()){ $returnValue = $clazz->getProperties(false); return (array) $returnValue; } //determine the parent path $parents = array(); $top = false; do{ if(!isset($lastLevelParents)){ $parentClasses = $clazz->getParentClasses(false); } else{ $parentClasses = array(); foreach($lastLevelParents as $parent){ $parentClasses = array_merge($parentClasses, $parent->getParentClasses(false)); } } if(count($parentClasses) == 0){ break; } $lastLevelParents = array(); foreach($parentClasses as $parentClass){ if($parentClass->getUri() == OntologyRdfs::RDFS_CLASS){ continue; } if($parentClass->getUri() == $topLevelClazz->getUri() ) { $parents[$parentClass->getUri()] = $parentClass; $top = true; break; } $allParentClasses = $parentClass->getParentClasses(true); if(array_key_exists($topLevelClazz->getUri(), $allParentClasses)){ $parents[$parentClass->getUri()] = $parentClass; } $lastLevelParents[$parentClass->getUri()] = $parentClass; } }while(!$top); foreach($parents as $parent){ $returnValue = array_merge($returnValue, $parent->getProperties(false)); } $returnValue = array_merge($returnValue, $clazz->getProperties(false)); return (array) $returnValue; }
php
public static function getClassProperties( core_kernel_classes_Class $clazz, core_kernel_classes_Class $topLevelClazz = null) { $returnValue = array(); if(is_null($topLevelClazz)){ $topLevelClazz = new core_kernel_classes_Class(TaoOntology::CLASS_URI_OBJECT ); } if($clazz->getUri() == $topLevelClazz->getUri()){ $returnValue = $clazz->getProperties(false); return (array) $returnValue; } //determine the parent path $parents = array(); $top = false; do{ if(!isset($lastLevelParents)){ $parentClasses = $clazz->getParentClasses(false); } else{ $parentClasses = array(); foreach($lastLevelParents as $parent){ $parentClasses = array_merge($parentClasses, $parent->getParentClasses(false)); } } if(count($parentClasses) == 0){ break; } $lastLevelParents = array(); foreach($parentClasses as $parentClass){ if($parentClass->getUri() == OntologyRdfs::RDFS_CLASS){ continue; } if($parentClass->getUri() == $topLevelClazz->getUri() ) { $parents[$parentClass->getUri()] = $parentClass; $top = true; break; } $allParentClasses = $parentClass->getParentClasses(true); if(array_key_exists($topLevelClazz->getUri(), $allParentClasses)){ $parents[$parentClass->getUri()] = $parentClass; } $lastLevelParents[$parentClass->getUri()] = $parentClass; } }while(!$top); foreach($parents as $parent){ $returnValue = array_merge($returnValue, $parent->getProperties(false)); } $returnValue = array_merge($returnValue, $clazz->getProperties(false)); return (array) $returnValue; }
[ "public", "static", "function", "getClassProperties", "(", "core_kernel_classes_Class", "$", "clazz", ",", "core_kernel_classes_Class", "$", "topLevelClazz", "=", "null", ")", "{", "$", "returnValue", "=", "array", "(", ")", ";", "if", "(", "is_null", "(", "$", ...
Enable you to get the properties of a class. The advantage of this method is to limit the level of recusrivity in the It get the properties up to the defined top class @access public @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> @param core_kernel_classes_Class $clazz @param core_kernel_classes_Class $topLevelClazz @return array
[ "Enable", "you", "to", "get", "the", "properties", "of", "a", "class", ".", "The", "advantage", "of", "this", "method", "is", "to", "limit", "the", "level", "of", "recusrivity", "in", "the", "It", "get", "the", "properties", "up", "to", "the", "defined",...
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/class.GenerisFormFactory.php#L158-L220
oat-sa/tao-core
helpers/form/class.GenerisFormFactory.php
tao_helpers_form_GenerisFormFactory.getPropertyProperties
public static function getPropertyProperties($mode = 'simple') { $returnValue = array(); switch($mode){ case 'simple': $defaultUris = array(GenerisRdf::PROPERTY_IS_LG_DEPENDENT); break; case 'advanced': default: $defaultUris = array( OntologyRdfs::RDFS_LABEL, WidgetRdf::PROPERTY_WIDGET, OntologyRdfs::RDFS_RANGE, GenerisRdf::PROPERTY_IS_LG_DEPENDENT ); break; } $resourceClass = new core_kernel_classes_Class(OntologyRdf::RDF_PROPERTY); foreach($resourceClass->getProperties() as $property){ if(in_array($property->getUri(), $defaultUris)){ array_push($returnValue, $property); } } return (array) $returnValue; }
php
public static function getPropertyProperties($mode = 'simple') { $returnValue = array(); switch($mode){ case 'simple': $defaultUris = array(GenerisRdf::PROPERTY_IS_LG_DEPENDENT); break; case 'advanced': default: $defaultUris = array( OntologyRdfs::RDFS_LABEL, WidgetRdf::PROPERTY_WIDGET, OntologyRdfs::RDFS_RANGE, GenerisRdf::PROPERTY_IS_LG_DEPENDENT ); break; } $resourceClass = new core_kernel_classes_Class(OntologyRdf::RDF_PROPERTY); foreach($resourceClass->getProperties() as $property){ if(in_array($property->getUri(), $defaultUris)){ array_push($returnValue, $property); } } return (array) $returnValue; }
[ "public", "static", "function", "getPropertyProperties", "(", "$", "mode", "=", "'simple'", ")", "{", "$", "returnValue", "=", "array", "(", ")", ";", "switch", "(", "$", "mode", ")", "{", "case", "'simple'", ":", "$", "defaultUris", "=", "array", "(", ...
Get the properties of the rdfs Property class @access public @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> @param string mode @return array
[ "Get", "the", "properties", "of", "the", "rdfs", "Property", "class" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/class.GenerisFormFactory.php#L252-L282
oat-sa/tao-core
helpers/form/class.GenerisFormFactory.php
tao_helpers_form_GenerisFormFactory.getPropertyMap
public static function getPropertyMap() { $returnValue = array( 'text' => array( 'title' => __('Text - Short - Field'), 'widget' => WidgetDefinitions::PROPERTY_TEXTBOX, 'range' => OntologyRdfs::RDFS_LITERAL, 'multiple' => GenerisRdf::GENERIS_FALSE ), 'longtext' => array( 'title' => __('Text - Long - Box'), 'widget' => WidgetDefinitions::PROPERTY_TEXTAREA, 'range' => OntologyRdfs::RDFS_LITERAL, 'multiple' => GenerisRdf::GENERIS_FALSE ), 'html' => array( 'title' => __('Text - Long - HTML editor'), 'widget' => WidgetDefinitions::PROPERTY_HTMLAREA, 'range' => OntologyRdfs::RDFS_LITERAL, 'multiple' => GenerisRdf::GENERIS_FALSE ), 'list' => array( 'title' => __('List - Single choice - Radio button'), 'widget' => WidgetDefinitions::PROPERTY_RADIOBOX, 'range' => OntologyRdfs::RDFS_RESOURCE, 'multiple' => GenerisRdf::GENERIS_FALSE ), 'multiplenodetree' => array( 'title' => __('Tree - Multiple node choice '), 'widget' => WidgetDefinitions::PROPERTY_TREEBOX, 'range' => OntologyRdfs::RDFS_RESOURCE, 'multiple' => GenerisRdf::GENERIS_TRUE ), 'longlist' => array( 'title' => __('List - Single choice - Drop down'), 'widget' => WidgetDefinitions::PROPERTY_COMBOBOX, 'range' => OntologyRdfs::RDFS_RESOURCE, 'multiple' => GenerisRdf::GENERIS_FALSE ), 'multilist' => array( 'title' => __('List - Multiple choice - Check box'), 'widget' => WidgetDefinitions::PROPERTY_CHECKBOX, 'range' => OntologyRdfs::RDFS_RESOURCE, 'multiple' => GenerisRdf::GENERIS_TRUE ), 'calendar' => array( 'title' => __('Calendar'), 'widget' => WidgetDefinitions::PROPERTY_CALENDAR, 'range' => OntologyRdfs::RDFS_LITERAL, 'multiple' => GenerisRdf::GENERIS_FALSE ), 'password' => array( 'title' => __('Password'), 'widget' => WidgetDefinitions::PROPERTY_HIDDENBOX, 'range' => OntologyRdfs::RDFS_LITERAL, 'multiple' => GenerisRdf::GENERIS_FALSE ), 'file' => array( 'title' => __('File'), 'widget' => WidgetDefinitions::PROPERTY_FILE, 'range' => GenerisRdf::CLASS_GENERIS_FILE, 'multiple' => GenerisRdf::GENERIS_FALSE ) ); return $returnValue; }
php
public static function getPropertyMap() { $returnValue = array( 'text' => array( 'title' => __('Text - Short - Field'), 'widget' => WidgetDefinitions::PROPERTY_TEXTBOX, 'range' => OntologyRdfs::RDFS_LITERAL, 'multiple' => GenerisRdf::GENERIS_FALSE ), 'longtext' => array( 'title' => __('Text - Long - Box'), 'widget' => WidgetDefinitions::PROPERTY_TEXTAREA, 'range' => OntologyRdfs::RDFS_LITERAL, 'multiple' => GenerisRdf::GENERIS_FALSE ), 'html' => array( 'title' => __('Text - Long - HTML editor'), 'widget' => WidgetDefinitions::PROPERTY_HTMLAREA, 'range' => OntologyRdfs::RDFS_LITERAL, 'multiple' => GenerisRdf::GENERIS_FALSE ), 'list' => array( 'title' => __('List - Single choice - Radio button'), 'widget' => WidgetDefinitions::PROPERTY_RADIOBOX, 'range' => OntologyRdfs::RDFS_RESOURCE, 'multiple' => GenerisRdf::GENERIS_FALSE ), 'multiplenodetree' => array( 'title' => __('Tree - Multiple node choice '), 'widget' => WidgetDefinitions::PROPERTY_TREEBOX, 'range' => OntologyRdfs::RDFS_RESOURCE, 'multiple' => GenerisRdf::GENERIS_TRUE ), 'longlist' => array( 'title' => __('List - Single choice - Drop down'), 'widget' => WidgetDefinitions::PROPERTY_COMBOBOX, 'range' => OntologyRdfs::RDFS_RESOURCE, 'multiple' => GenerisRdf::GENERIS_FALSE ), 'multilist' => array( 'title' => __('List - Multiple choice - Check box'), 'widget' => WidgetDefinitions::PROPERTY_CHECKBOX, 'range' => OntologyRdfs::RDFS_RESOURCE, 'multiple' => GenerisRdf::GENERIS_TRUE ), 'calendar' => array( 'title' => __('Calendar'), 'widget' => WidgetDefinitions::PROPERTY_CALENDAR, 'range' => OntologyRdfs::RDFS_LITERAL, 'multiple' => GenerisRdf::GENERIS_FALSE ), 'password' => array( 'title' => __('Password'), 'widget' => WidgetDefinitions::PROPERTY_HIDDENBOX, 'range' => OntologyRdfs::RDFS_LITERAL, 'multiple' => GenerisRdf::GENERIS_FALSE ), 'file' => array( 'title' => __('File'), 'widget' => WidgetDefinitions::PROPERTY_FILE, 'range' => GenerisRdf::CLASS_GENERIS_FILE, 'multiple' => GenerisRdf::GENERIS_FALSE ) ); return $returnValue; }
[ "public", "static", "function", "getPropertyMap", "(", ")", "{", "$", "returnValue", "=", "array", "(", "'text'", "=>", "array", "(", "'title'", "=>", "__", "(", "'Text - Short - Field'", ")", ",", "'widget'", "=>", "WidgetDefinitions", "::", "PROPERTY_TEXTBOX",...
Return the map between the Property properties: range, widget, etc. to shortcuts for the simplePropertyEditor @access public @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> @return array
[ "Return", "the", "map", "between", "the", "Property", "properties", ":", "range", "widget", "etc", ".", "to", "shortcuts", "for", "the", "simplePropertyEditor" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/class.GenerisFormFactory.php#L292-L361
oat-sa/tao-core
helpers/form/class.GenerisFormFactory.php
tao_helpers_form_GenerisFormFactory.extractTreeData
public static function extractTreeData($data, $recursive = false) { $returnValue = array(); if(isset($data['data'])){ $data = array($data); } foreach($data as $node){ $returnValue[$node['attributes']['id']] = $node['data']; if(isset($node['children'])){ $returnValue = array_merge($returnValue, self::extractTreeData($node['children'], true)); } } return (array) $returnValue; }
php
public static function extractTreeData($data, $recursive = false) { $returnValue = array(); if(isset($data['data'])){ $data = array($data); } foreach($data as $node){ $returnValue[$node['attributes']['id']] = $node['data']; if(isset($node['children'])){ $returnValue = array_merge($returnValue, self::extractTreeData($node['children'], true)); } } return (array) $returnValue; }
[ "public", "static", "function", "extractTreeData", "(", "$", "data", ",", "$", "recursive", "=", "false", ")", "{", "$", "returnValue", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "data", "[", "'data'", "]", ")", ")", "{", "$", "data...
Short description of method extractTreeData @access public @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> @param array $data @param boolean $recursive @return array
[ "Short", "description", "of", "method", "extractTreeData" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/class.GenerisFormFactory.php#L373-L393
oat-sa/tao-core
helpers/form/elements/class.Template.php
tao_helpers_form_elements_Template.getPrefix
public function getPrefix() { $returnValue = (string) ''; //prevent to use empty prefix. By default the name is used! if(empty($this->prefix) && !empty($this->name)){ $this->prefix = $this->name . '_'; } $returnValue = $this->prefix; return (string) $returnValue; }
php
public function getPrefix() { $returnValue = (string) ''; //prevent to use empty prefix. By default the name is used! if(empty($this->prefix) && !empty($this->name)){ $this->prefix = $this->name . '_'; } $returnValue = $this->prefix; return (string) $returnValue; }
[ "public", "function", "getPrefix", "(", ")", "{", "$", "returnValue", "=", "(", "string", ")", "''", ";", "//prevent to use empty prefix. By default the name is used!", "if", "(", "empty", "(", "$", "this", "->", "prefix", ")", "&&", "!", "empty", "(", "$", ...
Short description of method getPrefix @access public @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> @return string
[ "Short", "description", "of", "method", "getPrefix" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/elements/class.Template.php#L136-L152
oat-sa/tao-core
actions/class.TaskQueue.php
tao_actions_TaskQueue.get
public function get() { try { if (!$this->hasRequestParameter(self::TASK_ID_PARAM)) { throw new \common_exception_MissingParameter(self::TASK_ID_PARAM, $this->getRequestURI()); } $taskId = $this->getRequestParameter(self::TASK_ID_PARAM); /** @var TaskLogInterface $taskLog */ $taskLog = $this->getServiceLocator()->get(TaskLogInterface::SERVICE_ID); $filter = (new TaskLogFilter()) ->eq(TaskLogBrokerInterface::COLUMN_ID, $taskId); // trying to get data from the new task queue first $collection = $taskLog->search($filter); if ($collection->isEmpty()) { // if we don't have the task in the new queue, // loading the data from the old one $data = $this->getTaskData($taskId); } else { // we have the task in the new queue $entity = $collection->first(); $status = (string) $entity->getStatus(); if ($entity->getStatus()->isInProgress()) { $status = \oat\oatbox\task\Task::STATUS_RUNNING; } elseif ($entity->getStatus()->isCompleted() || $entity->getStatus()->isFailed()) { $status = \oat\oatbox\task\Task::STATUS_FINISHED; } $data['id'] = $entity->getId(); $data['status'] = $status; //convert to array for xml response. $data['report'] = json_decode(json_encode($entity->getReport())); } $this->returnSuccess($data); } catch (\Exception $e) { $this->returnFailure($e); } }
php
public function get() { try { if (!$this->hasRequestParameter(self::TASK_ID_PARAM)) { throw new \common_exception_MissingParameter(self::TASK_ID_PARAM, $this->getRequestURI()); } $taskId = $this->getRequestParameter(self::TASK_ID_PARAM); /** @var TaskLogInterface $taskLog */ $taskLog = $this->getServiceLocator()->get(TaskLogInterface::SERVICE_ID); $filter = (new TaskLogFilter()) ->eq(TaskLogBrokerInterface::COLUMN_ID, $taskId); // trying to get data from the new task queue first $collection = $taskLog->search($filter); if ($collection->isEmpty()) { // if we don't have the task in the new queue, // loading the data from the old one $data = $this->getTaskData($taskId); } else { // we have the task in the new queue $entity = $collection->first(); $status = (string) $entity->getStatus(); if ($entity->getStatus()->isInProgress()) { $status = \oat\oatbox\task\Task::STATUS_RUNNING; } elseif ($entity->getStatus()->isCompleted() || $entity->getStatus()->isFailed()) { $status = \oat\oatbox\task\Task::STATUS_FINISHED; } $data['id'] = $entity->getId(); $data['status'] = $status; //convert to array for xml response. $data['report'] = json_decode(json_encode($entity->getReport())); } $this->returnSuccess($data); } catch (\Exception $e) { $this->returnFailure($e); } }
[ "public", "function", "get", "(", ")", "{", "try", "{", "if", "(", "!", "$", "this", "->", "hasRequestParameter", "(", "self", "::", "TASK_ID_PARAM", ")", ")", "{", "throw", "new", "\\", "common_exception_MissingParameter", "(", "self", "::", "TASK_ID_PARAM"...
Get task data by identifier
[ "Get", "task", "data", "by", "identifier" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.TaskQueue.php#L44-L87
oat-sa/tao-core
actions/class.TaskQueue.php
tao_actions_TaskQueue.getStatus
public function getStatus() { try { if (!$this->hasRequestParameter(self::TASK_ID_PARAM)) { throw new \common_exception_MissingParameter(self::TASK_ID_PARAM, $this->getRequestURI()); } /** @var TaskLogInterface $taskLogService */ $taskLogService = $this->getServiceLocator()->get(TaskLogInterface::SERVICE_ID); $entity = $taskLogService->getById((string) $this->getRequestParameter(self::TASK_ID_PARAM)); $this->returnSuccess((string) $entity->getStatus()); } catch (\Exception $e) { $this->returnFailure($e); } }
php
public function getStatus() { try { if (!$this->hasRequestParameter(self::TASK_ID_PARAM)) { throw new \common_exception_MissingParameter(self::TASK_ID_PARAM, $this->getRequestURI()); } /** @var TaskLogInterface $taskLogService */ $taskLogService = $this->getServiceLocator()->get(TaskLogInterface::SERVICE_ID); $entity = $taskLogService->getById((string) $this->getRequestParameter(self::TASK_ID_PARAM)); $this->returnSuccess((string) $entity->getStatus()); } catch (\Exception $e) { $this->returnFailure($e); } }
[ "public", "function", "getStatus", "(", ")", "{", "try", "{", "if", "(", "!", "$", "this", "->", "hasRequestParameter", "(", "self", "::", "TASK_ID_PARAM", ")", ")", "{", "throw", "new", "\\", "common_exception_MissingParameter", "(", "self", "::", "TASK_ID_...
Returns only the status of a task, independently from the owner. NOTE: only works for tasks handled by the new task queue.
[ "Returns", "only", "the", "status", "of", "a", "task", "independently", "from", "the", "owner", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.TaskQueue.php#L129-L145
oat-sa/tao-core
helpers/Template.php
Template.img
public static function img($path, $extensionId = null) { if (is_null($extensionId)) { $extensionId = \Context::getInstance()->getExtensionName(); } return self::getAssetService()->getAsset('img/'.$path, $extensionId); }
php
public static function img($path, $extensionId = null) { if (is_null($extensionId)) { $extensionId = \Context::getInstance()->getExtensionName(); } return self::getAssetService()->getAsset('img/'.$path, $extensionId); }
[ "public", "static", "function", "img", "(", "$", "path", ",", "$", "extensionId", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "extensionId", ")", ")", "{", "$", "extensionId", "=", "\\", "Context", "::", "getInstance", "(", ")", "->", "get...
Expects a relative url to the image as path if extension name is omitted the current extension is used @param string $path @param string $extensionId @return string
[ "Expects", "a", "relative", "url", "to", "the", "image", "as", "path", "if", "extension", "name", "is", "omitted", "the", "current", "extension", "is", "used" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/Template.php#L37-L43
oat-sa/tao-core
helpers/Template.php
Template.inc
public static function inc($path, $extensionId = null, $data = array()) { $context = \Context::getInstance(); if (!is_null($extensionId) && $extensionId != $context->getExtensionName()) { // template is within different extension, change context $formerContext = $context->getExtensionName(); $context->setExtensionName($extensionId); } if(count($data) > 0){ \RenderContext::pushContext($data); } $absPath = self::getTemplate($path, $extensionId); if (file_exists($absPath)) { include($absPath); } else { \common_Logger::w('Failed to include "'.$absPath.'" in template'); } // restore context if (isset($formerContext)) { $context->setExtensionName($formerContext); } }
php
public static function inc($path, $extensionId = null, $data = array()) { $context = \Context::getInstance(); if (!is_null($extensionId) && $extensionId != $context->getExtensionName()) { // template is within different extension, change context $formerContext = $context->getExtensionName(); $context->setExtensionName($extensionId); } if(count($data) > 0){ \RenderContext::pushContext($data); } $absPath = self::getTemplate($path, $extensionId); if (file_exists($absPath)) { include($absPath); } else { \common_Logger::w('Failed to include "'.$absPath.'" in template'); } // restore context if (isset($formerContext)) { $context->setExtensionName($formerContext); } }
[ "public", "static", "function", "inc", "(", "$", "path", ",", "$", "extensionId", "=", "null", ",", "$", "data", "=", "array", "(", ")", ")", "{", "$", "context", "=", "\\", "Context", "::", "getInstance", "(", ")", ";", "if", "(", "!", "is_null", ...
Expects a relative url to the template that is to be included as path if extension name is omitted the current extension is used @param string $path @param string $extensionId @param array $data bind additional data to the context @return string
[ "Expects", "a", "relative", "url", "to", "the", "template", "that", "is", "to", "be", "included", "as", "path", "if", "extension", "name", "is", "omitted", "the", "current", "extension", "is", "used" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/Template.php#L84-L106
oat-sa/tao-core
helpers/class.Cli.php
tao_helpers_Cli.getBgColor
public static function getBgColor($name) { $returnValue = (string) ''; if(!empty($name) && array_key_exists($name, self::$colors['background'])){ $returnValue = self::$colors['background'][$name]; } return (string) $returnValue; }
php
public static function getBgColor($name) { $returnValue = (string) ''; if(!empty($name) && array_key_exists($name, self::$colors['background'])){ $returnValue = self::$colors['background'][$name]; } return (string) $returnValue; }
[ "public", "static", "function", "getBgColor", "(", "$", "name", ")", "{", "$", "returnValue", "=", "(", "string", ")", "''", ";", "if", "(", "!", "empty", "(", "$", "name", ")", "&&", "array_key_exists", "(", "$", "name", ",", "self", "::", "$", "c...
Get a background color compliant with the CLI. Available color names are: black, red, green, yellow, blue, magenta, cyan, light_gray. If the color name does not exist, an empty string is returned. @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> @param string name The name of the color. @return string The corresponding color code.
[ "Get", "a", "background", "color", "compliant", "with", "the", "CLI", ".", "Available", "color", "names", "are", ":", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "light_gray", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Cli.php#L103-L112
oat-sa/tao-core
helpers/class.Cli.php
tao_helpers_Cli.getFgColor
public static function getFgColor($name) { $returnValue = (string) ''; if(!empty($name) && array_key_exists($name, self::$colors['foreground'])){ $returnValue = self::$colors['foreground'][$name]; } return (string) $returnValue; }
php
public static function getFgColor($name) { $returnValue = (string) ''; if(!empty($name) && array_key_exists($name, self::$colors['foreground'])){ $returnValue = self::$colors['foreground'][$name]; } return (string) $returnValue; }
[ "public", "static", "function", "getFgColor", "(", "$", "name", ")", "{", "$", "returnValue", "=", "(", "string", ")", "''", ";", "if", "(", "!", "empty", "(", "$", "name", ")", "&&", "array_key_exists", "(", "$", "name", ",", "self", "::", "$", "c...
Get a foreground color compliant with the CLI. Available color names are: black, dark_gray, blue, light_blue, green, light_green, light_cyan, red, light_red, purple, brown, yellow, light_gray, white. If the provided color names is not supported, an empty string is returned. Otherwise, the corresponding color code is returned. @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> @param string name The color name. @return string A color code.
[ "Get", "a", "foreground", "color", "compliant", "with", "the", "CLI", ".", "Available", "color", "names", "are", ":", "black", "dark_gray", "blue", "light_blue", "green", "light_green", "light_cyan", "red", "light_red", "purple", "brown", "yellow", "light_gray", ...
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Cli.php#L126-L135
oat-sa/tao-core
models/classes/security/TokenGenerator.php
TokenGenerator.generate
protected function generate($length = 40) { try { return bin2hex(random_bytes($length / 2)); } catch (\TypeError $e) { // This is okay, so long as `Error` is caught before `Exception`. throw new \common_Exception("An unexpected error has occurred while trying to generate a security token", 0, $e); } catch (\Error $e) { // This is required, if you do not need to do anything just rethrow. throw new \common_Exception("An unexpected error has occurred while trying to generate a security token", 0, $e); } catch (\Exception $e) { throw new \common_Exception("Could not generate a security token. Is our OS secure?", 0, $e); } }
php
protected function generate($length = 40) { try { return bin2hex(random_bytes($length / 2)); } catch (\TypeError $e) { // This is okay, so long as `Error` is caught before `Exception`. throw new \common_Exception("An unexpected error has occurred while trying to generate a security token", 0, $e); } catch (\Error $e) { // This is required, if you do not need to do anything just rethrow. throw new \common_Exception("An unexpected error has occurred while trying to generate a security token", 0, $e); } catch (\Exception $e) { throw new \common_Exception("Could not generate a security token. Is our OS secure?", 0, $e); } }
[ "protected", "function", "generate", "(", "$", "length", "=", "40", ")", "{", "try", "{", "return", "bin2hex", "(", "random_bytes", "(", "$", "length", "/", "2", ")", ")", ";", "}", "catch", "(", "\\", "TypeError", "$", "e", ")", "{", "// This is oka...
Generates a security token @param int $length the expected token length @return string the token @throws \common_Exception
[ "Generates", "a", "security", "token" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/security/TokenGenerator.php#L36-L49
oat-sa/tao-core
models/classes/TaskQueueActionTrait.php
TaskQueueActionTrait.getTaskData
protected function getTaskData($taskId) { $task = $this->getTask($taskId); $result['id'] = $this->getTaskId($task); $result['status'] = $this->getTaskStatus($task); $result['report'] = $this->getTaskReport($task); return $result; }
php
protected function getTaskData($taskId) { $task = $this->getTask($taskId); $result['id'] = $this->getTaskId($task); $result['status'] = $this->getTaskStatus($task); $result['report'] = $this->getTaskReport($task); return $result; }
[ "protected", "function", "getTaskData", "(", "$", "taskId", ")", "{", "$", "task", "=", "$", "this", "->", "getTask", "(", "$", "taskId", ")", ";", "$", "result", "[", "'id'", "]", "=", "$", "this", "->", "getTaskId", "(", "$", "task", ")", ";", ...
Template method to generate task data to be returned to the end user. @param string $taskId @return array
[ "Template", "method", "to", "generate", "task", "data", "to", "be", "returned", "to", "the", "end", "user", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/TaskQueueActionTrait.php#L42-L50
oat-sa/tao-core
models/classes/TaskQueueActionTrait.php
TaskQueueActionTrait.getTask
protected function getTask($taskId) { if (!isset($this->tasks[$taskId])) { /** @var Queue $taskQueue */ $taskQueue = $this->getServiceManager()->get(Queue::SERVICE_ID); $task = $taskQueue->getTask($taskId); if ($task === null) { throw new \common_exception_NotFound(__('Task not found')); } $this->tasks[$taskId] = $task; } return $this->tasks[$taskId]; }
php
protected function getTask($taskId) { if (!isset($this->tasks[$taskId])) { /** @var Queue $taskQueue */ $taskQueue = $this->getServiceManager()->get(Queue::SERVICE_ID); $task = $taskQueue->getTask($taskId); if ($task === null) { throw new \common_exception_NotFound(__('Task not found')); } $this->tasks[$taskId] = $task; } return $this->tasks[$taskId]; }
[ "protected", "function", "getTask", "(", "$", "taskId", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "tasks", "[", "$", "taskId", "]", ")", ")", "{", "/** @var Queue $taskQueue */", "$", "taskQueue", "=", "$", "this", "->", "getServiceManag...
Get task instance from queue by identifier @param $taskId task identifier @throws \common_exception_NotFound @return Task
[ "Get", "task", "instance", "from", "queue", "by", "identifier" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/TaskQueueActionTrait.php#L58-L70
oat-sa/tao-core
models/classes/class.TaoService.php
tao_models_classes_TaoService.setUploadFileSourceId
public function setUploadFileSourceId($sourceId) { $ext = common_ext_ExtensionsManager::singleton()->getExtensionById('tao'); $ext->setConfig(self::CONFIG_UPLOAD_FILESOURCE, $sourceId); }
php
public function setUploadFileSourceId($sourceId) { $ext = common_ext_ExtensionsManager::singleton()->getExtensionById('tao'); $ext->setConfig(self::CONFIG_UPLOAD_FILESOURCE, $sourceId); }
[ "public", "function", "setUploadFileSourceId", "(", "$", "sourceId", ")", "{", "$", "ext", "=", "common_ext_ExtensionsManager", "::", "singleton", "(", ")", "->", "getExtensionById", "(", "'tao'", ")", ";", "$", "ext", "->", "setConfig", "(", "self", "::", "...
Set the default file source for TAO File Upload. @access public @author Jerome Bogaerts, <jerome@taotesting.com> @param string sourceId The repository to be used as the default TAO File Upload Source. @return void
[ "Set", "the", "default", "file", "source", "for", "TAO", "File", "Upload", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.TaoService.php#L56-L62
oat-sa/tao-core
models/classes/class.TaoService.php
tao_models_classes_TaoService.storeUploadedFile
public function storeUploadedFile(File $tmpFile, $name = '') { $ext = common_ext_ExtensionsManager::singleton()->getExtensionById('tao'); $fsId = $ext->getConfig(self::CONFIG_UPLOAD_FILESOURCE); $fss = $this->getServiceLocator()->get(FileSystemService::SERVICE_ID); $baseDir = $fss->getDirectory($fsId); do { $unique = uniqid(); $dir = implode('/',str_split(substr($unique, 0, 3))).'/'.substr($unique, 3); $file = $baseDir->getFile($dir.'/'.$name); } while ($file->exists()); $file->write($tmpFile->read()); $referencer = $this->getServiceLocator()->get(FileReferenceSerializer::SERVICE_ID); $serial = $referencer->serialize($file); return $serial; }
php
public function storeUploadedFile(File $tmpFile, $name = '') { $ext = common_ext_ExtensionsManager::singleton()->getExtensionById('tao'); $fsId = $ext->getConfig(self::CONFIG_UPLOAD_FILESOURCE); $fss = $this->getServiceLocator()->get(FileSystemService::SERVICE_ID); $baseDir = $fss->getDirectory($fsId); do { $unique = uniqid(); $dir = implode('/',str_split(substr($unique, 0, 3))).'/'.substr($unique, 3); $file = $baseDir->getFile($dir.'/'.$name); } while ($file->exists()); $file->write($tmpFile->read()); $referencer = $this->getServiceLocator()->get(FileReferenceSerializer::SERVICE_ID); $serial = $referencer->serialize($file); return $serial; }
[ "public", "function", "storeUploadedFile", "(", "File", "$", "tmpFile", ",", "$", "name", "=", "''", ")", "{", "$", "ext", "=", "common_ext_ExtensionsManager", "::", "singleton", "(", ")", "->", "getExtensionById", "(", "'tao'", ")", ";", "$", "fsId", "=",...
Store an uploaded file in the persistant storage and return a serial id @param File $tmpFile @param string $name @return string
[ "Store", "an", "uploaded", "file", "in", "the", "persistant", "storage", "and", "return", "a", "serial", "id" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.TaoService.php#L71-L86
oat-sa/tao-core
models/classes/cliArgument/argument/implementation/verbose/Verbose.php
Verbose.setOutputColorVisibility
protected function setOutputColorVisibility(array $params) { if ($this->hasParameter($params, '-nc') || $this->hasParameter($params, '--no-color')) { $this->hideColors = true; } }
php
protected function setOutputColorVisibility(array $params) { if ($this->hasParameter($params, '-nc') || $this->hasParameter($params, '--no-color')) { $this->hideColors = true; } }
[ "protected", "function", "setOutputColorVisibility", "(", "array", "$", "params", ")", "{", "if", "(", "$", "this", "->", "hasParameter", "(", "$", "params", ",", "'-nc'", ")", "||", "$", "this", "->", "hasParameter", "(", "$", "params", ",", "'--no-color'...
Sets the output color's visibility. @param array $params
[ "Sets", "the", "output", "color", "s", "visibility", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/cliArgument/argument/implementation/verbose/Verbose.php#L49-L54
oat-sa/tao-core
models/classes/cliArgument/argument/implementation/verbose/Verbose.php
Verbose.load
public function load(Action $action) { if ($action instanceof LoggerAwareInterface) { $action->setLogger( $this->getServiceLocator()->get(LoggerService::SERVICE_ID) ->addLogger( $this->hideColors ? new VerboseLogger($this->getMinimumLogLevel()) : new ColoredVerboseLogger($this->getMinimumLogLevel()) ) ); } }
php
public function load(Action $action) { if ($action instanceof LoggerAwareInterface) { $action->setLogger( $this->getServiceLocator()->get(LoggerService::SERVICE_ID) ->addLogger( $this->hideColors ? new VerboseLogger($this->getMinimumLogLevel()) : new ColoredVerboseLogger($this->getMinimumLogLevel()) ) ); } }
[ "public", "function", "load", "(", "Action", "$", "action", ")", "{", "if", "(", "$", "action", "instanceof", "LoggerAwareInterface", ")", "{", "$", "action", "->", "setLogger", "(", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "Lo...
Propagate the argument process to Action To load a verbose logger, a check is done Action interfaces to find LoggerInterface The verbose logger is loaded with the minimum level requires @param Action $action
[ "Propagate", "the", "argument", "process", "to", "Action", "To", "load", "a", "verbose", "logger", "a", "check", "is", "done", "Action", "interfaces", "to", "find", "LoggerInterface", "The", "verbose", "logger", "is", "loaded", "with", "the", "minimum", "level...
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/cliArgument/argument/implementation/verbose/Verbose.php#L70-L82
oat-sa/tao-core
models/classes/cliArgument/argument/implementation/verbose/Verbose.php
Verbose.hasParameter
protected function hasParameter(array $params, $name, $value = null) { $found = in_array($name, $params); if (is_null($value) || !$found) { return $found; } $paramValueIndex = array_search($name, $params) + 1; return isset($params[$paramValueIndex]) && ($params[$paramValueIndex] == $value); }
php
protected function hasParameter(array $params, $name, $value = null) { $found = in_array($name, $params); if (is_null($value) || !$found) { return $found; } $paramValueIndex = array_search($name, $params) + 1; return isset($params[$paramValueIndex]) && ($params[$paramValueIndex] == $value); }
[ "protected", "function", "hasParameter", "(", "array", "$", "params", ",", "$", "name", ",", "$", "value", "=", "null", ")", "{", "$", "found", "=", "in_array", "(", "$", "name", ",", "$", "params", ")", ";", "if", "(", "is_null", "(", "$", "value"...
Find a parameter $name into $params arguments If $value is defined, check if following parameter equals to given $value @param array $params @param $name @param null $value @return bool
[ "Find", "a", "parameter", "$name", "into", "$params", "arguments", "If", "$value", "is", "defined", "check", "if", "following", "parameter", "equals", "to", "given", "$value" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/cliArgument/argument/implementation/verbose/Verbose.php#L93-L101
oat-sa/tao-core
install/services/class.InstallService.php
tao_install_services_InstallService.execute
public function execute(){ $content = json_decode($this->getData()->getContent(), true); //instantiate the installator try{ set_error_handler(array(get_class($this), 'onError')); $container = new \Pimple\Container( array( \oat\oatbox\log\LoggerService::SERVICE_ID => new \oat\oatbox\log\LoggerService(), tao_install_Installator::CONTAINER_INDEX => array( 'root_path' => TAO_INSTALL_PATH, 'install_path' => dirname(__FILE__) . '/../../install', ) ) ); $installer = new tao_install_Installator($container); // For the moment, we force English as default language. $content['value']['module_lang'] = 'en-US'; // fallback until ui is ready if (!isset($content['value']['file_path'])) { $content['value']['file_path'] = TAO_INSTALL_PATH.'data'.DIRECTORY_SEPARATOR; } $installer->install($content['value']); $installationLog = $installer->getLog(); $message = (isset($installationLog['e']) || isset($installationLog['f']) || isset($installationLog['w'])) ? 'Installation complete (warnings occurred)' : 'Installation successful.'; $report = array( 'type' => 'InstallReport', 'value' => array( 'status' => 'valid', 'message' => $message, 'log' => $installationLog ) ); $this->setResult(new tao_install_services_Data(json_encode($report))); restore_error_handler(); } catch(Exception $e) { $report = array( 'type' => 'InstallReport', 'value' => array( 'status' => 'invalid', 'message' => $e->getMessage() . ' in ' . $e->getFile() . ' at line ' . $e->getLine(), 'log' => $installer->getLog() ) ); $this->setResult(new tao_install_services_Data(json_encode($report))); restore_error_handler(); } }
php
public function execute(){ $content = json_decode($this->getData()->getContent(), true); //instantiate the installator try{ set_error_handler(array(get_class($this), 'onError')); $container = new \Pimple\Container( array( \oat\oatbox\log\LoggerService::SERVICE_ID => new \oat\oatbox\log\LoggerService(), tao_install_Installator::CONTAINER_INDEX => array( 'root_path' => TAO_INSTALL_PATH, 'install_path' => dirname(__FILE__) . '/../../install', ) ) ); $installer = new tao_install_Installator($container); // For the moment, we force English as default language. $content['value']['module_lang'] = 'en-US'; // fallback until ui is ready if (!isset($content['value']['file_path'])) { $content['value']['file_path'] = TAO_INSTALL_PATH.'data'.DIRECTORY_SEPARATOR; } $installer->install($content['value']); $installationLog = $installer->getLog(); $message = (isset($installationLog['e']) || isset($installationLog['f']) || isset($installationLog['w'])) ? 'Installation complete (warnings occurred)' : 'Installation successful.'; $report = array( 'type' => 'InstallReport', 'value' => array( 'status' => 'valid', 'message' => $message, 'log' => $installationLog ) ); $this->setResult(new tao_install_services_Data(json_encode($report))); restore_error_handler(); } catch(Exception $e) { $report = array( 'type' => 'InstallReport', 'value' => array( 'status' => 'invalid', 'message' => $e->getMessage() . ' in ' . $e->getFile() . ' at line ' . $e->getLine(), 'log' => $installer->getLog() ) ); $this->setResult(new tao_install_services_Data(json_encode($report))); restore_error_handler(); } }
[ "public", "function", "execute", "(", ")", "{", "$", "content", "=", "json_decode", "(", "$", "this", "->", "getData", "(", ")", "->", "getContent", "(", ")", ",", "true", ")", ";", "//instantiate the installator\r", "try", "{", "set_error_handler", "(", "...
Executes the main logic of the service. @return tao_install_services_Data The result of the service execution.
[ "Executes", "the", "main", "logic", "of", "the", "service", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/install/services/class.InstallService.php#L48-L103
oat-sa/tao-core
models/classes/service/class.ServiceCall.php
tao_models_classes_service_ServiceCall.getRequiredVariables
public function getRequiredVariables() { $variables = array(); foreach ($this->inParameters as $param) { if ($param instanceof tao_models_classes_service_VariableParameter) { $variables[] = $param->getVariable(); } } return $variables; }
php
public function getRequiredVariables() { $variables = array(); foreach ($this->inParameters as $param) { if ($param instanceof tao_models_classes_service_VariableParameter) { $variables[] = $param->getVariable(); } } return $variables; }
[ "public", "function", "getRequiredVariables", "(", ")", "{", "$", "variables", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "inParameters", "as", "$", "param", ")", "{", "if", "(", "$", "param", "instanceof", "tao_models_classes_service_Va...
Gets the variables expected to be present to call this service @return array:
[ "Gets", "the", "variables", "expected", "to", "be", "present", "to", "call", "this", "service" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/service/class.ServiceCall.php#L107-L115
oat-sa/tao-core
models/classes/service/class.ServiceCall.php
tao_models_classes_service_ServiceCall.toOntology
public function toOntology() { $inResources = array(); $outResources = is_null($this->outParameter) ? array() : $this->outParameter->toOntology(); foreach ($this->inParameters as $param) { $inResources[] = $param->toOntology(); } $serviceCallClass = $this->getClass( WfEngineOntology::CLASS_URI_CALL_OF_SERVICES); $resource = $serviceCallClass->createInstanceWithProperties(array( OntologyRdfs::RDFS_LABEL => 'serviceCall', WfEngineOntology::PROPERTY_CALL_OF_SERVICES_SERVICE_DEFINITION => $this->serviceDefinitionId, WfEngineOntology::PROPERTY_CALL_OF_SERVICES_ACTUAL_PARAMETER_IN => $inResources, WfEngineOntology::PROPERTY_CALL_OF_SERVICES_ACTUAL_PARAMETER_OUT => $outResources, WfEngineOntology::PROPERTY_CALL_OF_SERVICES_WIDTH => '100', WfEngineOntology::PROPERTY_CALL_OF_SERVICES_HEIGHT => '100' )); return $resource; }
php
public function toOntology() { $inResources = array(); $outResources = is_null($this->outParameter) ? array() : $this->outParameter->toOntology(); foreach ($this->inParameters as $param) { $inResources[] = $param->toOntology(); } $serviceCallClass = $this->getClass( WfEngineOntology::CLASS_URI_CALL_OF_SERVICES); $resource = $serviceCallClass->createInstanceWithProperties(array( OntologyRdfs::RDFS_LABEL => 'serviceCall', WfEngineOntology::PROPERTY_CALL_OF_SERVICES_SERVICE_DEFINITION => $this->serviceDefinitionId, WfEngineOntology::PROPERTY_CALL_OF_SERVICES_ACTUAL_PARAMETER_IN => $inResources, WfEngineOntology::PROPERTY_CALL_OF_SERVICES_ACTUAL_PARAMETER_OUT => $outResources, WfEngineOntology::PROPERTY_CALL_OF_SERVICES_WIDTH => '100', WfEngineOntology::PROPERTY_CALL_OF_SERVICES_HEIGHT => '100' )); return $resource; }
[ "public", "function", "toOntology", "(", ")", "{", "$", "inResources", "=", "array", "(", ")", ";", "$", "outResources", "=", "is_null", "(", "$", "this", "->", "outParameter", ")", "?", "array", "(", ")", ":", "$", "this", "->", "outParameter", "->", ...
Stores a service call in the ontology @return core_kernel_classes_Resource
[ "Stores", "a", "service", "call", "in", "the", "ontology" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/service/class.ServiceCall.php#L122-L141
oat-sa/tao-core
models/classes/service/class.ServiceCall.php
tao_models_classes_service_ServiceCall.fromResource
public static function fromResource(core_kernel_classes_Resource $resource) { $values = $resource->getPropertiesValues(array( WfEngineOntology::PROPERTY_CALL_OF_SERVICES_SERVICE_DEFINITION, WfEngineOntology::PROPERTY_CALL_OF_SERVICES_ACTUAL_PARAMETER_IN, WfEngineOntology::PROPERTY_CALL_OF_SERVICES_ACTUAL_PARAMETER_OUT )); $serviceDefUri = current($values[WfEngineOntology::PROPERTY_CALL_OF_SERVICES_SERVICE_DEFINITION]); $serviceCall = new self($serviceDefUri); foreach ($values[WfEngineOntology::PROPERTY_CALL_OF_SERVICES_ACTUAL_PARAMETER_IN] as $inRes) { $param = tao_models_classes_service_Parameter::fromResource($inRes); $serviceCall->addInParameter($param); } if (!empty($values[WfEngineOntology::PROPERTY_CALL_OF_SERVICES_ACTUAL_PARAMETER_OUT])) { $param = tao_models_classes_service_Parameter::fromResource(current($values[WfEngineOntology::PROPERTY_CALL_OF_SERVICES_ACTUAL_PARAMETER_OUT])); $serviceCall->setOutParameter($param); } return $serviceCall; }
php
public static function fromResource(core_kernel_classes_Resource $resource) { $values = $resource->getPropertiesValues(array( WfEngineOntology::PROPERTY_CALL_OF_SERVICES_SERVICE_DEFINITION, WfEngineOntology::PROPERTY_CALL_OF_SERVICES_ACTUAL_PARAMETER_IN, WfEngineOntology::PROPERTY_CALL_OF_SERVICES_ACTUAL_PARAMETER_OUT )); $serviceDefUri = current($values[WfEngineOntology::PROPERTY_CALL_OF_SERVICES_SERVICE_DEFINITION]); $serviceCall = new self($serviceDefUri); foreach ($values[WfEngineOntology::PROPERTY_CALL_OF_SERVICES_ACTUAL_PARAMETER_IN] as $inRes) { $param = tao_models_classes_service_Parameter::fromResource($inRes); $serviceCall->addInParameter($param); } if (!empty($values[WfEngineOntology::PROPERTY_CALL_OF_SERVICES_ACTUAL_PARAMETER_OUT])) { $param = tao_models_classes_service_Parameter::fromResource(current($values[WfEngineOntology::PROPERTY_CALL_OF_SERVICES_ACTUAL_PARAMETER_OUT])); $serviceCall->setOutParameter($param); } return $serviceCall; }
[ "public", "static", "function", "fromResource", "(", "core_kernel_classes_Resource", "$", "resource", ")", "{", "$", "values", "=", "$", "resource", "->", "getPropertiesValues", "(", "array", "(", "WfEngineOntology", "::", "PROPERTY_CALL_OF_SERVICES_SERVICE_DEFINITION", ...
Builds a service call from it's serialized form @param core_kernel_classes_Resource $resource @return tao_models_classes_service_ServiceCall
[ "Builds", "a", "service", "call", "from", "it", "s", "serialized", "form" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/service/class.ServiceCall.php#L149-L166
oat-sa/tao-core
helpers/form/validators/class.DateTime.php
tao_helpers_form_validators_DateTime.evaluate
public function evaluate($values) { $returnValue = (bool) false; $value = trim($values); try{ $dateTime = new DateTime($value); // if no date given no need to go further. To check if not empty, use the NotEmpty validator if(!empty($value) && !empty($this->getOption('comparator')) && $this->getOption('datetime2_ref') instanceof tao_helpers_form_FormElement){ //try comparison: try{ $dateTime2 = new DateTime($this->getOption('datetime2_ref')->getRawValue()); }catch(Exception $e){} if($dateTime2 instanceof DateTimeInterface){ switch ($this->getOption('comparator')){ case 'after': case 'later': case 'sup': case '>':{ if ($dateTime > $dateTime2) { $returnValue = true; } else { $this->setMessage(__('Invalid date range (must be after: %s)',$dateTime2->format('Y-m-d'))); } break; } case '>=':{ if ($dateTime >= $dateTime2) { $returnValue = true; } else { $this->setMessage(__('Invalid date range (must be after or the same as: %s)',$dateTime2->format('Y-m-d'))); } break; } case 'before': case 'earlier': case 'inf': case '<':{ if ($dateTime < $dateTime2) { $returnValue = true; } else { $this->setMessage(__('Invalid date range (must be before: %s)',$dateTime2->format('Y-m-d'))); } break; } case '<=':{ if ($dateTime <= $dateTime2) { $returnValue = true; } else { $this->setMessage(__('Invalid date range (must be before or the same as: %s)',$dateTime2->format('Y-m-d'))); } break; } default: throw new common_Exception('Usuported comparator in DateTime Validator: '.$this->getOption('comparator')); } } }else{ $returnValue = true; } }catch(Exception $e){ $this->setMessage(__('The value of this field must be a valide date format, e.g. YYYY-MM-DD')); $returnValue = false; } return (bool) $returnValue; }
php
public function evaluate($values) { $returnValue = (bool) false; $value = trim($values); try{ $dateTime = new DateTime($value); // if no date given no need to go further. To check if not empty, use the NotEmpty validator if(!empty($value) && !empty($this->getOption('comparator')) && $this->getOption('datetime2_ref') instanceof tao_helpers_form_FormElement){ //try comparison: try{ $dateTime2 = new DateTime($this->getOption('datetime2_ref')->getRawValue()); }catch(Exception $e){} if($dateTime2 instanceof DateTimeInterface){ switch ($this->getOption('comparator')){ case 'after': case 'later': case 'sup': case '>':{ if ($dateTime > $dateTime2) { $returnValue = true; } else { $this->setMessage(__('Invalid date range (must be after: %s)',$dateTime2->format('Y-m-d'))); } break; } case '>=':{ if ($dateTime >= $dateTime2) { $returnValue = true; } else { $this->setMessage(__('Invalid date range (must be after or the same as: %s)',$dateTime2->format('Y-m-d'))); } break; } case 'before': case 'earlier': case 'inf': case '<':{ if ($dateTime < $dateTime2) { $returnValue = true; } else { $this->setMessage(__('Invalid date range (must be before: %s)',$dateTime2->format('Y-m-d'))); } break; } case '<=':{ if ($dateTime <= $dateTime2) { $returnValue = true; } else { $this->setMessage(__('Invalid date range (must be before or the same as: %s)',$dateTime2->format('Y-m-d'))); } break; } default: throw new common_Exception('Usuported comparator in DateTime Validator: '.$this->getOption('comparator')); } } }else{ $returnValue = true; } }catch(Exception $e){ $this->setMessage(__('The value of this field must be a valide date format, e.g. YYYY-MM-DD')); $returnValue = false; } return (bool) $returnValue; }
[ "public", "function", "evaluate", "(", "$", "values", ")", "{", "$", "returnValue", "=", "(", "bool", ")", "false", ";", "$", "value", "=", "trim", "(", "$", "values", ")", ";", "try", "{", "$", "dateTime", "=", "new", "DateTime", "(", "$", "value"...
(non-PHPdoc) @see tao_helpers_form_Validator::evaluate()
[ "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/validators/class.DateTime.php#L37-L112