| Current Path : /home/digilove/www/41423/ |
| Current File : /home/digilove/www/41423/com_sobipro.tar |
com_sobipro.php 0000644 00000024223 15235506046 0007601 0 ustar 00 <?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);
}
}
}
com_sobipro.xml 0000644 00000014147 15235506046 0007616 0 ustar 00 <?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>