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 | install/class.ExtensionInstaller.php | tao_install_ExtensionInstaller.installManagementRole | public function installManagementRole()
{
// Try to get a Management Role described by the extension itself.
// (this information comes actually from the Manifest of the extension)
$roleUri = $this->extension->getManifest()->getManagementRoleUri();
if (! empty($roleUri)) {
$role = new core_kernel_classes_Resource($roleUri);
$roleService = tao_models_classes_RoleService::singleton();
if (! $role->exists()) {
// Management role does not exist yet, so we create it
$roleClass = new core_kernel_classes_Class(TaoOntology::CLASS_URI_MANAGEMENT_ROLE);
$roleLabel = $this->extension->getId() . ' Manager';
$role = $roleClass->createInstance($roleLabel, $roleLabel . ' Role', $role->getUri());
$roleService->includeRole($role, new core_kernel_classes_Resource(TaoRoles::BACK_OFFICE));
}
// Take the Global Manager role and make it include
// the Management role of the currently installed extension.
if ($role->getUri() !== TaoRoles::GLOBAL_MANAGER) {
$globalManagerRole = new core_kernel_classes_Resource(TaoRoles::GLOBAL_MANAGER);
$roleService->includeRole($globalManagerRole, $role);
}
common_Logger::d("Management Role " . $role->getUri() . " created for extension '" . $this->extension->getId() . "'.");
} else {
// There is no Management role described by the Extension Manifest.
common_Logger::i("No management role for extension '" . $this->extension->getId() . "'.");
}
} | php | public function installManagementRole()
{
// Try to get a Management Role described by the extension itself.
// (this information comes actually from the Manifest of the extension)
$roleUri = $this->extension->getManifest()->getManagementRoleUri();
if (! empty($roleUri)) {
$role = new core_kernel_classes_Resource($roleUri);
$roleService = tao_models_classes_RoleService::singleton();
if (! $role->exists()) {
// Management role does not exist yet, so we create it
$roleClass = new core_kernel_classes_Class(TaoOntology::CLASS_URI_MANAGEMENT_ROLE);
$roleLabel = $this->extension->getId() . ' Manager';
$role = $roleClass->createInstance($roleLabel, $roleLabel . ' Role', $role->getUri());
$roleService->includeRole($role, new core_kernel_classes_Resource(TaoRoles::BACK_OFFICE));
}
// Take the Global Manager role and make it include
// the Management role of the currently installed extension.
if ($role->getUri() !== TaoRoles::GLOBAL_MANAGER) {
$globalManagerRole = new core_kernel_classes_Resource(TaoRoles::GLOBAL_MANAGER);
$roleService->includeRole($globalManagerRole, $role);
}
common_Logger::d("Management Role " . $role->getUri() . " created for extension '" . $this->extension->getId() . "'.");
} else {
// There is no Management role described by the Extension Manifest.
common_Logger::i("No management role for extension '" . $this->extension->getId() . "'.");
}
} | [
"public",
"function",
"installManagementRole",
"(",
")",
"{",
"// Try to get a Management Role described by the extension itself.",
"// (this information comes actually from the Manifest of the extension)",
"$",
"roleUri",
"=",
"$",
"this",
"->",
"extension",
"->",
"getManifest",
"... | Will make the Global Manager include the Management Role of the extension
to install (if it exists).
@access public
@author Jerome Bogaerts <jerome@taotesting.com>
@return void
@since 2.4 | [
"Will",
"make",
"the",
"Global",
"Manager",
"include",
"the",
"Management",
"Role",
"of",
"the",
"extension",
"to",
"install",
"(",
"if",
"it",
"exists",
")",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/install/class.ExtensionInstaller.php#L83-L113 |
oat-sa/tao-core | install/class.ExtensionInstaller.php | tao_install_ExtensionInstaller.applyAccessRules | public function applyAccessRules()
{
foreach ($this->extension->getManifest()->getAclTable() as $tableEntry) {
$rule = new AccessRule($tableEntry[0], $tableEntry[1], $tableEntry[2]);
AclProxy::applyRule($rule);
}
} | php | public function applyAccessRules()
{
foreach ($this->extension->getManifest()->getAclTable() as $tableEntry) {
$rule = new AccessRule($tableEntry[0], $tableEntry[1], $tableEntry[2]);
AclProxy::applyRule($rule);
}
} | [
"public",
"function",
"applyAccessRules",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"extension",
"->",
"getManifest",
"(",
")",
"->",
"getAclTable",
"(",
")",
"as",
"$",
"tableEntry",
")",
"{",
"$",
"rule",
"=",
"new",
"AccessRule",
"(",
"$",
"... | Will make the Global Manager include the Management Role of the extension
to install (if it exists).
@access public
@author Jerome Bogaerts <jerome@taotesting.com>
@return void
@since 2.4 | [
"Will",
"make",
"the",
"Global",
"Manager",
"include",
"the",
"Management",
"Role",
"of",
"the",
"extension",
"to",
"install",
"(",
"if",
"it",
"exists",
")",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/install/class.ExtensionInstaller.php#L124-L130 |
oat-sa/tao-core | install/class.ExtensionInstaller.php | tao_install_ExtensionInstaller.registerClientLib | public function registerClientLib()
{
$jsPath = trim(Template::js('', $this->extension->getId()), '/');
ClientLibRegistry::getRegistry()->register($this->extension->getId(), $jsPath);
$cssPath = trim(Template::css('', $this->extension->getId()), '/');
ClientLibRegistry::getRegistry()->register($this->extension->getId().'Css', $cssPath);
} | php | public function registerClientLib()
{
$jsPath = trim(Template::js('', $this->extension->getId()), '/');
ClientLibRegistry::getRegistry()->register($this->extension->getId(), $jsPath);
$cssPath = trim(Template::css('', $this->extension->getId()), '/');
ClientLibRegistry::getRegistry()->register($this->extension->getId().'Css', $cssPath);
} | [
"public",
"function",
"registerClientLib",
"(",
")",
"{",
"$",
"jsPath",
"=",
"trim",
"(",
"Template",
"::",
"js",
"(",
"''",
",",
"$",
"this",
"->",
"extension",
"->",
"getId",
"(",
")",
")",
",",
"'/'",
")",
";",
"ClientLibRegistry",
"::",
"getRegist... | Extension may declare client lib to add alias into requireJs
@author Lionel Lecaque, lionel@taotesting.com | [
"Extension",
"may",
"declare",
"client",
"lib",
"to",
"add",
"alias",
"into",
"requireJs"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/install/class.ExtensionInstaller.php#L137-L144 |
oat-sa/tao-core | install/services/class.CheckCustomService.php | tao_install_services_CheckCustomService.execute | public function execute(){
$content = json_decode($this->getData()->getContent(), true);
$name = $content['value']['name'];
$extension = $content['value']['extension'];
$check = self::buildComponent($this->getData());
if ($check !== null){
$report = $check->check();
$this->setResult(self::buildResult($this->getData(), $report, $check));
}
else{
throw new tao_install_services_UnknownCustomCheckException($name, $extension);
}
} | php | public function execute(){
$content = json_decode($this->getData()->getContent(), true);
$name = $content['value']['name'];
$extension = $content['value']['extension'];
$check = self::buildComponent($this->getData());
if ($check !== null){
$report = $check->check();
$this->setResult(self::buildResult($this->getData(), $report, $check));
}
else{
throw new tao_install_services_UnknownCustomCheckException($name, $extension);
}
} | [
"public",
"function",
"execute",
"(",
")",
"{",
"$",
"content",
"=",
"json_decode",
"(",
"$",
"this",
"->",
"getData",
"(",
")",
"->",
"getContent",
"(",
")",
",",
"true",
")",
";",
"$",
"name",
"=",
"$",
"content",
"[",
"'value'",
"]",
"[",
"'name... | Executes the main logic of the service.
@return tao_install_services_Data The result of the service execution. | [
"Executes",
"the",
"main",
"logic",
"of",
"the",
"service",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/install/services/class.CheckCustomService.php#L51-L64 |
oat-sa/tao-core | models/classes/user/import/RdsUserImportService.php | RdsUserImportService.persist | protected function persist(ImportMapperInterface $userMapper)
{
if (!$userMapper instanceof UserMapperInterface) {
throw new \Exception('Mapper should be a UserMapper');
}
$plainPassword = $userMapper->getPlainPassword();
$properties = $userMapper->getProperties();
$class = $this->getUserClass($properties);
$results = $class->searchInstances(
[
UserRdf::PROPERTY_LOGIN => $properties[UserRdf::PROPERTY_LOGIN]
],
[
'like' => false,
'recursive' => true
]
);
if(count($results) > 0){
$resource = $this->mergeUserProperties(current($results), $properties);
} else {
$resource = $class->createInstanceWithProperties($properties);
}
$this->triggerUserUpdated($resource, $properties, $plainPassword);
return $resource;
} | php | protected function persist(ImportMapperInterface $userMapper)
{
if (!$userMapper instanceof UserMapperInterface) {
throw new \Exception('Mapper should be a UserMapper');
}
$plainPassword = $userMapper->getPlainPassword();
$properties = $userMapper->getProperties();
$class = $this->getUserClass($properties);
$results = $class->searchInstances(
[
UserRdf::PROPERTY_LOGIN => $properties[UserRdf::PROPERTY_LOGIN]
],
[
'like' => false,
'recursive' => true
]
);
if(count($results) > 0){
$resource = $this->mergeUserProperties(current($results), $properties);
} else {
$resource = $class->createInstanceWithProperties($properties);
}
$this->triggerUserUpdated($resource, $properties, $plainPassword);
return $resource;
} | [
"protected",
"function",
"persist",
"(",
"ImportMapperInterface",
"$",
"userMapper",
")",
"{",
"if",
"(",
"!",
"$",
"userMapper",
"instanceof",
"UserMapperInterface",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Mapper should be a UserMapper'",
")",
";",
"}... | Persist a user, create or update
@param ImportMapperInterface $userMapper
@return \core_kernel_classes_Resource
@throws \Exception | [
"Persist",
"a",
"user",
"create",
"or",
"update"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/user/import/RdsUserImportService.php#L42-L72 |
oat-sa/tao-core | models/classes/user/import/RdsUserImportService.php | RdsUserImportService.triggerUserUpdated | protected function triggerUserUpdated(\core_kernel_classes_Resource $resource, array $properties, $plainPassword)
{
/** @var EventManager $eventManager */
$eventManager = $this->getServiceLocator()->get(EventManager::SERVICE_ID);
$eventManager->trigger(new UserUpdatedEvent($resource,
array_merge(
$properties,
[
'hashForKey' => UserHashForEncryption::hash($plainPassword)
]
)
));
} | php | protected function triggerUserUpdated(\core_kernel_classes_Resource $resource, array $properties, $plainPassword)
{
/** @var EventManager $eventManager */
$eventManager = $this->getServiceLocator()->get(EventManager::SERVICE_ID);
$eventManager->trigger(new UserUpdatedEvent($resource,
array_merge(
$properties,
[
'hashForKey' => UserHashForEncryption::hash($plainPassword)
]
)
));
} | [
"protected",
"function",
"triggerUserUpdated",
"(",
"\\",
"core_kernel_classes_Resource",
"$",
"resource",
",",
"array",
"$",
"properties",
",",
"$",
"plainPassword",
")",
"{",
"/** @var EventManager $eventManager */",
"$",
"eventManager",
"=",
"$",
"this",
"->",
"get... | Trigger UserEvent at user update
@param \core_kernel_classes_Resource $resource
@param array $properties
@param string $plainPassword | [
"Trigger",
"UserEvent",
"at",
"user",
"update"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/user/import/RdsUserImportService.php#L92-L104 |
oat-sa/tao-core | models/classes/user/import/RdsUserImportService.php | RdsUserImportService.mergeUserProperties | protected function mergeUserProperties(\core_kernel_classes_Resource $user, $properties)
{
foreach ($properties as $property => $value) {
$user->removePropertyValues($this->getProperty($property));
$user->editPropertyValues($this->getProperty($property), $value);
}
return $user;
} | php | protected function mergeUserProperties(\core_kernel_classes_Resource $user, $properties)
{
foreach ($properties as $property => $value) {
$user->removePropertyValues($this->getProperty($property));
$user->editPropertyValues($this->getProperty($property), $value);
}
return $user;
} | [
"protected",
"function",
"mergeUserProperties",
"(",
"\\",
"core_kernel_classes_Resource",
"$",
"user",
",",
"$",
"properties",
")",
"{",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"property",
"=>",
"$",
"value",
")",
"{",
"$",
"user",
"->",
"removeProperty... | Flush rdf properties to a resource
- delete old
- insert new
@param \core_kernel_classes_Resource $user
@param $properties
@return \core_kernel_classes_Resource | [
"Flush",
"rdf",
"properties",
"to",
"a",
"resource",
"-",
"delete",
"old",
"-",
"insert",
"new"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/user/import/RdsUserImportService.php#L115-L123 |
oat-sa/tao-core | models/classes/routing/FlowController.php | FlowController.forwardUrl | public function forwardUrl($url){
//get the current request
$request = common_http_Request::currentRequest();
$params = $request->getParams();
//parse the given URL
$parsedUrl = parse_url($url);
//if new parameters are given, then merge them
if(isset($parsedUrl['query']) && strlen($parsedUrl['query']) > 0){
$newParams = array();
parse_str($parsedUrl['query'], $newParams);
if(count($newParams) > 0){
$params = array_merge($params, $newParams);
}
}
//resolve the given URL for routing
$resolver = new Resolver(new common_http_Request($parsedUrl['path'], $request->getMethod(), $params));
$this->propagate($resolver);
$context = Context::getInstance();
// load the responsible extension
common_ext_ExtensionsManager::singleton()->getExtensionById($resolver->getExtensionId());
//update the context to the new route
$context->setExtensionName($resolver->getExtensionId());
$context->setModuleName($resolver->getControllerShortName());
$context->setActionName($resolver->getMethodName());
if(count($params) > 0){
$context->getRequest()->addParameters($params);
}
//add a custom header so the client knows where the route ends
header(self::FORWARD_HEADER . ': ' . $resolver->getExtensionId() . '/' . $resolver->getControllerShortName() . '/' . $resolver->getMethodName());
//execite the new action
$enforcer = new ActionEnforcer($resolver->getExtensionId(), $resolver->getControllerClass(), $resolver->getMethodName(), $params);
$this->propagate($enforcer);
$enforcer->execute();
//should not be reached
throw new InterruptedActionException('Interrupted action after a forward',
$context->getModuleName(),
$context->getActionName());
} | php | public function forwardUrl($url){
//get the current request
$request = common_http_Request::currentRequest();
$params = $request->getParams();
//parse the given URL
$parsedUrl = parse_url($url);
//if new parameters are given, then merge them
if(isset($parsedUrl['query']) && strlen($parsedUrl['query']) > 0){
$newParams = array();
parse_str($parsedUrl['query'], $newParams);
if(count($newParams) > 0){
$params = array_merge($params, $newParams);
}
}
//resolve the given URL for routing
$resolver = new Resolver(new common_http_Request($parsedUrl['path'], $request->getMethod(), $params));
$this->propagate($resolver);
$context = Context::getInstance();
// load the responsible extension
common_ext_ExtensionsManager::singleton()->getExtensionById($resolver->getExtensionId());
//update the context to the new route
$context->setExtensionName($resolver->getExtensionId());
$context->setModuleName($resolver->getControllerShortName());
$context->setActionName($resolver->getMethodName());
if(count($params) > 0){
$context->getRequest()->addParameters($params);
}
//add a custom header so the client knows where the route ends
header(self::FORWARD_HEADER . ': ' . $resolver->getExtensionId() . '/' . $resolver->getControllerShortName() . '/' . $resolver->getMethodName());
//execite the new action
$enforcer = new ActionEnforcer($resolver->getExtensionId(), $resolver->getControllerClass(), $resolver->getMethodName(), $params);
$this->propagate($enforcer);
$enforcer->execute();
//should not be reached
throw new InterruptedActionException('Interrupted action after a forward',
$context->getModuleName(),
$context->getActionName());
} | [
"public",
"function",
"forwardUrl",
"(",
"$",
"url",
")",
"{",
"//get the current request",
"$",
"request",
"=",
"common_http_Request",
"::",
"currentRequest",
"(",
")",
";",
"$",
"params",
"=",
"$",
"request",
"->",
"getParams",
"(",
")",
";",
"//parse the gi... | Forward the action to execute reqarding a URL
The forward runs into tha same HTTP request unlike redirect.
@param string $url the url to forward to | [
"Forward",
"the",
"action",
"to",
"execute",
"reqarding",
"a",
"URL",
"The",
"forward",
"runs",
"into",
"tha",
"same",
"HTTP",
"request",
"unlike",
"redirect",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/routing/FlowController.php#L53-L101 |
oat-sa/tao-core | models/classes/routing/FlowController.php | FlowController.forward | public function forward($action, $controller = null, $extension = null, $params = array())
{
//as we use a route resolver, it's easier to rebuild the URL to resolve it
$this->forwardUrl(\tao_helpers_Uri::url($action, $controller, $extension, $params));
} | php | public function forward($action, $controller = null, $extension = null, $params = array())
{
//as we use a route resolver, it's easier to rebuild the URL to resolve it
$this->forwardUrl(\tao_helpers_Uri::url($action, $controller, $extension, $params));
} | [
"public",
"function",
"forward",
"(",
"$",
"action",
",",
"$",
"controller",
"=",
"null",
",",
"$",
"extension",
"=",
"null",
",",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"//as we use a route resolver, it's easier to rebuild the URL to resolve it ",
"$",
... | Forward routing.
@param string $action the name of the new action
@param string $controller the name of the new controller/module
@param string $extension the name of the new extension
@param array $params additional parameters | [
"Forward",
"routing",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/routing/FlowController.php#L111-L115 |
oat-sa/tao-core | scripts/class.TaoTranslate.php | tao_scripts_TaoTranslate.preRun | public function preRun()
{
$this->options = array('verbose' => false,
'action' => null,
'extension' => null);
$this->options = array_merge($this->options, $this->parameters);
if ($this->options['verbose'] == true) {
$this->verbose = true;
}
// The 'action' parameter is always required.
if ($this->options['action'] == null) {
$this->err("Please enter the 'action' parameter.", true);
} else {
$this->options['action'] = strtolower($this->options['action']);
if (!in_array($this->options['action'], array_keys($this->getAllowedActions()))) {
$this->err("'" . $this->options['action'] . "' is not a valid action.", true);
} else {
// The 'action' parameter is ok.
// Let's check additional inputs depending on the value of the 'action' parameter.
$this->checkInput();
}
}
} | php | public function preRun()
{
$this->options = array('verbose' => false,
'action' => null,
'extension' => null);
$this->options = array_merge($this->options, $this->parameters);
if ($this->options['verbose'] == true) {
$this->verbose = true;
}
// The 'action' parameter is always required.
if ($this->options['action'] == null) {
$this->err("Please enter the 'action' parameter.", true);
} else {
$this->options['action'] = strtolower($this->options['action']);
if (!in_array($this->options['action'], array_keys($this->getAllowedActions()))) {
$this->err("'" . $this->options['action'] . "' is not a valid action.", true);
} else {
// The 'action' parameter is ok.
// Let's check additional inputs depending on the value of the 'action' parameter.
$this->checkInput();
}
}
} | [
"public",
"function",
"preRun",
"(",
")",
"{",
"$",
"this",
"->",
"options",
"=",
"array",
"(",
"'verbose'",
"=>",
"false",
",",
"'action'",
"=>",
"null",
",",
"'extension'",
"=>",
"null",
")",
";",
"$",
"this",
"->",
"options",
"=",
"array_merge",
"("... | Things that must happen before script execution.
@access public
@author Joel Bout, <joel.bout@tudor.lu>
@return void | [
"Things",
"that",
"must",
"happen",
"before",
"script",
"execution",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoTranslate.php#L135-L162 |
oat-sa/tao-core | scripts/class.TaoTranslate.php | tao_scripts_TaoTranslate.run | public function run()
{
// Select the action to perform depending on the 'action' parameter.
// Verification of the value of 'action' performed in self::preRun().
$actions = $this->getAllowedActions();
$pendingActionName = 'action' . $actions[$this->options['action']];
if (method_exists($this, $pendingActionName)) {
return $this->$pendingActionName();
}
} | php | public function run()
{
// Select the action to perform depending on the 'action' parameter.
// Verification of the value of 'action' performed in self::preRun().
$actions = $this->getAllowedActions();
$pendingActionName = 'action' . $actions[$this->options['action']];
if (method_exists($this, $pendingActionName)) {
return $this->$pendingActionName();
}
} | [
"public",
"function",
"run",
"(",
")",
"{",
"// Select the action to perform depending on the 'action' parameter.",
"// Verification of the value of 'action' performed in self::preRun().",
"$",
"actions",
"=",
"$",
"this",
"->",
"getAllowedActions",
"(",
")",
";",
"$",
"pending... | Main script implementation.
@access public
@author Joel Bout, <joel.bout@tudor.lu>
@return void | [
"Main",
"script",
"implementation",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoTranslate.php#L171-L180 |
oat-sa/tao-core | scripts/class.TaoTranslate.php | tao_scripts_TaoTranslate.checkInput | private function checkInput()
{
$actions = $this->getAllowedActions();
$pendingActionName = 'check' . $actions[$this->options['action']].'Input';
if (method_exists($this, $pendingActionName)) {
return $this->$pendingActionName();
}
} | php | private function checkInput()
{
$actions = $this->getAllowedActions();
$pendingActionName = 'check' . $actions[$this->options['action']].'Input';
if (method_exists($this, $pendingActionName)) {
return $this->$pendingActionName();
}
} | [
"private",
"function",
"checkInput",
"(",
")",
"{",
"$",
"actions",
"=",
"$",
"this",
"->",
"getAllowedActions",
"(",
")",
";",
"$",
"pendingActionName",
"=",
"'check'",
".",
"$",
"actions",
"[",
"$",
"this",
"->",
"options",
"[",
"'action'",
"]",
"]",
... | Checks the inputs for the current script call.
@access private
@author Joel Bout, <joel.bout@tudor.lu>
@return void | [
"Checks",
"the",
"inputs",
"for",
"the",
"current",
"script",
"call",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoTranslate.php#L202-L209 |
oat-sa/tao-core | scripts/class.TaoTranslate.php | tao_scripts_TaoTranslate.checkCreateInput | private function checkCreateInput()
{
$defaults = array('language' => null,
'languageLabel' => null,
'extension' => null,
'input' => dirname(__FILE__) . '/../../' . $this->options['extension'] . '/' . self::DEF_INPUT_DIR,
'output' => dirname(__FILE__) . '/../../' . $this->options['extension'] . '/' . self::DEF_OUTPUT_DIR,
'build' => true, // Build translation files by having a look in source code, models.
'force' => false); // Do not force rebuild if locale already exist.
$this->options = array_merge($defaults, $this->options);
if (is_null($this->options['language'])) {
$this->err("Please provide a 'language' identifier such as en-US, fr-CA, IT, ...", true);
} else {
if (is_null($this->options['extension'])) {
$this->err("Please provide an 'extension' for which the 'language' will be created", true);
} else {
// Check if the extension(s) exists.
$extensionsToCreate = explode(',', $this->options['extension']);
$extensionsToCreate = array_unique($extensionsToCreate);
foreach ($extensionsToCreate as $etc){
$this->options['input'] = dirname(__FILE__) . '/../../' . $etc . '/' . self::DEF_INPUT_DIR;
$this->options['output'] = dirname(__FILE__) . '/../../' . $etc . '/' . self::DEF_OUTPUT_DIR;
$extensionDir = dirname(__FILE__) . '/../../' . $etc;
if (!is_dir($extensionDir)) {
$this->err("The extension '" . $etc . "' does not exist.", true);
} else if (!is_readable($extensionDir)) {
$this->err("The '" . $etc . "' directory is not readable. Please check permissions on this directory.", true);
} else if (!is_writable($extensionDir)) {
$this->err("The '" . $etc . "' directory is not writable. Please check permissions on this directory.", true);
}
// The input 'parameter' is optional.
// (and only used if the 'build' parameter is set to true)
$this->checkInputOption();
// The 'output' parameter is optional.
$this->checkOutputOption();
}
}
}
} | php | private function checkCreateInput()
{
$defaults = array('language' => null,
'languageLabel' => null,
'extension' => null,
'input' => dirname(__FILE__) . '/../../' . $this->options['extension'] . '/' . self::DEF_INPUT_DIR,
'output' => dirname(__FILE__) . '/../../' . $this->options['extension'] . '/' . self::DEF_OUTPUT_DIR,
'build' => true, // Build translation files by having a look in source code, models.
'force' => false); // Do not force rebuild if locale already exist.
$this->options = array_merge($defaults, $this->options);
if (is_null($this->options['language'])) {
$this->err("Please provide a 'language' identifier such as en-US, fr-CA, IT, ...", true);
} else {
if (is_null($this->options['extension'])) {
$this->err("Please provide an 'extension' for which the 'language' will be created", true);
} else {
// Check if the extension(s) exists.
$extensionsToCreate = explode(',', $this->options['extension']);
$extensionsToCreate = array_unique($extensionsToCreate);
foreach ($extensionsToCreate as $etc){
$this->options['input'] = dirname(__FILE__) . '/../../' . $etc . '/' . self::DEF_INPUT_DIR;
$this->options['output'] = dirname(__FILE__) . '/../../' . $etc . '/' . self::DEF_OUTPUT_DIR;
$extensionDir = dirname(__FILE__) . '/../../' . $etc;
if (!is_dir($extensionDir)) {
$this->err("The extension '" . $etc . "' does not exist.", true);
} else if (!is_readable($extensionDir)) {
$this->err("The '" . $etc . "' directory is not readable. Please check permissions on this directory.", true);
} else if (!is_writable($extensionDir)) {
$this->err("The '" . $etc . "' directory is not writable. Please check permissions on this directory.", true);
}
// The input 'parameter' is optional.
// (and only used if the 'build' parameter is set to true)
$this->checkInputOption();
// The 'output' parameter is optional.
$this->checkOutputOption();
}
}
}
} | [
"private",
"function",
"checkCreateInput",
"(",
")",
"{",
"$",
"defaults",
"=",
"array",
"(",
"'language'",
"=>",
"null",
",",
"'languageLabel'",
"=>",
"null",
",",
"'extension'",
"=>",
"null",
",",
"'input'",
"=>",
"dirname",
"(",
"__FILE__",
")",
".",
"'... | Checks the inputs for the 'create' action.
@access private
@author Joel Bout, <joel.bout@tudor.lu>
@return void | [
"Checks",
"the",
"inputs",
"for",
"the",
"create",
"action",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoTranslate.php#L218-L262 |
oat-sa/tao-core | scripts/class.TaoTranslate.php | tao_scripts_TaoTranslate.checkUpdateInput | private function checkUpdateInput()
{
$defaults = array('language' => null,
'extension' => null,
'input' => dirname(__FILE__) . '/../../' . $this->options['extension'] . '/' . self::DEF_INPUT_DIR,
'output' => dirname(__FILE__) . '/../../' . $this->options['extension'] . '/' . self::DEF_OUTPUT_DIR);
$this->options = array_merge($defaults, $this->options);
if (is_null($this->options['language'])) {
$this->err("Please provide a 'language' identifier such as en-US, fr-CA, IT, ...", true);
} else {
// Check if the language folder exists and is readable/writable.
$languageDir = $this->buildLanguagePath($this->options['extension'], $this->options['language']);
if (!is_dir($languageDir)) {
$this->err("The 'language' directory ${languageDir} does not exist.", true);
} else if (!is_readable($languageDir)) {
$this->err("The 'language' directory ${languageDir} is not readable. Please check permissions on this directory.");
} else if (!is_writable($languageDir)) {
$this->err("The 'language' directory ${languageDir} is not writable. Please check permissions on this directory.");
} else {
if (is_null($this->options['extension'])) {
$this->err("Please provide an 'extension' for which the 'language' will be created", true);
} else {
// Check if the extension exists.
$extensionDir = dirname(__FILE__) . '/../../' . $this->options['extension'];
if (!is_dir($extensionDir)) {
$this->err("The extension '" . $this->options['extension'] . "' does not exist.", true);
} else if (!is_readable($extensionDir)) {
$this->err("The '" . $this->options['extension'] . "' directory is not readable. Please check permissions on this directory.", true);
} else if (!is_writable($extensionDir)) {
$this->err("The '" . $this->options['extension'] . "' directory is not writable. Please check permissions on this directory.", true);
} else {
// And can we read the messages.po file ?
if (!file_exists($languageDir . '/' . self::DEF_PO_FILENAME)) {
$this->err("Cannot find " . self::DEF_PO_FILENAME . " for extension '" . $this->options['extension'] . "' and language '" . $this->options['language'] . "'.", true);
} else if (!is_readable($languageDir . '/' . self::DEF_PO_FILENAME)) {
$this->err(self::DEF_PO_FILENAME . " is not readable for '" . $this->options['extension'] . "' and language '" . $this->options['language'] . "'. Please check permissions for this file." , true);
} else {
// The input 'parameter' is optional.
$this->checkInputOption();
// The 'output' parameter is optional.
$this->checkOutputOption();
}
}
}
}
}
} | php | private function checkUpdateInput()
{
$defaults = array('language' => null,
'extension' => null,
'input' => dirname(__FILE__) . '/../../' . $this->options['extension'] . '/' . self::DEF_INPUT_DIR,
'output' => dirname(__FILE__) . '/../../' . $this->options['extension'] . '/' . self::DEF_OUTPUT_DIR);
$this->options = array_merge($defaults, $this->options);
if (is_null($this->options['language'])) {
$this->err("Please provide a 'language' identifier such as en-US, fr-CA, IT, ...", true);
} else {
// Check if the language folder exists and is readable/writable.
$languageDir = $this->buildLanguagePath($this->options['extension'], $this->options['language']);
if (!is_dir($languageDir)) {
$this->err("The 'language' directory ${languageDir} does not exist.", true);
} else if (!is_readable($languageDir)) {
$this->err("The 'language' directory ${languageDir} is not readable. Please check permissions on this directory.");
} else if (!is_writable($languageDir)) {
$this->err("The 'language' directory ${languageDir} is not writable. Please check permissions on this directory.");
} else {
if (is_null($this->options['extension'])) {
$this->err("Please provide an 'extension' for which the 'language' will be created", true);
} else {
// Check if the extension exists.
$extensionDir = dirname(__FILE__) . '/../../' . $this->options['extension'];
if (!is_dir($extensionDir)) {
$this->err("The extension '" . $this->options['extension'] . "' does not exist.", true);
} else if (!is_readable($extensionDir)) {
$this->err("The '" . $this->options['extension'] . "' directory is not readable. Please check permissions on this directory.", true);
} else if (!is_writable($extensionDir)) {
$this->err("The '" . $this->options['extension'] . "' directory is not writable. Please check permissions on this directory.", true);
} else {
// And can we read the messages.po file ?
if (!file_exists($languageDir . '/' . self::DEF_PO_FILENAME)) {
$this->err("Cannot find " . self::DEF_PO_FILENAME . " for extension '" . $this->options['extension'] . "' and language '" . $this->options['language'] . "'.", true);
} else if (!is_readable($languageDir . '/' . self::DEF_PO_FILENAME)) {
$this->err(self::DEF_PO_FILENAME . " is not readable for '" . $this->options['extension'] . "' and language '" . $this->options['language'] . "'. Please check permissions for this file." , true);
} else {
// The input 'parameter' is optional.
$this->checkInputOption();
// The 'output' parameter is optional.
$this->checkOutputOption();
}
}
}
}
}
} | [
"private",
"function",
"checkUpdateInput",
"(",
")",
"{",
"$",
"defaults",
"=",
"array",
"(",
"'language'",
"=>",
"null",
",",
"'extension'",
"=>",
"null",
",",
"'input'",
"=>",
"dirname",
"(",
"__FILE__",
")",
".",
"'/../../'",
".",
"$",
"this",
"->",
"... | Checks the inputs for the 'update' action.
@access private
@author Joel Bout, <joel.bout@tudor.lu>
@return void | [
"Checks",
"the",
"inputs",
"for",
"the",
"update",
"action",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoTranslate.php#L271-L325 |
oat-sa/tao-core | scripts/class.TaoTranslate.php | tao_scripts_TaoTranslate.checkUpdateAllInput | private function checkUpdateAllInput()
{
$defaults = array('input' => dirname(__FILE__) . '/../../' . $this->options['extension'] . '/' . self::DEF_INPUT_DIR,
'output' => dirname(__FILE__) . '/../../' . $this->options['extension'] . '/' . self::DEF_OUTPUT_DIR,
'extension' => null);
$this->options = array_merge($defaults, $this->options);
// The input 'parameter' is optional.
$this->checkInputOption();
// The 'output' parameter is optional.
$this->checkOutputOption();
} | php | private function checkUpdateAllInput()
{
$defaults = array('input' => dirname(__FILE__) . '/../../' . $this->options['extension'] . '/' . self::DEF_INPUT_DIR,
'output' => dirname(__FILE__) . '/../../' . $this->options['extension'] . '/' . self::DEF_OUTPUT_DIR,
'extension' => null);
$this->options = array_merge($defaults, $this->options);
// The input 'parameter' is optional.
$this->checkInputOption();
// The 'output' parameter is optional.
$this->checkOutputOption();
} | [
"private",
"function",
"checkUpdateAllInput",
"(",
")",
"{",
"$",
"defaults",
"=",
"array",
"(",
"'input'",
"=>",
"dirname",
"(",
"__FILE__",
")",
".",
"'/../../'",
".",
"$",
"this",
"->",
"options",
"[",
"'extension'",
"]",
".",
"'/'",
".",
"self",
"::"... | checks the input for the 'updateAll' action.
@access private
@author Joel Bout, <joel.bout@tudor.lu>
@return void | [
"checks",
"the",
"input",
"for",
"the",
"updateAll",
"action",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoTranslate.php#L334-L349 |
oat-sa/tao-core | scripts/class.TaoTranslate.php | tao_scripts_TaoTranslate.checkDeleteInput | private function checkDeleteInput()
{
$defaults = array('language' => null,
'input' => dirname(__FILE__) . '/../../' . $this->options['extension'] . '/' . self::DEF_INPUT_DIR,
'output' => dirname(__FILE__) . '/../../' . $this->options['extension'] . '/' . self::DEF_OUTPUT_DIR,
'extension' => null);
$this->options = array_merge($defaults, $this->options);
if (is_null($this->options['extension'])){
$this->err("Please provide an 'extension' identifier.", true);
}else{
if (is_null($this->options['language'])) {
$this->err("Please provide a 'language' identifier such as en-US, fr-CA, IT, ...", true);
} else {
$this->checkInputOption();
}
}
} | php | private function checkDeleteInput()
{
$defaults = array('language' => null,
'input' => dirname(__FILE__) . '/../../' . $this->options['extension'] . '/' . self::DEF_INPUT_DIR,
'output' => dirname(__FILE__) . '/../../' . $this->options['extension'] . '/' . self::DEF_OUTPUT_DIR,
'extension' => null);
$this->options = array_merge($defaults, $this->options);
if (is_null($this->options['extension'])){
$this->err("Please provide an 'extension' identifier.", true);
}else{
if (is_null($this->options['language'])) {
$this->err("Please provide a 'language' identifier such as en-US, fr-CA, IT, ...", true);
} else {
$this->checkInputOption();
}
}
} | [
"private",
"function",
"checkDeleteInput",
"(",
")",
"{",
"$",
"defaults",
"=",
"array",
"(",
"'language'",
"=>",
"null",
",",
"'input'",
"=>",
"dirname",
"(",
"__FILE__",
")",
".",
"'/../../'",
".",
"$",
"this",
"->",
"options",
"[",
"'extension'",
"]",
... | Checks the inputs for the 'delete' action.
@access private
@author Joel Bout, <joel.bout@tudor.lu>
@return void/ | [
"Checks",
"the",
"inputs",
"for",
"the",
"delete",
"action",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoTranslate.php#L358-L378 |
oat-sa/tao-core | scripts/class.TaoTranslate.php | tao_scripts_TaoTranslate.actionCreate | public function actionCreate()
{
$extensionsToCreate = explode(',', $this->options['extension']);
$extensionsToCreate = array_unique($extensionsToCreate);
foreach ($extensionsToCreate as $etc){
$this->options['extension'] = $etc;
$this->options['input'] = dirname(__FILE__) . '/../../' . $etc . '/' . self::DEF_INPUT_DIR;
$this->options['output'] = dirname(__FILE__) . '/../../' . $etc . '/' . self::DEF_OUTPUT_DIR;
$this->outVerbose("Creating language '" . $this->options['language'] . "' for extension '" . $this->options['extension'] . "' ...");
// We first create the directory where locale files will go.
$dir = $this->buildLanguagePath($this->options['extension'], $this->options['language']);
$dirExists = false;
if (file_exists($dir) && is_dir($dir) && $this->options['force'] == true) {
$dirExists = true;
$this->outVerbose("Language '" . $this->options['language'] . "' exists for extension '" . $this->options['extension'] . "'. Creation will be forced.");
// Clean it up.
foreach (scandir($dir) as $d) {
if ($d !== '.' && $d !== '..' && $d !== '.svn') {
if (!tao_helpers_File::remove($dir . '/' . $d, true)) {
$this->err("Unable to clean up 'language' directory '" . $dir . "'.", true);
}
}
}
} else if (file_exists($dir) && is_dir($dir) && $this->options['force'] == false) {
$this->err("The 'language' " . $this->options['language'] . " already exists in the file system. Use the 'force' parameter to overwrite it.", true);
}
// If we are still here... it means that we have to create the language directory.
if (!$dirExists && !@mkdir($dir)) {
$this->err("Unable to create 'language' directory '" . $this->options['language'] . "'.", true);
} else {
if ($this->options['build'] == true) {
$sortingMethod = tao_helpers_translation_TranslationFile::SORT_ASC_I;
$this->outVerbose("Building language '" . $this->options['language'] . "' for extension '" . $this->options['extension'] . "' ...");
// Let's populate the language with raw PO files containing sources but no targets.
// Source code extraction.
$fileExtensions = array('php', 'tpl', 'js', 'ejs');
$filePaths = array();
foreach (self::$WHITE_LIST as $subFolder) {
$filePaths[] = $this->options['input'] . DIRECTORY_SEPARATOR. $subFolder;
}
$sourceExtractor = new tao_helpers_translation_SourceCodeExtractor($filePaths, $fileExtensions);
$sourceExtractor->extract();
$translationFile = new tao_helpers_translation_POFile();
$translationFile->setSourceLanguage(tao_helpers_translation_Utils::getDefaultLanguage());
$translationFile->setTargetLanguage($this->options['language']);
$translationFile->addTranslationUnits($sourceExtractor->getTranslationUnits());
$file = MenuService::getStructuresFilePath($this->options['extension']);
if (!is_null($file)) {
$structureExtractor = new tao_helpers_translation_StructureExtractor(array($file));
$structureExtractor->extract();
$translationFile->addTranslationUnits($structureExtractor->getTranslationUnits());
}
$sortedTus = $translationFile->sortBySource($sortingMethod);
$sortedTranslationFile = new tao_helpers_translation_POFile();
$sortedTranslationFile->setSourceLanguage(tao_helpers_translation_Utils::getDefaultLanguage());
$sortedTranslationFile->setTargetLanguage($this->options['language']);
$sortedTranslationFile->addTranslationUnits($sortedTus);
$this->preparePOFile($sortedTranslationFile, true);
$poPath = $dir . '/' . self::DEF_PO_FILENAME;
$writer = new tao_helpers_translation_POFileWriter($poPath,
$sortedTranslationFile);
$writer->write();
$this->outVerbose("PO Translation file '" . basename($poPath) . "' in '" . $this->options['language'] . "' created for extension '" . $this->options['extension'] ."'.");
$writer->write();
// Writing JS files
$jsPath = $dir . '/' . self::DEF_JS_FILENAME;
$writer = new tao_helpers_translation_JSFileWriter(
$jsPath, $sortedTranslationFile
);
$writer->write(false);
$this->outVerbose("JavaScript Translation file '" . basename($jsPath) . "' in '" . $this->options['language'] . "' created for extension '" . $this->options['extension'] ."'.");
$writer->write();
// Now that PO files & JS files are created, we can create the translation models
// if we find RDF models to load for this extension.
$translatableProperties = array(OntologyRdfs::RDFS_LABEL, OntologyRdfs::RDFS_COMMENT);
foreach ($this->getOntologyFiles() as $f){
common_Logger::d('reading rdf '.$f);
$translationFile = $this->extractPoFileFromRDF($f, $translatableProperties);
$writer = new tao_helpers_translation_POFileWriter($dir . '/' . $this->getOntologyPOFileName($f), $translationFile);
$writer->write();
$this->outVerbose("PO Translation file '" . $this->getOntologyPOFileName($f) . "' in '" . $this->options['language'] . "' created for extension '" . $this->options['extension'] . "'.");
}
$this->outVerbose("Language '" . $this->options['language'] . "' created for extension '" . $this->options['extension'] . "'.");
} else {
// Only build virgin files.
// (Like a virgin... woot !)
$translationFile = new tao_helpers_translation_POFile();
$translationFile->setSourceLanguage(tao_helpers_translation_Utils::getDefaultLanguage());
$translationFile->setTargetLanguage($this->options['language']);
$this->preparePOFile($translationFile, true);
foreach ($this->getOntologyFiles() as $f){
common_Logger::d('reading rdf '.$f);
$translationFile = new tao_helpers_translation_POFile();
$translationFile->setSourceLanguage(tao_helpers_translation_Utils::getDefaultLanguage());
$translationFile->setTargetLanguage($this->options['language']);
$translationFile->setExtensionId($this->options['extension']);
$writer = new tao_helpers_translation_POFileWriter($dir . '/' . $this->getOntologyPOFileName($f), $translationFile);
$writer->write();
}
$this->outVerbose("Language '" . $this->options['language'] . "' created for extension '" . $this->options['extension'] . "'.");
}
// Create the language manifest in RDF.
if ($this->options['extension'] == 'tao'){
$langDescription = tao_helpers_translation_RDFUtils::createLanguageDescription($this->options['language'],
$this->options['languageLabel']);
$langDescription->save($dir . '/' . self::DEF_LANG_FILENAME);
}
}
}
} | php | public function actionCreate()
{
$extensionsToCreate = explode(',', $this->options['extension']);
$extensionsToCreate = array_unique($extensionsToCreate);
foreach ($extensionsToCreate as $etc){
$this->options['extension'] = $etc;
$this->options['input'] = dirname(__FILE__) . '/../../' . $etc . '/' . self::DEF_INPUT_DIR;
$this->options['output'] = dirname(__FILE__) . '/../../' . $etc . '/' . self::DEF_OUTPUT_DIR;
$this->outVerbose("Creating language '" . $this->options['language'] . "' for extension '" . $this->options['extension'] . "' ...");
// We first create the directory where locale files will go.
$dir = $this->buildLanguagePath($this->options['extension'], $this->options['language']);
$dirExists = false;
if (file_exists($dir) && is_dir($dir) && $this->options['force'] == true) {
$dirExists = true;
$this->outVerbose("Language '" . $this->options['language'] . "' exists for extension '" . $this->options['extension'] . "'. Creation will be forced.");
// Clean it up.
foreach (scandir($dir) as $d) {
if ($d !== '.' && $d !== '..' && $d !== '.svn') {
if (!tao_helpers_File::remove($dir . '/' . $d, true)) {
$this->err("Unable to clean up 'language' directory '" . $dir . "'.", true);
}
}
}
} else if (file_exists($dir) && is_dir($dir) && $this->options['force'] == false) {
$this->err("The 'language' " . $this->options['language'] . " already exists in the file system. Use the 'force' parameter to overwrite it.", true);
}
// If we are still here... it means that we have to create the language directory.
if (!$dirExists && !@mkdir($dir)) {
$this->err("Unable to create 'language' directory '" . $this->options['language'] . "'.", true);
} else {
if ($this->options['build'] == true) {
$sortingMethod = tao_helpers_translation_TranslationFile::SORT_ASC_I;
$this->outVerbose("Building language '" . $this->options['language'] . "' for extension '" . $this->options['extension'] . "' ...");
// Let's populate the language with raw PO files containing sources but no targets.
// Source code extraction.
$fileExtensions = array('php', 'tpl', 'js', 'ejs');
$filePaths = array();
foreach (self::$WHITE_LIST as $subFolder) {
$filePaths[] = $this->options['input'] . DIRECTORY_SEPARATOR. $subFolder;
}
$sourceExtractor = new tao_helpers_translation_SourceCodeExtractor($filePaths, $fileExtensions);
$sourceExtractor->extract();
$translationFile = new tao_helpers_translation_POFile();
$translationFile->setSourceLanguage(tao_helpers_translation_Utils::getDefaultLanguage());
$translationFile->setTargetLanguage($this->options['language']);
$translationFile->addTranslationUnits($sourceExtractor->getTranslationUnits());
$file = MenuService::getStructuresFilePath($this->options['extension']);
if (!is_null($file)) {
$structureExtractor = new tao_helpers_translation_StructureExtractor(array($file));
$structureExtractor->extract();
$translationFile->addTranslationUnits($structureExtractor->getTranslationUnits());
}
$sortedTus = $translationFile->sortBySource($sortingMethod);
$sortedTranslationFile = new tao_helpers_translation_POFile();
$sortedTranslationFile->setSourceLanguage(tao_helpers_translation_Utils::getDefaultLanguage());
$sortedTranslationFile->setTargetLanguage($this->options['language']);
$sortedTranslationFile->addTranslationUnits($sortedTus);
$this->preparePOFile($sortedTranslationFile, true);
$poPath = $dir . '/' . self::DEF_PO_FILENAME;
$writer = new tao_helpers_translation_POFileWriter($poPath,
$sortedTranslationFile);
$writer->write();
$this->outVerbose("PO Translation file '" . basename($poPath) . "' in '" . $this->options['language'] . "' created for extension '" . $this->options['extension'] ."'.");
$writer->write();
// Writing JS files
$jsPath = $dir . '/' . self::DEF_JS_FILENAME;
$writer = new tao_helpers_translation_JSFileWriter(
$jsPath, $sortedTranslationFile
);
$writer->write(false);
$this->outVerbose("JavaScript Translation file '" . basename($jsPath) . "' in '" . $this->options['language'] . "' created for extension '" . $this->options['extension'] ."'.");
$writer->write();
// Now that PO files & JS files are created, we can create the translation models
// if we find RDF models to load for this extension.
$translatableProperties = array(OntologyRdfs::RDFS_LABEL, OntologyRdfs::RDFS_COMMENT);
foreach ($this->getOntologyFiles() as $f){
common_Logger::d('reading rdf '.$f);
$translationFile = $this->extractPoFileFromRDF($f, $translatableProperties);
$writer = new tao_helpers_translation_POFileWriter($dir . '/' . $this->getOntologyPOFileName($f), $translationFile);
$writer->write();
$this->outVerbose("PO Translation file '" . $this->getOntologyPOFileName($f) . "' in '" . $this->options['language'] . "' created for extension '" . $this->options['extension'] . "'.");
}
$this->outVerbose("Language '" . $this->options['language'] . "' created for extension '" . $this->options['extension'] . "'.");
} else {
// Only build virgin files.
// (Like a virgin... woot !)
$translationFile = new tao_helpers_translation_POFile();
$translationFile->setSourceLanguage(tao_helpers_translation_Utils::getDefaultLanguage());
$translationFile->setTargetLanguage($this->options['language']);
$this->preparePOFile($translationFile, true);
foreach ($this->getOntologyFiles() as $f){
common_Logger::d('reading rdf '.$f);
$translationFile = new tao_helpers_translation_POFile();
$translationFile->setSourceLanguage(tao_helpers_translation_Utils::getDefaultLanguage());
$translationFile->setTargetLanguage($this->options['language']);
$translationFile->setExtensionId($this->options['extension']);
$writer = new tao_helpers_translation_POFileWriter($dir . '/' . $this->getOntologyPOFileName($f), $translationFile);
$writer->write();
}
$this->outVerbose("Language '" . $this->options['language'] . "' created for extension '" . $this->options['extension'] . "'.");
}
// Create the language manifest in RDF.
if ($this->options['extension'] == 'tao'){
$langDescription = tao_helpers_translation_RDFUtils::createLanguageDescription($this->options['language'],
$this->options['languageLabel']);
$langDescription->save($dir . '/' . self::DEF_LANG_FILENAME);
}
}
}
} | [
"public",
"function",
"actionCreate",
"(",
")",
"{",
"$",
"extensionsToCreate",
"=",
"explode",
"(",
"','",
",",
"$",
"this",
"->",
"options",
"[",
"'extension'",
"]",
")",
";",
"$",
"extensionsToCreate",
"=",
"array_unique",
"(",
"$",
"extensionsToCreate",
... | Implementation of the 'create' action.
@access public
@author Joel Bout, <joel.bout@tudor.lu>
@return void | [
"Implementation",
"of",
"the",
"create",
"action",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoTranslate.php#L439-L572 |
oat-sa/tao-core | scripts/class.TaoTranslate.php | tao_scripts_TaoTranslate.actionUpdate | public function actionUpdate()
{
$this->outVerbose("Updating language '" . $this->options['language'] . "' for extension '" . $this->options['extension'] . "'...");
$sortingMethod = tao_helpers_translation_TranslationFile::SORT_ASC_I;
// Get virgin translations from the source code and manifest.
$filePaths = array();
foreach (self::$WHITE_LIST as $subFolder) {
$filePaths[] = $this->options['input'] . DIRECTORY_SEPARATOR. $subFolder;
}
$extensions = array('php', 'tpl', 'js', 'ejs');
$sourceCodeExtractor = new tao_helpers_translation_SourceCodeExtractor($filePaths, $extensions);
$sourceCodeExtractor->extract();
$translationFile = new tao_helpers_translation_POFile();
$translationFile->setSourceLanguage(tao_helpers_translation_Utils::getDefaultLanguage());
$translationFile->setTargetLanguage($this->options['language']);
$translationFile->addTranslationUnits($sourceCodeExtractor->getTranslationUnits());
$file = MenuService::getStructuresFilePath($this->options['extension']);
if (!is_null($file)) {
$structureExtractor = new tao_helpers_translation_StructureExtractor(array($file));
$structureExtractor->extract();
$structureUnits = $structureExtractor->getTranslationUnits();
$this->outVerbose(count($structureUnits) . ' units extracted from structures.xml.');
$translationFile->addTranslationUnits($structureUnits);
}
// For each TU that was recovered, have a look in an older version
// of the translations.
$oldFilePath = $this->buildLanguagePath($this->options['extension'], $this->options['language']) . '/' .self::DEF_PO_FILENAME;
$translationFileReader = new tao_helpers_translation_POFileReader($oldFilePath);
$translationFileReader->read();
$oldTranslationFile = $translationFileReader->getTranslationFile();
foreach ($oldTranslationFile->getTranslationUnits() as $oldTu) {
if (($newTu = $translationFile->getBySource($oldTu)) !== null && $oldTu->getTarget() != '') {
// No duplicates in TFs so I simply add it whatever happens.
// If it already has the same one, it means we will update it.
$newTu->setTarget($oldTu->getTarget());
}
}
$sortedTranslationFile = new tao_helpers_translation_POFile();
$sortedTranslationFile->setSourceLanguage($translationFile->getSourceLanguage());
$sortedTranslationFile->setTargetLanguage($translationFile->getTargetLanguage());
$sortedTranslationFile->addTranslationUnits($translationFile->sortBySource($sortingMethod));
$this->preparePOFile($sortedTranslationFile, true);
// Write the new ones.
$poFileWriter = new tao_helpers_translation_POFileWriter($oldFilePath, $sortedTranslationFile);
$poFileWriter->write();
$this->outVerbose("PO translation file '" . basename($oldFilePath) . "' in '" . $this->options['language'] . "' updated for extension '" . $this->options['extension'] . "'.");
$translatableProperties = array(OntologyRdfs::RDFS_LABEL, OntologyRdfs::RDFS_COMMENT);
// We now deal with RDF models.
foreach ($this->getOntologyFiles() as $f){
// Loop on 'master' models.
$translationFile = $this->extractPoFileFromRDF($f, $translatableProperties);
// The slave RDF file is the translation of the ontology that we find in /extId/Locales/langCode.
$slavePOFilePath = $this->buildLanguagePath($this->options['extension'], $this->options['language']) . '/' . $this->getOntologyPOFileName($f);
if (file_exists($slavePOFilePath)){
// Read the existing RDF Translation file for this RDF model.
$poReader = new tao_helpers_translation_POFileReader($slavePOFilePath);
$poReader->read();
$slavePOFile = $poReader->getTranslationFile();
// Try to update translation units found in the master PO file with
// targets found in the old translation of the ontology.
foreach ($slavePOFile->getTranslationUnits() as $oTu){
$translationFile->addTranslationUnit($oTu);
}
// Remove Slave PO file. It will be overwritten by the modified Master PO file.
tao_helpers_File::remove($slavePOFilePath);
}
// Write Master PO file as the new Slave PO file.
$rdfWriter = new tao_helpers_translation_POFileWriter($slavePOFilePath, $translationFile);
$rdfWriter->write();
$this->outVerbose("Translation model {$this->getOntologyPOFileName($f)} in '" . $this->options['language'] . "' updated for extension '" . $this->options['extension'] . "'.");
}
$this->outVerbose("Language '" . $this->options['language'] . "' updated for extension '" . $this->options['extension'] . "'.");
} | php | public function actionUpdate()
{
$this->outVerbose("Updating language '" . $this->options['language'] . "' for extension '" . $this->options['extension'] . "'...");
$sortingMethod = tao_helpers_translation_TranslationFile::SORT_ASC_I;
// Get virgin translations from the source code and manifest.
$filePaths = array();
foreach (self::$WHITE_LIST as $subFolder) {
$filePaths[] = $this->options['input'] . DIRECTORY_SEPARATOR. $subFolder;
}
$extensions = array('php', 'tpl', 'js', 'ejs');
$sourceCodeExtractor = new tao_helpers_translation_SourceCodeExtractor($filePaths, $extensions);
$sourceCodeExtractor->extract();
$translationFile = new tao_helpers_translation_POFile();
$translationFile->setSourceLanguage(tao_helpers_translation_Utils::getDefaultLanguage());
$translationFile->setTargetLanguage($this->options['language']);
$translationFile->addTranslationUnits($sourceCodeExtractor->getTranslationUnits());
$file = MenuService::getStructuresFilePath($this->options['extension']);
if (!is_null($file)) {
$structureExtractor = new tao_helpers_translation_StructureExtractor(array($file));
$structureExtractor->extract();
$structureUnits = $structureExtractor->getTranslationUnits();
$this->outVerbose(count($structureUnits) . ' units extracted from structures.xml.');
$translationFile->addTranslationUnits($structureUnits);
}
// For each TU that was recovered, have a look in an older version
// of the translations.
$oldFilePath = $this->buildLanguagePath($this->options['extension'], $this->options['language']) . '/' .self::DEF_PO_FILENAME;
$translationFileReader = new tao_helpers_translation_POFileReader($oldFilePath);
$translationFileReader->read();
$oldTranslationFile = $translationFileReader->getTranslationFile();
foreach ($oldTranslationFile->getTranslationUnits() as $oldTu) {
if (($newTu = $translationFile->getBySource($oldTu)) !== null && $oldTu->getTarget() != '') {
// No duplicates in TFs so I simply add it whatever happens.
// If it already has the same one, it means we will update it.
$newTu->setTarget($oldTu->getTarget());
}
}
$sortedTranslationFile = new tao_helpers_translation_POFile();
$sortedTranslationFile->setSourceLanguage($translationFile->getSourceLanguage());
$sortedTranslationFile->setTargetLanguage($translationFile->getTargetLanguage());
$sortedTranslationFile->addTranslationUnits($translationFile->sortBySource($sortingMethod));
$this->preparePOFile($sortedTranslationFile, true);
// Write the new ones.
$poFileWriter = new tao_helpers_translation_POFileWriter($oldFilePath, $sortedTranslationFile);
$poFileWriter->write();
$this->outVerbose("PO translation file '" . basename($oldFilePath) . "' in '" . $this->options['language'] . "' updated for extension '" . $this->options['extension'] . "'.");
$translatableProperties = array(OntologyRdfs::RDFS_LABEL, OntologyRdfs::RDFS_COMMENT);
// We now deal with RDF models.
foreach ($this->getOntologyFiles() as $f){
// Loop on 'master' models.
$translationFile = $this->extractPoFileFromRDF($f, $translatableProperties);
// The slave RDF file is the translation of the ontology that we find in /extId/Locales/langCode.
$slavePOFilePath = $this->buildLanguagePath($this->options['extension'], $this->options['language']) . '/' . $this->getOntologyPOFileName($f);
if (file_exists($slavePOFilePath)){
// Read the existing RDF Translation file for this RDF model.
$poReader = new tao_helpers_translation_POFileReader($slavePOFilePath);
$poReader->read();
$slavePOFile = $poReader->getTranslationFile();
// Try to update translation units found in the master PO file with
// targets found in the old translation of the ontology.
foreach ($slavePOFile->getTranslationUnits() as $oTu){
$translationFile->addTranslationUnit($oTu);
}
// Remove Slave PO file. It will be overwritten by the modified Master PO file.
tao_helpers_File::remove($slavePOFilePath);
}
// Write Master PO file as the new Slave PO file.
$rdfWriter = new tao_helpers_translation_POFileWriter($slavePOFilePath, $translationFile);
$rdfWriter->write();
$this->outVerbose("Translation model {$this->getOntologyPOFileName($f)} in '" . $this->options['language'] . "' updated for extension '" . $this->options['extension'] . "'.");
}
$this->outVerbose("Language '" . $this->options['language'] . "' updated for extension '" . $this->options['extension'] . "'.");
} | [
"public",
"function",
"actionUpdate",
"(",
")",
"{",
"$",
"this",
"->",
"outVerbose",
"(",
"\"Updating language '\"",
".",
"$",
"this",
"->",
"options",
"[",
"'language'",
"]",
".",
"\"' for extension '\"",
".",
"$",
"this",
"->",
"options",
"[",
"'extension'"... | Implementation of the 'update' action.
@access public
@author Joel Bout, <joel.bout@tudor.lu>
@return void | [
"Implementation",
"of",
"the",
"update",
"action",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoTranslate.php#L581-L670 |
oat-sa/tao-core | scripts/class.TaoTranslate.php | tao_scripts_TaoTranslate.actionUpdateAll | public function actionUpdateAll()
{
// Scan the locales folder for languages in the wwextension and
// launch actionUpdate for each of them.
// Get the list of languages that will be updated.
$locales = $this->getLanguageList();
// We now identified locales to be updated.
$this->outVerbose("Languages '" . implode(',', $locales) . "' will be updated for extension '" . $this->options['extension'] . "'.");
foreach ($locales as $l) {
$this->options['language'] = $l;
$this->checkUpdateInput();
$this->actionUpdate();
$this->outVerbose("");
}
} | php | public function actionUpdateAll()
{
// Scan the locales folder for languages in the wwextension and
// launch actionUpdate for each of them.
// Get the list of languages that will be updated.
$locales = $this->getLanguageList();
// We now identified locales to be updated.
$this->outVerbose("Languages '" . implode(',', $locales) . "' will be updated for extension '" . $this->options['extension'] . "'.");
foreach ($locales as $l) {
$this->options['language'] = $l;
$this->checkUpdateInput();
$this->actionUpdate();
$this->outVerbose("");
}
} | [
"public",
"function",
"actionUpdateAll",
"(",
")",
"{",
"// Scan the locales folder for languages in the wwextension and",
"// launch actionUpdate for each of them.",
"// Get the list of languages that will be updated.",
"$",
"locales",
"=",
"$",
"this",
"->",
"getLanguageList",
"(",... | Implementation of the 'updateAll' action.
@access public
@author Joel Bout, <joel.bout@tudor.lu>
@return void | [
"Implementation",
"of",
"the",
"updateAll",
"action",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoTranslate.php#L679-L698 |
oat-sa/tao-core | scripts/class.TaoTranslate.php | tao_scripts_TaoTranslate.actionDelete | public function actionDelete()
{
$this->outVerbose("Deleting language '" . $this->options['language'] . "' for extension '" . $this->options['extension'] . "' ...");
$dir = $this->buildLanguagePath($this->options['extension'], $this->options['language']);
if (!tao_helpers_File::remove($dir, true)) {
$this->err("Could not delete language '" . $this->options['language'] . "' for extension '" . $this->options['extension'] . "'.", true);
}
$this->outVerbose("Language '" . $this->options['language'] . "' for extension '" . $this->options['extension'] . "' successfully deleted.");
} | php | public function actionDelete()
{
$this->outVerbose("Deleting language '" . $this->options['language'] . "' for extension '" . $this->options['extension'] . "' ...");
$dir = $this->buildLanguagePath($this->options['extension'], $this->options['language']);
if (!tao_helpers_File::remove($dir, true)) {
$this->err("Could not delete language '" . $this->options['language'] . "' for extension '" . $this->options['extension'] . "'.", true);
}
$this->outVerbose("Language '" . $this->options['language'] . "' for extension '" . $this->options['extension'] . "' successfully deleted.");
} | [
"public",
"function",
"actionDelete",
"(",
")",
"{",
"$",
"this",
"->",
"outVerbose",
"(",
"\"Deleting language '\"",
".",
"$",
"this",
"->",
"options",
"[",
"'language'",
"]",
".",
"\"' for extension '\"",
".",
"$",
"this",
"->",
"options",
"[",
"'extension'"... | Implementation of the 'delete' action.
@access public
@author Joel Bout, <joel.bout@tudor.lu>
@return void | [
"Implementation",
"of",
"the",
"delete",
"action",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoTranslate.php#L707-L719 |
oat-sa/tao-core | scripts/class.TaoTranslate.php | tao_scripts_TaoTranslate.actionDeleteAll | public function actionDeleteAll()
{
// Get the list of languages that will be deleted.
$this->outVerbose("Deleting all languages for extension '" . $this->options['extension'] . "'...");
$locales = $this->getLanguageList();
foreach ($locales as $l) {
$this->options['language'] = $l;
$this->checkDeleteInput();
$this->actionDelete();
$this->outVerbose("");
}
} | php | public function actionDeleteAll()
{
// Get the list of languages that will be deleted.
$this->outVerbose("Deleting all languages for extension '" . $this->options['extension'] . "'...");
$locales = $this->getLanguageList();
foreach ($locales as $l) {
$this->options['language'] = $l;
$this->checkDeleteInput();
$this->actionDelete();
$this->outVerbose("");
}
} | [
"public",
"function",
"actionDeleteAll",
"(",
")",
"{",
"// Get the list of languages that will be deleted.",
"$",
"this",
"->",
"outVerbose",
"(",
"\"Deleting all languages for extension '\"",
".",
"$",
"this",
"->",
"options",
"[",
"'extension'",
"]",
".",
"\"'...\"",
... | Implementation of the 'deleteAll' action.
@access public
@author Joel Bout, <joel.bout@tudor.lu>
@return void | [
"Implementation",
"of",
"the",
"deleteAll",
"action",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoTranslate.php#L728-L744 |
oat-sa/tao-core | scripts/class.TaoTranslate.php | tao_scripts_TaoTranslate.buildLanguagePath | private function buildLanguagePath($extension, $language)
{
$returnValue = (string) '';
$returnValue = dirname(__FILE__) . '/../../' . $extension . '/' . self::DEF_OUTPUT_DIR . '/' . $language;
return (string) $returnValue;
} | php | private function buildLanguagePath($extension, $language)
{
$returnValue = (string) '';
$returnValue = dirname(__FILE__) . '/../../' . $extension . '/' . self::DEF_OUTPUT_DIR . '/' . $language;
return (string) $returnValue;
} | [
"private",
"function",
"buildLanguagePath",
"(",
"$",
"extension",
",",
"$",
"language",
")",
"{",
"$",
"returnValue",
"=",
"(",
"string",
")",
"''",
";",
"$",
"returnValue",
"=",
"dirname",
"(",
"__FILE__",
")",
".",
"'/../../'",
".",
"$",
"extension",
... | Builds the path to files dedicated to a given language (locale) for a
extension ID.
@access private
@author Joel Bout, <joel.bout@tudor.lu>
@param string extension
@param string language
@return string | [
"Builds",
"the",
"path",
"to",
"files",
"dedicated",
"to",
"a",
"given",
"language",
"(",
"locale",
")",
"for",
"a",
"extension",
"ID",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoTranslate.php#L859-L868 |
oat-sa/tao-core | scripts/class.TaoTranslate.php | tao_scripts_TaoTranslate.findStructureManifest | public function findStructureManifest($directory = null)
{
$returnValue = null;
if ($directory == null) {
$actionsDir = $this->options['input'] . '/actions';
} else {
$actionsDir = $directory . '/actions';
}
$dirEntries = scandir($actionsDir);
if ($dirEntries === false) {
$returnValue = false;
} else {
$structureFile = null;
foreach ($dirEntries as $f) {
if (preg_match("/(.*)structure\.xml$/", $f)) {
$structureFile = $f;
break;
}
}
if ($structureFile === null) {
$returnValue = false;
} else {
$returnValue = $structureFile;
}
}
return $returnValue;
} | php | public function findStructureManifest($directory = null)
{
$returnValue = null;
if ($directory == null) {
$actionsDir = $this->options['input'] . '/actions';
} else {
$actionsDir = $directory . '/actions';
}
$dirEntries = scandir($actionsDir);
if ($dirEntries === false) {
$returnValue = false;
} else {
$structureFile = null;
foreach ($dirEntries as $f) {
if (preg_match("/(.*)structure\.xml$/", $f)) {
$structureFile = $f;
break;
}
}
if ($structureFile === null) {
$returnValue = false;
} else {
$returnValue = $structureFile;
}
}
return $returnValue;
} | [
"public",
"function",
"findStructureManifest",
"(",
"$",
"directory",
"=",
"null",
")",
"{",
"$",
"returnValue",
"=",
"null",
";",
"if",
"(",
"$",
"directory",
"==",
"null",
")",
"{",
"$",
"actionsDir",
"=",
"$",
"this",
"->",
"options",
"[",
"'input'",
... | Find a structure.xml manifest in a given directory.
@access public
@author Joel Bout, <joel.bout@tudor.lu>
@param string directory
@return mixed | [
"Find",
"a",
"structure",
".",
"xml",
"manifest",
"in",
"a",
"given",
"directory",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoTranslate.php#L878-L911 |
oat-sa/tao-core | scripts/class.TaoTranslate.php | tao_scripts_TaoTranslate.preparePOFile | public function preparePOFile( tao_helpers_translation_POFile $poFile, $poEditorReady = false)
{
$poFile->addHeader('Project-Id-Version', PRODUCT_NAME . ' ' . ApplicationHelper::getVersionName());
$poFile->addHeader('PO-Revision-Date', date('Y-m-d') . 'T' . date('H:i:s'));
$poFile->addHeader('Last-Translator', 'TAO Translation Team <translation@tao.lu>');
$poFile->addHeader('MIME-Version', '1.0');
$poFile->addHeader('Language', $poFile->getTargetLanguage());
$poFile->addHeader('sourceLanguage', $poFile->getSourceLanguage());
$poFile->addHeader('targetLanguage', $poFile->getTargetLanguage());
$poFile->addHeader('Content-Type', 'text/plain; charset=utf-8');
$poFile->addHeader('Content-Transfer-Encoding', '8bit');
if ($poEditorReady) {
$poFile->addHeader('X-Poedit-Basepath', '../../');
$poFile->addHeader('X-Poedit-KeywordsList', '__');
$poFile->addHeader('X-Poedit-SearchPath-0', '.');
}
} | php | public function preparePOFile( tao_helpers_translation_POFile $poFile, $poEditorReady = false)
{
$poFile->addHeader('Project-Id-Version', PRODUCT_NAME . ' ' . ApplicationHelper::getVersionName());
$poFile->addHeader('PO-Revision-Date', date('Y-m-d') . 'T' . date('H:i:s'));
$poFile->addHeader('Last-Translator', 'TAO Translation Team <translation@tao.lu>');
$poFile->addHeader('MIME-Version', '1.0');
$poFile->addHeader('Language', $poFile->getTargetLanguage());
$poFile->addHeader('sourceLanguage', $poFile->getSourceLanguage());
$poFile->addHeader('targetLanguage', $poFile->getTargetLanguage());
$poFile->addHeader('Content-Type', 'text/plain; charset=utf-8');
$poFile->addHeader('Content-Transfer-Encoding', '8bit');
if ($poEditorReady) {
$poFile->addHeader('X-Poedit-Basepath', '../../');
$poFile->addHeader('X-Poedit-KeywordsList', '__');
$poFile->addHeader('X-Poedit-SearchPath-0', '.');
}
} | [
"public",
"function",
"preparePOFile",
"(",
"tao_helpers_translation_POFile",
"$",
"poFile",
",",
"$",
"poEditorReady",
"=",
"false",
")",
"{",
"$",
"poFile",
"->",
"addHeader",
"(",
"'Project-Id-Version'",
",",
"PRODUCT_NAME",
".",
"' '",
".",
"ApplicationHelper",
... | Prepare a PO file before output by adding headers to it.
@access public
@author Joel Bout, <joel.bout@tudor.lu>
@param tao_helpers_translation_POFile $poFile
@param bool $poEditorReady
@return void | [
"Prepare",
"a",
"PO",
"file",
"before",
"output",
"by",
"adding",
"headers",
"to",
"it",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoTranslate.php#L922-L940 |
oat-sa/tao-core | scripts/class.TaoTranslate.php | tao_scripts_TaoTranslate.isExtension | public function isExtension($directory)
{
$returnValue = (bool) false;
$hasStructure = $this->findStructureManifest($directory) !== false;
$hasPHPManifest = false;
$files = scandir($this->options['input']);
if ($files !== false) {
foreach ($files as $f) {
if (is_file($this->options['input'] . '/' .$f) && is_readable($this->options['input'] . '/' . $f)) {
if ($f == 'manifest.php') {
$hasPHPManifest = true;
}
}
}
}
$returnValue = $hasStructure || $hasPHPManifest;
return (bool) $returnValue;
} | php | public function isExtension($directory)
{
$returnValue = (bool) false;
$hasStructure = $this->findStructureManifest($directory) !== false;
$hasPHPManifest = false;
$files = scandir($this->options['input']);
if ($files !== false) {
foreach ($files as $f) {
if (is_file($this->options['input'] . '/' .$f) && is_readable($this->options['input'] . '/' . $f)) {
if ($f == 'manifest.php') {
$hasPHPManifest = true;
}
}
}
}
$returnValue = $hasStructure || $hasPHPManifest;
return (bool) $returnValue;
} | [
"public",
"function",
"isExtension",
"(",
"$",
"directory",
")",
"{",
"$",
"returnValue",
"=",
"(",
"bool",
")",
"false",
";",
"$",
"hasStructure",
"=",
"$",
"this",
"->",
"findStructureManifest",
"(",
"$",
"directory",
")",
"!==",
"false",
";",
"$",
"ha... | Determines if an given directory actually contains a TAO extension.
@access public
@author Joel Bout, <joel.bout@tudor.lu>
@param string directory
@return boolean | [
"Determines",
"if",
"an",
"given",
"directory",
"actually",
"contains",
"a",
"TAO",
"extension",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoTranslate.php#L950-L973 |
oat-sa/tao-core | scripts/class.TaoTranslate.php | tao_scripts_TaoTranslate.addManifestsTranslations | public function addManifestsTranslations( tao_helpers_translation_POFile $poFile)
{
$this->outVerbose("Adding all manifests messages to extension '" . $this->options['extension'] . "'");
$rootDir = dirname(__FILE__) . '/../../';
$directories = scandir($rootDir);
$exceptions = array('generis', 'tao', '.*');
if (false === $directories) {
$this->err("The TAO root directory is not readable. Please check permissions on this directory.", true);
} else {
foreach ($directories as $dir) {
if (is_dir($rootDir . $dir) && !in_array($dir, $exceptions)) {
// Maybe it should be read.
if (in_array('.*', $exceptions) && $dir[0] == '.') {
continue;
} else {
// Is this a TAO extension ?
$file = MenuService::getStructuresFilePath($this->options['extension']);
if (!is_null($file)) {
$structureExtractor = new tao_helpers_translation_StructureExtractor(array($file));
$structureExtractor->extract();
$poFile->addTranslationUnits($structureExtractor->getTranslationUnits());
$this->outVerbose("Manifest of extension '" . $dir . "' added to extension '" . $this->options['extension'] . "'");
}
}
}
}
}
} | php | public function addManifestsTranslations( tao_helpers_translation_POFile $poFile)
{
$this->outVerbose("Adding all manifests messages to extension '" . $this->options['extension'] . "'");
$rootDir = dirname(__FILE__) . '/../../';
$directories = scandir($rootDir);
$exceptions = array('generis', 'tao', '.*');
if (false === $directories) {
$this->err("The TAO root directory is not readable. Please check permissions on this directory.", true);
} else {
foreach ($directories as $dir) {
if (is_dir($rootDir . $dir) && !in_array($dir, $exceptions)) {
// Maybe it should be read.
if (in_array('.*', $exceptions) && $dir[0] == '.') {
continue;
} else {
// Is this a TAO extension ?
$file = MenuService::getStructuresFilePath($this->options['extension']);
if (!is_null($file)) {
$structureExtractor = new tao_helpers_translation_StructureExtractor(array($file));
$structureExtractor->extract();
$poFile->addTranslationUnits($structureExtractor->getTranslationUnits());
$this->outVerbose("Manifest of extension '" . $dir . "' added to extension '" . $this->options['extension'] . "'");
}
}
}
}
}
} | [
"public",
"function",
"addManifestsTranslations",
"(",
"tao_helpers_translation_POFile",
"$",
"poFile",
")",
"{",
"$",
"this",
"->",
"outVerbose",
"(",
"\"Adding all manifests messages to extension '\"",
".",
"$",
"this",
"->",
"options",
"[",
"'extension'",
"]",
".",
... | Add translations as translation units found in a structure.xml manifest
a given PO file.
@access public
@author Joel Bout, <joel.bout@tudor.lu>
@param tao_helpers_translation_POFile $poFile
@throws Exception
@return void | [
"Add",
"translations",
"as",
"translation",
"units",
"found",
"in",
"a",
"structure",
".",
"xml",
"manifest",
"a",
"given",
"PO",
"file",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoTranslate.php#L985-L1016 |
oat-sa/tao-core | scripts/class.TaoTranslate.php | tao_scripts_TaoTranslate.addLanguageToOntology | protected function addLanguageToOntology()
{
$this->outVerbose("Importing RDF language description '" . $this->options['language'] . "' to ontology...");
// RDF Language Descriptions are stored in the tao meta-extension locales.
$expectedDescriptionPath = $this->buildLanguagePath('tao', $this->options['language']) . '/lang.rdf';
if (file_exists($expectedDescriptionPath)){
if (is_readable($expectedDescriptionPath)){
// Let's remove any instance of the language description before inserting the new one.
$taoNS = 'http://www.tao.lu/Ontologies/TAO.rdf#';
$expectedLangUri = $taoNS . 'Lang' . $this->options['language'];
$lgDescription = new core_kernel_classes_Resource($expectedLangUri);
if ($lgDescription->exists()){
$lgDescription->delete();
$this->outVerbose("Existing RDF Description language '" . $this->options['language'] . "' deleted.");
}
$generisAdapterRdf = new tao_helpers_data_GenerisAdapterRdf();
if (true === $generisAdapterRdf->import($expectedDescriptionPath, null, LOCAL_NAMESPACE)){
$this->outVerbose("RDF language description '" . $this->options['language'] . "' successfully imported.");
}else{
$this->err("An error occured while importing the RDF language description '" . $this->options['language'] . "'.", true);
}
}else{
$this->err("RDF language description (lang.rdf) cannot be read in meta-extension 'tao' for language '" . $this->options['language'] . "'.", true);
}
}else{
$this->err("RDF language description (lang.rdf) not found in meta-extension 'tao' for language '" . $this->options['language'] . "'.", true);
}
$this->outVerbose("RDF language description '" . $this->options['language'] . "' added to ontology.");
} | php | protected function addLanguageToOntology()
{
$this->outVerbose("Importing RDF language description '" . $this->options['language'] . "' to ontology...");
// RDF Language Descriptions are stored in the tao meta-extension locales.
$expectedDescriptionPath = $this->buildLanguagePath('tao', $this->options['language']) . '/lang.rdf';
if (file_exists($expectedDescriptionPath)){
if (is_readable($expectedDescriptionPath)){
// Let's remove any instance of the language description before inserting the new one.
$taoNS = 'http://www.tao.lu/Ontologies/TAO.rdf#';
$expectedLangUri = $taoNS . 'Lang' . $this->options['language'];
$lgDescription = new core_kernel_classes_Resource($expectedLangUri);
if ($lgDescription->exists()){
$lgDescription->delete();
$this->outVerbose("Existing RDF Description language '" . $this->options['language'] . "' deleted.");
}
$generisAdapterRdf = new tao_helpers_data_GenerisAdapterRdf();
if (true === $generisAdapterRdf->import($expectedDescriptionPath, null, LOCAL_NAMESPACE)){
$this->outVerbose("RDF language description '" . $this->options['language'] . "' successfully imported.");
}else{
$this->err("An error occured while importing the RDF language description '" . $this->options['language'] . "'.", true);
}
}else{
$this->err("RDF language description (lang.rdf) cannot be read in meta-extension 'tao' for language '" . $this->options['language'] . "'.", true);
}
}else{
$this->err("RDF language description (lang.rdf) not found in meta-extension 'tao' for language '" . $this->options['language'] . "'.", true);
}
$this->outVerbose("RDF language description '" . $this->options['language'] . "' added to ontology.");
} | [
"protected",
"function",
"addLanguageToOntology",
"(",
")",
"{",
"$",
"this",
"->",
"outVerbose",
"(",
"\"Importing RDF language description '\"",
".",
"$",
"this",
"->",
"options",
"[",
"'language'",
"]",
".",
"\"' to ontology...\"",
")",
";",
"// RDF Language Descri... | Add the requested language in the ontology. It will used the parameters
the command line for logic.
@access protected
@author Joel Bout, <joel.bout@tudor.lu>
@return void | [
"Add",
"the",
"requested",
"language",
"in",
"the",
"ontology",
".",
"It",
"will",
"used",
"the",
"parameters",
"the",
"command",
"line",
"for",
"logic",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoTranslate.php#L1026-L1064 |
oat-sa/tao-core | scripts/class.TaoTranslate.php | tao_scripts_TaoTranslate.removeLanguageFromOntology | protected function removeLanguageFromOntology()
{
$this->outVerbose("Removing RDF language description '" . $this->options['language'] . "' from ontology...");
$taoNS = 'http://www.tao.lu/Ontologies/TAO.rdf#';
$expectedDescriptionUri = $taoNS . 'Lang' . $this->options['language'];
$lgResource = new core_kernel_classes_Resource($expectedDescriptionUri);
if (true === $lgResource->exists()) {
$lgResource->delete();
$this->outVerbose("RDF language description '" . $this->options['language'] . "' successfully removed.");
}else{
$this->outVerbose("RDF language description '" . $this->options['language'] . "' not found but considered removed.");
}
} | php | protected function removeLanguageFromOntology()
{
$this->outVerbose("Removing RDF language description '" . $this->options['language'] . "' from ontology...");
$taoNS = 'http://www.tao.lu/Ontologies/TAO.rdf#';
$expectedDescriptionUri = $taoNS . 'Lang' . $this->options['language'];
$lgResource = new core_kernel_classes_Resource($expectedDescriptionUri);
if (true === $lgResource->exists()) {
$lgResource->delete();
$this->outVerbose("RDF language description '" . $this->options['language'] . "' successfully removed.");
}else{
$this->outVerbose("RDF language description '" . $this->options['language'] . "' not found but considered removed.");
}
} | [
"protected",
"function",
"removeLanguageFromOntology",
"(",
")",
"{",
"$",
"this",
"->",
"outVerbose",
"(",
"\"Removing RDF language description '\"",
".",
"$",
"this",
"->",
"options",
"[",
"'language'",
"]",
".",
"\"' from ontology...\"",
")",
";",
"$",
"taoNS",
... | Removes a language from the Ontology and all triples with the related
tag. Will use command line parameters for logic.
@access protected
@author Joel Bout, <joel.bout@tudor.lu>
@return void | [
"Removes",
"a",
"language",
"from",
"the",
"Ontology",
"and",
"all",
"triples",
"with",
"the",
"related",
"tag",
".",
"Will",
"use",
"command",
"line",
"parameters",
"for",
"logic",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoTranslate.php#L1074-L1089 |
oat-sa/tao-core | scripts/class.TaoTranslate.php | tao_scripts_TaoTranslate.checkAuthInput | protected function checkAuthInput()
{
$defaults = array('user' => null,
'password' => null);
$this->options = array_merge($defaults, $this->options);
if ($this->options['user'] == null) {
$this->err("Please provide a value for the 'user' parameter.", true);
}
else if ($this->options['password'] == null) {
$this->err("Please provide a value for the 'password' parameter.", true);
}
} | php | protected function checkAuthInput()
{
$defaults = array('user' => null,
'password' => null);
$this->options = array_merge($defaults, $this->options);
if ($this->options['user'] == null) {
$this->err("Please provide a value for the 'user' parameter.", true);
}
else if ($this->options['password'] == null) {
$this->err("Please provide a value for the 'password' parameter.", true);
}
} | [
"protected",
"function",
"checkAuthInput",
"(",
")",
"{",
"$",
"defaults",
"=",
"array",
"(",
"'user'",
"=>",
"null",
",",
"'password'",
"=>",
"null",
")",
";",
"$",
"this",
"->",
"options",
"=",
"array_merge",
"(",
"$",
"defaults",
",",
"$",
"this",
"... | Checks authentication parameters for the TAO API.
@access protected
@author Joel Bout, <joel.bout@tudor.lu>
@return void | [
"Checks",
"authentication",
"parameters",
"for",
"the",
"TAO",
"API",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoTranslate.php#L1098-L1113 |
oat-sa/tao-core | scripts/class.TaoTranslate.php | tao_scripts_TaoTranslate.getOntologyFiles | private function getOntologyFiles()
{
$returnValue = array();
$ext = common_ext_ExtensionsManager::singleton()->getExtensionById($this->options['extension']);
$returnValue = $ext->getManifest()->getInstallModelFiles();
return (array) $returnValue;
} | php | private function getOntologyFiles()
{
$returnValue = array();
$ext = common_ext_ExtensionsManager::singleton()->getExtensionById($this->options['extension']);
$returnValue = $ext->getManifest()->getInstallModelFiles();
return (array) $returnValue;
} | [
"private",
"function",
"getOntologyFiles",
"(",
")",
"{",
"$",
"returnValue",
"=",
"array",
"(",
")",
";",
"$",
"ext",
"=",
"common_ext_ExtensionsManager",
"::",
"singleton",
"(",
")",
"->",
"getExtensionById",
"(",
"$",
"this",
"->",
"options",
"[",
"'exten... | Get the ontology file paths for a given extension, sorted by target name
@access private
@author Joel Bout, <joel.bout@tudor.lu>
@return array | [
"Get",
"the",
"ontology",
"file",
"paths",
"for",
"a",
"given",
"extension",
"sorted",
"by",
"target",
"name"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoTranslate.php#L1122-L1132 |
oat-sa/tao-core | scripts/class.TaoTranslate.php | tao_scripts_TaoTranslate.checkDisableInput | private function checkDisableInput()
{
$this->checkAuthInput();
$defaults = array('language' => null);
$this->options = array_merge($defaults, $this->options);
if ($this->options['language'] == null){
$this->err("Please provide the 'language' parameter.", true);
}
} | php | private function checkDisableInput()
{
$this->checkAuthInput();
$defaults = array('language' => null);
$this->options = array_merge($defaults, $this->options);
if ($this->options['language'] == null){
$this->err("Please provide the 'language' parameter.", true);
}
} | [
"private",
"function",
"checkDisableInput",
"(",
")",
"{",
"$",
"this",
"->",
"checkAuthInput",
"(",
")",
";",
"$",
"defaults",
"=",
"array",
"(",
"'language'",
"=>",
"null",
")",
";",
"$",
"this",
"->",
"options",
"=",
"array_merge",
"(",
"$",
"defaults... | Short description of method checkDisableInput
@access private
@author Joel Bout, <joel.bout@tudor.lu>
@return void | [
"Short",
"description",
"of",
"method",
"checkDisableInput"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoTranslate.php#L1164-L1174 |
oat-sa/tao-core | scripts/class.TaoTranslate.php | tao_scripts_TaoTranslate.actionEnable | public function actionEnable()
{
$userService = tao_models_classes_UserService::singleton();
$this->outVerbose("Connecting to TAO as '" . $this->options['user'] . "' ...");
if ($userService->loginUser($this->options['user'], $this->options['password'])){
$this->outVerbose("Connected to TAO as '" . $this->options['user'] . "'.");
$this->addLanguageToOntology();
$userService->logout();
$this->outVerbose("Disconnected from TAO.");
}else{
$this->err("Unable to connect to TAO as '" . $this->options['user'] . "'. Please check user name and password.", true);
}
} | php | public function actionEnable()
{
$userService = tao_models_classes_UserService::singleton();
$this->outVerbose("Connecting to TAO as '" . $this->options['user'] . "' ...");
if ($userService->loginUser($this->options['user'], $this->options['password'])){
$this->outVerbose("Connected to TAO as '" . $this->options['user'] . "'.");
$this->addLanguageToOntology();
$userService->logout();
$this->outVerbose("Disconnected from TAO.");
}else{
$this->err("Unable to connect to TAO as '" . $this->options['user'] . "'. Please check user name and password.", true);
}
} | [
"public",
"function",
"actionEnable",
"(",
")",
"{",
"$",
"userService",
"=",
"tao_models_classes_UserService",
"::",
"singleton",
"(",
")",
";",
"$",
"this",
"->",
"outVerbose",
"(",
"\"Connecting to TAO as '\"",
".",
"$",
"this",
"->",
"options",
"[",
"'user'"... | Short description of method actionEnable
@access public
@author Joel Bout, <joel.bout@tudor.lu>
@return void | [
"Short",
"description",
"of",
"method",
"actionEnable"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoTranslate.php#L1183-L1197 |
oat-sa/tao-core | scripts/class.TaoTranslate.php | tao_scripts_TaoTranslate.actionDisable | public function actionDisable()
{
$userService = tao_models_classes_UserService::singleton();
$this->outVerbose("Connecting to TAO as '" . $this->options['user'] . "' ...");
if ($userService->loginUser($this->options['user'], $this->options['password'])){
$this->outVerbose("Connected to TAO as '" . $this->options['user'] . "'.");
$this->removeLanguageFromOntology();
$userService->logout();
$this->outVerbose("Disconnected from TAO.");
}else{
$this->err("Unable to connect to TAO as '" . $this->options['user'] . "'. Please check user name and password.", true);
}
} | php | public function actionDisable()
{
$userService = tao_models_classes_UserService::singleton();
$this->outVerbose("Connecting to TAO as '" . $this->options['user'] . "' ...");
if ($userService->loginUser($this->options['user'], $this->options['password'])){
$this->outVerbose("Connected to TAO as '" . $this->options['user'] . "'.");
$this->removeLanguageFromOntology();
$userService->logout();
$this->outVerbose("Disconnected from TAO.");
}else{
$this->err("Unable to connect to TAO as '" . $this->options['user'] . "'. Please check user name and password.", true);
}
} | [
"public",
"function",
"actionDisable",
"(",
")",
"{",
"$",
"userService",
"=",
"tao_models_classes_UserService",
"::",
"singleton",
"(",
")",
";",
"$",
"this",
"->",
"outVerbose",
"(",
"\"Connecting to TAO as '\"",
".",
"$",
"this",
"->",
"options",
"[",
"'user'... | Implementation of the 'disable' action. When this action is called, a
Language Description ('language' param) is removed from the Knowledge
The language is at this time not available anymore to end-users. However,
Triples that had a corresponding language tag are not remove from the
If the language is enabled again via the 'enable' action of this script,
having corresponding languages will be reachable again.
@access public
@author Joel Bout, <joel.bout@tudor.lu>
@return void | [
"Implementation",
"of",
"the",
"disable",
"action",
".",
"When",
"this",
"action",
"is",
"called",
"a",
"Language",
"Description",
"(",
"language",
"param",
")",
"is",
"removed",
"from",
"the",
"Knowledge",
"The",
"language",
"is",
"at",
"this",
"time",
"not... | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoTranslate.php#L1211-L1225 |
oat-sa/tao-core | scripts/class.TaoTranslate.php | tao_scripts_TaoTranslate.actionCompile | public function actionCompile()
{
$extensionsToCreate = explode(',', $this->options['extension']);
$extensionsToCreate = array_unique($extensionsToCreate);
foreach ($extensionsToCreate as $extension){
$language = $this->options['language'];
$compiledTranslationFile = new tao_helpers_translation_TranslationFile();
$compiledTranslationFile->setTargetLanguage($this->options['language']);
$this->outVerbose("Compiling language '${language}' for extension '${extension}'...");
// Get the dependencies of the target extension.
// @todo Deal with dependencies at compilation time.
$dependencies = array();
if ($extension !== 'tao'){
$dependencies[] = 'tao';
}
$this->outVerbose("Resolving Dependencies...");
foreach ($dependencies as $depExtId){
$this->outVerbose("Adding messages from extension '${depExtId}' in '${language}'...");
// Does the locale exist for $depExtId?
$depPath = $this->buildLanguagePath($depExtId, $language) . '/' . self::DEF_PO_FILENAME;
if (!file_exists($depPath) || !is_readable($depPath)){
$this->outVerbose("Dependency on extension '${depExtId}' in '${language}' does not exist. Trying to resolve default language...");
$depPath = $this->buildLanguagePath($depExtId, tao_helpers_translation_Utils::getDefaultLanguage() . '/' . self::DEF_PO_FILENAME);
if (!file_exists($depPath) || !is_readable($depPath)){
$this->outVerbose("Dependency on extension '${depExtId}' in '${language}' does not exist.");
continue;
}
}
// Recompile the dependent extension (for the moment 'tao' meta-extension only).
$oldVerbose = $this->options['verbose'];
$this->parameters['verbose'] = false;
$this->options['extension'] = $depExtId;
$this->actionCompile();
$this->options['extension'] = $extension;
$this->parameters['verbose'] = $oldVerbose;
$poFileReader = new tao_helpers_translation_POFileReader($depPath);
$poFileReader->read();
$poFile = $poFileReader->getTranslationFile();
$poCount = $poFile->count();
$compiledTranslationFile->addTranslationUnits($poFile->getTranslationUnits());
$this->outVerbose("${poCount} messages added.");
}
if (($extDirectories = scandir(ROOT_PATH)) !== false){
// Get all public messages accross extensions.
foreach ($extDirectories as $extDir){
$extPath = ROOT_PATH . '/' . $extDir;
if (is_dir($extPath) && is_readable($extPath) && $extDir[0] != '.' && !in_array($extDir, $dependencies) && $extDir != $extension && $extDir != 'generis'){
$this->outVerbose("Adding public messages from extension '${extDir}' in '${language}'...");
$poPath = $this->buildLanguagePath($extDir, $language) . '/' . self::DEF_PO_FILENAME;
if (!file_exists($poPath) || !is_readable($poPath)){
$this->outVerbose("Extension '${extDir}' is not translated in language '${language}'. Trying to retrieve default language...");
$poPath = $this->buildLanguagePath($extDir, tao_helpers_translation_Utils::getDefaultLanguage()) . '/' . self::DEF_PO_FILENAME;
if (!file_exists($poPath) || !is_readable($poPath)){
$this->outVerbose("Extension '${extDir}' in '${language}' does not exist.");
continue;
}
}
$poFileReader = new tao_helpers_translation_POFileReader($poPath);
$poFileReader->read();
$poFile = $poFileReader->getTranslationFile();
$poUnits = $poFile->getByFlag('tao-public');
$poCount = count($poUnits);
$compiledTranslationFile->addTranslationUnits($poUnits);
$this->outVerbose("${poCount} public messages added.");
}
}
// Finally, add the translation units related to the target extension.
$path = $this->buildLanguagePath($extension, $language) . '/' . self::DEF_PO_FILENAME;
if (file_exists($path) && is_readable($path)){
$poFileReader = new tao_helpers_translation_POFileReader($path);
$poFileReader->read();
$poFile = $poFileReader->getTranslationFile();
$compiledTranslationFile->addTranslationUnits($poFile->getTranslationUnits());
// Sort the TranslationUnits.
$sortingMethod = tao_helpers_translation_TranslationFile::SORT_ASC_I;
$compiledTranslationFile->setTranslationUnits($compiledTranslationFile->sortBySource($sortingMethod));
$jsPath = $this->buildLanguagePath($extension, $language) . '/' . self::DEF_JS_FILENAME;
$jsFileWriter = new tao_helpers_translation_JSFileWriter($jsPath, $compiledTranslationFile);
$jsFileWriter->write();
$this->outVerbose("JavaScript compiled translations for extension '${extension}' with '${language}' written.");
}
else{
$this->err("PO file '${path}' for extension '${extension}' with language '${language}' cannot be read.", true);
}
}
else{
$this->err("Cannot list TAO Extensions from root path. Check your system rights.", true);
}
$this->outVerbose("Translations for '${extension}' with language '${language}' gracefully compiled.");
}
} | php | public function actionCompile()
{
$extensionsToCreate = explode(',', $this->options['extension']);
$extensionsToCreate = array_unique($extensionsToCreate);
foreach ($extensionsToCreate as $extension){
$language = $this->options['language'];
$compiledTranslationFile = new tao_helpers_translation_TranslationFile();
$compiledTranslationFile->setTargetLanguage($this->options['language']);
$this->outVerbose("Compiling language '${language}' for extension '${extension}'...");
// Get the dependencies of the target extension.
// @todo Deal with dependencies at compilation time.
$dependencies = array();
if ($extension !== 'tao'){
$dependencies[] = 'tao';
}
$this->outVerbose("Resolving Dependencies...");
foreach ($dependencies as $depExtId){
$this->outVerbose("Adding messages from extension '${depExtId}' in '${language}'...");
// Does the locale exist for $depExtId?
$depPath = $this->buildLanguagePath($depExtId, $language) . '/' . self::DEF_PO_FILENAME;
if (!file_exists($depPath) || !is_readable($depPath)){
$this->outVerbose("Dependency on extension '${depExtId}' in '${language}' does not exist. Trying to resolve default language...");
$depPath = $this->buildLanguagePath($depExtId, tao_helpers_translation_Utils::getDefaultLanguage() . '/' . self::DEF_PO_FILENAME);
if (!file_exists($depPath) || !is_readable($depPath)){
$this->outVerbose("Dependency on extension '${depExtId}' in '${language}' does not exist.");
continue;
}
}
// Recompile the dependent extension (for the moment 'tao' meta-extension only).
$oldVerbose = $this->options['verbose'];
$this->parameters['verbose'] = false;
$this->options['extension'] = $depExtId;
$this->actionCompile();
$this->options['extension'] = $extension;
$this->parameters['verbose'] = $oldVerbose;
$poFileReader = new tao_helpers_translation_POFileReader($depPath);
$poFileReader->read();
$poFile = $poFileReader->getTranslationFile();
$poCount = $poFile->count();
$compiledTranslationFile->addTranslationUnits($poFile->getTranslationUnits());
$this->outVerbose("${poCount} messages added.");
}
if (($extDirectories = scandir(ROOT_PATH)) !== false){
// Get all public messages accross extensions.
foreach ($extDirectories as $extDir){
$extPath = ROOT_PATH . '/' . $extDir;
if (is_dir($extPath) && is_readable($extPath) && $extDir[0] != '.' && !in_array($extDir, $dependencies) && $extDir != $extension && $extDir != 'generis'){
$this->outVerbose("Adding public messages from extension '${extDir}' in '${language}'...");
$poPath = $this->buildLanguagePath($extDir, $language) . '/' . self::DEF_PO_FILENAME;
if (!file_exists($poPath) || !is_readable($poPath)){
$this->outVerbose("Extension '${extDir}' is not translated in language '${language}'. Trying to retrieve default language...");
$poPath = $this->buildLanguagePath($extDir, tao_helpers_translation_Utils::getDefaultLanguage()) . '/' . self::DEF_PO_FILENAME;
if (!file_exists($poPath) || !is_readable($poPath)){
$this->outVerbose("Extension '${extDir}' in '${language}' does not exist.");
continue;
}
}
$poFileReader = new tao_helpers_translation_POFileReader($poPath);
$poFileReader->read();
$poFile = $poFileReader->getTranslationFile();
$poUnits = $poFile->getByFlag('tao-public');
$poCount = count($poUnits);
$compiledTranslationFile->addTranslationUnits($poUnits);
$this->outVerbose("${poCount} public messages added.");
}
}
// Finally, add the translation units related to the target extension.
$path = $this->buildLanguagePath($extension, $language) . '/' . self::DEF_PO_FILENAME;
if (file_exists($path) && is_readable($path)){
$poFileReader = new tao_helpers_translation_POFileReader($path);
$poFileReader->read();
$poFile = $poFileReader->getTranslationFile();
$compiledTranslationFile->addTranslationUnits($poFile->getTranslationUnits());
// Sort the TranslationUnits.
$sortingMethod = tao_helpers_translation_TranslationFile::SORT_ASC_I;
$compiledTranslationFile->setTranslationUnits($compiledTranslationFile->sortBySource($sortingMethod));
$jsPath = $this->buildLanguagePath($extension, $language) . '/' . self::DEF_JS_FILENAME;
$jsFileWriter = new tao_helpers_translation_JSFileWriter($jsPath, $compiledTranslationFile);
$jsFileWriter->write();
$this->outVerbose("JavaScript compiled translations for extension '${extension}' with '${language}' written.");
}
else{
$this->err("PO file '${path}' for extension '${extension}' with language '${language}' cannot be read.", true);
}
}
else{
$this->err("Cannot list TAO Extensions from root path. Check your system rights.", true);
}
$this->outVerbose("Translations for '${extension}' with language '${language}' gracefully compiled.");
}
} | [
"public",
"function",
"actionCompile",
"(",
")",
"{",
"$",
"extensionsToCreate",
"=",
"explode",
"(",
"','",
",",
"$",
"this",
"->",
"options",
"[",
"'extension'",
"]",
")",
";",
"$",
"extensionsToCreate",
"=",
"array_unique",
"(",
"$",
"extensionsToCreate",
... | Implementation of the 'compile' action.
@access public
@author Joel Bout, <joel.bout@tudor.lu>
@return void | [
"Implementation",
"of",
"the",
"compile",
"action",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoTranslate.php#L1234-L1345 |
oat-sa/tao-core | scripts/class.TaoTranslate.php | tao_scripts_TaoTranslate.checkCompileInput | private function checkCompileInput()
{
$defaults = array('extension' => null,
'language' => null,
'input' => dirname(__FILE__) . '/../../' . $this->options['extension'] . '/' . self::DEF_INPUT_DIR,
'output' => dirname(__FILE__) . '/../../' . $this->options['extension'] . '/' . self::DEF_OUTPUT_DIR);
$this->options = array_merge($defaults, $this->options);
if ($this->options['extension'] == null){
$this->err("Please provide the 'extension' parameter.", true);
}
else if ($this->options['language'] == null){
$this->err("Please provide the 'language' parameter.", true);
}
} | php | private function checkCompileInput()
{
$defaults = array('extension' => null,
'language' => null,
'input' => dirname(__FILE__) . '/../../' . $this->options['extension'] . '/' . self::DEF_INPUT_DIR,
'output' => dirname(__FILE__) . '/../../' . $this->options['extension'] . '/' . self::DEF_OUTPUT_DIR);
$this->options = array_merge($defaults, $this->options);
if ($this->options['extension'] == null){
$this->err("Please provide the 'extension' parameter.", true);
}
else if ($this->options['language'] == null){
$this->err("Please provide the 'language' parameter.", true);
}
} | [
"private",
"function",
"checkCompileInput",
"(",
")",
"{",
"$",
"defaults",
"=",
"array",
"(",
"'extension'",
"=>",
"null",
",",
"'language'",
"=>",
"null",
",",
"'input'",
"=>",
"dirname",
"(",
"__FILE__",
")",
".",
"'/../../'",
".",
"$",
"this",
"->",
... | Checks the input for the 'compile' action.
@access public
@author Joel Bout, <joel.bout@tudor.lu>
@return void | [
"Checks",
"the",
"input",
"for",
"the",
"compile",
"action",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoTranslate.php#L1354-L1371 |
oat-sa/tao-core | scripts/class.TaoTranslate.php | tao_scripts_TaoTranslate.actionCompileAll | public function actionCompileAll()
{
// Get the list of languages that will be compiled.
$this->outVerbose("Compiling all languages for extension '" . $this->options['extension'] . "'...");
$rootDir = ROOT_PATH;
$extensionDir = $rootDir . '/' . $this->options['extension'];
$localesDir = $extensionDir . '/locales';
$locales = array();
$directories = scandir($localesDir);
if ($directories === false) {
$this->err("The locales directory of extension '" . $this->options['extension'] . "' cannot be read.", true);
} else {
foreach ($directories as $dir) {
if ($dir[0] !== '.') {
// It is a language directory.
$locales[] = $dir;
}
}
}
foreach ($locales as $l) {
$this->options['language'] = $l;
$this->checkCompileInput();
$this->actionCompile();
$this->outVerbose("");
}
} | php | public function actionCompileAll()
{
// Get the list of languages that will be compiled.
$this->outVerbose("Compiling all languages for extension '" . $this->options['extension'] . "'...");
$rootDir = ROOT_PATH;
$extensionDir = $rootDir . '/' . $this->options['extension'];
$localesDir = $extensionDir . '/locales';
$locales = array();
$directories = scandir($localesDir);
if ($directories === false) {
$this->err("The locales directory of extension '" . $this->options['extension'] . "' cannot be read.", true);
} else {
foreach ($directories as $dir) {
if ($dir[0] !== '.') {
// It is a language directory.
$locales[] = $dir;
}
}
}
foreach ($locales as $l) {
$this->options['language'] = $l;
$this->checkCompileInput();
$this->actionCompile();
$this->outVerbose("");
}
} | [
"public",
"function",
"actionCompileAll",
"(",
")",
"{",
"// Get the list of languages that will be compiled.",
"$",
"this",
"->",
"outVerbose",
"(",
"\"Compiling all languages for extension '\"",
".",
"$",
"this",
"->",
"options",
"[",
"'extension'",
"]",
".",
"\"'...\""... | Implementation of the 'compileAll' action.
@access public
@author Joel Bout, <joel.bout@tudor.lu>
@return void | [
"Implementation",
"of",
"the",
"compileAll",
"action",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoTranslate.php#L1380-L1411 |
oat-sa/tao-core | models/classes/passwordRecovery/PasswordRecoveryService.php | PasswordRecoveryService.sendMail | public function sendMail(\core_kernel_classes_Resource $user)
{
$messagingService = $this->getMessagingService();
if (!$messagingService->isAvailable()) {
throw new PasswordRecoveryException('Messaging service is not available.');
}
$generisUser = new \core_kernel_users_GenerisUser($user);
$userNameProperty = new \core_kernel_classes_Property(GenerisRdf::PROPERTY_USER_FIRSTNAME);
$messageData = array(
'user_name' => (string) $user->getOnePropertyValue($userNameProperty),
'link' => $this->getPasswordRecoveryLink($user)
);
$message = new Message();
$message->setTo($generisUser);
$message->setBody($this->getMailContent($messageData));
$message->setTitle(__("Your TAO Password"));
$result = $messagingService->send($message);
return $result;
} | php | public function sendMail(\core_kernel_classes_Resource $user)
{
$messagingService = $this->getMessagingService();
if (!$messagingService->isAvailable()) {
throw new PasswordRecoveryException('Messaging service is not available.');
}
$generisUser = new \core_kernel_users_GenerisUser($user);
$userNameProperty = new \core_kernel_classes_Property(GenerisRdf::PROPERTY_USER_FIRSTNAME);
$messageData = array(
'user_name' => (string) $user->getOnePropertyValue($userNameProperty),
'link' => $this->getPasswordRecoveryLink($user)
);
$message = new Message();
$message->setTo($generisUser);
$message->setBody($this->getMailContent($messageData));
$message->setTitle(__("Your TAO Password"));
$result = $messagingService->send($message);
return $result;
} | [
"public",
"function",
"sendMail",
"(",
"\\",
"core_kernel_classes_Resource",
"$",
"user",
")",
"{",
"$",
"messagingService",
"=",
"$",
"this",
"->",
"getMessagingService",
"(",
")",
";",
"if",
"(",
"!",
"$",
"messagingService",
"->",
"isAvailable",
"(",
")",
... | Send email message with password recovery instructions.
@author Aleh Hutnikau <hutnikau@1pt.com>
@param core_kernel_classes_Resource $user The user has requested password recovery.
@return boolean Whether message was sent. | [
"Send",
"email",
"message",
"with",
"password",
"recovery",
"instructions",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/passwordRecovery/PasswordRecoveryService.php#L53-L75 |
oat-sa/tao-core | models/classes/passwordRecovery/PasswordRecoveryService.php | PasswordRecoveryService.getUser | public function getUser($property, $value)
{
$class = new \core_kernel_classes_Class(GenerisRdf::CLASS_GENERIS_USER);
$users = \tao_models_classes_UserService::singleton()->searchInstances(
array($property => $value),
$class,
array('like' => false, 'recursive' => true)
);
$user = empty($users) ? null : current($users);
return $user;
} | php | public function getUser($property, $value)
{
$class = new \core_kernel_classes_Class(GenerisRdf::CLASS_GENERIS_USER);
$users = \tao_models_classes_UserService::singleton()->searchInstances(
array($property => $value),
$class,
array('like' => false, 'recursive' => true)
);
$user = empty($users) ? null : current($users);
return $user;
} | [
"public",
"function",
"getUser",
"(",
"$",
"property",
",",
"$",
"value",
")",
"{",
"$",
"class",
"=",
"new",
"\\",
"core_kernel_classes_Class",
"(",
"GenerisRdf",
"::",
"CLASS_GENERIS_USER",
")",
";",
"$",
"users",
"=",
"\\",
"tao_models_classes_UserService",
... | Get user by property value
@param string $property uri
@param type $value property value
@return core_kernel_classes_Resource | null | [
"Get",
"user",
"by",
"property",
"value"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/passwordRecovery/PasswordRecoveryService.php#L83-L95 |
oat-sa/tao-core | models/classes/passwordRecovery/PasswordRecoveryService.php | PasswordRecoveryService.getUserMail | public function getUserMail(\core_kernel_classes_Resource $user)
{
$userMailProperty = new \core_kernel_classes_Property(GenerisRdf::PROPERTY_USER_MAIL);
$result = (string) $user->getOnePropertyValue($userMailProperty);
if (!$result || !filter_var($result, FILTER_VALIDATE_EMAIL)) {
$result = null;
}
return $result;
} | php | public function getUserMail(\core_kernel_classes_Resource $user)
{
$userMailProperty = new \core_kernel_classes_Property(GenerisRdf::PROPERTY_USER_MAIL);
$result = (string) $user->getOnePropertyValue($userMailProperty);
if (!$result || !filter_var($result, FILTER_VALIDATE_EMAIL)) {
$result = null;
}
return $result;
} | [
"public",
"function",
"getUserMail",
"(",
"\\",
"core_kernel_classes_Resource",
"$",
"user",
")",
"{",
"$",
"userMailProperty",
"=",
"new",
"\\",
"core_kernel_classes_Property",
"(",
"GenerisRdf",
"::",
"PROPERTY_USER_MAIL",
")",
";",
"$",
"result",
"=",
"(",
"str... | Get user mail value
@param core_kernel_classes_Resource $user
@return string | null | [
"Get",
"user",
"mail",
"value"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/passwordRecovery/PasswordRecoveryService.php#L102-L110 |
oat-sa/tao-core | models/classes/passwordRecovery/PasswordRecoveryService.php | PasswordRecoveryService.setPassword | public function setPassword(\core_kernel_classes_Resource $user, $newPassword)
{
\tao_models_classes_UserService::singleton()->setPassword($user, $newPassword);
$this->deleteToken($user);
} | php | public function setPassword(\core_kernel_classes_Resource $user, $newPassword)
{
\tao_models_classes_UserService::singleton()->setPassword($user, $newPassword);
$this->deleteToken($user);
} | [
"public",
"function",
"setPassword",
"(",
"\\",
"core_kernel_classes_Resource",
"$",
"user",
",",
"$",
"newPassword",
")",
"{",
"\\",
"tao_models_classes_UserService",
"::",
"singleton",
"(",
")",
"->",
"setPassword",
"(",
"$",
"user",
",",
"$",
"newPassword",
"... | Change user pasword
@param core_kernel_classes_Resource $user
@param string $newPassword New password value | [
"Change",
"user",
"pasword"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/passwordRecovery/PasswordRecoveryService.php#L117-L121 |
oat-sa/tao-core | models/classes/passwordRecovery/PasswordRecoveryService.php | PasswordRecoveryService.deleteToken | public function deleteToken(\core_kernel_classes_Resource $user)
{
$tokenProperty = new \core_kernel_classes_Property(self::PROPERTY_PASSWORD_RECOVERY_TOKEN);
return $user->removePropertyValues($tokenProperty);
} | php | public function deleteToken(\core_kernel_classes_Resource $user)
{
$tokenProperty = new \core_kernel_classes_Property(self::PROPERTY_PASSWORD_RECOVERY_TOKEN);
return $user->removePropertyValues($tokenProperty);
} | [
"public",
"function",
"deleteToken",
"(",
"\\",
"core_kernel_classes_Resource",
"$",
"user",
")",
"{",
"$",
"tokenProperty",
"=",
"new",
"\\",
"core_kernel_classes_Property",
"(",
"self",
"::",
"PROPERTY_PASSWORD_RECOVERY_TOKEN",
")",
";",
"return",
"$",
"user",
"->... | Delete password recovery token.
@param \core_kernel_classes_Resource $user
@return boolean | [
"Delete",
"password",
"recovery",
"token",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/passwordRecovery/PasswordRecoveryService.php#L129-L133 |
oat-sa/tao-core | models/classes/passwordRecovery/PasswordRecoveryService.php | PasswordRecoveryService.getMessagingService | public function getMessagingService()
{
if (is_null($this->messagingSerivce)) {
$this->messagingSerivce = MessagingService::singleton();
}
return $this->messagingSerivce;
} | php | public function getMessagingService()
{
if (is_null($this->messagingSerivce)) {
$this->messagingSerivce = MessagingService::singleton();
}
return $this->messagingSerivce;
} | [
"public",
"function",
"getMessagingService",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"messagingSerivce",
")",
")",
"{",
"$",
"this",
"->",
"messagingSerivce",
"=",
"MessagingService",
"::",
"singleton",
"(",
")",
";",
"}",
"return",
"$... | Get messaging service
@return MessagingService | [
"Get",
"messaging",
"service"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/passwordRecovery/PasswordRecoveryService.php#L140-L146 |
oat-sa/tao-core | models/classes/passwordRecovery/PasswordRecoveryService.php | PasswordRecoveryService.getMailContent | private function getMailContent($messageData)
{
$renderer = new \Renderer();
$renderer->setTemplate(Template::getTemplate('passwordRecovery/password-recovery-message.tpl', 'tao'));
foreach ($messageData as $key => $value) {
$renderer->setData($key, $value);
}
return $renderer->render();
} | php | private function getMailContent($messageData)
{
$renderer = new \Renderer();
$renderer->setTemplate(Template::getTemplate('passwordRecovery/password-recovery-message.tpl', 'tao'));
foreach ($messageData as $key => $value) {
$renderer->setData($key, $value);
}
return $renderer->render();
} | [
"private",
"function",
"getMailContent",
"(",
"$",
"messageData",
")",
"{",
"$",
"renderer",
"=",
"new",
"\\",
"Renderer",
"(",
")",
";",
"$",
"renderer",
"->",
"setTemplate",
"(",
"Template",
"::",
"getTemplate",
"(",
"'passwordRecovery/password-recovery-message.... | Function generates password recovery email message content
May be used in the following way:
<pre>
$this->getMailContent(array(
'user_name'=>'John Doe',
'link'=>$this->getPasswordRecoveryLink($user)
));
</pre>
@author Aleh Hutnikau <hutnikau@1pt.com>
@param array $messageData
@return string Message content | [
"Function",
"generates",
"password",
"recovery",
"email",
"message",
"content",
"May",
"be",
"used",
"in",
"the",
"following",
"way",
":",
"<pre",
">",
"$this",
"-",
">",
"getMailContent",
"(",
"array",
"(",
"user_name",
"=",
">",
"John",
"Doe",
"link",
"=... | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/passwordRecovery/PasswordRecoveryService.php#L162-L170 |
oat-sa/tao-core | models/classes/passwordRecovery/PasswordRecoveryService.php | PasswordRecoveryService.generateRecoveryToken | private function generateRecoveryToken(\core_kernel_classes_Resource $user)
{
$this->deleteToken($user);
$token = md5(uniqid(mt_rand(), true));
$tokenProperty = new \core_kernel_classes_Property(self::PROPERTY_PASSWORD_RECOVERY_TOKEN);
$user->setPropertyValue($tokenProperty, $token);
return $token;
} | php | private function generateRecoveryToken(\core_kernel_classes_Resource $user)
{
$this->deleteToken($user);
$token = md5(uniqid(mt_rand(), true));
$tokenProperty = new \core_kernel_classes_Property(self::PROPERTY_PASSWORD_RECOVERY_TOKEN);
$user->setPropertyValue($tokenProperty, $token);
return $token;
} | [
"private",
"function",
"generateRecoveryToken",
"(",
"\\",
"core_kernel_classes_Resource",
"$",
"user",
")",
"{",
"$",
"this",
"->",
"deleteToken",
"(",
"$",
"user",
")",
";",
"$",
"token",
"=",
"md5",
"(",
"uniqid",
"(",
"mt_rand",
"(",
")",
",",
"true",
... | Generate password recovery token.
If user already has passwordRecoveryToken property then it will be replaced.
@author Aleh Hutnikau <hutnikau@1pt.com>
@param core_kernel_classes_Resource $user The user has requested password recovery.
@return string Password recovery token. | [
"Generate",
"password",
"recovery",
"token",
".",
"If",
"user",
"already",
"has",
"passwordRecoveryToken",
"property",
"then",
"it",
"will",
"be",
"replaced",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/passwordRecovery/PasswordRecoveryService.php#L193-L202 |
oat-sa/tao-core | helpers/class.Http.php | tao_helpers_Http.getHeaders | public static function getHeaders()
{
if (self::$headers === null) {
if (function_exists('apache_request_headers')) {
$headers = apache_request_headers();
} else {
$headers = array();
if (isset($_SERVER['CONTENT_TYPE'])) {
$headers['Content-Type'] = $_SERVER['CONTENT_TYPE'];
}
if (isset($_ENV['CONTENT_TYPE'])) {
$headers['Content-Type'] = $_ENV['CONTENT_TYPE'];
}
foreach ($_SERVER as $key => $value) {
if (substr($key, 0, 5) == "HTTP_") {
// this is chaos, basically it is just there to capitalize the first
// letter of every word that is not an initial HTTP and strip HTTP
// code from przemek
$key = str_replace(" ", "-", ucwords(strtolower(str_replace("_", " ", substr($key, 5)))));
$headers[$key] = $value;
}
}
}
self::$headers = $headers;
}
return self::$headers;
} | php | public static function getHeaders()
{
if (self::$headers === null) {
if (function_exists('apache_request_headers')) {
$headers = apache_request_headers();
} else {
$headers = array();
if (isset($_SERVER['CONTENT_TYPE'])) {
$headers['Content-Type'] = $_SERVER['CONTENT_TYPE'];
}
if (isset($_ENV['CONTENT_TYPE'])) {
$headers['Content-Type'] = $_ENV['CONTENT_TYPE'];
}
foreach ($_SERVER as $key => $value) {
if (substr($key, 0, 5) == "HTTP_") {
// this is chaos, basically it is just there to capitalize the first
// letter of every word that is not an initial HTTP and strip HTTP
// code from przemek
$key = str_replace(" ", "-", ucwords(strtolower(str_replace("_", " ", substr($key, 5)))));
$headers[$key] = $value;
}
}
}
self::$headers = $headers;
}
return self::$headers;
} | [
"public",
"static",
"function",
"getHeaders",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"headers",
"===",
"null",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'apache_request_headers'",
")",
")",
"{",
"$",
"headers",
"=",
"apache_request_headers",
"(",
... | Return array of HTTP headers from the current request
@return array|false | [
"Return",
"array",
"of",
"HTTP",
"headers",
"from",
"the",
"current",
"request"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Http.php#L96-L123 |
oat-sa/tao-core | helpers/class.Http.php | tao_helpers_Http.getUploadedFile | public static function getUploadedFile($name)
{
// for large file, the $_FILES may be empty so see this before checking for other updates
$limit = SystemHelper::getFileUploadLimit();
$contentLength = intval($_SERVER['CONTENT_LENGTH']);
if( $limit > 0 && $contentLength > $limit && count(self::getFiles())===0){
throw new FileUploadException('Exceeded filesize limit of ' . $limit);
}
$files = self::getFiles();
$fileData = $files[$name];
if (isset($files[$name])) {
//check for upload errors
if (isset($fileData['error']) && $fileData['error'] != UPLOAD_ERR_OK) {
switch ($fileData['error']) {
case UPLOAD_ERR_NO_FILE:
throw new FileUploadException('No file sent.');
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
throw new FileUploadException('Exceeded filesize limit of ' . $limit);
default:
throw new common_exception_Error('Upload fails, check errors');
}
}
}
if (!is_uploaded_file($fileData['tmp_name'])) {
throw new common_exception_Error('Non uploaded file in filedata, potential attack');
}
return $fileData;
} | php | public static function getUploadedFile($name)
{
// for large file, the $_FILES may be empty so see this before checking for other updates
$limit = SystemHelper::getFileUploadLimit();
$contentLength = intval($_SERVER['CONTENT_LENGTH']);
if( $limit > 0 && $contentLength > $limit && count(self::getFiles())===0){
throw new FileUploadException('Exceeded filesize limit of ' . $limit);
}
$files = self::getFiles();
$fileData = $files[$name];
if (isset($files[$name])) {
//check for upload errors
if (isset($fileData['error']) && $fileData['error'] != UPLOAD_ERR_OK) {
switch ($fileData['error']) {
case UPLOAD_ERR_NO_FILE:
throw new FileUploadException('No file sent.');
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
throw new FileUploadException('Exceeded filesize limit of ' . $limit);
default:
throw new common_exception_Error('Upload fails, check errors');
}
}
}
if (!is_uploaded_file($fileData['tmp_name'])) {
throw new common_exception_Error('Non uploaded file in filedata, potential attack');
}
return $fileData;
} | [
"public",
"static",
"function",
"getUploadedFile",
"(",
"$",
"name",
")",
"{",
"// for large file, the $_FILES may be empty so see this before checking for other updates",
"$",
"limit",
"=",
"SystemHelper",
"::",
"getFileUploadLimit",
"(",
")",
";",
"$",
"contentLength",
"=... | Get the files data from an HTTP file upload (ie. from the $_FILES)
@author "Bertrand Chevrier <bertrand@taotesting.com>
@param string the file field name
@return array the file data
@throws common_exception_Error in case of wrong upload | [
"Get",
"the",
"files",
"data",
"from",
"an",
"HTTP",
"file",
"upload",
"(",
"ie",
".",
"from",
"the",
"$_FILES",
")"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Http.php#L156-L187 |
oat-sa/tao-core | helpers/class.Http.php | tao_helpers_Http.returnFile | public static function returnFile($filename, $contenttype = true, $svgzSupport = false)
{
if (tao_helpers_File::securityCheck($filename, true)) {
if (file_exists($filename)) {
$mimeType = tao_helpers_File::getMimeType($filename, true);
if ($contenttype) {
header('Content-Type: ' . $mimeType);
}
$fp = fopen($filename, 'rb');
if ($fp === false) {
header("HTTP/1.0 404 Not Found");
} else {
$pathinfo = pathinfo($filename);
if (isset($pathinfo['extension']) && $pathinfo['extension'] === 'svgz' && !$svgzSupport) {
header('Content-Encoding: gzip');
}
// session must be closed because, for example, video files might take a while to be sent to the client
// and we need the client to be able to make other calls to the server during that time
session_write_close();
$http416RequestRangeNotSatisfiable = 'HTTP/1.1 416 Requested Range Not Satisfiable';
$http206PartialContent = 'HTTP/1.1 206 Partial Content';
$http200OK = 'HTTP/1.1 200 OK';
$filesize = filesize($filename);
$offset = 0;
$length = $filesize;
$useFpassthru = false;
$partialContent = false;
header('Accept-Ranges: bytes');
if (isset($_SERVER['HTTP_RANGE'])) {
$partialContent = true;
preg_match('/bytes=(\d+)-(\d+)?/', $_SERVER['HTTP_RANGE'], $matches);
$offset = intval($matches[1]);
if (!isset($matches[2])) {
// no end position is given, so we serve the file from the start position to the end
$useFpassthru = true;
} else {
$length = intval($matches[2]) - $offset;
}
}
fseek($fp, $offset);
if ($partialContent) {
if (($offset < 0) || ($offset > $filesize)) {
header($http416RequestRangeNotSatisfiable);
} else {
if ($useFpassthru) {
// only a starting position is given
header($http206PartialContent);
header("Content-Length: " . ($filesize - $offset));
header('Content-Range: bytes ' . $offset . '-' . ($filesize - 1) . '/' . $filesize);
if (ob_get_level() > 0) ob_end_flush();
fpassthru($fp);
} else {
// we are given a starting position and how many bytes the client asks for
$endPosition = $offset + $length;
if ($endPosition > $filesize) {
header($http416RequestRangeNotSatisfiable);
} else {
header($http206PartialContent);
header("Content-Length: " . ($length));
header('Content-Range: bytes ' . $offset . '-' . ($offset + $length - 1) . '/' . $filesize);
// send 500KB per cycle
$bytesPerCycle = (1024 * 1024) * 0.5;
$currentPosition = $offset;
if (ob_get_level() > 0) ob_end_flush();
// because the client might ask for the whole file, we split the serving into little pieces
// this is also good in case someone with bad intentions tries to get the whole file many times
// and eat up the server memory, we are not loading the whole file into the memory.
while (!feof($fp)) {
if (($currentPosition + $bytesPerCycle) <= $endPosition) {
$data = fread($fp, $bytesPerCycle);
$currentPosition = $currentPosition + $bytesPerCycle;
echo $data;
} else {
$data = fread($fp, ($endPosition - $currentPosition));
echo $data;
}
}
}
}
}
} else {
// client does not want partial contents so we just serve the whole file
header($http200OK);
header("Content-Length: " . $filesize);
if (ob_get_level() > 0) ob_end_flush();
fpassthru($fp);
}
fclose($fp);
}
} else {
if (class_exists('common_Logger')) {
common_Logger::w('File '.$filename.' not found');
}
header("HTTP/1.0 404 Not Found");
}
} else {
throw new common_exception_Error('Security exception for path ' . $filename);
}
} | php | public static function returnFile($filename, $contenttype = true, $svgzSupport = false)
{
if (tao_helpers_File::securityCheck($filename, true)) {
if (file_exists($filename)) {
$mimeType = tao_helpers_File::getMimeType($filename, true);
if ($contenttype) {
header('Content-Type: ' . $mimeType);
}
$fp = fopen($filename, 'rb');
if ($fp === false) {
header("HTTP/1.0 404 Not Found");
} else {
$pathinfo = pathinfo($filename);
if (isset($pathinfo['extension']) && $pathinfo['extension'] === 'svgz' && !$svgzSupport) {
header('Content-Encoding: gzip');
}
// session must be closed because, for example, video files might take a while to be sent to the client
// and we need the client to be able to make other calls to the server during that time
session_write_close();
$http416RequestRangeNotSatisfiable = 'HTTP/1.1 416 Requested Range Not Satisfiable';
$http206PartialContent = 'HTTP/1.1 206 Partial Content';
$http200OK = 'HTTP/1.1 200 OK';
$filesize = filesize($filename);
$offset = 0;
$length = $filesize;
$useFpassthru = false;
$partialContent = false;
header('Accept-Ranges: bytes');
if (isset($_SERVER['HTTP_RANGE'])) {
$partialContent = true;
preg_match('/bytes=(\d+)-(\d+)?/', $_SERVER['HTTP_RANGE'], $matches);
$offset = intval($matches[1]);
if (!isset($matches[2])) {
// no end position is given, so we serve the file from the start position to the end
$useFpassthru = true;
} else {
$length = intval($matches[2]) - $offset;
}
}
fseek($fp, $offset);
if ($partialContent) {
if (($offset < 0) || ($offset > $filesize)) {
header($http416RequestRangeNotSatisfiable);
} else {
if ($useFpassthru) {
// only a starting position is given
header($http206PartialContent);
header("Content-Length: " . ($filesize - $offset));
header('Content-Range: bytes ' . $offset . '-' . ($filesize - 1) . '/' . $filesize);
if (ob_get_level() > 0) ob_end_flush();
fpassthru($fp);
} else {
// we are given a starting position and how many bytes the client asks for
$endPosition = $offset + $length;
if ($endPosition > $filesize) {
header($http416RequestRangeNotSatisfiable);
} else {
header($http206PartialContent);
header("Content-Length: " . ($length));
header('Content-Range: bytes ' . $offset . '-' . ($offset + $length - 1) . '/' . $filesize);
// send 500KB per cycle
$bytesPerCycle = (1024 * 1024) * 0.5;
$currentPosition = $offset;
if (ob_get_level() > 0) ob_end_flush();
// because the client might ask for the whole file, we split the serving into little pieces
// this is also good in case someone with bad intentions tries to get the whole file many times
// and eat up the server memory, we are not loading the whole file into the memory.
while (!feof($fp)) {
if (($currentPosition + $bytesPerCycle) <= $endPosition) {
$data = fread($fp, $bytesPerCycle);
$currentPosition = $currentPosition + $bytesPerCycle;
echo $data;
} else {
$data = fread($fp, ($endPosition - $currentPosition));
echo $data;
}
}
}
}
}
} else {
// client does not want partial contents so we just serve the whole file
header($http200OK);
header("Content-Length: " . $filesize);
if (ob_get_level() > 0) ob_end_flush();
fpassthru($fp);
}
fclose($fp);
}
} else {
if (class_exists('common_Logger')) {
common_Logger::w('File '.$filename.' not found');
}
header("HTTP/1.0 404 Not Found");
}
} else {
throw new common_exception_Error('Security exception for path ' . $filename);
}
} | [
"public",
"static",
"function",
"returnFile",
"(",
"$",
"filename",
",",
"$",
"contenttype",
"=",
"true",
",",
"$",
"svgzSupport",
"=",
"false",
")",
"{",
"if",
"(",
"tao_helpers_File",
"::",
"securityCheck",
"(",
"$",
"filename",
",",
"true",
")",
")",
... | Sends file content to the client(browser or video/audio player in the browser), it serves images, video/audio files and any other type of file.<br />
If the client asks for partial contents, then partial contents are served, if not, the whole file is send.<br />
Works well with big files, without eating up memory.
@author "Martin for OAT <code@taotesting.com>"
@param string $filename the file name
@param boolean $contenttype whether to add content type header or not
@param boolean $svgzSupport whether to add content encoding header or not
@throws common_exception_Error | [
"Sends",
"file",
"content",
"to",
"the",
"client",
"(",
"browser",
"or",
"video",
"/",
"audio",
"player",
"in",
"the",
"browser",
")",
"it",
"serves",
"images",
"video",
"/",
"audio",
"files",
"and",
"any",
"other",
"type",
"of",
"file",
".",
"<br",
"/... | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Http.php#L238-L342 |
oat-sa/tao-core | models/classes/menu/ActionService.php | ActionService.hasAccess | public function hasAccess(MenuAction $action, common_user_User $user, array $node){
$resolvedAction = $this->getResolvedAction($action);
if(!is_null($resolvedAction) && !is_null($user)){
if($node['type'] = $resolvedAction['context'] || $resolvedAction['context'] == 'resource') {
foreach($resolvedAction['required'] as $key){
if(!array_key_exists($key, $node)){
//missing required key
return self::ACCESS_UNDEFINED;
}
}
try {
if(AclProxy::hasAccess($user, $resolvedAction['controller'], $resolvedAction['action'], $node)){
return self::ACCESS_GRANTED;
}
return self::ACCESS_DENIED;
} catch(\Exception $e){
\common_Logger::w('Unable to resolve permission for action ' . $action->getId() . ' : ' . $e->getMessage() );
}
}
}
return self::ACCESS_UNDEFINED;
} | php | public function hasAccess(MenuAction $action, common_user_User $user, array $node){
$resolvedAction = $this->getResolvedAction($action);
if(!is_null($resolvedAction) && !is_null($user)){
if($node['type'] = $resolvedAction['context'] || $resolvedAction['context'] == 'resource') {
foreach($resolvedAction['required'] as $key){
if(!array_key_exists($key, $node)){
//missing required key
return self::ACCESS_UNDEFINED;
}
}
try {
if(AclProxy::hasAccess($user, $resolvedAction['controller'], $resolvedAction['action'], $node)){
return self::ACCESS_GRANTED;
}
return self::ACCESS_DENIED;
} catch(\Exception $e){
\common_Logger::w('Unable to resolve permission for action ' . $action->getId() . ' : ' . $e->getMessage() );
}
}
}
return self::ACCESS_UNDEFINED;
} | [
"public",
"function",
"hasAccess",
"(",
"MenuAction",
"$",
"action",
",",
"common_user_User",
"$",
"user",
",",
"array",
"$",
"node",
")",
"{",
"$",
"resolvedAction",
"=",
"$",
"this",
"->",
"getResolvedAction",
"(",
"$",
"action",
")",
";",
"if",
"(",
"... | Has a node access to an action
@param MenuAction $action the menu action
@param common_user_User $user the user to check
@param array $node the node/resource to verify
@return int the access level | [
"Has",
"a",
"node",
"access",
"to",
"an",
"action"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/menu/ActionService.php#L58-L81 |
oat-sa/tao-core | models/classes/menu/ActionService.php | ActionService.computePermissions | public function computePermissions(array $actions, \common_user_User $user, array $node)
{
$permissions = [];
foreach($actions as $action){
$access = $this->hasAccess($action, $user, $node);
if($access != self::ACCESS_UNDEFINED){
$permissions[$action->getId()] = ($access == self::ACCESS_GRANTED);
}
}
return $permissions;
} | php | public function computePermissions(array $actions, \common_user_User $user, array $node)
{
$permissions = [];
foreach($actions as $action){
$access = $this->hasAccess($action, $user, $node);
if($access != self::ACCESS_UNDEFINED){
$permissions[$action->getId()] = ($access == self::ACCESS_GRANTED);
}
}
return $permissions;
} | [
"public",
"function",
"computePermissions",
"(",
"array",
"$",
"actions",
",",
"\\",
"common_user_User",
"$",
"user",
",",
"array",
"$",
"node",
")",
"{",
"$",
"permissions",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"actions",
"as",
"$",
"action",
")",
... | Compute the permissions of a node against a list of actions
@param MenuAction[] $actions the menu actions
@param common_user_User $user the user to check
@param array $node the node/resource to verify
@return array the computed permissions as actionId => boolean | [
"Compute",
"the",
"permissions",
"of",
"a",
"node",
"against",
"a",
"list",
"of",
"actions"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/menu/ActionService.php#L90-L100 |
oat-sa/tao-core | models/classes/menu/ActionService.php | ActionService.getRequiredRights | public function getRequiredRights(MenuAction $action)
{
$rights = [];
$resolvedAction = $this->getResolvedAction($action);
if(!is_null($resolvedAction)){
try {
$rights = ControllerHelper::getRequiredRights(
$resolvedAction['controller'],
$resolvedAction['action']
);
} catch(\Exception $e){
\common_Logger::d('do not handle permissions for action : ' . $action->getName() . ' ' . $action->getUrl());
}
}
return $rights;
} | php | public function getRequiredRights(MenuAction $action)
{
$rights = [];
$resolvedAction = $this->getResolvedAction($action);
if(!is_null($resolvedAction)){
try {
$rights = ControllerHelper::getRequiredRights(
$resolvedAction['controller'],
$resolvedAction['action']
);
} catch(\Exception $e){
\common_Logger::d('do not handle permissions for action : ' . $action->getName() . ' ' . $action->getUrl());
}
}
return $rights;
} | [
"public",
"function",
"getRequiredRights",
"(",
"MenuAction",
"$",
"action",
")",
"{",
"$",
"rights",
"=",
"[",
"]",
";",
"$",
"resolvedAction",
"=",
"$",
"this",
"->",
"getResolvedAction",
"(",
"$",
"action",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
... | Get the rights required for the given action
@param MenuAction $action
@return array the required rights | [
"Get",
"the",
"rights",
"required",
"for",
"the",
"given",
"action"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/menu/ActionService.php#L107-L123 |
oat-sa/tao-core | models/classes/menu/ActionService.php | ActionService.getResolvedAction | private function getResolvedAction(MenuAction $action)
{
$actionId = $action->getId();
if(!isset($this->resolvedActions[$actionId])){
try{
if($action->getContext() == '*'){
//we assume the star context is not permission aware
$this->resolvedActions[$actionId] = null;
} else {
$resolver = new ActionResolver($action->getUrl());
$resolvedAction = [
'id' => $action->getId(),
'context' => $action->getContext(),
'controller' => $resolver->getController(),
'action' => $resolver->getAction(),
];
$resolvedAction['required'] = array_keys(
ControllerHelper::getRequiredRights($resolvedAction['controller'], $resolvedAction['action'])
);
$this->resolvedActions[$actionId] = $resolvedAction;
}
} catch(\ResolverException $re) {
$this->resolvedActions[$actionId] = null;
\common_Logger::d('do not handle permissions for action : ' . $action->getName() . ' ' . $action->getUrl());
} catch(\Exception $e){
$this->resolvedActions[$actionId] = null;
\common_Logger::d('do not handle permissions for action : ' . $action->getName() . ' ' . $action->getUrl());
}
}
return $this->resolvedActions[$actionId];
} | php | private function getResolvedAction(MenuAction $action)
{
$actionId = $action->getId();
if(!isset($this->resolvedActions[$actionId])){
try{
if($action->getContext() == '*'){
//we assume the star context is not permission aware
$this->resolvedActions[$actionId] = null;
} else {
$resolver = new ActionResolver($action->getUrl());
$resolvedAction = [
'id' => $action->getId(),
'context' => $action->getContext(),
'controller' => $resolver->getController(),
'action' => $resolver->getAction(),
];
$resolvedAction['required'] = array_keys(
ControllerHelper::getRequiredRights($resolvedAction['controller'], $resolvedAction['action'])
);
$this->resolvedActions[$actionId] = $resolvedAction;
}
} catch(\ResolverException $re) {
$this->resolvedActions[$actionId] = null;
\common_Logger::d('do not handle permissions for action : ' . $action->getName() . ' ' . $action->getUrl());
} catch(\Exception $e){
$this->resolvedActions[$actionId] = null;
\common_Logger::d('do not handle permissions for action : ' . $action->getName() . ' ' . $action->getUrl());
}
}
return $this->resolvedActions[$actionId];
} | [
"private",
"function",
"getResolvedAction",
"(",
"MenuAction",
"$",
"action",
")",
"{",
"$",
"actionId",
"=",
"$",
"action",
"->",
"getId",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"resolvedActions",
"[",
"$",
"actionId",
"]",
")... | Get the action resolved against itself in the current context
@param MenuAction $action the action
@return array the resolved action | [
"Get",
"the",
"action",
"resolved",
"against",
"itself",
"in",
"the",
"current",
"context"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/menu/ActionService.php#L131-L165 |
oat-sa/tao-core | models/classes/ThemeRegistry.php | ThemeRegistry.getTheme | private function getTheme($target, $themeId){
$returnValue = null;
if(!$this->isRegistered($target)){
throw new \common_Exception('Target '.$target.' does not exist');
} else {
$array = $this->get($target);
$found = false;
foreach ($array['available'] as $theme) {
if ($theme['id'] == $themeId) {
$found = true;
$returnValue = $theme;
break;
}
}
if (!$found) {
throw new ThemeNotFoundException('Theme '.$themeId.' not found for target '.$target);
}
}
return $returnValue;
} | php | private function getTheme($target, $themeId){
$returnValue = null;
if(!$this->isRegistered($target)){
throw new \common_Exception('Target '.$target.' does not exist');
} else {
$array = $this->get($target);
$found = false;
foreach ($array['available'] as $theme) {
if ($theme['id'] == $themeId) {
$found = true;
$returnValue = $theme;
break;
}
}
if (!$found) {
throw new ThemeNotFoundException('Theme '.$themeId.' not found for target '.$target);
}
}
return $returnValue;
} | [
"private",
"function",
"getTheme",
"(",
"$",
"target",
",",
"$",
"themeId",
")",
"{",
"$",
"returnValue",
"=",
"null",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isRegistered",
"(",
"$",
"target",
")",
")",
"{",
"throw",
"new",
"\\",
"common_Exception",
... | Get the theme array identified by its target and id
@param string $target
@param string $themeId
@return array
@throws \common_Exception | [
"Get",
"the",
"theme",
"array",
"identified",
"by",
"its",
"target",
"and",
"id"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/ThemeRegistry.php#L83-L103 |
oat-sa/tao-core | models/classes/ThemeRegistry.php | ThemeRegistry.getDefaultTheme | public function getDefaultTheme($target){
$defaultTheme = null;
if(!$this->isRegistered($target)){
throw new \common_Exception('Target '.$target.' does not exist');
} else {
$array = $this->get($target);
if(isset($array['default'])){
$themeId = $array['default'];
try{
$defaultTheme = $this->getTheme($target, $themeId);
}catch(Exception $e){
//not found
$defaultTheme = null;
}
}
}
return $defaultTheme;
} | php | public function getDefaultTheme($target){
$defaultTheme = null;
if(!$this->isRegistered($target)){
throw new \common_Exception('Target '.$target.' does not exist');
} else {
$array = $this->get($target);
if(isset($array['default'])){
$themeId = $array['default'];
try{
$defaultTheme = $this->getTheme($target, $themeId);
}catch(Exception $e){
//not found
$defaultTheme = null;
}
}
}
return $defaultTheme;
} | [
"public",
"function",
"getDefaultTheme",
"(",
"$",
"target",
")",
"{",
"$",
"defaultTheme",
"=",
"null",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isRegistered",
"(",
"$",
"target",
")",
")",
"{",
"throw",
"new",
"\\",
"common_Exception",
"(",
"'Target '"... | Get the default theme array | [
"Get",
"the",
"default",
"theme",
"array"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/ThemeRegistry.php#L108-L125 |
oat-sa/tao-core | models/classes/ThemeRegistry.php | ThemeRegistry.createTarget | public function createTarget($targetId, $base)
{
if(!is_string($base) && !is_array($base)){
throw new \common_Exception('Invalid base format');
}
$array = array(
'base' => $base,
'available' => array()
);
$this->set($targetId, $array);
} | php | public function createTarget($targetId, $base)
{
if(!is_string($base) && !is_array($base)){
throw new \common_Exception('Invalid base format');
}
$array = array(
'base' => $base,
'available' => array()
);
$this->set($targetId, $array);
} | [
"public",
"function",
"createTarget",
"(",
"$",
"targetId",
",",
"$",
"base",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"base",
")",
"&&",
"!",
"is_array",
"(",
"$",
"base",
")",
")",
"{",
"throw",
"new",
"\\",
"common_Exception",
"(",
"'Inval... | Adds a new target to the System
@param string $targetId
@param string|array $base
@throws \common_Exception | [
"Adds",
"a",
"new",
"target",
"to",
"the",
"System"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/ThemeRegistry.php#L134-L146 |
oat-sa/tao-core | models/classes/ThemeRegistry.php | ThemeRegistry.registerTheme | public function registerTheme($id, $name, $path = '', $targets = array(), $templates = array() )
{
if (preg_match('/^[a-zA-Z0-9]*$/', $id) === 0) {
throw new \common_Exception('Invalid id "'.$id.'"');
}
if (!is_array($targets) || count($targets) === 0){
throw new \common_Exception('No targets were provided for theme '.$id);
}
foreach ($targets as $target) {
if(!$this->isRegistered($target)){
throw new \common_Exception('Target '.$target.' does not exist');
} else {
$array = $this->get($target);
foreach ($array['available'] as $theme) {
if ($theme['id'] == $id) {
throw new \common_Exception('Theme '.$id.' already exists for target '.$target);
}
}
$theme = array(
'id' => $id,
'name' => $name
);
//the path is optional
if($path){
$theme['path'] = $path;
}
//register templates
if(is_array($templates) && count($templates) > 0){
$theme['templates'] = array();
foreach($templates as $templateId => $tpl){
$theme['templates'][$templateId] = $tpl;
}
}
$array['available'][] = $theme;
}
$this->set($target, $array);
}
} | php | public function registerTheme($id, $name, $path = '', $targets = array(), $templates = array() )
{
if (preg_match('/^[a-zA-Z0-9]*$/', $id) === 0) {
throw new \common_Exception('Invalid id "'.$id.'"');
}
if (!is_array($targets) || count($targets) === 0){
throw new \common_Exception('No targets were provided for theme '.$id);
}
foreach ($targets as $target) {
if(!$this->isRegistered($target)){
throw new \common_Exception('Target '.$target.' does not exist');
} else {
$array = $this->get($target);
foreach ($array['available'] as $theme) {
if ($theme['id'] == $id) {
throw new \common_Exception('Theme '.$id.' already exists for target '.$target);
}
}
$theme = array(
'id' => $id,
'name' => $name
);
//the path is optional
if($path){
$theme['path'] = $path;
}
//register templates
if(is_array($templates) && count($templates) > 0){
$theme['templates'] = array();
foreach($templates as $templateId => $tpl){
$theme['templates'][$templateId] = $tpl;
}
}
$array['available'][] = $theme;
}
$this->set($target, $array);
}
} | [
"public",
"function",
"registerTheme",
"(",
"$",
"id",
",",
"$",
"name",
",",
"$",
"path",
"=",
"''",
",",
"$",
"targets",
"=",
"array",
"(",
")",
",",
"$",
"templates",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/^[a-zA-Z0-9... | Adds a theme to the registry
@author Lionel Lecaque, lionel@taotesting.com
@param string $id
@param string $name
@param string $path
@param array $targets
@throws \common_Exception | [
"Adds",
"a",
"theme",
"to",
"the",
"registry"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/ThemeRegistry.php#L159-L203 |
oat-sa/tao-core | models/classes/ThemeRegistry.php | ThemeRegistry.resolveStylesheetUrl | private function resolveStylesheetUrl($path){
$websource = WebsourceManager::singleton()->getWebsource($this->get(ThemeRegistry::WEBSOURCE));
if(strpos($path , ThemeRegistry::WEBSOURCE) === 0) {
return $websource->getAccessUrl(substr($path, strlen(ThemeRegistry::WEBSOURCE)));
}
else {
$assetService = $this->getServiceManager()->get(AssetService::SERVICE_ID);
return $assetService->getAsset($path);
}
} | php | private function resolveStylesheetUrl($path){
$websource = WebsourceManager::singleton()->getWebsource($this->get(ThemeRegistry::WEBSOURCE));
if(strpos($path , ThemeRegistry::WEBSOURCE) === 0) {
return $websource->getAccessUrl(substr($path, strlen(ThemeRegistry::WEBSOURCE)));
}
else {
$assetService = $this->getServiceManager()->get(AssetService::SERVICE_ID);
return $assetService->getAsset($path);
}
} | [
"private",
"function",
"resolveStylesheetUrl",
"(",
"$",
"path",
")",
"{",
"$",
"websource",
"=",
"WebsourceManager",
"::",
"singleton",
"(",
")",
"->",
"getWebsource",
"(",
"$",
"this",
"->",
"get",
"(",
"ThemeRegistry",
"::",
"WEBSOURCE",
")",
")",
";",
... | Get the resolved absolute URL for a stylesheet
@param string $path
@return string | [
"Get",
"the",
"resolved",
"absolute",
"URL",
"for",
"a",
"stylesheet"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/ThemeRegistry.php#L264-L273 |
oat-sa/tao-core | models/classes/ThemeRegistry.php | ThemeRegistry.getResolvedBase | private function getResolvedBase($target){
$base = null;
$array = $this->get($target);
if(is_string($array['base'])){
$assetService = $this->getServiceManager()->get(AssetService::SERVICE_ID);
$base = $assetService->getAsset($array['base']);
} else if(is_array($array['base'])){
$base = array(
'css' => $this->resolveStylesheetUrl($array['base']['css']),
'templates' => array()
);
foreach($array['base']['templates'] as $id => $path){
$base['templates'][$id] = $this->resolveTemplatePath($path);
}
} else {
throw new common_Exception('invalid type for theme base');
}
return $base;
} | php | private function getResolvedBase($target){
$base = null;
$array = $this->get($target);
if(is_string($array['base'])){
$assetService = $this->getServiceManager()->get(AssetService::SERVICE_ID);
$base = $assetService->getAsset($array['base']);
} else if(is_array($array['base'])){
$base = array(
'css' => $this->resolveStylesheetUrl($array['base']['css']),
'templates' => array()
);
foreach($array['base']['templates'] as $id => $path){
$base['templates'][$id] = $this->resolveTemplatePath($path);
}
} else {
throw new common_Exception('invalid type for theme base');
}
return $base;
} | [
"private",
"function",
"getResolvedBase",
"(",
"$",
"target",
")",
"{",
"$",
"base",
"=",
"null",
";",
"$",
"array",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"target",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"array",
"[",
"'base'",
"]",
")",
... | Resolve the path and url defined in target "base"
@param string $target
@return mixed
@throws common_Exception | [
"Resolve",
"the",
"path",
"and",
"url",
"defined",
"in",
"target",
"base"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/ThemeRegistry.php#L293-L318 |
oat-sa/tao-core | models/classes/ThemeRegistry.php | ThemeRegistry.getAvailableThemes | public function getAvailableThemes()
{
$returnValue = array();
foreach ($this->getMap() as $target => $value) {
//ugly
if($target == ThemeRegistry::WEBSOURCE) {
continue;
}
//retrieve all other value
$returnValue[$target] = $value;
// adapt path for all theme
$returnValue[$target]['available'] = array();
foreach ($value['available'] as $theme) {
$returnValue[$target]['available'][] = $this->updatePath($theme);
}
$returnValue[$target]['base'] = $this->getResolvedBase($target);
}
return $returnValue;
} | php | public function getAvailableThemes()
{
$returnValue = array();
foreach ($this->getMap() as $target => $value) {
//ugly
if($target == ThemeRegistry::WEBSOURCE) {
continue;
}
//retrieve all other value
$returnValue[$target] = $value;
// adapt path for all theme
$returnValue[$target]['available'] = array();
foreach ($value['available'] as $theme) {
$returnValue[$target]['available'][] = $this->updatePath($theme);
}
$returnValue[$target]['base'] = $this->getResolvedBase($target);
}
return $returnValue;
} | [
"public",
"function",
"getAvailableThemes",
"(",
")",
"{",
"$",
"returnValue",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getMap",
"(",
")",
"as",
"$",
"target",
"=>",
"$",
"value",
")",
"{",
"//ugly",
"if",
"(",
"$",
"target",
... | Get list of available theme
The available themes have their URL and paths resolved
@author Lionel Lecaque, lionel@taotesting.com | [
"Get",
"list",
"of",
"available",
"theme",
"The",
"available",
"themes",
"have",
"their",
"URL",
"and",
"paths",
"resolved"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/ThemeRegistry.php#L326-L347 |
oat-sa/tao-core | models/classes/ThemeRegistry.php | ThemeRegistry.getTemplate | public function getTemplate($target, $themeId, $templateId){
$theme = $this->getTheme($target, $themeId);
if(isset($theme['templates']) && isset($theme['templates'][$templateId])){
return $this->resolveTemplatePath($theme['templates'][$templateId]);
}
return null;
} | php | public function getTemplate($target, $themeId, $templateId){
$theme = $this->getTheme($target, $themeId);
if(isset($theme['templates']) && isset($theme['templates'][$templateId])){
return $this->resolveTemplatePath($theme['templates'][$templateId]);
}
return null;
} | [
"public",
"function",
"getTemplate",
"(",
"$",
"target",
",",
"$",
"themeId",
",",
"$",
"templateId",
")",
"{",
"$",
"theme",
"=",
"$",
"this",
"->",
"getTheme",
"(",
"$",
"target",
",",
"$",
"themeId",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"them... | Get the absolute path to a theme template
@deprecated use theme\ThemeService instead
@param string $target
@param string $themeId
@param string $templateId
@return string | [
"Get",
"the",
"absolute",
"path",
"to",
"a",
"theme",
"template"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/ThemeRegistry.php#L358-L364 |
oat-sa/tao-core | models/classes/ThemeRegistry.php | ThemeRegistry.getStylesheet | public function getStylesheet($target, $themeId){
$theme = $this->getTheme($target, $themeId);
if(isset($theme['path'])){
return $this->resolveStylesheetUrl($theme['path']);
}
return null;//not found
} | php | public function getStylesheet($target, $themeId){
$theme = $this->getTheme($target, $themeId);
if(isset($theme['path'])){
return $this->resolveStylesheetUrl($theme['path']);
}
return null;//not found
} | [
"public",
"function",
"getStylesheet",
"(",
"$",
"target",
",",
"$",
"themeId",
")",
"{",
"$",
"theme",
"=",
"$",
"this",
"->",
"getTheme",
"(",
"$",
"target",
",",
"$",
"themeId",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"theme",
"[",
"'path'",
"]"... | Get the abosolute url to a stylesheet
@deprecated use theme\ThemeService instead
@param string $target
@param string $themeId
@return string | [
"Get",
"the",
"abosolute",
"url",
"to",
"a",
"stylesheet"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/ThemeRegistry.php#L374-L380 |
oat-sa/tao-core | models/classes/ThemeRegistry.php | ThemeRegistry.getBaseTemplate | public function getBaseTemplate($target, $templateId){
$base = $this->getResolvedBase($target);
if(is_array($base) && isset($base['templates']) && isset($base['templates'][$templateId])){
return $base['templates'][$templateId];
}
return null;
} | php | public function getBaseTemplate($target, $templateId){
$base = $this->getResolvedBase($target);
if(is_array($base) && isset($base['templates']) && isset($base['templates'][$templateId])){
return $base['templates'][$templateId];
}
return null;
} | [
"public",
"function",
"getBaseTemplate",
"(",
"$",
"target",
",",
"$",
"templateId",
")",
"{",
"$",
"base",
"=",
"$",
"this",
"->",
"getResolvedBase",
"(",
"$",
"target",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"base",
")",
"&&",
"isset",
"(",
"$"... | Get the asbolute path to the base template
@deprecated use theme\ThemeService instead
@param string $target
@param string $templateId
@return string | [
"Get",
"the",
"asbolute",
"path",
"to",
"the",
"base",
"template"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/ThemeRegistry.php#L390-L396 |
oat-sa/tao-core | models/classes/ThemeRegistry.php | ThemeRegistry.getBaseStylesheet | public function getBaseStylesheet($target){
$base = $this->getResolvedBase($target);
if(is_string($base)){
return $base;
}else if(is_array($base) && isset($base['css'])){
return $base['css'];
}
return null;
} | php | public function getBaseStylesheet($target){
$base = $this->getResolvedBase($target);
if(is_string($base)){
return $base;
}else if(is_array($base) && isset($base['css'])){
return $base['css'];
}
return null;
} | [
"public",
"function",
"getBaseStylesheet",
"(",
"$",
"target",
")",
"{",
"$",
"base",
"=",
"$",
"this",
"->",
"getResolvedBase",
"(",
"$",
"target",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"base",
")",
")",
"{",
"return",
"$",
"base",
";",
"}",
... | Get the absolute url to the base css
@deprecated use theme\ThemeService instead
@param string $target
@return string | [
"Get",
"the",
"absolute",
"url",
"to",
"the",
"base",
"css"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/ThemeRegistry.php#L405-L413 |
oat-sa/tao-core | actions/class.Roles.php | tao_actions_Roles.editRole | public function editRole()
{
$this->defaultData();
$clazz = $this->getCurrentClass();
$role = $this->getCurrentInstance();
$formContainer = new tao_actions_form_Role($clazz, $role);
$myForm = $formContainer->getForm();
if($myForm->isSubmited()){
if($myForm->isValid()){
$formValues = $myForm->getValues();
$roleService = tao_models_classes_RoleService::singleton();
$includedRolesProperty = $this->getProperty(GenerisRdf::PROPERTY_ROLE_INCLUDESROLE);
// We have to make the difference between the old list
// of included roles and the new ones.
$oldIncludedRolesUris = $role->getPropertyValues($includedRolesProperty);
$newIncludedRolesUris = $formValues[GenerisRdf::PROPERTY_ROLE_INCLUDESROLE];
$removeIncludedRolesUris = array_diff($oldIncludedRolesUris, $newIncludedRolesUris);
$addIncludedRolesUris = array_diff($newIncludedRolesUris, $oldIncludedRolesUris);
// Make the changes according to the detected differences.
foreach ($removeIncludedRolesUris as $rU){
$r = $this->getResource($rU);
$roleService->unincludeRole($role, $r);
}
foreach ($addIncludedRolesUris as $aU){
$r = $this->getResource($aU);
$roleService->includeRole($role, $r);
}
// Let's deal with other properties the usual way.
unset($formValues[$includedRolesProperty->getUri()]);
$binder = new tao_models_classes_dataBinding_GenerisFormDataBinder($role);
$role = $binder->bind($myForm->getValues());
core_kernel_users_Cache::removeIncludedRoles($role); // flush cache for this role.
$this->setData('selectNode', tao_helpers_Uri::encode($role->getUri()));
$this->setData('message', __('Role saved'));
$this->setData('reload', true);
}
}
$this->setData('uri', tao_helpers_Uri::encode($role->getUri()));
$this->setData('classUri', tao_helpers_Uri::encode($clazz->getUri()));
$this->setData('formTitle', 'Edit Role');
$this->setData('myForm', $myForm->render());
$this->setView('roles/form.tpl');
} | php | public function editRole()
{
$this->defaultData();
$clazz = $this->getCurrentClass();
$role = $this->getCurrentInstance();
$formContainer = new tao_actions_form_Role($clazz, $role);
$myForm = $formContainer->getForm();
if($myForm->isSubmited()){
if($myForm->isValid()){
$formValues = $myForm->getValues();
$roleService = tao_models_classes_RoleService::singleton();
$includedRolesProperty = $this->getProperty(GenerisRdf::PROPERTY_ROLE_INCLUDESROLE);
// We have to make the difference between the old list
// of included roles and the new ones.
$oldIncludedRolesUris = $role->getPropertyValues($includedRolesProperty);
$newIncludedRolesUris = $formValues[GenerisRdf::PROPERTY_ROLE_INCLUDESROLE];
$removeIncludedRolesUris = array_diff($oldIncludedRolesUris, $newIncludedRolesUris);
$addIncludedRolesUris = array_diff($newIncludedRolesUris, $oldIncludedRolesUris);
// Make the changes according to the detected differences.
foreach ($removeIncludedRolesUris as $rU){
$r = $this->getResource($rU);
$roleService->unincludeRole($role, $r);
}
foreach ($addIncludedRolesUris as $aU){
$r = $this->getResource($aU);
$roleService->includeRole($role, $r);
}
// Let's deal with other properties the usual way.
unset($formValues[$includedRolesProperty->getUri()]);
$binder = new tao_models_classes_dataBinding_GenerisFormDataBinder($role);
$role = $binder->bind($myForm->getValues());
core_kernel_users_Cache::removeIncludedRoles($role); // flush cache for this role.
$this->setData('selectNode', tao_helpers_Uri::encode($role->getUri()));
$this->setData('message', __('Role saved'));
$this->setData('reload', true);
}
}
$this->setData('uri', tao_helpers_Uri::encode($role->getUri()));
$this->setData('classUri', tao_helpers_Uri::encode($clazz->getUri()));
$this->setData('formTitle', 'Edit Role');
$this->setData('myForm', $myForm->render());
$this->setView('roles/form.tpl');
} | [
"public",
"function",
"editRole",
"(",
")",
"{",
"$",
"this",
"->",
"defaultData",
"(",
")",
";",
"$",
"clazz",
"=",
"$",
"this",
"->",
"getCurrentClass",
"(",
")",
";",
"$",
"role",
"=",
"$",
"this",
"->",
"getCurrentInstance",
"(",
")",
";",
"$",
... | Edit a group instance
@return void | [
"Edit",
"a",
"group",
"instance"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.Roles.php#L61-L114 |
oat-sa/tao-core | actions/class.Roles.php | tao_actions_Roles.delete | public function delete()
{
if (!$this->isXmlHttpRequest()) {
throw new common_exception_BadRequest('wrong request mode');
} else {
$deleted = false;
if($this->getRequestParameter('uri')){
$role = $this->getCurrentInstance();
if(!in_array($role->getUri(), $this->forbidden)){
//check if no user is using this role:
$userClass = $this->getClass(GenerisRdf::CLASS_GENERIS_USER);
$options = array('recursive' => true, 'like' => false);
$filters = array(GenerisRdf::PROPERTY_USER_ROLES => $role->getUri());
$users = $userClass->searchInstances($filters, $options);
if(empty($users)){
//delete role here:
$deleted = $this->getClassService()->removeRole($role);
}else{
//set message error
throw new UserErrorException(__('This role is still given to one or more users. Please remove the role to these users first.'));
}
}else{
throw new UserErrorException($role->getLabel() . ' could not be deleted');
}
}
$this->returnJson(array('deleted' => $deleted));
}
} | php | public function delete()
{
if (!$this->isXmlHttpRequest()) {
throw new common_exception_BadRequest('wrong request mode');
} else {
$deleted = false;
if($this->getRequestParameter('uri')){
$role = $this->getCurrentInstance();
if(!in_array($role->getUri(), $this->forbidden)){
//check if no user is using this role:
$userClass = $this->getClass(GenerisRdf::CLASS_GENERIS_USER);
$options = array('recursive' => true, 'like' => false);
$filters = array(GenerisRdf::PROPERTY_USER_ROLES => $role->getUri());
$users = $userClass->searchInstances($filters, $options);
if(empty($users)){
//delete role here:
$deleted = $this->getClassService()->removeRole($role);
}else{
//set message error
throw new UserErrorException(__('This role is still given to one or more users. Please remove the role to these users first.'));
}
}else{
throw new UserErrorException($role->getLabel() . ' could not be deleted');
}
}
$this->returnJson(array('deleted' => $deleted));
}
} | [
"public",
"function",
"delete",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isXmlHttpRequest",
"(",
")",
")",
"{",
"throw",
"new",
"common_exception_BadRequest",
"(",
"'wrong request mode'",
")",
";",
"}",
"else",
"{",
"$",
"deleted",
"=",
"false",
... | Delete a group or a group class
@throws UserErrorException
@throws common_exception_BadRequest
@throws common_exception_Error
@throws common_exception_MissingParameter
@return void | [
"Delete",
"a",
"group",
"or",
"a",
"group",
"class"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.Roles.php#L137-L167 |
oat-sa/tao-core | actions/form/class.List.php | tao_actions_form_List.initElements | public function initElements()
{
$labelElt = tao_helpers_form_FormFactory::getElement('label', 'Textbox');
$labelElt->setDescription(__('Name'));
$labelElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty'));
$this->form->addElement($labelElt);
$sizeElt = tao_helpers_form_FormFactory::getElement('size', 'Textbox');
$sizeElt->setDescription(__('Number of elements'));
$sizeElt->setAttribute('size', '4');
$sizeElt->setValue(1);
$sizeElt->addValidators(array(
tao_helpers_form_FormFactory::getValidator('NotEmpty'),
tao_helpers_form_FormFactory::getValidator('Integer', array('min' => 1))
));
$this->form->addElement($sizeElt);
} | php | public function initElements()
{
$labelElt = tao_helpers_form_FormFactory::getElement('label', 'Textbox');
$labelElt->setDescription(__('Name'));
$labelElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty'));
$this->form->addElement($labelElt);
$sizeElt = tao_helpers_form_FormFactory::getElement('size', 'Textbox');
$sizeElt->setDescription(__('Number of elements'));
$sizeElt->setAttribute('size', '4');
$sizeElt->setValue(1);
$sizeElt->addValidators(array(
tao_helpers_form_FormFactory::getValidator('NotEmpty'),
tao_helpers_form_FormFactory::getValidator('Integer', array('min' => 1))
));
$this->form->addElement($sizeElt);
} | [
"public",
"function",
"initElements",
"(",
")",
"{",
"$",
"labelElt",
"=",
"tao_helpers_form_FormFactory",
"::",
"getElement",
"(",
"'label'",
",",
"'Textbox'",
")",
";",
"$",
"labelElt",
"->",
"setDescription",
"(",
"__",
"(",
"'Name'",
")",
")",
";",
"$",
... | Short description of method initElements
@access public
@author Bertrand Chevrier, <bertrand.chevrier@tudor.lu>
@return mixed | [
"Short",
"description",
"of",
"method",
"initElements"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/form/class.List.php#L69-L87 |
oat-sa/tao-core | models/classes/routing/Resolver.php | Resolver.getControllerShortName | public function getControllerShortName()
{
$relativeUrl = $this->request->getUri()->getPath();
$rootUrl = parse_url(ROOT_URL);
if (isset($rootUrl['path'])) {
$rootUrlPath = $rootUrl['path'];
$relativeUrl = str_replace(rtrim($rootUrlPath, '/'), '', $relativeUrl);
}
$parts = explode('/', trim($relativeUrl, '/'));
if(count($parts) === 3){
return $parts[1];
}
return null;
} | php | public function getControllerShortName()
{
$relativeUrl = $this->request->getUri()->getPath();
$rootUrl = parse_url(ROOT_URL);
if (isset($rootUrl['path'])) {
$rootUrlPath = $rootUrl['path'];
$relativeUrl = str_replace(rtrim($rootUrlPath, '/'), '', $relativeUrl);
}
$parts = explode('/', trim($relativeUrl, '/'));
if(count($parts) === 3){
return $parts[1];
}
return null;
} | [
"public",
"function",
"getControllerShortName",
"(",
")",
"{",
"$",
"relativeUrl",
"=",
"$",
"this",
"->",
"request",
"->",
"getUri",
"(",
")",
"->",
"getPath",
"(",
")",
";",
"$",
"rootUrl",
"=",
"parse_url",
"(",
"ROOT_URL",
")",
";",
"if",
"(",
"iss... | Get the controller short name as used into the URL
@return string the name
@throws \ResolverException | [
"Get",
"the",
"controller",
"short",
"name",
"as",
"used",
"into",
"the",
"URL"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/routing/Resolver.php#L142-L158 |
oat-sa/tao-core | models/classes/routing/Resolver.php | Resolver.resolve | protected function resolve()
{
$extensionsManager = $this->getServiceLocator()->get(\common_ext_ExtensionsManager::SERVICE_ID);
$installed = $extensionsManager->getInstalledExtensionsIds();
foreach ($installed as $extId) {
$extension = $extensionsManager->getExtensionById($extId);
foreach ($this->getRoutes($extension) as $entry) {
/** @var Route $route */
$route = $entry['route'];
$called = $route->resolve($this->getRequest());
if ($called !== null) {
list($controller, $action) = explode('@', $called);
$this->controller = $controller;
$this->action = $action;
$this->extensionId = $entry['extId'];
return true;
}
}
}
throw new \ResolverException('Unable to resolve '.$this->request->getUri()->getPath());
} | php | protected function resolve()
{
$extensionsManager = $this->getServiceLocator()->get(\common_ext_ExtensionsManager::SERVICE_ID);
$installed = $extensionsManager->getInstalledExtensionsIds();
foreach ($installed as $extId) {
$extension = $extensionsManager->getExtensionById($extId);
foreach ($this->getRoutes($extension) as $entry) {
/** @var Route $route */
$route = $entry['route'];
$called = $route->resolve($this->getRequest());
if ($called !== null) {
list($controller, $action) = explode('@', $called);
$this->controller = $controller;
$this->action = $action;
$this->extensionId = $entry['extId'];
return true;
}
}
}
throw new \ResolverException('Unable to resolve '.$this->request->getUri()->getPath());
} | [
"protected",
"function",
"resolve",
"(",
")",
"{",
"$",
"extensionsManager",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"\\",
"common_ext_ExtensionsManager",
"::",
"SERVICE_ID",
")",
";",
"$",
"installed",
"=",
"$",
"extensionsMan... | Tries to resolve the current request using the routes first
and then falls back to the legacy controllers
@return bool
@throws \ResolverException
@throws \common_exception_InconsistentData
@throws \common_ext_ManifestNotFoundException | [
"Tries",
"to",
"resolve",
"the",
"current",
"request",
"using",
"the",
"routes",
"first",
"and",
"then",
"falls",
"back",
"to",
"the",
"legacy",
"controllers"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/routing/Resolver.php#L168-L190 |
oat-sa/tao-core | helpers/form/elements/template/class.Template.php | tao_helpers_form_elements_template_Template.feed | public function feed()
{
$values = array();
$prefix = preg_quote($this->getPrefix(), '/');
foreach($_POST as $key => $value){
if(preg_match("/^$prefix/", $key)){
$values[str_replace($this->getPrefix(), '', $key)] = $value;
}
}
$this->setValues($values);
} | php | public function feed()
{
$values = array();
$prefix = preg_quote($this->getPrefix(), '/');
foreach($_POST as $key => $value){
if(preg_match("/^$prefix/", $key)){
$values[str_replace($this->getPrefix(), '', $key)] = $value;
}
}
$this->setValues($values);
} | [
"public",
"function",
"feed",
"(",
")",
"{",
"$",
"values",
"=",
"array",
"(",
")",
";",
"$",
"prefix",
"=",
"preg_quote",
"(",
"$",
"this",
"->",
"getPrefix",
"(",
")",
",",
"'/'",
")",
";",
"foreach",
"(",
"$",
"_POST",
"as",
"$",
"key",
"=>",
... | Short description of method feed
@access public
@author Joel Bout, <joel.bout@tudor.lu>
@return mixed | [
"Short",
"description",
"of",
"method",
"feed"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/elements/template/class.Template.php#L47-L59 |
oat-sa/tao-core | helpers/form/elements/template/class.Template.php | tao_helpers_form_elements_template_Template.render | public function render()
{
$returnValue = (string) '';
if(file_exists($this->path) && is_readable($this->path)){
extract($this->variables);
ob_start();
common_Logger::i('including \''.$this->path.'\' into form', array('TAO'));
include $this->path;
$returnValue = ob_get_contents();
ob_end_clean();
//clean the extracted variables
foreach($this->variables as $key => $name){
unset($$key);
}
}
return (string) $returnValue;
} | php | public function render()
{
$returnValue = (string) '';
if(file_exists($this->path) && is_readable($this->path)){
extract($this->variables);
ob_start();
common_Logger::i('including \''.$this->path.'\' into form', array('TAO'));
include $this->path;
$returnValue = ob_get_contents();
ob_end_clean();
//clean the extracted variables
foreach($this->variables as $key => $name){
unset($$key);
}
}
return (string) $returnValue;
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"returnValue",
"=",
"(",
"string",
")",
"''",
";",
"if",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"path",
")",
"&&",
"is_readable",
"(",
"$",
"this",
"->",
"path",
")",
")",
"{",
"extract",
"("... | Short description of method render
@access public
@author Joel Bout, <joel.bout@tudor.lu>
@return string | [
"Short",
"description",
"of",
"method",
"render"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/elements/template/class.Template.php#L68-L98 |
oat-sa/tao-core | models/classes/menu/MenuService.php | MenuService.getStructuresFilePath | public static function getStructuresFilePath($extensionId)
{
$extension = \common_ext_ExtensionsManager::singleton()->getExtensionById($extensionId);
$extra = $extension->getManifest()->getExtra();
if (isset($extra['structures'])) {
$structureFilePath = $extra['structures'];
} else {
$structureFilePath = $extension->getDir().'actions/structures.xml';
}
if(file_exists($structureFilePath)){
return $structureFilePath;
} else {
return null;
}
} | php | public static function getStructuresFilePath($extensionId)
{
$extension = \common_ext_ExtensionsManager::singleton()->getExtensionById($extensionId);
$extra = $extension->getManifest()->getExtra();
if (isset($extra['structures'])) {
$structureFilePath = $extra['structures'];
} else {
$structureFilePath = $extension->getDir().'actions/structures.xml';
}
if(file_exists($structureFilePath)){
return $structureFilePath;
} else {
return null;
}
} | [
"public",
"static",
"function",
"getStructuresFilePath",
"(",
"$",
"extensionId",
")",
"{",
"$",
"extension",
"=",
"\\",
"common_ext_ExtensionsManager",
"::",
"singleton",
"(",
")",
"->",
"getExtensionById",
"(",
"$",
"extensionId",
")",
";",
"$",
"extra",
"=",
... | Load the extension structure file.
Return the SimpleXmlElement object (don't forget to cast it)
@access protected
@author Jerome Bogaerts, <jerome@taotesting.com>
@param string extensionId
@return SimpleXMLElement | [
"Load",
"the",
"extension",
"structure",
"file",
".",
"Return",
"the",
"SimpleXmlElement",
"object",
"(",
"don",
"t",
"forget",
"to",
"cast",
"it",
")"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/menu/MenuService.php#L62-L77 |
oat-sa/tao-core | models/classes/menu/MenuService.php | MenuService.getPerspectivesByGroup | public static function getPerspectivesByGroup($groupId) {
$perspectives = array();
foreach(self::getAllPerspectives() as $perspective) {
if($perspective -> getGroup() === $groupId) {
$perspectives[] = $perspective;
}
}
return $perspectives;
} | php | public static function getPerspectivesByGroup($groupId) {
$perspectives = array();
foreach(self::getAllPerspectives() as $perspective) {
if($perspective -> getGroup() === $groupId) {
$perspectives[] = $perspective;
}
}
return $perspectives;
} | [
"public",
"static",
"function",
"getPerspectivesByGroup",
"(",
"$",
"groupId",
")",
"{",
"$",
"perspectives",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"self",
"::",
"getAllPerspectives",
"(",
")",
"as",
"$",
"perspective",
")",
"{",
"if",
"(",
"$",
"... | Get the structure content (from the structure.xml file) of each extension filtered by group.
@param $groupId
@return array | [
"Get",
"the",
"structure",
"content",
"(",
"from",
"the",
"structure",
".",
"xml",
"file",
")",
"of",
"each",
"extension",
"filtered",
"by",
"group",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/menu/MenuService.php#L84-L92 |
oat-sa/tao-core | models/classes/menu/MenuService.php | MenuService.readStructure | public static function readStructure()
{
if(count(self::$structure) == 0 ){
if(self::USE_CACHE == false){
//rebuild structure each time
self::$structure = self::buildStructures();
} else {
//cache management
try {
self::$structure = \common_cache_FileCache::singleton()->get(self::CACHE_KEY);
} catch (\common_cache_NotFoundException $e) {
self::$structure = self::buildStructures();
\common_cache_FileCache::singleton()->put(self::$structure, self::CACHE_KEY);
}
}
}
return self::$structure;
} | php | public static function readStructure()
{
if(count(self::$structure) == 0 ){
if(self::USE_CACHE == false){
//rebuild structure each time
self::$structure = self::buildStructures();
} else {
//cache management
try {
self::$structure = \common_cache_FileCache::singleton()->get(self::CACHE_KEY);
} catch (\common_cache_NotFoundException $e) {
self::$structure = self::buildStructures();
\common_cache_FileCache::singleton()->put(self::$structure, self::CACHE_KEY);
}
}
}
return self::$structure;
} | [
"public",
"static",
"function",
"readStructure",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"self",
"::",
"$",
"structure",
")",
"==",
"0",
")",
"{",
"if",
"(",
"self",
"::",
"USE_CACHE",
"==",
"false",
")",
"{",
"//rebuild structure each time",
"self",
"::... | Reads the structure data.
This method manages to cache the structure if needed.
@return array() the structure data | [
"Reads",
"the",
"structure",
"data",
".",
"This",
"method",
"manages",
"to",
"cache",
"the",
"structure",
"if",
"needed",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/menu/MenuService.php#L108-L127 |
oat-sa/tao-core | models/classes/menu/MenuService.php | MenuService.buildStructures | protected static function buildStructures()
{
$perspectives = array();
$toAdd = array();
$sorted = \helpers_ExtensionHelper::sortByDependencies(\common_ext_ExtensionsManager::singleton()->getEnabledExtensions());
foreach(array_keys($sorted) as $extId){
$file = self::getStructuresFilePath($extId);
if(!is_null($file)){
$xmlStructures = new \SimpleXMLElement($file, null, true);
$extStructures = $xmlStructures->xpath("/structures/structure");
foreach($extStructures as $xmlStructure){
$perspective = Perspective::fromSimpleXMLElement($xmlStructure, $extId);
if (!isset($perspectives[$perspective->getId()])) {
$perspectives[$perspective->getId()] = $perspective;
} else {
foreach ($perspective->getChildren() as $section) {
$perspectives[$perspective->getId()]->addSection($section);
}
}
}
foreach($xmlStructures->xpath("/structures/toolbar/toolbaraction") as $xmlStructure){
$perspective = Perspective::fromLegacyToolbarAction($xmlStructure, $extId);
$perspectives[$perspective->getId()] = $perspective;
if (isset($xmlStructure['structure'])) {
$toAdd[$perspective->getId()] = (string)$xmlStructure['structure'];
}
}
}
}
foreach ($toAdd as $to => $from) {
if (isset($perspectives[$from]) && isset($perspectives[$to])) {
foreach($perspectives[$from]->getChildren() as $section) {
$perspectives[$to]->addSection($section);
}
}
}
usort($perspectives, function ($a, $b) {
return $a->getLevel() - $b->getLevel();
});
return array(
'perspectives' => $perspectives
);
} | php | protected static function buildStructures()
{
$perspectives = array();
$toAdd = array();
$sorted = \helpers_ExtensionHelper::sortByDependencies(\common_ext_ExtensionsManager::singleton()->getEnabledExtensions());
foreach(array_keys($sorted) as $extId){
$file = self::getStructuresFilePath($extId);
if(!is_null($file)){
$xmlStructures = new \SimpleXMLElement($file, null, true);
$extStructures = $xmlStructures->xpath("/structures/structure");
foreach($extStructures as $xmlStructure){
$perspective = Perspective::fromSimpleXMLElement($xmlStructure, $extId);
if (!isset($perspectives[$perspective->getId()])) {
$perspectives[$perspective->getId()] = $perspective;
} else {
foreach ($perspective->getChildren() as $section) {
$perspectives[$perspective->getId()]->addSection($section);
}
}
}
foreach($xmlStructures->xpath("/structures/toolbar/toolbaraction") as $xmlStructure){
$perspective = Perspective::fromLegacyToolbarAction($xmlStructure, $extId);
$perspectives[$perspective->getId()] = $perspective;
if (isset($xmlStructure['structure'])) {
$toAdd[$perspective->getId()] = (string)$xmlStructure['structure'];
}
}
}
}
foreach ($toAdd as $to => $from) {
if (isset($perspectives[$from]) && isset($perspectives[$to])) {
foreach($perspectives[$from]->getChildren() as $section) {
$perspectives[$to]->addSection($section);
}
}
}
usort($perspectives, function ($a, $b) {
return $a->getLevel() - $b->getLevel();
});
return array(
'perspectives' => $perspectives
);
} | [
"protected",
"static",
"function",
"buildStructures",
"(",
")",
"{",
"$",
"perspectives",
"=",
"array",
"(",
")",
";",
"$",
"toAdd",
"=",
"array",
"(",
")",
";",
"$",
"sorted",
"=",
"\\",
"helpers_ExtensionHelper",
"::",
"sortByDependencies",
"(",
"\\",
"c... | Get the structure content (from the structure.xml file) of each extension.
@return array | [
"Get",
"the",
"structure",
"content",
"(",
"from",
"the",
"structure",
".",
"xml",
"file",
")",
"of",
"each",
"extension",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/menu/MenuService.php#L133-L178 |
oat-sa/tao-core | models/classes/menu/MenuService.php | MenuService.getPerspective | public static function getPerspective($extension, $perspectiveId)
{
$returnValue = null;
foreach(self::getAllPerspectives() as $perspective){
if ($perspective->getId() == $perspectiveId) {
$returnValue = $perspective;
break;
}
}
if (empty($returnValue)) {
\common_logger::w('Structure '.$perspectiveId.' not found for extension '.$extension);
}
return $returnValue;
} | php | public static function getPerspective($extension, $perspectiveId)
{
$returnValue = null;
foreach(self::getAllPerspectives() as $perspective){
if ($perspective->getId() == $perspectiveId) {
$returnValue = $perspective;
break;
}
}
if (empty($returnValue)) {
\common_logger::w('Structure '.$perspectiveId.' not found for extension '.$extension);
}
return $returnValue;
} | [
"public",
"static",
"function",
"getPerspective",
"(",
"$",
"extension",
",",
"$",
"perspectiveId",
")",
"{",
"$",
"returnValue",
"=",
"null",
";",
"foreach",
"(",
"self",
"::",
"getAllPerspectives",
"(",
")",
"as",
"$",
"perspective",
")",
"{",
"if",
"(",... | Get the perspective for the extension/section in parameters
or null if not found
@access public
@author Jerome Bogaerts, <jerome@taotesting.com>
@param string extension
@param string perspectiveId
@return Structure | [
"Get",
"the",
"perspective",
"for",
"the",
"extension",
"/",
"section",
"in",
"parameters",
"or",
"null",
"if",
"not",
"found"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/menu/MenuService.php#L190-L205 |
oat-sa/tao-core | models/classes/menu/MenuService.php | MenuService.getSection | public static function getSection($extension, $perspectiveId, $sectionId)
{
$returnValue = null;
$structure = self::getPerspective($extension, $perspectiveId);
foreach ($structure->getChildren() as $section) {
if ($section->getId() == $sectionId) {
$returnValue = $section;
break;
}
}
if (empty($returnValue)) {
\common_logger::w('Section '.$sectionId.' not found found for perspective '.$perspectiveId);
}
return $returnValue;
} | php | public static function getSection($extension, $perspectiveId, $sectionId)
{
$returnValue = null;
$structure = self::getPerspective($extension, $perspectiveId);
foreach ($structure->getChildren() as $section) {
if ($section->getId() == $sectionId) {
$returnValue = $section;
break;
}
}
if (empty($returnValue)) {
\common_logger::w('Section '.$sectionId.' not found found for perspective '.$perspectiveId);
}
return $returnValue;
} | [
"public",
"static",
"function",
"getSection",
"(",
"$",
"extension",
",",
"$",
"perspectiveId",
",",
"$",
"sectionId",
")",
"{",
"$",
"returnValue",
"=",
"null",
";",
"$",
"structure",
"=",
"self",
"::",
"getPerspective",
"(",
"$",
"extension",
",",
"$",
... | Short description of method getSection
@access public
@author Jerome Bogaerts, <jerome@taotesting.com>
@param string extension
@param string perspectiveId
@param string sectionId
@return Section | [
"Short",
"description",
"of",
"method",
"getSection"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/menu/MenuService.php#L217-L233 |
oat-sa/tao-core | actions/form/class.Login.php | tao_actions_form_Login.initForm | public function initForm()
{
$this->form = tao_helpers_form_FormFactory::getForm('loginForm');
$connectElt = tao_helpers_form_FormFactory::getElement('connect', 'Submit');
$connectElt->setValue(__('Log in'));
$connectElt->setAttributes(array('disabled' => 'disabled'));
$connectElt->addClass('disabled');
$this->form->setActions(array($connectElt), 'bottom');
} | php | public function initForm()
{
$this->form = tao_helpers_form_FormFactory::getForm('loginForm');
$connectElt = tao_helpers_form_FormFactory::getElement('connect', 'Submit');
$connectElt->setValue(__('Log in'));
$connectElt->setAttributes(array('disabled' => 'disabled'));
$connectElt->addClass('disabled');
$this->form->setActions(array($connectElt), 'bottom');
} | [
"public",
"function",
"initForm",
"(",
")",
"{",
"$",
"this",
"->",
"form",
"=",
"tao_helpers_form_FormFactory",
"::",
"getForm",
"(",
"'loginForm'",
")",
";",
"$",
"connectElt",
"=",
"tao_helpers_form_FormFactory",
"::",
"getElement",
"(",
"'connect'",
",",
"'S... | Short description of method initForm
@access public
@author Bertrand Chevrier, <bertrand.chevrier@tudor.lu>
@return mixed | [
"Short",
"description",
"of",
"method",
"initForm"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/form/class.Login.php#L49-L58 |
oat-sa/tao-core | actions/form/class.Login.php | tao_actions_form_Login.initElements | public function initElements()
{
if (isset($this->data['redirect']) && !empty($this->data['redirect'])) {
$hiddenElt = tao_helpers_form_FormFactory::getElement('redirect', 'Hidden');
$hiddenElt->setValue($this->data['redirect']);
$this->form->addElement($hiddenElt);
}
$loginElt = tao_helpers_form_FormFactory::getElement('login', 'Textbox');
$loginElt->setDescription(Layout::getLoginLabel());
$loginElt->setAttributes(array('autofocus' => 'autofocus'));
$loginElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty'));
$this->form->addElement($loginElt);
$passwordWidgetId = (isset($this->data['enablePasswordReveal']) && !empty($this->data['enablePasswordReveal']))
? 'ViewableHiddenbox'
: 'Hiddenbox';
$passElt = tao_helpers_form_FormFactory::getElement('password', $passwordWidgetId);
$passElt->setDescription(Layout::getPasswordLabel());
$passElt->addValidator(
tao_helpers_form_FormFactory::getValidator('NotEmpty')
);
$this->form->addElement($passElt);
if (isset($this->data['disableAutocomplete']) && !empty($this->data['disableAutocomplete'])) {
$loginElt->setAttributes(array('autofocus' => 'autofocus', 'autocomplete' => 'off'));
$passElt->setAttributes(array('autocomplete' => 'off'));
}
} | php | public function initElements()
{
if (isset($this->data['redirect']) && !empty($this->data['redirect'])) {
$hiddenElt = tao_helpers_form_FormFactory::getElement('redirect', 'Hidden');
$hiddenElt->setValue($this->data['redirect']);
$this->form->addElement($hiddenElt);
}
$loginElt = tao_helpers_form_FormFactory::getElement('login', 'Textbox');
$loginElt->setDescription(Layout::getLoginLabel());
$loginElt->setAttributes(array('autofocus' => 'autofocus'));
$loginElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty'));
$this->form->addElement($loginElt);
$passwordWidgetId = (isset($this->data['enablePasswordReveal']) && !empty($this->data['enablePasswordReveal']))
? 'ViewableHiddenbox'
: 'Hiddenbox';
$passElt = tao_helpers_form_FormFactory::getElement('password', $passwordWidgetId);
$passElt->setDescription(Layout::getPasswordLabel());
$passElt->addValidator(
tao_helpers_form_FormFactory::getValidator('NotEmpty')
);
$this->form->addElement($passElt);
if (isset($this->data['disableAutocomplete']) && !empty($this->data['disableAutocomplete'])) {
$loginElt->setAttributes(array('autofocus' => 'autofocus', 'autocomplete' => 'off'));
$passElt->setAttributes(array('autocomplete' => 'off'));
}
} | [
"public",
"function",
"initElements",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"'redirect'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"data",
"[",
"'redirect'",
"]",
")",
")",
"{",
"$",
"hiddenElt",
"=",
... | Short description of method initElements
@access public
@author Bertrand Chevrier, <bertrand.chevrier@tudor.lu>
@return mixed | [
"Short",
"description",
"of",
"method",
"initElements"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/form/class.Login.php#L67-L94 |
oat-sa/tao-core | helpers/data/class.GenerisAdapterCsv.php | tao_helpers_data_GenerisAdapterCsv.load | public function load($csvFile)
{
$returnValue = null;
$csv = new tao_helpers_data_CsvFile($this->options);
$csv->load($csvFile);
$this->loadedFile = $csv;
$returnValue = $this->loadedFile;
return $returnValue;
} | php | public function load($csvFile)
{
$returnValue = null;
$csv = new tao_helpers_data_CsvFile($this->options);
$csv->load($csvFile);
$this->loadedFile = $csv;
$returnValue = $this->loadedFile;
return $returnValue;
} | [
"public",
"function",
"load",
"(",
"$",
"csvFile",
")",
"{",
"$",
"returnValue",
"=",
"null",
";",
"$",
"csv",
"=",
"new",
"tao_helpers_data_CsvFile",
"(",
"$",
"this",
"->",
"options",
")",
";",
"$",
"csv",
"->",
"load",
"(",
"$",
"csvFile",
")",
";... | enable you to load the data in the csvFile to an associative array
the options
@access public
@author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
@param string $csvFile
@return tao_helpers_data_CsvFile | [
"enable",
"you",
"to",
"load",
"the",
"data",
"in",
"the",
"csvFile",
"to",
"an",
"associative",
"array",
"the",
"options"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/data/class.GenerisAdapterCsv.php#L102-L112 |
oat-sa/tao-core | helpers/data/class.GenerisAdapterCsv.php | tao_helpers_data_GenerisAdapterCsv.import | public function import($source, core_kernel_classes_Class $destination = null)
{
if (!isset($this->options['map'])) {
throw new BadFunctionCallException("import map not set");
}
if (is_null($destination)) {
throw new InvalidArgumentException("${destination} must be a valid core_kernel_classes_Class");
}
/** @var UploadService $uploadService */
$uploadService = ServiceManager::getServiceManager()->get(UploadService::SERVICE_ID);
if (!$source instanceof File) {
$file = $uploadService->getUploadedFlyFile($source);
} else {
$file = $source;
}
if (@preg_match('//u', $file->read()) === false) {
return new \common_report_Report(\common_report_Report::TYPE_ERROR, __("The imported file is not properly UTF-8 encoded."));
}
$csvData = $this->load($file);
$createdResources = 0;
$toImport = $csvData->count();
$report = new common_report_Report(common_report_Report::TYPE_ERROR, __('Data not imported. All records are invalid.'));
for ($rowIterator = 0; $rowIterator < $csvData->count(); $rowIterator++) {
helpers_TimeOutHelper::setTimeOutLimit(helpers_TimeOutHelper::SHORT);
common_Logger::d("CSV - Importing CSV row ${rowIterator}.");
$resource = null;
$csvRow = $csvData->getRow($rowIterator);
try {
// default values
$evaluatedData = $this->options['staticMap'];
// validate csv values
foreach ($this->options['map'] as $propUri => $csvColumn) {
$this->validate($destination, $propUri, $csvRow, $csvColumn, $evaluatedData);
}
// evaluate csv values
foreach ($this->options['map'] as $propUri => $csvColumn) {
if ($csvColumn != 'csv_null' && $csvColumn != 'csv_select') {
// process value
if (isset($csvRow[$csvColumn]) && !is_null($csvRow[$csvColumn])) {
$property = new core_kernel_classes_Property($propUri);
$evaluatedData[$propUri] = $this->evaluateValues($csvColumn, $property, $csvRow[$csvColumn]);
}
}
}
// create resource
$resource = $destination->createInstanceWithProperties($evaluatedData);
// Apply 'resourceImported' callbacks.
foreach ($this->resourceImported as $callback) {
$callback($resource);
}
$report->add(new common_report_Report(common_report_Report::TYPE_SUCCESS, __('Imported resource "%s"', $resource->getLabel()), $resource));
$createdResources++;
} catch (ValidationException $valExc) {
$failure = common_report_Report::createFailure(
__('Row %s', $rowIterator + 1) . ' ' . $valExc->getProperty()->getLabel() . ': ' . $valExc->getUserMessage() . ' "' . $valExc->getValue() . '"'
);
$report->add($failure);
}
helpers_TimeOutHelper::reset();
}
$this->addOption('to_import', $toImport);
$this->addOption('imported', $createdResources);
if ($createdResources == $toImport) {
$report->setType(common_report_Report::TYPE_SUCCESS);
$report->setMessage(__('Imported %d resources', $toImport));
} elseif ($createdResources > 0) {
$report->setType(common_report_Report::TYPE_WARNING);
$report->setMessage(__('Imported %1$d/%2$d. Some records are invalid.', $createdResources, $toImport));
}
$uploadService->remove($file);
return $report;
} | php | public function import($source, core_kernel_classes_Class $destination = null)
{
if (!isset($this->options['map'])) {
throw new BadFunctionCallException("import map not set");
}
if (is_null($destination)) {
throw new InvalidArgumentException("${destination} must be a valid core_kernel_classes_Class");
}
/** @var UploadService $uploadService */
$uploadService = ServiceManager::getServiceManager()->get(UploadService::SERVICE_ID);
if (!$source instanceof File) {
$file = $uploadService->getUploadedFlyFile($source);
} else {
$file = $source;
}
if (@preg_match('//u', $file->read()) === false) {
return new \common_report_Report(\common_report_Report::TYPE_ERROR, __("The imported file is not properly UTF-8 encoded."));
}
$csvData = $this->load($file);
$createdResources = 0;
$toImport = $csvData->count();
$report = new common_report_Report(common_report_Report::TYPE_ERROR, __('Data not imported. All records are invalid.'));
for ($rowIterator = 0; $rowIterator < $csvData->count(); $rowIterator++) {
helpers_TimeOutHelper::setTimeOutLimit(helpers_TimeOutHelper::SHORT);
common_Logger::d("CSV - Importing CSV row ${rowIterator}.");
$resource = null;
$csvRow = $csvData->getRow($rowIterator);
try {
// default values
$evaluatedData = $this->options['staticMap'];
// validate csv values
foreach ($this->options['map'] as $propUri => $csvColumn) {
$this->validate($destination, $propUri, $csvRow, $csvColumn, $evaluatedData);
}
// evaluate csv values
foreach ($this->options['map'] as $propUri => $csvColumn) {
if ($csvColumn != 'csv_null' && $csvColumn != 'csv_select') {
// process value
if (isset($csvRow[$csvColumn]) && !is_null($csvRow[$csvColumn])) {
$property = new core_kernel_classes_Property($propUri);
$evaluatedData[$propUri] = $this->evaluateValues($csvColumn, $property, $csvRow[$csvColumn]);
}
}
}
// create resource
$resource = $destination->createInstanceWithProperties($evaluatedData);
// Apply 'resourceImported' callbacks.
foreach ($this->resourceImported as $callback) {
$callback($resource);
}
$report->add(new common_report_Report(common_report_Report::TYPE_SUCCESS, __('Imported resource "%s"', $resource->getLabel()), $resource));
$createdResources++;
} catch (ValidationException $valExc) {
$failure = common_report_Report::createFailure(
__('Row %s', $rowIterator + 1) . ' ' . $valExc->getProperty()->getLabel() . ': ' . $valExc->getUserMessage() . ' "' . $valExc->getValue() . '"'
);
$report->add($failure);
}
helpers_TimeOutHelper::reset();
}
$this->addOption('to_import', $toImport);
$this->addOption('imported', $createdResources);
if ($createdResources == $toImport) {
$report->setType(common_report_Report::TYPE_SUCCESS);
$report->setMessage(__('Imported %d resources', $toImport));
} elseif ($createdResources > 0) {
$report->setType(common_report_Report::TYPE_WARNING);
$report->setMessage(__('Imported %1$d/%2$d. Some records are invalid.', $createdResources, $toImport));
}
$uploadService->remove($file);
return $report;
} | [
"public",
"function",
"import",
"(",
"$",
"source",
",",
"core_kernel_classes_Class",
"$",
"destination",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"'map'",
"]",
")",
")",
"{",
"throw",
"new",
"BadFunctionCal... | Imports the currently loaded CsvFile into the destination Class.
The map should be set in the options before executing it.
@access public
@author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
@param string $source
@param core_kernel_classes_Class $destination
@return common_report_Report
@throws \BadFunctionCallException
@throws \InvalidArgumentException
@throws \oat\oatbox\service\ServiceNotFoundException
@throws \common_Exception | [
"Imports",
"the",
"currently",
"loaded",
"CsvFile",
"into",
"the",
"destination",
"Class",
".",
"The",
"map",
"should",
"be",
"set",
"in",
"the",
"options",
"before",
"executing",
"it",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/data/class.GenerisAdapterCsv.php#L128-L219 |
oat-sa/tao-core | helpers/data/class.GenerisAdapterCsv.php | tao_helpers_data_GenerisAdapterCsv.evaluateValues | protected function evaluateValues($column, core_kernel_classes_Property $property, $value)
{
$range = $property->getRange();
// assume literal if no range defined
$range = is_null($range) ? new core_kernel_classes_Class(OntologyRdfs::RDFS_LITERAL) : $range;
$evaluatedValue = $this->applyCallbacks($value, $this->options, $property);
// ensure it's an array
$evaluatedValue = is_array($evaluatedValue) ? $evaluatedValue : array($evaluatedValue);
if ($range->getUri() != OntologyRdfs::RDFS_LITERAL) {
// validate resources
foreach ($evaluatedValue as $key => $eVal) {
$resource = new core_kernel_classes_Resource($eVal);
if ($resource->exists()) {
if (!$resource->hasType($range)) {
// value outside of range
unset($evaluatedValue[$key]);
}
} else {
// value not found
unset($evaluatedValue[$key]);
}
}
}
return $evaluatedValue;
} | php | protected function evaluateValues($column, core_kernel_classes_Property $property, $value)
{
$range = $property->getRange();
// assume literal if no range defined
$range = is_null($range) ? new core_kernel_classes_Class(OntologyRdfs::RDFS_LITERAL) : $range;
$evaluatedValue = $this->applyCallbacks($value, $this->options, $property);
// ensure it's an array
$evaluatedValue = is_array($evaluatedValue) ? $evaluatedValue : array($evaluatedValue);
if ($range->getUri() != OntologyRdfs::RDFS_LITERAL) {
// validate resources
foreach ($evaluatedValue as $key => $eVal) {
$resource = new core_kernel_classes_Resource($eVal);
if ($resource->exists()) {
if (!$resource->hasType($range)) {
// value outside of range
unset($evaluatedValue[$key]);
}
} else {
// value not found
unset($evaluatedValue[$key]);
}
}
}
return $evaluatedValue;
} | [
"protected",
"function",
"evaluateValues",
"(",
"$",
"column",
",",
"core_kernel_classes_Property",
"$",
"property",
",",
"$",
"value",
")",
"{",
"$",
"range",
"=",
"$",
"property",
"->",
"getRange",
"(",
")",
";",
"// assume literal if no range defined",
"$",
"... | Evaluates the raw values provided by the csv file into
the actual values to be assigned to the resource
@param string $column
@param core_kernel_classes_Property $property
@param mixed $value
@return array | [
"Evaluates",
"the",
"raw",
"values",
"provided",
"by",
"the",
"csv",
"file",
"into",
"the",
"actual",
"values",
"to",
"be",
"assigned",
"to",
"the",
"resource"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/data/class.GenerisAdapterCsv.php#L243-L269 |
oat-sa/tao-core | helpers/data/class.GenerisAdapterCsv.php | tao_helpers_data_GenerisAdapterCsv.applyCallbacks | private function applyCallbacks($value, $options, core_kernel_classes_Property $targetProperty)
{
if (isset($options['callbacks'])) {
foreach (array('*', $targetProperty->getUri()) as $key) {
if (isset($options['callbacks'][$key]) && is_array($options['callbacks'][$key])) {
foreach ($options['callbacks'][$key] as $callback) {
if (is_callable($callback)) {
$value = call_user_func($callback, $value);
}
}
}
}
}
return $value;
} | php | private function applyCallbacks($value, $options, core_kernel_classes_Property $targetProperty)
{
if (isset($options['callbacks'])) {
foreach (array('*', $targetProperty->getUri()) as $key) {
if (isset($options['callbacks'][$key]) && is_array($options['callbacks'][$key])) {
foreach ($options['callbacks'][$key] as $callback) {
if (is_callable($callback)) {
$value = call_user_func($callback, $value);
}
}
}
}
}
return $value;
} | [
"private",
"function",
"applyCallbacks",
"(",
"$",
"value",
",",
"$",
"options",
",",
"core_kernel_classes_Property",
"$",
"targetProperty",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'callbacks'",
"]",
")",
")",
"{",
"foreach",
"(",
"array",
... | Short description of method applyCallbacks
@access private
@author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
@param string $value
@param array $options
@param core_kernel_classes_Property $targetProperty
@return string | [
"Short",
"description",
"of",
"method",
"applyCallbacks"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/data/class.GenerisAdapterCsv.php#L281-L296 |
oat-sa/tao-core | helpers/data/class.GenerisAdapterCsv.php | tao_helpers_data_GenerisAdapterCsv.attachResource | public function attachResource(core_kernel_classes_Property $targetProperty, core_kernel_classes_Resource $targetResource, $value)
{
// We have to check if the resource identified by value exists in the Ontology.
$resource = new core_kernel_classes_Resource($value);
if ($resource->exists()) {
// Is the range correct ?
$targetPropertyRanges = $targetProperty->getPropertyValuesCollection(new core_kernel_classes_Property(OntologyRdfs::RDFS_RANGE));
$rangeCompliance = false;
// If $targetPropertyRange->count = 0, we consider that the resouce
// may be attached because $rangeCompliance = true.
foreach ($targetPropertyRanges->getIterator() as $range) {
// Check all classes in target property's range.
if ($resource->hasType(new core_kernel_classes_Class($range))) {
$rangeCompliance = true;
break;
}
}
if (true == $rangeCompliance) {
$targetResource->setPropertyValue($targetProperty, $resource->getUri());
}
}
} | php | public function attachResource(core_kernel_classes_Property $targetProperty, core_kernel_classes_Resource $targetResource, $value)
{
// We have to check if the resource identified by value exists in the Ontology.
$resource = new core_kernel_classes_Resource($value);
if ($resource->exists()) {
// Is the range correct ?
$targetPropertyRanges = $targetProperty->getPropertyValuesCollection(new core_kernel_classes_Property(OntologyRdfs::RDFS_RANGE));
$rangeCompliance = false;
// If $targetPropertyRange->count = 0, we consider that the resouce
// may be attached because $rangeCompliance = true.
foreach ($targetPropertyRanges->getIterator() as $range) {
// Check all classes in target property's range.
if ($resource->hasType(new core_kernel_classes_Class($range))) {
$rangeCompliance = true;
break;
}
}
if (true == $rangeCompliance) {
$targetResource->setPropertyValue($targetProperty, $resource->getUri());
}
}
} | [
"public",
"function",
"attachResource",
"(",
"core_kernel_classes_Property",
"$",
"targetProperty",
",",
"core_kernel_classes_Resource",
"$",
"targetResource",
",",
"$",
"value",
")",
"{",
"// We have to check if the resource identified by value exists in the Ontology.",
"$",
"re... | Short description of method attachResource
@access public
@author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
@param core_kernel_classes_Property $targetProperty
@param core_kernel_classes_Resource $targetResource
@param string $value
@return mixed | [
"Short",
"description",
"of",
"method",
"attachResource"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/data/class.GenerisAdapterCsv.php#L308-L332 |
oat-sa/tao-core | actions/class.ClientConfig.php | tao_actions_ClientConfig.config | public function config()
{
$this->setContentHeader('application/javascript');
//get extension paths to set up aliases dynamically
$extensionsAliases = ClientLibRegistry::getRegistry()->getLibAliasMap();
$this->setData('extensionsAliases', $extensionsAliases);
$libConfigs = ClientLibConfigRegistry::getRegistry()->getMap();
// Dynamically adds the date format.
$formatter = DateHelper::getDateFormatter();
$libConfigs['util/locale']['dateTimeFormat'] = $formatter->getJavascriptFormat(DateHelper::FORMAT_LONG);
$this->setData('libConfigs', $libConfigs);
$extendedConfig = $this->getServiceLocator()->get(ClientConfigService::SERVICE_ID)->getExtendedConfig();
foreach ($extendedConfig as $key => $value) {
$this->setData($key, json_encode($value));
}
//use the resolver in order to validate the route
$resolver = $this->getResolver();
//loads the URLs context
/** @var AssetService $assetService */
$assetService = $this->getServiceLocator()->get(AssetService::SERVICE_ID);
$tao_base_www = $assetService->getJsBaseWww('tao');
$this->setData('buster', $assetService->getCacheBuster());
$base_www = $assetService->getJsBaseWww($resolver->getExtensionId());
$base_url = $this->getExtension($resolver->getExtensionId())->getConstant('BASE_URL');
$langCode = tao_helpers_I18n::getLangCode();
if(strpos($langCode, '-') > 0){
$lang = strtolower(substr($langCode, 0, strpos($langCode, '-')));
} else {
$lang = strtolower($langCode);
}
$this->setData('locale', $langCode);
$this->setData('client_timeout', $this->getClientTimeout());
$this->setData('crossorigin', $this->isCrossorigin());
$this->setData('tao_base_www', $tao_base_www);
$this->setData('context', json_encode([
'root_url' => ROOT_URL,
'base_url' => $base_url,
'taobase_www' => $tao_base_www,
'base_www' => $base_www,
'base_lang' => $lang,
'locale' => $langCode,
'timeout' => $this->getClientTimeout(),
'extension' => $resolver->getExtensionId(),
'module' => $resolver->getControllerShortName(),
'action' => $resolver->getMethodName(),
'shownExtension' => $this->getShownExtension(),
'shownStructure' => $this->getShownStructure(),
'bundle' => tao_helpers_Mode::is(tao_helpers_Mode::PRODUCTION)
]));
$this->setView('client_config.tpl');
} | php | public function config()
{
$this->setContentHeader('application/javascript');
//get extension paths to set up aliases dynamically
$extensionsAliases = ClientLibRegistry::getRegistry()->getLibAliasMap();
$this->setData('extensionsAliases', $extensionsAliases);
$libConfigs = ClientLibConfigRegistry::getRegistry()->getMap();
// Dynamically adds the date format.
$formatter = DateHelper::getDateFormatter();
$libConfigs['util/locale']['dateTimeFormat'] = $formatter->getJavascriptFormat(DateHelper::FORMAT_LONG);
$this->setData('libConfigs', $libConfigs);
$extendedConfig = $this->getServiceLocator()->get(ClientConfigService::SERVICE_ID)->getExtendedConfig();
foreach ($extendedConfig as $key => $value) {
$this->setData($key, json_encode($value));
}
//use the resolver in order to validate the route
$resolver = $this->getResolver();
//loads the URLs context
/** @var AssetService $assetService */
$assetService = $this->getServiceLocator()->get(AssetService::SERVICE_ID);
$tao_base_www = $assetService->getJsBaseWww('tao');
$this->setData('buster', $assetService->getCacheBuster());
$base_www = $assetService->getJsBaseWww($resolver->getExtensionId());
$base_url = $this->getExtension($resolver->getExtensionId())->getConstant('BASE_URL');
$langCode = tao_helpers_I18n::getLangCode();
if(strpos($langCode, '-') > 0){
$lang = strtolower(substr($langCode, 0, strpos($langCode, '-')));
} else {
$lang = strtolower($langCode);
}
$this->setData('locale', $langCode);
$this->setData('client_timeout', $this->getClientTimeout());
$this->setData('crossorigin', $this->isCrossorigin());
$this->setData('tao_base_www', $tao_base_www);
$this->setData('context', json_encode([
'root_url' => ROOT_URL,
'base_url' => $base_url,
'taobase_www' => $tao_base_www,
'base_www' => $base_www,
'base_lang' => $lang,
'locale' => $langCode,
'timeout' => $this->getClientTimeout(),
'extension' => $resolver->getExtensionId(),
'module' => $resolver->getControllerShortName(),
'action' => $resolver->getMethodName(),
'shownExtension' => $this->getShownExtension(),
'shownStructure' => $this->getShownStructure(),
'bundle' => tao_helpers_Mode::is(tao_helpers_Mode::PRODUCTION)
]));
$this->setView('client_config.tpl');
} | [
"public",
"function",
"config",
"(",
")",
"{",
"$",
"this",
"->",
"setContentHeader",
"(",
"'application/javascript'",
")",
";",
"//get extension paths to set up aliases dynamically",
"$",
"extensionsAliases",
"=",
"ClientLibRegistry",
"::",
"getRegistry",
"(",
")",
"->... | Get the require.js' config file | [
"Get",
"the",
"require",
".",
"js",
"config",
"file"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.ClientConfig.php#L40-L100 |
oat-sa/tao-core | actions/class.ClientConfig.php | tao_actions_ClientConfig.getExtension | private function getExtension($extensionId)
{
try {
return $this->getServiceLocator()->get(common_ext_ExtensionsManager::SERVICE_ID)->getExtensionById($extensionId);
} catch(common_ext_ExtensionException $cee){
throw new Exception(__('Wrong parameter shownExtension'), $cee);
}
} | php | private function getExtension($extensionId)
{
try {
return $this->getServiceLocator()->get(common_ext_ExtensionsManager::SERVICE_ID)->getExtensionById($extensionId);
} catch(common_ext_ExtensionException $cee){
throw new Exception(__('Wrong parameter shownExtension'), $cee);
}
} | [
"private",
"function",
"getExtension",
"(",
"$",
"extensionId",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"common_ext_ExtensionsManager",
"::",
"SERVICE_ID",
")",
"->",
"getExtensionById",
"(",
"$",
"ex... | Get an extension by it's id
@param string $extensionId the extension name/id
@return common_ext_Extension the extension
@throws Exception if the parameter contains an unknown extension | [
"Get",
"an",
"extension",
"by",
"it",
"s",
"id"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.ClientConfig.php#L108-L115 |
oat-sa/tao-core | actions/class.ClientConfig.php | tao_actions_ClientConfig.getShownExtension | private function getShownExtension()
{
if($this->hasRequestParameter('shownExtension')){
$shownExtension = $this->getRequestParameter('shownExtension');
if(strlen(trim($shownExtension)) > 0){
$extension = $this->getExtension($shownExtension);
return $extension->getName();
}
}
return null;
} | php | private function getShownExtension()
{
if($this->hasRequestParameter('shownExtension')){
$shownExtension = $this->getRequestParameter('shownExtension');
if(strlen(trim($shownExtension)) > 0){
$extension = $this->getExtension($shownExtension);
return $extension->getName();
}
}
return null;
} | [
"private",
"function",
"getShownExtension",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasRequestParameter",
"(",
"'shownExtension'",
")",
")",
"{",
"$",
"shownExtension",
"=",
"$",
"this",
"->",
"getRequestParameter",
"(",
"'shownExtension'",
")",
";",
"if... | Get and validate the extension name of the parameter 'shownExtension'
@return string the validated extension name
@throws Exception if the parameter contains an unknown extension | [
"Get",
"and",
"validate",
"the",
"extension",
"name",
"of",
"the",
"parameter",
"shownExtension"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.ClientConfig.php#L136-L146 |
oat-sa/tao-core | actions/class.ClientConfig.php | tao_actions_ClientConfig.getShownStructure | private function getShownStructure()
{
if($this->hasRequestParameter('shownStructure')){
$structure = $this->getRequestParameter('shownStructure');
$perspectives = \oat\tao\model\menu\MenuService::getAllPerspectives();
foreach($perspectives as $perspective){
if($perspective->getId() == $structure){
return $perspective->getId();
}
}
}
return null;
} | php | private function getShownStructure()
{
if($this->hasRequestParameter('shownStructure')){
$structure = $this->getRequestParameter('shownStructure');
$perspectives = \oat\tao\model\menu\MenuService::getAllPerspectives();
foreach($perspectives as $perspective){
if($perspective->getId() == $structure){
return $perspective->getId();
}
}
}
return null;
} | [
"private",
"function",
"getShownStructure",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasRequestParameter",
"(",
"'shownStructure'",
")",
")",
"{",
"$",
"structure",
"=",
"$",
"this",
"->",
"getRequestParameter",
"(",
"'shownStructure'",
")",
";",
"$",
"... | Get and validate the 'shownStructure' parameter
@return string the structure id if found in the list | [
"Get",
"and",
"validate",
"the",
"shownStructure",
"parameter"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.ClientConfig.php#L152-L164 |
oat-sa/tao-core | actions/class.ClientConfig.php | tao_actions_ClientConfig.getResolver | private function getResolver()
{
$url = tao_helpers_Uri::url(
$this->getRequestParameter('action'),
$this->getRequestParameter('module'),
$this->hasRequestParameter('extension') ? $this->getRequestParameter('extension') : \Context::getInstance()->getExtensionName()
);
try {
$route = new Resolver(new common_http_Request($url));
$this->propagate($route);
} catch (ResolverException $re){
throw new Exception(__('Wrong or missing parameter extension, module or action'), $re);
}
return $route;
} | php | private function getResolver()
{
$url = tao_helpers_Uri::url(
$this->getRequestParameter('action'),
$this->getRequestParameter('module'),
$this->hasRequestParameter('extension') ? $this->getRequestParameter('extension') : \Context::getInstance()->getExtensionName()
);
try {
$route = new Resolver(new common_http_Request($url));
$this->propagate($route);
} catch (ResolverException $re){
throw new Exception(__('Wrong or missing parameter extension, module or action'), $re);
}
return $route;
} | [
"private",
"function",
"getResolver",
"(",
")",
"{",
"$",
"url",
"=",
"tao_helpers_Uri",
"::",
"url",
"(",
"$",
"this",
"->",
"getRequestParameter",
"(",
"'action'",
")",
",",
"$",
"this",
"->",
"getRequestParameter",
"(",
"'module'",
")",
",",
"$",
"this"... | Get a resolved route from the GET parameters extension/module/action
@return Resolver
@throws Exception in case a parameter is missing or if the route can't be resolved | [
"Get",
"a",
"resolved",
"route",
"from",
"the",
"GET",
"parameters",
"extension",
"/",
"module",
"/",
"action"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.ClientConfig.php#L171-L185 |
oat-sa/tao-core | models/classes/controllerMap/ActionDescription.php | ActionDescription.getRequiredRights | public function getRequiredRights() {
$privileges = array();
foreach ($this->getDocBlock()->getTagsByName('requiresRight') as $tag) {
$privileges[$tag->getParameterName()] = $tag->getRightId();
}
return $privileges;
} | php | public function getRequiredRights() {
$privileges = array();
foreach ($this->getDocBlock()->getTagsByName('requiresRight') as $tag) {
$privileges[$tag->getParameterName()] = $tag->getRightId();
}
return $privileges;
} | [
"public",
"function",
"getRequiredRights",
"(",
")",
"{",
"$",
"privileges",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getDocBlock",
"(",
")",
"->",
"getTagsByName",
"(",
"'requiresRight'",
")",
"as",
"$",
"tag",
")",
"{",
"$",
"... | Returns an array of all rights required to execute the action
The array uses the name of the parmeter as key and the value is
a string identifying the right
@return string | [
"Returns",
"an",
"array",
"of",
"all",
"rights",
"required",
"to",
"execute",
"the",
"action"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/controllerMap/ActionDescription.php#L94-L100 |
oat-sa/tao-core | models/classes/oauth/DataStore.php | DataStore.findOauthConsumerResource | public function findOauthConsumerResource($consumer_key)
{
$returnValue = null;
$class = $this->getClass(self::CLASS_URI_OAUTH_CONSUMER);
$instances = $class->searchInstances(array(self::PROPERTY_OAUTH_KEY => $consumer_key), array('like' => false, 'recursive' => true));
if (count($instances) == 0) {
throw new \tao_models_classes_oauth_Exception('No Credentials for consumer key '.$consumer_key);
}
if (count($instances) > 1) {
throw new \tao_models_classes_oauth_Exception('Multiple Credentials for consumer key '.$consumer_key);
}
$returnValue = current($instances);
return $returnValue;
} | php | public function findOauthConsumerResource($consumer_key)
{
$returnValue = null;
$class = $this->getClass(self::CLASS_URI_OAUTH_CONSUMER);
$instances = $class->searchInstances(array(self::PROPERTY_OAUTH_KEY => $consumer_key), array('like' => false, 'recursive' => true));
if (count($instances) == 0) {
throw new \tao_models_classes_oauth_Exception('No Credentials for consumer key '.$consumer_key);
}
if (count($instances) > 1) {
throw new \tao_models_classes_oauth_Exception('Multiple Credentials for consumer key '.$consumer_key);
}
$returnValue = current($instances);
return $returnValue;
} | [
"public",
"function",
"findOauthConsumerResource",
"(",
"$",
"consumer_key",
")",
"{",
"$",
"returnValue",
"=",
"null",
";",
"$",
"class",
"=",
"$",
"this",
"->",
"getClass",
"(",
"self",
"::",
"CLASS_URI_OAUTH_CONSUMER",
")",
";",
"$",
"instances",
"=",
"$"... | Helper function to find the OauthConsumer RDF Resource
@access public
@author Joel Bout, <joel@taotesting.com>
@param string consumer_key
@return \core_kernel_classes_Resource | [
"Helper",
"function",
"to",
"find",
"the",
"OauthConsumer",
"RDF",
"Resource"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/oauth/DataStore.php#L58-L73 |
oat-sa/tao-core | models/classes/oauth/DataStore.php | DataStore.getOauthConsumer | public function getOauthConsumer(\common_http_Credentials $credentials)
{
if (!$credentials instanceof \core_kernel_classes_Resource) {
throw new \tao_models_classes_oauth_Exception('Unsupported credential type '.get_class($credentials));
}
$values = $credentials->getPropertiesValues(array(
self::PROPERTY_OAUTH_KEY,
self::PROPERTY_OAUTH_SECRET,
self::PROPERTY_OAUTH_CALLBACK
));
if (empty($values[self::PROPERTY_OAUTH_KEY]) || empty($values[self::PROPERTY_OAUTH_SECRET])) {
throw new \tao_models_classes_oauth_Exception('Incomplete oauth consumer definition for '.$credentials->getUri());
}
$consumer_key = (string)current($values[self::PROPERTY_OAUTH_KEY]);
$secret = (string)current($values[self::PROPERTY_OAUTH_SECRET]);
if (!empty($values[self::PROPERTY_OAUTH_CALLBACK])) {
$callbackUrl = (string)current($values[self::PROPERTY_OAUTH_CALLBACK]);
if (empty($callbackUrl)) {
$callbackUrl = null;
}
} else {
$callbackUrl = null;
}
return new OAuthConsumer($consumer_key, $secret, $callbackUrl);
} | php | public function getOauthConsumer(\common_http_Credentials $credentials)
{
if (!$credentials instanceof \core_kernel_classes_Resource) {
throw new \tao_models_classes_oauth_Exception('Unsupported credential type '.get_class($credentials));
}
$values = $credentials->getPropertiesValues(array(
self::PROPERTY_OAUTH_KEY,
self::PROPERTY_OAUTH_SECRET,
self::PROPERTY_OAUTH_CALLBACK
));
if (empty($values[self::PROPERTY_OAUTH_KEY]) || empty($values[self::PROPERTY_OAUTH_SECRET])) {
throw new \tao_models_classes_oauth_Exception('Incomplete oauth consumer definition for '.$credentials->getUri());
}
$consumer_key = (string)current($values[self::PROPERTY_OAUTH_KEY]);
$secret = (string)current($values[self::PROPERTY_OAUTH_SECRET]);
if (!empty($values[self::PROPERTY_OAUTH_CALLBACK])) {
$callbackUrl = (string)current($values[self::PROPERTY_OAUTH_CALLBACK]);
if (empty($callbackUrl)) {
$callbackUrl = null;
}
} else {
$callbackUrl = null;
}
return new OAuthConsumer($consumer_key, $secret, $callbackUrl);
} | [
"public",
"function",
"getOauthConsumer",
"(",
"\\",
"common_http_Credentials",
"$",
"credentials",
")",
"{",
"if",
"(",
"!",
"$",
"credentials",
"instanceof",
"\\",
"core_kernel_classes_Resource",
")",
"{",
"throw",
"new",
"\\",
"tao_models_classes_oauth_Exception",
... | Returns the OAuthConsumer for the provided credentials
@param \common_http_Credentials $consumer
@throws \tao_models_classes_oauth_Exception
@return \IMSGlobal\LTI\OAuth\OAuthConsumer | [
"Returns",
"the",
"OAuthConsumer",
"for",
"the",
"provided",
"credentials"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/oauth/DataStore.php#L82-L106 |
oat-sa/tao-core | models/classes/oauth/DataStore.php | DataStore.lookup_consumer | public function lookup_consumer($consumer_key)
{
$returnValue = null;
$consumer = $this->findOauthConsumerResource($consumer_key);
$secret = (string)$consumer->getUniquePropertyValue($this->getProperty(self::PROPERTY_OAUTH_SECRET));
$callbackUrl = null;
$returnValue = new OAuthConsumer($consumer_key, $secret, $callbackUrl);
return $returnValue;
} | php | public function lookup_consumer($consumer_key)
{
$returnValue = null;
$consumer = $this->findOauthConsumerResource($consumer_key);
$secret = (string)$consumer->getUniquePropertyValue($this->getProperty(self::PROPERTY_OAUTH_SECRET));
$callbackUrl = null;
$returnValue = new OAuthConsumer($consumer_key, $secret, $callbackUrl);
return $returnValue;
} | [
"public",
"function",
"lookup_consumer",
"(",
"$",
"consumer_key",
")",
"{",
"$",
"returnValue",
"=",
"null",
";",
"$",
"consumer",
"=",
"$",
"this",
"->",
"findOauthConsumerResource",
"(",
"$",
"consumer_key",
")",
";",
"$",
"secret",
"=",
"(",
"string",
... | returns the OauthConsumer for the specified key
@access public
@author Joel Bout, <joel@taotesting.com>
@param consumer_key
@return OAuthConsumer | [
"returns",
"the",
"OauthConsumer",
"for",
"the",
"specified",
"key"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/oauth/DataStore.php#L117-L128 |
oat-sa/tao-core | models/classes/oauth/DataStore.php | DataStore.lookup_token | public function lookup_token($consumer, $token_type, $token)
{
\common_Logger::d(__CLASS__.'::'.__FUNCTION__.' called for token '.$token.' of type '.$token_type);
return new OAuthToken($consumer, "");
} | php | public function lookup_token($consumer, $token_type, $token)
{
\common_Logger::d(__CLASS__.'::'.__FUNCTION__.' called for token '.$token.' of type '.$token_type);
return new OAuthToken($consumer, "");
} | [
"public",
"function",
"lookup_token",
"(",
"$",
"consumer",
",",
"$",
"token_type",
",",
"$",
"token",
")",
"{",
"\\",
"common_Logger",
"::",
"d",
"(",
"__CLASS__",
".",
"'::'",
".",
"__FUNCTION__",
".",
"' called for token '",
".",
"$",
"token",
".",
"' o... | Should verify if the token exists and return it
Always returns an token with an empty secret for now
@access public
@author Joel Bout, <joel@taotesting.com>
@param consumer
@param token_type
@param token
@return mixed | [
"Should",
"verify",
"if",
"the",
"token",
"exists",
"and",
"return",
"it",
"Always",
"returns",
"an",
"token",
"with",
"an",
"empty",
"secret",
"for",
"now"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/oauth/DataStore.php#L141-L145 |
oat-sa/tao-core | models/classes/oauth/DataStore.php | DataStore.lookup_nonce | public function lookup_nonce($consumer, $token, $nonce, $timestamp)
{
$store = $this->getSubService(self::OPTION_NONCE_STORE);
return $store->isValid($timestamp.'_'.$consumer->key.'_'.$nonce) ? null : true;
} | php | public function lookup_nonce($consumer, $token, $nonce, $timestamp)
{
$store = $this->getSubService(self::OPTION_NONCE_STORE);
return $store->isValid($timestamp.'_'.$consumer->key.'_'.$nonce) ? null : true;
} | [
"public",
"function",
"lookup_nonce",
"(",
"$",
"consumer",
",",
"$",
"token",
",",
"$",
"nonce",
",",
"$",
"timestamp",
")",
"{",
"$",
"store",
"=",
"$",
"this",
"->",
"getSubService",
"(",
"self",
"::",
"OPTION_NONCE_STORE",
")",
";",
"return",
"$",
... | Should verify if a nonce has already been used
always return NULL, meaning that nonces can be reused
@access public
@author Joel Bout, <joel@taotesting.com>
@param OAuthConsumer $consumer
@param OAuthToken $token
@param string $nonce
@param string $timestamp
@return mixed | [
"Should",
"verify",
"if",
"a",
"nonce",
"has",
"already",
"been",
"used",
"always",
"return",
"NULL",
"meaning",
"that",
"nonces",
"can",
"be",
"reused"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/oauth/DataStore.php#L159-L163 |
oat-sa/tao-core | models/classes/oauth/DataStore.php | DataStore.new_access_token | public function new_access_token($token, $consumer, $verifier = null)
{
\common_Logger::d(__CLASS__.'::'.__FUNCTION__.' called');
return null;
} | php | public function new_access_token($token, $consumer, $verifier = null)
{
\common_Logger::d(__CLASS__.'::'.__FUNCTION__.' called');
return null;
} | [
"public",
"function",
"new_access_token",
"(",
"$",
"token",
",",
"$",
"consumer",
",",
"$",
"verifier",
"=",
"null",
")",
"{",
"\\",
"common_Logger",
"::",
"d",
"(",
"__CLASS__",
".",
"'::'",
".",
"__FUNCTION__",
".",
"' called'",
")",
";",
"return",
"n... | Should create a new access token
not implemented
@access public
@author Joel Bout, <joel@taotesting.com>
@param token
@param consumer
@return mixed | [
"Should",
"create",
"a",
"new",
"access",
"token",
"not",
"implemented"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/oauth/DataStore.php#L191-L195 |
oat-sa/tao-core | models/classes/session/restSessionFactory/RestSessionFactory.php | RestSessionFactory.createSessionFromRequest | public function createSessionFromRequest($request, $resolver)
{
if (!$this->isRestController($resolver)) {
return false;
}
/** @var SessionBuilder $builder */
foreach ($this->getSessionBuilders() as $builder) {
if ($builder->isApplicable($request)) {
return $this->startSession($builder->getSession($request));
}
}
throw new LoginFailedException(array('Request cannot be authenticated.'));
} | php | public function createSessionFromRequest($request, $resolver)
{
if (!$this->isRestController($resolver)) {
return false;
}
/** @var SessionBuilder $builder */
foreach ($this->getSessionBuilders() as $builder) {
if ($builder->isApplicable($request)) {
return $this->startSession($builder->getSession($request));
}
}
throw new LoginFailedException(array('Request cannot be authenticated.'));
} | [
"public",
"function",
"createSessionFromRequest",
"(",
"$",
"request",
",",
"$",
"resolver",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isRestController",
"(",
"$",
"resolver",
")",
")",
"{",
"return",
"false",
";",
"}",
"/** @var SessionBuilder $builder */... | Create a rest session based on builders.
Give the request and resolver to builder to know if it is applicable
If yes, create and start the session from it
@param $request
@param $resolver
@return bool
@throws LoginFailedException | [
"Create",
"a",
"rest",
"session",
"based",
"on",
"builders",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/session/restSessionFactory/RestSessionFactory.php#L51-L63 |
oat-sa/tao-core | models/classes/session/restSessionFactory/RestSessionFactory.php | RestSessionFactory.getSessionBuilders | protected function getSessionBuilders()
{
$adapters = is_array($this->getOption(self::OPTION_BUILDERS)) ? $this->getOption(self::OPTION_BUILDERS) : [];
foreach ($adapters as $key => $adapter) {
if (!is_a($adapter, SessionBuilder::class, true)) {
throw new \LogicException('Session adapter must implement interface "SessionBuilder".');
}
$adapters[$key] = $this->propagate(new $adapter());
}
return $adapters;
} | php | protected function getSessionBuilders()
{
$adapters = is_array($this->getOption(self::OPTION_BUILDERS)) ? $this->getOption(self::OPTION_BUILDERS) : [];
foreach ($adapters as $key => $adapter) {
if (!is_a($adapter, SessionBuilder::class, true)) {
throw new \LogicException('Session adapter must implement interface "SessionBuilder".');
}
$adapters[$key] = $this->propagate(new $adapter());
}
return $adapters;
} | [
"protected",
"function",
"getSessionBuilders",
"(",
")",
"{",
"$",
"adapters",
"=",
"is_array",
"(",
"$",
"this",
"->",
"getOption",
"(",
"self",
"::",
"OPTION_BUILDERS",
")",
")",
"?",
"$",
"this",
"->",
"getOption",
"(",
"self",
"::",
"OPTION_BUILDERS",
... | Fetch rest session builder from the config
@return SessionBuilder[] | [
"Fetch",
"rest",
"session",
"builder",
"from",
"the",
"config"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/session/restSessionFactory/RestSessionFactory.php#L81-L91 |
oat-sa/tao-core | scripts/class.TaoRDFImport.php | tao_scripts_TaoRDFImport.preRun | public function preRun()
{
$this->options = array('verbose' => false,
'user' => null,
'password' => null,
'model' => null,
'input' => null);
$this->options = array_merge($this->options, $this->parameters);
// the 'file' param is checked by the parent implementation.
if ($this->options['user'] == null){
$this->err("Please provide a TAO 'user'.", true);
}
else if ($this->options['password'] == null){
$this->err("Please provide a TAO 'password'.", true);
}
else if ($this->options['input'] == null){
$this->err("Please provide a RDF 'input' file.", true);
}
} | php | public function preRun()
{
$this->options = array('verbose' => false,
'user' => null,
'password' => null,
'model' => null,
'input' => null);
$this->options = array_merge($this->options, $this->parameters);
// the 'file' param is checked by the parent implementation.
if ($this->options['user'] == null){
$this->err("Please provide a TAO 'user'.", true);
}
else if ($this->options['password'] == null){
$this->err("Please provide a TAO 'password'.", true);
}
else if ($this->options['input'] == null){
$this->err("Please provide a RDF 'input' file.", true);
}
} | [
"public",
"function",
"preRun",
"(",
")",
"{",
"$",
"this",
"->",
"options",
"=",
"array",
"(",
"'verbose'",
"=>",
"false",
",",
"'user'",
"=>",
"null",
",",
"'password'",
"=>",
"null",
",",
"'model'",
"=>",
"null",
",",
"'input'",
"=>",
"null",
")",
... | Short description of method preRun
@access public
@author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
@return void | [
"Short",
"description",
"of",
"method",
"preRun"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoRDFImport.php#L49-L73 |
oat-sa/tao-core | scripts/class.TaoRDFImport.php | tao_scripts_TaoRDFImport.run | public function run()
{
$userService = tao_models_classes_UserService::singleton();
$this->outVerbose("Connecting to TAO as '" . $this->options['user'] . "' ...");
if ($userService->loginUser($this->options['user'], $this->options['password'])){
$this->outVerbose("Connected to TAO as '" . $this->options['user'] . "'.");
$filename = $this->options['input'];
$action = new ImportRdf();
$params = array($filename);
if (!empty($this->options['model'])){
$nameSpace = common_ext_NamespaceManager::singleton()->getNamespace($this->options['model']);
$params[] = $nameSpace->getModelId();
}
$report = $action->__invoke($params);
$string = helpers_Report::renderToCommandline($report);
foreach (explode(PHP_EOL, $string) as $line) {
$this->out($line);
}
}
else{
$this->err("Unable to connect to TAO as '" . $this->options['user'] . "'.", true);
}
} | php | public function run()
{
$userService = tao_models_classes_UserService::singleton();
$this->outVerbose("Connecting to TAO as '" . $this->options['user'] . "' ...");
if ($userService->loginUser($this->options['user'], $this->options['password'])){
$this->outVerbose("Connected to TAO as '" . $this->options['user'] . "'.");
$filename = $this->options['input'];
$action = new ImportRdf();
$params = array($filename);
if (!empty($this->options['model'])){
$nameSpace = common_ext_NamespaceManager::singleton()->getNamespace($this->options['model']);
$params[] = $nameSpace->getModelId();
}
$report = $action->__invoke($params);
$string = helpers_Report::renderToCommandline($report);
foreach (explode(PHP_EOL, $string) as $line) {
$this->out($line);
}
}
else{
$this->err("Unable to connect to TAO as '" . $this->options['user'] . "'.", true);
}
} | [
"public",
"function",
"run",
"(",
")",
"{",
"$",
"userService",
"=",
"tao_models_classes_UserService",
"::",
"singleton",
"(",
")",
";",
"$",
"this",
"->",
"outVerbose",
"(",
"\"Connecting to TAO as '\"",
".",
"$",
"this",
"->",
"options",
"[",
"'user'",
"]",
... | Short description of method run
@access public
@author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
@return void | [
"Short",
"description",
"of",
"method",
"run"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/scripts/class.TaoRDFImport.php#L82-L110 |
oat-sa/tao-core | actions/class.ExtensionsManager.php | tao_actions_ExtensionsManager.index | public function index()
{
if ($this->isDebugMode() === true) {
$isProduction = false;
$availableExtArray = $this->getExtensionManager()->getAvailableExtensions();
usort($availableExtArray, function($a, $b) { return strcasecmp($a->getId(),$b->getId());});
$this->setData('availableExtArray', $availableExtArray);
} else {
$isProduction = true;
}
$this->setData('isProduction', $isProduction);
$this->setData('installedExtArray', $this->getExtensionManager()->getInstalledExtensions());
$this->setView('extensionManager/view.tpl');
} | php | public function index()
{
if ($this->isDebugMode() === true) {
$isProduction = false;
$availableExtArray = $this->getExtensionManager()->getAvailableExtensions();
usort($availableExtArray, function($a, $b) { return strcasecmp($a->getId(),$b->getId());});
$this->setData('availableExtArray', $availableExtArray);
} else {
$isProduction = true;
}
$this->setData('isProduction', $isProduction);
$this->setData('installedExtArray', $this->getExtensionManager()->getInstalledExtensions());
$this->setView('extensionManager/view.tpl');
} | [
"public",
"function",
"index",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isDebugMode",
"(",
")",
"===",
"true",
")",
"{",
"$",
"isProduction",
"=",
"false",
";",
"$",
"availableExtArray",
"=",
"$",
"this",
"->",
"getExtensionManager",
"(",
")",
"->... | Index page | [
"Index",
"page"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.ExtensionsManager.php#L40-L54 |
oat-sa/tao-core | actions/class.ExtensionsManager.php | tao_actions_ExtensionsManager.install | public function install()
{
$this->assertIsDebugMode();
$success = false;
try {
$extInstaller = new tao_install_ExtensionInstaller($this->getCurrentExtension());
$extInstaller->install();
$message = __('Extension "%s" has been installed', $this->getCurrentExtension()->getId());
$success = true;
// reinit user session
$session = $this->getSession()->refresh();
}
catch(common_ext_ExtensionException $e) {
$message = $e->getMessage();
}
$this->returnJson(array('success' => $success, 'message' => $message));
} | php | public function install()
{
$this->assertIsDebugMode();
$success = false;
try {
$extInstaller = new tao_install_ExtensionInstaller($this->getCurrentExtension());
$extInstaller->install();
$message = __('Extension "%s" has been installed', $this->getCurrentExtension()->getId());
$success = true;
// reinit user session
$session = $this->getSession()->refresh();
}
catch(common_ext_ExtensionException $e) {
$message = $e->getMessage();
}
$this->returnJson(array('success' => $success, 'message' => $message));
} | [
"public",
"function",
"install",
"(",
")",
"{",
"$",
"this",
"->",
"assertIsDebugMode",
"(",
")",
";",
"$",
"success",
"=",
"false",
";",
"try",
"{",
"$",
"extInstaller",
"=",
"new",
"tao_install_ExtensionInstaller",
"(",
"$",
"this",
"->",
"getCurrentExtens... | Install action
@throws common_exception_BadRequest If platform is on production mode
@throws common_exception_Error | [
"Install",
"action"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.ExtensionsManager.php#L79-L98 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.