public static function getRoute($item, $sef, $itemId, $config = array()) { if (is_numeric($item)) { $core = JCckDatabase::loadObject('SELECT cck, pkb FROM #__cck_core WHERE storage_location = "' . self::$type . '" AND pk = ' . (int) $item); if (!is_object($core)) { return ''; } $pk = $core->pkb; $config['type'] = $core->cck; } else { $pk = isset($item->pk) ? $item->pk : $item->id; $pk = JCckDatabase::loadResult('SELECT pkb FROM #__cck_core WHERE storage_location = "' . self::$type . '" AND pk = ' . (int) $pk); if (!$pk) { return ''; } } require_once JPATH_SITE . '/plugins/cck_storage_location/joomla_article/joomla_article.php'; return plgCCK_Storage_LocationJoomla_Article::getRoute($pk, $sef, $itemId, $config); }
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'; }
$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 { ?>