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/extension-tao-delivery-rdf
model/DeliveryAssemblyService.php
DeliveryAssemblyService.deleteDeliveryRuntime
protected function deleteDeliveryRuntime(core_kernel_classes_Resource $assembly) { /** @var GroupAssignment $deliveryAssignement */ $deliveryAssignement = $this->getServiceManager()->get(GroupAssignment::SERVICE_ID); $deliveryAssignement->onDelete($assembly); /** @var core_kernel_classes_Resource $runtimeResource */ $runtimeResource = $assembly->getUniquePropertyValue(new core_kernel_classes_Property(self::PROPERTY_DELIVERY_RUNTIME)); return $runtimeResource->delete(); }
php
protected function deleteDeliveryRuntime(core_kernel_classes_Resource $assembly) { /** @var GroupAssignment $deliveryAssignement */ $deliveryAssignement = $this->getServiceManager()->get(GroupAssignment::SERVICE_ID); $deliveryAssignement->onDelete($assembly); /** @var core_kernel_classes_Resource $runtimeResource */ $runtimeResource = $assembly->getUniquePropertyValue(new core_kernel_classes_Property(self::PROPERTY_DELIVERY_RUNTIME)); return $runtimeResource->delete(); }
[ "protected", "function", "deleteDeliveryRuntime", "(", "core_kernel_classes_Resource", "$", "assembly", ")", "{", "/** @var GroupAssignment $deliveryAssignement */", "$", "deliveryAssignement", "=", "$", "this", "->", "getServiceManager", "(", ")", "->", "get", "(", "GroupAssignment", "::", "SERVICE_ID", ")", ";", "$", "deliveryAssignement", "->", "onDelete", "(", "$", "assembly", ")", ";", "/** @var core_kernel_classes_Resource $runtimeResource */", "$", "runtimeResource", "=", "$", "assembly", "->", "getUniquePropertyValue", "(", "new", "core_kernel_classes_Property", "(", "self", "::", "PROPERTY_DELIVERY_RUNTIME", ")", ")", ";", "return", "$", "runtimeResource", "->", "delete", "(", ")", ";", "}" ]
Delete a runtime of a delivery @param core_kernel_classes_Resource $assembly @return bool @throws \core_kernel_classes_EmptyProperty @throws \core_kernel_classes_MultiplePropertyValuesException
[ "Delete", "a", "runtime", "of", "a", "delivery" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/DeliveryAssemblyService.php#L143-L151
oat-sa/extension-tao-delivery-rdf
model/DeliveryAssemblyService.php
DeliveryAssemblyService.deleteDeliveryDirectory
public function deleteDeliveryDirectory(core_kernel_classes_Resource $assembly) { $success = true; $deleted = 0; $directories = $assembly->getPropertyValues(new core_kernel_classes_Property(self::PROPERTY_DELIVERY_DIRECTORY)); foreach ($directories as $directory) { $instances = $this->getRootClass()->getInstances(true, array(self::PROPERTY_DELIVERY_DIRECTORY => $directory)); unset($instances[$assembly->getUri()]); if (empty($instances)) { $success = $this->getFileStorage()->deleteDirectoryById($directory) ? $success : false; $deleted++; } } \common_Logger::i('(' . (int) $deleted. ') deletions for delivery assembly: ' . $assembly->getUri()); return $success; }
php
public function deleteDeliveryDirectory(core_kernel_classes_Resource $assembly) { $success = true; $deleted = 0; $directories = $assembly->getPropertyValues(new core_kernel_classes_Property(self::PROPERTY_DELIVERY_DIRECTORY)); foreach ($directories as $directory) { $instances = $this->getRootClass()->getInstances(true, array(self::PROPERTY_DELIVERY_DIRECTORY => $directory)); unset($instances[$assembly->getUri()]); if (empty($instances)) { $success = $this->getFileStorage()->deleteDirectoryById($directory) ? $success : false; $deleted++; } } \common_Logger::i('(' . (int) $deleted. ') deletions for delivery assembly: ' . $assembly->getUri()); return $success; }
[ "public", "function", "deleteDeliveryDirectory", "(", "core_kernel_classes_Resource", "$", "assembly", ")", "{", "$", "success", "=", "true", ";", "$", "deleted", "=", "0", ";", "$", "directories", "=", "$", "assembly", "->", "getPropertyValues", "(", "new", "core_kernel_classes_Property", "(", "self", "::", "PROPERTY_DELIVERY_DIRECTORY", ")", ")", ";", "foreach", "(", "$", "directories", "as", "$", "directory", ")", "{", "$", "instances", "=", "$", "this", "->", "getRootClass", "(", ")", "->", "getInstances", "(", "true", ",", "array", "(", "self", "::", "PROPERTY_DELIVERY_DIRECTORY", "=>", "$", "directory", ")", ")", ";", "unset", "(", "$", "instances", "[", "$", "assembly", "->", "getUri", "(", ")", "]", ")", ";", "if", "(", "empty", "(", "$", "instances", ")", ")", "{", "$", "success", "=", "$", "this", "->", "getFileStorage", "(", ")", "->", "deleteDirectoryById", "(", "$", "directory", ")", "?", "$", "success", ":", "false", ";", "$", "deleted", "++", ";", "}", "}", "\\", "common_Logger", "::", "i", "(", "'('", ".", "(", "int", ")", "$", "deleted", ".", "') deletions for delivery assembly: '", ".", "$", "assembly", "->", "getUri", "(", ")", ")", ";", "return", "$", "success", ";", "}" ]
Delete directories related to a delivery, don't remove if dir is used by another delivery @param core_kernel_classes_Resource $assembly @return bool
[ "Delete", "directories", "related", "to", "a", "delivery", "don", "t", "remove", "if", "dir", "is", "used", "by", "another", "delivery" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/DeliveryAssemblyService.php#L159-L175
oat-sa/extension-tao-delivery-rdf
model/DeliveryAssemblyService.php
DeliveryAssemblyService.getRuntime
public function getRuntime( core_kernel_classes_Resource $assembly) { return $this->getServiceLocator()->get(RuntimeService::SERVICE_ID)->getRuntime($assembly->getUri()); }
php
public function getRuntime( core_kernel_classes_Resource $assembly) { return $this->getServiceLocator()->get(RuntimeService::SERVICE_ID)->getRuntime($assembly->getUri()); }
[ "public", "function", "getRuntime", "(", "core_kernel_classes_Resource", "$", "assembly", ")", "{", "return", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "RuntimeService", "::", "SERVICE_ID", ")", "->", "getRuntime", "(", "$", "assembly", "->", "getUri", "(", ")", ")", ";", "}" ]
Gets the service call to run this assembly @param core_kernel_classes_Resource $assembly @return tao_models_classes_service_ServiceCall
[ "Gets", "the", "service", "call", "to", "run", "this", "assembly" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/DeliveryAssemblyService.php#L183-L185
oat-sa/extension-tao-delivery-rdf
model/ContainerRuntime.php
ContainerRuntime.getRuntime
public function getRuntime($deliveryId) { $delivery = $this->getResource($deliveryId); if (!$delivery->exists()) { throw new \common_exception_NoContent('Unable to load runtime associated for delivery ' . $deliveryId . ' Delivery probably deleted.'); } $runtimeResource = $delivery->getUniquePropertyValue($this->getProperty(self::PROPERTY_RUNTIME)); return \tao_models_classes_service_ServiceCall::fromResource($runtimeResource); }
php
public function getRuntime($deliveryId) { $delivery = $this->getResource($deliveryId); if (!$delivery->exists()) { throw new \common_exception_NoContent('Unable to load runtime associated for delivery ' . $deliveryId . ' Delivery probably deleted.'); } $runtimeResource = $delivery->getUniquePropertyValue($this->getProperty(self::PROPERTY_RUNTIME)); return \tao_models_classes_service_ServiceCall::fromResource($runtimeResource); }
[ "public", "function", "getRuntime", "(", "$", "deliveryId", ")", "{", "$", "delivery", "=", "$", "this", "->", "getResource", "(", "$", "deliveryId", ")", ";", "if", "(", "!", "$", "delivery", "->", "exists", "(", ")", ")", "{", "throw", "new", "\\", "common_exception_NoContent", "(", "'Unable to load runtime associated for delivery '", ".", "$", "deliveryId", ".", "' Delivery probably deleted.'", ")", ";", "}", "$", "runtimeResource", "=", "$", "delivery", "->", "getUniquePropertyValue", "(", "$", "this", "->", "getProperty", "(", "self", "::", "PROPERTY_RUNTIME", ")", ")", ";", "return", "\\", "tao_models_classes_service_ServiceCall", "::", "fromResource", "(", "$", "runtimeResource", ")", ";", "}" ]
(non-PHPdoc) @see \oat\taoDelivery\model\RuntimeService::getRuntime()
[ "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/ContainerRuntime.php#L60-L69
oat-sa/extension-tao-delivery-rdf
scripts/RecompileDelivery.php
RecompileDelivery.process
private function process() { if (empty($this->params)) { throw new ResolutionException('Parameters were not given'); } $mode = $this->getMode(); switch ($mode) { case 'list': $this->listAction(); break; case 'compile': $this->compileAction(); break; } }
php
private function process() { if (empty($this->params)) { throw new ResolutionException('Parameters were not given'); } $mode = $this->getMode(); switch ($mode) { case 'list': $this->listAction(); break; case 'compile': $this->compileAction(); break; } }
[ "private", "function", "process", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "params", ")", ")", "{", "throw", "new", "ResolutionException", "(", "'Parameters were not given'", ")", ";", "}", "$", "mode", "=", "$", "this", "->", "getMode", "(", ")", ";", "switch", "(", "$", "mode", ")", "{", "case", "'list'", ":", "$", "this", "->", "listAction", "(", ")", ";", "break", ";", "case", "'compile'", ":", "$", "this", "->", "compileAction", "(", ")", ";", "break", ";", "}", "}" ]
Process action call @throws ResolutionException
[ "Process", "action", "call" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/scripts/RecompileDelivery.php#L105-L120
oat-sa/extension-tao-delivery-rdf
scripts/RecompileDelivery.php
RecompileDelivery.compileAction
private function compileAction() { $deliveryIds = array_slice($this->params, 1); $deliveryClass = new \core_kernel_classes_Class('http://www.tao.lu/Ontologies/TAODelivery.rdf#AssembledDelivery'); $this->report = new Report( Report::TYPE_INFO, 'Recompile deliveries:' ); foreach ($deliveryIds as $deliveryId) { $delivery = new \core_kernel_classes_Resource($deliveryId); if (!$delivery->exists()) { $this->report->add(new Report( Report::TYPE_ERROR, "Delivery $deliveryId does not exists" )); continue; } else if (!$delivery->isInstanceOf($deliveryClass)) { $this->report->add(new Report( Report::TYPE_ERROR, "$deliveryId is not delivery resource" )); continue; } try { $newDelivery = $this->compileDelivery($delivery); } catch (\common_Exception $e){ $this->report->add(new Report( Report::TYPE_ERROR, $e->getMessage() )); } $this->report->add(new Report( Report::TYPE_SUCCESS, "$deliveryId successfully compiled. New Id: {$newDelivery->getUri()}" )); } }
php
private function compileAction() { $deliveryIds = array_slice($this->params, 1); $deliveryClass = new \core_kernel_classes_Class('http://www.tao.lu/Ontologies/TAODelivery.rdf#AssembledDelivery'); $this->report = new Report( Report::TYPE_INFO, 'Recompile deliveries:' ); foreach ($deliveryIds as $deliveryId) { $delivery = new \core_kernel_classes_Resource($deliveryId); if (!$delivery->exists()) { $this->report->add(new Report( Report::TYPE_ERROR, "Delivery $deliveryId does not exists" )); continue; } else if (!$delivery->isInstanceOf($deliveryClass)) { $this->report->add(new Report( Report::TYPE_ERROR, "$deliveryId is not delivery resource" )); continue; } try { $newDelivery = $this->compileDelivery($delivery); } catch (\common_Exception $e){ $this->report->add(new Report( Report::TYPE_ERROR, $e->getMessage() )); } $this->report->add(new Report( Report::TYPE_SUCCESS, "$deliveryId successfully compiled. New Id: {$newDelivery->getUri()}" )); } }
[ "private", "function", "compileAction", "(", ")", "{", "$", "deliveryIds", "=", "array_slice", "(", "$", "this", "->", "params", ",", "1", ")", ";", "$", "deliveryClass", "=", "new", "\\", "core_kernel_classes_Class", "(", "'http://www.tao.lu/Ontologies/TAODelivery.rdf#AssembledDelivery'", ")", ";", "$", "this", "->", "report", "=", "new", "Report", "(", "Report", "::", "TYPE_INFO", ",", "'Recompile deliveries:'", ")", ";", "foreach", "(", "$", "deliveryIds", "as", "$", "deliveryId", ")", "{", "$", "delivery", "=", "new", "\\", "core_kernel_classes_Resource", "(", "$", "deliveryId", ")", ";", "if", "(", "!", "$", "delivery", "->", "exists", "(", ")", ")", "{", "$", "this", "->", "report", "->", "add", "(", "new", "Report", "(", "Report", "::", "TYPE_ERROR", ",", "\"Delivery $deliveryId does not exists\"", ")", ")", ";", "continue", ";", "}", "else", "if", "(", "!", "$", "delivery", "->", "isInstanceOf", "(", "$", "deliveryClass", ")", ")", "{", "$", "this", "->", "report", "->", "add", "(", "new", "Report", "(", "Report", "::", "TYPE_ERROR", ",", "\"$deliveryId is not delivery resource\"", ")", ")", ";", "continue", ";", "}", "try", "{", "$", "newDelivery", "=", "$", "this", "->", "compileDelivery", "(", "$", "delivery", ")", ";", "}", "catch", "(", "\\", "common_Exception", "$", "e", ")", "{", "$", "this", "->", "report", "->", "add", "(", "new", "Report", "(", "Report", "::", "TYPE_ERROR", ",", "$", "e", "->", "getMessage", "(", ")", ")", ")", ";", "}", "$", "this", "->", "report", "->", "add", "(", "new", "Report", "(", "Report", "::", "TYPE_SUCCESS", ",", "\"$deliveryId successfully compiled. New Id: {$newDelivery->getUri()}\"", ")", ")", ";", "}", "}" ]
Recompile deliveries
[ "Recompile", "deliveries" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/scripts/RecompileDelivery.php#L125-L166
oat-sa/extension-tao-delivery-rdf
scripts/RecompileDelivery.php
RecompileDelivery.listAction
private function listAction() { $deliveryClass = new \core_kernel_classes_Class('http://www.tao.lu/Ontologies/TAODelivery.rdf#AssembledDelivery'); $deliveries = $deliveryClass->getInstances(true); $result = []; foreach ($deliveries as $delivery) { /** @var \core_kernel_classes_Resource $delivery*/ $result[] = $delivery->getUri() . ' - ' . $delivery->getLabel(); } $this->report = new Report( Report::TYPE_INFO, implode(PHP_EOL, $result) ); }
php
private function listAction() { $deliveryClass = new \core_kernel_classes_Class('http://www.tao.lu/Ontologies/TAODelivery.rdf#AssembledDelivery'); $deliveries = $deliveryClass->getInstances(true); $result = []; foreach ($deliveries as $delivery) { /** @var \core_kernel_classes_Resource $delivery*/ $result[] = $delivery->getUri() . ' - ' . $delivery->getLabel(); } $this->report = new Report( Report::TYPE_INFO, implode(PHP_EOL, $result) ); }
[ "private", "function", "listAction", "(", ")", "{", "$", "deliveryClass", "=", "new", "\\", "core_kernel_classes_Class", "(", "'http://www.tao.lu/Ontologies/TAODelivery.rdf#AssembledDelivery'", ")", ";", "$", "deliveries", "=", "$", "deliveryClass", "->", "getInstances", "(", "true", ")", ";", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "deliveries", "as", "$", "delivery", ")", "{", "/** @var \\core_kernel_classes_Resource $delivery*/", "$", "result", "[", "]", "=", "$", "delivery", "->", "getUri", "(", ")", ".", "' - '", ".", "$", "delivery", "->", "getLabel", "(", ")", ";", "}", "$", "this", "->", "report", "=", "new", "Report", "(", "Report", "::", "TYPE_INFO", ",", "implode", "(", "PHP_EOL", ",", "$", "result", ")", ")", ";", "}" ]
Show list of all existing deliveries
[ "Show", "list", "of", "all", "existing", "deliveries" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/scripts/RecompileDelivery.php#L171-L184
oat-sa/extension-tao-delivery-rdf
controller/Guest.php
Guest.guest
public function guest() { common_session_SessionManager::endSession(); $session = new GuestTestTakerSession(); common_session_SessionManager::startSession($session); $returnUrl = $this->getServiceLocator()->get(ReturnUrlService::SERVICE_ID)->getReturnUrl(); $this->redirect($returnUrl); }
php
public function guest() { common_session_SessionManager::endSession(); $session = new GuestTestTakerSession(); common_session_SessionManager::startSession($session); $returnUrl = $this->getServiceLocator()->get(ReturnUrlService::SERVICE_ID)->getReturnUrl(); $this->redirect($returnUrl); }
[ "public", "function", "guest", "(", ")", "{", "common_session_SessionManager", "::", "endSession", "(", ")", ";", "$", "session", "=", "new", "GuestTestTakerSession", "(", ")", ";", "common_session_SessionManager", "::", "startSession", "(", "$", "session", ")", ";", "$", "returnUrl", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "ReturnUrlService", "::", "SERVICE_ID", ")", "->", "getReturnUrl", "(", ")", ";", "$", "this", "->", "redirect", "(", "$", "returnUrl", ")", ";", "}" ]
Init guest session and redirect to module index
[ "Init", "guest", "session", "and", "redirect", "to", "module", "index" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/controller/Guest.php#L39-L47
oat-sa/extension-tao-delivery-rdf
model/tasks/ImportAndCompile.php
ImportAndCompile.createTask
public static function createTask($importerId, $file, $customParams = [], $deliveryClassLabel = '') { $serviceManager = ServiceManager::getServiceManager(); $action = new self(); $action->setServiceLocator($serviceManager); $importersService = $serviceManager->get(ImportersService::SERVICE_ID); $importersService->getImporter($importerId); $fileUri = $action->saveFile($file['tmp_name'], $file['name']); /** @var QueueDispatcher $queueDispatcher */ $queueDispatcher = ServiceManager::getServiceManager()->get(QueueDispatcher::SERVICE_ID); return $queueDispatcher->createTask($action, [ self::OPTION_FILE => $fileUri, self::OPTION_IMPORTER => $importerId, self::OPTION_CUSTOM => $customParams, self::OPTION_DELIVERY_LABEL => $deliveryClassLabel, ], null, null, true); }
php
public static function createTask($importerId, $file, $customParams = [], $deliveryClassLabel = '') { $serviceManager = ServiceManager::getServiceManager(); $action = new self(); $action->setServiceLocator($serviceManager); $importersService = $serviceManager->get(ImportersService::SERVICE_ID); $importersService->getImporter($importerId); $fileUri = $action->saveFile($file['tmp_name'], $file['name']); /** @var QueueDispatcher $queueDispatcher */ $queueDispatcher = ServiceManager::getServiceManager()->get(QueueDispatcher::SERVICE_ID); return $queueDispatcher->createTask($action, [ self::OPTION_FILE => $fileUri, self::OPTION_IMPORTER => $importerId, self::OPTION_CUSTOM => $customParams, self::OPTION_DELIVERY_LABEL => $deliveryClassLabel, ], null, null, true); }
[ "public", "static", "function", "createTask", "(", "$", "importerId", ",", "$", "file", ",", "$", "customParams", "=", "[", "]", ",", "$", "deliveryClassLabel", "=", "''", ")", "{", "$", "serviceManager", "=", "ServiceManager", "::", "getServiceManager", "(", ")", ";", "$", "action", "=", "new", "self", "(", ")", ";", "$", "action", "->", "setServiceLocator", "(", "$", "serviceManager", ")", ";", "$", "importersService", "=", "$", "serviceManager", "->", "get", "(", "ImportersService", "::", "SERVICE_ID", ")", ";", "$", "importersService", "->", "getImporter", "(", "$", "importerId", ")", ";", "$", "fileUri", "=", "$", "action", "->", "saveFile", "(", "$", "file", "[", "'tmp_name'", "]", ",", "$", "file", "[", "'name'", "]", ")", ";", "/** @var QueueDispatcher $queueDispatcher */", "$", "queueDispatcher", "=", "ServiceManager", "::", "getServiceManager", "(", ")", "->", "get", "(", "QueueDispatcher", "::", "SERVICE_ID", ")", ";", "return", "$", "queueDispatcher", "->", "createTask", "(", "$", "action", ",", "[", "self", "::", "OPTION_FILE", "=>", "$", "fileUri", ",", "self", "::", "OPTION_IMPORTER", "=>", "$", "importerId", ",", "self", "::", "OPTION_CUSTOM", "=>", "$", "customParams", ",", "self", "::", "OPTION_DELIVERY_LABEL", "=>", "$", "deliveryClassLabel", ",", "]", ",", "null", ",", "null", ",", "true", ")", ";", "}" ]
Create task in queue @param $importerId test importer identifier @param array $file uploaded file @see \tao_helpers_Http::getUploadedFile() @param array $customParams @param string $deliveryClassLabel @return TaskInterface
[ "Create", "task", "in", "queue" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/tasks/ImportAndCompile.php#L178-L197
oat-sa/extension-tao-delivery-rdf
scripts/ToggleGuestAccess.php
ToggleGuestAccess.deactivate
private function deactivate() { $guestAccess = new GuestAccess(); try { if ($this->entryPointService->deactivateEntryPoint( $guestAccess->getId(), EntryPointService::OPTION_PRELOGIN ) ) { $rule = new AccessRule('grant', TaoRoles::ANONYMOUS, 'oat\taoDeliveryRdf\controller\Guest@guest'); AclProxy::revokeRule($rule); return Report::createSuccess('The guest entry point has been correctly deactivated'); } else { return Report::createInfo('The guest entry point was already deactivated'); } } catch (\common_exception_InconsistentData $e) { return Report::createFailure($e->getMessage()); } }
php
private function deactivate() { $guestAccess = new GuestAccess(); try { if ($this->entryPointService->deactivateEntryPoint( $guestAccess->getId(), EntryPointService::OPTION_PRELOGIN ) ) { $rule = new AccessRule('grant', TaoRoles::ANONYMOUS, 'oat\taoDeliveryRdf\controller\Guest@guest'); AclProxy::revokeRule($rule); return Report::createSuccess('The guest entry point has been correctly deactivated'); } else { return Report::createInfo('The guest entry point was already deactivated'); } } catch (\common_exception_InconsistentData $e) { return Report::createFailure($e->getMessage()); } }
[ "private", "function", "deactivate", "(", ")", "{", "$", "guestAccess", "=", "new", "GuestAccess", "(", ")", ";", "try", "{", "if", "(", "$", "this", "->", "entryPointService", "->", "deactivateEntryPoint", "(", "$", "guestAccess", "->", "getId", "(", ")", ",", "EntryPointService", "::", "OPTION_PRELOGIN", ")", ")", "{", "$", "rule", "=", "new", "AccessRule", "(", "'grant'", ",", "TaoRoles", "::", "ANONYMOUS", ",", "'oat\\taoDeliveryRdf\\controller\\Guest@guest'", ")", ";", "AclProxy", "::", "revokeRule", "(", "$", "rule", ")", ";", "return", "Report", "::", "createSuccess", "(", "'The guest entry point has been correctly deactivated'", ")", ";", "}", "else", "{", "return", "Report", "::", "createInfo", "(", "'The guest entry point was already deactivated'", ")", ";", "}", "}", "catch", "(", "\\", "common_exception_InconsistentData", "$", "e", ")", "{", "return", "Report", "::", "createFailure", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "}" ]
Try to deactivate the guest entry point @return Report
[ "Try", "to", "deactivate", "the", "guest", "entry", "point" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/scripts/ToggleGuestAccess.php#L88-L107
oat-sa/extension-tao-delivery-rdf
scripts/ToggleGuestAccess.php
ToggleGuestAccess.activate
private function activate() { $guestAccess = new GuestAccess(); try { $this->entryPointService->activateEntryPoint($guestAccess->getId(), EntryPointService::OPTION_PRELOGIN); $rule = new AccessRule('grant', TaoRoles::ANONYMOUS, 'oat\taoDeliveryRdf\controller\Guest@guest'); AclProxy::applyRule($rule); return Report::createSuccess('The guest entry point has been correctly activated'); } catch (\common_exception_InconsistentData $e) { return Report::createFailure($e->getMessage()); } }
php
private function activate() { $guestAccess = new GuestAccess(); try { $this->entryPointService->activateEntryPoint($guestAccess->getId(), EntryPointService::OPTION_PRELOGIN); $rule = new AccessRule('grant', TaoRoles::ANONYMOUS, 'oat\taoDeliveryRdf\controller\Guest@guest'); AclProxy::applyRule($rule); return Report::createSuccess('The guest entry point has been correctly activated'); } catch (\common_exception_InconsistentData $e) { return Report::createFailure($e->getMessage()); } }
[ "private", "function", "activate", "(", ")", "{", "$", "guestAccess", "=", "new", "GuestAccess", "(", ")", ";", "try", "{", "$", "this", "->", "entryPointService", "->", "activateEntryPoint", "(", "$", "guestAccess", "->", "getId", "(", ")", ",", "EntryPointService", "::", "OPTION_PRELOGIN", ")", ";", "$", "rule", "=", "new", "AccessRule", "(", "'grant'", ",", "TaoRoles", "::", "ANONYMOUS", ",", "'oat\\taoDeliveryRdf\\controller\\Guest@guest'", ")", ";", "AclProxy", "::", "applyRule", "(", "$", "rule", ")", ";", "return", "Report", "::", "createSuccess", "(", "'The guest entry point has been correctly activated'", ")", ";", "}", "catch", "(", "\\", "common_exception_InconsistentData", "$", "e", ")", "{", "return", "Report", "::", "createFailure", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "}" ]
Try to activate the guest entry point @return Report
[ "Try", "to", "activate", "the", "guest", "entry", "point" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/scripts/ToggleGuestAccess.php#L113-L125
oat-sa/extension-tao-delivery-rdf
model/DeliveryArchiveService.php
DeliveryArchiveService.generateNewTmpPath
private function generateNewTmpPath($fileName) { $folder = sys_get_temp_dir().DIRECTORY_SEPARATOR."tmp".md5($fileName. uniqid('', true)).DIRECTORY_SEPARATOR; if (!file_exists($folder)) { mkdir($folder); } $this->tmpDir = $folder; }
php
private function generateNewTmpPath($fileName) { $folder = sys_get_temp_dir().DIRECTORY_SEPARATOR."tmp".md5($fileName. uniqid('', true)).DIRECTORY_SEPARATOR; if (!file_exists($folder)) { mkdir($folder); } $this->tmpDir = $folder; }
[ "private", "function", "generateNewTmpPath", "(", "$", "fileName", ")", "{", "$", "folder", "=", "sys_get_temp_dir", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "\"tmp\"", ".", "md5", "(", "$", "fileName", ".", "uniqid", "(", "''", ",", "true", ")", ")", ".", "DIRECTORY_SEPARATOR", ";", "if", "(", "!", "file_exists", "(", "$", "folder", ")", ")", "{", "mkdir", "(", "$", "folder", ")", ";", "}", "$", "this", "->", "tmpDir", "=", "$", "folder", ";", "}" ]
generate unique tmp folder based on delivery. @param $fileName
[ "generate", "unique", "tmp", "folder", "based", "on", "delivery", "." ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/DeliveryArchiveService.php#L299-L308
oat-sa/extension-tao-delivery-rdf
model/export/AssemblyExporter.php
AssemblyExporter.getExportForm
public function getExportForm(core_kernel_classes_Resource $resource) { if ($resource instanceof core_kernel_classes_Class) { $formData= array('class' => $resource); } else { $formData= array('instance' => $resource); } $form = new ExportForm($formData); return $form->getForm(); }
php
public function getExportForm(core_kernel_classes_Resource $resource) { if ($resource instanceof core_kernel_classes_Class) { $formData= array('class' => $resource); } else { $formData= array('instance' => $resource); } $form = new ExportForm($formData); return $form->getForm(); }
[ "public", "function", "getExportForm", "(", "core_kernel_classes_Resource", "$", "resource", ")", "{", "if", "(", "$", "resource", "instanceof", "core_kernel_classes_Class", ")", "{", "$", "formData", "=", "array", "(", "'class'", "=>", "$", "resource", ")", ";", "}", "else", "{", "$", "formData", "=", "array", "(", "'instance'", "=>", "$", "resource", ")", ";", "}", "$", "form", "=", "new", "ExportForm", "(", "$", "formData", ")", ";", "return", "$", "form", "->", "getForm", "(", ")", ";", "}" ]
(non-PHPdoc) @see tao_models_classes_export_ExportHandler::getExportForm()
[ "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/export/AssemblyExporter.php#L50-L58
oat-sa/extension-tao-delivery-rdf
model/export/AssemblyExporter.php
AssemblyExporter.export
public function export($formValues, $destination) { if (!isset($formValues['exportInstance']) || empty($formValues['exportInstance'])) { throw new \common_Exception('No instance selected'); } $delivery = new core_kernel_classes_Resource($formValues['exportInstance']); $path = ServiceManager::getServiceManager()->get(AssemblerServiceInterface::SERVICE_ID)->exportCompiledDelivery($delivery); return $path; }
php
public function export($formValues, $destination) { if (!isset($formValues['exportInstance']) || empty($formValues['exportInstance'])) { throw new \common_Exception('No instance selected'); } $delivery = new core_kernel_classes_Resource($formValues['exportInstance']); $path = ServiceManager::getServiceManager()->get(AssemblerServiceInterface::SERVICE_ID)->exportCompiledDelivery($delivery); return $path; }
[ "public", "function", "export", "(", "$", "formValues", ",", "$", "destination", ")", "{", "if", "(", "!", "isset", "(", "$", "formValues", "[", "'exportInstance'", "]", ")", "||", "empty", "(", "$", "formValues", "[", "'exportInstance'", "]", ")", ")", "{", "throw", "new", "\\", "common_Exception", "(", "'No instance selected'", ")", ";", "}", "$", "delivery", "=", "new", "core_kernel_classes_Resource", "(", "$", "formValues", "[", "'exportInstance'", "]", ")", ";", "$", "path", "=", "ServiceManager", "::", "getServiceManager", "(", ")", "->", "get", "(", "AssemblerServiceInterface", "::", "SERVICE_ID", ")", "->", "exportCompiledDelivery", "(", "$", "delivery", ")", ";", "return", "$", "path", ";", "}" ]
(non-PHPdoc) @see tao_models_classes_export_ExportHandler::export()
[ "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/export/AssemblyExporter.php#L64-L73
oat-sa/extension-tao-delivery-rdf
controller/RestDelivery.php
RestDelivery.generate
public function generate() { try { if (!$this->hasRequestParameter(self::REST_DELIVERY_TEST_ID)) { throw new \common_exception_MissingParameter(self::REST_DELIVERY_TEST_ID, $this->getRequestURI()); } $test = $this->getResource($this->getRequestParameter(self::REST_DELIVERY_TEST_ID)); if (!$test->exists()) { throw new \common_exception_NotFound('Unable to find a test associated to the given uri.'); } $label = 'Delivery of ' . $test->getLabel(); $deliveryClass = $this->getDeliveryClassByParameters(); $deliveryFactory = $this->getServiceManager()->get(DeliveryFactory::SERVICE_ID); /** @var \common_report_Report $report */ $report = $deliveryFactory->create($deliveryClass, $test, $label); if ($report->getType() == \common_report_Report::TYPE_ERROR) { $this->logInfo('Unable to generate delivery execution ' . 'into taoDeliveryRdf::RestDelivery for test uri ' . $test->getUri()); throw new \common_Exception('Unable to generate delivery execution.'); } $delivery = $report->getData(); /** @var DeliveryFactory $deliveryFactoryService */ $deliveryFactoryService = $this->getServiceManager()->get(DeliveryFactory::SERVICE_ID); $initialProperties = $deliveryFactoryService->getInitialPropertiesFromRequest($this->getRequest()); $delivery = $deliveryFactoryService->setInitialProperties($initialProperties, $delivery); $this->returnSuccess(array('delivery' => $delivery->getUri())); } catch (\Exception $e) { $this->returnFailure($e); } }
php
public function generate() { try { if (!$this->hasRequestParameter(self::REST_DELIVERY_TEST_ID)) { throw new \common_exception_MissingParameter(self::REST_DELIVERY_TEST_ID, $this->getRequestURI()); } $test = $this->getResource($this->getRequestParameter(self::REST_DELIVERY_TEST_ID)); if (!$test->exists()) { throw new \common_exception_NotFound('Unable to find a test associated to the given uri.'); } $label = 'Delivery of ' . $test->getLabel(); $deliveryClass = $this->getDeliveryClassByParameters(); $deliveryFactory = $this->getServiceManager()->get(DeliveryFactory::SERVICE_ID); /** @var \common_report_Report $report */ $report = $deliveryFactory->create($deliveryClass, $test, $label); if ($report->getType() == \common_report_Report::TYPE_ERROR) { $this->logInfo('Unable to generate delivery execution ' . 'into taoDeliveryRdf::RestDelivery for test uri ' . $test->getUri()); throw new \common_Exception('Unable to generate delivery execution.'); } $delivery = $report->getData(); /** @var DeliveryFactory $deliveryFactoryService */ $deliveryFactoryService = $this->getServiceManager()->get(DeliveryFactory::SERVICE_ID); $initialProperties = $deliveryFactoryService->getInitialPropertiesFromRequest($this->getRequest()); $delivery = $deliveryFactoryService->setInitialProperties($initialProperties, $delivery); $this->returnSuccess(array('delivery' => $delivery->getUri())); } catch (\Exception $e) { $this->returnFailure($e); } }
[ "public", "function", "generate", "(", ")", "{", "try", "{", "if", "(", "!", "$", "this", "->", "hasRequestParameter", "(", "self", "::", "REST_DELIVERY_TEST_ID", ")", ")", "{", "throw", "new", "\\", "common_exception_MissingParameter", "(", "self", "::", "REST_DELIVERY_TEST_ID", ",", "$", "this", "->", "getRequestURI", "(", ")", ")", ";", "}", "$", "test", "=", "$", "this", "->", "getResource", "(", "$", "this", "->", "getRequestParameter", "(", "self", "::", "REST_DELIVERY_TEST_ID", ")", ")", ";", "if", "(", "!", "$", "test", "->", "exists", "(", ")", ")", "{", "throw", "new", "\\", "common_exception_NotFound", "(", "'Unable to find a test associated to the given uri.'", ")", ";", "}", "$", "label", "=", "'Delivery of '", ".", "$", "test", "->", "getLabel", "(", ")", ";", "$", "deliveryClass", "=", "$", "this", "->", "getDeliveryClassByParameters", "(", ")", ";", "$", "deliveryFactory", "=", "$", "this", "->", "getServiceManager", "(", ")", "->", "get", "(", "DeliveryFactory", "::", "SERVICE_ID", ")", ";", "/** @var \\common_report_Report $report */", "$", "report", "=", "$", "deliveryFactory", "->", "create", "(", "$", "deliveryClass", ",", "$", "test", ",", "$", "label", ")", ";", "if", "(", "$", "report", "->", "getType", "(", ")", "==", "\\", "common_report_Report", "::", "TYPE_ERROR", ")", "{", "$", "this", "->", "logInfo", "(", "'Unable to generate delivery execution '", ".", "'into taoDeliveryRdf::RestDelivery for test uri '", ".", "$", "test", "->", "getUri", "(", ")", ")", ";", "throw", "new", "\\", "common_Exception", "(", "'Unable to generate delivery execution.'", ")", ";", "}", "$", "delivery", "=", "$", "report", "->", "getData", "(", ")", ";", "/** @var DeliveryFactory $deliveryFactoryService */", "$", "deliveryFactoryService", "=", "$", "this", "->", "getServiceManager", "(", ")", "->", "get", "(", "DeliveryFactory", "::", "SERVICE_ID", ")", ";", "$", "initialProperties", "=", "$", "deliveryFactoryService", "->", "getInitialPropertiesFromRequest", "(", "$", "this", "->", "getRequest", "(", ")", ")", ";", "$", "delivery", "=", "$", "deliveryFactoryService", "->", "setInitialProperties", "(", "$", "initialProperties", ",", "$", "delivery", ")", ";", "$", "this", "->", "returnSuccess", "(", "array", "(", "'delivery'", "=>", "$", "delivery", "->", "getUri", "(", ")", ")", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "returnFailure", "(", "$", "e", ")", ";", "}", "}" ]
Generate a delivery from test uri Test uri has to be set and existing
[ "Generate", "a", "delivery", "from", "test", "uri", "Test", "uri", "has", "to", "be", "set", "and", "existing" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/controller/RestDelivery.php#L65-L99
oat-sa/extension-tao-delivery-rdf
controller/RestDelivery.php
RestDelivery.generateDeferred
public function generateDeferred() { try { if (! $this->hasRequestParameter(self::REST_DELIVERY_TEST_ID)) { throw new \common_exception_MissingParameter(self::REST_DELIVERY_TEST_ID, $this->getRequestURI()); } $test = $this->getResource($this->getRequestParameter(self::REST_DELIVERY_TEST_ID)); if (! $test->exists()) { throw new \common_exception_NotFound('Unable to find a test associated to the given uri.'); } $deliveryClass = $this->getDeliveryClassByParameters(); /** @var DeliveryFactory $deliveryFactoryService */ $deliveryFactoryService = $this->getServiceManager()->get(DeliveryFactory::SERVICE_ID); $initialProperties = $deliveryFactoryService->getInitialPropertiesFromRequest($this->getRequest()); $task = CompileDelivery::createTask($test, $deliveryClass, $initialProperties); $result = [ 'reference_id' => $task->getId() ]; /** @var TaskLogInterface $taskLog */ $taskLog = $this->getServiceManager()->get(TaskLogInterface::SERVICE_ID); $report = $taskLog->getReport($task->getId()); if (!empty($report)) { if ($report instanceof \common_report_Report) { //serialize report to array $report = json_decode($report); } $result['common_report_Report'] = $report; } return $this->returnSuccess($result); } catch (\Exception $e) { $this->returnFailure($e); } }
php
public function generateDeferred() { try { if (! $this->hasRequestParameter(self::REST_DELIVERY_TEST_ID)) { throw new \common_exception_MissingParameter(self::REST_DELIVERY_TEST_ID, $this->getRequestURI()); } $test = $this->getResource($this->getRequestParameter(self::REST_DELIVERY_TEST_ID)); if (! $test->exists()) { throw new \common_exception_NotFound('Unable to find a test associated to the given uri.'); } $deliveryClass = $this->getDeliveryClassByParameters(); /** @var DeliveryFactory $deliveryFactoryService */ $deliveryFactoryService = $this->getServiceManager()->get(DeliveryFactory::SERVICE_ID); $initialProperties = $deliveryFactoryService->getInitialPropertiesFromRequest($this->getRequest()); $task = CompileDelivery::createTask($test, $deliveryClass, $initialProperties); $result = [ 'reference_id' => $task->getId() ]; /** @var TaskLogInterface $taskLog */ $taskLog = $this->getServiceManager()->get(TaskLogInterface::SERVICE_ID); $report = $taskLog->getReport($task->getId()); if (!empty($report)) { if ($report instanceof \common_report_Report) { //serialize report to array $report = json_decode($report); } $result['common_report_Report'] = $report; } return $this->returnSuccess($result); } catch (\Exception $e) { $this->returnFailure($e); } }
[ "public", "function", "generateDeferred", "(", ")", "{", "try", "{", "if", "(", "!", "$", "this", "->", "hasRequestParameter", "(", "self", "::", "REST_DELIVERY_TEST_ID", ")", ")", "{", "throw", "new", "\\", "common_exception_MissingParameter", "(", "self", "::", "REST_DELIVERY_TEST_ID", ",", "$", "this", "->", "getRequestURI", "(", ")", ")", ";", "}", "$", "test", "=", "$", "this", "->", "getResource", "(", "$", "this", "->", "getRequestParameter", "(", "self", "::", "REST_DELIVERY_TEST_ID", ")", ")", ";", "if", "(", "!", "$", "test", "->", "exists", "(", ")", ")", "{", "throw", "new", "\\", "common_exception_NotFound", "(", "'Unable to find a test associated to the given uri.'", ")", ";", "}", "$", "deliveryClass", "=", "$", "this", "->", "getDeliveryClassByParameters", "(", ")", ";", "/** @var DeliveryFactory $deliveryFactoryService */", "$", "deliveryFactoryService", "=", "$", "this", "->", "getServiceManager", "(", ")", "->", "get", "(", "DeliveryFactory", "::", "SERVICE_ID", ")", ";", "$", "initialProperties", "=", "$", "deliveryFactoryService", "->", "getInitialPropertiesFromRequest", "(", "$", "this", "->", "getRequest", "(", ")", ")", ";", "$", "task", "=", "CompileDelivery", "::", "createTask", "(", "$", "test", ",", "$", "deliveryClass", ",", "$", "initialProperties", ")", ";", "$", "result", "=", "[", "'reference_id'", "=>", "$", "task", "->", "getId", "(", ")", "]", ";", "/** @var TaskLogInterface $taskLog */", "$", "taskLog", "=", "$", "this", "->", "getServiceManager", "(", ")", "->", "get", "(", "TaskLogInterface", "::", "SERVICE_ID", ")", ";", "$", "report", "=", "$", "taskLog", "->", "getReport", "(", "$", "task", "->", "getId", "(", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "report", ")", ")", "{", "if", "(", "$", "report", "instanceof", "\\", "common_report_Report", ")", "{", "//serialize report to array", "$", "report", "=", "json_decode", "(", "$", "report", ")", ";", "}", "$", "result", "[", "'common_report_Report'", "]", "=", "$", "report", ";", "}", "return", "$", "this", "->", "returnSuccess", "(", "$", "result", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "returnFailure", "(", "$", "e", ")", ";", "}", "}" ]
Put task to generate a delivery from test uri to the task queue Test uri has to be set and existing
[ "Put", "task", "to", "generate", "a", "delivery", "from", "test", "uri", "to", "the", "task", "queue", "Test", "uri", "has", "to", "be", "set", "and", "existing" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/controller/RestDelivery.php#L105-L146
oat-sa/extension-tao-delivery-rdf
controller/RestDelivery.php
RestDelivery.update
public function update() { try { if ($this->getRequestMethod() !== \Request::HTTP_POST) { throw new \common_exception_NotImplemented('Only post method is accepted to updating delivery'); } if (! $this->hasRequestParameter(self::REST_DELIVERY_SEARCH_PARAMS)) { throw new \common_exception_MissingParameter(self::REST_DELIVERY_SEARCH_PARAMS, $this->getRequestURI()); } $where = json_decode(html_entity_decode($this->getRequestParameter(self::REST_DELIVERY_SEARCH_PARAMS)), true); $propertyValues = $this->getRequestParameters(); unset($propertyValues[self::REST_DELIVERY_SEARCH_PARAMS]); $deliveryModelClass = $this->getDeliveryRootClass(); $deliveries = $deliveryModelClass->searchInstances($where, ['like' => false, 'recursive' => true]); $response = []; /** @var \core_kernel_classes_Resource $delivery */ foreach ($deliveries as $key => $delivery) { foreach ($propertyValues as $rdfKey => $rdfValue) { $rdfKey = \tao_helpers_Uri::decode($rdfKey); $property = $this->getProperty($rdfKey); $delivery->editPropertyValues($property, $rdfValue); } $response[] = ['delivery' => $delivery->getUri()]; } $this->returnSuccess($response); }catch (\Exception $e) { $this->returnFailure($e); } }
php
public function update() { try { if ($this->getRequestMethod() !== \Request::HTTP_POST) { throw new \common_exception_NotImplemented('Only post method is accepted to updating delivery'); } if (! $this->hasRequestParameter(self::REST_DELIVERY_SEARCH_PARAMS)) { throw new \common_exception_MissingParameter(self::REST_DELIVERY_SEARCH_PARAMS, $this->getRequestURI()); } $where = json_decode(html_entity_decode($this->getRequestParameter(self::REST_DELIVERY_SEARCH_PARAMS)), true); $propertyValues = $this->getRequestParameters(); unset($propertyValues[self::REST_DELIVERY_SEARCH_PARAMS]); $deliveryModelClass = $this->getDeliveryRootClass(); $deliveries = $deliveryModelClass->searchInstances($where, ['like' => false, 'recursive' => true]); $response = []; /** @var \core_kernel_classes_Resource $delivery */ foreach ($deliveries as $key => $delivery) { foreach ($propertyValues as $rdfKey => $rdfValue) { $rdfKey = \tao_helpers_Uri::decode($rdfKey); $property = $this->getProperty($rdfKey); $delivery->editPropertyValues($property, $rdfValue); } $response[] = ['delivery' => $delivery->getUri()]; } $this->returnSuccess($response); }catch (\Exception $e) { $this->returnFailure($e); } }
[ "public", "function", "update", "(", ")", "{", "try", "{", "if", "(", "$", "this", "->", "getRequestMethod", "(", ")", "!==", "\\", "Request", "::", "HTTP_POST", ")", "{", "throw", "new", "\\", "common_exception_NotImplemented", "(", "'Only post method is accepted to updating delivery'", ")", ";", "}", "if", "(", "!", "$", "this", "->", "hasRequestParameter", "(", "self", "::", "REST_DELIVERY_SEARCH_PARAMS", ")", ")", "{", "throw", "new", "\\", "common_exception_MissingParameter", "(", "self", "::", "REST_DELIVERY_SEARCH_PARAMS", ",", "$", "this", "->", "getRequestURI", "(", ")", ")", ";", "}", "$", "where", "=", "json_decode", "(", "html_entity_decode", "(", "$", "this", "->", "getRequestParameter", "(", "self", "::", "REST_DELIVERY_SEARCH_PARAMS", ")", ")", ",", "true", ")", ";", "$", "propertyValues", "=", "$", "this", "->", "getRequestParameters", "(", ")", ";", "unset", "(", "$", "propertyValues", "[", "self", "::", "REST_DELIVERY_SEARCH_PARAMS", "]", ")", ";", "$", "deliveryModelClass", "=", "$", "this", "->", "getDeliveryRootClass", "(", ")", ";", "$", "deliveries", "=", "$", "deliveryModelClass", "->", "searchInstances", "(", "$", "where", ",", "[", "'like'", "=>", "false", ",", "'recursive'", "=>", "true", "]", ")", ";", "$", "response", "=", "[", "]", ";", "/** @var \\core_kernel_classes_Resource $delivery */", "foreach", "(", "$", "deliveries", "as", "$", "key", "=>", "$", "delivery", ")", "{", "foreach", "(", "$", "propertyValues", "as", "$", "rdfKey", "=>", "$", "rdfValue", ")", "{", "$", "rdfKey", "=", "\\", "tao_helpers_Uri", "::", "decode", "(", "$", "rdfKey", ")", ";", "$", "property", "=", "$", "this", "->", "getProperty", "(", "$", "rdfKey", ")", ";", "$", "delivery", "->", "editPropertyValues", "(", "$", "property", ",", "$", "rdfValue", ")", ";", "}", "$", "response", "[", "]", "=", "[", "'delivery'", "=>", "$", "delivery", "->", "getUri", "(", ")", "]", ";", "}", "$", "this", "->", "returnSuccess", "(", "$", "response", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "returnFailure", "(", "$", "e", ")", ";", "}", "}" ]
Update delivery by parameters
[ "Update", "delivery", "by", "parameters" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/controller/RestDelivery.php#L151-L184
oat-sa/extension-tao-delivery-rdf
controller/RestDelivery.php
RestDelivery.updateDeferred
public function updateDeferred() { try { if ($this->getRequestMethod() !== \Request::HTTP_POST) { throw new \common_exception_NotImplemented('Only post method is accepted to updating delivery'); } if (! $this->hasRequestParameter(self::REST_DELIVERY_SEARCH_PARAMS)) { throw new \common_exception_MissingParameter(self::REST_DELIVERY_SEARCH_PARAMS, $this->getRequestURI()); } $where = json_decode(html_entity_decode($this->getRequestParameter(self::REST_DELIVERY_SEARCH_PARAMS)), true); $propertyValues = $this->getRequestParameters(); unset($propertyValues[self::REST_DELIVERY_SEARCH_PARAMS]); $task = UpdateDelivery::createTask($where, $propertyValues); $result = [ 'reference_id' => $task->getId() ]; /** @var TaskLogInterface $taskLog */ $taskLog = $this->getServiceManager()->get(TaskLogInterface::SERVICE_ID); $report = $taskLog->getReport($task->getId()); if (!empty($report)) { if ($report instanceof \common_report_Report) { //serialize report to array $report = json_decode($report); } $result['common_report_Report'] = $report; } return $this->returnSuccess($result); }catch (\Exception $e) { $this->returnFailure($e); } }
php
public function updateDeferred() { try { if ($this->getRequestMethod() !== \Request::HTTP_POST) { throw new \common_exception_NotImplemented('Only post method is accepted to updating delivery'); } if (! $this->hasRequestParameter(self::REST_DELIVERY_SEARCH_PARAMS)) { throw new \common_exception_MissingParameter(self::REST_DELIVERY_SEARCH_PARAMS, $this->getRequestURI()); } $where = json_decode(html_entity_decode($this->getRequestParameter(self::REST_DELIVERY_SEARCH_PARAMS)), true); $propertyValues = $this->getRequestParameters(); unset($propertyValues[self::REST_DELIVERY_SEARCH_PARAMS]); $task = UpdateDelivery::createTask($where, $propertyValues); $result = [ 'reference_id' => $task->getId() ]; /** @var TaskLogInterface $taskLog */ $taskLog = $this->getServiceManager()->get(TaskLogInterface::SERVICE_ID); $report = $taskLog->getReport($task->getId()); if (!empty($report)) { if ($report instanceof \common_report_Report) { //serialize report to array $report = json_decode($report); } $result['common_report_Report'] = $report; } return $this->returnSuccess($result); }catch (\Exception $e) { $this->returnFailure($e); } }
[ "public", "function", "updateDeferred", "(", ")", "{", "try", "{", "if", "(", "$", "this", "->", "getRequestMethod", "(", ")", "!==", "\\", "Request", "::", "HTTP_POST", ")", "{", "throw", "new", "\\", "common_exception_NotImplemented", "(", "'Only post method is accepted to updating delivery'", ")", ";", "}", "if", "(", "!", "$", "this", "->", "hasRequestParameter", "(", "self", "::", "REST_DELIVERY_SEARCH_PARAMS", ")", ")", "{", "throw", "new", "\\", "common_exception_MissingParameter", "(", "self", "::", "REST_DELIVERY_SEARCH_PARAMS", ",", "$", "this", "->", "getRequestURI", "(", ")", ")", ";", "}", "$", "where", "=", "json_decode", "(", "html_entity_decode", "(", "$", "this", "->", "getRequestParameter", "(", "self", "::", "REST_DELIVERY_SEARCH_PARAMS", ")", ")", ",", "true", ")", ";", "$", "propertyValues", "=", "$", "this", "->", "getRequestParameters", "(", ")", ";", "unset", "(", "$", "propertyValues", "[", "self", "::", "REST_DELIVERY_SEARCH_PARAMS", "]", ")", ";", "$", "task", "=", "UpdateDelivery", "::", "createTask", "(", "$", "where", ",", "$", "propertyValues", ")", ";", "$", "result", "=", "[", "'reference_id'", "=>", "$", "task", "->", "getId", "(", ")", "]", ";", "/** @var TaskLogInterface $taskLog */", "$", "taskLog", "=", "$", "this", "->", "getServiceManager", "(", ")", "->", "get", "(", "TaskLogInterface", "::", "SERVICE_ID", ")", ";", "$", "report", "=", "$", "taskLog", "->", "getReport", "(", "$", "task", "->", "getId", "(", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "report", ")", ")", "{", "if", "(", "$", "report", "instanceof", "\\", "common_report_Report", ")", "{", "//serialize report to array", "$", "report", "=", "json_decode", "(", "$", "report", ")", ";", "}", "$", "result", "[", "'common_report_Report'", "]", "=", "$", "report", ";", "}", "return", "$", "this", "->", "returnSuccess", "(", "$", "result", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "returnFailure", "(", "$", "e", ")", ";", "}", "}" ]
Update delivery by parameters
[ "Update", "delivery", "by", "parameters" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/controller/RestDelivery.php#L189-L222
oat-sa/extension-tao-delivery-rdf
controller/RestDelivery.php
RestDelivery.deleteDeferred
public function deleteDeferred() { try { if ($this->getRequestMethod() !== \Request::HTTP_DELETE) { throw new \common_exception_NotImplemented('Only delete method is accepted to deleting delivery'); } if (!$this->hasRequestParameter('uri')) { throw new \common_exception_MissingParameter('uri', $this->getRequestURI()); } $uri = $this->getRequestParameter('uri'); $delivery = $this->getResource($uri); if (!$delivery->exists()) { $this->returnFailure(new \common_exception_NotFound('Delivery has not been found')); } /** @var QueueDispatcher $queueDispatcher */ $queueDispatcher = $this->getServiceManager()->get(QueueDispatcher::SERVICE_ID); $task = new DeliveryDeleteTask(); $task->setServiceLocator($this->getServiceLocator()); $taskParameters = ['deliveryId' => $uri]; $task = $queueDispatcher->createTask($task, $taskParameters, __('Deleting of "%s"', $delivery->getLabel()), null, true); $data = $this->getTaskLogReturnData( $task->getId(), DeliveryDeleteTask::class ); $this->returnSuccess($data); } catch (\Exception $e) { $this->returnFailure($e); } }
php
public function deleteDeferred() { try { if ($this->getRequestMethod() !== \Request::HTTP_DELETE) { throw new \common_exception_NotImplemented('Only delete method is accepted to deleting delivery'); } if (!$this->hasRequestParameter('uri')) { throw new \common_exception_MissingParameter('uri', $this->getRequestURI()); } $uri = $this->getRequestParameter('uri'); $delivery = $this->getResource($uri); if (!$delivery->exists()) { $this->returnFailure(new \common_exception_NotFound('Delivery has not been found')); } /** @var QueueDispatcher $queueDispatcher */ $queueDispatcher = $this->getServiceManager()->get(QueueDispatcher::SERVICE_ID); $task = new DeliveryDeleteTask(); $task->setServiceLocator($this->getServiceLocator()); $taskParameters = ['deliveryId' => $uri]; $task = $queueDispatcher->createTask($task, $taskParameters, __('Deleting of "%s"', $delivery->getLabel()), null, true); $data = $this->getTaskLogReturnData( $task->getId(), DeliveryDeleteTask::class ); $this->returnSuccess($data); } catch (\Exception $e) { $this->returnFailure($e); } }
[ "public", "function", "deleteDeferred", "(", ")", "{", "try", "{", "if", "(", "$", "this", "->", "getRequestMethod", "(", ")", "!==", "\\", "Request", "::", "HTTP_DELETE", ")", "{", "throw", "new", "\\", "common_exception_NotImplemented", "(", "'Only delete method is accepted to deleting delivery'", ")", ";", "}", "if", "(", "!", "$", "this", "->", "hasRequestParameter", "(", "'uri'", ")", ")", "{", "throw", "new", "\\", "common_exception_MissingParameter", "(", "'uri'", ",", "$", "this", "->", "getRequestURI", "(", ")", ")", ";", "}", "$", "uri", "=", "$", "this", "->", "getRequestParameter", "(", "'uri'", ")", ";", "$", "delivery", "=", "$", "this", "->", "getResource", "(", "$", "uri", ")", ";", "if", "(", "!", "$", "delivery", "->", "exists", "(", ")", ")", "{", "$", "this", "->", "returnFailure", "(", "new", "\\", "common_exception_NotFound", "(", "'Delivery has not been found'", ")", ")", ";", "}", "/** @var QueueDispatcher $queueDispatcher */", "$", "queueDispatcher", "=", "$", "this", "->", "getServiceManager", "(", ")", "->", "get", "(", "QueueDispatcher", "::", "SERVICE_ID", ")", ";", "$", "task", "=", "new", "DeliveryDeleteTask", "(", ")", ";", "$", "task", "->", "setServiceLocator", "(", "$", "this", "->", "getServiceLocator", "(", ")", ")", ";", "$", "taskParameters", "=", "[", "'deliveryId'", "=>", "$", "uri", "]", ";", "$", "task", "=", "$", "queueDispatcher", "->", "createTask", "(", "$", "task", ",", "$", "taskParameters", ",", "__", "(", "'Deleting of \"%s\"'", ",", "$", "delivery", "->", "getLabel", "(", ")", ")", ",", "null", ",", "true", ")", ";", "$", "data", "=", "$", "this", "->", "getTaskLogReturnData", "(", "$", "task", "->", "getId", "(", ")", ",", "DeliveryDeleteTask", "::", "class", ")", ";", "$", "this", "->", "returnSuccess", "(", "$", "data", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "returnFailure", "(", "$", "e", ")", ";", "}", "}" ]
Delete delivery by URI
[ "Delete", "delivery", "by", "URI" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/controller/RestDelivery.php#L227-L262
oat-sa/extension-tao-delivery-rdf
controller/RestDelivery.php
RestDelivery.get
public function get() { try { if ($this->getRequestMethod() !== \Request::HTTP_GET) { throw new \common_exception_NotImplemented('Only get method is accepted to getting deliveries'); } $limit = 0; if ($this->hasRequestParameter('limit')) { $limit = $this->getRequestParameter('limit'); if (!is_numeric($limit) || (int)$limit != $limit || $limit < 0) { throw new \common_exception_ValidationFailed('limit', '\'Limit\' should be a positive integer'); } } $offset = 0; if ($this->hasRequestParameter('offset')) { $offset = $this->getRequestParameter('offset'); if (!is_numeric($offset) || (int)$offset != $offset || $offset < 0) { throw new \common_exception_ValidationFailed('offset', '\'Offset\' should be a positive integer'); } } $service = DeliveryAssemblyService::singleton(); /** @var \core_kernel_classes_Resource[] $deliveries */ $deliveries = $service->getAllAssemblies(); $overallCount = count($deliveries); if ($offset || $limit) { if ($overallCount <= $offset) { throw new \common_exception_ValidationFailed('offset', '\'Offset\' is too large'); } $deliveries = array_slice($deliveries, $offset, $limit); } $mappedDeliveries = []; foreach ($deliveries as $delivery) { $mappedDeliveries[] = [ 'uri' => $delivery->getUri(), 'label' => $delivery->getLabel(), ]; } $response = [ 'items' => $mappedDeliveries, 'overallCount' => $overallCount, ]; $this->returnSuccess($response); } catch (\Exception $e) { $this->returnFailure($e); } }
php
public function get() { try { if ($this->getRequestMethod() !== \Request::HTTP_GET) { throw new \common_exception_NotImplemented('Only get method is accepted to getting deliveries'); } $limit = 0; if ($this->hasRequestParameter('limit')) { $limit = $this->getRequestParameter('limit'); if (!is_numeric($limit) || (int)$limit != $limit || $limit < 0) { throw new \common_exception_ValidationFailed('limit', '\'Limit\' should be a positive integer'); } } $offset = 0; if ($this->hasRequestParameter('offset')) { $offset = $this->getRequestParameter('offset'); if (!is_numeric($offset) || (int)$offset != $offset || $offset < 0) { throw new \common_exception_ValidationFailed('offset', '\'Offset\' should be a positive integer'); } } $service = DeliveryAssemblyService::singleton(); /** @var \core_kernel_classes_Resource[] $deliveries */ $deliveries = $service->getAllAssemblies(); $overallCount = count($deliveries); if ($offset || $limit) { if ($overallCount <= $offset) { throw new \common_exception_ValidationFailed('offset', '\'Offset\' is too large'); } $deliveries = array_slice($deliveries, $offset, $limit); } $mappedDeliveries = []; foreach ($deliveries as $delivery) { $mappedDeliveries[] = [ 'uri' => $delivery->getUri(), 'label' => $delivery->getLabel(), ]; } $response = [ 'items' => $mappedDeliveries, 'overallCount' => $overallCount, ]; $this->returnSuccess($response); } catch (\Exception $e) { $this->returnFailure($e); } }
[ "public", "function", "get", "(", ")", "{", "try", "{", "if", "(", "$", "this", "->", "getRequestMethod", "(", ")", "!==", "\\", "Request", "::", "HTTP_GET", ")", "{", "throw", "new", "\\", "common_exception_NotImplemented", "(", "'Only get method is accepted to getting deliveries'", ")", ";", "}", "$", "limit", "=", "0", ";", "if", "(", "$", "this", "->", "hasRequestParameter", "(", "'limit'", ")", ")", "{", "$", "limit", "=", "$", "this", "->", "getRequestParameter", "(", "'limit'", ")", ";", "if", "(", "!", "is_numeric", "(", "$", "limit", ")", "||", "(", "int", ")", "$", "limit", "!=", "$", "limit", "||", "$", "limit", "<", "0", ")", "{", "throw", "new", "\\", "common_exception_ValidationFailed", "(", "'limit'", ",", "'\\'Limit\\' should be a positive integer'", ")", ";", "}", "}", "$", "offset", "=", "0", ";", "if", "(", "$", "this", "->", "hasRequestParameter", "(", "'offset'", ")", ")", "{", "$", "offset", "=", "$", "this", "->", "getRequestParameter", "(", "'offset'", ")", ";", "if", "(", "!", "is_numeric", "(", "$", "offset", ")", "||", "(", "int", ")", "$", "offset", "!=", "$", "offset", "||", "$", "offset", "<", "0", ")", "{", "throw", "new", "\\", "common_exception_ValidationFailed", "(", "'offset'", ",", "'\\'Offset\\' should be a positive integer'", ")", ";", "}", "}", "$", "service", "=", "DeliveryAssemblyService", "::", "singleton", "(", ")", ";", "/** @var \\core_kernel_classes_Resource[] $deliveries */", "$", "deliveries", "=", "$", "service", "->", "getAllAssemblies", "(", ")", ";", "$", "overallCount", "=", "count", "(", "$", "deliveries", ")", ";", "if", "(", "$", "offset", "||", "$", "limit", ")", "{", "if", "(", "$", "overallCount", "<=", "$", "offset", ")", "{", "throw", "new", "\\", "common_exception_ValidationFailed", "(", "'offset'", ",", "'\\'Offset\\' is too large'", ")", ";", "}", "$", "deliveries", "=", "array_slice", "(", "$", "deliveries", ",", "$", "offset", ",", "$", "limit", ")", ";", "}", "$", "mappedDeliveries", "=", "[", "]", ";", "foreach", "(", "$", "deliveries", "as", "$", "delivery", ")", "{", "$", "mappedDeliveries", "[", "]", "=", "[", "'uri'", "=>", "$", "delivery", "->", "getUri", "(", ")", ",", "'label'", "=>", "$", "delivery", "->", "getLabel", "(", ")", ",", "]", ";", "}", "$", "response", "=", "[", "'items'", "=>", "$", "mappedDeliveries", ",", "'overallCount'", "=>", "$", "overallCount", ",", "]", ";", "$", "this", "->", "returnSuccess", "(", "$", "response", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "returnFailure", "(", "$", "e", ")", ";", "}", "}" ]
List all deliveries or paginated range
[ "List", "all", "deliveries", "or", "paginated", "range" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/controller/RestDelivery.php#L267-L318
oat-sa/extension-tao-delivery-rdf
controller/RestDelivery.php
RestDelivery.getStatus
public function getStatus() { try { if (!$this->hasRequestParameter(self::TASK_ID_PARAM)) { throw new \common_exception_MissingParameter(self::TASK_ID_PARAM, $this->getRequestURI()); } $data = $this->getTaskLogReturnData( $this->getRequestParameter(self::TASK_ID_PARAM), CompileDelivery::class ); $children = $this->getStatusesForChildren($this->getRequestParameter(self::TASK_ID_PARAM)); $data['children'] = $children; $this->returnSuccess($data); } catch (\Exception $e) { $this->returnFailure($e); } }
php
public function getStatus() { try { if (!$this->hasRequestParameter(self::TASK_ID_PARAM)) { throw new \common_exception_MissingParameter(self::TASK_ID_PARAM, $this->getRequestURI()); } $data = $this->getTaskLogReturnData( $this->getRequestParameter(self::TASK_ID_PARAM), CompileDelivery::class ); $children = $this->getStatusesForChildren($this->getRequestParameter(self::TASK_ID_PARAM)); $data['children'] = $children; $this->returnSuccess($data); } catch (\Exception $e) { $this->returnFailure($e); } }
[ "public", "function", "getStatus", "(", ")", "{", "try", "{", "if", "(", "!", "$", "this", "->", "hasRequestParameter", "(", "self", "::", "TASK_ID_PARAM", ")", ")", "{", "throw", "new", "\\", "common_exception_MissingParameter", "(", "self", "::", "TASK_ID_PARAM", ",", "$", "this", "->", "getRequestURI", "(", ")", ")", ";", "}", "$", "data", "=", "$", "this", "->", "getTaskLogReturnData", "(", "$", "this", "->", "getRequestParameter", "(", "self", "::", "TASK_ID_PARAM", ")", ",", "CompileDelivery", "::", "class", ")", ";", "$", "children", "=", "$", "this", "->", "getStatusesForChildren", "(", "$", "this", "->", "getRequestParameter", "(", "self", "::", "TASK_ID_PARAM", ")", ")", ";", "$", "data", "[", "'children'", "]", "=", "$", "children", ";", "$", "this", "->", "returnSuccess", "(", "$", "data", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "returnFailure", "(", "$", "e", ")", ";", "}", "}" ]
Action to retrieve test compilation task status from queue
[ "Action", "to", "retrieve", "test", "compilation", "task", "status", "from", "queue" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/controller/RestDelivery.php#L323-L340
oat-sa/extension-tao-delivery-rdf
controller/RestDelivery.php
RestDelivery.createClass
public function createClass() { try { $class = $this->createSubClass($this->getDeliveryRootClass()); $result = [ 'message' => __('Class successfully created.'), 'delivery-uri' => $class->getUri(), ]; $this->returnSuccess($result); } catch (\common_exception_ClassAlreadyExists $e) { $result = [ 'message' => $e->getMessage(), 'delivery-uri' => $e->getClass()->getUri(), ]; $this->returnSuccess($result); } catch (\Exception $e) { $this->returnFailure($e); } }
php
public function createClass() { try { $class = $this->createSubClass($this->getDeliveryRootClass()); $result = [ 'message' => __('Class successfully created.'), 'delivery-uri' => $class->getUri(), ]; $this->returnSuccess($result); } catch (\common_exception_ClassAlreadyExists $e) { $result = [ 'message' => $e->getMessage(), 'delivery-uri' => $e->getClass()->getUri(), ]; $this->returnSuccess($result); } catch (\Exception $e) { $this->returnFailure($e); } }
[ "public", "function", "createClass", "(", ")", "{", "try", "{", "$", "class", "=", "$", "this", "->", "createSubClass", "(", "$", "this", "->", "getDeliveryRootClass", "(", ")", ")", ";", "$", "result", "=", "[", "'message'", "=>", "__", "(", "'Class successfully created.'", ")", ",", "'delivery-uri'", "=>", "$", "class", "->", "getUri", "(", ")", ",", "]", ";", "$", "this", "->", "returnSuccess", "(", "$", "result", ")", ";", "}", "catch", "(", "\\", "common_exception_ClassAlreadyExists", "$", "e", ")", "{", "$", "result", "=", "[", "'message'", "=>", "$", "e", "->", "getMessage", "(", ")", ",", "'delivery-uri'", "=>", "$", "e", "->", "getClass", "(", ")", "->", "getUri", "(", ")", ",", "]", ";", "$", "this", "->", "returnSuccess", "(", "$", "result", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "returnFailure", "(", "$", "e", ")", ";", "}", "}" ]
Create a Delivery Class Label parameter is mandatory If parent class parameter is an uri of valid delivery class, new class will be created under it If not parent class parameter is provided, class will be created under root class Comment parameter is not mandatory, used to describe new created class @return \core_kernel_classes_Class
[ "Create", "a", "Delivery", "Class" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/controller/RestDelivery.php#L417-L437
oat-sa/extension-tao-delivery-rdf
controller/RestDelivery.php
RestDelivery.getDeliveryClassByParameters
protected function getDeliveryClassByParameters() { $rootDeliveryClass = $this->getDeliveryRootClass(); // If an uri is provided, check if it's an existing delivery class if ($this->hasRequestParameter(self::REST_DELIVERY_CLASS_URI)) { $deliveryClass = $this->getClass($this->getRequestParameter(self::REST_DELIVERY_CLASS_URI)); if ($deliveryClass == $rootDeliveryClass || ($deliveryClass->exists() && $deliveryClass->isSubClassOf($rootDeliveryClass))) { return $deliveryClass; } throw new \common_Exception(__('Delivery class uri provided is not a valid delivery class.')); } if ($this->hasRequestParameter(self::REST_DELIVERY_CLASS_LABEL)) { $label = $this->getRequestParameter(self::REST_DELIVERY_CLASS_LABEL); $deliveryClasses = $rootDeliveryClass->getSubClasses(true); $classes = [$rootDeliveryClass->getUri()]; foreach ($deliveryClasses as $class) { $classes[] = $class->getUri(); } /** @var ComplexSearchService $search */ $search = $this->getServiceManager()->get(ComplexSearchService::SERVICE_ID); $queryBuilder = $search->query(); $criteria = $queryBuilder->newQuery() ->add(OntologyRdfs::RDFS_LABEL)->equals($label) ->add(OntologyRdfs::RDFS_SUBCLASSOF)->in($classes) ; $queryBuilder->setCriteria($criteria); $result = $search->getGateway()->search($queryBuilder); switch ($result->count()) { case 0: throw new \common_exception_NotFound(__('Delivery with label "%s" not found', $label)); case 1: return $this->getClass($result->current()->getUri()); default: $availableClasses = []; foreach ($result as $raw) { $availableClasses[] = $raw->getUri(); } throw new \common_exception_NotFound(__('Multiple delivery class found for label "%s": %s', $label, implode(',',$availableClasses) )); } } return $rootDeliveryClass; }
php
protected function getDeliveryClassByParameters() { $rootDeliveryClass = $this->getDeliveryRootClass(); // If an uri is provided, check if it's an existing delivery class if ($this->hasRequestParameter(self::REST_DELIVERY_CLASS_URI)) { $deliveryClass = $this->getClass($this->getRequestParameter(self::REST_DELIVERY_CLASS_URI)); if ($deliveryClass == $rootDeliveryClass || ($deliveryClass->exists() && $deliveryClass->isSubClassOf($rootDeliveryClass))) { return $deliveryClass; } throw new \common_Exception(__('Delivery class uri provided is not a valid delivery class.')); } if ($this->hasRequestParameter(self::REST_DELIVERY_CLASS_LABEL)) { $label = $this->getRequestParameter(self::REST_DELIVERY_CLASS_LABEL); $deliveryClasses = $rootDeliveryClass->getSubClasses(true); $classes = [$rootDeliveryClass->getUri()]; foreach ($deliveryClasses as $class) { $classes[] = $class->getUri(); } /** @var ComplexSearchService $search */ $search = $this->getServiceManager()->get(ComplexSearchService::SERVICE_ID); $queryBuilder = $search->query(); $criteria = $queryBuilder->newQuery() ->add(OntologyRdfs::RDFS_LABEL)->equals($label) ->add(OntologyRdfs::RDFS_SUBCLASSOF)->in($classes) ; $queryBuilder->setCriteria($criteria); $result = $search->getGateway()->search($queryBuilder); switch ($result->count()) { case 0: throw new \common_exception_NotFound(__('Delivery with label "%s" not found', $label)); case 1: return $this->getClass($result->current()->getUri()); default: $availableClasses = []; foreach ($result as $raw) { $availableClasses[] = $raw->getUri(); } throw new \common_exception_NotFound(__('Multiple delivery class found for label "%s": %s', $label, implode(',',$availableClasses) )); } } return $rootDeliveryClass; }
[ "protected", "function", "getDeliveryClassByParameters", "(", ")", "{", "$", "rootDeliveryClass", "=", "$", "this", "->", "getDeliveryRootClass", "(", ")", ";", "// If an uri is provided, check if it's an existing delivery class", "if", "(", "$", "this", "->", "hasRequestParameter", "(", "self", "::", "REST_DELIVERY_CLASS_URI", ")", ")", "{", "$", "deliveryClass", "=", "$", "this", "->", "getClass", "(", "$", "this", "->", "getRequestParameter", "(", "self", "::", "REST_DELIVERY_CLASS_URI", ")", ")", ";", "if", "(", "$", "deliveryClass", "==", "$", "rootDeliveryClass", "||", "(", "$", "deliveryClass", "->", "exists", "(", ")", "&&", "$", "deliveryClass", "->", "isSubClassOf", "(", "$", "rootDeliveryClass", ")", ")", ")", "{", "return", "$", "deliveryClass", ";", "}", "throw", "new", "\\", "common_Exception", "(", "__", "(", "'Delivery class uri provided is not a valid delivery class.'", ")", ")", ";", "}", "if", "(", "$", "this", "->", "hasRequestParameter", "(", "self", "::", "REST_DELIVERY_CLASS_LABEL", ")", ")", "{", "$", "label", "=", "$", "this", "->", "getRequestParameter", "(", "self", "::", "REST_DELIVERY_CLASS_LABEL", ")", ";", "$", "deliveryClasses", "=", "$", "rootDeliveryClass", "->", "getSubClasses", "(", "true", ")", ";", "$", "classes", "=", "[", "$", "rootDeliveryClass", "->", "getUri", "(", ")", "]", ";", "foreach", "(", "$", "deliveryClasses", "as", "$", "class", ")", "{", "$", "classes", "[", "]", "=", "$", "class", "->", "getUri", "(", ")", ";", "}", "/** @var ComplexSearchService $search */", "$", "search", "=", "$", "this", "->", "getServiceManager", "(", ")", "->", "get", "(", "ComplexSearchService", "::", "SERVICE_ID", ")", ";", "$", "queryBuilder", "=", "$", "search", "->", "query", "(", ")", ";", "$", "criteria", "=", "$", "queryBuilder", "->", "newQuery", "(", ")", "->", "add", "(", "OntologyRdfs", "::", "RDFS_LABEL", ")", "->", "equals", "(", "$", "label", ")", "->", "add", "(", "OntologyRdfs", "::", "RDFS_SUBCLASSOF", ")", "->", "in", "(", "$", "classes", ")", ";", "$", "queryBuilder", "->", "setCriteria", "(", "$", "criteria", ")", ";", "$", "result", "=", "$", "search", "->", "getGateway", "(", ")", "->", "search", "(", "$", "queryBuilder", ")", ";", "switch", "(", "$", "result", "->", "count", "(", ")", ")", "{", "case", "0", ":", "throw", "new", "\\", "common_exception_NotFound", "(", "__", "(", "'Delivery with label \"%s\" not found'", ",", "$", "label", ")", ")", ";", "case", "1", ":", "return", "$", "this", "->", "getClass", "(", "$", "result", "->", "current", "(", ")", "->", "getUri", "(", ")", ")", ";", "default", ":", "$", "availableClasses", "=", "[", "]", ";", "foreach", "(", "$", "result", "as", "$", "raw", ")", "{", "$", "availableClasses", "[", "]", "=", "$", "raw", "->", "getUri", "(", ")", ";", "}", "throw", "new", "\\", "common_exception_NotFound", "(", "__", "(", "'Multiple delivery class found for label \"%s\": %s'", ",", "$", "label", ",", "implode", "(", "','", ",", "$", "availableClasses", ")", ")", ")", ";", "}", "}", "return", "$", "rootDeliveryClass", ";", "}" ]
Get a delivery class based on parameters If an uri parameter is provided, and it is a delivery class, this delivery class is returned If a label parameter is provided, and only one delivery class has this label, this delivery class is returned @return \core_kernel_classes_Class @throws \common_Exception @throws \common_exception_NotFound
[ "Get", "a", "delivery", "class", "based", "on", "parameters" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/controller/RestDelivery.php#L449-L499
oat-sa/extension-tao-delivery-rdf
model/import/AssemblyImportHandler.php
AssemblyImportHandler.import
public function import($class, $form, $userId = null) { $fileInfo = $form->getValue('source'); //import for CSV if(isset($fileInfo)){ \helpers_TimeOutHelper::setTimeOutLimit(\helpers_TimeOutHelper::MEDIUM); //get the services instances we will need $itemService = \taoItems_models_classes_ItemsService::singleton(); $uploadedFile = $fileInfo['uploaded_file']; $uploadedFileBaseName = basename($uploadedFile); // uploaded file name contains an extra prefix that we have to remove. $uploadedFileBaseName = preg_replace('/^([0-9a-z])+_/', '', $uploadedFileBaseName, 1); $uploadedFileBaseName = preg_replace('/.zip|.ZIP$/', '', $uploadedFileBaseName); $validate = count($form->getValue('disable_validation')) == 0 ? true : false; try { $importer = new Assembler(); $report = $importer->importDelivery($class, $uploadedFile); } catch (\common_Exception $e) { $report = common_report_Report::createFailure(__('An error occured during the import')); if ($e instanceof \common_exception_UserReadableException) { $report->add($e); } } \tao_helpers_File::remove($uploadedFile); \helpers_TimeOutHelper::reset(); } else { throw new \common_exception_Error('No file provided as parameter \'source\' for Delivery Assembly import'); } return $report; }
php
public function import($class, $form, $userId = null) { $fileInfo = $form->getValue('source'); //import for CSV if(isset($fileInfo)){ \helpers_TimeOutHelper::setTimeOutLimit(\helpers_TimeOutHelper::MEDIUM); //get the services instances we will need $itemService = \taoItems_models_classes_ItemsService::singleton(); $uploadedFile = $fileInfo['uploaded_file']; $uploadedFileBaseName = basename($uploadedFile); // uploaded file name contains an extra prefix that we have to remove. $uploadedFileBaseName = preg_replace('/^([0-9a-z])+_/', '', $uploadedFileBaseName, 1); $uploadedFileBaseName = preg_replace('/.zip|.ZIP$/', '', $uploadedFileBaseName); $validate = count($form->getValue('disable_validation')) == 0 ? true : false; try { $importer = new Assembler(); $report = $importer->importDelivery($class, $uploadedFile); } catch (\common_Exception $e) { $report = common_report_Report::createFailure(__('An error occured during the import')); if ($e instanceof \common_exception_UserReadableException) { $report->add($e); } } \tao_helpers_File::remove($uploadedFile); \helpers_TimeOutHelper::reset(); } else { throw new \common_exception_Error('No file provided as parameter \'source\' for Delivery Assembly import'); } return $report; }
[ "public", "function", "import", "(", "$", "class", ",", "$", "form", ",", "$", "userId", "=", "null", ")", "{", "$", "fileInfo", "=", "$", "form", "->", "getValue", "(", "'source'", ")", ";", "//import for CSV", "if", "(", "isset", "(", "$", "fileInfo", ")", ")", "{", "\\", "helpers_TimeOutHelper", "::", "setTimeOutLimit", "(", "\\", "helpers_TimeOutHelper", "::", "MEDIUM", ")", ";", "//get the services instances we will need", "$", "itemService", "=", "\\", "taoItems_models_classes_ItemsService", "::", "singleton", "(", ")", ";", "$", "uploadedFile", "=", "$", "fileInfo", "[", "'uploaded_file'", "]", ";", "$", "uploadedFileBaseName", "=", "basename", "(", "$", "uploadedFile", ")", ";", "// uploaded file name contains an extra prefix that we have to remove.", "$", "uploadedFileBaseName", "=", "preg_replace", "(", "'/^([0-9a-z])+_/'", ",", "''", ",", "$", "uploadedFileBaseName", ",", "1", ")", ";", "$", "uploadedFileBaseName", "=", "preg_replace", "(", "'/.zip|.ZIP$/'", ",", "''", ",", "$", "uploadedFileBaseName", ")", ";", "$", "validate", "=", "count", "(", "$", "form", "->", "getValue", "(", "'disable_validation'", ")", ")", "==", "0", "?", "true", ":", "false", ";", "try", "{", "$", "importer", "=", "new", "Assembler", "(", ")", ";", "$", "report", "=", "$", "importer", "->", "importDelivery", "(", "$", "class", ",", "$", "uploadedFile", ")", ";", "}", "catch", "(", "\\", "common_Exception", "$", "e", ")", "{", "$", "report", "=", "common_report_Report", "::", "createFailure", "(", "__", "(", "'An error occured during the import'", ")", ")", ";", "if", "(", "$", "e", "instanceof", "\\", "common_exception_UserReadableException", ")", "{", "$", "report", "->", "add", "(", "$", "e", ")", ";", "}", "}", "\\", "tao_helpers_File", "::", "remove", "(", "$", "uploadedFile", ")", ";", "\\", "helpers_TimeOutHelper", "::", "reset", "(", ")", ";", "}", "else", "{", "throw", "new", "\\", "common_exception_Error", "(", "'No file provided as parameter \\'source\\' for Delivery Assembly import'", ")", ";", "}", "return", "$", "report", ";", "}" ]
(non-PHPdoc) @see tao_models_classes_import_ImportHandler::import()
[ "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/import/AssemblyImportHandler.php#L56-L93
oat-sa/extension-tao-delivery-rdf
model/DeliveryContainerService.php
DeliveryContainerService.getProviders
public function getProviders(DeliveryExecution $execution) { $serviceManager = $this->getServiceManager(); $providerService = $serviceManager->get(TestProviderService::SERVICE_ID); $providers = $providerService->getAllProviders(); return array_filter($providers, function ($provider) { return !is_null($provider) && $provider->isActive(); }); }
php
public function getProviders(DeliveryExecution $execution) { $serviceManager = $this->getServiceManager(); $providerService = $serviceManager->get(TestProviderService::SERVICE_ID); $providers = $providerService->getAllProviders(); return array_filter($providers, function ($provider) { return !is_null($provider) && $provider->isActive(); }); }
[ "public", "function", "getProviders", "(", "DeliveryExecution", "$", "execution", ")", "{", "$", "serviceManager", "=", "$", "this", "->", "getServiceManager", "(", ")", ";", "$", "providerService", "=", "$", "serviceManager", "->", "get", "(", "TestProviderService", "::", "SERVICE_ID", ")", ";", "$", "providers", "=", "$", "providerService", "->", "getAllProviders", "(", ")", ";", "return", "array_filter", "(", "$", "providers", ",", "function", "(", "$", "provider", ")", "{", "return", "!", "is_null", "(", "$", "provider", ")", "&&", "$", "provider", "->", "isActive", "(", ")", ";", "}", ")", ";", "}" ]
Get the list of providers for the current execution @param DeliveryExecution $execution @return array the list of providers
[ "Get", "the", "list", "of", "providers", "for", "the", "current", "execution" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/DeliveryContainerService.php#L63-L71
oat-sa/extension-tao-delivery-rdf
model/DeliveryContainerService.php
DeliveryContainerService.getPlugins
public function getPlugins(DeliveryExecution $deliveryExecution) { $serviceManager = $this->getServiceManager(); $pluginService = $serviceManager->get(TestPluginService::SERVICE_ID); $testRunnerFeatureService = $serviceManager->get(TestRunnerFeatureService::SERVICE_ID); $allPlugins = $pluginService->getAllPlugins(); $allTestRunnerFeatures = $testRunnerFeatureService->getAll(); $activeTestRunnerFeaturesIds = $this->getActiveFeatures($deliveryExecution->getDelivery()); // If test runner features are defined, we check if we need to disable some plugins accordingly if (count($allTestRunnerFeatures) > 0) { $pluginsToDisable = []; foreach ($allTestRunnerFeatures as $feature) { if (!in_array($feature->getId(), $activeTestRunnerFeaturesIds)) { $pluginsToDisable = array_merge($pluginsToDisable, $feature->getPluginsIds()); } } foreach ($allPlugins as $plugin) { if (!is_null($plugin) && in_array($plugin->getId(), $pluginsToDisable)) { $plugin->setActive(false); } } } // return the list of active plugins return array_filter($allPlugins, function ($plugin) { return !is_null($plugin) && $plugin->isActive(); }); }
php
public function getPlugins(DeliveryExecution $deliveryExecution) { $serviceManager = $this->getServiceManager(); $pluginService = $serviceManager->get(TestPluginService::SERVICE_ID); $testRunnerFeatureService = $serviceManager->get(TestRunnerFeatureService::SERVICE_ID); $allPlugins = $pluginService->getAllPlugins(); $allTestRunnerFeatures = $testRunnerFeatureService->getAll(); $activeTestRunnerFeaturesIds = $this->getActiveFeatures($deliveryExecution->getDelivery()); // If test runner features are defined, we check if we need to disable some plugins accordingly if (count($allTestRunnerFeatures) > 0) { $pluginsToDisable = []; foreach ($allTestRunnerFeatures as $feature) { if (!in_array($feature->getId(), $activeTestRunnerFeaturesIds)) { $pluginsToDisable = array_merge($pluginsToDisable, $feature->getPluginsIds()); } } foreach ($allPlugins as $plugin) { if (!is_null($plugin) && in_array($plugin->getId(), $pluginsToDisable)) { $plugin->setActive(false); } } } // return the list of active plugins return array_filter($allPlugins, function ($plugin) { return !is_null($plugin) && $plugin->isActive(); }); }
[ "public", "function", "getPlugins", "(", "DeliveryExecution", "$", "deliveryExecution", ")", "{", "$", "serviceManager", "=", "$", "this", "->", "getServiceManager", "(", ")", ";", "$", "pluginService", "=", "$", "serviceManager", "->", "get", "(", "TestPluginService", "::", "SERVICE_ID", ")", ";", "$", "testRunnerFeatureService", "=", "$", "serviceManager", "->", "get", "(", "TestRunnerFeatureService", "::", "SERVICE_ID", ")", ";", "$", "allPlugins", "=", "$", "pluginService", "->", "getAllPlugins", "(", ")", ";", "$", "allTestRunnerFeatures", "=", "$", "testRunnerFeatureService", "->", "getAll", "(", ")", ";", "$", "activeTestRunnerFeaturesIds", "=", "$", "this", "->", "getActiveFeatures", "(", "$", "deliveryExecution", "->", "getDelivery", "(", ")", ")", ";", "// If test runner features are defined, we check if we need to disable some plugins accordingly", "if", "(", "count", "(", "$", "allTestRunnerFeatures", ")", ">", "0", ")", "{", "$", "pluginsToDisable", "=", "[", "]", ";", "foreach", "(", "$", "allTestRunnerFeatures", "as", "$", "feature", ")", "{", "if", "(", "!", "in_array", "(", "$", "feature", "->", "getId", "(", ")", ",", "$", "activeTestRunnerFeaturesIds", ")", ")", "{", "$", "pluginsToDisable", "=", "array_merge", "(", "$", "pluginsToDisable", ",", "$", "feature", "->", "getPluginsIds", "(", ")", ")", ";", "}", "}", "foreach", "(", "$", "allPlugins", "as", "$", "plugin", ")", "{", "if", "(", "!", "is_null", "(", "$", "plugin", ")", "&&", "in_array", "(", "$", "plugin", "->", "getId", "(", ")", ",", "$", "pluginsToDisable", ")", ")", "{", "$", "plugin", "->", "setActive", "(", "false", ")", ";", "}", "}", "}", "// return the list of active plugins", "return", "array_filter", "(", "$", "allPlugins", ",", "function", "(", "$", "plugin", ")", "{", "return", "!", "is_null", "(", "$", "plugin", ")", "&&", "$", "plugin", "->", "isActive", "(", ")", ";", "}", ")", ";", "}" ]
Get the list of active plugins for the current execution @param DeliveryExecution $deliveryExecution @return TestPlugin[] the list of plugins
[ "Get", "the", "list", "of", "active", "plugins", "for", "the", "current", "execution" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/DeliveryContainerService.php#L78-L110
oat-sa/extension-tao-delivery-rdf
model/import/AssemblerService.php
AssemblerService.exportCompiledDelivery
public function exportCompiledDelivery(core_kernel_classes_Resource $compiledDelivery, $fsExportPath = '') { $this->logDebug("Exporting Delivery Assembly '" . $compiledDelivery->getUri() . "'..."); $fileName = \tao_helpers_Display::textCleaner($compiledDelivery->getLabel()).'.zip'; $path = \tao_helpers_File::concat(array(\tao_helpers_Export::getExportPath(), $fileName)); if (!\tao_helpers_File::securityCheck($path, true)) { throw new \Exception('Unauthorized file name'); } // If such a target zip file exists, remove it from local filesystem. It prevents some synchronicity issues // to occur while dealing with ZIP Archives (not explained yet). if (file_exists($path)) { unlink($path); } $zipArchive = new \ZipArchive(); if ($zipArchive->open($path, \ZipArchive::CREATE) !== true) { throw new \Exception('Unable to create archive at '.$path); } $this->doExportCompiledDelivery($path, $compiledDelivery, $zipArchive); $zipArchive->close(); if (!empty($fsExportPath)) { $this->logDebug("Writing Delivery Assembly '" . $compiledDelivery->getUri() . "' into shared file system at location '${fsExportPath}'..."); $fsExportPath = trim($fsExportPath); $fsExportPath = ltrim($fsExportPath,"/\\"); $zipArchiveHandler = fopen($path, 'r'); $this->getExportDirectory()->getFile($fsExportPath)->put($zipArchiveHandler); fclose($zipArchiveHandler); } return $path; }
php
public function exportCompiledDelivery(core_kernel_classes_Resource $compiledDelivery, $fsExportPath = '') { $this->logDebug("Exporting Delivery Assembly '" . $compiledDelivery->getUri() . "'..."); $fileName = \tao_helpers_Display::textCleaner($compiledDelivery->getLabel()).'.zip'; $path = \tao_helpers_File::concat(array(\tao_helpers_Export::getExportPath(), $fileName)); if (!\tao_helpers_File::securityCheck($path, true)) { throw new \Exception('Unauthorized file name'); } // If such a target zip file exists, remove it from local filesystem. It prevents some synchronicity issues // to occur while dealing with ZIP Archives (not explained yet). if (file_exists($path)) { unlink($path); } $zipArchive = new \ZipArchive(); if ($zipArchive->open($path, \ZipArchive::CREATE) !== true) { throw new \Exception('Unable to create archive at '.$path); } $this->doExportCompiledDelivery($path, $compiledDelivery, $zipArchive); $zipArchive->close(); if (!empty($fsExportPath)) { $this->logDebug("Writing Delivery Assembly '" . $compiledDelivery->getUri() . "' into shared file system at location '${fsExportPath}'..."); $fsExportPath = trim($fsExportPath); $fsExportPath = ltrim($fsExportPath,"/\\"); $zipArchiveHandler = fopen($path, 'r'); $this->getExportDirectory()->getFile($fsExportPath)->put($zipArchiveHandler); fclose($zipArchiveHandler); } return $path; }
[ "public", "function", "exportCompiledDelivery", "(", "core_kernel_classes_Resource", "$", "compiledDelivery", ",", "$", "fsExportPath", "=", "''", ")", "{", "$", "this", "->", "logDebug", "(", "\"Exporting Delivery Assembly '\"", ".", "$", "compiledDelivery", "->", "getUri", "(", ")", ".", "\"'...\"", ")", ";", "$", "fileName", "=", "\\", "tao_helpers_Display", "::", "textCleaner", "(", "$", "compiledDelivery", "->", "getLabel", "(", ")", ")", ".", "'.zip'", ";", "$", "path", "=", "\\", "tao_helpers_File", "::", "concat", "(", "array", "(", "\\", "tao_helpers_Export", "::", "getExportPath", "(", ")", ",", "$", "fileName", ")", ")", ";", "if", "(", "!", "\\", "tao_helpers_File", "::", "securityCheck", "(", "$", "path", ",", "true", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Unauthorized file name'", ")", ";", "}", "// If such a target zip file exists, remove it from local filesystem. It prevents some synchronicity issues", "// to occur while dealing with ZIP Archives (not explained yet).", "if", "(", "file_exists", "(", "$", "path", ")", ")", "{", "unlink", "(", "$", "path", ")", ";", "}", "$", "zipArchive", "=", "new", "\\", "ZipArchive", "(", ")", ";", "if", "(", "$", "zipArchive", "->", "open", "(", "$", "path", ",", "\\", "ZipArchive", "::", "CREATE", ")", "!==", "true", ")", "{", "throw", "new", "\\", "Exception", "(", "'Unable to create archive at '", ".", "$", "path", ")", ";", "}", "$", "this", "->", "doExportCompiledDelivery", "(", "$", "path", ",", "$", "compiledDelivery", ",", "$", "zipArchive", ")", ";", "$", "zipArchive", "->", "close", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "fsExportPath", ")", ")", "{", "$", "this", "->", "logDebug", "(", "\"Writing Delivery Assembly '\"", ".", "$", "compiledDelivery", "->", "getUri", "(", ")", ".", "\"' into shared file system at location '${fsExportPath}'...\"", ")", ";", "$", "fsExportPath", "=", "trim", "(", "$", "fsExportPath", ")", ";", "$", "fsExportPath", "=", "ltrim", "(", "$", "fsExportPath", ",", "\"/\\\\\"", ")", ";", "$", "zipArchiveHandler", "=", "fopen", "(", "$", "path", ",", "'r'", ")", ";", "$", "this", "->", "getExportDirectory", "(", ")", "->", "getFile", "(", "$", "fsExportPath", ")", "->", "put", "(", "$", "zipArchiveHandler", ")", ";", "fclose", "(", "$", "zipArchiveHandler", ")", ";", "}", "return", "$", "path", ";", "}" ]
export a compiled delivery into an archive @param core_kernel_classes_Resource $compiledDelivery @param string $fsExportPath @throws \Exception @return string
[ "export", "a", "compiled", "delivery", "into", "an", "archive" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/import/AssemblerService.php#L180-L215
oat-sa/extension-tao-delivery-rdf
model/import/AssemblerService.php
AssemblerService.doExportCompiledDelivery
protected function doExportCompiledDelivery($path, core_kernel_classes_Resource $compiledDelivery, \ZipArchive $zipArchive) { $taoDeliveryVersion = \common_ext_ExtensionsManager::singleton()->getInstalledVersion('taoDelivery'); $data = array( 'dir' => array(), 'label' => $compiledDelivery->getLabel(), 'version' => $taoDeliveryVersion ); $directories = $compiledDelivery->getPropertyValues(new core_kernel_classes_Property(DeliveryAssemblyService::PROPERTY_DELIVERY_DIRECTORY)); foreach ($directories as $id) { $directory = \tao_models_classes_service_FileStorage::singleton()->getDirectoryById($id); $files = $directory->getIterator(); foreach ($files as $file) { \tao_helpers_File::addFilesToZip($zipArchive, $directory->readPsrStream($file), $directory->getRelativePath() . $file); } $data['dir'][$id] = $directory->getRelativePath(); } $runtime = $compiledDelivery->getUniquePropertyValue(new core_kernel_classes_Property(DeliveryAssemblyService::PROPERTY_DELIVERY_RUNTIME)); $serviceCall = \tao_models_classes_service_ServiceCall::fromResource($runtime); $data['runtime'] = base64_encode($serviceCall->serializeToString()); $rdfExporter = new \tao_models_classes_export_RdfExporter(); $rdfdata = $rdfExporter->getRdfString(array($compiledDelivery)); if (!$zipArchive->addFromString('delivery.rdf', $rdfdata)) { throw new \common_Exception('Unable to add metadata to exported delivery assembly'); } $data['meta'] = 'delivery.rdf'; $content = json_encode($data); if (!$zipArchive->addFromString(self::MANIFEST_FILE, $content)) { $zipArchive->close(); unlink($path); throw new \common_Exception('Unable to add manifest to exported delivery assembly'); } }
php
protected function doExportCompiledDelivery($path, core_kernel_classes_Resource $compiledDelivery, \ZipArchive $zipArchive) { $taoDeliveryVersion = \common_ext_ExtensionsManager::singleton()->getInstalledVersion('taoDelivery'); $data = array( 'dir' => array(), 'label' => $compiledDelivery->getLabel(), 'version' => $taoDeliveryVersion ); $directories = $compiledDelivery->getPropertyValues(new core_kernel_classes_Property(DeliveryAssemblyService::PROPERTY_DELIVERY_DIRECTORY)); foreach ($directories as $id) { $directory = \tao_models_classes_service_FileStorage::singleton()->getDirectoryById($id); $files = $directory->getIterator(); foreach ($files as $file) { \tao_helpers_File::addFilesToZip($zipArchive, $directory->readPsrStream($file), $directory->getRelativePath() . $file); } $data['dir'][$id] = $directory->getRelativePath(); } $runtime = $compiledDelivery->getUniquePropertyValue(new core_kernel_classes_Property(DeliveryAssemblyService::PROPERTY_DELIVERY_RUNTIME)); $serviceCall = \tao_models_classes_service_ServiceCall::fromResource($runtime); $data['runtime'] = base64_encode($serviceCall->serializeToString()); $rdfExporter = new \tao_models_classes_export_RdfExporter(); $rdfdata = $rdfExporter->getRdfString(array($compiledDelivery)); if (!$zipArchive->addFromString('delivery.rdf', $rdfdata)) { throw new \common_Exception('Unable to add metadata to exported delivery assembly'); } $data['meta'] = 'delivery.rdf'; $content = json_encode($data); if (!$zipArchive->addFromString(self::MANIFEST_FILE, $content)) { $zipArchive->close(); unlink($path); throw new \common_Exception('Unable to add manifest to exported delivery assembly'); } }
[ "protected", "function", "doExportCompiledDelivery", "(", "$", "path", ",", "core_kernel_classes_Resource", "$", "compiledDelivery", ",", "\\", "ZipArchive", "$", "zipArchive", ")", "{", "$", "taoDeliveryVersion", "=", "\\", "common_ext_ExtensionsManager", "::", "singleton", "(", ")", "->", "getInstalledVersion", "(", "'taoDelivery'", ")", ";", "$", "data", "=", "array", "(", "'dir'", "=>", "array", "(", ")", ",", "'label'", "=>", "$", "compiledDelivery", "->", "getLabel", "(", ")", ",", "'version'", "=>", "$", "taoDeliveryVersion", ")", ";", "$", "directories", "=", "$", "compiledDelivery", "->", "getPropertyValues", "(", "new", "core_kernel_classes_Property", "(", "DeliveryAssemblyService", "::", "PROPERTY_DELIVERY_DIRECTORY", ")", ")", ";", "foreach", "(", "$", "directories", "as", "$", "id", ")", "{", "$", "directory", "=", "\\", "tao_models_classes_service_FileStorage", "::", "singleton", "(", ")", "->", "getDirectoryById", "(", "$", "id", ")", ";", "$", "files", "=", "$", "directory", "->", "getIterator", "(", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "\\", "tao_helpers_File", "::", "addFilesToZip", "(", "$", "zipArchive", ",", "$", "directory", "->", "readPsrStream", "(", "$", "file", ")", ",", "$", "directory", "->", "getRelativePath", "(", ")", ".", "$", "file", ")", ";", "}", "$", "data", "[", "'dir'", "]", "[", "$", "id", "]", "=", "$", "directory", "->", "getRelativePath", "(", ")", ";", "}", "$", "runtime", "=", "$", "compiledDelivery", "->", "getUniquePropertyValue", "(", "new", "core_kernel_classes_Property", "(", "DeliveryAssemblyService", "::", "PROPERTY_DELIVERY_RUNTIME", ")", ")", ";", "$", "serviceCall", "=", "\\", "tao_models_classes_service_ServiceCall", "::", "fromResource", "(", "$", "runtime", ")", ";", "$", "data", "[", "'runtime'", "]", "=", "base64_encode", "(", "$", "serviceCall", "->", "serializeToString", "(", ")", ")", ";", "$", "rdfExporter", "=", "new", "\\", "tao_models_classes_export_RdfExporter", "(", ")", ";", "$", "rdfdata", "=", "$", "rdfExporter", "->", "getRdfString", "(", "array", "(", "$", "compiledDelivery", ")", ")", ";", "if", "(", "!", "$", "zipArchive", "->", "addFromString", "(", "'delivery.rdf'", ",", "$", "rdfdata", ")", ")", "{", "throw", "new", "\\", "common_Exception", "(", "'Unable to add metadata to exported delivery assembly'", ")", ";", "}", "$", "data", "[", "'meta'", "]", "=", "'delivery.rdf'", ";", "$", "content", "=", "json_encode", "(", "$", "data", ")", ";", "if", "(", "!", "$", "zipArchive", "->", "addFromString", "(", "self", "::", "MANIFEST_FILE", ",", "$", "content", ")", ")", "{", "$", "zipArchive", "->", "close", "(", ")", ";", "unlink", "(", "$", "path", ")", ";", "throw", "new", "\\", "common_Exception", "(", "'Unable to add manifest to exported delivery assembly'", ")", ";", "}", "}" ]
Do Export Compiled Delivery Method containing the main behavior of exporting a compiled delivery into a ZIP archive. For developers wanting to override this method, the following information has to be taken into account: - The value of the $zipArgive argument is an already open ZipArchive object. - The method must keep the archive open after its execution (calling code will take care of it). @param $path @param core_kernel_classes_Resource $compiledDelivery @param \ZipArchive $zipArchive @throws \common_Exception @throws \core_kernel_classes_EmptyProperty
[ "Do", "Export", "Compiled", "Delivery" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/import/AssemblerService.php#L233-L270
oat-sa/extension-tao-delivery-rdf
model/GroupAssignment.php
GroupAssignment.getAssignments
public function getAssignments(User $user) { $assignments = array(); foreach ($this->getAssignmentFactories($user) as $factory) { $assignments[] = $factory->toAssignment(); } return $this->orderAssignments($assignments); }
php
public function getAssignments(User $user) { $assignments = array(); foreach ($this->getAssignmentFactories($user) as $factory) { $assignments[] = $factory->toAssignment(); } return $this->orderAssignments($assignments); }
[ "public", "function", "getAssignments", "(", "User", "$", "user", ")", "{", "$", "assignments", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getAssignmentFactories", "(", "$", "user", ")", "as", "$", "factory", ")", "{", "$", "assignments", "[", "]", "=", "$", "factory", "->", "toAssignment", "(", ")", ";", "}", "return", "$", "this", "->", "orderAssignments", "(", "$", "assignments", ")", ";", "}" ]
(non-PHPdoc) @see \oat\taoDelivery\model\AssignmentService::getAssignments()
[ "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/GroupAssignment.php#L55-L63
oat-sa/extension-tao-delivery-rdf
model/GroupAssignment.php
GroupAssignment.isUserExcluded
protected function isUserExcluded(\core_kernel_classes_Resource $delivery, User $user){ $excludedUsers = $delivery->getPropertyValues(new \core_kernel_classes_Property(DeliveryContainerService::PROPERTY_EXCLUDED_SUBJECTS)); return in_array($user->getIdentifier(), $excludedUsers); }
php
protected function isUserExcluded(\core_kernel_classes_Resource $delivery, User $user){ $excludedUsers = $delivery->getPropertyValues(new \core_kernel_classes_Property(DeliveryContainerService::PROPERTY_EXCLUDED_SUBJECTS)); return in_array($user->getIdentifier(), $excludedUsers); }
[ "protected", "function", "isUserExcluded", "(", "\\", "core_kernel_classes_Resource", "$", "delivery", ",", "User", "$", "user", ")", "{", "$", "excludedUsers", "=", "$", "delivery", "->", "getPropertyValues", "(", "new", "\\", "core_kernel_classes_Property", "(", "DeliveryContainerService", "::", "PROPERTY_EXCLUDED_SUBJECTS", ")", ")", ";", "return", "in_array", "(", "$", "user", "->", "getIdentifier", "(", ")", ",", "$", "excludedUsers", ")", ";", "}" ]
Check if a user is excluded from a delivery @param core_kernel_classes_Resource $delivery @param User $user the URI of the user to check @return boolean true if excluded
[ "Check", "if", "a", "user", "is", "excluded", "from", "a", "delivery" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/GroupAssignment.php#L169-L172
oat-sa/extension-tao-delivery-rdf
model/GroupAssignment.php
GroupAssignment.getGuestAccessDeliveries
public function getGuestAccessDeliveries() { $class = new core_kernel_classes_Class(DeliveryAssemblyService::CLASS_URI); return $class->searchInstances( array( DeliveryContainerService::PROPERTY_ACCESS_SETTINGS => DeliveryAssemblyService::PROPERTY_DELIVERY_GUEST_ACCESS ), array('recursive' => true) ); }
php
public function getGuestAccessDeliveries() { $class = new core_kernel_classes_Class(DeliveryAssemblyService::CLASS_URI); return $class->searchInstances( array( DeliveryContainerService::PROPERTY_ACCESS_SETTINGS => DeliveryAssemblyService::PROPERTY_DELIVERY_GUEST_ACCESS ), array('recursive' => true) ); }
[ "public", "function", "getGuestAccessDeliveries", "(", ")", "{", "$", "class", "=", "new", "core_kernel_classes_Class", "(", "DeliveryAssemblyService", "::", "CLASS_URI", ")", ";", "return", "$", "class", "->", "searchInstances", "(", "array", "(", "DeliveryContainerService", "::", "PROPERTY_ACCESS_SETTINGS", "=>", "DeliveryAssemblyService", "::", "PROPERTY_DELIVERY_GUEST_ACCESS", ")", ",", "array", "(", "'recursive'", "=>", "true", ")", ")", ";", "}" ]
Search for deliveries configured for guest access @return array
[ "Search", "for", "deliveries", "configured", "for", "guest", "access" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/GroupAssignment.php#L179-L189
oat-sa/extension-tao-delivery-rdf
model/GroupAssignment.php
GroupAssignment.hasDeliveryGuestAccess
protected function hasDeliveryGuestAccess(core_kernel_classes_Resource $delivery ) { $returnValue = false; $properties = $delivery->getPropertiesValues(array( new core_kernel_classes_Property(DeliveryContainerService::PROPERTY_ACCESS_SETTINGS ), )); $propAccessSettings = current($properties[DeliveryContainerService::PROPERTY_ACCESS_SETTINGS ]); $accessSetting = (!(is_object($propAccessSettings)) or ($propAccessSettings=="")) ? null : $propAccessSettings->getUri(); if( !is_null($accessSetting) ){ $returnValue = ($accessSetting === DeliveryAssemblyService::PROPERTY_DELIVERY_GUEST_ACCESS); } return $returnValue; }
php
protected function hasDeliveryGuestAccess(core_kernel_classes_Resource $delivery ) { $returnValue = false; $properties = $delivery->getPropertiesValues(array( new core_kernel_classes_Property(DeliveryContainerService::PROPERTY_ACCESS_SETTINGS ), )); $propAccessSettings = current($properties[DeliveryContainerService::PROPERTY_ACCESS_SETTINGS ]); $accessSetting = (!(is_object($propAccessSettings)) or ($propAccessSettings=="")) ? null : $propAccessSettings->getUri(); if( !is_null($accessSetting) ){ $returnValue = ($accessSetting === DeliveryAssemblyService::PROPERTY_DELIVERY_GUEST_ACCESS); } return $returnValue; }
[ "protected", "function", "hasDeliveryGuestAccess", "(", "core_kernel_classes_Resource", "$", "delivery", ")", "{", "$", "returnValue", "=", "false", ";", "$", "properties", "=", "$", "delivery", "->", "getPropertiesValues", "(", "array", "(", "new", "core_kernel_classes_Property", "(", "DeliveryContainerService", "::", "PROPERTY_ACCESS_SETTINGS", ")", ",", ")", ")", ";", "$", "propAccessSettings", "=", "current", "(", "$", "properties", "[", "DeliveryContainerService", "::", "PROPERTY_ACCESS_SETTINGS", "]", ")", ";", "$", "accessSetting", "=", "(", "!", "(", "is_object", "(", "$", "propAccessSettings", ")", ")", "or", "(", "$", "propAccessSettings", "==", "\"\"", ")", ")", "?", "null", ":", "$", "propAccessSettings", "->", "getUri", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "accessSetting", ")", ")", "{", "$", "returnValue", "=", "(", "$", "accessSetting", "===", "DeliveryAssemblyService", "::", "PROPERTY_DELIVERY_GUEST_ACCESS", ")", ";", "}", "return", "$", "returnValue", ";", "}" ]
Check if delivery configured for guest access @param core_kernel_classes_Resource $delivery @return bool @throws \common_exception_InvalidArgumentType
[ "Check", "if", "delivery", "configured", "for", "guest", "access" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/GroupAssignment.php#L246-L261
oat-sa/extension-tao-delivery-rdf
model/GroupAssignment.php
GroupAssignment.areWeInRange
protected function areWeInRange($startDate, $endDate){ return (empty($startDate) || date_create() >= $startDate) && (empty($endDate) || date_create() <= $endDate); }
php
protected function areWeInRange($startDate, $endDate){ return (empty($startDate) || date_create() >= $startDate) && (empty($endDate) || date_create() <= $endDate); }
[ "protected", "function", "areWeInRange", "(", "$", "startDate", ",", "$", "endDate", ")", "{", "return", "(", "empty", "(", "$", "startDate", ")", "||", "date_create", "(", ")", ">=", "$", "startDate", ")", "&&", "(", "empty", "(", "$", "endDate", ")", "||", "date_create", "(", ")", "<=", "$", "endDate", ")", ";", "}" ]
Check if the date are in range @param type $startDate @param type $endDate @return boolean true if in range
[ "Check", "if", "the", "date", "are", "in", "range" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/GroupAssignment.php#L317-L320
oat-sa/extension-tao-delivery-rdf
model/GroupAssignment.php
GroupAssignment.orderAssignments
protected function orderAssignments(array $assignments) { usort($assignments, function ($a, $b) { return $a->getDisplayOrder() - $b->getDisplayOrder(); }); return $assignments; }
php
protected function orderAssignments(array $assignments) { usort($assignments, function ($a, $b) { return $a->getDisplayOrder() - $b->getDisplayOrder(); }); return $assignments; }
[ "protected", "function", "orderAssignments", "(", "array", "$", "assignments", ")", "{", "usort", "(", "$", "assignments", ",", "function", "(", "$", "a", ",", "$", "b", ")", "{", "return", "$", "a", "->", "getDisplayOrder", "(", ")", "-", "$", "b", "->", "getDisplayOrder", "(", ")", ";", "}", ")", ";", "return", "$", "assignments", ";", "}" ]
Order Assignments of a given user. By default, this method relies on the taoDelivery:DisplayOrder property to order the assignments (Ascending order). However, implementers extending the GroupAssignment class are encouraged to override this method if they need another behaviour. @param array $assignments An array of assignments. @return array The $assignments array ordered.
[ "Order", "Assignments", "of", "a", "given", "user", "." ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/GroupAssignment.php#L333-L339
oat-sa/extension-tao-delivery-rdf
scripts/tools/DeliveryExecutionArchive.php
DeliveryExecutionArchive.process
private function process() { $time_start = microtime(true); if (empty($this->params)) { throw new ResolutionException('Parameters were not given'); } $option = $this->getOptionUsed(); switch ($option) { case 'list': $this->listAction(); break; case 'unarchive': $this->unArchiveAction(); break; case 'archive': $this->archiveAction(); break; case 'delete': $this->deleteArchivesAction(); break; } $time_end = microtime(true); $execution_time = ($time_end - $time_start)/60; $this->report->add(new Report(Report::TYPE_INFO, 'Time:' . round($execution_time, 4) .' Minutes.' )); }
php
private function process() { $time_start = microtime(true); if (empty($this->params)) { throw new ResolutionException('Parameters were not given'); } $option = $this->getOptionUsed(); switch ($option) { case 'list': $this->listAction(); break; case 'unarchive': $this->unArchiveAction(); break; case 'archive': $this->archiveAction(); break; case 'delete': $this->deleteArchivesAction(); break; } $time_end = microtime(true); $execution_time = ($time_end - $time_start)/60; $this->report->add(new Report(Report::TYPE_INFO, 'Time:' . round($execution_time, 4) .' Minutes.' )); }
[ "private", "function", "process", "(", ")", "{", "$", "time_start", "=", "microtime", "(", "true", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "params", ")", ")", "{", "throw", "new", "ResolutionException", "(", "'Parameters were not given'", ")", ";", "}", "$", "option", "=", "$", "this", "->", "getOptionUsed", "(", ")", ";", "switch", "(", "$", "option", ")", "{", "case", "'list'", ":", "$", "this", "->", "listAction", "(", ")", ";", "break", ";", "case", "'unarchive'", ":", "$", "this", "->", "unArchiveAction", "(", ")", ";", "break", ";", "case", "'archive'", ":", "$", "this", "->", "archiveAction", "(", ")", ";", "break", ";", "case", "'delete'", ":", "$", "this", "->", "deleteArchivesAction", "(", ")", ";", "break", ";", "}", "$", "time_end", "=", "microtime", "(", "true", ")", ";", "$", "execution_time", "=", "(", "$", "time_end", "-", "$", "time_start", ")", "/", "60", ";", "$", "this", "->", "report", "->", "add", "(", "new", "Report", "(", "Report", "::", "TYPE_INFO", ",", "'Time:'", ".", "round", "(", "$", "execution_time", ",", "4", ")", ".", "' Minutes.'", ")", ")", ";", "}" ]
Process action call @throws ResolutionException @throws \common_exception_Error @throws ServiceNotFoundException
[ "Process", "action", "call" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/scripts/tools/DeliveryExecutionArchive.php#L88-L116
oat-sa/extension-tao-delivery-rdf
scripts/tools/DeliveryExecutionArchive.php
DeliveryExecutionArchive.listAction
private function listAction() { $deliveryClass = $this->getClass(DeliveryAssemblyService::CLASS_URI ); $deliveries = $deliveryClass->getInstances(true); $result = []; foreach ($deliveries as $delivery) { /** @var \core_kernel_classes_Resource $delivery */ $result[] = $this->deliveryDescription($delivery); } $this->report = new Report( Report::TYPE_INFO, implode(PHP_EOL, $result) ); }
php
private function listAction() { $deliveryClass = $this->getClass(DeliveryAssemblyService::CLASS_URI ); $deliveries = $deliveryClass->getInstances(true); $result = []; foreach ($deliveries as $delivery) { /** @var \core_kernel_classes_Resource $delivery */ $result[] = $this->deliveryDescription($delivery); } $this->report = new Report( Report::TYPE_INFO, implode(PHP_EOL, $result) ); }
[ "private", "function", "listAction", "(", ")", "{", "$", "deliveryClass", "=", "$", "this", "->", "getClass", "(", "DeliveryAssemblyService", "::", "CLASS_URI", ")", ";", "$", "deliveries", "=", "$", "deliveryClass", "->", "getInstances", "(", "true", ")", ";", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "deliveries", "as", "$", "delivery", ")", "{", "/** @var \\core_kernel_classes_Resource $delivery */", "$", "result", "[", "]", "=", "$", "this", "->", "deliveryDescription", "(", "$", "delivery", ")", ";", "}", "$", "this", "->", "report", "=", "new", "Report", "(", "Report", "::", "TYPE_INFO", ",", "implode", "(", "PHP_EOL", ",", "$", "result", ")", ")", ";", "}" ]
Show list of all existing deliveries
[ "Show", "list", "of", "all", "existing", "deliveries" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/scripts/tools/DeliveryExecutionArchive.php#L121-L134
oat-sa/extension-tao-delivery-rdf
scripts/tools/DeliveryExecutionArchive.php
DeliveryExecutionArchive.helpAction
private function helpAction($message = null) { if ($message !== null) { $this->report = new Report( Report::TYPE_ERROR, $message . PHP_EOL ); } $helpReport = new Report( Report::TYPE_INFO, "Usage: " . __CLASS__ . " <mode> [<args>]" . PHP_EOL . PHP_EOL . "Available modes:" . PHP_EOL . " list get list of all deliveries" . PHP_EOL . " archive archive all deliveries use --force to forge regeneration" . PHP_EOL . " unarchive unarchive all deliveries --force to forge unarchiving" . PHP_EOL . " delete delete all archives deliveries" . PHP_EOL ); if ($this->report) { $this->report->add($helpReport); } else { $this->report = $helpReport; } }
php
private function helpAction($message = null) { if ($message !== null) { $this->report = new Report( Report::TYPE_ERROR, $message . PHP_EOL ); } $helpReport = new Report( Report::TYPE_INFO, "Usage: " . __CLASS__ . " <mode> [<args>]" . PHP_EOL . PHP_EOL . "Available modes:" . PHP_EOL . " list get list of all deliveries" . PHP_EOL . " archive archive all deliveries use --force to forge regeneration" . PHP_EOL . " unarchive unarchive all deliveries --force to forge unarchiving" . PHP_EOL . " delete delete all archives deliveries" . PHP_EOL ); if ($this->report) { $this->report->add($helpReport); } else { $this->report = $helpReport; } }
[ "private", "function", "helpAction", "(", "$", "message", "=", "null", ")", "{", "if", "(", "$", "message", "!==", "null", ")", "{", "$", "this", "->", "report", "=", "new", "Report", "(", "Report", "::", "TYPE_ERROR", ",", "$", "message", ".", "PHP_EOL", ")", ";", "}", "$", "helpReport", "=", "new", "Report", "(", "Report", "::", "TYPE_INFO", ",", "\"Usage: \"", ".", "__CLASS__", ".", "\" <mode> [<args>]\"", ".", "PHP_EOL", ".", "PHP_EOL", ".", "\"Available modes:\"", ".", "PHP_EOL", ".", "\" list get list of all deliveries\"", ".", "PHP_EOL", ".", "\" archive archive all deliveries use --force to forge regeneration\"", ".", "PHP_EOL", ".", "\" unarchive unarchive all deliveries --force to forge unarchiving\"", ".", "PHP_EOL", ".", "\" delete delete all archives deliveries\"", ".", "PHP_EOL", ")", ";", "if", "(", "$", "this", "->", "report", ")", "{", "$", "this", "->", "report", "->", "add", "(", "$", "helpReport", ")", ";", "}", "else", "{", "$", "this", "->", "report", "=", "$", "helpReport", ";", "}", "}" ]
Set help report @param string $message error message to be shown before help information @throws \common_exception_Error
[ "Set", "help", "report" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/scripts/tools/DeliveryExecutionArchive.php#L269-L293
oat-sa/extension-tao-delivery-rdf
model/DeliveryFactory.php
DeliveryFactory.create
public function create(core_kernel_classes_Class $deliveryClass, core_kernel_classes_Resource $test, $label = '', core_kernel_classes_Resource $deliveryResource = null) { \common_Logger::i('Creating '.$label.' with '.$test->getLabel().' under '.$deliveryClass->getLabel()); // checking on properties foreach ($this->getOption(self::OPTION_PROPERTIES) as $deliveryProperty => $testProperty) { $testPropretyInstance = new \core_kernel_classes_Property($testProperty); $validationValue = (string) $testPropretyInstance->getOnePropertyValue(new \core_kernel_classes_Property(ValidationRuleRegistry::PROPERTY_VALIDATION_RULE)); $propertyValues = $test->getPropertyValues($testPropretyInstance); if ($validationValue == 'notEmpty' && empty($propertyValues)) { $report = \common_report_Report::createFailure(__('Test publishing failed because "%s" is empty.', $testPropretyInstance->getLabel())); return $report; } } if (!$deliveryResource instanceof core_kernel_classes_Resource) { $deliveryResource = \core_kernel_classes_ResourceFactory::create($deliveryClass); } $this->deliveryResource = $deliveryResource; $storage = new TrackedStorage(); $this->propagate($storage); $compiler = \taoTests_models_classes_TestsService::singleton()->getCompiler($test, $storage); $report = $compiler->compile(); if ($report->getType() == \common_report_Report::TYPE_SUCCESS) { $serviceCall = $report->getData(); $properties = array( OntologyRdfs::RDFS_LABEL => $label, DeliveryAssemblyService::PROPERTY_DELIVERY_DIRECTORY => $storage->getSpawnedDirectoryIds(), DeliveryAssemblyService::PROPERTY_ORIGIN => $test, ); foreach ($this->getOption(self::OPTION_PROPERTIES) as $deliveryProperty => $testProperty) { $properties[$deliveryProperty] = $test->getPropertyValues(new \core_kernel_classes_Property($testProperty)); } $container = null; if ($compiler instanceof ContainerProvider) { $container = $compiler->getContainer(); } $compilationInstance = $this->createDeliveryResource($deliveryClass, $serviceCall, $container, $properties); $report->setData($compilationInstance); } return $report; }
php
public function create(core_kernel_classes_Class $deliveryClass, core_kernel_classes_Resource $test, $label = '', core_kernel_classes_Resource $deliveryResource = null) { \common_Logger::i('Creating '.$label.' with '.$test->getLabel().' under '.$deliveryClass->getLabel()); // checking on properties foreach ($this->getOption(self::OPTION_PROPERTIES) as $deliveryProperty => $testProperty) { $testPropretyInstance = new \core_kernel_classes_Property($testProperty); $validationValue = (string) $testPropretyInstance->getOnePropertyValue(new \core_kernel_classes_Property(ValidationRuleRegistry::PROPERTY_VALIDATION_RULE)); $propertyValues = $test->getPropertyValues($testPropretyInstance); if ($validationValue == 'notEmpty' && empty($propertyValues)) { $report = \common_report_Report::createFailure(__('Test publishing failed because "%s" is empty.', $testPropretyInstance->getLabel())); return $report; } } if (!$deliveryResource instanceof core_kernel_classes_Resource) { $deliveryResource = \core_kernel_classes_ResourceFactory::create($deliveryClass); } $this->deliveryResource = $deliveryResource; $storage = new TrackedStorage(); $this->propagate($storage); $compiler = \taoTests_models_classes_TestsService::singleton()->getCompiler($test, $storage); $report = $compiler->compile(); if ($report->getType() == \common_report_Report::TYPE_SUCCESS) { $serviceCall = $report->getData(); $properties = array( OntologyRdfs::RDFS_LABEL => $label, DeliveryAssemblyService::PROPERTY_DELIVERY_DIRECTORY => $storage->getSpawnedDirectoryIds(), DeliveryAssemblyService::PROPERTY_ORIGIN => $test, ); foreach ($this->getOption(self::OPTION_PROPERTIES) as $deliveryProperty => $testProperty) { $properties[$deliveryProperty] = $test->getPropertyValues(new \core_kernel_classes_Property($testProperty)); } $container = null; if ($compiler instanceof ContainerProvider) { $container = $compiler->getContainer(); } $compilationInstance = $this->createDeliveryResource($deliveryClass, $serviceCall, $container, $properties); $report->setData($compilationInstance); } return $report; }
[ "public", "function", "create", "(", "core_kernel_classes_Class", "$", "deliveryClass", ",", "core_kernel_classes_Resource", "$", "test", ",", "$", "label", "=", "''", ",", "core_kernel_classes_Resource", "$", "deliveryResource", "=", "null", ")", "{", "\\", "common_Logger", "::", "i", "(", "'Creating '", ".", "$", "label", ".", "' with '", ".", "$", "test", "->", "getLabel", "(", ")", ".", "' under '", ".", "$", "deliveryClass", "->", "getLabel", "(", ")", ")", ";", "// checking on properties", "foreach", "(", "$", "this", "->", "getOption", "(", "self", "::", "OPTION_PROPERTIES", ")", "as", "$", "deliveryProperty", "=>", "$", "testProperty", ")", "{", "$", "testPropretyInstance", "=", "new", "\\", "core_kernel_classes_Property", "(", "$", "testProperty", ")", ";", "$", "validationValue", "=", "(", "string", ")", "$", "testPropretyInstance", "->", "getOnePropertyValue", "(", "new", "\\", "core_kernel_classes_Property", "(", "ValidationRuleRegistry", "::", "PROPERTY_VALIDATION_RULE", ")", ")", ";", "$", "propertyValues", "=", "$", "test", "->", "getPropertyValues", "(", "$", "testPropretyInstance", ")", ";", "if", "(", "$", "validationValue", "==", "'notEmpty'", "&&", "empty", "(", "$", "propertyValues", ")", ")", "{", "$", "report", "=", "\\", "common_report_Report", "::", "createFailure", "(", "__", "(", "'Test publishing failed because \"%s\" is empty.'", ",", "$", "testPropretyInstance", "->", "getLabel", "(", ")", ")", ")", ";", "return", "$", "report", ";", "}", "}", "if", "(", "!", "$", "deliveryResource", "instanceof", "core_kernel_classes_Resource", ")", "{", "$", "deliveryResource", "=", "\\", "core_kernel_classes_ResourceFactory", "::", "create", "(", "$", "deliveryClass", ")", ";", "}", "$", "this", "->", "deliveryResource", "=", "$", "deliveryResource", ";", "$", "storage", "=", "new", "TrackedStorage", "(", ")", ";", "$", "this", "->", "propagate", "(", "$", "storage", ")", ";", "$", "compiler", "=", "\\", "taoTests_models_classes_TestsService", "::", "singleton", "(", ")", "->", "getCompiler", "(", "$", "test", ",", "$", "storage", ")", ";", "$", "report", "=", "$", "compiler", "->", "compile", "(", ")", ";", "if", "(", "$", "report", "->", "getType", "(", ")", "==", "\\", "common_report_Report", "::", "TYPE_SUCCESS", ")", "{", "$", "serviceCall", "=", "$", "report", "->", "getData", "(", ")", ";", "$", "properties", "=", "array", "(", "OntologyRdfs", "::", "RDFS_LABEL", "=>", "$", "label", ",", "DeliveryAssemblyService", "::", "PROPERTY_DELIVERY_DIRECTORY", "=>", "$", "storage", "->", "getSpawnedDirectoryIds", "(", ")", ",", "DeliveryAssemblyService", "::", "PROPERTY_ORIGIN", "=>", "$", "test", ",", ")", ";", "foreach", "(", "$", "this", "->", "getOption", "(", "self", "::", "OPTION_PROPERTIES", ")", "as", "$", "deliveryProperty", "=>", "$", "testProperty", ")", "{", "$", "properties", "[", "$", "deliveryProperty", "]", "=", "$", "test", "->", "getPropertyValues", "(", "new", "\\", "core_kernel_classes_Property", "(", "$", "testProperty", ")", ")", ";", "}", "$", "container", "=", "null", ";", "if", "(", "$", "compiler", "instanceof", "ContainerProvider", ")", "{", "$", "container", "=", "$", "compiler", "->", "getContainer", "(", ")", ";", "}", "$", "compilationInstance", "=", "$", "this", "->", "createDeliveryResource", "(", "$", "deliveryClass", ",", "$", "serviceCall", ",", "$", "container", ",", "$", "properties", ")", ";", "$", "report", "->", "setData", "(", "$", "compilationInstance", ")", ";", "}", "return", "$", "report", ";", "}" ]
Creates a new simple delivery @param core_kernel_classes_Class $deliveryClass @param core_kernel_classes_Resource $test @param string $label @param core_kernel_classes_Resource $deliveryResource @return \common_report_Report
[ "Creates", "a", "new", "simple", "delivery" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/DeliveryFactory.php#L81-L132
oat-sa/extension-tao-delivery-rdf
model/DeliveryFactory.php
DeliveryFactory.createDeliveryResource
protected function createDeliveryResource(core_kernel_classes_Class $deliveryClass, \tao_models_classes_service_ServiceCall $serviceCall, $container, $properties = array()) { $properties[DeliveryAssemblyService::PROPERTY_DELIVERY_TIME] = time(); $properties[DeliveryAssemblyService::PROPERTY_DELIVERY_RUNTIME] = $serviceCall->toOntology(); if (!isset($properties[DeliveryContainerService::PROPERTY_RESULT_SERVER])) { $properties[DeliveryContainerService::PROPERTY_RESULT_SERVER] = \taoResultServer_models_classes_ResultServerAuthoringService::singleton()->getDefaultResultServer(); } if (!is_null($container)) { $properties[ContainerRuntime::PROPERTY_CONTAINER] = json_encode($container); } if ($this->deliveryResource instanceof core_kernel_classes_Resource) { $compilationInstance = $this->deliveryResource; $compilationInstance->setPropertiesValues($properties); } else { $compilationInstance = $deliveryClass->createInstanceWithProperties($properties); } $eventManager = $this->getServiceManager()->get(EventManager::SERVICE_ID); $eventManager->trigger(new DeliveryCreatedEvent($compilationInstance->getUri())); return $compilationInstance; }
php
protected function createDeliveryResource(core_kernel_classes_Class $deliveryClass, \tao_models_classes_service_ServiceCall $serviceCall, $container, $properties = array()) { $properties[DeliveryAssemblyService::PROPERTY_DELIVERY_TIME] = time(); $properties[DeliveryAssemblyService::PROPERTY_DELIVERY_RUNTIME] = $serviceCall->toOntology(); if (!isset($properties[DeliveryContainerService::PROPERTY_RESULT_SERVER])) { $properties[DeliveryContainerService::PROPERTY_RESULT_SERVER] = \taoResultServer_models_classes_ResultServerAuthoringService::singleton()->getDefaultResultServer(); } if (!is_null($container)) { $properties[ContainerRuntime::PROPERTY_CONTAINER] = json_encode($container); } if ($this->deliveryResource instanceof core_kernel_classes_Resource) { $compilationInstance = $this->deliveryResource; $compilationInstance->setPropertiesValues($properties); } else { $compilationInstance = $deliveryClass->createInstanceWithProperties($properties); } $eventManager = $this->getServiceManager()->get(EventManager::SERVICE_ID); $eventManager->trigger(new DeliveryCreatedEvent($compilationInstance->getUri())); return $compilationInstance; }
[ "protected", "function", "createDeliveryResource", "(", "core_kernel_classes_Class", "$", "deliveryClass", ",", "\\", "tao_models_classes_service_ServiceCall", "$", "serviceCall", ",", "$", "container", ",", "$", "properties", "=", "array", "(", ")", ")", "{", "$", "properties", "[", "DeliveryAssemblyService", "::", "PROPERTY_DELIVERY_TIME", "]", "=", "time", "(", ")", ";", "$", "properties", "[", "DeliveryAssemblyService", "::", "PROPERTY_DELIVERY_RUNTIME", "]", "=", "$", "serviceCall", "->", "toOntology", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "properties", "[", "DeliveryContainerService", "::", "PROPERTY_RESULT_SERVER", "]", ")", ")", "{", "$", "properties", "[", "DeliveryContainerService", "::", "PROPERTY_RESULT_SERVER", "]", "=", "\\", "taoResultServer_models_classes_ResultServerAuthoringService", "::", "singleton", "(", ")", "->", "getDefaultResultServer", "(", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "container", ")", ")", "{", "$", "properties", "[", "ContainerRuntime", "::", "PROPERTY_CONTAINER", "]", "=", "json_encode", "(", "$", "container", ")", ";", "}", "if", "(", "$", "this", "->", "deliveryResource", "instanceof", "core_kernel_classes_Resource", ")", "{", "$", "compilationInstance", "=", "$", "this", "->", "deliveryResource", ";", "$", "compilationInstance", "->", "setPropertiesValues", "(", "$", "properties", ")", ";", "}", "else", "{", "$", "compilationInstance", "=", "$", "deliveryClass", "->", "createInstanceWithProperties", "(", "$", "properties", ")", ";", "}", "$", "eventManager", "=", "$", "this", "->", "getServiceManager", "(", ")", "->", "get", "(", "EventManager", "::", "SERVICE_ID", ")", ";", "$", "eventManager", "->", "trigger", "(", "new", "DeliveryCreatedEvent", "(", "$", "compilationInstance", "->", "getUri", "(", ")", ")", ")", ";", "return", "$", "compilationInstance", ";", "}" ]
Create a delivery resource based on a successfull compilation @param core_kernel_classes_Class $deliveryClass @param \tao_models_classes_service_ServiceCall $serviceCall @param string $containerId @param string $containerParam @param array $properties
[ "Create", "a", "delivery", "resource", "based", "on", "a", "successfull", "compilation" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/DeliveryFactory.php#L199-L221
koala-framework/koala-framework
Kwf/Uploads/Row.php
Kwf_Uploads_Row.getFileInfo
public function getFileInfo() { $ret = array( 'uploadId' => $this->id, 'mimeType' => $this->mime_type, 'filename' => $this->filename, 'extension'=> $this->extension, 'fileSize' => $this->getFileSize(), 'hashKey' => $this->getHashKey() ); if (!$this->id && is_file($this->filename)) { $ret['mimeType'] = $this->_getMimeType($this->filename); $ret['extension'] = substr(strrchr($this->filename, '.'), 1); } $size = $this->getImageDimensions(); if ($size) { $ret['image'] = true; $ret['imageHandyScaleFactor'] = Kwf_Media_Image::getHandyScaleFactor($size); if (abs($size['rotation']) == 90) { $size = array('width'=>$size['height'], 'height'=>$size['width']); } $ret['imageWidth'] = $size['width']; $ret['imageHeight'] = $size['height']; } else { $ret['image'] = false; } return $ret; }
php
public function getFileInfo() { $ret = array( 'uploadId' => $this->id, 'mimeType' => $this->mime_type, 'filename' => $this->filename, 'extension'=> $this->extension, 'fileSize' => $this->getFileSize(), 'hashKey' => $this->getHashKey() ); if (!$this->id && is_file($this->filename)) { $ret['mimeType'] = $this->_getMimeType($this->filename); $ret['extension'] = substr(strrchr($this->filename, '.'), 1); } $size = $this->getImageDimensions(); if ($size) { $ret['image'] = true; $ret['imageHandyScaleFactor'] = Kwf_Media_Image::getHandyScaleFactor($size); if (abs($size['rotation']) == 90) { $size = array('width'=>$size['height'], 'height'=>$size['width']); } $ret['imageWidth'] = $size['width']; $ret['imageHeight'] = $size['height']; } else { $ret['image'] = false; } return $ret; }
[ "public", "function", "getFileInfo", "(", ")", "{", "$", "ret", "=", "array", "(", "'uploadId'", "=>", "$", "this", "->", "id", ",", "'mimeType'", "=>", "$", "this", "->", "mime_type", ",", "'filename'", "=>", "$", "this", "->", "filename", ",", "'extension'", "=>", "$", "this", "->", "extension", ",", "'fileSize'", "=>", "$", "this", "->", "getFileSize", "(", ")", ",", "'hashKey'", "=>", "$", "this", "->", "getHashKey", "(", ")", ")", ";", "if", "(", "!", "$", "this", "->", "id", "&&", "is_file", "(", "$", "this", "->", "filename", ")", ")", "{", "$", "ret", "[", "'mimeType'", "]", "=", "$", "this", "->", "_getMimeType", "(", "$", "this", "->", "filename", ")", ";", "$", "ret", "[", "'extension'", "]", "=", "substr", "(", "strrchr", "(", "$", "this", "->", "filename", ",", "'.'", ")", ",", "1", ")", ";", "}", "$", "size", "=", "$", "this", "->", "getImageDimensions", "(", ")", ";", "if", "(", "$", "size", ")", "{", "$", "ret", "[", "'image'", "]", "=", "true", ";", "$", "ret", "[", "'imageHandyScaleFactor'", "]", "=", "Kwf_Media_Image", "::", "getHandyScaleFactor", "(", "$", "size", ")", ";", "if", "(", "abs", "(", "$", "size", "[", "'rotation'", "]", ")", "==", "90", ")", "{", "$", "size", "=", "array", "(", "'width'", "=>", "$", "size", "[", "'height'", "]", ",", "'height'", "=>", "$", "size", "[", "'width'", "]", ")", ";", "}", "$", "ret", "[", "'imageWidth'", "]", "=", "$", "size", "[", "'width'", "]", ";", "$", "ret", "[", "'imageHeight'", "]", "=", "$", "size", "[", "'height'", "]", ";", "}", "else", "{", "$", "ret", "[", "'image'", "]", "=", "false", ";", "}", "return", "$", "ret", ";", "}" ]
wird von upload-feld verwendet
[ "wird", "von", "upload", "-", "feld", "verwendet" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Uploads/Row.php#L119-L146
koala-framework/koala-framework
Kwf/Auth.php
Kwf_Auth.getInstance
public static function getInstance() { if (null === self::$_instance) { self::$_instance = new self(); // automatisches einloggen $autologin = Zend_Registry::get('config')->autologin; if ($autologin && Kwf_Setup::hasDb()) { $storage = self::$_instance->getStorage(); $loginData = $storage->read(); if (!isset($loginData['userId']) || !$loginData['userId']) { $userModel = Zend_Registry::get('userModel'); $r = $userModel->getRow($userModel->select()->whereEquals('email', $autologin)); if (!$r) { $msg = "Autologin email '$autologin' does not exists"; throw new Kwf_Exception("autologin failed: $msg"); } $loginData['userId'] = $r->id; $storage->write($loginData); } } } return self::$_instance; }
php
public static function getInstance() { if (null === self::$_instance) { self::$_instance = new self(); // automatisches einloggen $autologin = Zend_Registry::get('config')->autologin; if ($autologin && Kwf_Setup::hasDb()) { $storage = self::$_instance->getStorage(); $loginData = $storage->read(); if (!isset($loginData['userId']) || !$loginData['userId']) { $userModel = Zend_Registry::get('userModel'); $r = $userModel->getRow($userModel->select()->whereEquals('email', $autologin)); if (!$r) { $msg = "Autologin email '$autologin' does not exists"; throw new Kwf_Exception("autologin failed: $msg"); } $loginData['userId'] = $r->id; $storage->write($loginData); } } } return self::$_instance; }
[ "public", "static", "function", "getInstance", "(", ")", "{", "if", "(", "null", "===", "self", "::", "$", "_instance", ")", "{", "self", "::", "$", "_instance", "=", "new", "self", "(", ")", ";", "// automatisches einloggen", "$", "autologin", "=", "Zend_Registry", "::", "get", "(", "'config'", ")", "->", "autologin", ";", "if", "(", "$", "autologin", "&&", "Kwf_Setup", "::", "hasDb", "(", ")", ")", "{", "$", "storage", "=", "self", "::", "$", "_instance", "->", "getStorage", "(", ")", ";", "$", "loginData", "=", "$", "storage", "->", "read", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "loginData", "[", "'userId'", "]", ")", "||", "!", "$", "loginData", "[", "'userId'", "]", ")", "{", "$", "userModel", "=", "Zend_Registry", "::", "get", "(", "'userModel'", ")", ";", "$", "r", "=", "$", "userModel", "->", "getRow", "(", "$", "userModel", "->", "select", "(", ")", "->", "whereEquals", "(", "'email'", ",", "$", "autologin", ")", ")", ";", "if", "(", "!", "$", "r", ")", "{", "$", "msg", "=", "\"Autologin email '$autologin' does not exists\"", ";", "throw", "new", "Kwf_Exception", "(", "\"autologin failed: $msg\"", ")", ";", "}", "$", "loginData", "[", "'userId'", "]", "=", "$", "r", "->", "id", ";", "$", "storage", "->", "write", "(", "$", "loginData", ")", ";", "}", "}", "}", "return", "self", "::", "$", "_instance", ";", "}" ]
Kopiert von Zend_Auth und abgeändert
[ "Kopiert", "von", "Zend_Auth", "und", "abgeändert" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Auth.php#L5-L32
koala-framework/koala-framework
Kwf/User/EditModel.php
Kwf_User_EditModel.createRow
public function createRow(array $data=array()) { $row = parent::createRow($data); $this->_resetPermissions($row); return $row; }
php
public function createRow(array $data=array()) { $row = parent::createRow($data); $this->_resetPermissions($row); return $row; }
[ "public", "function", "createRow", "(", "array", "$", "data", "=", "array", "(", ")", ")", "{", "$", "row", "=", "parent", "::", "createRow", "(", "$", "data", ")", ";", "$", "this", "->", "_resetPermissions", "(", "$", "row", ")", ";", "return", "$", "row", ";", "}" ]
zurückgeben
[ "zurückgeben" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/User/EditModel.php#L47-L52
koala-framework/koala-framework
Kwc/Basic/Table/Trl/Model.php
Kwc_Basic_Table_Trl_Model._getComponentId
protected function _getComponentId($select) { $componentId = null; if ($select) { if ($select->getPart(Kwf_Model_Select::WHERE_EQUALS)) { foreach ($select->getPart(Kwf_Model_Select::WHERE_EQUALS) as $k=>$i) { if ($k == 'component_id') $componentId = $i; } } } return $componentId; }
php
protected function _getComponentId($select) { $componentId = null; if ($select) { if ($select->getPart(Kwf_Model_Select::WHERE_EQUALS)) { foreach ($select->getPart(Kwf_Model_Select::WHERE_EQUALS) as $k=>$i) { if ($k == 'component_id') $componentId = $i; } } } return $componentId; }
[ "protected", "function", "_getComponentId", "(", "$", "select", ")", "{", "$", "componentId", "=", "null", ";", "if", "(", "$", "select", ")", "{", "if", "(", "$", "select", "->", "getPart", "(", "Kwf_Model_Select", "::", "WHERE_EQUALS", ")", ")", "{", "foreach", "(", "$", "select", "->", "getPart", "(", "Kwf_Model_Select", "::", "WHERE_EQUALS", ")", "as", "$", "k", "=>", "$", "i", ")", "{", "if", "(", "$", "k", "==", "'component_id'", ")", "$", "componentId", "=", "$", "i", ";", "}", "}", "}", "return", "$", "componentId", ";", "}" ]
Extracts the component id from select
[ "Extracts", "the", "component", "id", "from", "select" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Basic/Table/Trl/Model.php#L18-L29
koala-framework/koala-framework
Kwc/Basic/Table/Trl/Model.php
Kwc_Basic_Table_Trl_Model._getTrlRow
protected function _getTrlRow($proxiedRow, $componentId) { $row = null; $proxyId = $proxiedRow->id; $select = $this->_trlModel->select() ->whereEquals('component_id', $componentId) ->whereEquals('master_id', $proxyId); $trlRow = $this->_trlModel->getRows($select)->current(); if ($trlRow) { $row = $trlRow; } else { $row = $this->_trlModel->createRow(); $row->master_id = $proxyId; $row->component_id = $componentId; $row->save(); } return $row; }
php
protected function _getTrlRow($proxiedRow, $componentId) { $row = null; $proxyId = $proxiedRow->id; $select = $this->_trlModel->select() ->whereEquals('component_id', $componentId) ->whereEquals('master_id', $proxyId); $trlRow = $this->_trlModel->getRows($select)->current(); if ($trlRow) { $row = $trlRow; } else { $row = $this->_trlModel->createRow(); $row->master_id = $proxyId; $row->component_id = $componentId; $row->save(); } return $row; }
[ "protected", "function", "_getTrlRow", "(", "$", "proxiedRow", ",", "$", "componentId", ")", "{", "$", "row", "=", "null", ";", "$", "proxyId", "=", "$", "proxiedRow", "->", "id", ";", "$", "select", "=", "$", "this", "->", "_trlModel", "->", "select", "(", ")", "->", "whereEquals", "(", "'component_id'", ",", "$", "componentId", ")", "->", "whereEquals", "(", "'master_id'", ",", "$", "proxyId", ")", ";", "$", "trlRow", "=", "$", "this", "->", "_trlModel", "->", "getRows", "(", "$", "select", ")", "->", "current", "(", ")", ";", "if", "(", "$", "trlRow", ")", "{", "$", "row", "=", "$", "trlRow", ";", "}", "else", "{", "$", "row", "=", "$", "this", "->", "_trlModel", "->", "createRow", "(", ")", ";", "$", "row", "->", "master_id", "=", "$", "proxyId", ";", "$", "row", "->", "component_id", "=", "$", "componentId", ";", "$", "row", "->", "save", "(", ")", ";", "}", "return", "$", "row", ";", "}" ]
returns the related trl-row
[ "returns", "the", "related", "trl", "-", "row" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Basic/Table/Trl/Model.php#L47-L64
koala-framework/koala-framework
Kwc/Basic/Table/Trl/Model.php
Kwc_Basic_Table_Trl_Model.getRow
public function getRow($select) { $componentId = $this->_getComponentId($select); $masterId = $this->_getId($select); if ($componentId && $masterId) { $select = new Kwf_Model_Select(); $c = Kwf_Component_Data_Root::getInstance() ->getComponentById($componentId, array('ignoreVisible'=>true)); $select->whereEquals('component_id', $c->chained->dbId); $select->whereEquals('id', $masterId); $proxyRow = $this->_proxyModel->getRow($select); return $this->getRowByProxiedRowAndComponentId($proxyRow, $componentId); } else { $trlRow = $this->_trlModel->getRow($select); $masterSelect = new Kwf_Model_Select(); $masterSelect->whereId($trlRow->master_id); $masterRow = $this->_proxyModel->getRow($masterSelect); return $this->getRowByProxiedRowAndComponentId($masterRow, $trlRow->component_id); } throw new Kwf_Exception_NotYetImplemented(); }
php
public function getRow($select) { $componentId = $this->_getComponentId($select); $masterId = $this->_getId($select); if ($componentId && $masterId) { $select = new Kwf_Model_Select(); $c = Kwf_Component_Data_Root::getInstance() ->getComponentById($componentId, array('ignoreVisible'=>true)); $select->whereEquals('component_id', $c->chained->dbId); $select->whereEquals('id', $masterId); $proxyRow = $this->_proxyModel->getRow($select); return $this->getRowByProxiedRowAndComponentId($proxyRow, $componentId); } else { $trlRow = $this->_trlModel->getRow($select); $masterSelect = new Kwf_Model_Select(); $masterSelect->whereId($trlRow->master_id); $masterRow = $this->_proxyModel->getRow($masterSelect); return $this->getRowByProxiedRowAndComponentId($masterRow, $trlRow->component_id); } throw new Kwf_Exception_NotYetImplemented(); }
[ "public", "function", "getRow", "(", "$", "select", ")", "{", "$", "componentId", "=", "$", "this", "->", "_getComponentId", "(", "$", "select", ")", ";", "$", "masterId", "=", "$", "this", "->", "_getId", "(", "$", "select", ")", ";", "if", "(", "$", "componentId", "&&", "$", "masterId", ")", "{", "$", "select", "=", "new", "Kwf_Model_Select", "(", ")", ";", "$", "c", "=", "Kwf_Component_Data_Root", "::", "getInstance", "(", ")", "->", "getComponentById", "(", "$", "componentId", ",", "array", "(", "'ignoreVisible'", "=>", "true", ")", ")", ";", "$", "select", "->", "whereEquals", "(", "'component_id'", ",", "$", "c", "->", "chained", "->", "dbId", ")", ";", "$", "select", "->", "whereEquals", "(", "'id'", ",", "$", "masterId", ")", ";", "$", "proxyRow", "=", "$", "this", "->", "_proxyModel", "->", "getRow", "(", "$", "select", ")", ";", "return", "$", "this", "->", "getRowByProxiedRowAndComponentId", "(", "$", "proxyRow", ",", "$", "componentId", ")", ";", "}", "else", "{", "$", "trlRow", "=", "$", "this", "->", "_trlModel", "->", "getRow", "(", "$", "select", ")", ";", "$", "masterSelect", "=", "new", "Kwf_Model_Select", "(", ")", ";", "$", "masterSelect", "->", "whereId", "(", "$", "trlRow", "->", "master_id", ")", ";", "$", "masterRow", "=", "$", "this", "->", "_proxyModel", "->", "getRow", "(", "$", "masterSelect", ")", ";", "return", "$", "this", "->", "getRowByProxiedRowAndComponentId", "(", "$", "masterRow", ",", "$", "trlRow", "->", "component_id", ")", ";", "}", "throw", "new", "Kwf_Exception_NotYetImplemented", "(", ")", ";", "}" ]
Should return the specified row, componentId and id has to be defined
[ "Should", "return", "the", "specified", "row", "componentId", "and", "id", "has", "to", "be", "defined" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Basic/Table/Trl/Model.php#L69-L89
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data._getPseudoPageUrl
protected function _getPseudoPageUrl() { $data = $this; $filename = ''; $hadStaticPage = false; do { if ($hadStaticPage && isset($data->generator) && !$data->isPseudoPage && $data->generator->getAddUrlPart() ) { $filename = $data->id.($filename ? ':' : '').$filename; } if ($data->isPseudoPage || $data->componentId == 'root') { if ($data->filename) $filename = $data->filename.($filename ? '/' : '').$filename; if ($data->componentId != 'root' && $data->generator->getGeneratorFlag('static')) { $hadStaticPage = true; } else { $hadStaticPage = false; } } } while ($data = $data->parent); $baseUrl = Kwf_Setup::getBaseUrl(); //TODO baseUrl vs. root filename: both do the same return ($baseUrl ? $baseUrl : '').'/'.$filename; }
php
protected function _getPseudoPageUrl() { $data = $this; $filename = ''; $hadStaticPage = false; do { if ($hadStaticPage && isset($data->generator) && !$data->isPseudoPage && $data->generator->getAddUrlPart() ) { $filename = $data->id.($filename ? ':' : '').$filename; } if ($data->isPseudoPage || $data->componentId == 'root') { if ($data->filename) $filename = $data->filename.($filename ? '/' : '').$filename; if ($data->componentId != 'root' && $data->generator->getGeneratorFlag('static')) { $hadStaticPage = true; } else { $hadStaticPage = false; } } } while ($data = $data->parent); $baseUrl = Kwf_Setup::getBaseUrl(); //TODO baseUrl vs. root filename: both do the same return ($baseUrl ? $baseUrl : '').'/'.$filename; }
[ "protected", "function", "_getPseudoPageUrl", "(", ")", "{", "$", "data", "=", "$", "this", ";", "$", "filename", "=", "''", ";", "$", "hadStaticPage", "=", "false", ";", "do", "{", "if", "(", "$", "hadStaticPage", "&&", "isset", "(", "$", "data", "->", "generator", ")", "&&", "!", "$", "data", "->", "isPseudoPage", "&&", "$", "data", "->", "generator", "->", "getAddUrlPart", "(", ")", ")", "{", "$", "filename", "=", "$", "data", "->", "id", ".", "(", "$", "filename", "?", "':'", ":", "''", ")", ".", "$", "filename", ";", "}", "if", "(", "$", "data", "->", "isPseudoPage", "||", "$", "data", "->", "componentId", "==", "'root'", ")", "{", "if", "(", "$", "data", "->", "filename", ")", "$", "filename", "=", "$", "data", "->", "filename", ".", "(", "$", "filename", "?", "'/'", ":", "''", ")", ".", "$", "filename", ";", "if", "(", "$", "data", "->", "componentId", "!=", "'root'", "&&", "$", "data", "->", "generator", "->", "getGeneratorFlag", "(", "'static'", ")", ")", "{", "$", "hadStaticPage", "=", "true", ";", "}", "else", "{", "$", "hadStaticPage", "=", "false", ";", "}", "}", "}", "while", "(", "$", "data", "=", "$", "data", "->", "parent", ")", ";", "$", "baseUrl", "=", "Kwf_Setup", "::", "getBaseUrl", "(", ")", ";", "//TODO baseUrl vs. root filename: both do the same", "return", "(", "$", "baseUrl", "?", "$", "baseUrl", ":", "''", ")", ".", "'/'", ".", "$", "filename", ";", "}" ]
Like ->url but also works for pseudoPages overridden in Data_Home
[ "Like", "-", ">", "url", "but", "also", "works", "for", "pseudoPages" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L102-L126
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.getExpandedComponentId
public function getExpandedComponentId() { if ($this->_expandedComponentIdCache) { return $this->_expandedComponentIdCache; } $generator = $this->generator; if ($generator instanceof Kwc_Root_Category_Generator) { $separator = '_'; } else { $separator = $generator->getIdSeparator(); } $this->_expandedComponentIdCache = $this->parent->getExpandedComponentId() . $separator . $this->id; return $this->_expandedComponentIdCache; }
php
public function getExpandedComponentId() { if ($this->_expandedComponentIdCache) { return $this->_expandedComponentIdCache; } $generator = $this->generator; if ($generator instanceof Kwc_Root_Category_Generator) { $separator = '_'; } else { $separator = $generator->getIdSeparator(); } $this->_expandedComponentIdCache = $this->parent->getExpandedComponentId() . $separator . $this->id; return $this->_expandedComponentIdCache; }
[ "public", "function", "getExpandedComponentId", "(", ")", "{", "if", "(", "$", "this", "->", "_expandedComponentIdCache", ")", "{", "return", "$", "this", "->", "_expandedComponentIdCache", ";", "}", "$", "generator", "=", "$", "this", "->", "generator", ";", "if", "(", "$", "generator", "instanceof", "Kwc_Root_Category_Generator", ")", "{", "$", "separator", "=", "'_'", ";", "}", "else", "{", "$", "separator", "=", "$", "generator", "->", "getIdSeparator", "(", ")", ";", "}", "$", "this", "->", "_expandedComponentIdCache", "=", "$", "this", "->", "parent", "->", "getExpandedComponentId", "(", ")", ".", "$", "separator", ".", "$", "this", "->", "id", ";", "return", "$", "this", "->", "_expandedComponentIdCache", ";", "}" ]
Returns component_id with seperate entries from every page in tree @example root |-1 |-2 |-3 componentId: 3, expandedComponentId: root-1_2_3 @return string
[ "Returns", "component_id", "with", "seperate", "entries", "from", "every", "page", "in", "tree" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L140-L155
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.getDomainComponent
public function getDomainComponent() { $component = $this; while ($component) { $class = $component->componentClass; if (Kwc_Abstract::hasSetting($class, 'baseProperties') && in_array('domain', Kwc_Abstract::getSetting($class, 'baseProperties')) ) { return $component; } $component = $component->parent; } }
php
public function getDomainComponent() { $component = $this; while ($component) { $class = $component->componentClass; if (Kwc_Abstract::hasSetting($class, 'baseProperties') && in_array('domain', Kwc_Abstract::getSetting($class, 'baseProperties')) ) { return $component; } $component = $component->parent; } }
[ "public", "function", "getDomainComponent", "(", ")", "{", "$", "component", "=", "$", "this", ";", "while", "(", "$", "component", ")", "{", "$", "class", "=", "$", "component", "->", "componentClass", ";", "if", "(", "Kwc_Abstract", "::", "hasSetting", "(", "$", "class", ",", "'baseProperties'", ")", "&&", "in_array", "(", "'domain'", ",", "Kwc_Abstract", "::", "getSetting", "(", "$", "class", ",", "'baseProperties'", ")", ")", ")", "{", "return", "$", "component", ";", "}", "$", "component", "=", "$", "component", "->", "parent", ";", "}", "}" ]
Returns domain component for current component @return Kwf_Component_Data
[ "Returns", "domain", "component", "for", "current", "component" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L162-L174
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.getDomainComponentId
public function getDomainComponentId() { if (!isset($this->_domainComponentIdCache)) { //cache ist vorallem für bei kwfUnserialize nützlich $this->_domainComponentIdCache = $this->getDomainComponent()->componentId; } return $this->_domainComponentIdCache; }
php
public function getDomainComponentId() { if (!isset($this->_domainComponentIdCache)) { //cache ist vorallem für bei kwfUnserialize nützlich $this->_domainComponentIdCache = $this->getDomainComponent()->componentId; } return $this->_domainComponentIdCache; }
[ "public", "function", "getDomainComponentId", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_domainComponentIdCache", ")", ")", "{", "//cache ist vorallem für bei kwfUnserialize nützlich", "$", "this", "->", "_domainComponentIdCache", "=", "$", "this", "->", "getDomainComponent", "(", ")", "->", "componentId", ";", "}", "return", "$", "this", "->", "_domainComponentIdCache", ";", "}" ]
Returns domain component id for current component @return string
[ "Returns", "domain", "component", "id", "for", "current", "component" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L181-L187
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.getAbsoluteUrl
public function getAbsoluteUrl() { $https = Kwf_Util_Https::domainSupportsHttps($this->getDomain()); $protocol = $https ? 'https' : 'http'; return $protocol . '://'.$this->getDomain().$this->url; }
php
public function getAbsoluteUrl() { $https = Kwf_Util_Https::domainSupportsHttps($this->getDomain()); $protocol = $https ? 'https' : 'http'; return $protocol . '://'.$this->getDomain().$this->url; }
[ "public", "function", "getAbsoluteUrl", "(", ")", "{", "$", "https", "=", "Kwf_Util_Https", "::", "domainSupportsHttps", "(", "$", "this", "->", "getDomain", "(", ")", ")", ";", "$", "protocol", "=", "$", "https", "?", "'https'", ":", "'http'", ";", "return", "$", "protocol", ".", "'://'", ".", "$", "this", "->", "getDomain", "(", ")", ".", "$", "this", "->", "url", ";", "}" ]
Returns absolute url including domain and protocol (http://) @return string
[ "Returns", "absolute", "url", "including", "domain", "and", "protocol", "(", "http", ":", "//", ")" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L204-L209
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.getPreviewUrl
public function getPreviewUrl() { if ($domain = $this->getBaseProperty('preliminaryDomain')) { $https = Kwf_Util_Https::domainSupportsHttps($domain); $protocol = $https ? 'https' : 'http'; $url = $protocol . '://'.$domain.$this->url; } else { $url = $this->getAbsoluteUrl(); } return Kwf_Setup::getBaseUrl().'/admin/component/preview/?url='.urlencode($url.'?kwcPreview'); }
php
public function getPreviewUrl() { if ($domain = $this->getBaseProperty('preliminaryDomain')) { $https = Kwf_Util_Https::domainSupportsHttps($domain); $protocol = $https ? 'https' : 'http'; $url = $protocol . '://'.$domain.$this->url; } else { $url = $this->getAbsoluteUrl(); } return Kwf_Setup::getBaseUrl().'/admin/component/preview/?url='.urlencode($url.'?kwcPreview'); }
[ "public", "function", "getPreviewUrl", "(", ")", "{", "if", "(", "$", "domain", "=", "$", "this", "->", "getBaseProperty", "(", "'preliminaryDomain'", ")", ")", "{", "$", "https", "=", "Kwf_Util_Https", "::", "domainSupportsHttps", "(", "$", "domain", ")", ";", "$", "protocol", "=", "$", "https", "?", "'https'", ":", "'http'", ";", "$", "url", "=", "$", "protocol", ".", "'://'", ".", "$", "domain", ".", "$", "this", "->", "url", ";", "}", "else", "{", "$", "url", "=", "$", "this", "->", "getAbsoluteUrl", "(", ")", ";", "}", "return", "Kwf_Setup", "::", "getBaseUrl", "(", ")", ".", "'/admin/component/preview/?url='", ".", "urlencode", "(", "$", "url", ".", "'?kwcPreview'", ")", ";", "}" ]
Returns preview url @return string
[ "Returns", "preview", "url" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L216-L226
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.getRecursiveChildComponents
public function getRecursiveChildComponents($select = array(), $childSelect = array('page'=>false)) { if (is_array($select)) { $select = new Kwf_Component_Select($select); } else { $select = clone $select; } Kwf_Benchmark::count('getRecursiveChildComponents'); if (is_array($childSelect)) { $childSelect = new Kwf_Component_Select($childSelect); } $ret = $this->getChildComponents($select); if ($select->hasPart('limitCount') && $select->getPart('limitCount') <= count($ret)) { return $ret; } $genSelect = new Kwf_Component_Select(); $genSelect->copyParts(array( Kwf_Component_Select::WHERE_HOME, Kwf_Component_Select::WHERE_PAGE, Kwf_Component_Select::WHERE_PSEUDO_PAGE, Kwf_Component_Select::WHERE_FLAGS, Kwf_Component_Select::WHERE_BOX, Kwf_Component_Select::WHERE_MULTI_BOX, Kwf_Component_Select::WHERE_SHOW_IN_MENU, Kwf_Component_Select::WHERE_COMPONENT_CLASSES, Kwf_Component_Select::WHERE_PAGE_GENERATOR, Kwf_Component_Select::WHERE_GENERATOR, Kwf_Component_Select::WHERE_HAS_EDIT_COMPONENTS, Kwf_Component_Select::WHERE_INHERIT, Kwf_Component_Select::WHERE_UNIQUE, Kwf_Component_Select::WHERE_GENERATOR_CLASS, Kwf_Component_Select::WHERE_COMPONENT_KEY, ), $select); $selectHash = md5($genSelect->getHash().$childSelect->getHash()); $cacheId = 'recCCGen-'.$selectHash.$this->componentClass.implode('__', $this->inheritClasses); $generators = Kwf_Cache_SimpleStatic::fetch($cacheId, $success); if (!$success) { //get (statically=fast and cached) all generators that could create the component we are looking for $generators = $this->_getRecursiveGenerators( Kwc_Abstract::getChildComponentClasses($this, $childSelect), //all classes $this could create that match $childSelect $genSelect, $childSelect, $selectHash); Kwf_Cache_SimpleStatic::add($cacheId, $generators); } $noSubPages = $childSelect->hasPart('wherePage') && !$childSelect->getPart('wherePage') || $childSelect->hasPart('wherePseudoPage') && !$childSelect->getPart('wherePseudoPage'); if ($noSubPages) { $select->whereChildOf($this); } else { $select->whereSubroot($this); } foreach ($generators as $g) { if ($g['type'] == 'notStatic') { $gen = Kwf_Component_Generator_Abstract::getInstance($g['class'], $g['key']); $s = clone $select; if (!$noSubPages) { //unset limit as we may have filter away results $s->unsetPart('limitCount'); } foreach ($gen->getChildData(null, $s) as $d) { $add = true; if (!$noSubPages) { // sucht über unterseiten hinweg, wird hier erst im Nachhinein gehandelt, langsam $add = false; $c = $d; while (!$add && $c) { if ($c->componentId == $this->componentId) $add = true; $c = $c->parent; } } if ($add && !in_array($d, $ret, true)) { $ret[] = $d; if ($select->hasPart('limitCount') && $select->getPart('limitCount') <= count($ret)) { return $ret; } } } } } foreach ($generators as $k=>$g) { if ($g['type'] == 'cards') { $lookingForDefault = true; if ($select->hasPart('whereComponentClasses')) { $gen = Kwf_Component_Generator_Abstract ::getInstance($g['class'], $g['key'], array(), $g['pluginBaseComponentClass']); $classes = array_values($gen->getChildComponentClasses()); $defaultCardClass = $classes[0]; if (!in_array($defaultCardClass, $select->getPart('whereComponentClasses'))) { $lookingForDefault = false; } } if ($lookingForDefault) { //we have to look for it like for a static component because it's the default value that might not be in the table //this is not so efficient $generators[$k]['type'] = 'static'; //(kind of hackish to change the type here but works for now) } else { $gen = Kwf_Component_Generator_Abstract ::getInstance($g['class'], $g['key'], array(), $g['pluginBaseComponentClass']); foreach ($gen->getChildData(null, clone $select) as $d) { $ret[] = $d; if ($select->hasPart('limitCount') && $select->getPart('limitCount') <= count($ret)) { return $ret; } } } } } $staticGeneratorComponentClasses = array(); foreach ($generators as $k=>$g) { if ($g['type'] == 'static') { if ($g['pluginBaseComponentClass']) { $staticGeneratorComponentClasses[] = $g['pluginBaseComponentClass']; } else { $staticGeneratorComponentClasses[] = $g['class']; } } } if ($staticGeneratorComponentClasses) { $pdSelect = clone $childSelect; $pdSelect->whereComponentClasses($staticGeneratorComponentClasses); $pdSelect->copyParts(array('ignoreVisible'), $select); $pd = $this->getRecursiveChildComponents($pdSelect, $childSelect); foreach ($generators as $k=>$g) { if ($g['type'] == 'static') { $parentDatas = array(); foreach ($pd as $d) { if ($d->componentClass == $g['class'] || $d->componentClass == $g['pluginBaseComponentClass']) { $parentDatas[] = $d; } } if ($parentDatas) { $gen = Kwf_Component_Generator_Abstract ::getInstance($g['class'], $g['key'], array(), $g['pluginBaseComponentClass']); foreach ($gen->getChildData($parentDatas, $select) as $d) { if (!in_array($d, $ret, true)) { $ret[] = $d; if ($select->hasPart('limitCount') && $select->getPart('limitCount') <= count($ret)) { return $ret; } } } } } } } return $ret; }
php
public function getRecursiveChildComponents($select = array(), $childSelect = array('page'=>false)) { if (is_array($select)) { $select = new Kwf_Component_Select($select); } else { $select = clone $select; } Kwf_Benchmark::count('getRecursiveChildComponents'); if (is_array($childSelect)) { $childSelect = new Kwf_Component_Select($childSelect); } $ret = $this->getChildComponents($select); if ($select->hasPart('limitCount') && $select->getPart('limitCount') <= count($ret)) { return $ret; } $genSelect = new Kwf_Component_Select(); $genSelect->copyParts(array( Kwf_Component_Select::WHERE_HOME, Kwf_Component_Select::WHERE_PAGE, Kwf_Component_Select::WHERE_PSEUDO_PAGE, Kwf_Component_Select::WHERE_FLAGS, Kwf_Component_Select::WHERE_BOX, Kwf_Component_Select::WHERE_MULTI_BOX, Kwf_Component_Select::WHERE_SHOW_IN_MENU, Kwf_Component_Select::WHERE_COMPONENT_CLASSES, Kwf_Component_Select::WHERE_PAGE_GENERATOR, Kwf_Component_Select::WHERE_GENERATOR, Kwf_Component_Select::WHERE_HAS_EDIT_COMPONENTS, Kwf_Component_Select::WHERE_INHERIT, Kwf_Component_Select::WHERE_UNIQUE, Kwf_Component_Select::WHERE_GENERATOR_CLASS, Kwf_Component_Select::WHERE_COMPONENT_KEY, ), $select); $selectHash = md5($genSelect->getHash().$childSelect->getHash()); $cacheId = 'recCCGen-'.$selectHash.$this->componentClass.implode('__', $this->inheritClasses); $generators = Kwf_Cache_SimpleStatic::fetch($cacheId, $success); if (!$success) { //get (statically=fast and cached) all generators that could create the component we are looking for $generators = $this->_getRecursiveGenerators( Kwc_Abstract::getChildComponentClasses($this, $childSelect), //all classes $this could create that match $childSelect $genSelect, $childSelect, $selectHash); Kwf_Cache_SimpleStatic::add($cacheId, $generators); } $noSubPages = $childSelect->hasPart('wherePage') && !$childSelect->getPart('wherePage') || $childSelect->hasPart('wherePseudoPage') && !$childSelect->getPart('wherePseudoPage'); if ($noSubPages) { $select->whereChildOf($this); } else { $select->whereSubroot($this); } foreach ($generators as $g) { if ($g['type'] == 'notStatic') { $gen = Kwf_Component_Generator_Abstract::getInstance($g['class'], $g['key']); $s = clone $select; if (!$noSubPages) { //unset limit as we may have filter away results $s->unsetPart('limitCount'); } foreach ($gen->getChildData(null, $s) as $d) { $add = true; if (!$noSubPages) { // sucht über unterseiten hinweg, wird hier erst im Nachhinein gehandelt, langsam $add = false; $c = $d; while (!$add && $c) { if ($c->componentId == $this->componentId) $add = true; $c = $c->parent; } } if ($add && !in_array($d, $ret, true)) { $ret[] = $d; if ($select->hasPart('limitCount') && $select->getPart('limitCount') <= count($ret)) { return $ret; } } } } } foreach ($generators as $k=>$g) { if ($g['type'] == 'cards') { $lookingForDefault = true; if ($select->hasPart('whereComponentClasses')) { $gen = Kwf_Component_Generator_Abstract ::getInstance($g['class'], $g['key'], array(), $g['pluginBaseComponentClass']); $classes = array_values($gen->getChildComponentClasses()); $defaultCardClass = $classes[0]; if (!in_array($defaultCardClass, $select->getPart('whereComponentClasses'))) { $lookingForDefault = false; } } if ($lookingForDefault) { //we have to look for it like for a static component because it's the default value that might not be in the table //this is not so efficient $generators[$k]['type'] = 'static'; //(kind of hackish to change the type here but works for now) } else { $gen = Kwf_Component_Generator_Abstract ::getInstance($g['class'], $g['key'], array(), $g['pluginBaseComponentClass']); foreach ($gen->getChildData(null, clone $select) as $d) { $ret[] = $d; if ($select->hasPart('limitCount') && $select->getPart('limitCount') <= count($ret)) { return $ret; } } } } } $staticGeneratorComponentClasses = array(); foreach ($generators as $k=>$g) { if ($g['type'] == 'static') { if ($g['pluginBaseComponentClass']) { $staticGeneratorComponentClasses[] = $g['pluginBaseComponentClass']; } else { $staticGeneratorComponentClasses[] = $g['class']; } } } if ($staticGeneratorComponentClasses) { $pdSelect = clone $childSelect; $pdSelect->whereComponentClasses($staticGeneratorComponentClasses); $pdSelect->copyParts(array('ignoreVisible'), $select); $pd = $this->getRecursiveChildComponents($pdSelect, $childSelect); foreach ($generators as $k=>$g) { if ($g['type'] == 'static') { $parentDatas = array(); foreach ($pd as $d) { if ($d->componentClass == $g['class'] || $d->componentClass == $g['pluginBaseComponentClass']) { $parentDatas[] = $d; } } if ($parentDatas) { $gen = Kwf_Component_Generator_Abstract ::getInstance($g['class'], $g['key'], array(), $g['pluginBaseComponentClass']); foreach ($gen->getChildData($parentDatas, $select) as $d) { if (!in_array($d, $ret, true)) { $ret[] = $d; if ($select->hasPart('limitCount') && $select->getPart('limitCount') <= count($ret)) { return $ret; } } } } } } } return $ret; }
[ "public", "function", "getRecursiveChildComponents", "(", "$", "select", "=", "array", "(", ")", ",", "$", "childSelect", "=", "array", "(", "'page'", "=>", "false", ")", ")", "{", "if", "(", "is_array", "(", "$", "select", ")", ")", "{", "$", "select", "=", "new", "Kwf_Component_Select", "(", "$", "select", ")", ";", "}", "else", "{", "$", "select", "=", "clone", "$", "select", ";", "}", "Kwf_Benchmark", "::", "count", "(", "'getRecursiveChildComponents'", ")", ";", "if", "(", "is_array", "(", "$", "childSelect", ")", ")", "{", "$", "childSelect", "=", "new", "Kwf_Component_Select", "(", "$", "childSelect", ")", ";", "}", "$", "ret", "=", "$", "this", "->", "getChildComponents", "(", "$", "select", ")", ";", "if", "(", "$", "select", "->", "hasPart", "(", "'limitCount'", ")", "&&", "$", "select", "->", "getPart", "(", "'limitCount'", ")", "<=", "count", "(", "$", "ret", ")", ")", "{", "return", "$", "ret", ";", "}", "$", "genSelect", "=", "new", "Kwf_Component_Select", "(", ")", ";", "$", "genSelect", "->", "copyParts", "(", "array", "(", "Kwf_Component_Select", "::", "WHERE_HOME", ",", "Kwf_Component_Select", "::", "WHERE_PAGE", ",", "Kwf_Component_Select", "::", "WHERE_PSEUDO_PAGE", ",", "Kwf_Component_Select", "::", "WHERE_FLAGS", ",", "Kwf_Component_Select", "::", "WHERE_BOX", ",", "Kwf_Component_Select", "::", "WHERE_MULTI_BOX", ",", "Kwf_Component_Select", "::", "WHERE_SHOW_IN_MENU", ",", "Kwf_Component_Select", "::", "WHERE_COMPONENT_CLASSES", ",", "Kwf_Component_Select", "::", "WHERE_PAGE_GENERATOR", ",", "Kwf_Component_Select", "::", "WHERE_GENERATOR", ",", "Kwf_Component_Select", "::", "WHERE_HAS_EDIT_COMPONENTS", ",", "Kwf_Component_Select", "::", "WHERE_INHERIT", ",", "Kwf_Component_Select", "::", "WHERE_UNIQUE", ",", "Kwf_Component_Select", "::", "WHERE_GENERATOR_CLASS", ",", "Kwf_Component_Select", "::", "WHERE_COMPONENT_KEY", ",", ")", ",", "$", "select", ")", ";", "$", "selectHash", "=", "md5", "(", "$", "genSelect", "->", "getHash", "(", ")", ".", "$", "childSelect", "->", "getHash", "(", ")", ")", ";", "$", "cacheId", "=", "'recCCGen-'", ".", "$", "selectHash", ".", "$", "this", "->", "componentClass", ".", "implode", "(", "'__'", ",", "$", "this", "->", "inheritClasses", ")", ";", "$", "generators", "=", "Kwf_Cache_SimpleStatic", "::", "fetch", "(", "$", "cacheId", ",", "$", "success", ")", ";", "if", "(", "!", "$", "success", ")", "{", "//get (statically=fast and cached) all generators that could create the component we are looking for", "$", "generators", "=", "$", "this", "->", "_getRecursiveGenerators", "(", "Kwc_Abstract", "::", "getChildComponentClasses", "(", "$", "this", ",", "$", "childSelect", ")", ",", "//all classes $this could create that match $childSelect", "$", "genSelect", ",", "$", "childSelect", ",", "$", "selectHash", ")", ";", "Kwf_Cache_SimpleStatic", "::", "add", "(", "$", "cacheId", ",", "$", "generators", ")", ";", "}", "$", "noSubPages", "=", "$", "childSelect", "->", "hasPart", "(", "'wherePage'", ")", "&&", "!", "$", "childSelect", "->", "getPart", "(", "'wherePage'", ")", "||", "$", "childSelect", "->", "hasPart", "(", "'wherePseudoPage'", ")", "&&", "!", "$", "childSelect", "->", "getPart", "(", "'wherePseudoPage'", ")", ";", "if", "(", "$", "noSubPages", ")", "{", "$", "select", "->", "whereChildOf", "(", "$", "this", ")", ";", "}", "else", "{", "$", "select", "->", "whereSubroot", "(", "$", "this", ")", ";", "}", "foreach", "(", "$", "generators", "as", "$", "g", ")", "{", "if", "(", "$", "g", "[", "'type'", "]", "==", "'notStatic'", ")", "{", "$", "gen", "=", "Kwf_Component_Generator_Abstract", "::", "getInstance", "(", "$", "g", "[", "'class'", "]", ",", "$", "g", "[", "'key'", "]", ")", ";", "$", "s", "=", "clone", "$", "select", ";", "if", "(", "!", "$", "noSubPages", ")", "{", "//unset limit as we may have filter away results", "$", "s", "->", "unsetPart", "(", "'limitCount'", ")", ";", "}", "foreach", "(", "$", "gen", "->", "getChildData", "(", "null", ",", "$", "s", ")", "as", "$", "d", ")", "{", "$", "add", "=", "true", ";", "if", "(", "!", "$", "noSubPages", ")", "{", "// sucht über unterseiten hinweg, wird hier erst im Nachhinein gehandelt, langsam", "$", "add", "=", "false", ";", "$", "c", "=", "$", "d", ";", "while", "(", "!", "$", "add", "&&", "$", "c", ")", "{", "if", "(", "$", "c", "->", "componentId", "==", "$", "this", "->", "componentId", ")", "$", "add", "=", "true", ";", "$", "c", "=", "$", "c", "->", "parent", ";", "}", "}", "if", "(", "$", "add", "&&", "!", "in_array", "(", "$", "d", ",", "$", "ret", ",", "true", ")", ")", "{", "$", "ret", "[", "]", "=", "$", "d", ";", "if", "(", "$", "select", "->", "hasPart", "(", "'limitCount'", ")", "&&", "$", "select", "->", "getPart", "(", "'limitCount'", ")", "<=", "count", "(", "$", "ret", ")", ")", "{", "return", "$", "ret", ";", "}", "}", "}", "}", "}", "foreach", "(", "$", "generators", "as", "$", "k", "=>", "$", "g", ")", "{", "if", "(", "$", "g", "[", "'type'", "]", "==", "'cards'", ")", "{", "$", "lookingForDefault", "=", "true", ";", "if", "(", "$", "select", "->", "hasPart", "(", "'whereComponentClasses'", ")", ")", "{", "$", "gen", "=", "Kwf_Component_Generator_Abstract", "::", "getInstance", "(", "$", "g", "[", "'class'", "]", ",", "$", "g", "[", "'key'", "]", ",", "array", "(", ")", ",", "$", "g", "[", "'pluginBaseComponentClass'", "]", ")", ";", "$", "classes", "=", "array_values", "(", "$", "gen", "->", "getChildComponentClasses", "(", ")", ")", ";", "$", "defaultCardClass", "=", "$", "classes", "[", "0", "]", ";", "if", "(", "!", "in_array", "(", "$", "defaultCardClass", ",", "$", "select", "->", "getPart", "(", "'whereComponentClasses'", ")", ")", ")", "{", "$", "lookingForDefault", "=", "false", ";", "}", "}", "if", "(", "$", "lookingForDefault", ")", "{", "//we have to look for it like for a static component because it's the default value that might not be in the table", "//this is not so efficient", "$", "generators", "[", "$", "k", "]", "[", "'type'", "]", "=", "'static'", ";", "//(kind of hackish to change the type here but works for now)", "}", "else", "{", "$", "gen", "=", "Kwf_Component_Generator_Abstract", "::", "getInstance", "(", "$", "g", "[", "'class'", "]", ",", "$", "g", "[", "'key'", "]", ",", "array", "(", ")", ",", "$", "g", "[", "'pluginBaseComponentClass'", "]", ")", ";", "foreach", "(", "$", "gen", "->", "getChildData", "(", "null", ",", "clone", "$", "select", ")", "as", "$", "d", ")", "{", "$", "ret", "[", "]", "=", "$", "d", ";", "if", "(", "$", "select", "->", "hasPart", "(", "'limitCount'", ")", "&&", "$", "select", "->", "getPart", "(", "'limitCount'", ")", "<=", "count", "(", "$", "ret", ")", ")", "{", "return", "$", "ret", ";", "}", "}", "}", "}", "}", "$", "staticGeneratorComponentClasses", "=", "array", "(", ")", ";", "foreach", "(", "$", "generators", "as", "$", "k", "=>", "$", "g", ")", "{", "if", "(", "$", "g", "[", "'type'", "]", "==", "'static'", ")", "{", "if", "(", "$", "g", "[", "'pluginBaseComponentClass'", "]", ")", "{", "$", "staticGeneratorComponentClasses", "[", "]", "=", "$", "g", "[", "'pluginBaseComponentClass'", "]", ";", "}", "else", "{", "$", "staticGeneratorComponentClasses", "[", "]", "=", "$", "g", "[", "'class'", "]", ";", "}", "}", "}", "if", "(", "$", "staticGeneratorComponentClasses", ")", "{", "$", "pdSelect", "=", "clone", "$", "childSelect", ";", "$", "pdSelect", "->", "whereComponentClasses", "(", "$", "staticGeneratorComponentClasses", ")", ";", "$", "pdSelect", "->", "copyParts", "(", "array", "(", "'ignoreVisible'", ")", ",", "$", "select", ")", ";", "$", "pd", "=", "$", "this", "->", "getRecursiveChildComponents", "(", "$", "pdSelect", ",", "$", "childSelect", ")", ";", "foreach", "(", "$", "generators", "as", "$", "k", "=>", "$", "g", ")", "{", "if", "(", "$", "g", "[", "'type'", "]", "==", "'static'", ")", "{", "$", "parentDatas", "=", "array", "(", ")", ";", "foreach", "(", "$", "pd", "as", "$", "d", ")", "{", "if", "(", "$", "d", "->", "componentClass", "==", "$", "g", "[", "'class'", "]", "||", "$", "d", "->", "componentClass", "==", "$", "g", "[", "'pluginBaseComponentClass'", "]", ")", "{", "$", "parentDatas", "[", "]", "=", "$", "d", ";", "}", "}", "if", "(", "$", "parentDatas", ")", "{", "$", "gen", "=", "Kwf_Component_Generator_Abstract", "::", "getInstance", "(", "$", "g", "[", "'class'", "]", ",", "$", "g", "[", "'key'", "]", ",", "array", "(", ")", ",", "$", "g", "[", "'pluginBaseComponentClass'", "]", ")", ";", "foreach", "(", "$", "gen", "->", "getChildData", "(", "$", "parentDatas", ",", "$", "select", ")", "as", "$", "d", ")", "{", "if", "(", "!", "in_array", "(", "$", "d", ",", "$", "ret", ",", "true", ")", ")", "{", "$", "ret", "[", "]", "=", "$", "d", ";", "if", "(", "$", "select", "->", "hasPart", "(", "'limitCount'", ")", "&&", "$", "select", "->", "getPart", "(", "'limitCount'", ")", "<=", "count", "(", "$", "ret", ")", ")", "{", "return", "$", "ret", ";", "}", "}", "}", "}", "}", "}", "}", "return", "$", "ret", ";", "}" ]
Returns child components recursively This method usually is very efficient and tries to create as less data objects as possible. It is still a complex operation thus should not get called too often. @param Kwf_Component_Select|array what to search for @param Kwf_Component_Select|array how deep to search @return array(Kwf_Component_Data)
[ "Returns", "child", "components", "recursively" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L382-L536
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.countChildComponents
public function countChildComponents($select = array()) { Kwf_Benchmark::count('countChildComponents'); $select = $this->_formatSelect($select); if (!$select->hasPart(Kwf_Component_Select::WHERE_GENERATOR)) { throw new Kwf_Exception("You can count only for one generator at a time"); } $generators = Kwf_Component_Generator_Abstract::getInstances($this->componentClass, $select); return current($generators)->countChildData($this, $select); }
php
public function countChildComponents($select = array()) { Kwf_Benchmark::count('countChildComponents'); $select = $this->_formatSelect($select); if (!$select->hasPart(Kwf_Component_Select::WHERE_GENERATOR)) { throw new Kwf_Exception("You can count only for one generator at a time"); } $generators = Kwf_Component_Generator_Abstract::getInstances($this->componentClass, $select); return current($generators)->countChildData($this, $select); }
[ "public", "function", "countChildComponents", "(", "$", "select", "=", "array", "(", ")", ")", "{", "Kwf_Benchmark", "::", "count", "(", "'countChildComponents'", ")", ";", "$", "select", "=", "$", "this", "->", "_formatSelect", "(", "$", "select", ")", ";", "if", "(", "!", "$", "select", "->", "hasPart", "(", "Kwf_Component_Select", "::", "WHERE_GENERATOR", ")", ")", "{", "throw", "new", "Kwf_Exception", "(", "\"You can count only for one generator at a time\"", ")", ";", "}", "$", "generators", "=", "Kwf_Component_Generator_Abstract", "::", "getInstances", "(", "$", "this", "->", "componentClass", ",", "$", "select", ")", ";", "return", "current", "(", "$", "generators", ")", "->", "countChildData", "(", "$", "this", ",", "$", "select", ")", ";", "}" ]
returns the number of child components for a single generator Only works for a single generator - you have to specify the required generator. This is much more efficient than count(->getChildComponents()) as it will result in an SELECT COUNT() sql query @param array|Kwf_Component_Select @return int
[ "returns", "the", "number", "of", "child", "components", "for", "a", "single", "generator" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L652-L663
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.getChildIds
public function getChildIds($select = array()) { $select = $this->_formatSelect($select); if (!$select->hasPart(Kwf_Component_Select::WHERE_GENERATOR)) { throw new Kwf_Exception('Only one generator supported, please restrict select to a generator'); } $generator = current(Kwf_Component_Generator_Abstract::getInstances($this, $select)); return $generator->getChildIds($this, $select); }
php
public function getChildIds($select = array()) { $select = $this->_formatSelect($select); if (!$select->hasPart(Kwf_Component_Select::WHERE_GENERATOR)) { throw new Kwf_Exception('Only one generator supported, please restrict select to a generator'); } $generator = current(Kwf_Component_Generator_Abstract::getInstances($this, $select)); return $generator->getChildIds($this, $select); }
[ "public", "function", "getChildIds", "(", "$", "select", "=", "array", "(", ")", ")", "{", "$", "select", "=", "$", "this", "->", "_formatSelect", "(", "$", "select", ")", ";", "if", "(", "!", "$", "select", "->", "hasPart", "(", "Kwf_Component_Select", "::", "WHERE_GENERATOR", ")", ")", "{", "throw", "new", "Kwf_Exception", "(", "'Only one generator supported, please restrict select to a generator'", ")", ";", "}", "$", "generator", "=", "current", "(", "Kwf_Component_Generator_Abstract", "::", "getInstances", "(", "$", "this", ",", "$", "select", ")", ")", ";", "return", "$", "generator", "->", "getChildIds", "(", "$", "this", ",", "$", "select", ")", ";", "}" ]
Returns child ids for a single generator Only works for a single generator - you have to specify the required generator. This is much more efficient than getChildComponents as no rows or data objects will be created. @param array|Kwf_Component_Select @return int[]
[ "Returns", "child", "ids", "for", "a", "single", "generator" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L675-L683
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.getChildComponents
public function getChildComponents($select = array()) { $select = $this->_formatSelect($select); $sc = $select->getHash(); if (isset($this->_childComponentsCache[$sc])) { Kwf_Benchmark::count('getChildComponents cached'); } else { Kwf_Benchmark::count('getChildComponents uncached'); } if (!isset($this->_childComponentsCache[$sc])) { $this->_childComponentsCache[$sc] = array(); if ($select->getPart(Kwf_Component_Select::WHERE_COMPONENT_CLASSES) === array()) { return $this->_childComponentsCache[$sc]; //vorzeitig abbrechen, da kommt sicher kein ergebnis } if ($select->hasPart(Kwf_Component_Select::LIMIT_COUNT)) { $limitCount = $select->getPart(Kwf_Component_Select::LIMIT_COUNT); } else { $limitCount = null; } $generators = Kwf_Component_Generator_Abstract::getOwnInstances($this, $select); $ret = $this->_getChildComponentsFromGenerators($generators, $select, $limitCount); if (is_null($limitCount) || count($ret) < $limitCount) { //wenn limit nicht erreicht, inherited generator auch noch fragen if (!is_null($limitCount)) $limitCount -= count($ret); $generators = Kwf_Component_Generator_Abstract::getInheritedInstances($this, $select); $ret += $this->_getChildComponentsFromGenerators($generators, $select, $limitCount); //kein array_merge, da wuerden die keys verloren gehen - und die sind eh eindeutig } $this->_childComponentsCache[$sc] = $ret; } return $this->_childComponentsCache[$sc]; }
php
public function getChildComponents($select = array()) { $select = $this->_formatSelect($select); $sc = $select->getHash(); if (isset($this->_childComponentsCache[$sc])) { Kwf_Benchmark::count('getChildComponents cached'); } else { Kwf_Benchmark::count('getChildComponents uncached'); } if (!isset($this->_childComponentsCache[$sc])) { $this->_childComponentsCache[$sc] = array(); if ($select->getPart(Kwf_Component_Select::WHERE_COMPONENT_CLASSES) === array()) { return $this->_childComponentsCache[$sc]; //vorzeitig abbrechen, da kommt sicher kein ergebnis } if ($select->hasPart(Kwf_Component_Select::LIMIT_COUNT)) { $limitCount = $select->getPart(Kwf_Component_Select::LIMIT_COUNT); } else { $limitCount = null; } $generators = Kwf_Component_Generator_Abstract::getOwnInstances($this, $select); $ret = $this->_getChildComponentsFromGenerators($generators, $select, $limitCount); if (is_null($limitCount) || count($ret) < $limitCount) { //wenn limit nicht erreicht, inherited generator auch noch fragen if (!is_null($limitCount)) $limitCount -= count($ret); $generators = Kwf_Component_Generator_Abstract::getInheritedInstances($this, $select); $ret += $this->_getChildComponentsFromGenerators($generators, $select, $limitCount); //kein array_merge, da wuerden die keys verloren gehen - und die sind eh eindeutig } $this->_childComponentsCache[$sc] = $ret; } return $this->_childComponentsCache[$sc]; }
[ "public", "function", "getChildComponents", "(", "$", "select", "=", "array", "(", ")", ")", "{", "$", "select", "=", "$", "this", "->", "_formatSelect", "(", "$", "select", ")", ";", "$", "sc", "=", "$", "select", "->", "getHash", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "_childComponentsCache", "[", "$", "sc", "]", ")", ")", "{", "Kwf_Benchmark", "::", "count", "(", "'getChildComponents cached'", ")", ";", "}", "else", "{", "Kwf_Benchmark", "::", "count", "(", "'getChildComponents uncached'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "_childComponentsCache", "[", "$", "sc", "]", ")", ")", "{", "$", "this", "->", "_childComponentsCache", "[", "$", "sc", "]", "=", "array", "(", ")", ";", "if", "(", "$", "select", "->", "getPart", "(", "Kwf_Component_Select", "::", "WHERE_COMPONENT_CLASSES", ")", "===", "array", "(", ")", ")", "{", "return", "$", "this", "->", "_childComponentsCache", "[", "$", "sc", "]", ";", "//vorzeitig abbrechen, da kommt sicher kein ergebnis", "}", "if", "(", "$", "select", "->", "hasPart", "(", "Kwf_Component_Select", "::", "LIMIT_COUNT", ")", ")", "{", "$", "limitCount", "=", "$", "select", "->", "getPart", "(", "Kwf_Component_Select", "::", "LIMIT_COUNT", ")", ";", "}", "else", "{", "$", "limitCount", "=", "null", ";", "}", "$", "generators", "=", "Kwf_Component_Generator_Abstract", "::", "getOwnInstances", "(", "$", "this", ",", "$", "select", ")", ";", "$", "ret", "=", "$", "this", "->", "_getChildComponentsFromGenerators", "(", "$", "generators", ",", "$", "select", ",", "$", "limitCount", ")", ";", "if", "(", "is_null", "(", "$", "limitCount", ")", "||", "count", "(", "$", "ret", ")", "<", "$", "limitCount", ")", "{", "//wenn limit nicht erreicht, inherited generator auch noch fragen", "if", "(", "!", "is_null", "(", "$", "limitCount", ")", ")", "$", "limitCount", "-=", "count", "(", "$", "ret", ")", ";", "$", "generators", "=", "Kwf_Component_Generator_Abstract", "::", "getInheritedInstances", "(", "$", "this", ",", "$", "select", ")", ";", "$", "ret", "+=", "$", "this", "->", "_getChildComponentsFromGenerators", "(", "$", "generators", ",", "$", "select", ",", "$", "limitCount", ")", ";", "//kein array_merge, da wuerden die keys verloren gehen - und die sind eh eindeutig", "}", "$", "this", "->", "_childComponentsCache", "[", "$", "sc", "]", "=", "$", "ret", ";", "}", "return", "$", "this", "->", "_childComponentsCache", "[", "$", "sc", "]", ";", "}" ]
Returns child components matching the given select @param array|Kwf_Component_Select @return Kwf_Component_Data[]
[ "Returns", "child", "components", "matching", "the", "given", "select" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L691-L727
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.getChildPages
public function getChildPages($select = array(), $childSelect = array('page'=>false)) { if (is_array($select)) { $select = new Kwf_Component_Select($select); } else { $select = clone $select; } $select->wherePage(true); return $this->getRecursiveChildComponents($select, $childSelect); }
php
public function getChildPages($select = array(), $childSelect = array('page'=>false)) { if (is_array($select)) { $select = new Kwf_Component_Select($select); } else { $select = clone $select; } $select->wherePage(true); return $this->getRecursiveChildComponents($select, $childSelect); }
[ "public", "function", "getChildPages", "(", "$", "select", "=", "array", "(", ")", ",", "$", "childSelect", "=", "array", "(", "'page'", "=>", "false", ")", ")", "{", "if", "(", "is_array", "(", "$", "select", ")", ")", "{", "$", "select", "=", "new", "Kwf_Component_Select", "(", "$", "select", ")", ";", "}", "else", "{", "$", "select", "=", "clone", "$", "select", ";", "}", "$", "select", "->", "wherePage", "(", "true", ")", ";", "return", "$", "this", "->", "getRecursiveChildComponents", "(", "$", "select", ",", "$", "childSelect", ")", ";", "}" ]
Returns child pages matching the given select Not only direct children will be returned, also pages created by child components. @param array|Kwf_Component_Select additional constraints @param array|Kwf_Component_Select constraints on how deep indirect child pages will be returned @return Kwf_Component_Data[]
[ "Returns", "child", "pages", "matching", "the", "given", "select" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L767-L776
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.getChildPseudoPages
public function getChildPseudoPages($select = array(), $childSelect = array('page'=>false)) { if (is_array($select)) { $select = new Kwf_Component_Select($select); } else { $select = clone $select; } $select->wherePseudoPage(true); return $this->getRecursiveChildComponents($select, $childSelect); }
php
public function getChildPseudoPages($select = array(), $childSelect = array('page'=>false)) { if (is_array($select)) { $select = new Kwf_Component_Select($select); } else { $select = clone $select; } $select->wherePseudoPage(true); return $this->getRecursiveChildComponents($select, $childSelect); }
[ "public", "function", "getChildPseudoPages", "(", "$", "select", "=", "array", "(", ")", ",", "$", "childSelect", "=", "array", "(", "'page'", "=>", "false", ")", ")", "{", "if", "(", "is_array", "(", "$", "select", ")", ")", "{", "$", "select", "=", "new", "Kwf_Component_Select", "(", "$", "select", ")", ";", "}", "else", "{", "$", "select", "=", "clone", "$", "select", ";", "}", "$", "select", "->", "wherePseudoPage", "(", "true", ")", ";", "return", "$", "this", "->", "getRecursiveChildComponents", "(", "$", "select", ",", "$", "childSelect", ")", ";", "}" ]
Returns child pseudo pages matching the given select Not only direct children will be returned, also pseudo pages created by child components. @param array|Kwf_Component_Select additional constraints @param array|Kwf_Component_Select constraints on how deep indirect child pseudo pages will be returned @return Kwf_Component_Data[]
[ "Returns", "child", "pseudo", "pages", "matching", "the", "given", "select" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L787-L796
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.getChildBoxes
public function getChildBoxes($select = array()) { if (is_array($select)) { $select = new Kwf_Component_Select($select); } else { $select = clone $select; } $select->whereBox(true); return $this->getRecursiveChildComponents($select); }
php
public function getChildBoxes($select = array()) { if (is_array($select)) { $select = new Kwf_Component_Select($select); } else { $select = clone $select; } $select->whereBox(true); return $this->getRecursiveChildComponents($select); }
[ "public", "function", "getChildBoxes", "(", "$", "select", "=", "array", "(", ")", ")", "{", "if", "(", "is_array", "(", "$", "select", ")", ")", "{", "$", "select", "=", "new", "Kwf_Component_Select", "(", "$", "select", ")", ";", "}", "else", "{", "$", "select", "=", "clone", "$", "select", ";", "}", "$", "select", "->", "whereBox", "(", "true", ")", ";", "return", "$", "this", "->", "getRecursiveChildComponents", "(", "$", "select", ")", ";", "}" ]
Returns child boxes matching the given select Not only direct children will be returned, also boxes created by child components. @param array|Kwf_Component_Select @return Kwf_Component_Data[]
[ "Returns", "child", "boxes", "matching", "the", "given", "select" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L806-L815
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.getChildPage
public function getChildPage($select = array(), $childSelect = array('page'=>false)) { if (is_array($select)) { $select = new Kwf_Component_Select($select); } $select->limit(1); return current($this->getChildPages($select, $childSelect)); }
php
public function getChildPage($select = array(), $childSelect = array('page'=>false)) { if (is_array($select)) { $select = new Kwf_Component_Select($select); } $select->limit(1); return current($this->getChildPages($select, $childSelect)); }
[ "public", "function", "getChildPage", "(", "$", "select", "=", "array", "(", ")", ",", "$", "childSelect", "=", "array", "(", "'page'", "=>", "false", ")", ")", "{", "if", "(", "is_array", "(", "$", "select", ")", ")", "{", "$", "select", "=", "new", "Kwf_Component_Select", "(", "$", "select", ")", ";", "}", "$", "select", "->", "limit", "(", "1", ")", ";", "return", "current", "(", "$", "this", "->", "getChildPages", "(", "$", "select", ",", "$", "childSelect", ")", ")", ";", "}" ]
Returns a single child page @see getChildPages @return Kwf_Component_Data
[ "Returns", "a", "single", "child", "page" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L835-L842
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.getChildPseudoPage
public function getChildPseudoPage($select = array()) { if (is_array($select)) { $select = new Kwf_Component_Select($select); } $select->limit(1); $ret = $this->getChildPseudoPages($select); if (!$ret) return null; return current($ret); }
php
public function getChildPseudoPage($select = array()) { if (is_array($select)) { $select = new Kwf_Component_Select($select); } $select->limit(1); $ret = $this->getChildPseudoPages($select); if (!$ret) return null; return current($ret); }
[ "public", "function", "getChildPseudoPage", "(", "$", "select", "=", "array", "(", ")", ")", "{", "if", "(", "is_array", "(", "$", "select", ")", ")", "{", "$", "select", "=", "new", "Kwf_Component_Select", "(", "$", "select", ")", ";", "}", "$", "select", "->", "limit", "(", "1", ")", ";", "$", "ret", "=", "$", "this", "->", "getChildPseudoPages", "(", "$", "select", ")", ";", "if", "(", "!", "$", "ret", ")", "return", "null", ";", "return", "current", "(", "$", "ret", ")", ";", "}" ]
Returns a single child pseudo page @see getChildPseudoPages @return Kwf_Component_Data
[ "Returns", "a", "single", "child", "pseudo", "page" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L850-L859
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.getChildComponent
public function getChildComponent($select = array()) { $select = $this->_formatSelect($select); $select->limit(1); $cc = $this->getChildComponents($select); if (!$cc) return null; return current($cc); }
php
public function getChildComponent($select = array()) { $select = $this->_formatSelect($select); $select->limit(1); $cc = $this->getChildComponents($select); if (!$cc) return null; return current($cc); }
[ "public", "function", "getChildComponent", "(", "$", "select", "=", "array", "(", ")", ")", "{", "$", "select", "=", "$", "this", "->", "_formatSelect", "(", "$", "select", ")", ";", "$", "select", "->", "limit", "(", "1", ")", ";", "$", "cc", "=", "$", "this", "->", "getChildComponents", "(", "$", "select", ")", ";", "if", "(", "!", "$", "cc", ")", "return", "null", ";", "return", "current", "(", "$", "cc", ")", ";", "}" ]
Returns a single direct child component @see getChildComponents @return Kwf_Component_Data
[ "Returns", "a", "single", "direct", "child", "component" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L880-L887
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.getRecursiveChildComponent
public function getRecursiveChildComponent($select = array(), $childSelect = array('page'=>false)) { $select = $this->_formatSelect($select); $select->limit(1); $cc = $this->getRecursiveChildComponents($select, $childSelect); if (!$cc) return null; return current($cc); }
php
public function getRecursiveChildComponent($select = array(), $childSelect = array('page'=>false)) { $select = $this->_formatSelect($select); $select->limit(1); $cc = $this->getRecursiveChildComponents($select, $childSelect); if (!$cc) return null; return current($cc); }
[ "public", "function", "getRecursiveChildComponent", "(", "$", "select", "=", "array", "(", ")", ",", "$", "childSelect", "=", "array", "(", "'page'", "=>", "false", ")", ")", "{", "$", "select", "=", "$", "this", "->", "_formatSelect", "(", "$", "select", ")", ";", "$", "select", "->", "limit", "(", "1", ")", ";", "$", "cc", "=", "$", "this", "->", "getRecursiveChildComponents", "(", "$", "select", ",", "$", "childSelect", ")", ";", "if", "(", "!", "$", "cc", ")", "return", "null", ";", "return", "current", "(", "$", "cc", ")", ";", "}" ]
Returns a single child component @see getRecursiveChildComponents @return Kwf_Component_Data
[ "Returns", "a", "single", "child", "component" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L896-L903
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.getComponent
public function getComponent() { if (!isset($this->_component)) { $class = $this->componentClass; $class = strpos($class, '.') ? substr($class, 0, strpos($class, '.')) : $class; $component = new $class($this); $this->_component = $component; } return $this->_component; }
php
public function getComponent() { if (!isset($this->_component)) { $class = $this->componentClass; $class = strpos($class, '.') ? substr($class, 0, strpos($class, '.')) : $class; $component = new $class($this); $this->_component = $component; } return $this->_component; }
[ "public", "function", "getComponent", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_component", ")", ")", "{", "$", "class", "=", "$", "this", "->", "componentClass", ";", "$", "class", "=", "strpos", "(", "$", "class", ",", "'.'", ")", "?", "substr", "(", "$", "class", ",", "0", ",", "strpos", "(", "$", "class", ",", "'.'", ")", ")", ":", "$", "class", ";", "$", "component", "=", "new", "$", "class", "(", "$", "this", ")", ";", "$", "this", "->", "_component", "=", "$", "component", ";", "}", "return", "$", "this", "->", "_component", ";", "}" ]
Returns the Component object of to this data @return Kwc_Abstract
[ "Returns", "the", "Component", "object", "of", "to", "this", "data" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L910-L919
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.getPage
public function getPage() { $page = $this; if ($this->isPage) return $this; if (isset($this->_lazyParent)) { //optimierung: hier koennen eventuell ein paar nicht-pages uebersprungen werden $id = $this->_lazyParent; if (is_numeric($id) || strpos($id, '-') === false) { //ist eine page } else { if (strpos($id, '_') === false) { $id = substr($id, 0, strpos($id, '-')); if (!is_numeric($id)) { return null; } } else { $underScorePos = strrpos($id, '_'); $hyphenPos = strpos($id, '-', $underScorePos); if ($hyphenPos > $underScorePos) { $id = substr($id, 0, $hyphenPos); } } } return Kwf_Component_Data_Root::getInstance()->getComponentById($id, array('ignoreVisible'=>true)); } while ($page && !$page->isPage) { $page = $page->parent; } return $page; }
php
public function getPage() { $page = $this; if ($this->isPage) return $this; if (isset($this->_lazyParent)) { //optimierung: hier koennen eventuell ein paar nicht-pages uebersprungen werden $id = $this->_lazyParent; if (is_numeric($id) || strpos($id, '-') === false) { //ist eine page } else { if (strpos($id, '_') === false) { $id = substr($id, 0, strpos($id, '-')); if (!is_numeric($id)) { return null; } } else { $underScorePos = strrpos($id, '_'); $hyphenPos = strpos($id, '-', $underScorePos); if ($hyphenPos > $underScorePos) { $id = substr($id, 0, $hyphenPos); } } } return Kwf_Component_Data_Root::getInstance()->getComponentById($id, array('ignoreVisible'=>true)); } while ($page && !$page->isPage) { $page = $page->parent; } return $page; }
[ "public", "function", "getPage", "(", ")", "{", "$", "page", "=", "$", "this", ";", "if", "(", "$", "this", "->", "isPage", ")", "return", "$", "this", ";", "if", "(", "isset", "(", "$", "this", "->", "_lazyParent", ")", ")", "{", "//optimierung: hier koennen eventuell ein paar nicht-pages uebersprungen werden", "$", "id", "=", "$", "this", "->", "_lazyParent", ";", "if", "(", "is_numeric", "(", "$", "id", ")", "||", "strpos", "(", "$", "id", ",", "'-'", ")", "===", "false", ")", "{", "//ist eine page", "}", "else", "{", "if", "(", "strpos", "(", "$", "id", ",", "'_'", ")", "===", "false", ")", "{", "$", "id", "=", "substr", "(", "$", "id", ",", "0", ",", "strpos", "(", "$", "id", ",", "'-'", ")", ")", ";", "if", "(", "!", "is_numeric", "(", "$", "id", ")", ")", "{", "return", "null", ";", "}", "}", "else", "{", "$", "underScorePos", "=", "strrpos", "(", "$", "id", ",", "'_'", ")", ";", "$", "hyphenPos", "=", "strpos", "(", "$", "id", ",", "'-'", ",", "$", "underScorePos", ")", ";", "if", "(", "$", "hyphenPos", ">", "$", "underScorePos", ")", "{", "$", "id", "=", "substr", "(", "$", "id", ",", "0", ",", "$", "hyphenPos", ")", ";", "}", "}", "}", "return", "Kwf_Component_Data_Root", "::", "getInstance", "(", ")", "->", "getComponentById", "(", "$", "id", ",", "array", "(", "'ignoreVisible'", "=>", "true", ")", ")", ";", "}", "while", "(", "$", "page", "&&", "!", "$", "page", "->", "isPage", ")", "{", "$", "page", "=", "$", "page", "->", "parent", ";", "}", "return", "$", "page", ";", "}" ]
Returns the page this data belongs to (might be a page itself) @return Kwf_Component_Data
[ "Returns", "the", "page", "this", "data", "belongs", "to", "(", "might", "be", "a", "page", "itself", ")" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L926-L955
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.getPageOrRoot
public function getPageOrRoot() { $page = $this; while ($page && !$page->isPage) { if ($page instanceof Kwf_Component_Data_Root) return $page; $page = $page->parent; } return $page; }
php
public function getPageOrRoot() { $page = $this; while ($page && !$page->isPage) { if ($page instanceof Kwf_Component_Data_Root) return $page; $page = $page->parent; } return $page; }
[ "public", "function", "getPageOrRoot", "(", ")", "{", "$", "page", "=", "$", "this", ";", "while", "(", "$", "page", "&&", "!", "$", "page", "->", "isPage", ")", "{", "if", "(", "$", "page", "instanceof", "Kwf_Component_Data_Root", ")", "return", "$", "page", ";", "$", "page", "=", "$", "page", "->", "parent", ";", "}", "return", "$", "page", ";", "}" ]
Returns the page this data belongs to (might be a page itself) OR (if there is no page) the root component @return Kwf_Component_Data
[ "Returns", "the", "page", "this", "data", "belongs", "to", "(", "might", "be", "a", "page", "itself", ")", "OR", "(", "if", "there", "is", "no", "page", ")", "the", "root", "component" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L962-L970
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.getPseudoPageOrRoot
public function getPseudoPageOrRoot() { $page = $this; while ($page && !$page->isPseudoPage) { if ($page instanceof Kwf_Component_Data_Root) return $page; $page = $page->parent; } return $page; }
php
public function getPseudoPageOrRoot() { $page = $this; while ($page && !$page->isPseudoPage) { if ($page instanceof Kwf_Component_Data_Root) return $page; $page = $page->parent; } return $page; }
[ "public", "function", "getPseudoPageOrRoot", "(", ")", "{", "$", "page", "=", "$", "this", ";", "while", "(", "$", "page", "&&", "!", "$", "page", "->", "isPseudoPage", ")", "{", "if", "(", "$", "page", "instanceof", "Kwf_Component_Data_Root", ")", "return", "$", "page", ";", "$", "page", "=", "$", "page", "->", "parent", ";", "}", "return", "$", "page", ";", "}" ]
Returns the psuedo page or pagethis data belongs to (might be a page itself) OR (if there is no page) the root component @return Kwf_Component_Data
[ "Returns", "the", "psuedo", "page", "or", "pagethis", "data", "belongs", "to", "(", "might", "be", "a", "page", "itself", ")", "OR", "(", "if", "there", "is", "no", "page", ")", "the", "root", "component" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L977-L985
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.getPseudoPage
public function getPseudoPage() { $page = $this; while ($page && !$page->isPseudoPage) { $page = $page->parent; } return $page; }
php
public function getPseudoPage() { $page = $this; while ($page && !$page->isPseudoPage) { $page = $page->parent; } return $page; }
[ "public", "function", "getPseudoPage", "(", ")", "{", "$", "page", "=", "$", "this", ";", "while", "(", "$", "page", "&&", "!", "$", "page", "->", "isPseudoPage", ")", "{", "$", "page", "=", "$", "page", "->", "parent", ";", "}", "return", "$", "page", ";", "}" ]
Returns the pseudo page this data belongs to (might be a pseudo page itself) @return Kwf_Component_Data
[ "Returns", "the", "pseudo", "page", "this", "data", "belongs", "to", "(", "might", "be", "a", "pseudo", "page", "itself", ")" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L992-L999
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.getParentPage
public function getParentPage() { $page = $this->getPage(); if ($page && $page->parent) { return $page->parent->getPage(); } return null; }
php
public function getParentPage() { $page = $this->getPage(); if ($page && $page->parent) { return $page->parent->getPage(); } return null; }
[ "public", "function", "getParentPage", "(", ")", "{", "$", "page", "=", "$", "this", "->", "getPage", "(", ")", ";", "if", "(", "$", "page", "&&", "$", "page", "->", "parent", ")", "{", "return", "$", "page", "->", "parent", "->", "getPage", "(", ")", ";", "}", "return", "null", ";", "}" ]
Returns the parent page of this data @return Kwf_Component_Data
[ "Returns", "the", "parent", "page", "of", "this", "data" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L1006-L1013
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.getParentPageOrRoot
public function getParentPageOrRoot() { $page = $this->getPageOrRoot(); if ($page->parent) { return $page->parent->getPageOrRoot(); } return $page; }
php
public function getParentPageOrRoot() { $page = $this->getPageOrRoot(); if ($page->parent) { return $page->parent->getPageOrRoot(); } return $page; }
[ "public", "function", "getParentPageOrRoot", "(", ")", "{", "$", "page", "=", "$", "this", "->", "getPageOrRoot", "(", ")", ";", "if", "(", "$", "page", "->", "parent", ")", "{", "return", "$", "page", "->", "parent", "->", "getPageOrRoot", "(", ")", ";", "}", "return", "$", "page", ";", "}" ]
Returns the parent page OR (if there is no none) the root component @return Kwf_Component_Data
[ "Returns", "the", "parent", "page", "OR", "(", "if", "there", "is", "no", "none", ")", "the", "root", "component" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L1020-L1027
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.getParentPseudoPage
public function getParentPseudoPage() { $page = $this->getPseudoPage(); if ($page && $page->parent) { return $page->parent->getPseudoPage(); } return null; }
php
public function getParentPseudoPage() { $page = $this->getPseudoPage(); if ($page && $page->parent) { return $page->parent->getPseudoPage(); } return null; }
[ "public", "function", "getParentPseudoPage", "(", ")", "{", "$", "page", "=", "$", "this", "->", "getPseudoPage", "(", ")", ";", "if", "(", "$", "page", "&&", "$", "page", "->", "parent", ")", "{", "return", "$", "page", "->", "parent", "->", "getPseudoPage", "(", ")", ";", "}", "return", "null", ";", "}" ]
Returns the parent pseudo page of this data @return Kwf_Component_Data
[ "Returns", "the", "parent", "pseudo", "page", "of", "this", "data" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L1034-L1041
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.getParentPseudoPageOrRoot
public function getParentPseudoPageOrRoot() { $page = $this->getPseudoPage(); if ($page && $page->parent) { return $page->parent->getPseudoPageOrRoot(); } return null; }
php
public function getParentPseudoPageOrRoot() { $page = $this->getPseudoPage(); if ($page && $page->parent) { return $page->parent->getPseudoPageOrRoot(); } return null; }
[ "public", "function", "getParentPseudoPageOrRoot", "(", ")", "{", "$", "page", "=", "$", "this", "->", "getPseudoPage", "(", ")", ";", "if", "(", "$", "page", "&&", "$", "page", "->", "parent", ")", "{", "return", "$", "page", "->", "parent", "->", "getPseudoPageOrRoot", "(", ")", ";", "}", "return", "null", ";", "}" ]
Returns the parent pseudo page OR (if there is no none) the root component @return Kwf_Component_Data
[ "Returns", "the", "parent", "pseudo", "page", "OR", "(", "if", "there", "is", "no", "none", ")", "the", "root", "component" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L1049-L1056
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.getParentByClass
public function getParentByClass($cls) { if (!is_array($cls)) $cls = array($cls); $d = $this; while ($d) { foreach ($cls as $i) { if (is_instance_of($d->componentClass, $i)) { return $d; } } $d = $d->parent; } return $d; }
php
public function getParentByClass($cls) { if (!is_array($cls)) $cls = array($cls); $d = $this; while ($d) { foreach ($cls as $i) { if (is_instance_of($d->componentClass, $i)) { return $d; } } $d = $d->parent; } return $d; }
[ "public", "function", "getParentByClass", "(", "$", "cls", ")", "{", "if", "(", "!", "is_array", "(", "$", "cls", ")", ")", "$", "cls", "=", "array", "(", "$", "cls", ")", ";", "$", "d", "=", "$", "this", ";", "while", "(", "$", "d", ")", "{", "foreach", "(", "$", "cls", "as", "$", "i", ")", "{", "if", "(", "is_instance_of", "(", "$", "d", "->", "componentClass", ",", "$", "i", ")", ")", "{", "return", "$", "d", ";", "}", "}", "$", "d", "=", "$", "d", "->", "parent", ";", "}", "return", "$", "d", ";", "}" ]
Returns the parent matching a given component class @param string|array component class or array of component classes @return Kwf_Component_Data
[ "Returns", "the", "parent", "matching", "a", "given", "component", "class" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L1064-L1077
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.getParentComponent
public function getParentComponent($numParent = 1) { if (isset($this->_lazyParent)) { $id = $this->_lazyParent; for ($i=0;$i<$numParent;$i++) { $pos = max(strrpos($id, '_'), strrpos($id, '-')); if ($pos) { $id = substr($id, 0, $pos); } else { $c = Kwf_Component_Data_Root::getInstance()->getComponentById($id, array('ignoreVisible'=>true)); for ($j=0;$j<$numParent-$i-1;$j++) { $c = $c->parent; } return $c; } } return Kwf_Component_Data_Root::getInstance()->getComponentById($id, array('ignoreVisible'=>true)); } $c = $this; for ($i=0;$i<$numParent;$i++) { $c = $c->parent; } return $c; }
php
public function getParentComponent($numParent = 1) { if (isset($this->_lazyParent)) { $id = $this->_lazyParent; for ($i=0;$i<$numParent;$i++) { $pos = max(strrpos($id, '_'), strrpos($id, '-')); if ($pos) { $id = substr($id, 0, $pos); } else { $c = Kwf_Component_Data_Root::getInstance()->getComponentById($id, array('ignoreVisible'=>true)); for ($j=0;$j<$numParent-$i-1;$j++) { $c = $c->parent; } return $c; } } return Kwf_Component_Data_Root::getInstance()->getComponentById($id, array('ignoreVisible'=>true)); } $c = $this; for ($i=0;$i<$numParent;$i++) { $c = $c->parent; } return $c; }
[ "public", "function", "getParentComponent", "(", "$", "numParent", "=", "1", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_lazyParent", ")", ")", "{", "$", "id", "=", "$", "this", "->", "_lazyParent", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "numParent", ";", "$", "i", "++", ")", "{", "$", "pos", "=", "max", "(", "strrpos", "(", "$", "id", ",", "'_'", ")", ",", "strrpos", "(", "$", "id", ",", "'-'", ")", ")", ";", "if", "(", "$", "pos", ")", "{", "$", "id", "=", "substr", "(", "$", "id", ",", "0", ",", "$", "pos", ")", ";", "}", "else", "{", "$", "c", "=", "Kwf_Component_Data_Root", "::", "getInstance", "(", ")", "->", "getComponentById", "(", "$", "id", ",", "array", "(", "'ignoreVisible'", "=>", "true", ")", ")", ";", "for", "(", "$", "j", "=", "0", ";", "$", "j", "<", "$", "numParent", "-", "$", "i", "-", "1", ";", "$", "j", "++", ")", "{", "$", "c", "=", "$", "c", "->", "parent", ";", "}", "return", "$", "c", ";", "}", "}", "return", "Kwf_Component_Data_Root", "::", "getInstance", "(", ")", "->", "getComponentById", "(", "$", "id", ",", "array", "(", "'ignoreVisible'", "=>", "true", ")", ")", ";", "}", "$", "c", "=", "$", "this", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "numParent", ";", "$", "i", "++", ")", "{", "$", "c", "=", "$", "c", "->", "parent", ";", "}", "return", "$", "c", ";", "}" ]
Returns a parent component from a given depth more efficient than getting ->parent multiple times (only if data was unserialized) @param int levels to go up @return Kwf_Component_Data
[ "Returns", "a", "parent", "component", "from", "a", "given", "depth" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L1087-L1110
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.getInheritsParent
public function getInheritsParent() { $page = $this; while ($page && !$page->inherits) { if ($page instanceof Kwf_Component_Data_Root) return $page; $page = $page->parent; } return $page; }
php
public function getInheritsParent() { $page = $this; while ($page && !$page->inherits) { if ($page instanceof Kwf_Component_Data_Root) return $page; $page = $page->parent; } return $page; }
[ "public", "function", "getInheritsParent", "(", ")", "{", "$", "page", "=", "$", "this", ";", "while", "(", "$", "page", "&&", "!", "$", "page", "->", "inherits", ")", "{", "if", "(", "$", "page", "instanceof", "Kwf_Component_Data_Root", ")", "return", "$", "page", ";", "$", "page", "=", "$", "page", "->", "parent", ";", "}", "return", "$", "page", ";", "}" ]
Returns the page this data belongs to (might be a page itself) OR (if there is no page) the root component @return Kwf_Component_Data
[ "Returns", "the", "page", "this", "data", "belongs", "to", "(", "might", "be", "a", "page", "itself", ")", "OR", "(", "if", "there", "is", "no", "page", ")", "the", "root", "component" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L1150-L1158
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.getTitle
public function getTitle() { $title = array(); $row = $this->getPage(); if (!$row) { return null; } do { if ($row->name != '' && $row->name != 'Home') { $title[] = $row->name; } } while ($row = $row->getParentPage()); return implode(' - ', $title); }
php
public function getTitle() { $title = array(); $row = $this->getPage(); if (!$row) { return null; } do { if ($row->name != '' && $row->name != 'Home') { $title[] = $row->name; } } while ($row = $row->getParentPage()); return implode(' - ', $title); }
[ "public", "function", "getTitle", "(", ")", "{", "$", "title", "=", "array", "(", ")", ";", "$", "row", "=", "$", "this", "->", "getPage", "(", ")", ";", "if", "(", "!", "$", "row", ")", "{", "return", "null", ";", "}", "do", "{", "if", "(", "$", "row", "->", "name", "!=", "''", "&&", "$", "row", "->", "name", "!=", "'Home'", ")", "{", "$", "title", "[", "]", "=", "$", "row", "->", "name", ";", "}", "}", "while", "(", "$", "row", "=", "$", "row", "->", "getParentPage", "(", ")", ")", ";", "return", "implode", "(", "' - '", ",", "$", "title", ")", ";", "}" ]
Returns the title of the page Can be overridden to customize. By default names of parent pages will be used @return string
[ "Returns", "the", "title", "of", "the", "page" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L1169-L1182
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.getChildPageByPath
public function getChildPageByPath($path) { $page = $this; $pathParts = preg_split('#([/:])#', $path, -1, PREG_SPLIT_DELIM_CAPTURE); for($i=0; $i<count($pathParts); $i++) { $pathPart = $pathParts[$i]; $i++; $nextSeparator = isset($pathParts[$i]) ? $pathParts[$i] : '/'; if ($nextSeparator == '/') { $pages = $page->getRecursiveChildComponents(array( 'filename' => $pathPart, 'pseudoPage'=>true, 'limit'=>1), array('pseudoPage'=>false)); } else { // if path is separated by ':', id comes without '-', search for child-component $pages = $page->getRecursiveChildComponents(array( 'id' => '-' . $pathPart, 'pseudoPage'=>false, 'limit'=>1), array('pseudoPage'=>false)); } $page = current($pages); if (!$page) break; } return $page; }
php
public function getChildPageByPath($path) { $page = $this; $pathParts = preg_split('#([/:])#', $path, -1, PREG_SPLIT_DELIM_CAPTURE); for($i=0; $i<count($pathParts); $i++) { $pathPart = $pathParts[$i]; $i++; $nextSeparator = isset($pathParts[$i]) ? $pathParts[$i] : '/'; if ($nextSeparator == '/') { $pages = $page->getRecursiveChildComponents(array( 'filename' => $pathPart, 'pseudoPage'=>true, 'limit'=>1), array('pseudoPage'=>false)); } else { // if path is separated by ':', id comes without '-', search for child-component $pages = $page->getRecursiveChildComponents(array( 'id' => '-' . $pathPart, 'pseudoPage'=>false, 'limit'=>1), array('pseudoPage'=>false)); } $page = current($pages); if (!$page) break; } return $page; }
[ "public", "function", "getChildPageByPath", "(", "$", "path", ")", "{", "$", "page", "=", "$", "this", ";", "$", "pathParts", "=", "preg_split", "(", "'#([/:])#'", ",", "$", "path", ",", "-", "1", ",", "PREG_SPLIT_DELIM_CAPTURE", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "pathParts", ")", ";", "$", "i", "++", ")", "{", "$", "pathPart", "=", "$", "pathParts", "[", "$", "i", "]", ";", "$", "i", "++", ";", "$", "nextSeparator", "=", "isset", "(", "$", "pathParts", "[", "$", "i", "]", ")", "?", "$", "pathParts", "[", "$", "i", "]", ":", "'/'", ";", "if", "(", "$", "nextSeparator", "==", "'/'", ")", "{", "$", "pages", "=", "$", "page", "->", "getRecursiveChildComponents", "(", "array", "(", "'filename'", "=>", "$", "pathPart", ",", "'pseudoPage'", "=>", "true", ",", "'limit'", "=>", "1", ")", ",", "array", "(", "'pseudoPage'", "=>", "false", ")", ")", ";", "}", "else", "{", "// if path is separated by ':', id comes without '-', search for child-component", "$", "pages", "=", "$", "page", "->", "getRecursiveChildComponents", "(", "array", "(", "'id'", "=>", "'-'", ".", "$", "pathPart", ",", "'pseudoPage'", "=>", "false", ",", "'limit'", "=>", "1", ")", ",", "array", "(", "'pseudoPage'", "=>", "false", ")", ")", ";", "}", "$", "page", "=", "current", "(", "$", "pages", ")", ";", "if", "(", "!", "$", "page", ")", "break", ";", "}", "return", "$", "page", ";", "}" ]
Searches for a child page by a given path Should only be used to resolve incoming paths @param string @return Kwf_Component_Data
[ "Searches", "for", "a", "child", "page", "by", "a", "given", "path" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L1216-L1242
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.getLanguage
public function getLanguage() { if (!isset($this->_languageCache)) { //cache ist vorallem für bei kwfUnserialize nützlich $this->_languageCache = $this->getBaseProperty('language'); } return $this->_languageCache; }
php
public function getLanguage() { if (!isset($this->_languageCache)) { //cache ist vorallem für bei kwfUnserialize nützlich $this->_languageCache = $this->getBaseProperty('language'); } return $this->_languageCache; }
[ "public", "function", "getLanguage", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_languageCache", ")", ")", "{", "//cache ist vorallem für bei kwfUnserialize nützlich", "$", "this", "->", "_languageCache", "=", "$", "this", "->", "getBaseProperty", "(", "'language'", ")", ";", "}", "return", "$", "this", "->", "_languageCache", ";", "}" ]
Returns the language used by this data @return string
[ "Returns", "the", "language", "used", "by", "this", "data" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L1249-L1255
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.getBaseProperty
public function getBaseProperty($propertyName) { $ret = null; if (isset($this->_serializedBaseProperties[$propertyName])) { $ret = $this->_serializedBaseProperties[$propertyName]; } $c = $this; while (is_null($ret) && $c) { if (Kwc_Abstract::getFlag($c->componentClass, 'hasBaseProperties')) { $ret = $c->getComponent()->getBaseProperty($propertyName); } $c = $c->parent; } return $ret; }
php
public function getBaseProperty($propertyName) { $ret = null; if (isset($this->_serializedBaseProperties[$propertyName])) { $ret = $this->_serializedBaseProperties[$propertyName]; } $c = $this; while (is_null($ret) && $c) { if (Kwc_Abstract::getFlag($c->componentClass, 'hasBaseProperties')) { $ret = $c->getComponent()->getBaseProperty($propertyName); } $c = $c->parent; } return $ret; }
[ "public", "function", "getBaseProperty", "(", "$", "propertyName", ")", "{", "$", "ret", "=", "null", ";", "if", "(", "isset", "(", "$", "this", "->", "_serializedBaseProperties", "[", "$", "propertyName", "]", ")", ")", "{", "$", "ret", "=", "$", "this", "->", "_serializedBaseProperties", "[", "$", "propertyName", "]", ";", "}", "$", "c", "=", "$", "this", ";", "while", "(", "is_null", "(", "$", "ret", ")", "&&", "$", "c", ")", "{", "if", "(", "Kwc_Abstract", "::", "getFlag", "(", "$", "c", "->", "componentClass", ",", "'hasBaseProperties'", ")", ")", "{", "$", "ret", "=", "$", "c", "->", "getComponent", "(", ")", "->", "getBaseProperty", "(", "$", "propertyName", ")", ";", "}", "$", "c", "=", "$", "c", "->", "parent", ";", "}", "return", "$", "ret", ";", "}" ]
Retrieves a base Property for a component Any component can add a flag called 'hasBaseProperties' and implement getBaseProperties($propertyName) to return a property specific for this component and all child components (e.g. language, domain, id for analytics...) It's also possible to specify the returned property by adding an array "baseProperties" to the settings. This may help some to exclude components to be asked for base Properties which they actually don't return. @param string $propertyName @return string Property
[ "Retrieves", "a", "base", "Property", "for", "a", "component" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L1270-L1284
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.isVisible
public function isVisible() { $c = $this; while($c) { if (isset($c->invisible) && $c->invisible) { return false; } $c = $c->parent; } return true; }
php
public function isVisible() { $c = $this; while($c) { if (isset($c->invisible) && $c->invisible) { return false; } $c = $c->parent; } return true; }
[ "public", "function", "isVisible", "(", ")", "{", "$", "c", "=", "$", "this", ";", "while", "(", "$", "c", ")", "{", "if", "(", "isset", "(", "$", "c", "->", "invisible", ")", "&&", "$", "c", "->", "invisible", ")", "{", "return", "false", ";", "}", "$", "c", "=", "$", "c", "->", "parent", ";", "}", "return", "true", ";", "}" ]
Returns if this component is visible A component is visible if all parents are visible. @return bool
[ "Returns", "if", "this", "component", "is", "visible" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L1309-L1319
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.isShownInMenu
public function isShownInMenu() { if (!$this->isPage) return false; if ($this->generator instanceof Kwc_Root_Category_Generator) { //it's not worth for this single special case to add a generator method, but should be done if other special cases are needed return !$this->row->hide; } else { if (!$this->generator->hasSetting('showInMenu')) return false; return (bool)$this->generator->getSetting('showInMenu'); } }
php
public function isShownInMenu() { if (!$this->isPage) return false; if ($this->generator instanceof Kwc_Root_Category_Generator) { //it's not worth for this single special case to add a generator method, but should be done if other special cases are needed return !$this->row->hide; } else { if (!$this->generator->hasSetting('showInMenu')) return false; return (bool)$this->generator->getSetting('showInMenu'); } }
[ "public", "function", "isShownInMenu", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isPage", ")", "return", "false", ";", "if", "(", "$", "this", "->", "generator", "instanceof", "Kwc_Root_Category_Generator", ")", "{", "//it's not worth for this single special case to add a generator method, but should be done if other special cases are needed", "return", "!", "$", "this", "->", "row", "->", "hide", ";", "}", "else", "{", "if", "(", "!", "$", "this", "->", "generator", "->", "hasSetting", "(", "'showInMenu'", ")", ")", "return", "false", ";", "return", "(", "bool", ")", "$", "this", "->", "generator", "->", "getSetting", "(", "'showInMenu'", ")", ";", "}", "}" ]
Returns if this page should be shown in menus Category_Generators can change that dynamically using the hide column, other generators have a 'showInMenu' setting (defaults to false) @return bool
[ "Returns", "if", "this", "page", "should", "be", "shown", "in", "menus" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L1329-L1339
koala-framework/koala-framework
Kwf/Component/Data.php
Kwf_Component_Data.render
public function render($enableCache = null, $renderMaster = false, &$hasDynamicParts = false) { $output = new Kwf_Component_Renderer(); if ($enableCache !== null) $output->setEnableCache($enableCache); if ($renderMaster) { return $output->renderMaster($this, $hasDynamicParts); } else { return $output->renderComponent($this, $hasDynamicParts); } }
php
public function render($enableCache = null, $renderMaster = false, &$hasDynamicParts = false) { $output = new Kwf_Component_Renderer(); if ($enableCache !== null) $output->setEnableCache($enableCache); if ($renderMaster) { return $output->renderMaster($this, $hasDynamicParts); } else { return $output->renderComponent($this, $hasDynamicParts); } }
[ "public", "function", "render", "(", "$", "enableCache", "=", "null", ",", "$", "renderMaster", "=", "false", ",", "&", "$", "hasDynamicParts", "=", "false", ")", "{", "$", "output", "=", "new", "Kwf_Component_Renderer", "(", ")", ";", "if", "(", "$", "enableCache", "!==", "null", ")", "$", "output", "->", "setEnableCache", "(", "$", "enableCache", ")", ";", "if", "(", "$", "renderMaster", ")", "{", "return", "$", "output", "->", "renderMaster", "(", "$", "this", ",", "$", "hasDynamicParts", ")", ";", "}", "else", "{", "return", "$", "output", "->", "renderComponent", "(", "$", "this", ",", "$", "hasDynamicParts", ")", ";", "}", "}" ]
Render the component Usually only used internally or for debugging @param bool if view cache should be used, if null config setting will be used @param bool if master should be rendered @return string
[ "Render", "the", "component" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Data.php#L1403-L1412
koala-framework/koala-framework
Kwf/Model/Abstract.php
Kwf_Model_Abstract.findAllInstances
public static function findAllInstances() { $ret = array(); $modelProviders = Kwf_Config::getValueArray('modelProviders'); foreach ($modelProviders as $modelProvider) { if ($modelProvider) { $modelProvider = new $modelProvider; $ret = array_merge($modelProvider->findModels(), $ret); } } $ret = array_unique($ret, SORT_REGULAR); return $ret; }
php
public static function findAllInstances() { $ret = array(); $modelProviders = Kwf_Config::getValueArray('modelProviders'); foreach ($modelProviders as $modelProvider) { if ($modelProvider) { $modelProvider = new $modelProvider; $ret = array_merge($modelProvider->findModels(), $ret); } } $ret = array_unique($ret, SORT_REGULAR); return $ret; }
[ "public", "static", "function", "findAllInstances", "(", ")", "{", "$", "ret", "=", "array", "(", ")", ";", "$", "modelProviders", "=", "Kwf_Config", "::", "getValueArray", "(", "'modelProviders'", ")", ";", "foreach", "(", "$", "modelProviders", "as", "$", "modelProvider", ")", "{", "if", "(", "$", "modelProvider", ")", "{", "$", "modelProvider", "=", "new", "$", "modelProvider", ";", "$", "ret", "=", "array_merge", "(", "$", "modelProvider", "->", "findModels", "(", ")", ",", "$", "ret", ")", ";", "}", "}", "$", "ret", "=", "array_unique", "(", "$", "ret", ",", "SORT_REGULAR", ")", ";", "return", "$", "ret", ";", "}" ]
Try to find all used models in the current app
[ "Try", "to", "find", "all", "used", "models", "in", "the", "current", "app" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Model/Abstract.php#L1248-L1260
koala-framework/koala-framework
Kwf/Setup.php
Kwf_Setup.setUp
public static function setUp($configClass = 'Kwf_Config_Web') { error_reporting(E_ALL & ~E_STRICT); define('APP_PATH', getcwd()); Kwf_Setup::$configClass = $configClass; if (PHP_SAPI == 'cli') { //don't use cached setup on cli so clear-cache will always work even if eg. paths change require_once dirname(__FILE__).'/../Kwf/Util/Setup.php'; Kwf_Util_Setup::minimalBootstrap(); $setupCode = Kwf_Util_Setup::generateCode(); Zend_Registry::_unsetInstance(); eval(substr($setupCode, 5)); } else if (!@include(APP_PATH.'/cache/setup'.self::CACHE_SETUP_VERSION.'.php')) { if (!file_exists(APP_PATH.'/cache/setup'.self::CACHE_SETUP_VERSION.'.php')) { require_once dirname(__FILE__).'/../Kwf/Util/Setup.php'; Kwf_Util_Setup::minimalBootstrapAndGenerateFile(); } include(APP_PATH.'/cache/setup'.self::CACHE_SETUP_VERSION.'.php'); } Kwf_Benchmark::checkpoint('setUp'); }
php
public static function setUp($configClass = 'Kwf_Config_Web') { error_reporting(E_ALL & ~E_STRICT); define('APP_PATH', getcwd()); Kwf_Setup::$configClass = $configClass; if (PHP_SAPI == 'cli') { //don't use cached setup on cli so clear-cache will always work even if eg. paths change require_once dirname(__FILE__).'/../Kwf/Util/Setup.php'; Kwf_Util_Setup::minimalBootstrap(); $setupCode = Kwf_Util_Setup::generateCode(); Zend_Registry::_unsetInstance(); eval(substr($setupCode, 5)); } else if (!@include(APP_PATH.'/cache/setup'.self::CACHE_SETUP_VERSION.'.php')) { if (!file_exists(APP_PATH.'/cache/setup'.self::CACHE_SETUP_VERSION.'.php')) { require_once dirname(__FILE__).'/../Kwf/Util/Setup.php'; Kwf_Util_Setup::minimalBootstrapAndGenerateFile(); } include(APP_PATH.'/cache/setup'.self::CACHE_SETUP_VERSION.'.php'); } Kwf_Benchmark::checkpoint('setUp'); }
[ "public", "static", "function", "setUp", "(", "$", "configClass", "=", "'Kwf_Config_Web'", ")", "{", "error_reporting", "(", "E_ALL", "&", "~", "E_STRICT", ")", ";", "define", "(", "'APP_PATH'", ",", "getcwd", "(", ")", ")", ";", "Kwf_Setup", "::", "$", "configClass", "=", "$", "configClass", ";", "if", "(", "PHP_SAPI", "==", "'cli'", ")", "{", "//don't use cached setup on cli so clear-cache will always work even if eg. paths change", "require_once", "dirname", "(", "__FILE__", ")", ".", "'/../Kwf/Util/Setup.php'", ";", "Kwf_Util_Setup", "::", "minimalBootstrap", "(", ")", ";", "$", "setupCode", "=", "Kwf_Util_Setup", "::", "generateCode", "(", ")", ";", "Zend_Registry", "::", "_unsetInstance", "(", ")", ";", "eval", "(", "substr", "(", "$", "setupCode", ",", "5", ")", ")", ";", "}", "else", "if", "(", "!", "@", "include", "(", "APP_PATH", ".", "'/cache/setup'", ".", "self", "::", "CACHE_SETUP_VERSION", ".", "'.php'", ")", ")", "{", "if", "(", "!", "file_exists", "(", "APP_PATH", ".", "'/cache/setup'", ".", "self", "::", "CACHE_SETUP_VERSION", ".", "'.php'", ")", ")", "{", "require_once", "dirname", "(", "__FILE__", ")", ".", "'/../Kwf/Util/Setup.php'", ";", "Kwf_Util_Setup", "::", "minimalBootstrapAndGenerateFile", "(", ")", ";", "}", "include", "(", "APP_PATH", ".", "'/cache/setup'", ".", "self", "::", "CACHE_SETUP_VERSION", ".", "'.php'", ")", ";", "}", "Kwf_Benchmark", "::", "checkpoint", "(", "'setUp'", ")", ";", "}" ]
increase version if incompatible changes to generated file are made
[ "increase", "version", "if", "incompatible", "changes", "to", "generated", "file", "are", "made" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Setup.php#L27-L48
koala-framework/koala-framework
Kwf/Setup.php
Kwf_Setup.hasAuthedUser
public static function hasAuthedUser() { static $benchmarkEnabled; if (!isset($benchmarkEnabled)) $benchmarkEnabled = Kwf_Benchmark::isEnabled(); if ($benchmarkEnabled) $t = microtime(true); if (class_exists('Kwf_User_Model', false)) { if ($benchmarkEnabled) Kwf_Benchmark::subCheckpoint('hasAuthedUser: Kwf_User_Model already loaded, asked model', microtime(true)-$t); $m = Kwf_Registry::get('userModel'); if (!$m) return false; $ret = $m->hasAuthedUser(); } else { if (!Zend_Session::isStarted() && !Zend_Session::sessionExists() && !Kwf_Config::getValue('autologin') ) { if ($benchmarkEnabled) Kwf_Benchmark::subCheckpoint('hasAuthedUser: no session', microtime(true)-$t); return false; } if (!Kwf_Auth::getInstance()->getStorage()->read()) { if ($benchmarkEnabled) Kwf_Benchmark::subCheckpoint('hasAuthedUser: storage empty', microtime(true)-$t); return false; } $m = Kwf_Registry::get('userModel'); if (!$m) return false; $ret = $m->hasAuthedUser(); if ($benchmarkEnabled) Kwf_Benchmark::subCheckpoint('hasAuthedUser: asked model', microtime(true)-$t); } return $ret; }
php
public static function hasAuthedUser() { static $benchmarkEnabled; if (!isset($benchmarkEnabled)) $benchmarkEnabled = Kwf_Benchmark::isEnabled(); if ($benchmarkEnabled) $t = microtime(true); if (class_exists('Kwf_User_Model', false)) { if ($benchmarkEnabled) Kwf_Benchmark::subCheckpoint('hasAuthedUser: Kwf_User_Model already loaded, asked model', microtime(true)-$t); $m = Kwf_Registry::get('userModel'); if (!$m) return false; $ret = $m->hasAuthedUser(); } else { if (!Zend_Session::isStarted() && !Zend_Session::sessionExists() && !Kwf_Config::getValue('autologin') ) { if ($benchmarkEnabled) Kwf_Benchmark::subCheckpoint('hasAuthedUser: no session', microtime(true)-$t); return false; } if (!Kwf_Auth::getInstance()->getStorage()->read()) { if ($benchmarkEnabled) Kwf_Benchmark::subCheckpoint('hasAuthedUser: storage empty', microtime(true)-$t); return false; } $m = Kwf_Registry::get('userModel'); if (!$m) return false; $ret = $m->hasAuthedUser(); if ($benchmarkEnabled) Kwf_Benchmark::subCheckpoint('hasAuthedUser: asked model', microtime(true)-$t); } return $ret; }
[ "public", "static", "function", "hasAuthedUser", "(", ")", "{", "static", "$", "benchmarkEnabled", ";", "if", "(", "!", "isset", "(", "$", "benchmarkEnabled", ")", ")", "$", "benchmarkEnabled", "=", "Kwf_Benchmark", "::", "isEnabled", "(", ")", ";", "if", "(", "$", "benchmarkEnabled", ")", "$", "t", "=", "microtime", "(", "true", ")", ";", "if", "(", "class_exists", "(", "'Kwf_User_Model'", ",", "false", ")", ")", "{", "if", "(", "$", "benchmarkEnabled", ")", "Kwf_Benchmark", "::", "subCheckpoint", "(", "'hasAuthedUser: Kwf_User_Model already loaded, asked model'", ",", "microtime", "(", "true", ")", "-", "$", "t", ")", ";", "$", "m", "=", "Kwf_Registry", "::", "get", "(", "'userModel'", ")", ";", "if", "(", "!", "$", "m", ")", "return", "false", ";", "$", "ret", "=", "$", "m", "->", "hasAuthedUser", "(", ")", ";", "}", "else", "{", "if", "(", "!", "Zend_Session", "::", "isStarted", "(", ")", "&&", "!", "Zend_Session", "::", "sessionExists", "(", ")", "&&", "!", "Kwf_Config", "::", "getValue", "(", "'autologin'", ")", ")", "{", "if", "(", "$", "benchmarkEnabled", ")", "Kwf_Benchmark", "::", "subCheckpoint", "(", "'hasAuthedUser: no session'", ",", "microtime", "(", "true", ")", "-", "$", "t", ")", ";", "return", "false", ";", "}", "if", "(", "!", "Kwf_Auth", "::", "getInstance", "(", ")", "->", "getStorage", "(", ")", "->", "read", "(", ")", ")", "{", "if", "(", "$", "benchmarkEnabled", ")", "Kwf_Benchmark", "::", "subCheckpoint", "(", "'hasAuthedUser: storage empty'", ",", "microtime", "(", "true", ")", "-", "$", "t", ")", ";", "return", "false", ";", "}", "$", "m", "=", "Kwf_Registry", "::", "get", "(", "'userModel'", ")", ";", "if", "(", "!", "$", "m", ")", "return", "false", ";", "$", "ret", "=", "$", "m", "->", "hasAuthedUser", "(", ")", ";", "if", "(", "$", "benchmarkEnabled", ")", "Kwf_Benchmark", "::", "subCheckpoint", "(", "'hasAuthedUser: asked model'", ",", "microtime", "(", "true", ")", "-", "$", "t", ")", ";", "}", "return", "$", "ret", ";", "}" ]
Check if user is logged in (faster than directly calling user model) Only asks user model (expensive) when there is something stored in the session or class already loaded @return boolean if user is logged in
[ "Check", "if", "user", "is", "logged", "in", "(", "faster", "than", "directly", "calling", "user", "model", ")" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Setup.php#L289-L317
koala-framework/koala-framework
Kwf/Setup.php
Kwf_Setup.checkPreLogin
public static function checkPreLogin($requiredUsername, $requiredPassword) { $authUser = !empty($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : false; $authPW = !empty($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : false; $kwfAuthorization = null; if (isset($_SERVER['HTTP_X_KWF_AUTHORIZATION'])) { $kwfAuthorization = $_SERVER['HTTP_X_KWF_AUTHORIZATION']; } else if (isset($_COOKIE['KWF-Authorization'])) { $kwfAuthorization = $_COOKIE['KWF-Authorization']; } if ($kwfAuthorization !== null) { $authValue = explode(' ', $kwfAuthorization); if (count($authValue) === 2 && strtolower($authValue[0]) === 'basic') { $authorization = explode(':', base64_decode($authValue[1])); if (count($authorization) === 2) { $authUser = $authorization[0]; $authPW = $authorization[1]; } } } if (!$authUser || !$authPW || $authUser !== $requiredUsername || $authPW !== $requiredPassword ) { header('WWW-Authenticate: Basic realm="Page locked by preLogin"'); throw new Kwf_Exception_Unauthorized('PreLogin required'); } }
php
public static function checkPreLogin($requiredUsername, $requiredPassword) { $authUser = !empty($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : false; $authPW = !empty($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : false; $kwfAuthorization = null; if (isset($_SERVER['HTTP_X_KWF_AUTHORIZATION'])) { $kwfAuthorization = $_SERVER['HTTP_X_KWF_AUTHORIZATION']; } else if (isset($_COOKIE['KWF-Authorization'])) { $kwfAuthorization = $_COOKIE['KWF-Authorization']; } if ($kwfAuthorization !== null) { $authValue = explode(' ', $kwfAuthorization); if (count($authValue) === 2 && strtolower($authValue[0]) === 'basic') { $authorization = explode(':', base64_decode($authValue[1])); if (count($authorization) === 2) { $authUser = $authorization[0]; $authPW = $authorization[1]; } } } if (!$authUser || !$authPW || $authUser !== $requiredUsername || $authPW !== $requiredPassword ) { header('WWW-Authenticate: Basic realm="Page locked by preLogin"'); throw new Kwf_Exception_Unauthorized('PreLogin required'); } }
[ "public", "static", "function", "checkPreLogin", "(", "$", "requiredUsername", ",", "$", "requiredPassword", ")", "{", "$", "authUser", "=", "!", "empty", "(", "$", "_SERVER", "[", "'PHP_AUTH_USER'", "]", ")", "?", "$", "_SERVER", "[", "'PHP_AUTH_USER'", "]", ":", "false", ";", "$", "authPW", "=", "!", "empty", "(", "$", "_SERVER", "[", "'PHP_AUTH_PW'", "]", ")", "?", "$", "_SERVER", "[", "'PHP_AUTH_PW'", "]", ":", "false", ";", "$", "kwfAuthorization", "=", "null", ";", "if", "(", "isset", "(", "$", "_SERVER", "[", "'HTTP_X_KWF_AUTHORIZATION'", "]", ")", ")", "{", "$", "kwfAuthorization", "=", "$", "_SERVER", "[", "'HTTP_X_KWF_AUTHORIZATION'", "]", ";", "}", "else", "if", "(", "isset", "(", "$", "_COOKIE", "[", "'KWF-Authorization'", "]", ")", ")", "{", "$", "kwfAuthorization", "=", "$", "_COOKIE", "[", "'KWF-Authorization'", "]", ";", "}", "if", "(", "$", "kwfAuthorization", "!==", "null", ")", "{", "$", "authValue", "=", "explode", "(", "' '", ",", "$", "kwfAuthorization", ")", ";", "if", "(", "count", "(", "$", "authValue", ")", "===", "2", "&&", "strtolower", "(", "$", "authValue", "[", "0", "]", ")", "===", "'basic'", ")", "{", "$", "authorization", "=", "explode", "(", "':'", ",", "base64_decode", "(", "$", "authValue", "[", "1", "]", ")", ")", ";", "if", "(", "count", "(", "$", "authorization", ")", "===", "2", ")", "{", "$", "authUser", "=", "$", "authorization", "[", "0", "]", ";", "$", "authPW", "=", "$", "authorization", "[", "1", "]", ";", "}", "}", "}", "if", "(", "!", "$", "authUser", "||", "!", "$", "authPW", "||", "$", "authUser", "!==", "$", "requiredUsername", "||", "$", "authPW", "!==", "$", "requiredPassword", ")", "{", "header", "(", "'WWW-Authenticate: Basic realm=\"Page locked by preLogin\"'", ")", ";", "throw", "new", "Kwf_Exception_Unauthorized", "(", "'PreLogin required'", ")", ";", "}", "}" ]
Is used in generated setup.php (cache/setupX.php) and in ContentSender_Default.php @throws Kwf_Exception_Unauthorized
[ "Is", "used", "in", "generated", "setup", ".", "php", "(", "cache", "/", "setupX", ".", "php", ")", "and", "in", "ContentSender_Default", ".", "php" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Setup.php#L323-L353
koala-framework/koala-framework
Kwc/Abstract/Events.php
Kwc_Abstract_Events.onOwnRowUpdate
public final function onOwnRowUpdate(Kwf_Events_Event_Row_Abstract $event) { $cmps = Kwf_Component_Data_Root::getInstance()->getComponentsByDbId( $event->row->component_id, array('ignoreVisible'=>true) ); foreach ($cmps as $c) { if ($c->componentClass == $this->_class) { if ($c->isVisible()) { $this->fireEvent(new Kwf_Component_Event_Component_ContentChanged( $this->_class, $c )); if (Kwc_Abstract::hasSetting($this->_class, 'throwHasContentChangedOnRowColumnsUpdate')) { if ($event->isDirty(Kwc_Abstract::getSetting($this->_class, 'throwHasContentChangedOnRowColumnsUpdate'))) { $this->fireEvent(new Kwf_Component_Event_Component_HasContentChanged( $this->_class, $c )); } } $this->_onOwnRowUpdate($c, $event); $this->_onOwnRowUpdateNotVisible($c, $event); } else { $this->_onOwnRowUpdateNotVisible($c, $event); } } } }
php
public final function onOwnRowUpdate(Kwf_Events_Event_Row_Abstract $event) { $cmps = Kwf_Component_Data_Root::getInstance()->getComponentsByDbId( $event->row->component_id, array('ignoreVisible'=>true) ); foreach ($cmps as $c) { if ($c->componentClass == $this->_class) { if ($c->isVisible()) { $this->fireEvent(new Kwf_Component_Event_Component_ContentChanged( $this->_class, $c )); if (Kwc_Abstract::hasSetting($this->_class, 'throwHasContentChangedOnRowColumnsUpdate')) { if ($event->isDirty(Kwc_Abstract::getSetting($this->_class, 'throwHasContentChangedOnRowColumnsUpdate'))) { $this->fireEvent(new Kwf_Component_Event_Component_HasContentChanged( $this->_class, $c )); } } $this->_onOwnRowUpdate($c, $event); $this->_onOwnRowUpdateNotVisible($c, $event); } else { $this->_onOwnRowUpdateNotVisible($c, $event); } } } }
[ "public", "final", "function", "onOwnRowUpdate", "(", "Kwf_Events_Event_Row_Abstract", "$", "event", ")", "{", "$", "cmps", "=", "Kwf_Component_Data_Root", "::", "getInstance", "(", ")", "->", "getComponentsByDbId", "(", "$", "event", "->", "row", "->", "component_id", ",", "array", "(", "'ignoreVisible'", "=>", "true", ")", ")", ";", "foreach", "(", "$", "cmps", "as", "$", "c", ")", "{", "if", "(", "$", "c", "->", "componentClass", "==", "$", "this", "->", "_class", ")", "{", "if", "(", "$", "c", "->", "isVisible", "(", ")", ")", "{", "$", "this", "->", "fireEvent", "(", "new", "Kwf_Component_Event_Component_ContentChanged", "(", "$", "this", "->", "_class", ",", "$", "c", ")", ")", ";", "if", "(", "Kwc_Abstract", "::", "hasSetting", "(", "$", "this", "->", "_class", ",", "'throwHasContentChangedOnRowColumnsUpdate'", ")", ")", "{", "if", "(", "$", "event", "->", "isDirty", "(", "Kwc_Abstract", "::", "getSetting", "(", "$", "this", "->", "_class", ",", "'throwHasContentChangedOnRowColumnsUpdate'", ")", ")", ")", "{", "$", "this", "->", "fireEvent", "(", "new", "Kwf_Component_Event_Component_HasContentChanged", "(", "$", "this", "->", "_class", ",", "$", "c", ")", ")", ";", "}", "}", "$", "this", "->", "_onOwnRowUpdate", "(", "$", "c", ",", "$", "event", ")", ";", "$", "this", "->", "_onOwnRowUpdateNotVisible", "(", "$", "c", ",", "$", "event", ")", ";", "}", "else", "{", "$", "this", "->", "_onOwnRowUpdateNotVisible", "(", "$", "c", ",", "$", "event", ")", ";", "}", "}", "}", "}" ]
override _onOwnRowUpdate to implement custom functionality
[ "override", "_onOwnRowUpdate", "to", "implement", "custom", "functionality" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Abstract/Events.php#L35-L60
koala-framework/koala-framework
Kwc/Menu/Abstract/Events.php
Kwc_Menu_Abstract_Events._onMenuChanged
protected function _onMenuChanged(Kwf_Events_Event_Abstract $event, Kwf_Component_Data $menu) { $this->fireEvent(new Kwf_Component_Event_Component_ContentChanged( $this->_class, $menu )); }
php
protected function _onMenuChanged(Kwf_Events_Event_Abstract $event, Kwf_Component_Data $menu) { $this->fireEvent(new Kwf_Component_Event_Component_ContentChanged( $this->_class, $menu )); }
[ "protected", "function", "_onMenuChanged", "(", "Kwf_Events_Event_Abstract", "$", "event", ",", "Kwf_Component_Data", "$", "menu", ")", "{", "$", "this", "->", "fireEvent", "(", "new", "Kwf_Component_Event_Component_ContentChanged", "(", "$", "this", "->", "_class", ",", "$", "menu", ")", ")", ";", "}" ]
overridden in Kwc_Menu_Events to fire HasContentChanged
[ "overridden", "in", "Kwc_Menu_Events", "to", "fire", "HasContentChanged" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Menu/Abstract/Events.php#L63-L68
koala-framework/koala-framework
Kwc/Shop/Cart/Checkout/Payment/PayPal/ConfirmLink/Component.php
Kwc_Shop_Cart_Checkout_Payment_PayPal_ConfirmLink_Component.buildPayPalButtonHtml
public static function buildPayPalButtonHtml($params, $payment, $order) { $paypalId = $payment->getBaseProperty('paypalId'); $alternative = $order->alternative_shipping_address; $params = array( 'charset' => 'utf-8', 'cmd' => '_xclick', 'business' => $paypalId, // 'lc' => 'AT', 'item_name' => $payment->getComponent()->getItemName($order), //'cbt' => trlKwf('back to ...'), //eigener zurück zu Text könnte so gesetzt werden 'amount' => $params['amount'], 'currency_code' => $params['currency_code'], 'button_subtype' => 'products', 'no_note' => '1', 'no_shipping' => $params['no_shipping'], 'rm' => '1', 'return' => $payment->getChildComponent('_confirm')->getAbsoluteUrl() . '?custom=' . urlencode($params['custom']), 'cancel_return' => $payment->getChildComponent('_cancel')->getAbsoluteUrl(), 'notify_url' => $payment->getChildComponent('_ipn')->getAbsoluteUrl(), 'bn' => 'PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted', 'custom' => $params['custom'] ); if ($params['no_shipping'] === 0 || $params['no_shipping'] === 2) { $params = array_merge($params, array( 'cmd' => '_ext-enter', 'redirect_cmd' => '_xclick', 'address_override' => '1', 'email' => $order->email, 'first_name' => ($alternative) ? $order->shipping_firstname : $order->firstname, 'last_name' => ($alternative) ? $order->shipping_lastname : $order->lastname, 'address1' => ($alternative) ? $order->shipping_street : $order->street, 'address2' => ($alternative) ? $order->shipping_addition : $order->addition, 'city' => ($alternative) ? $order->shipping_city : $order->city, 'country' => ($alternative) ? $order->shipping_country : $order->country, 'zip' => ($alternative) ? $order->shipping_zip : $order->zip )); } $paypalDomain = Kwf_Registry::get('config')->paypalDomain; $ret = "<form id=\"paypalButton\" action=\"https://$paypalDomain/cgi-bin/webscr\" method=\"post\">\n"; foreach ($params as $k=>$i) { $ret .= "<input type=\"hidden\" name=\"$k\" value=\"".Kwf_Util_HtmlSpecialChars::filter($i)."\">\n"; } $ret .= "<input type=\"image\" src=\"https://www.paypal.com/de_DE/AT/i/btn/btn_buynowCC_LG.gif\" border=\"0\" name=\"submit\" alt=\"PayPal - The safer, easier way to pay online!\">\n"; $ret .= "<img alt=\"\" border=\"0\" src=\"https://www.paypal.com/de_DE/i/scr/pixel.gif\" width=\"1\" height=\"1\">\n"; $ret .= "</form>\n"; return $ret; }
php
public static function buildPayPalButtonHtml($params, $payment, $order) { $paypalId = $payment->getBaseProperty('paypalId'); $alternative = $order->alternative_shipping_address; $params = array( 'charset' => 'utf-8', 'cmd' => '_xclick', 'business' => $paypalId, // 'lc' => 'AT', 'item_name' => $payment->getComponent()->getItemName($order), //'cbt' => trlKwf('back to ...'), //eigener zurück zu Text könnte so gesetzt werden 'amount' => $params['amount'], 'currency_code' => $params['currency_code'], 'button_subtype' => 'products', 'no_note' => '1', 'no_shipping' => $params['no_shipping'], 'rm' => '1', 'return' => $payment->getChildComponent('_confirm')->getAbsoluteUrl() . '?custom=' . urlencode($params['custom']), 'cancel_return' => $payment->getChildComponent('_cancel')->getAbsoluteUrl(), 'notify_url' => $payment->getChildComponent('_ipn')->getAbsoluteUrl(), 'bn' => 'PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted', 'custom' => $params['custom'] ); if ($params['no_shipping'] === 0 || $params['no_shipping'] === 2) { $params = array_merge($params, array( 'cmd' => '_ext-enter', 'redirect_cmd' => '_xclick', 'address_override' => '1', 'email' => $order->email, 'first_name' => ($alternative) ? $order->shipping_firstname : $order->firstname, 'last_name' => ($alternative) ? $order->shipping_lastname : $order->lastname, 'address1' => ($alternative) ? $order->shipping_street : $order->street, 'address2' => ($alternative) ? $order->shipping_addition : $order->addition, 'city' => ($alternative) ? $order->shipping_city : $order->city, 'country' => ($alternative) ? $order->shipping_country : $order->country, 'zip' => ($alternative) ? $order->shipping_zip : $order->zip )); } $paypalDomain = Kwf_Registry::get('config')->paypalDomain; $ret = "<form id=\"paypalButton\" action=\"https://$paypalDomain/cgi-bin/webscr\" method=\"post\">\n"; foreach ($params as $k=>$i) { $ret .= "<input type=\"hidden\" name=\"$k\" value=\"".Kwf_Util_HtmlSpecialChars::filter($i)."\">\n"; } $ret .= "<input type=\"image\" src=\"https://www.paypal.com/de_DE/AT/i/btn/btn_buynowCC_LG.gif\" border=\"0\" name=\"submit\" alt=\"PayPal - The safer, easier way to pay online!\">\n"; $ret .= "<img alt=\"\" border=\"0\" src=\"https://www.paypal.com/de_DE/i/scr/pixel.gif\" width=\"1\" height=\"1\">\n"; $ret .= "</form>\n"; return $ret; }
[ "public", "static", "function", "buildPayPalButtonHtml", "(", "$", "params", ",", "$", "payment", ",", "$", "order", ")", "{", "$", "paypalId", "=", "$", "payment", "->", "getBaseProperty", "(", "'paypalId'", ")", ";", "$", "alternative", "=", "$", "order", "->", "alternative_shipping_address", ";", "$", "params", "=", "array", "(", "'charset'", "=>", "'utf-8'", ",", "'cmd'", "=>", "'_xclick'", ",", "'business'", "=>", "$", "paypalId", ",", "// 'lc' => 'AT',", "'item_name'", "=>", "$", "payment", "->", "getComponent", "(", ")", "->", "getItemName", "(", "$", "order", ")", ",", "//'cbt' => trlKwf('back to ...'), //eigener zurück zu Text könnte so gesetzt werden", "'amount'", "=>", "$", "params", "[", "'amount'", "]", ",", "'currency_code'", "=>", "$", "params", "[", "'currency_code'", "]", ",", "'button_subtype'", "=>", "'products'", ",", "'no_note'", "=>", "'1'", ",", "'no_shipping'", "=>", "$", "params", "[", "'no_shipping'", "]", ",", "'rm'", "=>", "'1'", ",", "'return'", "=>", "$", "payment", "->", "getChildComponent", "(", "'_confirm'", ")", "->", "getAbsoluteUrl", "(", ")", ".", "'?custom='", ".", "urlencode", "(", "$", "params", "[", "'custom'", "]", ")", ",", "'cancel_return'", "=>", "$", "payment", "->", "getChildComponent", "(", "'_cancel'", ")", "->", "getAbsoluteUrl", "(", ")", ",", "'notify_url'", "=>", "$", "payment", "->", "getChildComponent", "(", "'_ipn'", ")", "->", "getAbsoluteUrl", "(", ")", ",", "'bn'", "=>", "'PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted'", ",", "'custom'", "=>", "$", "params", "[", "'custom'", "]", ")", ";", "if", "(", "$", "params", "[", "'no_shipping'", "]", "===", "0", "||", "$", "params", "[", "'no_shipping'", "]", "===", "2", ")", "{", "$", "params", "=", "array_merge", "(", "$", "params", ",", "array", "(", "'cmd'", "=>", "'_ext-enter'", ",", "'redirect_cmd'", "=>", "'_xclick'", ",", "'address_override'", "=>", "'1'", ",", "'email'", "=>", "$", "order", "->", "email", ",", "'first_name'", "=>", "(", "$", "alternative", ")", "?", "$", "order", "->", "shipping_firstname", ":", "$", "order", "->", "firstname", ",", "'last_name'", "=>", "(", "$", "alternative", ")", "?", "$", "order", "->", "shipping_lastname", ":", "$", "order", "->", "lastname", ",", "'address1'", "=>", "(", "$", "alternative", ")", "?", "$", "order", "->", "shipping_street", ":", "$", "order", "->", "street", ",", "'address2'", "=>", "(", "$", "alternative", ")", "?", "$", "order", "->", "shipping_addition", ":", "$", "order", "->", "addition", ",", "'city'", "=>", "(", "$", "alternative", ")", "?", "$", "order", "->", "shipping_city", ":", "$", "order", "->", "city", ",", "'country'", "=>", "(", "$", "alternative", ")", "?", "$", "order", "->", "shipping_country", ":", "$", "order", "->", "country", ",", "'zip'", "=>", "(", "$", "alternative", ")", "?", "$", "order", "->", "shipping_zip", ":", "$", "order", "->", "zip", ")", ")", ";", "}", "$", "paypalDomain", "=", "Kwf_Registry", "::", "get", "(", "'config'", ")", "->", "paypalDomain", ";", "$", "ret", "=", "\"<form id=\\\"paypalButton\\\" action=\\\"https://$paypalDomain/cgi-bin/webscr\\\" method=\\\"post\\\">\\n\"", ";", "foreach", "(", "$", "params", "as", "$", "k", "=>", "$", "i", ")", "{", "$", "ret", ".=", "\"<input type=\\\"hidden\\\" name=\\\"$k\\\" value=\\\"\"", ".", "Kwf_Util_HtmlSpecialChars", "::", "filter", "(", "$", "i", ")", ".", "\"\\\">\\n\"", ";", "}", "$", "ret", ".=", "\"<input type=\\\"image\\\" src=\\\"https://www.paypal.com/de_DE/AT/i/btn/btn_buynowCC_LG.gif\\\" border=\\\"0\\\" name=\\\"submit\\\" alt=\\\"PayPal - The safer, easier way to pay online!\\\">\\n\"", ";", "$", "ret", ".=", "\"<img alt=\\\"\\\" border=\\\"0\\\" src=\\\"https://www.paypal.com/de_DE/i/scr/pixel.gif\\\" width=\\\"1\\\" height=\\\"1\\\">\\n\"", ";", "$", "ret", ".=", "\"</form>\\n\"", ";", "return", "$", "ret", ";", "}" ]
used in trl
[ "used", "in", "trl" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Shop/Cart/Checkout/Payment/PayPal/ConfirmLink/Component.php#L27-L77
koala-framework/koala-framework
Kwc/Form/Field/Abstract/Trl/Component.php
Kwc_Form_Field_Abstract_Trl_Component.getSubmitMessage
public function getSubmitMessage($row) { $message = ''; if ($this->getFormField()->getFieldLabel()) { $message .= $this->getFormField()->getFieldLabel().': '; } $message .= $row->{$this->getFormField()->getName()}; return $message; }
php
public function getSubmitMessage($row) { $message = ''; if ($this->getFormField()->getFieldLabel()) { $message .= $this->getFormField()->getFieldLabel().': '; } $message .= $row->{$this->getFormField()->getName()}; return $message; }
[ "public", "function", "getSubmitMessage", "(", "$", "row", ")", "{", "$", "message", "=", "''", ";", "if", "(", "$", "this", "->", "getFormField", "(", ")", "->", "getFieldLabel", "(", ")", ")", "{", "$", "message", ".=", "$", "this", "->", "getFormField", "(", ")", "->", "getFieldLabel", "(", ")", ".", "': '", ";", "}", "$", "message", ".=", "$", "row", "->", "{", "$", "this", "->", "getFormField", "(", ")", "->", "getName", "(", ")", "}", ";", "return", "$", "message", ";", "}" ]
This function is used to return a human-readable string for this field depending on submited data. @param Kwc_Form_Dynamic_Form_MailRow $row @return string
[ "This", "function", "is", "used", "to", "return", "a", "human", "-", "readable", "string", "for", "this", "field", "depending", "on", "submited", "data", "." ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Form/Field/Abstract/Trl/Component.php#L73-L82
koala-framework/koala-framework
Kwc/Menu/ParentMenu/Component.php
Kwc_Menu_ParentMenu_Component._getCurrentPages
protected function _getCurrentPages() { $ret = array(); $p = $this->getData()->getPage(); while ($p) { $ret[] = $p; $p = $p->getParentPage(); } return $ret; }
php
protected function _getCurrentPages() { $ret = array(); $p = $this->getData()->getPage(); while ($p) { $ret[] = $p; $p = $p->getParentPage(); } return $ret; }
[ "protected", "function", "_getCurrentPages", "(", ")", "{", "$", "ret", "=", "array", "(", ")", ";", "$", "p", "=", "$", "this", "->", "getData", "(", ")", "->", "getPage", "(", ")", ";", "while", "(", "$", "p", ")", "{", "$", "ret", "[", "]", "=", "$", "p", ";", "$", "p", "=", "$", "p", "->", "getParentPage", "(", ")", ";", "}", "return", "$", "ret", ";", "}" ]
Array mit aktueller Seiten und Parent Pages
[ "Array", "mit", "aktueller", "Seiten", "und", "Parent", "Pages" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Menu/ParentMenu/Component.php#L52-L61
koala-framework/koala-framework
Kwc/Menu/ParentMenu/Component.php
Kwc_Menu_ParentMenu_Component._processMenuSetCurrent
protected function _processMenuSetCurrent(&$ret) { $currentPages = array_reverse($this->_getCurrentPages()); $currentPageIds = array(); foreach ($currentPages as $page) { if (!$page instanceof Kwf_Component_Data_Root) { $currentPageIds[] = $page->componentId; $selected = $page->componentId; //the last one is selected } } foreach ($ret as $k=>$i) { if (in_array($i['data']->componentId, $currentPageIds)) { $ret[$k]['current'] = true; $ret[$k]['class'] .= ' '.self::getBemClass($this->_getSetting('menuComponentClass'), 'item--current', 'current'); if ($selected == $i['data']->componentId) { $ret[$k]['selected'] = true; $ret[$k]['class'] .= ' '.self::getBemClass($this->_getSetting('menuComponentClass'), 'item--selected', 'selected'); } } } }
php
protected function _processMenuSetCurrent(&$ret) { $currentPages = array_reverse($this->_getCurrentPages()); $currentPageIds = array(); foreach ($currentPages as $page) { if (!$page instanceof Kwf_Component_Data_Root) { $currentPageIds[] = $page->componentId; $selected = $page->componentId; //the last one is selected } } foreach ($ret as $k=>$i) { if (in_array($i['data']->componentId, $currentPageIds)) { $ret[$k]['current'] = true; $ret[$k]['class'] .= ' '.self::getBemClass($this->_getSetting('menuComponentClass'), 'item--current', 'current'); if ($selected == $i['data']->componentId) { $ret[$k]['selected'] = true; $ret[$k]['class'] .= ' '.self::getBemClass($this->_getSetting('menuComponentClass'), 'item--selected', 'selected'); } } } }
[ "protected", "function", "_processMenuSetCurrent", "(", "&", "$", "ret", ")", "{", "$", "currentPages", "=", "array_reverse", "(", "$", "this", "->", "_getCurrentPages", "(", ")", ")", ";", "$", "currentPageIds", "=", "array", "(", ")", ";", "foreach", "(", "$", "currentPages", "as", "$", "page", ")", "{", "if", "(", "!", "$", "page", "instanceof", "Kwf_Component_Data_Root", ")", "{", "$", "currentPageIds", "[", "]", "=", "$", "page", "->", "componentId", ";", "$", "selected", "=", "$", "page", "->", "componentId", ";", "//the last one is selected", "}", "}", "foreach", "(", "$", "ret", "as", "$", "k", "=>", "$", "i", ")", "{", "if", "(", "in_array", "(", "$", "i", "[", "'data'", "]", "->", "componentId", ",", "$", "currentPageIds", ")", ")", "{", "$", "ret", "[", "$", "k", "]", "[", "'current'", "]", "=", "true", ";", "$", "ret", "[", "$", "k", "]", "[", "'class'", "]", ".=", "' '", ".", "self", "::", "getBemClass", "(", "$", "this", "->", "_getSetting", "(", "'menuComponentClass'", ")", ",", "'item--current'", ",", "'current'", ")", ";", "if", "(", "$", "selected", "==", "$", "i", "[", "'data'", "]", "->", "componentId", ")", "{", "$", "ret", "[", "$", "k", "]", "[", "'selected'", "]", "=", "true", ";", "$", "ret", "[", "$", "k", "]", "[", "'class'", "]", ".=", "' '", ".", "self", "::", "getBemClass", "(", "$", "this", "->", "_getSetting", "(", "'menuComponentClass'", ")", ",", "'item--selected'", ",", "'selected'", ")", ";", "}", "}", "}", "}" ]
helper that sets current to current page
[ "helper", "that", "sets", "current", "to", "current", "page" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Menu/ParentMenu/Component.php#L64-L85
koala-framework/koala-framework
Kwc/Box/Title/Component.php
Kwc_Box_Title_Component.injectTitle
public static function injectTitle($html, $title) { $startPos = strpos($html, '<title>'); $endPos = strpos($html, '</title>')+8; $html = substr($html, 0, $startPos) .$title .substr($html, $endPos); return $html; }
php
public static function injectTitle($html, $title) { $startPos = strpos($html, '<title>'); $endPos = strpos($html, '</title>')+8; $html = substr($html, 0, $startPos) .$title .substr($html, $endPos); return $html; }
[ "public", "static", "function", "injectTitle", "(", "$", "html", ",", "$", "title", ")", "{", "$", "startPos", "=", "strpos", "(", "$", "html", ",", "'<title>'", ")", ";", "$", "endPos", "=", "strpos", "(", "$", "html", ",", "'</title>'", ")", "+", "8", ";", "$", "html", "=", "substr", "(", "$", "html", ",", "0", ",", "$", "startPos", ")", ".", "$", "title", ".", "substr", "(", "$", "html", ",", "$", "endPos", ")", ";", "return", "$", "html", ";", "}" ]
public for trl
[ "public", "for", "trl" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwc/Box/Title/Component.php#L44-L52
koala-framework/koala-framework
Kwf/Assets/Package/LazyLoad.php
Kwf_Assets_Package_LazyLoad.getInstance
public static function getInstance($dependencyName, array $loadedDependencies) { $k = $dependencyName . '_' . implode('_', $loadedDependencies); if (!isset(self::$_instances[$k])) { self::$_instances[$k] = new self(Kwf_Assets_Package_Default::getDefaultProviderList(), $dependencyName, $loadedDependencies); } return self::$_instances[$k]; }
php
public static function getInstance($dependencyName, array $loadedDependencies) { $k = $dependencyName . '_' . implode('_', $loadedDependencies); if (!isset(self::$_instances[$k])) { self::$_instances[$k] = new self(Kwf_Assets_Package_Default::getDefaultProviderList(), $dependencyName, $loadedDependencies); } return self::$_instances[$k]; }
[ "public", "static", "function", "getInstance", "(", "$", "dependencyName", ",", "array", "$", "loadedDependencies", ")", "{", "$", "k", "=", "$", "dependencyName", ".", "'_'", ".", "implode", "(", "'_'", ",", "$", "loadedDependencies", ")", ";", "if", "(", "!", "isset", "(", "self", "::", "$", "_instances", "[", "$", "k", "]", ")", ")", "{", "self", "::", "$", "_instances", "[", "$", "k", "]", "=", "new", "self", "(", "Kwf_Assets_Package_Default", "::", "getDefaultProviderList", "(", ")", ",", "$", "dependencyName", ",", "$", "loadedDependencies", ")", ";", "}", "return", "self", "::", "$", "_instances", "[", "$", "k", "]", ";", "}" ]
Returns a Default Asset Package (using Kwf_Assets_ProviderList_Default) Very fast, as all expensive operations are done lazily
[ "Returns", "a", "Default", "Asset", "Package", "(", "using", "Kwf_Assets_ProviderList_Default", ")" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Assets/Package/LazyLoad.php#L12-L19
koala-framework/koala-framework
Kwf/Model/RowCache.php
Kwf_Model_RowCache.clearRowsCache
public function clearRowsCache($select) { $cacheIds = array(); foreach ($this->getIds($select) as $id) { $cacheIds[] = $this->_getCacheId($id); } Kwf_Cache_Simple::delete($cacheIds); }
php
public function clearRowsCache($select) { $cacheIds = array(); foreach ($this->getIds($select) as $id) { $cacheIds[] = $this->_getCacheId($id); } Kwf_Cache_Simple::delete($cacheIds); }
[ "public", "function", "clearRowsCache", "(", "$", "select", ")", "{", "$", "cacheIds", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getIds", "(", "$", "select", ")", "as", "$", "id", ")", "{", "$", "cacheIds", "[", "]", "=", "$", "this", "->", "_getCacheId", "(", "$", "id", ")", ";", "}", "Kwf_Cache_Simple", "::", "delete", "(", "$", "cacheIds", ")", ";", "}" ]
called by Events when saving
[ "called", "by", "Events", "when", "saving" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Model/RowCache.php#L34-L41
koala-framework/koala-framework
Kwf/Model/Union/Row.php
Kwf_Model_Union_Row._setDirty
protected function _setDirty($name) { $mapping = $this->_model->getUnionColumnMapping(); $columns = get_class_vars($mapping); $columns = $columns['columns']; if (in_array($name, $columns)) { $name = $this->_sourceRow->getModel()->getColumnMapping($mapping, $name); $this->_sourceRow->_setDirty($name); } }
php
protected function _setDirty($name) { $mapping = $this->_model->getUnionColumnMapping(); $columns = get_class_vars($mapping); $columns = $columns['columns']; if (in_array($name, $columns)) { $name = $this->_sourceRow->getModel()->getColumnMapping($mapping, $name); $this->_sourceRow->_setDirty($name); } }
[ "protected", "function", "_setDirty", "(", "$", "name", ")", "{", "$", "mapping", "=", "$", "this", "->", "_model", "->", "getUnionColumnMapping", "(", ")", ";", "$", "columns", "=", "get_class_vars", "(", "$", "mapping", ")", ";", "$", "columns", "=", "$", "columns", "[", "'columns'", "]", ";", "if", "(", "in_array", "(", "$", "name", ",", "$", "columns", ")", ")", "{", "$", "name", "=", "$", "this", "->", "_sourceRow", "->", "getModel", "(", ")", "->", "getColumnMapping", "(", "$", "mapping", ",", "$", "name", ")", ";", "$", "this", "->", "_sourceRow", "->", "_setDirty", "(", "$", "name", ")", ";", "}", "}" ]
für forceSave
[ "für", "forceSave" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Model/Union/Row.php#L81-L90
koala-framework/koala-framework
Kwf/Component/Abstract/Admin.php
Kwf_Component_Abstract_Admin.getControllerUrl
public function getControllerUrl($class = 'Index') { $urlOptions = array( 'class' => $this->_class, 'componentController' => $class, 'action' => '' ); $router = Kwf_Controller_Front::getInstance()->getWebRouter(); if (Zend_Registry::isRegistered('testRootComponentClass')) { $urlOptions['root'] = Zend_Registry::get('testRootComponentClass'); $name = 'kwf_test_componentedit'; } else { $name = 'componentedit'; } return $router->assemble($urlOptions, $name, true); }
php
public function getControllerUrl($class = 'Index') { $urlOptions = array( 'class' => $this->_class, 'componentController' => $class, 'action' => '' ); $router = Kwf_Controller_Front::getInstance()->getWebRouter(); if (Zend_Registry::isRegistered('testRootComponentClass')) { $urlOptions['root'] = Zend_Registry::get('testRootComponentClass'); $name = 'kwf_test_componentedit'; } else { $name = 'componentedit'; } return $router->assemble($urlOptions, $name, true); }
[ "public", "function", "getControllerUrl", "(", "$", "class", "=", "'Index'", ")", "{", "$", "urlOptions", "=", "array", "(", "'class'", "=>", "$", "this", "->", "_class", ",", "'componentController'", "=>", "$", "class", ",", "'action'", "=>", "''", ")", ";", "$", "router", "=", "Kwf_Controller_Front", "::", "getInstance", "(", ")", "->", "getWebRouter", "(", ")", ";", "if", "(", "Zend_Registry", "::", "isRegistered", "(", "'testRootComponentClass'", ")", ")", "{", "$", "urlOptions", "[", "'root'", "]", "=", "Zend_Registry", "::", "get", "(", "'testRootComponentClass'", ")", ";", "$", "name", "=", "'kwf_test_componentedit'", ";", "}", "else", "{", "$", "name", "=", "'componentedit'", ";", "}", "return", "$", "router", "->", "assemble", "(", "$", "urlOptions", ",", "$", "name", ",", "true", ")", ";", "}" ]
TODO: in ExtConfig/Abstract verschieben
[ "TODO", ":", "in", "ExtConfig", "/", "Abstract", "verschieben" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Component/Abstract/Admin.php#L66-L81
koala-framework/koala-framework
Kwf/Controller/Action/Component/PagesController.php
Kwf_Controller_Action_Component_PagesController.getComponentNodeConfig
public static function getComponentNodeConfig($component, $user, $acl, array &$componentConfigs = array()) { $data = parent::getNodeConfig($component); $enabled = $acl->isAllowed($user, $component); if (!$enabled && !$component instanceof Kwf_Component_Data_Root/*root nicht überprüfen, die wird immar angezeigt*/) { $allowedComponents = $acl->getAllowedRecursiveChildComponents($user, $component); $allowed = false; foreach ($allowedComponents as $allowedComponent) { $c = $allowedComponent; while ($c) { if ($c->componentId == $component->componentId) { if (!$allowedComponent->isPage) { if (self::_getAllEditComponents(array($allowedComponent), $user, $acl)) { //es gibt bearbeiten buttons, seite anzeigen $allowed = true; break; } if (!$allowed) { //nächste allowComponent überprüfen continue 2; } } else { //seiten sind immer erlaubt (wegen seiteneigenschaften) $allowed = true; } break 2; } $c = $c->parent; } } //wenn gar keine unterkomponente bearbeitet werden kann seite ausblenden if (!$allowed) return null; } if (!$enabled) { //wenn eine unterkomponente (nicht seite!) bearbeitet werden kann seite nicht ausgrauen $editComponents = $acl->getAllowedChildComponents($user, $component); if ($editComponents) $enabled = true; } else { $editComponents = array($component); } $data['disabled'] = !$enabled; if ($component->componentId != 'root' && !$enabled) { $data['iconEffects'][] = 'forbidden'; } if (!$acl->isAllowed($user, $component)) { //wenn komponente *selbst* nicht bearbeitbar ist actions deaktivieren //(in dem fall ist eine unterkomponente der seite bearbeitbar) $data['actions'] = array_merge($data['actions'], array( 'delete' => false, 'copy' => false, 'visible' => false, 'makeHome' => false, )); $data['allowDrag'] = false; } //wenn *unter* der seite eine page möglich ist (pageGenerator vorhanden) dann //hinzufügen + drop erlauben //das kann nicht im Generator ermittelt werden, der macht nur sich selbst if ($acl->isAllowed($user, $component)) { $pageGenerator = Kwf_Component_Generator_Abstract::getInstances($component, array( 'pageGenerator' => true )); if ($pageGenerator && $pageGenerator[0] instanceof Kwc_Root_Category_Generator) { $data['actions']['add'] = true; $data['actions']['paste'] = true; $data['allowDrop'] = true; } } $data['actions']['preview'] = (bool)$component->isPage; //default werte $data['actions'] = array_merge(array( 'properties' => !$data['disabled'], 'delete' => false, 'copy' => false, 'paste' => false, 'visible' => false, 'makeHome' => false, 'add' => false, ), $data['actions']); $data['editComponents'] = self::_getAllEditComponents($editComponents, $user, $acl, $componentConfigs); return $data; }
php
public static function getComponentNodeConfig($component, $user, $acl, array &$componentConfigs = array()) { $data = parent::getNodeConfig($component); $enabled = $acl->isAllowed($user, $component); if (!$enabled && !$component instanceof Kwf_Component_Data_Root/*root nicht überprüfen, die wird immar angezeigt*/) { $allowedComponents = $acl->getAllowedRecursiveChildComponents($user, $component); $allowed = false; foreach ($allowedComponents as $allowedComponent) { $c = $allowedComponent; while ($c) { if ($c->componentId == $component->componentId) { if (!$allowedComponent->isPage) { if (self::_getAllEditComponents(array($allowedComponent), $user, $acl)) { //es gibt bearbeiten buttons, seite anzeigen $allowed = true; break; } if (!$allowed) { //nächste allowComponent überprüfen continue 2; } } else { //seiten sind immer erlaubt (wegen seiteneigenschaften) $allowed = true; } break 2; } $c = $c->parent; } } //wenn gar keine unterkomponente bearbeitet werden kann seite ausblenden if (!$allowed) return null; } if (!$enabled) { //wenn eine unterkomponente (nicht seite!) bearbeitet werden kann seite nicht ausgrauen $editComponents = $acl->getAllowedChildComponents($user, $component); if ($editComponents) $enabled = true; } else { $editComponents = array($component); } $data['disabled'] = !$enabled; if ($component->componentId != 'root' && !$enabled) { $data['iconEffects'][] = 'forbidden'; } if (!$acl->isAllowed($user, $component)) { //wenn komponente *selbst* nicht bearbeitbar ist actions deaktivieren //(in dem fall ist eine unterkomponente der seite bearbeitbar) $data['actions'] = array_merge($data['actions'], array( 'delete' => false, 'copy' => false, 'visible' => false, 'makeHome' => false, )); $data['allowDrag'] = false; } //wenn *unter* der seite eine page möglich ist (pageGenerator vorhanden) dann //hinzufügen + drop erlauben //das kann nicht im Generator ermittelt werden, der macht nur sich selbst if ($acl->isAllowed($user, $component)) { $pageGenerator = Kwf_Component_Generator_Abstract::getInstances($component, array( 'pageGenerator' => true )); if ($pageGenerator && $pageGenerator[0] instanceof Kwc_Root_Category_Generator) { $data['actions']['add'] = true; $data['actions']['paste'] = true; $data['allowDrop'] = true; } } $data['actions']['preview'] = (bool)$component->isPage; //default werte $data['actions'] = array_merge(array( 'properties' => !$data['disabled'], 'delete' => false, 'copy' => false, 'paste' => false, 'visible' => false, 'makeHome' => false, 'add' => false, ), $data['actions']); $data['editComponents'] = self::_getAllEditComponents($editComponents, $user, $acl, $componentConfigs); return $data; }
[ "public", "static", "function", "getComponentNodeConfig", "(", "$", "component", ",", "$", "user", ",", "$", "acl", ",", "array", "&", "$", "componentConfigs", "=", "array", "(", ")", ")", "{", "$", "data", "=", "parent", "::", "getNodeConfig", "(", "$", "component", ")", ";", "$", "enabled", "=", "$", "acl", "->", "isAllowed", "(", "$", "user", ",", "$", "component", ")", ";", "if", "(", "!", "$", "enabled", "&&", "!", "$", "component", "instanceof", "Kwf_Component_Data_Root", "/*root nicht überprüfen, die wird immar angezeigt*/) ", "{", "", "$", "allowedComponents", "=", "$", "acl", "->", "getAllowedRecursiveChildComponents", "(", "$", "user", ",", "$", "component", ")", ";", "$", "allowed", "=", "false", ";", "foreach", "(", "$", "allowedComponents", "as", "$", "allowedComponent", ")", "{", "$", "c", "=", "$", "allowedComponent", ";", "while", "(", "$", "c", ")", "{", "if", "(", "$", "c", "->", "componentId", "==", "$", "component", "->", "componentId", ")", "{", "if", "(", "!", "$", "allowedComponent", "->", "isPage", ")", "{", "if", "(", "self", "::", "_getAllEditComponents", "(", "array", "(", "$", "allowedComponent", ")", ",", "$", "user", ",", "$", "acl", ")", ")", "{", "//es gibt bearbeiten buttons, seite anzeigen", "$", "allowed", "=", "true", ";", "break", ";", "}", "if", "(", "!", "$", "allowed", ")", "{", "//nächste allowComponent überprüfen", "continue", "2", ";", "}", "}", "else", "{", "//seiten sind immer erlaubt (wegen seiteneigenschaften)", "$", "allowed", "=", "true", ";", "}", "break", "2", ";", "}", "$", "c", "=", "$", "c", "->", "parent", ";", "}", "}", "//wenn gar keine unterkomponente bearbeitet werden kann seite ausblenden", "if", "(", "!", "$", "allowed", ")", "return", "null", ";", "}", "if", "(", "!", "$", "enabled", ")", "{", "//wenn eine unterkomponente (nicht seite!) bearbeitet werden kann seite nicht ausgrauen", "$", "editComponents", "=", "$", "acl", "->", "getAllowedChildComponents", "(", "$", "user", ",", "$", "component", ")", ";", "if", "(", "$", "editComponents", ")", "$", "enabled", "=", "true", ";", "}", "else", "{", "$", "editComponents", "=", "array", "(", "$", "component", ")", ";", "}", "$", "data", "[", "'disabled'", "]", "=", "!", "$", "enabled", ";", "if", "(", "$", "component", "->", "componentId", "!=", "'root'", "&&", "!", "$", "enabled", ")", "{", "$", "data", "[", "'iconEffects'", "]", "[", "]", "=", "'forbidden'", ";", "}", "if", "(", "!", "$", "acl", "->", "isAllowed", "(", "$", "user", ",", "$", "component", ")", ")", "{", "//wenn komponente *selbst* nicht bearbeitbar ist actions deaktivieren", "//(in dem fall ist eine unterkomponente der seite bearbeitbar)", "$", "data", "[", "'actions'", "]", "=", "array_merge", "(", "$", "data", "[", "'actions'", "]", ",", "array", "(", "'delete'", "=>", "false", ",", "'copy'", "=>", "false", ",", "'visible'", "=>", "false", ",", "'makeHome'", "=>", "false", ",", ")", ")", ";", "$", "data", "[", "'allowDrag'", "]", "=", "false", ";", "}", "//wenn *unter* der seite eine page möglich ist (pageGenerator vorhanden) dann", "//hinzufügen + drop erlauben", "//das kann nicht im Generator ermittelt werden, der macht nur sich selbst", "if", "(", "$", "acl", "->", "isAllowed", "(", "$", "user", ",", "$", "component", ")", ")", "{", "$", "pageGenerator", "=", "Kwf_Component_Generator_Abstract", "::", "getInstances", "(", "$", "component", ",", "array", "(", "'pageGenerator'", "=>", "true", ")", ")", ";", "if", "(", "$", "pageGenerator", "&&", "$", "pageGenerator", "[", "0", "]", "instanceof", "Kwc_Root_Category_Generator", ")", "{", "$", "data", "[", "'actions'", "]", "[", "'add'", "]", "=", "true", ";", "$", "data", "[", "'actions'", "]", "[", "'paste'", "]", "=", "true", ";", "$", "data", "[", "'allowDrop'", "]", "=", "true", ";", "}", "}", "$", "data", "[", "'actions'", "]", "[", "'preview'", "]", "=", "(", "bool", ")", "$", "component", "->", "isPage", ";", "//default werte", "$", "data", "[", "'actions'", "]", "=", "array_merge", "(", "array", "(", "'properties'", "=>", "!", "$", "data", "[", "'disabled'", "]", ",", "'delete'", "=>", "false", ",", "'copy'", "=>", "false", ",", "'paste'", "=>", "false", ",", "'visible'", "=>", "false", ",", "'makeHome'", "=>", "false", ",", "'add'", "=>", "false", ",", ")", ",", "$", "data", "[", "'actions'", "]", ")", ";", "$", "data", "[", "'editComponents'", "]", "=", "self", "::", "_getAllEditComponents", "(", "$", "editComponents", ",", "$", "user", ",", "$", "acl", ",", "$", "componentConfigs", ")", ";", "return", "$", "data", ";", "}" ]
public static zum testen
[ "public", "static", "zum", "testen" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Controller/Action/Component/PagesController.php#L14-L102
koala-framework/koala-framework
Kwf/Controller/Action/Component/PagesController.php
Kwf_Controller_Action_Component_PagesController.getEditComponents
public static function getEditComponents($component) { $editComponents = array(); //egal ob component eine page ist oder nicht, selbst darf sie immer bearbeitet werden //es ist dann *keine* page wenn der benutzer unter eine unterkomponente bearbeiten darf - nicht aber die page selbst $editComponents[] = $component; $editComponents = array_merge($editComponents, $component->getRecursiveChildComponents( array( 'hasEditComponents' => true, 'ignoreVisible' => true, 'generatorFlags' => array('showInPageTreeAdmin' => false), ), array( 'generatorFlags' => array('showInPageTreeAdmin' => false), 'hasEditComponents' => true, ) ) ); return $editComponents; }
php
public static function getEditComponents($component) { $editComponents = array(); //egal ob component eine page ist oder nicht, selbst darf sie immer bearbeitet werden //es ist dann *keine* page wenn der benutzer unter eine unterkomponente bearbeiten darf - nicht aber die page selbst $editComponents[] = $component; $editComponents = array_merge($editComponents, $component->getRecursiveChildComponents( array( 'hasEditComponents' => true, 'ignoreVisible' => true, 'generatorFlags' => array('showInPageTreeAdmin' => false), ), array( 'generatorFlags' => array('showInPageTreeAdmin' => false), 'hasEditComponents' => true, ) ) ); return $editComponents; }
[ "public", "static", "function", "getEditComponents", "(", "$", "component", ")", "{", "$", "editComponents", "=", "array", "(", ")", ";", "//egal ob component eine page ist oder nicht, selbst darf sie immer bearbeitet werden", "//es ist dann *keine* page wenn der benutzer unter eine unterkomponente bearbeiten darf - nicht aber die page selbst", "$", "editComponents", "[", "]", "=", "$", "component", ";", "$", "editComponents", "=", "array_merge", "(", "$", "editComponents", ",", "$", "component", "->", "getRecursiveChildComponents", "(", "array", "(", "'hasEditComponents'", "=>", "true", ",", "'ignoreVisible'", "=>", "true", ",", "'generatorFlags'", "=>", "array", "(", "'showInPageTreeAdmin'", "=>", "false", ")", ",", ")", ",", "array", "(", "'generatorFlags'", "=>", "array", "(", "'showInPageTreeAdmin'", "=>", "false", ")", ",", "'hasEditComponents'", "=>", "true", ",", ")", ")", ")", ";", "return", "$", "editComponents", ";", "}" ]
static zum Testen
[ "static", "zum", "Testen" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Controller/Action/Component/PagesController.php#L159-L180
koala-framework/koala-framework
Kwf/Controller/Action/Component/PagesController.php
Kwf_Controller_Action_Component_PagesController.getSharedComponents
public static function getSharedComponents($component) { static $sharedClasses = array(); if (!isset($sharedClasses[Kwf_Component_Data_Root::getComponentClass()])) { //pro root klasse cachen weil die sich ja bei den tests ändern kann $componentClasses = Kwc_Abstract::getComponentClasses(); $sharedClasses[Kwf_Component_Data_Root::getComponentClass()] = array(); foreach ($componentClasses as $componentClass) { $class = Kwc_Abstract::getFlag($componentClass, 'sharedDataClass'); if ($class) $sharedClasses[Kwf_Component_Data_Root::getComponentClass()][$componentClass] = $class; } } $ret = array(); foreach ($sharedClasses[Kwf_Component_Data_Root::getComponentClass()] as $componentClass => $sharedClass) { $targetComponent = null; if (is_instance_of($component->componentClass, $sharedClass)) { $targetComponent = $component; } if (!$targetComponent) { $components = $component->getRecursiveChildComponents( array('componentClass' => $sharedClass, 'pseudoPage' => false) ); if (count($components) > 0) $targetComponent = array_shift($components); } if ($targetComponent) $ret[$componentClass] = $targetComponent; } return $ret; }
php
public static function getSharedComponents($component) { static $sharedClasses = array(); if (!isset($sharedClasses[Kwf_Component_Data_Root::getComponentClass()])) { //pro root klasse cachen weil die sich ja bei den tests ändern kann $componentClasses = Kwc_Abstract::getComponentClasses(); $sharedClasses[Kwf_Component_Data_Root::getComponentClass()] = array(); foreach ($componentClasses as $componentClass) { $class = Kwc_Abstract::getFlag($componentClass, 'sharedDataClass'); if ($class) $sharedClasses[Kwf_Component_Data_Root::getComponentClass()][$componentClass] = $class; } } $ret = array(); foreach ($sharedClasses[Kwf_Component_Data_Root::getComponentClass()] as $componentClass => $sharedClass) { $targetComponent = null; if (is_instance_of($component->componentClass, $sharedClass)) { $targetComponent = $component; } if (!$targetComponent) { $components = $component->getRecursiveChildComponents( array('componentClass' => $sharedClass, 'pseudoPage' => false) ); if (count($components) > 0) $targetComponent = array_shift($components); } if ($targetComponent) $ret[$componentClass] = $targetComponent; } return $ret; }
[ "public", "static", "function", "getSharedComponents", "(", "$", "component", ")", "{", "static", "$", "sharedClasses", "=", "array", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "sharedClasses", "[", "Kwf_Component_Data_Root", "::", "getComponentClass", "(", ")", "]", ")", ")", "{", "//pro root klasse cachen weil die sich ja bei den tests ändern kann", "$", "componentClasses", "=", "Kwc_Abstract", "::", "getComponentClasses", "(", ")", ";", "$", "sharedClasses", "[", "Kwf_Component_Data_Root", "::", "getComponentClass", "(", ")", "]", "=", "array", "(", ")", ";", "foreach", "(", "$", "componentClasses", "as", "$", "componentClass", ")", "{", "$", "class", "=", "Kwc_Abstract", "::", "getFlag", "(", "$", "componentClass", ",", "'sharedDataClass'", ")", ";", "if", "(", "$", "class", ")", "$", "sharedClasses", "[", "Kwf_Component_Data_Root", "::", "getComponentClass", "(", ")", "]", "[", "$", "componentClass", "]", "=", "$", "class", ";", "}", "}", "$", "ret", "=", "array", "(", ")", ";", "foreach", "(", "$", "sharedClasses", "[", "Kwf_Component_Data_Root", "::", "getComponentClass", "(", ")", "]", "as", "$", "componentClass", "=>", "$", "sharedClass", ")", "{", "$", "targetComponent", "=", "null", ";", "if", "(", "is_instance_of", "(", "$", "component", "->", "componentClass", ",", "$", "sharedClass", ")", ")", "{", "$", "targetComponent", "=", "$", "component", ";", "}", "if", "(", "!", "$", "targetComponent", ")", "{", "$", "components", "=", "$", "component", "->", "getRecursiveChildComponents", "(", "array", "(", "'componentClass'", "=>", "$", "sharedClass", ",", "'pseudoPage'", "=>", "false", ")", ")", ";", "if", "(", "count", "(", "$", "components", ")", ">", "0", ")", "$", "targetComponent", "=", "array_shift", "(", "$", "components", ")", ";", "}", "if", "(", "$", "targetComponent", ")", "$", "ret", "[", "$", "componentClass", "]", "=", "$", "targetComponent", ";", "}", "return", "$", "ret", ";", "}" ]
static zum Testen
[ "static", "zum", "Testen" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Controller/Action/Component/PagesController.php#L183-L209
koala-framework/koala-framework
Kwf/Media/Image.php
Kwf_Media_Image.getResponsiveWidthStep
public static function getResponsiveWidthStep($width, $widths) { foreach ($widths as $cachedWidth) { if ($width <= $cachedWidth) { return $cachedWidth; } } return end($widths); }
php
public static function getResponsiveWidthStep($width, $widths) { foreach ($widths as $cachedWidth) { if ($width <= $cachedWidth) { return $cachedWidth; } } return end($widths); }
[ "public", "static", "function", "getResponsiveWidthStep", "(", "$", "width", ",", "$", "widths", ")", "{", "foreach", "(", "$", "widths", "as", "$", "cachedWidth", ")", "{", "if", "(", "$", "width", "<=", "$", "cachedWidth", ")", "{", "return", "$", "cachedWidth", ";", "}", "}", "return", "end", "(", "$", "widths", ")", ";", "}" ]
Returns next supported image-width
[ "Returns", "next", "supported", "image", "-", "width" ]
train
https://github.com/koala-framework/koala-framework/blob/2131b9b10b6c368ea02ad448d5f8a4deef0fe971/Kwf/Media/Image.php#L7-L15