예제 #1
0
 /**
  * Method to update an object in the database.
  *
  * @return  JContent  The content object.
  *
  * @since   12.1
  * @throws  LogicException
  * @throws  RuntimeException
  */
 public function update()
 {
     // Assert the object is loaded.
     $this->assertIsLoaded();
     // Make sure the item is checked out.
     // $this->checkout();
     // Check for an alias.
     if (empty($this->alias)) {
         $this->alias = $this->title;
     }
     // Sanitize the alias.
     $this->alias = JFilterOutput::stringURLSafe($this->alias);
     // Update the last modified data for the content.
     $this->modified_date = JDate::getInstance();
     $this->modified_user_id = !$this->user->get('guest') ? (int) $this->user->get('content_id') : null;
     // Update the revision number.
     if (!$this->isTemporary()) {
         $this->revision += 1;
     }
     // Check the content object.
     $this->validate();
     // Trigger the before update event.
     $this->app->triggerEvent('onContentBeforeUpdate', array($this));
     // Perform the actual database updates.
     $this->doUpdate();
     // Trigger the after update event.
     $this->app->triggerEvent('onContentAfterUpdate', array($this));
     return $this;
 }
예제 #2
0
 /**
  * Gets a content form.
  *
  * @param   string  $type  The content type.
  *
  * @return  JForm  The form object.
  *
  * @since   12.1
  * @throws  RuntimeException
  */
 public function getForm($type)
 {
     // Get the form name.
     $name = 'JContent' . $type;
     try {
         // Get the base form.
         $form = JForm::getInstance($name, 'content', array('control' => 'jform'));
         // Load the type form.
         $form->loadFile($type, false, false);
         // Trigger the form preparation event.
         $this->app->triggerEvent('onContentPrepareForm', array($form));
     } catch (Exception $error) {
         throw new RuntimeException($error->getMessage(), $error->getCode(), $error);
     }
     return $form;
 }