示例#1
0
 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');
 }
示例#2
0
 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');
 }
示例#3
0
 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');
 }
示例#4
0
 function EditItem()
 {
     require_once ROOT_DIR . '/sys/eContent/EContentItem.php';
     require_once ROOT_DIR . '/sys/DataObjectUtil.php';
     global $user;
     global $interface;
     global $configArray;
     $structure = EContentItem::getObjectStructure();
     $object = new EContentItem();
     $recordId = strip_tags($_REQUEST['id']);
     $itemId = strip_tags($_REQUEST['itemId']);
     $object->id = $itemId;
     if ($object->find(true)) {
         $interface->assign('object', $object);
         $interface->assign('title', 'Edit eContent Item');
         $interface->assign('submitUrl', $configArray['Site']['path'] . "/EcontentRecord/SaveItem");
         $interface->assign('editForm', DataObjectUtil::getEditForm($structure));
         return $interface->fetch('EcontentRecord/ajax-editItem.tpl');
     } else {
         return "Could not find a record for item {$itemId}";
     }
 }
示例#5
0
 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');
 }
示例#6
0
 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');
 }