/** * @return sorted array */ public function getAttributesForTimeTrigger() { $attributes = $this->resolveAttributesForActionsOrTimeTriggerData(true, true, true); $attributes = array_merge($attributes, $this->resolveDynamicallyDerivedAttributesForActionsOrTimeTriggerData(true, true, true)); $sortedAttributes = ArrayUtil::subValueSort($attributes, 'label', 'asort'); return $sortedAttributes; }
/** * @return array of all module rights data */ public static function getAllModuleRightsDataByPermitable(Permitable $permitable) { $data = array(); $modules = Module::getModuleObjects(); foreach ($modules as $module) { if ($module instanceof SecurableModule) { $moduleClassName = get_class($module); $rights = $moduleClassName::getRightsNames(); $rightLabels = $moduleClassName::getTranslatedRightsLabels(); $reflectionClass = new ReflectionClass($moduleClassName); if (!empty($rights)) { $rightsData = array(); foreach ($rights as $right) { if (!isset($rightLabels[$right])) { throw new NotSupportedException($right); } $explicit = $permitable->getExplicitActualRight($moduleClassName, $right); $inherited = $permitable->getInheritedActualRight($moduleClassName, $right); $effective = $permitable->getEffectiveRight($moduleClassName, $right); $constants = $reflectionClass->getConstants(); $constantId = array_search($right, $constants); $rightsData[$constantId] = array('displayName' => $rightLabels[$right], 'explicit' => RightsUtil::getRightStringFromRight($explicit), 'inherited' => RightsUtil::getRightStringFromRight($inherited), 'effective' => RightsUtil::getRightStringFromRight($effective)); } $data[$moduleClassName] = ArrayUtil::subValueSort($rightsData, 'displayName', 'asort'); } } } return $data; }
/** * Helper function to get all model attributes as an array, that we can compare with responses from API. * @param OwnedSecurableItem $model * @return array */ public static function getModelAttributes(RedBeanModel $model) { $adapter = new ModelAttributesAdapter($model); $customAttributes = ArrayUtil::subValueSort($adapter->getCustomAttributes(), 'attributeLabel', 'asort'); $standardAttributes = ArrayUtil::subValueSort($adapter->getStandardAttributes(), 'attributeLabel', 'asort'); $allAttributes = array_merge($customAttributes, $standardAttributes); return $allAttributes; }
/** * @return array */ public function getAttributesForOrderBys() { $attributes = $this->getAttributesNotIncludingDerivedAttributesData(); $attributes = $this->resolveAttributesForOrderBys($attributes); $attributes = array_merge($attributes, $this->getDynamicallyDerivedAttributesData()); $sortedAttributes = ArrayUtil::subValueSort($attributes, 'label', 'asort'); return $sortedAttributes; }
/** * Get list of all index and derived attributes * @return array of all attributes */ public static function getAllAttributes() { $contact = new Contact(); $adapter = new ContactWebFormModelAttributesAdapter($contact); $attributes = $adapter->getAttributes(); $attributes = ArrayUtil::subValueSort($attributes, 'attributeLabel', 'asort'); return $attributes; }
/** * @param RedBeanModel $precedingModel * @param null $precedingRelation * @return array|sorted * @throws NotSupportedException */ public function getSelectableRelationsData(RedBeanModel $precedingModel = null, $precedingRelation = null) { if ($precedingModel != null && $precedingRelation == null || $precedingModel == null && $precedingRelation != null) { throw new NotSupportedException(); } $attributes = array(); foreach ($this->model->getAttributes() as $attribute => $notUsed) { if ($this->model->isRelation($attribute) && !$this->rules->relationIsReportedAsAttribute($this->model, $attribute) && $this->rules->attributeIsReportable($this->model, $attribute) && !$this->relationLinksToPrecedingRelation($attribute, $precedingModel, $precedingRelation) && $this->model->isRelationTypeAHasOneVariant($attribute)) { $this->resolveRelationToSelectableRelationData($attributes, $attribute); } } $sortedAttributes = ArrayUtil::subValueSort($attributes, 'label', 'asort'); return $sortedAttributes; }
/** * Get list of all index and derived attributes that can be placed on any web form * @return array of all attributes */ public static function getAllAttributes() { $contact = new Contact(); $adapter = new ContactWebFormModelAttributesAdapter($contact); $attributes = $adapter->getAttributes(); $placeAbleAttributes = array(); foreach ($attributes as $attributeName => $attributeData) { if (!$attributeData['isReadOnly'] && $attributeName != 'googleWebTrackingId') { $placeAbleAttributes[$attributeName] = $attributeData; } } $placeAbleAttributes = ArrayUtil::subValueSort($placeAbleAttributes, 'attributeLabel', 'asort'); return $placeAbleAttributes; }
protected function getLanguagesList($languageStatus = null) { if (is_array($this->languagesList) && !empty($this->languagesList)) { switch ($languageStatus) { case self::LANGUAGE_STATUS_ACTIVE: return $this->languagesList[self::LANGUAGE_STATUS_ACTIVE]; break; case self::LANGUAGE_STATUS_INACTIVE: return $this->languagesList[self::LANGUAGE_STATUS_INACTIVE]; break; case null: return $this->languagesList; break; } } $languagesList = array(self::LANGUAGE_STATUS_ACTIVE => array(), self::LANGUAGE_STATUS_INACTIVE => array()); $languagesData = self::getLanguagesData(); foreach ($languagesData as $languageCode => $languageData) { if ($languageData['active']) { $status = self::LANGUAGE_STATUS_ACTIVE; } else { $status = self::LANGUAGE_STATUS_INACTIVE; } $languagesList[$status][$languageCode] = $languageData; } $languagesList[self::LANGUAGE_STATUS_ACTIVE] = ArrayUtil::subValueSort($languagesList[self::LANGUAGE_STATUS_ACTIVE], 'label', 'asort'); $languagesList[self::LANGUAGE_STATUS_INACTIVE] = ArrayUtil::subValueSort($languagesList[self::LANGUAGE_STATUS_INACTIVE], 'label', 'asort'); $this->languagesList = $languagesList; return $this->getLanguagesList($languageStatus); }
protected static function sortCategoryItems($categoryItems) { return ArrayUtil::subValueSort($categoryItems, 'titleLabel', 'asort'); }
/** * Exclude User relations and Owned relations. * @return sorted array */ public function getSelectableRelationsDataForActionTypeRelation() { $attributes = array(); foreach ($this->model->getAttributes() as $attribute => $notUsed) { if ($this->model->isRelation($attribute) && !$this->rules->relationIsUsedAsAttribute($this->model, $attribute) && $this->rules->attributeCanBeTriggered($this->model, $attribute) && !$this->model->isOwnedRelation($attribute) && $this->model->getRelationModelClassName($attribute) != 'User') { $this->resolveRelationToSelectableRelationData($attributes, $attribute); } } $attributes = array_merge($attributes, $this->getDerivedRelationsViaCastedUpModelData()); $attributes = array_merge($attributes, $this->getInferredRelationsData()); $sortedAttributes = ArrayUtil::subValueSort($attributes, 'label', 'asort'); return $sortedAttributes; }
/** * @return array */ public function getAttributesForGroupBys() { $attributes = array(); if ($this->shouldIncludeIdAsGroupByAttribute) { $attributes['id'] = array('label' => Zurmo::t('Core', 'Id')); } $attributes = array_merge($attributes, $this->getGroupByModifierAttributes()); $attributes = array_merge($attributes, $this->getDynamicallyDerivedAttributesData()); $sortedAttributes = ArrayUtil::subValueSort($attributes, 'label', 'asort'); return $sortedAttributes; }
/** * List all model attributes * @param $params * @return ApiResult * @throws ApiException */ protected function processListAttributes($params) { $data = array(); try { $modelClassName = $this->getModelName(); $model = new $modelClassName(); $adapter = new ModelAttributesAdapter($model); $customAttributes = ArrayUtil::subValueSort($adapter->getCustomAttributes(), 'attributeLabel', 'asort'); $standardAttributes = ArrayUtil::subValueSort($adapter->getStandardAttributes(), 'attributeLabel', 'asort'); $allAttributes = array_merge($customAttributes, $standardAttributes); $data['items'] = $allAttributes; $result = new ApiResult(ApiResponse::STATUS_SUCCESS, $data, null, null); } catch (Exception $e) { $message = $e->getMessage(); throw new ApiException($message); } return $result; }
public function actionModuleLayoutsList() { assert('!empty($_GET["moduleClassName"])'); $moduleClassName = $_GET['moduleClassName']; $module = new $_GET['moduleClassName'](null, null); $modelClassName = $moduleClassName::getPrimaryModelName(); $model = new $modelClassName(); $viewClassNames = $moduleClassName::getViewClassNames(); $editableViewsCollection = array(); foreach ($viewClassNames as $className) { $classToEvaluate = new ReflectionClass($className); if (is_subclass_of($className, 'MetadataView') && !$classToEvaluate->isAbstract() && $className::getDesignerRulesType() != null) { $designerRulesType = $className::getDesignerRulesType(); $designerRulesClassName = $designerRulesType . 'DesignerRules'; $designerRules = new $designerRulesClassName(); if ($designerRules->allowEditInLayoutTool()) { $editableViewsCollection[] = array('titleLabel' => $designerRules->resolveDisplayNameByView($className), 'route' => '/designer/default/layoutEdit', 'viewClassName' => $className); } } } $editableViewsCollection = ArrayUtil::subValueSort($editableViewsCollection, 'titleLabel', 'asort'); $title = $moduleClassName::getModuleLabelByTypeAndLanguage('Plural') . ': ' . Zurmo::t('DesignerModule', 'Layouts'); $breadcrumbLinks = array($title); $canvasView = new ActionBarAndModuleEditableMetadataCollectionView($this->getId(), $this->getModule()->getId(), $module, $moduleClassName::getModuleLabelByTypeAndLanguage('Plural'), $editableViewsCollection, $title); $view = new DesignerPageView(ZurmoDefaultAdminViewUtil::makeViewWithBreadcrumbsForCurrentUser($this, $canvasView, $breadcrumbLinks, 'DesignerBreadCrumbView')); echo $view->render(); }