protected function _core($data, &$config = array(), $pk = 0) { if (!$config['id']) { $isNew = true; $config['id'] = parent::g_onCCK_Storage_LocationPrepareStore(); } else { $isNew = false; } // Init $table = self::_getTable($pk); $isNew = $pk > 0 ? false : true; if (isset($table->tags)) { $tags = $table->tags; unset($table->tags); } else { $tags = null; } if (isset($data['tags'])) { if (!empty($data['tags']) && $data['tags'][0] != '') { $table->newTags = $data['tags']; } unset($data['tags']); } self::_initTable($table, $data, $config); // Check Error if (self::$error === true) { return false; } // Prepare if (is_array($data)) { $table->bind($data); } if ($isNew && !isset($data['rules'])) { $data['rules'] = array('core.create' => array(), 'core.delete' => array(), 'core.edit' => array(), 'core.edit.state' => array(), 'core.edit.own' => array()); } if (isset($data['rules']) && $data['rules']) { if (!is_array($data['rules'])) { $data['rules'] = json_decode($data['rules']); } $rules = new JAccessRules(JCckDevHelper::getRules($data['rules'])); $table->setRules($rules); } $table->check(); self::_completeTable($table, $data, $config); // Store $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('content'); $dispatcher->trigger('onContentBeforeSave', array(self::$context, &$table, $isNew)); if ($isNew === true && parent::g_isMax($table->{self::$author}, $table->{self::$parent}, $config)) { return; } if (!$table->store()) { JFactory::getApplication()->enqueueMessage($table->getError(), 'error'); if ($isNew) { parent::g_onCCK_Storage_LocationRollback($config['id']); } return false; } // Checkin parent::g_checkIn($table); self::$pk = $table->{self::$key}; if (!$config['pk']) { $config['pk'] = self::$pk; } $config['author'] = $table->{self::$author}; $config['parent'] = $table->{self::$parent}; parent::g_onCCK_Storage_LocationStore($data, self::$table, self::$pk, $config); $dispatcher->trigger('onContentAfterSave', array(self::$context, &$table, $isNew)); // Associations // todo }
if (isset($this) && isset($this->config)) { $config =& $this->config; } // Prepare $item->params = is_object($params) ? clone $params : new JRegistry(); if (!$loaded) { $items = JCckDatabase::loadObjectList('SELECT a.id, b.title AS parent_title, b.alias AS parent_alias' . ' FROM #__categories AS a LEFT JOIN #__categories AS b ON b.id = a.parent_id' . ' WHERE a.id IN (' . (string) $pks . ')', 'id'); $loaded = 1; } if (isset($items[$item->pk]->parent_title)) { $item->parent_title = $items[$item->pk]->parent_title; } if (isset($items[$item->pk]->parent_alias)) { $item->parent_alias = $items[$item->pk]->parent_alias; } $link = plgCCK_Storage_LocationJoomla_Category::getRoute($item, $config['doSEF'], $config['Itemid'], $config); ?> <div> <?php if ($item->params->get('show_category_title')) { $tag = $plg_params->get('item_tag_title', 'h2'); $class = $plg_params->get('item_class_title', ''); $class = $class ? ' class="' . $class . '"' : ''; echo '<' . $tag . $class . '>' . '<a href="' . $link . '">' . $item->title . '</a>' . '</' . $tag . '>'; } echo JHtml::_('content.prepare', $item->description); ?> </div> <?php if ($plg_params->get('item_separator', 1)) {
public static function onCCK_Storage_LocationImport($data, &$config = array(), $pk = 0) { if (!$config['pk']) { // Init $pk = isset($data[self::$key]) && $data[self::$key] > 0 ? $data[self::$key] : 0; $table = self::_getTable($pk); $isNew = $table->{self::$key} > 0 ? false : true; $iPk = 0; if ($isNew) { if (isset($data[self::$key])) { $iPk = $data[self::$key]; unset($data[self::$key]); } $config['log'] = 'created'; } else { preg_match('#::cck::(.*)::/cck::#U', $table->{self::$custom}, $matches); $config['id'] = $matches[1]; $config['log'] = 'updated'; } if (!$config['id']) { $config['id'] = parent::g_onCCK_Storage_LocationPrepareStore(); } self::_initTable($table, $data, $config, true); // Prepare $table->bind($data); if ($isNew && !isset($data['rules'])) { $data['rules'] = array('core.create' => array(), 'core.delete' => array(), 'core.edit' => array(), 'core.edit.state' => array(), 'core.edit.own' => array()); } if (isset($data['rules'])) { $rules = new JAccessRules($data['rules']); $table->setRules($rules); } if (!@$table->title) { $table->title = JFactory::getDate()->format('Y-m-d-H-i-s'); $table->check(); $table->alias .= '-' . $config['x']; } else { $table->check(); } self::_completeTable($table, $data, $config); // Store $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('content'); $dispatcher->trigger('onContentBeforeSave', array(self::$context, &$table, $isNew)); if (!$table->store()) { $config['error'] = true; $config['log'] = 'cancelled'; $config['pk'] = $pk; parent::g_onCCK_Storage_LocationRollback($config['id']); return false; } $dispatcher->trigger('onContentAfterSave', array(self::$context, &$table, $isNew)); // Tweak if ($iPk > 0) { if (JCckDatabase::execute('UPDATE ' . self::$table . ' SET ' . self::$key . ' = ' . (int) $iPk . ' WHERE ' . self::$key . ' = ' . (int) $table->{self::$key})) { $table->{self::$key} = $iPk; $config['auto_inc'] = $iPk > $config['auto_inc'] ? $iPk : $config['auto_inc']; if ($table->asset_id) { JCckDatabase::execute('UPDATE #__assets SET name = "com_content.category.' . $iPk . '" WHERE id = ' . (int) $table->asset_id); } } } if (!$config['pk']) { $config['pk'] = $table->{self::$key}; } $config['author'] = $table->{self::$author}; $config['parent'] = $table->{self::$parent}; } parent::g_onCCK_Storage_LocationStore($data, self::$table, $config['pk'], $config); return true; }