Пример #1
0
 /**
  * Defining a ∞:∞ (multiple) relation. This adds relations to the getMultiple() method.
  *
  * In other words: is a table RELATED TO MANY other records?
  *
  * @param   string   $itemName       is how it will be known locally to the getRelatedItems method (plural)
  * @param   string   $tableClass     if skipped it is defined automatically as ComponentnameTableItemname
  * @param   string   $localKey       is the column containing our side of the FK relation, default: our primary key field name
  * @param   string   $ourPivotKey    is the column containing our side of the FK relation in the pivot table, default: $localKey
  * @param   string   $theirPivotKey  is the column containing the other table's side of the FK relation in the pivot table, default $remoteKey
  * @param   string   $remoteKey      is the remote table's FK column, default: componentname_itemname_id
  * @param   string   $glueTable      is the name of the glue (pivot) table, default: #__componentname_thisclassname_itemname with plural items (e.g. #__foobar_users_roles)
  * @param   boolean  $default        is this the default multiple relation?
  */
 public function addMultipleRelation($itemName, $tableClass = null, $localKey = null, $ourPivotKey = null, $theirPivotKey = null, $remoteKey = null, $glueTable = null, $default = true)
 {
     $itemName = $this->normaliseItemName($itemName, true);
     if (empty($localKey)) {
         $localKey = $this->table->getKeyName();
     }
     $this->addBespokePivotRelation('multiple', $itemName, $tableClass, $localKey, $remoteKey, $ourPivotKey, $theirPivotKey, $glueTable, $default);
 }
Пример #2
0
Файл: model.php Проект: 01J/topm
 /**
  * Method to load a row for editing from the version history table.
  *
  * @param   integer    $version_id  Key to the version history table.
  * @param   F0FTable   &$table      Content table object being loaded.
  * @param   string     $alias       The type_alias in #__content_types
  *
  * @return  boolean  False on failure or error, true otherwise.
  *
  * @since   2.3
  */
 public function loadhistory($version_id, F0FTable &$table, $alias)
 {
     // Only attempt to check the row in if it exists.
     if ($version_id) {
         $user = JFactory::getUser();
         // Get an instance of the row to checkout.
         $historyTable = JTable::getInstance('Contenthistory');
         if (!$historyTable->load($version_id)) {
             $this->setError($historyTable->getError());
             return false;
         }
         $rowArray = JArrayHelper::fromObject(json_decode($historyTable->version_data));
         $typeId = JTable::getInstance('Contenttype')->getTypeId($alias);
         if ($historyTable->ucm_type_id != $typeId) {
             $this->setError(JText::_('JLIB_APPLICATION_ERROR_HISTORY_ID_MISMATCH'));
             $key = $table->getKeyName();
             if (isset($rowArray[$key])) {
                 $table->checkIn($rowArray[$key]);
             }
             return false;
         }
     }
     $this->setState('save_date', $historyTable->save_date);
     $this->setState('version_note', $historyTable->version_note);
     return $table->bind($rowArray);
 }