diff --git a/oss/joomla/trunk/plugins/search/attachments.php b/oss/joomla/trunk/plugins/search/attachments.php
new file mode 100644
index 00000000..cf618f10
--- /dev/null
+++ b/oss/joomla/trunk/plugins/search/attachments.php
@@ -0,0 +1,196 @@
+registerEvent( 'onSearch', 'plgSearchAttachments' );
+$mainframe->registerEvent( 'onSearchAreas', 'plgSearchAttachmentAreas' );
+
+JPlugin::loadLanguage( 'plg_search_attachments', JPATH_ADMINISTRATOR);
+
+/**
+ * @return array An array of search areas
+ */
+function &plgSearchAttachmentAreas() {
+ static $areas = array(
+ 'attachments' => 'Attachments'
+ );
+ return $areas;
+}
+
+/* Attachment Search method
+ */
+function plgSearchAttachments( $text, $phrase='', $ordering='', $areas=null )
+{
+ $db =& JFactory::getDBO();
+ $user =& JFactory::getUser();
+
+ // Exit if the search does not include attachments
+ if (is_array( $areas )) {
+ if (!array_intersect( $areas, array_keys( plgSearchAttachmentAreas() ) )) {
+ return array();
+ }
+ }
+
+ // Make sure we have something to search for
+ $text = trim( $text );
+ if ($text == '') {
+ return array();
+ }
+
+ // load plugin params info
+ $plugin =& JPluginHelper::getPlugin('search', 'attachments');
+ $pluginParams = new JParameter( $plugin->params );
+ $limit = $pluginParams->def( 'search_limit', 50 );
+
+ // Get the component parameters
+ jimport('joomla.application.component.helper');
+ $attachParams = JComponentHelper::getParams('com_attachments');
+ $secure = $attachParams->get('secure', false);
+ $user_field_1 = false;
+ if ( strlen($attachParams->get('user_field_1_name', '')) > 0 ) {
+ $user_field_1 = true;
+ $user_field_1_name = $attachParams->get('user_field_1_name');
+ }
+ $user_field_2 = false;
+ if ( strlen($attachParams->get('user_field_2_name', '')) > 0 ) {
+ $user_field_2 = true;
+ $user_field_2_name = $attachParams->get('user_field_2_name');
+ }
+ $user_field_3 = false;
+ if ( strlen($attachParams->get('user_field_3_name', '')) > 0 ) {
+ $user_field_3 = true;
+ $user_field_3_name = $attachParams->get('user_field_3_name');
+ }
+
+ $wheres = array();
+
+ switch ($phrase)
+ {
+ case 'exact':
+ $text = $db->Quote( '%'.$db->getEscaped( $text, true ).'%', false );
+ $user_fields_sql = '';
+ if ( $user_field_1 )
+ $user_fields_sql .= " OR (LOWER(a.user_field_1) LIKE $text)";
+ if ( $user_field_2 )
+ $user_fields_sql .= " OR (LOWER(a.user_field_2) LIKE $text)";
+ if ( $user_field_3 )
+ $user_fields_sql .= " OR (LOWER(a.user_field_3) LIKE $text)";
+
+ $where = "((LOWER(a.filename) LIKE $text)" .
+ " OR (LOWER(a.display_filename) LIKE $text)" .
+ $user_fields_sql .
+ " OR (LOWER(a.description) LIKE $text))";
+ break;
+
+ default:
+ $words = explode( ' ', $text );
+ $wheres = array();
+ foreach ($words as $word)
+ {
+ $word = $db->Quote( '%'.$db->getEscaped( $word, true ).'%', false );
+ $wheres2 = array();
+ $wheres2[] = "LOWER(a.filename) LIKE $word";
+ $wheres2[] = "LOWER(a.display_filename) LIKE $word";
+ if ( $user_field_1 )
+ $wheres2[] = "LOWER(a.user_field_1) LIKE $word";
+ if ( $user_field_2 )
+ $wheres2[] = "LOWER(a.user_field_2) LIKE $word";
+ if ( $user_field_3 )
+ $wheres2[] = "LOWER(a.user_field_3) LIKE $word";
+ $wheres2[] = "LOWER(a.description) LIKE $word";
+ $wheres[] = implode( ' OR ', $wheres2 );
+ }
+ $where = '(' . implode( ($phrase == 'all' ? ') AND (' : ') OR ('), $wheres ) . ')';
+ break;
+ }
+
+ // Set up the sorting
+ switch ( $ordering )
+ {
+ case 'oldest':
+ $order = 'a.create_date ASC';
+ break;
+
+ case 'newest':
+ $order = 'a.create_date DESC';
+ break;
+
+ case 'alpha':
+ default:
+ $order = 'a.filename DESC';
+ }
+
+ // Load the permissions functions
+ require_once(JPATH_SITE.DS.'components'.DS.'com_attachments'.DS.'permissions.php');
+ $user =& JFactory::getUser();
+
+ // Construct and execute the query
+ $query = 'SELECT *, a.id as attachment_id, c.title as article_title'
+ . ' FROM #__attachments AS a'
+ . ' LEFT JOIN #__content as c ON a.article_id = c.id'
+ . ' WHERE ('. $where .')'
+ . ' AND a.published = 1'
+ . ' ORDER BY '. $order;
+ $db->setQuery( $query, 0, $limit );
+ $rows = $db->loadObjectList();
+
+ $count = count( $rows );
+
+ $k = 0;
+ $results = Array();
+
+ for ( $i = 0; $i < $count; $i++ ) {
+
+ // Do not add the attachment if the user may not access it
+ if ( !AttachmentsPermissions::user_may_access_attachment($user, $rows[$i]->id)) {
+ continue;
+ }
+
+ // Construct the download URL if necessary
+ if ( $secure ) {
+ $rows[$i]->href = JRoute::_("index.php?option=com_attachments&task=download&id=".$rows[$i]->attachment_id);
+ }
+ else {
+ $rows[$i]->href = $rows[$i]->url;
+ }
+ if ( $rows[$i]->display_filename && (strlen($rows[$i]->display_filename) > 0) ) {
+ $rows[$i]->title = $rows[$i]->display_filename;
+ }
+ else {
+ $rows[$i]->title = $rows[$i]->filename;
+ }
+
+ // Set the text to the string containing the search target
+ if ( strlen($rows[$i]->display_filename) > 0 ) {
+ $text = $rows[$i]->display_filename .
+ " (" . JText::_('FILENAME COLON') . " " . $rows[$i]->filename . ") ";
+ }
+ else {
+ $text = JText::_('FILENAME COLON') . " " . $rows[$i]->filename;
+ }
+
+ if ( strlen($rows[$i]->description) > 0 ) {
+ $text .= " | " . JText::_('DESCRIPTION COLON') . $rows[$i]->description;
+ }
+
+ if ( $user_field_1 && (strlen($rows[$i]->user_field_1) > 0) ) {
+ $text .= " | " . $user_field_1_name . ": " . $rows[$i]->user_field_1;
+ }
+ if ( $user_field_2 && (strlen($rows[$i]->user_field_2) > 0) ) {
+ $text .= " | " . $user_field_2_name . ": " . $rows[$i]->user_field_2;
+ }
+ if ( $user_field_3 && (strlen($rows[$i]->user_field_3) > 0) ) {
+ $text .= " | " . $user_field_3_name . ": " . $rows[$i]->user_field_3;
+ }
+ $rows[$i]->text = $text;
+ $rows[$i]->created = $rows[$i]->create_date;
+ $rows[$i]->browsernav = 2;
+ $rows[$i]->section = JText::_('ATTACHED TO ARTICLE').": ".$rows[$i]->article_title;
+
+ $results[$k] = $rows[$i];
+ $k++;
+ }
+
+ return $results;
+}
\ No newline at end of file
diff --git a/oss/joomla/trunk/plugins/search/attachments.xml b/oss/joomla/trunk/plugins/search/attachments.xml
new file mode 100644
index 00000000..951642c3
--- /dev/null
+++ b/oss/joomla/trunk/plugins/search/attachments.xml
@@ -0,0 +1,23 @@
+
+
+
+ Search - Attachments
+ Paul McDermott (www.bluebellsupport.com), Jonathan Cameron
+ August 17, 2008
+ (C) 2007, 2008 Jonathan M. Cameron. All rights reserved.
+ http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ jmcameron@jmcameron.net
+ http://joomlacode.org/gf/project/attachments/
+ 1.3.4
+ ATTACHMENTS SEARCH INSTALLED
+
+ en-GB.plg_search_attachments.ini
+
+
+ attachments.php
+
+
+
+
+
\ No newline at end of file
diff --git a/oss/joomla/trunk/plugins/search/categories.php b/oss/joomla/trunk/plugins/search/categories.php
new file mode 100644
index 00000000..79b535e6
--- /dev/null
+++ b/oss/joomla/trunk/plugins/search/categories.php
@@ -0,0 +1,116 @@
+registerEvent( 'onSearch', 'plgSearchCategories' );
+$mainframe->registerEvent( 'onSearchAreas', 'plgSearchCategoryAreas' );
+
+JPlugin::loadLanguage( 'plg_search_categories' );
+
+/**
+ * @return array An array of search areas
+ */
+function &plgSearchCategoryAreas()
+{
+ static $areas = array(
+ '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 plgSearchCategories( $text, $phrase='', $ordering='', $areas=null )
+{
+ $db =& JFactory::getDBO();
+ $user =& JFactory::getUser();
+ $searchText = $text;
+
+ require_once(JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php');
+
+ if (is_array( $areas )) {
+ if (!array_intersect( $areas, array_keys( plgSearchCategoryAreas() ) )) {
+ return array();
+ }
+ }
+
+ // load plugin params info
+ $plugin =& JPluginHelper::getPlugin('search', 'categories');
+ $pluginParams = new JParameter( $plugin->params );
+
+ $limit = $pluginParams->def( 'search_limit', 50 );
+
+ $text = trim( $text );
+ if ( $text == '' ) {
+ return array();
+ }
+
+ switch ( $ordering ) {
+ case 'alpha':
+ $order = 'a.name ASC';
+ break;
+
+ case 'category':
+ case 'popular':
+ case 'newest':
+ case 'oldest':
+ default:
+ $order = 'a.name DESC';
+ }
+
+ $text = $db->Quote( '%'.$db->getEscaped( $text, true ).'%', false );
+ $query = 'SELECT a.title, a.description AS text, "" AS created, a.name,'
+ . ' "2" AS browsernav,'
+ . ' s.id AS secid, a.id AS catid,'
+ . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug'
+ . ' FROM #__categories AS a'
+ . ' INNER JOIN #__sections AS s ON s.id = a.section'
+ . ' WHERE ( a.name LIKE '.$text
+ . ' OR a.title LIKE '.$text
+ . ' OR a.description LIKE '.$text.' )'
+ . ' AND a.published = 1'
+ . ' AND s.published = 1'
+ . ' AND a.access <= '.(int) $user->get('aid')
+ . ' AND s.access <= '.(int) $user->get('aid')
+ . ' GROUP BY a.id'
+ . ' ORDER BY '. $order
+ ;
+ $db->setQuery( $query, 0, $limit );
+ $rows = $db->loadObjectList();
+
+ $count = count( $rows );
+ for ( $i = 0; $i < $count; $i++ ) {
+ $rows[$i]->href = ContentHelperRoute::getCategoryRoute($rows[$i]->slug, $rows[$i]->secid);
+ $rows[$i]->section = JText::_( 'Category' );
+ }
+
+ $return = array();
+ foreach($rows AS $key => $category) {
+ if(searchHelper::checkNoHTML($category, $searchText, array('name', 'title', 'text'))) {
+ $return[] = $category;
+ }
+ }
+
+ return $return;
+}
diff --git a/oss/joomla/trunk/plugins/search/categories.xml b/oss/joomla/trunk/plugins/search/categories.xml
new file mode 100644
index 00000000..2d0f44dc
--- /dev/null
+++ b/oss/joomla/trunk/plugins/search/categories.xml
@@ -0,0 +1,18 @@
+
+
+ Search - Categories
+ Joomla! Project
+ November 2005
+ Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
+ http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ admin@joomla.org
+ www.joomla.org
+ 1.5
+ Allows Searching of Categories information
+
+ categories.php
+
+
+
+
+
\ No newline at end of file
diff --git a/oss/joomla/trunk/plugins/search/contacts.php b/oss/joomla/trunk/plugins/search/contacts.php
new file mode 100644
index 00000000..9beb5623
--- /dev/null
+++ b/oss/joomla/trunk/plugins/search/contacts.php
@@ -0,0 +1,116 @@
+registerEvent( 'onSearch', 'plgSearchContacts' );
+$mainframe->registerEvent( 'onSearchAreas', 'plgSearchContactAreas' );
+
+JPlugin::loadLanguage( 'plg_search_contacts' );
+
+/**
+ * @return array An array of search areas
+ */
+function &plgSearchContactAreas()
+{
+ static $areas = array(
+ '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 mathcing option, exact|any|all
+* @param string ordering option, newest|oldest|popular|alpha|category
+*/
+function plgSearchContacts( $text, $phrase='', $ordering='', $areas=null )
+{
+ $db =& JFactory::getDBO();
+ $user =& JFactory::getUser();
+
+ if (is_array( $areas )) {
+ if (!array_intersect( $areas, array_keys( plgSearchContactAreas() ) )) {
+ return array();
+ }
+ }
+
+ // load plugin params info
+ $plugin =& JPluginHelper::getPlugin('search', 'contacts');
+ $pluginParams = new JParameter( $plugin->params );
+
+ $limit = $pluginParams->def( 'search_limit', 50 );
+
+ $text = trim( $text );
+ if ($text == '') {
+ return array();
+ }
+
+ $section = JText::_( 'Contact' );
+
+ switch ( $ordering ) {
+ case 'alpha':
+ $order = 'a.name ASC';
+ break;
+
+ case 'category':
+ $order = 'b.title ASC, a.name ASC';
+ break;
+
+ case 'popular':
+ case 'newest':
+ case 'oldest':
+ default:
+ $order = 'a.name DESC';
+ }
+
+ $text = $db->Quote( '%'.$db->getEscaped( $text, true ).'%', false );
+ $query = 'SELECT a.name AS title, "" AS created,'
+ . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug, '
+ . ' CASE WHEN CHAR_LENGTH(b.alias) THEN CONCAT_WS(\':\', b.id, b.alias) ELSE b.id END AS catslug, '
+ . ' CONCAT_WS( ", ", a.name, a.con_position, a.misc ) AS text,'
+ . ' CONCAT_WS( " / ", '.$db->Quote($section).', b.title ) AS section,'
+ . ' "2" AS browsernav'
+ . ' FROM #__contact_details AS a'
+ . ' INNER JOIN #__categories AS b ON b.id = a.catid'
+ . ' 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 = 1'
+ . ' AND b.published = 1'
+ . ' AND a.access <= '.(int) $user->get( 'aid' )
+ . ' AND b.access <= '.(int) $user->get( 'aid' )
+ . ' GROUP BY a.id'
+ . ' ORDER BY '. $order
+ ;
+ $db->setQuery( $query, 0, $limit );
+ $rows = $db->loadObjectList();
+
+ foreach($rows as $key => $row) {
+ $rows[$key]->href = 'index.php?option=com_contact&view=contact&id='.$row->slug.'&catid='.$row->catslug;
+ }
+
+ return $rows;
+}
diff --git a/oss/joomla/trunk/plugins/search/contacts.xml b/oss/joomla/trunk/plugins/search/contacts.xml
new file mode 100644
index 00000000..ab5c2023
--- /dev/null
+++ b/oss/joomla/trunk/plugins/search/contacts.xml
@@ -0,0 +1,18 @@
+
+
+ Search - Contacts
+ Joomla! Project
+ November 2005
+ Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
+ http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ admin@joomla.org
+ www.joomla.org
+ 1.5
+ Allows Searching of Contacts Component
+
+ contacts.php
+
+
+
+
+
\ No newline at end of file
diff --git a/oss/joomla/trunk/plugins/search/content.php b/oss/joomla/trunk/plugins/search/content.php
new file mode 100644
index 00000000..d2721cab
--- /dev/null
+++ b/oss/joomla/trunk/plugins/search/content.php
@@ -0,0 +1,264 @@
+registerEvent( 'onSearch', 'plgSearchContent' );
+$mainframe->registerEvent( 'onSearchAreas', 'plgSearchContentAreas' );
+
+JPlugin::loadLanguage( 'plg_search_content' );
+
+/**
+ * @return array An array of search areas
+ */
+function &plgSearchContentAreas()
+{
+ static $areas = array(
+ 'content' => '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 plgSearchContent( $text, $phrase='', $ordering='', $areas=null )
+{
+ global $mainframe;
+
+ $db =& JFactory::getDBO();
+ $user =& JFactory::getUser();
+
+ require_once(JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php');
+ require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_search'.DS.'helpers'.DS.'search.php');
+
+ $searchText = $text;
+ if (is_array( $areas )) {
+ if (!array_intersect( $areas, array_keys( plgSearchContentAreas() ) )) {
+ return array();
+ }
+ }
+
+ // load plugin params info
+ $plugin =& JPluginHelper::getPlugin('search', 'content');
+ $pluginParams = new JParameter( $plugin->params );
+
+ $sContent = $pluginParams->get( 'search_content', 1 );
+ $sUncategorised = $pluginParams->get( 'search_uncategorised', 1 );
+ $sArchived = $pluginParams->get( 'search_archived', 1 );
+ $limit = $pluginParams->def( 'search_limit', 50 );
+
+ $nullDate = $db->getNullDate();
+ $date =& JFactory::getDate();
+ $now = $date->toMySQL();
+
+ $text = trim( $text );
+ if ($text == '') {
+ return array();
+ }
+
+ $wheres = array();
+ switch ($phrase) {
+ case 'exact':
+ $text = $db->Quote( '%'.$db->getEscaped( $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->getEscaped( $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 = 'b.title ASC, a.title ASC';
+ $morder = 'a.title ASC';
+ break;
+
+ case 'newest':
+ default:
+ $order = 'a.created DESC';
+ break;
+ }
+
+ $rows = array();
+
+ // search articles
+ if ( $sContent && $limit > 0 )
+ {
+ $query = 'SELECT a.title AS title, a.metadesc, a.metakey,'
+ . ' a.created AS created,'
+ . ' CONCAT(a.introtext, a.fulltext) AS text,'
+ . ' CONCAT_WS( "/", u.title, b.title ) AS section,'
+ . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,'
+ . ' CASE WHEN CHAR_LENGTH(b.alias) THEN CONCAT_WS(":", b.id, b.alias) ELSE b.id END as catslug,'
+ . ' u.id AS sectionid,'
+ . ' "2" AS browsernav'
+ . ' FROM #__content AS a'
+ . ' INNER JOIN #__categories AS b ON b.id=a.catid'
+ . ' INNER JOIN #__sections AS u ON u.id = a.sectionid'
+ . ' WHERE ( '.$where.' )'
+ . ' AND a.state = 1'
+ . ' AND u.published = 1'
+ . ' AND b.published = 1'
+ . ' AND a.access <= '.(int) $user->get( 'aid' )
+ . ' AND b.access <= '.(int) $user->get( 'aid' )
+ . ' AND u.access <= '.(int) $user->get( 'aid' )
+ . ' 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).' )'
+ . ' GROUP BY a.id'
+ . ' ORDER BY '. $order
+ ;
+ $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->sectionid);
+ }
+ }
+ $rows[] = $list;
+ }
+
+ // search uncategorised content
+ if ( $sUncategorised && $limit > 0 )
+ {
+ $query = 'SELECT id, a.title AS title, a.created AS created, a.metadesc, a.metakey, '
+ . ' CONCAT(a.introtext, a.fulltext) AS text,'
+ . ' "2" as browsernav, "'. $db->Quote(JText::_('Uncategorised Content')) .'" AS section'
+ . ' FROM #__content AS a'
+ . ' WHERE ('.$where.')'
+ . ' AND a.state = 1'
+ . ' AND a.access <= '.(int) $user->get( 'aid' )
+ . ' AND a.sectionid = 0'
+ . ' AND a.catid = 0'
+ . ' 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).' )'
+ . ' ORDER BY '. ($morder ? $morder : $order)
+ ;
+ $db->setQuery( $query, 0, $limit );
+ $list2 = $db->loadObjectList();
+ $limit -= count($list2);
+
+ if(isset($list2))
+ {
+ foreach($list2 as $key => $item)
+ {
+ $list2[$key]->href = ContentHelperRoute::getArticleRoute($item->id);
+ }
+ }
+
+ $rows[] = $list2;
+ }
+
+ // search archived content
+ if ( $sArchived && $limit > 0 )
+ {
+ $searchArchived = JText::_( 'Archived' );
+
+ $query = 'SELECT a.title AS title, a.metadesc, a.metakey,'
+ . ' a.created AS created,'
+ . ' CONCAT(a.introtext, a.fulltext) AS text,'
+ . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,'
+ . ' CASE WHEN CHAR_LENGTH(b.alias) THEN CONCAT_WS(":", b.id, b.alias) ELSE b.id END as catslug,'
+ . ' u.id AS sectionid,'
+ . ' CONCAT_WS( "/", u.title, b.title ) AS section,'
+ . ' "2" AS browsernav'
+ . ' FROM #__content AS a'
+ . ' INNER JOIN #__categories AS b ON b.id=a.catid AND b.access <= ' .$user->get( 'gid' )
+ . ' INNER JOIN #__sections AS u ON u.id = a.sectionid'
+ . ' WHERE ( '.$where.' )'
+ . ' AND a.state = -1'
+ . ' AND u.published = 1'
+ . ' AND b.published = 1'
+ . ' AND a.access <= '.(int) $user->get( 'aid' )
+ . ' AND b.access <= '.(int) $user->get( 'aid' )
+ . ' AND u.access <= '.(int) $user->get( 'aid' )
+ . ' 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).' )'
+ . ' ORDER BY '. $order
+ ;
+ $db->setQuery( $query, 0, $limit );
+ $list3 = $db->loadObjectList();
+
+ if(isset($list3))
+ {
+ foreach($list3 as $key => $item)
+ {
+ $list3[$key]->href = ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->sectionid);
+ }
+ }
+
+ $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;
+}
diff --git a/oss/joomla/trunk/plugins/search/content.xml b/oss/joomla/trunk/plugins/search/content.xml
new file mode 100644
index 00000000..a5e2df08
--- /dev/null
+++ b/oss/joomla/trunk/plugins/search/content.xml
@@ -0,0 +1,31 @@
+
+
+ Search - Content
+ Joomla! Project
+ November 2005
+ Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
+ http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ admin@joomla.org
+ www.joomla.org
+ 1.5
+ ALLOWS SEARCHING OF ALL ARTICLES
+
+ content.php
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/oss/joomla/trunk/plugins/search/index.html b/oss/joomla/trunk/plugins/search/index.html
new file mode 100644
index 00000000..fa6d84e8
--- /dev/null
+++ b/oss/joomla/trunk/plugins/search/index.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/oss/joomla/trunk/plugins/search/newsfeeds.php b/oss/joomla/trunk/plugins/search/newsfeeds.php
new file mode 100644
index 00000000..57a9ffb5
--- /dev/null
+++ b/oss/joomla/trunk/plugins/search/newsfeeds.php
@@ -0,0 +1,131 @@
+registerEvent( 'onSearch', 'plgSearchNewsfeedslinks' );
+$mainframe->registerEvent( 'onSearchAreas', 'plgSearchNewsfeedAreas' );
+
+JPlugin::loadLanguage( 'plg_search_newsfeeds' );
+
+/**
+ * @return array An array of search areas
+ */
+function &plgSearchNewsfeedAreas()
+{
+ static $areas = array(
+ 'newsfeeds' => 'Newsfeeds'
+ );
+ 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 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 plgSearchNewsfeedslinks( $text, $phrase='', $ordering='', $areas=null )
+{
+ $db =& JFactory::getDBO();
+ $user =& JFactory::getUser();
+
+ if (is_array( $areas )) {
+ if (!array_intersect( $areas, array_keys( plgSearchNewsfeedAreas() ) )) {
+ return array();
+ }
+ }
+
+ // load plugin params info
+ $plugin =& JPluginHelper::getPlugin('search', 'newsfeeds');
+ $pluginParams = new JParameter( $plugin->params );
+
+ $limit = $pluginParams->def( 'search_limit', 50 );
+
+ $text = trim( $text );
+ if ($text == '') {
+ return array();
+ }
+
+ $wheres = array();
+ switch ($phrase) {
+ case 'exact':
+ $text = $db->Quote( '%'.$db->getEscaped( $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->getEscaped( $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 = 'b.title ASC, a.name ASC';
+ break;
+
+ case 'oldest':
+ case 'popular':
+ case 'newest':
+ default:
+ $order = 'a.name ASC';
+ }
+
+ $searchNewsfeeds = JText::_( 'Newsfeeds' );
+
+ $query = 'SELECT a.name AS title, "" AS created, a.link AS text,'
+ . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug, '
+ . ' CASE WHEN CHAR_LENGTH(b.alias) THEN CONCAT_WS(\':\', b.id, b.alias) ELSE b.id END as catslug, '
+ . ' CONCAT_WS( " / ", '. $db->Quote($searchNewsfeeds) .', b.title )AS section,'
+ . ' "1" AS browsernav'
+ . ' FROM #__newsfeeds AS a'
+ . ' INNER JOIN #__categories AS b ON b.id = a.catid'
+ . ' WHERE ( '. $where .' )'
+ . ' AND a.published = 1'
+ . ' AND b.published = 1'
+ . ' AND b.access <= '. (int) $user->get( 'aid' )
+ . ' ORDER BY '. $order
+ ;
+ $db->setQuery( $query, 0, $limit );
+ $rows = $db->loadObjectList();
+
+ foreach($rows as $key => $row) {
+ $rows[$key]->href = 'index.php?option=com_newsfeeds&view=newsfeed&catid='.$row->catslug.'&id='.$row->slug;
+ }
+
+ return $rows;
+}
diff --git a/oss/joomla/trunk/plugins/search/newsfeeds.xml b/oss/joomla/trunk/plugins/search/newsfeeds.xml
new file mode 100644
index 00000000..2b55e3f4
--- /dev/null
+++ b/oss/joomla/trunk/plugins/search/newsfeeds.xml
@@ -0,0 +1,18 @@
+
+
+ Search - Newsfeeds
+ Joomla! Project
+ November 2005
+ Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
+ http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ admin@joomla.org
+ www.joomla.org
+ 1.5
+ Allows Searching of Newsfeeds
+
+ newsfeeds.php
+
+
+
+
+
\ No newline at end of file
diff --git a/oss/joomla/trunk/plugins/search/sections.php b/oss/joomla/trunk/plugins/search/sections.php
new file mode 100644
index 00000000..dd0fac0d
--- /dev/null
+++ b/oss/joomla/trunk/plugins/search/sections.php
@@ -0,0 +1,112 @@
+registerEvent( 'onSearch', 'plgSearchSections' );
+$mainframe->registerEvent( 'onSearchAreas', 'plgSearchSectionAreas' );
+
+JPlugin::loadLanguage( 'plg_search_sections' );
+
+/**
+ * @return array An array of search areas
+ */
+function &plgSearchSectionAreas() {
+ static $areas = array(
+ 'sections' => 'Sections'
+ );
+ return $areas;
+}
+
+/**
+* Sections 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 plgSearchSections( $text, $phrase='', $ordering='', $areas=null )
+{
+ $db =& JFactory::getDBO();
+ $user =& JFactory::getUser();
+
+ $searchText = $text;
+
+ require_once(JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php');
+
+ if (is_array( $areas )) {
+ if (!array_intersect( $areas, array_keys( plgSearchSectionAreas() ) )) {
+ return array();
+ }
+ }
+
+ // load plugin params info
+ $plugin =& JPluginHelper::getPlugin('search', 'sections');
+ $pluginParams = new JParameter( $plugin->params );
+
+ $limit = $pluginParams->def( 'search_limit', 50 );
+
+ $text = trim( $text );
+ if ($text == '') {
+ return array();
+ }
+
+ switch ( $ordering ) {
+ case 'alpha':
+ $order = 'a.name ASC';
+ break;
+
+ case 'category':
+ case 'popular':
+ case 'newest':
+ case 'oldest':
+ default:
+ $order = 'a.name DESC';
+ }
+
+ $text = $db->Quote( '%'.$db->getEscaped( $text, true ).'%', false );
+ $query = 'SELECT a.title AS title, a.description AS text, a.name, '
+ . ' "" AS created,'
+ . ' "2" AS browsernav,'
+ . ' a.id AS secid'
+ . ' FROM #__sections AS a'
+ . ' WHERE ( a.name LIKE '.$text
+ . ' OR a.title LIKE '.$text
+ . ' OR a.description LIKE '.$text.' )'
+ . ' AND a.published = 1'
+ . ' AND a.access <= '.(int) $user->get( 'aid' )
+ . ' GROUP BY a.id'
+ . ' ORDER BY '. $order
+ ;
+ $db->setQuery( $query, 0, $limit );
+ $rows = $db->loadObjectList();
+
+ $count = count( $rows );
+ for ( $i = 0; $i < $count; $i++ )
+ {
+ $rows[$i]->href = ContentHelperRoute::getSectionRoute($rows[$i]->secid);
+ $rows[$i]->section = JText::_( 'Section' );
+ }
+
+ $return = array();
+ foreach($rows AS $key => $section) {
+ if(searchHelper::checkNoHTML($section, $searchText, array('name', 'title', 'text'))) {
+ $return[] = $section;
+ }
+ }
+ return $return;
+}
diff --git a/oss/joomla/trunk/plugins/search/sections.xml b/oss/joomla/trunk/plugins/search/sections.xml
new file mode 100644
index 00000000..e0fe90f7
--- /dev/null
+++ b/oss/joomla/trunk/plugins/search/sections.xml
@@ -0,0 +1,18 @@
+
+
+ Search - Sections
+ Joomla! Project
+ November 2005
+ Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
+ http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ admin@joomla.org
+ www.joomla.org
+ 1.5
+ Allows Searching of Content Section information
+
+ sections.php
+
+
+
+
+
\ No newline at end of file
diff --git a/oss/joomla/trunk/plugins/search/weblinks.php b/oss/joomla/trunk/plugins/search/weblinks.php
new file mode 100644
index 00000000..57aae739
--- /dev/null
+++ b/oss/joomla/trunk/plugins/search/weblinks.php
@@ -0,0 +1,150 @@
+registerEvent( 'onSearch', 'plgSearchWeblinks' );
+$mainframe->registerEvent( 'onSearchAreas', 'plgSearchWeblinksAreas' );
+
+JPlugin::loadLanguage( 'plg_search_weblinks' );
+
+/**
+ * @return array An array of search areas
+ */
+function &plgSearchWeblinksAreas() {
+ static $areas = array(
+ '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 plgSearchWeblinks( $text, $phrase='', $ordering='', $areas=null )
+{
+ $db =& JFactory::getDBO();
+ $user =& JFactory::getUser();
+
+ $searchText = $text;
+
+ require_once(JPATH_SITE.DS.'components'.DS.'com_weblinks'.DS.'helpers'.DS.'route.php');
+
+ if (is_array( $areas )) {
+ if (!array_intersect( $areas, array_keys( plgSearchWeblinksAreas() ) )) {
+ return array();
+ }
+ }
+
+ // load plugin params info
+ $plugin =& JPluginHelper::getPlugin('search', 'weblinks');
+ $pluginParams = new JParameter( $plugin->params );
+
+ $limit = $pluginParams->def( 'search_limit', 50 );
+
+ $text = trim( $text );
+ if ($text == '') {
+ return array();
+ }
+ $section = JText::_( 'Web Links' );
+
+ $wheres = array();
+ switch ($phrase)
+ {
+ case 'exact':
+ $text = $db->Quote( '%'.$db->getEscaped( $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->getEscaped( $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.date ASC';
+ break;
+
+ case 'popular':
+ $order = 'a.hits DESC';
+ break;
+
+ case 'alpha':
+ $order = 'a.title ASC';
+ break;
+
+ case 'category':
+ $order = 'b.title ASC, a.title ASC';
+ break;
+
+ case 'newest':
+ default:
+ $order = 'a.date DESC';
+ }
+
+ $query = 'SELECT a.title AS title, a.description AS text, a.date AS created, a.url, '
+ . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug, '
+ . ' CASE WHEN CHAR_LENGTH(b.alias) THEN CONCAT_WS(\':\', b.id, b.alias) ELSE b.id END as catslug, '
+ . ' CONCAT_WS( " / ", '.$db->Quote($section).', b.title ) AS section,'
+ . ' "1" AS browsernav'
+ . ' FROM #__weblinks AS a'
+ . ' INNER JOIN #__categories AS b ON b.id = a.catid'
+ . ' WHERE ('. $where .')'
+ . ' AND a.published = 1'
+ . ' AND b.published = 1'
+ . ' AND b.access <= '.(int) $user->get( 'aid' )
+ . ' ORDER BY '. $order
+ ;
+ $db->setQuery( $query, 0, $limit );
+ $rows = $db->loadObjectList();
+
+ foreach($rows as $key => $row) {
+ $rows[$key]->href = WeblinksHelperRoute::getWeblinkRoute($row->slug, $row->catslug);
+ }
+
+ $return = array();
+ foreach($rows AS $key => $weblink) {
+ if(searchHelper::checkNoHTML($weblink, $searchText, array('url', 'text', 'title'))) {
+ $return[] = $weblink;
+ }
+ }
+
+ return $return;
+}
diff --git a/oss/joomla/trunk/plugins/search/weblinks.xml b/oss/joomla/trunk/plugins/search/weblinks.xml
new file mode 100644
index 00000000..1678cb11
--- /dev/null
+++ b/oss/joomla/trunk/plugins/search/weblinks.xml
@@ -0,0 +1,18 @@
+
+
+ Search - Weblinks
+ Joomla! Project
+ November 2005
+ Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
+ http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ admin@joomla.org
+ www.joomla.org
+ 1.5
+ Allows Searching of Weblinks Component
+
+ weblinks.php
+
+
+
+
+
\ No newline at end of file
diff --git a/oss/joomla/trunk/plugins/system/backlink.php b/oss/joomla/trunk/plugins/system/backlink.php
new file mode 100644
index 00000000..cceec708
--- /dev/null
+++ b/oss/joomla/trunk/plugins/system/backlink.php
@@ -0,0 +1,529 @@
+_db = JFactory::getDBO();
+ parent :: __construct($subject, $config);
+ }
+
+ function onAfterInitialise()
+ {
+ global $mainframe;
+ if ($mainframe->isAdmin()) {
+ return; // Dont run in admin
+ }
+
+ $sef = $this->params->get('sef', 1);
+ $url = $this->params->get('url', 1);
+
+ $legacysef = $this->params->get('legacysef', 1);
+ if (!$sef && !$url && !$legacysef)
+ return; // None of the options enabled, bail!
+
+ // Grab the system as early as possible, we're going to terminate it potentially
+ // Case 1: Query string match (shouldn't need this but its here anyway)
+ if ($url && isset ($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) && strpos($_SERVER['QUERY_STRING'], '&')) {
+ $query_string = $_SERVER['QUERY_STRING'];
+ $this->_lookup($query_string);
+ }
+
+ // Case 2: SEF or similar match
+ if ($sef && isset ($_SERVER['SCRIPT_NAME']) && isset ($_SERVER['REQUEST_URI'])) {
+ $part = str_replace('index.php', '', $_SERVER['SCRIPT_NAME']);
+ if($part != '/') {
+ $search = str_replace($part, '', $_SERVER['REQUEST_URI']);
+ } else {
+ $search = ltrim($_SERVER['REQUEST_URI'],'/');
+ }
+ $this->_lookup($search);
+ }
+ // Case 3: Old school core sef; used to backlink
+ // Enable only if:
+ // 1: SEF is enabled
+ // 2: Legacy SEF Plugin Param is set
+ // 3: And there is no backlink
+ if ($mainframe->getCfg('sef')
+ && $legacysef
+ && !strstr($_SERVER['REQUEST_URI'],'nobacklink')
+ && !strlen($_SERVER['QUERY_STRING'])) {
+ $this->_legacysef();
+ }
+
+ }
+
+ function _lookup($searchstring)
+ {
+ // return blank strings and just index.php on its own...
+ if (!strlen($searchstring) || $searchstring == trim('index.php',' ?')) {
+ return;
+ }
+
+ $sef = $this->params->get('sef', 1);
+ $url = $this->params->get('url', 1);
+
+ if (!$sef && !$url) {
+ return; // Neither option enabled, bail!
+ }
+
+ $query = 'SELECT * FROM #__migration_backlinks WHERE ';
+ $where = Array ();
+ $search = $this->_db->Quote( $this->_db->getEscaped( $searchstring, true ).'%', false );
+
+ if ($url) {
+ $where[] = 'url LIKE ' . $search;
+ }
+ if ($sef) {
+ $where[] = 'sefurl LIKE ' . $search;
+ }
+
+ $query .= implode(' OR ', $where);
+ $this->_db->setQuery($query);
+ $results = $this->_db->loadAssocList();
+
+ if (count($results)) {
+ // Get the first one...
+ $this->_redirect($results[0]['itemid'], $results[0]['name'], $results[0]['newurl']);
+ }
+ }
+
+ function _redirect($Itemid, $name, $url = null)
+ {
+ global $mainframe;
+ if (!strlen($url))
+ {
+ $menu = & JSite :: getMenu();
+ $item = $menu->getItem($Itemid);
+ //$url = $item->link;
+
+ switch ($item->type)
+ {
+ case 'url' :
+ if ((strpos($item->link, 'index.php?') !== false) && (strpos($item->link, 'Itemid=') === false)) {
+ $url = $item->link . '&Itemid=' . $item->id;
+ } else {
+ $url = $item->link;
+ }
+ break;
+
+ default :
+ $url = 'index.php?Itemid=' . $item->id;
+ //$url = $item->link . '&Itemid='.$item->id;
+ break;
+ }
+ $url = JRoute :: _($url);
+ //$url = JURI :: base() . $url; // was $surl with third option of below being url and second being surl
+ $name = $item->name;
+ }
+ // Check we're not redirecting to ourselves
+ if(!stristr($url,$_SERVER['REQUEST_URI']) && !stristr($url,$_SERVER['SCRIPT_NAME'].'/'.$_SERVER['QUERY_STRING'])) {
+ return;
+ }
+
+ $name = $name ? $name : "Unknown";
+
+ header('Location: ' . str_replace('&','&',$url), true, '301'); // redirect and kill of and &
+ jexit(JText :: sprintf('"%s" has moved to %s. Click the link if your browser does not redirect you automatically.', $name, $url, $url));
+ }
+
+ function _legacysef()
+ {
+ $mosConfig_absolute_path = JPATH_SITE;
+ $mosConfig_live_site = JURI :: base();
+ $url_array = explode('/', $_SERVER['REQUEST_URI']);
+
+ if (in_array('content', $url_array))
+ {
+ /**
+ * Content
+ * http://www.domain.com/$option/$task/$sectionid/$id/$Itemid/$limit/$limitstart
+ */
+
+ $uri = explode('content/', $_SERVER['REQUEST_URI']);
+ $option = 'com_content';
+ $_GET['option'] = $option;
+ $_REQUEST['option'] = $option;
+ $pos = array_search('content', $url_array);
+
+ // language hook for content
+ $lang = '';
+ foreach ($url_array as $key => $value)
+ {
+ if (!strcasecmp(substr($value, 0, 5), 'lang,'))
+ {
+ $temp = explode(',', $value);
+ if (isset ($temp[0]) && $temp[0] != '' && isset ($temp[1]) && $temp[1] != '')
+ {
+ $_GET['lang'] = $temp[1];
+ $_REQUEST['lang'] = $temp[1];
+ $lang = $temp[1];
+ }
+ unset ($url_array[$key]);
+ }
+ }
+
+ if (isset ($url_array[$pos +8]) && $url_array[$pos +8] != '' && in_array('category', $url_array) && (strpos($url_array[$pos +5], 'order,') !== false) && (strpos($url_array[$pos +6], 'filter,') !== false))
+ {
+ // $option/$task/$sectionid/$id/$Itemid/$order/$filter/$limit/$limitstart
+ $task = $url_array[$pos +1];
+ $sectionid = $url_array[$pos +2];
+ $id = $url_array[$pos +3];
+ $Itemid = $url_array[$pos +4];
+ $order = str_replace('order,', '', $url_array[$pos +5]);
+ $filter = str_replace('filter,', '', $url_array[$pos +6]);
+ $limit = $url_array[$pos +7];
+ $limitstart = $url_array[$pos +8];
+
+ // pass data onto global variables
+ $_GET['task'] = $task;
+ $_REQUEST['task'] = $task;
+ $_GET['sectionid'] = $sectionid;
+ $_REQUEST['sectionid'] = $sectionid;
+ $_GET['id'] = $id;
+ $_REQUEST['id'] = $id;
+ $_GET['Itemid'] = $Itemid;
+ $_REQUEST['Itemid'] = $Itemid;
+ $_GET['order'] = $order;
+ $_REQUEST['order'] = $order;
+ $_GET['filter'] = $filter;
+ $_REQUEST['filter'] = $filter;
+ $_GET['limit'] = $limit;
+ $_REQUEST['limit'] = $limit;
+ $_GET['limitstart'] = $limitstart;
+ $_REQUEST['limitstart'] = $limitstart;
+
+ $QUERY_STRING = "option=com_content&task=$task§ionid=$sectionid&id=$id&Itemid=$Itemid&order=$order&filter=$filter&limit=$limit&limitstart=$limitstart";
+ }
+ else if (isset ($url_array[$pos +7]) && $url_array[$pos +7] != '' && $url_array[$pos +5] > 1000 && (in_array('archivecategory', $url_array) || in_array('archivesection', $url_array)))
+ {
+ // $option/$task/$id/$limit/$limitstart/year/month/module
+ $task = $url_array[$pos +1];
+ $id = $url_array[$pos +2];
+ $limit = $url_array[$pos +3];
+ $limitstart = $url_array[$pos +4];
+ $year = $url_array[$pos +5];
+ $month = $url_array[$pos +6];
+ $module = $url_array[$pos +7];
+
+ // pass data onto global variables
+ $_GET['task'] = $task;
+ $_REQUEST['task'] = $task;
+ $_GET['id'] = $id;
+ $_REQUEST['id'] = $id;
+ $_GET['limit'] = $limit;
+ $_REQUEST['limit'] = $limit;
+ $_GET['limitstart'] = $limitstart;
+ $_REQUEST['limitstart'] = $limitstart;
+ $_GET['year'] = $year;
+ $_REQUEST['year'] = $year;
+ $_GET['month'] = $month;
+ $_REQUEST['month'] = $month;
+ $_GET['module'] = $module;
+ $_REQUEST['module'] = $module;
+
+ $QUERY_STRING = "option=com_content&task=$task&id=$id&limit=$limit&limitstart=$limitstart&year=$year&month=$month&module=$module";
+ }
+ else if (isset ($url_array[$pos +7]) && $url_array[$pos +7] != '' && $url_array[$pos +6] > 1000 && (in_array('archivecategory', $url_array) || in_array('archivesection', $url_array)))
+ {
+ // $option/$task/$id/$Itemid/$limit/$limitstart/year/month
+ $task = $url_array[$pos +1];
+ $id = $url_array[$pos +2];
+ $Itemid = $url_array[$pos +3];
+ $limit = $url_array[$pos +4];
+ $limitstart = $url_array[$pos +5];
+ $year = $url_array[$pos +6];
+ $month = $url_array[$pos +7];
+
+ // pass data onto global variables
+ $_GET['task'] = $task;
+ $_REQUEST['task'] = $task;
+ $_GET['id'] = $id;
+ $_REQUEST['id'] = $id;
+ $_GET['Itemid'] = $Itemid;
+ $_REQUEST['Itemid'] = $Itemid;
+ $_GET['limit'] = $limit;
+ $_REQUEST['limit'] = $limit;
+ $_GET['limitstart'] = $limitstart;
+ $_REQUEST['limitstart'] = $limitstart;
+ $_GET['year'] = $year;
+ $_REQUEST['year'] = $year;
+ $_GET['month'] = $month;
+ $_REQUEST['month'] = $month;
+
+ $QUERY_STRING = "option=com_content&task=$task&id=$id&Itemid=$Itemid&limit=$limit&limitstart=$limitstart&year=$year&month=$month";
+ }
+ else if (isset ($url_array[$pos +7]) && $url_array[$pos +7] != '' && in_array('category', $url_array) && (strpos($url_array[$pos +5], 'order,') !== false))
+ {
+ // $option/$task/$sectionid/$id/$Itemid/$order/$limit/$limitstart
+ $task = $url_array[$pos +1];
+ $sectionid = $url_array[$pos +2];
+ $id = $url_array[$pos +3];
+ $Itemid = $url_array[$pos +4];
+ $order = str_replace('order,', '', $url_array[$pos +5]);
+ $limit = $url_array[$pos +6];
+ $limitstart = $url_array[$pos +7];
+
+ // pass data onto global variables
+ $_GET['task'] = $task;
+ $_REQUEST['task'] = $task;
+ $_GET['sectionid'] = $sectionid;
+ $_REQUEST['sectionid'] = $sectionid;
+ $_GET['id'] = $id;
+ $_REQUEST['id'] = $id;
+ $_GET['Itemid'] = $Itemid;
+ $_REQUEST['Itemid'] = $Itemid;
+ $_GET['order'] = $order;
+ $_REQUEST['order'] = $order;
+ $_GET['limit'] = $limit;
+ $_REQUEST['limit'] = $limit;
+ $_GET['limitstart'] = $limitstart;
+ $_REQUEST['limitstart'] = $limitstart;
+
+ $QUERY_STRING = "option=com_content&task=$task§ionid=$sectionid&id=$id&Itemid=$Itemid&order=$order&limit=$limit&limitstart=$limitstart";
+ }
+ else if (isset ($url_array[$pos +6]) && $url_array[$pos +6] != '')
+ {
+ // $option/$task/$sectionid/$id/$Itemid/$limit/$limitstart
+ $task = $url_array[$pos +1];
+ $sectionid = $url_array[$pos +2];
+ $id = $url_array[$pos +3];
+ $Itemid = $url_array[$pos +4];
+ $limit = $url_array[$pos +5];
+ $limitstart = $url_array[$pos +6];
+
+ // pass data onto global variables
+ $_GET['task'] = $task;
+ $_REQUEST['task'] = $task;
+ $_GET['sectionid'] = $sectionid;
+ $_REQUEST['sectionid'] = $sectionid;
+ $_GET['id'] = $id;
+ $_REQUEST['id'] = $id;
+ $_GET['Itemid'] = $Itemid;
+ $_REQUEST['Itemid'] = $Itemid;
+ $_GET['limit'] = $limit;
+ $_REQUEST['limit'] = $limit;
+ $_GET['limitstart'] = $limitstart;
+ $_REQUEST['limitstart'] = $limitstart;
+
+ $QUERY_STRING = "option=com_content&task=$task§ionid=$sectionid&id=$id&Itemid=$Itemid&limit=$limit&limitstart=$limitstart";
+ }
+ else if (isset ($url_array[$pos +5]) && $url_array[$pos +5] != '')
+ {
+ // $option/$task/$id/$Itemid/$limit/$limitstart
+ $task = $url_array[$pos +1];
+ $id = $url_array[$pos +2];
+ $Itemid = $url_array[$pos +3];
+ $limit = $url_array[$pos +4];
+ $limitstart = $url_array[$pos +5];
+
+ // pass data onto global variables
+ $_GET['task'] = $task;
+ $_REQUEST['task'] = $task;
+ $_GET['id'] = $id;
+ $_REQUEST['id'] = $id;
+ $_GET['Itemid'] = $Itemid;
+ $_REQUEST['Itemid'] = $Itemid;
+ $_GET['limit'] = $limit;
+ $_REQUEST['limit'] = $limit;
+ $_GET['limitstart'] = $limitstart;
+ $_REQUEST['limitstart'] = $limitstart;
+
+ $QUERY_STRING = "option=com_content&task=$task&id=$id&Itemid=$Itemid&limit=$limit&limitstart=$limitstart";
+ }
+ else if (isset ($url_array[$pos +4]) && $url_array[$pos +4] != '' && (in_array('archivecategory', $url_array) || in_array('archivesection', $url_array)))
+ {
+ // $option/$task/$year/$month/$module
+ $task = $url_array[$pos +1];
+ $year = $url_array[$pos +2];
+ $month = $url_array[$pos +3];
+ $module = $url_array[$pos +4];
+
+ // pass data onto global variables
+ $_GET['task'] = $task;
+ $_REQUEST['task'] = $task;
+ $_GET['year'] = $year;
+ $_REQUEST['year'] = $year;
+ $_GET['month'] = $month;
+ $_REQUEST['month'] = $month;
+ $_GET['module'] = $module;
+ $_REQUEST['module'] = $module;
+
+ $QUERY_STRING = "option=com_content&task=$task&year=$year&month=$month&module=$module";
+ }
+ else if (!(isset ($url_array[$pos +5]) && $url_array[$pos +5] != '') && isset ($url_array[$pos +4]) && $url_array[$pos +4] != '')
+ {
+ // $option/$task/$sectionid/$id/$Itemid
+ $task = $url_array[$pos +1];
+ $sectionid = $url_array[$pos +2];
+ $id = $url_array[$pos +3];
+ $Itemid = $url_array[$pos +4];
+
+ // pass data onto global variables
+ $_GET['task'] = $task;
+ $_REQUEST['task'] = $task;
+ $_GET['sectionid'] = $sectionid;
+ $_REQUEST['sectionid'] = $sectionid;
+ $_GET['id'] = $id;
+ $_REQUEST['id'] = $id;
+ $_GET['Itemid'] = $Itemid;
+ $_REQUEST['Itemid'] = $Itemid;
+
+ $QUERY_STRING = "option=com_content&task=$task§ionid=$sectionid&id=$id&Itemid=$Itemid";
+ }
+ else if (!(isset ($url_array[$pos +4]) && $url_array[$pos +4] != '') && (isset ($url_array[$pos +3]) && $url_array[$pos +3] != ''))
+ {
+ // $option/$task/$id/$Itemid
+ $task = $url_array[$pos +1];
+ $id = $url_array[$pos +2];
+ $Itemid = $url_array[$pos +3];
+
+ // pass data onto global variables
+ $_GET['task'] = $task;
+ $_REQUEST['task'] = $task;
+ $_GET['id'] = $id;
+ $_REQUEST['id'] = $id;
+ $_GET['Itemid'] = $Itemid;
+ $_REQUEST['Itemid'] = $Itemid;
+
+ $QUERY_STRING = "option=com_content&task=$task&id=$id&Itemid=$Itemid";
+ }
+ else if (!(isset ($url_array[$pos +3]) && $url_array[$pos +3] != '') && (isset ($url_array[$pos +2]) && $url_array[$pos +2] != ''))
+ {
+ // $option/$task/$id
+ $task = $url_array[$pos +1];
+ $id = $url_array[$pos +2];
+
+ // pass data onto global variables
+ $_GET['task'] = $task;
+ $_REQUEST['task'] = $task;
+ $_GET['id'] = $id;
+ $_REQUEST['id'] = $id;
+
+ $QUERY_STRING = "option=com_content&task=$task&id=$id";
+ }
+ else if (!(isset ($url_array[$pos +2]) && $url_array[$pos +2] != '') && (isset ($url_array[$pos +1]) && $url_array[$pos +1] != ''))
+ {
+ // $option/$task
+ $task = $url_array[$pos +1];
+
+ $_GET['task'] = $task;
+ $_REQUEST['task'] = $task;
+
+ $QUERY_STRING = 'option=com_content&task=' . $task;
+ }
+
+ if ($lang != '') {
+ $QUERY_STRING .= '&lang=' . $lang;
+ }
+
+ $_SERVER['QUERY_STRING'] = $QUERY_STRING;
+ $REQUEST_URI = $uri[0] . 'index.php?' . $QUERY_STRING;
+ $_SERVER['REQUEST_URI'] = $REQUEST_URI;
+
+ }
+ else if (in_array('component', $url_array))
+ {
+ $name = 'component';
+ /*
+ Components
+ http://www.domain.com/component/$name,$value
+ */
+ $uri = explode('component/', $_SERVER['REQUEST_URI']);
+ $uri_array = explode('/', $uri[1]);
+ $QUERY_STRING = '';
+
+ // needed for check if component exists
+ $path = $mosConfig_absolute_path . '/components';
+ $dirlist = array ();
+ if (is_dir($path))
+ {
+ $base = opendir($path);
+ while (false !== ($dir = readdir($base)))
+ {
+ if ($dir !== '.' && $dir !== '..' && is_dir($path . '/' . $dir) && strtolower($dir) !== 'cvs' && strtolower($dir) !== '.svn') {
+ $dirlist[] = $dir;
+ }
+ }
+ closedir($base);
+ }
+
+ foreach ($uri_array as $value)
+ {
+ $temp = explode(',', $value);
+ if (isset ($temp[0]) && $temp[0] != '' && isset ($temp[1]) && $temp[1] != '')
+ {
+ $_GET[$temp[0]] = $temp[1];
+ $_REQUEST[$temp[0]] = $temp[1];
+
+ // check to ensure component actually exists
+ if ($temp[0] == 'option')
+ {
+ $check = '';
+ if (count($dirlist)) {
+ foreach ($dirlist as $dir) {
+ if ($temp[1] == $dir) {
+ $check = 1;
+ break;
+ }
+ }
+ }
+ // redirect to 404 page if no component found to match url
+ if (!$check)
+ {
+ header('HTTP/1.0 404 Not Found');
+ require_once ($mosConfig_absolute_path . '/templates/404.php');
+ exit (404);
+ }
+ }
+
+ if ($QUERY_STRING == '') {
+ $QUERY_STRING .= "$temp[0]=$temp[1]";
+ } else {
+ $QUERY_STRING .= "&$temp[0]=$temp[1]";
+ }
+ }
+ }
+
+ $_SERVER['QUERY_STRING'] = $QUERY_STRING;
+ $REQUEST_URI = $uri[0] . 'index.php?' . $QUERY_STRING;
+ $_SERVER['REQUEST_URI'] = $REQUEST_URI;
+
+ }
+ // let this go through and the rest of the system should handle it properly
+ }
+
+}
\ No newline at end of file
diff --git a/oss/joomla/trunk/plugins/system/backlink.xml b/oss/joomla/trunk/plugins/system/backlink.xml
new file mode 100644
index 00000000..5c0902db
--- /dev/null
+++ b/oss/joomla/trunk/plugins/system/backlink.xml
@@ -0,0 +1,29 @@
+
+
+ System - Backlinks
+ Joomla! Project
+ September 2007
+ Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
+ http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ admin@joomla.org
+ www.joomla.org
+ 1.5
+ Provides backlink support
+
+ backlink.php
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/oss/joomla/trunk/plugins/system/cache.php b/oss/joomla/trunk/plugins/system/cache.php
new file mode 100644
index 00000000..d74dc9d3
--- /dev/null
+++ b/oss/joomla/trunk/plugins/system/cache.php
@@ -0,0 +1,117 @@
+ JPATH_BASE.DS.'cache',
+ 'defaultgroup' => 'page',
+ 'lifetime' => $this->params->get('cachetime', 15) * 60,
+ 'browsercache' => $this->params->get('browsercache', false),
+ 'caching' => false,
+ 'language' => $config->getValue('config.language', 'en-GB')
+ );
+
+ jimport('joomla.cache.cache');
+ $this->_cache =& JCache::getInstance( 'page', $options );
+ }
+
+ /**
+ * Converting the site URL to fit to the HTTP request
+ *
+ */
+ function onAfterInitialise()
+ {
+ global $mainframe, $_PROFILER;
+ $user = &JFactory::getUser();
+
+ if($mainframe->isAdmin() || JDEBUG) {
+ return;
+ }
+
+ if (!$user->get('aid') && $_SERVER['REQUEST_METHOD'] == 'GET') {
+ $this->_cache->setCaching(true);
+ }
+
+ $data = $this->_cache->get();
+
+ if($data !== false)
+ {
+ // the following code searches for a token in the cached page and replaces it with the
+ // proper token.
+ $token = JUtility::getToken();
+ $search = '##';
+ $replacement = '';
+ $data = preg_replace( $search, $replacement, $data );
+
+ JResponse::setBody($data);
+
+ echo JResponse::toString($mainframe->getCfg('gzip'));
+
+ if(JDEBUG)
+ {
+ $_PROFILER->mark('afterCache');
+ echo implode( '', $_PROFILER->getBuffer());
+ }
+
+ $mainframe->close();
+ }
+ }
+
+ function onAfterRender()
+ {
+ global $mainframe;
+
+ if($mainframe->isAdmin() || JDEBUG) {
+ return;
+ }
+
+ $user =& JFactory::getUser();
+ if(!$user->get('aid')) {
+ //We need to check again here, because auto-login plugins have not been fired before the first aid check
+ $this->_cache->store();
+ }
+ }
+}
diff --git a/oss/joomla/trunk/plugins/system/cache.xml b/oss/joomla/trunk/plugins/system/cache.xml
new file mode 100644
index 00000000..d99732fd
--- /dev/null
+++ b/oss/joomla/trunk/plugins/system/cache.xml
@@ -0,0 +1,22 @@
+
+
+ System - Cache
+ Joomla! Project
+ February 2007
+ Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
+ http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ admin@joomla.org
+ www.joomla.org
+ 1.5
+ Provides page caching
+
+ cache.php
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/oss/joomla/trunk/plugins/system/debug.php b/oss/joomla/trunk/plugins/system/debug.php
new file mode 100644
index 00000000..9723e0da
--- /dev/null
+++ b/oss/joomla/trunk/plugins/system/debug.php
@@ -0,0 +1,207 @@
+loadLanguage( );
+ }
+
+ /**
+ * Converting the site URL to fit to the HTTP request
+ *
+ */
+ function onAfterRender()
+ {
+ global $_PROFILER, $mainframe, $database;
+
+ // Do not render if debugging is not enabled
+ if(!JDEBUG) { return; }
+
+ $document =& JFactory::getDocument();
+ $doctype = $document->getType();
+
+ // Only render for HTML output
+ if ( $doctype !== 'html' ) { return; }
+
+ $profiler =& $_PROFILER;
+
+ ob_start();
+ echo '';
+ if ($this->params->get('profile', 1)) {
+ echo '
'.JText::_( 'Profile Information' ).'
';
+ foreach ( $profiler->getBuffer() as $mark ) {
+ echo '
'.$mark.'
';
+ }
+ }
+
+ if ($this->params->get('memory', 1)) {
+ echo '
'.JText::_( 'Memory Usage' ).'
';
+ echo $profiler->getMemory();
+ }
+
+ if ($this->params->get('queries', 1))
+ {
+ jimport('geshi.geshi');
+
+ $geshi = new GeSHi( '', 'sql' );
+ $geshi->set_header_type(GESHI_HEADER_DIV);
+ //$geshi->enable_line_numbers( GESHI_FANCY_LINE_NONE );
+
+ $newlineKeywords = '/
'
+ .'(FROM|LEFT|INNER|OUTER|WHERE|SET|VALUES|ORDER|GROUP|HAVING|LIMIT|ON|AND)'
+ .'<\\/span>/i'
+ ;
+
+ $db =& JFactory::getDBO();
+
+ echo ''.JText::sprintf( 'Queries logged', $db->getTicker() ).'
';
+
+ if ($log = $db->getLog())
+ {
+ echo '';
+ foreach ($log as $k=>$sql)
+ {
+ $geshi->set_source($sql);
+ $text = $geshi->parse_code();
+ $text = preg_replace($newlineKeywords, '
\\0', $text);
+ echo '- '.$text.'
';
+ }
+ echo '
';
+ }
+
+ if(isset($database))
+ {
+ echo ''.JText::sprintf( 'Legacy Queries logged', $database->getTicker() ).'
';
+ echo '';
+
+ foreach ($database->getLog() as $k=>$sql)
+ {
+ $geshi->set_source($sql);
+ $text = $geshi->parse_code();
+ $text = preg_replace($newlineKeywords, '
\\0', $text);
+ echo '- '.$text.'
';
+ }
+
+ echo '
';
+ }
+ }
+
+ $lang = &JFactory::getLanguage();
+ if ($this->params->get('language_files', 1))
+ {
+ echo ''.JText::_( 'Language Files Loaded' ).'
';
+ echo '';
+ $extensions = $lang->getPaths();
+ foreach ( $extensions as $extension => $files)
+ {
+ foreach ( $files as $file => $status )
+ {
+ echo "- $file $status
";
+ }
+ }
+ echo '
';
+ }
+
+ $langStrings = $this->params->get('language_strings', -1);
+ if ($langStrings < 0 OR $langStrings == 1) {
+ echo ''.JText::_( 'Untranslated Strings Diagnostic' ).'
';
+ echo '';
+ $orphans = $lang->getOrphans();
+ if (count( $orphans ))
+ {
+ ksort( $orphans, SORT_STRING );
+ foreach ($orphans as $key => $occurance) {
+ foreach ( $occurance as $i => $info) {
+ $class = @$info['class'];
+ $func = @$info['function'];
+ $file = @$info['file'];
+ $line = @$info['line'];
+ echo strtoupper( $key )."\t$class::$func()\t[$file:$line]\n";
+ }
+ }
+ }
+ else {
+ echo JText::_( 'None' );
+ }
+ echo '';
+ }
+ if ($langStrings < 0 OR $langStrings == 2) {
+ echo ''.JText::_( 'Untranslated Strings Designer' ).'
';
+ echo '';
+ $orphans = $lang->getOrphans();
+ if (count( $orphans ))
+ {
+ ksort( $orphans, SORT_STRING );
+ $guesses = array();
+ foreach ($orphans as $key => $occurance) {
+ if (is_array( $occurance ) AND isset( $occurance[0] )) {
+ $info = &$occurance[0];
+ $file = @$info['file'];
+ if (!isset( $guesses[$file] )) {
+ $guesses[$file] = array();
+ }
+
+ $guess = str_replace( '_', ' ', $info['string'] );
+ if ($strip = $this->params->get('language_prefix')) {
+ $guess = trim( preg_replace( chr(1).'^'.$strip.chr(1), '', $guess ) );
+ }
+ $guesses[$file][] = trim( strtoupper( $key ) ).'='.$guess;
+ }
+ }
+ foreach ($guesses as $file => $keys) {
+ echo "\n\n# ".($file ? $file : JText::_( 'Unknown file' ))."\n\n";
+ echo implode( "\n", $keys );
+ }
+ }
+ else {
+ echo JText::_( 'None' );
+ }
+ echo '';
+ }
+ echo ' ';
+
+ $debug = ob_get_clean();
+
+ $body = JResponse::getBody();
+ $body = str_replace('