echo 'Skipping Module Table ... <br>'; } // check to see if the parameter 'skipTables' was provided $skipTables = isset($_REQUEST['skipTables']); // if NOT then reset the tables... if (!$skipTables) { /* * NavBarGroup Table * * Divides the NavBar into seperate Groups. Links on the NavBar are under these groups. * * navbargroup_id [INTEGER] Primary Key for this table * navbargroup_nameKey [STRING] The multilingual lookup key to retrieve the group name. '[group_[nameKey]]' * navbargroup_order [INTEGER] defines the order in which the groups are to be displayed on the Nav Bar. */ $NavBarGroup = new RowManager_NavBarGroupManager(); $NavBarGroup->dropTable(); $NavBarGroup->createTable(); // NavBarGroup is a RowLabelBridge, so we must use that to create the initial // entries: $seriesKey = moduleNavBar::MULTILINGUAL_SERIES_KEY; $pageKey = RowManager_NavBarGroupManager::XML_NODE_NAME; $multiLingualContext = new MultilingualManager(1, $seriesKey, $pageKey); $group = $NavBarGroup->getRowLabelBridge($multiLingualContext); $values = array(); $values['label_label'] = 'Admin'; $group->loadFromArray($values); $group->createNewEntry(); /* * NavBarLinks Table *
/** * function getHTML * <pre> * This method returns the HTML data generated by this object. * </pre> * @return [STRING] HTML Display data. */ function getHTML() { // Uncomment the following line if you want to create a template // tailored for this page: //$path = $this->pathModuleRoot.'templates/'; // Otherwise use the standard Templates for the site: $path = SITE_PATH_TEMPLATES; /* * store the link values */ // example: // $this->linkValues[ 'view' ] = 'add/new/href/data/here'; // store the link labels $this->linkLabels['edit'] = $this->labels->getLabel('[Edit]'); $this->linkLabels['del'] = $this->labels->getLabel('[Delete]'); $this->linkLabels['cont'] = $this->labels->getLabel('[Continue]'); // $this->linkLabels[ 'view' ] = 'new link label here'; /* * store any additional link Columns */ // example: $title = $this->labels->getLabel('[title_access_groups]'); $columnLabel = $this->labels->getLabel('[accessGroups]'); $link = $this->linkValues['accessGroups']; $fieldName = 'navbarlink_id'; $this->addLinkColumn($title, $columnLabel, $link, $fieldName); $title = $this->labels->getLabel('[title_viewer]'); $columnLabel = $this->labels->getLabel('[viewers]'); $link = $this->linkValues['viewers']; $fieldName = 'navbarlink_id'; $this->addLinkColumn($title, $columnLabel, $link, $fieldName); /* * Update any label tags ... */ // example: $groupManager = new RowManager_NavBarGroupManager($this->navbargroup_id); $seriesKey = moduleNavBar::MULTILINGUAL_SERIES_KEY; $pageKey = $groupManager->getXMLNodeName(); $groupMultiLingual = new MultilingualManager($this->viewer->getLanguageID(), $seriesKey, $pageKey); $bridgeManager = new RowLabelBridge($groupManager, $groupMultiLingual); $name = $bridgeManager->getLabel(); $this->labels->setLabelTag('[Title]', '[groupName]', $name); // NOTE: this parent method prepares the $this->template with the // common AdminBox data. $this->prepareTemplate($path); // store the statevar id to edit $this->template->set('editEntryID', $this->navbarlink_id); // store all the fields to the template $this->setFormFieldsToTemplate(); /* * Form related Template variables: */ /* * Insert the date start/end values for the following date fields: */ // example: //$this->template->set( 'startYear_[fieldName]', 2000); //$this->template->set( 'endYear_[fieldName]', 2010); /* * List related Template variables : */ // Store the XML Node name for the Data Access Field List $xmlNodeName = $this->dataManager->getXMLNodeName(); $this->template->set('rowManagerXMLNodeName', $xmlNodeName); // store the primary key field name for the data being displayed $this->template->set('primaryKeyFieldName', 'navbarlink_id'); // store data list to the template // NOTE: we initialize it here to make sure we capture any new data // from a recent processData() call. // $this->dataList = new NavBarLinksList( $this->navbargroup_id, $this->sortBy ); $linkManager = new RowManager_NavBarLinksManager(); $linkManager->setGroupID($this->navbargroup_id); $bridgeManager = new RowLabelBridge($linkManager, $this->bridgeMultiLingualManager); $bridgeManager->setSortOrder($this->sortBy); $this->dataList = $bridgeManager->getListIterator(); $this->template->setXML('dataList', $this->dataList->getXML()); /* * Add any additional data required by the template here */ $moduleManager = new RowManager_siteModuleManager(); $moduleManager->setSortOrder($moduleManager->getLabelField()); $moduleList = $moduleManager->getListIterator(); $this->template->set('list_module_id', $moduleList->getDropListArray()); $dateList = array('0000-00-00 00:00:00' => ''); $this->template->set('list_navbarlink_startDateTime', $dateList); $this->template->set('list_navbarlink_endDateTime', $dateList); $templateName = TEMPLATE_ADMIN_BOX; // if you are creating a custom template for this page then // replace $templateName with the following: //$templateName = 'page_LinkList.php'; return $this->template->fetch($templateName); }
/** * function createCache * <pre> * Create a cache entry for a given viewer_id and language_id * </pre> * @param $viewerID [OBJECT] the viewer object of the person to make a * cache entry for. * @return [void] */ function createCache($viewer) { $viewerID = $viewer->getID(); $languageID = $viewer->getLanguageID(); $groupArray = array(); // Make sure all required Row Managers are included $accountAdminPath = SITE_PATH_MODULES . 'site_AccountAdmin/objects_da/'; $navBarPath = SITE_PATH_MODULES . 'site_NavBar/objects_da/'; $pathToRoot = Page::findPathExtension($accountAdminPath); require_once $pathToRoot . $accountAdminPath . 'ViewerAccessGroupManager.php'; require_once $pathToRoot . $navBarPath . 'NavBarGroupManager.php'; require_once $pathToRoot . $navBarPath . 'NavLinkAccessGroupManager.php'; require_once $pathToRoot . $navBarPath . 'NavLinkViewerManager.php'; require_once $pathToRoot . $navBarPath . 'NavBarLinksManager.php'; // get list of Links linked to this viewer // array of links: link_id, link_text, link_url, group_id $viewerLinks = $this->getViewerLinks($viewerID, $languageID); // get list of Links linked to this viewer's groups // array of links: link_id, link_text, link_url, group_id $groupLinks = $this->getGroupLinks($viewerID, $languageID); /* * combine lists */ $combinedLinks = array(); $usedLinks = array(); // for each viewerLink for ($indx = 0; $indx < count($viewerLinks); $indx++) { // compute a link key $linkKey = $viewerLinks[$indx]['navbarlink_url'] . '[' . $viewerLinks[$indx]['module_id'] . ']'; // if this link key has not already been added (no duplicate links) if (!key_exists($linkKey, $usedLinks)) { $usedLinks[$linkKey] = $linkKey; $combinedLinks[] = $viewerLinks[$indx]; } } // for each groupLink for ($indx = 0; $indx < count($groupLinks); $indx++) { $linkKey = $groupLinks[$indx]['navbarlink_url'] . '[' . $groupLinks[$indx]['module_id'] . ']'; if (!key_exists($linkKey, $usedLinks)) { $usedLinks[$linkKey] = $linkKey; $combinedLinks[] = $groupLinks[$indx]; } } // for each link in combinedLinks for ($indx = 0; $indx < count($combinedLinks); $indx++) { // if groupObject in GroupArray then $groupID = (int) $combinedLinks[$indx]['navbargroup_id']; if (!key_exists($groupID, $groupArray)) { // create new group Object $group = new GroupItem(); $groupManager = new RowManager_NavBarGroupManager($groupID); $multiLingualContext = new MultilingualManager($languageID); $bridgeManager = $groupManager->getRowLabelBridge($multiLingualContext); $group->loadFromArray($bridgeManager->getArrayOfValues()); // store in GroupArray $groupArray[$groupID] = $group; } // end if // Add link Object to Group Object $link = new LinkItem(); $link->loadFromArray($combinedLinks[$indx]); $groupArray[$groupID]->addItem($link); } // next item // Now manually sort the group Items since we couldn't get the SQL // to sort it. $sortedArray = array(); foreach ($groupArray as $group) { $key = $group->getOrder() . $group->getText(); $sortedArray[$key] = $group; } ksort($sortedArray); // send array of group objects to Template $template = new Template($pathToRoot . SITE_PATH_MODULES . 'site_NavBar/templates/'); $template->set('arrayGroup', $sortedArray); $template->set('pathToRoot', $this->getPathToRootTag()); // get cache data from template $cacheData = $template->fetch('obj_NavBar.php'); $cacheData = str_replace('[userID]', $viewer->getUserID(), $cacheData); $cacheData = str_replace('[passWord]', $viewer->getPassword(), $cacheData); if ((int) $viewer->getLanguageID() == 1) { $cacheData = str_replace('[gtsLanguageID]', 'en', $cacheData); } else { $cacheData = str_replace('[gtsLanguageID]', 'chi', $cacheData); } // store cache data in this object $this->setValueByFieldName('navbarcache_cache', $cacheData); //echo 'cacheData=[<pre>'.$cacheData.'</pre>]<br>'; // set isValid to true $this->setCacheValid(); $this->setViewerID($viewerID); $this->setLanguageID($languageID); // update DB Table if ($this->isLoaded()) { $this->updateDBTable(); } else { $this->createNewEntry(); } }