| Current Path : /home/bonneesp/www/tmp/gmapfplinks/ |
| Current File : /home/bonneesp/www/tmp/gmapfplinks/place.php |
<?php
/**
* GMapFP Advanced Link for JCE 2.1 (jce_advlink_gmapfp_1.1)
* Based on "joomlalinks" found in JCE's core distribution. Modified by Fabrice4821
* to support GMapFP
* @author Fabrice4821
* @license GNU/GPL
* JCE/GMapFP Advanced Link is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
*/
defined('_WF_EXT') or die('RESTRICTED');
class GMapFPlinksPlace extends JObject
{
var $_option = 'com_gmapfp';
function getInstance()
{
static $instance;
if (!is_object($instance)) {
$instance = new JoomlalinksContact();
}
return $instance;
}
public function getOption()
{
return $this->_option;
}
public function getList()
{
//Reference to JConentEditor (JCE) instance
$wf = WFEditorPlugin::getInstance();
if ($wf->checkAccess('links.gmapfplinks.places', 1)) {
return '<li id="index.php?option=com_gmapfp"><div class="tree-row"><div class="tree-image"></div><span class="folder gmapfp nolink"><a href="javascript:;">'.WFText::_('WF_LINKS_GMAPFPLINKS_PLACES').'</a></span></div></li>';
}
}
function getLinks($args)
{
require_once(JPATH_SITE . '/components/com_gmapfp/helpers/route.php');
$items = array();
$layout = isset($args->layout) ? $args->layout : '';
switch ($layout) {
default:
$categories = WFLinkBrowser::getCategory('com_gmapfp');
foreach ($categories as $category) {
$itemid = WFLinkBrowser::getItemId('com_gmapfp', array('categories' => null, 'category' => $category->slug));
if (method_exists('ContentHelperRoute', 'getSectionRoute')) {
$id = GMapFPHelperRoute::getCategoryRoute($category->slug);
} else {
$id = 'index.php?option=com_gmapfp&view=gmapfp&layout=categorie&catid='. $category->slug . $itemid;
}
$items[] = array(
'id' => $id,
'name' => $category->title . ' / ' . $category->alias,
'class' => 'folder categories'
);
}
break;
case 'categorie':
$categories = WFLinkBrowser::getCategory('com_gmapfp', $args->catid);
foreach ($categories as $category) {
$children = WFLinkBrowser::getCategory('com_gmapfp', $category->id);
if ($children) {
if (method_exists('ContentHelperRoute', 'getSectionRoute')) {
$id = GMapFPHelperRoute::getCategoryRoute($category->id);
} else {
$id = 'index.php?option=com_gmapfp&view=gmapfp&layout=categorie&catid='. $category->id;
}
} else {
$itemid = WFLinkBrowser::getItemId('com_gmapfp', array('categorie' => null, 'category' => $category->slug));
if (method_exists('ContentHelperRoute', 'getSectionRoute')) {
$id = GMapFPHelperRoute::getCategoryRoute($category->slug);
} else {
$id = 'index.php?option=com_gmapfp&view=gmapfp&layout=categorie&catid='. $category->slug . $itemid;
}
}
$items[] = array(
'id' => $id,
'name' => $category->title . ' / ' . $category->alias,
'class' => 'folder categories'
);
}
$_lieux = self::_lieux($args->catid);
foreach ($_lieux as $lieu) {
$catid = $args->catid ? '&catid='. $args->catid : '';
$itemid = WFLinkBrowser::getItemId('com_gmapfp', array('categories' => null, 'category' => $catid));
if (method_exists('GMapFPHelperRoute', 'getArticleRoute')) {
$id = GMapFPHelperRoute::getArticleRoute($lieu->id, $catid);
} else {
if (method_exists('GMapFPHelperRoute', '_enfant'))
$id = 'index.php?option=com_gmapfp&view=gmapfp&layout=article&map_id='. $lieu->id . '-' .$lieu->alias . $itemid;
else
$id = 'index.php?option=com_gmapfp&view=gmapfp&layout=article&id='. $lieu->id . '-' .$lieu->alias . $itemid;
}
$items[] = array(
'id' => $id,
'name' => $lieu->nom . ' / ' . $lieu->alias,
'class' => 'file'
);
}
break;
}
return $items;
}
function _lieux($id)
{
$db = JFactory::getDBO();
$user = JFactory::getUser();
$where = '';
if (method_exists('JUser', 'getAuthorisedViewLevels')) {
$where .= ' AND access IN ('.implode(',', $user->getAuthorisedViewLevels()).')';
} else {
$where .= ' AND access <= '.(int) $user->get('aid');
}
$query = 'SELECT id, nom, alias'
. ' FROM #__gmapfp'
. ' WHERE catid = '.(int) $id
. ' AND published = 1'
. $where
. ' ORDER BY nom'
;
$db->setQuery($query);
return $db->loadObjectList();
}
}
?>