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
helpers/class.File.php
tao_helpers_File.getSafeFileName
public static function getSafeFileName($fileName, $directory = null) { $lastDot = strrpos($fileName, '.'); $file = $lastDot ? substr($fileName, 0, $lastDot) : $fileName; $ending = $lastDot ? substr($fileName, $lastDot+1) : ''; $safeName = self::removeSpecChars($file); $safeEnding = empty($ending) ? '' : '.'.self::removeSpecChars($ending); if ($directory != null && file_exists($directory.$safeName.$safeEnding)) { $count = 1; while (file_exists($directory.$safeName.'_'.$count.$safeEnding)) { $count++; } $safeName = $safeName.'_'.$count; } return $safeName.$safeEnding; }
php
public static function getSafeFileName($fileName, $directory = null) { $lastDot = strrpos($fileName, '.'); $file = $lastDot ? substr($fileName, 0, $lastDot) : $fileName; $ending = $lastDot ? substr($fileName, $lastDot+1) : ''; $safeName = self::removeSpecChars($file); $safeEnding = empty($ending) ? '' : '.'.self::removeSpecChars($ending); if ($directory != null && file_exists($directory.$safeName.$safeEnding)) { $count = 1; while (file_exists($directory.$safeName.'_'.$count.$safeEnding)) { $count++; } $safeName = $safeName.'_'.$count; } return $safeName.$safeEnding; }
[ "public", "static", "function", "getSafeFileName", "(", "$", "fileName", ",", "$", "directory", "=", "null", ")", "{", "$", "lastDot", "=", "strrpos", "(", "$", "fileName", ",", "'.'", ")", ";", "$", "file", "=", "$", "lastDot", "?", "substr", "(", "...
Get a safe filename for a proposed filename. If directory is specified it will return a filename which is safe to not overwritte an existing file. This function is not injective. @param string $fileName @param string $directory @return string
[ "Get", "a", "safe", "filename", "for", "a", "proposed", "filename", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.File.php#L634-L652
oat-sa/tao-core
helpers/class.File.php
tao_helpers_File.removeSpecChars
private static function removeSpecChars($string, $repl='-', $lower=true) { $spec_chars = array ( 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'Ae', 'Å' => 'A','Æ' => 'A', 'Ç' => 'C', 'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', 'Ì' => 'I', 'Í' => 'I', 'Î' => 'I', 'Ï' => 'I', 'Ð' => 'E', 'Ñ' => 'N', 'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O', 'Õ' => 'O', 'Ö' => 'Oe', 'Ø' => 'O', 'Ù' => 'U', 'Ú' => 'U','Û' => 'U', 'Ü' => 'Ue', 'Ý' => 'Y', 'Þ' => 'T', 'ß' => 'ss', 'à' => 'a', 'á' => 'a', 'â' => 'a', 'ã' => 'a', 'ä' => 'ae', 'å' => 'a', 'æ' => 'ae', 'ç' => 'c', 'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e', 'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', 'ð' => 'e', 'ñ' => 'n', 'ò' => 'o', 'ó' => 'o', 'ô' => 'o', 'õ' => 'o', 'ö' => 'oe', 'ø' => 'o', 'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ü' => 'ue', 'ý' => 'y', 'þ' => 't', 'ÿ' => 'y', ' ' => $repl, '?' => $repl, '\'' => $repl, '.' => $repl, '/' => $repl, '&' => $repl, ')' => $repl, '(' => $repl, '[' => $repl, ']' => $repl, '_' => $repl, ',' => $repl, ':' => $repl, '-' => $repl, '!' => $repl, '"' => $repl, '`' => $repl, '°' => $repl, '%' => $repl, ' ' => $repl, ' ' => $repl, '{' => $repl, '}' => $repl, '#' => $repl, '’' => $repl ); $string = strtr($string, $spec_chars); $string = trim(preg_replace("~[^a-z0-9]+~i", $repl, $string), $repl); return $lower ? strtolower($string) : $string; }
php
private static function removeSpecChars($string, $repl='-', $lower=true) { $spec_chars = array ( 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'Ae', 'Å' => 'A','Æ' => 'A', 'Ç' => 'C', 'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', 'Ì' => 'I', 'Í' => 'I', 'Î' => 'I', 'Ï' => 'I', 'Ð' => 'E', 'Ñ' => 'N', 'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O', 'Õ' => 'O', 'Ö' => 'Oe', 'Ø' => 'O', 'Ù' => 'U', 'Ú' => 'U','Û' => 'U', 'Ü' => 'Ue', 'Ý' => 'Y', 'Þ' => 'T', 'ß' => 'ss', 'à' => 'a', 'á' => 'a', 'â' => 'a', 'ã' => 'a', 'ä' => 'ae', 'å' => 'a', 'æ' => 'ae', 'ç' => 'c', 'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e', 'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', 'ð' => 'e', 'ñ' => 'n', 'ò' => 'o', 'ó' => 'o', 'ô' => 'o', 'õ' => 'o', 'ö' => 'oe', 'ø' => 'o', 'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ü' => 'ue', 'ý' => 'y', 'þ' => 't', 'ÿ' => 'y', ' ' => $repl, '?' => $repl, '\'' => $repl, '.' => $repl, '/' => $repl, '&' => $repl, ')' => $repl, '(' => $repl, '[' => $repl, ']' => $repl, '_' => $repl, ',' => $repl, ':' => $repl, '-' => $repl, '!' => $repl, '"' => $repl, '`' => $repl, '°' => $repl, '%' => $repl, ' ' => $repl, ' ' => $repl, '{' => $repl, '}' => $repl, '#' => $repl, '’' => $repl ); $string = strtr($string, $spec_chars); $string = trim(preg_replace("~[^a-z0-9]+~i", $repl, $string), $repl); return $lower ? strtolower($string) : $string; }
[ "private", "static", "function", "removeSpecChars", "(", "$", "string", ",", "$", "repl", "=", "'-'", ",", "$", "lower", "=", "true", ")", "{", "$", "spec_chars", "=", "array", "(", "'Á' ", "> ", "A',", " ", "Â' =", " '", "', ", "'", "' =>", "'A", ...
Remove special characters for safe filenames @author Dieter Raber @param string $string @param string $repl @param string $lower @return string
[ "Remove", "special", "characters", "for", "safe", "filenames" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.File.php#L665-L684
oat-sa/tao-core
helpers/class.File.php
tao_helpers_File.isDirEmpty
public static function isDirEmpty($directory){ $path = self::concat(array($directory, '*')); return (count(glob($path, GLOB_NOSORT)) === 0 ); }
php
public static function isDirEmpty($directory){ $path = self::concat(array($directory, '*')); return (count(glob($path, GLOB_NOSORT)) === 0 ); }
[ "public", "static", "function", "isDirEmpty", "(", "$", "directory", ")", "{", "$", "path", "=", "self", "::", "concat", "(", "array", "(", "$", "directory", ",", "'*'", ")", ")", ";", "return", "(", "count", "(", "glob", "(", "$", "path", ",", "GL...
Check if the directory is empty @param string $directory @return boolean
[ "Check", "if", "the", "directory", "is", "empty" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.File.php#L692-L695
oat-sa/tao-core
helpers/class.Request.php
tao_helpers_Request.isAjax
public static function isAjax() { $returnValue = (bool) false; if(isset($_SERVER['HTTP_X_REQUESTED_WITH'])){ if(strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){ $returnValue = true; } } return (bool) $returnValue; }
php
public static function isAjax() { $returnValue = (bool) false; if(isset($_SERVER['HTTP_X_REQUESTED_WITH'])){ if(strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){ $returnValue = true; } } return (bool) $returnValue; }
[ "public", "static", "function", "isAjax", "(", ")", "{", "$", "returnValue", "=", "(", "bool", ")", "false", ";", "if", "(", "isset", "(", "$", "_SERVER", "[", "'HTTP_X_REQUESTED_WITH'", "]", ")", ")", "{", "if", "(", "strtolower", "(", "$", "_SERVER",...
Enables you to know if the request in the current scope is an ajax @access public @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> @return boolean
[ "Enables", "you", "to", "know", "if", "the", "request", "in", "the", "current", "scope", "is", "an", "ajax" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Request.php#L47-L58
oat-sa/tao-core
helpers/class.Request.php
tao_helpers_Request.getRelativeUrl
public static function getRelativeUrl($url = null) { $url = is_null($url) ? '/'.ltrim($_SERVER['REQUEST_URI'], '/') : $url; $rootUrlPath = parse_url(ROOT_URL, PHP_URL_PATH); $absPath = parse_url($url, PHP_URL_PATH); if (substr($absPath, 0, strlen($rootUrlPath)) != $rootUrlPath ) { throw new ResolverException('Request Uri '.$url.' outside of TAO path '.ROOT_URL); } if ($absPath === $rootUrlPath) { $result = ''; } else { $result = substr($absPath, strlen($rootUrlPath)); } return $result; }
php
public static function getRelativeUrl($url = null) { $url = is_null($url) ? '/'.ltrim($_SERVER['REQUEST_URI'], '/') : $url; $rootUrlPath = parse_url(ROOT_URL, PHP_URL_PATH); $absPath = parse_url($url, PHP_URL_PATH); if (substr($absPath, 0, strlen($rootUrlPath)) != $rootUrlPath ) { throw new ResolverException('Request Uri '.$url.' outside of TAO path '.ROOT_URL); } if ($absPath === $rootUrlPath) { $result = ''; } else { $result = substr($absPath, strlen($rootUrlPath)); } return $result; }
[ "public", "static", "function", "getRelativeUrl", "(", "$", "url", "=", "null", ")", "{", "$", "url", "=", "is_null", "(", "$", "url", ")", "?", "'/'", ".", "ltrim", "(", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ",", "'/'", ")", ":", "$", "url", ...
Returns the current relative call url, without leading slash @param string $url @throws ResolverException @return string
[ "Returns", "the", "current", "relative", "call", "url", "without", "leading", "slash" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Request.php#L67-L80
oat-sa/tao-core
helpers/class.Request.php
tao_helpers_Request.load
public static function load($url, $useSession = false) { $returnValue = (string) ''; if(!empty($url)){ if($useSession){ session_write_close(); } $curlHandler = curl_init(); //if there is an http auth, it's mandatory to connect with curl if(USE_HTTP_AUTH){ curl_setopt($curlHandler, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($curlHandler, CURLOPT_USERPWD, USE_HTTP_USER.":".USE_HTTP_PASS); } curl_setopt($curlHandler, CURLOPT_RETURNTRANSFER, 1); //to keep the session if($useSession){ if(!preg_match("/&$/", $url)){ $url .= '&'; } $url .= 'session_id=' . session_id(); curl_setopt($curlHandler, CURLOPT_COOKIE, session_name(). '=' . $_COOKIE[session_name()] . '; path=/'); } curl_setopt($curlHandler, CURLOPT_URL, $url); $returnValue = curl_exec($curlHandler); if(curl_errno($curlHandler) > 0){ throw new Exception("Request error ".curl_errno($curlHandler).": ". curl_error($curlHandler)); } curl_close($curlHandler); } return (string) $returnValue; }
php
public static function load($url, $useSession = false) { $returnValue = (string) ''; if(!empty($url)){ if($useSession){ session_write_close(); } $curlHandler = curl_init(); //if there is an http auth, it's mandatory to connect with curl if(USE_HTTP_AUTH){ curl_setopt($curlHandler, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($curlHandler, CURLOPT_USERPWD, USE_HTTP_USER.":".USE_HTTP_PASS); } curl_setopt($curlHandler, CURLOPT_RETURNTRANSFER, 1); //to keep the session if($useSession){ if(!preg_match("/&$/", $url)){ $url .= '&'; } $url .= 'session_id=' . session_id(); curl_setopt($curlHandler, CURLOPT_COOKIE, session_name(). '=' . $_COOKIE[session_name()] . '; path=/'); } curl_setopt($curlHandler, CURLOPT_URL, $url); $returnValue = curl_exec($curlHandler); if(curl_errno($curlHandler) > 0){ throw new Exception("Request error ".curl_errno($curlHandler).": ". curl_error($curlHandler)); } curl_close($curlHandler); } return (string) $returnValue; }
[ "public", "static", "function", "load", "(", "$", "url", ",", "$", "useSession", "=", "false", ")", "{", "$", "returnValue", "=", "(", "string", ")", "''", ";", "if", "(", "!", "empty", "(", "$", "url", ")", ")", "{", "if", "(", "$", "useSession"...
Perform an HTTP Request on the defined url and return the content @access public @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> @param string url @param boolean useSession if you want to use the same session in the remotre server @return string @throws Exception
[ "Perform", "an", "HTTP", "Request", "on", "the", "defined", "url", "and", "return", "the", "content" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Request.php#L93-L134
oat-sa/tao-core
models/classes/taskQueue/Task/TaskFactory.php
TaskFactory.build
public static function build($basicData) { $className = $basicData[TaskInterface::JSON_TASK_CLASS_NAME_KEY]; if (class_exists($className) && is_subclass_of($className, TaskInterface::class)) { $metaData = $basicData[TaskInterface::JSON_METADATA_KEY]; /** @var TaskInterface $task */ $task = new $className($metaData[TaskInterface::JSON_METADATA_ID_KEY], $metaData[TaskInterface::JSON_METADATA_OWNER_KEY]); $task->setMetadata($metaData); $task->setParameter($basicData[TaskInterface::JSON_PARAMETERS_KEY]); if (isset($metaData[TaskInterface::JSON_METADATA_CREATED_AT_KEY])) { $task->setCreatedAt(new \DateTime($metaData[TaskInterface::JSON_METADATA_CREATED_AT_KEY])); } return $task; } throw new InvalidTaskException; }
php
public static function build($basicData) { $className = $basicData[TaskInterface::JSON_TASK_CLASS_NAME_KEY]; if (class_exists($className) && is_subclass_of($className, TaskInterface::class)) { $metaData = $basicData[TaskInterface::JSON_METADATA_KEY]; /** @var TaskInterface $task */ $task = new $className($metaData[TaskInterface::JSON_METADATA_ID_KEY], $metaData[TaskInterface::JSON_METADATA_OWNER_KEY]); $task->setMetadata($metaData); $task->setParameter($basicData[TaskInterface::JSON_PARAMETERS_KEY]); if (isset($metaData[TaskInterface::JSON_METADATA_CREATED_AT_KEY])) { $task->setCreatedAt(new \DateTime($metaData[TaskInterface::JSON_METADATA_CREATED_AT_KEY])); } return $task; } throw new InvalidTaskException; }
[ "public", "static", "function", "build", "(", "$", "basicData", ")", "{", "$", "className", "=", "$", "basicData", "[", "TaskInterface", "::", "JSON_TASK_CLASS_NAME_KEY", "]", ";", "if", "(", "class_exists", "(", "$", "className", ")", "&&", "is_subclass_of", ...
@param array $basicData @return TaskInterface @throws InvalidTaskException
[ "@param", "array", "$basicData" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/taskQueue/Task/TaskFactory.php#L31-L51
oat-sa/tao-core
helpers/class.Scriptloader.php
tao_helpers_Scriptloader.contextInit
public static function contextInit($extension, $module, $action) { $basePath = '/'.$extension.'/views/'; //load module scripts $jsModuleFile = $basePath.self::JS.'/controllers/'.strtolower($module).'/'.$action.'.'.self::JS; $cssModuleFile = $basePath.self::CSS.'/'.$module.'.'.self::CSS; $cssModuleDir = $basePath.self::CSS.'/'.$module.'/'; if(file_exists($jsModuleFile)){ self::addJsFile($jsModuleFile); } if(file_exists($cssModuleFile)){ self::addCssFile($cssModuleFile); } foreach(glob($cssModuleDir.'*.'.self::CSS) as $file){ self::addCssFile($file); } // //@todo load action scripts // }
php
public static function contextInit($extension, $module, $action) { $basePath = '/'.$extension.'/views/'; //load module scripts $jsModuleFile = $basePath.self::JS.'/controllers/'.strtolower($module).'/'.$action.'.'.self::JS; $cssModuleFile = $basePath.self::CSS.'/'.$module.'.'.self::CSS; $cssModuleDir = $basePath.self::CSS.'/'.$module.'/'; if(file_exists($jsModuleFile)){ self::addJsFile($jsModuleFile); } if(file_exists($cssModuleFile)){ self::addCssFile($cssModuleFile); } foreach(glob($cssModuleDir.'*.'.self::CSS) as $file){ self::addCssFile($file); } // //@todo load action scripts // }
[ "public", "static", "function", "contextInit", "(", "$", "extension", ",", "$", "module", ",", "$", "action", ")", "{", "$", "basePath", "=", "'/'", ".", "$", "extension", ".", "'/views/'", ";", "//load module scripts", "$", "jsModuleFile", "=", "$", "base...
Short description of method contextInit @access public @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> @param string extension @param string module @param string action @return mixed
[ "Short", "description", "of", "method", "contextInit" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Scriptloader.php#L90-L117
oat-sa/tao-core
helpers/class.Scriptloader.php
tao_helpers_Scriptloader.setPaths
public static function setPaths($paths, $recursive = false, $filter = '') { foreach($paths as $path){ if(!preg_match("/\/$/", $path)){ $path .= '/'; } if(empty($filter) || strtolower($filter) == tao_helpers_Scriptloader::CSS){ foreach(glob($path . "*." . tao_helpers_Scriptloader::CSS) as $cssFile){ self::$cssFiles[] = $path . $cssFile; } } if(empty($filter) || strtolower($filter) == tao_helpers_Scriptloader::JS){ foreach(glob($path . "*." . tao_helpers_Scriptloader::JS) as $jsFile){ self::$jsFiles[] = $path . $jsFile; } } if($recursive){ $dirs = array(); foreach(scandir($path) as $file){ if(is_dir($path.$file) && $file != '.' && $file != '..'){ $dirs[] = $path.$file; } } if(count($dirs) > 0){ self::setPaths($dirs, true, $filter); } } } }
php
public static function setPaths($paths, $recursive = false, $filter = '') { foreach($paths as $path){ if(!preg_match("/\/$/", $path)){ $path .= '/'; } if(empty($filter) || strtolower($filter) == tao_helpers_Scriptloader::CSS){ foreach(glob($path . "*." . tao_helpers_Scriptloader::CSS) as $cssFile){ self::$cssFiles[] = $path . $cssFile; } } if(empty($filter) || strtolower($filter) == tao_helpers_Scriptloader::JS){ foreach(glob($path . "*." . tao_helpers_Scriptloader::JS) as $jsFile){ self::$jsFiles[] = $path . $jsFile; } } if($recursive){ $dirs = array(); foreach(scandir($path) as $file){ if(is_dir($path.$file) && $file != '.' && $file != '..'){ $dirs[] = $path.$file; } } if(count($dirs) > 0){ self::setPaths($dirs, true, $filter); } } } }
[ "public", "static", "function", "setPaths", "(", "$", "paths", ",", "$", "recursive", "=", "false", ",", "$", "filter", "=", "''", ")", "{", "foreach", "(", "$", "paths", "as", "$", "path", ")", "{", "if", "(", "!", "preg_match", "(", "\"/\\/$/\"", ...
define the paths to look for the scripts @access public @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> @param array paths @param boolean recursive @param string filter @return mixed
[ "define", "the", "paths", "to", "look", "for", "the", "scripts" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Scriptloader.php#L129-L159
oat-sa/tao-core
helpers/class.Scriptloader.php
tao_helpers_Scriptloader.addFile
public static function addFile($file, $type = '') { if(empty($type)){ if(preg_match("/\.".tao_helpers_Scriptloader::CSS."$/", $file)){ $type = tao_helpers_Scriptloader::CSS; } if(preg_match("/\.".tao_helpers_Scriptloader::JS."$/", $file)){ $type = tao_helpers_Scriptloader::JS; } } switch(strtolower($type)){ case tao_helpers_Scriptloader::CSS: self::$cssFiles[] = $file; break; case tao_helpers_Scriptloader::JS: self::$jsFiles[] = $file; break; default: throw new Exception("Unknown script type for file : ".$file); } }
php
public static function addFile($file, $type = '') { if(empty($type)){ if(preg_match("/\.".tao_helpers_Scriptloader::CSS."$/", $file)){ $type = tao_helpers_Scriptloader::CSS; } if(preg_match("/\.".tao_helpers_Scriptloader::JS."$/", $file)){ $type = tao_helpers_Scriptloader::JS; } } switch(strtolower($type)){ case tao_helpers_Scriptloader::CSS: self::$cssFiles[] = $file; break; case tao_helpers_Scriptloader::JS: self::$jsFiles[] = $file; break; default: throw new Exception("Unknown script type for file : ".$file); } }
[ "public", "static", "function", "addFile", "(", "$", "file", ",", "$", "type", "=", "''", ")", "{", "if", "(", "empty", "(", "$", "type", ")", ")", "{", "if", "(", "preg_match", "(", "\"/\\.\"", ".", "tao_helpers_Scriptloader", "::", "CSS", ".", "\"$...
add a file to load @access public @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> @param string file @param string type @return mixed @throws Exception
[ "add", "a", "file", "to", "load" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Scriptloader.php#L171-L189
oat-sa/tao-core
helpers/class.Scriptloader.php
tao_helpers_Scriptloader.addCssFiles
public static function addCssFiles($files = array()) { foreach($files as $file){ self::addFile($file, tao_helpers_Scriptloader::CSS); } }
php
public static function addCssFiles($files = array()) { foreach($files as $file){ self::addFile($file, tao_helpers_Scriptloader::CSS); } }
[ "public", "static", "function", "addCssFiles", "(", "$", "files", "=", "array", "(", ")", ")", "{", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "self", "::", "addFile", "(", "$", "file", ",", "tao_helpers_Scriptloader", "::", "CSS", ")",...
add an array of css files to load @access public @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> @param array files @return mixed
[ "add", "an", "array", "of", "css", "files", "to", "load" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Scriptloader.php#L229-L236
oat-sa/tao-core
helpers/class.Scriptloader.php
tao_helpers_Scriptloader.addJsFiles
public static function addJsFiles($files = array()) { foreach($files as $file){ self::addFile($file, tao_helpers_Scriptloader::JS); } }
php
public static function addJsFiles($files = array()) { foreach($files as $file){ self::addFile($file, tao_helpers_Scriptloader::JS); } }
[ "public", "static", "function", "addJsFiles", "(", "$", "files", "=", "array", "(", ")", ")", "{", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "self", "::", "addFile", "(", "$", "file", ",", "tao_helpers_Scriptloader", "::", "JS", ")", ...
add an array of css files to load @access public @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> @param array files @return mixed
[ "add", "an", "array", "of", "css", "files", "to", "load" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Scriptloader.php#L246-L253
oat-sa/tao-core
helpers/class.Scriptloader.php
tao_helpers_Scriptloader.addJsVars
public static function addJsVars($vars) { if(is_array($vars)){ foreach($vars as $name => $value){ if(is_int($name)){ $name = 'var_'.$name; } self::addJsVar($name, $value); } } }
php
public static function addJsVars($vars) { if(is_array($vars)){ foreach($vars as $name => $value){ if(is_int($name)){ $name = 'var_'.$name; } self::addJsVar($name, $value); } } }
[ "public", "static", "function", "addJsVars", "(", "$", "vars", ")", "{", "if", "(", "is_array", "(", "$", "vars", ")", ")", "{", "foreach", "(", "$", "vars", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "is_int", "(", "$", "name", ...
Short description of method addJsVars @access public @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> @param array vars @return mixed
[ "Short", "description", "of", "method", "addJsVars" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Scriptloader.php#L281-L295
oat-sa/tao-core
helpers/class.Scriptloader.php
tao_helpers_Scriptloader.render
public static function render($filter = '') { $returnValue = (string) ''; if(empty($filter) || strtolower($filter) == tao_helpers_Scriptloader::CSS){ foreach(self::$cssFiles as $file){ $returnValue .= "\t<link rel='stylesheet' type='text/css' href='{$file}' />\n"; } } if(empty($filter) || strtolower($filter) == tao_helpers_Scriptloader::JS){ if(count(self::$jsVars) > 0){ $returnValue .= "\t<script type='text/javascript'>\n"; foreach(self::$jsVars as $name => $value){ $returnValue .= "\tvar {$name} = '{$value}';\n"; } $returnValue .= "\t</script>\n"; } foreach(self::$jsFiles as $file){ $returnValue .= "\t<script type='text/javascript' src='{$file}' ></script>\n"; } } return (string) $returnValue; }
php
public static function render($filter = '') { $returnValue = (string) ''; if(empty($filter) || strtolower($filter) == tao_helpers_Scriptloader::CSS){ foreach(self::$cssFiles as $file){ $returnValue .= "\t<link rel='stylesheet' type='text/css' href='{$file}' />\n"; } } if(empty($filter) || strtolower($filter) == tao_helpers_Scriptloader::JS){ if(count(self::$jsVars) > 0){ $returnValue .= "\t<script type='text/javascript'>\n"; foreach(self::$jsVars as $name => $value){ $returnValue .= "\tvar {$name} = '{$value}';\n"; } $returnValue .= "\t</script>\n"; } foreach(self::$jsFiles as $file){ $returnValue .= "\t<script type='text/javascript' src='{$file}' ></script>\n"; } } return (string) $returnValue; }
[ "public", "static", "function", "render", "(", "$", "filter", "=", "''", ")", "{", "$", "returnValue", "=", "(", "string", ")", "''", ";", "if", "(", "empty", "(", "$", "filter", ")", "||", "strtolower", "(", "$", "filter", ")", "==", "tao_helpers_Sc...
render the html to load the resources @access public @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> @param string filter @return string
[ "render", "the", "html", "to", "load", "the", "resources" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Scriptloader.php#L309-L334
oat-sa/tao-core
models/classes/class.LanguageService.php
tao_models_classes_LanguageService.getLanguageByCode
public function getLanguageByCode($code) { $returnValue = null; $langClass = new core_kernel_classes_Class(static::CLASS_URI_LANGUAGES); $langs = $langClass->searchInstances(array( OntologyRdf::RDF_VALUE => $code ), array( 'like' => false )); if (count($langs) == 1) { $returnValue = current($langs); } else { common_Logger::w('Could not find language with code '.$code); } return $returnValue; }
php
public function getLanguageByCode($code) { $returnValue = null; $langClass = new core_kernel_classes_Class(static::CLASS_URI_LANGUAGES); $langs = $langClass->searchInstances(array( OntologyRdf::RDF_VALUE => $code ), array( 'like' => false )); if (count($langs) == 1) { $returnValue = current($langs); } else { common_Logger::w('Could not find language with code '.$code); } return $returnValue; }
[ "public", "function", "getLanguageByCode", "(", "$", "code", ")", "{", "$", "returnValue", "=", "null", ";", "$", "langClass", "=", "new", "core_kernel_classes_Class", "(", "static", "::", "CLASS_URI_LANGUAGES", ")", ";", "$", "langs", "=", "$", "langClass", ...
Short description of method getLanguageByCode @access public @author Joel Bout, <joel.bout@tudor.lu> @param string $code @return core_kernel_classes_Resource|null
[ "Short", "description", "of", "method", "getLanguageByCode" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.LanguageService.php#L75-L94
oat-sa/tao-core
models/classes/class.LanguageService.php
tao_models_classes_LanguageService.getCode
public function getCode( core_kernel_classes_Resource $language) { $returnValue = (string) ''; $valueProperty = new core_kernel_classes_Property(OntologyRdf::RDF_VALUE); $returnValue = $language->getUniquePropertyValue($valueProperty); return (string) $returnValue; }
php
public function getCode( core_kernel_classes_Resource $language) { $returnValue = (string) ''; $valueProperty = new core_kernel_classes_Property(OntologyRdf::RDF_VALUE); $returnValue = $language->getUniquePropertyValue($valueProperty); return (string) $returnValue; }
[ "public", "function", "getCode", "(", "core_kernel_classes_Resource", "$", "language", ")", "{", "$", "returnValue", "=", "(", "string", ")", "''", ";", "$", "valueProperty", "=", "new", "core_kernel_classes_Property", "(", "OntologyRdf", "::", "RDF_VALUE", ")", ...
Short description of method getCode @access public @author Joel Bout, <joel.bout@tudor.lu> @param core_kernel_classes_Resource $language @return string
[ "Short", "description", "of", "method", "getCode" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.LanguageService.php#L104-L110
oat-sa/tao-core
models/classes/class.LanguageService.php
tao_models_classes_LanguageService.getAvailableLanguagesByUsage
public function getAvailableLanguagesByUsage( core_kernel_classes_Resource $usage) { $returnValue = array(); $langClass = new core_kernel_classes_Class(static::CLASS_URI_LANGUAGES); $returnValue = $langClass->searchInstances(array( static::PROPERTY_LANGUAGE_USAGES => $usage->getUri() ), array( 'like' => false )); return (array) $returnValue; }
php
public function getAvailableLanguagesByUsage( core_kernel_classes_Resource $usage) { $returnValue = array(); $langClass = new core_kernel_classes_Class(static::CLASS_URI_LANGUAGES); $returnValue = $langClass->searchInstances(array( static::PROPERTY_LANGUAGE_USAGES => $usage->getUri() ), array( 'like' => false )); return (array) $returnValue; }
[ "public", "function", "getAvailableLanguagesByUsage", "(", "core_kernel_classes_Resource", "$", "usage", ")", "{", "$", "returnValue", "=", "array", "(", ")", ";", "$", "langClass", "=", "new", "core_kernel_classes_Class", "(", "static", "::", "CLASS_URI_LANGUAGES", ...
Short description of method getAvailableLanguagesByUsage @access public @author Joel Bout, <joel.bout@tudor.lu> @param core_kernel_classes_Resource $usage @return array
[ "Short", "description", "of", "method", "getAvailableLanguagesByUsage" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.LanguageService.php#L120-L130
oat-sa/tao-core
models/classes/class.LanguageService.php
tao_models_classes_LanguageService.isLanguageAvailable
public function isLanguageAvailable($code, core_kernel_classes_Resource $usage) { $langClass = new core_kernel_classes_Class(static::CLASS_URI_LANGUAGES); $result = $langClass->searchInstances( array( OntologyRdf::RDF_VALUE => $code, static::PROPERTY_LANGUAGE_USAGES => $usage->getUri(), ), array('like' => false) ); return !empty($result); }
php
public function isLanguageAvailable($code, core_kernel_classes_Resource $usage) { $langClass = new core_kernel_classes_Class(static::CLASS_URI_LANGUAGES); $result = $langClass->searchInstances( array( OntologyRdf::RDF_VALUE => $code, static::PROPERTY_LANGUAGE_USAGES => $usage->getUri(), ), array('like' => false) ); return !empty($result); }
[ "public", "function", "isLanguageAvailable", "(", "$", "code", ",", "core_kernel_classes_Resource", "$", "usage", ")", "{", "$", "langClass", "=", "new", "core_kernel_classes_Class", "(", "static", "::", "CLASS_URI_LANGUAGES", ")", ";", "$", "result", "=", "$", ...
Checks the language availability in the given context(usage). @param string $code The language code to check. (for example: en-US) @param core_kernel_classes_Resource $usage The context of the availability. @return bool
[ "Checks", "the", "language", "availability", "in", "the", "given", "context", "(", "usage", ")", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.LanguageService.php#L140-L152
oat-sa/tao-core
models/classes/class.LanguageService.php
tao_models_classes_LanguageService.generateAll
public function generateAll($checkPreviousBundle = false) { $this->generateServerBundles(); $files = $this->generateClientBundles($checkPreviousBundle); return $files; }
php
public function generateAll($checkPreviousBundle = false) { $this->generateServerBundles(); $files = $this->generateClientBundles($checkPreviousBundle); return $files; }
[ "public", "function", "generateAll", "(", "$", "checkPreviousBundle", "=", "false", ")", "{", "$", "this", "->", "generateServerBundles", "(", ")", ";", "$", "files", "=", "$", "this", "->", "generateClientBundles", "(", "$", "checkPreviousBundle", ")", ";", ...
Regenerates client and server translation @return string[] list of client files regenerated
[ "Regenerates", "client", "and", "server", "translation" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.LanguageService.php#L172-L177
oat-sa/tao-core
models/classes/class.LanguageService.php
tao_models_classes_LanguageService.generateServerBundles
public function generateServerBundles() { $usage = $this->getResource(self::INSTANCE_LANGUAGE_USAGE_GUI); foreach ($this->getAvailableLanguagesByUsage($usage) as $language) { $langCode = $this->getCode($language); $this->buildServerBundle($langCode); } }
php
public function generateServerBundles() { $usage = $this->getResource(self::INSTANCE_LANGUAGE_USAGE_GUI); foreach ($this->getAvailableLanguagesByUsage($usage) as $language) { $langCode = $this->getCode($language); $this->buildServerBundle($langCode); } }
[ "public", "function", "generateServerBundles", "(", ")", "{", "$", "usage", "=", "$", "this", "->", "getResource", "(", "self", "::", "INSTANCE_LANGUAGE_USAGE_GUI", ")", ";", "foreach", "(", "$", "this", "->", "getAvailableLanguagesByUsage", "(", "$", "usage", ...
Generate server translation file, forching a cache overwrite
[ "Generate", "server", "translation", "file", "forching", "a", "cache", "overwrite" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.LanguageService.php#L244-L251
oat-sa/tao-core
models/classes/class.LanguageService.php
tao_models_classes_LanguageService.getServerBundle
public function getServerBundle($langCode) { $cache = $this->getServiceLocator()->get(common_cache_Cache::SERVICE_ID); try { $translations = $cache->get(self::TRANSLATION_PREFIX.$langCode); } catch (common_cache_NotFoundException $ex) { $translations = $this->buildServerBundle($langCode); } return $translations; }
php
public function getServerBundle($langCode) { $cache = $this->getServiceLocator()->get(common_cache_Cache::SERVICE_ID); try { $translations = $cache->get(self::TRANSLATION_PREFIX.$langCode); } catch (common_cache_NotFoundException $ex) { $translations = $this->buildServerBundle($langCode); } return $translations; }
[ "public", "function", "getServerBundle", "(", "$", "langCode", ")", "{", "$", "cache", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "common_cache_Cache", "::", "SERVICE_ID", ")", ";", "try", "{", "$", "translations", "=", "$", ...
Returns the translation strings for a given language Conflicting translations get resolved by order of dependencies @param string $langCode @return array translation strings
[ "Returns", "the", "translation", "strings", "for", "a", "given", "language", "Conflicting", "translations", "get", "resolved", "by", "order", "of", "dependencies" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.LanguageService.php#L259-L268
oat-sa/tao-core
models/classes/class.LanguageService.php
tao_models_classes_LanguageService.buildServerBundle
protected function buildServerBundle($langCode) { $extensions = common_ext_ExtensionsManager::singleton()->getInstalledExtensions(); $extensions = helpers_ExtensionHelper::sortByDependencies($extensions); $translations = []; foreach ($extensions as $extension) { $file = $extension->getDir(). 'locales' . DIRECTORY_SEPARATOR . $langCode. DIRECTORY_SEPARATOR . 'messages.po'; $new = l10n::getPoFile($file); if (is_array($new)) { $translations = array_merge($translations, $new); } } $cache = $this->getServiceLocator()->get(common_cache_Cache::SERVICE_ID); $cache->put($translations, self::TRANSLATION_PREFIX.$langCode); return $translations; }
php
protected function buildServerBundle($langCode) { $extensions = common_ext_ExtensionsManager::singleton()->getInstalledExtensions(); $extensions = helpers_ExtensionHelper::sortByDependencies($extensions); $translations = []; foreach ($extensions as $extension) { $file = $extension->getDir(). 'locales' . DIRECTORY_SEPARATOR . $langCode. DIRECTORY_SEPARATOR . 'messages.po'; $new = l10n::getPoFile($file); if (is_array($new)) { $translations = array_merge($translations, $new); } } $cache = $this->getServiceLocator()->get(common_cache_Cache::SERVICE_ID); $cache->put($translations, self::TRANSLATION_PREFIX.$langCode); return $translations; }
[ "protected", "function", "buildServerBundle", "(", "$", "langCode", ")", "{", "$", "extensions", "=", "common_ext_ExtensionsManager", "::", "singleton", "(", ")", "->", "getInstalledExtensions", "(", ")", ";", "$", "extensions", "=", "helpers_ExtensionHelper", "::",...
Rebuild the translation cache from the POs situated in each installed extension @param string $langCode @return array translation
[ "Rebuild", "the", "translation", "cache", "from", "the", "POs", "situated", "in", "each", "installed", "extension" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.LanguageService.php#L275-L290
oat-sa/tao-core
models/classes/class.LanguageService.php
tao_models_classes_LanguageService.filterLanguage
public static function filterLanguage($value) { $uri = self::getExistingLanguageUri($value); /** @noinspection NullPointerExceptionInspection */ return $uri !== null ? $uri : self::singleton()->getLanguageByCode(DEFAULT_LANG)->getUri(); }
php
public static function filterLanguage($value) { $uri = self::getExistingLanguageUri($value); /** @noinspection NullPointerExceptionInspection */ return $uri !== null ? $uri : self::singleton()->getLanguageByCode(DEFAULT_LANG)->getUri(); }
[ "public", "static", "function", "filterLanguage", "(", "$", "value", ")", "{", "$", "uri", "=", "self", "::", "getExistingLanguageUri", "(", "$", "value", ")", ";", "/** @noinspection NullPointerExceptionInspection */", "return", "$", "uri", "!==", "null", "?", ...
Filter a value of a language to transform it into uri If it's an uri, returns it If it's a language code returns the associated uri Else returns the default language uri @param $value @return string @throws common_exception_Error
[ "Filter", "a", "value", "of", "a", "language", "to", "transform", "it", "into", "uri" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.LanguageService.php#L317-L324
oat-sa/tao-core
models/classes/dataBinding/class.GenerisInstanceDataBinder.php
tao_models_classes_dataBinding_GenerisInstanceDataBinder.bind
public function bind($data) { $returnValue = null; try { $instance = $this->getTargetInstance(); $eventManager = \oat\oatbox\service\ServiceManager::getServiceManager()->get(\oat\oatbox\event\EventManager::CONFIG_ID); foreach($data as $propertyUri => $propertyValue){ if($propertyUri == OntologyRdf::RDF_TYPE){ foreach($instance->getTypes() as $type){ $instance->removeType($type); } if(!is_array($propertyValue)){ $types = array($propertyValue) ; } foreach($types as $type){ $instance->setType(new core_kernel_classes_Class($type)); } continue; } $prop = new core_kernel_classes_Property( $propertyUri ); $values = $instance->getPropertyValuesCollection($prop); if($values->count() > 0){ if(is_array($propertyValue)){ $instance->removePropertyValues($prop); foreach($propertyValue as $aPropertyValue){ $instance->setPropertyValue( $prop, $aPropertyValue ); } } else if (is_string($propertyValue)){ $instance->editPropertyValues( $prop, $propertyValue ); if(strlen(trim($propertyValue))==0){ //if the property value is an empty space(the default value in a select input field), delete the corresponding triplet (and not all property values) $instance->removePropertyValues($prop, array('pattern' => '')); } } } else{ if(is_array($propertyValue)){ foreach($propertyValue as $aPropertyValue){ $instance->setPropertyValue( $prop, $aPropertyValue ); } } else if (is_string($propertyValue) && strlen(trim($propertyValue)) !== 0 ){ $instance->setPropertyValue( $prop, $propertyValue ); } } $eventManager->trigger(new \oat\tao\model\event\MetadataModified($instance, $propertyUri, $propertyValue)); } $returnValue = $instance; } catch (common_Exception $e){ $msg = "An error occured while binding property values to instance '': " . $e->getMessage(); $instanceUri = $instance->getUri(); throw new tao_models_classes_dataBinding_GenerisInstanceDataBindingException($msg); } return $returnValue; }
php
public function bind($data) { $returnValue = null; try { $instance = $this->getTargetInstance(); $eventManager = \oat\oatbox\service\ServiceManager::getServiceManager()->get(\oat\oatbox\event\EventManager::CONFIG_ID); foreach($data as $propertyUri => $propertyValue){ if($propertyUri == OntologyRdf::RDF_TYPE){ foreach($instance->getTypes() as $type){ $instance->removeType($type); } if(!is_array($propertyValue)){ $types = array($propertyValue) ; } foreach($types as $type){ $instance->setType(new core_kernel_classes_Class($type)); } continue; } $prop = new core_kernel_classes_Property( $propertyUri ); $values = $instance->getPropertyValuesCollection($prop); if($values->count() > 0){ if(is_array($propertyValue)){ $instance->removePropertyValues($prop); foreach($propertyValue as $aPropertyValue){ $instance->setPropertyValue( $prop, $aPropertyValue ); } } else if (is_string($propertyValue)){ $instance->editPropertyValues( $prop, $propertyValue ); if(strlen(trim($propertyValue))==0){ //if the property value is an empty space(the default value in a select input field), delete the corresponding triplet (and not all property values) $instance->removePropertyValues($prop, array('pattern' => '')); } } } else{ if(is_array($propertyValue)){ foreach($propertyValue as $aPropertyValue){ $instance->setPropertyValue( $prop, $aPropertyValue ); } } else if (is_string($propertyValue) && strlen(trim($propertyValue)) !== 0 ){ $instance->setPropertyValue( $prop, $propertyValue ); } } $eventManager->trigger(new \oat\tao\model\event\MetadataModified($instance, $propertyUri, $propertyValue)); } $returnValue = $instance; } catch (common_Exception $e){ $msg = "An error occured while binding property values to instance '': " . $e->getMessage(); $instanceUri = $instance->getUri(); throw new tao_models_classes_dataBinding_GenerisInstanceDataBindingException($msg); } return $returnValue; }
[ "public", "function", "bind", "(", "$", "data", ")", "{", "$", "returnValue", "=", "null", ";", "try", "{", "$", "instance", "=", "$", "this", "->", "getTargetInstance", "(", ")", ";", "$", "eventManager", "=", "\\", "oat", "\\", "oatbox", "\\", "ser...
Simply bind data from the source to a specific generis class instance. The array of the data to be bound must contain keys that are property The repspective values can be either scalar or vector (array) values or values. - If the element of the $data array is scalar, it is simply bound using - If the element of the $data array is a vector, the property values are with the values of the vector. @access public @author Jerome Bogaerts, <jerome@taotesting.com> @param array data An array of values where keys are Property URIs and values are either scalar or vector values. @return mixed
[ "Simply", "bind", "data", "from", "the", "source", "to", "a", "specific", "generis", "class", "instance", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/dataBinding/class.GenerisInstanceDataBinder.php#L100-L177
oat-sa/tao-core
helpers/class.Display.php
tao_helpers_Display.textCutter
public static function textCutter($input, $maxLength = 75) { $encoding = self::getApplicationService()->getDefaultEncoding(); if (mb_strlen($input, $encoding) > $maxLength){ $input = "<span title='$input' class='cutted' style='cursor:pointer;'>".mb_substr($input, 0, $maxLength, $encoding)."[...]</span>"; } $returnValue = $input; return (string) $returnValue; }
php
public static function textCutter($input, $maxLength = 75) { $encoding = self::getApplicationService()->getDefaultEncoding(); if (mb_strlen($input, $encoding) > $maxLength){ $input = "<span title='$input' class='cutted' style='cursor:pointer;'>".mb_substr($input, 0, $maxLength, $encoding)."[...]</span>"; } $returnValue = $input; return (string) $returnValue; }
[ "public", "static", "function", "textCutter", "(", "$", "input", ",", "$", "maxLength", "=", "75", ")", "{", "$", "encoding", "=", "self", "::", "getApplicationService", "(", ")", "->", "getDefaultEncoding", "(", ")", ";", "if", "(", "mb_strlen", "(", "$...
Enables you to cut a long string and end it with [...] and add an hover to display the complete string on mouse over. @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> @param string input The string input. @param int maxLength (optional, default = 75) The maximum length for the result string. @return string The cut string, enclosed in a <span> html tag. This tag received the 'cutted' CSS class.
[ "Enables", "you", "to", "cut", "a", "long", "string", "and", "end", "it", "with", "[", "...", "]", "and", "add", "an", "hover", "to", "display", "the", "complete", "string", "on", "mouse", "over", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Display.php#L45-L55
oat-sa/tao-core
helpers/class.Display.php
tao_helpers_Display.textCleaner
public static function textCleaner($input, $joker = '_', $maxLength = -1) { $returnValue = ''; $randJoker = ($joker == '*'); $length = ((defined('TAO_DEFAULT_ENCODING')) ? mb_strlen($input, TAO_DEFAULT_ENCODING) : mb_strlen($input)); if($maxLength > -1 ){ $length = min($length, $maxLength); } $i = 0; while ($i < $length){ if (preg_match("/^[a-zA-Z0-9_-]{1}$/u", $input[$i])){ $returnValue .= $input[$i]; } else{ if ($input[$i] == ' '){ $returnValue .= '_'; } else{ $returnValue .= ((true === $randJoker) ? chr(rand(97, 122)) : $joker); } } $i++; } return (string) $returnValue; }
php
public static function textCleaner($input, $joker = '_', $maxLength = -1) { $returnValue = ''; $randJoker = ($joker == '*'); $length = ((defined('TAO_DEFAULT_ENCODING')) ? mb_strlen($input, TAO_DEFAULT_ENCODING) : mb_strlen($input)); if($maxLength > -1 ){ $length = min($length, $maxLength); } $i = 0; while ($i < $length){ if (preg_match("/^[a-zA-Z0-9_-]{1}$/u", $input[$i])){ $returnValue .= $input[$i]; } else{ if ($input[$i] == ' '){ $returnValue .= '_'; } else{ $returnValue .= ((true === $randJoker) ? chr(rand(97, 122)) : $joker); } } $i++; } return (string) $returnValue; }
[ "public", "static", "function", "textCleaner", "(", "$", "input", ",", "$", "joker", "=", "'_'", ",", "$", "maxLength", "=", "-", "1", ")", "{", "$", "returnValue", "=", "''", ";", "$", "randJoker", "=", "(", "$", "joker", "==", "'*'", ")", ";", ...
Clean a text with a joker character to replace any characters that is alphanumeric. @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> @param string input The string input. @param string joker (optional, default = '_') A joker character that will be the alphanumeric placeholder. @param int maxLength (optional, default = -1) output maximum length @return string The result string.
[ "Clean", "a", "text", "with", "a", "joker", "character", "to", "replace", "any", "characters", "that", "is", "alphanumeric", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Display.php#L67-L94
oat-sa/tao-core
helpers/class.Display.php
tao_helpers_Display.htmlize
public static function htmlize($input) { $returnValue = htmlentities($input, ENT_COMPAT, self::getApplicationService()->getDefaultEncoding()); return (string) $returnValue; }
php
public static function htmlize($input) { $returnValue = htmlentities($input, ENT_COMPAT, self::getApplicationService()->getDefaultEncoding()); return (string) $returnValue; }
[ "public", "static", "function", "htmlize", "(", "$", "input", ")", "{", "$", "returnValue", "=", "htmlentities", "(", "$", "input", ",", "ENT_COMPAT", ",", "self", "::", "getApplicationService", "(", ")", "->", "getDefaultEncoding", "(", ")", ")", ";", "re...
Display clean and more secure text into an HTML page. The implementation of this method is done with htmlentities.This method is Unicode safe. @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> @param string input The input string. @return string The htmlized string.
[ "Display", "clean", "and", "more", "secure", "text", "into", "an", "HTML", "page", ".", "The", "implementation", "of", "this", "method", "is", "done", "with", "htmlentities", ".", "This", "method", "is", "Unicode", "safe", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Display.php#L104-L109
oat-sa/tao-core
helpers/class.Display.php
tao_helpers_Display.sanitizeXssHtml
public static function sanitizeXssHtml($input) { $config = HTMLPurifier_Config::createDefault(); //we don't use HTMLPurifier cache //because it writes serialized files inside it's own folder //so this won't work in a multi server env $config->set('Cache.DefinitionImpl', null); //allow target=_blank on links $config->set('Attr.AllowedFrameTargets', ['_blank']); $purifier = new HTMLPurifier($config); return $purifier->purify( $input ); }
php
public static function sanitizeXssHtml($input) { $config = HTMLPurifier_Config::createDefault(); //we don't use HTMLPurifier cache //because it writes serialized files inside it's own folder //so this won't work in a multi server env $config->set('Cache.DefinitionImpl', null); //allow target=_blank on links $config->set('Attr.AllowedFrameTargets', ['_blank']); $purifier = new HTMLPurifier($config); return $purifier->purify( $input ); }
[ "public", "static", "function", "sanitizeXssHtml", "(", "$", "input", ")", "{", "$", "config", "=", "HTMLPurifier_Config", "::", "createDefault", "(", ")", ";", "//we don't use HTMLPurifier cache", "//because it writes serialized files inside it's own folder", "//so this won'...
Sanitize all parts that could be used in XSS (script, style, hijacked links, etc.) and update some attributes to use a safe behavior. @see http://htmlpurifier.org/live/configdoc/plain.html @param string $input the input HTML @return string the sanitized HTML
[ "Sanitize", "all", "parts", "that", "could", "be", "used", "in", "XSS", "(", "script", "style", "hijacked", "links", "etc", ".", ")", "and", "update", "some", "attributes", "to", "use", "a", "safe", "behavior", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Display.php#L139-L153
oat-sa/tao-core
models/classes/service/class.Parameter.php
tao_models_classes_service_Parameter.fromResource
public static function fromResource(core_kernel_classes_Resource $resource) { $values = $resource->getPropertiesValues(array( WfEngineOntology::PROPERTY_ACTUAL_PARAMETER_FORMAL_PARAMETER, WfEngineOntology::PROPERTY_ACTUAL_PARAMETER_CONSTANT_VALUE, WfEngineOntology::PROPERTY_ACTUAL_PARAMETER_PROCESS_VARIABLE )); if (count($values[WfEngineOntology::PROPERTY_ACTUAL_PARAMETER_FORMAL_PARAMETER]) != 1) { throw new common_exception_InconsistentData('Actual variable '.$resource->getUri().' missing formal parameter'); } if (count($values[WfEngineOntology::PROPERTY_ACTUAL_PARAMETER_CONSTANT_VALUE]) + count($values[WfEngineOntology::PROPERTY_ACTUAL_PARAMETER_PROCESS_VARIABLE]) != 1) { throw new common_exception_InconsistentData('Actual variable '.$resource->getUri().' invalid, ' .count($values[WfEngineOntology::PROPERTY_ACTUAL_PARAMETER_CONSTANT_VALUE]).' constant values and ' .count($values[WfEngineOntology::PROPERTY_ACTUAL_PARAMETER_PROCESS_VARIABLE]).' process variables'); } if (count($values[WfEngineOntology::PROPERTY_ACTUAL_PARAMETER_CONSTANT_VALUE]) > 0) { $param = new tao_models_classes_service_ConstantParameter( current($values[WfEngineOntology::PROPERTY_ACTUAL_PARAMETER_FORMAL_PARAMETER]), current($values[WfEngineOntology::PROPERTY_ACTUAL_PARAMETER_CONSTANT_VALUE]) ); } else { $param = new tao_models_classes_service_VariableParameter( current($values[WfEngineOntology::PROPERTY_ACTUAL_PARAMETER_FORMAL_PARAMETER]), current($values[WfEngineOntology::PROPERTY_ACTUAL_PARAMETER_PROCESS_VARIABLE]) ); } return $param; }
php
public static function fromResource(core_kernel_classes_Resource $resource) { $values = $resource->getPropertiesValues(array( WfEngineOntology::PROPERTY_ACTUAL_PARAMETER_FORMAL_PARAMETER, WfEngineOntology::PROPERTY_ACTUAL_PARAMETER_CONSTANT_VALUE, WfEngineOntology::PROPERTY_ACTUAL_PARAMETER_PROCESS_VARIABLE )); if (count($values[WfEngineOntology::PROPERTY_ACTUAL_PARAMETER_FORMAL_PARAMETER]) != 1) { throw new common_exception_InconsistentData('Actual variable '.$resource->getUri().' missing formal parameter'); } if (count($values[WfEngineOntology::PROPERTY_ACTUAL_PARAMETER_CONSTANT_VALUE]) + count($values[WfEngineOntology::PROPERTY_ACTUAL_PARAMETER_PROCESS_VARIABLE]) != 1) { throw new common_exception_InconsistentData('Actual variable '.$resource->getUri().' invalid, ' .count($values[WfEngineOntology::PROPERTY_ACTUAL_PARAMETER_CONSTANT_VALUE]).' constant values and ' .count($values[WfEngineOntology::PROPERTY_ACTUAL_PARAMETER_PROCESS_VARIABLE]).' process variables'); } if (count($values[WfEngineOntology::PROPERTY_ACTUAL_PARAMETER_CONSTANT_VALUE]) > 0) { $param = new tao_models_classes_service_ConstantParameter( current($values[WfEngineOntology::PROPERTY_ACTUAL_PARAMETER_FORMAL_PARAMETER]), current($values[WfEngineOntology::PROPERTY_ACTUAL_PARAMETER_CONSTANT_VALUE]) ); } else { $param = new tao_models_classes_service_VariableParameter( current($values[WfEngineOntology::PROPERTY_ACTUAL_PARAMETER_FORMAL_PARAMETER]), current($values[WfEngineOntology::PROPERTY_ACTUAL_PARAMETER_PROCESS_VARIABLE]) ); } return $param; }
[ "public", "static", "function", "fromResource", "(", "core_kernel_classes_Resource", "$", "resource", ")", "{", "$", "values", "=", "$", "resource", "->", "getPropertiesValues", "(", "array", "(", "WfEngineOntology", "::", "PROPERTY_ACTUAL_PARAMETER_FORMAL_PARAMETER", "...
Builds a service call parameter from it's serialized form @param core_kernel_classes_Resource $resource @return tao_models_classes_service_Parameter
[ "Builds", "a", "service", "call", "parameter", "from", "it", "s", "serialized", "form" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/service/class.Parameter.php#L84-L110
oat-sa/tao-core
models/classes/search/SearchTokenGenerator.php
SearchTokenGenerator.generateTokens
public function generateTokens(\core_kernel_classes_Resource $resource) { $tokens = array(); foreach ($this->getProperties($resource) as $property) { $indexes = $this->getIndexes($property); if (!empty($indexes)) { $values = $resource->getPropertyValues($property); foreach ($indexes as $index) { $tokenizer = $index->getTokenizer(); if ($tokenizer instanceof ResourceTokenizer) { $strings = $tokenizer->getStrings($resource); } elseif ($tokenizer instanceof PropertyValueTokenizer) { $strings = $tokenizer->getStrings($values); } else { throw new \common_exception_InconsistentData('Unsupported tokenizer '.get_class($tokenizer)); } $tokens[] = array($index, $strings); } } } return $tokens; }
php
public function generateTokens(\core_kernel_classes_Resource $resource) { $tokens = array(); foreach ($this->getProperties($resource) as $property) { $indexes = $this->getIndexes($property); if (!empty($indexes)) { $values = $resource->getPropertyValues($property); foreach ($indexes as $index) { $tokenizer = $index->getTokenizer(); if ($tokenizer instanceof ResourceTokenizer) { $strings = $tokenizer->getStrings($resource); } elseif ($tokenizer instanceof PropertyValueTokenizer) { $strings = $tokenizer->getStrings($values); } else { throw new \common_exception_InconsistentData('Unsupported tokenizer '.get_class($tokenizer)); } $tokens[] = array($index, $strings); } } } return $tokens; }
[ "public", "function", "generateTokens", "(", "\\", "core_kernel_classes_Resource", "$", "resource", ")", "{", "$", "tokens", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getProperties", "(", "$", "resource", ")", "as", "$", "property", ...
returns an array of subarrays containing [index, strings] @param \core_kernel_classes_Resource $resource @throws \common_exception_InconsistentData @return array complex array
[ "returns", "an", "array", "of", "subarrays", "containing", "[", "index", "strings", "]" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/search/SearchTokenGenerator.php#L50-L70
oat-sa/tao-core
models/classes/cliArgument/ArgumentService.php
ArgumentService.load
public function load(Action $action, array $params) { /** @var Argument $argument */ foreach ($this->getArguments() as $argument) { if ($argument->isApplicable($params)) { $this->getServiceManager()->propagate($argument); $argument->load($action); } } }
php
public function load(Action $action, array $params) { /** @var Argument $argument */ foreach ($this->getArguments() as $argument) { if ($argument->isApplicable($params)) { $this->getServiceManager()->propagate($argument); $argument->load($action); } } }
[ "public", "function", "load", "(", "Action", "$", "action", ",", "array", "$", "params", ")", "{", "/** @var Argument $argument */", "foreach", "(", "$", "this", "->", "getArguments", "(", ")", "as", "$", "argument", ")", "{", "if", "(", "$", "argument", ...
Get arguments from config and check if there are applicable In case of yes, process them @param Action $action @param array $params
[ "Get", "arguments", "from", "config", "and", "check", "if", "there", "are", "applicable", "In", "case", "of", "yes", "process", "them" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/cliArgument/ArgumentService.php#L38-L47
oat-sa/tao-core
actions/class.Log.php
tao_actions_Log.log
public function log() { $result = []; if ($this->hasRequestParameter('messages')) { $messages = json_decode($this->getRawParameter('messages'), true); foreach ($messages as $message) { \common_Logger::singleton()->log($this->getLevel($message['level']), json_encode($message), ['frontend']); } } $this->returnJson($result); }
php
public function log() { $result = []; if ($this->hasRequestParameter('messages')) { $messages = json_decode($this->getRawParameter('messages'), true); foreach ($messages as $message) { \common_Logger::singleton()->log($this->getLevel($message['level']), json_encode($message), ['frontend']); } } $this->returnJson($result); }
[ "public", "function", "log", "(", ")", "{", "$", "result", "=", "[", "]", ";", "if", "(", "$", "this", "->", "hasRequestParameter", "(", "'messages'", ")", ")", "{", "$", "messages", "=", "json_decode", "(", "$", "this", "->", "getRawParameter", "(", ...
Log the message sent from client side
[ "Log", "the", "message", "sent", "from", "client", "side" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.Log.php#L34-L44
oat-sa/tao-core
actions/class.Log.php
tao_actions_Log.getLevel
private function getLevel($level) { $result = \common_Logger::TRACE_LEVEL; switch ($level) { case 'fatal' : $result = \common_Logger::FATAL_LEVEL; break; case 'error' : $result = \common_Logger::ERROR_LEVEL; break; case 'warn' : $result = \common_Logger::WARNING_LEVEL; break; case 'info' : $result = \common_Logger::INFO_LEVEL; break; case 'debug' : $result = \common_Logger::DEBUG_LEVEL; break; case 'trace' : $result = \common_Logger::DEBUG_LEVEL; break; } return $result; }
php
private function getLevel($level) { $result = \common_Logger::TRACE_LEVEL; switch ($level) { case 'fatal' : $result = \common_Logger::FATAL_LEVEL; break; case 'error' : $result = \common_Logger::ERROR_LEVEL; break; case 'warn' : $result = \common_Logger::WARNING_LEVEL; break; case 'info' : $result = \common_Logger::INFO_LEVEL; break; case 'debug' : $result = \common_Logger::DEBUG_LEVEL; break; case 'trace' : $result = \common_Logger::DEBUG_LEVEL; break; } return $result; }
[ "private", "function", "getLevel", "(", "$", "level", ")", "{", "$", "result", "=", "\\", "common_Logger", "::", "TRACE_LEVEL", ";", "switch", "(", "$", "level", ")", "{", "case", "'fatal'", ":", "$", "result", "=", "\\", "common_Logger", "::", "FATAL_LE...
Map log level @todo make it compatible with PRS-3 log levels @param $level @return int
[ "Map", "log", "level" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.Log.php#L52-L76
oat-sa/tao-core
helpers/form/elements/xhtml/class.JsonObject.php
tao_helpers_form_elements_xhtml_JsonObject.render
public function render() { $returnValue = $this->renderLabel(); if (empty($this->value) === true) { // @todo should be in a blue info box. $returnValue .= "No values to display."; } elseif (($jsonObject = @json_decode($this->value)) === null) { // @todo should be in a red error box. $returnValue .= "Invalid value."; } else { // Valid JSON to be displayed. $returnValue .= "<ul class=\"json-object-list\">"; foreach ($jsonObject as $jsonKey => $jsonValue) { $returnValue .= "<li>"; $returnValue .= "<div class=\"widget-jsonobject-key\">" . _dh($jsonKey) . ":</div>"; $returnValue .= "<div><input class=\"widget-jsonobject-value\" type=\"text\" disabled=\"disabled\" value=\"${jsonValue}\" /></</div>"; $returnValue .= "</li>"; } $returnValue .= "</ul>\n"; } return $returnValue; }
php
public function render() { $returnValue = $this->renderLabel(); if (empty($this->value) === true) { // @todo should be in a blue info box. $returnValue .= "No values to display."; } elseif (($jsonObject = @json_decode($this->value)) === null) { // @todo should be in a red error box. $returnValue .= "Invalid value."; } else { // Valid JSON to be displayed. $returnValue .= "<ul class=\"json-object-list\">"; foreach ($jsonObject as $jsonKey => $jsonValue) { $returnValue .= "<li>"; $returnValue .= "<div class=\"widget-jsonobject-key\">" . _dh($jsonKey) . ":</div>"; $returnValue .= "<div><input class=\"widget-jsonobject-value\" type=\"text\" disabled=\"disabled\" value=\"${jsonValue}\" /></</div>"; $returnValue .= "</li>"; } $returnValue .= "</ul>\n"; } return $returnValue; }
[ "public", "function", "render", "(", ")", "{", "$", "returnValue", "=", "$", "this", "->", "renderLabel", "(", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "value", ")", "===", "true", ")", "{", "// @todo should be in a blue info box.", "$", "re...
Render the JSON String as a collection of key/value pairs @return string
[ "Render", "the", "JSON", "String", "as", "a", "collection", "of", "key", "/", "value", "pairs" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/elements/xhtml/class.JsonObject.php#L35-L62
oat-sa/tao-core
models/classes/Tree/GetTreeRequest.php
GetTreeRequest.create
public static function create(Request $request) { if ($request->hasParameter('classUri')) { $classUri = tao_helpers_Uri::decode($request->getParameter('classUri')); $class = new core_kernel_classes_Class($classUri); $hideNode = true; } elseif ($request->hasParameter('rootNode')) { $class = new core_kernel_classes_Class($request->getParameter('rootNode')); $hideNode = false; } else { throw new common_Exception('Missing node information for ' . __FUNCTION__); } $openNodes = array($class->getUri()); $openNodesParameter = $request->getParameter('openNodes'); $openParentNodesParameter = $request->getParameter('openParentNodes'); if ($request->hasParameter('openNodes') && is_array($openNodesParameter)) { $openNodes = array_merge($openNodes, $openNodesParameter); } else if ($request->hasParameter('openParentNodes') && is_array($openParentNodesParameter)) { $childNodes = $openParentNodesParameter; $openNodes = TreeHelper::getNodesToOpen($childNodes, $class); } $limit = $request->hasParameter('limit') ? $request->getParameter('limit') : self::DEFAULT_LIMIT; $offset = $request->hasParameter('offset') ? $request->getParameter('offset') : 0; $showInstance = $request->hasParameter('hideInstances') ? !$request->getParameter('hideInstances') : true; $orderProp = $request->hasParameter('order') ? $request->getParameter('order') : OntologyRdfs::RDFS_LABEL; $orderDir = $request->hasParameter('orderdir') ? $request->getParameter('orderdir') : self::DEFAULT_ORDERDIR; $filterProperties = []; if ($request->hasParameter('filterProperties')) { $filterProperties = $request->getParameter('filterProperties'); if (!is_array($filterProperties)) { $filterProperties = []; } } return new self( $class, $limit, $offset, $showInstance, $hideNode, $openNodes, [], [ 'order' => [ $orderProp => $orderDir ] ], $filterProperties ); }
php
public static function create(Request $request) { if ($request->hasParameter('classUri')) { $classUri = tao_helpers_Uri::decode($request->getParameter('classUri')); $class = new core_kernel_classes_Class($classUri); $hideNode = true; } elseif ($request->hasParameter('rootNode')) { $class = new core_kernel_classes_Class($request->getParameter('rootNode')); $hideNode = false; } else { throw new common_Exception('Missing node information for ' . __FUNCTION__); } $openNodes = array($class->getUri()); $openNodesParameter = $request->getParameter('openNodes'); $openParentNodesParameter = $request->getParameter('openParentNodes'); if ($request->hasParameter('openNodes') && is_array($openNodesParameter)) { $openNodes = array_merge($openNodes, $openNodesParameter); } else if ($request->hasParameter('openParentNodes') && is_array($openParentNodesParameter)) { $childNodes = $openParentNodesParameter; $openNodes = TreeHelper::getNodesToOpen($childNodes, $class); } $limit = $request->hasParameter('limit') ? $request->getParameter('limit') : self::DEFAULT_LIMIT; $offset = $request->hasParameter('offset') ? $request->getParameter('offset') : 0; $showInstance = $request->hasParameter('hideInstances') ? !$request->getParameter('hideInstances') : true; $orderProp = $request->hasParameter('order') ? $request->getParameter('order') : OntologyRdfs::RDFS_LABEL; $orderDir = $request->hasParameter('orderdir') ? $request->getParameter('orderdir') : self::DEFAULT_ORDERDIR; $filterProperties = []; if ($request->hasParameter('filterProperties')) { $filterProperties = $request->getParameter('filterProperties'); if (!is_array($filterProperties)) { $filterProperties = []; } } return new self( $class, $limit, $offset, $showInstance, $hideNode, $openNodes, [], [ 'order' => [ $orderProp => $orderDir ] ], $filterProperties ); }
[ "public", "static", "function", "create", "(", "Request", "$", "request", ")", "{", "if", "(", "$", "request", "->", "hasParameter", "(", "'classUri'", ")", ")", "{", "$", "classUri", "=", "tao_helpers_Uri", "::", "decode", "(", "$", "request", "->", "ge...
@param Request $request @return GetTreeRequest @throws common_Exception
[ "@param", "Request", "$request", "@return", "GetTreeRequest" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/Tree/GetTreeRequest.php#L75-L129
oat-sa/tao-core
models/classes/routing/TaoFrontController.php
TaoFrontController.legacy
public function legacy(common_http_Request $pRequest) { $request = ServerRequest::fromGlobals(); $response = new Response(); $this($request, $response); }
php
public function legacy(common_http_Request $pRequest) { $request = ServerRequest::fromGlobals(); $response = new Response(); $this($request, $response); }
[ "public", "function", "legacy", "(", "common_http_Request", "$", "pRequest", ")", "{", "$", "request", "=", "ServerRequest", "::", "fromGlobals", "(", ")", ";", "$", "response", "=", "new", "Response", "(", ")", ";", "$", "this", "(", "$", "request", ","...
Run the controller @deprecated use $this->__invoke() instead @param common_http_Request $pRequest @throws \ActionEnforcingException @throws \common_exception_Error @throws \common_exception_InvalidArgumentType @throws \common_ext_ExtensionException
[ "Run", "the", "controller" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/routing/TaoFrontController.php#L116-L121
oat-sa/tao-core
models/classes/accessControl/AclProxy.php
AclProxy.getImplementations
protected static function getImplementations() { if (is_null(self::$implementations)) { self::$implementations = array( new FuncProxy(), new DataAccessControl() ); /* $taoExt = \common_ext_ExtensionsManager::singleton()->getExtensionById('tao'); self::$implementations = array(); foreach ($taoExt->getConfig('accessControl') as $acClass) { if (class_exists($acClass) && in_array('oat\tao\model\accessControl\AccessControl', class_implements($acClass))) { self::$implementations[] = new $acClass(); } else { throw new \common_exception_Error('Unsupported class '.$acClass); } } */ } return self::$implementations; }
php
protected static function getImplementations() { if (is_null(self::$implementations)) { self::$implementations = array( new FuncProxy(), new DataAccessControl() ); /* $taoExt = \common_ext_ExtensionsManager::singleton()->getExtensionById('tao'); self::$implementations = array(); foreach ($taoExt->getConfig('accessControl') as $acClass) { if (class_exists($acClass) && in_array('oat\tao\model\accessControl\AccessControl', class_implements($acClass))) { self::$implementations[] = new $acClass(); } else { throw new \common_exception_Error('Unsupported class '.$acClass); } } */ } return self::$implementations; }
[ "protected", "static", "function", "getImplementations", "(", ")", "{", "if", "(", "is_null", "(", "self", "::", "$", "implementations", ")", ")", "{", "self", "::", "$", "implementations", "=", "array", "(", "new", "FuncProxy", "(", ")", ",", "new", "Da...
get the current access control implementations @return array
[ "get", "the", "current", "access", "control", "implementations" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/accessControl/AclProxy.php#L47-L67
oat-sa/tao-core
models/classes/accessControl/AclProxy.php
AclProxy.hasAccess
public static function hasAccess(User $user, $controller, $action, $parameters) { $access = true; foreach (self::getImplementations() as $impl) { $access = $access && $impl->hasAccess($user, $controller, $action, $parameters); } return $access; }
php
public static function hasAccess(User $user, $controller, $action, $parameters) { $access = true; foreach (self::getImplementations() as $impl) { $access = $access && $impl->hasAccess($user, $controller, $action, $parameters); } return $access; }
[ "public", "static", "function", "hasAccess", "(", "User", "$", "user", ",", "$", "controller", ",", "$", "action", ",", "$", "parameters", ")", "{", "$", "access", "=", "true", ";", "foreach", "(", "self", "::", "getImplementations", "(", ")", "as", "$...
Returns whenever or not a user has access to a specified link @param string $action @param string $controller @param string $extension @param array $parameters @return boolean
[ "Returns", "whenever", "or", "not", "a", "user", "has", "access", "to", "a", "specified", "link" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/accessControl/AclProxy.php#L78-L84
oat-sa/tao-core
models/classes/websource/BaseWebsource.php
BaseWebsource.spawn
protected static function spawn($fileSystemId, $customConfig = array()) { $customConfig[self::OPTION_FILESYSTEM_ID] = $fileSystemId; $customConfig[self::OPTION_ID] = uniqid(); $webSource = new static($customConfig); WebsourceManager::singleton()->addWebsource($webSource); return $webSource; }
php
protected static function spawn($fileSystemId, $customConfig = array()) { $customConfig[self::OPTION_FILESYSTEM_ID] = $fileSystemId; $customConfig[self::OPTION_ID] = uniqid(); $webSource = new static($customConfig); WebsourceManager::singleton()->addWebsource($webSource); return $webSource; }
[ "protected", "static", "function", "spawn", "(", "$", "fileSystemId", ",", "$", "customConfig", "=", "array", "(", ")", ")", "{", "$", "customConfig", "[", "self", "::", "OPTION_FILESYSTEM_ID", "]", "=", "$", "fileSystemId", ";", "$", "customConfig", "[", ...
Used to instantiate new AccessProviders @param $fileSystemId @param array $customConfig @return BaseWebsource @throws \common_Exception
[ "Used", "to", "instantiate", "new", "AccessProviders" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/websource/BaseWebsource.php#L63-L70
oat-sa/tao-core
models/classes/websource/BaseWebsource.php
BaseWebsource.getMimetype
public function getMimetype($filePath) { $mimeType = $this->getFileSystem()->getMimetype($filePath); $pathParts = pathinfo($filePath); if (isset($pathParts['extension'])) { //manage bugs in finfo switch ($pathParts['extension']) { case 'js': if ($mimeType === 'text/plain' || $mimeType === 'text/x-asm' || $mimeType === 'text/x-c') { return 'text/javascript'; } break; case 'css': //for css files mime type can be 'text/plain' due to bug in finfo (see more: https://bugs.php.net/bug.php?id=53035) if ($mimeType === 'text/plain' || $mimeType === 'text/x-asm') { return 'text/css'; } break; case 'svg': if ($mimeType === 'text/plain') { return 'image/svg+xml'; } break; case 'mp3': return 'audio/mpeg'; break; } } return $mimeType; }
php
public function getMimetype($filePath) { $mimeType = $this->getFileSystem()->getMimetype($filePath); $pathParts = pathinfo($filePath); if (isset($pathParts['extension'])) { //manage bugs in finfo switch ($pathParts['extension']) { case 'js': if ($mimeType === 'text/plain' || $mimeType === 'text/x-asm' || $mimeType === 'text/x-c') { return 'text/javascript'; } break; case 'css': //for css files mime type can be 'text/plain' due to bug in finfo (see more: https://bugs.php.net/bug.php?id=53035) if ($mimeType === 'text/plain' || $mimeType === 'text/x-asm') { return 'text/css'; } break; case 'svg': if ($mimeType === 'text/plain') { return 'image/svg+xml'; } break; case 'mp3': return 'audio/mpeg'; break; } } return $mimeType; }
[ "public", "function", "getMimetype", "(", "$", "filePath", ")", "{", "$", "mimeType", "=", "$", "this", "->", "getFileSystem", "(", ")", "->", "getMimetype", "(", "$", "filePath", ")", ";", "$", "pathParts", "=", "pathinfo", "(", "$", "filePath", ")", ...
Get a file's mime-type. @param string $filePath The path to the file. @return string|false The file mime-type or false on failure. @throws \common_exception_Error @throws \common_exception_NotFound
[ "Get", "a", "file", "s", "mime", "-", "type", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/websource/BaseWebsource.php#L124-L155
oat-sa/tao-core
models/classes/mvc/error/ExceptionInterpretor.php
ExceptionInterpretor.interpretError
protected function interpretError() { switch (get_class($this->exception)) { case UserErrorException::class: case tao_models_classes_MissingRequestParameterException::class: case common_exception_MissingParameter::class: case common_exception_BadRequest::class: $this->returnHttpCode = 400; $this->responseClassName = 'MainResponse'; break; case 'tao_models_classes_AccessDeniedException': case 'ResolverException': $this->returnHttpCode = 403; $this->responseClassName = 'RedirectResponse'; break; case 'tao_models_classes_UserException': $this->returnHttpCode = 403; $this->responseClassName = 'MainResponse'; break; case 'ActionEnforcingException': case 'tao_models_classes_FileNotFoundException': $this->returnHttpCode = 404; $this->responseClassName = 'MainResponse'; break; default : $this->responseClassName = 'MainResponse'; $this->returnHttpCode = 500; break; } return $this; }
php
protected function interpretError() { switch (get_class($this->exception)) { case UserErrorException::class: case tao_models_classes_MissingRequestParameterException::class: case common_exception_MissingParameter::class: case common_exception_BadRequest::class: $this->returnHttpCode = 400; $this->responseClassName = 'MainResponse'; break; case 'tao_models_classes_AccessDeniedException': case 'ResolverException': $this->returnHttpCode = 403; $this->responseClassName = 'RedirectResponse'; break; case 'tao_models_classes_UserException': $this->returnHttpCode = 403; $this->responseClassName = 'MainResponse'; break; case 'ActionEnforcingException': case 'tao_models_classes_FileNotFoundException': $this->returnHttpCode = 404; $this->responseClassName = 'MainResponse'; break; default : $this->responseClassName = 'MainResponse'; $this->returnHttpCode = 500; break; } return $this; }
[ "protected", "function", "interpretError", "(", ")", "{", "switch", "(", "get_class", "(", "$", "this", "->", "exception", ")", ")", "{", "case", "UserErrorException", "::", "class", ":", "case", "tao_models_classes_MissingRequestParameterException", "::", "class", ...
interpret exception type and set up render responseClassName and http status to return
[ "interpret", "exception", "type", "and", "set", "up", "render", "responseClassName", "and", "http", "status", "to", "return" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/mvc/error/ExceptionInterpretor.php#L76-L106
oat-sa/tao-core
models/classes/mvc/error/ExceptionInterpretor.php
ExceptionInterpretor.getResponse
public function getResponse() { $class = $this->getResponseClassName(); /** @var $response ResponseAbstract */ $response = new $class; $response->setServiceLocator($this->getServiceLocator()); $response->setException($this->exception) ->setHttpCode($this->returnHttpCode) ->trace(); return $response; }
php
public function getResponse() { $class = $this->getResponseClassName(); /** @var $response ResponseAbstract */ $response = new $class; $response->setServiceLocator($this->getServiceLocator()); $response->setException($this->exception) ->setHttpCode($this->returnHttpCode) ->trace(); return $response; }
[ "public", "function", "getResponse", "(", ")", "{", "$", "class", "=", "$", "this", "->", "getResponseClassName", "(", ")", ";", "/** @var $response ResponseAbstract */", "$", "response", "=", "new", "$", "class", ";", "$", "response", "->", "setServiceLocator",...
return an instance of ResponseInterface @return ResponseAbstract
[ "return", "an", "instance", "of", "ResponseInterface" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/mvc/error/ExceptionInterpretor.php#L130-L140
oat-sa/tao-core
models/classes/taskQueue/TaskLog/Decorator/CategoryEntityDecorator.php
CategoryEntityDecorator.toArray
public function toArray() { $result = parent::toArray(); $result['category'] = $this->taskLogService->getCategoryForTask($this->getTaskName()); return $result; }
php
public function toArray() { $result = parent::toArray(); $result['category'] = $this->taskLogService->getCategoryForTask($this->getTaskName()); return $result; }
[ "public", "function", "toArray", "(", ")", "{", "$", "result", "=", "parent", "::", "toArray", "(", ")", ";", "$", "result", "[", "'category'", "]", "=", "$", "this", "->", "taskLogService", "->", "getCategoryForTask", "(", "$", "this", "->", "getTaskNam...
Add category to the result. Required by our frontend. @return array
[ "Add", "category", "to", "the", "result", ".", "Required", "by", "our", "frontend", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/taskQueue/TaskLog/Decorator/CategoryEntityDecorator.php#L56-L63
oat-sa/tao-core
helpers/form/class.FormElement.php
tao_helpers_form_FormElement.addClass
public function addClass($className) { $existingClasses = !empty($this->attributes['class']) ? explode(' ',$this->attributes['class']) : array(); $existingClasses[] = $className; $this->attributes['class'] = implode(' ', array_unique($existingClasses)); }
php
public function addClass($className) { $existingClasses = !empty($this->attributes['class']) ? explode(' ',$this->attributes['class']) : array(); $existingClasses[] = $className; $this->attributes['class'] = implode(' ', array_unique($existingClasses)); }
[ "public", "function", "addClass", "(", "$", "className", ")", "{", "$", "existingClasses", "=", "!", "empty", "(", "$", "this", "->", "attributes", "[", "'class'", "]", ")", "?", "explode", "(", "' '", ",", "$", "this", "->", "attributes", "[", "'class...
Add a CSS class jQuery style @author Dieter Raber, <dieter@taotesting.com> @param string $className
[ "Add", "a", "CSS", "class", "jQuery", "style" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/class.FormElement.php#L199-L206
oat-sa/tao-core
helpers/form/class.FormElement.php
tao_helpers_form_FormElement.removeClass
public function removeClass($className) { $existingClasses = !empty($this->attributes['class']) ? explode(' ',$this->attributes['class']) : array(); unset($existingClasses[array_search($className, $existingClasses)]); $this->attributes['class'] = implode(' ', $existingClasses); }
php
public function removeClass($className) { $existingClasses = !empty($this->attributes['class']) ? explode(' ',$this->attributes['class']) : array(); unset($existingClasses[array_search($className, $existingClasses)]); $this->attributes['class'] = implode(' ', $existingClasses); }
[ "public", "function", "removeClass", "(", "$", "className", ")", "{", "$", "existingClasses", "=", "!", "empty", "(", "$", "this", "->", "attributes", "[", "'class'", "]", ")", "?", "explode", "(", "' '", ",", "$", "this", "->", "attributes", "[", "'cl...
Remove a CSS class jQuery style @author Dieter Raber, <dieter@taotesting.com> @param string $className
[ "Remove", "a", "CSS", "class", "jQuery", "style" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/class.FormElement.php#L215-L222
oat-sa/tao-core
helpers/form/class.FormElement.php
tao_helpers_form_FormElement.getDescription
public function getDescription() { if(empty($this->description)){ $returnValue = ucfirst(strtolower($this->name)); } else{ $returnValue = $this->description; } return (string) $returnValue; }
php
public function getDescription() { if(empty($this->description)){ $returnValue = ucfirst(strtolower($this->name)); } else{ $returnValue = $this->description; } return (string) $returnValue; }
[ "public", "function", "getDescription", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "description", ")", ")", "{", "$", "returnValue", "=", "ucfirst", "(", "strtolower", "(", "$", "this", "->", "name", ")", ")", ";", "}", "else", "{", ...
Short description of method getDescription @author Joel Bout, <joel@taotesting.com> @return string
[ "Short", "description", "of", "method", "getDescription" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/class.FormElement.php#L298-L309
oat-sa/tao-core
helpers/form/class.FormElement.php
tao_helpers_form_FormElement.addValidator
public function addValidator(ValidatorInterface $validator) { if ($validator instanceof tao_helpers_form_validators_NotEmpty) { $this->addAttribute('required', true); } $this->validators[] = $validator; }
php
public function addValidator(ValidatorInterface $validator) { if ($validator instanceof tao_helpers_form_validators_NotEmpty) { $this->addAttribute('required', true); } $this->validators[] = $validator; }
[ "public", "function", "addValidator", "(", "ValidatorInterface", "$", "validator", ")", "{", "if", "(", "$", "validator", "instanceof", "tao_helpers_form_validators_NotEmpty", ")", "{", "$", "this", "->", "addAttribute", "(", "'required'", ",", "true", ")", ";", ...
Short description of method addValidator @author Joel Bout, <joel@taotesting.com> @param ValidatorInterface $validator
[ "Short", "description", "of", "method", "addValidator" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/class.FormElement.php#L364-L370
oat-sa/tao-core
helpers/form/class.FormElement.php
tao_helpers_form_FormElement.validate
public function validate() { $returnValue = true; if(!$this->forcedValid){ foreach($this->validators as $validator){ if(!$validator->evaluate($this->getRawValue())){ $this->error[] = $validator->getMessage(); $returnValue = false; common_Logger::d($this->getName().' is invalid for '.$validator->getName(), array('TAO')); if ($this->isBreakOnFirstError()){ break; } } } } return $returnValue; }
php
public function validate() { $returnValue = true; if(!$this->forcedValid){ foreach($this->validators as $validator){ if(!$validator->evaluate($this->getRawValue())){ $this->error[] = $validator->getMessage(); $returnValue = false; common_Logger::d($this->getName().' is invalid for '.$validator->getName(), array('TAO')); if ($this->isBreakOnFirstError()){ break; } } } } return $returnValue; }
[ "public", "function", "validate", "(", ")", "{", "$", "returnValue", "=", "true", ";", "if", "(", "!", "$", "this", "->", "forcedValid", ")", "{", "foreach", "(", "$", "this", "->", "validators", "as", "$", "validator", ")", "{", "if", "(", "!", "$...
Short description of method validate @author Joel Bout, <joel@taotesting.com> @return boolean
[ "Short", "description", "of", "method", "validate" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/class.FormElement.php#L403-L421
oat-sa/tao-core
helpers/form/class.FormElement.php
tao_helpers_form_FormElement.removeValidator
public function removeValidator($name) { $returnValue = false; $name = (string) $name; if(strpos($name, 'tao_helpers_form_validators_') === 0){ $name = str_replace('tao_helpers_form_validators_', '', $name); } if(isset($this->validators[$name])){ unset($this->validators[$name]); $returnValue = true; } return $returnValue; }
php
public function removeValidator($name) { $returnValue = false; $name = (string) $name; if(strpos($name, 'tao_helpers_form_validators_') === 0){ $name = str_replace('tao_helpers_form_validators_', '', $name); } if(isset($this->validators[$name])){ unset($this->validators[$name]); $returnValue = true; } return $returnValue; }
[ "public", "function", "removeValidator", "(", "$", "name", ")", "{", "$", "returnValue", "=", "false", ";", "$", "name", "=", "(", "string", ")", "$", "name", ";", "if", "(", "strpos", "(", "$", "name", ",", "'tao_helpers_form_validators_'", ")", "===", ...
Short description of method removeValidator @author Joel Bout, <joel@taotesting.com> @param string $name @return boolean
[ "Short", "description", "of", "method", "removeValidator" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/class.FormElement.php#L464-L478
oat-sa/tao-core
helpers/form/class.FormElement.php
tao_helpers_form_FormElement.feed
public function feed() { if (isset( $_POST[$this->name] ) && $this->name !== 'uri' && $this->name !== 'classUri' ) { $this->setValue( tao_helpers_Uri::decode( $_POST[$this->name] ) ); } }
php
public function feed() { if (isset( $_POST[$this->name] ) && $this->name !== 'uri' && $this->name !== 'classUri' ) { $this->setValue( tao_helpers_Uri::decode( $_POST[$this->name] ) ); } }
[ "public", "function", "feed", "(", ")", "{", "if", "(", "isset", "(", "$", "_POST", "[", "$", "this", "->", "name", "]", ")", "&&", "$", "this", "->", "name", "!==", "'uri'", "&&", "$", "this", "->", "name", "!==", "'classUri'", ")", "{", "$", ...
Reads the submitted data into the form element @author Joel Bout, <joel@taotesting.com>
[ "Reads", "the", "submitted", "data", "into", "the", "form", "element" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/class.FormElement.php#L485-L492
oat-sa/tao-core
helpers/class.Javascript.php
tao_helpers_Javascript.buildObject
public static function buildObject($var, $format = false){ if (is_array($var)) { $returnValue = '{'; $i = 1; foreach($var as $k => $v){ $k = is_int($k)?'"'.json_encode($k).'"':json_encode($k); $returnValue .= $k.':'.self::buildObject($v, $format); $returnValue .= ($i < count($var)) ? ',' : ''; $returnValue .= $format ? PHP_EOL : ''; $i++; } $returnValue .= '}'; } else { // Some versions of PHP simply fail // when encoding non UTF-8 data. Some other // versions return null... If it fails, simply // reproduce a single failure scenario. $returnValue = @json_encode($var); if ($returnValue === false) { $returnValue = json_encode(null); } } return $returnValue; }
php
public static function buildObject($var, $format = false){ if (is_array($var)) { $returnValue = '{'; $i = 1; foreach($var as $k => $v){ $k = is_int($k)?'"'.json_encode($k).'"':json_encode($k); $returnValue .= $k.':'.self::buildObject($v, $format); $returnValue .= ($i < count($var)) ? ',' : ''; $returnValue .= $format ? PHP_EOL : ''; $i++; } $returnValue .= '}'; } else { // Some versions of PHP simply fail // when encoding non UTF-8 data. Some other // versions return null... If it fails, simply // reproduce a single failure scenario. $returnValue = @json_encode($var); if ($returnValue === false) { $returnValue = json_encode(null); } } return $returnValue; }
[ "public", "static", "function", "buildObject", "(", "$", "var", ",", "$", "format", "=", "false", ")", "{", "if", "(", "is_array", "(", "$", "var", ")", ")", "{", "$", "returnValue", "=", "'{'", ";", "$", "i", "=", "1", ";", "foreach", "(", "$", ...
converts a php array or string into a javascript format @access public @author Joel Bout, <joel@taotesting.com> @param mixed $var @param boolean format @return string
[ "converts", "a", "php", "array", "or", "string", "into", "a", "javascript", "format" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Javascript.php#L44-L70
oat-sa/tao-core
actions/class.SaSModule.php
tao_actions_SaSModule.sasSelect
public function sasSelect() { $context = Context::getInstance(); $module = $context->getModuleName(); $this->setData('treeName', __('Select')); $this->setData('dataUrl', _url('sasGetOntologyData')); $this->setData('editClassUrl', tao_helpers_Uri::url('sasSet', $module)); if($this->getRequestParameter('selectInstance') == 'true'){ $this->setData('editInstanceUrl', tao_helpers_Uri::url('sasSet', $module)); $this->setData('editClassUrl', false); } else{ $this->setData('editInstanceUrl', false); $this->setData('editClassUrl', tao_helpers_Uri::url('sasSet', $module)); } $this->setData('classLabel', $this->getRootClass()->getLabel()); $this->setView("sas/select.tpl", 'tao'); }
php
public function sasSelect() { $context = Context::getInstance(); $module = $context->getModuleName(); $this->setData('treeName', __('Select')); $this->setData('dataUrl', _url('sasGetOntologyData')); $this->setData('editClassUrl', tao_helpers_Uri::url('sasSet', $module)); if($this->getRequestParameter('selectInstance') == 'true'){ $this->setData('editInstanceUrl', tao_helpers_Uri::url('sasSet', $module)); $this->setData('editClassUrl', false); } else{ $this->setData('editInstanceUrl', false); $this->setData('editClassUrl', tao_helpers_Uri::url('sasSet', $module)); } $this->setData('classLabel', $this->getRootClass()->getLabel()); $this->setView("sas/select.tpl", 'tao'); }
[ "public", "function", "sasSelect", "(", ")", "{", "$", "context", "=", "Context", "::", "getInstance", "(", ")", ";", "$", "module", "=", "$", "context", "->", "getModuleName", "(", ")", ";", "$", "this", "->", "setData", "(", "'treeName'", ",", "__", ...
Service of class or instance selection with a tree. @return void
[ "Service", "of", "class", "or", "instance", "selection", "with", "a", "tree", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.SaSModule.php#L74-L95
oat-sa/tao-core
actions/class.SaSModule.php
tao_actions_SaSModule.sasSet
public function sasSet() { $message = __('Error'); //set the class uri if($this->hasRequestParameter('classUri')){ $clazz = $this->getCurrentClass(); if(!is_null($clazz)){ $this->setVariables(array($this->getDataKind().'ClassUri' => $clazz->getUri())); $message = $clazz->getLabel().' '.__('class selected'); } } //set the instance uri if($this->hasRequestParameter('uri')){ $instance = $this->getCurrentInstance(); if(!is_null($instance)){ $this->setVariables(array($this->getDataKind().'Uri' => $instance->getUri())); $message = __('%s %s selected', $instance->getLabel(), $this->getDataKind()); } } $this->setData('message', $message); //only for the notification $this->setView('messages.tpl', 'tao'); }
php
public function sasSet() { $message = __('Error'); //set the class uri if($this->hasRequestParameter('classUri')){ $clazz = $this->getCurrentClass(); if(!is_null($clazz)){ $this->setVariables(array($this->getDataKind().'ClassUri' => $clazz->getUri())); $message = $clazz->getLabel().' '.__('class selected'); } } //set the instance uri if($this->hasRequestParameter('uri')){ $instance = $this->getCurrentInstance(); if(!is_null($instance)){ $this->setVariables(array($this->getDataKind().'Uri' => $instance->getUri())); $message = __('%s %s selected', $instance->getLabel(), $this->getDataKind()); } } $this->setData('message', $message); //only for the notification $this->setView('messages.tpl', 'tao'); }
[ "public", "function", "sasSet", "(", ")", "{", "$", "message", "=", "__", "(", "'Error'", ")", ";", "//set the class uri", "if", "(", "$", "this", "->", "hasRequestParameter", "(", "'classUri'", ")", ")", "{", "$", "clazz", "=", "$", "this", "->", "get...
Save the uri or the classUri in parameter into the workflow engine by using the dedicated seervice @return void
[ "Save", "the", "uri", "or", "the", "classUri", "in", "parameter", "into", "the", "workflow", "engine", "by", "using", "the", "dedicated", "seervice" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.SaSModule.php#L101-L126
oat-sa/tao-core
actions/class.SaSModule.php
tao_actions_SaSModule.sasAddInstance
public function sasAddInstance() { try { $clazz = $this->getCurrentClass(); } catch (common_Exception $e) { $clazz = $this->getRootClass(); } // @todo call the correct service $instance = $this->getClassService()->createInstance($clazz); if(!is_null($instance) && $instance instanceof core_kernel_classes_Resource){ //init variable service: $this->setVariables(array($this->getDataKind().'Uri' => $instance->getUri())); $params = array( 'uri' => tao_helpers_Uri::encode($instance->getUri()), 'classUri' => tao_helpers_Uri::encode($clazz->getUri()), 'standalone' => $this->isStandAlone() ); $this->redirect(_url('sasEditInstance', null, null, $params)); } }
php
public function sasAddInstance() { try { $clazz = $this->getCurrentClass(); } catch (common_Exception $e) { $clazz = $this->getRootClass(); } // @todo call the correct service $instance = $this->getClassService()->createInstance($clazz); if(!is_null($instance) && $instance instanceof core_kernel_classes_Resource){ //init variable service: $this->setVariables(array($this->getDataKind().'Uri' => $instance->getUri())); $params = array( 'uri' => tao_helpers_Uri::encode($instance->getUri()), 'classUri' => tao_helpers_Uri::encode($clazz->getUri()), 'standalone' => $this->isStandAlone() ); $this->redirect(_url('sasEditInstance', null, null, $params)); } }
[ "public", "function", "sasAddInstance", "(", ")", "{", "try", "{", "$", "clazz", "=", "$", "this", "->", "getCurrentClass", "(", ")", ";", "}", "catch", "(", "common_Exception", "$", "e", ")", "{", "$", "clazz", "=", "$", "this", "->", "getRootClass", ...
Add a new instance @return void
[ "Add", "a", "new", "instance" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.SaSModule.php#L132-L153
oat-sa/tao-core
actions/class.SaSModule.php
tao_actions_SaSModule.sasDeleteInstance
public function sasDeleteInstance() { $clazz = $this->getCurrentClass(); $instance = $this->getCurrentInstance(); $this->setData('label', $instance->getLabel()); $this->setData('uri', tao_helpers_Uri::encode($instance->getUri())); $this->setData('classUri', tao_helpers_Uri::encode($clazz->getUri())); $this->setView('sas/delete.tpl', 'tao'); }
php
public function sasDeleteInstance() { $clazz = $this->getCurrentClass(); $instance = $this->getCurrentInstance(); $this->setData('label', $instance->getLabel()); $this->setData('uri', tao_helpers_Uri::encode($instance->getUri())); $this->setData('classUri', tao_helpers_Uri::encode($clazz->getUri())); $this->setView('sas/delete.tpl', 'tao'); }
[ "public", "function", "sasDeleteInstance", "(", ")", "{", "$", "clazz", "=", "$", "this", "->", "getCurrentClass", "(", ")", ";", "$", "instance", "=", "$", "this", "->", "getCurrentInstance", "(", ")", ";", "$", "this", "->", "setData", "(", "'label'", ...
Delete an instance @return void
[ "Delete", "an", "instance" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.SaSModule.php#L187-L197
oat-sa/tao-core
actions/class.SaSModule.php
tao_actions_SaSModule.getCurrentClass
protected function getCurrentClass() { $classUri = tao_helpers_Uri::decode($this->getRequestParameter('classUri')); if ($this->isStandAlone() && (is_null($classUri) || empty($classUri))) { return $this->getRootClass(); } else { return parent::getCurrentClass(); } }
php
protected function getCurrentClass() { $classUri = tao_helpers_Uri::decode($this->getRequestParameter('classUri')); if ($this->isStandAlone() && (is_null($classUri) || empty($classUri))) { return $this->getRootClass(); } else { return parent::getCurrentClass(); } }
[ "protected", "function", "getCurrentClass", "(", ")", "{", "$", "classUri", "=", "tao_helpers_Uri", "::", "decode", "(", "$", "this", "->", "getRequestParameter", "(", "'classUri'", ")", ")", ";", "if", "(", "$", "this", "->", "isStandAlone", "(", ")", "&&...
get the current item class regarding the classUri' request parameter prevent exception by returning the root class if no class is selected @return core_kernel_classes_Class the item class
[ "get", "the", "current", "item", "class", "regarding", "the", "classUri", "request", "parameter", "prevent", "exception", "by", "returning", "the", "root", "class", "if", "no", "class", "is", "selected" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.SaSModule.php#L207-L215
oat-sa/tao-core
actions/class.SaSModule.php
tao_actions_SaSModule.sasGetOntologyData
public function sasGetOntologyData() { if(!$this->isXmlHttpRequest()){ throw new common_exception_IsAjaxAction(__FUNCTION__); } $showInstances = $this->hasRequestParameter('hideInstances') ? !(bool)$this->getRequestParameter('hideInstances') : true; $hideNode = $this->hasRequestParameter('classUri'); $clazz = $this->hasRequestParameter('classUri') ? $this->getCurrentClass() : $this->getRootClass(); if($this->hasRequestParameter('offset')){ $options['offset'] = $this->getRequestParameter('offset'); } $limit = $this->hasRequestParameter('limit') ? $this->getRequestParameter('limit') : 0; $offset = $this->hasRequestParameter('offset') ? $this->getRequestParameter('offset') : 0; $factory = new GenerisTreeFactory($showInstances, array($clazz->getUri()), $limit, $offset); $tree = $factory->buildTree($clazz); $returnValue = $hideNode ? ($tree['children']) : $tree; $this->returnJson($returnValue); }
php
public function sasGetOntologyData() { if(!$this->isXmlHttpRequest()){ throw new common_exception_IsAjaxAction(__FUNCTION__); } $showInstances = $this->hasRequestParameter('hideInstances') ? !(bool)$this->getRequestParameter('hideInstances') : true; $hideNode = $this->hasRequestParameter('classUri'); $clazz = $this->hasRequestParameter('classUri') ? $this->getCurrentClass() : $this->getRootClass(); if($this->hasRequestParameter('offset')){ $options['offset'] = $this->getRequestParameter('offset'); } $limit = $this->hasRequestParameter('limit') ? $this->getRequestParameter('limit') : 0; $offset = $this->hasRequestParameter('offset') ? $this->getRequestParameter('offset') : 0; $factory = new GenerisTreeFactory($showInstances, array($clazz->getUri()), $limit, $offset); $tree = $factory->buildTree($clazz); $returnValue = $hideNode ? ($tree['children']) : $tree; $this->returnJson($returnValue); }
[ "public", "function", "sasGetOntologyData", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isXmlHttpRequest", "(", ")", ")", "{", "throw", "new", "common_exception_IsAjaxAction", "(", "__FUNCTION__", ")", ";", "}", "$", "showInstances", "=", "$", "this",...
simplified Version of TaoModule function @return void
[ "simplified", "Version", "of", "TaoModule", "function" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.SaSModule.php#L222-L246
oat-sa/tao-core
actions/class.SaSModule.php
tao_actions_SaSModule.isStandalone
protected function isStandalone() { if (is_null($this->isStandAlone)) { if ($this->hasRequestParameter('standalone') && $this->getRequestParameter('standalone')) { tao_helpers_Context::load('STANDALONE_MODE'); $this->isStandAlone = true; $this->setData('client_config_url', $this->getClientConfigUrl()); $this->logDebug('Standalone mode set'); } else { $this->isStandAlone = false; } } return $this->isStandAlone; }
php
protected function isStandalone() { if (is_null($this->isStandAlone)) { if ($this->hasRequestParameter('standalone') && $this->getRequestParameter('standalone')) { tao_helpers_Context::load('STANDALONE_MODE'); $this->isStandAlone = true; $this->setData('client_config_url', $this->getClientConfigUrl()); $this->logDebug('Standalone mode set'); } else { $this->isStandAlone = false; } } return $this->isStandAlone; }
[ "protected", "function", "isStandalone", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "isStandAlone", ")", ")", "{", "if", "(", "$", "this", "->", "hasRequestParameter", "(", "'standalone'", ")", "&&", "$", "this", "->", "getRequestParamete...
Get the standAlone state @return bool
[ "Get", "the", "standAlone", "state" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.SaSModule.php#L266-L280
oat-sa/tao-core
helpers/translation/class.JSFileWriter.php
tao_helpers_translation_JSFileWriter.write
public function write() { $path = $this->getFilePath(); $strings = array(); foreach ($this->getTranslationFile()->getTranslationUnits() as $tu) { if ($tu->getTarget() !== ''){ $strings[$tu->getSource()] = $tu->getTarget(); } } $buffer = json_encode($strings, JSON_HEX_QUOT | JSON_HEX_APOS); if(!file_put_contents($path, $buffer)){ throw new tao_helpers_translation_TranslationException("An error occured while writing Javascript " . "translation file '${path}'."); } }
php
public function write() { $path = $this->getFilePath(); $strings = array(); foreach ($this->getTranslationFile()->getTranslationUnits() as $tu) { if ($tu->getTarget() !== ''){ $strings[$tu->getSource()] = $tu->getTarget(); } } $buffer = json_encode($strings, JSON_HEX_QUOT | JSON_HEX_APOS); if(!file_put_contents($path, $buffer)){ throw new tao_helpers_translation_TranslationException("An error occured while writing Javascript " . "translation file '${path}'."); } }
[ "public", "function", "write", "(", ")", "{", "$", "path", "=", "$", "this", "->", "getFilePath", "(", ")", ";", "$", "strings", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getTranslationFile", "(", ")", "->", "getTranslationUnits"...
Write a javascript AMD module that provides translations for the target languages. @access public @return mixed
[ "Write", "a", "javascript", "AMD", "module", "that", "provides", "translations", "for", "the", "target", "languages", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/translation/class.JSFileWriter.php#L42-L59
oat-sa/tao-core
models/classes/controllerMap/RequiresRightTag.php
RequiresRightTag.setContent
public function setContent($content) { parent::setContent($content); $parts = preg_split('/\s+/Su', $this->description, 3); if (count($parts) >= 2) { $this->parameter = $parts[0]; $this->rightId = $parts[1]; } $this->setDescription(isset($parts[2]) ? $parts[2] : ''); $this->content = $content; return $this; }
php
public function setContent($content) { parent::setContent($content); $parts = preg_split('/\s+/Su', $this->description, 3); if (count($parts) >= 2) { $this->parameter = $parts[0]; $this->rightId = $parts[1]; } $this->setDescription(isset($parts[2]) ? $parts[2] : ''); $this->content = $content; return $this; }
[ "public", "function", "setContent", "(", "$", "content", ")", "{", "parent", "::", "setContent", "(", "$", "content", ")", ";", "$", "parts", "=", "preg_split", "(", "'/\\s+/Su'", ",", "$", "this", "->", "description", ",", "3", ")", ";", "if", "(", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/controllerMap/RequiresRightTag.php#L55-L70
oat-sa/tao-core
models/classes/service/SettingsStorage.php
SettingsStorage.getPersistence
private function getPersistence() { if ($this->persistence === null) { $this->persistence = common_persistence_KeyValuePersistence::getPersistence( $this->getOption(self::OPTION_PERSISTENCE) ); } return $this->persistence; }
php
private function getPersistence() { if ($this->persistence === null) { $this->persistence = common_persistence_KeyValuePersistence::getPersistence( $this->getOption(self::OPTION_PERSISTENCE) ); } return $this->persistence; }
[ "private", "function", "getPersistence", "(", ")", "{", "if", "(", "$", "this", "->", "persistence", "===", "null", ")", "{", "$", "this", "->", "persistence", "=", "common_persistence_KeyValuePersistence", "::", "getPersistence", "(", "$", "this", "->", "getO...
Get the persistence
[ "Get", "the", "persistence" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/service/SettingsStorage.php#L79-L87
oat-sa/tao-core
models/classes/api/ApiClientConnector.php
ApiClientConnector.request
public function request($method, $uri, array $options = []) { return $this->getClient()->request($method, $uri, $options); }
php
public function request($method, $uri, array $options = []) { return $this->getClient()->request($method, $uri, $options); }
[ "public", "function", "request", "(", "$", "method", ",", "$", "uri", ",", "array", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "getClient", "(", ")", "->", "request", "(", "$", "method", ",", "$", "uri", ",", "$", "opti...
Create and send an HTTP request. Use an absolute path to override the base path of the client, or a relative path to append to the base path of the client. The URL can contain the query string as well. @param string $method HTTP method. @param string|UriInterface $uri URI object or string. @param array $options Request options to apply. @return ResponseInterface @throws GuzzleException
[ "Create", "and", "send", "an", "HTTP", "request", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/api/ApiClientConnector.php#L71-L74
oat-sa/tao-core
models/classes/api/ApiClientConnector.php
ApiClientConnector.requestAsync
public function requestAsync($method, $uri, array $options = []) { return $this->getClient()->requestAsync($method, $uri, $options); }
php
public function requestAsync($method, $uri, array $options = []) { return $this->getClient()->requestAsync($method, $uri, $options); }
[ "public", "function", "requestAsync", "(", "$", "method", ",", "$", "uri", ",", "array", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "getClient", "(", ")", "->", "requestAsync", "(", "$", "method", ",", "$", "uri", ",", "$...
Create and send an asynchronous HTTP request. Use an absolute path to override the base path of the client, or a relative path to append to the base path of the client. The URL can contain the query string as well. Use an array to provide a URL template and additional variables to use in the URL template expansion. @param string $method HTTP method @param string|UriInterface $uri URI object or string. @param array $options Request options to apply. @return PromiseInterface
[ "Create", "and", "send", "an", "asynchronous", "HTTP", "request", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/api/ApiClientConnector.php#L104-L107
oat-sa/tao-core
models/classes/api/ApiClientConnector.php
ApiClientConnector.getClientOptions
protected function getClientOptions() { $options = $this->getOptions(); if (!isset($options['headers']) || !isset($options['headers']['Content-Type'])) { $options['headers']['Content-Type'] = ['application/json']; } else { if (!in_array('application/json', $options['headers']['Content-Type'])) { $options['headers']['Content-Type'][] = ['application/json']; } } return $options; }
php
protected function getClientOptions() { $options = $this->getOptions(); if (!isset($options['headers']) || !isset($options['headers']['Content-Type'])) { $options['headers']['Content-Type'] = ['application/json']; } else { if (!in_array('application/json', $options['headers']['Content-Type'])) { $options['headers']['Content-Type'][] = ['application/json']; } } return $options; }
[ "protected", "function", "getClientOptions", "(", ")", "{", "$", "options", "=", "$", "this", "->", "getOptions", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "options", "[", "'headers'", "]", ")", "||", "!", "isset", "(", "$", "options", "[", ...
Get the options as client options @return array
[ "Get", "the", "options", "as", "client", "options" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/api/ApiClientConnector.php#L140-L151
oat-sa/tao-core
models/classes/table/class.StaticColumn.php
tao_models_classes_table_StaticColumn.getValue
public function getValue( core_kernel_classes_Resource $resource, tao_models_classes_table_Column $column) { $returnValue = (string) ''; $returnValue = $column->value; return (string) $returnValue; }
php
public function getValue( core_kernel_classes_Resource $resource, tao_models_classes_table_Column $column) { $returnValue = (string) ''; $returnValue = $column->value; return (string) $returnValue; }
[ "public", "function", "getValue", "(", "core_kernel_classes_Resource", "$", "resource", ",", "tao_models_classes_table_Column", "$", "column", ")", "{", "$", "returnValue", "=", "(", "string", ")", "''", ";", "$", "returnValue", "=", "$", "column", "->", "value"...
Short description of method getValue @access public @author Joel Bout, <joel.bout@tudor.lu> @param Resource resource @param Column column @return string
[ "Short", "description", "of", "method", "getValue" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/table/class.StaticColumn.php#L75-L84
oat-sa/tao-core
models/classes/accessControl/data/DataAccessControl.php
DataAccessControl.extractAndGroupUriFromParameters
private function extractAndGroupUriFromParameters(array $requestParameters, array $filterNames) { if (empty($filterNames)) { return []; } $groupedUris = []; foreach ($this->flattenArray($requestParameters) as $key => $value) { $encodedUri = $this->getEncodedUri($value); if (in_array($key, $filterNames, true) && common_Utils::isUri($encodedUri)) { $groupedUris[$key][] = $encodedUri; } } return $groupedUris; }
php
private function extractAndGroupUriFromParameters(array $requestParameters, array $filterNames) { if (empty($filterNames)) { return []; } $groupedUris = []; foreach ($this->flattenArray($requestParameters) as $key => $value) { $encodedUri = $this->getEncodedUri($value); if (in_array($key, $filterNames, true) && common_Utils::isUri($encodedUri)) { $groupedUris[$key][] = $encodedUri; } } return $groupedUris; }
[ "private", "function", "extractAndGroupUriFromParameters", "(", "array", "$", "requestParameters", ",", "array", "$", "filterNames", ")", "{", "if", "(", "empty", "(", "$", "filterNames", ")", ")", "{", "return", "[", "]", ";", "}", "$", "groupedUris", "=", ...
@param array $requestParameters @param array $filterNames @return array
[ "@param", "array", "$requestParameters", "@param", "array", "$filterNames" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/accessControl/data/DataAccessControl.php#L53-L70
oat-sa/tao-core
models/classes/accessControl/data/DataAccessControl.php
DataAccessControl.hasAccess
public function hasAccess(User $user, $controller, $action, $requestParameters) { $required = array(); try { // $rights = ServiceManager::getServiceManager()->get(RouteAnnotationService::SERVICE_ID)->getRights($controller, $action); // todo use $rights when PHPDoc Annotations will be moved to the Doctrines annotations $requiredRights = ControllerHelper::getRequiredRights($controller, $action); $uris = $this->extractAndGroupUriFromParameters($requestParameters, array_keys($requiredRights)); foreach($uris as $name => $urisValue) { $required[] = array_fill_keys($urisValue, $requiredRights[$name]); } } catch (ActionNotFoundException $e) { // action not found, no access return false; } return empty($required) ? true : $this->hasPrivileges($user, array_merge(...$required)); }
php
public function hasAccess(User $user, $controller, $action, $requestParameters) { $required = array(); try { // $rights = ServiceManager::getServiceManager()->get(RouteAnnotationService::SERVICE_ID)->getRights($controller, $action); // todo use $rights when PHPDoc Annotations will be moved to the Doctrines annotations $requiredRights = ControllerHelper::getRequiredRights($controller, $action); $uris = $this->extractAndGroupUriFromParameters($requestParameters, array_keys($requiredRights)); foreach($uris as $name => $urisValue) { $required[] = array_fill_keys($urisValue, $requiredRights[$name]); } } catch (ActionNotFoundException $e) { // action not found, no access return false; } return empty($required) ? true : $this->hasPrivileges($user, array_merge(...$required)); }
[ "public", "function", "hasAccess", "(", "User", "$", "user", ",", "$", "controller", ",", "$", "action", ",", "$", "requestParameters", ")", "{", "$", "required", "=", "array", "(", ")", ";", "try", "{", "// $rights = ServiceManager::getServiceManager()->get(Rou...
@param User $user @param $controller @param $action @param $requestParameters @return bool @see \oat\tao\model\accessControl\AccessControl::hasAccess()
[ "@param", "User", "$user", "@param", "$controller", "@param", "$action", "@param", "$requestParameters" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/accessControl/data/DataAccessControl.php#L82-L101
oat-sa/tao-core
models/classes/accessControl/data/DataAccessControl.php
DataAccessControl.hasPrivileges
public function hasPrivileges(User $user, array $required) { foreach ($required as $resourceId=>$right) { if ($right === 'WRITE' && !$this->hasWritePrivilege($user, $resourceId)) { common_Logger::d('User \''.$user->getIdentifier().'\' does not have lock for resource \''.$resourceId.'\''); return false; } if (!in_array($right, $this->getPermissionProvider()->getSupportedRights())) { $required[$resourceId] = PermissionInterface::RIGHT_UNSUPPORTED; } } $permissions = $this->getPermissionProvider()->getPermissions($user, array_keys($required)); foreach ($required as $id => $right) { if (!isset($permissions[$id]) || !in_array($right, $permissions[$id])) { common_Logger::d('User \''.$user->getIdentifier().'\' does not have \''.$right.'\' permission for resource \''.$id.'\''); return false; } } return true; }
php
public function hasPrivileges(User $user, array $required) { foreach ($required as $resourceId=>$right) { if ($right === 'WRITE' && !$this->hasWritePrivilege($user, $resourceId)) { common_Logger::d('User \''.$user->getIdentifier().'\' does not have lock for resource \''.$resourceId.'\''); return false; } if (!in_array($right, $this->getPermissionProvider()->getSupportedRights())) { $required[$resourceId] = PermissionInterface::RIGHT_UNSUPPORTED; } } $permissions = $this->getPermissionProvider()->getPermissions($user, array_keys($required)); foreach ($required as $id => $right) { if (!isset($permissions[$id]) || !in_array($right, $permissions[$id])) { common_Logger::d('User \''.$user->getIdentifier().'\' does not have \''.$right.'\' permission for resource \''.$id.'\''); return false; } } return true; }
[ "public", "function", "hasPrivileges", "(", "User", "$", "user", ",", "array", "$", "required", ")", "{", "foreach", "(", "$", "required", "as", "$", "resourceId", "=>", "$", "right", ")", "{", "if", "(", "$", "right", "===", "'WRITE'", "&&", "!", "$...
Whenever or not the user has the required rights required takes the form of: resourceId => $right @param User $user @param array $required @return boolean
[ "Whenever", "or", "not", "the", "user", "has", "the", "required", "rights" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/accessControl/data/DataAccessControl.php#L125-L144
oat-sa/tao-core
models/classes/user/implementation/UserLocksService.php
UserLocksService.getLockout
protected function getLockout() { if (!$this->lockout || !$this->lockout instanceof LockoutStorage) { $lockout = $this->getOption(self::OPTION_LOCKOUT_STORAGE); $this->lockout = ($lockout and class_exists($lockout)) ? new $lockout : new RdfLockoutStorage(); } return $this->lockout; }
php
protected function getLockout() { if (!$this->lockout || !$this->lockout instanceof LockoutStorage) { $lockout = $this->getOption(self::OPTION_LOCKOUT_STORAGE); $this->lockout = ($lockout and class_exists($lockout)) ? new $lockout : new RdfLockoutStorage(); } return $this->lockout; }
[ "protected", "function", "getLockout", "(", ")", "{", "if", "(", "!", "$", "this", "->", "lockout", "||", "!", "$", "this", "->", "lockout", "instanceof", "LockoutStorage", ")", "{", "$", "lockout", "=", "$", "this", "->", "getOption", "(", "self", "::...
Returns proper lockout implementation @return LockoutStorage|RdfLockoutStorage
[ "Returns", "proper", "lockout", "implementation" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/user/implementation/UserLocksService.php#L82-L90
oat-sa/tao-core
models/classes/messaging/transportStrategy/FileSink.php
FileSink.getFilePath
public function getFilePath(User $receiver) { $basePath = $this->getOption(self::CONFIG_FILEPATH); if (is_null($basePath) || !file_exists($basePath)) { throw new \common_exception_InconsistentData('Missing path '.self::CONFIG_FILEPATH.' for '.__CLASS__); } $path = $basePath.\tao_helpers_File::getSafeFileName($receiver->getIdentifier()).DIRECTORY_SEPARATOR; if (!file_exists($path)) { mkdir($path); } return $path.\tao_helpers_File::getSafeFileName('message.html', $path); }
php
public function getFilePath(User $receiver) { $basePath = $this->getOption(self::CONFIG_FILEPATH); if (is_null($basePath) || !file_exists($basePath)) { throw new \common_exception_InconsistentData('Missing path '.self::CONFIG_FILEPATH.' for '.__CLASS__); } $path = $basePath.\tao_helpers_File::getSafeFileName($receiver->getIdentifier()).DIRECTORY_SEPARATOR; if (!file_exists($path)) { mkdir($path); } return $path.\tao_helpers_File::getSafeFileName('message.html', $path); }
[ "public", "function", "getFilePath", "(", "User", "$", "receiver", ")", "{", "$", "basePath", "=", "$", "this", "->", "getOption", "(", "self", "::", "CONFIG_FILEPATH", ")", ";", "if", "(", "is_null", "(", "$", "basePath", ")", "||", "!", "file_exists", ...
Get file path to save message @param User $receiver @param boolean $refresh whether the file path must be regenerated.
[ "Get", "file", "path", "to", "save", "message" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/messaging/transportStrategy/FileSink.php#L52-L63
oat-sa/tao-core
actions/class.UserSettings.php
tao_actions_UserSettings.password
public function password() { $this->setData('formTitle', __("Change password")); if ($this->getServiceLocator()->get(ApplicationService::SERVICE_ID)->isDemo()) { $this->setData('myForm', __('Unable to change passwords in demo mode')); } else { $myFormContainer = new tao_actions_form_UserPassword(); $myForm = $myFormContainer->getForm(); if($myForm->isSubmited()){ if($myForm->isValid()){ $user = $this->getUserService()->getCurrentUser(); $this->getServiceLocator()->get(tao_models_classes_UserService::SERVICE_ID) ->setPassword($user, $myForm->getValue('newpassword')); $this->setData('message', __('Password changed')); } } $this->setData('myForm', $myForm->render()); } $this->setView('form/settings_user.tpl'); }
php
public function password() { $this->setData('formTitle', __("Change password")); if ($this->getServiceLocator()->get(ApplicationService::SERVICE_ID)->isDemo()) { $this->setData('myForm', __('Unable to change passwords in demo mode')); } else { $myFormContainer = new tao_actions_form_UserPassword(); $myForm = $myFormContainer->getForm(); if($myForm->isSubmited()){ if($myForm->isValid()){ $user = $this->getUserService()->getCurrentUser(); $this->getServiceLocator()->get(tao_models_classes_UserService::SERVICE_ID) ->setPassword($user, $myForm->getValue('newpassword')); $this->setData('message', __('Password changed')); } } $this->setData('myForm', $myForm->render()); } $this->setView('form/settings_user.tpl'); }
[ "public", "function", "password", "(", ")", "{", "$", "this", "->", "setData", "(", "'formTitle'", ",", "__", "(", "\"Change password\"", ")", ")", ";", "if", "(", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "ApplicationService", ...
Action dedicated to change the password of the user currently connected.
[ "Action", "dedicated", "to", "change", "the", "password", "of", "the", "user", "currently", "connected", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.UserSettings.php#L44-L64
oat-sa/tao-core
actions/class.UserSettings.php
tao_actions_UserSettings.properties
public function properties() { $myFormContainer = new tao_actions_form_UserSettings($this->getUserSettings()); $myForm = $myFormContainer->getForm(); if ($myForm->isSubmited() && $myForm->isValid()) { $userLangService = $this->getServiceLocator()->get(UserLanguageServiceInterface::class); $currentUser = $this->getUserService()->getCurrentUser(); $userSettings = [ GenerisRdf::PROPERTY_USER_TIMEZONE => $myForm->getValue('timezone'), ]; $uiLang = $this->getResource($myForm->getValue('ui_lang')); $userSettings[GenerisRdf::PROPERTY_USER_UILG] = $uiLang->getUri(); if ($userLangService->isDataLanguageEnabled()) { $dataLang = $this->getResource($myForm->getValue('data_lang')); $userSettings[GenerisRdf::PROPERTY_USER_DEFLG] = $dataLang->getUri(); } $binder = new tao_models_classes_dataBinding_GenerisFormDataBinder($currentUser); if($binder->bind($userSettings)){ $this->getSession()->refresh(); $uiLangCode = tao_models_classes_LanguageService::singleton()->getCode($uiLang); $extension = $this->getServiceLocator()->get(common_ext_ExtensionsManager::SERVICE_ID)->getExtensionById('tao'); tao_helpers_I18n::init($extension, $uiLangCode); $this->setData('message', __('Settings updated')); $this->setData('reload', true); } } $userLabel = $this->getUserService()->getCurrentUser()->getLabel(); $this->setData('formTitle', __("My settings (%s)", $userLabel)); $this->setData('myForm', $myForm->render()); //$this->setView('form.tpl'); $this->setView('form/settings_user.tpl'); }
php
public function properties() { $myFormContainer = new tao_actions_form_UserSettings($this->getUserSettings()); $myForm = $myFormContainer->getForm(); if ($myForm->isSubmited() && $myForm->isValid()) { $userLangService = $this->getServiceLocator()->get(UserLanguageServiceInterface::class); $currentUser = $this->getUserService()->getCurrentUser(); $userSettings = [ GenerisRdf::PROPERTY_USER_TIMEZONE => $myForm->getValue('timezone'), ]; $uiLang = $this->getResource($myForm->getValue('ui_lang')); $userSettings[GenerisRdf::PROPERTY_USER_UILG] = $uiLang->getUri(); if ($userLangService->isDataLanguageEnabled()) { $dataLang = $this->getResource($myForm->getValue('data_lang')); $userSettings[GenerisRdf::PROPERTY_USER_DEFLG] = $dataLang->getUri(); } $binder = new tao_models_classes_dataBinding_GenerisFormDataBinder($currentUser); if($binder->bind($userSettings)){ $this->getSession()->refresh(); $uiLangCode = tao_models_classes_LanguageService::singleton()->getCode($uiLang); $extension = $this->getServiceLocator()->get(common_ext_ExtensionsManager::SERVICE_ID)->getExtensionById('tao'); tao_helpers_I18n::init($extension, $uiLangCode); $this->setData('message', __('Settings updated')); $this->setData('reload', true); } } $userLabel = $this->getUserService()->getCurrentUser()->getLabel(); $this->setData('formTitle', __("My settings (%s)", $userLabel)); $this->setData('myForm', $myForm->render()); //$this->setView('form.tpl'); $this->setView('form/settings_user.tpl'); }
[ "public", "function", "properties", "(", ")", "{", "$", "myFormContainer", "=", "new", "tao_actions_form_UserSettings", "(", "$", "this", "->", "getUserSettings", "(", ")", ")", ";", "$", "myForm", "=", "$", "myFormContainer", "->", "getForm", "(", ")", ";",...
Action dedicated to change the settings of the user (language, ...)
[ "Action", "dedicated", "to", "change", "the", "settings", "of", "the", "user", "(", "language", "...", ")" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.UserSettings.php#L69-L108
oat-sa/tao-core
actions/class.UserSettings.php
tao_actions_UserSettings.getUserSettings
private function getUserSettings(){ $currentUser = $this->getUserService()->getCurrentUser(); $props = $currentUser->getPropertiesValues([ $this->getProperty(GenerisRdf::PROPERTY_USER_UILG), $this->getProperty(GenerisRdf::PROPERTY_USER_DEFLG), $this->getProperty(GenerisRdf::PROPERTY_USER_TIMEZONE) ]); $langs = []; if (!empty($props[GenerisRdf::PROPERTY_USER_UILG])) { $langs['ui_lang'] = current($props[GenerisRdf::PROPERTY_USER_UILG])->getUri(); } if (!empty($props[GenerisRdf::PROPERTY_USER_DEFLG])) { $langs['data_lang'] = current($props[GenerisRdf::PROPERTY_USER_DEFLG])->getUri(); } $langs['timezone'] = !empty($props[GenerisRdf::PROPERTY_USER_TIMEZONE]) ? (string) current($props[GenerisRdf::PROPERTY_USER_TIMEZONE]) : TIME_ZONE; return $langs; }
php
private function getUserSettings(){ $currentUser = $this->getUserService()->getCurrentUser(); $props = $currentUser->getPropertiesValues([ $this->getProperty(GenerisRdf::PROPERTY_USER_UILG), $this->getProperty(GenerisRdf::PROPERTY_USER_DEFLG), $this->getProperty(GenerisRdf::PROPERTY_USER_TIMEZONE) ]); $langs = []; if (!empty($props[GenerisRdf::PROPERTY_USER_UILG])) { $langs['ui_lang'] = current($props[GenerisRdf::PROPERTY_USER_UILG])->getUri(); } if (!empty($props[GenerisRdf::PROPERTY_USER_DEFLG])) { $langs['data_lang'] = current($props[GenerisRdf::PROPERTY_USER_DEFLG])->getUri(); } $langs['timezone'] = !empty($props[GenerisRdf::PROPERTY_USER_TIMEZONE]) ? (string) current($props[GenerisRdf::PROPERTY_USER_TIMEZONE]) : TIME_ZONE; return $langs; }
[ "private", "function", "getUserSettings", "(", ")", "{", "$", "currentUser", "=", "$", "this", "->", "getUserService", "(", ")", "->", "getCurrentUser", "(", ")", ";", "$", "props", "=", "$", "currentUser", "->", "getPropertiesValues", "(", "[", "$", "this...
Get the settings of the current user. This method returns an associative array with the following keys: - 'ui_lang': The value associated to this key is a core_kernel_classes_Resource object which represents the language selected for the Graphical User Interface. - 'data_lang': The value associated to this key is a core_kernel_classes_Resource object which respresents the language selected to access the data in persistent memory. - 'timezone': The value associated to this key is a core_kernel_classes_Resource object which respresents the timezone selected to display times and dates. @return array The URIs of the languages.
[ "Get", "the", "settings", "of", "the", "current", "user", ".", "This", "method", "returns", "an", "associative", "array", "with", "the", "following", "keys", ":" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.UserSettings.php#L124-L142
oat-sa/tao-core
helpers/translation/class.POFileWriter.php
tao_helpers_translation_POFileWriter.write
public function write() { $buffer = ''; $file = $this->getTranslationFile(); // Add PO Headers. $buffer .= 'msgid ""' . "\n"; $buffer .= 'msgstr ""' . "\n"; // If the TranslationFile is a specific POFile instance, we add PO Headers // to the output. if (get_class($this->getTranslationFile()) == 'tao_helpers_translation_POFile') { foreach ($file->getHeaders() as $name => $value) { $buffer .= '"' . $name . ': ' . $value . '\n"' . "\n"; } } // Write all Translation Units. $buffer .= "\n"; foreach($this->getTranslationFile()->getTranslationUnits() as $tu) { $c = tao_helpers_translation_POUtils::sanitize($tu->getContext(), true); $s = tao_helpers_translation_POUtils::sanitize($tu->getSource(), true); $t = tao_helpers_translation_POUtils::sanitize($tu->getTarget(), true); $a = tao_helpers_translation_POUtils::serializeAnnotations($tu->getAnnotations()); if (!empty($a)){ $buffer .= "${a}\n"; } if ($c) { $buffer .= "msgctxt \"{$c}\"\n"; } $buffer .= "msgid \"{$s}\"\n"; $buffer .= "msgstr \"{$t}\"\n"; $buffer .= "\n"; } return file_put_contents($this->getFilePath(), $buffer); }
php
public function write() { $buffer = ''; $file = $this->getTranslationFile(); // Add PO Headers. $buffer .= 'msgid ""' . "\n"; $buffer .= 'msgstr ""' . "\n"; // If the TranslationFile is a specific POFile instance, we add PO Headers // to the output. if (get_class($this->getTranslationFile()) == 'tao_helpers_translation_POFile') { foreach ($file->getHeaders() as $name => $value) { $buffer .= '"' . $name . ': ' . $value . '\n"' . "\n"; } } // Write all Translation Units. $buffer .= "\n"; foreach($this->getTranslationFile()->getTranslationUnits() as $tu) { $c = tao_helpers_translation_POUtils::sanitize($tu->getContext(), true); $s = tao_helpers_translation_POUtils::sanitize($tu->getSource(), true); $t = tao_helpers_translation_POUtils::sanitize($tu->getTarget(), true); $a = tao_helpers_translation_POUtils::serializeAnnotations($tu->getAnnotations()); if (!empty($a)){ $buffer .= "${a}\n"; } if ($c) { $buffer .= "msgctxt \"{$c}\"\n"; } $buffer .= "msgid \"{$s}\"\n"; $buffer .= "msgstr \"{$t}\"\n"; $buffer .= "\n"; } return file_put_contents($this->getFilePath(), $buffer); }
[ "public", "function", "write", "(", ")", "{", "$", "buffer", "=", "''", ";", "$", "file", "=", "$", "this", "->", "getTranslationFile", "(", ")", ";", "// Add PO Headers.", "$", "buffer", ".=", "'msgid \"\"'", ".", "\"\\n\"", ";", "$", "buffer", ".=", ...
Short description of method write @access public @author firstname and lastname of author, <author@example.org> @return mixed
[ "Short", "description", "of", "method", "write" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/translation/class.POFileWriter.php#L49-L91
oat-sa/tao-core
helpers/ControllerHelper.php
ControllerHelper.getControllers
public static function getControllers($extensionId) { try { $controllerClasses = ServiceManager::getServiceManager()->get('generis/cache')->get(self::EXTENSION_PREFIX.$extensionId); } catch (\common_cache_NotFoundException $e) { $factory = new Factory(); $controllerClasses = array(); foreach ($factory->getControllers($extensionId) as $controller) { $controllerClasses[] = $controller->getClassName(); } ServiceManager::getServiceManager()->get('generis/cache')->put($controllerClasses, self::EXTENSION_PREFIX.$extensionId); } return $controllerClasses; }
php
public static function getControllers($extensionId) { try { $controllerClasses = ServiceManager::getServiceManager()->get('generis/cache')->get(self::EXTENSION_PREFIX.$extensionId); } catch (\common_cache_NotFoundException $e) { $factory = new Factory(); $controllerClasses = array(); foreach ($factory->getControllers($extensionId) as $controller) { $controllerClasses[] = $controller->getClassName(); } ServiceManager::getServiceManager()->get('generis/cache')->put($controllerClasses, self::EXTENSION_PREFIX.$extensionId); } return $controllerClasses; }
[ "public", "static", "function", "getControllers", "(", "$", "extensionId", ")", "{", "try", "{", "$", "controllerClasses", "=", "ServiceManager", "::", "getServiceManager", "(", ")", "->", "get", "(", "'generis/cache'", ")", "->", "get", "(", "self", "::", "...
Returns al lthe controllers of an extension @param string $extensionId @return array
[ "Returns", "al", "lthe", "controllers", "of", "an", "extension" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/ControllerHelper.php#L45-L57
oat-sa/tao-core
helpers/ControllerHelper.php
ControllerHelper.getActions
public static function getActions($controllerClassName) { try { $actions = ServiceManager::getServiceManager()->get('generis/cache')->get(self::CONTROLLER_PREFIX.$controllerClassName); } catch (\common_cache_NotFoundException $e) { $factory = new Factory(); $desc = $factory->getControllerDescription($controllerClassName); $actions = array(); foreach ($desc->getActions() as $action) { $actions[] = $action->getName(); } ServiceManager::getServiceManager()->get('generis/cache')->put($actions, self::CONTROLLER_PREFIX.$controllerClassName); } return $actions; }
php
public static function getActions($controllerClassName) { try { $actions = ServiceManager::getServiceManager()->get('generis/cache')->get(self::CONTROLLER_PREFIX.$controllerClassName); } catch (\common_cache_NotFoundException $e) { $factory = new Factory(); $desc = $factory->getControllerDescription($controllerClassName); $actions = array(); foreach ($desc->getActions() as $action) { $actions[] = $action->getName(); } ServiceManager::getServiceManager()->get('generis/cache')->put($actions, self::CONTROLLER_PREFIX.$controllerClassName); } return $actions; }
[ "public", "static", "function", "getActions", "(", "$", "controllerClassName", ")", "{", "try", "{", "$", "actions", "=", "ServiceManager", "::", "getServiceManager", "(", ")", "->", "get", "(", "'generis/cache'", ")", "->", "get", "(", "self", "::", "CONTRO...
Get the list of actions for a controller @param string $controllerClassName @return array
[ "Get", "the", "list", "of", "actions", "for", "a", "controller" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/ControllerHelper.php#L65-L79
oat-sa/tao-core
helpers/ControllerHelper.php
ControllerHelper.getRequiredRights
public static function getRequiredRights($controllerClassName, $actionName) { try { $rights = ServiceManager::getServiceManager()->get('generis/cache')->get(self::ACTION_PREFIX.$controllerClassName.'@'.$actionName); } catch (\common_cache_NotFoundException $e) { $factory = new Factory(); $controller = $factory->getActionDescription($controllerClassName, $actionName); $rights = $controller->getRequiredRights(); ServiceManager::getServiceManager()->get('generis/cache')->put($rights, self::ACTION_PREFIX.$controllerClassName.'@'.$actionName); } return $rights; }
php
public static function getRequiredRights($controllerClassName, $actionName) { try { $rights = ServiceManager::getServiceManager()->get('generis/cache')->get(self::ACTION_PREFIX.$controllerClassName.'@'.$actionName); } catch (\common_cache_NotFoundException $e) { $factory = new Factory(); $controller = $factory->getActionDescription($controllerClassName, $actionName); $rights = $controller->getRequiredRights(); ServiceManager::getServiceManager()->get('generis/cache')->put($rights, self::ACTION_PREFIX.$controllerClassName.'@'.$actionName); } return $rights; }
[ "public", "static", "function", "getRequiredRights", "(", "$", "controllerClassName", ",", "$", "actionName", ")", "{", "try", "{", "$", "rights", "=", "ServiceManager", "::", "getServiceManager", "(", ")", "->", "get", "(", "'generis/cache'", ")", "->", "get"...
Get the required rights for the execution of an action Returns an associative array with the parameter as key and the rights as values @param string $controllerClassName @param string $actionName @return array
[ "Get", "the", "required", "rights", "for", "the", "execution", "of", "an", "action" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/ControllerHelper.php#L91-L101
oat-sa/tao-core
models/classes/class.HttpDigestAuthAdapter.php
tao_models_classes_HttpDigestAuthAdapter.authenticate
public function authenticate() { throw new common_exception_NotImplemented(); $digest = tao_helpers_Http::getDigest(); $data = tao_helpers_Http::parseDigest($digest); //store the hash A1 as a property to be updated on register/changepassword $trialLogin = 'admin'; $trialPassword = 'admin'; $A1 = md5($trialLogin . ':' . $this::realm . ':' . $trialPassword); $A2 = md5($_SERVER['REQUEST_METHOD'].':'.$data['uri']); $valid_response = md5($A1.':'.$data['nonce'].':'.$data['nc'].':'.$data['cnonce'].':'.$data['qop'].':'.$A2); }
php
public function authenticate() { throw new common_exception_NotImplemented(); $digest = tao_helpers_Http::getDigest(); $data = tao_helpers_Http::parseDigest($digest); //store the hash A1 as a property to be updated on register/changepassword $trialLogin = 'admin'; $trialPassword = 'admin'; $A1 = md5($trialLogin . ':' . $this::realm . ':' . $trialPassword); $A2 = md5($_SERVER['REQUEST_METHOD'].':'.$data['uri']); $valid_response = md5($A1.':'.$data['nonce'].':'.$data['nc'].':'.$data['cnonce'].':'.$data['qop'].':'.$A2); }
[ "public", "function", "authenticate", "(", ")", "{", "throw", "new", "common_exception_NotImplemented", "(", ")", ";", "$", "digest", "=", "tao_helpers_Http", "::", "getDigest", "(", ")", ";", "$", "data", "=", "tao_helpers_Http", "::", "parseDigest", "(", "$"...
(non-PHPdoc) @see common_user_auth_Adapter::authenticate()
[ "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.HttpDigestAuthAdapter.php#L52-L63
oat-sa/tao-core
models/classes/taskQueue/Queue/Broker/InMemoryQueueBroker.php
InMemoryQueueBroker.pop
public function pop() { if (!$this->count()) { return null; } $task = $this->getQueue()->dequeue(); return $this->unserializeTask($task, ''); }
php
public function pop() { if (!$this->count()) { return null; } $task = $this->getQueue()->dequeue(); return $this->unserializeTask($task, ''); }
[ "public", "function", "pop", "(", ")", "{", "if", "(", "!", "$", "this", "->", "count", "(", ")", ")", "{", "return", "null", ";", "}", "$", "task", "=", "$", "this", "->", "getQueue", "(", ")", "->", "dequeue", "(", ")", ";", "return", "$", ...
Overwriting the parent totally because in this case we need a much simpler logic for popping messages. @return mixed|null
[ "Overwriting", "the", "parent", "totally", "because", "in", "this", "case", "we", "need", "a", "much", "simpler", "logic", "for", "popping", "messages", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/taskQueue/Queue/Broker/InMemoryQueueBroker.php#L81-L90
oat-sa/tao-core
helpers/form/validators/class.Callback.php
tao_helpers_form_validators_Callback.evaluate
public function evaluate($values) { $returnValue = (bool) false; if ($this->hasOption('function')) { $function = $this->getOption('function'); if (function_exists($function)) { $callback = array($function); } else { throw new common_Exception("callback function does not exist"); } } else if ($this->hasOption('class')) { $class = $this->getOption('class'); $method = $this->getOption('method'); if (class_exists($class) && method_exists($class, $method)) { $callback = array($class, $method); } else { throw new common_Exception("callback method does not exist"); } } else if ($this->hasOption('object')) { $object = $this->getOption('object'); $method = $this->getOption('method'); if (method_exists($object, $method)) { $callback = array($object, $method); } else { throw new common_Exception("callback method does not exist"); } } if ($this->hasOption('param')) { $returnValue = (bool)call_user_func($callback, $values, $this->getOption('param')); } else { $returnValue = (bool)call_user_func($callback, $values); } return (bool)$returnValue; }
php
public function evaluate($values) { $returnValue = (bool) false; if ($this->hasOption('function')) { $function = $this->getOption('function'); if (function_exists($function)) { $callback = array($function); } else { throw new common_Exception("callback function does not exist"); } } else if ($this->hasOption('class')) { $class = $this->getOption('class'); $method = $this->getOption('method'); if (class_exists($class) && method_exists($class, $method)) { $callback = array($class, $method); } else { throw new common_Exception("callback method does not exist"); } } else if ($this->hasOption('object')) { $object = $this->getOption('object'); $method = $this->getOption('method'); if (method_exists($object, $method)) { $callback = array($object, $method); } else { throw new common_Exception("callback method does not exist"); } } if ($this->hasOption('param')) { $returnValue = (bool)call_user_func($callback, $values, $this->getOption('param')); } else { $returnValue = (bool)call_user_func($callback, $values); } return (bool)$returnValue; }
[ "public", "function", "evaluate", "(", "$", "values", ")", "{", "$", "returnValue", "=", "(", "bool", ")", "false", ";", "if", "(", "$", "this", "->", "hasOption", "(", "'function'", ")", ")", "{", "$", "function", "=", "$", "this", "->", "getOption"...
Short description of method evaluate @access public @author Joel Bout, <joel.bout@tudor.lu> @param string $values @return bool @throws common_Exception @internal param $values
[ "Short", "description", "of", "method", "evaluate" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/validators/class.Callback.php#L57-L93
oat-sa/tao-core
helpers/grid/Cell/class.SubgridAdapter.php
tao_helpers_grid_Cell_SubgridAdapter.getValue
public function getValue($rowId, $columnId, $data = null) { $returnValue = null; if(isset($this->data[$rowId]) && is_a($this->data[$rowId], 'wfEngine_helpers_Monitoring_ActivityMonitoringGrid')){ $returnValue = $this->data[$rowId]; } else{ $subgridData = $this->getSubgridRows($rowId); $cloneSubGridCtn = clone $this->subGridContainer; $cloneSubGridCtn->getGrid()->setData($subgridData); $returnValue = $cloneSubGridCtn; $this->data[$rowId] = $cloneSubGridCtn; } return $returnValue; }
php
public function getValue($rowId, $columnId, $data = null) { $returnValue = null; if(isset($this->data[$rowId]) && is_a($this->data[$rowId], 'wfEngine_helpers_Monitoring_ActivityMonitoringGrid')){ $returnValue = $this->data[$rowId]; } else{ $subgridData = $this->getSubgridRows($rowId); $cloneSubGridCtn = clone $this->subGridContainer; $cloneSubGridCtn->getGrid()->setData($subgridData); $returnValue = $cloneSubGridCtn; $this->data[$rowId] = $cloneSubGridCtn; } return $returnValue; }
[ "public", "function", "getValue", "(", "$", "rowId", ",", "$", "columnId", ",", "$", "data", "=", "null", ")", "{", "$", "returnValue", "=", "null", ";", "if", "(", "isset", "(", "$", "this", "->", "data", "[", "$", "rowId", "]", ")", "&&", "is_a...
Short description of method getValue @access public @author Cédric Alfonsi, <cedric.alfonsi@tudor.lu> @param string rowId @param string columnId @param string data @return mixed
[ "Short", "description", "of", "method", "getValue" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/grid/Cell/class.SubgridAdapter.php#L97-L117
oat-sa/tao-core
helpers/form/validators/class.Password.php
tao_helpers_form_validators_Password.evaluate
public function evaluate($values) { $returnValue = (bool) false; if (is_array($values) && count($values) == 2) { list($first, $second) = $values; $returnValue = $first == $second; } elseif ($this->hasOption('password2_ref')) { $secondElement = $this->getOption('password2_ref'); if (is_null($secondElement) || ! $secondElement instanceof tao_helpers_form_FormElement) { throw new common_Exception("Please set the reference of the second password element"); } if($values == $secondElement->getRawValue() && trim($values) != ''){ $returnValue = true; } } else { throw new common_Exception("Please set the reference of the second password element or provide array of 2 elements"); } return (bool) $returnValue; }
php
public function evaluate($values) { $returnValue = (bool) false; if (is_array($values) && count($values) == 2) { list($first, $second) = $values; $returnValue = $first == $second; } elseif ($this->hasOption('password2_ref')) { $secondElement = $this->getOption('password2_ref'); if (is_null($secondElement) || ! $secondElement instanceof tao_helpers_form_FormElement) { throw new common_Exception("Please set the reference of the second password element"); } if($values == $secondElement->getRawValue() && trim($values) != ''){ $returnValue = true; } } else { throw new common_Exception("Please set the reference of the second password element or provide array of 2 elements"); } return (bool) $returnValue; }
[ "public", "function", "evaluate", "(", "$", "values", ")", "{", "$", "returnValue", "=", "(", "bool", ")", "false", ";", "if", "(", "is_array", "(", "$", "values", ")", "&&", "count", "(", "$", "values", ")", "==", "2", ")", "{", "list", "(", "$"...
Short description of method evaluate @access public @author Joel Bout, <joel.bout@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.Password.php#L48-L72
oat-sa/tao-core
helpers/JavaScript.php
JavaScript.getClientConfigUrl
public static function getClientConfigUrl($extraParameters = array()){ $context = \Context::getInstance(); $clientConfigParams = [ 'extension' => $context->getExtensionName(), 'module' => $context->getModuleName(), 'action' => $context->getActionName() ]; return _url('config', 'ClientConfig', 'tao', array_merge($clientConfigParams, $extraParameters)); }
php
public static function getClientConfigUrl($extraParameters = array()){ $context = \Context::getInstance(); $clientConfigParams = [ 'extension' => $context->getExtensionName(), 'module' => $context->getModuleName(), 'action' => $context->getActionName() ]; return _url('config', 'ClientConfig', 'tao', array_merge($clientConfigParams, $extraParameters)); }
[ "public", "static", "function", "getClientConfigUrl", "(", "$", "extraParameters", "=", "array", "(", ")", ")", "{", "$", "context", "=", "\\", "Context", "::", "getInstance", "(", ")", ";", "$", "clientConfigParams", "=", "[", "'extension'", "=>", "$", "c...
Helps you to add the URL of the client side config file @param array $extraParameters additional parameters to append to the URL @return string the URL
[ "Helps", "you", "to", "add", "the", "URL", "of", "the", "client", "side", "config", "file" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/JavaScript.php#L31-L40
oat-sa/tao-core
models/classes/metadata/injector/OntologyMetadataInjector.php
OntologyMetadataInjector.setOptions
public function setOptions(array $options) { if (! array_key_exists(self::CONFIG_SOURCE, $options) || ! is_array($options[self::CONFIG_SOURCE]) || empty($options[self::CONFIG_SOURCE]) ) { throw new InconsistencyConfigException(__('Injector has to contains a valid "source" field.')); } if (! array_key_exists(self::CONFIG_DESTINATION, $options) || ! is_array($options[self::CONFIG_DESTINATION]) || empty($options[self::CONFIG_DESTINATION]) ) { throw new InconsistencyConfigException(__('Injector has to contains a valid "destination" field.')); } parent::setOptions($options); }
php
public function setOptions(array $options) { if (! array_key_exists(self::CONFIG_SOURCE, $options) || ! is_array($options[self::CONFIG_SOURCE]) || empty($options[self::CONFIG_SOURCE]) ) { throw new InconsistencyConfigException(__('Injector has to contains a valid "source" field.')); } if (! array_key_exists(self::CONFIG_DESTINATION, $options) || ! is_array($options[self::CONFIG_DESTINATION]) || empty($options[self::CONFIG_DESTINATION]) ) { throw new InconsistencyConfigException(__('Injector has to contains a valid "destination" field.')); } parent::setOptions($options); }
[ "public", "function", "setOptions", "(", "array", "$", "options", ")", "{", "if", "(", "!", "array_key_exists", "(", "self", "::", "CONFIG_SOURCE", ",", "$", "options", ")", "||", "!", "is_array", "(", "$", "options", "[", "self", "::", "CONFIG_SOURCE", ...
Override Configurable parent to check required field (source & destination) @param array $options @throws InconsistencyConfigException
[ "Override", "Configurable", "parent", "to", "check", "required", "field", "(", "source", "&", "destination", ")" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/metadata/injector/OntologyMetadataInjector.php#L65-L82
oat-sa/tao-core
models/classes/metadata/injector/OntologyMetadataInjector.php
OntologyMetadataInjector.createInjectorHelpers
public function createInjectorHelpers() { $this->setReaders($this->getOption(self::CONFIG_SOURCE)); $this->setWriters($this->getOption(self::CONFIG_DESTINATION)); }
php
public function createInjectorHelpers() { $this->setReaders($this->getOption(self::CONFIG_SOURCE)); $this->setWriters($this->getOption(self::CONFIG_DESTINATION)); }
[ "public", "function", "createInjectorHelpers", "(", ")", "{", "$", "this", "->", "setReaders", "(", "$", "this", "->", "getOption", "(", "self", "::", "CONFIG_SOURCE", ")", ")", ";", "$", "this", "->", "setWriters", "(", "$", "this", "->", "getOption", "...
Create injector helpers (readers & writers) from options
[ "Create", "injector", "helpers", "(", "readers", "&", "writers", ")", "from", "options" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/metadata/injector/OntologyMetadataInjector.php#L87-L91
oat-sa/tao-core
models/classes/metadata/injector/OntologyMetadataInjector.php
OntologyMetadataInjector.read
public function read(array $dataSource) { $data = $errors = []; foreach ($this->readers as $name => $reader) { try { $data[$name] = $reader->getValue($dataSource); } catch (MetadataReaderNotFoundException $e) { $errors[$name] = $e->getMessage(); } } if (! empty($errors)) { foreach ($errors as $name => $error) { \common_Logger::d('Error on injector "' . __CLASS__ . '" with reader "' . $name . '" : ' . $error); } throw new MetadataInjectorReadException( 'Injector "' . __CLASS__ . '" cannot read all required values from readers: ' . implode(', ', array_keys($errors)) ); } return $data; }
php
public function read(array $dataSource) { $data = $errors = []; foreach ($this->readers as $name => $reader) { try { $data[$name] = $reader->getValue($dataSource); } catch (MetadataReaderNotFoundException $e) { $errors[$name] = $e->getMessage(); } } if (! empty($errors)) { foreach ($errors as $name => $error) { \common_Logger::d('Error on injector "' . __CLASS__ . '" with reader "' . $name . '" : ' . $error); } throw new MetadataInjectorReadException( 'Injector "' . __CLASS__ . '" cannot read all required values from readers: ' . implode(', ', array_keys($errors)) ); } return $data; }
[ "public", "function", "read", "(", "array", "$", "dataSource", ")", "{", "$", "data", "=", "$", "errors", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "readers", "as", "$", "name", "=>", "$", "reader", ")", "{", "try", "{", "$", "data",...
Read all values from readers and store it into array of $name => reader $value Throw exception if at least one reader cannot read value @param array $dataSource @return array All collected data from $this->readers @throws MetadataInjectorReadException
[ "Read", "all", "values", "from", "readers", "and", "store", "it", "into", "array", "of", "$name", "=", ">", "reader", "$value", "Throw", "exception", "if", "at", "least", "one", "reader", "cannot", "read", "value" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/metadata/injector/OntologyMetadataInjector.php#L101-L123
oat-sa/tao-core
models/classes/metadata/injector/OntologyMetadataInjector.php
OntologyMetadataInjector.write
public function write(\core_kernel_classes_Resource $resource, array $data, $dryrun = false) { $writers = $errors = []; foreach ($this->writers as $name => $writer) { try { $value = $writer->format($data); if ($writer->validate($value)) { $writers[$name] = $writer; } else { $errors[$name] = 'Writer "' . $name . '" cannot validate value.'; } } catch (MetadataReaderNotFoundException $e) { $errors[$name] = 'Writer "' . $name . '" cannot format value: ' . $e->getMessage(); } } foreach ($writers as $name => $writer) { if (! $writer instanceof OntologyWriter) { $errors[$name] = __CLASS__ . ' must implements ' . OntologyWriter::class; continue; } try { $writer->write($resource, $data, $dryrun); } catch (MetadataWriterException $e) { $errors[$name] = $e->getMessage(); } } if (! empty($errors)) { foreach ($errors as $name => $error) { \common_Logger::d('Error on injector "' . __CLASS__ . '" with writer "' . $name . '" : ' . $error); } throw new MetadataInjectorWriteException( 'Injector "' . __CLASS__ . '" cannot write values from writers: ' . implode(', ', array_keys($errors)) ); } return true; }
php
public function write(\core_kernel_classes_Resource $resource, array $data, $dryrun = false) { $writers = $errors = []; foreach ($this->writers as $name => $writer) { try { $value = $writer->format($data); if ($writer->validate($value)) { $writers[$name] = $writer; } else { $errors[$name] = 'Writer "' . $name . '" cannot validate value.'; } } catch (MetadataReaderNotFoundException $e) { $errors[$name] = 'Writer "' . $name . '" cannot format value: ' . $e->getMessage(); } } foreach ($writers as $name => $writer) { if (! $writer instanceof OntologyWriter) { $errors[$name] = __CLASS__ . ' must implements ' . OntologyWriter::class; continue; } try { $writer->write($resource, $data, $dryrun); } catch (MetadataWriterException $e) { $errors[$name] = $e->getMessage(); } } if (! empty($errors)) { foreach ($errors as $name => $error) { \common_Logger::d('Error on injector "' . __CLASS__ . '" with writer "' . $name . '" : ' . $error); } throw new MetadataInjectorWriteException( 'Injector "' . __CLASS__ . '" cannot write values from writers: ' . implode(', ', array_keys($errors)) ); } return true; }
[ "public", "function", "write", "(", "\\", "core_kernel_classes_Resource", "$", "resource", ",", "array", "$", "data", ",", "$", "dryrun", "=", "false", ")", "{", "$", "writers", "=", "$", "errors", "=", "[", "]", ";", "foreach", "(", "$", "this", "->",...
Write $data values using $this->writers @param \core_kernel_classes_Resource $resource @param array $data @param bool $dryrun @return bool @throws MetadataInjectorWriteException
[ "Write", "$data", "values", "using", "$this", "-", ">", "writers" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/metadata/injector/OntologyMetadataInjector.php#L134-L174
oat-sa/tao-core
models/classes/metadata/injector/OntologyMetadataInjector.php
OntologyMetadataInjector.setReaders
protected function setReaders(array $readers) { foreach ($readers as $name => $options) { $this->readers[$name] = new KeyReader($options); } }
php
protected function setReaders(array $readers) { foreach ($readers as $name => $options) { $this->readers[$name] = new KeyReader($options); } }
[ "protected", "function", "setReaders", "(", "array", "$", "readers", ")", "{", "foreach", "(", "$", "readers", "as", "$", "name", "=>", "$", "options", ")", "{", "$", "this", "->", "readers", "[", "$", "name", "]", "=", "new", "KeyReader", "(", "$", ...
Set $this->readers with Reader instance @param array $readers @throws InconsistencyConfigException
[ "Set", "$this", "-", ">", "readers", "with", "Reader", "instance" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/metadata/injector/OntologyMetadataInjector.php#L182-L187
oat-sa/tao-core
models/classes/metadata/injector/OntologyMetadataInjector.php
OntologyMetadataInjector.setWriters
protected function setWriters(array $writers) { foreach ($writers as $name => $destination) { $this->writers[$name] = $this->buildService($destination); } }
php
protected function setWriters(array $writers) { foreach ($writers as $name => $destination) { $this->writers[$name] = $this->buildService($destination); } }
[ "protected", "function", "setWriters", "(", "array", "$", "writers", ")", "{", "foreach", "(", "$", "writers", "as", "$", "name", "=>", "$", "destination", ")", "{", "$", "this", "->", "writers", "[", "$", "name", "]", "=", "$", "this", "->", "buildS...
Set $this->writers with OntologyWriter instance @param array $writers
[ "Set", "$this", "-", ">", "writers", "with", "OntologyWriter", "instance" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/metadata/injector/OntologyMetadataInjector.php#L194-L199
oat-sa/tao-core
models/classes/metadata/injector/OntologyMetadataInjector.php
OntologyMetadataInjector.__toPhpCode
public function __toPhpCode() { $source = ''; if (! empty($this->readers)) { foreach ($this->readers as $reader) { $source .= \common_Utils::toHumanReadablePhpString($reader, 2) . PHP_EOL; } } $destination = ''; if (! empty($this->writers)) { foreach ($this->writers as $writer) { $destination .= \common_Utils::toHumanReadablePhpString($writer, 2) . PHP_EOL; } } $params = [self::CONFIG_SOURCE => $this->readers, self::CONFIG_DESTINATION => $this->writers]; return 'new ' . get_class($this) . '(' . \common_Utils::toHumanReadablePhpString($params, 1) . '),'; }
php
public function __toPhpCode() { $source = ''; if (! empty($this->readers)) { foreach ($this->readers as $reader) { $source .= \common_Utils::toHumanReadablePhpString($reader, 2) . PHP_EOL; } } $destination = ''; if (! empty($this->writers)) { foreach ($this->writers as $writer) { $destination .= \common_Utils::toHumanReadablePhpString($writer, 2) . PHP_EOL; } } $params = [self::CONFIG_SOURCE => $this->readers, self::CONFIG_DESTINATION => $this->writers]; return 'new ' . get_class($this) . '(' . \common_Utils::toHumanReadablePhpString($params, 1) . '),'; }
[ "public", "function", "__toPhpCode", "(", ")", "{", "$", "source", "=", "''", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "readers", ")", ")", "{", "foreach", "(", "$", "this", "->", "readers", "as", "$", "reader", ")", "{", "$", "sourc...
To configuration serialization @return string
[ "To", "configuration", "serialization" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/metadata/injector/OntologyMetadataInjector.php#L206-L225
oat-sa/tao-core
models/classes/taskQueue/TaskLog/Decorator/HasFileEntityDecorator.php
HasFileEntityDecorator.toArray
public function toArray() { $result = parent::toArray(); $result['hasFile'] = false; $fileNameOrSerial = $this->getFileNameFromReport(); if ($fileNameOrSerial) { $result['hasFile'] = $this->isFileReferenced($fileNameOrSerial) ? true : $this->isFileStoredInQueueStorage($fileNameOrSerial); } return $result; }
php
public function toArray() { $result = parent::toArray(); $result['hasFile'] = false; $fileNameOrSerial = $this->getFileNameFromReport(); if ($fileNameOrSerial) { $result['hasFile'] = $this->isFileReferenced($fileNameOrSerial) ? true : $this->isFileStoredInQueueStorage($fileNameOrSerial); } return $result; }
[ "public", "function", "toArray", "(", ")", "{", "$", "result", "=", "parent", "::", "toArray", "(", ")", ";", "$", "result", "[", "'hasFile'", "]", "=", "false", ";", "$", "fileNameOrSerial", "=", "$", "this", "->", "getFileNameFromReport", "(", ")", "...
Add 'hasFile' to the result. Required by our frontend. @return array
[ "Add", "hasFile", "to", "the", "result", ".", "Required", "by", "our", "frontend", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/taskQueue/TaskLog/Decorator/HasFileEntityDecorator.php#L68-L83
oat-sa/tao-core
helpers/translation/class.POFileReader.php
tao_helpers_translation_POFileReader.read
public function read() { $file = $this->getFilePath(); if (!file_exists($file)) { throw new tao_helpers_translation_TranslationException("The translation file '${file}' does not exist."); } // Create the translation file. $tf = new tao_helpers_translation_POFile(); $fc = implode('',file($file)); $matched = preg_match_all('/((?:#[\.:,\|]{0,1}\s+(?:.*?)\\n)*)'. '(msgctxt\s+(?:"(?:[^"]|\\\\")*?"\s*)+)?'. '(msgid\s+(?:"(?:[^"]|\\\\")*?"\s*)+)\s+' . '(msgstr\s+(?:"(?:[^"]|\\\\")*?(?<!\\\)"\s*)+)/', $fc, $matches); preg_match('/sourceLanguage: (.*?)\\n/s', $fc, $sourceLanguage); preg_match('/targetLanguage: (.*?)\\n/s', $fc, $targetLanguage); if (count($sourceLanguage)) { $tf->setSourceLanguage(substr($sourceLanguage[1],0,5)); } if (count($targetLanguage)) { $tf->setTargetLanguage(substr($targetLanguage[1],0,5)); } if ($matched) { for ($i = 0; $i < $matched; $i++) { $annotations = $matches[1][$i]; $msgctxt = preg_replace('/\s*msgctxt\s*"(.*)"\s*/s','\\1',$matches[2][$i]); $msgid = preg_replace('/\s*msgid\s*"(.*)"\s*/s','\\1',$matches[3][$i]); $msgstr = preg_replace('/\s*msgstr\s*"(.*)"\s*/s','\\1',$matches[4][$i]); // Do not include meta data as a translation unit.. if ($msgid !== ''){ // Sanitze the strings. $msgid = tao_helpers_translation_POUtils::sanitize($msgid); $msgstr = tao_helpers_translation_POUtils::sanitize($msgstr); $msgctxt = tao_helpers_translation_POUtils::sanitize($msgctxt); $tu = new tao_helpers_translation_POTranslationUnit(); // Set up source & target. $tu->setSource($msgid); if ($msgstr !== '') { $tu->setTarget($msgstr); } if ($msgctxt){ $tu->setContext($msgctxt); } // Deal with annotations $annotations = tao_helpers_translation_POUtils::unserializeAnnotations($annotations); foreach ($annotations as $name => $value){ $tu->addAnnotation($name, $value); } $tf->addTranslationUnit($tu); } } } $this->setTranslationFile($tf); }
php
public function read() { $file = $this->getFilePath(); if (!file_exists($file)) { throw new tao_helpers_translation_TranslationException("The translation file '${file}' does not exist."); } // Create the translation file. $tf = new tao_helpers_translation_POFile(); $fc = implode('',file($file)); $matched = preg_match_all('/((?:#[\.:,\|]{0,1}\s+(?:.*?)\\n)*)'. '(msgctxt\s+(?:"(?:[^"]|\\\\")*?"\s*)+)?'. '(msgid\s+(?:"(?:[^"]|\\\\")*?"\s*)+)\s+' . '(msgstr\s+(?:"(?:[^"]|\\\\")*?(?<!\\\)"\s*)+)/', $fc, $matches); preg_match('/sourceLanguage: (.*?)\\n/s', $fc, $sourceLanguage); preg_match('/targetLanguage: (.*?)\\n/s', $fc, $targetLanguage); if (count($sourceLanguage)) { $tf->setSourceLanguage(substr($sourceLanguage[1],0,5)); } if (count($targetLanguage)) { $tf->setTargetLanguage(substr($targetLanguage[1],0,5)); } if ($matched) { for ($i = 0; $i < $matched; $i++) { $annotations = $matches[1][$i]; $msgctxt = preg_replace('/\s*msgctxt\s*"(.*)"\s*/s','\\1',$matches[2][$i]); $msgid = preg_replace('/\s*msgid\s*"(.*)"\s*/s','\\1',$matches[3][$i]); $msgstr = preg_replace('/\s*msgstr\s*"(.*)"\s*/s','\\1',$matches[4][$i]); // Do not include meta data as a translation unit.. if ($msgid !== ''){ // Sanitze the strings. $msgid = tao_helpers_translation_POUtils::sanitize($msgid); $msgstr = tao_helpers_translation_POUtils::sanitize($msgstr); $msgctxt = tao_helpers_translation_POUtils::sanitize($msgctxt); $tu = new tao_helpers_translation_POTranslationUnit(); // Set up source & target. $tu->setSource($msgid); if ($msgstr !== '') { $tu->setTarget($msgstr); } if ($msgctxt){ $tu->setContext($msgctxt); } // Deal with annotations $annotations = tao_helpers_translation_POUtils::unserializeAnnotations($annotations); foreach ($annotations as $name => $value){ $tu->addAnnotation($name, $value); } $tf->addTranslationUnit($tu); } } } $this->setTranslationFile($tf); }
[ "public", "function", "read", "(", ")", "{", "$", "file", "=", "$", "this", "->", "getFilePath", "(", ")", ";", "if", "(", "!", "file_exists", "(", "$", "file", ")", ")", "{", "throw", "new", "tao_helpers_translation_TranslationException", "(", "\"The tran...
Short description of method read @access public @author firstname and lastname of author, <author@example.org> @throws tao_helpers_translation_TranslationException @return mixed
[ "Short", "description", "of", "method", "read" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/translation/class.POFileReader.php#L50-L119
oat-sa/tao-core
models/classes/entryPoint/EntryPointService.php
EntryPointService.overrideEntryPoint
public function overrideEntryPoint($id, Entrypoint $e) { $entryPoints = $this->getOption(self::OPTION_ENTRYPOINTS); $entryPoints[$id] = $e; $this->setOption(self::OPTION_ENTRYPOINTS, $entryPoints); }
php
public function overrideEntryPoint($id, Entrypoint $e) { $entryPoints = $this->getOption(self::OPTION_ENTRYPOINTS); $entryPoints[$id] = $e; $this->setOption(self::OPTION_ENTRYPOINTS, $entryPoints); }
[ "public", "function", "overrideEntryPoint", "(", "$", "id", ",", "Entrypoint", "$", "e", ")", "{", "$", "entryPoints", "=", "$", "this", "->", "getOption", "(", "self", "::", "OPTION_ENTRYPOINTS", ")", ";", "$", "entryPoints", "[", "$", "id", "]", "=", ...
Replace the entrypoint with the id provided @param string $id @param Entrypoint $e
[ "Replace", "the", "entrypoint", "with", "the", "id", "provided" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/entryPoint/EntryPointService.php#L47-L52
oat-sa/tao-core
models/classes/entryPoint/EntryPointService.php
EntryPointService.activateEntryPoint
public function activateEntryPoint($entryId, $target) { $success = false; $entryPoints = $this->getOption(self::OPTION_ENTRYPOINTS); if (!isset($entryPoints[$entryId])) { throw new \common_exception_InconsistentData('Unknown entrypoint '.$entryId); } $actives = $this->hasOption($target) ? $this->getOption($target) : array(); if (!in_array($entryId, $actives)) { $actives[] = $entryId; $this->setOption($target, $actives); $success = true; } return $success; }
php
public function activateEntryPoint($entryId, $target) { $success = false; $entryPoints = $this->getOption(self::OPTION_ENTRYPOINTS); if (!isset($entryPoints[$entryId])) { throw new \common_exception_InconsistentData('Unknown entrypoint '.$entryId); } $actives = $this->hasOption($target) ? $this->getOption($target) : array(); if (!in_array($entryId, $actives)) { $actives[] = $entryId; $this->setOption($target, $actives); $success = true; } return $success; }
[ "public", "function", "activateEntryPoint", "(", "$", "entryId", ",", "$", "target", ")", "{", "$", "success", "=", "false", ";", "$", "entryPoints", "=", "$", "this", "->", "getOption", "(", "self", "::", "OPTION_ENTRYPOINTS", ")", ";", "if", "(", "!", ...
Activate an existing entry point for a specific target @param string $entryId @param string $target @throws \common_exception_InconsistentData @return boolean success
[ "Activate", "an", "existing", "entry", "point", "for", "a", "specific", "target" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/entryPoint/EntryPointService.php#L62-L77
oat-sa/tao-core
models/classes/entryPoint/EntryPointService.php
EntryPointService.deactivateEntryPoint
public function deactivateEntryPoint($entryId, $target = self::OPTION_POSTLOGIN) { $success = false; $entryPoints = $this->getOption(self::OPTION_ENTRYPOINTS); if (!isset($entryPoints[$entryId])) { throw new \common_exception_InconsistentData('Unknown entrypoint '.$entryId); } $actives = $this->hasOption($target) ? $this->getOption($target) : array(); if (in_array($entryId, $actives)) { $actives = array_diff($actives, array($entryId)); $this->setOption($target, $actives); $success = true; } else { \common_Logger::w('Tried to desactivate inactive entry point '.$entryId); } return $success; }
php
public function deactivateEntryPoint($entryId, $target = self::OPTION_POSTLOGIN) { $success = false; $entryPoints = $this->getOption(self::OPTION_ENTRYPOINTS); if (!isset($entryPoints[$entryId])) { throw new \common_exception_InconsistentData('Unknown entrypoint '.$entryId); } $actives = $this->hasOption($target) ? $this->getOption($target) : array(); if (in_array($entryId, $actives)) { $actives = array_diff($actives, array($entryId)); $this->setOption($target, $actives); $success = true; } else { \common_Logger::w('Tried to desactivate inactive entry point '.$entryId); } return $success; }
[ "public", "function", "deactivateEntryPoint", "(", "$", "entryId", ",", "$", "target", "=", "self", "::", "OPTION_POSTLOGIN", ")", "{", "$", "success", "=", "false", ";", "$", "entryPoints", "=", "$", "this", "->", "getOption", "(", "self", "::", "OPTION_E...
Dectivate an existing entry point for a specific target @param string $entryId @param string $target @throws \common_exception_InconsistentData @return boolean success
[ "Dectivate", "an", "existing", "entry", "point", "for", "a", "specific", "target" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/entryPoint/EntryPointService.php#L87-L103
oat-sa/tao-core
models/classes/entryPoint/EntryPointService.php
EntryPointService.addEntryPoint
public function addEntryPoint(Entrypoint $e, $target = null) { $entryPoints = $this->getOption(self::OPTION_ENTRYPOINTS); $entryPoints[$e->getId()] = $e; $this->setOption(self::OPTION_ENTRYPOINTS, $entryPoints); if (!is_null($target)) { $this->activateEntryPoint($e->getId(), $target); } }
php
public function addEntryPoint(Entrypoint $e, $target = null) { $entryPoints = $this->getOption(self::OPTION_ENTRYPOINTS); $entryPoints[$e->getId()] = $e; $this->setOption(self::OPTION_ENTRYPOINTS, $entryPoints); if (!is_null($target)) { $this->activateEntryPoint($e->getId(), $target); } }
[ "public", "function", "addEntryPoint", "(", "Entrypoint", "$", "e", ",", "$", "target", "=", "null", ")", "{", "$", "entryPoints", "=", "$", "this", "->", "getOption", "(", "self", "::", "OPTION_ENTRYPOINTS", ")", ";", "$", "entryPoints", "[", "$", "e", ...
Add an Entrypoint and activate it if a target is specified @param Entrypoint $e @param string $target
[ "Add", "an", "Entrypoint", "and", "activate", "it", "if", "a", "target", "is", "specified" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/entryPoint/EntryPointService.php#L112-L121
oat-sa/tao-core
models/classes/entryPoint/EntryPointService.php
EntryPointService.removeEntryPoint
public function removeEntryPoint($entryId) { $entryPoints = $this->getOption(self::OPTION_ENTRYPOINTS); if (!isset($entryPoints[$entryId])) { throw new \common_exception_InconsistentData('Unknown entrypoint ' . $entryId); } // delete entrypoint from all options entries $options = $this->getOptions(); foreach ($options as $section => $option) { $sectionIsArray = false; foreach ($option as $key => $val) { if ($key === $entryId || $val == $entryId) { unset($options[$section][$key]); } if ($val == $entryId) { $sectionIsArray = true; } } if ($sectionIsArray) { $options[$section] = array_values($options[$section]); } } $this->setOptions($options); }
php
public function removeEntryPoint($entryId) { $entryPoints = $this->getOption(self::OPTION_ENTRYPOINTS); if (!isset($entryPoints[$entryId])) { throw new \common_exception_InconsistentData('Unknown entrypoint ' . $entryId); } // delete entrypoint from all options entries $options = $this->getOptions(); foreach ($options as $section => $option) { $sectionIsArray = false; foreach ($option as $key => $val) { if ($key === $entryId || $val == $entryId) { unset($options[$section][$key]); } if ($val == $entryId) { $sectionIsArray = true; } } if ($sectionIsArray) { $options[$section] = array_values($options[$section]); } } $this->setOptions($options); }
[ "public", "function", "removeEntryPoint", "(", "$", "entryId", ")", "{", "$", "entryPoints", "=", "$", "this", "->", "getOption", "(", "self", "::", "OPTION_ENTRYPOINTS", ")", ";", "if", "(", "!", "isset", "(", "$", "entryPoints", "[", "$", "entryId", "]...
Remove entrypoint @param $entryId @throws \common_exception_InconsistentData
[ "Remove", "entrypoint" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/entryPoint/EntryPointService.php#L129-L156
oat-sa/tao-core
models/classes/entryPoint/EntryPointService.php
EntryPointService.getEntryPoints
public function getEntryPoints($target = self::OPTION_POSTLOGIN) { $ids = $this->hasOption($target) ? $this->getOption($target) : array(); $existing = $this->getOption(self::OPTION_ENTRYPOINTS); if ($target === self::OPTION_ENTRYPOINTS) { return $existing; } $entryPoints = array(); foreach ($ids as $id) { $entryPoints[$id] = $existing[$id]; } return $entryPoints; }
php
public function getEntryPoints($target = self::OPTION_POSTLOGIN) { $ids = $this->hasOption($target) ? $this->getOption($target) : array(); $existing = $this->getOption(self::OPTION_ENTRYPOINTS); if ($target === self::OPTION_ENTRYPOINTS) { return $existing; } $entryPoints = array(); foreach ($ids as $id) { $entryPoints[$id] = $existing[$id]; } return $entryPoints; }
[ "public", "function", "getEntryPoints", "(", "$", "target", "=", "self", "::", "OPTION_POSTLOGIN", ")", "{", "$", "ids", "=", "$", "this", "->", "hasOption", "(", "$", "target", ")", "?", "$", "this", "->", "getOption", "(", "$", "target", ")", ":", ...
Get all entrypoints for a designated target @param string $target @return Entrypoint[]
[ "Get", "all", "entrypoints", "for", "a", "designated", "target" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/entryPoint/EntryPointService.php#L164-L178
oat-sa/tao-core
models/classes/entryPoint/EntryPointService.php
EntryPointService.registerEntryPoint
public function registerEntryPoint(Entrypoint $e) { $this->addEntryPoint($e, self::OPTION_POSTLOGIN); $this->getServiceManager()->register(self::SERVICE_ID, $this); }
php
public function registerEntryPoint(Entrypoint $e) { $this->addEntryPoint($e, self::OPTION_POSTLOGIN); $this->getServiceManager()->register(self::SERVICE_ID, $this); }
[ "public", "function", "registerEntryPoint", "(", "Entrypoint", "$", "e", ")", "{", "$", "this", "->", "addEntryPoint", "(", "$", "e", ",", "self", "::", "OPTION_POSTLOGIN", ")", ";", "$", "this", "->", "getServiceManager", "(", ")", "->", "register", "(", ...
Legacy function for backward compatibilitiy @param Entrypoint $e @param string $target @deprecated
[ "Legacy", "function", "for", "backward", "compatibilitiy" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/entryPoint/EntryPointService.php#L198-L202
oat-sa/tao-core
models/classes/maintenance/Maintenance.php
Maintenance.isPlatformReady
public function isPlatformReady(MaintenanceState $state = null) { if (is_null($state)) { $state = $this->getPlatformState(); } return ($state->getBooleanStatus() === true); }
php
public function isPlatformReady(MaintenanceState $state = null) { if (is_null($state)) { $state = $this->getPlatformState(); } return ($state->getBooleanStatus() === true); }
[ "public", "function", "isPlatformReady", "(", "MaintenanceState", "$", "state", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "state", ")", ")", "{", "$", "state", "=", "$", "this", "->", "getPlatformState", "(", ")", ";", "}", "return", "(", ...
Check if platform is ready, if $state is null, it is retrieved from storage @param MaintenanceState|null $state @return bool
[ "Check", "if", "platform", "is", "ready", "if", "$state", "is", "null", "it", "is", "retrieved", "from", "storage" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/maintenance/Maintenance.php#L52-L58