Beispiel #1
0
 /**
  * Overrides JTable::load(). Loads event information and binds it.
  *
  * @param   mixed    $keys   An optional primary key value to load the row by, or an a$
  *                           set the instance property value is used.
  * @param   boolean  $reset  True to reset the default values before loading the new r$
  *
  * @return  boolean  True if successful. False if row not found.
  *
  * @link    http://docs.joomla.org/JTable/load
  * @since   11.1
  * @throws  InvalidArgumentException
  * @throws  RuntimeException
  * @throws  UnexpectedValueException
  */
 public function load($keys = null, $reset = true)
 {
     global $shareddb, $sharedtbl, $sharedlinktbl, $koid;
     // Load article content
     $result = parent::load($keys, $reset);
     if ($result === false) {
         return false;
     }
     // No need to load anything if there's no primary key
     if (!$this->hasPrimaryKey()) {
         return true;
     }
     // Load event content
     $query = $this->_db->getQuery(true)->select('*')->from($this->_db->quoteName($shareddb) . '.' . $this->_db->quoteName($sharedtbl))->where($this->_db->quoteName('article_id') . ' = ' . $this->getArticleId() . ' AND ' . $this->_db->quoteName('koid') . ' = ' . $this->_db->quote($this->koid));
     $this->_db->setQuery($query);
     $row = $this->_db->loadAssoc();
     // Bind event content to this object
     if ($row != null) {
         return $this->bind($row);
     }
 }
Beispiel #2
0
 /**
  * Create an item entry for a resource
  *
  * @param   integer  $id  Optional ID to use
  * @return  boolean
  */
 public function make($id = null)
 {
     if ($this->exists()) {
         return true;
     }
     $id = $id ?: Request::getInt('id', 0);
     $this->_tbl->loadType($id, $this->_type);
     if ($this->exists()) {
         return true;
     }
     include_once PATH_CORE . DS . 'libraries' . DS . 'joomla' . DS . 'database' . DS . 'table' . DS . 'content.php';
     $article = new \JTableContent($this->_db);
     $article->load($id);
     if (!$article->id) {
         $this->setError(Lang::txt('Article not found.'));
         return false;
     }
     $text = strip_tags($article->introtext);
     $text = str_replace(array("\n", "\r", "\t"), ' ', $text);
     $text = preg_replace('/\\s+/', ' ', $text);
     $url = Request::getVar('REQUEST_URI', '', 'server');
     $url = $url ?: Route::url('index.php?option=com_content&id=' . $article->alias);
     $url = str_replace('?tryto=collect', '', $url);
     $url = str_replace('no_html=1', '', $url);
     $url = trim($url, '&');
     $this->set('type', $this->_type)->set('object_id', $article->id)->set('created', $article->created)->set('created_by', $article->created_by)->set('title', $article->title)->set('description', String::truncate($text, 300, array('html' => true)))->set('url', $url);
     if (!$this->store()) {
         return false;
     }
     return true;
 }