function launch() { global $interface; global $configArray; $isNew = true; if (isset($_REQUEST['id']) && strlen($_REQUEST['id']) > 0) { $editorialReview = new EditorialReview(); $editorialReview->editorialReviewId = $_REQUEST['id']; $editorialReview->find(); if ($editorialReview->N > 0) { $editorialReview->fetch(); $interface->assign('object', $editorialReview); $interface->setPageTitle('Edit Editorial Review'); $isNew = false; } } $structure = EditorialReview::getObjectStructure(); if ($isNew) { if (isset($_REQUEST['recordId'])) { $structure['recordId']['default'] = strip_tags($_REQUEST['recordId']); } } if (isset($_REQUEST['submit']) || isset($_REQUEST['submitStay']) || isset($_REQUEST['submitReturnToList']) || isset($_REQUEST['submitAddAnother'])) { //Save the object $results = DataObjectUtil::saveObject($structure, 'EditorialReview'); $editorialReview = $results['object']; //redirect to the view of the competency if we saved ok. if (!$results['validatedOk'] || !$results['saveOk']) { //Display the errors for the user. $interface->assign('errors', $results['errors']); $interface->assign('object', $editorialReview); $_REQUEST['id'] = $editorialReview->editorialReviewId; } else { //Show the new tip that was created if (isset($_REQUEST['submitReturnToList'])) { if (strpos($editorialReview->recordId, 'econtentRecord') === 0) { $shortId = str_replace('econtentRecord', '', $editorialReview->recordId); header('Location:' . $configArray['Site']['path'] . "/EcontentRecord/{$shortId}/Home"); } else { header('Location:' . $configArray['Site']['path'] . "/Record/{$editorialReview->recordId}/Home"); } } elseif (isset($_REQUEST['submitAddAnother'])) { header('Location:' . $configArray['Site']['path'] . "/EditorialReview/Edit?recordId={$editorialReview->recordId}"); } else { header('Location:' . $configArray['Site']['path'] . "/EditorialReview/{$editorialReview->editorialReviewId}/View"); exit; } } } //Manipulate the structure as needed if ($isNew) { } else { } $interface->assign('isNew', $isNew); $interface->assign('submitUrl', $configArray['Site']['path'] . '/EditorialReview/Edit'); $interface->assign('editForm', DataObjectUtil::getEditForm($structure)); $interface->setTemplate('edit.tpl'); $interface->display('layout.tpl'); }
function launch() { global $interface; global $configArray; global $user; //If the user isn't logged in, take them to the login page if (!$user) { header("Location: {$configArray['Site']['path']}/MyAccount/Login"); die; } //Make sure the user has permission to access the page if (!$user->hasRole('epubAdmin')) { $interface->setTemplate('../Admin/noPermission.tpl'); $interface->display('layout.tpl'); exit; } $structure = EContentRecord::getObjectStructure(); if (isset($_REQUEST['submitStay']) || isset($_REQUEST['submit']) || isset($_REQUEST['submitReturnToList']) || isset($_REQUEST['submitAddAnother'])) { //Save the object $results = DataObjectUtil::saveObject($structure, 'EContentRecord'); $eContentRecord = $results['object']; //redirect to the view of the eContentRecord if we saved ok. if (!$results['validatedOk'] || !$results['saveOk']) { //Display the errors for the user. $interface->assign('errors', $results['errors']); $interface->assign('object', $eContentRecord); $_REQUEST['id'] = ${$eContentRecord}->id; } else { //Show the new tip that was created header('Location:' . $configArray['Site']['path'] . "/EcontentRecord/{$eContentRecord->id}/Home"); exit; } } $isNew = true; if (isset($_REQUEST['id']) && strlen($_REQUEST['id']) > 0 && is_numeric($_REQUEST['id'])) { $object = EContentRecord::staticGet('id', strip_tags($_REQUEST['id'])); $interface->assign('object', $object); $interface->setPageTitle('Edit EContentRecord'); $isNew = false; } else { $interface->setPageTitle('Submit a New EContentRecord'); } //Manipulate the structure as needed if ($isNew) { } else { } $interface->assign('isNew', $isNew); $interface->assign('submitUrl', $configArray['Site']['path'] . '/EcontentRecord/Edit'); $interface->assign('editForm', DataObjectUtil::getEditForm($structure)); $interface->setTemplate('edit.tpl'); $interface->display('layout.tpl'); }
function launch() { global $interface; global $timer; global $configArray; global $user; $id = $_REQUEST['id']; $structure = EContentItem::getObjectStructure(); $ret = DataObjectUtil::saveObject($structure, 'EContentItem'); if (!$ret['validatedOk']) { echo "Item failed validation."; } elseif (!$ret['saveOk']) { echo "Could not save the new item"; } else { $object = $ret['object']; header("Location: " . $configArray['Site']['path'] . "/EcontentRecord/{$object->recordId}/Home"); } }
function launch() { global $interface; global $configArray; $isNew = true; if (isset($_REQUEST['id']) && strlen($_REQUEST['id']) > 0) { $epubFile = new EContentItem(); $epubFile->id = $_REQUEST['id']; $epubFile->find(); if ($epubFile->N > 0) { $epubFile->fetch(); $interface->assign('object', $epubFile); $interface->setPageTitle('Edit EPUB File'); $isNew = false; } } $structure = EContentItem::getObjectStructure(); if (isset($_REQUEST['submit'])) { //Save the object $results = DataObjectUtil::saveObject($structure, 'EContentItem'); $epubFile = $results['object']; //redirect to the view of the competency if we saved ok. if (!$results['validatedOk'] || !$results['saveOk']) { //Display the errors for the user. $interface->assign('errors', $results['errors']); $interface->assign('object', $epubFile); $_REQUEST['id'] = $epubFile->id; } else { //Show the new tip that was created header('Location:' . $configArray['Site']['path'] . "/EContent/{$epubFile->id}/View"); exit; } } //Manipulate the structure as needed if ($isNew) { } else { } $interface->assign('isNew', $isNew); $interface->assign('submitUrl', $configArray['Site']['path'] . '/EContent/Edit'); $interface->assign('editForm', DataObjectUtil::getEditForm($structure)); $interface->setTemplate('edit.tpl'); $interface->display('layout.tpl'); }
function launch() { global $configArray; global $interface; global $user; $interface->assign('canAddNew', $this->canAddNew()); $interface->assign('canDelete', $this->canDelete()); $interface->assign('showReturnToList', $this->showReturnToList()); $interface->assign('showExportAndCompare', $this->showExportAndCompare()); //Figure out what mode we are in if (isset($_REQUEST['objectAction'])) { $objectAction = $_REQUEST['objectAction']; } else { $objectAction = 'list'; } if ($objectAction == 'delete' && isset($_REQUEST['id'])) { parent::launch(); exit; } //Get all available widgets $availableWidgets = array(); $listWidget = new ListWidget(); if ($user->hasRole('libraryAdmin') || $user->hasRole('contentEditor')) { $homeLibrary = Library::getPatronHomeLibrary(); $listWidget->libraryId = $homeLibrary->libraryId; } $listWidget->orderBy('name ASC'); $listWidget->find(); while ($listWidget->fetch()) { $availableWidgets[$listWidget->id] = clone $listWidget; } $interface->assign('availableWidgets', $availableWidgets); //Get the selected widget if (isset($_REQUEST['id']) && is_numeric($_REQUEST['id'])) { $widget = $availableWidgets[$_REQUEST['id']]; $interface->assign('object', $widget); } //Do actions that require preprocessing if ($objectAction == 'save') { if (!isset($widget)) { $widget = new ListWidget(); } DataObjectUtil::updateFromUI($widget, $listWidget->getObjectStructure()); $validationResults = DataObjectUtil::saveObject($listWidget->getObjectStructure(), "ListWidget"); if (!$validationResults['validatedOk']) { $interface->assign('object', $widget); $interface->assign('errors', $validationResults['errors']); $objectAction = 'edit'; } else { $interface->assign('object', $validationResults['object']); $objectAction = 'view'; } } if ($objectAction == 'list') { $interface->setTemplate('listWidgets.tpl'); } else { if ($objectAction == 'edit' || $objectAction == 'add') { if (isset($_REQUEST['id'])) { $interface->assign('widgetid', $_REQUEST['id']); $interface->assign('id', $_REQUEST['id']); } $editForm = DataObjectUtil::getEditForm($listWidget->getObjectStructure()); $interface->assign('editForm', $editForm); $interface->setTemplate('listWidgetEdit.tpl'); } else { $interface->setTemplate('listWidget.tpl'); } } $interface->setPageTitle('List Widgets'); $interface->display('layout.tpl'); }
private function saveElement() { $listWidgetLinks = new ListWidgetListsLinks(); DataObjectUtil::updateFromUI($listWidgetLinks, $listWidgetLinks->getObjectStructure()); $validationResults = DataObjectUtil::saveObject($listWidgetLinks->getObjectStructure(), "ListWidgetListsLinks"); }
function launch() { global $interface; global $user; $interface->assign('canAddNew', $this->canAddNew()); $interface->assign('canDelete', $this->canDelete()); $interface->assign('showReturnToList', $this->showReturnToList()); $interface->assign('showExportAndCompare', $this->showExportAndCompare()); //Figure out what mode we are in if (isset($_REQUEST['objectAction'])) { $objectAction = $_REQUEST['objectAction']; } else { $objectAction = 'list'; } if ($objectAction == 'delete' && isset($_REQUEST['id'])) { parent::launch(); exit; } //Get all available widgets $availableWidgets = array(); $listWidget = new ListWidget(); if ($user->hasRole('libraryAdmin') || $user->hasRole('contentEditor')) { $homeLibrary = Library::getPatronHomeLibrary(); $listWidget->libraryId = $homeLibrary->libraryId; } $listWidget->orderBy('name ASC'); $listWidget->find(); while ($listWidget->fetch()) { $availableWidgets[$listWidget->id] = clone $listWidget; } $interface->assign('availableWidgets', $availableWidgets); //Get the selected widget if (isset($_REQUEST['id']) && is_numeric($_REQUEST['id'])) { $widget = $availableWidgets[$_REQUEST['id']]; $interface->assign('object', $widget); } //Do actions that require pre-processing if ($objectAction == 'save') { if (!isset($widget)) { $widget = new ListWidget(); } DataObjectUtil::updateFromUI($widget, $listWidget->getObjectStructure()); $validationResults = DataObjectUtil::saveObject($listWidget->getObjectStructure(), "ListWidget"); if (!$validationResults['validatedOk']) { $interface->assign('object', $widget); $interface->assign('errors', $validationResults['errors']); $objectAction = 'edit'; } else { $interface->assign('object', $validationResults['object']); $objectAction = 'view'; } } if ($objectAction == 'list') { $interface->setTemplate('listWidgets.tpl'); } else { if ($objectAction == 'edit' || $objectAction == 'add') { if (isset($_REQUEST['id'])) { $interface->assign('widgetid', $_REQUEST['id']); $interface->assign('id', $_REQUEST['id']); } $editForm = DataObjectUtil::getEditForm($listWidget->getObjectStructure()); $interface->assign('editForm', $editForm); $interface->setTemplate('listWidgetEdit.tpl'); } else { // Set some default sizes for the iframe we embed on the view page switch ($widget->style) { case 'horizontal': $width = 650; $height = 275; break; case 'vertical': $width = 175; $height = 400; break; case 'text-list': $width = 400; $height = 200; break; case 'single': case 'single-with-next': $width = 225; $height = 275; break; } $interface->assign('width', $width); $interface->assign('height', $height); $interface->setTemplate('listWidget.tpl'); } } $interface->assign('sidebar', 'MyAccount/account-sidebar.tpl'); $interface->setPageTitle('List Widgets'); $interface->display('layout.tpl'); }