Exemple #1
0
 /**
  * This method is called by Joomla! itself when it needs to update the UCM content
  *
  * @return  bool
  */
 public function updateUcmContent()
 {
     // Process the tags
     $data = $this->getData();
     $alias = $this->getContentType();
     $ucmContentTable = \JTable::getInstance('Corecontent');
     $ucm = new \JUcmContent($this, $alias);
     $ucmData = $data ? $ucm->mapData($data) : $ucm->ucmData;
     $primaryId = $ucm->getPrimaryKey($ucmData['common']['core_type_id'], $ucmData['common']['core_content_item_id']);
     $result = $ucmContentTable->load($primaryId);
     $result = $result && $ucmContentTable->bind($ucmData['common']);
     $result = $result && $ucmContentTable->check();
     $result = $result && $ucmContentTable->store();
     $ucmId = $ucmContentTable->core_content_id;
     return $result;
 }
Exemple #2
0
 /**
  * Function that handles saving tags used in a table class after a store()
  *
  * @param   JTable   $table    JTable being processed
  * @param   array    $newTags  Array of new tags
  * @param   boolean  $replace  Flag indicating if all exising tags should be replaced
  *
  * @return  boolean
  *
  * @since   3.1
  */
 public function postStoreProcess($table, $newTags = array(), $replace = true)
 {
     if (!empty($table->newTags) && empty($newTags)) {
         $newTags = $table->newTags;
     }
     // If existing row, check to see if tags have changed.
     $newTable = clone $table;
     $newTable->reset();
     $key = $newTable->getKeyName();
     $typeAlias = $this->typeAlias;
     $result = true;
     // Process ucm_content and ucm_base if either tags have changed or we have some tags.
     if ($this->tagsChanged || $newTags) {
         if (!$newTags) {
             // Delete all tags data
             $key = $table->getKeyName();
             $result = $this->deleteTagData($table, $table->{$key});
         } else {
             // Process the tags
             $rowdata = new JHelperContent();
             $data = $rowdata->getRowData($table);
             $ucmContentTable = JTable::getInstance('Corecontent');
             $ucm = new JUcmContent($table, $this->typeAlias);
             $ucmData = $data ? $ucm->mapData($data) : $ucm->ucmData;
             $primaryId = $ucm->getPrimaryKey($ucmData['common']['core_type_id'], $ucmData['common']['core_content_item_id']);
             $result = $ucmContentTable->load($primaryId);
             $result = $result && $ucmContentTable->bind($ucmData['common']);
             $result = $result && $ucmContentTable->check();
             $result = $result && $ucmContentTable->store();
             $ucmId = $ucmContentTable->core_content_id;
             // Store the tag data if the article data was saved and run related methods.
             $result = $result && $this->tagItem($ucmId, $table, $newTags, $replace);
         }
     }
     return $result;
 }
Exemple #3
0
 /**
  * Function that handles saving tags used in a table class after a store()
  *
  * @param   JTable  $table      JTable being processed
  *
  * @return  null
  *
  * @since   3.1
  */
 public function postStoreProcess($table)
 {
     $metaObject = json_decode($table->get('metadata'));
     $tags = isset($metaObject->tags) ? $metaObject->tags : null;
     $result = true;
     // Process ucm_content and ucm_base if either tags have changed or we have some tags.
     if ($this->tagsChanged || $tags) {
         if (!$tags) {
             // Delete all tags data
             $key = $table->getKeyName();
             $result = $this->deleteTagData($table, $table->{$key});
         } else {
             // Process the tags
             $rowdata = new JHelperContent();
             $data = $rowdata->getRowData($table);
             $ucmContentTable = JTable::getInstance('Corecontent');
             $ucm = new JUcmContent($table, $this->typeAlias);
             $ucmData = $data ? $ucm->mapData($data) : $ucm->ucmData;
             $primaryId = $ucm->getPrimaryKey($ucmData['common']['core_type_id'], $ucmData['common']['core_content_item_id']);
             $result = $ucmContentTable->load($primaryId);
             $result = $result && $ucmContentTable->bind($ucmData['common']);
             $result = $result && $ucmContentTable->check();
             $result = $result && $ucmContentTable->store();
             $ucmId = $ucmContentTable->core_content_id;
             // Store the tag data if the article data was saved and run related methods.
             $result = $result && $this->tagItem($ucmId, $table, json_decode($table->metadata)->tags, true);
         }
     }
     return $result;
 }