static function getObjectStructure() { global $user; //Load Libraries for lookup values $library = new Library(); $library->orderBy('displayName'); if ($user->hasRole('libraryAdmin')) { $homeLibrary = Library::getPatronHomeLibrary(); $library->libraryId = $homeLibrary->libraryId; } $library->find(); $libraryList = array(); while ($library->fetch()) { $libraryList[$library->libraryId] = $library->displayName; } require_once ROOT_DIR . '/sys/Browse/BrowseCategory.php'; $browseCategories = new BrowseCategory(); $browseCategories->orderBy('label'); $browseCategories->find(); $browseCategoryList = array(); while ($browseCategories->fetch()) { $browseCategoryList[$browseCategories->textId] = $browseCategories->label . " ({$browseCategories->textId})"; } $structure = array('id' => array('property' => 'id', 'type' => 'label', 'label' => 'Id', 'description' => 'The unique id of the hours within the database'), 'libraryId' => array('property' => 'libraryId', 'type' => 'enum', 'values' => $libraryList, 'label' => 'Library', 'description' => 'A link to the library which the location belongs to'), 'browseCategoryTextId' => array('property' => 'browseCategoryTextId', 'type' => 'enum', 'values' => $browseCategoryList, 'label' => 'Browse Category', 'description' => 'The browse category to display '), 'weight' => array('property' => 'weight', 'type' => 'numeric', 'label' => 'Weight', 'weight' => 'Defines how lists are sorted within the widget. Lower weights are displayed to the left of the screen.', 'required' => true)); foreach ($structure as $fieldName => $field) { $field['propertyOld'] = $field['property'] . 'Old'; $structure[$fieldName] = $field; } return $structure; }
function getAllObjects() { $browseCategory = new BrowseCategory(); $browseCategory->orderBy('label'); $browseCategory->find(); $list = array(); while ($browseCategory->fetch()) { $list[$browseCategory->id] = clone $browseCategory; } return $list; }
static function listBrowseCategories() { $browseCategoryList = array(); require_once ROOT_DIR . '/sys/Browse/BrowseCategory.php'; $browseCategories = new BrowseCategory(); $browseCategories->orderBy('label'); $browseCategories->find(); while ($browseCategories->fetch()) { $browseCategoryList[$browseCategories->id] = $browseCategories->label . " ({$browseCategories->textId})"; } return $browseCategoryList; }
function getWorkInfo() { global $interface; //Indicate we are showing search results so we don't get hold buttons $interface->assign('displayingSearchResults', true); require_once ROOT_DIR . '/RecordDrivers/GroupedWorkDriver.php'; $id = $_REQUEST['id']; $recordDriver = new GroupedWorkDriver($id); if (isset($_REQUEST['browseCategoryId'])) { require_once ROOT_DIR . '/sys/Browse/BrowseCategory.php'; $browseCategory = new BrowseCategory(); $browseCategory->textId = $_REQUEST['browseCategoryId']; if ($browseCategory->find(true)) { $browseCategory->numTitlesClickedOn++; $browseCategory->update(); } } $interface->assign('recordDriver', $recordDriver); // // if the grouped work consists of only 1 related item, return the record url, otherwise return the grouped-work url $relatedRecords = $recordDriver->getRelatedRecords(); // // long version, for unlikely case that $relatedRecords[0] won't work // if (count($relatedRecords) == 1) { // $onlyRecord = reset($relatedRecords); // $url = $onlyRecord['url']; // } else { // $url = $recordDriver->getLinkUrl(); // } // short version $url = count($relatedRecords) == 1 ? $relatedRecords[0]['url'] : $recordDriver->getLinkUrl(); $escapedId = htmlentities($recordDriver->getPermanentId()); // escape for html $buttonLabel = translate('Add to favorites'); $results = array('title' => "<a href='{$url}'>{$recordDriver->getTitle()}</a>", 'modalBody' => $interface->fetch("GroupedWork/work-details.tpl"), 'modalButtons' => "<span onclick=\"return VuFind.GroupedWork.showSaveToListForm(this, '{$escapedId}');\" class=\"modal-buttons btn btn-primary\" style='float: left'>{$buttonLabel}</span>" . "<a href='{$url}'><span class='modal-buttons btn btn-primary'>More Info</span></a>"); return json_encode($results); }
/** * @param bool $reload Reload object's BrowseCategory * @return BrowseCategory */ private function getBrowseCategory($reload = false) { if ($this->browseCategory && !$reload) { return $this->browseCategory; } require_once ROOT_DIR . '/sys/Browse/BrowseCategory.php'; $browseCategory = new BrowseCategory(); $browseCategory->textId = $this->textId; $result = $browseCategory->find(true); if ($result) { $this->browseCategory = $browseCategory; } return $this->browseCategory; }
/** * @param LocationBrowseCategory|LibraryBrowseCategory|null $localBrowseCategories * @return BrowseCategory[] */ public function getBrowseCategories($localBrowseCategories = null) { global $interface; $browseCategories = array(); $specifiedCategory = isset($_REQUEST['browseCategory']); $specifiedSubCategory = $specifiedCategory && isset($_REQUEST['subCategory']); // make a specified main browse category required if ($localBrowseCategories) { $first = key($localBrowseCategories); // get key of first category foreach ($localBrowseCategories as $index => $localBrowseCategory) { $browseCategory = new BrowseCategory(); $browseCategory->textId = $localBrowseCategory->browseCategoryTextId; if ($browseCategory->find(true)) { $browseCategories[] = clone $browseCategory; if ($specifiedCategory && $_REQUEST['browseCategory'] == $browseCategory->textId || !$specifiedCategory && $index == $first) { $selectedBrowseCategory = clone $browseCategory; //TODO needed? $interface->assign('selectedBrowseCategory', $selectedBrowseCategory); if ($specifiedSubCategory) { $selectedBrowseCategory->getSubCategories(); $validSubCategory = false; $subCategories = array(); /** @var SubBrowseCategories $subCategory */ foreach ($selectedBrowseCategory->subBrowseCategories as $subCategory) { // Get Needed Info about sub-category /** @var BrowseCategory $temp */ $temp = BrowseCategory::staticGet('id', $subCategory->subCategoryId); if ($temp) { if ($temp->textId == $_REQUEST['subCategory']) { $validSubCategory = true; } $subCategories[] = array('label' => $temp->label, 'textId' => $temp->textId); } } if ($validSubCategory) { $interface->assign('subCategoryTextId', $_REQUEST['subCategory']); $interface->assign('subCategories', $subCategories); } } } } } } else { // get All BrowseCategories $browseCategory = new BrowseCategory(); $browseCategory->find(); while ($browseCategory->fetch()) { // $browseCategory->getSubCategories(); // add subcategory information to the object $browseCategories[] = clone $browseCategory; if ($specifiedCategory && $_REQUEST['browseCategory'] == $browseCategory->textId) { $selectedBrowseCategory = clone $browseCategory; $interface->assign('selectedBrowseCategory', $selectedBrowseCategory); if ($specifiedSubCategory) { $selectedBrowseCategory->getSubCategories(); $validSubCategory = false; $subCategories = array(); /** @var SubBrowseCategories $subCategory */ foreach ($selectedBrowseCategory->subBrowseCategories as $subCategory) { // Get Needed Info about sub-category /** @var BrowseCategory $temp */ $temp = BrowseCategory::staticGet('id', $subCategory->subCategoryId); if ($temp) { if ($temp->textId == $_REQUEST['subCategory']) { $validSubCategory = true; } $subCategories[] = array('label' => $temp->label, 'textId' => $temp->textId); } } if ($validSubCategory) { $interface->assign('subCategoryTextId', $_REQUEST['subCategory']); $interface->assign('subCategories', $subCategories); } } } } } return $browseCategories; }