AAAAPK ]y>\V search/categories/index.htmlnu W+A
PK ]y>\i search/categories/categories.phpnu W+A loadLanguage();
}
/**
* @return array An array of search areas
*/
function onContentSearchAreas()
{
static $areas = array(
'categories' => 'PLG_SEARCH_CATEGORIES_CATEGORIES'
);
return $areas;
}
/**
* Categories Search method
*
* The sql must return the following fields that are
* used in a common display routine: href, title, section, created, text,
* browsernav
* @param string Target search string
* @param string mathcing option, exact|any|all
* @param string ordering option, newest|oldest|popular|alpha|category
* @param mixed An array if restricted to areas, null if search all
*/
function onContentSearch($text, $phrase='', $ordering='', $areas=null)
{
$db = JFactory::getDbo();
$user = JFactory::getUser();
$app = JFactory::getApplication();
$groups = implode(',', $user->getAuthorisedViewLevels());
$searchText = $text;
if (is_array($areas)) {
if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) {
return array();
}
}
$sContent = $this->params->get('search_content', 1);
$sArchived = $this->params->get('search_archived', 1);
$limit = $this->params->def('search_limit', 50);
$state = array();
if ($sContent) {
$state[]=1;
}
if ($sArchived) {
$state[]=2;
}
$text = trim($text);
if ($text == '') {
return array();
}
switch($phrase) {
case 'exact':
$text = $db->Quote('%'.$db->escape($text, true).'%', false);
$wheres2 = array();
$wheres2[] = 'a.title LIKE '.$text;
$wheres2[] = 'a.description LIKE '.$text;
$where = '(' . implode(') OR (', $wheres2) . ')';
break;
case 'any':
case 'all';
default:
$words = explode(' ', $text);
$wheres = array();
foreach ($words as $word) {
$word = $db->Quote('%'.$db->escape($word, true).'%', false);
$wheres2 = array();
$wheres2[] = 'a.title LIKE '.$word;
$wheres2[] = 'a.description LIKE '.$word;
$wheres[] = implode(' OR ', $wheres2);
}
$where = '(' . implode(($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')';
break;
}
switch ($ordering) {
case 'alpha':
$order = 'a.title ASC';
break;
case 'category':
case 'popular':
case 'newest':
case 'oldest':
default:
$order = 'a.title DESC';
}
$text = $db->Quote('%'.$db->escape($text, true).'%', false);
$query = $db->getQuery(true);
$return = array();
if (!empty($state)) {
//sqlsrv changes
$case_when = ' CASE WHEN ';
$case_when .= $query->charLength('a.alias');
$case_when .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $a_id.' END as slug';
$query->select('a.title, a.description AS text, "" AS created, "2" AS browsernav, a.id AS catid, ' . $case_when);
$query->from('#__categories AS a');
$query->where('(a.title LIKE '. $text .' OR a.description LIKE '. $text .') AND a.published IN ('.implode(',', $state).') AND a.extension = \'com_content\''
.'AND a.access IN ('. $groups .')' );
$query->group('a.id');
$query->order($order);
if ($app->isSite() && $app->getLanguageFilter()) {
$query->where('a.language in (' . $db->Quote(JFactory::getLanguage()->getTag()) . ',' . $db->Quote('*') . ')');
}
$db->setQuery($query, 0, $limit);
$rows = $db->loadObjectList();
if ($rows) {
$count = count($rows);
for ($i = 0; $i < $count; $i++) {
$rows[$i]->href = ContentHelperRoute::getCategoryRoute($rows[$i]->slug);
$rows[$i]->section = JText::_('JCATEGORY');
}
foreach($rows as $key => $category) {
if (searchHelper::checkNoHTML($category, $searchText, array('name', 'title', 'text'))) {
$return[] = $category;
}
}
}
}
return $return;
}
}
PK ]y>\-J` ` search/categories/categories.xmlnu W+A
plg_search_categories
Joomla! Project
November 2005
Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved.
GNU General Public License version 2 or later; see LICENSE.txt
admin@joomla.org
www.joomla.org
2.5.0
PLG_SEARCH_CATEGORIES_XML_DESCRIPTION
categories.php
index.html
en-GB.plg_search_categories.ini
en-GB.plg_search_categories.sys.ini
PK ]y>\) search/categories/.htaccessnu W+A
Order allow,deny
Deny from all
PK ]y>\V search/contacts/index.htmlnu W+A
PK ]y>\) search/contacts/.htaccessnu W+A
Order allow,deny
Deny from all
PK ]y>\\k k search/contacts/contacts.phpnu W+A loadLanguage();
}
/**
* @return array An array of search areas
*/
function onContentSearchAreas()
{
static $areas = array(
'contacts' => 'PLG_SEARCH_CONTACTS_CONTACTS'
);
return $areas;
}
/**
* Contacts Search method
*
* The sql must return the following fields that are used in a common display
* routine: href, title, section, created, text, browsernav
* @param string Target search string
* @param string matching option, exact|any|all
* @param string ordering option, newest|oldest|popular|alpha|category
*/
function onContentSearch($text, $phrase='', $ordering='', $areas=null)
{
$db = JFactory::getDbo();
$app = JFactory::getApplication();
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
if (is_array($areas)) {
if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) {
return array();
}
}
$sContent = $this->params->get('search_content', 1);
$sArchived = $this->params->get('search_archived', 1);
$limit = $this->params->def('search_limit', 50);
$state = array();
if ($sContent) {
$state[]=1;
}
if ($sArchived) {
$state[]=2;
}
$text = trim($text);
if ($text == '') {
return array();
}
$section = JText::_('PLG_SEARCH_CONTACTS_CONTACTS');
switch ($ordering) {
case 'alpha':
$order = 'a.name ASC';
break;
case 'category':
$order = 'c.title ASC, a.name ASC';
break;
case 'popular':
case 'newest':
case 'oldest':
default:
$order = 'a.name DESC';
}
$text = $db->Quote('%'.$db->escape($text, true).'%', false);
$rows = array();
if (!empty($state)) {
$query = $db->getQuery(true);
//sqlsrv changes
$case_when = ' CASE WHEN ';
$case_when .= $query->charLength('a.alias');
$case_when .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $a_id.' END as slug';
$case_when1 = ' CASE WHEN ';
$case_when1 .= $query->charLength('c.alias');
$case_when1 .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when1 .= ' ELSE ';
$case_when1 .= $c_id.' END as catslug';
$query->select('a.name AS title, \'\' AS created, a.con_position, a.misc, '
.$case_when.','.$case_when1.', '
. $query->concatenate(array("a.name", "a.con_position", "a.misc"), ",").' AS text,'
. $query->concatenate(array($db->Quote($section), "c.title"), " / ").' AS section,'
. '\'2\' AS browsernav');
$query->from('#__contact_details AS a');
$query->innerJoin('#__categories AS c ON c.id = a.catid');
$query->where('(a.name LIKE '. $text .'OR a.misc LIKE '. $text .'OR a.con_position LIKE '. $text
.'OR a.address LIKE '. $text .'OR a.suburb LIKE '. $text .'OR a.state LIKE '. $text
.'OR a.country LIKE '. $text .'OR a.postcode LIKE '. $text .'OR a.telephone LIKE '. $text
.'OR a.fax LIKE '. $text .') AND a.published IN ('.implode(',', $state).') AND c.published=1 '
.'AND a.access IN ('. $groups. ') AND c.access IN ('. $groups. ')' );
$query->group('a.id, a.con_position, a.misc');
$query->order($order);
// Filter by language
if ($app->isSite() && $app->getLanguageFilter()) {
$tag = JFactory::getLanguage()->getTag();
$query->where('a.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')');
$query->where('c.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')');
}
$db->setQuery($query, 0, $limit);
$rows = $db->loadObjectList();
if ($rows) {
foreach($rows as $key => $row) {
$rows[$key]->href = 'index.php?option=com_contact&view=contact&id='.$row->slug.'&catid='.$row->catslug;
$rows[$key]->text = $row->title;
$rows[$key]->text .= ($row->con_position) ? ', '.$row->con_position : '';
$rows[$key]->text .= ($row->misc) ? ', '.$row->misc : '';
}
}
}
return $rows;
}
}
PK ]y>\ftS S search/contacts/contacts.xmlnu W+A
plg_search_contacts
Joomla! Project
November 2005
Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved.
GNU General Public License version 2 or later; see LICENSE.txt
admin@joomla.org
www.joomla.org
2.5.0
PLG_SEARCH_CONTACTS_XML_DESCRIPTION
contacts.php
index.html
en-GB.plg_search_contacts.ini
en-GB.plg_search_contacts.sys.ini
PK ]y>\) search/content/.htaccessnu W+A
Order allow,deny
Deny from all
PK ]y>\V search/content/index.htmlnu W+A
PK ]y>\iJ search/content/content.phpnu W+A 'JGLOBAL_ARTICLES'
);
return $areas;
}
/**
* Content Search method
* The sql must return the following fields that are used in a common display
* routine: href, title, section, created, text, browsernav
* @param string Target search string
* @param string mathcing option, exact|any|all
* @param string ordering option, newest|oldest|popular|alpha|category
* @param mixed An array if the search it to be restricted to areas, null if search all
*/
function onContentSearch($text, $phrase='', $ordering='', $areas=null)
{
$db = JFactory::getDbo();
$app = JFactory::getApplication();
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
$tag = JFactory::getLanguage()->getTag();
require_once JPATH_SITE . '/components/com_content/helpers/route.php';
require_once JPATH_ADMINISTRATOR . '/components/com_search/helpers/search.php';
$searchText = $text;
if (is_array($areas)) {
if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) {
return array();
}
}
$sContent = $this->params->get('search_content', 1);
$sArchived = $this->params->get('search_archived', 1);
$limit = $this->params->def('search_limit', 50);
$nullDate = $db->getNullDate();
$date = JFactory::getDate();
$now = $date->toSql();
$text = trim($text);
if ($text == '') {
return array();
}
$wheres = array();
switch ($phrase) {
case 'exact':
$text = $db->Quote('%'.$db->escape($text, true).'%', false);
$wheres2 = array();
$wheres2[] = 'a.title LIKE '.$text;
$wheres2[] = 'a.introtext LIKE '.$text;
$wheres2[] = 'a.fulltext LIKE '.$text;
$wheres2[] = 'a.metakey LIKE '.$text;
$wheres2[] = 'a.metadesc LIKE '.$text;
$where = '(' . implode(') OR (', $wheres2) . ')';
break;
case 'all':
case 'any':
default:
$words = explode(' ', $text);
$wheres = array();
foreach ($words as $word) {
$word = $db->Quote('%'.$db->escape($word, true).'%', false);
$wheres2 = array();
$wheres2[] = 'a.title LIKE '.$word;
$wheres2[] = 'a.introtext LIKE '.$word;
$wheres2[] = 'a.fulltext LIKE '.$word;
$wheres2[] = 'a.metakey LIKE '.$word;
$wheres2[] = 'a.metadesc LIKE '.$word;
$wheres[] = implode(' OR ', $wheres2);
}
$where = '(' . implode(($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')';
break;
}
$morder = '';
switch ($ordering) {
case 'oldest':
$order = 'a.created ASC';
break;
case 'popular':
$order = 'a.hits DESC';
break;
case 'alpha':
$order = 'a.title ASC';
break;
case 'category':
$order = 'c.title ASC, a.title ASC';
$morder = 'a.title ASC';
break;
case 'newest':
default:
$order = 'a.created DESC';
break;
}
$rows = array();
$query = $db->getQuery(true);
// search articles
if ($sContent && $limit > 0)
{
$query->clear();
//sqlsrv changes
$case_when = ' CASE WHEN ';
$case_when .= $query->charLength('a.alias');
$case_when .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $a_id.' END as slug';
$case_when1 = ' CASE WHEN ';
$case_when1 .= $query->charLength('c.alias');
$case_when1 .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when1 .= ' ELSE ';
$case_when1 .= $c_id.' END as catslug';
$query->select('a.title AS title, a.metadesc, a.metakey, a.created AS created, a.language');
$query->select($query->concatenate(array('a.introtext', 'a.fulltext')).' AS text');
$query->select('c.title AS section, '.$case_when.','.$case_when1.', '.'\'2\' AS browsernav');
$query->from('#__content AS a');
$query->innerJoin('#__categories AS c ON c.id=a.catid');
$query->where('('. $where .')' . 'AND a.state=1 AND c.published = 1 AND a.access IN ('.$groups.') '
.'AND c.access IN ('.$groups.') '
.'AND (a.publish_up = '.$db->Quote($nullDate).' OR a.publish_up <= '.$db->Quote($now).') '
.'AND (a.publish_down = '.$db->Quote($nullDate).' OR a.publish_down >= '.$db->Quote($now).')' );
$query->group('a.id, a.title, a.metadesc, a.metakey, a.created, a.introtext, a.fulltext, c.title, a.alias, c.alias, c.id');
$query->order($order);
// Filter by language
if ($app->isSite() && $app->getLanguageFilter()) {
$query->where('a.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')');
$query->where('c.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')');
}
$db->setQuery($query, 0, $limit);
$list = $db->loadObjectList();
$limit -= count($list);
if (isset($list))
{
foreach($list as $key => $item)
{
$list[$key]->href = ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->language);
}
}
$rows[] = $list;
}
// search archived content
if ($sArchived && $limit > 0)
{
$searchArchived = JText::_('JARCHIVED');
$query->clear();
//sqlsrv changes
$case_when = ' CASE WHEN ';
$case_when .= $query->charLength('a.alias');
$case_when .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $a_id.' END as slug';
$case_when1 = ' CASE WHEN ';
$case_when1 .= $query->charLength('c.alias');
$case_when1 .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when1 .= ' ELSE ';
$case_when1 .= $c_id.' END as catslug';
$query->select('a.title AS title, a.metadesc, a.metakey, a.created AS created, '
.$query->concatenate(array("a.introtext", "a.fulltext")).' AS text,'
.$case_when.','.$case_when1.', '
.'c.title AS section, \'2\' AS browsernav');
//.'CONCAT_WS("/", c.title) AS section, \'2\' AS browsernav' );
$query->from('#__content AS a');
$query->innerJoin('#__categories AS c ON c.id=a.catid AND c.access IN ('. $groups .')');
$query->where('('. $where .') AND a.state = 2 AND c.published = 1 AND a.access IN ('. $groups
.') AND c.access IN ('. $groups .') '
.'AND (a.publish_up = '.$db->Quote($nullDate).' OR a.publish_up <= '.$db->Quote($now).') '
.'AND (a.publish_down = '.$db->Quote($nullDate).' OR a.publish_down >= '.$db->Quote($now).')' );
$query->order($order);
// Filter by language
if ($app->isSite() && $app->getLanguageFilter()) {
$query->where('a.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')');
$query->where('c.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')');
}
$db->setQuery($query, 0, $limit);
$list3 = $db->loadObjectList();
// find an itemid for archived to use if there isn't another one
$item = $app->getMenu()->getItems('link', 'index.php?option=com_content&view=archive', true);
$itemid = isset($item->id) ? '&Itemid='.$item->id : '';
if (isset($list3))
{
foreach($list3 as $key => $item)
{
$date = JFactory::getDate($item->created);
$created_month = $date->format("n");
$created_year = $date->format("Y");
$list3[$key]->href = JRoute::_('index.php?option=com_content&view=archive&year='.$created_year.'&month='.$created_month.$itemid);
}
}
$rows[] = $list3;
}
$results = array();
if (count($rows))
{
foreach($rows as $row)
{
$new_row = array();
foreach($row as $key => $article) {
if (searchHelper::checkNoHTML($article, $searchText, array('text', 'title', 'metadesc', 'metakey'))) {
$new_row[] = $article;
}
}
$results = array_merge($results, (array) $new_row);
}
}
return $results;
}
}
PK ]y>\C]! search/content/content.xmlnu W+A
plg_search_content
Joomla! Project
November 2005
Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved.
GNU General Public License version 2 or later; see LICENSE.txt
admin@joomla.org
www.joomla.org
2.5.0
PLG_SEARCH_CONTENT_XML_DESCRIPTION
content.php
index.html
en-GB.plg_search_content.ini
en-GB.plg_search_content.sys.ini
PK ]y>\V search/index.htmlnu W+A
PK ]y>\V search/weblinks/index.htmlnu W+A
PK ]y>\_ search/weblinks/weblinks.phpnu W+A loadLanguage();
}
/**
* @return array An array of search areas
*/
function onContentSearchAreas() {
static $areas = array(
'weblinks' => 'PLG_SEARCH_WEBLINKS_WEBLINKS'
);
return $areas;
}
/**
* Weblink Search method
*
* The sql must return the following fields that are used in a common display
* routine: href, title, section, created, text, browsernav
* @param string Target search string
* @param string mathcing option, exact|any|all
* @param string ordering option, newest|oldest|popular|alpha|category
* @param mixed An array if the search it to be restricted to areas, null if search all
*/
function onContentSearch($text, $phrase='', $ordering='', $areas=null)
{
$db = JFactory::getDbo();
$app = JFactory::getApplication();
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
$searchText = $text;
if (is_array($areas)) {
if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) {
return array();
}
}
$sContent = $this->params->get('search_content', 1);
$sArchived = $this->params->get('search_archived', 1);
$limit = $this->params->def('search_limit', 50);
$state = array();
if ($sContent) {
$state[]=1;
}
if ($sArchived) {
$state[]=2;
}
$text = trim($text);
if ($text == '') {
return array();
}
$section = JText::_('PLG_SEARCH_WEBLINKS');
$wheres = array();
switch ($phrase)
{
case 'exact':
$text = $db->Quote('%'.$db->escape($text, true).'%', false);
$wheres2 = array();
$wheres2[] = 'a.url LIKE '.$text;
$wheres2[] = 'a.description LIKE '.$text;
$wheres2[] = 'a.title LIKE '.$text;
$where = '(' . implode(') OR (', $wheres2) . ')';
break;
case 'all':
case 'any':
default:
$words = explode(' ', $text);
$wheres = array();
foreach ($words as $word)
{
$word = $db->Quote('%'.$db->escape($word, true).'%', false);
$wheres2 = array();
$wheres2[] = 'a.url LIKE '.$word;
$wheres2[] = 'a.description LIKE '.$word;
$wheres2[] = 'a.title LIKE '.$word;
$wheres[] = implode(' OR ', $wheres2);
}
$where = '(' . implode(($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')';
break;
}
switch ($ordering)
{
case 'oldest':
$order = 'a.created ASC';
break;
case 'popular':
$order = 'a.hits DESC';
break;
case 'alpha':
$order = 'a.title ASC';
break;
case 'category':
$order = 'c.title ASC, a.title ASC';
break;
case 'newest':
default:
$order = 'a.created DESC';
}
$return = array();
if (!empty($state)) {
$query = $db->getQuery(true);
//sqlsrv changes
$case_when = ' CASE WHEN ';
$case_when .= $query->charLength('a.alias');
$case_when .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $a_id.' END as slug';
$case_when1 = ' CASE WHEN ';
$case_when1 .= $query->charLength('c.alias');
$case_when1 .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when1 .= ' ELSE ';
$case_when1 .= $c_id.' END as catslug';
$query->select('a.title AS title, a.description AS text, a.created AS created, a.url, '
.$case_when.','.$case_when1.', '
.$query->concatenate(array($db->Quote($section), "c.title"), " / ").' AS section, \'1\' AS browsernav');
$query->from('#__weblinks AS a');
$query->innerJoin('#__categories AS c ON c.id = a.catid');
$query->where('('.$where.')' . ' AND a.state in ('.implode(',', $state).') AND c.published=1 AND c.access IN ('.$groups.')');
$query->order($order);
// Filter by language
if ($app->isSite() && $app->getLanguageFilter()) {
$tag = JFactory::getLanguage()->getTag();
$query->where('a.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')');
$query->where('c.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')');
}
$db->setQuery($query, 0, $limit);
$rows = $db->loadObjectList();
$return = array();
if ($rows) {
foreach($rows as $key => $row) {
$rows[$key]->href = WeblinksHelperRoute::getWeblinkRoute($row->slug, $row->catslug);
}
foreach($rows as $key => $weblink) {
if (searchHelper::checkNoHTML($weblink, $searchText, array('url', 'text', 'title'))) {
$return[] = $weblink;
}
}
}
}
return $return;
}
}
PK ]y>\OS S search/weblinks/weblinks.xmlnu W+A
plg_search_weblinks
Joomla! Project
November 2005
Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved.
GNU General Public License version 2 or later; see LICENSE.txt
admin@joomla.org
www.joomla.org
2.5.0
PLG_SEARCH_WEBLINKS_XML_DESCRIPTION
weblinks.php
index.html
en-GB.plg_search_weblinks.ini
en-GB.plg_search_weblinks.sys.ini
PK ]y>\) search/weblinks/.htaccessnu W+A
Order allow,deny
Deny from all
PK ]y>\V search/newsfeeds/index.htmlnu W+A
PK ]y>\Na[ [ search/newsfeeds/newsfeeds.xmlnu W+A
plg_search_newsfeeds
Joomla! Project
November 2005
Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved.
GNU General Public License version 2 or later; see LICENSE.txt
admin@joomla.org
www.joomla.org
2.5.0
PLG_SEARCH_NEWSFEEDS_XML_DESCRIPTION
newsfeeds.php
index.html
en-GB.plg_search_newsfeeds.ini
en-GB.plg_search_newsfeeds.sys.ini
PK ]y>\o search/newsfeeds/newsfeeds.phpnu W+A loadLanguage();
}
/**
* @return array An array of search areas
*/
function onContentSearchAreas()
{
static $areas = array(
'newsfeeds' => 'PLG_SEARCH_NEWSFEEDS_NEWSFEEDS'
);
return $areas;
}
/**
* Newsfeeds Search method
*
* The sql must return the following fields that are used in a common display
* routine: href, title, section, created, text, browsernav
* @param string Target search string
* @param string mathcing option, exact|any|all
* @param string ordering option, newest|oldest|popular|alpha|category
* @param mixed An array if the search it to be restricted to areas, null if search all
*/
function onContentSearch($text, $phrase='', $ordering='', $areas=null)
{
$db = JFactory::getDbo();
$app = JFactory::getApplication();
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
if (is_array($areas)) {
if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) {
return array();
}
}
$sContent = $this->params->get('search_content', 1);
$sArchived = $this->params->get('search_archived', 1);
$limit = $this->params->def('search_limit', 50);
$state = array();
if ($sContent) {
$state[]=1;
}
if ($sArchived) {
$state[]=2;
}
$text = trim($text);
if ($text == '') {
return array();
}
switch ($phrase) {
case 'exact':
$text = $db->Quote('%'.$db->escape($text, true).'%', false);
$wheres2 = array();
$wheres2[] = 'a.name LIKE '.$text;
$wheres2[] = 'a.link LIKE '.$text;
$where = '(' . implode(') OR (', $wheres2) . ')';
break;
case 'all':
case 'any':
default:
$words = explode(' ', $text);
$wheres = array();
foreach ($words as $word)
{
$word = $db->Quote('%'.$db->escape($word, true).'%', false);
$wheres2 = array();
$wheres2[] = 'a.name LIKE '.$word;
$wheres2[] = 'a.link LIKE '.$word;
$wheres[] = implode(' OR ', $wheres2);
}
$where = '(' . implode(($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')';
break;
}
switch ($ordering) {
case 'alpha':
$order = 'a.name ASC';
break;
case 'category':
$order = 'c.title ASC, a.name ASC';
break;
case 'oldest':
case 'popular':
case 'newest':
default:
$order = 'a.name ASC';
}
$searchNewsfeeds = JText::_('PLG_SEARCH_NEWSFEEDS_NEWSFEEDS');
$rows = array();
if (!empty($state)) {
$query = $db->getQuery(true);
//sqlsrv changes
$case_when = ' CASE WHEN ';
$case_when .= $query->charLength('a.alias');
$case_when .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $a_id.' END as slug';
$case_when1 = ' CASE WHEN ';
$case_when1 .= $query->charLength('c.alias');
$case_when1 .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when1 .= ' ELSE ';
$case_when1 .= $c_id.' END as catslug';
$query->select('a.name AS title, "" AS created, a.link AS text, ' . $case_when."," . $case_when1);
$query->select($query->concatenate(array($db->Quote($searchNewsfeeds), 'c.title'), " / ").' AS section');
$query->select('"1" AS browsernav');
$query->from('#__newsfeeds AS a');
$query->innerJoin('#__categories as c ON c.id = a.catid');
$query->where('('. $where .')' . 'AND a.published IN ('.implode(',', $state).') AND c.published = 1 AND c.access IN ('. $groups .')');
$query->order($order);
// Filter by language
if ($app->isSite() && $app->getLanguageFilter()) {
$tag = JFactory::getLanguage()->getTag();
$query->where('a.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')');
$query->where('c.language in (' . $db->Quote($tag) . ',' . $db->Quote('*') . ')');
}
$db->setQuery($query, 0, $limit);
$rows = $db->loadObjectList();
if ($rows) {
foreach($rows as $key => $row) {
$rows[$key]->href = 'index.php?option=com_newsfeeds&view=newsfeed&catid='.$row->catslug.'&id='.$row->slug;
}
}
}
return $rows;
}
}
PK ]y>\) search/newsfeeds/.htaccessnu W+A
Order allow,deny
Deny from all
PK ]y>\) search/.htaccessnu W+A
Order allow,deny
Deny from all
PK ]y>\J( ( search/virtuemart/virtuemart.phpnu W+A registerEvent ('onSearch', 'plgSearchVirtuemart');
$app->registerEvent ('onSearchAreas', 'plgSearchVirtuemartAreas');
} else {
/**
* @return array An array of search areas
*/
class plgSearchVirtuemart extends JPlugin {
function onContentSearchAreas () {
$this->loadLanguage ();
static $areas = array(
'virtuemart' => 'PLG_SEARCH_VIRTUEMART_PRODUCTS'
);
return $areas;
}
function getTableSQLFields () {
return array();
}
/**
* virtuemart Products Search method
*
* The sql must return the following fields that are used in a common display
* routine: href, title, section, created, text, browsernav
*
* @param string Target search string
* @param string mathcing option, exact|any|all
* @param string ordering option, newest|oldest|popular|alpha|category
*/
function onContentSearch ($text, $phrase = '', $ordering = '', $areas = NULL) {
$db = JFactory::getDbo ();
$app = JFactory::getApplication ();
$user = JFactory::getUser ();
$groups = implode (',', $user->getAuthorisedViewLevels ());
$tag = JFactory::getLanguage ()->getTag ();
$searchText = $text;
if (is_array ($areas)) {
if (!array_intersect ($areas, array_keys ($this->onContentSearchAreas ()))) {
return array();
}
}
// load plugin params info
// $plugin = & JPluginHelper::getPlugin('search', 'virtuemart');
// $pluginParams = new JParameter($plugin->params);
// $limit = $pluginParams->def('search_limit', 50);
$limit = $this->params->def ('search_limit', 50);
if (!class_exists ('VmConfig')) {
require(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php');
}
VmConfig::loadConfig ();
/* TO do it work with date
$nullDate = $db->getNullDate();
$date = JFactory::getDate();
$now = $date->toMySQL();
*/
$text = trim ($text);
if ($text == '') {
return array();
}
$section = JText::_ ('Products');
$wheres = array();
switch ($phrase) {
case 'exact':
$text = $db->Quote ('%' . $db->getEscaped ($text, TRUE) . '%', FALSE);
$wheres2 = array();
$wheres2[] = 'p.product_sku LIKE ' . $text;
$wheres2[] = 'a.product_name LIKE ' . $text;
$wheres2[] = 'a.product_s_desc LIKE ' . $text;
$wheres2[] = 'a.product_desc LIKE ' . $text;
$wheres2[] = 'b.category_name LIKE ' . $text;
$where = '(' . implode (') OR (', $wheres2) . ')';
break;
case 'all':
case 'any':
default:
$words = explode (' ', $text);
$wheres = array();
foreach ($words as $word) {
$word = $db->Quote ('%' . $db->getEscaped ($word, TRUE) . '%', FALSE);
$wheres2 = array();
$wheres2[] = 'p.product_sku LIKE ' . $word;
$wheres2[] = 'a.product_name LIKE ' . $word;
$wheres2[] = 'a.product_s_desc LIKE ' . $word;
$wheres2[] = 'a.product_desc LIKE ' . $word;
$wheres2[] = 'b.category_name LIKE ' . $word;
$wheres[] = implode (' OR ', $wheres2);
}
$where = '(' . implode (($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')';
break;
}
switch ($ordering) {
case 'alpha':
$order = 'a.product_name ASC';
break;
case 'category':
$order = 'b.category_name ASC, a.product_name ASC';
break;
case 'popular':
$order = 'a.product_name ASC';
break;
case 'newest':
$order = 'p.created_on DESC';
break;
case 'oldest':
$order = 'p.created_on ASC';
break;
default:
$order = 'a.product_name DESC';
}
$where_shopper_group="";
$usermodel = VmModel::getModel ('user');
$currentVMuser = $usermodel->getUser ();
$virtuemart_shoppergroup_ids = (array)$currentVMuser->shopper_groups;
if (is_array ($virtuemart_shoppergroup_ids)) {
$sgrgroups = array();
foreach ($virtuemart_shoppergroup_ids as $virtuemart_shoppergroup_id) {
$sgrgroups[] = 'psgr.`virtuemart_shoppergroup_id`= "' . (int)$virtuemart_shoppergroup_id . '" ';
}
$sgrgroups[] = 'psgr.`virtuemart_shoppergroup_id` IS NULL ';
$where_shopper_group = "AND ( " . implode (' OR ', $sgrgroups) . " ) ";
}
// search product //TODO b.virtuemart_category_id>0 should be configurable
$text = $db->Quote ('%' . $db->getEscaped ($text, TRUE) . '%', FALSE);
$query = "SELECT DISTINCT CONCAT( a.product_name,' (',p.product_sku,')' ) AS title, a.virtuemart_product_id , b.virtuemart_category_id , a.product_s_desc AS text, b.category_name as section,
p.created_on as created, '2' AS browsernav
FROM `#__virtuemart_products_" . VMLANG . "` AS a
JOIN #__virtuemart_products as p using (`virtuemart_product_id`)
LEFT JOIN `#__virtuemart_product_categories` AS xref ON xref.`virtuemart_product_id` = a.`virtuemart_product_id`
LEFT JOIN `#__virtuemart_categories_" . VMLANG . "` AS b ON b.`virtuemart_category_id` = xref.`virtuemart_category_id`
LEFT JOIN `#__virtuemart_product_shoppergroups` as `psgr` on (`psgr`.`virtuemart_product_id`=`a`.`virtuemart_product_id`) "
. ' WHERE ' . $where . ' and p.published=1 ' .$where_shopper_group
. (VmConfig::get ('show_uncat_child_products') ? '' : ' and b.virtuemart_category_id>0 ')
. ' ORDER BY ' . $order;
$db->setQuery ($query, 0, $limit);
$rows = $db->loadObjectList ();
if ($rows) {
foreach ($rows as $key => $row) {
$rows[$key]->href = 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $row->virtuemart_product_id . '&virtuemart_category_id=' . $row->virtuemart_category_id;
// $rows[$key]->text = $text;
}
}
return $rows;
}
}
}
/**
* @return array An array of search areas
*/
function &plgSearchVirtuemartAreas () {
$this->loadLanguage ();
static $areas = array(
'virtuemart' => 'PLG_SEARCH_VIRTUEMART_PRODUCTS'
);
return $areas;
}
/**
* virtuemart Products Search method
*
* The sql must return the following fields that are used in a common display
* routine: href, title, section, created, text, browsernav
*
* @param string Target search string
* @param string mathcing option, exact|any|all
* @param string ordering option, newest|oldest|popular|alpha|category
*/
function plgSearchVirtuemart ($text, $phrase = '', $ordering = '', $areas = NULL) {
$db = JFactory::getDBO ();
$user = JFactory::getUser ();
if (is_array ($areas)) {
if (!array_intersect ($areas, array_keys (plgSearchVirtuemartAreas ()))) {
return array();
}
}
// load plugin params info
$plugin = & JPluginHelper::getPlugin ('search', 'virtuemart');
$pluginParams = new JParameter($plugin->params);
if (!class_exists ('VmConfig')) {
require(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php');
}
VmConfig::loadConfig ();
$limit = $pluginParams->def ('search_limit', 50);
$text = trim ($text);
if ($text == '') {
return array();
}
$section = JText::_ ('Products');
$wheres = array();
switch ($phrase) {
case 'exact':
$text = $db->Quote ('%' . $db->getEscaped ($text, TRUE) . '%', FALSE);
$wheres2 = array();
$wheres2[] = 'p.product_sku LIKE ' . $text;
$wheres2[] = 'a.product_name LIKE ' . $text;
$wheres2[] = 'a.product_s_desc LIKE ' . $text;
$wheres2[] = 'a.product_desc LIKE ' . $text;
$wheres2[] = 'b.category_name LIKE ' . $text;
$where = '(' . implode (') OR (', $wheres2) . ')';
break;
case 'all':
case 'any':
default:
$words = explode (' ', $text);
$wheres = array();
foreach ($words as $word) {
$word = $db->Quote ('%' . $db->getEscaped ($word, TRUE) . '%', FALSE);
$wheres2 = array();
$wheres2[] = 'p.product_sku LIKE ' . $word;
$wheres2[] = 'a.product_name LIKE ' . $word;
$wheres2[] = 'a.product_s_desc LIKE ' . $word;
$wheres2[] = 'a.product_desc LIKE ' . $word;
$wheres2[] = 'b.category_name LIKE ' . $word;
$wheres[] = implode (' OR ', $wheres2);
}
$where = '(' . implode (($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')';
break;
}
switch ($ordering) {
case 'alpha':
$order = 'a.product_name ASC';
break;
case 'category':
$order = 'b.category_name ASC, a.product_name ASC';
break;
case 'popular':
$order = 'a.product_name ASC';
break;
case 'newest':
$order = 'p.created_on DESC';
break;
case 'oldest':
$order = 'p.created_on ASC';
break;
default:
$order = 'a.product_name DESC';
}
$text = $db->Quote ('%' . $db->getEscaped ($text, TRUE) . '%', FALSE);
$query = "SELECT DISTINCT CONCAT( a.product_name,' (',p.product_sku,')' ) AS title, a.virtuemart_product_id , b.virtuemart_category_id , a.product_s_desc AS text, b.category_name as section,
p.created_on as created, '2' AS browsernav
FROM `#__virtuemart_products_" . VMLANG . "` AS a
JOIN `#__virtuemart_products` as p using (`virtuemart_product_id`)
LEFT JOIN `#__virtuemart_product_categories` AS xref ON xref.virtuemart_product_id = a.virtuemart_product_id
LEFT JOIN `#__virtuemart_categories_" . VMLANG . "` AS b ON b.virtuemart_category_id = xref.virtuemart_category_id"
. ' WHERE ' . $where . ' and p.published=1 and b.virtuemart_category_id>0 '
. ' ORDER BY ' . $order;
$db->setQuery ($query, 0, $limit);
$rows = $db->loadObjectList ();
if ($rows) {
foreach ($rows as $key => $row) {
$rows[$key]->href = 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $row->virtuemart_product_id . '&virtuemart_category_id=' . $row->virtuemart_category_id;
// $rows[$key]->text = $text;
}
}
return $rows;
}
PK ]y>\x(b b search/virtuemart/virtuemart.xmlnu W+A
plg_search_virtuemart
January 09 2013
The VirtueMart Development Team
http://www.virtuemart.net
Copyright (C) 2004-2014 Virtuemart Team. All rights reserved.
http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
2.0.18a
Allows Searching of VirtueMart Component
en-GB.plg_search_virtuemart.ini
fr-FR.plg_search_virtuemart.ini
virtuemart.php
index.html
PK ]y>\) search/virtuemart/.htaccessnu W+A
Order allow,deny
Deny from all
PK ]y>\V search/virtuemart/index.htmlnu W+A
PK ]y>\V quickicon/index.htmlnu W+A
PK ]y>\V quickicon/eosnotify/index.htmlnu W+A
PK ]y>\) quickicon/eosnotify/.htaccessnu W+A
Order allow,deny
Deny from all
PK ]y>\; ! quickicon/eosnotify/eosnotify.xmlnu W+A
PLG_EOSNOTIFY
Joomla! Project
October 2014
Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved.
http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
admin@joomla.org
www.joomla.org
2.5.0
End of Support Notifier
eosnotify.php
index.html
PK ]y>\8 8 ! quickicon/eosnotify/eosnotify.phpnu W+A loadLanguage();
}
/**
* This method is called when the Quick Icons module is constructing its set
* of icons. You can return an array which defines a single icon and it will
* be rendered right after the stock Quick Icons.
*
* @param $context The calling context
*
* @return array A list of icon definition associative arrays, consisting of the
* keys link, image, text and access.
*
* @since 2.5.28
*/
public function onGetIcons($context)
{
if (!JFactory::getApplication()->isAdmin() || version_compare(JVERSION, '3.0', '>='))
{
return;
}
$text = JText::_('PLG_EOSNOTIFY_SUPPORT_ENDING');
if (JFactory::getDate() >= '2015-01-01')
{
$text = JText::_('PLG_EOSNOTIFY_SUPPORT_ENDED');
}
if (JAdministratorHelper::findOption() == 'com_cpanel')
{
JFactory::getApplication()->enqueueMessage(JText::sprintf('PLG_EOSNOTIFY_CLICK_FOR_INFORMATION_WITH_LINK', $text), 'error');
}
}
}
PK ]y>\) quickicon/.htaccessnu W+A
Order allow,deny
Deny from all
PK ]y>\-{ { ' quickicon/joomlaupdate/joomlaupdate.xmlnu W+A
plg_quickicon_joomlaupdate
Joomla! Project
August 2011
Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved.
http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
admin@joomla.org
www.joomla.org
2.5.0
PLG_QUICKICON_JOOMLAUPDATE_XML_DESCRIPTION
joomlaupdate.php
index.html
en-GB.plg_quickicon_joomlaupdate.ini
en-GB.plg_quickicon_joomlaupdate.sys.ini
PK ]y>\ve6
' quickicon/joomlaupdate/joomlaupdate.phpnu W+A loadLanguage();
}
/**
* This method is called when the Quick Icons module is constructing its set
* of icons. You can return an array which defines a single icon and it will
* be rendered right after the stock Quick Icons.
*
* @param $context The calling context
*
* @return array A list of icon definition associative arrays, consisting of the
* keys link, image, text and access.
*
* @since 2.5
*/
public function onGetIcons($context)
{
if ($context != $this->params->get('context', 'mod_quickicon') || !JFactory::getUser()->authorise('core.manage', 'com_installer')) {
return;
}
$cur_template = JFactory::getApplication()->getTemplate();
$ajax_url = JURI::base().'index.php?option=com_installer&view=update&task=update.ajax';
$script = "var plg_quickicon_joomlaupdate_ajax_url = '$ajax_url';\n";
$script .= 'var plg_quickicon_jupdatecheck_jversion = "'.JVERSION.'";'."\n";
$script .= 'var plg_quickicon_joomlaupdate_text = {"UPTODATE" : "'.
JText::_('PLG_QUICKICON_JOOMLAUPDATE_UPTODATE', true).'", "UPDATEFOUND": "'.
JText::_('PLG_QUICKICON_JOOMLAUPDATE_UPDATEFOUND', true).'", "ERROR": "'.
JText::_('PLG_QUICKICON_JOOMLAUPDATE_ERROR', true)."\"};\n";
$script .= 'var plg_quickicon_joomlaupdate_img = {"UPTODATE" : "'.
JURI::base(true) .'/templates/'. $cur_template .'/images/header/icon-48-jupdate-uptodate.png'.'", "ERROR": "'.
JURI::base(true) .'/templates/'. $cur_template .'/images/header/icon-48-deny.png'.'", "UPDATEFOUND": "'.
JURI::base(true) .'/templates/'. $cur_template .'/images/header/icon-48-jupdate-updatefound.png'."\"};\n";
$document = JFactory::getDocument();
$document->addScriptDeclaration($script);
$document->addScript(JURI::base().'../media/plg_quickicon_joomlaupdate/jupdatecheck.js');
return array(array(
'link' => 'index.php?option=com_joomlaupdate',
'image' => 'header/icon-48-download.png',
'text' => JText::_('PLG_QUICKICON_JOOMLAUPDATE_CHECKING'),
'id' => 'plg_quickicon_joomlaupdate'
));
}
}
PK ]y>\V ! quickicon/joomlaupdate/index.htmlnu W+A
PK ]y>\) quickicon/joomlaupdate/.htaccessnu W+A
Order allow,deny
Deny from all
PK ]y>\ }t - quickicon/extensionupdate/extensionupdate.phpnu W+A loadLanguage();
}
/**
* Returns an icon definition for an icon which looks for extensions updates
* via AJAX and displays a notification when such updates are found.
*
* @param $context The calling context
*
* @return array A list of icon definition associative arrays, consisting of the
* keys link, image, text and access.
*
* @since 2.5
*/
public function onGetIcons($context)
{
if ($context != $this->params->get('context', 'mod_quickicon') || !JFactory::getUser()->authorise('core.manage', 'com_installer')) {
return;
}
$cur_template = JFactory::getApplication()->getTemplate();
$ajax_url = JURI::base().'index.php?option=com_installer&view=update&task=update.ajax';
$script = "var plg_quickicon_extensionupdate_ajax_url = '$ajax_url';\n";
$script .= 'var plg_quickicon_extensionupdate_text = {"UPTODATE" : "'.
JText::_('PLG_QUICKICON_EXTENSIONUPDATE_UPTODATE', true).'", "UPDATEFOUND": "'.
JText::_('PLG_QUICKICON_EXTENSIONUPDATE_UPDATEFOUND', true).'", "ERROR": "'.
JText::_('PLG_QUICKICON_EXTENSIONUPDATE_ERROR', true)."\"};\n";
$document = JFactory::getDocument();
$document->addScriptDeclaration($script);
$document->addScript(JURI::base().'../media/plg_quickicon_extensionupdate/extensionupdatecheck.js');
return array(array(
'link' => 'index.php?option=com_installer&view=update',
'image' => 'header/icon-48-extension.png',
'text' => JText::_('PLG_QUICKICON_EXTENSIONUPDATE_CHECKING'),
'id' => 'plg_quickicon_extensionupdate'
));
}
}
PK ]y>\) # quickicon/extensionupdate/.htaccessnu W+A
Order allow,deny
Deny from all
PK ]y>\Ʊ0 - quickicon/extensionupdate/extensionupdate.xmlnu W+A
plg_quickicon_extensionupdate
Joomla! Project
August 2011
Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved.
http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
admin@joomla.org
www.joomla.org
2.5.0
PLG_QUICKICON_EXTENSIONUPDATE_XML_DESCRIPTION
extensionupdate.php
index.html
en-GB.plg_quickicon_extensionupdate.ini
en-GB.plg_quickicon_extensionupdate.sys.ini
PK ]y>\V $ quickicon/extensionupdate/index.htmlnu W+A
PK ]y>\) vmshipment/.htaccessnu W+A
Order allow,deny
Deny from all
PK ]y>\) % vmshipment/weight_countries/.htaccessnu W+A
Order allow,deny
Deny from all
PK ]y>\bF F 0 vmshipment/weight_countries/weight_countries.phpnu W+A _loggable = TRUE;
$this->_tablepkey = 'id';
$this->_tableId = 'id';
$this->tableFields = array_keys ($this->getTableSQLFields ());
$varsToPush = $this->getVarsToPush ();
$this->setConfigParameterable ($this->_configTableFieldName, $varsToPush);
}
/**
* Create the table for this plugin if it does not yet exist.
*
* @author Valérie Isaksen
*/
public function getVmPluginCreateTableSQL () {
return $this->createTableSQL ('Shipment Weight Countries Table');
}
/**
* @return array
*/
function getTableSQLFields () {
$SQLfields = array(
'id' => 'int(1) UNSIGNED NOT NULL AUTO_INCREMENT',
'virtuemart_order_id' => 'int(11) UNSIGNED',
'order_number' => 'char(32)',
'virtuemart_shipmentmethod_id' => 'mediumint(1) UNSIGNED',
'shipment_name' => 'varchar(5000)',
'order_weight' => 'decimal(10,4)',
'shipment_weight_unit' => 'char(3) DEFAULT \'KG\'',
'shipment_cost' => 'decimal(10,2)',
'shipment_package_fee' => 'decimal(10,2)',
'tax_id' => 'smallint(1)'
);
return $SQLfields;
}
/**
* This method is fired when showing the order details in the frontend.
* It displays the shipment-specific data.
*
* @param integer $virtuemart_order_id The order ID
* @param integer $virtuemart_shipmentmethod_id The selected shipment method id
* @param string $shipment_name Shipment Name
* @return mixed Null for shipments that aren't active, text (HTML) otherwise
* @author Valérie Isaksen
* @author Max Milbers
*/
public function plgVmOnShowOrderFEShipment ($virtuemart_order_id, $virtuemart_shipmentmethod_id, &$shipment_name) {
$this->onShowOrderFE ($virtuemart_order_id, $virtuemart_shipmentmethod_id, $shipment_name);
}
/**
* This event is fired after the order has been stored; it gets the shipment method-
* specific data.
*
* @param int $order_id The order_id being processed
* @param object $cart the cart
* @param array $order The actual order saved in the DB
* @return mixed Null when this method was not selected, otherwise true
* @author Valerie Isaksen
*/
function plgVmConfirmedOrder (VirtueMartCart $cart, $order) {
if (!($method = $this->getVmPluginMethod ($order['details']['BT']->virtuemart_shipmentmethod_id))) {
return NULL; // Another method was selected, do nothing
}
if (!$this->selectedThisElement ($method->shipment_element)) {
return FALSE;
}
$values['virtuemart_order_id'] = $order['details']['BT']->virtuemart_order_id;
$values['order_number'] = $order['details']['BT']->order_number;
$values['virtuemart_shipmentmethod_id'] = $order['details']['BT']->virtuemart_shipmentmethod_id;
$values['shipment_name'] = $this->renderPluginName ($method);
$values['order_weight'] = $this->getOrderWeight ($cart, $method->weight_unit);
$values['shipment_weight_unit'] = $method->weight_unit;
$values['shipment_cost'] = $method->cost;
$values['shipment_package_fee'] = $method->package_fee;
$values['tax_id'] = $method->tax_id;
$this->storePSPluginInternalData ($values);
return TRUE;
}
/**
* This method is fired when showing the order details in the backend.
* It displays the shipment-specific data.
* NOTE, this plugin should NOT be used to display form fields, since it's called outside
* a form! Use plgVmOnUpdateOrderBE() instead!
*
* @param integer $virtuemart_order_id The order ID
* @param integer $virtuemart_shipmentmethod_id The order shipment method ID
* @param object $_shipInfo Object with the properties 'shipment' and 'name'
* @return mixed Null for shipments that aren't active, text (HTML) otherwise
* @author Valerie Isaksen
*/
public function plgVmOnShowOrderBEShipment ($virtuemart_order_id, $virtuemart_shipmentmethod_id) {
if (!($this->selectedThisByMethodId ($virtuemart_shipmentmethod_id))) {
return NULL;
}
$html = $this->getOrderShipmentHtml ($virtuemart_order_id);
return $html;
}
/**
* @param $virtuemart_order_id
* @return string
*/
function getOrderShipmentHtml ($virtuemart_order_id) {
$db = JFactory::getDBO ();
$q = 'SELECT * FROM `' . $this->_tablename . '` '
. 'WHERE `virtuemart_order_id` = ' . $virtuemart_order_id;
$db->setQuery ($q);
if (!($shipinfo = $db->loadObject ())) {
vmWarn (500, $q . " " . $db->getErrorMsg ());
return '';
}
if (!class_exists ('CurrencyDisplay')) {
require(JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php');
}
$currency = CurrencyDisplay::getInstance ();
$tax = ShopFunctions::getTaxByID ($shipinfo->tax_id);
$taxDisplay = is_array ($tax) ? $tax['calc_value'] . ' ' . $tax['calc_value_mathop'] : $shipinfo->tax_id;
$taxDisplay = ($taxDisplay == -1) ? JText::_ ('COM_VIRTUEMART_PRODUCT_TAX_NONE') : $taxDisplay;
$html = '' . "\n";
$html .= $this->getHtmlHeaderBE ();
$html .= $this->getHtmlRowBE ('WEIGHT_COUNTRIES_SHIPPING_NAME', $shipinfo->shipment_name);
$html .= $this->getHtmlRowBE ('WEIGHT_COUNTRIES_WEIGHT', $shipinfo->order_weight . ' ' . ShopFunctions::renderWeightUnit ($shipinfo->shipment_weight_unit));
$html .= $this->getHtmlRowBE ('WEIGHT_COUNTRIES_COST', $currency->priceDisplay ($shipinfo->shipment_cost));
$html .= $this->getHtmlRowBE ('WEIGHT_COUNTRIES_PACKAGE_FEE', $currency->priceDisplay ($shipinfo->shipment_package_fee));
$html .= $this->getHtmlRowBE ('WEIGHT_COUNTRIES_TAX', $taxDisplay);
$html .= '
' . "\n";
return $html;
}
/**
* @param VirtueMartCart $cart
* @param $method
* @param $cart_prices
* @return int
*/
function getCosts (VirtueMartCart $cart, $method, $cart_prices) {
if ($method->free_shipment && $cart_prices['salesPrice'] >= $method->free_shipment) {
return 0;
} else {
return $method->cost + $method->package_fee;
}
}
/**
* @param \VirtueMartCart $cart
* @param int $method
* @param array $cart_prices
* @return bool
*/
protected function checkConditions ($cart, $method, $cart_prices) {
$this->convert ($method);
//vmTrace('checkConditions');
$orderWeight = $this->getOrderWeight ($cart, $method->weight_unit);
$address = (($cart->ST == 0) ? $cart->BT : $cart->ST);
$type = (($cart->ST == 0) ? 'BT' : 'ST');
$countries = array();
if (!empty($method->countries)) {
if (!is_array ($method->countries)) {
$countries[0] = $method->countries;
} else {
$countries = $method->countries;
}
}
// probably did not gave his BT:ST address
if (!is_array ($address)) {
// there are some address dependant conditions, redirect then
/*
if ($method->zip_start or $method->zip_stop or empty($countries)) {
$mainframe = JFactory::getApplication ();
$redirectMsg = JText::_ ('VMSHIPMENT_WEIGHT_COUNTRIES_ADDRESS_FIRST');
//vmWarn($redirectMsg);
$mainframe->redirect (JRoute::_ ('index.php?option=com_virtuemart&view=user&task=editaddresscheckout&addrtype=BT'), $redirectMsg);
}
*/
vmdebug('checkConditions $address is not an array, set zip and country id = 0');
$address = array();
$address['zip'] = 0;
$address['virtuemart_country_id'] = 0;
}
$weight_cond = $this->testRange($orderWeight,$method,'weight_start','weight_stop','weight');
$nbproducts_cond = $this->_nbproductsCond ($cart, $method);
if(isset($cart_prices['salesPrice'])){
$orderamount_cond = $this->testRange($cart_prices['salesPrice'],$method,'orderamount_start','orderamount_stop','order amount');
} else {
$orderamount_cond = FALSE;
}
$userFieldsModel =VmModel::getModel('Userfields');
if ($userFieldsModel->fieldPublished('zip', $type)){
if (!isset($address['zip'])) {
$address['zip'] = '';
}
$zip_cond = $this->testRange($address['zip'],$method,'zip_start','zip_stop','zip');
} else {
$zip_cond = true;
}
if ($userFieldsModel->fieldPublished('virtuemart_country_id', $type)){
if (!isset($address['virtuemart_country_id'])) {
$address['virtuemart_country_id'] = 0;
}
if (in_array ($address['virtuemart_country_id'], $countries) || count ($countries) == 0) {
//vmdebug('checkConditions '.$method->shipment_name.' fit ',$weight_cond,(int)$zip_cond,$nbproducts_cond,$orderamount_cond);
vmdebug('shipmentmethod '.$method->shipment_name.' = TRUE for variable virtuemart_country_id = '.$address['virtuemart_country_id'].', Reason: Countries in rule '.implode($countries,', ').' or none set');
$country_cond = true;
}
else{
vmdebug('shipmentmethod '.$method->shipment_name.' = FALSE for variable virtuemart_country_id = '.$address['virtuemart_country_id'].', Reason: Country '.implode($countries,', ').' does not fit');
$country_cond = false;
}
} else {
vmdebug('shipmentmethod '.$method->shipment_name.' = TRUE for variable virtuemart_country_id, Reason: no boundary conditions set');
$country_cond = true;
}
$allconditions = (int) $weight_cond + (int)$zip_cond + (int)$nbproducts_cond + (int)$orderamount_cond + (int)$country_cond;
if($allconditions === 5){
return TRUE;
} else {
vmdebug('checkConditions '.$method->name.' does not fit',(int)$nbproducts_cond,(int)$zip_cond);
return FALSE;
}
return FALSE;
}
/**
* @param $method
*/
function convert (&$method) {
//$method->weight_start = (float) $method->weight_start;
//$method->weight_stop = (float) $method->weight_stop;
$method->orderamount_start = (float)str_replace(',','.',$method->orderamount_start);
$method->orderamount_stop = (float)str_replace(',','.',$method->orderamount_stop);
$method->zip_start = (int)$method->zip_start;
$method->zip_stop = (int)$method->zip_stop;
$method->nbproducts_start = (int)$method->nbproducts_start;
$method->nbproducts_stop = (int)$method->nbproducts_stop;
$method->free_shipment = (float)str_replace(',','.',$method->free_shipment);
}
/**
* @param $cart
* @param $method
* @return bool
*/
private function _nbproductsCond ($cart, $method) {
if (empty($method->nbproducts_start) and empty($method->nbproducts_stop)) {
//vmdebug('_nbproductsCond',$method);
return true;
}
$nbproducts = 0;
foreach ($cart->products as $product) {
$nbproducts += $product->quantity;
}
if ($nbproducts) {
$nbproducts_cond = $this->testRange($nbproducts,$method,'nbproducts_start','nbproducts_stop','products quantity');
} else {
$nbproducts_cond = false;
}
return $nbproducts_cond;
}
private function testRange($value, $method, $floor, $ceiling,$name){
$cond = true;
if(!empty($method->$floor) and !empty($method->$ceiling)){
$cond = (($value >= $method->$floor AND $value <= $method->$ceiling));
if(!$cond){
$result = 'FALSE';
$reason = 'is NOT within Range of the condition from '.$method->$floor.' to '.$method->$ceiling;
} else {
$result = 'TRUE';
$reason = 'is within Range of the condition from '.$method->$floor.' to '.$method->$ceiling;
}
} else if(!empty($method->$floor)){
$cond = ($value >= $method->$floor);
if(!$cond){
$result = 'FALSE';
$reason = 'is not at least '.$method->$floor;
} else {
$result = 'TRUE';
$reason = 'is over min limit '.$method->$floor;
}
} else if(!empty($method->$ceiling)){
$cond = ($value <= $method->$ceiling);
if(!$cond){
$result = 'FALSE';
$reason = 'is over '.$method->$ceiling;
} else {
$result = 'TRUE';
$reason = 'is lower than the set '.$method->$ceiling;
}
} else {
$result = 'TRUE';
$reason = 'no boundary conditions set';
}
vmdebug('shipmentmethod '.$method->shipment_name.' = '.$result.' for variable '.$name.' = '.$value.' Reason: '.$reason);
return $cond;
}
/**
* Create the table for this plugin if it does not yet exist.
* This functions checks if the called plugin is active one.
* When yes it is calling the standard method to create the tables
*
* @author Valérie Isaksen
*
*/
function plgVmOnStoreInstallShipmentPluginTable ($jplugin_id) {
return $this->onStoreInstallPluginTable ($jplugin_id);
}
/**
* @param VirtueMartCart $cart
* @return null
*/
public function plgVmOnSelectCheckShipment (VirtueMartCart &$cart) {
return $this->OnSelectCheck ($cart);
}
/**
* plgVmDisplayListFE
* This event is fired to display the pluginmethods in the cart (edit shipment/payment) for example
*
* @param object $cart Cart object
* @param integer $selected ID of the method selected
* @return boolean True on success, false on failures, null when this plugin was not selected.
* On errors, JError::raiseWarning (or JError::raiseError) must be used to set a message.
*
* @author Valerie Isaksen
* @author Max Milbers
*/
public function plgVmDisplayListFEShipment (VirtueMartCart $cart, $selected = 0, &$htmlIn) {
return $this->displayListFE ($cart, $selected, $htmlIn);
}
/**
* @param VirtueMartCart $cart
* @param array $cart_prices
* @param $cart_prices_name
* @return bool|null
*/
public function plgVmOnSelectedCalculatePriceShipment (VirtueMartCart $cart, array &$cart_prices, &$cart_prices_name) {
return $this->onSelectedCalculatePrice ($cart, $cart_prices, $cart_prices_name);
}
/**
* plgVmOnCheckAutomaticSelected
* Checks how many plugins are available. If only one, the user will not have the choice. Enter edit_xxx page
* The plugin must check first if it is the correct type
*
* @author Valerie Isaksen
* @param VirtueMartCart cart: the cart object
* @return null if no plugin was found, 0 if more then one plugin was found, virtuemart_xxx_id if only one plugin is found
*
*/
function plgVmOnCheckAutomaticSelectedShipment (VirtueMartCart $cart, array $cart_prices, &$shipCounter) {
if ($shipCounter > 1) {
return 0;
}
return $this->onCheckAutomaticSelected ($cart, $cart_prices, $shipCounter);
}
/**
* This method is fired when showing when priting an Order
* It displays the the payment method-specific data.
*
* @param integer $_virtuemart_order_id The order ID
* @param integer $method_id method used for this order
* @return mixed Null when for payment methods that were not selected, text (HTML) otherwise
* @author Valerie Isaksen
*/
function plgVmonShowOrderPrint ($order_number, $method_id) {
return $this->onShowOrderPrint ($order_number, $method_id);
}
function plgVmDeclarePluginParamsShipment ($name, $id, &$data) {
return $this->declarePluginParams ('shipment', $name, $id, $data);
}
/**
* @author Max Milbers
* @param $data
* @param $table
* @return bool
*/
function plgVmSetOnTablePluginShipment(&$data,&$table){
$name = $data['shipment_element'];
$id = $data['shipment_jplugin_id'];
if (!empty($this->_psType) and !$this->selectedThis ($this->_psType, $name, $id)) {
return FALSE;
} else {
$toConvert = array('weight_start','weight_stop','orderamount_start','orderamount_stop');
foreach($toConvert as $field){
if(!empty($data[$field])){
$data[$field] = str_replace(array(',',' '),array('.',''),$data[$field]);
} else {
unset($data[$field]);
}
}
$data['nbproducts_start'] = (int) $data['nbproducts_start'];
$data['nbproducts_stop'] = (int) $data['nbproducts_stop'];
//I dont see a reason for it
/*$toConvert = array('zip_start','zip_stop','nbproducts_start' , 'nbproducts_stop');
foreach($toConvert as $field){
if(!empty($data[$field])){
$data[$field] = str_replace( ' ','',$data[$field]);
} else {
unset($data[$field]);
}
if (preg_match ("/[^0-9]/", $data[$field])) {
vmWarn( JText::sprintf('VMSHIPMENT_WEIGHT_COUNTRIES_NUMERIC', JText::_('VMSHIPMENT_WEIGHT_COUNTRIES_'.$field) ) );
}
}*/
//Reasonable tests:
if(!empty($data['zip_start']) and !empty($data['zip_stop']) and (int)$data['zip_start']>=(int)$data['zip_stop']){
vmWarn('VMSHIPMENT_WEIGHT_COUNTRIES_ZIP_CONDITION_WRONG');
}
if(!empty($data['weight_start']) and !empty($data['weight_stop']) and (float)$data['weight_start']>=(float)$data['weight_stop']){
vmWarn('VMSHIPMENT_WEIGHT_COUNTRIES_WEIGHT_CONDITION_WRONG');
}
if(!empty($data['orderamount_start']) and !empty($data['orderamount_stop']) and (float)$data['orderamount_start']>=(float)$data['orderamount_stop']){
vmWarn('VMSHIPMENT_WEIGHT_COUNTRIES_AMOUNT_CONDITION_WRONG');
}
if(!empty($data['nbproducts_start']) and !empty($data['nbproducts_stop']) and (float)$data['nbproducts_start']>=(float)$data['nbproducts_stop']){
vmWarn('VMSHIPMENT_WEIGHT_COUNTRIES_NBPRODUCTS_CONDITION_WRONG');
}
return $this->setOnTablePluginParams ($name, $id, $table);
}
}
}
// No closing tag
PK ]y>\b 0 vmshipment/weight_countries/weight_countries.xmlnu W+A
VMSHIPMENT_WEIGHT_COUNTRIES
January 10 2014
The VirtueMart Development Team
http://www.virtuemart.net
Copyright (C) 2004-2014 Virtuemart Team. All rights reserved.
http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
2.0.26d
VMSHIPMENT_WEIGHT_COUNTRIES_PLUGIN_DESC
en-GB.plg_vmshipment_weight_countries.ini
weight_countries.php
weight_countries
PK ]y>\ &