Exemplo n.º 1
0
 /**
  * Shows the "not enough permissions" view
  */
 function showNotEnoughPermissionsView()
 {
     $controllerMessage = new ControllerMessage($this->text["notenoughpermissions"], ControllerMessage::getErrorType());
     array_push($this->controllerMessageArray, $controllerMessage);
     $this->displayView("folder.tpl.php");
 }
Exemplo n.º 2
0
 /**
  * Shows a view that allows the user to update an object
  * @param $object Object - object to update
  * @param $setPostInContext boolean - if true, $object won't be used to fill the fields. Instead, data received by post will be used for that purpose.
  */
 function showUpdateView($setPostInContext = false)
 {
     $object = $this->object;
     // Has the required permissions ?
     if ($object->canDoAction(null, Action::EDIT_OBJECTS_ACTION()) == false) {
         $controllerMessage = new ControllerMessage($this->text["notenoughpermissions"], ControllerMessage::getErrorType());
         array_push($this->controllerMessageArray, $controllerMessage);
         $this->showView(false);
         return;
     }
     // Title of the page
     $pageTitle = str_replace("className", $this->class->getTitle(), $this->text["updateobject"]);
     // Attributes
     $frontLanguageArray = $this->constructFrontLanguageArray($object);
     // Folders
     $allowedFolderArray = $this->getFolderArray($this->class, $object);
     $this->tpl->assign("objectId", $object->getId());
     // Add items to toolbar
     $this->setUpdateToolbar();
     if ($setPostInContext) {
         $this->setPostInContext($frontLanguageArray);
     } else {
         $dateFormat = DateFormatFactory::getDateFormat();
         $isoDateFormat = new IsoDateFormat();
         $isPublished = $object->getIsPublished();
         if ($isPublished) {
             $this->tpl->assign("publishCheckbox", "-1");
         }
         $publishFromDate = $isoDateFormat->parseDatetime($object->getStartPublishing());
         if ($publishFromDate != null) {
             $this->tpl->assign("publishFromText", $dateFormat->toDateString($publishFromDate));
         }
         $publishToDate = $isoDateFormat->parseDatetime($object->getEndPublishing());
         if ($publishToDate != null) {
             $this->tpl->assign("publishToText", $dateFormat->toDateString($publishToDate));
         }
         $this->tpl->assign("hits", $object->getHits());
         $createdOnDate = $isoDateFormat->parseDatetime($object->getCreated());
         $user = $object->getCreatedByUser();
         $this->tpl->assign("createdOn", $dateFormat->toDatetimeString($createdOnDate));
         $this->tpl->assign("createdBy", $user->getName());
         $updatedOnDate = $isoDateFormat->parseDatetime($object->getUpdated());
         $user = $object->getUpdatedByUser();
         $updatedBy = "-";
         $updatedOn = "-";
         if ($updatedOnDate != null) {
             $updatedOn = $dateFormat->toDatetimeString($updatedOnDate);
         }
         if ($user != null) {
             $updatedBy = $user->getName();
         }
         $this->tpl->assign("updatedOn", $updatedOn);
         $this->tpl->assign("updatedBy", $updatedBy);
     }
     $this->displayAdd($pageTitle, $frontLanguageArray, $allowedFolderArray);
 }
 /**
  * Adds an error message to this controller
  * @param $field String - codename of this field in the text array
  */
 function addErrorMessage($textFieldName)
 {
     $field = $this->text[$textFieldName];
     $message = str_replace("field", $field, $this->text["required"]);
     $controllerMessage = new ControllerMessage($message, ControllerMessage::getErrorType());
     array_push($this->controllerMessageArray, $controllerMessage);
 }