public static function resolveBreadCrumbViewForDetailsControllerAction(CController $controller, $stickySearchKey, RedBeanModel $model) { assert('is_string($stickySearchKey)'); if (ArrayUtil::getArrayValue(GetUtil::getData(), 'stickyOffset') !== null && StickySearchUtil::getDataByKey($stickySearchKey) != null) { $stickyLoadUrl = Yii::app()->createUrl($controller->getModule()->getId() . '/' . $controller->getId() . '/renderStickyListBreadCrumbContent', array('stickyKey' => $stickySearchKey, 'stickyOffset' => ArrayUtil::getArrayValue(GetUtil::getData(), 'stickyOffset'), 'stickyModelId' => $model->id)); } else { $stickyLoadUrl = null; } $className = static::resolveStickyDetailsAndRelationsBreadCrumbViewClassName(); return new $className($controller->getId(), $controller->getModule()->getId(), static::resolveBreadcrumbLinks($model), $controller->getModule()->getModuleLabelByTypeAndLanguage('Plural'), $stickyLoadUrl); }
/** * @return rendered content from view as string. */ public static function renderList(CController $controller, $dataProvider) { assert('$dataProvider instanceof RedBeanModelDataProvider'); $auditEventsListView = new AuditEventsModalListView($controller->getId(), $controller->getModule()->getId(), 'AuditEvent', $dataProvider, 'modal'); $view = new ModalView($controller, $auditEventsListView); return $view->render(); }
/** * @return rendered content from view as string. */ public static function renderList(CController $controller, $dataProvider, $action) { assert('$dataProvider instanceof RedBeanModelDataProvider'); $modalListLinkProvider = new UserDetailsModalListLinkProvider('users', 'default', 'details'); $usersListView = new UsersByModelModalListView($controller->getId(), $controller->getModule()->getId(), $action, 'User', $modalListLinkProvider, $dataProvider, 'modal'); $view = new ModalView($controller, $usersListView); return $view->render(); }
/** * @return rendered content from view as string. */ protected static function renderModalSearchList(CController $controller, $modalListLinkProvider, $stateMetadataAdapterClassName = null) { assert('$modalListLinkProvider instanceof ModalListLinkProvider'); $className = $controller->getModule()->getPluralCamelCasedName() . 'ModalSearchAndListView'; $modelClassName = $controller->getModule()->getPrimaryModelName(); $searchViewClassName = $className::getSearchViewClassName(); if ($searchViewClassName::getModelForMetadataClassName() != null) { $formModelClassName = $searchViewClassName::getModelForMetadataClassName(); $model = new $modelClassName(false); $searchModel = new $formModelClassName($model); } else { throw new NotSupportedException(); } $pageSize = Yii::app()->pagination->resolveActiveForCurrentUserByType('modalListPageSize', get_class($controller->getModule())); $dataProvider = $controller->makeRedBeanDataProviderByDataCollection($searchModel, $pageSize, $stateMetadataAdapterClassName); $searchAndListView = new $className($controller->getId(), $controller->getModule()->getId(), $controller->getAction()->getId(), $modalListLinkProvider, $searchModel, $model, $dataProvider, 'modal'); $view = new ModalView($controller, $searchAndListView); return $view->render(); }
protected static function makeHeaderView(CController $controller) { $headerView = null; $settingsMenuItems = MenuUtil::getOrderedAccessibleHeaderMenuForCurrentUser(); $settingsMenuItems = static::resolveHeaderMenuItemsForMobile($settingsMenuItems); $userMenuItems = static::getAndResolveUserMenuItemsForHeader(); $applicationName = ZurmoConfigurationUtil::getByModuleName('ZurmoModule', 'applicationName'); if (Yii::app()->userInterface->isMobile()) { $headerView = new MobileHeaderView($settingsMenuItems, $userMenuItems, $applicationName); } else { $shortcutsCreateMenuItems = MenuUtil::getAccessibleShortcutsCreateMenuByCurrentUser(); $moduleNamesAndLabels = GlobalSearchUtil::getGlobalSearchScopingModuleNamesAndLabelsDataByUser(Yii::app()->user->userModel); $sourceUrl = Yii::app()->createUrl('zurmo/default/globalSearchAutoComplete'); GlobalSearchUtil::resolveModuleNamesAndLabelsDataWithAllOption($moduleNamesAndLabels); $headerView = new HeaderView($controller->getId(), $controller->getModule()->getId(), $settingsMenuItems, $userMenuItems, $shortcutsCreateMenuItems, $moduleNamesAndLabels, $sourceUrl, $applicationName); } return $headerView; }
/** * Map modal view for map popup.. * @return rendered content from view as string. */ protected function renderModalMapView(CController $controller, $modalMapAddressData, $stateMetadataAdapterClassName = null) { $renderAndMapModalView = new AddressMapModalView($controller->getId(), $controller->getModule()->getId(), $modalMapAddressData, 'modal'); $view = new ModalView($controller, $renderAndMapModalView); return $view->render(); }
/** * Finds the layout file for the specified controller's layout. * @param CController $controller the controller * @param string $layoutName the layout name * @return string the layout file path. False if the file does not exist. */ public function getLayoutFile($controller, $layoutName) { $moduleViewPath = $basePath = $this->getViewPath(); $module = $controller->getModule(); if (empty($layoutName)) { while ($module !== null) { if ($module->layout === false) { return false; } if (!empty($module->layout)) { break; } $module = $module->getParentModule(); } if ($module === null) { $layoutName = Yii::app()->layout; } else { $layoutName = $module->layout; $moduleViewPath .= '/' . $module->getId(); } } else { if ($module !== null) { $moduleViewPath .= '/' . $module->getId(); } } return $controller->resolveViewFile($layoutName, $moduleViewPath . '/layouts', $basePath, $moduleViewPath); }
/** * Eventually refactor to support different randomness seeds on a per module basis, but until this is fleshed * out more, we will just hard-code the seeding here. */ public static function showCoin(CController $controller) { //Reporting and Data cleanup actions should show coins more frequently if ($controller->getModule()->getId() == 'reports') { $value = mt_rand(1, 25); } else { $value = mt_rand(1, 50); } if ($value == 7) { return true; } return false; }
/** * Given a controller, two contained views, construct the gridview * used by the designer page view. * @param CController $controller * @param View $containedView * @param View $secondContainedView * @param array $breadCrumbLinks * @param $breadcrumbViewClassName * @param array $cssClasses * @return GridView */ public static function makeTwoViewsWithBreadcrumbsForCurrentUser(CController $controller, View $containedView, View $secondContainedView, $breadCrumbLinks, $breadcrumbViewClassName, $cssClasses = array()) { assert('is_array($breadCrumbLinks)'); $gridView = new GridView(3, 1); $gridView->setCssClasses($cssClasses); $gridView->setView(new $breadcrumbViewClassName($controller->getId(), $controller->getModule()->getId(), $breadCrumbLinks), 0, 0); $gridView->setView($containedView, 1, 0); $gridView->setView($secondContainedView, 2, 0); return static::makeStandardViewForCurrentUser($controller, $gridView); }
/** * Gets the action instances for the given controller * @param \CController $controller the controller to get actions for * * @return \CAction[] the controller actions */ public function getActionInstances(\CController $controller) { $controllerId = $controller->getId(); $module = $controller->getModule(); if (!is_object($module)) { $module = \Yii::app(); } $uniqueId = $this->getModuleUniqueId($module); if (!isset($this->_data[$uniqueId])) { $this->_data[$uniqueId] = array(); } if (!isset($this->_data[$uniqueId]['controllers'])) { $this->getControllerInstances($module); } if (!isset($this->_data[$uniqueId]['controllers'][$controllerId]['actions'])) { $this->_data[$uniqueId]['controllers'][$controllerId]['actions'] = $this->createActionInstances($controller); } return $this->_data[$uniqueId]['controllers'][$controllerId]['actions']; }