function store() { $success = parent::store(); if (!JVersion::isCompatible("1.6.0")) { if (isset($this->_catextra)) { $this->_catextra->id = $this->id; $this->_catextra->store(); } } if ($success) { JPluginHelper::importPlugin("jevents"); $dispatcher =& JDispatcher::getInstance(); $set = $dispatcher->trigger('afterSaveCategory', array($this)); } return $success; }
function store($updateNulls = false) { $success = parent::store(); if ($success) { JPluginHelper::importPlugin("jevents"); $dispatcher = JEventDispatcher::getInstance(); $set = $dispatcher->trigger('afterSaveCategory', array($this)); /* $table = JTable::getInstance('Category', 'JTable', array('dbo' => JFactory::getDbo())); if (!$table->rebuild()) { throw new Exception( $table->getError(), 500); } */ } return $success; }
/** * Make a #__faq_categories entry * * @param object $tbl * @return integer */ public function section($tbl) { $category = new \JTableCategory($this->db); $category->title = $tbl->title; $category->alias = $tbl->alias; $category->description = $tbl->description; $category->state = $tbl->published; $category->access = $tbl->access; $category->section = $tbl->parent_id; $category->store(); return $category->id; }
protected function getCategory($params) { $breadcrumbs = $params->get('data.breadcrumbs'); $breadcrumbs = preg_replace('#^\\s*<a[^>]*>.*?</a>\\s*<img[^>]*>\\s*#is', '', $breadcrumbs); $breadcrumbs = preg_replace('#\\s*<img[^>]*>\\s*$#is', '', $breadcrumbs); $breadcrumbs = preg_replace('#\\s*<img[^>]*>\\s*#is', '|', $breadcrumbs); $breadcrumbs = strip_tags($breadcrumbs); $breadcrumbs = htmlspecialchars_decode($breadcrumbs); $breadcrumbs = explode('|', $breadcrumbs); $db = JFactory::getDbo(); $parentId = 1; $depth = $params->get('depth'); foreach ($breadcrumbs as $title) { $depth++; $alias = JApplication::stringURLSafe($title); $table = new JTableCategory($db); $table->load(array('alias' => $alias, 'extension' => 'com_jed')); if (empty($table->id)) { $table->title = $title; $table->alias = $alias; $table->description = $this->params->get("data.{$depth}", ''); $table->extension = 'com_jed'; $table->published = 1; $table->access = 1; $table->created_user_id = 42; $table->language = '*'; $table->setLocation($parentId, 'last-child'); // Store the data. if (!$table->store()) { $this->setError($table->getError()); return false; } // Rebuild the path for the category: if (!$table->rebuildPath($table->id)) { $this->setError($table->getError()); return false; } // Rebuild the paths of the category's children: if (!$table->rebuild($table->id, $table->lft, $table->level, $table->path)) { $this->setError($table->getError()); return false; } } else { if ($this->params->get("data.{$depth}", '') != '') { $table->description = $this->params->get("data.{$depth}", ''); $table->store(); } } $parentId = $table->id; } return $parentId; }