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 '
  1. '.$text.'
  2. '; + } + 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 '
  1. '.$text.'
  2. '; + } + + echo '
'; + } + } + + $lang = &JFactory::getLanguage(); + if ($this->params->get('language_files', 1)) + { + echo '

'.JText::_( 'Language Files Loaded' ).'

'; + 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('', $debug.'', $body); + JResponse::setBody($body); + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/plugins/system/debug.xml b/oss/joomla/trunk/plugins/system/debug.xml new file mode 100644 index 00000000..789f0357 --- /dev/null +++ b/oss/joomla/trunk/plugins/system/debug.xml @@ -0,0 +1,40 @@ + + + System - Debug + Joomla! Project + December 2006 + 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 debug information + + debug.php + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/oss/joomla/trunk/plugins/system/index.html b/oss/joomla/trunk/plugins/system/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/plugins/system/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/plugins/system/legacy.php b/oss/joomla/trunk/plugins/system/legacy.php new file mode 100644 index 00000000..62f0567f --- /dev/null +++ b/oss/joomla/trunk/plugins/system/legacy.php @@ -0,0 +1,403 @@ +setValue('config.legacy', 1); + + // Import library dependencies + require_once(dirname(__FILE__).DS.'legacy'.DS.'classes.php'); + require_once(dirname(__FILE__).DS.'legacy'.DS.'functions.php'); + + // Register legacy classes for autoloading + JLoader::register('mosAdminMenus' , dirname(__FILE__).DS.'legacy'.DS.'adminmenus.php'); + JLoader::register('mosCache' , dirname(__FILE__).DS.'legacy'.DS.'cache.php'); + JLoader::register('mosCategory' , dirname(__FILE__).DS.'legacy'.DS.'category.php'); + JLoader::register('mosCommonHTML' , dirname(__FILE__).DS.'legacy'.DS.'commonhtml.php'); + JLoader::register('mosComponent' , dirname(__FILE__).DS.'legacy'.DS.'component.php'); + JLoader::register('mosContent' , dirname(__FILE__).DS.'legacy'.DS.'content.php'); + JLoader::register('mosDBTable' , dirname(__FILE__).DS.'legacy'.DS.'dbtable.php'); + JLoader::register('mosHTML' , dirname(__FILE__).DS.'legacy'.DS.'html.php'); + JLoader::register('mosInstaller' , dirname(__FILE__).DS.'legacy'.DS.'installer.php'); + JLoader::register('mosMainFrame' , dirname(__FILE__).DS.'legacy'.DS.'mainframe.php'); + JLoader::register('mosMambot' , dirname(__FILE__).DS.'legacy'.DS.'mambot.php'); + JLoader::register('mosMambotHandler', dirname(__FILE__).DS.'legacy'.DS.'mambothandler.php'); + JLoader::register('mosMenu' , dirname(__FILE__).DS.'legacy'.DS.'menu.php'); + JLoader::register('mosMenuBar' , dirname(__FILE__).DS.'legacy'.DS.'menubar.php'); + JLoader::register('mosModule' , dirname(__FILE__).DS.'legacy'.DS.'module.php'); + //JLoader::register('mosPageNav' , dirname(__FILE__).DS.'legacy'.DS.'pagination.php'); + JLoader::register('mosParameters' , dirname(__FILE__).DS.'legacy'.DS.'parameters.php'); + JLoader::register('patFactory' , dirname(__FILE__).DS.'legacy'.DS.'patfactory.php'); + JLoader::register('mosProfiler' , dirname(__FILE__).DS.'legacy'.DS.'profiler.php'); + JLoader::register('mosSection' , dirname(__FILE__).DS.'legacy'.DS.'section.php'); + JLoader::register('mosSession' , dirname(__FILE__).DS.'legacy'.DS.'session.php'); + JLoader::register('mosToolbar' , dirname(__FILE__).DS.'legacy'.DS.'toolbar.php'); + JLoader::register('mosUser' , dirname(__FILE__).DS.'legacy'.DS.'user.php'); + + // Register class for the database, depends on which db type has been selected for use + $dbtype = $config->getValue('config.dbtype', 'mysql'); + JLoader::register('database' , dirname(__FILE__).DS.'legacy'.DS.$dbtype.'.php'); + + /** + * Legacy define, _ISO define not used anymore. All output is forced as utf-8. + * @deprecated As of version 1.5 + */ + define('_ISO','charset=utf-8'); + + /** + * Legacy constant, use _JEXEC instead + * @deprecated As of version 1.5 + */ + define( '_VALID_MOS', 1 ); + + /** + * Legacy constant, use _JEXEC instead + * @deprecated As of version 1.5 + */ + define( '_MOS_MAMBO_INCLUDED', 1 ); + + /** + * Legacy constant, use DATE_FORMAT_LC instead + * @deprecated As of version 1.5 + */ + DEFINE('_DATE_FORMAT_LC', JText::_('DATE_FORMAT_LC1') ); //Uses PHP's strftime Command Format + + /** + * Legacy constant, use DATE_FORMAT_LC2 instead + * @deprecated As of version 1.5 + */ + DEFINE('_DATE_FORMAT_LC2', JText::_('DATE_FORMAT_LC2')); + + /** + * Legacy constant, use JFilterInput instead + * @deprecated As of version 1.5 + */ + DEFINE( "_MOS_NOTRIM", 0x0001 ); + + /** + * Legacy constant, use JFilterInput instead + * @deprecated As of version 1.5 + */ + DEFINE( "_MOS_ALLOWHTML", 0x0002 ); + + /** + * Legacy constant, use JFilterInput instead + * @deprecated As of version 1.5 + */ + DEFINE( "_MOS_ALLOWRAW", 0x0004 ); + + /** + * Legacy global, use JVersion->getLongVersion() instead + * @name $_VERSION + * @deprecated As of version 1.5 + */ + $GLOBALS['_VERSION'] = new JVersion(); + $version = $GLOBALS['_VERSION']->getLongVersion(); + + /** + * Legacy global, use JFactory::getDBO() instead + * @name $database + * @deprecated As of version 1.5 + */ + $conf =& JFactory::getConfig(); + $GLOBALS['database'] = new database($conf->getValue('config.host'), $conf->getValue('config.user'), $conf->getValue('config.password'), $conf->getValue('config.db'), $conf->getValue('config.dbprefix')); + $GLOBALS['database']->debug($conf->getValue('config.debug')); + + /** + * Legacy global, use JFactory::getUser() [JUser object] instead + * @name $my + * @deprecated As of version 1.5 + */ + $user =& JFactory::getUser(); + + $GLOBALS['my'] = (object)$user->getProperties(); + $GLOBALS['my']->gid = $user->get('aid', 0); + + /** + * Insert configuration values into global scope (for backwards compatibility) + * @deprecated As of version 1.5 + */ + + $temp = new JConfig; + foreach (get_object_vars($temp) as $k => $v) { + $name = 'mosConfig_'.$k; + $GLOBALS[$name] = $v; + } + + $GLOBALS['mosConfig_live_site'] = substr_replace(JURI::root(), '', -1, 1); + $GLOBALS['mosConfig_absolute_path'] = JPATH_SITE; + $GLOBALS['mosConfig_cachepath'] = JPATH_BASE.DS.'cache'; + + $GLOBALS['mosConfig_offset_user'] = 0; + + $lang =& JFactory::getLanguage(); + $GLOBALS['mosConfig_lang'] = $lang->getBackwardLang(); + + $config->setValue('config.live_site', $GLOBALS['mosConfig_live_site']); + $config->setValue('config.absolute_path', $GLOBALS['mosConfig_absolute_path']); + $config->setValue('config.lang', $GLOBALS['mosConfig_lang']); + + /** + * Legacy global, use JFactory::getUser() instead + * @name $acl + * @deprecated As of version 1.5 + */ + $acl =& JFactory::getACL(); + + // Legacy ACL's for backward compat + $acl->addACL( 'administration', 'edit', 'users', 'super administrator', 'components', 'all' ); + $acl->addACL( 'administration', 'edit', 'users', 'administrator', 'components', 'all' ); + $acl->addACL( 'administration', 'edit', 'users', 'super administrator', 'user properties', 'block_user' ); + $acl->addACL( 'administration', 'manage', 'users', 'super administrator', 'components', 'com_users' ); + $acl->addACL( 'administration', 'manage', 'users', 'administrator', 'components', 'com_users' ); + $acl->addACL( 'administration', 'config', 'users', 'super administrator' ); + //$acl->addACL( 'administration', 'config', 'users', 'administrator' ); + + $acl->addACL( 'action', 'add', 'users', 'author', 'content', 'all' ); + $acl->addACL( 'action', 'add', 'users', 'editor', 'content', 'all' ); + $acl->addACL( 'action', 'add', 'users', 'publisher', 'content', 'all' ); + $acl->addACL( 'action', 'edit', 'users', 'author', 'content', 'own' ); + $acl->addACL( 'action', 'edit', 'users', 'editor', 'content', 'all' ); + $acl->addACL( 'action', 'edit', 'users', 'publisher', 'content', 'all' ); + $acl->addACL( 'action', 'publish', 'users', 'publisher', 'content', 'all' ); + + $acl->addACL( 'action', 'add', 'users', 'manager', 'content', 'all' ); + $acl->addACL( 'action', 'edit', 'users', 'manager', 'content', 'all' ); + $acl->addACL( 'action', 'publish', 'users', 'manager', 'content', 'all' ); + + $acl->addACL( 'action', 'add', 'users', 'administrator', 'content', 'all' ); + $acl->addACL( 'action', 'edit', 'users', 'administrator', 'content', 'all' ); + $acl->addACL( 'action', 'publish', 'users', 'administrator', 'content', 'all' ); + + $acl->addACL( 'action', 'add', 'users', 'super administrator', 'content', 'all' ); + $acl->addACL( 'action', 'edit', 'users', 'super administrator', 'content', 'all' ); + $acl->addACL( 'action', 'publish', 'users', 'super administrator', 'content', 'all' ); + + $acl->addACL( 'com_syndicate', 'manage', 'users', 'super administrator' ); + $acl->addACL( 'com_syndicate', 'manage', 'users', 'administrator' ); + $acl->addACL( 'com_syndicate', 'manage', 'users', 'manager' ); + + $GLOBALS['acl'] =& $acl; + + /** + * Legacy global + * @name $task + * @deprecated As of version 1.5 + */ + $GLOBALS['task'] = JRequest::getString('task'); + + /** + * Load the site language file (the old way - to be deprecated) + * @deprecated As of version 1.5 + */ + global $mosConfig_lang; + $mosConfig_lang = JFilterInput::clean($mosConfig_lang, 'cmd'); + $file = JPATH_SITE.DS.'language'.DS.$mosConfig_lang.'.php'; + if (file_exists( $file )) { + require_once( $file); + } else { + $file = JPATH_SITE.DS.'language'.DS.'english.php'; + if (file_exists( $file )) { + require_once( $file ); + } + } + + /** + * Legacy global + * use JApplicaiton->registerEvent and JApplication->triggerEvent for event handling + * use JPlugingHelper::importPlugin to load bot code + * @deprecated As of version 1.5 + */ + $GLOBALS['_MAMBOTS'] = new mosMambotHandler(); + + $mosmsg = JRequest::getVar( 'mosmsg' ); + $mainframe->enqueueMessage( $mosmsg ); + } + + /** + * Fixes the $my global if the user was restored by the remember me plugin + */ + function onAfterInitialise() + { + $user =& JFactory::getUser(); + if ($user->id) { + if ($GLOBALS['my']->id === 0) { + $GLOBALS['my'] = (object)$user->getProperties(); + $GLOBALS['my']->gid = $user->get('aid', 0); + } + } + + return true; + } + + + + function onAfterRoute() + { + global $mainframe; + if ($mainframe->isAdmin()) { + return; + } + + switch(JRequest::getCmd('option')) + { + case 'com_content' : + $this->routeContent(); + break; + case 'com_newsfeeds' : + $this->routeNewsfeeds(); + break; + case 'com_weblinks' : + $this->routeWeblinks(); + break; + case 'com_frontpage' : + JRequest::setVar('option', 'com_content'); + JRequest::setVar('view', 'frontpage'); + break; + case 'com_login' : + JRequest::setVar('option', 'com_user'); + JRequest::setVar('view', 'login'); + break; + case 'com_registration' : + JRequest::setVar('option', 'com_user'); + JRequest::setVar('view', 'register'); + break; + } + + /** + * Legacy global, use JApplication::getTemplate() instead + * @name $cur_template + * @deprecated As of version 1.5 + */ + $GLOBALS['cur_template'] = $mainframe->getTemplate(); + } + + function routeContent() + { + $viewName = JRequest::getCmd( 'view', 'article' ); + $layout = JRequest::getCmd( 'layout', 'default' ); + + // interceptors to support legacy urls + switch( JRequest::getCmd('task')) + { + //index.php?option=com_content&task=x&id=x&Itemid=x + case 'blogsection': + $viewName = 'section'; + $layout = 'blog'; + break; + case 'section': + $viewName = 'section'; + break; + case 'category': + $viewName = 'category'; + break; + case 'blogcategory': + $viewName = 'category'; + $layout = 'blog'; + break; + case 'archivesection': + case 'archivecategory': + $viewName = 'archive'; + break; + case 'frontpage' : + $viewName = 'frontpage'; + break; + case 'view': + $viewName = 'article'; + break; + } + + JRequest::setVar('layout', $layout); + JRequest::setVar('view', $viewName); + } + + function routeNewsfeeds() + { + $viewName = JRequest::getCmd( 'view', 'categories' ); + + // interceptors to support legacy urls + switch( JRequest::getCmd('task')) + { + //index.php?option=com_newsfeeds&task=x&catid=xid=x&Itemid=x + case 'view': + $viewName = 'newsfeed'; + break; + + default: + { + if(JRequest::getInt('catid') && !JRequest::getCmd('view')) { + $viewName = 'category'; + } + } + } + + JRequest::setVar('view', $viewName); + } + + function routeWeblinks() + { + $viewName = JRequest::getCmd( 'view', 'categories' ); + + // interceptors to support legacy urls + switch( JRequest::getCmd('task')) + { + //index.php?option=com_weblinks&task=x&catid=xid=x + case 'view': + $viewName = 'weblink'; + break; + + default: + { + if(($catid = JRequest::getInt('catid')) && !JRequest::getCmd('view')) { + $viewName = 'category'; + JRequest::setVar('id', $catid); + } + } + } + + JRequest::setVar('view', $viewName); + } +} diff --git a/oss/joomla/trunk/plugins/system/legacy.xml b/oss/joomla/trunk/plugins/system/legacy.xml new file mode 100644 index 00000000..39741db1 --- /dev/null +++ b/oss/joomla/trunk/plugins/system/legacy.xml @@ -0,0 +1,25 @@ + + + System - Legacy + Joomla! Project + January 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 legacy support for older version of Joomla! + + legacy.php + legacy/classes.php + legacy/functions.php + legacy/toolbar.php + legacy/index.html + + + + + + + + diff --git a/oss/joomla/trunk/plugins/system/legacy/adminmenus.php b/oss/joomla/trunk/plugins/system/legacy/adminmenus.php new file mode 100644 index 00000000..9183bf16 --- /dev/null +++ b/oss/joomla/trunk/plugins/system/legacy/adminmenus.php @@ -0,0 +1,416 @@ +published ); + return $published; + } + + /** + * Legacy function, use {@link JAdminMenus::MenuLinks()} instead + * + * @deprecated As of version 1.5 + */ + function MenuLinks( &$lookup, $all=NULL, $none=NULL, $unassigned=1 ) + { + $options = JHTML::_('menu.linkoptions', $lookup, $all, $none|$unassigned); + if (empty( $lookup )) { + $lookup = array( JHTML::_('select.option', -1 ) ); + } + $pages = JHTML::_('select.genericlist', $options, 'selections[]', 'class="inputbox" size="15" multiple="multiple"', 'value', 'text', $lookup, 'selections' ); + return $pages; + } + + /** + * Legacy function, deprecated + * + * @deprecated As of version 1.5 + */ + function Category( &$menu, $id, $javascript='' ) + { + $db =& JFactory::getDBO(); + + $query = 'SELECT c.id AS `value`, c.section AS `id`, CONCAT_WS( " / ", s.title, c.title) AS `text`' + . ' FROM #__sections AS s' + . ' INNER JOIN #__categories AS c ON c.section = s.id' + . ' WHERE s.scope = "content"' + . ' ORDER BY s.name, c.name' + ; + $db->setQuery( $query ); + $rows = $db->loadObjectList(); + $category = ''; + + $category .= JHTML::_('select.genericlist', $rows, 'componentid', 'class="inputbox" size="10"'. $javascript, 'value', 'text', $menu->componentid ); + $category .= ''; + + return $category; + } + + /** + * Legacy function, deprecated + * + * @deprecated As of version 1.5 + */ + function Section( &$menu, $id, $all=0 ) + { + $db =& JFactory::getDBO(); + + $query = 'SELECT s.id AS `value`, s.id AS `id`, s.title AS `text`' + . ' FROM #__sections AS s' + . ' WHERE s.scope = "content"' + . ' ORDER BY s.name' + ; + $db->setQuery( $query ); + if ( $all ) { + $rows[] = JHTML::_('select.option', 0, '- '. JText::_( 'All Sections' ) .' -' ); + $rows = array_merge( $rows, $db->loadObjectList() ); + } else { + $rows = $db->loadObjectList(); + } + + $section = JHTML::_('select.genericlist', $rows, 'componentid', 'class="inputbox" size="10"', 'value', 'text', $menu->componentid ); + $section .= ''; + + return $section; + } + + /** + * Legacy function, deprecated + * + * @deprecated As of version 1.5 + */ + function Component( &$menu, $id ) + { + $db =& JFactory::getDBO(); + + $query = 'SELECT c.id AS value, c.name AS text, c.link' + . ' FROM #__components AS c' + . ' WHERE c.link <> ""' + . ' ORDER BY c.name' + ; + $db->setQuery( $query ); + $rows = $db->loadObjectList( ); + + $component = JHTML::_('select.genericlist', $rows, 'componentid', 'class="inputbox" size="10"', 'value', 'text', $menu->componentid, '', 1 ); + + return $component; + } + + + /** + * Legacy function, deprecated + * + * @deprecated As of version 1.5 + */ + function ComponentName( &$menu, $id ) + { + $db =& JFactory::getDBO(); + + $query = 'SELECT c.id AS value, c.name AS text, c.link' + . ' FROM #__components AS c' + . ' WHERE c.link <> ""' + . ' ORDER BY c.name' + ; + $db->setQuery( $query ); + $rows = $db->loadObjectList( ); + + $component = 'Component'; + foreach ( $rows as $row ) { + if ( $row->value == $menu->componentid ) { + $component = JText::_( $row->text ); + } + } + + return $component; + } + + + /** + * Legacy function, use {@link JHTML::_('list.images', )} instead + * + * @deprecated As of version 1.5 + */ + function Images( $name, &$active, $javascript=NULL, $directory=NULL ) + { + return JHTML::_('list.images', $name, $active, $javascript, $directory); + } + + /** + * Legacy function, use {@link JHTML::_('list.specificordering', )} instead + * + * @deprecated As of version 1.5 + */ + function SpecificOrdering( &$row, $id, $query, $neworder=0 ) + { + return JHTML::_('list.specificordering', $row, $id, $query, $neworder); + } + + /** + * Legacy function, use {@link JHTML::_('list.users', )} instead + * + * @deprecated As of version 1.5 + */ + function UserSelect( $name, $active, $nouser=0, $javascript=NULL, $order='name', $reg=1 ) + { + return JHTML::_('list.users', $name, $active, $nouser, $javascript, $order, $reg); + } + + /** + * Legacy function, use {@link JHTML::_('list.positions', )} instead + * + * @deprecated As of version 1.5 + */ + function Positions( $name, $active=NULL, $javascript=NULL, $none=1, $center=1, $left=1, $right=1, $id=false ) + { + return JHTML::_('list.positions', $name, $active, $javascript, $none, $center, $left, $right, $id); + } + + /** + * Legacy function, use {@link JHTML::_('list.category', )} instead + * + * @deprecated As of version 1.5 + */ + function ComponentCategory( $name, $section, $active=NULL, $javascript=NULL, $order='ordering', $size=1, $sel_cat=1 ) + { + return JHTML::_('list.category', $name, $section, $active, $javascript, $order, $size, $sel_cat); + } + + /** + * Legacy function, use {@link JHTML::_('list.section', )} instead + * + * @deprecated As of version 1.5 + */ + function SelectSection( $name, $active=NULL, $javascript=NULL, $order='ordering' ) + { + return JHTML::_('list.section', $name, $active, $javascript, $order); + } + + /** + * Legacy function, deprecated + * + * @deprecated As of version 1.5 + */ + function Links2Menu( $type, $and ) + { + $db =& JFactory::getDBO(); + + $query = 'SELECT * ' + . ' FROM #__menu ' + . ' WHERE type = '.$db->Quote($type) + . ' AND published = 1' + . $and + ; + $db->setQuery( $query ); + $menus = $db->loadObjectList(); + + return $menus; + } + + /** + * Legacy function, deprecated + * + * @deprecated As of version 1.5 + */ + function MenuSelect( $name='menuselect', $javascript=NULL ) + { + $db =& JFactory::getDBO(); + + $query = 'SELECT params' + . ' FROM #__modules' + . ' WHERE module = "mod_mainmenu"' + ; + $db->setQuery( $query ); + $menus = $db->loadObjectList(); + $total = count( $menus ); + $menuselect = array(); + for( $i = 0; $i < $total; $i++ ) + { + $registry = new JRegistry(); + $registry->loadINI($menus[$i]->params); + $params = $registry->toObject( ); + + $menuselect[$i]->value = $params->menutype; + $menuselect[$i]->text = $params->menutype; + } + // sort array of objects + JArrayHelper::sortObjects( $menuselect, 'text', 1 ); + + $menus = JHTML::_('select.genericlist', $menuselect, $name, 'class="inputbox" size="10" '. $javascript, 'value', 'text' ); + + return $menus; + } + + /** + * Legacy function, deprecated + * + * @deprecated As of version 1.5 + */ + function ReadImages( $imagePath, $folderPath, &$folders, &$images ) + { + jimport( 'joomla.filesystem.folder' ); + $imgFiles = JFolder::files( $imagePath ); + + foreach ($imgFiles as $file) + { + $ff_ = $folderPath.DS.$file; + $ff = $folderPath.DS.$file; + $i_f = $imagePath .'/'. $file; + + if ( is_dir( $i_f ) && $file <> 'CVS' && $file <> '.svn') { + $folders[] = JHTML::_('select.option', $ff_ ); + mosAdminMenus::ReadImages( $i_f, $ff_, $folders, $images ); + } else if ( eregi( "bmp|gif|jpg|png", $file ) && is_file( $i_f ) ) { + // leading / we don't need + $imageFile = substr( $ff, 1 ); + $images[$folderPath][] = JHTML::_('select.option', $imageFile, $file ); + } + } + } + + /** + * Legacy function, deprecated + * + * @deprecated As of version 1.5 + */ + function GetImageFolders( &$folders, $path ) + { + $javascript = "onchange=\"changeDynaList( 'imagefiles', folderimages, document.adminForm.folders.options[document.adminForm.folders.selectedIndex].value, 0, 0); previewImage( 'imagefiles', 'view_imagefiles', '$path/' );\""; + $getfolders = JHTML::_('select.genericlist', $folders, 'folders', 'class="inputbox" size="1" '. $javascript, 'value', 'text', '/' ); + return $getfolders; + } + + /** + * Legacy function, deprecated + * + * @deprecated As of version 1.5 + */ + function GetImages( &$images, $path ) + { + if ( !isset($images['/'] ) ) { + $images['/'][] = JHTML::_('select.option', '' ); + } + + //$javascript = "onchange=\"previewImage( 'imagefiles', 'view_imagefiles', '$path/' )\" onfocus=\"previewImage( 'imagefiles', 'view_imagefiles', '$path/' )\""; + $javascript = "onchange=\"previewImage( 'imagefiles', 'view_imagefiles', '$path/' )\""; + $getimages = JHTML::_('select.genericlist', $images['/'], 'imagefiles', 'class="inputbox" size="10" multiple="multiple" '. $javascript , 'value', 'text', null ); + + return $getimages; + } + + /** + * Legacy function, deprecated + * + * @deprecated As of version 1.5 + */ + function GetSavedImages( &$row, $path ) + { + $images2 = array(); + foreach( $row->images as $file ) { + $temp = explode( '|', $file ); + if( strrchr($temp[0], '/') ) { + $filename = substr( strrchr($temp[0], '/' ), 1 ); + } else { + $filename = $temp[0]; + } + $images2[] = JHTML::_('select.option', $file, $filename ); + } + //$javascript = "onchange=\"previewImage( 'imagelist', 'view_imagelist', '$path/' ); showImageProps( '$path/' ); \" onfocus=\"previewImage( 'imagelist', 'view_imagelist', '$path/' )\""; + $javascript = "onchange=\"previewImage( 'imagelist', 'view_imagelist', '$path/' ); showImageProps( '$path/' ); \""; + $imagelist = JHTML::_('select.genericlist', $images2, 'imagelist', 'class="inputbox" size="10" '. $javascript, 'value', 'text' ); + + return $imagelist; + } + + /** + * Legacy function, use {@link JHTML::_('image.site')} instead + * + * @deprecated As of version 1.5 + */ + function ImageCheck( $file, $directory='/images/M_images/', $param=NULL, $param_directory='/images/M_images/', $alt=NULL, $name='image', $type=1, $align='top' ) + { + $attribs = array('align' => $align); + return JHTML::_('image.site', $file, $directory, $param, $param_directory, $alt, $attribs, $type); + } + + /** + * Legacy function, use {@link JHTML::_('image.administrator')} instead + * + * @deprecated As of version 1.5 + */ + function ImageCheckAdmin( $file, $directory='/images/', $param=NULL, $param_directory='/images/', $alt=NULL, $name=NULL, $type=1, $align='middle' ) + { + $attribs = array('align' => $align); + return JHTML::_('image.administrator', $file, $directory, $param, $param_directory, $alt, $attribs, $type); + } + + /** + * Legacy function, use {@link MenusHelper::getMenuTypes()} instead + * + * @deprecated As of version 1.5 + */ + function menutypes() + { + JError::raiseNotice( 0, 'mosAdminMenus::menutypes method deprecated' ); + } + + /** + * Legacy function, use {@link MenusHelper::menuItem()} instead + * + * @deprecated As of version 1.5 + */ + function menuItem( $item ) + { + JError::raiseNotice( 0, 'mosAdminMenus::menuItem method deprecated' ); + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/plugins/system/legacy/cache.php b/oss/joomla/trunk/plugins/system/legacy/cache.php new file mode 100644 index 00000000..d85fe94f --- /dev/null +++ b/oss/joomla/trunk/plugins/system/legacy/cache.php @@ -0,0 +1,42 @@ +clean($group); + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/plugins/system/legacy/category.php b/oss/joomla/trunk/plugins/system/legacy/category.php new file mode 100644 index 00000000..3bd5f261 --- /dev/null +++ b/oss/joomla/trunk/plugins/system/legacy/category.php @@ -0,0 +1,60 @@ +reorder( $where ); + } + + /** + * Legacy Method, use {@link JTable::publish()} instead + * @deprecated As of 1.0.3 + */ + function publish_array( $cid=null, $publish=1, $user_id=0 ) + { + $this->publish( $cid, $publish, $user_id ); + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/plugins/system/legacy/classes.php b/oss/joomla/trunk/plugins/system/legacy/classes.php new file mode 100644 index 00000000..4da9ecf7 --- /dev/null +++ b/oss/joomla/trunk/plugins/system/legacy/classes.php @@ -0,0 +1,106 @@ + $useCookies) ); + } + + function startTab( $tabText, $paneid ) { + echo $this->startPanel( $tabText, $paneid); + } + + function endTab() { + echo $this->endPanel(); + } + + function startPane( $tabText ){ + echo parent::startPane( $tabText ); + } + + function endPane(){ + echo parent::endPane(); + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/plugins/system/legacy/commonhtml.php b/oss/joomla/trunk/plugins/system/legacy/commonhtml.php new file mode 100644 index 00000000..e59909ec --- /dev/null +++ b/oss/joomla/trunk/plugins/system/legacy/commonhtml.php @@ -0,0 +1,270 @@ + + + +
+ + + + + + + + + menutype; ?> + + + + + + + + + + name; ?> + + + + + + + + + published ) { + case -2: + echo ''. JText::_( 'Trashed' ) .''; + break; + case 0: + echo JText::_( 'UnPublished' ); + break; + case 1: + default: + echo ''. JText::_( 'Published' ) .''; + break; + } + ?> + + + + + + + + + + +
+ . + + + + + + + + + + + + + + + + + + +
+ + + + menutype; ?> +
+ + + type; ?> +
+ + + + + name; ?> + +
+ + + published ) { + case -2: + echo ''. JText::_( 'Trashed' ) .''; + break; + case 0: + echo JText::_( 'UnPublished' ); + break; + case 1: + default: + echo ''. JText::_( 'Published' ) .''; + break; + } + ?> +
+
+ + + + reorder( $where ); + } + + /** + * Legacy Method, use {@link JTable::publish()} instead + * @deprecated As of 1.0.3 + */ + function publish_array( $cid=null, $publish=1, $user_id=0 ) + { + $this->publish( $cid, $publish, $user_id ); + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/plugins/system/legacy/content.php b/oss/joomla/trunk/plugins/system/legacy/content.php new file mode 100644 index 00000000..ddfb883e --- /dev/null +++ b/oss/joomla/trunk/plugins/system/legacy/content.php @@ -0,0 +1,60 @@ +reorder( $where ); + } + + /** + * Legacy Method, use {@link JTable::publish()} instead + * @deprecated As of 1.0.3 + */ + function publish_array( $cid=null, $publish=1, $user_id=0 ) + { + $this->publish( $cid, $publish, $user_id ); + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/plugins/system/legacy/dbtable.php b/oss/joomla/trunk/plugins/system/legacy/dbtable.php new file mode 100644 index 00000000..5035c9d4 --- /dev/null +++ b/oss/joomla/trunk/plugins/system/legacy/dbtable.php @@ -0,0 +1,131 @@ +reorder( $where ); + } + + /** + * Legacy Method, use {@link JTable::publish()} instead + * @deprecated As of 1.0.3 + */ + function publish_array( $cid=null, $publish=1, $user_id=0 ) + { + $this->publish( $cid, $publish, $user_id ); + } + + /** + * Legacy Method, make sure you use {@link JRequest::get()} or {@link JRequest::getVar()} instead + * @deprecated As of 1.5 + */ + function filter( $ignoreList=null ) + { + $ignore = is_array( $ignoreList ); + + $filter = & JFilterInput::getInstance(); + foreach ($this->getProperties() as $k => $v) + { + if ($ignore && in_array( $k, $ignoreList ) ) { + continue; + } + $this->$k = $filter->clean( $this->$k ); + } + } + + /** + * Legacy Method, use {@link JObject::getProperties()} instead + * @deprecated As of 1.5 + */ + function getPublicProperties() + { + $properties = $this->getProperties(); + return array_keys($properties); + } + + /** + * Legacy Method, use {@link JObject::getError()} instead + * @deprecated As of 1.5 + */ + function getError($i = null, $toString = true ) + { + return $this->_error; + } + + /** + * Legacy Method, use {@link JObject::setError()} instead + * @deprecated As of 1.5 + */ + function setErrorNum( $value ) + { + $this->_errorNum = $value; + } + + /** + * Legacy Method, use {@link JObject::getError()} instead + * @deprecated As of 1.5 + */ + function getErrorNum() + { + return $this->_errorNum; + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/plugins/system/legacy/functions.php b/oss/joomla/trunk/plugins/system/legacy/functions.php new file mode 100644 index 00000000..e288cb34 --- /dev/null +++ b/oss/joomla/trunk/plugins/system/legacy/functions.php @@ -0,0 +1,910 @@ + instead + * + * @deprecated As of version 1.5 + */ +function mosCountModules( $position='left' ) { + jimport('joomla.application.module.helper'); + return count(JModuleHelper::getModules($position)); +} + +/** + * Legacy function, use instead + * + * @deprecated As of version 1.5 + */ +function mosMainBody() { + ?> instead + * + * @deprecated As of version 1.5 + */ +function mosLoadModules( $position='left', $style=0 ) +{ + // Select the module chrome function + if (is_numeric($style)) + { + switch ( $style ) + { + case -3: + $style = 'rounded'; + break; + + case -2: + $style = 'xhtml'; + break; + + case -1: + $style = 'raw'; + break; + + case 0 : + default : + $style = 'table'; + break; + } + } + ?> instead + * + * @deprecated As of version 1.5 + */ +function mosLoadModule( $name, $style=-1 ) { + ?> instead + * + * @deprecated As of version 1.5 + */ +function mosShowHead() { + ?> instead + * + * @deprecated As of version 1.5 + */ +function mosCountAdminModules( $position='left' ) { + $document =& JFactory::getDocument(); + return count($document->getModules($position)); +} + +/** + * Legacy function, using instead + * + * @deprecated As of version 1.5 + */ +function mosMainBody_Admin() { + ?> instead + * + * @deprecated As of version 1.5 + */ + +function mosLoadAdminModules( $position='left', $style=0 ) { + + // Select the module chrome function + if (is_numeric($style)) + { + switch ( $style ) + { + case 2: + $style = 'xhtml'; + break; + + case 0 : + default : + $style = 'raw'; + break; + } + } + ?> instead + * + * @deprecated As of version 1.5 + */ +function mosLoadAdminModule( $name, $style=0 ) { + ?> instead + * + * @deprecated As of version 1.5 + */ +function mosShowHead_Admin() { + ?> $val) { + $ret[$key] = mosStripslashes( $val ); + } + } else { + $ret = $value; + } + } + return $ret; +} + +/** + * Legacy function, use {@link JArrayHelper JArrayHelper->toObject()} instead + * + * @deprecated As of version 1.5 + */ +function mosBindArrayToObject( $array, &$obj, $ignore='', $prefix=NULL, $checkSlashes=true ) +{ + if (!is_array( $array ) || !is_object( $obj )) { + return (false); + } + + foreach (get_object_vars($obj) as $k => $v) + { + if( substr( $k, 0, 1 ) != '_' ) + { + // internal attributes of an object are ignored + if (strpos( $ignore, $k) === false) + { + if ($prefix) { + $ak = $prefix . $k; + } else { + $ak = $k; + } + if (isset($array[$ak])) { + $obj->$k = ($checkSlashes && get_magic_quotes_gpc()) ? mosStripslashes( $array[$ak] ) : $array[$ak]; + } + } + } + } + + return true; +} + +/** + * Legacy function, use {@link JUtility::getHash()} instead + * + * @deprecated As of version 1.5 + */ +function mosHash( $seed ) { + return JUtility::getHash( $seed ); +} + +/** +* Legacy function + * + * @deprecated As of version 1.5 +*/ +function mosNotAuth() +{ + $user =& JFactory::getUser(); + echo JText::_('ALERTNOTAUTH'); + if ($user->get('id') < 1) { + echo "
" . JText::_( 'You need to login.' ); + } +} + +/** + * Legacy function, use (@link JError} or {@link JApplication::redirect()} instead. + * + * @deprecated As of version 1.5 + */ +function mosErrorAlert( $text, $action='window.history.go(-1);', $mode=1 ) +{ + global $mainframe; + + $text = nl2br( $text ); + $text = addslashes( $text ); + $text = strip_tags( $text ); + + switch ( $mode ) { + case 2: + echo " \n"; + break; + + case 1: + default: + echo " \n"; + echo ''; + break; + } + + $mainframe->close(); +} + +/** + * Legacy function, use {@link JPath::clean()} instead + * + * @deprecated As of version 1.5 + */ +function mosPathName($p_path, $p_addtrailingslash = true) +{ + jimport('joomla.filesystem.path'); + $path = JPath::clean($p_path); + if ($p_addtrailingslash) { + $path = rtrim($path, DS) . DS; + } + return $path; +} + +/** + * Legacy function, use {@link JFolder::files()} or {@link JFolder::folders()} instead + * + * @deprecated As of version 1.5 + */ +function mosReadDirectory( $path, $filter='.', $recurse=false, $fullpath=false ) +{ + $arr = array(null); + + // Get the files and folders + jimport('joomla.filesystem.folder'); + $files = JFolder::files($path, $filter, $recurse, $fullpath); + $folders = JFolder::folders($path, $filter, $recurse, $fullpath); + // Merge files and folders into one array + $arr = array_merge($files, $folders); + // Sort them all + asort($arr); + return $arr; +} + +/** + * Legacy function, use {@link JFactory::getMailer()} instead + * + * @deprecated As of version 1.5 + */ +function mosCreateMail( $from='', $fromname='', $subject, $body ) { + + $mail =& JFactory::getMailer(); + + $mail->From = $from ? $from : $mail->From; + $mail->FromName = $fromname ? $fromname : $mail->FromName; + $mail->Subject = $subject; + $mail->Body = $body; + + return $mail; +} + +/** + * Legacy function, use {@link JUtility::sendMail()} instead + * + * @deprecated As of version 1.5 + */ +function mosMail($from, $fromname, $recipient, $subject, $body, $mode=0, $cc=NULL, $bcc=NULL, $attachment=NULL, $replyto=NULL, $replytoname=NULL ) { + return JUTility::sendMail($from, $fromname, $recipient, $subject, $body, $mode, $cc, $bcc, $attachment, $replyto, $replytoname ); +} + +/** + * Legacy function, use {@link JUtility::sendAdminMail()} instead + * + * @deprecated As of version 1.5 + */ +function mosSendAdminMail( $adminName, $adminEmail, $email, $type, $title, $author ) { + JUtility::sendAdminMail( $adminName, $adminEmail, $email, $type, $title, $author ); +} + +/** + * Legacy function, use {@link JUserHelper::genRandomPassword()} instead + * + * @deprecated As of version 1.5 + */ +function mosMakePassword() { + jimport('joomla.user.helper'); + return JUserHelper::genRandomPassword(); +} + +/** + * Legacy function, use {@link JApplication::redirect() JApplication->redirect()} instead + * + * @deprecated As of version 1.5 + */ +function mosRedirect( $url, $msg='' ) { + global $mainframe; + $mainframe->redirect( $url, $msg ); +} + +/** + * Legacy function, use {@link JFolder::create()} + * + * @deprecated As of version 1.5 + */ +function mosMakePath($base, $path='', $mode = NULL) { + + if ($mode===null) { + $mode = 0755; + } + + jimport('joomla.filesystem.folder'); + return JFolder::create($base.$path, $mode); +} + +/** + * Legacy function, use {@link JArrayHelper::toInteger()} instead + * + * @deprecated As of version 1.5 + */ +function mosArrayToInts( &$array, $default=null ) { + return JArrayHelper::toInteger( $array, $default ); +} + +/** + * Legacy function, use {@link JException::getTrace() JException->getTrace()} instead + * + * @deprecated As of version 1.5 + */ +function mosBackTrace( $message='' ) { + if (function_exists( 'debug_backtrace' )) { + echo '
'; + if ($message) { + echo '

' . $message . '

'; + } + foreach( debug_backtrace() as $back) { + if (@$back['file']) { + echo '
' . str_replace( JPATH_ROOT, '', $back['file'] ) . ':' . $back['line']; + } + } + echo '
'; + } +} + +/** + * Legacy function, use {@link JPath::setPermissions()} instead + * + * @deprecated As of version 1.5 + */ +function mosChmod( $path ) { + jimport('joomla.filesystem.path'); + return JPath::setPermissions( $path ); +} + +/** + * Legacy function, use {@link JPath::setPermissions()} instead + * + * @deprecated As of version 1.5 + */ +function mosChmodRecursive( $path, $filemode=NULL, $dirmode=NULL ) { + jimport('joomla.filesystem.path'); + return JPath::setPermissions( $path, $filemode, $dirmode ); +} + +/** + * Legacy function, use {@link JPath::canChmod()} instead + * + * @deprecated As of version 1.5 + */ +function mosIsChmodable( $file ) { + jimport('joomla.filesystem.path'); + return JPath::canChmod( $file ); +} + +/** + * Legacy function, replaced by geshi bot + * + * @deprecated As of version 1.5 + */ +function mosShowSource( $filename, $withLineNums=false ) { + + ini_set('highlight.html', '000000'); + ini_set('highlight.default', '#800000'); + ini_set('highlight.keyword','#0000ff'); + ini_set('highlight.string', '#ff00ff'); + ini_set('highlight.comment','#008000'); + + if (!($source = @highlight_file( $filename, true ))) { + return JText::_( 'Operation Failed' ); + } + $source = explode("
", $source); + + $ln = 1; + + $txt = ''; + foreach( $source as $line ) { + $txt .= ""; + if ($withLineNums) { + $txt .= ""; + $txt .= str_replace( ' ', ' ', sprintf( "%4d:", $ln ) ); + $txt .= ""; + } + $txt .= "$line
"; + $ln++; + } + return $txt; +} + +/** + * Legacy function, use mosLoadModule( 'breadcrumb', -1 ); instead + * + * @deprecated As of version 1.5 + */ +function mosPathWay() { + mosLoadModule('breadcrumb', -1); +} + +/** + * Legacy function, use {@link JBrowser::getInstance()} instead + * + * @deprecated As of version 1.5 + */ +function mosGetBrowser( $agent ) { + jimport('joomla.environment.browser'); + $instance =& JBrowser::getInstance(); + return $instance; +} + +/** + * Legacy function, use {@link JApplication::getBrowser()} instead + * + * @deprecated As of version 1.5 + */ +function mosGetOS( $agent ) { + jimport('joomla.environment.browser'); + $instance =& JBrowser::getInstance(); + return $instance->getPlatform(); +} + +/** + * Legacy function, use {@link JArrayHelper::getValue()} instead + * + * @deprecated As of version 1.5 + */ +function mosGetParam( &$arr, $name, $def=null, $mask=0 ) +{ + // Static input filters for specific settings + static $noHtmlFilter = null; + static $safeHtmlFilter = null; + + $var = JArrayHelper::getValue( $arr, $name, $def, '' ); + + // If the no trim flag is not set, trim the variable + if (!($mask & 1) && is_string($var)) { + $var = trim($var); + } + + // Now we handle input filtering + if ($mask & 2) { + // If the allow html flag is set, apply a safe html filter to the variable + if (is_null($safeHtmlFilter)) { + $safeHtmlFilter = & JFilterInput::getInstance(null, null, 1, 1); + } + $var = $safeHtmlFilter->clean($var, 'none'); + } elseif ($mask & 4) { + // If the allow raw flag is set, do not modify the variable + $var = $var; + } else { + // Since no allow flags were set, we will apply the most strict filter to the variable + if (is_null($noHtmlFilter)) { + $noHtmlFilter = & JFilterInput::getInstance(/* $tags, $attr, $tag_method, $attr_method, $xss_auto */); + } + $var = $noHtmlFilter->clean($var, 'none'); + } + return $var; +} + +/** + * Legacy function, use {@link JHTML::_('list.genericordering', )} instead + * + * @deprecated As of version 1.5 + */ +function mosGetOrderingList( $sql, $chop='30' ) +{ + return JHTML::_('list.genericordering', $sql, $chop); +} + +/** + * Legacy function, use {@link JRegistry} instead + * + * @deprecated As of version 1.5 + */ +function mosParseParams( $txt ) { + + $registry = new JRegistry(); + $registry->loadINI($txt); + return $registry->toObject( ); +} + +/** + * Legacy function, removed + * + * @deprecated As of version 1.5 + */ +function mosLoadComponent( $name ) +{ + // set up some global variables for use by the frontend component + global $mainframe, $database; + $name = JFilterInput::clean($name, 'cmd'); + $path = JPATH_SITE.DS.'components'.DS.'com_'.$name.DS.$name.'.php'; + if (file_exists($path)) { + include $path; + } +} + +/** + * Legacy function, use {@link JEditor::init()} instead + * + * @deprecated As of version 1.5 + */ +function initEditor() +{ + $editor =& JFactory::getEditor(); + echo $editor->initialise(); +} + +/** + * Legacy function, use {@link JEditor::save()} or {@link JEditor::getContent()} instead + * + * @deprecated As of version 1.5 + */ +function getEditorContents($editorArea, $hiddenField) +{ + jimport( 'joomla.html.editor' ); + $editor =& JFactory::getEditor(); + echo $editor->save( $hiddenField ); +} + +/** + * Legacy function, use {@link JEditor::display()} instead + * + * @deprecated As of version 1.5 + */ +function editorArea($name, $content, $hiddenField, $width, $height, $col, $row) +{ + jimport( 'joomla.html.editor' ); + $editor =& JFactory::getEditor(); + echo $editor->display($hiddenField, $content, $width, $height, $col, $row); +} + +/** + * Legacy function, use {@link JMenu::authorize()} instead + * + * @deprecated As of version 1.5 + */ +function mosMenuCheck( $Itemid, $menu_option, $task, $gid ) +{ + $user =& JFactory::getUser(); + $menus =& JSite::getMenu(); + return $menus->authorize($Itemid, $user->get('aid')); +} + +/** + * Legacy function, use {@link JArrayHelper::fromObject()} instead + * + * @deprecated As of version 1.5 + */ +function mosObjectToArray( $p_obj, $recurse = true, $regex = null ) +{ + $result = JArrayHelper::fromObject( $p_obj, $recurse, $regex ); + return $result; +} + +/** + * Legacy function, use {@link JHTML::_('date', )} instead + * + * @deprecated As of version 1.5 + */ +function mosFormatDate( $date = 'now', $format = null, $offset = null ) { + + if ( ! $format ) + { + $format = JText::_('DATE_FORMAT_LC1'); + } + + return JHTML::_('date', $date, $format, $offset); +} + +/** + * Legacy function, use {@link JHTML::_('date', )} instead + * + * @deprecated As of version 1.5 + */ +function mosCurrentDate( $format="" ) +{ + if ($format=="") { + $format = JText::_( 'DATE_FORMAT_LC1' ); + } + + return JHTML::_('date', 'now', $format); +} + +/** + * Legacy function, use {@link JFilterOutput::objectHTMLSafe()} instead + * + * @deprecated As of version 1.5 + */ +function mosMakeHtmlSafe( &$mixed, $quote_style=ENT_QUOTES, $exclude_keys='' ) { + JFilterOutput::objectHTMLSafe( $mixed, $quote_style, $exclude_keys ); +} + +/** + * Legacy function, handled by {@link JDocument} Zlib outputfilter + * + * @deprecated As of version 1.5 + */ +function initGzip() +{ + global $mainframe, $do_gzip_compress; + + + // attempt to disable session.use_trans_sid + ini_set('session.use_trans_sid', false); + + $do_gzip_compress = FALSE; + if ($mainframe->getCfg('gzip') == 1) { + $phpver = phpversion(); + $useragent = mosGetParam( $_SERVER, 'HTTP_USER_AGENT', '' ); + $canZip = mosGetParam( $_SERVER, 'HTTP_ACCEPT_ENCODING', '' ); + + if ( $phpver >= '4.0.4pl1' && + ( strpos($useragent,'compatible') !== false || + strpos($useragent,'Gecko') !== false + ) + ) { + // Check for gzip header or northon internet securities + if ( isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) { + $encodings = explode(',', strtolower($_SERVER['HTTP_ACCEPT_ENCODING'])); + } + if ( (in_array('gzip', $encodings) || isset( $_SERVER['---------------']) ) && extension_loaded('zlib') && function_exists('ob_gzhandler') && !ini_get('zlib.output_compression') && !ini_get('session.use_trans_sid') ) { + // You cannot specify additional output handlers if + // zlib.output_compression is activated here + ob_start( 'ob_gzhandler' ); + return; + } + } else if ( $phpver > '4.0' ) { + if ( strpos($canZip,'gzip') !== false ) { + if (extension_loaded( 'zlib' )) { + $do_gzip_compress = TRUE; + ob_start(); + ob_implicit_flush(0); + + header( 'Content-Encoding: gzip' ); + return; + } + } + } + } + ob_start(); +} + +/** + * Legacy function, use JFolder::delete($path) + * + * @deprecated As of version 1.5 + */ +function deldir( $dir ) +{ + $current_dir = opendir( $dir ); + $old_umask = umask(0); + while ($entryname = readdir( $current_dir )) { + if ($entryname != '.' and $entryname != '..') { + if (is_dir( $dir . $entryname )) { + deldir( mosPathName( $dir . $entryname ) ); + } else { + @chmod($dir . $entryname, 0777); + unlink( $dir . $entryname ); + } + } + } + umask($old_umask); + closedir( $current_dir ); + return rmdir( $dir ); +} + +/** + * Legacy function, handled by {@link JDocument} Zlib outputfilter + * + * @deprecated As of version 1.5 + */ +function doGzip() +{ + global $do_gzip_compress; + if ( $do_gzip_compress ) + { + $gzip_contents = ob_get_contents(); + ob_end_clean(); + + $gzip_size = strlen($gzip_contents); + $gzip_crc = crc32($gzip_contents); + + $gzip_contents = gzcompress($gzip_contents, 9); + $gzip_contents = substr($gzip_contents, 0, strlen($gzip_contents) - 4); + + echo "\x1f\x8b\x08\x00\x00\x00\x00\x00"; + echo $gzip_contents; + echo pack('V', $gzip_crc); + echo pack('V', $gzip_size); + } else { + ob_end_flush(); + } +} + +/** + * Legacy function, use {@link JArrayHelper::sortObjects()} instead + * + * @deprecated As of version 1.5 + */ +function SortArrayObjects( &$a, $k, $sort_direction=1 ) +{ + JArrayHelper::sortObjects($a, $k, $sort_direction); +} + +/** + * Legacy function, {@link JRequest::getVar()} + * + * @deprecated As of version 1.5 + */ +function josGetArrayInts( $name, $type=NULL ) { + + $array = JRequest::getVar($name, array(), 'default', 'array' ); + + return $array; +} + +/** + * Legacy function, {@link JSession} transparently checks for spoofing attacks + * + * @deprecated As of version 1.5 + */ +function josSpoofCheck( $header=false, $alternate=null ) +{ + // Lets make sure they saw the html form + $check = true; + $hash = josSpoofValue($alternate); + $valid = JRequest::getBool( $hash, 0, 'post' ); + if (!$valid) { + $check = false; + } + + // Make sure request came from a client with a user agent string. + if (!isset( $_SERVER['HTTP_USER_AGENT'] )) { + $check = false; + } + + // Check to make sure that the request was posted as well. + $requestMethod = JArrayHelper::getValue( $_SERVER, 'REQUEST_METHOD' ); + if ($requestMethod != 'POST') { + $check = false; + } + + if (!$check) + { + header( 'HTTP/1.0 403 Forbidden' ); + jexit( JText::_('E_SESSION_TIMEOUT') ); + } +} + +/** + * Legacy function, use {@link JUtility::getToken()} instead + * + * @deprecated As of version 1.5 + */ +function josSpoofValue($alt = NULL) +{ + global $mainframe; + + if ($alt) { + if ( $alt == 1 ) { + $random = date( 'Ymd' ); + } else { + $random = $alt . date( 'Ymd' ); + } + } else { + $random = date( 'dmY' ); + } + // the prefix ensures that the hash is non-numeric + // otherwise it will be intercepted by globals.php + $validate = 'j' . mosHash( $mainframe->getCfg( 'db' ) . $random ); + + return $validate; +} + +/** + * Legacy function to load the tooltip library. + * + * @deprecated As of version 1.5 + */ +function loadOverlib() { + JHTML::_('behavior.tooltip'); +} + +/** +* Legacy utility function to provide ToolTips +* +* @deprecated As of version 1.5 +*/ +function mosToolTip( $tooltip, $title='', $width='', $image='tooltip.png', $text='', $href='', $link=1 ) +{ + // Initialize the toolips if required + static $init; + if ( ! $init ) + { + JHTML::_('behavior.tooltip'); + $init = true; + } + + return JHTML::_('tooltip', $tooltip, $title, $image, $text, $href, $link); +} + +/** + * Legacy function to convert an internal Joomla URL to a humanly readible URL. + * + * @deprecated As of version 1.5 + */ +function sefRelToAbs($value) +{ + // Replace all & with & as the router doesn't understand & + $url = str_replace('&', '&', $value); + if(substr(strtolower($url),0,9) != "index.php") return $url; + $uri = JURI::getInstance(); + $prefix = $uri->toString(array('scheme', 'host', 'port')); + return $prefix.JRoute::_($url); +} + + +/** + * Legacy function to replaces & with & for xhtml compliance + * + * @deprecated As of version 1.5 + */ +function ampReplace( $text ) { + return JFilterOutput::ampReplace($text); +} + +/** + * Legacy function to replaces & with & for xhtml compliance + * + * @deprecated As of version 1.5 + */ +function mosTreeRecurse( $id, $indent, $list, &$children, $maxlevel=9999, $level=0, $type=1 ) +{ + jimport('joomla.html.html'); + return JHTML::_('menu.treerecurse', $id, $indent, $list, $children, $maxlevel, $level, $type); +} + +/** + * Legacy function, use {@link JHTML::tooltip()} instead + * + * @deprecated As of version 1.5 + */ +function mosWarning($warning, $title='Joomla! Warning') { + return JHTML::tooltip($warning, $title, 'warning.png', null, null, null); +} diff --git a/oss/joomla/trunk/plugins/system/legacy/html.php b/oss/joomla/trunk/plugins/system/legacy/html.php new file mode 100644 index 00000000..464a7c39 --- /dev/null +++ b/oss/joomla/trunk/plugins/system/legacy/html.php @@ -0,0 +1,346 @@ +'. JText::_( 'Writable' ) .''; + $unwriteable = ''. JText::_( 'Unwritable' ) .''; + + echo ''; + echo ''; + echo $text; + if ( $visible ) { + echo $folder . '/'; + } + echo ''; + echo ''; + if ( $relative ) { + echo is_writable( "../$folder" ) ? $writeable : $unwriteable; + } else { + echo is_writable( "$folder" ) ? $writeable : $unwriteable; + } + echo ''; + echo ''; + } + + /** + * Legacy function, deprecated + * + * @deprecated As of version 1.5 + */ + function monthSelectList( $tag_name, $tag_attribs, $selected ) + { + $arr = array( + mosHTML::makeOption( '01', JText::_( 'JANUARY_SHORT' ) ), + mosHTML::makeOption( '02', JText::_( 'FEBRUARY_SHORT' ) ), + mosHTML::makeOption( '03', JText::_( 'MARCH_SHORT' ) ), + mosHTML::makeOption( '04', JText::_( 'APRIL_SHORT' ) ), + mosHTML::makeOption( '05', JText::_( 'MAY_SHORT' ) ), + mosHTML::makeOption( '06', JText::_( 'JUNE_SHORT' ) ), + mosHTML::makeOption( '07', JText::_( 'JULY_SHORT' ) ), + mosHTML::makeOption( '08', JText::_( 'AUGUST_SHORT' ) ), + mosHTML::makeOption( '09', JText::_( 'SEPTEMBER_SHORT' ) ), + mosHTML::makeOption( '10', JText::_( 'OCTOBER_SHORT' ) ), + mosHTML::makeOption( '11', JText::_( 'NOVEMBER_SHORT' ) ), + mosHTML::makeOption( '12', JText::_( 'DECEMBER_SHORT' ) ) + ); + + return mosHTML::selectList( $arr, $tag_name, $tag_attribs, 'value', 'text', $selected ); + } + + /** + * Legacy function, deprecated + * + * @deprecated As of version 1.5 + */ + function treeSelectList( &$src_list, $src_id, $tgt_list, $tag_name, $tag_attribs, $key, $text, $selected ) + { + + // establish the hierarchy of the menu + $children = array(); + // first pass - collect children + foreach ($src_list as $v ) { + $pt = $v->parent; + $list = @$children[$pt] ? $children[$pt] : array(); + array_push( $list, $v ); + $children[$pt] = $list; + } + // second pass - get an indent list of the items + $ilist = JHTML::_('menu.treerecurse', 0, '', array(), $children ); + + // assemble menu items to the array + $this_treename = ''; + foreach ($ilist as $item) { + if ($this_treename) { + if ($item->id != $src_id && strpos( $item->treename, $this_treename ) === false) { + $tgt_list[] = mosHTML::makeOption( $item->id, $item->treename ); + } + } else { + if ($item->id != $src_id) { + $tgt_list[] = mosHTML::makeOption( $item->id, $item->treename ); + } else { + $this_treename = "$item->treename/"; + } + } + } + // build the html select list + return mosHTML::selectList( $tgt_list, $tag_name, $tag_attribs, $key, $text, $selected ); + } + + /** + * Legacy function, deprecated + * + * @deprecated As of version 1.5 + */ + function yesnoSelectList( $tag_name, $tag_attribs, $selected, $yes='yes', $no='no' ) + { + $arr = array( + mosHTML::makeOption( 0, JText::_( $no ) ), + mosHTML::makeOption( 1, JText::_( $yes ) ), + ); + + return mosHTML::selectList( $arr, $tag_name, $tag_attribs, 'value', 'text', (int) $selected ); + } + + /** + * Legacy function, use {@link JHTML::_('grid.id')} instead + * + * @deprecated As of version 1.5 + */ + function idBox( $rowNum, $recId, $checkedOut=false, $name='cid' ) + { + return JHTML::_('grid.id', $rowNum, $recId, $checkedOut, $name); + } + + /** + * Legacy function, deprecated + * + * @deprecated As of version 1.5 + */ + function sortIcon( $text, $base_href, $field, $state='none' ) + { + $alts = array( + 'none' => JText::_( 'No Sorting' ), + 'asc' => JText::_( 'Sort Ascending' ), + 'desc' => JText::_( 'Sort Descending' ), + ); + + $next_state = 'asc'; + if ($state == 'asc') { + $next_state = 'desc'; + } else if ($state == 'desc') { + $next_state = 'none'; + } + + if ($state == 'none') { + $img = ''; + } else { + $img = "\"{$alts[$next_state]}\""; + } + + $html = "" + . JText::_( $text ) + . '  ' + . $img + . ""; + + return $html; + } + + /** + * Legacy function, deprecated + * + * @deprecated As of version 1.5 + */ + function CloseButton ( &$params, $hide_js=NULL ) + { + + // displays close button in Pop-up window + if ( $params->get( 'popup' ) && !$hide_js ) { + ?> +
+ + '; + echo '', "'"), '', $_SERVER['HTTP_REFERER']) .'">'. JText::_( 'BACK' ) .''; + echo ''; + } + ?> +
+ get( 'back_button' ) && !$params->get( 'popup' ) && !$hide_js) { + ?> +
+ + +
+ get( 'print' ) && !$hide_js ) { + // use default settings if none declared + if ( !$status ) { + $status = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no'; + } + + // checks template image directory for image, if non found default are loaded + if ( $params->get( 'icons' ) ) { + $image = mosAdminMenus::ImageCheck( 'printButton.png', '/images/M_images/', NULL, NULL, JText::_( 'Print' ), JText::_( 'Print' ) ); + } else { + $image = JText::_( 'ICON_SEP' ) .' '. JText::_( 'Print' ) .' '. JText::_( 'ICON_SEP' ); + } + + if ( $params->get( 'popup' ) && !$hide_js ) { + // Print Preview button - used when viewing page + ?> + + + + + + + \ No newline at end of file diff --git a/oss/joomla/trunk/plugins/system/legacy/installer.php b/oss/joomla/trunk/plugins/system/legacy/installer.php new file mode 100644 index 00000000..eea54bee --- /dev/null +++ b/oss/joomla/trunk/plugins/system/legacy/installer.php @@ -0,0 +1,33 @@ +setTitle()} instead or override in your application class + * + * @since 1.5 + * @deprecated As of version 1.5 + */ + function setPageTitle( $title=null ) + { + $document=& JFactory::getDocument(); + $document->setTitle($title); + } + + /** + * Deprecated, use {@link JDocument::getTitle() JDocument->getTitle()} instead or override in your application class + * @since 1.5 + * @deprecated As of version 1.5 + */ + function getPageTitle() + { + $document=& JFactory::getDocument(); + return $document->getTitle(); + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/plugins/system/legacy/mambot.php b/oss/joomla/trunk/plugins/system/legacy/mambot.php new file mode 100644 index 00000000..35d8ad26 --- /dev/null +++ b/oss/joomla/trunk/plugins/system/legacy/mambot.php @@ -0,0 +1,60 @@ +reorder( $where ); + } + + /** + * Legacy Method, use {@link JTable::publish()} instead + * @deprecated As of 1.0.3 + */ + function publish_array( $cid=null, $publish=1, $user_id=0 ) + { + $this->publish( $cid, $publish, $user_id ); + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/plugins/system/legacy/mambothandler.php b/oss/joomla/trunk/plugins/system/legacy/mambothandler.php new file mode 100644 index 00000000..74f28a60 --- /dev/null +++ b/oss/joomla/trunk/plugins/system/legacy/mambothandler.php @@ -0,0 +1,82 @@ +trigger()} instead and handle return values + * in your code + * + * @param string The event name + * @since 1.5 + * @deprecated As of 1.5 + */ + function call($event) + { + $args = & func_get_args(); + array_shift($args); + + $retArray = $this->trigger( $event, $args ); + return $retArray[0]; + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/plugins/system/legacy/menu.php b/oss/joomla/trunk/plugins/system/legacy/menu.php new file mode 100644 index 00000000..e50fae4f --- /dev/null +++ b/oss/joomla/trunk/plugins/system/legacy/menu.php @@ -0,0 +1,60 @@ +reorder( $where ); + } + + /** + * Legacy Method, use {@link JTable::publish()} instead + * @deprecated As of 1.0.3 + */ + function publish_array( $cid=null, $publish=1, $user_id=0 ) + { + $this->publish( $cid, $publish, $user_id ); + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/plugins/system/legacy/menubar.php b/oss/joomla/trunk/plugins/system/legacy/menubar.php new file mode 100644 index 00000000..49924640 --- /dev/null +++ b/oss/joomla/trunk/plugins/system/legacy/menubar.php @@ -0,0 +1,76 @@ +reorder( $where ); + } + + /** + * Legacy Method, use {@link JTable::publish()} instead + * @deprecated As of 1.0.3 + */ + function publish_array( $cid=null, $publish=1, $user_id=0 ) + { + $this->publish( $cid, $publish, $user_id ); + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/plugins/system/legacy/mysql.php b/oss/joomla/trunk/plugins/system/legacy/mysql.php new file mode 100644 index 00000000..86e83181 --- /dev/null +++ b/oss/joomla/trunk/plugins/system/legacy/mysql.php @@ -0,0 +1,80 @@ + $host, 'user' => $user, 'password' => $password, 'database' => $database, 'prefix' => $prefix ); + parent::__construct( $options ); + } + + /** + * This global function loads the first row of a query into an object + * + * If an object is passed to this function, the returned row is bound to the existing elements of object. + * If object has a value of null, then all of the returned query fields returned in the object. + * + * @param object The address of variable + */ + function loadObject( &$object ) + { + if ($object != null) + { + if (!($cur = $this->query())) { + return false; + } + + if ($array = mysql_fetch_assoc( $cur )) + { + mysql_free_result( $cur ); + mosBindArrayToObject( $array, $object, null, null, false ); + return true; + } else { + return false; + } + + } + else + { + $object = parent::loadObject(); + return $object; + } + } + + /** + * Execute a batch query + * + * @abstract + * @access public + * @return mixed A database resource if successful, FALSE if not. + */ + function query_batch( $abort_on_error=true, $p_transaction_safe = false) + { + return parent::queryBatch( $abort_on_error, $p_transaction_safe); + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/plugins/system/legacy/mysqli.php b/oss/joomla/trunk/plugins/system/legacy/mysqli.php new file mode 100644 index 00000000..d245588f --- /dev/null +++ b/oss/joomla/trunk/plugins/system/legacy/mysqli.php @@ -0,0 +1,80 @@ + $host, 'user' => $user, 'password' => $password, 'database' => $database, 'prefix' => $prefix ); + parent::__construct( $options ); + } + + /** + * This global function loads the first row of a query into an object + * + * If an object is passed to this function, the returned row is bound to the existing elements of object. + * If object has a value of null, then all of the returned query fields returned in the object. + * + * @param object The address of variable + */ + function loadObject( &$object ) + { + if ($object != null) + { + if (!($cur = $this->query())) { + return false; + } + + if ($array = mysqli_fetch_assoc( $cur )) + { + mysqli_free_result( $cur ); + mosBindArrayToObject( $array, $object, null, null, false ); + return true; + } else { + return false; + } + + } + else + { + $object = parent::loadObject(); + return $object; + } + } + + /** + * Execute a batch query + * + * @abstract + * @access public + * @return mixed A database resource if successful, FALSE if not. + */ + function query_batch( $abort_on_error=true, $p_transaction_safe = false) + { + return parent::queryBatch( $abort_on_error, $p_transaction_safe); + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/plugins/system/legacy/pagination.php b/oss/joomla/trunk/plugins/system/legacy/pagination.php new file mode 100644 index 00000000..e8bc7202 --- /dev/null +++ b/oss/joomla/trunk/plugins/system/legacy/pagination.php @@ -0,0 +1,137 @@ +getLimitBox(); + * + * @deprecated as of 1.5 + */ + function writeLimitBox($link = null) { + echo $this->getLimitBox(); + } + + /** + * Writes the counter string + * Use: print $pagination->getLimitBox(); + * + * @deprecated as of 1.5 + */ + function writePagesCounter() { + return $this->getPagesCounter(); + } + + /** + * Writes the page list string + * Use: print $pagination->getPagesLinks(); + * + * @deprecated as of 1.5 + */ + function writePagesLinks($link = null) { + return $this->getPagesLinks(); + } + + /** + * Writes the html for the leafs counter, eg, Page 1 of x + * Use: print $pagination->getPagesCounter(); + * + * @deprecated as of 1.5 + */ + function writeLeafsCounter() { + return $this->getPagesCounter(); + } + + /** + * Returns the pagination offset at an index + * Use: $pagination->getRowOffset($index); instead + * + * @deprecated as of 1.5 + */ + function rowNumber($index) { + return $index +1 + $this->limitstart; + } + + /** + * Return the icon to move an item UP + * + * @deprecated as of 1.5 + */ + function orderUpIcon2($id, $order, $condition = true, $task = 'orderup', $alt = '#') + { + // handling of default value + if ($alt = '#') { + $alt = JText::_('Move Up'); + } + + if ($order == 0) { + $img = 'uparrow0.png'; + } else { + if ($order < 0) { + $img = 'uparrow-1.png'; + } else { + $img = 'uparrow.png'; + } + } + $output = ''; + $output .= ''.$alt.''; + + return $output; + } + + /** + * Return the icon to move an item DOWN + * + * @deprecated as of 1.5 + */ + function orderDownIcon2($id, $order, $condition = true, $task = 'orderdown', $alt = '#') + { + // handling of default value + if ($alt = '#') { + $alt = JText::_('Move Down'); + } + + if ($order == 0) { + $img = 'downarrow0.png'; + } else { + if ($order < 0) { + $img = 'downarrow-1.png'; + } else { + $img = 'downarrow.png'; + } + } + $output = ''; + $output .= ''.$alt.''; + + return $output; + } +} +?> \ No newline at end of file diff --git a/oss/joomla/trunk/plugins/system/legacy/parameters.php b/oss/joomla/trunk/plugins/system/legacy/parameters.php new file mode 100644 index 00000000..4d98716a --- /dev/null +++ b/oss/joomla/trunk/plugins/system/legacy/parameters.php @@ -0,0 +1,94 @@ +toObject()} instead + * + * @deprecated As of version 1.5 + */ + function toObject() + { + parent::toObject(); + } + + /** + * Legacy function, use {@link JParameter::toArray() JParameter->toArray()} instead + * + * @deprecated As of version 1.5 + */ + function toArray() + { + parent::toArray(); + } + + /** + * Parse an .ini string, based on phpDocumentor phpDocumentor_parse_ini_file function + * + * @access public + * @param mixed The ini string or array of lines + * @param boolean add an associative index for each section [in brackets] + * @return object + */ + function parse($txt, $process_sections = false, $asArray = false) + { + $this->loadINI($txt); + + if($asArray) { + return $this->toArray(); + } + + return $this->toObject( ); + } + + /** + * Special handling for textarea param + */ + function textareaHandling( &$txt ) + { + $total = count( $txt ); + for( $i=0; $i < $total; $i++ ) { + if ( strstr( $txt[$i], "\n" ) ) { + $txt[$i] = str_replace( "\n", '
', $txt[$i] ); + } + } + $txt = implode( "\n", $txt ); + + return $txt; + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/plugins/system/legacy/patfactory.php b/oss/joomla/trunk/plugins/system/legacy/patfactory.php new file mode 100644 index 00000000..c4275d33 --- /dev/null +++ b/oss/joomla/trunk/plugins/system/legacy/patfactory.php @@ -0,0 +1,61 @@ +readTemplatesFromFile( 'page.html' ); + $tmpl->applyInputFilter('ShortModifiers'); + + // load the stock templates + if (is_array( $files )) { + foreach ($files as $file) + { + $tmpl->readTemplatesFromInput( $file ); + } + } + + // TODO: Do the protocol better + $tmpl->addVar( 'form', 'formAction', basename(str_replace(array('"', '<', '>', "'"), '', $_SERVER["PHP_SELF"])) ); + $tmpl->addVar( 'form', 'formName', 'adminForm' ); + + $tmpl->setRoot( dirname( __FILE__ ) . '/tmpl'); + $tmpl->setNamespace( 'mos' ); + + if ($bodyHtml) { + $tmpl->setAttribute( 'body', 'src', $bodyHtml ); + } + return $tmpl; + } +} diff --git a/oss/joomla/trunk/plugins/system/legacy/profiler.php b/oss/joomla/trunk/plugins/system/legacy/profiler.php new file mode 100644 index 00000000..c75e1e6d --- /dev/null +++ b/oss/joomla/trunk/plugins/system/legacy/profiler.php @@ -0,0 +1,38 @@ +reorder( $where ); + } + + /** + * Legacy Method, use {@link JTable::publish()} instead + * @deprecated As of 1.0.3 + */ + function publish_array( $cid=null, $publish=1, $user_id=0 ) + { + $this->publish( $cid, $publish, $user_id ); + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/plugins/system/legacy/session.php b/oss/joomla/trunk/plugins/system/legacy/session.php new file mode 100644 index 00000000..d0149b3f --- /dev/null +++ b/oss/joomla/trunk/plugins/system/legacy/session.php @@ -0,0 +1,105 @@ +getCfg('secret') . $value . $_SERVER['REMOTE_ADDR'] ); + } + + /** + * Set the information to allow a session to persist + */ + function persist() + { + global $mainframe; + + $usercookie = mosGetParam( $_COOKIE, 'usercookie', null ); + if ($usercookie) { + // Remember me cookie exists. Login with usercookie info. + $mainframe->login( $usercookie['username'], $usercookie['password'] ); + } + } + + /** + * Legacy Method, use {@link JTable::reorder()} instead + * @deprecated As of 1.5 + */ + function updateOrder( $where='' ) + { + return $this->reorder( $where ); + } + + /** + * Legacy Method, use {@link JTable::publish()} instead + * @deprecated As of 1.0.3 + */ + function publish_array( $cid=null, $publish=1, $user_id=0 ) + { + $this->publish( $cid, $publish, $user_id ); + } + + /** + * Legacy Method, use {@link JTable::publish()} instead + * @deprecated As of 1.5 + */ + function setFromRequest( $key, $varName, $default=null ) + { + if (isset( $_REQUEST[$varName] )) { + return $_SESSION[$key] = $_REQUEST[$varName]; + } else if (isset( $_SESSION[$key] )) { + return $_SESSION[$key]; + } else { + return $_SESSION[$key] = $default; + } + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/plugins/system/legacy/toolbar.php b/oss/joomla/trunk/plugins/system/legacy/toolbar.php new file mode 100644 index 00000000..5eeee217 --- /dev/null +++ b/oss/joomla/trunk/plugins/system/legacy/toolbar.php @@ -0,0 +1,318 @@ +addStyleSheet( 'templates/system/css/toolbar.css' ); + ?> + + + + + setQuery( $sql ); + $cur_template = $db->loadResult(); + + $alt = JText::_( 'Preview' ); + $image = JHTML::_('image.site', 'preview_f2.png', 'images/', NULL, NULL, $alt ); + ?> + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +   
+ diff --git a/oss/joomla/trunk/plugins/system/legacy/user.php b/oss/joomla/trunk/plugins/system/legacy/user.php new file mode 100644 index 00000000..6588610b --- /dev/null +++ b/oss/joomla/trunk/plugins/system/legacy/user.php @@ -0,0 +1,108 @@ +reorder( $where ); + } + + /** + * Legacy Method, use {@link JTable::publish()} instead + * @deprecated As of 1.0.3 + */ + function publish_array( $cid=null, $publish=1, $user_id=0 ) + { + $this->publish( $cid, $publish, $user_id ); + } + + /** + * Returns a complete user list + * + * @return array + * @deprecated As of 1.5 + */ + function getUserList() + { + $this->_db->setQuery("SELECT username FROM #__users"); + return $this->_db->loadAssocList(); + } + + /** + * Gets the users from a group + * + * @param string The value for the group + * @param string The name for the group + * @param string If RECURSE, will drill into child groups + * @param string Ordering for the list + * @return array + * @deprecated As of 1.5 + */ + function getUserListFromGroup( $value, $name, $recurse='NO_RECURSE', $order='name' ) + { + $acl =& JFactory::getACL(); + + // Change back in + $group_id = $acl->get_group_id( $value, $name, 'ARO'); + $objects = $acl->get_group_objects( $group_id, 'ARO', 'RECURSE'); + + if (isset( $objects['users'] )) + { + $gWhere = '(id =' . implode( ' OR id =', $objects['users'] ) . ')'; + + $query = 'SELECT id AS value, name AS text' + . ' FROM #__users' + . ' WHERE block = "0"' + . ' AND ' . $gWhere + . ' ORDER BY '. $order + ; + $this->_db->setQuery( $query ); + $options = $this->_db->loadObjectList(); + return $options; + } else { + return array(); + } + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/plugins/system/log.php b/oss/joomla/trunk/plugins/system/log.php new file mode 100644 index 00000000..86491770 --- /dev/null +++ b/oss/joomla/trunk/plugins/system/log.php @@ -0,0 +1,74 @@ +addEntry($errorlog); + } break; + + case JAUTHENTICATE_STATUS_FAILURE : + { + $errorlog['status'] = $response['type'] . " FAILURE: "; + $errorlog['comment'] = $response['error_message']; + $log->addEntry($errorlog); + } break; + + default : + { + $errorlog['status'] = $response['type'] . " UNKNOWN ERROR: "; + $errorlog['comment'] = $response['error_message']; + $log->addEntry($errorlog); + } break; + } + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/plugins/system/log.xml b/oss/joomla/trunk/plugins/system/log.xml new file mode 100644 index 00000000..139dbf56 --- /dev/null +++ b/oss/joomla/trunk/plugins/system/log.xml @@ -0,0 +1,17 @@ + + + System - Log + Joomla! Project + April 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 system logging + + log.php + + + + \ No newline at end of file diff --git a/oss/joomla/trunk/plugins/system/remember.php b/oss/joomla/trunk/plugins/system/remember.php new file mode 100644 index 00000000..a29da61c --- /dev/null +++ b/oss/joomla/trunk/plugins/system/remember.php @@ -0,0 +1,77 @@ +isAdmin()) { + return; + } + + $user = &JFactory::getUser(); + if (!$user->get('gid')) + { + jimport('joomla.utilities.utility'); + $hash = JUtility::getHash('JLOGIN_REMEMBER'); + + if ($str = JRequest::getString($hash, '', 'cookie', JREQUEST_ALLOWRAW | JREQUEST_NOTRIM)) + { + jimport('joomla.utilities.simplecrypt'); + + //Create the encryption key, apply extra hardening using the user agent string + $key = JUtility::getHash(@$_SERVER['HTTP_USER_AGENT']); + + $crypt = new JSimpleCrypt($key); + $str = $crypt->decrypt($str); + + $options = array(); + $options['silent'] = true; + if (!$mainframe->login(@unserialize($str), $options)) { + // Clear the remember me cookie + setcookie( JUtility::getHash('JLOGIN_REMEMBER'), false, time() - 86400, '/' ); + } + } + } + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/plugins/system/remember.xml b/oss/joomla/trunk/plugins/system/remember.xml new file mode 100644 index 00000000..3a2e01da --- /dev/null +++ b/oss/joomla/trunk/plugins/system/remember.xml @@ -0,0 +1,17 @@ + + + System - Remember Me + Joomla! Project + April 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 remember me functionality + + remember.php + + + + \ No newline at end of file diff --git a/oss/joomla/trunk/plugins/system/sef.php b/oss/joomla/trunk/plugins/system/sef.php new file mode 100644 index 00000000..3fe9d914 --- /dev/null +++ b/oss/joomla/trunk/plugins/system/sef.php @@ -0,0 +1,106 @@ +getName() != 'site') { + return true; + } + + //Replace src links + $base = JURI::base(true).'/'; + $buffer = JResponse::getBody(); + + $regex = '#href="index.php\?([^"]*)#m'; + $buffer = preg_replace_callback( $regex, array('plgSystemSEF', 'route'), $buffer ); + + $protocols = '[a-zA-Z0-9]+:'; //To check for all unknown protocals (a protocol must contain at least one alpahnumeric fillowed by : + $regex = '#(src|href)="(?!/|'.$protocols.'|\#|\')([^"]*)"#m'; + $buffer = preg_replace($regex, "$1=\"$base\$2\"", $buffer); + $regex = '#(onclick="window.open\(\')(?!/|'.$protocols.'|\#)([^/]+[^\']*?\')#m'; + $buffer = preg_replace($regex, '$1'.$base.'$2', $buffer); + + // ONMOUSEOVER / ONMOUSEOUT + $regex = '#(onmouseover|onmouseout)="this.src=([\']+)(?!/|'.$protocols.'|\#|\')([^"]+)"#m'; + $buffer = preg_replace($regex, '$1="this.src=$2'. $base .'$3$4"', $buffer); + + // Background image + $regex = '#style\s*=\s*[\'\"](.*):\s*url\s*\([\'\"]?(?!/|'.$protocols.'|\#)([^\)\'\"]+)[\'\"]?\)#m'; + $buffer = preg_replace($regex, 'style="$1: url(\''. $base .'$2$3\')', $buffer); + + // OBJECT -- fix it only inside the tag + $regex = '#(]\s*value\s*=\s*"(?!/|'.$protocols.'|\#|\')([^"]*)"#m'; + $buffer = preg_replace($regex, '$1name="$2" value="' . $base . '$3"', $buffer); + + // OBJECT -- fix it only inside the tag + $regex = '#(]*)value\s*=\s*"(?!/|'.$protocols.'|\#|\')([^"]*)"\s*name\s*=\s*"(movie|src|url)"#m'; + $buffer = preg_replace($regex, ' + + System - SEF + Joomla! Project + December 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 + DESCPLGSYSTEMSEF + + sef.php + + +