| Current Path : /proc/thread-self/root/proc/thread-self/root/home/digilove/.cagefs/tmp/ |
| Current File : //proc/thread-self/root/proc/thread-self/root/home/digilove/.cagefs/tmp/phpqAjfjo |
<?php
/**
* @version $Id$
* @copyright Copyright (C) 2007 - 2009 Joomla! Vargas. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @author Guillermo Vargas (guille@vargas.co.cr)
*/
defined( '_JEXEC' ) or die( 'Restricted access' );
require_once JPATH_SITE . '/components/com_content/helpers/route.php';
require_once JPATH_SITE . '/components/com_content/helpers/query.php';
/**
* Handles standard Joomla's Content articles/categories
*
* This plugin is able to expand the categories keeping the right order of the
* articles acording to the menu settings and the user session data (user state).
*
* This is a very complex plugin, if you are trying to build your own plugin
* for other component, I suggest you to take a look to another plugis as
* they are usually most simple. ;)
*/
class xmap_com_content
{
/**
* This function is called before a menu item is printed. We use it to set the
* proper uniqueid for the item
*
* @param object Menu item to be "prepared"
* @param array The extension params
*
* @return void
* @since 1.2
*/
static function prepareMenuItem($node, &$params)
{
$db = JFactory::getDbo();
$link_query = parse_url($node->link);
if (!isset($link_query['query'])) {
return;
}
parse_str(html_entity_decode($link_query['query']), $link_vars);
$view = JArrayHelper::getValue($link_vars, 'view', '');
$layout = JArrayHelper::getValue($link_vars, 'layout', '');
$id = JArrayHelper::getValue($link_vars, 'id', 0);
//----- Set add_images param
$params['add_images'] = JArrayHelper::getValue($params, 'add_images', 0);
//----- Set add pagebreaks param
$add_pagebreaks = JArrayHelper::getValue($params, 'add_pagebreaks', 1);
$params['add_pagebreaks'] = JArrayHelper::getValue($params, 'add_pagebreaks', 1);
switch ($view) {
case 'category':
if ($id) {
$node->uid = 'com_contentc' . $id;
} else {
$node->uid = 'com_content' . $layout;
}
$node->expandible = true;
break;
case 'article':
$node->uid = 'com_contenta' . $id;
$node->expandible = false;
$query = $db->getQuery(true);
$query->select($db->quoteName('created'))
->select($db->quoteName('modified'))
->from($db->quoteName('#__content'))
->where($db->quoteName('id').'='.intval($id));
if ($params['add_pagebreaks'] || $params['add_images']){
$query->select($db->quoteName('introtext'))
->select($db->quoteName('fulltext'));
}
$db->setQuery($query);
if (($row = $db->loadObject()) != NULL) {
$node->modified = $row->modified;
$text = @$item->introtext . @$item->fulltext;
if ($params['add_images']) {
$node->images = XmapHelper::getImages($text,JArrayHelper::getValue($params, 'max_images', 1000));
}
if ($params['add_pagebreaks']) {
$node->subnodes = XmapHelper::getPagebreaks($text,$node->link);
$node->expandible = (count($node->subnodes) > 0); // This article has children
}
}
break;
case 'archive':
$node->expandible = true;
break;
case 'featured':
$node->uid = 'com_contentfeatured';
$node->expandible = false;
}
}
/**
* Expands a com_content menu item
*
* @return void
* @since 1.0
*/
static function getTree($xmap, $parent, &$params)
{
$db = JFactory::getDBO();
$app = JFactory::getApplication();
$user = JFactory::getUser();
$result = null;
$link_query = parse_url($parent->link);
if (!isset($link_query['query'])) {
return;
}
parse_str(html_entity_decode($link_query['query']), $link_vars);
$view = JArrayHelper::getValue($link_vars, 'view', '');
$id = intval(JArrayHelper::getValue($link_vars, 'id', ''));
/* * *
* Parameters Initialitation
* */
//----- Set expand_categories param
$expand_categories = JArrayHelper::getValue($params, 'expand_categories', 1);
$expand_categories = ( $expand_categories == 1
|| ( $expand_categories == 2 && $xmap->view == 'xml')
|| ( $expand_categories == 3 && $xmap->view == 'html')
|| $xmap->view == 'navigator');
$params['expand_categories'] = $expand_categories;
//----- Set expand_featured param
$expand_featured = JArrayHelper::getValue($params, 'expand_featured', 1);
$expand_featured = ( $expand_featured == 1
|| ( $expand_featured == 2 && $xmap->view == 'xml')
|| ( $expand_featured == 3 && $xmap->view == 'html')
|| $xmap->view == 'navigator');
$params['expand_featured'] = $expand_featured;
//----- Set expand_featured param
$include_archived = JArrayHelper::getValue($params, 'include_archived', 2);
$include_archived = ( $include_archived == 1
|| ( $include_archived == 2 && $xmap->view == 'xml')
|| ( $include_archived == 3 && $xmap->view == 'html')
|| $xmap->view == 'navigator');
$params['include_archived'] = $include_archived;
//----- Set show_unauth param
$show_unauth = JArrayHelper::getValue($params, 'show_unauth', 1);
$show_unauth = ( $show_unauth == 1
|| ( $show_unauth == 2 && $xmap->view == 'xml')
|| ( $show_unauth == 3 && $xmap->view == 'html'));
$params['show_unauth'] = $show_unauth;
//----- Set add_images param
$add_images = JArrayHelper::getValue($params, 'add_images', 0) && $xmap->isImages;
$add_images = ( $add_images && $xmap->view == 'xml');
$params['add_images'] = $add_images;
$params['max_images'] = JArrayHelper::getValue($params, 'max_images', 1000);
//----- Set add pagebreaks param
$add_pagebreaks = JArrayHelper::getValue($params, 'add_pagebreaks', 1);
$add_pagebreaks = ( $add_pagebreaks == 1
|| ( $add_pagebreaks == 2 && $xmap->view == 'xml')
|| ( $add_pagebreaks == 3 && $xmap->view == 'html')
|| $xmap->view == 'navigator');
$params['add_pagebreaks'] = $add_pagebreaks;
if ($params['add_pagebreaks'] && !defined('_XMAP_COM_CONTENT_LOADED')) {
define('_XMAP_COM_CONTENT_LOADED',1); // Load it just once
$lang = JFactory::getLanguage();
$lang->load('plg_content_pagebreak');
}
//----- Set cat_priority and cat_changefreq params
$priority = JArrayHelper::getValue($params, 'cat_priority', $parent->priority);
$changefreq = JArrayHelper::getValue($params, 'cat_changefreq', $parent->changefreq);
if ($priority == '-1')
$priority = $parent->priority;
if ($changefreq == '-1')
$changefreq = $parent->changefreq;
$params['cat_priority'] = $priority;
$params['cat_changefreq'] = $changefreq;
//----- Set art_priority and art_changefreq params
$priority = JArrayHelper::getValue($params, 'art_priority', $parent->priority);
$changefreq = JArrayHelper::getValue($params, 'art_changefreq', $parent->changefreq);
if ($priority == '-1')
$priority = $parent->priority;
if ($changefreq == '-1')
$changefreq = $parent->changefreq;
$params['art_priority'] = $priority;
$params['art_changefreq'] = $changefreq;
$params['max_art'] = intval(JArrayHelper::getValue($params, 'max_art', 0));
$params['max_art_age'] = intval(JArrayHelper::getValue($params, 'max_art_age', 0));
$params['nullDate'] = $db->Quote($db->getNullDate());
$params['nowDate'] = $db->Quote(JFactory::getDate()->toSql());
$params['groups'] = implode(',', $user->getAuthorisedViewLevels());
// Define the language filter condition for the query
$params['language_filter'] = $app->getLanguageFilter();
switch ($view) {
case 'category':
if (!$id) {
$id = intval(JArrayHelper::getValue($params, 'id', 0));
}
if ($params['expand_categories'] && $id) {
$result = self::expandCategory($xmap, $parent, $id, $params, $parent->id);
}
break;
case 'featured':
if ($params['expand_featured']) {
$result = self::includeCategoryContent($xmap, $parent, 'featured', $params,$parent->id);
}
break;
case 'categories':
if ($params['expand_categories']) {
$result = self::expandCategory($xmap, $parent, ($id ? $id : 1), $params, $parent->id);
}
break;
case 'archive':
if ($params['expand_featured']) {
$result = self::includeCategoryContent($xmap, $parent, 'archived', $params,$parent->id);
}
break;
case 'article':
// if it's an article menu item, we have to check if we have to expand the
// article's page breaks
if ($params['add_pagebreaks']){
$query = $db->getQuery(true);
$query->select($db->quoteName('introtext'))
->select($db->quoteName('fulltext'))
->select($db->quoteName('alias'))
->select($db->quoteName('catid'))
->from($db->quoteName('#__content'))
->where($db->quoteName('id').'='.intval($id));
$db->setQuery($query);
$row = $db->loadObject();
$parent->slug = $row->alias ? ($id . ':' . $row->alias) : $id;
$parent->link = ContentHelperRoute::getArticleRoute($parent->slug, $row->catid);
$subnodes = XmapHelper::getPagebreaks($row->introtext.$row->fulltext,$parent->link);
self::printNodes($xmap, $parent, $params, $subnodes);
}
}
return $result;
}
/**
* Get all content items within a content category.
* Returns an array of all contained content items.
*
* @param object $xmap
* @param object $parent the menu item
* @param int $catid the id of the category to be expanded
* @param array $params an assoc array with the params for this plugin on Xmap
* @param int $itemid the itemid to use for this category's children
*/
static function expandCategory($xmap, $parent, $catid, &$params, $itemid)
{
$db = JFactory::getDBO();
$where = array('a.parent_id = ' . $catid . ' AND a.published = 1 AND a.extension=\'com_content\'');
if ($params['language_filter'] ) {
$where[] = 'a.language in ('.$db->quote(JFactory::getLanguage()->getTag()).','.$db->quote('*').')';
}
if (!$params['show_unauth']) {
$where[] = 'a.access IN (' . $params['groups'] . ') ';
}
$orderby = 'a.lft';
$query = 'SELECT a.id, a.title, a.alias, a.access, a.path AS route, '
. 'a.created_time created, a.modified_time modified '
. 'FROM #__categories AS a '
. 'WHERE '. implode(' AND ',$where)
. ( $xmap->view != 'xml' ? "\n ORDER BY " . $orderby . "" : '' );
$db->setQuery($query);
#echo nl2br(str_replace('#__','jos_',$db->getQuery()));exit;
$items = $db->loadObjectList();
if (count($items) > 0) {
$xmap->changeLevel(1);
foreach ($items as $item) {
$node = new stdclass();
$node->id = $parent->id;
$node->uid = $parent->uid . 'c' . $item->id;
$node->browserNav = $parent->browserNav;
$node->priority = $params['cat_priority'];
$node->changefreq = $params['cat_changefreq'];
$node->name = $item->title;
$node->expandible = true;
$node->secure = $parent->secure;
// TODO: Should we include category name or metakey here?
// $node->keywords = $item->metakey;
$node->newsItem = 0;
// For the google news we should use te publication date instead
// the last modification date. See
if ($xmap->isNews || !$item->modified)
$item->modified = $item->created;
$node->slug = $item->route ? ($item->id . ':' . $item->route) : $item->id;
$node->link = ContentHelperRoute::getCategoryRoute($node->slug);
if (strpos($node->link,'Itemid=')===false) {
$node->itemid = $itemid;
$node->link .= '&Itemid='.$itemid;
} else {
$node->itemid = preg_replace('/.*Itemid=([0-9]+).*/','$1',$node->link);
}
if ($xmap->printNode($node)) {
self::expandCategory($xmap, $parent, $item->id, $params, $node->itemid);
}
}
$xmap->changeLevel(-1);
}
// Include Category's content
self::includeCategoryContent($xmap, $parent, $catid, $params, $itemid);
return true;
}
/**
* Get all content items within a content category.
* Returns an array of all contained content items.
*
* @since 2.0
*/
static function includeCategoryContent($xmap, $parent, $catid, &$params,$Itemid)
{
$db = JFactory::getDBO();
// We do not do ordering for XML sitemap.
if ($xmap->view != 'xml') {
$orderby = self::buildContentOrderBy($parent->params,$parent->id,$Itemid);
//$orderby = !empty($menuparams['orderby']) ? $menuparams['orderby'] : (!empty($menuparams['orderby_sec']) ? $menuparams['orderby_sec'] : 'rdate' );
//$orderby = self::orderby_sec($orderby);
}
if ($params['include_archived']) {
$where = array('(a.state = 1 or a.state = 2)');
} else {
$where = array('a.state = 1');
}
if ($catid=='featured') {
$where[] = 'a.featured=1';
} elseif ($catid=='archived') {
$where = array('a.state=2');
} elseif(is_numeric($catid)) {
$where[] = 'a.catid='.(int) $catid;
}
if ($params['max_art_age'] || $xmap->isNews) {
$days = (($xmap->isNews && ($params['max_art_age'] > 3 || !$params['max_art_age'])) ? 3 : $params['max_art_age']);
$where[] = "( a.created >= '"
. date('Y-m-d H:i:s', time() - $days * 86400) . "' ) ";
}
if ($params['language_filter'] ) {
$where[] = 'a.language in ('.$db->quote(JFactory::getLanguage()->getTag()).','.$db->quote('*').')';
}
if (!$params['show_unauth'] ){
$where[] = 'a.access IN (' . $params['groups'] . ') ';
}
$query = 'SELECT a.id, a.title, a.alias, a.catid, '
. 'a.created created, a.modified modified'
. ',a.language'
. (($params['add_images'] || $params['add_pagebreaks']) ? ',a.introtext, a.fulltext ' : ' ')
. 'FROM #__content AS a '
. ($catid =='featured'? 'LEFT JOIN #__content_frontpage AS fp ON a.id = fp.content_id ' : ' ')
. 'WHERE ' . implode(' AND ',$where) . ' AND '
. ' (a.publish_up = ' . $params['nullDate']
. ' OR a.publish_up <= ' . $params['nowDate'] . ') AND '
. ' (a.publish_down = ' . $params['nullDate']
. ' OR a.publish_down >= ' . $params['nowDate'] . ') '
. ( $xmap->view != 'xml' ? "\n ORDER BY $orderby " : '' )
. ( $params['max_art'] ? "\n LIMIT {$params['max_art']}" : '');
$db->setQuery($query);
//echo nl2br(str_replace('#__','mgbj2_',$db->getQuery()));
$items = $db->loadObjectList();
if (count($items) > 0) {
$xmap->changeLevel(1);
foreach ($items as $item) {
$node = new stdclass();
$node->id = $parent->id;
$node->uid = $parent->uid . 'a' . $item->id;
$node->browserNav = $parent->browserNav;
$node->priority = $params['art_priority'];
$node->changefreq = $params['art_changefreq'];
$node->name = $item->title;
$node->modified = $item->modified;
$node->expandible = false;
$node->secure = $parent->secure;
// TODO: Should we include category name or metakey here?
// $node->keywords = $item->metakey;
$node->newsItem = 1;
$node->language = $item->language;
// For the google news we should use te publication date instead
// the last modification date. See
if ($xmap->isNews || !$node->modified)
$node->modified = $item->created;
$node->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id;
//$node->catslug = $item->category_route ? ($catid . ':' . $item->category_route) : $catid;
$node->catslug = $item->catid;
$node->link = ContentHelperRoute::getArticleRoute($node->slug, $node->catslug);
// Add images to the article
$text = @$item->introtext . @$item->fulltext;
if ($params['add_images']) {
$node->images = XmapHelper::getImages($text,$params['max_images']);
}
if ($params['add_pagebreaks']) {
$subnodes = XmapHelper::getPagebreaks($text,$node->link);
$node->expandible = (count($subnodes) > 0); // This article has children
}
if ($xmap->printNode($node) && $node->expandible) {
self::printNodes($xmap, $parent, $params, $subnodes);
}
}
$xmap->changeLevel(-1);
}
return true;
}
static private function printNodes($xmap, $parent, &$params, &$subnodes)
{
$xmap->changeLevel(1);
$i=0;
foreach ($subnodes as $subnode) {
$i++;
$subnode->id = $parent->id;
$subnode->uid = $parent->uid.'p'.$i;
$subnode->browserNav = $parent->browserNav;
$subnode->priority = $params['art_priority'];
$subnode->changefreq = $params['art_changefreq'];
$subnode->secure = $parent->secure;
$xmap->printNode($subnode);
}
$xmap->changeLevel(-1);
}
/**
* Generates the order by part of the query according to the
* menu/component/user settings. It checks if the current user
* has already changed the article's ordering column in the frontend
*
* @param JRegistry $params
* @param int $parentId
* @param int $itemid
* @return string
*/
static function buildContentOrderBy(&$params,$parentId,$itemid)
{
$app = JFactory::getApplication('site');
// Case when the child gets a different menu itemid than it's parent
if ($parentId != $itemid) {
$menu = $app->getMenu();
$item = $menu->getItem($itemid);
$menuParams = clone($params);
$itemParams = new JRegistry($item->params);
$menuParams->merge($itemParams);
} else {
$menuParams =& $params;
}
$filter_order = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order', 'filter_order', '', 'string');
$filter_order_Dir = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order_Dir', 'filter_order_Dir', '', 'cmd');
$orderby = ' ';
if ($filter_order && $filter_order_Dir) {
$orderby .= $filter_order . ' ' . $filter_order_Dir . ', ';
}
$articleOrderby = $menuParams->get('orderby_sec', 'rdate');
$articleOrderDate = $menuParams->get('order_date');
//$categoryOrderby = $menuParams->def('orderby_pri', '');
$secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate) . ', ';
//$primary = ContentHelperQuery::orderbyPrimary($categoryOrderby);
//$orderby .= $primary . ' ' . $secondary . ' a.created ';
$orderby .= $secondary . ' a.created ';
return $orderby;
}
}<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id$ -->
<extension type="plugin" group="xmap" version="1.6" method="upgrade">
<name>Xmap - Content Plugin</name>
<author>Guillermo Vargas</author>
<creationDate>01/26/2011</creationDate>
<copyright>GNU GPL</copyright>
<license>http://www.gnu.org/copyleft/gpl.html GNU/GPL</license>
<authorEmail>guille@vargas.co.cr</authorEmail>
<authorUrl>joomla.vargas.co.cr</authorUrl>
<version>2.0.4</version>
<description>XMAP_CONTENT_PLUGIN_DESCRIPTION</description>
<files>
<filename plugin="com_content">com_content.php</filename>
<filename>index.html</filename>
</files>
<languages folder="language">
<!--
these files will be installed in the administrator/language folder.
-->
<language tag="en-GB">en-GB.plg_xmap_com_content.ini</language>
<language tag="es-ES">es-ES.plg_xmap_com_content.ini</language>
<language tag="fa-IR">fa-IR.plg_xmap_com_content.ini</language>
<language tag="cs-CZ">cs-CZ.plg_xmap_com_content.ini</language>
<language tag="nl-NL">nl-NL.plg_xmap_com_content.ini</language>
<language tag="ru-RU">ru-RU.plg_xmap_com_content.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field name="expand_categories" type="list" default="1" label="XMAP_SETTING_EXPAND_CATEGORIES" description="XMAP_SETTING_EXPAND_CATEGORIES_DESC">
<option value="0">XMAP_OPTION_NEVER</option>
<option value="1">XMAP_OPTION_ALWAYS</option>
<option value="2">XMAP_OPTION_XML_ONLY</option>
<option value="3">XMAP_OPTION_HTML_ONLY</option>
</field>
<field name="expand_featured" type="list" default="1" label="XMAP_SETTING_EXPAND_FEATURED" description="XMAP_SETTING_EXPAND_FEATURED_DESC">
<option value="0">XMAP_OPTION_NEVER</option>
<option value="1">XMAP_OPTION_ALWAYS</option>
<option value="2">XMAP_OPTION_XML_ONLY</option>
<option value="3">XMAP_OPTION_HTML_ONLY</option>
</field>
<field name="include_archived" type="list" default="2" label="XMAP_SETTING_INCLUDE_ARCHIVED" description="XMAP_SETTING_INCLUDE_ARCHIVED_DESC">
<option value="0">XMAP_OPTION_NEVER</option>
<option value="1">XMAP_OPTION_ALWAYS</option>
<option value="2">XMAP_OPTION_XML_ONLY</option>
<option value="3">XMAP_OPTION_HTML_ONLY</option>
</field>
<field name="show_unauth" type="list" default="0" label="XMAP_SETTING_SHOW_UNAUTH_LINKS" description="XMAP_SETTING_SHOW_UNAUTH_LINKS_DESC">
<option value="0">XMAP_OPTION_NEVER</option>
<option value="1">XMAP_OPTION_ALWAYS</option>
<option value="2">XMAP_OPTION_XML_ONLY</option>
<option value="3">XMAP_OPTION_HTML_ONLY</option>
</field>
<field name="add_pagebreaks" type="list" default="1" label="XMAP_SETTING_ADD_PAGEBREAKS_LABEL" description="XMAP_SETTING_ADD_PAGEBREAKS_DESC">
<option value="0">XMAP_OPTION_NEVER</option>
<option value="1">XMAP_OPTION_ALWAYS</option>
<option value="2">XMAP_OPTION_XML_ONLY</option>
<option value="3">XMAP_OPTION_HTML_ONLY</option>
</field>
<field name="max_art" type="text" default="0" label="XMAP_SETTING_MAX_ART_CAT" description="XMAP_SETTING_MAX_ART_CAT_DESC" />
<field name="max_art_age" type="text" default="0" label="XMAP_SETTING_MAX_ART_AGE" description="XMAP_SETTING_MAX_ART_AGE_DESC" />
</fieldset>
<fieldset name="xml">
<field name="add_images" type="list" default="1" label="XMAP_SETTING_ADD_IMAGES_LABEL" description="XMAP_SETTING_ADD_IMAGES_DESC">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="cat_priority" type="list" default="-1" label="XMAP_SETTING_CAT_PRIORITY" description="XMAP_SETTING_CAT_PRIORITY_DESC">
<option value="-1">XMAP_OPTION_USE_PARENT_MENU</option>
<option value="0.0">0.0</option>
<option value="0.1">0.1</option>
<option value="0.2">0.2</option>
<option value="0.3">0.3</option>
<option value="0.4">0.4</option>
<option value="0.5">0.5</option>
<option value="0.6">0.6</option>
<option value="0.7">0.7</option>
<option value="0.8">0.8</option>
<option value="0.9">0.9</option>
<option value="1">1</option>
</field>
<field name="cat_changefreq" type="list" default="-1" label="XMAP_SETTING_CAT_CHANCE_FREQ" description="XMAP_SETTING_CAT_CHANCE_FREQ_DESC">
<option value="-1">XMAP_OPTION_USE_PARENT_MENU</option>
<option value="always">XMAP_OPTION_ALWAYS</option>
<option value="hourly">XMAP_OPTION_HOURLY</option>
<option value="daily">XMAP_OPTION_DAILY</option>
<option value="weekly">XMAP_OPTION_WEEKLY</option>
<option value="monthly">XMAP_OPTION_MONTHLY</option>
<option value="yearly">XMAP_OPTION_YEARLY</option>
<option value="never">XMAP_OPTION_NEVER</option>
</field>
<field name="art_priority" type="list" default="-1" label="XMAP_SETTING_ART_PRIORITY" description="XMAP_SETTING_ART_PRIORITY_DESC">
<option value="-1">XMAP_OPTION_USE_PARENT_MENU</option>
<option value="0.0">0.0</option>
<option value="0.1">0.1</option>
<option value="0.2">0.2</option>
<option value="0.3">0.3</option>
<option value="0.4">0.4</option>
<option value="0.5">0.5</option>
<option value="0.6">0.6</option>
<option value="0.7">0.7</option>
<option value="0.8">0.8</option>
<option value="0.9">0.9</option>
<option value="1">1</option>
</field>
<field name="art_changefreq" type="list" default="-1" label="XMAP_SETTING_ART_CHANCE_FREQ" description="XMAP_SETTING_ART_CHANCE_FREQ_DESC">
<option value="-1">XMAP_OPTION_USE_PARENT_MENU</option>
<option value="always">XMAP_OPTION_ALWAYS</option>
<option value="hourly">XMAP_OPTION_HOURLY</option>
<option value="daily">XMAP_OPTION_DAILY</option>
<option value="weekly">XMAP_OPTION_WEEKLY</option>
<option value="monthly">XMAP_OPTION_MONTHLY</option>
<option value="yearly">XMAP_OPTION_YEARLY</option>
<option value="never">XMAP_OPTION_NEVER</option>
</field>
</fieldset>
<fieldset name="news">
<field name="keywords" type="list" default="1" label="XMAP_SETTING_NEWS_KEYWORDS_LABEL" description="XMAP_SETTING_NEWS_KEYWORDS_DESC">
<option value="metakey">XMAP_SETTING_NEWS_KEYWORDS_METAKEYS</option>
<option value="category">XMAP_SETTING_NEWS_KEYWORDS_CATTITLE</option>
<option value="both">XMAP_SETTING_NEWS_KEYWORDS_METAKEYS_CATTITLE</option>
<option value="none">XMAP_SETTING_NEWS_KEYWORDS_NONE</option>
</field>
</fieldset>
</fields>
</config>
</extension>
<!DOCTYPE html><title></title><?php
/**
* @version $Id$
* @copyright Copyright (C) 2007 - 2009 Joomla! Vargas. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @author Guillermo Vargas (guille@vargas.co.cr)
*/
defined( '_JEXEC' ) or die( 'Restricted access' );
/** Handles Mosets Tree component */
class xmap_com_mtree
{
static function getTree( $xmap, $parent, &$params )
{
if ($xmap->isNews) // This component does not provide news content. don't waste time/resources
return false;
$db = JFactory::getDbo();
$catid=0;
if ( strpos($parent->link, 'task=listcats') ) {
$link_query = parse_url( $parent->link );
parse_str( html_entity_decode($link_query['query']), $link_vars);
$catid = JArrayHelper::getValue($link_vars,'cat_id',0);
}
$include_links = JArrayHelper::getValue($params,'include_links',1);
$include_links = ( $include_links == 1
|| ( $include_links == 2 && $xmap->view == 'xml')
|| ( $include_links == 3 && $xmap->view == 'html')
|| $xmap->view == 'navigator');
$params['include_links'] = $include_links;
$priority = JArrayHelper::getValue($params,'cat_priority',$parent->priority);
$changefreq = JArrayHelper::getValue($params,'cat_changefreq',$parent->changefreq);
if ($priority == '-1')
$priority = $parent->priority;
if ($changefreq == '-1')
$changefreq = $parent->changefreq;
$params['cat_priority'] = $priority;
$params['cat_changefreq'] = $changefreq;
$priority = JArrayHelper::getValue($params,'link_priority',$parent->priority);
$changefreq = JArrayHelper::getValue($params,'link_changefreq',$parent->changefreq);
if ($priority == '-1')
$priority = $parent->priority;
if ($changefreq == '-1')
$changefreq = $parent->changefreq;
$params['link_priority'] = $priority;
$params['link_changefreq'] = $changefreq;
$ordering = JArrayHelper::getValue($params,'cats_order','cat_name');
$orderdir = JArrayHelper::getValue($params,'cats_orderdir','ASC');
if ( !in_array($ordering,array('ordering','cat_name','cat_created')) )
$ordering = 'cat_name';
if ( !in_array($orderdir,array('ASC','DESC')) ){
$orderdir = 'ASC';
}
$params['cats_order'] = $db->quoteName($ordering)." $orderdir";
if ( $include_links ) {
$ordering = JArrayHelper::getValue($params,'links_order','ordering');
$orderdir = JArrayHelper::getValue($params,'links_orderdir','ASC');
if ( !in_array($ordering,array('ordering','link_name','link_modified','link_created','link_hits')) )
$ordering = 'ordering';
if ( !in_array($orderdir,array('ASC','DESC')) ){
$orderdir = 'ASC';
}
$params['links_order'] = $db->quoteName($ordering)." $orderdir";
$params['limit'] = '';
$params['days'] = '';
$limit = JArrayHelper::getValue($params,'max_links',0);
if ( intval($limit) )
$params['limit'] = ' LIMIT '.intval($limit);
$days = JArrayHelper::getValue($params,'max_age','');
if ( intval($days) )
$params['days'] = ' AND a.link_created >=\''.date('Y-m-d H:i:s',($xmap->now - ($days*86400))) ."' ";
}
xmap_com_mtree::getMtreeCategory($xmap,$parent,$params,$catid);
}
/* Returns URLs of all Categories and links in of one category using recursion */
static function getMtreeCategory ($xmap, $parent, &$params, $catid )
{
$database =& JFactory::getDbo();
$query = "SELECT cat_name, cat_id ".
"FROM #__mt_cats WHERE cat_published='1' AND cat_approved='1' AND cat_parent = $catid " .
"ORDER BY " . $params['cats_order'];
$database->setQuery($query);
$rows = $database->loadObjectList();
$xmap->changeLevel(1);
foreach($rows as $row) {
$node = new stdclass;
$node->name = $row->cat_name;
$node->link = 'index.php?option=com_mtree&task=listcats&cat_id='.$row->cat_id.'&Itemid='.$parent->id;
$node->id = $parent->id;
$node->uid = $parent->uid .'c'.$row->cat_id;
$node->browserNav = $parent->browserNav;
$node->modified = NULL;
$node->priority = $params['cat_priority'];
$node->changefreq = $params['cat_changefreq'];
$node->expandible = true;
$node->secure = $parent->secure;
if ( $xmap->printNode($node) !== FALSE) {
xmap_com_mtree::getMtreeCategory($xmap,$parent,$params,$row->cat_id);
}
}
/* Returns URLs of all listings in the current category */
if ($params['include_links']) {
$query = " SELECT a.link_name, a.link_id, a.link_created as created, a.link_modified as modified \n".
" FROM #__mt_links AS a, #__mt_cl as b \n".
" WHERE a.link_id = b.link_id \n".
" AND b.cat_id = $catid " .
" AND ( link_published='1' AND link_approved='1' ) " .
$params['days'] .
" ORDER BY " . $params['links_order'] .
$params['limit'];
$database->setQuery($query);
$rows = $database->loadObjectList();
foreach($rows as $row) {
if ( !$row->modified || ($row->modified == $database->getNullDate())) {
$row->modified = $row->created;
}
$node = new stdclass;
$node->name = $row->link_name;
$node->link = 'index.php?option=com_mtree&task=viewlink&link_id='.$row->link_id.'&Itemid='.$parent->id;
$node->id = $parent->id;
$node->uid = $parent->uid.'l'.$row->link_id;
$node->browserNav = $parent->browserNav;
$node->modified = $row->modified;
$node->priority = $params['link_priority'];
$node->changefreq = $params['link_changefreq'];
$node->expandible = false;
$node->secure = $parent->secure;
$xmap->printNode($node);
}
}
$xmap->changeLevel(-1);
}
}
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Id$ -->
<extension type="plugin" group="xmap" version="1.6" method="upgrade">
<name>Xmap - Mosets Tree Plugin</name>
<author>Guillermo Vargas</author>
<creationDate>07/20/2011</creationDate>
<copyright>GNU GPL</copyright>
<license>http://www.gnu.org/copyleft/gpl.html GNU/GPL</license>
<authorEmail>guille@vargas.co.cr</authorEmail>
<authorUrl>joomla.vargas.co.cr</authorUrl>
<version>2.0.2</version>
<description>XMAP_MTREE_PLUGIN_DESCRIPTION</description>
<files>
<filename plugin="com_mtree">com_mtree.php</filename>
<filename>index.html</filename>
</files>
<languages folder="language">
<!--
these files will be installed in the administrator/language folder.
-->
<language tag="en-GB">en-GB.plg_xmap_com_mtree.ini</language>
<language tag="es-ES">es-ES.plg_xmap_com_mtree.ini</language>
<language tag="fa-IR">fa-IR.plg_xmap_com_mtree.ini</language>
<language tag="cs-CZ">cs-CZ.plg_xmap_com_mtree.ini</language>
<language tag="nl-NL">nl-NL.plg_xmap_com_mtree.ini</language>
<language tag="ru-RU">ru-RU.plg_xmap_com_mtree.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field name="cats_order" type="list" default="cat_name" label="XMAP_SETTING_CATEGORIES_ORDER_LABEL" description="XMAP_SETTING_CATEGORIES_ORDER_DESC">
<option value="ordering">XMAP_SETTING_OPTION_ORDERING_DEFAULT</option>
<option value="cat_name">XMAP_SETTING_OPTION_ORDERING_NAME</option>
<option value="cat_created">XMAP_SETTING_OPTION_ORDERING_CREATED</option>
</field>
<field name="cats_orderdir" type="list" default="ASC" label="XMAP_SETTING_CATEGORIES_ORDER_DIR_LABEL" description="XMAP_SETTING_CATEGORIES_ORDER_DIR_DESC">
<option value="ASC">XMAP_SETTING_OPTION_ORDERING_DIR_ASC</option>
<option value="DESC">XMAP_SETTING_OPTION_ORDERING_DIR_DESC</option>
</field>
<field name="include_links" type="list" default="1" label="XMAP_SETTING_SHOW_LISTINGS_LABEL" description="XMAP_SETTING_SHOW_LISTINGS_DESC">
<option value="0">XMAP_OPTION_NEVER</option>
<option value="1">XMAP_OPTION_ALWAYS</option>
<option value="2">XMAP_OPTION_XML_ONLY</option>
<option value="3">XMAP_OPTION_HTML_ONLY</option>
</field>
<field name="links_order" type="list" default="ordering" label="XMAP_SETTING_LISTINGS_ORDER_LABEL" description="XMAP_SETTING_LISTINGS_ORDER_DESC">
<option value="ordering">XMAP_SETTING_OPTION_ORDERING_DEFAULT</option>
<option value="link_name">XMAP_SETTING_OPTION_ORDERING_NAME</option>
<option value="link_created">XMAP_SETTING_OPTION_ORDERING_CREATED</option>
<option value="link_modified">XMAP_SETTING_OPTION_ORDERING_MODIFIED</option>
<option value="link_hits">XMAP_SETTING_OPTION_ORDERING_HITS</option>
</field>
<field name="entries_orderdir" type="list" default="ASC" label="XMAP_SETTING_LISTINGS_ORDER_DIR_LABEL" description="XMAP_SETTING_LISTINGS_ORDER_DIR_DESC">
<option value="ASC">XMAP_SETTING_OPTION_ORDERING_DIR_ASC</option>
<option value="DESC">XMAP_SETTING_OPTION_ORDERING_DIR_DESC</option>
</field>
<field name="max_links" type="text" default="" label="XMAP_SETTING_MAX_ENTRIES_LABEL" description="XMAP_SETTING_MAX_ENTRIES_DESC" />
<field name="max_age" type="text" default="" label="XMAP_SETTING_LISTINGS_NEWER_THAN_LABEL" description="XMAP_SETTING_LISTINGS_NEWER_THAN_LABEL" />
</fieldset>
<fieldset name="xml">
<field name="cat_priority" type="list" default="0.5" label="XMAP_MTREE_CATEGORY_PRIORITY_LABEL" description="XMAP_MTREE_CATEGORY_PRIORITY_DESC">
<option value="-1">XMAP_OPTION_USE_PARENT_MENU</option>
<option value="0.0">0.0</option>
<option value="0.1">0.1</option>
<option value="0.2">0.2</option>
<option value="0.3">0.3</option>
<option value="0.4">0.4</option>
<option value="0.5">0.5</option>
<option value="0.6">0.6</option>
<option value="0.7">0.7</option>
<option value="0.8">0.8</option>
<option value="0.9">0.9</option>
<option value="1">1</option>
</field>
<field name="cat_changefreq" type="list" default="weekly" label="XMAP_MTREE_CATEGORY_CHANGEFREQ_LABEL" description="XMAP_MTREE_CATEGORY_CHANGEFREQ_DESC">
<option value="-1">XMAP_OPTION_USE_PARENT_MENU</option>
<option value="always">XMAP_OPTION_ALWAYS</option>
<option value="hourly">XMAP_OPTION_HOURLY</option>
<option value="daily">XMAP_OPTION_DAILY</option>
<option value="weekly">XMAP_OPTION_WEEKLY</option>
<option value="monthly">XMAP_OPTION_MONTHLY</option>
<option value="yearly">XMAP_OPTION_YEARLY</option>
<option value="never">XMAP_OPTION_NEVER</option>
</field>
<field name="link_priority" type="list" default="0.5" label="XMAP_MTREE_LISTING_PRIORITY_LABEL" description="XMAP_MTREE_LISTING_PRIORITY_DESC">
<option value="-1">XMAP_OPTION_USE_PARENT_MENU</option>
<option value="0.0">0.0</option>
<option value="0.1">0.1</option>
<option value="0.2">0.2</option>
<option value="0.3">0.3</option>
<option value="0.4">0.4</option>
<option value="0.5">0.5</option>
<option value="0.6">0.6</option>
<option value="0.7">0.7</option>
<option value="0.8">0.8</option>
<option value="0.9">0.9</option>
<option value="1">1</option>
</field>
<field name="link_changefreq" type="list" default="weekly" label="XMAP_MTREE_LISTING_CHANGEFREQ_LABEL" description="XMAP_MTREE_LISTING_CHANGEFREQ_DESC">
<option value="-1">XMAP_OPTION_USE_PARENT_MENU</option>
<option value="always">XMAP_OPTION_ALWAYS</option>
<option value="hourly">XMAP_OPTION_HOURLY</option>
<option value="daily">XMAP_OPTION_DAILY</option>
<option value="weekly">XMAP_OPTION_WEEKLY</option>
<option value="monthly">XMAP_OPTION_MONTHLY</option>
<option value="yearly">XMAP_OPTION_YEARLY</option>
<option value="never">XMAP_OPTION_NEVER</option>
</field>
</fieldset>
</fields>
</config>
</extension>
<!DOCTYPE html><title></title><?php
/**
* @author Guillermo Vargas guille@vargas.co.cr
* @version $Id$
* @package xmap
* @license GNU/GPL
* @authorSite http://www.jooxmap.com
*/
defined( '_JEXEC' ) or die( 'Restricted access' );
/** Adds support for SobiPro categories to Xmap */
class xmap_com_sobipro {
static $sectionConfig = array();
/*
* This function is called before a menu item is printed. We use it to set the
* proper uniqueid for the item and indicate whether the node is expandible or not
*/
function prepareMenuItem($node, &$params) {
$link_query = parse_url( $node->link );
parse_str( html_entity_decode($link_query['query']), $link_vars);
$sid = JArrayHelper::getValue($link_vars,'sid',0);
$db = JFactory::getDbo();
$db->setQuery('SELECT * FROM `#__sobipro_object` where id='.(int)$sid);
$row = $db->loadObject();
$node->uid = 'com_sobiproo'.$sid;
if ( $row->oType == 'section' || $row->oType == 'category' ) {
$node->expandible = true;
} else {
$node->expandible = false;
}
}
/** Get the content tree for this kind of content */
function getTree( $xmap, $parent, &$params ) {
if ($xmap->isNews) // This component does not provide news content. don't waste time/resources
return false;
if (!self::loadSobi()){
return;
}
$link_query = parse_url( $parent->link );
parse_str( html_entity_decode($link_query['query']), $link_vars);
$sid =JArrayHelper::getValue($link_vars,'sid',1);
$task =JArrayHelper::getValue($link_vars,'task', null);
if (in_array($task, array('search', 'entry.add'))) {
return;
}
$db = JFactory::getDbo();
$db->setQuery('SELECT * FROM `#__sobipro_object` where id='.(int)$sid);
$object = $db->loadObject();
if ($object->oType == 'entry') {
return;
} elseif ( $object->oType == 'category' ) {
$sectionId = self::findCategorySection($object->parent);
} else {
$sectionId = $sid;
}
self::$sectionConfig = self::getSectionConfig($sectionId);
$include_entries =JArrayHelper::getValue($params,'include_entries',1);
$include_entries = ( $include_entries == 1
|| ( $include_entries == 2 && $xmap->view == 'xml')
|| ( $include_entries == 3 && $xmap->view == 'html')
|| $xmap->view == 'navigator');
$params['include_entries'] = $include_entries;
$priority =JArrayHelper::getValue($params,'cat_priority',$parent->priority);
$changefreq =JArrayHelper::getValue($params,'cat_changefreq',$parent->changefreq);
if ($priority == '-1')
$priority = $parent->priority;
if ($changefreq == '-1')
$changefreq = $parent->changefreq;
$params['cat_priority'] = $priority;
$params['cat_changefreq'] = $changefreq;
$priority =JArrayHelper::getValue($params,'entry_priority',$parent->priority);
$changefreq =JArrayHelper::getValue($params,'entry_changefreq',$parent->changefreq);
if ($priority == '-1')
$priority = $parent->priority;
if ($changefreq == '-1')
$changefreq = $parent->changefreq;
$params['entry_priority'] = $priority;
$params['entry_changefreq'] = $changefreq;
$date = JFactory::getDate();
$params['now'] = $date->toMySql();
if ( $include_entries ) {
$ordering = JArrayHelper::getValue($params,'entries_order','b.position');
$orderdir = JArrayHelper::getValue($params,'entries_orderdir','ASC');
if ( !in_array($ordering,array('b.position','a.counter','b.validSince','a.updatedTime')) ){
$ordering = 'b.position';
}
if ( !in_array($orderdir,array('ASC','DESC')) ){
$orderdir = 'ASC';
}
$params['ordering'] = $ordering. ' '. $orderdir;
$params['limit'] = '';
$params['days'] = '';
$limit = JArrayHelper::getValue($params,'max_entries','');
if ( intval($limit) )
$params['limit'] = ' LIMIT '.$limit;
$days = JArrayHelper::getValue($params,'max_age','');
if ( intval($days) )
$params['days'] = ' AND a.publish_up >=\''.strftime("%Y-%m-%d %H:%M:%S",$xmap->now - ($days*86400)) ."' ";
}
xmap_com_sobipro::getCategoryTree($xmap, $parent, $sid, $params);
}
/** SobiPro support */
function getCategoryTree( $xmap, $parent, $sid, &$params ) {
$database =& JFactory::getDBO();
$query =
"SELECT a.id,a.nid, a.name, b.pid as pid "
."\n FROM #__sobipro_object AS a, #__sobipro_relations AS b "
."\n WHERE a.parent=$sid"
." AND a.oType='category'"
." AND b.oType=a.oType"
." AND a.state=1 "
." AND a.approved=1 "
."\n AND a.id=b.id "
."\n ORDER BY b.position ASC";
$database->setQuery( $query );
$rows = $database->loadObjectList();
$modified = time();
$xmap->changeLevel(1);
foreach($rows as $row) {
$node = new stdclass;
$node->id = $parent->id;
$node->uid = 'com_sobiproc'.$row->id; // Unique ID
$node->browserNav = $parent->browserNav;
$node->name = html_entity_decode($row->name);
$node->modified = $modified;
#$node->link = 'index.php?option=com_sobipro&sid='.$row->id.':'.trim( SPLang::urlSafe( $row->name ) ).'&Itemid='.$parent->id;
$node->link = SPJoomlaMainFrame::url( array('sid' => $row->id, 'title' => $row->name), false, false );
$node->priority = $params['cat_priority'];
$node->changefreq = $params['cat_changefreq'];
$node->expandible = true;
$node->secure = $parent->secure;
if ( $xmap->printNode($node) !== FALSE ) {
xmap_com_sobipro::getCategoryTree($xmap, $parent, $row->id, $params);
}
}
if ( $params['include_entries'] ) {
$query =
"SELECT a.id, c.baseData as name,a.updatedTime as modified,b.validSince as publish_up, b.pid as catid "
."\n FROM #__sobipro_object AS a, #__sobipro_relations AS b, #__sobipro_field_data c"
."\n WHERE a.state=1 "
."\n AND a.id=b.id "
."\n AND b.oType = 'entry'"
."\n AND b.pid = $sid"
."\n AND a.approved=1 "
."\n AND (a.validUntil>='{$params['now']}' or a.validUntil='0000-00-00 00:00:00' ) "
."\n AND (a.validSince<='{$params['now']}' or a.validSince='0000-00-00 00:00:00' ) "
."\n AND a.id=c.sid AND c.fid=".self::$sectionConfig['name_field']->sValue
."\n AND c.section=".self::$sectionConfig['name_field']->section
. $params['days']
."\n ORDER BY " . $params['ordering']
. $params['limit'];
$database->setQuery( $query );
$rows = $database->loadObjectList();
foreach($rows as $row) {
$node = new stdclass;
$node->id = $parent->id;
$node->uid = 'com_sobiproe'.$row->id; // Unique ID
$node->browserNav = $parent->browserNav;
$node->name = html_entity_decode($row->name);
$node->modified = $row->modified? $row->modified : $row->publish_up;
$node->priority = $params['entry_priority'];
$node->changefreq = $params['entry_changefreq'];
$node->expandible = false;
$node->secure = $parent->secure;
# $node->link = 'index.php?option=com_sobipro&pid='.$row->catid . '&sid=' . $row->id.':'.trim( SPLang::urlSafe( $row->name )).'&Itemid='.$parent->id;
$node->link = SPJoomlaMainFrame::url( array('sid' => $row->id, 'pid' => $row->catid, 'title' => $row->name), false, false );
$xmap->printNode($node);
}
}
$xmap->changeLevel(-1);
}
static protected function getSectionConfig($sectionId)
{
$db = JFactory::getDbo();
$db->setQuery('SELECT * FROM `#__sobipro_config` where section='.(int)$sectionId);
return $db->loadObjectList('sKey');
}
static protected function loadSobi()
{
if (defined('SOBI_TESTS')) {
return true;
}
define( 'SOBI_TESTS', false );
$ver = new JVersion();
$ver = str_replace( '.', null, $ver->RELEASE );
// added by Pierre Burri-Wittke globeall.de
if ($ver > '15') { $ver = '16'; }
define( 'SOBI_CMS', 'joomla'. $ver );
define( 'SOBIPRO', true );
define( 'SOBI_TASK', 'task' );
define( 'SOBI_DEFLANG', JFactory::getLanguage()->getDefault() );
define( 'SOBI_ACL', 'front' );
define( 'SOBI_ROOT', JPATH_ROOT );
define( 'SOBI_MEDIA', implode( '/', array( JPATH_ROOT, 'media', 'sobipro' ) ) );
define( 'SOBI_MEDIA_LIVE', JURI::root().'/media/sobipro' );
define( 'SOBI_PATH', SOBI_ROOT.'/components/com_sobipro' );
if (!file_exists(SOBI_PATH.'/lib/base/fs/loader.php')) {
return false;
}
require_once SOBI_PATH.'/lib/base/fs/loader.php';
SPLoader::loadClass( 'sobi' );
SPLoader::loadClass( 'base.request' );
SPLoader::loadClass( 'base.object' );
SPLoader::loadClass( 'base.factory' );
SPLoader::loadClass( 'base.mainframe' );
// added by Pierre Burri-Wittke globeall.de
SPLoader::loadClass( 'base.const' );
SPLoader::loadClass( 'cms.base.mainframe' );
SPLoader::loadClass( 'cms.base.lang' );
return true;
}
static protected function findCategorySection($sid)
{
$db = JFactory::getDbo();
$db->setQuery('SELECT id,parent,oType FROM `#__sobipro_object` where id='.(int)$sid);
$row = $db->loadObject();
if ($row->oType == 'section') {
return $row->id;
} else {
return self::findCategorySection($row->parent);
}
}
}
<?xml version="1.0" encoding="iso-8859-1"?>
<extension type="plugin" group="xmap" version="1.6" method="upgrade">
<name>Xmap - SobiPro Plugin</name>
<author>Guillermo Vargas</author>
<creationDate>07/15/2011</creationDate>
<copyright>GNU GPL</copyright>
<license>http://www.gnu.org/copyleft/gpl.html GNU/GPL</license>
<authorEmail>guille@vargas.co.cr</authorEmail>
<authorUrl>joomla.vargas.co.cr</authorUrl>
<version>2.0.2</version>
<description>Xmap Plugin for SobiPro component</description>
<files>
<filename plugin="com_sobipro">com_sobipro.php</filename>
</files>
<languages folder="language">
<!--
these files will be installed in the administrator/language folder.
-->
<language tag="en-GB">en-GB.plg_xmap_com_sobipro.ini</language>
<language tag="es-ES">es-ES.plg_xmap_com_sobipro.ini</language>
<language tag="fa-IR">fa-IR.plg_xmap_com_sobipro.ini</language>
<language tag="cs-CZ">cs-CZ.plg_xmap_com_sobipro.ini</language>
<language tag="nl-NL">nl-NL.plg_xmap_com_sobipro.ini</language>
<language tag="ru-RU">ru-RU.plg_xmap_com_sobipro.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field name="include_entries" type="list" default="1" label="XMAP_SETTING_SHOW_ENTRIES_LABEL" description="XMAP_SETTING_SHOW_ENTRIES_DESC">
<option value="0">XMAP_OPTION_NEVER</option>
<option value="1">XMAP_OPTION_ALWAYS</option>
<option value="2">XMAP_OPTION_XML_ONLY</option>
<option value="3">XMAP_OPTION_HTML_ONLY</option>
</field>
<field name="max_entries" type="text" default="" label="XMAP_SETTING_MAX_ENTRIES_LABEL" description="XMAP_SETTING_MAX_ENTRIES_DESC" />
<field name="max_age" type="text" default="" label="XMAP_SOBIPRO_NEWEST_THAN_LABEL" description="XMAP_SOBIPRO_NEWEST_THAN_DESC" />
<field name="entries_order" type="list" default="a.ordering" label="XMAP_OPTION_ENTRIES_ORDER" description="XMAP_OPTION_ENTRIES_ORDER_DESC">
<option value="b.position">XMAP_OPTION_DEFAULT</option>
<option value="a.counter">XMAP_OPTION_VISITS</option>
<option value="b.validSince">XMAP_OPTION_PUBLISH</option>
<option value="a.updatedTime">XMAP_OPTION_MOD</option>
</field>
<field name="entries_orderdir" type="list" default="DESC" label="XMAP_SETTING_CATEGORIES_ORDER_DIR_LABEL" description="XMAP_SETTING_CATEGORIES_ORDER_DIR_DESC">
<option value="ASC">XMAP_SETTING_OPTION_ORDERING_DIR_ASC</option>
<option value="DESC">XMAP_SETTING_OPTION_ORDERING_DIR_DESC</option>
</field>
</fieldset>
<fieldset name="xml">
<field name="cat_priority" type="list" default="-1" label="XMAP_SOBIPRO_CATEGORY_PRIORITY_LABEL" description="XMAP_SOBIPRO_CATEGORY_PRIORITY_DESC">
<option value="-1">XMAP_OPTION_USE_PARENT_MENU</option>
<option value="0.0">0.0</option>
<option value="0.1">0.1</option>
<option value="0.2">0.2</option>
<option value="0.3">0.3</option>
<option value="0.4">0.4</option>
<option value="0.5">0.5</option>
<option value="0.6">0.6</option>
<option value="0.7">0.7</option>
<option value="0.8">0.8</option>
<option value="0.9">0.9</option>
<option value="1">1</option>
</field>
<field name="cat_changefreq" type="list" default="weekly" label="XMAP_SOBIPRO_CATEGORY_CHANGEFREQ_LABEL" description="XMAP_SOBIPRO_CATEGORY_CHANGEFREQ_DESC">
<option value="-1">XMAP_OPTION_USE_PARENT_MENU</option>
<option value="always">XMAP_OPTION_ALWAYS</option>
<option value="hourly">XMAP_OPTION_HOURLY</option>
<option value="daily">XMAP_OPTION_DAILY</option>
<option value="weekly">XMAP_OPTION_WEEKLY</option>
<option value="monthly">XMAP_OPTION_MONTHLY</option>
<option value="yearly">XMAP_OPTION_YEARLY</option>
<option value="never">XMAP_OPTION_NEVER</option>
</field>
<field name="entry_priority" type="list" default="-1" label="XMAP_SOBIPRO_ENTRIES_PRIORITY_LABEL" description="XMAP_SOBIPRO_ENTRIES_PRIORITY_DESC">
<option value="-1">XMAP_OPTION_USE_PARENT_MENU</option>
<option value="0.0">0.0</option>
<option value="0.1">0.1</option>
<option value="0.2">0.2</option>
<option value="0.3">0.3</option>
<option value="0.4">0.4</option>
<option value="0.5">0.5</option>
<option value="0.6">0.6</option>
<option value="0.7">0.7</option>
<option value="0.8">0.8</option>
<option value="0.9">0.9</option>
<option value="1">1</option>
</field>
<field name="entry_changefreq" type="list" default="weekly" label="XMAP_SOBIPRO_ENTRIES_CHANGEFREQ_LABEL" description="XMAP_SOBIPRO_ENTRIES_CHANGEFREQ_DESC">
<option value="-1">XMAP_OPTION_USE_PARENT_MENU</option>
<option value="always">XMAP_OPTION_ALWAYS</option>
<option value="hourly">XMAP_OPTION_HOURLY</option>
<option value="daily">XMAP_OPTION_DAILY</option>
<option value="weekly">XMAP_OPTION_WEEKLY</option>
<option value="monthly">XMAP_OPTION_MONTHLY</option>
<option value="yearly">XMAP_OPTION_YEARLY</option>
<option value="never">XMAP_OPTION_NEVER</option>
</field>
</fieldset>
</fields>
</config>
</extension>
<?php
/**
* @author Guillermo Vargas, http://www.jooxmap.com
* @email guille@vargas.co.cr
* @version $Id: com_virtuemart.php 154 2011-04-09 23:44:12Z guilleva $
* @package Xmap
* @license GNU/GPL
* @description Xmap plugin for Virtuemart component
*/
defined( '_JEXEC' ) or die( 'Restricted access' );
/** Adds support for Virtuemart categories to Xmap */
class xmap_com_virtuemart
{
protected static $categoryModel;
protected static $productModel;
protected static $initialized = false;
static $urlBase;
/*
* This function is called before a menu item is printed. We use it to set the
* proper uniqueid for the item and indicate whether the node is expandible or not
*/
static function prepareMenuItem($node, &$params)
{
$app = JFactory::getApplication();
$link_query = parse_url($node->link);
parse_str(html_entity_decode($link_query['query']), $link_vars);
$catid = JArrayHelper::getValue($link_vars, 'virtuemart_category_id', 0);
$prodid = JArrayHelper::getValue($link_vars, 'virtuemart_product_id', 0);
if (!$catid)
{
$menu = $app->getMenu();
$menuParams = $menu->getParams($node->id);
$catid = $menuParams->get('virtuemart_category_id', 0);
}
if (!$prodid)
{
$menu = $app->getMenu();
$menuParams = $menu->getParams($node->id);
$prodid = $menuParams->get('virtuemart_product_id', 0);
}
if ($prodid && $catid)
{
$node->uid = 'com_virtuemartc' . $catid . 'p' . $prodid;
$node->expandible = false;
}
elseif($catid)
{
$node->uid = 'com_virtuemartc' . $catid;
$node->expandible = true;
}
}
/** Get the content tree for this kind of content */
static function getTree($xmap, $parent, &$params)
{
self::initialize();
$app = JFactory::getApplication();
$menu = $app->getMenu();
$link_query = parse_url($parent->link);
parse_str(html_entity_decode($link_query['query']), $link_vars);
$catid = intval(JArrayHelper::getValue($link_vars, 'virtuemart_category_id', 0));
$params['Itemid'] = intval(JArrayHelper::getValue($link_vars, 'Itemid', $parent->id));
$view = JArrayHelper::getValue($link_vars, 'view', '');
// we currently support only categories
if (!in_array($view, array('categories','category')))
{
return true;
}
$include_products = JArrayHelper::getValue($params, 'include_products', 1);
$include_products = ( $include_products == 1
|| ( $include_products == 2 && $xmap->view == 'xml')
|| ( $include_products == 3 && $xmap->view == 'html'));
$params['include_products'] = $include_products;
$params['include_product_images'] = (JArrayHelper::getValue($params, 'include_product_images', 1) && $xmap->view == 'xml');
$params['product_image_license_url'] = trim(JArrayHelper::getValue($params, 'product_image_license_url', ''));
$priority = JArrayHelper::getValue($params, 'cat_priority', $parent->priority);
$changefreq = JArrayHelper::getValue($params, 'cat_changefreq', $parent->changefreq);
if ($priority == '-1')
{
$priority = $parent->priority;
}
if ($changefreq == '-1')
{
$changefreq = $parent->changefreq;
}
$params['cat_priority'] = $priority;
$params['cat_changefreq'] = $changefreq;
$priority = JArrayHelper::getValue($params, 'prod_priority', $parent->priority);
$changefreq = JArrayHelper::getValue($params, 'prod_changefreq', $parent->changefreq);
if ($priority == '-1')
{
$priority = $parent->priority;
}
if ($changefreq == '-1')
{
$changefreq = $parent->changefreq;
}
$params['prod_priority'] = $priority;
$params['prod_changefreq'] = $changefreq;
xmap_com_virtuemart::getCategoryTree($xmap, $parent, $params, $catid);
return true;
}
/** Virtuemart support */
static function getCategoryTree($xmap, $parent, &$params, $catid=0)
{
$database = JFactory::getDBO();
if (!isset($urlBase))
{
$urlBase = JURI::base();
}
$vendorId = 1;
$cache = JFactory::getCache('com_virtuemart','callback');
$children = $cache->call( array( 'VirtueMartModelCategory', 'getChildCategoryList' ),$vendorId, $catid );
$xmap->changeLevel(1);
foreach ($children as $row)
{
$node = new stdclass;
$node->id = $parent->id;
$node->uid = $parent->uid . 'c' . $row->virtuemart_category_id;
$node->browserNav = $parent->browserNav;
$node->name = stripslashes($row->category_name);
$node->priority = $params['cat_priority'];
$node->changefreq = $params['cat_changefreq'];
$node->expandible = true;
$node->link = 'index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $row->virtuemart_category_id . '&Itemid='.$parent->id;
if ($xmap->printNode($node) !== FALSE)
{
xmap_com_virtuemart::getCategoryTree($xmap, $parent, $params, $row->virtuemart_category_id);
}
}
$xmap->changeLevel(-1);
if ($params['include_products'] && $catid != 0)
{
$products = self::$productModel->getProductsInCategory($catid);
if ($params['include_product_images'])
{
self::$categoryModel->addImages($products,1);
}
$xmap->changeLevel(1);
foreach ($products as $row)
{
$node = new stdclass;
$node->id = $parent->id;
$node->uid = $parent->uid . 'c' . $row->virtuemart_category_id . 'p' . $row->virtuemart_product_id;
$node->browserNav = $parent->browserNav;
$node->priority = $params['prod_priority'];
$node->changefreq = $params['prod_changefreq'];
$node->name = $row->product_name;
$node->modified = strtotime($row->modified_on);
$node->expandible = false;
$node->link = 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $row->virtuemart_product_id . '&virtuemart_category_id=' . $row->virtuemart_category_id . '&Itemid=' . $parent->id;
if ($params['include_product_images'])
{
foreach ($row->images as $image)
{
if (isset($image->file_url))
{
$imagenode = new stdClass;
$imagenode->src = $urlBase . $image->file_url_thumb;
$imagenode->title = $row->product_name;
$imagenode->license = $params['product_image_license_url'];
$node->images[] = $imagenode;
}
}
}
$xmap->printNode($node);
}
$xmap->changeLevel(-1);
}
}
static protected function initialize()
{
if (self::$initialized) return;
$app = JFactory::getApplication ();
if (!class_exists( 'VmConfig' ))
{
require(JPATH_ADMINISTRATOR . '/components/com_virtuemart/helpers/config.php');
VmConfig::loadConfig();
}
JTable::addIncludePath(JPATH_VM_ADMINISTRATOR . '/tables');
VmConfig::set ('llimit_init_FE', 9000);
$app->setUserState('com_virtuemart.htmlc-1.limit',9000);
$app->setUserState('com_virtuemart.htmlc0.limit',9000);
$app->setUserState('com_virtuemart.xmlc0.limit' ,9000);
if (!class_exists('VirtueMartModelCategory')) require(JPATH_VM_ADMINISTRATOR . '/models/category.php');
self::$categoryModel = new VirtueMartModelCategory();
if (!class_exists('VirtueMartModelProduct')) require(JPATH_VM_ADMINISTRATOR . '/models/product.php');
self::$productModel = new VirtueMartModelProduct();
}
}
<?xml version="1.0" encoding="iso-8859-1"?>
<extension type="plugin" group="xmap" version="1.6" method="upgrade">
<name>Xmap - Virtuemart Plugin</name>
<author>Guillermo Vargas</author>
<creationDate>January 2012</creationDate>
<copyright>GNU GPL</copyright>
<license>http://www.gnu.org/copyleft/gpl.html GNU/GPL</license>
<authorEmail>guille@vargas.co.cr</authorEmail>
<authorUrl>joomla.vargas.co.cr</authorUrl>
<version>2.0.3</version>
<description>XMAP_VM_PLUGIN_DESCRIPTION</description>
<files>
<filename plugin="com_virtuemart">com_virtuemart.php</filename>
<filename>index.html</filename>
</files>
<languages folder="language">
<!--
these files will be installed in the administrator/language folder.
-->
<language tag="en-GB">en-GB.plg_xmap_com_virtuemart.ini</language>
<language tag="es-ES">es-ES.plg_xmap_com_virtuemart.ini</language>
<language tag="fa-IR">fa-IR.plg_xmap_com_virtuemart.ini</language>
<language tag="cs-CZ">cs-CZ.plg_xmap_com_virtuemart.ini</language>
<language tag="nl-NL">nl-NL.plg_xmap_com_virtuemart.ini</language>
<language tag="ru-RU">ru-RU.plg_xmap_com_virtuemart.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field name="include_products" type="list" default="1" label="XMAP_VM_SETTING_SHOW_PRODUCTS_LABEL" description="XMAP_VM_SETTING_SHOW_PRODUCTS_DESC">
<option value="0">XMAP_OPTION_NEVER</option>
<option value="1">XMAP_OPTION_ALWAYS</option>
<option value="2">XMAP_OPTION_XML_ONLY</option>
<option value="3">XMAP_OPTION_HTML_ONLY</option>
</field>
<!-- not yet supported on Xmap 2
<field name="include_product_images" type="list" default="0" label="Include Product Images" description="Should we include product images in the sitemap?">
<option value="0">No</option>
<option value="1">Yes</option>
</field>
<field name="product_image_license_url" type="text" default="" label="Image License URL" description="URL of a page giving the license for images included in your sitemap"/>
-->
</fieldset>
<fieldset name="xml">
<field name="cat_priority" type="list" default="-1" label="XMAP_VM_CATEGORY_PRIORITY_LABEL" description="XMAP_VM_CATEGORY_PRIORITY_DESC">
<option value="-1">XMAP_OPTION_USE_PARENT_MENU</option>
<option value="0.0">0.0</option>
<option value="0.1">0.1</option>
<option value="0.2">0.2</option>
<option value="0.3">0.3</option>
<option value="0.4">0.4</option>
<option value="0.5">0.5</option>
<option value="0.6">0.6</option>
<option value="0.7">0.7</option>
<option value="0.8">0.8</option>
<option value="0.9">0.9</option>
<option value="1">1</option>
</field>
<field name="cat_changefreq" type="list" default="-1" label="XMAP_VM_CATEGORY_CHANGEFREQ_LABEL" description="XMAP_VM_CATEGORY_CHANGEFREQ_DESC">
<option value="-1">XMAP_OPTION_USE_PARENT_MENU</option>
<option value="always">XMAP_OPTION_ALWAYS</option>
<option value="hourly">XMAP_OPTION_HOURLY</option>
<option value="daily">XMAP_OPTION_DAILY</option>
<option value="weekly">XMAP_OPTION_WEEKLY</option>
<option value="monthly">XMAP_OPTION_MONTHLY</option>
<option value="yearly">XMAP_OPTION_YEARLY</option>
<option value="never">XMAP_OPTION_NEVER</option>
</field>
<field name="prod_priority" type="list" default="-1" label="XMAP_VM_PRODUCT_PRIORITY_LABEL" description="XMAP_VM_PRODUCT_PRIORITY_DESC">
<option value="-1">XMAP_OPTION_USE_PARENT_MENU</option>
<option value="0.0">0.0</option>
<option value="0.1">0.1</option>
<option value="0.2">0.2</option>
<option value="0.3">0.3</option>
<option value="0.4">0.4</option>
<option value="0.5">0.5</option>
<option value="0.6">0.6</option>
<option value="0.7">0.7</option>
<option value="0.8">0.8</option>
<option value="0.9">0.9</option>
<option value="1">1</option>
</field>
<field name="prod_changefreq" type="list" default="-1" label="XMAP_VM_PRODUCT_CHANGEFREQ_LABEL" description="XMAP_VM_PRODUCT_CHANGEFREQ_DESC">
<option value="-1">XMAP_OPTION_USE_PARENT_MENU</option>
<option value="always">XMAP_OPTION_ALWAYS</option>
<option value="hourly">XMAP_OPTION_HOURLY</option>
<option value="daily">XMAP_OPTION_DAILY</option>
<option value="weekly">XMAP_OPTION_WEEKLY</option>
<option value="monthly">XMAP_OPTION_MONTHLY</option>
<option value="yearly">XMAP_OPTION_YEARLY</option>
<option value="never">XMAP_OPTION_NEVER</option>
</field>
</fieldset>
</fields>
</config>
</extension>