first commit
This commit is contained in:
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @copyright Copyright (c) 2009-2022 Ryan Demmer. All rights reserved
|
||||
* @license GNU/GPL 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* JCE 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('JPATH_PLATFORM') or die;
|
||||
|
||||
class JoomlalinksContact extends JObject
|
||||
{
|
||||
private $option = 'com_contact';
|
||||
|
||||
/**
|
||||
* Returns a reference to a editor object.
|
||||
*
|
||||
* This method must be invoked as:
|
||||
* <pre> $browser =JContentEditor::getInstance();</pre>
|
||||
*
|
||||
* @return JCE The editor object
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function getInstance($options = array())
|
||||
{
|
||||
static $instance;
|
||||
|
||||
if (!is_object($instance)) {
|
||||
$instance = new self($options);
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
public function getOption()
|
||||
{
|
||||
return $this->option;
|
||||
}
|
||||
|
||||
public function getList()
|
||||
{
|
||||
return '<li id="index.php?option=com_contact" class="folder contact nolink"><div class="uk-tree-row"><a href="#"><span class="uk-tree-icon"></span><span class="uk-tree-text">' . JText::_('WF_LINKS_JOOMLALINKS_CONTACTS') . '</span></a></div></li>';
|
||||
}
|
||||
|
||||
public function getLinks($args)
|
||||
{
|
||||
$items = array();
|
||||
$view = isset($args->view) ? $args->view : '';
|
||||
|
||||
$language = '';
|
||||
|
||||
// create a new RouteHelper instance
|
||||
$router = new JHelperRoute();
|
||||
|
||||
switch ($view) {
|
||||
default:
|
||||
$categories = WFLinkBrowser::getCategory('com_contact', 1, $this->get('category_alias', 1));
|
||||
|
||||
foreach ($categories as $category) {
|
||||
// language
|
||||
if (isset($category->language)) {
|
||||
$language = $category->language;
|
||||
}
|
||||
|
||||
$url = JHelperRoute::getCategoryRoute($category->id, $language, 'com_contact');
|
||||
|
||||
// convert to SEF
|
||||
$url = self::route($url);
|
||||
|
||||
$items[] = array(
|
||||
'id' => 'index.php?option=com_contact&view=category&id=' . $category->id,
|
||||
'url' => $url,
|
||||
'name' => $category->title . ' / ' . $category->alias,
|
||||
'class' => 'folder contact',
|
||||
);
|
||||
}
|
||||
break;
|
||||
case 'category':
|
||||
$categories = WFLinkBrowser::getCategory('com_contact', $args->id, $this->get('category_alias', 1));
|
||||
|
||||
foreach ($categories as $category) {
|
||||
$children = WFLinkBrowser::getCategory('com_contact', $category->id, $this->get('category_alias', 1));
|
||||
|
||||
// language
|
||||
if (isset($category->language)) {
|
||||
$language = $category->language;
|
||||
}
|
||||
|
||||
if ($children) {
|
||||
$id = JHelperRoute::getCategoryRoute($category->id, $language, 'com_contact');
|
||||
} else {
|
||||
$id = JHelperRoute::getCategoryRoute($category->slug, $language, 'com_contact');
|
||||
}
|
||||
|
||||
// convert to SEF
|
||||
$url = self::route($id);
|
||||
|
||||
$items[] = array(
|
||||
'url' => $url,
|
||||
'id' => $id,
|
||||
'name' => $category->title . ' / ' . $category->alias,
|
||||
'class' => 'folder content',
|
||||
);
|
||||
}
|
||||
|
||||
$contacts = self::getContacts($args->id);
|
||||
|
||||
foreach ($contacts as $contact) {
|
||||
// language
|
||||
if (isset($contact->language)) {
|
||||
$language = $contact->language;
|
||||
}
|
||||
|
||||
$id = $router->getRoute($contact->id, 'com_contact.contact', '', $language, $args->id);
|
||||
$id = self::route($id);
|
||||
|
||||
$items[] = array(
|
||||
'id' => $id,
|
||||
'name' => $contact->name . ' / ' . $contact->alias,
|
||||
'class' => 'file',
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
private static function route($url)
|
||||
{
|
||||
$wf = WFEditorPlugin::getInstance();
|
||||
|
||||
if ((bool) $wf->getParam('links.joomlalinks.sef_url', 0)) {
|
||||
$url = WFLinkHelper::route($url);
|
||||
}
|
||||
|
||||
// remove Itemid if "home"
|
||||
$url = WFLinkHelper::removeHomeItemId($url);
|
||||
|
||||
// remove Itemid
|
||||
if ((bool) $wf->getParam('links.joomlalinks.itemid', 1) === false) {
|
||||
$url = WFLinkHelper::removeItemId($url);
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
private static function getContacts($id)
|
||||
{
|
||||
$db = JFactory::getDBO();
|
||||
$user = JFactory::getUser();
|
||||
|
||||
$query = $db->getQuery(true);
|
||||
$query->select('id, name, alias, language')->from('#__contact_details')->where(array('catid=' . (int) $id, 'published = 1'));
|
||||
|
||||
if (!$user->authorise('core.admin')) {
|
||||
$query->where('access IN (' . implode(',', $user->getAuthorisedViewLevels()) . ')');
|
||||
}
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,318 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @copyright Copyright (c) 2009-2022 Ryan Demmer. All rights reserved
|
||||
* @license GNU/GPL 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* JCE 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('JPATH_PLATFORM') or die;
|
||||
|
||||
class JoomlalinksContent extends JObject
|
||||
{
|
||||
private $option = 'com_content';
|
||||
|
||||
/**
|
||||
* Returns a reference to a editor object.
|
||||
*
|
||||
* This method must be invoked as:
|
||||
* <pre> $browser =JContentEditor::getInstance();</pre>
|
||||
*
|
||||
* @return JCE The editor object
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function getInstance($options = array())
|
||||
{
|
||||
static $instance;
|
||||
|
||||
if (!is_object($instance)) {
|
||||
$instance = new self($options);
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
public function getOption()
|
||||
{
|
||||
return $this->option;
|
||||
}
|
||||
|
||||
public function getList()
|
||||
{
|
||||
return '<li id="index.php?option=com_content" class="folder content nolink"><div class="uk-tree-row"><a href="#"><span class="uk-tree-icon"></span><span class="uk-tree-text">' . JText::_('WF_LINKS_JOOMLALINKS_CONTENT') . '</span></a></div></li>';
|
||||
}
|
||||
|
||||
public function getLinks($args)
|
||||
{
|
||||
$items = array();
|
||||
$view = isset($args->view) ? $args->view : '';
|
||||
|
||||
$language = '';
|
||||
|
||||
// create a new RouteHelper instance
|
||||
$router = new JHelperRoute();
|
||||
|
||||
switch ($view) {
|
||||
// get top-level categories
|
||||
default:
|
||||
$articles = array();
|
||||
|
||||
if (!isset($args->id)) {
|
||||
$args->id = 1;
|
||||
}
|
||||
|
||||
$categories = WFLinkBrowser::getCategory('com_content', $args->id);
|
||||
|
||||
// get any articles in this category (in Joomla! 1.6+ a category can contain sub-categories and articles)
|
||||
$articles = self::getArticles($args->id);
|
||||
|
||||
foreach ($categories as $category) {
|
||||
$url = '';
|
||||
|
||||
if (isset($category->language)) {
|
||||
$language = $category->language;
|
||||
}
|
||||
|
||||
$id = JHelperRoute::getCategoryRoute($category->id, $language, 'com_content');
|
||||
|
||||
if (strpos($id, 'index.php?Itemid=') !== false) {
|
||||
$url = self::getMenuLink($id);
|
||||
$id = 'index.php?option=com_content&view=category&id=' . $category->id;
|
||||
}
|
||||
|
||||
$items[] = array(
|
||||
'url' => self::route($url),
|
||||
'id' => $id,
|
||||
'name' => $category->title . ' / ' . $category->alias,
|
||||
'class' => 'folder content',
|
||||
);
|
||||
}
|
||||
|
||||
if (!empty($articles)) {
|
||||
// output article links
|
||||
foreach ($articles as $article) {
|
||||
if (isset($article->language)) {
|
||||
$language = $article->language;
|
||||
}
|
||||
|
||||
$id = $router->getRoute($article->slug, 'com_content.article', '', $language, $article->catslug);
|
||||
$id = self::route($id);
|
||||
|
||||
$items[] = array(
|
||||
'id' => $id,
|
||||
'name' => $article->title . ' / ' . $article->alias,
|
||||
'class' => 'file',
|
||||
);
|
||||
|
||||
$anchors = self::getAnchors($article->content);
|
||||
|
||||
foreach ($anchors as $anchor) {
|
||||
$items[] = array(
|
||||
'id' => $id . '#' . $anchor,
|
||||
'name' => '#' . $anchor,
|
||||
'class' => 'file anchor',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
// get articles and / or sub-categories
|
||||
case 'category':
|
||||
// get any articles in this category (in Joomla! 1.6+ a category can contain sub-categories and articles)
|
||||
$articles = self::getArticles($args->id);
|
||||
|
||||
// get sub-categories
|
||||
$categories = WFLinkBrowser::getCategory('com_content', $args->id);
|
||||
|
||||
if (count($categories)) {
|
||||
foreach ($categories as $category) {
|
||||
// check for sub-categories
|
||||
$sub = WFLinkBrowser::getCategory('com_content', $category->id);
|
||||
|
||||
// language
|
||||
if (isset($category->language)) {
|
||||
$language = $category->language;
|
||||
}
|
||||
|
||||
$url = '';
|
||||
$id = JHelperRoute::getCategoryRoute($category->id, $language, 'com_content');
|
||||
|
||||
// get sub-categories
|
||||
if (count($sub)) {
|
||||
$url = $id;
|
||||
$id = 'index.php?option=com_content&view=section&id=' . $category->id;
|
||||
// no sub-categories, get articles for category
|
||||
} else {
|
||||
// no com_content, might be link like index.php?ItemId=1
|
||||
if (strpos($id, 'index.php?Itemid=') !== false) {
|
||||
$url = $id; //$id;
|
||||
$id = 'index.php?option=com_content&view=category&id=' . $category->id;
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos($url, 'index.php?Itemid=') !== false) {
|
||||
$url = self::getMenuLink($url);
|
||||
}
|
||||
|
||||
$items[] = array(
|
||||
'url' => self::route($url),
|
||||
'id' => $id,
|
||||
'name' => $category->title . ' / ' . $category->alias,
|
||||
'class' => 'folder content',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// output article links
|
||||
foreach ($articles as $article) {
|
||||
// language
|
||||
if (isset($article->language)) {
|
||||
$language = $article->language;
|
||||
}
|
||||
|
||||
$id = $router->getRoute($article->slug, 'com_content.article', '', $language, $article->catslug);
|
||||
$id = self::route($id);
|
||||
|
||||
$items[] = array(
|
||||
'id' => $id,
|
||||
'name' => $article->title . ' / ' . $article->alias,
|
||||
'class' => 'file' . ($article->state ? '' : ' unpublished uk-text-muted'),
|
||||
);
|
||||
|
||||
$anchors = self::getAnchors($article->content);
|
||||
|
||||
foreach ($anchors as $anchor) {
|
||||
$items[] = array(
|
||||
'id' => $id . '#' . $anchor,
|
||||
'name' => '#' . $anchor,
|
||||
'class' => 'file anchor',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
private static function getMenuLink($url)
|
||||
{
|
||||
$wf = WFEditorPlugin::getInstance();
|
||||
|
||||
// resolve the url from the menu link
|
||||
if ($wf->getParam('links.joomlalinks.article_resolve_alias', 1)) {
|
||||
// get itemid
|
||||
preg_match('#Itemid=([\d]+)#', $url, $matches);
|
||||
// get link from menu
|
||||
if (count($matches) > 1) {
|
||||
$menu = JTable::getInstance('menu');
|
||||
$menu->load($matches[1]);
|
||||
|
||||
if ($menu->link) {
|
||||
return $menu->link . '&Itemid=' . $menu->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
private function getArticles($id)
|
||||
{
|
||||
$db = JFactory::getDBO();
|
||||
$user = JFactory::getUser();
|
||||
|
||||
$wf = WFEditorPlugin::getInstance();
|
||||
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
$case = '';
|
||||
|
||||
if ($wf->getParam('links.joomlalinks.article_alias', 1)) {
|
||||
//sqlsrv changes
|
||||
$case_when1 = ' CASE WHEN ';
|
||||
$case_when1 .= $query->charLength('a.alias', '!=', '0');
|
||||
$case_when1 .= ' THEN ';
|
||||
$a_id = $query->castAsChar('a.id');
|
||||
$case_when1 .= $query->concatenate(array($a_id, 'a.alias'), ':');
|
||||
$case_when1 .= ' ELSE ';
|
||||
$case_when1 .= $a_id . ' END as slug';
|
||||
|
||||
$case_when2 = ' CASE WHEN ';
|
||||
$case_when2 .= $query->charLength('b.alias', '!=', '0');
|
||||
$case_when2 .= ' THEN ';
|
||||
$c_id = $query->castAsChar('b.id');
|
||||
$case_when2 .= $query->concatenate(array($c_id, 'b.alias'), ':');
|
||||
$case_when2 .= ' ELSE ';
|
||||
$case_when2 .= $c_id . ' END as catslug';
|
||||
|
||||
$case = ',' . $case_when1 . ',' . $case_when2;
|
||||
}
|
||||
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
|
||||
$query->select('a.id AS slug, b.id AS catslug, a.alias, a.state, a.title AS title, a.access, ' . $query->concatenate(array('a.introtext', 'a.fulltext')) . ' AS content, a.language' . $case);
|
||||
$query->from('#__content AS a');
|
||||
$query->innerJoin('#__categories AS b ON b.id = ' . (int) $id);
|
||||
|
||||
$query->where('a.catid = ' . (int) $id);
|
||||
|
||||
if ($wf->getParam('links.joomlalinks.article_unpublished', 0) == 1) {
|
||||
$query->where('(a.state = 0 OR a.state = 1)');
|
||||
} else {
|
||||
$query->where('a.state = 1');
|
||||
}
|
||||
|
||||
if (!$user->authorise('core.admin')) {
|
||||
$query->where('a.access IN (' . $groups . ')');
|
||||
$query->where('b.access IN (' . $groups . ')');
|
||||
}
|
||||
|
||||
$query->order('a.title');
|
||||
|
||||
$db->setQuery($query, 0);
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
|
||||
private static function getAnchors($content)
|
||||
{
|
||||
preg_match_all('#<a([^>]+)(name|id)="([a-z]+[\w\-\:\.]*)"([^>]*)>#i', $content, $matches, PREG_SET_ORDER);
|
||||
|
||||
$anchors = array();
|
||||
|
||||
if (!empty($matches)) {
|
||||
foreach ($matches as $match) {
|
||||
if (strpos($match[0], 'href') === false) {
|
||||
$anchors[] = $match[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $anchors;
|
||||
}
|
||||
|
||||
private static function route($url)
|
||||
{
|
||||
$wf = WFEditorPlugin::getInstance();
|
||||
|
||||
if ((bool) $wf->getParam('links.joomlalinks.sef_url', 0)) {
|
||||
$url = WFLinkHelper::route($url);
|
||||
}
|
||||
|
||||
// remove Itemid if "home"
|
||||
$url = WFLinkHelper::removeHomeItemId($url);
|
||||
|
||||
// remove Itemid if set
|
||||
if ((bool) $wf->getParam('links.joomlalinks.itemid', 1) === false) {
|
||||
$url = WFLinkHelper::removeItemId($url);
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@@ -0,0 +1 @@
|
||||
.unpublished .uk-icon::before{content:"\e99d"}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 5.2 KiB |
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
347
components/com_jce/editor/extensions/links/joomlalinks/menu.php
Normal file
347
components/com_jce/editor/extensions/links/joomlalinks/menu.php
Normal file
@@ -0,0 +1,347 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @copyright Copyright (c) 2009-2022 Ryan Demmer. All rights reserved
|
||||
* @license GNU/GPL 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* JCE 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('JPATH_PLATFORM') or die;
|
||||
|
||||
class JoomlalinksMenu extends JObject
|
||||
{
|
||||
private $option = 'com_menu';
|
||||
|
||||
/**
|
||||
* Returns a reference to a editor object.
|
||||
*
|
||||
* This method must be invoked as:
|
||||
* <pre> $browser =JContentEditor::getInstance();</pre>
|
||||
*
|
||||
* @return JCE The editor object
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function getInstance($options = array())
|
||||
{
|
||||
static $instance;
|
||||
|
||||
if (!is_object($instance)) {
|
||||
$instance = new self($options);
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
public function getOption()
|
||||
{
|
||||
return $this->option;
|
||||
}
|
||||
|
||||
public function getList()
|
||||
{
|
||||
return '<li id="index.php?option=com_menu" class="folder menu nolink"><div class="uk-tree-row"><a href="#"><span class="uk-tree-icon"></span><span class="uk-tree-text">' . JText::_('WF_LINKS_JOOMLALINKS_MENU') . '</span></a></div></li>';
|
||||
}
|
||||
|
||||
public function getLinks($args)
|
||||
{
|
||||
$items = array();
|
||||
$view = isset($args->view) ? $args->view : '';
|
||||
switch ($view) {
|
||||
// create top-level (non-linkable) menu types
|
||||
default:
|
||||
$types = self::getMenuTypes();
|
||||
foreach ($types as $type) {
|
||||
$items[] = array(
|
||||
'id' => 'index.php?option=com_menu&view=menu&type=' . $type->id,
|
||||
'name' => $type->title,
|
||||
'class' => 'folder menu nolink',
|
||||
);
|
||||
}
|
||||
break;
|
||||
// get menus and sub-menus
|
||||
case 'menu':
|
||||
$type = isset($args->type) ? $args->type : 0;
|
||||
$id = $type ? 0 : $args->id;
|
||||
|
||||
$menus = self::getMenu($id, $type);
|
||||
|
||||
foreach ($menus as $menu) {
|
||||
$class = array();
|
||||
|
||||
// bypass errors in menu parameters syntax
|
||||
try {
|
||||
$params = new JRegistry($menu->params);
|
||||
} catch (Exception $e) {
|
||||
$params = new JRegistry();
|
||||
}
|
||||
|
||||
switch ($menu->type) {
|
||||
case 'separator':
|
||||
if (!$menu->link) {
|
||||
$class[] = 'nolink';
|
||||
}
|
||||
|
||||
$link = '';
|
||||
break;
|
||||
|
||||
case 'alias':
|
||||
// If this is an alias use the item id stored in the parameters to make the link.
|
||||
$link = 'index.php?Itemid=' . $params->get('aliasoptions');
|
||||
break;
|
||||
|
||||
default:
|
||||
// resolve link
|
||||
$link = $this->resolveLink($menu);
|
||||
break;
|
||||
}
|
||||
|
||||
$children = (int) self::getChildren($menu->id);
|
||||
$title = isset($menu->name) ? $menu->name : $menu->title;
|
||||
|
||||
if ($children) {
|
||||
$class = array_merge($class, array('folder', 'menu'));
|
||||
} else {
|
||||
$class[] = 'file';
|
||||
}
|
||||
|
||||
if ($params->get('secure')) {
|
||||
$link = self::toSSL($link);
|
||||
}
|
||||
|
||||
// language
|
||||
if (isset($menu->language)) {
|
||||
$link .= $this->getLangauge($menu->language);
|
||||
}
|
||||
|
||||
$items[] = array(
|
||||
'id' => $children ? 'index.php?option=com_menu&view=menu&id=' . $menu->id : $link,
|
||||
'url' => self::route($link),
|
||||
'name' => $title . ' / ' . $menu->alias,
|
||||
'class' => implode(' ', $class),
|
||||
);
|
||||
}
|
||||
break;
|
||||
// get menu items
|
||||
case 'submenu':
|
||||
$menus = self::getMenu($args->id);
|
||||
foreach ($menus as $menu) {
|
||||
if ($menu->type == 'menulink') {
|
||||
//$menu = AdvlinkMenu::_alias($menu->id);
|
||||
}
|
||||
|
||||
$children = (int) self::getChildren($menu->id);
|
||||
|
||||
$title = isset($menu->name) ? $menu->name : $menu->title;
|
||||
|
||||
// get params
|
||||
$params = new JRegistry($menu->params);
|
||||
|
||||
// resolve link
|
||||
$link = $this->resolveLink($menu);
|
||||
|
||||
// language
|
||||
if (isset($menu->language)) {
|
||||
$link .= $this->getLangauge($menu->language);
|
||||
}
|
||||
|
||||
if ($params->get('secure')) {
|
||||
$link = self::toSSL($link);
|
||||
}
|
||||
|
||||
$items[] = array(
|
||||
'id' => self::route($link),
|
||||
'name' => $title . ' / ' . $menu->alias,
|
||||
'class' => $children ? 'folder menu' : 'file',
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert link to SSL.
|
||||
*
|
||||
* @param type $link
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function toSSL($link)
|
||||
{
|
||||
if (strcasecmp(substr($link, 0, 4), 'http') && (strpos($link, 'index.php?') !== false)) {
|
||||
$uri = JURI::getInstance();
|
||||
|
||||
// Get prefix
|
||||
$prefix = $uri->toString(array('host', 'port'));
|
||||
|
||||
// trim slashes
|
||||
$link = trim($link, '/');
|
||||
|
||||
// Build the URL.
|
||||
$link = 'https://' . $prefix . '/' . $link;
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
private function resolveLink($menu)
|
||||
{
|
||||
// get link from menu object
|
||||
$link = $menu->link;
|
||||
|
||||
// internal link
|
||||
if ($link && strpos($link, 'index.php') === 0) {
|
||||
if ((int) $this->get('menu_resolve_alias', 1)) {
|
||||
// no Itemid
|
||||
if (strpos($link, 'Itemid=') === false) {
|
||||
$link .= '&Itemid=' . $menu->id;
|
||||
}
|
||||
// short link
|
||||
} else {
|
||||
$link = 'index.php?Itemid=' . $menu->id;
|
||||
}
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
private static function getMenuTypes()
|
||||
{
|
||||
$db = JFactory::getDBO();
|
||||
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
$query->select('*')->from('#__menu_types')->where('client_id = 0')->order('title');
|
||||
|
||||
$db->setQuery($query, 0);
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
|
||||
private static function getAlias($id)
|
||||
{
|
||||
$db = JFactory::getDBO();
|
||||
$user = JFactory::getUser();
|
||||
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
$query->select('params')->from('#__menu')->where('id = ' . (int) $id);
|
||||
|
||||
$db->setQuery($query, 0);
|
||||
$params = new JRegistry($db->loadResult());
|
||||
|
||||
$query->clear();
|
||||
$query->select('id, name, link, alias')->from('#__menu')->where(array('published = 1', 'id = ' . (int) $params->get('menu_item')));
|
||||
|
||||
if (!$user->authorise('core.admin')) {
|
||||
$query->where('access IN (' . implode(',', $user->getAuthorisedViewLevels()) . ')');
|
||||
}
|
||||
|
||||
$query->order('name');
|
||||
|
||||
$db->setQuery($query, 0);
|
||||
|
||||
return $db->loadObject();
|
||||
}
|
||||
|
||||
private static function getChildren($id)
|
||||
{
|
||||
$db = JFactory::getDBO();
|
||||
$user = JFactory::getUser();
|
||||
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
$query->select('COUNT(id)')->from('#__menu')->where(array('published = 1', 'client_id = 0'));
|
||||
|
||||
if (!$user->authorise('core.admin')) {
|
||||
$query->where('access IN (' . implode(',', $user->getAuthorisedViewLevels()) . ')');
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$query->where('parent_id = ' . (int) $id);
|
||||
}
|
||||
|
||||
$db->setQuery($query, 0);
|
||||
|
||||
return $db->loadResult();
|
||||
}
|
||||
|
||||
private static function getMenu($parent = 0, $type = 0)
|
||||
{
|
||||
$db = JFactory::getDBO();
|
||||
$user = JFactory::getUser();
|
||||
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
$query->select('m.*')->from('#__menu AS m');
|
||||
|
||||
if ($type) {
|
||||
$query->innerJoin('#__menu_types AS s ON s.id = ' . (int) $type);
|
||||
$query->where('m.menutype = s.menutype');
|
||||
}
|
||||
|
||||
if ($parent == 0) {
|
||||
$parent = 1;
|
||||
}
|
||||
|
||||
$query->where(array('m.published = 1', 'm.parent_id = ' . (int) $parent));
|
||||
|
||||
if (!$user->authorise('core.admin')) {
|
||||
$query->where('m.access IN (' . implode(',', $user->getAuthorisedViewLevels()) . ')');
|
||||
}
|
||||
|
||||
// only site menu items
|
||||
$query->where('m.client_id = 0');
|
||||
|
||||
$query->order('m.lft ASC');
|
||||
|
||||
$db->setQuery($query, 0);
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
|
||||
private function getLangauge($language)
|
||||
{
|
||||
$db = JFactory::getDBO();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
$link = '';
|
||||
|
||||
$query->select('a.sef AS sef');
|
||||
$query->select('a.lang_code AS lang_code');
|
||||
$query->from('#__languages AS a');
|
||||
$db->setQuery($query);
|
||||
$langs = $db->loadObjectList();
|
||||
|
||||
foreach ($langs as $lang) {
|
||||
if ($language == $lang->lang_code) {
|
||||
$language = $lang->sef;
|
||||
$link .= '&lang=' . $language;
|
||||
}
|
||||
}
|
||||
return $link;
|
||||
}
|
||||
|
||||
private static function route($url)
|
||||
{
|
||||
$wf = WFEditorPlugin::getInstance();
|
||||
|
||||
if ((bool) $wf->getParam('links.joomlalinks.sef_url', 0)) {
|
||||
$url = WFLinkHelper::route($url);
|
||||
}
|
||||
|
||||
// remove Itemid if "home"
|
||||
$url = WFLinkHelper::removeHomeItemId($url);
|
||||
|
||||
// remove Itemid
|
||||
if ((bool) $wf->getParam('links.joomlalinks.itemid', 1) === false) {
|
||||
$url = WFLinkHelper::removeItemId($url);
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
150
components/com_jce/editor/extensions/links/joomlalinks/tags.php
Normal file
150
components/com_jce/editor/extensions/links/joomlalinks/tags.php
Normal file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @copyright Copyright (c) 2009-2022 Ryan Demmer. All rights reserved
|
||||
* @license GNU/GPL 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* JCE 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('JPATH_PLATFORM') or die;
|
||||
|
||||
class JoomlalinksTags extends JObject
|
||||
{
|
||||
private $option = 'com_tags';
|
||||
|
||||
/**
|
||||
* Returns a reference to a editor object.
|
||||
*
|
||||
* This method must be invoked as:
|
||||
* <pre> $browser =JContentEditor::getInstance();</pre>
|
||||
*
|
||||
* @return JCE The editor object
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function getInstance($options = array())
|
||||
{
|
||||
static $instance;
|
||||
|
||||
if (!is_object($instance)) {
|
||||
$instance = new self($options);
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
public function getOption()
|
||||
{
|
||||
return $this->option;
|
||||
}
|
||||
|
||||
public function getList()
|
||||
{
|
||||
return '<li id="index.php?option=com_tags" class="folder content nolink"><div class="uk-tree-row"><a href="#"><span class="uk-tree-icon"></span><span class="uk-tree-text">' . JText::_('WF_LINKS_JOOMLALINKS_TAGS') . '</span></a></div></li>';
|
||||
}
|
||||
|
||||
public function getLinks($args)
|
||||
{
|
||||
require_once JPATH_SITE . '/components/com_tags/helpers/route.php';
|
||||
|
||||
$items = array();
|
||||
$view = isset($args->view) ? $args->view : '';
|
||||
|
||||
$language = '';
|
||||
|
||||
// create a new RouteHelper instance
|
||||
$router = new JHelperRoute();
|
||||
|
||||
$tags = array();
|
||||
|
||||
if (!isset($args->id)) {
|
||||
$args->id = 1;
|
||||
}
|
||||
|
||||
// get any articles in this category (in Joomla! 1.6+ a category can contain sub-categories and articles)
|
||||
$tags = self::getTags($args->id);
|
||||
|
||||
if (!empty($tags)) {
|
||||
// output article links
|
||||
foreach ($tags as $tag) {
|
||||
if (isset($tag->language)) {
|
||||
$language = $tag->language;
|
||||
}
|
||||
|
||||
$id = $router->getRoute($tag->slug, 'com_tags.tag', '', $language);
|
||||
$id = $this->route($id);
|
||||
|
||||
$items[] = array(
|
||||
'id' => $id,
|
||||
'name' => $tag->title . ' / ' . $tag->alias,
|
||||
'class' => 'file',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
private static function getTags($id)
|
||||
{
|
||||
$db = JFactory::getDBO();
|
||||
$user = JFactory::getUser();
|
||||
|
||||
$wf = WFEditorPlugin::getInstance();
|
||||
|
||||
$query = $db->getQuery(true);
|
||||
$query->select('a.id, a.title, a.alias');
|
||||
|
||||
if ($wf->getParam('links.joomlalinks.tag_alias', 1)) {
|
||||
$case_when_item_alias = ' CASE WHEN ';
|
||||
$case_when_item_alias .= $query->charLength('a.alias', '!=', '0');
|
||||
$case_when_item_alias .= ' THEN ';
|
||||
$a_id = $query->castAsChar('a.id');
|
||||
$case_when_item_alias .= $query->concatenate(array($a_id, 'a.alias'), ':');
|
||||
$case_when_item_alias .= ' ELSE ';
|
||||
$case_when_item_alias .= $a_id . ' END as slug';
|
||||
$query->select($case_when_item_alias);
|
||||
}
|
||||
|
||||
$query->from('#__tags AS a');
|
||||
$query->where('a.alias <> ' . $db->quote('root'));
|
||||
$query->where($db->qn('a.published') . ' = 1');
|
||||
|
||||
if (!$user->authorise('core.admin')) {
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
$query->where('a.access IN (' . $groups . ')');
|
||||
}
|
||||
|
||||
if (JLanguageMultilang::isEnabled()) {
|
||||
$tag = JFactory::getLanguage()->getTag();
|
||||
$query->where('a.language in (' . $db->quote($tag) . ',' . $db->quote('*') . ')');
|
||||
}
|
||||
|
||||
$query->order('a.title');
|
||||
|
||||
$db->setQuery($query, 0);
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
|
||||
private static function route($url)
|
||||
{
|
||||
$wf = WFEditorPlugin::getInstance();
|
||||
|
||||
if ((bool) $wf->getParam('links.joomlalinks.sef_url', 0)) {
|
||||
$url = WFLinkHelper::route($url);
|
||||
}
|
||||
|
||||
// remove Itemid if "home"
|
||||
$url = WFLinkHelper::removeHomeItemId($url);
|
||||
|
||||
// remove Itemid
|
||||
if ((bool) $wf->getParam('links.joomlalinks.itemid', 1) === false) {
|
||||
$url = WFLinkHelper::removeItemId($url);
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,235 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @copyright Copyright (c) 2009-2022 Ryan Demmer. All rights reserved
|
||||
* @license GNU/GPL 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* JCE 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('JPATH_PLATFORM') or die;
|
||||
|
||||
class JoomlalinksWeblinks extends JObject
|
||||
{
|
||||
private $option = 'com_weblinks';
|
||||
|
||||
/**
|
||||
* Returns a reference to a editor object.
|
||||
*
|
||||
* This method must be invoked as:
|
||||
* <pre> $browser =JContentEditor::getInstance();</pre>
|
||||
*
|
||||
* @return JCE The editor object
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function getInstance($options = array())
|
||||
{
|
||||
static $instance;
|
||||
|
||||
if (!is_object($instance)) {
|
||||
$instance = new self($options);
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
public function getOption()
|
||||
{
|
||||
return $this->option;
|
||||
}
|
||||
|
||||
public function getList()
|
||||
{
|
||||
return '<li id="index.php?option=com_weblinks&view=categories" class="folder menu nolink"><div class="uk-tree-row"><a href="#"><span class="uk-tree-icon"></span><span class="uk-tree-text">' . JText::_('WF_LINKS_JOOMLALINKS_WEBLINKS') . '</span></a></div></li>';
|
||||
}
|
||||
|
||||
public function getLinks($args)
|
||||
{
|
||||
$wf = WFEditorPlugin::getInstance();
|
||||
$items = array();
|
||||
|
||||
if (!defined('JPATH_PLATFORM')) {
|
||||
require_once JPATH_SITE . '/includes/application.php';
|
||||
}
|
||||
|
||||
require_once JPATH_SITE . '/components/com_weblinks/helpers/route.php';
|
||||
|
||||
$language = '';
|
||||
|
||||
switch ($args->view) {
|
||||
// Get all WebLink categories
|
||||
default:
|
||||
case 'categories':
|
||||
$categories = WFLinkBrowser::getCategory('com_weblinks', 1, $wf->getParam('links.joomlalinks.category_alias', 1));
|
||||
|
||||
foreach ($categories as $category) {
|
||||
$url = '';
|
||||
|
||||
if (method_exists('WeblinksHelperRoute', 'getCategoryRoute')) {
|
||||
// language
|
||||
if (isset($category->language)) {
|
||||
$language = $category->language;
|
||||
}
|
||||
|
||||
$id = WeblinksHelperRoute::getCategoryRoute($category->id, $language);
|
||||
|
||||
if (strpos($id, 'index.php?Itemid=') !== false) {
|
||||
$url = $id;
|
||||
$id = 'index.php?option=com_weblinks&view=category&id=' . $category->id;
|
||||
}
|
||||
} else {
|
||||
$itemid = WFLinkBrowser::getItemId('com_weblinks', array('categories' => null, 'category' => $category->id));
|
||||
$id = 'index.php?option=com_weblinks&view=category&id=' . $category->id . $itemid;
|
||||
}
|
||||
|
||||
$items[] = array(
|
||||
'url' => self::route($url),
|
||||
'id' => $id,
|
||||
'name' => $category->title . ' / ' . $category->alias,
|
||||
'class' => 'folder weblink',
|
||||
);
|
||||
}
|
||||
break;
|
||||
// Get all links in the category
|
||||
case 'category':
|
||||
$categories = WFLinkBrowser::getCategory('com_weblinks', $args->id, $wf->getParam('links.joomlalinks.category_alias', 1));
|
||||
|
||||
if (count($categories)) {
|
||||
foreach ($categories as $category) {
|
||||
$children = WFLinkBrowser::getCategory('com_weblinks', $category->id, $wf->getParam('links.joomlalinks.category_alias', 1));
|
||||
|
||||
$url = '';
|
||||
|
||||
if ($children) {
|
||||
$id = 'index.php?option=com_weblinks&view=category&id=' . $category->id;
|
||||
} else {
|
||||
if (method_exists('WeblinksHelperRoute', 'getCategoryRoute')) {
|
||||
// language
|
||||
if (isset($category->language)) {
|
||||
$language = $category->language;
|
||||
}
|
||||
|
||||
$id = WeblinksHelperRoute::getCategoryRoute($category->id, $language);
|
||||
|
||||
if (strpos($id, 'index.php?Itemid=') !== false) {
|
||||
$url = $id;
|
||||
$id = 'index.php?option=com_weblinks&view=category&id=' . $category->id;
|
||||
}
|
||||
} else {
|
||||
$itemid = WFLinkBrowser::getItemId('com_weblinks', array('categories' => null, 'category' => $category->id));
|
||||
$id = 'index.php?option=com_weblinks&view=category&id=' . $category->id . $itemid;
|
||||
}
|
||||
}
|
||||
|
||||
$items[] = array(
|
||||
'url' => self::route($url),
|
||||
'id' => $id,
|
||||
'name' => $category->title . ' / ' . $category->alias,
|
||||
'class' => 'folder weblink',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$weblinks = self::getWeblinks($args->id);
|
||||
|
||||
foreach ($weblinks as $weblink) {
|
||||
// language
|
||||
if (isset($weblink->language)) {
|
||||
$language = $weblink->language;
|
||||
}
|
||||
|
||||
$id = WeblinksHelperRoute::getWeblinkRoute($weblink->slug, $weblink->catslug, $language);
|
||||
|
||||
if (defined('JPATH_PLATFORM')) {
|
||||
$id .= '&task=weblink.go';
|
||||
}
|
||||
|
||||
$items[] = array(
|
||||
'id' => self::route($id),
|
||||
'name' => $weblink->title . ' / ' . $weblink->alias,
|
||||
'class' => 'file',
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
public static function getWeblinks($id)
|
||||
{
|
||||
$wf = WFEditorPlugin::getInstance();
|
||||
|
||||
$db = JFactory::getDBO();
|
||||
$user = JFactory::getUser();
|
||||
|
||||
$dbquery = $db->getQuery(true);
|
||||
|
||||
$section = JText::_('Web Links');
|
||||
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
$case = '';
|
||||
|
||||
if ((int) $wf->getParam('links.joomlalinks.weblinks_alias', 1)) {
|
||||
//sqlsrv changes
|
||||
$case_when1 = ' CASE WHEN ';
|
||||
$case_when1 .= $dbquery->charLength('a.alias', '!=', '0');
|
||||
$case_when1 .= ' THEN ';
|
||||
$a_id = $dbquery->castAsChar('a.id');
|
||||
$case_when1 .= $dbquery->concatenate(array($a_id, 'a.alias'), ':');
|
||||
$case_when1 .= ' ELSE ';
|
||||
$case_when1 .= $a_id . ' END as slug';
|
||||
|
||||
$case_when2 = ' CASE WHEN ';
|
||||
$case_when2 .= $dbquery->charLength('b.alias', '!=', '0');
|
||||
$case_when2 .= ' THEN ';
|
||||
$c_id = $dbquery->castAsChar('b.id');
|
||||
$case_when2 .= $dbquery->concatenate(array($c_id, 'b.alias'), ':');
|
||||
$case_when2 .= ' ELSE ';
|
||||
$case_when2 .= $c_id . ' END as catslug';
|
||||
|
||||
$case .= ',' . $case_when1 . ',' . $case_when2;
|
||||
}
|
||||
|
||||
$query->select('a.id AS slug, b.id AS catslug, a.title AS title, a.description AS text, a.url, a.alias, a.language' . $case);
|
||||
|
||||
$query->from('#__weblinks AS a');
|
||||
$query->innerJoin('#__categories AS b ON b.id = ' . (int) $id);
|
||||
$query->where('a.catid = ' . (int) $id);
|
||||
|
||||
$query->where('a.state = 1');
|
||||
|
||||
if (!$user->authorise('core.admin')) {
|
||||
$query->where('b.access IN (' . implode(',', $user->getAuthorisedViewLevels()) . ')');
|
||||
}
|
||||
|
||||
$query->where('b.published = 1');
|
||||
$query->order('a.title');
|
||||
|
||||
$db->setQuery($query, 0);
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
|
||||
private static function route($url)
|
||||
{
|
||||
$wf = WFEditorPlugin::getInstance();
|
||||
|
||||
if ($wf->getParam('links.joomlalinks.sef_url', 0)) {
|
||||
$url = WFLinkHelper::route($url);
|
||||
}
|
||||
|
||||
// remove Itemid if "home"
|
||||
$url = WFLinkHelper::removeHomeItemId($url);
|
||||
|
||||
// remove Itemid
|
||||
if ((bool) $wf->getParam('links.joomlalinks.itemid', 1) === false) {
|
||||
$url = WFLinkHelper::removeItemId($url);
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user