Пример #1
0
 public static function onCCK_Storage_LocationImport($data, &$config = array(), $pk = 0)
 {
     if (!$config['pk']) {
         // Init
         if (!$pk) {
             if (isset($config['key']) && $config['key']) {
                 if (isset($data[$config['key']]) && $data[$config['key']] != '') {
                     $pk = JCckDatabase::loadResult('SELECT ' . self::$key . ' FROM ' . self::$table . ' WHERE ' . $config['key'] . ' = "' . $data[$config['key']] . '"');
                 }
                 $pk = $pk > 0 ? $pk : 0;
             } else {
                 $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.delete' => array(), 'core.edit' => array(), 'core.edit.state' => array());
             $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));
         // Featured
         self::_setFeatured($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.article.' . $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;
 }
Пример #2
0
 public function onCCK_FieldPrepareContent(&$field, $value = '', &$config = array())
 {
     if (self::$type != $field->type) {
         return;
     }
     parent::g_onCCK_FieldPrepareContent($field, $config);
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $access = implode(',', $user->getAuthorisedViewLevels());
     $text = '';
     if ($field->extended && $field->extended != @$config['type']) {
         $options2 = JCckDev::fromJSON($field->options2);
         $name = $field->storage_field2 ? $field->storage_field2 : $field->storage_field;
         $value = array();
         if (@$options2['child_language']) {
             $language = $options2['child_language'] == '-1' ? JFactory::getLanguage()->getTag() : $options2['child_language'];
             $language = ' AND a.language = "' . $language . '"';
         } else {
             $language = '';
         }
         $location = @$options2['child_location'] ? $options2['child_location'] : 'joomla_article';
         $order = @$options2['child_orderby'] ? ' ORDER BY a.' . $options2['child_orderby'] . ' ' . $options2['child_orderby_direction'] : ' ORDER BY a.title ASC';
         $limit = @$options2['child_limit'] ? ' LIMIT ' . $options2['child_limit'] : '';
         switch ($field->bool2) {
             case 2:
                 $properties = array('table', 'access', 'custom', 'status');
                 $properties = JCck::callFunc('plgCCK_Storage_Location' . $location, 'getStaticProperties', $properties);
                 $and = $properties['status'] ? ' AND a.' . $properties['status'] . ' = 1' : '';
                 $and .= $properties['access'] ? ' AND a.' . $properties['access'] . ' IN (' . $access . ')' : '';
                 $items = JCckDatabase::loadObjectList('SELECT a.id as pk, a.' . $properties['custom'] . ' FROM ' . $properties['table'] . ' AS a LEFT JOIN #__cck_store_join_' . $name . ' AS b on b.id = a.id' . ' WHERE b.id2 = ' . (int) $config['pk'] . $and . $language . $order . $limit);
                 if (count($items)) {
                     foreach ($items as $item) {
                         $text .= JHtml::_('content.prepare', $item->{$properties}['custom']);
                         $value[] = $item->pk;
                     }
                 }
                 break;
             case 1:
                 $properties = array('table', 'access', 'status');
                 $properties = JCck::callFunc('plgCCK_Storage_Location' . $location, 'getStaticProperties', $properties);
                 $and = $properties['status'] ? ' AND a.' . $properties['status'] . ' = 1' : '';
                 $and .= $properties['access'] ? ' AND a.' . $properties['access'] . ' IN (' . $access . ')' : '';
                 $items = JCckDatabase::loadObjectList('SELECT a.id as pk, a.title FROM ' . $properties['table'] . ' AS a LEFT JOIN #__cck_store_join_' . $name . ' AS b ON b.id = a.id' . ' WHERE b.id2 = ' . (int) $config['pk'] . $and . $language . $order . $limit);
                 if (count($items)) {
                     foreach ($items as $item) {
                         $text .= ', ' . $item->title;
                         $value[] = $item->pk;
                     }
                 }
                 if ($text) {
                     $text = substr($text, 2);
                 }
                 break;
             default:
                 $options2 = new JRegistry();
                 $options2->loadString($field->options2);
                 $options3_json = $options2->get('child_link_options');
                 $options3 = new JRegistry();
                 $options3->loadString($options3_json);
                 // todo >> href
                 $properties = array('table', 'access', 'status', 'to_route');
                 $properties = JCck::callFunc('plgCCK_Storage_Location' . $location, 'getStaticProperties', $properties);
                 $and = $properties['status'] ? ' AND a.' . $properties['status'] . ' = 1' : '';
                 $and .= $properties['access'] ? ' AND a.' . $properties['access'] . ' IN (' . $access . ')' : '';
                 $items = JCckDatabase::loadObjectList('SELECT ' . $properties['to_route'] . ' FROM ' . $properties['table'] . ' AS a LEFT JOIN #__cck_store_join_' . $name . ' AS b ON b.id = a.id' . ' WHERE b.id2 = ' . (int) $config['pk'] . $and . $language . $order . $limit);
                 if (count($items)) {
                     $sef = JFactory::getConfig()->get('sef') ? $options3->get('sef', 2) : 0;
                     JCck::callFunc_Array('plgCCK_Storage_Location' . $location, 'setRoutes', array(&$items, $sef, $options3->get('itemid', $app->input->getInt('Itemid', 0))));
                     foreach ($items as $item) {
                         $text .= ', ' . '<a href="' . $item->link . '">' . $item->title . '</a>';
                         $value[] = $item->pk;
                     }
                     if ($text) {
                         $text = substr($text, 2);
                     }
                 }
                 break;
         }
         $field->divider = ',';
         $value = implode($field->divider, $value);
     } else {
         if ($value) {
             switch ($field->bool) {
                 case 2:
                     $text = JCckDatabase::loadResult('SELECT a.introtext FROM ' . self::$table . ' AS a WHERE a.id = ' . (int) $value . ' AND a.state = 1 AND a.access IN (' . $access . ')');
                     $text = JHtml::_('content.prepare', $text);
                     break;
                 case 1:
                     $text = JCckDatabase::loadResult('SELECT a.title FROM ' . self::$table . ' AS a WHERE a.id = ' . (int) $value . ' AND a.state = 1 AND a.access IN (' . $access . ')');
                     break;
                 default:
                     require_once JPATH_SITE . '/plugins/cck_storage_location/' . self::$type . '/' . self::$type . '.php';
                     $item = JCckDatabase::loadObject('SELECT a.id, a.title, a.alias, a.catid, a.language FROM ' . self::$table . ' AS a WHERE a.id = ' . (int) $value . ' AND a.state = 1 AND a.access IN (' . $access . ')');
                     if (is_object($item)) {
                         $options2 = new JRegistry();
                         $options2->loadString($field->options2);
                         $options3_json = $options2->get('parent_link_options');
                         $options3 = new JRegistry();
                         $options3->loadString($options3_json);
                         $field2 = (object) array('link' => 'content', 'link_options' => $options3_json, 'id' => $field->name, 'name' => $field->name, 'text' => htmlspecialchars($item->title), 'value' => '');
                         JCckPluginLink::g_setLink($field2, $config);
                         $field2->link = plgCCK_Storage_LocationJoomla_Article::getRoute($item, $options3->get('sef', 2), $options3->get('itemid', $app->input->getInt('Itemid', 0)));
                         JCckPluginLink::g_setHtml($field2, 'text');
                         $text = $field2->html;
                         $field->link = $field2->link;
                         $field->html = $field2->html;
                     }
                     break;
             }
         }
     }
     $field->value = $value;
     $field->text = $text;
     $field->typo_target = 'text';
 }
Пример #3
0
        $items = array();
    }
    $loaded = 1;
}
if ($plg_params->get('bridge')) {
    if (isset($items[$item->pkb]->language)) {
        $item->language = $items[$item->pkb]->language;
    }
    if (isset($items[$item->pkb]->category_title)) {
        $item->category_title = $items[$item->pkb]->category_title;
    }
    if (isset($items[$item->pkb]->category_alias)) {
        $item->category_alias = $items[$item->pkb]->category_alias;
    }
    $item->pk = $item->pkb;
    $link = plgCCK_Storage_LocationJoomla_Article::getRoute($item, $config['doSEF'], $config['Itemid'], $config);
    ?>
	<div>
		<?php 
    if ($item->params->get('show_title')) {
        $tag = $plg_params->get('item_tag_title', 'h2');
        $class = $plg_params->get('item_class_title', '');
        $class = $class ? ' class="' . $class . '"' : '';
        echo '<' . $tag . $class . '>' . ($item->params->get('link_titles') ? '<a href="' . $link . '">' . $item->title . '</a>' : $item->title) . '</' . $tag . '>';
    }
    echo JHtml::_('content.prepare', $item->introtext);
    ?>
	</div>
<?php 
} else {
    ?>
Пример #4
0
 public static function parseRoute(&$vars, $segments, $n, $config)
 {
     $config['join_key'] = 'pkb';
     require_once JPATH_SITE . '/plugins/cck_storage_location/joomla_article/joomla_article.php';
     plgCCK_Storage_LocationJoomla_Article::parseRoute($vars, $segments, $n, $config);
 }
 protected function _core($data, &$config = array(), $pk = 0)
 {
     if (!$config['id']) {
         $isNew = true;
         $config['id'] = parent::g_onCCK_Storage_LocationPrepareStore();
     } else {
         $isNew = false;
     }
     // Init
     $app = JFactory::getApplication();
     $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)) {
         if ($config['task'] == 'save2copy') {
             $empty = array(self::$key, 'alias', 'created', 'created_by', 'hits', 'modified', 'modified_by', 'version');
             foreach ($empty as $k) {
                 $data[$k] = '';
             }
         }
         $table->bind($data);
     }
     if ($isNew && !isset($data['rules'])) {
         $data['rules'] = array('core.delete' => array(), 'core.edit' => array(), 'core.edit.state' => 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;
     }
     // Featured
     self::_setFeatured($table, $isNew);
     // 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
     if (JCckDevHelper::hasLanguageAssociations()) {
         self::_setAssociations($table, $data, $isNew, $config);
     }
 }