function launch() { global $configArray; global $interface; global $user; $source = $_REQUEST['source']; $sourceId = $_REQUEST['id']; $existingWidget = isset($_REQUEST['widgetId']) ? $_REQUEST['widgetId'] : -1; $widgetName = isset($_REQUEST['widgetName']) ? $_REQUEST['widgetName'] : ''; if ($existingWidget == -1) { $widget = new ListWidget(); $widget->name = $widgetName; if ($user->hasRole('libraryAdmin') || $user->hasRole('contentEditor')) { //Get all widgets for the library $userLibrary = Library::getPatronHomeLibrary(); $widget->libraryId = $userLibrary->libraryId; } else { $widget->libraryId = -1; } $widget->customCss = ''; $widget->autoRotate = 0; $widget->description = ''; $widget->showTitleDescriptions = 1; $widget->onSelectCallback = ''; $widget->fullListLink = ''; $widget->listDisplayType = 'tabs'; $widget->showMultipleTitles = 1; $widget->insert(); } else { $widget = new ListWidget(); $widget->id = $existingWidget; $widget->find(true); } //Make sure to save the search if ($source == 'search') { $searchObject = new SearchEntry(); $searchObject->id = $sourceId; $searchObject->find(true); $searchObject->saved = 1; $searchObject->update(); } //Add the list to the widget $widgetList = new ListWidgetList(); $widgetList->listWidgetId = $widget->id; $widgetList->displayFor = 'all'; $widgetList->source = "{$source}:{$sourceId}"; $widgetList->name = $widgetName; $widgetList->weight = 0; $widgetList->insert(); //Redirect to the widget header("Location: {$path}/Admin/ListWidgets?objectAction=view&id={$widget->id}"); }
public function __get($name) { if ($name == "lists") { if (!isset($this->lists)) { //Get the list of lists that are being displayed for the widget $this->lists = array(); $listWidgetList = new ListWidgetList(); $listWidgetList->listWidgetId = $this->id; $listWidgetList->orderBy('weight ASC'); $listWidgetList->find(); while ($listWidgetList->fetch()) { $this->lists[$listWidgetList->id] = clone $listWidgetList; } } return $this->lists; } return null; }
private function launchEdit($widgetId, $widgetListId) { global $configArray; global $interface; $interface->setPageTitle('List Widgets'); //Get Info about the Widget $widget = new ListWidget(); $widget->whereAdd('id = ' . $widgetId); $widget->find(); $widget->fetch(); $interface->assign('widgetName', $widget->name); $interface->assign('widgetId', $widget->id); //Get Info about the current TAB $widgetList = new ListWidgetList(); $widgetList->whereAdd('id = ' . $widgetListId); $widgetList->find(); $widgetList->fetch(); $interface->assign('widgetListName', $widgetList->name); //Get all available links $availableLinks = array(); $listWidgetLinks = new ListWidgetListsLinks(); $listWidgetLinks->whereAdd('listWidgetListsId = ' . $widgetListId); $listWidgetLinks->orderBy('weight ASC'); $listWidgetLinks->find(); while ($listWidgetLinks->fetch()) { $availableLinks[$listWidgetLinks->id] = clone $listWidgetLinks; } $interface->assign('availableLinks', $availableLinks); $interface->setTemplate('listWidgetListLinks.tpl'); }