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; }