first commit

This commit is contained in:
alazhar
2020-01-02 22:20:31 +07:00
commit 10eb3340ad
5753 changed files with 631345 additions and 0 deletions

View File

@ -0,0 +1,69 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_contact
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('ContactHelper', JPATH_ADMINISTRATOR . '/components/com_contact/helpers/contact.php');
JLoader::register('CategoryHelperAssociation', JPATH_ADMINISTRATOR . '/components/com_categories/helpers/association.php');
/**
* Contact Component Association Helper
*
* @package Joomla.Site
* @subpackage com_contact
* @since 3.0
*/
abstract class ContactHelperAssociation extends CategoryHelperAssociation
{
/**
* Method to get the associations for a given item
*
* @param integer $id Id of the item
* @param string $view Name of the view
*
* @return array Array of associations for the item
*
* @since 3.0
*/
public static function getAssociations($id = 0, $view = null)
{
jimport('helper.route', JPATH_COMPONENT_SITE);
$app = JFactory::getApplication();
$jinput = $app->input;
$view = is_null($view) ? $jinput->get('view') : $view;
$id = empty($id) ? $jinput->getInt('id') : $id;
if ($view == 'contact')
{
if ($id)
{
$associations = JLanguageAssociations::getAssociations('com_contact', '#__contact_details', 'com_contact.item', $id);
$return = array();
foreach ($associations as $tag => $item)
{
$return[$tag] = ContactHelperRoute::getContactRoute($item->id, $item->catid, $item->language);
}
return $return;
}
}
if ($view == 'category' || $view == 'categories')
{
return self::getCategoryAssociations($id, 'com_contact');
}
return array();
}
}

View File

@ -0,0 +1,28 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_contact
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Contact Component Category Tree
*
* @package Joomla.Site
* @subpackage com_contact
* @since 1.6
*/
class ContactCategories extends JCategories
{
public function __construct($options = array())
{
$options['table'] = '#__contact_details';
$options['extension'] = 'com_contact';
$options['statefield'] = 'published';
parent::__construct($options);
}
}

View File

@ -0,0 +1,85 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_contact
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Content Component HTML Helper
*
* @static
* @package Joomla.Site
* @subpackage com_content
* @since 1.5
*/
class JHtmlIcon
{
public static function email($contact, $params, $attribs = array())
{
require_once JPATH_SITE . '/components/com_mailto/helpers/mailto.php';
$uri = JUri::getInstance();
$base = $uri->toString(array('scheme', 'host', 'port'));
$link = $base . JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catid), false);
$url = 'index.php?option=com_mailto&tmpl=component&link='.MailToHelper::addLink($link);
$status = 'width=400,height=350,menubar=yes,resizable=yes';
if ($params->get('show_icons'))
{
$text = JHtml::_('image', 'system/emailButton.png', JText::_('JGLOBAL_EMAIL'), null, true);
}
else
{
$text = '&#160;'.JText::_('JGLOBAL_EMAIL');
}
$attribs['title'] = JText::_('JGLOBAL_EMAIL');
$attribs['onclick'] = "window.open(this.href,'win2','".$status."'); return false;";
$output = JHtml::_('link', JRoute::_($url), $text, $attribs);
return $output;
}
public static function print_popup($article, $params, $attribs = array())
{
$url = ContentHelperRoute::getContactRoute($contact->slug, $contact->catid);
$url .= '&tmpl=component&print=1&layout=default&page='.@ $request->limitstart;
$status = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no';
// checks template image directory for image, if non found default are loaded
if ($params->get('show_icons'))
{
$text = JHtml::_('image', 'system/printButton.png', JText::_('JGLOBAL_PRINT'), null, true);
}
else
{
$text = JText::_('JGLOBAL_ICON_SEP') .'&#160;'. JText::_('JGLOBAL_PRINT') .'&#160;'. JText::_('JGLOBAL_ICON_SEP');
}
$attribs['title'] = JText::_('JGLOBAL_PRINT');
$attribs['onclick'] = "window.open(this.href,'win2','".$status."'); return false;";
$attribs['rel'] = 'nofollow';
return JHtml::_('link', JRoute::_($url), $text, $attribs);
}
public static function print_screen($contact, $params, $attribs = array())
{
// checks template image directory for image, if non found default are loaded
if ($params->get('show_icons'))
{
$text = JHtml::_('image', 'system/printButton.png', JText::_('JGLOBAL_PRINT'), null, true);
}
else
{
$text = JText::_('JGLOBAL_ICON_SEP') .'&#160;'. JText::_('JGLOBAL_PRINT') .'&#160;'. JText::_('JGLOBAL_ICON_SEP');
}
return '<a href="#" onclick="window.print();return false;">'.$text.'</a>';
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,224 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_contact
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Contact Component Route Helper
*
* @static
* @package Joomla.Site
* @subpackage com_contact
* @since 1.5
*/
abstract class ContactHelperRoute
{
protected static $lookup;
/**
* @param integer The route of the contact
*/
public static function getContactRoute($id, $catid, $language = 0)
{
$needles = array(
'contact' => array((int) $id)
);
//Create the link
$link = 'index.php?option=com_contact&view=contact&id='. $id;
if ($catid > 1)
{
$categories = JCategories::getInstance('Contact');
$category = $categories->get($catid);
if ($category)
{
$needles['category'] = array_reverse($category->getPath());
$needles['categories'] = $needles['category'];
$link .= '&catid='.$catid;
}
}
if ($language && $language != "*" && JLanguageMultilang::isEnabled())
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('a.sef AS sef')
->select('a.lang_code AS lang_code')
->from('#__languages AS a');
$db->setQuery($query);
$langs = $db->loadObjectList();
foreach ($langs as $lang)
{
if ($language == $lang->lang_code)
{
$link .= '&lang='.$lang->sef;
$needles['language'] = $language;
}
}
}
if ($item = self::_findItem($needles))
{
$link .= '&Itemid='.$item;
}
elseif ($item = self::_findItem())
{
$link .= '&Itemid='.$item;
}
return $link;
}
public static function getCategoryRoute($catid, $language = 0)
{
if ($catid instanceof JCategoryNode)
{
$id = $catid->id;
$category = $catid;
}
else
{
$id = (int) $catid;
$category = JCategories::getInstance('Contact')->get($id);
}
if ($id < 1)
{
$link = '';
}
else
{
//Create the link
$link = 'index.php?option=com_contact&view=category&id='.$id;
$needles = array(
'category' => array($id)
);
if ($language && $language != "*" && JLanguageMultilang::isEnabled())
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('a.sef AS sef')
->select('a.lang_code AS lang_code')
->from('#__languages AS a');
$db->setQuery($query);
$langs = $db->loadObjectList();
foreach ($langs as $lang)
{
if ($language == $lang->lang_code)
{
$link .= '&lang='.$lang->sef;
$needles['language'] = $language;
}
}
}
if ($item = self::_findItem($needles))
{
$link .= '&Itemid='.$item;
}
else
{
if ($category)
{
$catids = array_reverse($category->getPath());
$needles = array(
'category' => $catids,
'categories' => $catids
);
if ($item = self::_findItem($needles))
{
$link .= '&Itemid='.$item;
}
elseif ($item = self::_findItem())
{
$link .= '&Itemid='.$item;
}
}
}
}
return $link;
}
protected static function _findItem($needles = null)
{
$app = JFactory::getApplication();
$menus = $app->getMenu('site');
$language = isset($needles['language']) ? $needles['language'] : '*';
// Prepare the reverse lookup array.
if (!isset(self::$lookup[$language]))
{
self::$lookup[$language] = array();
$component = JComponentHelper::getComponent('com_contact');
$attributes = array('component_id');
$values = array($component->id);
if ($language != '*')
{
$attributes[] = 'language';
$values[] = array($needles['language'], '*');
}
$items = $menus->getItems($attributes, $values);
foreach ($items as $item)
{
if (isset($item->query) && isset($item->query['view']))
{
$view = $item->query['view'];
if (!isset(self::$lookup[$language][$view]))
{
self::$lookup[$language][$view] = array();
}
if (isset($item->query['id']))
{
// here it will become a bit tricky
// language != * can override existing entries
// language == * cannot override existing entries
if (!isset(self::$lookup[$language][$view][$item->query['id']]) || $item->language != '*')
{
self::$lookup[$language][$view][$item->query['id']] = $item->id;
}
}
}
}
}
if ($needles)
{
foreach ($needles as $view => $ids)
{
if (isset(self::$lookup[$language][$view]))
{
foreach ($ids as $id)
{
if (isset(self::$lookup[$language][$view][(int) $id]))
{
return self::$lookup[$language][$view][(int) $id];
}
}
}
}
}
$active = $menus->getActive();
if ($active && ($active->language == '*' || !JLanguageMultilang::isEnabled()))
{
return $active->id;
}
// if not found, return language specific home link
$default = $menus->getDefault($language);
return !empty($default->id) ? $default->id : null;
}
}