/**
	 * Determines if the given value is correct for a date textbox. The value
	 * must be an instance of the Date class.
	 * @return true if it's correct, false if it is not
	 */
	function isValid()
	{
		if ($this->required == true && $value == null) return false;
		
		$dateFormat = DateFormatFactory::getDateFormat();
		$date = $dateFormat->parseDatetime($this->value);
		
		if ($date == null) return false;
		
		return true;
	}
 /**
  * Controller constructor, must be called by the controller subclass
  * @param $pageTitleTextKey Key of the title in the text array
  */
 function Controller()
 {
     $this->method = "showView";
     if (array_key_exists("method", $_REQUEST)) {
         $this->method = $_REQUEST["method"];
     }
     $this->icfTemplating = new IcfTemplating();
     $this->tpl =& $this->icfTemplating->getTpl();
     $this->text =& $this->icfTemplating->getText();
     $this->controllerMessageArray = array();
     $this->pageTitle = "";
     $this->dateFormat = DateFormatFactory::getDateFormat();
     $this->controllerData =& $this->newControllerData();
 }
 /**
  * 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);
 }