protected function resolveActionElementInformationDuringRender(&$elementInformation) { parent::resolveActionElementInformationDuringRender($elementInformation); if ($elementInformation['type'] == $this->activeActionElementType) { $elementInformation['htmlOptions']['class'] .= ' active'; } }
/** * @param $element * @param $elementInformation * @return bool */ protected function shouldRenderToolBarElement($element, $elementInformation) { assert('$element instanceof ActionElement'); assert('is_array($elementInformation)'); $moduleMenuItems = $this->module->getDesignerMenuItems(); if (!parent::shouldRenderToolBarElement($element, $elementInformation)) { return false; } if ($elementInformation['type'] == 'DesignerGeneralMenu' && !ArrayUtil::getArrayValue($moduleMenuItems, 'showGeneralLink')) { return false; } if ($elementInformation['type'] == 'DesignerFieldsMenu' && !ArrayUtil::getArrayValue($moduleMenuItems, 'showFieldsLink')) { return false; } if ($elementInformation['type'] == 'DesignerLayoutsMenu' && !ArrayUtil::getArrayValue($moduleMenuItems, 'showLayoutsLink')) { return false; } return true; }
protected function shouldRenderToolBarElement($element, $elementInformation) { if (!parent::shouldRenderToolBarElement($element, $elementInformation)) { return false; } if (in_array($elementInformation['type'], array('UserEditLink', 'AuditEventsModalListLink', 'ChangePasswordLink', 'UserConfigurationLink')) && !UserAccessUtil::canCurrentUserViewALinkRequiringElevatedAccess($this->model)) { return false; } return true; }
protected static function assertMetadataIsValid(array $metadata) { parent::assertMetadataIsValid($metadata); $attributeNames = array(); $derivedTypes = array(); if (isset($metadata['global']['panels'])) { foreach ($metadata["global"]["panels"] as $panel) { assert('is_array($panel["rows"])'); foreach ($panel["rows"] as $row) { $cellCount = 0; assert('is_array($row["cells"])'); foreach ($row["cells"] as $cell) { if (is_array($cell['elements'])) { assert('count($cell["elements"]) == 1'); $elementInformation = $cell['elements'][0]; if ($elementInformation['attributeName'] == 'null') { assert('!in_array($elementInformation["type"], $derivedTypes)'); $derivedTypes[] = $elementInformation['type']; $elementclassname = $elementInformation['type'] . 'Element'; assert('class_exists($elementclassname)'); } elseif ($elementInformation['attributeName'] == null) { assert('$elementInformation["type"] == "Null"'); // Not Coding Standard } else { /* Is attribute present more than once on the view? */ assert('!in_array($elementInformation["attributeName"], $attributeNames)'); $attributeNames[] = $elementInformation['attributeName']; assert('is_string($elementInformation["attributeName"])'); } } $cellCount++; $designerRules = DesignerRulesFactory::createDesignerRulesByView(get_called_class()); if ($designerRules != null) { assert('$cellCount <= $designerRules->maxCellsPerRow()'); } } } } } if (isset($metadata['global']['toolbar'])) { assert('is_array($metadata["global"]["toolbar"]["elements"])'); assert('count($metadata["global"]["toolbar"]) == 1'); $elementTypes = array(); foreach ($metadata['global']['toolbar']['elements'] as $elementInformation) { assert('isset($elementInformation["type"])'); $elementTypes[] = $elementInformation['type']; $elementclassname = $elementInformation['type'] . 'ActionElement'; assert('class_exists($elementclassname)'); } } if (isset($metadata['global']['nonPlaceableAttributeNames'])) { assert('is_array($metadata["global"]["nonPlaceableAttributeNames"])'); } assert('!isset($metadata["derivedAttributeTypes"])'); if (isset($metadata['global']['derivedAttributeTypes'])) { assert('is_array($metadata["global"]["derivedAttributeTypes"])'); foreach ($metadata['global']['derivedAttributeTypes'] as $elementType) { $elementclassname = $elementType . 'Element'; assert('class_exists($elementclassname)'); } } }
/** * Override to check for different scenarios depending on if the group is * special or not. Everyone and SuperAdministrators are special groups * for example. * Checks for $elementInformation['resolveToDisplay'] to be present and if it is, * will run the resolveName as a function on the group model. * @return boolean */ protected function shouldRenderToolBarElement($element, $elementInformation) { assert('$element instanceof ActionElement'); assert('is_array($elementInformation)'); if (!parent::shouldRenderToolBarElement($element, $elementInformation)) { return false; } if (isset($elementInformation['resolveToDisplay'])) { $resolveMethodName = $elementInformation['resolveToDisplay']; if (!$this->model->{$resolveMethodName}()) { return false; } } return true; }
/** * Expects there to be a modelClassName parameter passed through the elementInformation that can be used * to compare the Rights security on based on the actionType of the element. * (non-PHPdoc) * @see MetadataView::shouldRenderToolBarElement() */ protected function shouldRenderToolBarElement($element, $elementInformation) { assert('$element instanceof ActionElement'); assert('is_array($elementInformation)'); if (!parent::shouldRenderToolBarElement($element, $elementInformation)) { return false; } if (isset($elementInformation['modelClassName'])) { $modelClassName = $elementInformation['modelClassName']; //Todo: figure out how to not need to new up a new model. return ActionSecurityUtil::canCurrentUserPerformAction($element->getActionType(), new $modelClassName(false)); } return true; }