repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6 values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1 value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
oat-sa/tao-core | models/classes/maintenance/Maintenance.php | Maintenance.getPlatformState | public function getPlatformState()
{
try {
return $this->getStorage()->getCurrentPlatformState();
} catch (\common_exception_NotFound $e) {
$this->enablePlatform();
return new MaintenanceState(
array(MaintenanceState::STATUS => MaintenanceState::LIVE_MODE)
);
}
} | php | public function getPlatformState()
{
try {
return $this->getStorage()->getCurrentPlatformState();
} catch (\common_exception_NotFound $e) {
$this->enablePlatform();
return new MaintenanceState(
array(MaintenanceState::STATUS => MaintenanceState::LIVE_MODE)
);
}
} | [
"public",
"function",
"getPlatformState",
"(",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"getStorage",
"(",
")",
"->",
"getCurrentPlatformState",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"common_exception_NotFound",
"$",
"e",
")",
"{",
"$",
"this",... | Get the current maintenance state of the platform
@return MaintenanceState | [
"Get",
"the",
"current",
"maintenance",
"state",
"of",
"the",
"platform"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/maintenance/Maintenance.php#L81-L91 |
oat-sa/tao-core | models/classes/maintenance/Maintenance.php | Maintenance.setPlatformState | protected function setPlatformState($status)
{
$state = new MaintenanceState(array(
MaintenanceState::STATUS => $status
));
$this->getStorage()->setPlatformState($state);
} | php | protected function setPlatformState($status)
{
$state = new MaintenanceState(array(
MaintenanceState::STATUS => $status
));
$this->getStorage()->setPlatformState($state);
} | [
"protected",
"function",
"setPlatformState",
"(",
"$",
"status",
")",
"{",
"$",
"state",
"=",
"new",
"MaintenanceState",
"(",
"array",
"(",
"MaintenanceState",
"::",
"STATUS",
"=>",
"$",
"status",
")",
")",
";",
"$",
"this",
"->",
"getStorage",
"(",
")",
... | Update platform state
@param $status | [
"Update",
"platform",
"state"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/maintenance/Maintenance.php#L98-L105 |
oat-sa/tao-core | models/classes/maintenance/Maintenance.php | Maintenance.getStorage | public function getStorage()
{
if (! $this->storage) {
if (! $this->hasOption(self::OPTION_PERSISTENCE)) {
throw new InconsistencyConfigException(__('Maintenance service must have a persistence option.'));
}
$this->storage = new MaintenanceStorage(
\common_persistence_Manager::getPersistence($this->getOption(self::OPTION_PERSISTENCE))
);
}
return $this->storage;
} | php | public function getStorage()
{
if (! $this->storage) {
if (! $this->hasOption(self::OPTION_PERSISTENCE)) {
throw new InconsistencyConfigException(__('Maintenance service must have a persistence option.'));
}
$this->storage = new MaintenanceStorage(
\common_persistence_Manager::getPersistence($this->getOption(self::OPTION_PERSISTENCE))
);
}
return $this->storage;
} | [
"public",
"function",
"getStorage",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"storage",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasOption",
"(",
"self",
"::",
"OPTION_PERSISTENCE",
")",
")",
"{",
"throw",
"new",
"InconsistencyConfigExcepti... | Get the maintenance storage
@return MaintenanceStorage
@throws InconsistencyConfigException | [
"Get",
"the",
"maintenance",
"storage"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/maintenance/Maintenance.php#L113-L124 |
oat-sa/tao-core | helpers/form/validators/class.Unique.php | tao_helpers_form_validators_Unique.evaluate | public function evaluate($values)
{
$domain = $this->getProperty()->getDomain();
foreach ($domain as $class) {
$resources = $class->searchInstances(array($this->getProperty()->getUri() => $values), array('recursive' => true, 'like' => false));
if (count($resources) > 0) {
return false;
}
}
return true;
} | php | public function evaluate($values)
{
$domain = $this->getProperty()->getDomain();
foreach ($domain as $class) {
$resources = $class->searchInstances(array($this->getProperty()->getUri() => $values), array('recursive' => true, 'like' => false));
if (count($resources) > 0) {
return false;
}
}
return true;
} | [
"public",
"function",
"evaluate",
"(",
"$",
"values",
")",
"{",
"$",
"domain",
"=",
"$",
"this",
"->",
"getProperty",
"(",
")",
"->",
"getDomain",
"(",
")",
";",
"foreach",
"(",
"$",
"domain",
"as",
"$",
"class",
")",
"{",
"$",
"resources",
"=",
"$... | (non-PHPdoc)
@see tao_helpers_form_Validator::evaluate() | [
"(",
"non",
"-",
"PHPdoc",
")"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/validators/class.Unique.php#L73-L83 |
oat-sa/tao-core | models/classes/resources/TreeResourceLookup.php | TreeResourceLookup.formatTreeData | private function formatTreeData(array $treeData)
{
return array_map(function($data){
$formated = [
'label' => $data['data'],
'type' => $data['type'],
'uri' => $data['attributes']['data-uri'],
'classUri' => $data['attributes']['data-classUri'],
'signature' => $data['attributes']['data-signature'],
'state' => isset($data['state']) ? $data['state'] : false,
'count' => isset($data['count']) ? $data['count'] : 0
];
if(isset($data['children'])){
$formated['children'] = $this->formatTreeData($data['children']);
}
return $formated;
}, $treeData);
} | php | private function formatTreeData(array $treeData)
{
return array_map(function($data){
$formated = [
'label' => $data['data'],
'type' => $data['type'],
'uri' => $data['attributes']['data-uri'],
'classUri' => $data['attributes']['data-classUri'],
'signature' => $data['attributes']['data-signature'],
'state' => isset($data['state']) ? $data['state'] : false,
'count' => isset($data['count']) ? $data['count'] : 0
];
if(isset($data['children'])){
$formated['children'] = $this->formatTreeData($data['children']);
}
return $formated;
}, $treeData);
} | [
"private",
"function",
"formatTreeData",
"(",
"array",
"$",
"treeData",
")",
"{",
"return",
"array_map",
"(",
"function",
"(",
"$",
"data",
")",
"{",
"$",
"formated",
"=",
"[",
"'label'",
"=>",
"$",
"data",
"[",
"'data'",
"]",
",",
"'type'",
"=>",
"$",... | Reformat the the tree : state and count
Add the resource's categories
@param array $treeData
@return array the formated data | [
"Reformat",
"the",
"the",
"tree",
":",
"state",
"and",
"count",
"Add",
"the",
"resource",
"s",
"categories"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/resources/TreeResourceLookup.php#L81-L99 |
oat-sa/tao-core | actions/form/class.EditClassLabel.php | tao_actions_form_EditClassLabel.initForm | protected function initForm()
{
(isset($this->options['name'])) ? $name = $this->options['name'] : $name = '';
if (empty($name)) {
$name = 'form_' . (count(self::$forms) + 1);
}
unset($this->options['name']);
$this->form = \tao_helpers_form_FormFactory::getForm($name, $this->options);
$this->form->setActions(\tao_helpers_form_FormFactory::getCommonActions(), 'bottom');
} | php | protected function initForm()
{
(isset($this->options['name'])) ? $name = $this->options['name'] : $name = '';
if (empty($name)) {
$name = 'form_' . (count(self::$forms) + 1);
}
unset($this->options['name']);
$this->form = \tao_helpers_form_FormFactory::getForm($name, $this->options);
$this->form->setActions(\tao_helpers_form_FormFactory::getCommonActions(), 'bottom');
} | [
"protected",
"function",
"initForm",
"(",
")",
"{",
"(",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"'name'",
"]",
")",
")",
"?",
"$",
"name",
"=",
"$",
"this",
"->",
"options",
"[",
"'name'",
"]",
":",
"$",
"name",
"=",
"''",
";",
"if",
... | Initialize the form
@access protected
@author Bertrand Chevrier, <bertrand.chevrier@tudor.lu>
@return mixed | [
"Initialize",
"the",
"form"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/form/class.EditClassLabel.php#L74-L86 |
oat-sa/tao-core | actions/form/class.EditClassLabel.php | tao_actions_form_EditClassLabel.initElements | protected function initElements()
{
$clazz = $this->getClassInstance();
$labelProp = new \core_kernel_classes_Property(OntologyRdfs::RDFS_LABEL);
//map properties widgets to form elements
$element = \tao_helpers_form_GenerisFormFactory::elementMap($labelProp);
if (!is_null($element)) {
$value = $clazz->getLabel();
if (!is_null($value)) {
$element->setValue($value);
}
//set label validator
$element->addValidators([
\tao_helpers_form_FormFactory::getValidator('NotEmpty'),
]);
$namespace = substr($clazz->getUri(), 0, strpos($clazz->getUri(), '#'));
if ($namespace != LOCAL_NAMESPACE) {
$readonly = \tao_helpers_form_FormFactory::getElement($element->getName(), 'Readonly');
$readonly->setDescription($element->getDescription());
$readonly->setValue($element->getRawValue());
$element = $readonly;
}
$element->addClass('global');
$this->form->addElement($element);
}
//add an hidden elt for the class uri
$classUriElt = \tao_helpers_form_FormFactory::getElement('classUri', 'Hidden');
$classUriElt->setValue(\tao_helpers_Uri::encode($clazz->getUri()));
$classUriElt->addClass('global');
$this->form->addElement($classUriElt);
$this->addSignature();
} | php | protected function initElements()
{
$clazz = $this->getClassInstance();
$labelProp = new \core_kernel_classes_Property(OntologyRdfs::RDFS_LABEL);
//map properties widgets to form elements
$element = \tao_helpers_form_GenerisFormFactory::elementMap($labelProp);
if (!is_null($element)) {
$value = $clazz->getLabel();
if (!is_null($value)) {
$element->setValue($value);
}
//set label validator
$element->addValidators([
\tao_helpers_form_FormFactory::getValidator('NotEmpty'),
]);
$namespace = substr($clazz->getUri(), 0, strpos($clazz->getUri(), '#'));
if ($namespace != LOCAL_NAMESPACE) {
$readonly = \tao_helpers_form_FormFactory::getElement($element->getName(), 'Readonly');
$readonly->setDescription($element->getDescription());
$readonly->setValue($element->getRawValue());
$element = $readonly;
}
$element->addClass('global');
$this->form->addElement($element);
}
//add an hidden elt for the class uri
$classUriElt = \tao_helpers_form_FormFactory::getElement('classUri', 'Hidden');
$classUriElt->setValue(\tao_helpers_Uri::encode($clazz->getUri()));
$classUriElt->addClass('global');
$this->form->addElement($classUriElt);
$this->addSignature();
} | [
"protected",
"function",
"initElements",
"(",
")",
"{",
"$",
"clazz",
"=",
"$",
"this",
"->",
"getClassInstance",
"(",
")",
";",
"$",
"labelProp",
"=",
"new",
"\\",
"core_kernel_classes_Property",
"(",
"OntologyRdfs",
"::",
"RDFS_LABEL",
")",
";",
"//map prope... | Initialize the form elements
@access protected
@author Bertrand Chevrier, <bertrand.chevrier@tudor.lu>
@return mixed | [
"Initialize",
"the",
"form",
"elements"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/form/class.EditClassLabel.php#L95-L130 |
oat-sa/tao-core | helpers/form/validators/class.Regex.php | tao_helpers_form_validators_Regex.evaluate | public function evaluate( $values )
{
$returnValue = false;
if (is_string( $values ) || is_numeric( $values )) {
$returnValue = (preg_match( $this->getOption('format'), $values ) === 1);
}
return $returnValue;
} | php | public function evaluate( $values )
{
$returnValue = false;
if (is_string( $values ) || is_numeric( $values )) {
$returnValue = (preg_match( $this->getOption('format'), $values ) === 1);
}
return $returnValue;
} | [
"public",
"function",
"evaluate",
"(",
"$",
"values",
")",
"{",
"$",
"returnValue",
"=",
"false",
";",
"if",
"(",
"is_string",
"(",
"$",
"values",
")",
"||",
"is_numeric",
"(",
"$",
"values",
")",
")",
"{",
"$",
"returnValue",
"=",
"(",
"preg_match",
... | Short description of method evaluate
@access public
@author Joel Bout, <joel.bout@tudor.lu>
@param values
@return boolean | [
"Short",
"description",
"of",
"method",
"evaluate"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/validators/class.Regex.php#L54-L63 |
oat-sa/tao-core | actions/form/class.AbstractProperty.php | tao_actions_form_AbstractProperty.initForm | protected function initForm()
{
(isset($this->options['name'])) ? $name = $this->options['name'] : $name = '';
if(empty($name)){
$name = 'form_'.(count(self::$forms)+1);
}
unset($this->options['name']);
$this->index = array_key_exists( 'index', $this->options ) ? $this->options['index'] : 1;
$this->form = tao_helpers_form_FormFactory::getForm($name, $this->options);
} | php | protected function initForm()
{
(isset($this->options['name'])) ? $name = $this->options['name'] : $name = '';
if(empty($name)){
$name = 'form_'.(count(self::$forms)+1);
}
unset($this->options['name']);
$this->index = array_key_exists( 'index', $this->options ) ? $this->options['index'] : 1;
$this->form = tao_helpers_form_FormFactory::getForm($name, $this->options);
} | [
"protected",
"function",
"initForm",
"(",
")",
"{",
"(",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"'name'",
"]",
")",
")",
"?",
"$",
"name",
"=",
"$",
"this",
"->",
"options",
"[",
"'name'",
"]",
":",
"$",
"name",
"=",
"''",
";",
"if",
... | Initialize the form
@access protected
@author Bertrand Chevrier, <bertrand.chevrier@tudor.lu>
@return mixed | [
"Initialize",
"the",
"form"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/form/class.AbstractProperty.php#L60-L75 |
oat-sa/tao-core | actions/form/class.AbstractProperty.php | tao_actions_form_AbstractProperty.getGroupTitle | protected function getGroupTitle($property)
{
if ($this->isParentProperty()){
foreach ($property->getDomain()->getIterator() as $domain) {
$domainLabel[] = $domain->getLabel();
}
$groupTitle = '<span class="property-heading-label">' . _dh($property->getLabel()) . '</span>'
. '<span class="property-heading-toolbar">'
. _dh(implode(' ', $domainLabel))
. ' <span class="icon-find"></span>'
. ' <span class="icon-edit"></span>'
. '</span>';
}else{
$groupTitle = '<span class="property-heading-label">' . _dh($property->getLabel()) . '</span>'
. '<span class="property-heading-toolbar">'
. ' <span class="icon-find"></span>'
. '<span class="icon-edit"></span>'
. '<span class="icon-bin property-deleter" data-uri=\''.tao_helpers_Display::encodeAttrValue($property->getUri()).'\'></span>'
. '</span>';
}
return $groupTitle;
} | php | protected function getGroupTitle($property)
{
if ($this->isParentProperty()){
foreach ($property->getDomain()->getIterator() as $domain) {
$domainLabel[] = $domain->getLabel();
}
$groupTitle = '<span class="property-heading-label">' . _dh($property->getLabel()) . '</span>'
. '<span class="property-heading-toolbar">'
. _dh(implode(' ', $domainLabel))
. ' <span class="icon-find"></span>'
. ' <span class="icon-edit"></span>'
. '</span>';
}else{
$groupTitle = '<span class="property-heading-label">' . _dh($property->getLabel()) . '</span>'
. '<span class="property-heading-toolbar">'
. ' <span class="icon-find"></span>'
. '<span class="icon-edit"></span>'
. '<span class="icon-bin property-deleter" data-uri=\''.tao_helpers_Display::encodeAttrValue($property->getUri()).'\'></span>'
. '</span>';
}
return $groupTitle;
} | [
"protected",
"function",
"getGroupTitle",
"(",
"$",
"property",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isParentProperty",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"property",
"->",
"getDomain",
"(",
")",
"->",
"getIterator",
"(",
")",
"as",
"$",
"dom... | Returns html for property
@param $property
@return string | [
"Returns",
"html",
"for",
"property"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/form/class.AbstractProperty.php#L91-L115 |
oat-sa/tao-core | models/classes/accessControl/class.AclProxy.php | tao_models_classes_accessControl_AclProxy.hasAccess | public static function hasAccess($action, $controller, $extension, $parameters = array()) {
$user = common_session_SessionManager::getSession()->getUser();
try {
$resolver = ActionResolver::getByControllerName($controller, $extension);
$className = $resolver->getController();
} catch (ResolverException $e) {
return false;
}
return AclProxy::hasAccess($user, $className, $action, $parameters);
} | php | public static function hasAccess($action, $controller, $extension, $parameters = array()) {
$user = common_session_SessionManager::getSession()->getUser();
try {
$resolver = ActionResolver::getByControllerName($controller, $extension);
$className = $resolver->getController();
} catch (ResolverException $e) {
return false;
}
return AclProxy::hasAccess($user, $className, $action, $parameters);
} | [
"public",
"static",
"function",
"hasAccess",
"(",
"$",
"action",
",",
"$",
"controller",
",",
"$",
"extension",
",",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"$",
"user",
"=",
"common_session_SessionManager",
"::",
"getSession",
"(",
")",
"->",... | Returns whenever or not the current user has access to a specified link
@param string $action
@param string $controller
@param string $extension
@param array $parameters
@return boolean
@deprecated | [
"Returns",
"whenever",
"or",
"not",
"the",
"current",
"user",
"has",
"access",
"to",
"a",
"specified",
"link"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/accessControl/class.AclProxy.php#L46-L55 |
oat-sa/tao-core | models/classes/accessControl/class.AclProxy.php | tao_models_classes_accessControl_AclProxy.hasAccessUrl | public static function hasAccessUrl($url) {
$user = common_session_SessionManager::getSession()->getUser();
try {
$resolver = new ActionResolver($url);
return AclProxy::hasAccess($user, $resolver->getController(), $resolver->getAction(), array());
$className = $resolver->getController();
} catch (ResolverException $e) {
return false;
}
} | php | public static function hasAccessUrl($url) {
$user = common_session_SessionManager::getSession()->getUser();
try {
$resolver = new ActionResolver($url);
return AclProxy::hasAccess($user, $resolver->getController(), $resolver->getAction(), array());
$className = $resolver->getController();
} catch (ResolverException $e) {
return false;
}
} | [
"public",
"static",
"function",
"hasAccessUrl",
"(",
"$",
"url",
")",
"{",
"$",
"user",
"=",
"common_session_SessionManager",
"::",
"getSession",
"(",
")",
"->",
"getUser",
"(",
")",
";",
"try",
"{",
"$",
"resolver",
"=",
"new",
"ActionResolver",
"(",
"$",... | Does not respect params
@param string $url
@return boolean | [
"Does",
"not",
"respect",
"params"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/accessControl/class.AclProxy.php#L63-L72 |
oat-sa/tao-core | actions/form/class.SimpleProperty.php | tao_actions_form_SimpleProperty.initElements | protected function initElements()
{
$property = $this->getPropertyInstance();
$index = $this->getIndex();
$propertyProperties = array_merge(
tao_helpers_form_GenerisFormFactory::getDefaultProperties(),
array(new core_kernel_classes_Property(GenerisRdf::PROPERTY_IS_LG_DEPENDENT),
new core_kernel_classes_Property(TaoOntology::PROPERTY_GUI_ORDER),
$this->getProperty(ValidationRuleRegistry::PROPERTY_VALIDATION_RULE)
)
);
$values = $property->getPropertiesValues($propertyProperties);
$elementNames = array();
foreach($propertyProperties as $propertyProperty){
//map properties widgets to form elements
$element = tao_helpers_form_GenerisFormFactory::elementMap($propertyProperty);
if(!is_null($element)){
//take property values to populate the form
if (isset($values[$propertyProperty->getUri()])) {
$propertyValues = $values[$propertyProperty->getUri()];
foreach($propertyValues as $value){
if(!is_null($value)){
if($value instanceof core_kernel_classes_Resource){
$element->setValue($value->getUri());
}
if($value instanceof core_kernel_classes_Literal){
$element->setValue((string)$value);
}
}
}
}
$element->setName("{$index}_{$element->getName()}");
$element->addClass('property');
if ($propertyProperty->getUri() == TaoOntology::PROPERTY_GUI_ORDER){
$element->addValidator(tao_helpers_form_FormFactory::getValidator('Integer'));
}
if ($propertyProperty->getUri() == OntologyRdfs::RDFS_LABEL){
$element->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty'));
}
$this->form->addElement($element);
$elementNames[] = $element->getName();
}
}
//build the type list from the "widget/range to type" map
$typeElt = tao_helpers_form_FormFactory::getElement("{$index}_type", 'Combobox');
$typeElt->setDescription(__('Type'));
$typeElt->addAttribute('class', 'property-type property');
$typeElt->setEmptyOption(' --- '.__('select').' --- ');
$options = array();
$checkRange = false;
foreach(tao_helpers_form_GenerisFormFactory::getPropertyMap() as $typeKey => $map){
$options[$typeKey] = $map['title'];
$widget = $property->getWidget();
if($widget instanceof core_kernel_classes_Resource) {
if($widget->getUri() == $map['widget']){
$typeElt->setValue($typeKey);
$checkRange = is_null($map['range']);
}
}
}
$typeElt->setOptions($options);
$this->form->addElement($typeElt);
$elementNames[] = $typeElt->getName();
$range = $property->getRange();
$rangeSelect = tao_helpers_form_FormFactory::getElement( "{$this->getIndex()}_range", 'Combobox' );
$rangeSelect->setDescription( __( 'List values' ) );
$rangeSelect->addAttribute( 'class', 'property-listvalues property' );
$rangeSelect->setEmptyOption( ' --- ' . __( 'select' ) . ' --- ' );
if ($checkRange) {
$rangeSelect->addValidator( tao_helpers_form_FormFactory::getValidator( 'NotEmpty' ) );
}
$this->form->addElement($rangeSelect);
$elementNames[] = $rangeSelect->getName();
//list drop down
$listElt = $this->getListElement( $range );
$this->form->addElement($listElt);
$elementNames[] = $listElt->getName();
//trees dropdown
$treeElt = $this->getTreeElement( $range );
$this->form->addElement($treeElt);
$elementNames[] = $treeElt->getName();
//index part
$indexes = $property->getPropertyValues(new \core_kernel_classes_Property(OntologyIndex::PROPERTY_INDEX));
foreach($indexes as $i => $indexUri){
$indexProperty = new OntologyIndex($indexUri);
$indexFormContainer = new tao_actions_form_IndexProperty($indexProperty,$index.$i);
/** @var tao_helpers_form_Form $indexForm */
$indexForm = $indexFormContainer->getForm();
foreach($indexForm->getElements() as $element){
$this->form->addElement($element);
$elementNames[] = $element->getName();
}
}
//add this element only when the property is defined (type)
if(!is_null($property->getRange())){
$addIndexElt = tao_helpers_form_FormFactory::getElement("index_{$index}_add", 'Free');
$addIndexElt->setValue(
"<a href='#' class='btn-info index-adder small index'><span class='icon-add'></span> " . __(
'Add index'
) . "</a><div class='clearfix'></div>"
);
$this->form->addElement($addIndexElt);
$elementNames[] = $addIndexElt;
}
else{
$addIndexElt = tao_helpers_form_FormFactory::getElement("index_{$index}_p", 'Free');
$addIndexElt->setValue(
"<p class='index' >" . __(
'Choose a type for your property first'
) . "</p>"
);
$this->form->addElement($addIndexElt);
$elementNames[] = $addIndexElt;
}
//add an hidden elt for the property uri
$encodedUri = tao_helpers_Uri::encode($property->getUri());
$propUriElt = tao_helpers_form_FormFactory::getElement("{$index}_uri", 'Hidden');
$propUriElt->addAttribute('class', 'property-uri property');
$propUriElt->setValue($encodedUri);
$this->form->addElement($propUriElt);
$elementNames[] = $propUriElt;
if(count($elementNames) > 0){
$groupTitle = $this->getGroupTitle($property);
$this->form->createGroup("property_{$encodedUri}", $groupTitle, $elementNames);
}
} | php | protected function initElements()
{
$property = $this->getPropertyInstance();
$index = $this->getIndex();
$propertyProperties = array_merge(
tao_helpers_form_GenerisFormFactory::getDefaultProperties(),
array(new core_kernel_classes_Property(GenerisRdf::PROPERTY_IS_LG_DEPENDENT),
new core_kernel_classes_Property(TaoOntology::PROPERTY_GUI_ORDER),
$this->getProperty(ValidationRuleRegistry::PROPERTY_VALIDATION_RULE)
)
);
$values = $property->getPropertiesValues($propertyProperties);
$elementNames = array();
foreach($propertyProperties as $propertyProperty){
//map properties widgets to form elements
$element = tao_helpers_form_GenerisFormFactory::elementMap($propertyProperty);
if(!is_null($element)){
//take property values to populate the form
if (isset($values[$propertyProperty->getUri()])) {
$propertyValues = $values[$propertyProperty->getUri()];
foreach($propertyValues as $value){
if(!is_null($value)){
if($value instanceof core_kernel_classes_Resource){
$element->setValue($value->getUri());
}
if($value instanceof core_kernel_classes_Literal){
$element->setValue((string)$value);
}
}
}
}
$element->setName("{$index}_{$element->getName()}");
$element->addClass('property');
if ($propertyProperty->getUri() == TaoOntology::PROPERTY_GUI_ORDER){
$element->addValidator(tao_helpers_form_FormFactory::getValidator('Integer'));
}
if ($propertyProperty->getUri() == OntologyRdfs::RDFS_LABEL){
$element->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty'));
}
$this->form->addElement($element);
$elementNames[] = $element->getName();
}
}
//build the type list from the "widget/range to type" map
$typeElt = tao_helpers_form_FormFactory::getElement("{$index}_type", 'Combobox');
$typeElt->setDescription(__('Type'));
$typeElt->addAttribute('class', 'property-type property');
$typeElt->setEmptyOption(' --- '.__('select').' --- ');
$options = array();
$checkRange = false;
foreach(tao_helpers_form_GenerisFormFactory::getPropertyMap() as $typeKey => $map){
$options[$typeKey] = $map['title'];
$widget = $property->getWidget();
if($widget instanceof core_kernel_classes_Resource) {
if($widget->getUri() == $map['widget']){
$typeElt->setValue($typeKey);
$checkRange = is_null($map['range']);
}
}
}
$typeElt->setOptions($options);
$this->form->addElement($typeElt);
$elementNames[] = $typeElt->getName();
$range = $property->getRange();
$rangeSelect = tao_helpers_form_FormFactory::getElement( "{$this->getIndex()}_range", 'Combobox' );
$rangeSelect->setDescription( __( 'List values' ) );
$rangeSelect->addAttribute( 'class', 'property-listvalues property' );
$rangeSelect->setEmptyOption( ' --- ' . __( 'select' ) . ' --- ' );
if ($checkRange) {
$rangeSelect->addValidator( tao_helpers_form_FormFactory::getValidator( 'NotEmpty' ) );
}
$this->form->addElement($rangeSelect);
$elementNames[] = $rangeSelect->getName();
//list drop down
$listElt = $this->getListElement( $range );
$this->form->addElement($listElt);
$elementNames[] = $listElt->getName();
//trees dropdown
$treeElt = $this->getTreeElement( $range );
$this->form->addElement($treeElt);
$elementNames[] = $treeElt->getName();
//index part
$indexes = $property->getPropertyValues(new \core_kernel_classes_Property(OntologyIndex::PROPERTY_INDEX));
foreach($indexes as $i => $indexUri){
$indexProperty = new OntologyIndex($indexUri);
$indexFormContainer = new tao_actions_form_IndexProperty($indexProperty,$index.$i);
/** @var tao_helpers_form_Form $indexForm */
$indexForm = $indexFormContainer->getForm();
foreach($indexForm->getElements() as $element){
$this->form->addElement($element);
$elementNames[] = $element->getName();
}
}
//add this element only when the property is defined (type)
if(!is_null($property->getRange())){
$addIndexElt = tao_helpers_form_FormFactory::getElement("index_{$index}_add", 'Free');
$addIndexElt->setValue(
"<a href='#' class='btn-info index-adder small index'><span class='icon-add'></span> " . __(
'Add index'
) . "</a><div class='clearfix'></div>"
);
$this->form->addElement($addIndexElt);
$elementNames[] = $addIndexElt;
}
else{
$addIndexElt = tao_helpers_form_FormFactory::getElement("index_{$index}_p", 'Free');
$addIndexElt->setValue(
"<p class='index' >" . __(
'Choose a type for your property first'
) . "</p>"
);
$this->form->addElement($addIndexElt);
$elementNames[] = $addIndexElt;
}
//add an hidden elt for the property uri
$encodedUri = tao_helpers_Uri::encode($property->getUri());
$propUriElt = tao_helpers_form_FormFactory::getElement("{$index}_uri", 'Hidden');
$propUriElt->addAttribute('class', 'property-uri property');
$propUriElt->setValue($encodedUri);
$this->form->addElement($propUriElt);
$elementNames[] = $propUriElt;
if(count($elementNames) > 0){
$groupTitle = $this->getGroupTitle($property);
$this->form->createGroup("property_{$encodedUri}", $groupTitle, $elementNames);
}
} | [
"protected",
"function",
"initElements",
"(",
")",
"{",
"$",
"property",
"=",
"$",
"this",
"->",
"getPropertyInstance",
"(",
")",
";",
"$",
"index",
"=",
"$",
"this",
"->",
"getIndex",
"(",
")",
";",
"$",
"propertyProperties",
"=",
"array_merge",
"(",
"t... | Initialize the form elements
@access protected
@author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> | [
"Initialize",
"the",
"form",
"elements"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/form/class.SimpleProperty.php#L46-L190 |
oat-sa/tao-core | actions/form/class.SimpleProperty.php | tao_actions_form_SimpleProperty.getTreeElement | protected function getTreeElement( $range )
{
$dataService = TreeService::singleton();
/**
* @var tao_helpers_form_elements_xhtml_Combobox $element
*/
$element = tao_helpers_form_FormFactory::getElement( "{$this->getIndex()}_range_tree", 'Combobox' );
$element->setDescription( __( 'Tree values' ) );
$element->addAttribute( 'class', 'property-template tree-template' );
$element->addAttribute( 'disabled', 'disabled' );
$element->setEmptyOption( ' --- ' . __( 'select' ) . ' --- ' );
$treeOptions = array();
foreach ($dataService->getTrees() as $tree) {
$treeOptions[tao_helpers_Uri::encode( $tree->getUri() )] = $tree->getLabel();
if (null !== $range && $range->getUri() === $tree->getUri()) {
$element->setValue( $tree->getUri() );
}
}
$element->setOptions( $treeOptions );
return $element;
} | php | protected function getTreeElement( $range )
{
$dataService = TreeService::singleton();
/**
* @var tao_helpers_form_elements_xhtml_Combobox $element
*/
$element = tao_helpers_form_FormFactory::getElement( "{$this->getIndex()}_range_tree", 'Combobox' );
$element->setDescription( __( 'Tree values' ) );
$element->addAttribute( 'class', 'property-template tree-template' );
$element->addAttribute( 'disabled', 'disabled' );
$element->setEmptyOption( ' --- ' . __( 'select' ) . ' --- ' );
$treeOptions = array();
foreach ($dataService->getTrees() as $tree) {
$treeOptions[tao_helpers_Uri::encode( $tree->getUri() )] = $tree->getLabel();
if (null !== $range && $range->getUri() === $tree->getUri()) {
$element->setValue( $tree->getUri() );
}
}
$element->setOptions( $treeOptions );
return $element;
} | [
"protected",
"function",
"getTreeElement",
"(",
"$",
"range",
")",
"{",
"$",
"dataService",
"=",
"TreeService",
"::",
"singleton",
"(",
")",
";",
"/**\n\t\t * @var tao_helpers_form_elements_xhtml_Combobox $element\n\t\t */",
"$",
"element",
"=",
"tao_helpers_form_FormFactor... | @param $range
@return tao_helpers_form_elements_xhtml_Combobox
@throws common_Exception | [
"@param",
"$range"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/form/class.SimpleProperty.php#L198-L220 |
oat-sa/tao-core | actions/form/class.SimpleProperty.php | tao_actions_form_SimpleProperty.getListElement | protected function getListElement( $range )
{
$service = tao_models_classes_ListService::singleton();
/**
* @var tao_helpers_form_elements_xhtml_Combobox $element
*/
$element = tao_helpers_form_FormFactory::getElement( "{$this->getIndex()}_range_list", 'Combobox' );
$element->setDescription( __( 'List values' ) );
$element->addAttribute( 'class', 'property-template list-template' );
$element->addAttribute( 'disabled', 'disabled' );
$element->setEmptyOption( ' --- ' . __( 'select' ) . ' --- ' );
$listOptions = array();
foreach ($service->getLists() as $list) {
$listOptions[tao_helpers_Uri::encode( $list->getUri() )] = $list->getLabel();
if (null !== $range && $range->getUri() === $list->getUri()) {
$element->setValue( $list->getUri() );
}
}
$listOptions['new'] = ' + ' . __( 'Add / Edit lists' );
$element->setOptions( $listOptions );
return $element;
} | php | protected function getListElement( $range )
{
$service = tao_models_classes_ListService::singleton();
/**
* @var tao_helpers_form_elements_xhtml_Combobox $element
*/
$element = tao_helpers_form_FormFactory::getElement( "{$this->getIndex()}_range_list", 'Combobox' );
$element->setDescription( __( 'List values' ) );
$element->addAttribute( 'class', 'property-template list-template' );
$element->addAttribute( 'disabled', 'disabled' );
$element->setEmptyOption( ' --- ' . __( 'select' ) . ' --- ' );
$listOptions = array();
foreach ($service->getLists() as $list) {
$listOptions[tao_helpers_Uri::encode( $list->getUri() )] = $list->getLabel();
if (null !== $range && $range->getUri() === $list->getUri()) {
$element->setValue( $list->getUri() );
}
}
$listOptions['new'] = ' + ' . __( 'Add / Edit lists' );
$element->setOptions( $listOptions );
return $element;
} | [
"protected",
"function",
"getListElement",
"(",
"$",
"range",
")",
"{",
"$",
"service",
"=",
"tao_models_classes_ListService",
"::",
"singleton",
"(",
")",
";",
"/**\n\t\t * @var tao_helpers_form_elements_xhtml_Combobox $element\n\t\t */",
"$",
"element",
"=",
"tao_helpers_... | @param $range
@return tao_helpers_form_elements_xhtml_Combobox
@throws common_Exception | [
"@param",
"$range"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/form/class.SimpleProperty.php#L228-L254 |
oat-sa/tao-core | helpers/report/class.Rendering.php | tao_helpers_report_Rendering.render | public static function render(common_report_Report $report) {
$stack = new SplStack();
$renderingStack = new SplStack();
$traversed = array();
$stack->push($report);
$nesting = 0;
while ($stack->count() > 0) {
$current = $stack->pop();
if (in_array($current, $traversed, true) === false && $current->hasChildren() === true) {
$nesting++;
// -- Hierarchical report, 1st pass (descending).
// Repush report for a 2ndpass.
$stack->push($current);
// Tag as already traversed.
$traversed[] = $current;
// Push the children for a 1st pass.
foreach ($current as $child) {
$stack->push($child);
}
}
else if (in_array($current, $traversed, true) === true && $current->hasChildren() === true) {
$nesting--;
// -- Hierachical report, 2nd pass (ascending).
// Get the nested renderings of the current report.
$children = array();
foreach ($current as $child) {
$children[] = $renderingStack->pop();
}
$renderingStack->push(self::renderReport($current, $children, $nesting));
}
else {
// -- Leaf report, 1st & single pass.
$renderingStack->push(self::renderReport($current, array(), $nesting, true));
}
}
return $renderingStack->pop();
} | php | public static function render(common_report_Report $report) {
$stack = new SplStack();
$renderingStack = new SplStack();
$traversed = array();
$stack->push($report);
$nesting = 0;
while ($stack->count() > 0) {
$current = $stack->pop();
if (in_array($current, $traversed, true) === false && $current->hasChildren() === true) {
$nesting++;
// -- Hierarchical report, 1st pass (descending).
// Repush report for a 2ndpass.
$stack->push($current);
// Tag as already traversed.
$traversed[] = $current;
// Push the children for a 1st pass.
foreach ($current as $child) {
$stack->push($child);
}
}
else if (in_array($current, $traversed, true) === true && $current->hasChildren() === true) {
$nesting--;
// -- Hierachical report, 2nd pass (ascending).
// Get the nested renderings of the current report.
$children = array();
foreach ($current as $child) {
$children[] = $renderingStack->pop();
}
$renderingStack->push(self::renderReport($current, $children, $nesting));
}
else {
// -- Leaf report, 1st & single pass.
$renderingStack->push(self::renderReport($current, array(), $nesting, true));
}
}
return $renderingStack->pop();
} | [
"public",
"static",
"function",
"render",
"(",
"common_report_Report",
"$",
"report",
")",
"{",
"$",
"stack",
"=",
"new",
"SplStack",
"(",
")",
";",
"$",
"renderingStack",
"=",
"new",
"SplStack",
"(",
")",
";",
"$",
"traversed",
"=",
"array",
"(",
")",
... | Render a common_report_Report object into an HTML string output.
@param common_report_Report $report A report to be rendered
@return string The HTML rendering. | [
"Render",
"a",
"common_report_Report",
"object",
"into",
"an",
"HTML",
"string",
"output",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/report/class.Rendering.php#L36-L83 |
oat-sa/tao-core | helpers/report/class.Rendering.php | tao_helpers_report_Rendering.renderReport | private static function renderReport(common_report_Report $report, array $childRenderedReports = array(), $nesting = 0, $leaf = false) {
switch ($report->getType()) {
case common_report_Report::TYPE_SUCCESS:
$typeClass = 'success';
break;
case common_report_Report::TYPE_WARNING:
$typeClass = 'warning';
break;
case common_report_Report::TYPE_ERROR:
$typeClass = 'error';
break;
default:
$typeClass = 'info';
break;
}
$openingTag = '<div class="feedback-' . $typeClass . ' feedback-nesting-' . $nesting . ' ' . (($leaf === true) ? 'leaf' : 'hierarchical') . ' tao-scope">';
$leafIcon = ($leaf === true) ? ' leaf-icon' : ' hierarchical-icon';
$icon = '<span class="icon-' . $typeClass . $leafIcon . '"></span>';
$message = nl2br(_dh($report->__toString()));
$endingTag = '</div>';
$okButton = '<p><button id="import-continue" class="btn-info"><span class="icon-right"></span>' . __("Continue") . '</button></p>';
// Put all the children renderings together.
$content = implode('', $childRenderedReports);
return $openingTag . $icon . $message . $content . (($nesting != 0) ? '' : $okButton) . $endingTag;
} | php | private static function renderReport(common_report_Report $report, array $childRenderedReports = array(), $nesting = 0, $leaf = false) {
switch ($report->getType()) {
case common_report_Report::TYPE_SUCCESS:
$typeClass = 'success';
break;
case common_report_Report::TYPE_WARNING:
$typeClass = 'warning';
break;
case common_report_Report::TYPE_ERROR:
$typeClass = 'error';
break;
default:
$typeClass = 'info';
break;
}
$openingTag = '<div class="feedback-' . $typeClass . ' feedback-nesting-' . $nesting . ' ' . (($leaf === true) ? 'leaf' : 'hierarchical') . ' tao-scope">';
$leafIcon = ($leaf === true) ? ' leaf-icon' : ' hierarchical-icon';
$icon = '<span class="icon-' . $typeClass . $leafIcon . '"></span>';
$message = nl2br(_dh($report->__toString()));
$endingTag = '</div>';
$okButton = '<p><button id="import-continue" class="btn-info"><span class="icon-right"></span>' . __("Continue") . '</button></p>';
// Put all the children renderings together.
$content = implode('', $childRenderedReports);
return $openingTag . $icon . $message . $content . (($nesting != 0) ? '' : $okButton) . $endingTag;
} | [
"private",
"static",
"function",
"renderReport",
"(",
"common_report_Report",
"$",
"report",
",",
"array",
"$",
"childRenderedReports",
"=",
"array",
"(",
")",
",",
"$",
"nesting",
"=",
"0",
",",
"$",
"leaf",
"=",
"false",
")",
"{",
"switch",
"(",
"$",
"... | Contains the logic to render a report and its children.
@param common_report_Report $report A report to be rendered.
@param array $childRenderedReports An array of strings containing the separate rendering of $report's child reports.
@param integer $nesting The current nesting level (root = 0).
@return string The HTML output of $report. | [
"Contains",
"the",
"logic",
"to",
"render",
"a",
"report",
"and",
"its",
"children",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/report/class.Rendering.php#L93-L124 |
oat-sa/tao-core | helpers/report/class.Rendering.php | tao_helpers_report_Rendering.renderToCommandline | public static function renderToCommandline(common_report_Report $report, $intend = 0) {
return helpers_Report::renderToCommandLine($report, helpers_Report::AUTOSENSE, $intend);
} | php | public static function renderToCommandline(common_report_Report $report, $intend = 0) {
return helpers_Report::renderToCommandLine($report, helpers_Report::AUTOSENSE, $intend);
} | [
"public",
"static",
"function",
"renderToCommandline",
"(",
"common_report_Report",
"$",
"report",
",",
"$",
"intend",
"=",
"0",
")",
"{",
"return",
"helpers_Report",
"::",
"renderToCommandLine",
"(",
"$",
"report",
",",
"helpers_Report",
"::",
"AUTOSENSE",
",",
... | Contains the logic to render a report and its children to the command line
@deprecated
@param common_report_Report $report A report to be rendered.
@param integer $intend the intend of the message.
@return string The command line output of $report. | [
"Contains",
"the",
"logic",
"to",
"render",
"a",
"report",
"and",
"its",
"children",
"to",
"the",
"command",
"line"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/report/class.Rendering.php#L134-L136 |
oat-sa/tao-core | models/classes/class.RoleService.php | tao_models_classes_RoleService.getRole | public function getRole($uri)
{
$returnValue = null;
if(!empty($uri)){
$returnValue = new core_kernel_classes_Resource($uri);
}
return $returnValue;
} | php | public function getRole($uri)
{
$returnValue = null;
if(!empty($uri)){
$returnValue = new core_kernel_classes_Resource($uri);
}
return $returnValue;
} | [
"public",
"function",
"getRole",
"(",
"$",
"uri",
")",
"{",
"$",
"returnValue",
"=",
"null",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"uri",
")",
")",
"{",
"$",
"returnValue",
"=",
"new",
"core_kernel_classes_Resource",
"(",
"$",
"uri",
")",
";",
"}",... | Get the Role matching the uri
@access public
@author Joel Bout, <joel@taotesting.com>
@param string uri
@return core_kernel_classes_Resource | [
"Get",
"the",
"Role",
"matching",
"the",
"uri"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.RoleService.php#L93-L102 |
oat-sa/tao-core | models/classes/class.RoleService.php | tao_models_classes_RoleService.setRoleToUsers | public function setRoleToUsers( core_kernel_classes_Resource $role, $users = array())
{
$returnValue = (bool) false;
$userService = tao_models_classes_UserService::singleton();
$rolesProperty = new core_kernel_classes_Property(GenerisRdf::PROPERTY_USER_ROLES);
foreach ($users as $u){
$u = ($u instanceof core_kernel_classes_Resource) ? $u : new core_kernel_classes_Resource($u);
// just in case of ...
$userService->unnatachRole($u, $role);
// assign the new role.
$u->setPropertyValue($rolesProperty, $role);
if (common_session_SessionManager::getSession()->getUserUri() == $u->getUri()) {
common_session_SessionManager::getSession()->refresh();
}
}
$returnValue = true;
return (bool) $returnValue;
} | php | public function setRoleToUsers( core_kernel_classes_Resource $role, $users = array())
{
$returnValue = (bool) false;
$userService = tao_models_classes_UserService::singleton();
$rolesProperty = new core_kernel_classes_Property(GenerisRdf::PROPERTY_USER_ROLES);
foreach ($users as $u){
$u = ($u instanceof core_kernel_classes_Resource) ? $u : new core_kernel_classes_Resource($u);
// just in case of ...
$userService->unnatachRole($u, $role);
// assign the new role.
$u->setPropertyValue($rolesProperty, $role);
if (common_session_SessionManager::getSession()->getUserUri() == $u->getUri()) {
common_session_SessionManager::getSession()->refresh();
}
}
$returnValue = true;
return (bool) $returnValue;
} | [
"public",
"function",
"setRoleToUsers",
"(",
"core_kernel_classes_Resource",
"$",
"role",
",",
"$",
"users",
"=",
"array",
"(",
")",
")",
"{",
"$",
"returnValue",
"=",
"(",
"bool",
")",
"false",
";",
"$",
"userService",
"=",
"tao_models_classes_UserService",
"... | assign a role to a set of users
@access public
@author Joel Bout, <joel@taotesting.com>
@param Resource role
@param array users
@return boolean | [
"assign",
"a",
"role",
"to",
"a",
"set",
"of",
"users"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.RoleService.php#L129-L152 |
oat-sa/tao-core | models/classes/class.RoleService.php | tao_models_classes_RoleService.getUsers | public function getUsers( core_kernel_classes_Resource $role)
{
$returnValue = array();
$filters = array(GenerisRdf::PROPERTY_USER_ROLES => $role->getUri());
$options = array('like' => false, 'recursive' => true);
$userClass = new core_kernel_classes_Class(GenerisRdf::CLASS_GENERIS_USER);
$results = $userClass->searchInstances($filters, $options);
$returnValue = array_keys($results);
return (array) $returnValue;
} | php | public function getUsers( core_kernel_classes_Resource $role)
{
$returnValue = array();
$filters = array(GenerisRdf::PROPERTY_USER_ROLES => $role->getUri());
$options = array('like' => false, 'recursive' => true);
$userClass = new core_kernel_classes_Class(GenerisRdf::CLASS_GENERIS_USER);
$results = $userClass->searchInstances($filters, $options);
$returnValue = array_keys($results);
return (array) $returnValue;
} | [
"public",
"function",
"getUsers",
"(",
"core_kernel_classes_Resource",
"$",
"role",
")",
"{",
"$",
"returnValue",
"=",
"array",
"(",
")",
";",
"$",
"filters",
"=",
"array",
"(",
"GenerisRdf",
"::",
"PROPERTY_USER_ROLES",
"=>",
"$",
"role",
"->",
"getUri",
"(... | get the users who have the role in parameter
@access public
@author Joel Bout, <joel@taotesting.com>
@param core_kernel_classes_Resource role
@return array | [
"get",
"the",
"users",
"who",
"have",
"the",
"role",
"in",
"parameter"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.RoleService.php#L162-L175 |
oat-sa/tao-core | models/classes/class.RoleService.php | tao_models_classes_RoleService.addRole | public function addRole($label, $includedRoles = null, core_kernel_classes_Class $class = null)
{
return $this->generisUserService->addRole($label, $includedRoles, $class);
} | php | public function addRole($label, $includedRoles = null, core_kernel_classes_Class $class = null)
{
return $this->generisUserService->addRole($label, $includedRoles, $class);
} | [
"public",
"function",
"addRole",
"(",
"$",
"label",
",",
"$",
"includedRoles",
"=",
"null",
",",
"core_kernel_classes_Class",
"$",
"class",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"generisUserService",
"->",
"addRole",
"(",
"$",
"label",
",",
"... | Creates a new Role in persistent memory.
@param string label The label of the new role.
@param mixed includedRoles The roles to include to the new role. Can be either a core_kernel_classes_Resource or an array of core_kernel_classes_Resource.
@param core_kernel_classes_Class (optional) A specific class for the new role.
@return core_kernel_classes_Resource The newly created role. | [
"Creates",
"a",
"new",
"Role",
"in",
"persistent",
"memory",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.RoleService.php#L185-L188 |
oat-sa/tao-core | models/classes/class.RoleService.php | tao_models_classes_RoleService.removeRole | public function removeRole(core_kernel_classes_Resource $role)
{
$this->getEventManager()->trigger(new RoleRemovedEvent($role->getUri()));
return $this->generisUserService->removeRole($role);
} | php | public function removeRole(core_kernel_classes_Resource $role)
{
$this->getEventManager()->trigger(new RoleRemovedEvent($role->getUri()));
return $this->generisUserService->removeRole($role);
} | [
"public",
"function",
"removeRole",
"(",
"core_kernel_classes_Resource",
"$",
"role",
")",
"{",
"$",
"this",
"->",
"getEventManager",
"(",
")",
"->",
"trigger",
"(",
"new",
"RoleRemovedEvent",
"(",
"$",
"role",
"->",
"getUri",
"(",
")",
")",
")",
";",
"ret... | Remove a given Role from persistent memory. References to this role
will also be removed from the persistent memory.
@param core_kernel_classes_Resource $role The Role to remove.
@return boolean True if the Role was removed, false otherwise. | [
"Remove",
"a",
"given",
"Role",
"from",
"persistent",
"memory",
".",
"References",
"to",
"this",
"role",
"will",
"also",
"be",
"removed",
"from",
"the",
"persistent",
"memory",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.RoleService.php#L197-L201 |
oat-sa/tao-core | models/classes/class.RoleService.php | tao_models_classes_RoleService.includeRole | public function includeRole(core_kernel_classes_Resource $role, core_kernel_classes_Resource $roleToInclude)
{
$this->generisUserService->includeRole($role, $roleToInclude);
$this->getEventManager()->trigger(new RoleChangedEvent($role->getUri(), 'included role', $roleToInclude->getUri()));
} | php | public function includeRole(core_kernel_classes_Resource $role, core_kernel_classes_Resource $roleToInclude)
{
$this->generisUserService->includeRole($role, $roleToInclude);
$this->getEventManager()->trigger(new RoleChangedEvent($role->getUri(), 'included role', $roleToInclude->getUri()));
} | [
"public",
"function",
"includeRole",
"(",
"core_kernel_classes_Resource",
"$",
"role",
",",
"core_kernel_classes_Resource",
"$",
"roleToInclude",
")",
"{",
"$",
"this",
"->",
"generisUserService",
"->",
"includeRole",
"(",
"$",
"role",
",",
"$",
"roleToInclude",
")"... | Includes the $roleToInclude Role to the $role Role.
@param core_kernel_classes_Resource $role A Role.
@param core_kernel_classes_Resource $roleToInclude A Role to include. | [
"Includes",
"the",
"$roleToInclude",
"Role",
"to",
"the",
"$role",
"Role",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.RoleService.php#L220-L224 |
oat-sa/tao-core | models/classes/class.RoleService.php | tao_models_classes_RoleService.unincludeRole | public function unincludeRole(core_kernel_classes_Resource $role, core_kernel_classes_Resource $roleToUninclude)
{
$this->generisUserService->unincludeRole($role, $roleToUninclude);
$this->getEventManager()->trigger(new RoleChangedEvent($role->getUri(), 'excluded role', $roleToUninclude->getUri()));
} | php | public function unincludeRole(core_kernel_classes_Resource $role, core_kernel_classes_Resource $roleToUninclude)
{
$this->generisUserService->unincludeRole($role, $roleToUninclude);
$this->getEventManager()->trigger(new RoleChangedEvent($role->getUri(), 'excluded role', $roleToUninclude->getUri()));
} | [
"public",
"function",
"unincludeRole",
"(",
"core_kernel_classes_Resource",
"$",
"role",
",",
"core_kernel_classes_Resource",
"$",
"roleToUninclude",
")",
"{",
"$",
"this",
"->",
"generisUserService",
"->",
"unincludeRole",
"(",
"$",
"role",
",",
"$",
"roleToUninclude... | Uninclude a Role from another Role.
@param core_kernel_classes_Resource $role The Role from which you want to uninclude another Role.
@param core_kernel_classes_Resource $roleToUninclude The Role to uninclude. | [
"Uninclude",
"a",
"Role",
"from",
"another",
"Role",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.RoleService.php#L232-L236 |
oat-sa/tao-core | helpers/class.Numeric.php | tao_helpers_Numeric.parseFloat | public static function parseFloat($value)
{
$returnValue = (float) 0.0;
$returnValue = str_replace(',', '.', $value);
$returnValue = preg_replace('/[^\-\d.]/', '', $returnValue);
return (float) $returnValue;
} | php | public static function parseFloat($value)
{
$returnValue = (float) 0.0;
$returnValue = str_replace(',', '.', $value);
$returnValue = preg_replace('/[^\-\d.]/', '', $returnValue);
return (float) $returnValue;
} | [
"public",
"static",
"function",
"parseFloat",
"(",
"$",
"value",
")",
"{",
"$",
"returnValue",
"=",
"(",
"float",
")",
"0.0",
";",
"$",
"returnValue",
"=",
"str_replace",
"(",
"','",
",",
"'.'",
",",
"$",
"value",
")",
";",
"$",
"returnValue",
"=",
"... | Converts a string to a float, in order to support negative values.
@access public
@author Jehan Bihin, <jehan.bihin@tudor.lu>
@param string value
@return float | [
"Converts",
"a",
"string",
"to",
"a",
"float",
"in",
"order",
"to",
"support",
"negative",
"values",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/class.Numeric.php#L42-L50 |
oat-sa/tao-core | models/classes/oauth/class.Service.php | tao_models_classes_oauth_Service.sign | public function sign(common_http_Request $request, common_http_Credentials $credentials, $authorizationHeader = false) {
return $this->getService()->sign($request, $credentials, $authorizationHeader);
} | php | public function sign(common_http_Request $request, common_http_Credentials $credentials, $authorizationHeader = false) {
return $this->getService()->sign($request, $credentials, $authorizationHeader);
} | [
"public",
"function",
"sign",
"(",
"common_http_Request",
"$",
"request",
",",
"common_http_Credentials",
"$",
"credentials",
",",
"$",
"authorizationHeader",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"getService",
"(",
")",
"->",
"sign",
"(",
"$",
... | Adds a signature to the request
@access public
@author Joel Bout, <joel@taotesting.com>
@param $authorizationHeader Move the signature parameters into the Authorization header of the request | [
"Adds",
"a",
"signature",
"to",
"the",
"request"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/oauth/class.Service.php#L40-L42 |
oat-sa/tao-core | models/classes/oauth/class.Service.php | tao_models_classes_oauth_Service.validate | public function validate(common_http_Request $request, common_http_Credentials $credentials = null) {
return $this->getService()->validate($request, $credentials);
} | php | public function validate(common_http_Request $request, common_http_Credentials $credentials = null) {
return $this->getService()->validate($request, $credentials);
} | [
"public",
"function",
"validate",
"(",
"common_http_Request",
"$",
"request",
",",
"common_http_Credentials",
"$",
"credentials",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getService",
"(",
")",
"->",
"validate",
"(",
"$",
"request",
",",
"$",
"cr... | Validates the signature of the current request
@access protected
@author Joel Bout, <joel@taotesting.com>
@param common_http_Request request
@throws common_Exception exception thrown if validation fails | [
"Validates",
"the",
"signature",
"of",
"the",
"current",
"request"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/oauth/class.Service.php#L52-L54 |
oat-sa/tao-core | helpers/form/validators/class.Equals.php | tao_helpers_form_validators_Equals.setOptions | public function setOptions(array $options)
{
parent::setOptions($options);
if(!$this->hasOption('reference') || !$this->getOption('reference') instanceof tao_helpers_form_FormElement){
throw new common_Exception("No FormElement provided as reference for Equals validator");
}
$reference = $this->getOption('reference');
if ($this->hasOption('invert') && $this->getOption('invert')) {
$this->setMessage(__('This should not equal %s',$reference->getDescription()));
} else {
$this->setMessage(__('This should equal %s',$reference->getDescription()));
}
} | php | public function setOptions(array $options)
{
parent::setOptions($options);
if(!$this->hasOption('reference') || !$this->getOption('reference') instanceof tao_helpers_form_FormElement){
throw new common_Exception("No FormElement provided as reference for Equals validator");
}
$reference = $this->getOption('reference');
if ($this->hasOption('invert') && $this->getOption('invert')) {
$this->setMessage(__('This should not equal %s',$reference->getDescription()));
} else {
$this->setMessage(__('This should equal %s',$reference->getDescription()));
}
} | [
"public",
"function",
"setOptions",
"(",
"array",
"$",
"options",
")",
"{",
"parent",
"::",
"setOptions",
"(",
"$",
"options",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"hasOption",
"(",
"'reference'",
")",
"||",
"!",
"$",
"this",
"->",
"getOption",... | --- OPERATIONS --- | [
"---",
"OPERATIONS",
"---"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/validators/class.Equals.php#L43-L56 |
oat-sa/tao-core | helpers/form/validators/class.Equals.php | tao_helpers_form_validators_Equals.evaluate | public function evaluate($values)
{
$returnValue = (bool) false;
$invert = $this->hasOption('invert') ? $this->getOption('invert') : false;
$reference = $this->getOption('reference');
$equals = ($values == $reference->getRawValue());
$returnValue = $invert ? !$equals : $equals;
return (bool) $returnValue;
} | php | public function evaluate($values)
{
$returnValue = (bool) false;
$invert = $this->hasOption('invert') ? $this->getOption('invert') : false;
$reference = $this->getOption('reference');
$equals = ($values == $reference->getRawValue());
$returnValue = $invert ? !$equals : $equals;
return (bool) $returnValue;
} | [
"public",
"function",
"evaluate",
"(",
"$",
"values",
")",
"{",
"$",
"returnValue",
"=",
"(",
"bool",
")",
"false",
";",
"$",
"invert",
"=",
"$",
"this",
"->",
"hasOption",
"(",
"'invert'",
")",
"?",
"$",
"this",
"->",
"getOption",
"(",
"'invert'",
"... | Short description of method evaluate
@access public
@author Joel Bout, <joel.bout@tudor.lu>
@param values
@return boolean | [
"Short",
"description",
"of",
"method",
"evaluate"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/validators/class.Equals.php#L67-L79 |
oat-sa/tao-core | actions/class.Main.php | tao_actions_Main.entry | public function entry()
{
$this->defaultData();
$entries = array();
foreach (EntryPointService::getRegistry()->getEntryPoints() as $entry) {
if (tao_models_classes_accessControl_AclProxy::hasAccessUrl($entry->getUrl())) {
$entries[] = $entry;
}
}
if (empty($entries)) {
// no access -> error
if (common_session_SessionManager::isAnonymous()) {
/* @var $urlRouteService DefaultUrlService */
$urlRouteService = $this->getServiceLocator()->get(DefaultUrlService::SERVICE_ID);
$this->redirect($urlRouteService->getLoginUrl());
} else {
common_session_SessionManager::endSession();
return $this->returnError(__('You currently have no access to the platform'), true, 403);
}
} elseif (count($entries) == 1 && !common_session_SessionManager::isAnonymous()) {
// single entrypoint -> redirect
$entry = current($entries);
return $this->redirect($entry->getUrl());
} else {
// multiple entries -> choice
if (!common_session_SessionManager::isAnonymous()) {
$this->setData('user', $this->getSession()->getUserLabel());
}
$this->setData('entries', $entries);
$naviElements = $this->getNavigationElementsByGroup('settings');
foreach($naviElements as $key => $naviElement) {
if($naviElement['perspective']->getId() !== 'user_settings') {
unset($naviElements[$key]);
continue;
}
}
if ($this->hasRequestParameter('errorMessage')){
$this->setData('errorMessage', $this->getRequestParameter('errorMessage'));
}
$this->setData('logout', $this->getServiceLocator()->get(DefaultUrlService::SERVICE_ID)->getLogoutUrl());
$this->setData('userLabel', $this->getSession()->getUserLabel());
$this->setData('settings-menu', $naviElements);
$this->setData('current-section', $this->getRequestParameter('section'));
$this->setData('content-template', array('blocks/entry-points.tpl', 'tao'));
$this->setView('layout.tpl', 'tao');
}
} | php | public function entry()
{
$this->defaultData();
$entries = array();
foreach (EntryPointService::getRegistry()->getEntryPoints() as $entry) {
if (tao_models_classes_accessControl_AclProxy::hasAccessUrl($entry->getUrl())) {
$entries[] = $entry;
}
}
if (empty($entries)) {
// no access -> error
if (common_session_SessionManager::isAnonymous()) {
/* @var $urlRouteService DefaultUrlService */
$urlRouteService = $this->getServiceLocator()->get(DefaultUrlService::SERVICE_ID);
$this->redirect($urlRouteService->getLoginUrl());
} else {
common_session_SessionManager::endSession();
return $this->returnError(__('You currently have no access to the platform'), true, 403);
}
} elseif (count($entries) == 1 && !common_session_SessionManager::isAnonymous()) {
// single entrypoint -> redirect
$entry = current($entries);
return $this->redirect($entry->getUrl());
} else {
// multiple entries -> choice
if (!common_session_SessionManager::isAnonymous()) {
$this->setData('user', $this->getSession()->getUserLabel());
}
$this->setData('entries', $entries);
$naviElements = $this->getNavigationElementsByGroup('settings');
foreach($naviElements as $key => $naviElement) {
if($naviElement['perspective']->getId() !== 'user_settings') {
unset($naviElements[$key]);
continue;
}
}
if ($this->hasRequestParameter('errorMessage')){
$this->setData('errorMessage', $this->getRequestParameter('errorMessage'));
}
$this->setData('logout', $this->getServiceLocator()->get(DefaultUrlService::SERVICE_ID)->getLogoutUrl());
$this->setData('userLabel', $this->getSession()->getUserLabel());
$this->setData('settings-menu', $naviElements);
$this->setData('current-section', $this->getRequestParameter('section'));
$this->setData('content-template', array('blocks/entry-points.tpl', 'tao'));
$this->setView('layout.tpl', 'tao');
}
} | [
"public",
"function",
"entry",
"(",
")",
"{",
"$",
"this",
"->",
"defaultData",
"(",
")",
";",
"$",
"entries",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"EntryPointService",
"::",
"getRegistry",
"(",
")",
"->",
"getEntryPoints",
"(",
")",
"as",
"$",... | First page, when arriving on a system
to choose front or back office | [
"First",
"page",
"when",
"arriving",
"on",
"a",
"system",
"to",
"choose",
"front",
"or",
"back",
"office"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.Main.php#L57-L105 |
oat-sa/tao-core | actions/class.Main.php | tao_actions_Main.login | public function login()
{
$this->defaultData();
/** @var common_ext_ExtensionsManager $extensionManager */
$extensionManager = $this->getServiceLocator()->get(common_ext_ExtensionsManager::SERVICE_ID);
$extension = $extensionManager->getExtensionById('tao');
$config = $extension->getConfig('login');
$disableAutoComplete = !empty($config['disableAutocomplete']);
$enablePasswordReveal = !empty($config['enablePasswordReveal']);
$enableIframeProtection = !empty($config['block_iframe_usage']) && $config['block_iframe_usage'];
if ($enableIframeProtection) {
\oat\tao\model\security\IFrameBlocker::setHeader();
}
$params = array(
'disableAutocomplete' => $disableAutoComplete,
'enablePasswordReveal' => $enablePasswordReveal,
);
if ($this->hasRequestParameter('redirect')) {
$redirectUrl = $_REQUEST['redirect'];
if (substr($redirectUrl, 0,1) == '/' || substr($redirectUrl, 0, strlen(ROOT_URL)) == ROOT_URL) {
$params['redirect'] = $redirectUrl;
}
}
$container = new tao_actions_form_Login($params);
$form = $container->getForm();
if ($form->isSubmited()) {
if ($form->isValid()) {
/** @var UserLocks $userLocksService */
$userLocksService = $this->getServiceLocator()->get(UserLocks::SERVICE_ID);
/** @var EventManager $eventManager */
$eventManager = $this->getServiceLocator()->get(EventManager::SERVICE_ID);
try {
if ($userLocksService->isLocked($form->getValue('login'))) {
$this->logInfo("User '" . $form->getValue('login') . "' has been locked.");
$statusDetails = $userLocksService->getStatusDetails($form->getValue('login'));
if ($statusDetails['auto']) {
$msg = __('You have been locked due to too many failed login attempts. ');
if ($userLocksService->getOption(UserLocks::OPTION_USE_HARD_LOCKOUT)) {
$msg .= __('Please contact your administrator.');
} else {
/** @var DateInterval $remaining */
$remaining = $statusDetails['remaining'];
$reference = new DateTimeImmutable;
$endTime = $reference->add($remaining);
$diffInSeconds = $endTime->getTimestamp() - $reference->getTimestamp();
$msg .= __('Please try in %s.',
$diffInSeconds > 60
? tao_helpers_Date::displayInterval($statusDetails['remaining'], tao_helpers_Date::FORMAT_INTERVAL_LONG)
: $diffInSeconds . ' ' . ($diffInSeconds == 1 ? __('second') : __('seconds'))
);
}
} else {
$msg = __('Your account has been locked, please contact your administrator.');
}
$this->setData('errorMessage', $msg);
} else {
if (LoginService::login($form->getValue('login'), $form->getValue('password'))) {
$logins = $this->getSession()->getUser()->getPropertyValues(UserRdf::PROPERTY_LOGIN);
$eventManager->trigger(new LoginSucceedEvent(current($logins)));
$this->logInfo("Successful login of user '" . $form->getValue('login') . "'.");
if ($this->hasRequestParameter('redirect') && tao_models_classes_accessControl_AclProxy::hasAccessUrl($_REQUEST['redirect'])) {
$this->redirect($_REQUEST['redirect']);
} else {
$this->forward('entry');
}
} else {
$eventManager->trigger(new LoginFailedEvent($form->getValue('login')));
$this->logInfo("Unsuccessful login of user '" . $form->getValue('login') . "'.");
$msg = __('Invalid login or password. Please try again.');
if ($userLocksService->getOption(UserLocks::OPTION_USE_HARD_LOCKOUT)) {
$remainingAttempts = $userLocksService->getLockoutRemainingAttempts($form->getValue('login'));
if ($remainingAttempts !== false) {
if ($remainingAttempts === 0) {
$msg = __('Invalid login or password. Your account has been locked, please contact your administrator.');
} else {
$msg = $msg . ' ' .
($remainingAttempts === 1
? __('Last attempt before your account is locked.')
: __('%d attempts left before your account is locked.', $remainingAttempts));
}
}
}
$this->setData('errorMessage', $msg);
}
}
} catch (core_kernel_users_Exception $e) {
$this->setData('errorMessage', __('Invalid login or password. Please try again.'));
}
} else {
foreach ($form->getElements() as $formElement) {
$fieldError = $formElement->getError();
if ($fieldError) {
$this->setData('fieldMessages_' . $formElement->getName(), $fieldError);
}
}
}
}
$this->setData('title', __("TAO Login"));
$this->setData('autocompleteDisabled', (int)$disableAutoComplete);
$this->setData('passwordRevealEnabled', (int)$enablePasswordReveal);
$entryPointService = $this->getServiceLocator()->get(EntryPointService::SERVICE_ID);
$this->setData('entryPoints', $entryPointService->getEntryPoints(EntryPointService::OPTION_PRELOGIN));
if ($this->hasRequestParameter('msg')) {
$this->setData('msg', $this->getRequestParameter('msg'));
}
$this->setData('show_gdpr', !empty($config['show_gdpr']) && $config['show_gdpr']);
$this->setData('content-template', array('blocks/login.tpl', 'tao'));
$this->setView('layout.tpl', 'tao');
} | php | public function login()
{
$this->defaultData();
/** @var common_ext_ExtensionsManager $extensionManager */
$extensionManager = $this->getServiceLocator()->get(common_ext_ExtensionsManager::SERVICE_ID);
$extension = $extensionManager->getExtensionById('tao');
$config = $extension->getConfig('login');
$disableAutoComplete = !empty($config['disableAutocomplete']);
$enablePasswordReveal = !empty($config['enablePasswordReveal']);
$enableIframeProtection = !empty($config['block_iframe_usage']) && $config['block_iframe_usage'];
if ($enableIframeProtection) {
\oat\tao\model\security\IFrameBlocker::setHeader();
}
$params = array(
'disableAutocomplete' => $disableAutoComplete,
'enablePasswordReveal' => $enablePasswordReveal,
);
if ($this->hasRequestParameter('redirect')) {
$redirectUrl = $_REQUEST['redirect'];
if (substr($redirectUrl, 0,1) == '/' || substr($redirectUrl, 0, strlen(ROOT_URL)) == ROOT_URL) {
$params['redirect'] = $redirectUrl;
}
}
$container = new tao_actions_form_Login($params);
$form = $container->getForm();
if ($form->isSubmited()) {
if ($form->isValid()) {
/** @var UserLocks $userLocksService */
$userLocksService = $this->getServiceLocator()->get(UserLocks::SERVICE_ID);
/** @var EventManager $eventManager */
$eventManager = $this->getServiceLocator()->get(EventManager::SERVICE_ID);
try {
if ($userLocksService->isLocked($form->getValue('login'))) {
$this->logInfo("User '" . $form->getValue('login') . "' has been locked.");
$statusDetails = $userLocksService->getStatusDetails($form->getValue('login'));
if ($statusDetails['auto']) {
$msg = __('You have been locked due to too many failed login attempts. ');
if ($userLocksService->getOption(UserLocks::OPTION_USE_HARD_LOCKOUT)) {
$msg .= __('Please contact your administrator.');
} else {
/** @var DateInterval $remaining */
$remaining = $statusDetails['remaining'];
$reference = new DateTimeImmutable;
$endTime = $reference->add($remaining);
$diffInSeconds = $endTime->getTimestamp() - $reference->getTimestamp();
$msg .= __('Please try in %s.',
$diffInSeconds > 60
? tao_helpers_Date::displayInterval($statusDetails['remaining'], tao_helpers_Date::FORMAT_INTERVAL_LONG)
: $diffInSeconds . ' ' . ($diffInSeconds == 1 ? __('second') : __('seconds'))
);
}
} else {
$msg = __('Your account has been locked, please contact your administrator.');
}
$this->setData('errorMessage', $msg);
} else {
if (LoginService::login($form->getValue('login'), $form->getValue('password'))) {
$logins = $this->getSession()->getUser()->getPropertyValues(UserRdf::PROPERTY_LOGIN);
$eventManager->trigger(new LoginSucceedEvent(current($logins)));
$this->logInfo("Successful login of user '" . $form->getValue('login') . "'.");
if ($this->hasRequestParameter('redirect') && tao_models_classes_accessControl_AclProxy::hasAccessUrl($_REQUEST['redirect'])) {
$this->redirect($_REQUEST['redirect']);
} else {
$this->forward('entry');
}
} else {
$eventManager->trigger(new LoginFailedEvent($form->getValue('login')));
$this->logInfo("Unsuccessful login of user '" . $form->getValue('login') . "'.");
$msg = __('Invalid login or password. Please try again.');
if ($userLocksService->getOption(UserLocks::OPTION_USE_HARD_LOCKOUT)) {
$remainingAttempts = $userLocksService->getLockoutRemainingAttempts($form->getValue('login'));
if ($remainingAttempts !== false) {
if ($remainingAttempts === 0) {
$msg = __('Invalid login or password. Your account has been locked, please contact your administrator.');
} else {
$msg = $msg . ' ' .
($remainingAttempts === 1
? __('Last attempt before your account is locked.')
: __('%d attempts left before your account is locked.', $remainingAttempts));
}
}
}
$this->setData('errorMessage', $msg);
}
}
} catch (core_kernel_users_Exception $e) {
$this->setData('errorMessage', __('Invalid login or password. Please try again.'));
}
} else {
foreach ($form->getElements() as $formElement) {
$fieldError = $formElement->getError();
if ($fieldError) {
$this->setData('fieldMessages_' . $formElement->getName(), $fieldError);
}
}
}
}
$this->setData('title', __("TAO Login"));
$this->setData('autocompleteDisabled', (int)$disableAutoComplete);
$this->setData('passwordRevealEnabled', (int)$enablePasswordReveal);
$entryPointService = $this->getServiceLocator()->get(EntryPointService::SERVICE_ID);
$this->setData('entryPoints', $entryPointService->getEntryPoints(EntryPointService::OPTION_PRELOGIN));
if ($this->hasRequestParameter('msg')) {
$this->setData('msg', $this->getRequestParameter('msg'));
}
$this->setData('show_gdpr', !empty($config['show_gdpr']) && $config['show_gdpr']);
$this->setData('content-template', array('blocks/login.tpl', 'tao'));
$this->setView('layout.tpl', 'tao');
} | [
"public",
"function",
"login",
"(",
")",
"{",
"$",
"this",
"->",
"defaultData",
"(",
")",
";",
"/** @var common_ext_ExtensionsManager $extensionManager */",
"$",
"extensionManager",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"common_e... | Authentication form,
default page, main entry point to the user
@return void
@throws Exception
@throws common_ext_ExtensionException
@throws core_kernel_persistence_Exception | [
"Authentication",
"form",
"default",
"page",
"main",
"entry",
"point",
"to",
"the",
"user"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.Main.php#L115-L251 |
oat-sa/tao-core | actions/class.Main.php | tao_actions_Main.logout | public function logout()
{
$this->defaultData();
$eventManager = $this->getServiceLocator()->get(EventManager::SERVICE_ID);
$logins = $this->getSession()->getUser()->getPropertyValues(UserRdf::PROPERTY_LOGIN);
$eventManager->trigger(new LogoutSucceedEvent(current($logins)));
common_session_SessionManager::endSession();
/* @var $urlRouteService DefaultUrlService */
$urlRouteService = $this->getServiceLocator()->get(DefaultUrlService::SERVICE_ID);
$this->redirect($urlRouteService->getRedirectUrl('logout'));
} | php | public function logout()
{
$this->defaultData();
$eventManager = $this->getServiceLocator()->get(EventManager::SERVICE_ID);
$logins = $this->getSession()->getUser()->getPropertyValues(UserRdf::PROPERTY_LOGIN);
$eventManager->trigger(new LogoutSucceedEvent(current($logins)));
common_session_SessionManager::endSession();
/* @var $urlRouteService DefaultUrlService */
$urlRouteService = $this->getServiceLocator()->get(DefaultUrlService::SERVICE_ID);
$this->redirect($urlRouteService->getRedirectUrl('logout'));
} | [
"public",
"function",
"logout",
"(",
")",
"{",
"$",
"this",
"->",
"defaultData",
"(",
")",
";",
"$",
"eventManager",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"EventManager",
"::",
"SERVICE_ID",
")",
";",
"$",
"logins",
"... | Logout, destroy the session and back to the login page | [
"Logout",
"destroy",
"the",
"session",
"and",
"back",
"to",
"the",
"login",
"page"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.Main.php#L256-L270 |
oat-sa/tao-core | actions/class.Main.php | tao_actions_Main.index | public function index()
{
$this->defaultData();
$user = $this->getUserService()->getCurrentUser();
$extension = $this->getRequestParameter('ext');
$structure = $this->getRequestParameter('structure');
if($this->hasRequestParameter('structure')) {
// structured mode
// @todo stop using session to manage uri/classUri
$this->removeSessionAttribute('uri');
$this->removeSessionAttribute('classUri');
$this->removeSessionAttribute('showNodeUri');
TaoCe::setLastVisitedUrl(
_url(
'index',
'Main',
'tao',
array(
'structure' => $structure,
'ext' => $extension
)
)
);
$sections = $this->getSections($extension, $structure);
if (count($sections) > 0) {
$this->setData('sections', $sections);
} else {
$this->logWarning('no sections');
}
} else {
//check if the user is a noob, otherwise redirect him to his last visited extension.
$firstTime = TaoCe::isFirstTimeInTao();
if ($firstTime == false) {
$lastVisited = TaoCe::getLastVisitedUrl();
if(!is_null($lastVisited)){
$this->redirect($lastVisited);
}
}
}
$perspectiveTypes = array(Perspective::GROUP_DEFAULT, 'settings', 'persistent');
foreach ($perspectiveTypes as $perspectiveType) {
$this->setData($perspectiveType . '-menu', $this->getNavigationElementsByGroup($perspectiveType));
}
/* @var $notifService NotificationServiceInterface */
$notifService = $this->getServiceLocator()->get(NotificationServiceInterface::SERVICE_ID);
if($notifService->getVisibility()) {
$notif = $notifService->notificationCount($user->getUri());
$this->setData('unread-notification', $notif[NotificationInterface::CREATED_STATUS]);
$this->setData('notification-url', _url('index' , 'Main' , 'tao' ,
[
'structure' => 'tao_Notifications',
'ext' => 'tao',
'section' => 'settings_my_notifications',
]
));
}
/* @var $urlRouteService DefaultUrlService */
$urlRouteService = $this->getServiceLocator()->get(DefaultUrlService::SERVICE_ID);
$this->setData('logout', $urlRouteService->getLogoutUrl());
$this->setData('user_lang', $this->getSession()->getDataLanguage());
$this->setData('userLabel', $this->getSession()->getUserLabel());
// re-added to highlight selected extension in menu
$this->setData('shownExtension', $extension);
$this->setData('shownStructure', $structure);
$this->setData('current-section', $this->getRequestParameter('section'));
// Add csrf token
$tokenService = $this->getServiceLocator()->get(TokenService::SERVICE_ID);
$tokenName = $tokenService->getTokenName();
$token = $tokenService->createToken();
$this->setCookie($tokenName, $token, null, '/');
$this->setData('xsrf-token-name', $tokenName);
//creates the URL of the action used to configure the client side
$clientConfigParams = array(
'shownExtension' => $extension,
'shownStructure' => $structure
);
$this->setData('client_config_url', $this->getClientConfigUrl($clientConfigParams));
$this->setData('content-template', array('blocks/sections.tpl', 'tao'));
$this->setView('layout.tpl', 'tao');
} | php | public function index()
{
$this->defaultData();
$user = $this->getUserService()->getCurrentUser();
$extension = $this->getRequestParameter('ext');
$structure = $this->getRequestParameter('structure');
if($this->hasRequestParameter('structure')) {
// structured mode
// @todo stop using session to manage uri/classUri
$this->removeSessionAttribute('uri');
$this->removeSessionAttribute('classUri');
$this->removeSessionAttribute('showNodeUri');
TaoCe::setLastVisitedUrl(
_url(
'index',
'Main',
'tao',
array(
'structure' => $structure,
'ext' => $extension
)
)
);
$sections = $this->getSections($extension, $structure);
if (count($sections) > 0) {
$this->setData('sections', $sections);
} else {
$this->logWarning('no sections');
}
} else {
//check if the user is a noob, otherwise redirect him to his last visited extension.
$firstTime = TaoCe::isFirstTimeInTao();
if ($firstTime == false) {
$lastVisited = TaoCe::getLastVisitedUrl();
if(!is_null($lastVisited)){
$this->redirect($lastVisited);
}
}
}
$perspectiveTypes = array(Perspective::GROUP_DEFAULT, 'settings', 'persistent');
foreach ($perspectiveTypes as $perspectiveType) {
$this->setData($perspectiveType . '-menu', $this->getNavigationElementsByGroup($perspectiveType));
}
/* @var $notifService NotificationServiceInterface */
$notifService = $this->getServiceLocator()->get(NotificationServiceInterface::SERVICE_ID);
if($notifService->getVisibility()) {
$notif = $notifService->notificationCount($user->getUri());
$this->setData('unread-notification', $notif[NotificationInterface::CREATED_STATUS]);
$this->setData('notification-url', _url('index' , 'Main' , 'tao' ,
[
'structure' => 'tao_Notifications',
'ext' => 'tao',
'section' => 'settings_my_notifications',
]
));
}
/* @var $urlRouteService DefaultUrlService */
$urlRouteService = $this->getServiceLocator()->get(DefaultUrlService::SERVICE_ID);
$this->setData('logout', $urlRouteService->getLogoutUrl());
$this->setData('user_lang', $this->getSession()->getDataLanguage());
$this->setData('userLabel', $this->getSession()->getUserLabel());
// re-added to highlight selected extension in menu
$this->setData('shownExtension', $extension);
$this->setData('shownStructure', $structure);
$this->setData('current-section', $this->getRequestParameter('section'));
// Add csrf token
$tokenService = $this->getServiceLocator()->get(TokenService::SERVICE_ID);
$tokenName = $tokenService->getTokenName();
$token = $tokenService->createToken();
$this->setCookie($tokenName, $token, null, '/');
$this->setData('xsrf-token-name', $tokenName);
//creates the URL of the action used to configure the client side
$clientConfigParams = array(
'shownExtension' => $extension,
'shownStructure' => $structure
);
$this->setData('client_config_url', $this->getClientConfigUrl($clientConfigParams));
$this->setData('content-template', array('blocks/sections.tpl', 'tao'));
$this->setView('layout.tpl', 'tao');
} | [
"public",
"function",
"index",
"(",
")",
"{",
"$",
"this",
"->",
"defaultData",
"(",
")",
";",
"$",
"user",
"=",
"$",
"this",
"->",
"getUserService",
"(",
")",
"->",
"getCurrentUser",
"(",
")",
";",
"$",
"extension",
"=",
"$",
"this",
"->",
"getReque... | The main action, load the layout
@return void | [
"The",
"main",
"action",
"load",
"the",
"layout"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.Main.php#L277-L372 |
oat-sa/tao-core | actions/class.Main.php | tao_actions_Main.getNavigationElementsByGroup | private function getNavigationElementsByGroup($groupId)
{
$entries = array();
foreach (MenuService::getPerspectivesByGroup($groupId) as $i => $perspective) {
$binding = $perspective->getBinding();
$children = $this->getMenuElementChildren($perspective);
if (!empty($binding) || !empty($children)) {
$entry = array(
'perspective' => $perspective,
'children' => $children
);
if (!is_null($binding)) {
$entry['binding'] = $perspective->getExtension() . '/' . $binding;
}
$entries[$i] = $entry;
}
}
return $entries;
} | php | private function getNavigationElementsByGroup($groupId)
{
$entries = array();
foreach (MenuService::getPerspectivesByGroup($groupId) as $i => $perspective) {
$binding = $perspective->getBinding();
$children = $this->getMenuElementChildren($perspective);
if (!empty($binding) || !empty($children)) {
$entry = array(
'perspective' => $perspective,
'children' => $children
);
if (!is_null($binding)) {
$entry['binding'] = $perspective->getExtension() . '/' . $binding;
}
$entries[$i] = $entry;
}
}
return $entries;
} | [
"private",
"function",
"getNavigationElementsByGroup",
"(",
"$",
"groupId",
")",
"{",
"$",
"entries",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"MenuService",
"::",
"getPerspectivesByGroup",
"(",
"$",
"groupId",
")",
"as",
"$",
"i",
"=>",
"$",
"perspectiv... | Get perspective data depending on the group set in structure.xml
@param $groupId
@return array | [
"Get",
"perspective",
"data",
"depending",
"on",
"the",
"group",
"set",
"in",
"structure",
".",
"xml"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.Main.php#L380-L399 |
oat-sa/tao-core | actions/class.Main.php | tao_actions_Main.getMenuElementChildren | private function getMenuElementChildren(Perspective $menuElement)
{
$user = $this->getSession()->getUser();
$children = array();
foreach ($menuElement->getChildren() as $section) {
try {
$resolver = new ActionResolver($section->getUrl());
if (FuncProxy::accessPossible($user, $resolver->getController(), $resolver->getAction())) {
$children[] = $section;
}
} catch (ResolverException $e) {
$this->logWarning('Invalid reference in structures: '.$e->getMessage());
}
}
return $children;
} | php | private function getMenuElementChildren(Perspective $menuElement)
{
$user = $this->getSession()->getUser();
$children = array();
foreach ($menuElement->getChildren() as $section) {
try {
$resolver = new ActionResolver($section->getUrl());
if (FuncProxy::accessPossible($user, $resolver->getController(), $resolver->getAction())) {
$children[] = $section;
}
} catch (ResolverException $e) {
$this->logWarning('Invalid reference in structures: '.$e->getMessage());
}
}
return $children;
} | [
"private",
"function",
"getMenuElementChildren",
"(",
"Perspective",
"$",
"menuElement",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"getUser",
"(",
")",
";",
"$",
"children",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
... | Get nested menu elements depending on user rights.
@param Perspective $menuElement from the structure.xml
@return array menu elements list | [
"Get",
"nested",
"menu",
"elements",
"depending",
"on",
"user",
"rights",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.Main.php#L407-L422 |
oat-sa/tao-core | actions/class.Main.php | tao_actions_Main.getSections | private function getSections($shownExtension, $shownStructure)
{
$sections = array();
$user = $this->getSession()->getUser();
$structure = MenuService::getPerspective($shownExtension, $shownStructure);
if (!is_null($structure)) {
foreach ($structure->getChildren() as $section) {
$resolver = new ActionResolver($section->getUrl());
if (FuncProxy::accessPossible($user, $resolver->getController(), $resolver->getAction())) {
foreach($section->getActions() as $action){
$this->propagate($action);
$resolver = new ActionResolver($action->getUrl());
if(!FuncProxy::accessPossible($user, $resolver->getController(), $resolver->getAction())){
$section->removeAction($action);
}
}
$sections[] = $section;
}
}
}
return $sections;
} | php | private function getSections($shownExtension, $shownStructure)
{
$sections = array();
$user = $this->getSession()->getUser();
$structure = MenuService::getPerspective($shownExtension, $shownStructure);
if (!is_null($structure)) {
foreach ($structure->getChildren() as $section) {
$resolver = new ActionResolver($section->getUrl());
if (FuncProxy::accessPossible($user, $resolver->getController(), $resolver->getAction())) {
foreach($section->getActions() as $action){
$this->propagate($action);
$resolver = new ActionResolver($action->getUrl());
if(!FuncProxy::accessPossible($user, $resolver->getController(), $resolver->getAction())){
$section->removeAction($action);
}
}
$sections[] = $section;
}
}
}
return $sections;
} | [
"private",
"function",
"getSections",
"(",
"$",
"shownExtension",
",",
"$",
"shownStructure",
")",
"{",
"$",
"sections",
"=",
"array",
"(",
")",
";",
"$",
"user",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"getUser",
"(",
")",
";",
"$",
"s... | Get the sections of the current extension's structure
@param string $shownExtension
@param string $shownStructure
@return array the sections | [
"Get",
"the",
"sections",
"of",
"the",
"current",
"extension",
"s",
"structure"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.Main.php#L431-L458 |
oat-sa/tao-core | helpers/data/class.CsvFile.php | tao_helpers_data_CsvFile.load | public function load($source)
{
if ($source instanceof File) {
$resource = $source->readStream();
} else {
if (!is_file($source)) {
throw new InvalidArgumentException("Expected CSV file '" . $source . "' could not be open.");
}
if (!is_readable($source)) {
throw new InvalidArgumentException("CSV file '" . $source . "' is not readable.");
}
$resource = fopen($source, 'r');
}
// More readable variables
$enclosure = preg_quote($this->options['field_encloser'], '/');
$delimiter = $this->options['field_delimiter'];
$multiValueSeparator = $this->options['multi_values_delimiter'];
$adle = ini_get('auto_detect_line_endings');
ini_set('auto_detect_line_endings', true);
if ($this->options['first_row_column_names']) {
$fields = fgetcsv($resource, 0, $delimiter, $enclosure);
$this->setColumnMapping($fields);
}
$data = array();
while (($rowFields = fgetcsv($resource, 0, $delimiter, $enclosure)) !== false) {
$lineData = [];
foreach ($rowFields as $fieldData) {
// If there is nothing in the cell, replace by null for abstraction consistency.
if ($fieldData == '') {
$fieldData = null;
} elseif (!empty($multiValueSeparator) && mb_strpos($fieldData, $multiValueSeparator) !== false) {
// try to split by multi_value_delimiter
$multiField = [];
foreach (explode($multiValueSeparator, $fieldData) as $item) {
if (!empty($item)) {
$multiField[] = $item;
}
}
$fieldData = $multiField;
}
$lineData[] = $fieldData;
}
$data[] = $lineData;
// Update the column count.
$currentRowColumnCount = count($rowFields);
if ($this->getColumnCount() < $currentRowColumnCount) {
$this->setColumnCount($currentRowColumnCount);
}
}
ini_set('auto_detect_line_endings', $adle);
fclose($resource);
$this->setData($data);
} | php | public function load($source)
{
if ($source instanceof File) {
$resource = $source->readStream();
} else {
if (!is_file($source)) {
throw new InvalidArgumentException("Expected CSV file '" . $source . "' could not be open.");
}
if (!is_readable($source)) {
throw new InvalidArgumentException("CSV file '" . $source . "' is not readable.");
}
$resource = fopen($source, 'r');
}
// More readable variables
$enclosure = preg_quote($this->options['field_encloser'], '/');
$delimiter = $this->options['field_delimiter'];
$multiValueSeparator = $this->options['multi_values_delimiter'];
$adle = ini_get('auto_detect_line_endings');
ini_set('auto_detect_line_endings', true);
if ($this->options['first_row_column_names']) {
$fields = fgetcsv($resource, 0, $delimiter, $enclosure);
$this->setColumnMapping($fields);
}
$data = array();
while (($rowFields = fgetcsv($resource, 0, $delimiter, $enclosure)) !== false) {
$lineData = [];
foreach ($rowFields as $fieldData) {
// If there is nothing in the cell, replace by null for abstraction consistency.
if ($fieldData == '') {
$fieldData = null;
} elseif (!empty($multiValueSeparator) && mb_strpos($fieldData, $multiValueSeparator) !== false) {
// try to split by multi_value_delimiter
$multiField = [];
foreach (explode($multiValueSeparator, $fieldData) as $item) {
if (!empty($item)) {
$multiField[] = $item;
}
}
$fieldData = $multiField;
}
$lineData[] = $fieldData;
}
$data[] = $lineData;
// Update the column count.
$currentRowColumnCount = count($rowFields);
if ($this->getColumnCount() < $currentRowColumnCount) {
$this->setColumnCount($currentRowColumnCount);
}
}
ini_set('auto_detect_line_endings', $adle);
fclose($resource);
$this->setData($data);
} | [
"public",
"function",
"load",
"(",
"$",
"source",
")",
"{",
"if",
"(",
"$",
"source",
"instanceof",
"File",
")",
"{",
"$",
"resource",
"=",
"$",
"source",
"->",
"readStream",
"(",
")",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"... | Load the file and parse csv lines
Extract headers if `first_row_column_names` is in $this->options
@access public
@author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
@param string $source
@return void | [
"Load",
"the",
"file",
"and",
"parse",
"csv",
"lines"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/data/class.CsvFile.php#L161-L219 |
oat-sa/tao-core | helpers/data/class.CsvFile.php | tao_helpers_data_CsvFile.getRow | public function getRow($index, $associative = false)
{
$data = $this->getData();
if (isset($data[$index])) {
if ($associative == false) {
$returnValue = $data[$index];
} else {
$mapping = $this->getColumnMapping();
if (!count($mapping)) {
// Trying to access by column name but no mapping detected.
throw new InvalidArgumentException("Cannot access column mapping for this CSV file.");
} else {
$mappedRow = array();
for ($i = 0; $i < count($mapping); $i++) {
$mappedRow[$mapping[$i]] = $data[$index][$i];
}
$returnValue = $mappedRow;
}
}
} else {
throw new InvalidArgumentException("No row at index ${index}.");
}
return (array)$returnValue;
} | php | public function getRow($index, $associative = false)
{
$data = $this->getData();
if (isset($data[$index])) {
if ($associative == false) {
$returnValue = $data[$index];
} else {
$mapping = $this->getColumnMapping();
if (!count($mapping)) {
// Trying to access by column name but no mapping detected.
throw new InvalidArgumentException("Cannot access column mapping for this CSV file.");
} else {
$mappedRow = array();
for ($i = 0; $i < count($mapping); $i++) {
$mappedRow[$mapping[$i]] = $data[$index][$i];
}
$returnValue = $mappedRow;
}
}
} else {
throw new InvalidArgumentException("No row at index ${index}.");
}
return (array)$returnValue;
} | [
"public",
"function",
"getRow",
"(",
"$",
"index",
",",
"$",
"associative",
"=",
"false",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"$",
"index",
"]",
")",
")",
"{",
"if"... | Get a row at a given row $index.
@access public
@author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
@param int index The row index. First = 0.
@param boolean associative Says that if the keys of the array must be the column names or not. If $associative is set to true but there are no column names in the CSV file, an IllegalArgumentException is thrown.
@return array | [
"Get",
"a",
"row",
"at",
"a",
"given",
"row",
"$index",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/data/class.CsvFile.php#L255-L279 |
oat-sa/tao-core | helpers/data/class.CsvFile.php | tao_helpers_data_CsvFile.getValue | public function getValue($row, $col)
{
$returnValue = null;
$data = $this->getData();
if (isset($data[$row][$col])) {
$returnValue = $data[$row][$col];
} else if (isset($data[$row]) && is_string($col)) {
// try to access by col name.
$mapping = $this->getColumnMapping();
for ($i = 0; $i < count($mapping); $i++) {
if ($mapping[$i] == $col && isset($data[$row][$col])) {
// Column with name $col extists.
$returnValue = $data[$row][$col];
}
}
} else {
throw new InvalidArgumentException("No value at ${row},${col}.");
}
return $returnValue;
} | php | public function getValue($row, $col)
{
$returnValue = null;
$data = $this->getData();
if (isset($data[$row][$col])) {
$returnValue = $data[$row][$col];
} else if (isset($data[$row]) && is_string($col)) {
// try to access by col name.
$mapping = $this->getColumnMapping();
for ($i = 0; $i < count($mapping); $i++) {
if ($mapping[$i] == $col && isset($data[$row][$col])) {
// Column with name $col extists.
$returnValue = $data[$row][$col];
}
}
} else {
throw new InvalidArgumentException("No value at ${row},${col}.");
}
return $returnValue;
} | [
"public",
"function",
"getValue",
"(",
"$",
"row",
",",
"$",
"col",
")",
"{",
"$",
"returnValue",
"=",
"null",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"$",
"row",
"]",
"[",
... | Get the value at the specified $row,$col.
@access public
@author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
@param int row Row index. If there is now row at $index, an IllegalArgumentException is thrown.
@param int col
@return mixed | [
"Get",
"the",
"value",
"at",
"the",
"specified",
"$row",
"$col",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/data/class.CsvFile.php#L302-L322 |
oat-sa/tao-core | helpers/data/class.CsvFile.php | tao_helpers_data_CsvFile.setValue | public function setValue($row, $col, $value)
{
$data = $this->getData();
if (isset($data[$row][$col])) {
$this->data[$row][$col] = $value;
} else if (isset($data[$row]) && is_string($col)) {
// try to access by col name.
$mapping = $this->getColumnMapping();
for ($i = 0; $i < count($mapping); $i++) {
if ($mapping[$i] == $col && isset($data[$row][$col])) {
// Column with name $col extists.
$this->data[$row][$col] = $value;
}
}
// Not found.
throw new InvalidArgumentException("Unknown column ${col}");
} else {
throw new InvalidArgumentException("No value at ${row},${col}.");
}
} | php | public function setValue($row, $col, $value)
{
$data = $this->getData();
if (isset($data[$row][$col])) {
$this->data[$row][$col] = $value;
} else if (isset($data[$row]) && is_string($col)) {
// try to access by col name.
$mapping = $this->getColumnMapping();
for ($i = 0; $i < count($mapping); $i++) {
if ($mapping[$i] == $col && isset($data[$row][$col])) {
// Column with name $col extists.
$this->data[$row][$col] = $value;
}
}
// Not found.
throw new InvalidArgumentException("Unknown column ${col}");
} else {
throw new InvalidArgumentException("No value at ${row},${col}.");
}
} | [
"public",
"function",
"setValue",
"(",
"$",
"row",
",",
"$",
"col",
",",
"$",
"value",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"$",
"row",
"]",
"[",
"$",
"col",
"]",
... | Sets a value at the specified $row,$col.
@access public
@author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
@param int row Row Index. If there is no such row, an IllegalArgumentException is thrown.
@param int col
@param int value The value to set at $row,$col.
@return void | [
"Sets",
"a",
"value",
"at",
"the",
"specified",
"$row",
"$col",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/data/class.CsvFile.php#L334-L354 |
oat-sa/tao-core | helpers/form/elements/xhtml/class.Treeview.php | tao_helpers_form_elements_xhtml_Treeview.feed | public function feed()
{
$expression = "/^" . preg_quote($this->name, "/") . "(.)*[0-9]+$/";
$foundIndexes = array();
foreach ($_POST as $key => $value) {
if (preg_match($expression, $key)) {
$foundIndexes[] = $key;
}
}
if ((count($foundIndexes) > 0 && $_POST[$foundIndexes[0]] !== self::NO_TREEVIEW_INTERACTION_IDENTIFIER) || count($foundIndexes) === 0) {
$this->setValues(array());
} elseif ((count($foundIndexes) > 0 && $_POST[$foundIndexes[0]] === self::NO_TREEVIEW_INTERACTION_IDENTIFIER)) {
array_shift($foundIndexes);
}
foreach ($foundIndexes as $index) {
$this->addValue(tao_helpers_Uri::decode($_POST[$index]));
}
} | php | public function feed()
{
$expression = "/^" . preg_quote($this->name, "/") . "(.)*[0-9]+$/";
$foundIndexes = array();
foreach ($_POST as $key => $value) {
if (preg_match($expression, $key)) {
$foundIndexes[] = $key;
}
}
if ((count($foundIndexes) > 0 && $_POST[$foundIndexes[0]] !== self::NO_TREEVIEW_INTERACTION_IDENTIFIER) || count($foundIndexes) === 0) {
$this->setValues(array());
} elseif ((count($foundIndexes) > 0 && $_POST[$foundIndexes[0]] === self::NO_TREEVIEW_INTERACTION_IDENTIFIER)) {
array_shift($foundIndexes);
}
foreach ($foundIndexes as $index) {
$this->addValue(tao_helpers_Uri::decode($_POST[$index]));
}
} | [
"public",
"function",
"feed",
"(",
")",
"{",
"$",
"expression",
"=",
"\"/^\"",
".",
"preg_quote",
"(",
"$",
"this",
"->",
"name",
",",
"\"/\"",
")",
".",
"\"(.)*[0-9]+$/\"",
";",
"$",
"foundIndexes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
... | Short description of method feed
@access public
@author Joel Bout, <joel.bout@tudor.lu>
@return mixed | [
"Short",
"description",
"of",
"method",
"feed"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/elements/xhtml/class.Treeview.php#L44-L63 |
oat-sa/tao-core | helpers/translation/class.TranslationUnit.php | tao_helpers_translation_TranslationUnit.hasSameTranslationUnitSource | public function hasSameTranslationUnitSource( tao_helpers_translation_TranslationUnit $translationUnit)
{
$returnValue = (bool) false;
$returnValue = $this->getSource() == $translationUnit->getSource();
return (bool) $returnValue;
} | php | public function hasSameTranslationUnitSource( tao_helpers_translation_TranslationUnit $translationUnit)
{
$returnValue = (bool) false;
$returnValue = $this->getSource() == $translationUnit->getSource();
return (bool) $returnValue;
} | [
"public",
"function",
"hasSameTranslationUnitSource",
"(",
"tao_helpers_translation_TranslationUnit",
"$",
"translationUnit",
")",
"{",
"$",
"returnValue",
"=",
"(",
"bool",
")",
"false",
";",
"$",
"returnValue",
"=",
"$",
"this",
"->",
"getSource",
"(",
")",
"=="... | Short description of method hasSameTranslationUnitSource
@access public
@author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
@param TranslationUnit translationUnit
@return boolean | [
"Short",
"description",
"of",
"method",
"hasSameTranslationUnitSource"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/translation/class.TranslationUnit.php#L383-L392 |
oat-sa/tao-core | helpers/translation/class.TranslationUnit.php | tao_helpers_translation_TranslationUnit.hasSameTranslationUnitTarget | public function hasSameTranslationUnitTarget( tao_helpers_translation_TranslationUnit $translationUnit)
{
$returnValue = (bool) false;
$returnValue = $this->getTarget() == $translationUnit->getTarget();
return (bool) $returnValue;
} | php | public function hasSameTranslationUnitTarget( tao_helpers_translation_TranslationUnit $translationUnit)
{
$returnValue = (bool) false;
$returnValue = $this->getTarget() == $translationUnit->getTarget();
return (bool) $returnValue;
} | [
"public",
"function",
"hasSameTranslationUnitTarget",
"(",
"tao_helpers_translation_TranslationUnit",
"$",
"translationUnit",
")",
"{",
"$",
"returnValue",
"=",
"(",
"bool",
")",
"false",
";",
"$",
"returnValue",
"=",
"$",
"this",
"->",
"getTarget",
"(",
")",
"=="... | Short description of method hasSameTranslationUnitTarget
@access public
@author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
@param TranslationUnit translationUnit
@return boolean | [
"Short",
"description",
"of",
"method",
"hasSameTranslationUnitTarget"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/translation/class.TranslationUnit.php#L402-L411 |
oat-sa/tao-core | helpers/translation/class.TranslationUnit.php | tao_helpers_translation_TranslationUnit.hasSameTranslationUnitSourceLanguage | public function hasSameTranslationUnitSourceLanguage( tao_helpers_translation_TranslationUnit $translationUnit)
{
$returnValue = (bool) false;
$returnValue = $this->getSourceLanguage() == $translationUnit->getSourceLanguage();
return (bool) $returnValue;
} | php | public function hasSameTranslationUnitSourceLanguage( tao_helpers_translation_TranslationUnit $translationUnit)
{
$returnValue = (bool) false;
$returnValue = $this->getSourceLanguage() == $translationUnit->getSourceLanguage();
return (bool) $returnValue;
} | [
"public",
"function",
"hasSameTranslationUnitSourceLanguage",
"(",
"tao_helpers_translation_TranslationUnit",
"$",
"translationUnit",
")",
"{",
"$",
"returnValue",
"=",
"(",
"bool",
")",
"false",
";",
"$",
"returnValue",
"=",
"$",
"this",
"->",
"getSourceLanguage",
"(... | Checks whether or not a given TranslationUnit has the same source
than the current instance.
@access public
@author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
@param TranslationUnit translationUnit
@return boolean | [
"Checks",
"whether",
"or",
"not",
"a",
"given",
"TranslationUnit",
"has",
"the",
"same",
"source",
"than",
"the",
"current",
"instance",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/translation/class.TranslationUnit.php#L422-L431 |
oat-sa/tao-core | helpers/translation/class.TranslationUnit.php | tao_helpers_translation_TranslationUnit.hasSameTranslationUnitTargetLanguage | public function hasSameTranslationUnitTargetLanguage( tao_helpers_translation_TranslationUnit $translationUnit)
{
$returnValue = (bool) false;
$returnValue = $this->getTargetLanguage() == $translationUnit->getTargetLanguage();
return (bool) $returnValue;
} | php | public function hasSameTranslationUnitTargetLanguage( tao_helpers_translation_TranslationUnit $translationUnit)
{
$returnValue = (bool) false;
$returnValue = $this->getTargetLanguage() == $translationUnit->getTargetLanguage();
return (bool) $returnValue;
} | [
"public",
"function",
"hasSameTranslationUnitTargetLanguage",
"(",
"tao_helpers_translation_TranslationUnit",
"$",
"translationUnit",
")",
"{",
"$",
"returnValue",
"=",
"(",
"bool",
")",
"false",
";",
"$",
"returnValue",
"=",
"$",
"this",
"->",
"getTargetLanguage",
"(... | Checks whether or not a given TranslationUnit has the same target
than the current instance.
@access public
@author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
@param TranslationUnit translationUnit
@return boolean | [
"Checks",
"whether",
"or",
"not",
"a",
"given",
"TranslationUnit",
"has",
"the",
"same",
"target",
"than",
"the",
"current",
"instance",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/translation/class.TranslationUnit.php#L442-L451 |
oat-sa/tao-core | models/classes/service/ApplicationService.php | ApplicationService.getConstantValue | private function getConstantValue($constantName)
{
$serviceLocator = $this->getServiceLocator();
if (!$serviceLocator instanceof ServiceLocatorInterface) {
throw new common_exception_Error();
}
return $serviceLocator->get(common_ext_ExtensionsManager::SERVICE_ID)
->getExtensionById('tao')
->getConstant($constantName);
} | php | private function getConstantValue($constantName)
{
$serviceLocator = $this->getServiceLocator();
if (!$serviceLocator instanceof ServiceLocatorInterface) {
throw new common_exception_Error();
}
return $serviceLocator->get(common_ext_ExtensionsManager::SERVICE_ID)
->getExtensionById('tao')
->getConstant($constantName);
} | [
"private",
"function",
"getConstantValue",
"(",
"$",
"constantName",
")",
"{",
"$",
"serviceLocator",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
";",
"if",
"(",
"!",
"$",
"serviceLocator",
"instanceof",
"ServiceLocatorInterface",
")",
"{",
"throw",
... | @param string $constantName
@return string
@throws \common_exception_Error
@throws \common_ext_ExtensionException | [
"@param",
"string",
"$constantName",
"@return",
"string"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/service/ApplicationService.php#L105-L115 |
oat-sa/tao-core | helpers/Layout.php | Layout.getReleaseMsgData | public static function getReleaseMsgData(){
$params = array(
'version-type' => '',
'is-unstable' => self::isUnstable(),
'is-sandbox' => false,
'logo' => self::getLogoUrl(),
'link' => self::getLinkUrl(),
'msg' => self::getMessage()
);
switch(TAO_RELEASE_STATUS){
case 'alpha':
case 'demoA':
$params['version-type'] = __('Alpha version');
break;
case 'beta':
case 'demoB':
$params['version-type'] = __('Beta version');
break;
case 'demoS':
$params['version-type'] = __('Demo Sandbox');
$params['is-sandbox'] = true;
$params['msg'] = self::getSandboxExpiration();
break;
}
return $params;
} | php | public static function getReleaseMsgData(){
$params = array(
'version-type' => '',
'is-unstable' => self::isUnstable(),
'is-sandbox' => false,
'logo' => self::getLogoUrl(),
'link' => self::getLinkUrl(),
'msg' => self::getMessage()
);
switch(TAO_RELEASE_STATUS){
case 'alpha':
case 'demoA':
$params['version-type'] = __('Alpha version');
break;
case 'beta':
case 'demoB':
$params['version-type'] = __('Beta version');
break;
case 'demoS':
$params['version-type'] = __('Demo Sandbox');
$params['is-sandbox'] = true;
$params['msg'] = self::getSandboxExpiration();
break;
}
return $params;
} | [
"public",
"static",
"function",
"getReleaseMsgData",
"(",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"'version-type'",
"=>",
"''",
",",
"'is-unstable'",
"=>",
"self",
"::",
"isUnstable",
"(",
")",
",",
"'is-sandbox'",
"=>",
"false",
",",
"'logo'",
"=>",
"... | Compute the parameters for the release message
@return array | [
"Compute",
"the",
"parameters",
"for",
"the",
"release",
"message"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/Layout.php#L42-L71 |
oat-sa/tao-core | helpers/Layout.php | Layout.getSandboxExpiration | public static function getSandboxExpiration(){
$datetime = new \DateTime();
$d = new \DateTime($datetime->format('Y-m-d'));
$weekday = $d->format('w');
$weekNumber = $d->format('W');
$diff = $weekNumber % 2 ? 7 : 6 - $weekday;
$d->modify(sprintf('+ %d day', $diff));
return \tao_helpers_Date::displayInterval($d, \tao_helpers_Date::FORMAT_INTERVAL_LONG);
} | php | public static function getSandboxExpiration(){
$datetime = new \DateTime();
$d = new \DateTime($datetime->format('Y-m-d'));
$weekday = $d->format('w');
$weekNumber = $d->format('W');
$diff = $weekNumber % 2 ? 7 : 6 - $weekday;
$d->modify(sprintf('+ %d day', $diff));
return \tao_helpers_Date::displayInterval($d, \tao_helpers_Date::FORMAT_INTERVAL_LONG);
} | [
"public",
"static",
"function",
"getSandboxExpiration",
"(",
")",
"{",
"$",
"datetime",
"=",
"new",
"\\",
"DateTime",
"(",
")",
";",
"$",
"d",
"=",
"new",
"\\",
"DateTime",
"(",
"$",
"datetime",
"->",
"format",
"(",
"'Y-m-d'",
")",
")",
";",
"$",
"we... | Compute the expiration time for the sandbox version
@return string | [
"Compute",
"the",
"expiration",
"time",
"for",
"the",
"sandbox",
"version"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/Layout.php#L79-L87 |
oat-sa/tao-core | helpers/Layout.php | Layout.renderIcon | public static function renderIcon($icon, $defaultIcon) {
$srcExt = '';
$isBase64 = false;
$iconClass = $defaultIcon;
if(!is_null($icon)){
if($icon->getSource()) {
$imgXts = 'png|jpg|jpe|jpeg|gif|svg';
$regExp = sprintf('~((^data:image/(%s))|(\.(%s)$))~', $imgXts, $imgXts);
$srcExt = preg_match($regExp, $icon->getSource(), $matches) ? array_pop($matches) : array();
$isBase64 = 0 === strpos($icon->getSource(), 'data:image');
}
$iconClass = $icon->getId() ? $icon->getId() : $defaultIcon;
}
// clarification icon vs. glyph: same thing but due to certain CSS rules a second class is required
switch($srcExt) {
case 'png':
case 'jpg':
case 'jpe':
case 'jpeg':
case 'gif':
return $isBase64
? '<img src="' . $icon->getSource() . '" alt="" class="glyph" />'
: '<img src="' . Template::img($icon->getSource(), $icon->getExtension()) . '" alt="" class="glyph" />';
break;
case 'svg':
return sprintf(
'<svg class="svg-glyph"><use xlink:href="%s#%s"/></svg>',
Template::img($icon->getSource(), $icon->getExtension()),
$icon->getId()
);
case ''; // no source means an icon font is used
return sprintf('<span class="%s glyph"></span>', $iconClass);
}
} | php | public static function renderIcon($icon, $defaultIcon) {
$srcExt = '';
$isBase64 = false;
$iconClass = $defaultIcon;
if(!is_null($icon)){
if($icon->getSource()) {
$imgXts = 'png|jpg|jpe|jpeg|gif|svg';
$regExp = sprintf('~((^data:image/(%s))|(\.(%s)$))~', $imgXts, $imgXts);
$srcExt = preg_match($regExp, $icon->getSource(), $matches) ? array_pop($matches) : array();
$isBase64 = 0 === strpos($icon->getSource(), 'data:image');
}
$iconClass = $icon->getId() ? $icon->getId() : $defaultIcon;
}
// clarification icon vs. glyph: same thing but due to certain CSS rules a second class is required
switch($srcExt) {
case 'png':
case 'jpg':
case 'jpe':
case 'jpeg':
case 'gif':
return $isBase64
? '<img src="' . $icon->getSource() . '" alt="" class="glyph" />'
: '<img src="' . Template::img($icon->getSource(), $icon->getExtension()) . '" alt="" class="glyph" />';
break;
case 'svg':
return sprintf(
'<svg class="svg-glyph"><use xlink:href="%s#%s"/></svg>',
Template::img($icon->getSource(), $icon->getExtension()),
$icon->getId()
);
case ''; // no source means an icon font is used
return sprintf('<span class="%s glyph"></span>', $iconClass);
}
} | [
"public",
"static",
"function",
"renderIcon",
"(",
"$",
"icon",
",",
"$",
"defaultIcon",
")",
"{",
"$",
"srcExt",
"=",
"''",
";",
"$",
"isBase64",
"=",
"false",
";",
"$",
"iconClass",
"=",
"$",
"defaultIcon",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",... | $icon defined in oat\tao\model\menu\Perspective::fromSimpleXMLElement
$icon has two methods, getSource() and getId().
There are three possible ways to include icons, either as font, img or svg (not yet supported).
- Font uses source to address the style sheet (TAO font as default) and id to build the class name
- Img uses source only
- Svg uses source to address an SVG sprite and id to point to the right icon in there
@param Icon $icon
@param string $defaultIcon e.g. icon-extension | icon-action
@return string icon as html | [
"$icon",
"defined",
"in",
"oat",
"\\",
"tao",
"\\",
"model",
"\\",
"menu",
"\\",
"Perspective",
"::",
"fromSimpleXMLElement"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/Layout.php#L102-L140 |
oat-sa/tao-core | helpers/Layout.php | Layout.getAmdLoader | public static function getAmdLoader($bundle = null, $controller = null, $params = null, $allowAnonymous = false){
$bundleMode = \tao_helpers_Mode::is('production');
$configUrl = get_data('client_config_url');
$requireJsUrl = Template::js('lib/require.js', 'tao');
$bootstrapUrl = Template::js('loader/bootstrap.js', 'tao');
$loader = new AmdLoader($configUrl, $requireJsUrl, $bootstrapUrl);
if(\common_session_SessionManager::isAnonymous() && !$allowAnonymous) {
$controller = 'controller/login';
$bundle = Template::js('loader/login.min.js', 'tao');
}
if($bundleMode){
return "<script src='" . Template::js('loader/vendor.min.js', 'tao') . "'></script>\n" .
$loader->getBundleLoader($bundle, $controller, $params);
}
return $loader->getDynamicLoader($controller, $params);
} | php | public static function getAmdLoader($bundle = null, $controller = null, $params = null, $allowAnonymous = false){
$bundleMode = \tao_helpers_Mode::is('production');
$configUrl = get_data('client_config_url');
$requireJsUrl = Template::js('lib/require.js', 'tao');
$bootstrapUrl = Template::js('loader/bootstrap.js', 'tao');
$loader = new AmdLoader($configUrl, $requireJsUrl, $bootstrapUrl);
if(\common_session_SessionManager::isAnonymous() && !$allowAnonymous) {
$controller = 'controller/login';
$bundle = Template::js('loader/login.min.js', 'tao');
}
if($bundleMode){
return "<script src='" . Template::js('loader/vendor.min.js', 'tao') . "'></script>\n" .
$loader->getBundleLoader($bundle, $controller, $params);
}
return $loader->getDynamicLoader($controller, $params);
} | [
"public",
"static",
"function",
"getAmdLoader",
"(",
"$",
"bundle",
"=",
"null",
",",
"$",
"controller",
"=",
"null",
",",
"$",
"params",
"=",
"null",
",",
"$",
"allowAnonymous",
"=",
"false",
")",
"{",
"$",
"bundleMode",
"=",
"\\",
"tao_helpers_Mode",
"... | Create the AMD loader for the current context.
It will load login's modules for anonymous session.
Loads the bundle mode in production and the dynamic mode in debug.
@param string $bundle the bundle URL
@param string $controller the controller module id
@param array $params additional parameters
@return string the script tag | [
"Create",
"the",
"AMD",
"loader",
"for",
"the",
"current",
"context",
".",
"It",
"will",
"load",
"login",
"s",
"modules",
"for",
"anonymous",
"session",
".",
"Loads",
"the",
"bundle",
"mode",
"in",
"production",
"and",
"the",
"dynamic",
"mode",
"in",
"debu... | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/Layout.php#L152-L172 |
oat-sa/tao-core | helpers/Layout.php | Layout.getContentTemplate | public static function getContentTemplate() {
$templateData = (array)get_data('content-template');
$contentExtension = get_data('content-extension');
$contentTemplate['path'] = $templateData[0];
$contentTemplate['ext'] = isset($templateData[1])
? $templateData[1]
: ($contentExtension ? $contentExtension : 'tao');
return $contentTemplate;
} | php | public static function getContentTemplate() {
$templateData = (array)get_data('content-template');
$contentExtension = get_data('content-extension');
$contentTemplate['path'] = $templateData[0];
$contentTemplate['ext'] = isset($templateData[1])
? $templateData[1]
: ($contentExtension ? $contentExtension : 'tao');
return $contentTemplate;
} | [
"public",
"static",
"function",
"getContentTemplate",
"(",
")",
"{",
"$",
"templateData",
"=",
"(",
"array",
")",
"get_data",
"(",
"'content-template'",
")",
";",
"$",
"contentExtension",
"=",
"get_data",
"(",
"'content-extension'",
")",
";",
"$",
"contentTempla... | Retrieve the template with the actual content
@return array | [
"Retrieve",
"the",
"template",
"with",
"the",
"actual",
"content"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/Layout.php#L198-L206 |
oat-sa/tao-core | helpers/Layout.php | Layout.getLogoUrl | public static function getLogoUrl()
{
$theme = self::getCurrentTheme();
if (
$theme instanceof ConfigurableTheme ||
$theme instanceof ConfigurablePlatformTheme
) {
$logoFile = $theme->getLogoUrl();
if (! empty($logoFile)) {
return $logoFile;
}
}
return static::getDefaultLogoUrl();
} | php | public static function getLogoUrl()
{
$theme = self::getCurrentTheme();
if (
$theme instanceof ConfigurableTheme ||
$theme instanceof ConfigurablePlatformTheme
) {
$logoFile = $theme->getLogoUrl();
if (! empty($logoFile)) {
return $logoFile;
}
}
return static::getDefaultLogoUrl();
} | [
"public",
"static",
"function",
"getLogoUrl",
"(",
")",
"{",
"$",
"theme",
"=",
"self",
"::",
"getCurrentTheme",
"(",
")",
";",
"if",
"(",
"$",
"theme",
"instanceof",
"ConfigurableTheme",
"||",
"$",
"theme",
"instanceof",
"ConfigurablePlatformTheme",
")",
"{",... | Get the logo URL.
In case of non configurable theme, logo can be changed following on platform readiness
@return string The absolute URL to the logo image. | [
"Get",
"the",
"logo",
"URL",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/Layout.php#L215-L229 |
oat-sa/tao-core | helpers/Layout.php | Layout.getLinkUrl | public static function getLinkUrl()
{
$theme = self::getCurrentTheme();
if (
$theme instanceof ConfigurableTheme ||
$theme instanceof ConfigurablePlatformTheme
) {
$link = $theme->getLink();
if (! empty($link)) {
return $link;
}
}
//move this into the standard template setData()
switch (TAO_RELEASE_STATUS) {
case 'alpha':
case 'demoA':
case 'beta':
case 'demoB':
$link = 'https://forum.taocloud.org/';
break;
default:
$link = 'http://taotesting.com';
break;
}
return $link;
} | php | public static function getLinkUrl()
{
$theme = self::getCurrentTheme();
if (
$theme instanceof ConfigurableTheme ||
$theme instanceof ConfigurablePlatformTheme
) {
$link = $theme->getLink();
if (! empty($link)) {
return $link;
}
}
//move this into the standard template setData()
switch (TAO_RELEASE_STATUS) {
case 'alpha':
case 'demoA':
case 'beta':
case 'demoB':
$link = 'https://forum.taocloud.org/';
break;
default:
$link = 'http://taotesting.com';
break;
}
return $link;
} | [
"public",
"static",
"function",
"getLinkUrl",
"(",
")",
"{",
"$",
"theme",
"=",
"self",
"::",
"getCurrentTheme",
"(",
")",
";",
"if",
"(",
"$",
"theme",
"instanceof",
"ConfigurableTheme",
"||",
"$",
"theme",
"instanceof",
"ConfigurablePlatformTheme",
")",
"{",... | Get the url link of current theme
Url is used into header, to provide link to logo
Url is used into footer, to provide link to footer message
In case of non configurable theme, link can be changed following on platform readiness
@return string | [
"Get",
"the",
"url",
"link",
"of",
"current",
"theme",
"Url",
"is",
"used",
"into",
"header",
"to",
"provide",
"link",
"to",
"logo",
"Url",
"is",
"used",
"into",
"footer",
"to",
"provide",
"link",
"to",
"footer",
"message"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/Layout.php#L281-L309 |
oat-sa/tao-core | helpers/Layout.php | Layout.getMessage | public static function getMessage()
{
$theme = self::getCurrentTheme();
if (
$theme instanceof ConfigurableTheme ||
$theme instanceof ConfigurablePlatformTheme
) {
$message = $theme->getMessage();
if (! empty($message)) {
return $message;
}
}
switch (TAO_RELEASE_STATUS) {
case 'alpha':
case 'demoA':
case 'beta':
case 'demoB':
$message = __('Please report bugs, ideas, comments or feedback on the TAO Forum');
break;
default:
$message = '';
break;
}
return $message;
} | php | public static function getMessage()
{
$theme = self::getCurrentTheme();
if (
$theme instanceof ConfigurableTheme ||
$theme instanceof ConfigurablePlatformTheme
) {
$message = $theme->getMessage();
if (! empty($message)) {
return $message;
}
}
switch (TAO_RELEASE_STATUS) {
case 'alpha':
case 'demoA':
case 'beta':
case 'demoB':
$message = __('Please report bugs, ideas, comments or feedback on the TAO Forum');
break;
default:
$message = '';
break;
}
return $message;
} | [
"public",
"static",
"function",
"getMessage",
"(",
")",
"{",
"$",
"theme",
"=",
"self",
"::",
"getCurrentTheme",
"(",
")",
";",
"if",
"(",
"$",
"theme",
"instanceof",
"ConfigurableTheme",
"||",
"$",
"theme",
"instanceof",
"ConfigurablePlatformTheme",
")",
"{",... | Get the message of current theme
Message is used into header, to provide title to logo
Message is used into footer, as footer message
In case of non configurable theme, message can be changed following on platform readiness
@return string | [
"Get",
"the",
"message",
"of",
"current",
"theme",
"Message",
"is",
"used",
"into",
"header",
"to",
"provide",
"title",
"to",
"logo",
"Message",
"is",
"used",
"into",
"footer",
"as",
"footer",
"message"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/Layout.php#L320-L346 |
oat-sa/tao-core | helpers/Layout.php | Layout.getOperatedByData | public static function getOperatedByData() {
$name = '';
$email = '';
// find data in the theme, they will be there if installed with the taoStyles extension
$theme = self::getCurrentTheme();
if ($theme instanceof ConfigurablePlatformTheme) {
$operatedBy = $theme->getOperatedBy();
$name = $operatedBy['name'];
$email = $operatedBy['email'];
}
// otherwise they will be stored in config
if(!$name && !$email) {
$operatedByService = ServiceManager::getServiceManager()->get(OperatedByService::SERVICE_ID);
$name = $operatedByService->getName();
$email = $operatedByService->getEmail();
}
$data = [
'name' => $name,
'email' => empty($email)
? ''
: StringUtils::encodeText('mailto:' . $email)
];
return $data;
} | php | public static function getOperatedByData() {
$name = '';
$email = '';
// find data in the theme, they will be there if installed with the taoStyles extension
$theme = self::getCurrentTheme();
if ($theme instanceof ConfigurablePlatformTheme) {
$operatedBy = $theme->getOperatedBy();
$name = $operatedBy['name'];
$email = $operatedBy['email'];
}
// otherwise they will be stored in config
if(!$name && !$email) {
$operatedByService = ServiceManager::getServiceManager()->get(OperatedByService::SERVICE_ID);
$name = $operatedByService->getName();
$email = $operatedByService->getEmail();
}
$data = [
'name' => $name,
'email' => empty($email)
? ''
: StringUtils::encodeText('mailto:' . $email)
];
return $data;
} | [
"public",
"static",
"function",
"getOperatedByData",
"(",
")",
"{",
"$",
"name",
"=",
"''",
";",
"$",
"email",
"=",
"''",
";",
"// find data in the theme, they will be there if installed with the taoStyles extension",
"$",
"theme",
"=",
"self",
"::",
"getCurrentTheme",
... | Get the currently registered OperatedBy data
@return array | [
"Get",
"the",
"currently",
"registered",
"OperatedBy",
"data"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/Layout.php#L352-L380 |
oat-sa/tao-core | helpers/Layout.php | Layout.getVerboseVersionName | public static function getVerboseVersionName() {
preg_match('~(?<revision>([\d\.]+))([\W_]?(?<specifics>(.*)?))~', trim(TAO_VERSION), $components);
if(empty($components['revision'])) {
return TAO_VERSION;
}
$version = '';
if(!empty($components['specifics'])) {
$version .= ucwords($components['specifics']) . ' rev ';
}
$version .= ucwords($components['revision']);
return $version;
} | php | public static function getVerboseVersionName() {
preg_match('~(?<revision>([\d\.]+))([\W_]?(?<specifics>(.*)?))~', trim(TAO_VERSION), $components);
if(empty($components['revision'])) {
return TAO_VERSION;
}
$version = '';
if(!empty($components['specifics'])) {
$version .= ucwords($components['specifics']) . ' rev ';
}
$version .= ucwords($components['revision']);
return $version;
} | [
"public",
"static",
"function",
"getVerboseVersionName",
"(",
")",
"{",
"preg_match",
"(",
"'~(?<revision>([\\d\\.]+))([\\W_]?(?<specifics>(.*)?))~'",
",",
"trim",
"(",
"TAO_VERSION",
")",
",",
"$",
"components",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"components",... | Turn TAO_VERSION in a more verbose form.
If TAO_VERSION diverges too much from the usual patterns TAO_VERSION will be returned unaltered.
Examples (TAO_VERSION => return value):
3.2.0-sprint52 => Sprint52 rev 3.2.0
v3.2.0-sprint52 => Sprint52 rev 3.2.0
3.2.0sprint52 => Sprint52 rev 3.2.0
3.2.0 => 3.2.0
3.2 => 3.2
3.2 0 => 3.2
pattern w/o numbers => pattern w/o numbers
@return string | [
"Turn",
"TAO_VERSION",
"in",
"a",
"more",
"verbose",
"form",
".",
"If",
"TAO_VERSION",
"diverges",
"too",
"much",
"from",
"the",
"usual",
"patterns",
"TAO_VERSION",
"will",
"be",
"returned",
"unaltered",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/Layout.php#L409-L420 |
oat-sa/tao-core | helpers/Layout.php | Layout.renderThemeTemplate | public static function renderThemeTemplate($target, $templateId, $data = array()){
//search in the registry to get the custom template to render
$tpl = self::getThemeTemplate($target, $templateId);
$theme = self::getCurrentTheme();
if(!is_null($tpl)){
if ($theme instanceof ConfigurablePlatformTheme) {
// allow to use the getters from ConfigurablePlatformTheme
// to insert logo and such
$data['themeObj'] = $theme;
}
//render the template
$renderer = new \Renderer($tpl, $data);
return $renderer->render();
}
return '';
} | php | public static function renderThemeTemplate($target, $templateId, $data = array()){
//search in the registry to get the custom template to render
$tpl = self::getThemeTemplate($target, $templateId);
$theme = self::getCurrentTheme();
if(!is_null($tpl)){
if ($theme instanceof ConfigurablePlatformTheme) {
// allow to use the getters from ConfigurablePlatformTheme
// to insert logo and such
$data['themeObj'] = $theme;
}
//render the template
$renderer = new \Renderer($tpl, $data);
return $renderer->render();
}
return '';
} | [
"public",
"static",
"function",
"renderThemeTemplate",
"(",
"$",
"target",
",",
"$",
"templateId",
",",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"//search in the registry to get the custom template to render",
"$",
"tpl",
"=",
"self",
"::",
"getThemeTemplate",... | Render a themable template identified by its id
@param string $templateId
@param array $data
@return string | [
"Render",
"a",
"themable",
"template",
"identified",
"by",
"its",
"id"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/Layout.php#L465-L482 |
oat-sa/tao-core | models/classes/datatable/implementation/AbstractDatatablePayload.php | AbstractDatatablePayload.getPayload | public function getPayload()
{
$queryBuilder = $this->getSearchService()->query();
$this->doFiltration($queryBuilder);
$this->doPagination($queryBuilder);
$this->doSorting($queryBuilder);
$searchResult = $this->doSearch($queryBuilder);
$result = $this->doPostProcessing($searchResult);
return $result;
} | php | public function getPayload()
{
$queryBuilder = $this->getSearchService()->query();
$this->doFiltration($queryBuilder);
$this->doPagination($queryBuilder);
$this->doSorting($queryBuilder);
$searchResult = $this->doSearch($queryBuilder);
$result = $this->doPostProcessing($searchResult);
return $result;
} | [
"public",
"function",
"getPayload",
"(",
")",
"{",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"getSearchService",
"(",
")",
"->",
"query",
"(",
")",
";",
"$",
"this",
"->",
"doFiltration",
"(",
"$",
"queryBuilder",
")",
";",
"$",
"this",
"->",
"doPag... | Template method to find data.
Any step (such as filtration, pagination, sorting e.t.c. can be changed in concrete class). | [
"Template",
"method",
"to",
"find",
"data",
".",
"Any",
"step",
"(",
"such",
"as",
"filtration",
"pagination",
"sorting",
"e",
".",
"t",
".",
"c",
".",
"can",
"be",
"changed",
"in",
"concrete",
"class",
")",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/datatable/implementation/AbstractDatatablePayload.php#L86-L97 |
oat-sa/tao-core | models/classes/datatable/implementation/AbstractDatatablePayload.php | AbstractDatatablePayload.doFiltration | protected function doFiltration(QueryBuilderInterface $queryBuilder)
{
$search = $this->getSearchService();
$filters = $this->map($this->getFilters(), true);
$query = $search->searchType($queryBuilder, $this->getType(), true);
foreach ($filters as $filterProp => $filterVal) {
foreach ($filterVal as $values) {
if (is_array($values)) {
$query->addCriterion($filterProp, SupportedOperatorHelper::IN, $values);
} elseif (is_string($values)) {
$query->addCriterion($filterProp, SupportedOperatorHelper::CONTAIN, $values);
}
}
}
$queryBuilder->setCriteria($query);
} | php | protected function doFiltration(QueryBuilderInterface $queryBuilder)
{
$search = $this->getSearchService();
$filters = $this->map($this->getFilters(), true);
$query = $search->searchType($queryBuilder, $this->getType(), true);
foreach ($filters as $filterProp => $filterVal) {
foreach ($filterVal as $values) {
if (is_array($values)) {
$query->addCriterion($filterProp, SupportedOperatorHelper::IN, $values);
} elseif (is_string($values)) {
$query->addCriterion($filterProp, SupportedOperatorHelper::CONTAIN, $values);
}
}
}
$queryBuilder->setCriteria($query);
} | [
"protected",
"function",
"doFiltration",
"(",
"QueryBuilderInterface",
"$",
"queryBuilder",
")",
"{",
"$",
"search",
"=",
"$",
"this",
"->",
"getSearchService",
"(",
")",
";",
"$",
"filters",
"=",
"$",
"this",
"->",
"map",
"(",
"$",
"this",
"->",
"getFilte... | Apply filters to search query
@param QueryBuilderInterface $queryBuilder | [
"Apply",
"filters",
"to",
"search",
"query"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/datatable/implementation/AbstractDatatablePayload.php#L111-L129 |
oat-sa/tao-core | models/classes/datatable/implementation/AbstractDatatablePayload.php | AbstractDatatablePayload.map | protected function map($filter, $multitask = false)
{
$data = [];
$map = $this->getPropertiesMap();
foreach ($filter as $key => $val) {
$key = isset($map[$key]) ? $map[$key] : $key;
if ($multitask) {
if (!is_array($val)) {
$data[$key] = [$val];
} else {
$data[$key][] = array_unique($val);
}
} else {
$data[$key] = $val;
}
}
return $data;
} | php | protected function map($filter, $multitask = false)
{
$data = [];
$map = $this->getPropertiesMap();
foreach ($filter as $key => $val) {
$key = isset($map[$key]) ? $map[$key] : $key;
if ($multitask) {
if (!is_array($val)) {
$data[$key] = [$val];
} else {
$data[$key][] = array_unique($val);
}
} else {
$data[$key] = $val;
}
}
return $data;
} | [
"protected",
"function",
"map",
"(",
"$",
"filter",
",",
"$",
"multitask",
"=",
"false",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"map",
"=",
"$",
"this",
"->",
"getPropertiesMap",
"(",
")",
";",
"foreach",
"(",
"$",
"filter",
"as",
"$",
"... | Convert array keys specified in the CSV file to keys which are used in the TAO.
If $reverse is `true` reverse conversion will be performed.
Example:
```php
$studentCsvMapper->map(['fname' => 'john']);
// ['http://www.tao.lu/Ontologies/generis.rdf#userFirstName' => 'john']
```
@param array $filter
@param bool|string $multitask will return all filters as [[filter1], [filter2]]
@return array | [
"Convert",
"array",
"keys",
"specified",
"in",
"the",
"CSV",
"file",
"to",
"keys",
"which",
"are",
"used",
"in",
"the",
"TAO",
".",
"If",
"$reverse",
"is",
"true",
"reverse",
"conversion",
"will",
"be",
"performed",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/datatable/implementation/AbstractDatatablePayload.php#L235-L255 |
oat-sa/tao-core | models/classes/datatable/implementation/AbstractDatatablePayload.php | AbstractDatatablePayload.fetchPropertyValues | protected function fetchPropertyValues($payload)
{
$propertyMap = $this->getPropertiesMap();
$data = [];
foreach ($payload['data'] as $resource) {
$resource = (object)$resource;
$resource = new \core_kernel_classes_Resource($resource->subject);
$resourceData = $resource->getPropertiesValues($propertyMap);
$entityInfo = array_map(function($row) use($resourceData) {
$stringData = array_map(function($value){
return ($value instanceof \core_kernel_classes_Resource) ? $value->getUri() : (string) $value;
}, $resourceData[$row]);
return join(',', $stringData);
}, $propertyMap);
$entityInfo['uri'] = $resource->getUri();
$entityInfo['id'] = \tao_helpers_Uri::encode($resource->getUri());
$data[] = $entityInfo;
}
$payload['data'] = $data;
return $payload;
} | php | protected function fetchPropertyValues($payload)
{
$propertyMap = $this->getPropertiesMap();
$data = [];
foreach ($payload['data'] as $resource) {
$resource = (object)$resource;
$resource = new \core_kernel_classes_Resource($resource->subject);
$resourceData = $resource->getPropertiesValues($propertyMap);
$entityInfo = array_map(function($row) use($resourceData) {
$stringData = array_map(function($value){
return ($value instanceof \core_kernel_classes_Resource) ? $value->getUri() : (string) $value;
}, $resourceData[$row]);
return join(',', $stringData);
}, $propertyMap);
$entityInfo['uri'] = $resource->getUri();
$entityInfo['id'] = \tao_helpers_Uri::encode($resource->getUri());
$data[] = $entityInfo;
}
$payload['data'] = $data;
return $payload;
} | [
"protected",
"function",
"fetchPropertyValues",
"(",
"$",
"payload",
")",
"{",
"$",
"propertyMap",
"=",
"$",
"this",
"->",
"getPropertiesMap",
"(",
")",
";",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"payload",
"[",
"'data'",
"]",
"as",
"$"... | Fetch all the values of properties listed in properties map
@param $payload
@return mixed
@throws \common_exception_InvalidArgumentType | [
"Fetch",
"all",
"the",
"values",
"of",
"properties",
"listed",
"in",
"properties",
"map"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/datatable/implementation/AbstractDatatablePayload.php#L265-L287 |
oat-sa/tao-core | helpers/InstallHelper.php | InstallHelper.installRecursively | public static function installRecursively($extensionIDs, $installData=array())
{
try {
return parent::installRecursively($extensionIDs, $installData);
} catch (\common_ext_ExtensionException $e) {
static::log('w', 'Exception('.$e->getMessage().') during install for extension "'.$e->getExtensionId().'"');
throw new \tao_install_utils_Exception("An error occured during the installation of extension '" . $e->getExtensionId() . "'.");
}
} | php | public static function installRecursively($extensionIDs, $installData=array())
{
try {
return parent::installRecursively($extensionIDs, $installData);
} catch (\common_ext_ExtensionException $e) {
static::log('w', 'Exception('.$e->getMessage().') during install for extension "'.$e->getExtensionId().'"');
throw new \tao_install_utils_Exception("An error occured during the installation of extension '" . $e->getExtensionId() . "'.");
}
} | [
"public",
"static",
"function",
"installRecursively",
"(",
"$",
"extensionIDs",
",",
"$",
"installData",
"=",
"array",
"(",
")",
")",
"{",
"try",
"{",
"return",
"parent",
"::",
"installRecursively",
"(",
"$",
"extensionIDs",
",",
"$",
"installData",
")",
";"... | Override of original install helper to throw install exception
on errors
@param array $extensionIDs
@param array $installData
@throws \tao_install_utils_Exception
@return multitype:string | [
"Override",
"of",
"original",
"install",
"helper",
"to",
"throw",
"install",
"exception",
"on",
"errors"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/InstallHelper.php#L40-L48 |
oat-sa/tao-core | helpers/grid/class.GridContainer.php | tao_helpers_grid_GridContainer.initGrid | protected function initGrid()
{
$returnValue = (bool) false;
//set data if data given
$returnValue = $this->grid->setData($this->data);
return (bool) $returnValue;
} | php | protected function initGrid()
{
$returnValue = (bool) false;
//set data if data given
$returnValue = $this->grid->setData($this->data);
return (bool) $returnValue;
} | [
"protected",
"function",
"initGrid",
"(",
")",
"{",
"$",
"returnValue",
"=",
"(",
"bool",
")",
"false",
";",
"//set data if data given",
"$",
"returnValue",
"=",
"$",
"this",
"->",
"grid",
"->",
"setData",
"(",
"$",
"this",
"->",
"data",
")",
";",
"retur... | Short description of method initGrid
@access protected
@author Somsack Sipasseuth, <somsack.sipasseuth@tudor.lu>
@return boolean | [
"Short",
"description",
"of",
"method",
"initGrid"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/grid/class.GridContainer.php#L148-L160 |
oat-sa/tao-core | helpers/grid/class.GridContainer.php | tao_helpers_grid_GridContainer.initOptions | public function initOptions($options = array())
{
$returnValue = (bool) false;
$columns = $this->grid->getColumns();
if(isset($options['columns'])){
foreach($options['columns'] as $columnId=>$columnOptions){
if(isset($columns[$columnId])){
foreach($columnOptions as $optionsName=>$optionsValue){
if($optionsName=='columns'){
//if the options is columns, the options will be used to augment the subgrid model
$columns = $this->grid->getColumns();
$subGridAdapter = null;
//get the last subgrid adapter which defines the column
$adapters = $columns[$columnId]->getAdapters();
$adaptersLength = count($adapters);
for($i=$adaptersLength-1; $i>=0; $i--){
if($adapters[$i] instanceof tao_helpers_grid_Cell_SubgridAdapter){
$subGridAdapter = $adapters[$i];
break;
}
}
if(is_null($subGridAdapter)){
throw new Exception(__('The column ').$columnId.__(' requires a subgrid adapter'));
}
//init options of the subgrid
$subGridAdapter->getGridContainer()->initOptions($columnOptions);
continue;
}
$columns[$columnId]->setOption($optionsName, $optionsValue);
}
}
}
}
return (bool) $returnValue;
} | php | public function initOptions($options = array())
{
$returnValue = (bool) false;
$columns = $this->grid->getColumns();
if(isset($options['columns'])){
foreach($options['columns'] as $columnId=>$columnOptions){
if(isset($columns[$columnId])){
foreach($columnOptions as $optionsName=>$optionsValue){
if($optionsName=='columns'){
//if the options is columns, the options will be used to augment the subgrid model
$columns = $this->grid->getColumns();
$subGridAdapter = null;
//get the last subgrid adapter which defines the column
$adapters = $columns[$columnId]->getAdapters();
$adaptersLength = count($adapters);
for($i=$adaptersLength-1; $i>=0; $i--){
if($adapters[$i] instanceof tao_helpers_grid_Cell_SubgridAdapter){
$subGridAdapter = $adapters[$i];
break;
}
}
if(is_null($subGridAdapter)){
throw new Exception(__('The column ').$columnId.__(' requires a subgrid adapter'));
}
//init options of the subgrid
$subGridAdapter->getGridContainer()->initOptions($columnOptions);
continue;
}
$columns[$columnId]->setOption($optionsName, $optionsValue);
}
}
}
}
return (bool) $returnValue;
} | [
"public",
"function",
"initOptions",
"(",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"returnValue",
"=",
"(",
"bool",
")",
"false",
";",
"$",
"columns",
"=",
"$",
"this",
"->",
"grid",
"->",
"getColumns",
"(",
")",
";",
"if",
"(",
"isse... | Short description of method initOptions
@access public
@author Somsack Sipasseuth, <somsack.sipasseuth@tudor.lu>
@return boolean | [
"Short",
"description",
"of",
"method",
"initOptions"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/grid/class.GridContainer.php#L197-L239 |
oat-sa/tao-core | helpers/translation/class.SourceCodeExtractor.php | tao_helpers_translation_SourceCodeExtractor.extract | public function extract()
{
$this->setTranslationUnits(array());
foreach ($this->getPaths() as $dir) {
// Directories should come with a trailing slash.
$d = strrev($dir);
if ($d[0] !== '/') {
$dir = $dir . '/';
}
$this->recursiveSearch($dir);
}
} | php | public function extract()
{
$this->setTranslationUnits(array());
foreach ($this->getPaths() as $dir) {
// Directories should come with a trailing slash.
$d = strrev($dir);
if ($d[0] !== '/') {
$dir = $dir . '/';
}
$this->recursiveSearch($dir);
}
} | [
"public",
"function",
"extract",
"(",
")",
"{",
"$",
"this",
"->",
"setTranslationUnits",
"(",
"array",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getPaths",
"(",
")",
"as",
"$",
"dir",
")",
"{",
"// Directories should come with a trailing slash... | Short description of method extract
@access public
@author firstname and lastname of author, <author@example.org> | [
"Short",
"description",
"of",
"method",
"extract"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/translation/class.SourceCodeExtractor.php#L61-L75 |
oat-sa/tao-core | helpers/translation/class.SourceCodeExtractor.php | tao_helpers_translation_SourceCodeExtractor.recursiveSearch | private function recursiveSearch($directory)
{
if (is_dir($directory)) {
// We get the list of files and directories.
if (($files = scandir($directory)) !== false) {
foreach($files as $fd) {
if (!preg_match("/^\./", $fd) && $fd != "ext") {
// If it is a directory ...
if (is_dir($directory . $fd. "/")) {
$this->recursiveSearch($directory . $fd . "/");
// If it is a file ...
} else {
// Retrieve from the file ...
$this->getTranslationsInFile($directory . $fd);
}
}
}
}
}
} | php | private function recursiveSearch($directory)
{
if (is_dir($directory)) {
// We get the list of files and directories.
if (($files = scandir($directory)) !== false) {
foreach($files as $fd) {
if (!preg_match("/^\./", $fd) && $fd != "ext") {
// If it is a directory ...
if (is_dir($directory . $fd. "/")) {
$this->recursiveSearch($directory . $fd . "/");
// If it is a file ...
} else {
// Retrieve from the file ...
$this->getTranslationsInFile($directory . $fd);
}
}
}
}
}
} | [
"private",
"function",
"recursiveSearch",
"(",
"$",
"directory",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"directory",
")",
")",
"{",
"// We get the list of files and directories.",
"if",
"(",
"(",
"$",
"files",
"=",
"scandir",
"(",
"$",
"directory",
")",
")... | Short description of method recursiveSearch
@access private
@author firstname and lastname of author, <author@example.org>
@param string $directory | [
"Short",
"description",
"of",
"method",
"recursiveSearch"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/translation/class.SourceCodeExtractor.php#L84-L109 |
oat-sa/tao-core | helpers/translation/class.SourceCodeExtractor.php | tao_helpers_translation_SourceCodeExtractor.getTranslationsInFile | private function getTranslationsInFile($filePath)
{
// File extension ?
$extOk = in_array(\Jig\Utils\FsUtils::getFileExtension($filePath), $this->getFileTypes());
if ($extOk){
foreach ($this->getBannedFileType() as $bannedExt){
$extOk &= substr_compare($filePath, $bannedExt, strlen($filePath)-strlen($bannedExt), strlen($bannedExt)) !== 0;
}
}
if ($extOk) {
// We read the file.
$lines = file($filePath);
foreach ($lines as $line) {
$strings = $this->getTranslationPhrases( $line );
//preg_match_all("/__(\(| )+['\"](.*?)['\"](\))?/u", $line, $string);
//lookup for __('to translate') or __ 'to translate'
// preg_match_all("/__(\(| )+(('(.*?)')|(\"(.*?)\"))(\))?/u", $line, $string);
foreach($strings as $s) {
$tu = new tao_helpers_translation_TranslationUnit();
$tu->setSource(tao_helpers_translation_POUtils::sanitize($s));
$tus = $this->getTranslationUnits();
$found = false;
// We must add the string as a new TranslationUnit only
// if a similiar source does not exist.
foreach ($tus as $t) {
if ($tu->getSource() == $t->getSource()) {
$found = true;
break;
}
}
if (!$found) {
$tus[] = $tu;
$this->setTranslationUnits($tus);
}
}
}
}
} | php | private function getTranslationsInFile($filePath)
{
// File extension ?
$extOk = in_array(\Jig\Utils\FsUtils::getFileExtension($filePath), $this->getFileTypes());
if ($extOk){
foreach ($this->getBannedFileType() as $bannedExt){
$extOk &= substr_compare($filePath, $bannedExt, strlen($filePath)-strlen($bannedExt), strlen($bannedExt)) !== 0;
}
}
if ($extOk) {
// We read the file.
$lines = file($filePath);
foreach ($lines as $line) {
$strings = $this->getTranslationPhrases( $line );
//preg_match_all("/__(\(| )+['\"](.*?)['\"](\))?/u", $line, $string);
//lookup for __('to translate') or __ 'to translate'
// preg_match_all("/__(\(| )+(('(.*?)')|(\"(.*?)\"))(\))?/u", $line, $string);
foreach($strings as $s) {
$tu = new tao_helpers_translation_TranslationUnit();
$tu->setSource(tao_helpers_translation_POUtils::sanitize($s));
$tus = $this->getTranslationUnits();
$found = false;
// We must add the string as a new TranslationUnit only
// if a similiar source does not exist.
foreach ($tus as $t) {
if ($tu->getSource() == $t->getSource()) {
$found = true;
break;
}
}
if (!$found) {
$tus[] = $tu;
$this->setTranslationUnits($tus);
}
}
}
}
} | [
"private",
"function",
"getTranslationsInFile",
"(",
"$",
"filePath",
")",
"{",
"// File extension ?",
"$",
"extOk",
"=",
"in_array",
"(",
"\\",
"Jig",
"\\",
"Utils",
"\\",
"FsUtils",
"::",
"getFileExtension",
"(",
"$",
"filePath",
")",
",",
"$",
"this",
"->... | Short description of method getTranslationsInFile
@access private
@author firstname and lastname of author, <author@example.org>
@param string $filePath | [
"Short",
"description",
"of",
"method",
"getTranslationsInFile"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/translation/class.SourceCodeExtractor.php#L159-L205 |
oat-sa/tao-core | helpers/translation/class.SourceCodeExtractor.php | tao_helpers_translation_SourceCodeExtractor.getTranslationPhrases | protected function getTranslationPhrases( $line )
{
$strings = array();
$patternMatch1 = array();
$patternMatch2 = array();
preg_match_all( "/__\\(([\\\"'])(?:(?=(\\\\?))\\2.)*?\\1/u", $line, $patternMatch1); //for php and JS helper function
preg_match_all( "/\{\{__ ['\"](.*?)['\"]\}\}/u", $line, $patternMatch2 ); //used for parsing templates
if ( ! empty( $patternMatch1[0] )) {
$strings = array_reduce(
$patternMatch1[0],
function ( $m, $str ) use ( $patternMatch1 ) {
$found = preg_match(
"/([\"'])(?:(?=(\\\\?))\\2.)*?\\1/u",
$str,
$matches
); //matches first passed argument only
$m[] = $found ? trim( $matches[0], '"\'' ) : $patternMatch1[1];
return $m;
},
array()
);
}
if ( ! empty( $patternMatch2[1] )) {
$strings = array_merge( $strings, $patternMatch2[1] );
return $strings;
}
return $strings;
} | php | protected function getTranslationPhrases( $line )
{
$strings = array();
$patternMatch1 = array();
$patternMatch2 = array();
preg_match_all( "/__\\(([\\\"'])(?:(?=(\\\\?))\\2.)*?\\1/u", $line, $patternMatch1); //for php and JS helper function
preg_match_all( "/\{\{__ ['\"](.*?)['\"]\}\}/u", $line, $patternMatch2 ); //used for parsing templates
if ( ! empty( $patternMatch1[0] )) {
$strings = array_reduce(
$patternMatch1[0],
function ( $m, $str ) use ( $patternMatch1 ) {
$found = preg_match(
"/([\"'])(?:(?=(\\\\?))\\2.)*?\\1/u",
$str,
$matches
); //matches first passed argument only
$m[] = $found ? trim( $matches[0], '"\'' ) : $patternMatch1[1];
return $m;
},
array()
);
}
if ( ! empty( $patternMatch2[1] )) {
$strings = array_merge( $strings, $patternMatch2[1] );
return $strings;
}
return $strings;
} | [
"protected",
"function",
"getTranslationPhrases",
"(",
"$",
"line",
")",
"{",
"$",
"strings",
"=",
"array",
"(",
")",
";",
"$",
"patternMatch1",
"=",
"array",
"(",
")",
";",
"$",
"patternMatch2",
"=",
"array",
"(",
")",
";",
"preg_match_all",
"(",
"\"/__... | @param $line
@return array | [
"@param",
"$line"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/translation/class.SourceCodeExtractor.php#L228-L260 |
oat-sa/tao-core | models/classes/dataBinding/class.GenerisFormDataBinder.php | tao_models_classes_dataBinding_GenerisFormDataBinder.bind | public function bind($data)
{
$returnValue = null;
try {
$instance = parent::bind($data);
// Take care of what the generic data binding did not.
foreach ($data as $p => $d){
$property = new core_kernel_classes_Property($p);
if ($d instanceof tao_helpers_form_data_UploadFileDescription){
$this->bindUploadFileDescription($property, $d);
}
}
$returnValue = $instance;
}
catch (common_Exception $e){
$msg = "An error occured while binding property values to instance '': " . $e->getMessage();
throw new tao_models_classes_dataBinding_GenerisFormDataBindingException($msg);
}
return $returnValue;
} | php | public function bind($data)
{
$returnValue = null;
try {
$instance = parent::bind($data);
// Take care of what the generic data binding did not.
foreach ($data as $p => $d){
$property = new core_kernel_classes_Property($p);
if ($d instanceof tao_helpers_form_data_UploadFileDescription){
$this->bindUploadFileDescription($property, $d);
}
}
$returnValue = $instance;
}
catch (common_Exception $e){
$msg = "An error occured while binding property values to instance '': " . $e->getMessage();
throw new tao_models_classes_dataBinding_GenerisFormDataBindingException($msg);
}
return $returnValue;
} | [
"public",
"function",
"bind",
"(",
"$",
"data",
")",
"{",
"$",
"returnValue",
"=",
"null",
";",
"try",
"{",
"$",
"instance",
"=",
"parent",
"::",
"bind",
"(",
"$",
"data",
")",
";",
"// Take care of what the generic data binding did not.",
"foreach",
"(",
"$... | Simply bind data from a Generis Instance Form to a specific generis class
The array of the data to be bound must contain keys that are property
The repspective values can be either scalar or vector (array) values or
values.
- If the element of the $data array is scalar, it is simply bound using
- If the element of the $data array is a vector, the property values are
with the values of the vector.
- If the element is an object, the binder will infer the best method to
it in the persistent memory, depending on its nature.
@access public
@author Jerome Bogaerts <jerome@taotesting.com>
@param array data An array of values where keys are Property URIs and values are either scalar, vector or object values.
@return mixed | [
"Simply",
"bind",
"data",
"from",
"a",
"Generis",
"Instance",
"Form",
"to",
"a",
"specific",
"generis",
"class"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/dataBinding/class.GenerisFormDataBinder.php#L60-L86 |
oat-sa/tao-core | models/classes/dataBinding/class.GenerisFormDataBinder.php | tao_models_classes_dataBinding_GenerisFormDataBinder.bindUploadFileDescription | protected function bindUploadFileDescription(
core_kernel_classes_Property $property,
tao_helpers_form_data_UploadFileDescription $desc
) {
$instance = $this->getTargetInstance();
// If form has delete action, remove file
if ($desc->getAction() == tao_helpers_form_data_UploadFileDescription::FORM_ACTION_DELETE) {
$this->removeFile($property);
}
// If form has add action, remove file & replace by new
elseif ($desc->getAction() == tao_helpers_form_data_UploadFileDescription::FORM_ACTION_ADD) {
$name = $desc->getName();
$size = $desc->getSize();
if (! empty($name) && ! empty($size)) {
// Remove old
$this->removeFile($property);
// Move the file at the right place.
$source = $desc->getTmpPath();
$serial = tao_models_classes_TaoService::singleton()->storeUploadedFile($source, $name);
$this->getServiceLocator()->get(UploadService::SERVICE_ID)->remove($source);
// Create association between item & file, database side
$instance->editPropertyValues($property, $serial);
// Update the UploadFileDescription with the stored file.
$desc->setFile($serial);
}
}
} | php | protected function bindUploadFileDescription(
core_kernel_classes_Property $property,
tao_helpers_form_data_UploadFileDescription $desc
) {
$instance = $this->getTargetInstance();
// If form has delete action, remove file
if ($desc->getAction() == tao_helpers_form_data_UploadFileDescription::FORM_ACTION_DELETE) {
$this->removeFile($property);
}
// If form has add action, remove file & replace by new
elseif ($desc->getAction() == tao_helpers_form_data_UploadFileDescription::FORM_ACTION_ADD) {
$name = $desc->getName();
$size = $desc->getSize();
if (! empty($name) && ! empty($size)) {
// Remove old
$this->removeFile($property);
// Move the file at the right place.
$source = $desc->getTmpPath();
$serial = tao_models_classes_TaoService::singleton()->storeUploadedFile($source, $name);
$this->getServiceLocator()->get(UploadService::SERVICE_ID)->remove($source);
// Create association between item & file, database side
$instance->editPropertyValues($property, $serial);
// Update the UploadFileDescription with the stored file.
$desc->setFile($serial);
}
}
} | [
"protected",
"function",
"bindUploadFileDescription",
"(",
"core_kernel_classes_Property",
"$",
"property",
",",
"tao_helpers_form_data_UploadFileDescription",
"$",
"desc",
")",
"{",
"$",
"instance",
"=",
"$",
"this",
"->",
"getTargetInstance",
"(",
")",
";",
"// If for... | Binds an UploadFileDescription with the target instance.
@access protected
@author Jerome Bogaerts <jerome@taotesting.com>
@param core_kernel_classes_Property $property The property to bind the data.
@param tao_helpers_form_data_UploadFileDescription $desc the upload file description.
@return void
@throws \oat\oatbox\service\ServiceNotFoundException
@throws \common_Exception | [
"Binds",
"an",
"UploadFileDescription",
"with",
"the",
"target",
"instance",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/dataBinding/class.GenerisFormDataBinder.php#L99-L132 |
oat-sa/tao-core | models/classes/dataBinding/class.GenerisFormDataBinder.php | tao_models_classes_dataBinding_GenerisFormDataBinder.removeFile | protected function removeFile(core_kernel_classes_Property $property)
{
$instance = $this->getTargetInstance();
$referencer = $this->getServiceLocator()->get(FileReferenceSerializer::SERVICE_ID);
foreach ($instance->getPropertyValues($property) as $oldFileSerial) {
/** @var \oat\oatbox\filesystem\File $oldFile */
$oldFile = $referencer->unserializeFile($oldFileSerial);
$oldFile->delete();
$referencer->cleanup($oldFileSerial);
$instance->removePropertyValue($property, $oldFileSerial);
}
} | php | protected function removeFile(core_kernel_classes_Property $property)
{
$instance = $this->getTargetInstance();
$referencer = $this->getServiceLocator()->get(FileReferenceSerializer::SERVICE_ID);
foreach ($instance->getPropertyValues($property) as $oldFileSerial) {
/** @var \oat\oatbox\filesystem\File $oldFile */
$oldFile = $referencer->unserializeFile($oldFileSerial);
$oldFile->delete();
$referencer->cleanup($oldFileSerial);
$instance->removePropertyValue($property, $oldFileSerial);
}
} | [
"protected",
"function",
"removeFile",
"(",
"core_kernel_classes_Property",
"$",
"property",
")",
"{",
"$",
"instance",
"=",
"$",
"this",
"->",
"getTargetInstance",
"(",
")",
";",
"$",
"referencer",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
... | Remove file stored into given $property from $targetInstance
- Remove file properties
- Remove physically file
- Remove property link between item & file
@param core_kernel_classes_Property $property | [
"Remove",
"file",
"stored",
"into",
"given",
"$property",
"from",
"$targetInstance",
"-",
"Remove",
"file",
"properties",
"-",
"Remove",
"physically",
"file",
"-",
"Remove",
"property",
"link",
"between",
"item",
"&",
"file"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/dataBinding/class.GenerisFormDataBinder.php#L142-L154 |
oat-sa/tao-core | helpers/data/class.GenerisAdapterRdf.php | tao_helpers_data_GenerisAdapterRdf.import | public function import($source, core_kernel_classes_Class $destination = null, $namespace = null)
{
/** @var UploadService $uploadService */
$uploadService = ServiceManager::getServiceManager()->get(UploadService::SERVICE_ID);
if (!$source instanceof File) {
$file = $uploadService->getUploadedFlyFile($source);
} else {
$file = $source;
}
$returnValue = false;
if ($file->exists()) {
$api = core_kernel_impl_ApiModelOO::singleton();
if ($destination !== null) {
$targetNamespace = substr($destination->getUri(), 0, strpos($destination->getUri(), '#'));
} elseif ($namespace !== null) {
$targetNamespace = $namespace;
} else {
$targetNamespace = rtrim(common_ext_NamespaceManager::singleton()->getLocalNamespace()->getUri(), '#');
}
$returnValue = $api->importXmlRdf($targetNamespace, $file);
}
$uploadService->remove($file);
return $returnValue;
} | php | public function import($source, core_kernel_classes_Class $destination = null, $namespace = null)
{
/** @var UploadService $uploadService */
$uploadService = ServiceManager::getServiceManager()->get(UploadService::SERVICE_ID);
if (!$source instanceof File) {
$file = $uploadService->getUploadedFlyFile($source);
} else {
$file = $source;
}
$returnValue = false;
if ($file->exists()) {
$api = core_kernel_impl_ApiModelOO::singleton();
if ($destination !== null) {
$targetNamespace = substr($destination->getUri(), 0, strpos($destination->getUri(), '#'));
} elseif ($namespace !== null) {
$targetNamespace = $namespace;
} else {
$targetNamespace = rtrim(common_ext_NamespaceManager::singleton()->getLocalNamespace()->getUri(), '#');
}
$returnValue = $api->importXmlRdf($targetNamespace, $file);
}
$uploadService->remove($file);
return $returnValue;
} | [
"public",
"function",
"import",
"(",
"$",
"source",
",",
"core_kernel_classes_Class",
"$",
"destination",
"=",
"null",
",",
"$",
"namespace",
"=",
"null",
")",
"{",
"/** @var UploadService $uploadService */",
"$",
"uploadService",
"=",
"ServiceManager",
"::",
"getSe... | Import a XML file as is into the ontology
@access public
@author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
@param string $source
@param core_kernel_classes_Class $destination
@param string $namespace
@return boolean
@throws \oat\oatbox\service\ServiceNotFoundException
@throws \common_Exception | [
"Import",
"a",
"XML",
"file",
"as",
"is",
"into",
"the",
"ontology"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/data/class.GenerisAdapterRdf.php#L50-L77 |
oat-sa/tao-core | helpers/data/class.GenerisAdapterRdf.php | tao_helpers_data_GenerisAdapterRdf.export | public function export(core_kernel_classes_Class $source = null)
{
if ($source === null) {
return core_kernel_api_ModelExporter::exportAll();
}
$graph = new EasyRdf_Graph();
if ($source->isClass()) {
$this->addClass($graph, $source);
} else {
$this->addResource($graph, $source);
}
$format = EasyRdf_Format::getFormat('rdfxml');
return $graph->serialise($format);
} | php | public function export(core_kernel_classes_Class $source = null)
{
if ($source === null) {
return core_kernel_api_ModelExporter::exportAll();
}
$graph = new EasyRdf_Graph();
if ($source->isClass()) {
$this->addClass($graph, $source);
} else {
$this->addResource($graph, $source);
}
$format = EasyRdf_Format::getFormat('rdfxml');
return $graph->serialise($format);
} | [
"public",
"function",
"export",
"(",
"core_kernel_classes_Class",
"$",
"source",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"source",
"===",
"null",
")",
"{",
"return",
"core_kernel_api_ModelExporter",
"::",
"exportAll",
"(",
")",
";",
"}",
"$",
"graph",
"=",
... | Export to xml-rdf the ontology of the Class in parameter.
All the ontologies are exported if the class is not set
@access public
@author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
@param core_kernel_classes_Class|null $source
@return string
@throws EasyRdf_Exception | [
"Export",
"to",
"xml",
"-",
"rdf",
"the",
"ontology",
"of",
"the",
"Class",
"in",
"parameter",
".",
"All",
"the",
"ontologies",
"are",
"exported",
"if",
"the",
"class",
"is",
"not",
"set"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/data/class.GenerisAdapterRdf.php#L89-L103 |
oat-sa/tao-core | helpers/data/class.GenerisAdapterRdf.php | tao_helpers_data_GenerisAdapterRdf.addClass | private function addClass(EasyRdf_Graph $graph, core_kernel_classes_Class $resource)
{
$this->addResource($graph, $resource);
foreach ($resource->getInstances() as $instance) {
$this->addResource($graph, $instance);
}
foreach ($resource->getSubClasses() as $subclass) {
$this->addClass($graph, $subclass);
}
foreach ($resource->getProperties() as $property) {
$this->addResource($graph, $property);
}
} | php | private function addClass(EasyRdf_Graph $graph, core_kernel_classes_Class $resource)
{
$this->addResource($graph, $resource);
foreach ($resource->getInstances() as $instance) {
$this->addResource($graph, $instance);
}
foreach ($resource->getSubClasses() as $subclass) {
$this->addClass($graph, $subclass);
}
foreach ($resource->getProperties() as $property) {
$this->addResource($graph, $property);
}
} | [
"private",
"function",
"addClass",
"(",
"EasyRdf_Graph",
"$",
"graph",
",",
"core_kernel_classes_Class",
"$",
"resource",
")",
"{",
"$",
"this",
"->",
"addResource",
"(",
"$",
"graph",
",",
"$",
"resource",
")",
";",
"foreach",
"(",
"$",
"resource",
"->",
... | Add a class to the graph
@param EasyRdf_Graph $graph
@param core_kernel_classes_Class $resource
@ignore | [
"Add",
"a",
"class",
"to",
"the",
"graph"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/data/class.GenerisAdapterRdf.php#L112-L125 |
oat-sa/tao-core | helpers/data/class.GenerisAdapterRdf.php | tao_helpers_data_GenerisAdapterRdf.addResource | private function addResource(EasyRdf_Graph $graph, core_kernel_classes_Resource $resource)
{
foreach ($resource->getRdfTriples() as $triple) {
$language = !empty($triple->lg) ? $triple->lg : null;
if (common_Utils::isUri($triple->object)) {
if ($triple->predicate !== OntologyRdf::RDF_TYPE && strpos($triple->object, LOCAL_NAMESPACE) !== false) {
continue;
}
$graph->add($triple->subject, $triple->predicate, $triple->object);
} else {
if ($this->isSerializedFile($triple->object)) {
continue;
}
$graph->addLiteral($triple->subject, $triple->predicate, $triple->object, $language);
}
}
} | php | private function addResource(EasyRdf_Graph $graph, core_kernel_classes_Resource $resource)
{
foreach ($resource->getRdfTriples() as $triple) {
$language = !empty($triple->lg) ? $triple->lg : null;
if (common_Utils::isUri($triple->object)) {
if ($triple->predicate !== OntologyRdf::RDF_TYPE && strpos($triple->object, LOCAL_NAMESPACE) !== false) {
continue;
}
$graph->add($triple->subject, $triple->predicate, $triple->object);
} else {
if ($this->isSerializedFile($triple->object)) {
continue;
}
$graph->addLiteral($triple->subject, $triple->predicate, $triple->object, $language);
}
}
} | [
"private",
"function",
"addResource",
"(",
"EasyRdf_Graph",
"$",
"graph",
",",
"core_kernel_classes_Resource",
"$",
"resource",
")",
"{",
"foreach",
"(",
"$",
"resource",
"->",
"getRdfTriples",
"(",
")",
"as",
"$",
"triple",
")",
"{",
"$",
"language",
"=",
"... | Add a resource to the graph
@param EasyRdf_Graph $graph
@param core_kernel_classes_Resource $resource
@ignore | [
"Add",
"a",
"resource",
"to",
"the",
"graph"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/data/class.GenerisAdapterRdf.php#L134-L150 |
oat-sa/tao-core | helpers/data/class.GenerisAdapterRdf.php | tao_helpers_data_GenerisAdapterRdf.isSerializedFile | private function isSerializedFile($object)
{
$isFile = false;
$type = substr($object, 0, strpos($object, ':'));
if (in_array($type, ['file', 'dir'])) {
$isFile = true;
}
return $isFile;
} | php | private function isSerializedFile($object)
{
$isFile = false;
$type = substr($object, 0, strpos($object, ':'));
if (in_array($type, ['file', 'dir'])) {
$isFile = true;
}
return $isFile;
} | [
"private",
"function",
"isSerializedFile",
"(",
"$",
"object",
")",
"{",
"$",
"isFile",
"=",
"false",
";",
"$",
"type",
"=",
"substr",
"(",
"$",
"object",
",",
"0",
",",
"strpos",
"(",
"$",
"object",
",",
"':'",
")",
")",
";",
"if",
"(",
"in_array"... | Check if the given object is a serialized file reference
@param string $object
@return bool
@see \oat\generis\model\fileReference\UrlFileSerializer::unserialize | [
"Check",
"if",
"the",
"given",
"object",
"is",
"a",
"serialized",
"file",
"reference"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/data/class.GenerisAdapterRdf.php#L159-L168 |
oat-sa/tao-core | helpers/metadata/ResourceCompiledMetadataHelper.php | ResourceCompiledMetadataHelper.getValue | public function getValue($name)
{
return isset($this->metaData[$name]) ? $this->metaData[$name] : null;
} | php | public function getValue($name)
{
return isset($this->metaData[$name]) ? $this->metaData[$name] : null;
} | [
"public",
"function",
"getValue",
"(",
"$",
"name",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"metaData",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"metaData",
"[",
"$",
"name",
"]",
":",
"null",
";",
"}"
] | Gets a particular value from compiled metadata of a Resource.
In case of no value can be found with given $language,
the implementation will try to retrieve a value for the default installation
language. Otherwise, the method returns NULL.
@param string $language
@param string $name
@return mixed | [
"Gets",
"a",
"particular",
"value",
"from",
"compiled",
"metadata",
"of",
"a",
"Resource",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/metadata/ResourceCompiledMetadataHelper.php#L46-L49 |
oat-sa/tao-core | helpers/metadata/ResourceCompiledMetadataHelper.php | ResourceCompiledMetadataHelper.unserialize | public function unserialize($data)
{
if (!is_string($data)) {
throw new \common_exception_InconsistentData('The encoded resource metadata should be provided as a string');
}
$metaData = json_decode($data, true);
if (!is_array($metaData)) {
throw new \common_exception_InconsistentData('The decoded resource metadata should be an array');
}
$this->metaData = $metaData;
return $this->metaData;
} | php | public function unserialize($data)
{
if (!is_string($data)) {
throw new \common_exception_InconsistentData('The encoded resource metadata should be provided as a string');
}
$metaData = json_decode($data, true);
if (!is_array($metaData)) {
throw new \common_exception_InconsistentData('The decoded resource metadata should be an array');
}
$this->metaData = $metaData;
return $this->metaData;
} | [
"public",
"function",
"unserialize",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"data",
")",
")",
"{",
"throw",
"new",
"\\",
"common_exception_InconsistentData",
"(",
"'The encoded resource metadata should be provided as a string'",
")",
";",... | Unpacks resource metadata from a string.
@param string $data
@return array
@throws \common_exception_InconsistentData | [
"Unpacks",
"resource",
"metadata",
"from",
"a",
"string",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/metadata/ResourceCompiledMetadataHelper.php#L67-L81 |
oat-sa/tao-core | models/classes/class.UserService.php | tao_models_classes_UserService.loginUser | public function loginUser($login, $password)
{
$returnValue = (bool) false;
try{
$returnValue = LoginService::login($login, $password);
}
catch(core_kernel_users_Exception $ue){
common_Logger::e("A fatal error occured at user login time: " . $ue->getMessage());
}
return (bool) $returnValue;
} | php | public function loginUser($login, $password)
{
$returnValue = (bool) false;
try{
$returnValue = LoginService::login($login, $password);
}
catch(core_kernel_users_Exception $ue){
common_Logger::e("A fatal error occured at user login time: " . $ue->getMessage());
}
return (bool) $returnValue;
} | [
"public",
"function",
"loginUser",
"(",
"$",
"login",
",",
"$",
"password",
")",
"{",
"$",
"returnValue",
"=",
"(",
"bool",
")",
"false",
";",
"try",
"{",
"$",
"returnValue",
"=",
"LoginService",
"::",
"login",
"(",
"$",
"login",
",",
"$",
"password",
... | authenticate a user
@access public
@author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
@param string login
@param string password
@return boolean
@deprecated | [
"authenticate",
"a",
"user"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.UserService.php#L94-L105 |
oat-sa/tao-core | models/classes/class.UserService.php | tao_models_classes_UserService.getCurrentUser | public function getCurrentUser()
{
$returnValue = null;
if(!common_session_SessionManager::isAnonymous()){
$userUri = \common_session_SessionManager::getSession()->getUser()->getIdentifier();
if(!empty($userUri)){
$returnValue = new core_kernel_classes_Resource($userUri);
} else {
common_Logger::d('no userUri');
}
}
return $returnValue;
} | php | public function getCurrentUser()
{
$returnValue = null;
if(!common_session_SessionManager::isAnonymous()){
$userUri = \common_session_SessionManager::getSession()->getUser()->getIdentifier();
if(!empty($userUri)){
$returnValue = new core_kernel_classes_Resource($userUri);
} else {
common_Logger::d('no userUri');
}
}
return $returnValue;
} | [
"public",
"function",
"getCurrentUser",
"(",
")",
"{",
"$",
"returnValue",
"=",
"null",
";",
"if",
"(",
"!",
"common_session_SessionManager",
"::",
"isAnonymous",
"(",
")",
")",
"{",
"$",
"userUri",
"=",
"\\",
"common_session_SessionManager",
"::",
"getSession",... | retrieve the logged in user
@access public
@author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
@return core_kernel_classes_Resource | [
"retrieve",
"the",
"logged",
"in",
"user"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.UserService.php#L114-L128 |
oat-sa/tao-core | models/classes/class.UserService.php | tao_models_classes_UserService.loginExists | public function loginExists($login, core_kernel_classes_Class $class = null)
{
$returnValue = (bool) false;
$returnValue = $this->generisUserService->loginExists($login, $class);
return (bool) $returnValue;
} | php | public function loginExists($login, core_kernel_classes_Class $class = null)
{
$returnValue = (bool) false;
$returnValue = $this->generisUserService->loginExists($login, $class);
return (bool) $returnValue;
} | [
"public",
"function",
"loginExists",
"(",
"$",
"login",
",",
"core_kernel_classes_Class",
"$",
"class",
"=",
"null",
")",
"{",
"$",
"returnValue",
"=",
"(",
"bool",
")",
"false",
";",
"$",
"returnValue",
"=",
"$",
"this",
"->",
"generisUserService",
"->",
... | Check if the login is already used
@access public
@author Jerome Bogaerts, <jerome@taotesting.com>
@param string login
@param
@return boolean | [
"Check",
"if",
"the",
"login",
"is",
"already",
"used"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.UserService.php#L139-L146 |
oat-sa/tao-core | models/classes/class.UserService.php | tao_models_classes_UserService.loginAvailable | public function loginAvailable($login)
{
$returnValue = (bool) false;
if(!empty($login)){
$returnValue = !$this->loginExists($login);
}
return (bool) $returnValue;
} | php | public function loginAvailable($login)
{
$returnValue = (bool) false;
if(!empty($login)){
$returnValue = !$this->loginExists($login);
}
return (bool) $returnValue;
} | [
"public",
"function",
"loginAvailable",
"(",
"$",
"login",
")",
"{",
"$",
"returnValue",
"=",
"(",
"bool",
")",
"false",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"login",
")",
")",
"{",
"$",
"returnValue",
"=",
"!",
"$",
"this",
"->",
"loginExists",
... | Check if the login is available (because it's unique)
@access public
@author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
@param string login
@return boolean | [
"Check",
"if",
"the",
"login",
"is",
"available",
"(",
"because",
"it",
"s",
"unique",
")"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.UserService.php#L156-L165 |
oat-sa/tao-core | models/classes/class.UserService.php | tao_models_classes_UserService.getOneUser | public function getOneUser($login, core_kernel_classes_Class $class = null)
{
$returnValue = null;
if (empty($login)){
throw new common_exception_InvalidArgumentType('Missing login for '.__FUNCTION__);
}
$class = (!empty($class)) ? $class : $this->getRootClass();
$user = $this->generisUserService->getOneUser($login, $class);
if (!empty($user)){
$userRolesProperty = new core_kernel_classes_Property(GenerisRdf::PROPERTY_USER_ROLES);
$userRoles = $user->getPropertyValuesCollection($userRolesProperty);
$allowedRoles = $this->getAllowedRoles();
if($this->generisUserService->userHasRoles($user, $allowedRoles)){
$returnValue = $user;
} else {
common_Logger::i('User found for login \''.$login.'\' but does not have matchign roles');
}
} else {
common_Logger::i('No user found for login \''.$login.'\'');
}
return $returnValue;
} | php | public function getOneUser($login, core_kernel_classes_Class $class = null)
{
$returnValue = null;
if (empty($login)){
throw new common_exception_InvalidArgumentType('Missing login for '.__FUNCTION__);
}
$class = (!empty($class)) ? $class : $this->getRootClass();
$user = $this->generisUserService->getOneUser($login, $class);
if (!empty($user)){
$userRolesProperty = new core_kernel_classes_Property(GenerisRdf::PROPERTY_USER_ROLES);
$userRoles = $user->getPropertyValuesCollection($userRolesProperty);
$allowedRoles = $this->getAllowedRoles();
if($this->generisUserService->userHasRoles($user, $allowedRoles)){
$returnValue = $user;
} else {
common_Logger::i('User found for login \''.$login.'\' but does not have matchign roles');
}
} else {
common_Logger::i('No user found for login \''.$login.'\'');
}
return $returnValue;
} | [
"public",
"function",
"getOneUser",
"(",
"$",
"login",
",",
"core_kernel_classes_Class",
"$",
"class",
"=",
"null",
")",
"{",
"$",
"returnValue",
"=",
"null",
";",
"if",
"(",
"empty",
"(",
"$",
"login",
")",
")",
"{",
"throw",
"new",
"common_exception_Inva... | Get a user that has a given login.
@access public
@author Jerome Bogaerts, <jerome@taotesting.com>
@param string login the user login is the unique identifier to retrieve him.
@param core_kernel_classes_Class A specific class to search the user.
@return core_kernel_classes_Resource | [
"Get",
"a",
"user",
"that",
"has",
"a",
"given",
"login",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.UserService.php#L176-L204 |
oat-sa/tao-core | models/classes/class.UserService.php | tao_models_classes_UserService.removeUser | public function removeUser( core_kernel_classes_Resource $user)
{
$returnValue = (bool) false;
if(!is_null($user)) {
$this->checkCurrentUserAccess($this->getUserRoles($user));
$returnValue = $this->generisUserService->removeUser($user);
$this->getEventManager()->trigger(new UserRemovedEvent($user->getUri()));
}
return (bool) $returnValue;
} | php | public function removeUser( core_kernel_classes_Resource $user)
{
$returnValue = (bool) false;
if(!is_null($user)) {
$this->checkCurrentUserAccess($this->getUserRoles($user));
$returnValue = $this->generisUserService->removeUser($user);
$this->getEventManager()->trigger(new UserRemovedEvent($user->getUri()));
}
return (bool) $returnValue;
} | [
"public",
"function",
"removeUser",
"(",
"core_kernel_classes_Resource",
"$",
"user",
")",
"{",
"$",
"returnValue",
"=",
"(",
"bool",
")",
"false",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"user",
")",
")",
"{",
"$",
"this",
"->",
"checkCurrentUserAccess"... | Remove a user
@access public
@author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
@param core_kernel_classes_Resource $user
@return boolean | [
"Remove",
"a",
"user"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.UserService.php#L237-L248 |
oat-sa/tao-core | models/classes/class.UserService.php | tao_models_classes_UserService.logout | public function logout()
{
$returnValue = (bool) false;
$returnValue = $this->generisUserService->logout();
return (bool) $returnValue;
} | php | public function logout()
{
$returnValue = (bool) false;
$returnValue = $this->generisUserService->logout();
return (bool) $returnValue;
} | [
"public",
"function",
"logout",
"(",
")",
"{",
"$",
"returnValue",
"=",
"(",
"bool",
")",
"false",
";",
"$",
"returnValue",
"=",
"$",
"this",
"->",
"generisUserService",
"->",
"logout",
"(",
")",
";",
"return",
"(",
"bool",
")",
"$",
"returnValue",
";"... | Short description of method logout
@access public
@author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
@return boolean | [
"Short",
"description",
"of",
"method",
"logout"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.UserService.php#L279-L286 |
oat-sa/tao-core | models/classes/class.UserService.php | tao_models_classes_UserService.getAllUsers | public function getAllUsers($options = [], $filters = [GenerisRdf::PROPERTY_USER_LOGIN => '*'])
{
$userClass = new core_kernel_classes_Class(TaoOntology::CLASS_URI_TAO_USER);
$options = array_merge(['recursive' => true, 'like' => true], $options);
return (array) $userClass->searchInstances($filters, $options);
} | php | public function getAllUsers($options = [], $filters = [GenerisRdf::PROPERTY_USER_LOGIN => '*'])
{
$userClass = new core_kernel_classes_Class(TaoOntology::CLASS_URI_TAO_USER);
$options = array_merge(['recursive' => true, 'like' => true], $options);
return (array) $userClass->searchInstances($filters, $options);
} | [
"public",
"function",
"getAllUsers",
"(",
"$",
"options",
"=",
"[",
"]",
",",
"$",
"filters",
"=",
"[",
"GenerisRdf",
"::",
"PROPERTY_USER_LOGIN",
"=>",
"'*'",
"]",
")",
"{",
"$",
"userClass",
"=",
"new",
"core_kernel_classes_Class",
"(",
"TaoOntology",
"::"... | Short description of method getAllUsers
@access public
@author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
@param array $options
@param array $filters
@return array | [
"Short",
"description",
"of",
"method",
"getAllUsers"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.UserService.php#L297-L303 |
oat-sa/tao-core | models/classes/class.UserService.php | tao_models_classes_UserService.getCountUsers | public function getCountUsers($options = [], $filters = [])
{
$userClass = new core_kernel_classes_Class(TaoOntology::CLASS_URI_TAO_USER);
return $userClass->countInstances($filters, $options);
} | php | public function getCountUsers($options = [], $filters = [])
{
$userClass = new core_kernel_classes_Class(TaoOntology::CLASS_URI_TAO_USER);
return $userClass->countInstances($filters, $options);
} | [
"public",
"function",
"getCountUsers",
"(",
"$",
"options",
"=",
"[",
"]",
",",
"$",
"filters",
"=",
"[",
"]",
")",
"{",
"$",
"userClass",
"=",
"new",
"core_kernel_classes_Class",
"(",
"TaoOntology",
"::",
"CLASS_URI_TAO_USER",
")",
";",
"return",
"$",
"us... | Returns count of instances, that match conditions in options and filters
@access public
@author Ivan Klimchuk <klimchuk@1pt.com>
@param array $options
@param array $filters
@return int | [
"Returns",
"count",
"of",
"instances",
"that",
"match",
"conditions",
"in",
"options",
"and",
"filters"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.UserService.php#L313-L318 |
oat-sa/tao-core | models/classes/class.UserService.php | tao_models_classes_UserService.toTree | public function toTree( core_kernel_classes_Class $clazz, array $options = array())
{
$returnValue = array();
$users = $this->getAllUsers(array('order' => GenerisRdf::PROPERTY_USER_LOGIN));
foreach($users as $user){
$login = (string) $user->getOnePropertyValue(new core_kernel_classes_Property(GenerisRdf::PROPERTY_USER_LOGIN));
$returnValue[] = array(
'data' => tao_helpers_Display::textCutter($login, 16),
'attributes' => array(
'id' => tao_helpers_Uri::encode($user->getUri()),
'class' => 'node-instance'
)
);
}
return (array) $returnValue;
} | php | public function toTree( core_kernel_classes_Class $clazz, array $options = array())
{
$returnValue = array();
$users = $this->getAllUsers(array('order' => GenerisRdf::PROPERTY_USER_LOGIN));
foreach($users as $user){
$login = (string) $user->getOnePropertyValue(new core_kernel_classes_Property(GenerisRdf::PROPERTY_USER_LOGIN));
$returnValue[] = array(
'data' => tao_helpers_Display::textCutter($login, 16),
'attributes' => array(
'id' => tao_helpers_Uri::encode($user->getUri()),
'class' => 'node-instance'
)
);
}
return (array) $returnValue;
} | [
"public",
"function",
"toTree",
"(",
"core_kernel_classes_Class",
"$",
"clazz",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"returnValue",
"=",
"array",
"(",
")",
";",
"$",
"users",
"=",
"$",
"this",
"->",
"getAllUsers",
"(",
"... | Short description of method toTree
@access public
@author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
@param core_kernel_classes_Class $clazz
@param array $options
@return array | [
"Short",
"description",
"of",
"method",
"toTree"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.UserService.php#L329-L347 |
oat-sa/tao-core | models/classes/class.UserService.php | tao_models_classes_UserService.addUser | public function addUser($login, $password, core_kernel_classes_Resource $role = null, core_kernel_classes_Class $class = null){
$this->checkCurrentUserAccess($role);
if (empty($class)){
$class = $this->getRootClass();
}
$user = $this->generisUserService->addUser($login, $password, $role, $class);
//set up default properties
if(!is_null($user)){
$user->setPropertyValue(new core_kernel_classes_Property(TaoOntology::PROPERTY_USER_FIRST_TIME), GenerisRdf::GENERIS_TRUE);
}
return $user;
} | php | public function addUser($login, $password, core_kernel_classes_Resource $role = null, core_kernel_classes_Class $class = null){
$this->checkCurrentUserAccess($role);
if (empty($class)){
$class = $this->getRootClass();
}
$user = $this->generisUserService->addUser($login, $password, $role, $class);
//set up default properties
if(!is_null($user)){
$user->setPropertyValue(new core_kernel_classes_Property(TaoOntology::PROPERTY_USER_FIRST_TIME), GenerisRdf::GENERIS_TRUE);
}
return $user;
} | [
"public",
"function",
"addUser",
"(",
"$",
"login",
",",
"$",
"password",
",",
"core_kernel_classes_Resource",
"$",
"role",
"=",
"null",
",",
"core_kernel_classes_Class",
"$",
"class",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"checkCurrentUserAccess",
"(",
"$... | Add a new user.
@param string login The login to give the user.
@param string password the password in clear.
@param core_kernel_classes_Resource role A role to grant to the user.
@param core_kernel_classes_Class A specific class to use to instantiate the new user. If not specified, the class returned by the getUserClass method is used.
@return core_kernel_classes_Resource the new user
@throws core_kernel_users_Exception If an error occurs. | [
"Add",
"a",
"new",
"user",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.UserService.php#L359-L374 |
oat-sa/tao-core | models/classes/class.UserService.php | tao_models_classes_UserService.attachRole | public function attachRole(core_kernel_classes_Resource $user, core_kernel_classes_Resource $role)
{
// check that current user has rights to set this role
$this->checkCurrentUserAccess($role);
$this->generisUserService->attachRole($user, $role);
} | php | public function attachRole(core_kernel_classes_Resource $user, core_kernel_classes_Resource $role)
{
// check that current user has rights to set this role
$this->checkCurrentUserAccess($role);
$this->generisUserService->attachRole($user, $role);
} | [
"public",
"function",
"attachRole",
"(",
"core_kernel_classes_Resource",
"$",
"user",
",",
"core_kernel_classes_Resource",
"$",
"role",
")",
"{",
"// check that current user has rights to set this role\r",
"$",
"this",
"->",
"checkCurrentUserAccess",
"(",
"$",
"role",
")",
... | Attach a Generis Role to a given TAO User. A UserException will be
if an error occurs. If the User already has the role, nothing happens.
@access public
@author Jerome Bogaerts, <jerome@taotesting.com>
@param Resource user The User you want to attach a Role.
@param Resource role A Role to attach to a User.
@throws core_kernel_users_Exception If an error occurs. | [
"Attach",
"a",
"Generis",
"Role",
"to",
"a",
"given",
"TAO",
"User",
".",
"A",
"UserException",
"will",
"be",
"if",
"an",
"error",
"occurs",
".",
"If",
"the",
"User",
"already",
"has",
"the",
"role",
"nothing",
"happens",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.UserService.php#L439-L444 |
oat-sa/tao-core | models/classes/class.UserService.php | tao_models_classes_UserService.unnatachRole | public function unnatachRole(core_kernel_classes_Resource $user, core_kernel_classes_Resource $role)
{
try {
$this->checkCurrentUserAccess($role);
$this->generisUserService->unnatachRole($user, $role);
} catch (common_exception_Error $e) {
}
} | php | public function unnatachRole(core_kernel_classes_Resource $user, core_kernel_classes_Resource $role)
{
try {
$this->checkCurrentUserAccess($role);
$this->generisUserService->unnatachRole($user, $role);
} catch (common_exception_Error $e) {
}
} | [
"public",
"function",
"unnatachRole",
"(",
"core_kernel_classes_Resource",
"$",
"user",
",",
"core_kernel_classes_Resource",
"$",
"role",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"checkCurrentUserAccess",
"(",
"$",
"role",
")",
";",
"$",
"this",
"->",
"generisUs... | Unnatach a Role from a given TAO User.
@access public
@author Jerome Bogaerts, <jerome@taotesting.com>
@param Resource user A TAO user from which you want to unnattach the Role.
@param Resource role The Role you want to Unnatach from the TAO User.
@throws core_kernel_users_Exception If an error occurs. | [
"Unnatach",
"a",
"Role",
"from",
"a",
"given",
"TAO",
"User",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.UserService.php#L455-L462 |
oat-sa/tao-core | models/classes/class.UserService.php | tao_models_classes_UserService.getPermittedRoles | public function getPermittedRoles(core_kernel_classes_Resource $user, array $roles, $encoded = true)
{
$exclude = [];
if (!$this->userHasRoles($user, TaoRoles::SYSTEM_ADMINISTRATOR)) {
$exclude[] = $encoded ? tao_helpers_Uri::encode(TaoRoles::SYSTEM_ADMINISTRATOR) : TaoRoles::SYSTEM_ADMINISTRATOR;
if (!$this->userHasRoles($user, TaoRoles::GLOBAL_MANAGER)) {
$exclude[] = $encoded ? tao_helpers_Uri::encode(TaoRoles::GLOBAL_MANAGER) : TaoRoles::GLOBAL_MANAGER;
}
}
if (count($exclude)) {
$roles = array_filter($roles, function($k) use ($exclude) {
return !in_array($k, $exclude);
}, ARRAY_FILTER_USE_KEY);
}
return $roles;
} | php | public function getPermittedRoles(core_kernel_classes_Resource $user, array $roles, $encoded = true)
{
$exclude = [];
if (!$this->userHasRoles($user, TaoRoles::SYSTEM_ADMINISTRATOR)) {
$exclude[] = $encoded ? tao_helpers_Uri::encode(TaoRoles::SYSTEM_ADMINISTRATOR) : TaoRoles::SYSTEM_ADMINISTRATOR;
if (!$this->userHasRoles($user, TaoRoles::GLOBAL_MANAGER)) {
$exclude[] = $encoded ? tao_helpers_Uri::encode(TaoRoles::GLOBAL_MANAGER) : TaoRoles::GLOBAL_MANAGER;
}
}
if (count($exclude)) {
$roles = array_filter($roles, function($k) use ($exclude) {
return !in_array($k, $exclude);
}, ARRAY_FILTER_USE_KEY);
}
return $roles;
} | [
"public",
"function",
"getPermittedRoles",
"(",
"core_kernel_classes_Resource",
"$",
"user",
",",
"array",
"$",
"roles",
",",
"$",
"encoded",
"=",
"true",
")",
"{",
"$",
"exclude",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"userHasRoles",
"(... | Filter roles to leave only permitted roles
@param $user
@param $roles
@return array | [
"Filter",
"roles",
"to",
"leave",
"only",
"permitted",
"roles"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.UserService.php#L493-L508 |
oat-sa/tao-core | models/classes/class.UserService.php | tao_models_classes_UserService.checkCurrentUserAccess | public function checkCurrentUserAccess($roles)
{
if ($this->getCurrentUser() === null) {
return;
}
if ($roles instanceof core_kernel_classes_Resource) {
$roles = [$roles->getUri()];
}
if (is_array($roles)) {
$roles = array_map(function($role) {
return $role instanceof core_kernel_classes_Resource ? $role->getUri() : $role;
}, $roles);
}
if (in_array(TaoRoles::SYSTEM_ADMINISTRATOR, $roles)
&& !$this->userHasRoles($this->getCurrentUser(), TaoRoles::SYSTEM_ADMINISTRATOR)
) {
throw new common_exception_Error('Permission denied');
}
if (in_array(TaoRoles::GLOBAL_MANAGER, $roles)
&& !$this->userHasRoles($this->getCurrentUser(), [TaoRoles::SYSTEM_ADMINISTRATOR, TaoRoles::GLOBAL_MANAGER])
) {
throw new common_exception_Error('Permission denied');
}
} | php | public function checkCurrentUserAccess($roles)
{
if ($this->getCurrentUser() === null) {
return;
}
if ($roles instanceof core_kernel_classes_Resource) {
$roles = [$roles->getUri()];
}
if (is_array($roles)) {
$roles = array_map(function($role) {
return $role instanceof core_kernel_classes_Resource ? $role->getUri() : $role;
}, $roles);
}
if (in_array(TaoRoles::SYSTEM_ADMINISTRATOR, $roles)
&& !$this->userHasRoles($this->getCurrentUser(), TaoRoles::SYSTEM_ADMINISTRATOR)
) {
throw new common_exception_Error('Permission denied');
}
if (in_array(TaoRoles::GLOBAL_MANAGER, $roles)
&& !$this->userHasRoles($this->getCurrentUser(), [TaoRoles::SYSTEM_ADMINISTRATOR, TaoRoles::GLOBAL_MANAGER])
) {
throw new common_exception_Error('Permission denied');
}
} | [
"public",
"function",
"checkCurrentUserAccess",
"(",
"$",
"roles",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getCurrentUser",
"(",
")",
"===",
"null",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"roles",
"instanceof",
"core_kernel_classes_Resource",
")",
... | Thrown an exception if user doesn't have permissions
@param $roles
@throws common_exception_Error | [
"Thrown",
"an",
"exception",
"if",
"user",
"doesn",
"t",
"have",
"permissions"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/class.UserService.php#L515-L541 |
oat-sa/tao-core | models/classes/table/class.PropertyColumn.php | tao_models_classes_table_PropertyColumn.toArray | public function toArray()
{
$returnValue = array();
$returnValue = parent::toArray();
$returnValue['prop'] = $this->property->getUri();
return (array) $returnValue;
} | php | public function toArray()
{
$returnValue = array();
$returnValue = parent::toArray();
$returnValue['prop'] = $this->property->getUri();
return (array) $returnValue;
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"returnValue",
"=",
"array",
"(",
")",
";",
"$",
"returnValue",
"=",
"parent",
"::",
"toArray",
"(",
")",
";",
"$",
"returnValue",
"[",
"'prop'",
"]",
"=",
"$",
"this",
"->",
"property",
"->",
"get... | Short description of method toArray
@access public
@author Joel Bout, <joel.bout@tudor.lu>
@return array | [
"Short",
"description",
"of",
"method",
"toArray"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/table/class.PropertyColumn.php#L127-L137 |
oat-sa/tao-core | actions/form/class.PasswordRecovery.php | tao_actions_form_PasswordRecovery.initForm | public function initForm()
{
$this->form = tao_helpers_form_FormFactory::getForm('passwordRecoveryForm');
$connectElt = tao_helpers_form_FormFactory::getElement('recovery', 'Submit');
$connectElt->setValue(__('Email'));
$connectElt->setAttribute('class', 'btn-success small');
$this->form->setActions(array($connectElt), 'bottom');
} | php | public function initForm()
{
$this->form = tao_helpers_form_FormFactory::getForm('passwordRecoveryForm');
$connectElt = tao_helpers_form_FormFactory::getElement('recovery', 'Submit');
$connectElt->setValue(__('Email'));
$connectElt->setAttribute('class', 'btn-success small');
$this->form->setActions(array($connectElt), 'bottom');
} | [
"public",
"function",
"initForm",
"(",
")",
"{",
"$",
"this",
"->",
"form",
"=",
"tao_helpers_form_FormFactory",
"::",
"getForm",
"(",
"'passwordRecoveryForm'",
")",
";",
"$",
"connectElt",
"=",
"tao_helpers_form_FormFactory",
"::",
"getElement",
"(",
"'recovery'",
... | Initialize password recovery form
@access public
@author Aleh Hutnikau <hutnikau@1pt.com> | [
"Initialize",
"password",
"recovery",
"form"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/form/class.PasswordRecovery.php#L37-L45 |
oat-sa/tao-core | actions/form/class.PasswordRecovery.php | tao_actions_form_PasswordRecovery.initElements | public function initElements()
{
$mailElement = tao_helpers_form_FormFactory::getElement('userMail', 'Textbox');
$mailElement->setDescription(__('Your mail') . '*');
$mailElement->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty'));
$mailElement->addValidator(tao_helpers_form_FormFactory::getValidator('Email'));
$mailElement->setAttributes(array('autofocus' => 'autofocus'));
$this->form->addElement($mailElement);
} | php | public function initElements()
{
$mailElement = tao_helpers_form_FormFactory::getElement('userMail', 'Textbox');
$mailElement->setDescription(__('Your mail') . '*');
$mailElement->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty'));
$mailElement->addValidator(tao_helpers_form_FormFactory::getValidator('Email'));
$mailElement->setAttributes(array('autofocus' => 'autofocus'));
$this->form->addElement($mailElement);
} | [
"public",
"function",
"initElements",
"(",
")",
"{",
"$",
"mailElement",
"=",
"tao_helpers_form_FormFactory",
"::",
"getElement",
"(",
"'userMail'",
",",
"'Textbox'",
")",
";",
"$",
"mailElement",
"->",
"setDescription",
"(",
"__",
"(",
"'Your mail'",
")",
".",
... | Initialiaze recovery form elements
@access public
@author Aleh Hutnikau <hutnikau@1pt.com> | [
"Initialiaze",
"recovery",
"form",
"elements"
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/form/class.PasswordRecovery.php#L53-L62 |
oat-sa/tao-core | actions/class.PropertiesAuthoring.php | tao_actions_PropertiesAuthoring.addClassProperty | public function addClassProperty()
{
if(!$this->isXmlHttpRequest()){
throw new common_exception_BadRequest('wrong request mode');
}
$clazz = $this->getClass($this->getRequestParameter('id'));
if($this->hasRequestParameter('index')){
$index = intval($this->getRequestParameter('index'));
}
else{
$index = count($clazz->getProperties(false)) + 1;
}
$propMode = 'simple';
if($this->hasSessionAttribute('property_mode')){
$propMode = $this->getSessionAttribute('property_mode');
}
//instanciate a property form
$propFormClass = 'tao_actions_form_'.ucfirst(strtolower($propMode)).'Property';
if(!class_exists($propFormClass)){
$propFormClass = 'tao_actions_form_SimpleProperty';
}
$propFormContainer = new $propFormClass($clazz, $clazz->createProperty('Property_'.$index), array('index' => $index));
$myForm = $propFormContainer->getForm();
$this->setData('data', $myForm->renderElements());
$this->setView('blank.tpl', 'tao');
} | php | public function addClassProperty()
{
if(!$this->isXmlHttpRequest()){
throw new common_exception_BadRequest('wrong request mode');
}
$clazz = $this->getClass($this->getRequestParameter('id'));
if($this->hasRequestParameter('index')){
$index = intval($this->getRequestParameter('index'));
}
else{
$index = count($clazz->getProperties(false)) + 1;
}
$propMode = 'simple';
if($this->hasSessionAttribute('property_mode')){
$propMode = $this->getSessionAttribute('property_mode');
}
//instanciate a property form
$propFormClass = 'tao_actions_form_'.ucfirst(strtolower($propMode)).'Property';
if(!class_exists($propFormClass)){
$propFormClass = 'tao_actions_form_SimpleProperty';
}
$propFormContainer = new $propFormClass($clazz, $clazz->createProperty('Property_'.$index), array('index' => $index));
$myForm = $propFormContainer->getForm();
$this->setData('data', $myForm->renderElements());
$this->setView('blank.tpl', 'tao');
} | [
"public",
"function",
"addClassProperty",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isXmlHttpRequest",
"(",
")",
")",
"{",
"throw",
"new",
"common_exception_BadRequest",
"(",
"'wrong request mode'",
")",
";",
"}",
"$",
"clazz",
"=",
"$",
"this",
"... | Render the add property sub form.
@throws Exception
@throws common_exception_BadRequest
@return void
@requiresRight id WRITE | [
"Render",
"the",
"add",
"property",
"sub",
"form",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.PropertiesAuthoring.php#L84-L115 |
oat-sa/tao-core | actions/class.PropertiesAuthoring.php | tao_actions_PropertiesAuthoring.removeClassProperty | public function removeClassProperty()
{
$success = false;
if(!$this->isXmlHttpRequest()){
throw new common_exception_BadRequest('wrong request mode');
}
$class = $this->getClass($this->getRequestParameter('classUri'));
$property = $this->getProperty($this->getRequestParameter('uri'));
//delete property mode
foreach($class->getProperties() as $classProperty) {
if ($classProperty->equals($property)) {
$indexes = $property->getPropertyValues($this->getProperty(OntologyIndex::PROPERTY_INDEX));
//delete property and the existing values of this property
if($property->delete(true)){
//delete index linked to the property
foreach($indexes as $indexUri){
$index = $this->getResource($indexUri);
$index->delete(true);
}
$success = true;
break;
}
}
}
if ($success) {
$this->returnJson(array(
'success' => true
));
return;
} else {
$this->returnError(__('Unable to remove the property.'));
}
} | php | public function removeClassProperty()
{
$success = false;
if(!$this->isXmlHttpRequest()){
throw new common_exception_BadRequest('wrong request mode');
}
$class = $this->getClass($this->getRequestParameter('classUri'));
$property = $this->getProperty($this->getRequestParameter('uri'));
//delete property mode
foreach($class->getProperties() as $classProperty) {
if ($classProperty->equals($property)) {
$indexes = $property->getPropertyValues($this->getProperty(OntologyIndex::PROPERTY_INDEX));
//delete property and the existing values of this property
if($property->delete(true)){
//delete index linked to the property
foreach($indexes as $indexUri){
$index = $this->getResource($indexUri);
$index->delete(true);
}
$success = true;
break;
}
}
}
if ($success) {
$this->returnJson(array(
'success' => true
));
return;
} else {
$this->returnError(__('Unable to remove the property.'));
}
} | [
"public",
"function",
"removeClassProperty",
"(",
")",
"{",
"$",
"success",
"=",
"false",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isXmlHttpRequest",
"(",
")",
")",
"{",
"throw",
"new",
"common_exception_BadRequest",
"(",
"'wrong request mode'",
")",
";",
"}... | Render the add property sub form.
@throws Exception
@throws common_exception_BadRequest
@return void
@requiresRight classUri WRITE | [
"Render",
"the",
"add",
"property",
"sub",
"form",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.PropertiesAuthoring.php#L125-L161 |
oat-sa/tao-core | actions/class.PropertiesAuthoring.php | tao_actions_PropertiesAuthoring.removePropertyIndex | public function removePropertyIndex()
{
if(!$this->isXmlHttpRequest()){
throw new common_exception_BadRequest('wrong request mode');
}
if(!$this->hasRequestParameter('uri')){
throw new common_exception_MissingParameter("Uri parameter is missing");
}
if(!$this->hasRequestParameter('indexProperty')){
throw new common_exception_MissingParameter("indexProperty parameter is missing");
}
$indexPropertyUri = tao_helpers_Uri::decode($this->getRequestParameter('indexProperty'));
//remove use of index property in property
$property = $this->getProperty(tao_helpers_Uri::decode($this->getRequestParameter('uri')));
$property->removePropertyValue($this->getProperty(OntologyIndex::PROPERTY_INDEX),$indexPropertyUri);
//remove index property
$indexProperty = new OntologyIndex($indexPropertyUri);
$indexProperty->delete();
$this->returnJson(array('id' => $this->getRequestParameter('indexProperty')));
} | php | public function removePropertyIndex()
{
if(!$this->isXmlHttpRequest()){
throw new common_exception_BadRequest('wrong request mode');
}
if(!$this->hasRequestParameter('uri')){
throw new common_exception_MissingParameter("Uri parameter is missing");
}
if(!$this->hasRequestParameter('indexProperty')){
throw new common_exception_MissingParameter("indexProperty parameter is missing");
}
$indexPropertyUri = tao_helpers_Uri::decode($this->getRequestParameter('indexProperty'));
//remove use of index property in property
$property = $this->getProperty(tao_helpers_Uri::decode($this->getRequestParameter('uri')));
$property->removePropertyValue($this->getProperty(OntologyIndex::PROPERTY_INDEX),$indexPropertyUri);
//remove index property
$indexProperty = new OntologyIndex($indexPropertyUri);
$indexProperty->delete();
$this->returnJson(array('id' => $this->getRequestParameter('indexProperty')));
} | [
"public",
"function",
"removePropertyIndex",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isXmlHttpRequest",
"(",
")",
")",
"{",
"throw",
"new",
"common_exception_BadRequest",
"(",
"'wrong request mode'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"... | remove the index of the property.
@throws Exception
@throws common_exception_BadRequest
@return void | [
"remove",
"the",
"index",
"of",
"the",
"property",
"."
] | train | https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/class.PropertiesAuthoring.php#L169-L193 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.