diff --git a/administrator/components/com_admin/sql/updates/mysql/2.5.0-2011-12-19.sql b/administrator/components/com_admin/sql/updates/mysql/2.5.0-2011-12-19.sql index 3c2e2855963d7..94e9c9ae44543 100644 --- a/administrator/components/com_admin/sql/updates/mysql/2.5.0-2011-12-19.sql +++ b/administrator/components/com_admin/sql/updates/mysql/2.5.0-2011-12-19.sql @@ -18,5 +18,3 @@ CREATE TABLE IF NOT EXISTS `#__user_notes` ( KEY `idx_user_id` (`user_id`), KEY `idx_category_id` (`catid`) ) DEFAULT CHARSET=utf8; - -INSERT INTO `#__extensions` VALUES(null, 'plg_captcha_recaptcha', 'plugin', 'recaptcha', 'captcha', 0, 1, 1, 0, '{}', '{"public_key":"","private_key":"","theme":"clean"}', '', '', 0, '0000-00-00 00:00:00', 0, 0); diff --git a/administrator/components/com_admin/sql/updates/mysql/2.5.0-2011-12-21.sql b/administrator/components/com_admin/sql/updates/mysql/2.5.0-2011-12-21-1.sql similarity index 77% rename from administrator/components/com_admin/sql/updates/mysql/2.5.0-2011-12-21.sql rename to administrator/components/com_admin/sql/updates/mysql/2.5.0-2011-12-21-1.sql index af2dfc2b961da..e0735c3522c2f 100644 --- a/administrator/components/com_admin/sql/updates/mysql/2.5.0-2011-12-21.sql +++ b/administrator/components/com_admin/sql/updates/mysql/2.5.0-2011-12-21-1.sql @@ -1,10 +1,5 @@ -# Finder stuff INSERT INTO `#__extensions` (`extension_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `manifest_cache`, `params`, `custom_data`, `system_data`, `checked_out`, `checked_out_time`, `ordering`, `state`) VALUES (27, 'com_finder', 'component', 'com_finder', '', 1, 1, 0, 0, '', '{"show_description":"1","description_length":255,"allow_empty_query":"0","show_url":"1","show_advanced":"1","expand_advanced":"0","show_date_filters":"0","highlight_terms":"1","opensearch_name":"","opensearch_description":"","batch_size":"50","memory_table_limit":30000,"title_multiplier":"1.7","text_multiplier":"0.7","meta_multiplier":"1.2","path_multiplier":"2.0","misc_multiplier":"0.3","stemmer":"porter_en"}', '', '', 0, '0000-00-00 00:00:00', 0, 0), -(435, 'plg_content_joomla', 'plugin', 'joomla', 'content', 0, 1, 1, 0, '', '{}', '', '', 0, '0000-00-00 00:00:00', 0, 0), -(436, 'plg_system_languagecode', 'plugin', 'languagecode', 'system', 0, 0, 1, 0, '', '{}', '', '', 0, '0000-00-00 00:00:00', 10, 0), -(437, 'plg_quickicon_joomlaupdate', 'plugin', 'joomlaupdate', 'quickicon', 0, 1, 1, 1, '', '{}', '', '', 0, '0000-00-00 00:00:00', 0, 0), -(438, 'plg_quickicon_extensionupdate', 'plugin', 'extensionupdate', 'quickicon', 0, 1, 1, 1, '', '{}', '', '', 0, '0000-00-00 00:00:00', 0, 0), (439, 'plg_captcha_recaptcha', 'plugin', 'recaptcha', 'captcha', 0, 1, 1, 0, '{}', '{"public_key":"","private_key":"","theme":"clean"}', '', '', 0, '0000-00-00 00:00:00', 0, 0), (440, 'plg_system_highlight', 'plugin', 'highlight', 'system', 0, 1, 1, 0, '', '{}', '', '', 0, '0000-00-00 00:00:00', 7, 0), (441, 'plg_content_finder', 'plugin', 'finder', 'content', 0, 0, 1, 0, '{"legacy":false,"name":"plg_content_finder","type":"plugin","creationDate":"December 2011","author":"Joomla! Project","copyright":"Copyright (C) 2005 - 2011 Open Source Matters. All rights reserved.","authorEmail":"admin@joomla.org","authorUrl":"www.joomla.org","version":"1.7.0","description":"PLG_CONTENT_FINDER_XML_DESCRIPTION","group":""}', '{}', '', '', 0, '0000-00-00 00:00:00', 0, 0), @@ -12,4 +7,9 @@ INSERT INTO `#__extensions` (`extension_id`, `name`, `type`, `element`, `folder` (443, 'plg_finder_contacts', 'plugin', 'contacts', 'finder', 0, 1, 1, 0, '', '{}', '', '', 0, '0000-00-00 00:00:00', 2, 0), (444, 'plg_finder_content', 'plugin', 'content', 'finder', 0, 1, 1, 0, '', '{}', '', '', 0, '0000-00-00 00:00:00', 3, 0), (445, 'plg_finder_newsfeeds', 'plugin', 'newsfeeds', 'finder', 0, 1, 1, 0, '', '{}', '', '', 0, '0000-00-00 00:00:00', 4, 0), -(446, 'plg_finder_weblinks', 'plugin', 'weblinks', 'finder', 0, 1, 1, 0, '', '{}', '', '', 0, '0000-00-00 00:00:00', 5, 0); \ No newline at end of file +(446, 'plg_finder_weblinks', 'plugin', 'weblinks', 'finder', 0, 1, 1, 0, '', '{}', '', '', 0, '0000-00-00 00:00:00', 5, 0), +(223, 'mod_finder', 'module', 'mod_finder', '', 0, 1, 0, 0, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0); + + +INSERT INTO `#__assets` (`id`, `parent_id`, `lft`, `rgt`, `level`, `name`, `title`, `rules`) VALUES +(33,1,63,64,1,'com_finder','com_finder','{"core.admin":{"7":1},"core.manage":{"6":1}}'); diff --git a/administrator/components/com_admin/sql/updates/mysql/2.5.0-2011-12-21-2.sql b/administrator/components/com_admin/sql/updates/mysql/2.5.0-2011-12-21-2.sql new file mode 100644 index 0000000000000..dd1a0d44f16c3 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/mysql/2.5.0-2011-12-21-2.sql @@ -0,0 +1,244 @@ +CREATE TABLE IF NOT EXISTS `#__finder_links_terms0` ( + `link_id` int(10) unsigned NOT NULL, + `term_id` int(10) unsigned NOT NULL, + `weight` float unsigned NOT NULL, + PRIMARY KEY (`link_id`,`term_id`), + KEY `idx_term_weight` (`term_id`,`weight`), + KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) +) DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `#__finder_links_terms1` ( + `link_id` int(10) unsigned NOT NULL, + `term_id` int(10) unsigned NOT NULL, + `weight` float unsigned NOT NULL, + PRIMARY KEY (`link_id`,`term_id`), + KEY `idx_term_weight` (`term_id`,`weight`), + KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) +) DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `#__finder_links_terms2` ( + `link_id` int(10) unsigned NOT NULL, + `term_id` int(10) unsigned NOT NULL, + `weight` float unsigned NOT NULL, + PRIMARY KEY (`link_id`,`term_id`), + KEY `idx_term_weight` (`term_id`,`weight`), + KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) +) DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `#__finder_links_terms3` ( + `link_id` int(10) unsigned NOT NULL, + `term_id` int(10) unsigned NOT NULL, + `weight` float unsigned NOT NULL, + PRIMARY KEY (`link_id`,`term_id`), + KEY `idx_term_weight` (`term_id`,`weight`), + KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) +) DEFAULT CHARSET=utf8; + + +CREATE TABLE IF NOT EXISTS `#__finder_links_terms4` ( + `link_id` int(10) unsigned NOT NULL, + `term_id` int(10) unsigned NOT NULL, + `weight` float unsigned NOT NULL, + PRIMARY KEY (`link_id`,`term_id`), + KEY `idx_term_weight` (`term_id`,`weight`), + KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) +) DEFAULT CHARSET=utf8; + + +CREATE TABLE IF NOT EXISTS `#__finder_links_terms5` ( + `link_id` int(10) unsigned NOT NULL, + `term_id` int(10) unsigned NOT NULL, + `weight` float unsigned NOT NULL, + PRIMARY KEY (`link_id`,`term_id`), + KEY `idx_term_weight` (`term_id`,`weight`), + KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) +) DEFAULT CHARSET=utf8; + + +CREATE TABLE IF NOT EXISTS `#__finder_links_terms6` ( + `link_id` int(10) unsigned NOT NULL, + `term_id` int(10) unsigned NOT NULL, + `weight` float unsigned NOT NULL, + PRIMARY KEY (`link_id`,`term_id`), + KEY `idx_term_weight` (`term_id`,`weight`), + KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) +) DEFAULT CHARSET=utf8; + + +CREATE TABLE IF NOT EXISTS `#__finder_links_terms7` ( + `link_id` int(10) unsigned NOT NULL, + `term_id` int(10) unsigned NOT NULL, + `weight` float unsigned NOT NULL, + PRIMARY KEY (`link_id`,`term_id`), + KEY `idx_term_weight` (`term_id`,`weight`), + KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) +) DEFAULT CHARSET=utf8; + + +CREATE TABLE IF NOT EXISTS `#__finder_links_terms8` ( + `link_id` int(10) unsigned NOT NULL, + `term_id` int(10) unsigned NOT NULL, + `weight` float unsigned NOT NULL, + PRIMARY KEY (`link_id`,`term_id`), + KEY `idx_term_weight` (`term_id`,`weight`), + KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) +) DEFAULT CHARSET=utf8; + + +CREATE TABLE IF NOT EXISTS `#__finder_links_terms9` ( + `link_id` int(10) unsigned NOT NULL, + `term_id` int(10) unsigned NOT NULL, + `weight` float unsigned NOT NULL, + PRIMARY KEY (`link_id`,`term_id`), + KEY `idx_term_weight` (`term_id`,`weight`), + KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) +) DEFAULT CHARSET=utf8; + + +CREATE TABLE IF NOT EXISTS `#__finder_links_termsa` ( + `link_id` int(10) unsigned NOT NULL, + `term_id` int(10) unsigned NOT NULL, + `weight` float unsigned NOT NULL, + PRIMARY KEY (`link_id`,`term_id`), + KEY `idx_term_weight` (`term_id`,`weight`), + KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) +) DEFAULT CHARSET=utf8; + + +CREATE TABLE IF NOT EXISTS `#__finder_links_termsb` ( + `link_id` int(10) unsigned NOT NULL, + `term_id` int(10) unsigned NOT NULL, + `weight` float unsigned NOT NULL, + PRIMARY KEY (`link_id`,`term_id`), + KEY `idx_term_weight` (`term_id`,`weight`), + KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) +) DEFAULT CHARSET=utf8; + + +CREATE TABLE IF NOT EXISTS `#__finder_links_termsc` ( + `link_id` int(10) unsigned NOT NULL, + `term_id` int(10) unsigned NOT NULL, + `weight` float unsigned NOT NULL, + PRIMARY KEY (`link_id`,`term_id`), + KEY `idx_term_weight` (`term_id`,`weight`), + KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) +) DEFAULT CHARSET=utf8; + + +CREATE TABLE IF NOT EXISTS `#__finder_links_termsd` ( + `link_id` int(10) unsigned NOT NULL, + `term_id` int(10) unsigned NOT NULL, + `weight` float unsigned NOT NULL, + PRIMARY KEY (`link_id`,`term_id`), + KEY `idx_term_weight` (`term_id`,`weight`), + KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) +) DEFAULT CHARSET=utf8; + + +CREATE TABLE IF NOT EXISTS `#__finder_links_termse` ( + `link_id` int(10) unsigned NOT NULL, + `term_id` int(10) unsigned NOT NULL, + `weight` float unsigned NOT NULL, + PRIMARY KEY (`link_id`,`term_id`), + KEY `idx_term_weight` (`term_id`,`weight`), + KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) +) DEFAULT CHARSET=utf8; + + +CREATE TABLE IF NOT EXISTS `#__finder_links_termsf` ( + `link_id` int(10) unsigned NOT NULL, + `term_id` int(10) unsigned NOT NULL, + `weight` float unsigned NOT NULL, + PRIMARY KEY (`link_id`,`term_id`), + KEY `idx_term_weight` (`term_id`,`weight`), + KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) +) DEFAULT CHARSET=utf8; + + +CREATE TABLE IF NOT EXISTS `#__finder_taxonomy` ( + `id` int(10) unsigned NOT NULL auto_increment, + `parent_id` int(10) unsigned NOT NULL default '0', + `title` varchar(255) NOT NULL, + `state` tinyint(1) unsigned NOT NULL default '1', + `access` tinyint(1) unsigned NOT NULL default '0', + `ordering` tinyint(1) unsigned NOT NULL default '0', + PRIMARY KEY (`id`), + KEY `parent_id` (`parent_id`), + KEY `state` (`state`), + KEY `ordering` (`ordering`), + KEY `access` (`access`), + KEY `idx_parent_published` (`parent_id`,`state`,`access`) +) DEFAULT CHARSET=utf8; + + +CREATE TABLE IF NOT EXISTS `#__finder_taxonomy_map` ( + `link_id` int(10) unsigned NOT NULL, + `node_id` int(10) unsigned NOT NULL, + PRIMARY KEY (`link_id`,`node_id`), + KEY `link_id` (`link_id`), + KEY `node_id` (`node_id`) +) DEFAULT CHARSET=utf8; + + +CREATE TABLE IF NOT EXISTS `#__finder_terms` ( + `term_id` int(10) unsigned NOT NULL auto_increment, + `term` varchar(75) NOT NULL, + `stem` varchar(75) NOT NULL, + `common` tinyint(1) unsigned NOT NULL default '0', + `phrase` tinyint(1) unsigned NOT NULL default '0', + `weight` float unsigned NOT NULL default '0', + `soundex` varchar(75) NOT NULL, + `links` int(10) NOT NULL default '0', + PRIMARY KEY (`term_id`), + UNIQUE KEY `idx_term` (`term`), + KEY `idx_term_phrase` (`term`,`phrase`), + KEY `idx_stem_phrase` (`stem`,`phrase`), + KEY `idx_soundex_phrase` (`soundex`,`phrase`) +) DEFAULT CHARSET=utf8; + + +CREATE TABLE IF NOT EXISTS `#__finder_terms_common` ( + `term` varchar(75) NOT NULL, + `language` varchar(3) NOT NULL, + KEY `idx_word_lang` (`term`,`language`), + KEY `idx_lang` (`language`) +) DEFAULT CHARSET=utf8; + + +CREATE TABLE IF NOT EXISTS `#__finder_tokens` ( + `term` varchar(75) NOT NULL, + `stem` varchar(75) NOT NULL, + `common` tinyint(1) unsigned NOT NULL default '0', + `phrase` tinyint(1) unsigned NOT NULL default '0', + `weight` float unsigned NOT NULL default '1', + `context` tinyint(1) unsigned NOT NULL default '2', + KEY `idx_word` (`term`), + KEY `idx_context` (`context`) +) ENGINE=MEMORY DEFAULT CHARSET=utf8; + + +CREATE TABLE IF NOT EXISTS `#__finder_tokens_aggregate` ( + `term_id` int(10) unsigned NOT NULL, + `map_suffix` char(1) NOT NULL, + `term` varchar(75) NOT NULL, + `stem` varchar(75) NOT NULL, + `common` tinyint(1) unsigned NOT NULL default '0', + `phrase` tinyint(1) unsigned NOT NULL default '0', + `term_weight` float unsigned NOT NULL, + `context` tinyint(1) unsigned NOT NULL default '2', + `context_weight` float unsigned NOT NULL, + `total_weight` float unsigned NOT NULL, + KEY `token` (`term`), + KEY `keyword_id` (`term_id`) +) ENGINE=MEMORY DEFAULT CHARSET=utf8; + + +CREATE TABLE IF NOT EXISTS `#__finder_types` ( + `id` int(10) unsigned NOT NULL auto_increment, + `title` varchar(100) NOT NULL, + `mime` varchar(100) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `title` (`title`) +) DEFAULT CHARSET=utf8; + + diff --git a/administrator/components/com_admin/sql/updates/mysql/2.5.0-2011-12-22.sql b/administrator/components/com_admin/sql/updates/mysql/2.5.0-2011-12-22.sql new file mode 100644 index 0000000000000..fe86a15975904 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/mysql/2.5.0-2011-12-22.sql @@ -0,0 +1,123 @@ +REPLACE INTO `#__finder_taxonomy` (`id`, `parent_id`, `title`, `state`, `access`, `ordering`) VALUES +(1, 0, 'ROOT', 0, 0, 0); + +REPLACE INTO `#__finder_terms_common` (`term`, `language`) VALUES +('a', 'en'), +('about', 'en'), +('after', 'en'), +('ago', 'en'), +('all', 'en'), +('am', 'en'), +('an', 'en'), +('and', 'en'), +('ani', 'en'), +('any', 'en'), +('are', 'en'), +('aren''t', 'en'), +('as', 'en'), +('at', 'en'), +('be', 'en'), +('but', 'en'), +('by', 'en'), +('for', 'en'), +('from', 'en'), +('get', 'en'), +('go', 'en'), +('how', 'en'), +('if', 'en'), +('in', 'en'), +('into', 'en'), +('is', 'en'), +('isn''t', 'en'), +('it', 'en'), +('its', 'en'), +('me', 'en'), +('more', 'en'), +('most', 'en'), +('must', 'en'), +('my', 'en'), +('new', 'en'), +('no', 'en'), +('none', 'en'), +('not', 'en'), +('noth', 'en'), +('nothing', 'en'), +('of', 'en'), +('off', 'en'), +('often', 'en'), +('old', 'en'), +('on', 'en'), +('onc', 'en'), +('once', 'en'), +('onli', 'en'), +('only', 'en'), +('or', 'en'), +('other', 'en'), +('our', 'en'), +('ours', 'en'), +('out', 'en'), +('over', 'en'), +('page', 'en'), +('she', 'en'), +('should', 'en'), +('small', 'en'), +('so', 'en'), +('some', 'en'), +('than', 'en'), +('thank', 'en'), +('that', 'en'), +('the', 'en'), +('their', 'en'), +('theirs', 'en'), +('them', 'en'), +('then', 'en'), +('there', 'en'), +('these', 'en'), +('they', 'en'), +('this', 'en'), +('those', 'en'), +('thus', 'en'), +('time', 'en'), +('times', 'en'), +('to', 'en'), +('too', 'en'), +('true', 'en'), +('under', 'en'), +('until', 'en'), +('up', 'en'), +('upon', 'en'), +('use', 'en'), +('user', 'en'), +('users', 'en'), +('veri', 'en'), +('version', 'en'), +('very', 'en'), +('via', 'en'), +('want', 'en'), +('was', 'en'), +('way', 'en'), +('were', 'en'), +('what', 'en'), +('when', 'en'), +('where', 'en'), +('whi', 'en'), +('which', 'en'), +('who', 'en'), +('whom', 'en'), +('whose', 'en'), +('why', 'en'), +('wide', 'en'), +('will', 'en'), +('with', 'en'), +('within', 'en'), +('without', 'en'), +('would', 'en'), +('yes', 'en'), +('yet', 'en'), +('you', 'en'), +('your', 'en'), +('yours', 'en'); + + +INSERT INTO `#__menu` (`id`, `menutype`, `title`, `alias`, `note`, `path`, `link`, `type`, `published`, `parent_id`, `level`, `component_id`, `ordering`, `checked_out`, `checked_out_time`, `browserNav`, `access`, `img`, `template_style_id`, `params`, `lft`, `rgt`, `home`, `language`, `client_id`) VALUES +(21, 'menu', 'com_finder', 'Smart Search', '', 'Smart Search', 'index.php?option=com_finder', 'component', 0, 1, 1, 27, 0, 0, '0000-00-00 00:00:00', 0, 0, 'class:finder', 0, '', 41, 42, 0, '*', 1); diff --git a/administrator/components/com_finder/finder.xml b/administrator/components/com_finder/finder.xml index 11ef465ce41eb..e7894cb3d6670 100644 --- a/administrator/components/com_finder/finder.xml +++ b/administrator/components/com_finder/finder.xml @@ -1,6 +1,6 @@ - Finder + com_finder Joomla! Project (C) 2005 - 2011 Open Source Matters. All rights reserved. August 2011 diff --git a/administrator/modules/mod_finder_status/index.html b/administrator/modules/mod_finder_status/index.html deleted file mode 100644 index 3af63015d2219..0000000000000 --- a/administrator/modules/mod_finder_status/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/administrator/modules/mod_finder_status/mod_finder_status.php b/administrator/modules/mod_finder_status/mod_finder_status.php deleted file mode 100644 index a7446cf1fd2d6..0000000000000 --- a/administrator/modules/mod_finder_status/mod_finder_status.php +++ /dev/null @@ -1,30 +0,0 @@ -addStyleDeclaration( - 'span#finder-status-message { display: none; }' -); -?> - diff --git a/administrator/modules/mod_finder_status/mod_finder_status.xml b/administrator/modules/mod_finder_status/mod_finder_status.xml deleted file mode 100644 index 7ba0abf996953..0000000000000 --- a/administrator/modules/mod_finder_status/mod_finder_status.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - mod_finder_status - Joomla! Project - (C) 2005 - 2011 Open Source Matters. All rights reserved. - November 2010 - GNU General Public License version 2 or later; see LICENSE.txt - admin@joomla.org - www.joomla.org - 2.5.0 - MOD_FINDER_STATUS_XML_DESCRIPTION - script.php - - index.html - mod_finder_status.php - mod_finder_status.xml - - - js - - - language/en-GB/en-GB.mod_finder_status.ini - language/en-GB/en-GB.mod_finder_status.sys.ini - - \ No newline at end of file diff --git a/administrator/templates/bluestork/css/template.css b/administrator/templates/bluestork/css/template.css index 47cacd6e0d3f2..542a9fb64c798 100644 --- a/administrator/templates/bluestork/css/template.css +++ b/administrator/templates/bluestork/css/template.css @@ -2071,7 +2071,7 @@ a.jgrid:hover { text-decoration: none;} .icon-16-readmess { background-image: url(../images/menu/icon-16-readmess.png); } .icon-16-redirect { background-image: url(../images/menu/icon-16-redirect.png); } .icon-16-search { background-image: url(../images/menu/icon-16-search.png); } -.icon-16-finder { background-image: url(../images/menu/icon-16-finder.png); } +.icon-16-finder { background-image: url(../images/menu/icon-16-search.png); } .icon-16-section { background-image: url(../images/menu/icon-16-section.png); } .icon-16-static { background-image: url(../images/menu/icon-16-static.png); } .icon-16-stats { background-image: url(../images/menu/icon-16-stats.png); } @@ -2192,7 +2192,7 @@ a.jgrid:hover { text-decoration: none;} .icon-48-massmail { background-image: url(../images/header/icon-48-massmail.png); } .icon-48-redirect { background-image: url(../images/header/icon-48-redirect.png); } .icon-48-search { background-image: url(../images/header/icon-48-search.png); } -.icon-48-finder { background-image: url(../images/header/icon-48-finder.png); } +.icon-48-finder { background-image: url(../images/header/icon-48-search.png); } .icon-48-newsfeeds { background-image: url(../images/header/icon-48-newsfeeds.png); } .icon-48-newsfeeds-cat { background-image: url(../images/header/icon-48-newsfeeds-cat.png); } .icon-48-weblinks { background-image: url(../images/header/icon-48-links.png); } diff --git a/administrator/templates/hathor/css/colour_blue.css b/administrator/templates/hathor/css/colour_blue.css index 86fd8b79070d1..bc8ede2cf6ecd 100644 --- a/administrator/templates/hathor/css/colour_blue.css +++ b/administrator/templates/hathor/css/colour_blue.css @@ -1140,7 +1140,7 @@ a img.calendar { } .icon-16-finder { - background-image: url(../images/menu/icon-16-finder.png); + background-image: url(../images/menu/icon-16-search.png); } .icon-16-weblinks { @@ -1559,7 +1559,7 @@ a img.calendar { } .icon-48-finder { - background-image: url(../images/header/icon-48-finder.png); + background-image: url(../images/header/icon-48-search.png); } .icon-48-newsfeeds { diff --git a/administrator/templates/hathor/css/colour_brown.css b/administrator/templates/hathor/css/colour_brown.css index c62d220397aeb..af1349ee68e9c 100644 --- a/administrator/templates/hathor/css/colour_brown.css +++ b/administrator/templates/hathor/css/colour_brown.css @@ -983,7 +983,7 @@ a img.calendar { } .icon-16-finder { - background-image: url(../images/menu/icon-16-finder.png); + background-image: url(../images/menu/icon-16-search.png); } .icon-16-weblinks { @@ -1402,7 +1402,7 @@ a img.calendar { } .icon-48-finder { - background-image: url(../images/header/icon-48-finder.png); + background-image: url(../images/header/icon-48-search.png); } .icon-48-newsfeeds { diff --git a/administrator/templates/hathor/css/colour_highcontrast.css b/administrator/templates/hathor/css/colour_highcontrast.css index 7cee8d2d8f8d2..ba60003efcd8d 100644 --- a/administrator/templates/hathor/css/colour_highcontrast.css +++ b/administrator/templates/hathor/css/colour_highcontrast.css @@ -1098,7 +1098,7 @@ a img.calendar { } .icon-16-finder { - background-image: url(../images/menu/icon-16-finder.png); + background-image: url(../images/menu/icon-16-search.png); } .icon-16-weblinks { @@ -1517,7 +1517,7 @@ a img.calendar { } .icon-48-finder { - background-image: url(../images/header/icon-48-finder.png); + background-image: url(../images/header/icon-48-search.png); } .icon-48-newsfeeds { diff --git a/administrator/templates/hathor/css/colour_standard.css b/administrator/templates/hathor/css/colour_standard.css index d143bbcab9ecc..b86b22395b62d 100644 --- a/administrator/templates/hathor/css/colour_standard.css +++ b/administrator/templates/hathor/css/colour_standard.css @@ -1042,7 +1042,7 @@ a img.calendar { } .icon-16-finder { - background-image: url(../images/menu/icon-16-finder.png); + background-image: url(../images/menu/icon-16-search.png); } .icon-16-weblinks { @@ -1461,7 +1461,7 @@ a img.calendar { } .icon-48-finder { - background-image: url(../images/header/icon-48-finder.png); + background-image: url(../images/header/icon-48-search.png); } .icon-48-newsfeeds { diff --git a/installation/CHANGELOG b/installation/CHANGELOG index 41b4b2ce83eb3..755ef4703b1ae 100644 --- a/installation/CHANGELOG +++ b/installation/CHANGELOG @@ -27,8 +27,12 @@ $ -> Language fix or change - -> Removed ! -> Note +-------------------- 2.5.0 Beta1 Release [22-Dec-2011] ------------------ + 22-Dec-2011 Mark Dexter # [#27453] toSQL Date format + # [#27471] *Updating 1.7.0 with 2.5 beta update package does not install Finder + # [#27482] Changesearch/ finder template image references 22-Dec-2011 Jean-Marie Simonet $ Updating installation ini files pt-BR, ckb-IQ, lo-LA @@ -42,8 +46,6 @@ $ -> Language fix or change + Missing an hathor view in [#27414] # [#27273] Sorting broken in com_contact single category view (Denise McLaurin) --------------------- 2.5.0 Beta1 Release [22-Dec-2011] ------------------ - 21-Dec-2011 Mark Dexter + [#27348] Finder Integration: Rob Schley, Michael Babker, Elin Waring, Chris Davenport, Omar Ramos, Viet Hoang Vu, Jean Marie Simonet, Rouven Weßling, Louis Landry, Gabriele Pongelli diff --git a/media/com_finder/images/calendar.png b/media/com_finder/images/calendar.png new file mode 100644 index 0000000000000..01adf8820d6ee Binary files /dev/null and b/media/com_finder/images/calendar.png differ diff --git a/media/com_finder/images/mime/pdf.png b/media/com_finder/images/mime/pdf.png new file mode 100644 index 0000000000000..cb1643489d16c --- /dev/null +++ b/media/com_finder/images/mime/pdf.png @@ -0,0 +1,802 @@ + + + + + + + + + media/com_finder/images/mime/pdf.png at e04372b05a245009ddfab5cf1c58f3ec00ccc06b from elinw/joomla-cms - GitHub + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + +
+

+ elinw / + joomla-cms + + forked from joomla/joomla-cms + +

+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ + + + + + +

Browsing ref e04372b05a

+ +
+

+ Add back some images. + +

+
+ commit e04372b05a + +
+ + elinw + authored + +
+
+
+ + +
+ + + +
+
+ +
+
+
+
+ Txt + 100644 + 0.222 kb +
+ +
+
+
+ +
+
+ +
+
+
+
+ +
+ + + +
+
+ + + + + + + + +
+

Markdown Cheat Sheet

+ +
+ +
+
+

Format Text

+

Headers

+
+# This is an <h1> tag
+## This is an <h2> tag
+###### This is an <h6> tag
+

Text styles

+
+*This text will be italic*
+_This will also be italic_
+**This text will be bold**
+__This will also be bold__
+
+*You **can** combine them*
+
+
+
+

Lists

+

Unordered

+
+* Item 1
+* Item 2
+  * Item 2a
+  * Item 2b
+

Ordered

+
+1. Item 1
+2. Item 2
+3. Item 3
+   * Item 3a
+   * Item 3b
+
+
+

Miscellaneous

+

Images

+
+![GitHub Logo](/images/logo.png)
+Format: ![Alt Text](url)
+
+

Links

+
+http://github.com - automatic!
+[GitHub](http://github.com)
+

Blockquotes

+
+As Kanye West said:
+
+> We're living the future so
+> the present is our past.
+
+
+
+
+ +

Code Examples in Markdown

+
+

Syntax highlighting with GFM

+
+```javascript
+function fancyAlert(arg) {
+  if(arg) {
+    $.facebox({div:'#foo'})
+  }
+}
+```
+
+
+

Or, indent your code 4 spaces

+
+Here is a Python code example
+without syntax highlighting:
+
+    def foo:
+      if not bar:
+        return true
+
+
+

Inline code for comments

+
+I think you should use an
+`<addr>` element here instead.
+
+
+ +
+ + + +
+ +
+

Something went wrong with that request. Please try again. Dismiss

+
+ + + + + + + diff --git a/plugins/finder/categories/categories.php b/plugins/finder/categories/categories.php index cc52eb53b4b34..a8440757adae8 100644 --- a/plugins/finder/categories/categories.php +++ b/plugins/finder/categories/categories.php @@ -1,381 +1,405 @@ -loadLanguage(); - } - - /** - * Method to remove the link information for items that have been deleted. - * - * @param string $context The context of the action being performed. - * @param JTable $table A JTable object containing the record to be deleted - * - * @return boolean True on success. - * - * @since 2.5 - * @throws Exception on database error. - */ - public function onFinderDelete($context, $table) - { - if ($context == 'com_categories.category') - { - $id = $table->id; - } - elseif ($context == 'com_finder.index') - { - $id = $table->link_id; - } - else - { - return true; - } - // Remove the items. - return $this->remove($id); - } - - /** - * Method to determine if the access level of an item changed. - * - * @param string $context The context of the content passed to the plugin. - * @param JTable $row A JTable object - * @param boolean $isNew If the content has just been created - * - * @return boolean True on success. - * - * @since 2.5 - * @throws Exception on database error. - */ - public function onFinderAfterSave($context, $row, $isNew) - { - // We only want to handle categories here - if ($context != 'com_categories.category') - { - return true; - } - - // Check if the access levels are different - if (!$isNew && $this->old_access != $row->access) - { - $sql = clone($this->_getStateQuery()); - $sql->where('c.id = ' . (int) $row->id); - - // Get the access level. - $this->db->setQuery($sql); - $item = $this->db->loadObject(); - - // Set the access level. - $temp = max($row->access, $item->cat_access); - - // Update the item. - $this->change((int) $row->id, 'access', $temp); - - // Queue the item to be reindexed. - FinderIndexerQueue::add($context, $row->id, JFactory::getDate()->toMySQL()); - } - - return true; - } - - /** - * Method to reindex the link information for an item that has been saved. - * This event is fired before the data is actually saved so we are going - * to queue the item to be indexed later. - * - * @param string $context The context of the content passed to the plugin. - * @param JTable $row A JTable object - * @param boolean $isNew If the content is just about to be created - * - * @return boolean True on success. - * - * @since 2.5 - * @throws Exception on database error. - */ - public function onFinderBeforeSave($context, $row, $isNew) - { - // We only want to handle categories here - if ($context != 'com_categories.category') - { - return true; - } - - // Query the database for the old access level if the item isn't new - if (!$isNew) - { - $query = $this->db->getQuery(true); - $query->select($this->db->quoteName('access')); - $query->from($this->db->quoteName('#__categories')); - $query->where($this->db->quoteName('id') . ' = ' . $row->id); - $this->db->setQuery($query); - - // Store the access level to determine if it changes - $this->old_access = $this->db->loadResult(); - } - - return true; - } - - /** - * Method to update the link information for items that have been changed - * from outside the edit screen. This is fired when the item is published, - * unpublished, archived, or unarchived from the list view. - * - * @param string $context The context for the content passed to the plugin. - * @param array $pks A list of primary key ids of the content that has changed state. - * @param integer $value The value of the state that the content has been changed to. - * - * @return void - * - * @since 2.5 - */ - public function onFinderChangeState($context, $pks, $value) - { - // We only want to handle categories here - if ($context != 'com_categories.category') - { - // The article published state is tied to the category - // published state so we need to look up all published states - // before we change anything. - foreach ($pks as $pk) - { - $sql = clone($this->_getStateQuery()); - $sql->where('c.id = ' . (int) $pk); - - // Get the published states. - $this->db->setQuery($sql); - $item = $this->db->loadObject(); - - // Translate the state. - $temp = $this->translateState($value); - - // Update the item. - $this->change($pk, 'state', $temp); - - // Queue the item to be reindexed. - FinderIndexerQueue::add($context, $pk, JFactory::getDate()->toMySQL()); - } - } - - // Handle when the plugin is disabled - if ($context == 'com_plugins.plugin' && $value === 0) - { - // Since multiple plugins may be disabled at a time, we need to check first - // that we're handling categories - foreach ($pks as $pk) - { - if ($this->getPluginType($pk) == 'categories') - { - // Get all of the categories to unindex them - $sql = clone($this->_getStateQuery()); - $this->db->setQuery($sql); - $items = $this->db->loadColumn(); - - // Remove each item - foreach ($items as $item) - { - $this->remove($item); - } - } - } - } - } - - /** - * Method to index an item. The item must be a FinderIndexerResult object. - * - * @param FinderIndexerResult $item The item to index as an FinderIndexerResult object. - * - * @return void - * - * @since 2.5 - * @throws Exception on database error. - */ - protected function index(FinderIndexerResult $item) - { - // Check if the extension is enabled - if (JComponentHelper::isEnabled($this->extension) == false) - { - return; - } - - // Need to import component route helpers dynamically, hence the reason it's handled here - if (JFile::exists(JPATH_SITE . '/components/' . $item->extension . '/helpers/route.php')) - { - include_once JPATH_SITE . '/components/' . $item->extension . '/helpers/route.php'; - } - - $extension = ucfirst(substr($item->extension, 4)); - - // Initialize the item parameters. - $registry = new JRegistry; - $registry->loadString($item->params); - $item->params = $registry; - - // Trigger the onContentPrepare event. - $item->summary = FinderIndexerHelper::prepareContent($item->summary, $item->params); - - // Build the necessary route and path information. - $item->url = $this->getURL($item->id, $item->extension, $this->layout); - if (class_exists($extension . 'HelperRoute') && method_exists($extension . 'HelperRoute', 'getCategoryRoute')) - { - $class = $extension . 'HelperRoute'; - - // This is necessary for PHP 5.2 compatibility - $item->route = call_user_func(array($class, 'getCategoryRoute'), $item->id); - - // Use this when PHP 5.3 is minimum supported - //$item->route = $class::getCategoryRoute($item->id); - } - else - { - $item->route = ContentHelperRoute::getCategoryRoute($item->slug, $item->catid); - } - $item->path = FinderIndexerHelper::getContentPath($item->route); - - // Get the menu title if it exists. - $title = $this->getItemMenuTitle($item->url); - - // Adjust the title if necessary. - if (!empty($title) && $this->params->get('use_menu_title', true)) - { - $item->title = $title; - } - - // Translate the state. Categories should only be published if the section is published. - $item->state = $this->translateState($item->state); - - // Set the language. - $item->language = $item->params->get('language', FinderIndexerHelper::getDefaultLanguage()); - - // Add the type taxonomy data. - $item->addTaxonomy('Type', 'Category'); - - // Get content extras. - FinderIndexerHelper::getContentExtras($item); - - // Index the item. - FinderIndexer::index($item); - } - - /** - * Method to setup the indexer to be run. - * - * @return boolean True on success. - * - * @since 2.5 - */ - protected function setup() - { - // Load com_content route helper as it is the fallback for routing in the indexer in this instance. - include_once JPATH_SITE . '/components/com_content/helpers/route.php'; - - return true; - } - - /** - * Method to get the SQL query used to retrieve the list of content items. - * - * @param mixed $sql A JDatabaseQuery object or null. - * - * @return JDatabaseQuery A database object. - * - * @since 2.5 - */ - protected function getListQuery($sql = null) - { - $db = JFactory::getDbo(); - // Check if we can use the supplied SQL query. - $sql = is_a($sql, 'JDatabaseQuery') ? $sql : $db->getQuery(true); - $sql->select('a.id, a.title, a.alias, a.description AS summary, a.extension'); - $sql->select('a.created_time AS start_date, a.published AS state, a.access, a.params'); - $sql->select('CASE WHEN CHAR_LENGTH(a.alias) THEN ' . $sql->concatenate(array('a.id', 'a.alias'), ':') . ' ELSE a.id END as slug'); - $sql->from('#__categories AS a'); - $sql->where($db->quoteName('a.id') . ' > 1'); - - return $sql; - } - - /** - * Method to get a SQL query to load the published and access states for - * a category and section. - * - * @return JDatabaseQuery A database object. - * - * @since 2.5 - */ - private function _getStateQuery() - { - $sql = $this->db->getQuery(true); - $sql->select($this->db->quoteName('c.id')); - $sql->select($this->db->quoteName('c.published') . ' AS cat_state'); - $sql->select($this->db->quoteName('c.access') . ' AS cat_access'); - $sql->from($this->db->quoteName('#__categories') . ' AS c'); - - return $sql; - } -} +loadLanguage(); + } + + /** + * Method to remove the link information for items that have been deleted. + * + * @param string $context The context of the action being performed. + * @param JTable $table A JTable object containing the record to be deleted + * + * @return boolean True on success. + * + * @since 2.5 + * @throws Exception on database error. + */ + public function onFinderDelete($context, $table) + { + if ($context == 'com_categories.category') + { + $id = $table->id; + } + elseif ($context == 'com_finder.index') + { + $id = $table->link_id; + } + else + { + return true; + } + // Remove the items. + return $this->remove($id); + } + + /** + * Method to determine if the access level of an item changed. + * + * @param string $context The context of the content passed to the plugin. + * @param JTable $row A JTable object + * @param boolean $isNew If the content has just been created + * + * @return boolean True on success. + * + * @since 2.5 + * @throws Exception on database error. + */ + public function onFinderAfterSave($context, $row, $isNew) + { + // We only want to handle categories here + if ($context != 'com_categories.category') + { + return true; + } + + // Check if the access levels are different + if (!$isNew && $this->old_access != $row->access) + { + $sql = clone($this->_getStateQuery()); + $sql->where('c.id = ' . (int) $row->id); + + // Get the access level. + $this->db->setQuery($sql); + $item = $this->db->loadObject(); + + // Set the access level. + $temp = max($row->access, $item->cat_access); + + // Update the item. + $this->change((int) $row->id, 'access', $temp); + + // Queue the item to be reindexed. + FinderIndexerQueue::add($context, $row->id, JFactory::getDate()->toMySQL()); + } + + return true; + } + + /** + * Method to reindex the link information for an item that has been saved. + * This event is fired before the data is actually saved so we are going + * to queue the item to be indexed later. + * + * @param string $context The context of the content passed to the plugin. + * @param JTable $row A JTable object + * @param boolean $isNew If the content is just about to be created + * + * @return boolean True on success. + * + * @since 2.5 + * @throws Exception on database error. + */ + public function onFinderBeforeSave($context, $row, $isNew) + { + // We only want to handle categories here + if ($context != 'com_categories.category') + { + return true; + } + + // Query the database for the old access level if the item isn't new + if (!$isNew) + { + $query = $this->db->getQuery(true); + $query->select($this->db->quoteName('access')); + $query->from($this->db->quoteName('#__categories')); + $query->where($this->db->quoteName('id') . ' = ' . $row->id); + $this->db->setQuery($query); + + // Store the access level to determine if it changes + $this->old_access = $this->db->loadResult(); + } + + return true; + } + + /** + * Method to update the link information for items that have been changed + * from outside the edit screen. This is fired when the item is published, + * unpublished, archived, or unarchived from the list view. + * + * @param string $context The context for the content passed to the plugin. + * @param array $pks A list of primary key ids of the content that has changed state. + * @param integer $value The value of the state that the content has been changed to. + * + * @return void + * + * @since 2.5 + */ + public function onFinderChangeState($context, $pks, $value) + { + // We only want to handle categories here + if ($context != 'com_categories.category') + { + // The article published state is tied to the category + // published state so we need to look up all published states + // before we change anything. + foreach ($pks as $pk) + { + $sql = clone($this->_getStateQuery()); + $sql->where('c.id = ' . (int) $pk); + + // Get the published states. + $this->db->setQuery($sql); + $item = $this->db->loadObject(); + + // Translate the state. + $temp = $this->translateState($value); + + // Update the item. + $this->change($pk, 'state', $temp); + + // Queue the item to be reindexed. + FinderIndexerQueue::add($context, $pk, JFactory::getDate()->toMySQL()); + } + } + + // Handle when the plugin is disabled + if ($context == 'com_plugins.plugin' && $value === 0) + { + // Since multiple plugins may be disabled at a time, we need to check first + // that we're handling categories + foreach ($pks as $pk) + { + if ($this->getPluginType($pk) == 'categories') + { + // Get all of the categories to unindex them + $sql = clone($this->_getStateQuery()); + $this->db->setQuery($sql); + $items = $this->db->loadColumn(); + + // Remove each item + foreach ($items as $item) + { + $this->remove($item); + } + } + } + } + } + + /** + * Method to index an item. The item must be a FinderIndexerResult object. + * + * @param FinderIndexerResult $item The item to index as an FinderIndexerResult object. + * + * @return void + * + * @since 2.5 + * @throws Exception on database error. + */ + protected function index(FinderIndexerResult $item) + { + // Check if the extension is enabled + if (JComponentHelper::isEnabled($this->extension) == false) + { + return; + } + + // Need to import component route helpers dynamically, hence the reason it's handled here + if (JFile::exists(JPATH_SITE . '/components/' . $item->extension . '/helpers/route.php')) + { + include_once JPATH_SITE . '/components/' . $item->extension . '/helpers/route.php'; + } + + $extension = ucfirst(substr($item->extension, 4)); + + // Initialize the item parameters. + $registry = new JRegistry; + $registry->loadString($item->params); + $item->params = $registry; + + $registry = new JRegistry; + $registry->loadString($item->metadata); + $item->metadata = $registry; + + /* + * Add the meta-data processing instructions based on the newsfeeds + * configuration parameters. + */ + // Add the meta-author. + $item->metaauthor = $item->metadata->get('author'); + + // Handle the link to the meta-data. + $item->addInstruction(FinderIndexer::META_CONTEXT, 'link'); + $item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey'); + $item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc'); + $item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor'); + $item->addInstruction(FinderIndexer::META_CONTEXT, 'author'); + //$item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_alias'); + + // Trigger the onContentPrepare event. + $item->summary = FinderIndexerHelper::prepareContent($item->summary, $item->params); + + // Build the necessary route and path information. + $item->url = $this->getURL($item->id, $item->extension, $this->layout); + if (class_exists($extension . 'HelperRoute') && method_exists($extension . 'HelperRoute', 'getCategoryRoute')) + { + $class = $extension . 'HelperRoute'; + + // This is necessary for PHP 5.2 compatibility + $item->route = call_user_func(array($class, 'getCategoryRoute'), $item->id); + + // Use this when PHP 5.3 is minimum supported + //$item->route = $class::getCategoryRoute($item->id); + } + else + { + $item->route = ContentHelperRoute::getCategoryRoute($item->slug, $item->catid); + } + $item->path = FinderIndexerHelper::getContentPath($item->route); + + // Get the menu title if it exists. + $title = $this->getItemMenuTitle($item->url); + + // Adjust the title if necessary. + if (!empty($title) && $this->params->get('use_menu_title', true)) + { + $item->title = $title; + } + + // Translate the state. Categories should only be published if the parent category is published. + $item->state = $this->translateState($item->state); + + // Set the language. + $item->language = $item->params->get('language', FinderIndexerHelper::getDefaultLanguage()); + + // Add the type taxonomy data. + $item->addTaxonomy('Type', 'Category'); + + // Add the language taxonomy data. + $item->addTaxonomy('Language', $item->language); + + // Get content extras. + FinderIndexerHelper::getContentExtras($item); + + // Index the item. + FinderIndexer::index($item); + } + + /** + * Method to setup the indexer to be run. + * + * @return boolean True on success. + * + * @since 2.5 + */ + protected function setup() + { + // Load com_content route helper as it is the fallback for routing in the indexer in this instance. + include_once JPATH_SITE . '/components/com_content/helpers/route.php'; + + return true; + } + + /** + * Method to get the SQL query used to retrieve the list of content items. + * + * @param mixed $sql A JDatabaseQuery object or null. + * + * @return JDatabaseQuery A database object. + * + * @since 2.5 + */ + protected function getListQuery($sql = null) + { + $db = JFactory::getDbo(); + // Check if we can use the supplied SQL query. + $sql = is_a($sql, 'JDatabaseQuery') ? $sql : $db->getQuery(true); + $sql->select('a.id, a.title, a.alias, a.description AS summary, a.extension'); + $sql->select('a.created_time AS start_date, a.published AS state, a.access, a.params'); + $sql->select('a.created_user_id AS created_by, a.modified_time AS modified, a.modified_user_id AS modified_by'); + $sql->select('a.metakey, a.metadesc, a.metadata, a.language, a.lft, a.parent_id, a.level'); + $sql->select('CASE WHEN CHAR_LENGTH(a.alias) THEN ' . $sql->concatenate(array('a.id', 'a.alias'), ':') . ' ELSE a.id END as slug'); + $sql->from('#__categories AS a'); + $sql->where($db->quoteName('a.id') . ' > 1'); + + return $sql; + } + + /** + * Method to get a SQL query to load the published and access states for + * a category. + * + * @return JDatabaseQuery A database object. + * + * @since 2.5 + */ + private function _getStateQuery() + { + $sql = $this->db->getQuery(true); + $sql->select($this->db->quoteName('c.id')); + $sql->select($this->db->quoteName('c.published') . ' AS cat_state'); + $sql->select($this->db->quoteName('c.access') . ' AS cat_access'); + $sql->from($this->db->quoteName('#__categories') . ' AS c'); + + return $sql; + } +} diff --git a/plugins/finder/contacts/contacts.php b/plugins/finder/contacts/contacts.php index 05c1627276da9..000a82d83e1ce 100644 --- a/plugins/finder/contacts/contacts.php +++ b/plugins/finder/contacts/contacts.php @@ -1,573 +1,595 @@ -loadLanguage(); - } - - /** - * Method to update the item link information when the item category is - * changed. This is fired when the item category is published or unpublished - * from the list view. - * - * @param string $extension The extension whose category has been updated. - * @param array $pks A list of primary key ids of the content that has changed state. - * @param integer $value The value of the state that the content has been changed to. - * - * @return void - * - * @since 2.5 - */ - public function onFinderCategoryChangeState($extension, $pks, $value) - { - // Make sure we're handling com_contact categories - if ($extension != 'com_contact') - { - return; - } - - // The contact published state is tied to the category - // published state so we need to look up all published states - // before we change anything. - foreach ($pks as $pk) - { - $sql = clone($this->_getStateQuery()); - $sql->where('c.id = ' . (int) $pk); - - // Get the published states. - $this->db->setQuery($sql); - $items = $this->db->loadObjectList(); - - // Adjust the state for each item within the category. - foreach ($items as $item) - { - // Translate the state. - $temp = $this->translateState($item->state, $value); - - // Update the item. - $this->change($item->id, 'state', $temp); - - // Queue the item to be reindexed. - FinderIndexerQueue::add('com_contact.contact', $item->id, JFactory::getDate()->toMySQL()); - } - } - } - - /** - * Method to remove the link information for items that have been deleted. - * - * This event will fire when contacts are deleted and when an indexed item is deleted. - * - * @param string $context The context of the action being performed. - * @param JTable $table A JTable object containing the record to be deleted - * - * @return boolean True on success. - * - * @since 2.5 - * @throws Exception on database error. - */ - public function onFinderAfterDelete($context, $table) - { - if ($context == 'com_contact.contact') - { - $id = $table->id; - } - elseif ($context == 'com_finder.index') - { - $id = $table->link_id; - } - else - { - return true; - } - // Remove the items. - return $this->remove($id); - } - - /** - * Method to determine if the access level of an item changed. - * - * @param string $context The context of the content passed to the plugin. - * @param JTable $row A JTable object - * @param boolean $isNew If the content has just been created - * - * @return boolean True on success. - * - * @since 2.5 - * @throws Exception on database error. - */ - public function onFinderAfterSave($context, $row, $isNew) - { - // We only want to handle contacts here - if ($context == 'com_contact.contact') - { - // Check if the access levels are different - if (!$isNew && $this->old_access != $row->access) - { - $sql = clone($this->_getStateQuery()); - $sql->where('a.id = ' . (int) $row->id); - - // Get the access level. - $this->db->setQuery($sql); - $item = $this->db->loadObject(); - - // Set the access level. - $temp = max($row->access, $item->cat_access); - - // Update the item. - $this->change((int) $row->id, 'access', $temp); - } - - // Queue the item to be reindexed. - FinderIndexerQueue::add($context, $row->id, JFactory::getDate()->toMySQL()); - } - - // Check for access changes in the category - if ($context == 'com_categories.category') - { - // Check if the access levels are different - if (!$isNew && $this->old_cataccess != $row->access) - { - $sql = clone($this->_getStateQuery()); - $sql->where('c.id = ' . (int) $row->id); - - // Get the access level. - $this->db->setQuery($sql); - $items = $this->db->loadObjectList(); - - // Adjust the access level for each item within the category. - foreach ($items as $item) - { - // Set the access level. - $temp = max($item->access, $row->access); - - // Update the item. - $this->change((int) $item->id, 'access', $temp); - - // Queue the item to be reindexed. - FinderIndexerQueue::add('com_contact.contact', $row->id, JFactory::getDate()->toMySQL()); - } - } - } - - return true; - } - - /** - * Method to reindex the link information for an item that has been saved. - * This event is fired before the data is actually saved so we are going - * to queue the item to be indexed later. - * - * @param string $context The context of the content passed to the plugin. - * @param JTable $row A JTable object - * @param boolean $isNew If the content is just about to be created - * - * @return boolean True on success. - * - * @since 2.5 - * @throws Exception on database error. - */ - public function onFinderBeforeSave($context, $row, $isNew) - { - // We only want to handle contacts here - if ($context == 'com_contact.contact') - { - // Query the database for the old access level if the item isn't new - if (!$isNew) - { - $query = $this->db->getQuery(true); - $query->select($this->db->quoteName('access')); - $query->from($this->db->quoteName('#__contact_details')); - $query->where($this->db->quoteName('id') . ' = ' . $row->id); - $this->db->setQuery($query); - - // Store the access level to determine if it changes - $this->old_access = $this->db->loadResult(); - } - } - - // Check for access levels from the category - if ($context == 'com_categories.category') - { - // Query the database for the old access level if the item isn't new - if (!$isNew) - { - $query = $this->db->getQuery(true); - $query->select($this->db->quoteName('access')); - $query->from($this->db->quoteName('#__categories')); - $query->where($this->db->quoteName('id') . ' = ' . $row->id); - $this->db->setQuery($query); - - // Store the access level to determine if it changes - $this->old_cataccess = $this->db->loadResult(); - } - } - - return true; - } - - /** - * Method to update the link information for items that have been changed - * from outside the edit screen. This is fired when the item is published, - * unpublished, archived, or unarchived from the list view. - * - * @param string $context The context for the content passed to the plugin. - * @param array $pks A list of primary key ids of the content that has changed state. - * @param integer $value The value of the state that the content has been changed to. - * - * @return void - * - * @since 2.5 - */ - public function onFinderChangeState($context, $pks, $value) - { - // We only want to handle contacts here - if ($context != 'com_contact.contact') - { - // The contact published state is tied to the category - // published state so we need to look up all published states - // before we change anything. - foreach ($pks as $pk) - { - $sql = clone($this->_getStateQuery()); - $sql->where('a.id = ' . (int) $pk); - - // Get the published states. - $this->db->setQuery($sql); - $item = $this->db->loadObject(); - - // Translate the state. - $temp = $this->translateState($value, $item->cat_state); - - // Update the item. - $this->change($pk, 'state', $temp); - - // Queue the item to be reindexed. - FinderIndexerQueue::add($context, $pk, JFactory::getDate()->toMySQL()); - } - } - - // Handle when the plugin is disabled - if ($context == 'com_plugins.plugin' && $value === 0) - { - // Since multiple plugins may be disabled at a time, we need to check first - // that we're handling contacts - foreach ($pks as $pk) - { - if ($this->getPluginType($pk) == 'contacts') - { - // Get all of the contacts to unindex them - $sql = clone($this->_getStateQuery()); - $this->db->setQuery($sql); - $items = $this->db->loadColumn(); - - // Remove each item - foreach ($items as $item) - { - $this->remove($item); - } - } - } - } - } - - /** - * Method to index an item. The item must be a FinderIndexerResult object. - * - * @param FinderIndexerResult $item The item to index as an FinderIndexerResult object. - * - * @return void - * - * @since 2.5 - * @throws Exception on database error. - */ - protected function index(FinderIndexerResult $item) - { - // Check if the extension is enabled - if (JComponentHelper::isEnabled($this->extension) == false) - { - return; - } - - // Initialize the item parameters. - $registry = new JRegistry; - $registry->loadString($item->params); - $item->params = $registry; - - // Let's do a little trick to get the Itemid. - $tmp = array('option' => 'com_contact', 'view' => 'contact', 'id' => $item->slug, 'catid' => $item->catslug); - ContactBuildRoute($tmp); - $Itemid = !empty($tmp['Itemid']) ? '&Itemid=' . $tmp['Itemid'] : null; - - // Build the necessary route and path information. - $item->url = $this->getURL($item->id, $this->extension, $this->layout); - $item->route = $this->getURL($item->slug, $this->extension, $this->layout) . '&catid=' . $item->catslug . $Itemid; - $item->path = FinderIndexerHelper::getContentPath($item->route); - - // Get the menu title if it exists. - $title = $this->getItemMenuTitle($item->url); - - // Adjust the title if necessary. - if (!empty($title) && $this->params->get('use_menu_title', true)) - { - $item->title = $title; - } - - /* - * Add the meta-data processing instructions based on the contact - * configuration parameters. - */ - // Handle the contact position. - if ($item->params->get('show_position', true)) - { - $item->addInstruction(FinderIndexer::META_CONTEXT, 'position'); - } - - // Handle the contact street address. - if ($item->params->get('show_street_address', true)) - { - $item->addInstruction(FinderIndexer::META_CONTEXT, 'address'); - } - - // Handle the contact city. - if ($item->params->get('show_suburb', true)) - { - $item->addInstruction(FinderIndexer::META_CONTEXT, 'city'); - } - - // Handle the contact region. - if ($item->params->get('show_state', true)) - { - $item->addInstruction(FinderIndexer::META_CONTEXT, 'region'); - } - - // Handle the contact country. - if ($item->params->get('show_country', true)) - { - $item->addInstruction(FinderIndexer::META_CONTEXT, 'country'); - } - - // Handle the contact zip code. - if ($item->params->get('show_postcode', true)) - { - $item->addInstruction(FinderIndexer::META_CONTEXT, 'zip'); - } - - // Handle the contact telephone number. - if ($item->params->get('show_telephone', true)) - { - $item->addInstruction(FinderIndexer::META_CONTEXT, 'telephone'); - } - - // Handle the contact fax number. - if ($item->params->get('show_fax', true)) - { - $item->addInstruction(FinderIndexer::META_CONTEXT, 'fax'); - } - - // Handle the contact e-mail address. - if ($item->params->get('show_email', true)) - { - $item->addInstruction(FinderIndexer::META_CONTEXT, 'email'); - } - - // Handle the contact mobile number. - if ($item->params->get('show_mobile', true)) - { - $item->addInstruction(FinderIndexer::META_CONTEXT, 'mobile'); - } - - // Handle the contact webpage. - if ($item->params->get('show_webpage', true)) - { - $item->addInstruction(FinderIndexer::META_CONTEXT, 'webpage'); - } - - // Handle the contact user name. - $item->addInstruction(FinderIndexer::META_CONTEXT, 'user'); - - // Set the language. - $item->language = FinderIndexerHelper::getDefaultLanguage(); - - // Add the type taxonomy data. - $item->addTaxonomy('Type', 'Contact'); - - // Add the category taxonomy data. - if (!empty($item->category)) - { - $item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access); - } - - // Add the region taxonomy data. - if (!empty($item->region) && $this->params->get('tax_add_region', true)) - { - $item->addTaxonomy('Region', $item->region); - } - - // Add the country taxonomy data. - if (!empty($item->country) && $this->params->get('tax_add_country', true)) - { - $item->addTaxonomy('Country', $item->country); - } - - // Get content extras. - FinderIndexerHelper::getContentExtras($item); - - // Index the item. - FinderIndexer::index($item); - } - - /** - * Method to setup the indexer to be run. - * - * @return boolean True on success. - * - * @since 2.5 - */ - protected function setup() - { - // Load dependent classes. - require_once JPATH_SITE . '/components/com_contact/router.php'; - - // This is a hack to get around the lack of a route helper. - FinderIndexerHelper::getContentPath('index.php?option=com_contact'); - - return true; - } - - /** - * Method to get the SQL query used to retrieve the list of content items. - * - * @param mixed $sql A JDatabaseQuery object or null. - * - * @return JDatabaseQuery A database object. - * - * @since 2.5 - */ - protected function getListQuery($sql = null) - { - $db = JFactory::getDbo(); - // Check if we can use the supplied SQL query. - $sql = is_a($sql, 'JDatabaseQuery') ? $sql : $db->getQuery(true); - $sql->select('a.id, a.name AS title, a.alias, con_position AS position, a.address, a.created AS start_date'); - $sql->select('a.publish_up AS publish_start_date, a.publish_down AS publish_end_date'); - $sql->select('a.suburb AS city, a.state AS region, a.country, a.postcode AS zip'); - $sql->select('a.telephone, a.fax, a.misc AS summary, a.email_to AS email, a.mobile'); - $sql->select('a.webpage, a.access, a.published AS state, a.ordering, a.params, a.catid'); - $sql->select('c.title AS category, c.published AS cat_state, c.access AS cat_access'); - $sql->select('CASE WHEN CHAR_LENGTH(a.alias) THEN ' . $sql->concatenate(array('a.id', 'a.alias'), ':') . ' ELSE a.id END as slug'); - $sql->select('CASE WHEN CHAR_LENGTH(c.alias) THEN ' . $sql->concatenate(array('c.id', 'c.alias'), ':') . ' ELSE c.id END as catslug'); - $sql->select('u.name AS user'); - $sql->from('#__contact_details AS a'); - $sql->join('LEFT', '#__categories AS c ON c.id = a.catid'); - $sql->join('LEFT', '#__users AS u ON u.id = a.user_id'); - - return $sql; - } - - /** - * Method to get the query clause for getting items to update by time. - * - * @param string $time The modified timestamp. - * - * @return JDatabaseQuery A database object. - * - * @since 2.5 - */ - protected function getUpdateQueryByTime($time) - { - /* - * The #__contact_details table does not have a modified date column - * so we need to use a different method for find new items. Our best - * bet is to order by the primary key putting the new items first. - */ - $sql = $this->db->getQuery(true); - $sql->order('a.id DESC'); - - return $sql; - } - - /** - * Method to get a SQL query to load the published and access states for - * an contact and category. - * - * @return JDatabaseQuery A database object. - * - * @since 2.5 - */ - private function _getStateQuery() - { - $sql = $this->db->getQuery(true); - $sql->select('a.id'); - $sql->select('a.published AS state, c.published AS cat_state'); - $sql->select('a.access, c.access AS cat_access'); - $sql->from('#__contact_details AS a'); - $sql->join('LEFT', '#__categories AS c ON c.id = a.catid'); - - return $sql; - } -} +loadLanguage(); + } + + /** + * Method to update the item link information when the item category is + * changed. This is fired when the item category is published or unpublished + * from the list view. + * + * @param string $extension The extension whose category has been updated. + * @param array $pks A list of primary key ids of the content that has changed state. + * @param integer $value The value of the state that the content has been changed to. + * + * @return void + * + * @since 2.5 + */ + public function onFinderCategoryChangeState($extension, $pks, $value) + { + // Make sure we're handling com_contact categories + if ($extension != 'com_contact') + { + return; + } + + // The contact published state is tied to the category + // published state so we need to look up all published states + // before we change anything. + foreach ($pks as $pk) + { + $sql = clone($this->_getStateQuery()); + $sql->where('c.id = ' . (int) $pk); + + // Get the published states. + $this->db->setQuery($sql); + $items = $this->db->loadObjectList(); + + // Adjust the state for each item within the category. + foreach ($items as $item) + { + // Translate the state. + $temp = $this->translateState($item->state, $value); + + // Update the item. + $this->change($item->id, 'state', $temp); + + // Queue the item to be reindexed. + FinderIndexerQueue::add('com_contact.contact', $item->id, JFactory::getDate()->toMySQL()); + } + } + } + + /** + * Method to remove the link information for items that have been deleted. + * + * This event will fire when contacts are deleted and when an indexed item is deleted. + * + * @param string $context The context of the action being performed. + * @param JTable $table A JTable object containing the record to be deleted + * + * @return boolean True on success. + * + * @since 2.5 + * @throws Exception on database error. + */ + public function onFinderAfterDelete($context, $table) + { + if ($context == 'com_contact.contact') + { + $id = $table->id; + } + elseif ($context == 'com_finder.index') + { + $id = $table->link_id; + } + else + { + return true; + } + // Remove the items. + return $this->remove($id); + } + + /** + * Method to determine if the access level of an item changed. + * + * @param string $context The context of the content passed to the plugin. + * @param JTable $row A JTable object + * @param boolean $isNew If the content has just been created + * + * @return boolean True on success. + * + * @since 2.5 + * @throws Exception on database error. + */ + public function onFinderAfterSave($context, $row, $isNew) + { + // We only want to handle contacts here + if ($context == 'com_contact.contact') + { + // Check if the access levels are different + if (!$isNew && $this->old_access != $row->access) + { + $sql = clone($this->_getStateQuery()); + $sql->where('a.id = ' . (int) $row->id); + + // Get the access level. + $this->db->setQuery($sql); + $item = $this->db->loadObject(); + + // Set the access level. + $temp = max($row->access, $item->cat_access); + + // Update the item. + $this->change((int) $row->id, 'access', $temp); + } + + // Queue the item to be reindexed. + FinderIndexerQueue::add($context, $row->id, JFactory::getDate()->toMySQL()); + } + + // Check for access changes in the category + if ($context == 'com_categories.category') + { + // Check if the access levels are different + if (!$isNew && $this->old_cataccess != $row->access) + { + $sql = clone($this->_getStateQuery()); + $sql->where('c.id = ' . (int) $row->id); + + // Get the access level. + $this->db->setQuery($sql); + $items = $this->db->loadObjectList(); + + // Adjust the access level for each item within the category. + foreach ($items as $item) + { + // Set the access level. + $temp = max($item->access, $row->access); + + // Update the item. + $this->change((int) $item->id, 'access', $temp); + + // Queue the item to be reindexed. + FinderIndexerQueue::add('com_contact.contact', $row->id, JFactory::getDate()->toMySQL()); + } + } + } + + return true; + } + + /** + * Method to reindex the link information for an item that has been saved. + * This event is fired before the data is actually saved so we are going + * to queue the item to be indexed later. + * + * @param string $context The context of the content passed to the plugin. + * @param JTable $row A JTable object + * @param boolean $isNew If the content is just about to be created + * + * @return boolean True on success. + * + * @since 2.5 + * @throws Exception on database error. + */ + public function onFinderBeforeSave($context, $row, $isNew) + { + // We only want to handle contacts here + if ($context == 'com_contact.contact') + { + // Query the database for the old access level if the item isn't new + if (!$isNew) + { + $query = $this->db->getQuery(true); + $query->select($this->db->quoteName('access')); + $query->from($this->db->quoteName('#__contact_details')); + $query->where($this->db->quoteName('id') . ' = ' . $row->id); + $this->db->setQuery($query); + + // Store the access level to determine if it changes + $this->old_access = $this->db->loadResult(); + } + } + + // Check for access levels from the category + if ($context == 'com_categories.category') + { + // Query the database for the old access level if the item isn't new + if (!$isNew) + { + $query = $this->db->getQuery(true); + $query->select($this->db->quoteName('access')); + $query->from($this->db->quoteName('#__categories')); + $query->where($this->db->quoteName('id') . ' = ' . $row->id); + $this->db->setQuery($query); + + // Store the access level to determine if it changes + $this->old_cataccess = $this->db->loadResult(); + } + } + + return true; + } + + /** + * Method to update the link information for items that have been changed + * from outside the edit screen. This is fired when the item is published, + * unpublished, archived, or unarchived from the list view. + * + * @param string $context The context for the content passed to the plugin. + * @param array $pks A list of primary key ids of the content that has changed state. + * @param integer $value The value of the state that the content has been changed to. + * + * @return void + * + * @since 2.5 + */ + public function onFinderChangeState($context, $pks, $value) + { + // We only want to handle contacts here + if ($context != 'com_contact.contact') + { + // The contact published state is tied to the category + // published state so we need to look up all published states + // before we change anything. + foreach ($pks as $pk) + { + $sql = clone($this->_getStateQuery()); + $sql->where('a.id = ' . (int) $pk); + + // Get the published states. + $this->db->setQuery($sql); + $item = $this->db->loadObject(); + + // Translate the state. + $temp = $this->translateState($value, $item->cat_state); + + // Update the item. + $this->change($pk, 'state', $temp); + + // Queue the item to be reindexed. + FinderIndexerQueue::add($context, $pk, JFactory::getDate()->toMySQL()); + } + } + + // Handle when the plugin is disabled + if ($context == 'com_plugins.plugin' && $value === 0) + { + // Since multiple plugins may be disabled at a time, we need to check first + // that we're handling contacts + foreach ($pks as $pk) + { + if ($this->getPluginType($pk) == 'contacts') + { + // Get all of the contacts to unindex them + $sql = clone($this->_getStateQuery()); + $this->db->setQuery($sql); + $items = $this->db->loadColumn(); + + // Remove each item + foreach ($items as $item) + { + $this->remove($item); + } + } + } + } + } + + /** + * Method to index an item. The item must be a FinderIndexerResult object. + * + * @param FinderIndexerResult $item The item to index as an FinderIndexerResult object. + * + * @return void + * + * @since 2.5 + * @throws Exception on database error. + */ + protected function index(FinderIndexerResult $item) + { + // Check if the extension is enabled + if (JComponentHelper::isEnabled($this->extension) == false) + { + return; + } + + // Initialize the item parameters. + $registry = new JRegistry; + $registry->loadString($item->params); + $item->params = $registry; + + $registry = new JRegistry; + $registry->loadString($item->metadata); + $item->metadata = $registry; + + // Let's do a little trick to get the Itemid. + $tmp = array('option' => 'com_contact', 'view' => 'contact', 'id' => $item->slug, 'catid' => $item->catslug); + ContactBuildRoute($tmp); + $Itemid = !empty($tmp['Itemid']) ? '&Itemid=' . $tmp['Itemid'] : null; + + // Build the necessary route and path information. + $item->url = $this->getURL($item->id, $this->extension, $this->layout); + $item->route = $this->getURL($item->slug, $this->extension, $this->layout) . '&catid=' . $item->catslug . $Itemid; + $item->path = FinderIndexerHelper::getContentPath($item->route); + + // Get the menu title if it exists. + $title = $this->getItemMenuTitle($item->url); + + // Adjust the title if necessary. + if (!empty($title) && $this->params->get('use_menu_title', true)) + { + $item->title = $title; + } + + /* + * Add the meta-data processing instructions based on the contact + * configuration parameters. + */ + // Add the meta-author. + $item->metaauthor = $item->metadata->get('author'); + + $item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey'); + $item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc'); + $item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor'); + $item->addInstruction(FinderIndexer::META_CONTEXT, 'author'); + $item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_alias'); + + // Handle the contact position. + if ($item->params->get('show_position', true)) + { + $item->addInstruction(FinderIndexer::META_CONTEXT, 'position'); + } + + // Handle the contact street address. + if ($item->params->get('show_street_address', true)) + { + $item->addInstruction(FinderIndexer::META_CONTEXT, 'address'); + } + + // Handle the contact city. + if ($item->params->get('show_suburb', true)) + { + $item->addInstruction(FinderIndexer::META_CONTEXT, 'city'); + } + + // Handle the contact region. + if ($item->params->get('show_state', true)) + { + $item->addInstruction(FinderIndexer::META_CONTEXT, 'region'); + } + + // Handle the contact country. + if ($item->params->get('show_country', true)) + { + $item->addInstruction(FinderIndexer::META_CONTEXT, 'country'); + } + + // Handle the contact zip code. + if ($item->params->get('show_postcode', true)) + { + $item->addInstruction(FinderIndexer::META_CONTEXT, 'zip'); + } + + // Handle the contact telephone number. + if ($item->params->get('show_telephone', true)) + { + $item->addInstruction(FinderIndexer::META_CONTEXT, 'telephone'); + } + + // Handle the contact fax number. + if ($item->params->get('show_fax', true)) + { + $item->addInstruction(FinderIndexer::META_CONTEXT, 'fax'); + } + + // Handle the contact e-mail address. + if ($item->params->get('show_email', true)) + { + $item->addInstruction(FinderIndexer::META_CONTEXT, 'email'); + } + + // Handle the contact mobile number. + if ($item->params->get('show_mobile', true)) + { + $item->addInstruction(FinderIndexer::META_CONTEXT, 'mobile'); + } + + // Handle the contact webpage. + if ($item->params->get('show_webpage', true)) + { + $item->addInstruction(FinderIndexer::META_CONTEXT, 'webpage'); + } + + // Handle the contact user name. + $item->addInstruction(FinderIndexer::META_CONTEXT, 'user'); + + // Set the language. + $item->language = FinderIndexerHelper::getDefaultLanguage(); + + // Add the type taxonomy data. + $item->addTaxonomy('Type', 'Contact'); + + // Add the category taxonomy data. + $item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access); + + // Add the language taxonomy data. + $item->addTaxonomy('Language', $item->language); + + // Add the region taxonomy data. + if (!empty($item->region) && $this->params->get('tax_add_region', true)) + { + $item->addTaxonomy('Region', $item->region); + } + + // Add the country taxonomy data. + if (!empty($item->country) && $this->params->get('tax_add_country', true)) + { + $item->addTaxonomy('Country', $item->country); + } + + // Add the position taxonomy data. + if (!empty($item->position) && $this->params->get('tax_add_position', true)) + { + $item->addTaxonomy('Position', $item->country); + } + + // Get content extras. + FinderIndexerHelper::getContentExtras($item); + + // Index the item. + FinderIndexer::index($item); + } + + /** + * Method to setup the indexer to be run. + * + * @return boolean True on success. + * + * @since 2.5 + */ + protected function setup() + { + // Load dependent classes. + require_once JPATH_SITE . '/components/com_contact/router.php'; + + // This is a hack to get around the lack of a route helper. + FinderIndexerHelper::getContentPath('index.php?option=com_contact'); + + return true; + } + + /** + * Method to get the SQL query used to retrieve the list of content items. + * + * @param mixed $sql A JDatabaseQuery object or null. + * + * @return JDatabaseQuery A database object. + * + * @since 2.5 + */ + protected function getListQuery($sql = null) + { + $db = JFactory::getDbo(); + // Check if we can use the supplied SQL query. + $sql = is_a($sql, 'JDatabaseQuery') ? $sql : $db->getQuery(true); + $sql->select('a.id, a.name AS title, a.alias, con_position AS position, a.address, a.created AS start_date'); + $sql->select('a.created_by_alias, a.modified, a.modified_by'); + $sql->select('a.metakey, a.metadesc, a.metadata, a.language'); + $sql->select('a.sortname1, a.sortname2, a.sortname3'); + $sql->select('a.publish_up AS publish_start_date, a.publish_down AS publish_end_date'); + $sql->select('a.suburb AS city, a.state AS region, a.country, a.postcode AS zip'); + $sql->select('a.telephone, a.fax, a.misc AS summary, a.email_to AS email, a.mobile'); + $sql->select('a.webpage, a.access, a.published AS state, a.ordering, a.params, a.catid'); + $sql->select('c.title AS category, c.published AS cat_state, c.access AS cat_access'); + $sql->select('CASE WHEN CHAR_LENGTH(a.alias) THEN ' . $sql->concatenate(array('a.id', 'a.alias'), ':') . ' ELSE a.id END as slug'); + $sql->select('CASE WHEN CHAR_LENGTH(c.alias) THEN ' . $sql->concatenate(array('c.id', 'c.alias'), ':') . ' ELSE c.id END as catslug'); + $sql->select('u.name AS user'); + $sql->from('#__contact_details AS a'); + $sql->join('LEFT', '#__categories AS c ON c.id = a.catid'); + $sql->join('LEFT', '#__users AS u ON u.id = a.user_id'); + + return $sql; + } + + /** + * Method to get the query clause for getting items to update by time. + * + * @param string $time The modified timestamp. + * + * @return JDatabaseQuery A database object. + * + * @since 2.5 + */ + protected function getUpdateQueryByTime($time) + { + /* + * The #__contact_details table does not have a modified date column + * so we need to use a different method for find new items. Our best + * bet is to order by the primary key putting the new items first. + */ + $sql = $this->db->getQuery(true); + $sql->order('a.id DESC'); + + return $sql; + } + + /** + * Method to get a SQL query to load the published and access states for + * an contact and category. + * + * @return JDatabaseQuery A database object. + * + * @since 2.5 + */ + private function _getStateQuery() + { + $sql = $this->db->getQuery(true); + $sql->select('a.id'); + $sql->select('a.published AS state, c.published AS cat_state'); + $sql->select('a.access, c.access AS cat_access'); + $sql->from('#__contact_details AS a'); + $sql->join('LEFT', '#__categories AS c ON c.id = a.catid'); + + return $sql; + } +} diff --git a/plugins/finder/content/content.php b/plugins/finder/content/content.php index f9ca27678de26..9dbf49174c396 100644 --- a/plugins/finder/content/content.php +++ b/plugins/finder/content/content.php @@ -1,498 +1,494 @@ -loadLanguage(); - } - - /** - * Method to update the item link information when the item category is - * changed. This is fired when the item category is published or unpublished - * from the list view. - * - * @param string $extension The extension whose category has been updated. - * @param array $pks A list of primary key ids of the content that has changed state. - * @param integer $value The value of the state that the content has been changed to. - * - * @return void - * - * @since 2.5 - */ - public function onFinderCategoryChangeState($extension, $pks, $value) - { - // Make sure we're handling com_content categories - if ($extension != 'com_content') - { - return; - } - - // The article published state is tied to the category - // published state so we need to look up all published states - // before we change anything. - foreach ($pks as $pk) - { - $sql = clone($this->_getStateQuery()); - $sql->where('c.id = ' . (int) $pk); - - // Get the published states. - $this->db->setQuery($sql); - $items = $this->db->loadObjectList(); - - // Adjust the state for each item within the category. - foreach ($items as $item) - { - // Translate the state. - $temp = $this->translateState($item->state, $value); - - // Update the item. - $this->change($item->id, 'state', $temp); - - // Queue the item to be reindexed. -// FinderIndexerQueue::add('com_content.article', $item->id, JFactory::getDate()->toMySQL()); - } - } - } - - /** - * Method to remove the link information for items that have been deleted. - * - * @param string $context The context of the action being performed. - * @param JTable $table A JTable object containing the record to be deleted - * - * @return boolean True on success. - * - * @since 2.5 - * @throws Exception on database error. - */ - public function onFinderAfterDelete($context, $table) - { - if ($context == 'com_content.article') - { - $id = $table->id; - } - elseif ($context == 'com_finder.index') - { - $id = $table->link_id; - } - else - { - return true; - } - // Remove the items. - return $this->remove($id); - } - - /** - * Method to determine if the access level of an item changed. - * - * @param string $context The context of the content passed to the plugin. - * @param JTable $row A JTable object - * @param boolean $isNew If the content has just been created - * - * @return boolean True on success. - * - * @since 2.5 - * @throws Exception on database error. - */ - public function onFinderAfterSave($context, $row, $isNew) - { - // We only want to handle articles here - if ($context == 'com_content.article') - { - // Check if the access levels are different - if (!$isNew && $this->old_access != $row->access) - { - $sql = clone($this->_getStateQuery()); - $sql->where('a.id = ' . (int) $row->id); - - // Get the access level. - $this->db->setQuery($sql); - $item = $this->db->loadObject(); - - // Set the access level. - $temp = max($row->access, $item->cat_access); - - // Update the item. - $this->change((int) $row->id, 'access', $temp); - } - - // Queue the item to be reindexed. -// FinderIndexerQueue::add($context, $row->id, JFactory::getDate()->toMySQL()); - - // Run the setup method. - $this->setup(); - - // Get the item. - $item = $this->getItem($row->id); - - // Index the item. - $this->index($item); - - } - - // Check for access changes in the category - if ($context == 'com_categories.category') - { - // Check if the access levels are different - if (!$isNew && $this->old_cataccess != $row->access) - { - $sql = clone($this->_getStateQuery()); - $sql->where('c.id = ' . (int) $row->id); - - // Get the access level. - $this->db->setQuery($sql); - $items = $this->db->loadObjectList(); - - // Adjust the access level for each item within the category. - foreach ($items as $item) - { - // Set the access level. - $temp = max($item->access, $row->access); - - // Update the item. - $this->change((int) $item->id, 'access', $temp); - - // Queue the item to be reindexed. -// FinderIndexerQueue::add('com_content.article', $row->id, JFactory::getDate()->toMySQL()); - } - } - } - - return true; - } - - /** - * Method to reindex the link information for an item that has been saved. - * This event is fired before the data is actually saved so we are going - * to queue the item to be indexed later. - * - * @param string $context The context of the content passed to the plugin. - * @param JTable $row A JTable object - * @param boolean $isNew If the content is just about to be created - * - * @return boolean True on success. - * - * @since 2.5 - * @throws Exception on database error. - */ - public function onFinderBeforeSave($context, $row, $isNew) - { - // We only want to handle articles here - if ($context == 'com_content.article') - { - // Query the database for the old access level if the item isn't new - if (!$isNew) - { - $query = $this->db->getQuery(true); - $query->select($this->db->quoteName('access')); - $query->from($this->db->quoteName('#__content')); - $query->where($this->db->quoteName('id') . ' = ' . (int)$row->id); - $this->db->setQuery($query); - - // Store the access level to determine if it changes - $this->old_access = $this->db->loadResult(); - } - } - - // Check for access levels from the category - if ($context == 'com_categories.category') - { - // Query the database for the old access level if the item isn't new - if (!$isNew) - { - $query = $this->db->getQuery(true); - $query->select($this->db->quoteName('access')); - $query->from($this->db->quoteName('#__categories')); - $query->where($this->db->quoteName('id') . ' = ' . (int)$row->id); - $this->db->setQuery($query); - - // Store the access level to determine if it changes - $this->old_cataccess = $this->db->loadResult(); - } - } - - return true; - } - - /** - * Method to update the link information for items that have been changed - * from outside the edit screen. This is fired when the item is published, - * unpublished, archived, or unarchived from the list view. - * - * @param string $context The context for the content passed to the plugin. - * @param array $pks A list of primary key ids of the content that has changed state. - * @param integer $value The value of the state that the content has been changed to. - * - * @return void - * - * @since 2.5 - */ - public function onFinderChangeState($context, $pks, $value) - { - // We only want to handle articles here - if ($context != 'com_content.article') - { - // The article published state is tied to the category - // published state so we need to look up all published states - // before we change anything. - foreach ($pks as $pk) - { - $sql = clone($this->_getStateQuery()); - $sql->where('a.id = ' . (int) $pk); - - // Get the published states. - $this->db->setQuery($sql); - $item = $this->db->loadObject(); - - // Translate the state. - $temp = $this->translateState($value, $item->cat_state); - - // Update the item. - $this->change($pk, 'state', $temp); - - // Queue the item to be reindexed. -// FinderIndexerQueue::add($context, $pk, JFactory::getDate()->toMySQL()); - } - } - - // Handle when the plugin is disabled - if ($context == 'com_plugins.plugin' && $value === 0) - { - // Since multiple plugins may be disabled at a time, we need to check first - // that we're handling articles - foreach ($pks as $pk) - { - if ($this->getPluginType($pk) == 'content') - { - // Get all of the articles to unindex them - $sql = clone($this->_getStateQuery()); - $this->db->setQuery($sql); - $items = $this->db->loadColumn(); - - // Remove each item - foreach ($items as $item) - { - $this->remove($item); - } - } - } - } - } - - /** - * Method to index an item. The item must be a FinderIndexerResult object. - * - * @param FinderIndexerResult $item The item to index as an FinderIndexerResult object. - * - * @return void - * - * @since 2.5 - * @throws Exception on database error. - */ - protected function index(FinderIndexerResult $item) - { - // Check if the extension is enabled - if (JComponentHelper::isEnabled($this->extension) == false) - { - return; - } - - // Initialize the item parameters. - $registry = new JRegistry; - $registry->loadString($item->params); - $item->params = JComponentHelper::getParams('com_content', true); - $item->params->merge($registry); - - $registry = new JRegistry; - $registry->loadString($item->metadata); - $item->metadata = $registry; - - // Trigger the onContentPrepare event. - $item->summary = FinderIndexerHelper::prepareContent($item->summary, $item->params); - $item->body = FinderIndexerHelper::prepareContent($item->body, $item->params); - - // Build the necessary route and path information. - $item->url = $this->getURL($item->id, $this->extension, $this->layout); - $item->route = ContentHelperRoute::getArticleRoute($item->slug, $item->catslug); - $item->path = FinderIndexerHelper::getContentPath($item->route); - - // Get the menu title if it exists. - $title = $this->getItemMenuTitle($item->url); - - // Adjust the title if necessary. - if (!empty($title) && $this->params->get('use_menu_title', true)) - { - $item->title = $title; - } - - // Add the meta-author. - $item->metaauthor = $item->metadata->get('author'); - - // Add the meta-data processing instructions. - $item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey'); - $item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc'); - $item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor'); - $item->addInstruction(FinderIndexer::META_CONTEXT, 'author'); - $item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_alias'); - - // Translate the state. Articles should only be published if the category is published. - $item->state = $this->translateState($item->state, $item->cat_state); - - // Set the language. - $item->language = $item->params->get('language', FinderIndexerHelper::getDefaultLanguage()); - - // Add the type taxonomy data. - $item->addTaxonomy('Type', 'Article'); - - // Add the author taxonomy data. - if (!empty($item->author) || !empty($item->created_by_alias)) - { - $item->addTaxonomy('Author', !empty($item->created_by_alias) ? $item->created_by_alias : $item->author); - } - - // Add the category taxonomy data. - if (!empty($item->category)) - { - $item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access); - } - else - { - $item->addTaxonomy('Category', JText::_('Uncategorized')); - } - - // Get content extras. - FinderIndexerHelper::getContentExtras($item); - - // Index the item. - FinderIndexer::index($item); - } - - /** - * Method to setup the indexer to be run. - * - * @return boolean True on success. - * - * @since 2.5 - */ - protected function setup() - { - // Load dependent classes. - include_once JPATH_SITE . '/components/com_content/helpers/route.php'; - - return true; - } - - /** - * Method to get the SQL query used to retrieve the list of content items. - * - * @param mixed $sql A JDatabaseQuery object or null. - * - * @return JDatabaseQuery A database object. - * - * @since 2.5 - */ - protected function getListQuery($sql = null) - { - $db = JFactory::getDbo(); - // Check if we can use the supplied SQL query. - $sql = is_a($sql, 'JDatabaseQuery') ? $sql : $db->getQuery(true); - $sql->select('a.id, a.title, a.alias, a.introtext AS summary, a.fulltext AS body'); - $sql->select('a.state, a.catid, a.created AS start_date, a.created_by'); - $sql->select('a.created_by_alias, a.modified, a.modified_by, a.attribs AS params'); - $sql->select('a.metakey, a.metadesc, a.metadata, a.access, a.version, a.ordering'); - $sql->select('a.publish_up AS publish_start_date, a.publish_down AS publish_end_date'); - $sql->select('c.title AS category, c.published AS cat_state, c.access AS cat_access'); - $sql->select('CASE WHEN CHAR_LENGTH(a.alias) THEN ' . $sql->concatenate(array('a.id', 'a.alias'), ':') . ' ELSE a.id END as slug'); - $sql->select('CASE WHEN CHAR_LENGTH(c.alias) THEN ' . $sql->concatenate(array('c.id', 'c.alias'), ':') . ' ELSE c.id END as catslug'); - $sql->select('u.name AS author'); - $sql->from('#__content AS a'); - $sql->join('LEFT', '#__categories AS c ON c.id = a.catid'); - $sql->join('LEFT', '#__users AS u ON u.id = a.created_by'); - - return $sql; - } - - /** - * Method to get a SQL query to load the published and access states for - * an article and category. - * - * @return JDatabaseQuery A database object. - * - * @since 2.5 - */ - private function _getStateQuery() - { - $sql = $this->db->getQuery(true); - $sql->select('a.id'); - $sql->select('a.state, c.published AS cat_state'); - $sql->select('a.access, c.access AS cat_access'); - $sql->from('#__content AS a'); - $sql->join('LEFT', '#__categories AS c ON c.id = a.catid'); - - return $sql; - } -} +loadLanguage(); + } + + /** + * Method to update the item link information when the item category is + * changed. This is fired when the item category is published or unpublished + * from the list view. + * + * @param string $extension The extension whose category has been updated. + * @param array $pks A list of primary key ids of the content that has changed state. + * @param integer $value The value of the state that the content has been changed to. + * + * @return void + * + * @since 2.5 + */ + public function onFinderCategoryChangeState($extension, $pks, $value) + { + // Make sure we're handling com_content categories + if ($extension != 'com_content') + { + return; + } + + // The article published state is tied to the category + // published state so we need to look up all published states + // before we change anything. + foreach ($pks as $pk) + { + $sql = clone($this->_getStateQuery()); + $sql->where('c.id = ' . (int) $pk); + + // Get the published states. + $this->db->setQuery($sql); + $items = $this->db->loadObjectList(); + + // Adjust the state for each item within the category. + foreach ($items as $item) + { + // Translate the state. + $temp = $this->translateState($item->state, $value); + + // Update the item. + $this->change($item->id, 'state', $temp); + + // Queue the item to be reindexed. +// FinderIndexerQueue::add('com_content.article', $item->id, JFactory::getDate()->toMySQL()); + } + } + } + + /** + * Method to remove the link information for items that have been deleted. + * + * @param string $context The context of the action being performed. + * @param JTable $table A JTable object containing the record to be deleted + * + * @return boolean True on success. + * + * @since 2.5 + * @throws Exception on database error. + */ + public function onFinderAfterDelete($context, $table) + { + if ($context == 'com_content.article') + { + $id = $table->id; + } + elseif ($context == 'com_finder.index') + { + $id = $table->link_id; + } + else + { + return true; + } + // Remove the items. + return $this->remove($id); + } + + /** + * Method to determine if the access level of an item changed. + * + * @param string $context The context of the content passed to the plugin. + * @param JTable $row A JTable object + * @param boolean $isNew If the content has just been created + * + * @return boolean True on success. + * + * @since 2.5 + * @throws Exception on database error. + */ + public function onFinderAfterSave($context, $row, $isNew) + { + // We only want to handle articles here + if ($context == 'com_content.article') + { + // Check if the access levels are different + if (!$isNew && $this->old_access != $row->access) + { + $sql = clone($this->_getStateQuery()); + $sql->where('a.id = ' . (int) $row->id); + + // Get the access level. + $this->db->setQuery($sql); + $item = $this->db->loadObject(); + + // Set the access level. + $temp = max($row->access, $item->cat_access); + + // Update the item. + $this->change((int) $row->id, 'access', $temp); + } + + // Queue the item to be reindexed. +// FinderIndexerQueue::add($context, $row->id, JFactory::getDate()->toMySQL()); + + // Run the setup method. + $this->setup(); + + // Get the item. + $item = $this->getItem($row->id); + + // Index the item. + $this->index($item); + + } + + // Check for access changes in the category + if ($context == 'com_categories.category') + { + // Check if the access levels are different + if (!$isNew && $this->old_cataccess != $row->access) + { + $sql = clone($this->_getStateQuery()); + $sql->where('c.id = ' . (int) $row->id); + + // Get the access level. + $this->db->setQuery($sql); + $items = $this->db->loadObjectList(); + + // Adjust the access level for each item within the category. + foreach ($items as $item) + { + // Set the access level. + $temp = max($item->access, $row->access); + + // Update the item. + $this->change((int) $item->id, 'access', $temp); + + // Queue the item to be reindexed. +// FinderIndexerQueue::add('com_content.article', $row->id, JFactory::getDate()->toMySQL()); + } + } + } + + return true; + } + + /** + * Method to reindex the link information for an item that has been saved. + * This event is fired before the data is actually saved so we are going + * to queue the item to be indexed later. + * + * @param string $context The context of the content passed to the plugin. + * @param JTable $row A JTable object + * @param boolean $isNew If the content is just about to be created + * + * @return boolean True on success. + * + * @since 2.5 + * @throws Exception on database error. + */ + public function onFinderBeforeSave($context, $row, $isNew) + { + // We only want to handle articles here + if ($context == 'com_content.article') + { + // Query the database for the old access level if the item isn't new + if (!$isNew) + { + $query = $this->db->getQuery(true); + $query->select($this->db->quoteName('access')); + $query->from($this->db->quoteName('#__content')); + $query->where($this->db->quoteName('id') . ' = ' . (int)$row->id); + $this->db->setQuery($query); + + // Store the access level to determine if it changes + $this->old_access = $this->db->loadResult(); + } + } + + // Check for access levels from the category + if ($context == 'com_categories.category') + { + // Query the database for the old access level if the item isn't new + if (!$isNew) + { + $query = $this->db->getQuery(true); + $query->select($this->db->quoteName('access')); + $query->from($this->db->quoteName('#__categories')); + $query->where($this->db->quoteName('id') . ' = ' . (int)$row->id); + $this->db->setQuery($query); + + // Store the access level to determine if it changes + $this->old_cataccess = $this->db->loadResult(); + } + } + + return true; + } + + /** + * Method to update the link information for items that have been changed + * from outside the edit screen. This is fired when the item is published, + * unpublished, archived, or unarchived from the list view. + * + * @param string $context The context for the content passed to the plugin. + * @param array $pks A list of primary key ids of the content that has changed state. + * @param integer $value The value of the state that the content has been changed to. + * + * @return void + * + * @since 2.5 + */ + public function onFinderChangeState($context, $pks, $value) + { + // We only want to handle articles here + if ($context != 'com_content.article') + { + // The article published state is tied to the category + // published state so we need to look up all published states + // before we change anything. + foreach ($pks as $pk) + { + $sql = clone($this->_getStateQuery()); + $sql->where('a.id = ' . (int) $pk); + + // Get the published states. + $this->db->setQuery($sql); + $item = $this->db->loadObject(); + + // Translate the state. + $temp = $this->translateState($value, $item->cat_state); + + // Update the item. + $this->change($pk, 'state', $temp); + + // Queue the item to be reindexed. +// FinderIndexerQueue::add($context, $pk, JFactory::getDate()->toMySQL()); + } + } + + // Handle when the plugin is disabled + if ($context == 'com_plugins.plugin' && $value === 0) + { + // Since multiple plugins may be disabled at a time, we need to check first + // that we're handling articles + foreach ($pks as $pk) + { + if ($this->getPluginType($pk) == 'content') + { + // Get all of the articles to unindex them + $sql = clone($this->_getStateQuery()); + $this->db->setQuery($sql); + $items = $this->db->loadColumn(); + + // Remove each item + foreach ($items as $item) + { + $this->remove($item); + } + } + } + } + } + + /** + * Method to index an item. The item must be a FinderIndexerResult object. + * + * @param FinderIndexerResult $item The item to index as an FinderIndexerResult object. + * + * @return void + * + * @since 2.5 + * @throws Exception on database error. + */ + protected function index(FinderIndexerResult $item) + { + // Check if the extension is enabled + if (JComponentHelper::isEnabled($this->extension) == false) + { + return; + } + + // Initialize the item parameters. + $registry = new JRegistry; + $registry->loadString($item->params); + $item->params = JComponentHelper::getParams('com_content', true); + $item->params->merge($registry); + + $registry = new JRegistry; + $registry->loadString($item->metadata); + $item->metadata = $registry; + + // Trigger the onContentPrepare event. + $item->summary = FinderIndexerHelper::prepareContent($item->summary, $item->params); + $item->body = FinderIndexerHelper::prepareContent($item->body, $item->params); + + // Build the necessary route and path information. + $item->url = $this->getURL($item->id, $this->extension, $this->layout); + $item->route = ContentHelperRoute::getArticleRoute($item->slug, $item->catslug); + $item->path = FinderIndexerHelper::getContentPath($item->route); + + // Get the menu title if it exists. + $title = $this->getItemMenuTitle($item->url); + + // Adjust the title if necessary. + if (!empty($title) && $this->params->get('use_menu_title', true)) + { + $item->title = $title; + } + + // Add the meta-author. + //$item->metaauthor = $item->metadata->get('author'); + + // Add the meta-data processing instructions. + $item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey'); + $item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc'); + $item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor'); + $item->addInstruction(FinderIndexer::META_CONTEXT, 'author'); + $item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_alias'); + + // Translate the state. Articles should only be published if the category is published. + $item->state = $this->translateState($item->state, $item->cat_state); + + // Set the language. + $item->language = $item->params->get('language', FinderIndexerHelper::getDefaultLanguage()); + + // Add the type taxonomy data. + $item->addTaxonomy('Type', 'Article'); + + // Add the author taxonomy data. + if (!empty($item->author) || !empty($item->created_by_alias)) + { + $item->addTaxonomy('Author', !empty($item->created_by_alias) ? $item->created_by_alias : $item->author); + } + + // Add the category taxonomy data. + $item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access); + + // Add the language taxonomy data. + $item->addTaxonomy('Language', $item->language); + + // Get content extras. + FinderIndexerHelper::getContentExtras($item); + + // Index the item. + FinderIndexer::index($item); + } + + /** + * Method to setup the indexer to be run. + * + * @return boolean True on success. + * + * @since 2.5 + */ + protected function setup() + { + // Load dependent classes. + include_once JPATH_SITE . '/components/com_content/helpers/route.php'; + + return true; + } + + /** + * Method to get the SQL query used to retrieve the list of content items. + * + * @param mixed $sql A JDatabaseQuery object or null. + * + * @return JDatabaseQuery A database object. + * + * @since 2.5 + */ + protected function getListQuery($sql = null) + { + $db = JFactory::getDbo(); + // Check if we can use the supplied SQL query. + $sql = is_a($sql, 'JDatabaseQuery') ? $sql : $db->getQuery(true); + $sql->select('a.id, a.title, a.alias, a.introtext AS summary, a.fulltext AS body'); + $sql->select('a.state, a.catid, a.created AS start_date, a.created_by'); + $sql->select('a.created_by_alias, a.modified, a.modified_by, a.attribs AS params'); + $sql->select('a.metakey, a.metadesc, a.metadata, a.access, a.version, a.ordering'); + $sql->select('a.publish_up AS publish_start_date, a.publish_down AS publish_end_date'); + $sql->select('c.title AS category, c.published AS cat_state, c.access AS cat_access'); + $sql->select('CASE WHEN CHAR_LENGTH(a.alias) THEN ' . $sql->concatenate(array('a.id', 'a.alias'), ':') . ' ELSE a.id END as slug'); + $sql->select('CASE WHEN CHAR_LENGTH(c.alias) THEN ' . $sql->concatenate(array('c.id', 'c.alias'), ':') . ' ELSE c.id END as catslug'); + $sql->select('u.name AS author'); + $sql->from('#__content AS a'); + $sql->join('LEFT', '#__categories AS c ON c.id = a.catid'); + $sql->join('LEFT', '#__users AS u ON u.id = a.created_by'); + + return $sql; + } + + /** + * Method to get a SQL query to load the published and access states for + * an article and category. + * + * @return JDatabaseQuery A database object. + * + * @since 2.5 + */ + private function _getStateQuery() + { + $sql = $this->db->getQuery(true); + $sql->select('a.id'); + $sql->select('a.state, c.published AS cat_state'); + $sql->select('a.access, c.access AS cat_access'); + $sql->from('#__content AS a'); + $sql->join('LEFT', '#__categories AS c ON c.id = a.catid'); + + return $sql; + } +} diff --git a/plugins/finder/newsfeeds/newsfeeds.php b/plugins/finder/newsfeeds/newsfeeds.php index 6c5aa4bfa25b6..f93160d53fda9 100644 --- a/plugins/finder/newsfeeds/newsfeeds.php +++ b/plugins/finder/newsfeeds/newsfeeds.php @@ -1,447 +1,471 @@ -loadLanguage(); - } - - /** - * Method to update the item link information when the item category is - * changed. This is fired when the item category is published or unpublished - * from the list view. - * - * @param string $extension The extension whose category has been updated. - * @param array $pks A list of primary key ids of the content that has changed state. - * @param integer $value The value of the state that the content has been changed to. - * - * @return void - * - * @since 2.5 - */ - public function onFinderCategoryChangeState($extension, $pks, $value) - { - // Make sure we're handling com_newsfeeds categories - if ($extension != 'com_newsfeeds') - { - return; - } - - // The news feed published state is tied to the category - // published state so we need to look up all published states - // before we change anything. - foreach ($pks as $pk) - { - $sql = clone($this->_getStateQuery()); - $sql->where('c.id = ' . (int) $pk); - - // Get the published states. - $this->db->setQuery($sql); - $items = $this->db->loadObjectList(); - - // Adjust the state for each item within the category. - foreach ($items as $item) - { - // Translate the state. - $temp = $this->translateState($item->state, $value); - - // Update the item. - $this->change($item->id, 'state', $temp); - - // Queue the item to be reindexed. - FinderIndexerQueue::add('com_newsfeeds.newsfeed', $item->id, JFactory::getDate()->toMySQL()); - } - } - } - - /** - * Method to remove the link information for items that have been deleted. - * - * @param string $context The context of the action being performed. - * @param JTable $table A JTable object containing the record to be deleted - * - * @return boolean True on success. - * - * @since 2.5 - * @throws Exception on database error. - */ - public function onFinderAfterDelete($context, $table) - { - if ($context == 'com_newsfeeds.newsfeed') - { - $id = $table->id; - } - elseif ($context == 'com_finder.index') - { - $id = $table->link_id; - } - else - { - return true; - } - // Remove the items. - return $this->remove($id); - } - - /** - * Method to determine if the access level of an item changed. - * - * @param string $context The context of the content passed to the plugin. - * @param JTable $row A JTable object - * @param boolean $isNew If the content has just been created - * - * @return boolean True on success. - * - * @since 2.5 - * @throws Exception on database error. - */ - public function onFinderAfterSave($context, $row, $isNew) - { - // We only want to handle news feeds here - if ($context == 'com_newsfeeds.newsfeed') - { - // Check if the access levels are different - if (!$isNew && $this->old_access != $row->access) - { - $sql = clone($this->_getStateQuery()); - $sql->where('a.id = ' . (int) $row->id); - - // Get the access level. - $this->db->setQuery($sql); - $item = $this->db->loadObject(); - - // Set the access level. - $temp = max($row->access, $item->cat_access); - - // Update the item. - $this->change((int) $row->id, 'access', $temp); - } - - // Queue the item to be reindexed. - FinderIndexerQueue::add($context, $row->id, JFactory::getDate()->toMySQL()); - } - - // Check for access changes in the category - if ($context == 'com_categories.category') - { - // Check if the access levels are different - if (!$isNew && $this->old_cataccess != $row->access) - { - $sql = clone($this->_getStateQuery()); - $sql->where('c.id = ' . (int) $row->id); - - // Get the access level. - $this->db->setQuery($sql); - $items = $this->db->loadObjectList(); - - // Adjust the access level for each item within the category. - foreach ($items as $item) - { - // Set the access level. - $temp = max($item->access, $row->access); - - // Update the item. - $this->change((int) $item->id, 'access', $temp); - - // Queue the item to be reindexed. - FinderIndexerQueue::add('com_newsfeeds.newsfeed', $row->id, JFactory::getDate()->toMySQL()); - } - } - } - - return true; - } - - /** - * Method to reindex the link information for an item that has been saved. - * This event is fired before the data is actually saved so we are going - * to queue the item to be indexed later. - * - * @param string $context The context of the content passed to the plugin. - * @param JTable $row A JTable object - * @param boolean $isNew If the content is just about to be created - * - * @return boolean True on success. - * - * @since 2.5 - * @throws Exception on database error. - */ - public function onFinderBeforeSave($context, $row, $isNew) - { - // We only want to handle news feeds here - if ($context == 'com_newsfeeds.newsfeed') - { - // Query the database for the old access level if the item isn't new - if (!$isNew) - { - $query = $this->db->getQuery(true); - $query->select($this->db->quoteName('access')); - $query->from($this->db->quoteName('#__newsfeeds')); - $query->where($this->db->quoteName('id') . ' = ' . $row->id); - $this->db->setQuery($query); - - // Store the access level to determine if it changes - $this->old_access = $this->db->loadResult(); - } - } - - // Check for access levels from the category - if ($context == 'com_categories.category') - { - // Query the database for the old access level if the item isn't new - if (!$isNew) - { - $query = $this->db->getQuery(true); - $query->select($this->db->quoteName('access')); - $query->from($this->db->quoteName('#__categories')); - $query->where($this->db->quoteName('id') . ' = ' . $row->id); - $this->db->setQuery($query); - - // Store the access level to determine if it changes - $this->old_cataccess = $this->db->loadResult(); - } - } - - return true; - } - - /** - * Method to update the link information for items that have been changed - * from outside the edit screen. This is fired when the item is published, - * unpublished, archived, or unarchived from the list view. - * - * @param string $context The context for the content passed to the plugin. - * @param array $pks A list of primary key ids of the content that has changed state. - * @param integer $value The value of the state that the content has been changed to. - * - * @return void - * - * @since 2.5 - */ - public function onFinderChangeState($context, $pks, $value) - { - // We only want to handle news feeds here - if ($context != 'com_newsfeeds.newsfeed') - { - // The news feed published state is tied to the category - // published state so we need to look up all published states - // before we change anything. - foreach ($pks as $pk) - { - $sql = clone($this->_getStateQuery()); - $sql->where('a.id = ' . (int) $pk); - - // Get the published states. - $this->db->setQuery($sql); - $item = $this->db->loadObject(); - - // Translate the state. - $temp = $this->translateState($value, $item->cat_state); - - // Update the item. - $this->change($pk, 'state', $temp); - - // Queue the item to be reindexed. - FinderIndexerQueue::add($context, $pk, JFactory::getDate()->toMySQL()); - } - } - - // Handle when the plugin is disabled - if ($context == 'com_plugins.plugin' && $value === 0) - { - // Since multiple plugins may be disabled at a time, we need to check first - // that we're handling news feeds - foreach ($pks as $pk) - { - if ($this->getPluginType($pk) == 'newsfeeds') - { - // Get all of the news feeds to unindex them - $sql = clone($this->_getStateQuery()); - $this->db->setQuery($sql); - $items = $this->db->loadColumn(); - - // Remove each item - foreach ($items as $item) - { - $this->remove($item); - } - } - } - } - } - - /** - * Method to index an item. The item must be a FinderIndexerResult object. - * - * @param FinderIndexerResult $item The item to index as an FinderIndexerResult object. - * - * @return void - * - * @since 2.5 - * @throws Exception on database error. - */ - protected function index(FinderIndexerResult $item) - { - // Check if the extension is enabled - if (JComponentHelper::isEnabled($this->extension) == false) - { - return; - } - - // Initialize the item parameters. - $registry = new JRegistry; - $registry->loadString($item->params); - $item->params = $registry; - - // Build the necessary route and path information. - $item->url = $this->getURL($item->id, $this->extension, $this->layout); - $item->route = NewsfeedsHelperRoute::getNewsfeedRoute($item->slug, $item->catslug); - $item->path = FinderIndexerHelper::getContentPath($item->route); - - // Handle the link to the meta-data. - $item->addInstruction(FinderIndexer::META_CONTEXT, 'link'); - - // Set the language. - $item->language = FinderIndexerHelper::getDefaultLanguage(); - - // Add the type taxonomy data. - $item->addTaxonomy('Type', 'News Feed'); - - // Add the category taxonomy data. - if (!empty($item->category)) - { - $item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access); - } - - // Get content extras. - FinderIndexerHelper::getContentExtras($item); - - // Index the item. - FinderIndexer::index($item); - } - - /** - * Method to setup the indexer to be run. - * - * @return boolean True on success. - * - * @since 2.5 - */ - protected function setup() - { - // Load dependent classes. - require_once JPATH_SITE . '/includes/application.php'; - require_once JPATH_SITE . '/components/com_newsfeeds/helpers/route.php'; - - return true; - } - - /** - * Method to get the SQL query used to retrieve the list of content items. - * - * @param mixed $sql A JDatabaseQuery object or null. - * - * @return JDatabaseQuery A database object. - * - * @since 2.5 - */ - protected function getListQuery($sql = null) - { - $db = JFactory::getDbo(); - // Check if we can use the supplied SQL query. - $sql = is_a($sql, 'JDatabaseQuery') ? $sql : $db->getQuery(true); - $sql->select('a.id, a.catid, a.name AS title, a.alias, a.link AS link'); - $sql->select('a.published AS state, a.ordering, a.created AS start_date, a.params, a.access'); - $sql->select('a.publish_up AS publish_start_date, a.publish_down AS publish_end_date'); - $sql->select('c.title AS category, c.published AS cat_state, c.access AS cat_access'); - $sql->select('CASE WHEN CHAR_LENGTH(a.alias) THEN ' . $sql->concatenate(array('a.id', 'a.alias'), ':') . ' ELSE a.id END as slug'); - $sql->select('CASE WHEN CHAR_LENGTH(c.alias) THEN ' . $sql->concatenate(array('c.id', 'c.alias'), ':') . ' ELSE c.id END as catslug'); - $sql->from('#__newsfeeds AS a'); - $sql->join('LEFT', '#__categories AS c ON c.id = a.catid'); - - return $sql; - } - - /** - * Method to get a SQL query to load the published and access states for - * a news feed and category. - * - * @return JDatabaseQuery A database object. - * - * @since 2.5 - */ - private function _getStateQuery() - { - $sql = $this->db->getQuery(true); - $sql->select('a.id'); - $sql->select('a.published AS state, c.published AS cat_state'); - $sql->select('a.access AS access, c.access AS cat_access'); - $sql->from('#__newsfeeds AS a'); - $sql->join('LEFT', '#__categories AS c ON c.id = a.catid'); - - return $sql; - } -} +loadLanguage(); + } + + /** + * Method to update the item link information when the item category is + * changed. This is fired when the item category is published or unpublished + * from the list view. + * + * @param string $extension The extension whose category has been updated. + * @param array $pks A list of primary key ids of the content that has changed state. + * @param integer $value The value of the state that the content has been changed to. + * + * @return void + * + * @since 2.5 + */ + public function onFinderCategoryChangeState($extension, $pks, $value) + { + // Make sure we're handling com_newsfeeds categories + if ($extension != 'com_newsfeeds') + { + return; + } + + // The news feed published state is tied to the category + // published state so we need to look up all published states + // before we change anything. + foreach ($pks as $pk) + { + $sql = clone($this->_getStateQuery()); + $sql->where('c.id = ' . (int) $pk); + + // Get the published states. + $this->db->setQuery($sql); + $items = $this->db->loadObjectList(); + + // Adjust the state for each item within the category. + foreach ($items as $item) + { + // Translate the state. + $temp = $this->translateState($item->state, $value); + + // Update the item. + $this->change($item->id, 'state', $temp); + + // Queue the item to be reindexed. + FinderIndexerQueue::add('com_newsfeeds.newsfeed', $item->id, JFactory::getDate()->toMySQL()); + } + } + } + + /** + * Method to remove the link information for items that have been deleted. + * + * @param string $context The context of the action being performed. + * @param JTable $table A JTable object containing the record to be deleted + * + * @return boolean True on success. + * + * @since 2.5 + * @throws Exception on database error. + */ + public function onFinderAfterDelete($context, $table) + { + if ($context == 'com_newsfeeds.newsfeed') + { + $id = $table->id; + } + elseif ($context == 'com_finder.index') + { + $id = $table->link_id; + } + else + { + return true; + } + // Remove the items. + return $this->remove($id); + } + + /** + * Method to determine if the access level of an item changed. + * + * @param string $context The context of the content passed to the plugin. + * @param JTable $row A JTable object + * @param boolean $isNew If the content has just been created + * + * @return boolean True on success. + * + * @since 2.5 + * @throws Exception on database error. + */ + public function onFinderAfterSave($context, $row, $isNew) + { + // We only want to handle news feeds here + if ($context == 'com_newsfeeds.newsfeed') + { + // Check if the access levels are different + if (!$isNew && $this->old_access != $row->access) + { + $sql = clone($this->_getStateQuery()); + $sql->where('a.id = ' . (int) $row->id); + + // Get the access level. + $this->db->setQuery($sql); + $item = $this->db->loadObject(); + + // Set the access level. + $temp = max($row->access, $item->cat_access); + + // Update the item. + $this->change((int) $row->id, 'access', $temp); + } + + // Queue the item to be reindexed. + FinderIndexerQueue::add($context, $row->id, JFactory::getDate()->toMySQL()); + } + + // Check for access changes in the category + if ($context == 'com_categories.category') + { + // Check if the access levels are different + if (!$isNew && $this->old_cataccess != $row->access) + { + $sql = clone($this->_getStateQuery()); + $sql->where('c.id = ' . (int) $row->id); + + // Get the access level. + $this->db->setQuery($sql); + $items = $this->db->loadObjectList(); + + // Adjust the access level for each item within the category. + foreach ($items as $item) + { + // Set the access level. + $temp = max($item->access, $row->access); + + // Update the item. + $this->change((int) $item->id, 'access', $temp); + + // Queue the item to be reindexed. + FinderIndexerQueue::add('com_newsfeeds.newsfeed', $row->id, JFactory::getDate()->toMySQL()); + } + } + } + + return true; + } + + /** + * Method to reindex the link information for an item that has been saved. + * This event is fired before the data is actually saved so we are going + * to queue the item to be indexed later. + * + * @param string $context The context of the content passed to the plugin. + * @param JTable $row A JTable object + * @param boolean $isNew If the content is just about to be created + * + * @return boolean True on success. + * + * @since 2.5 + * @throws Exception on database error. + */ + public function onFinderBeforeSave($context, $row, $isNew) + { + // We only want to handle news feeds here + if ($context == 'com_newsfeeds.newsfeed') + { + // Query the database for the old access level if the item isn't new + if (!$isNew) + { + $query = $this->db->getQuery(true); + $query->select($this->db->quoteName('access')); + $query->from($this->db->quoteName('#__newsfeeds')); + $query->where($this->db->quoteName('id') . ' = ' . $row->id); + $this->db->setQuery($query); + + // Store the access level to determine if it changes + $this->old_access = $this->db->loadResult(); + } + } + + // Check for access levels from the category + if ($context == 'com_categories.category') + { + // Query the database for the old access level if the item isn't new + if (!$isNew) + { + $query = $this->db->getQuery(true); + $query->select($this->db->quoteName('access')); + $query->from($this->db->quoteName('#__categories')); + $query->where($this->db->quoteName('id') . ' = ' . $row->id); + $this->db->setQuery($query); + + // Store the access level to determine if it changes + $this->old_cataccess = $this->db->loadResult(); + } + } + + return true; + } + + /** + * Method to update the link information for items that have been changed + * from outside the edit screen. This is fired when the item is published, + * unpublished, archived, or unarchived from the list view. + * + * @param string $context The context for the content passed to the plugin. + * @param array $pks A list of primary key ids of the content that has changed state. + * @param integer $value The value of the state that the content has been changed to. + * + * @return void + * + * @since 2.5 + */ + public function onFinderChangeState($context, $pks, $value) + { + // We only want to handle news feeds here + if ($context != 'com_newsfeeds.newsfeed') + { + // The news feed published state is tied to the category + // published state so we need to look up all published states + // before we change anything. + foreach ($pks as $pk) + { + $sql = clone($this->_getStateQuery()); + $sql->where('a.id = ' . (int) $pk); + + // Get the published states. + $this->db->setQuery($sql); + $item = $this->db->loadObject(); + + // Translate the state. + $temp = $this->translateState($value, $item->cat_state); + + // Update the item. + $this->change($pk, 'state', $temp); + + // Queue the item to be reindexed. + FinderIndexerQueue::add($context, $pk, JFactory::getDate()->toMySQL()); + } + } + + // Handle when the plugin is disabled + if ($context == 'com_plugins.plugin' && $value === 0) + { + // Since multiple plugins may be disabled at a time, we need to check first + // that we're handling news feeds + foreach ($pks as $pk) + { + if ($this->getPluginType($pk) == 'newsfeeds') + { + // Get all of the news feeds to unindex them + $sql = clone($this->_getStateQuery()); + $this->db->setQuery($sql); + $items = $this->db->loadColumn(); + + // Remove each item + foreach ($items as $item) + { + $this->remove($item); + } + } + } + } + } + + /** + * Method to index an item. The item must be a FinderIndexerResult object. + * + * @param FinderIndexerResult $item The item to index as an FinderIndexerResult object. + * + * @return void + * + * @since 2.5 + * @throws Exception on database error. + */ + protected function index(FinderIndexerResult $item) + { + // Check if the extension is enabled + if (JComponentHelper::isEnabled($this->extension) == false) + { + return; + } + + // Initialize the item parameters. + $registry = new JRegistry; + $registry->loadString($item->params); + $item->params = $registry; + + $registry = new JRegistry; + $registry->loadString($item->metadata); + $item->metadata = $registry; + + // Build the necessary route and path information. + $item->url = $this->getURL($item->id, $this->extension, $this->layout); + $item->route = NewsfeedsHelperRoute::getNewsfeedRoute($item->slug, $item->catslug); + $item->path = FinderIndexerHelper::getContentPath($item->route); + + /* + * Add the meta-data processing instructions based on the newsfeeds + * configuration parameters. + */ + // Add the meta-author. + $item->metaauthor = $item->metadata->get('author'); + + // Handle the link to the meta-data. + $item->addInstruction(FinderIndexer::META_CONTEXT, 'link'); + + $item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey'); + $item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc'); + $item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor'); + $item->addInstruction(FinderIndexer::META_CONTEXT, 'author'); + $item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_alias'); + // Set the language. + $item->language = FinderIndexerHelper::getDefaultLanguage(); + + // Add the type taxonomy data. + $item->addTaxonomy('Type', 'News Feed'); + + // Add the category taxonomy data. + if (!empty($item->category)) + { + $item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access); + } + + // Add the category taxonomy data. + $item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access); + + // Add the language taxonomy data. + $item->addTaxonomy('Language', $item->language); + + // Get content extras. + FinderIndexerHelper::getContentExtras($item); + + // Index the item. + FinderIndexer::index($item); + } + + /** + * Method to setup the indexer to be run. + * + * @return boolean True on success. + * + * @since 2.5 + */ + protected function setup() + { + // Load dependent classes. + require_once JPATH_SITE . '/includes/application.php'; + require_once JPATH_SITE . '/components/com_newsfeeds/helpers/route.php'; + + return true; + } + + /** + * Method to get the SQL query used to retrieve the list of content items. + * + * @param mixed $sql A JDatabaseQuery object or null. + * + * @return JDatabaseQuery A database object. + * + * @since 2.5 + */ + protected function getListQuery($sql = null) + { + $db = JFactory::getDbo(); + // Check if we can use the supplied SQL query. + $sql = is_a($sql, 'JDatabaseQuery') ? $sql : $db->getQuery(true); + $sql->select('a.id, a.catid, a.name AS title, a.alias, a.link AS link'); + $sql->select('a.published AS state, a.ordering, a.created AS start_date, a.params, a.access'); + $sql->select('a.publish_up AS publish_start_date, a.publish_down AS publish_end_date'); + $sql->select('a.metakey, a.metadesc, a.metadata, a.language'); + $sql->select('a.created_by, a.created_by_alias, a.modified, a.modified_by'); + $sql->select('c.title AS category, c.published AS cat_state, c.access AS cat_access'); + $sql->select('CASE WHEN CHAR_LENGTH(a.alias) THEN ' . $sql->concatenate(array('a.id', 'a.alias'), ':') . ' ELSE a.id END as slug'); + $sql->select('CASE WHEN CHAR_LENGTH(c.alias) THEN ' . $sql->concatenate(array('c.id', 'c.alias'), ':') . ' ELSE c.id END as catslug'); + $sql->from('#__newsfeeds AS a'); + $sql->join('LEFT', '#__categories AS c ON c.id = a.catid'); + + return $sql; + } + + /** + * Method to get a SQL query to load the published and access states for + * a news feed and category. + * + * @return JDatabaseQuery A database object. + * + * @since 2.5 + */ + private function _getStateQuery() + { + $sql = $this->db->getQuery(true); + $sql->select('a.id'); + $sql->select('a.published AS state, c.published AS cat_state'); + $sql->select('a.access AS access, c.access AS cat_access'); + $sql->from('#__newsfeeds AS a'); + $sql->join('LEFT', '#__categories AS c ON c.id = a.catid'); + + return $sql; + } +} diff --git a/plugins/finder/weblinks/weblinks.php b/plugins/finder/weblinks/weblinks.php index aaedebbcb8a80..70ea70413d00d 100644 --- a/plugins/finder/weblinks/weblinks.php +++ b/plugins/finder/weblinks/weblinks.php @@ -1,466 +1,482 @@ -loadLanguage(); - } - - /** - * Method to update the item link information when the item category is - * changed. This is fired when the item category is published or unpublished - * from the list view. - * - * @param string $extension The extension whose category has been updated. - * @param array $pks A list of primary key ids of the content that has changed state. - * @param integer $value The value of the state that the content has been changed to. - * - * @return void - * - * @since 2.5 - */ - public function onCategoryChangeState($extension, $pks, $value) - { - // Make sure we're handling com_weblinks categories - if ($extension != 'com_weblinks') - { - return; - } - - // The web link published state is tied to the category - // published state so we need to look up all published states - // before we change anything. - foreach ($pks as $pk) - { - $sql = clone($this->_getStateQuery()); - $sql->where('c.id = ' . (int) $pk); - - // Get the published states. - $this->db->setQuery($sql); - $items = $this->db->loadObjectList(); - - // Adjust the state for each item within the category. - foreach ($items as $item) - { - // Translate the state. - $temp = $this->translateState($item->state, $value); - - // Update the item. - $this->change($item->id, 'state', $temp); - - // Queue the item to be reindexed. - FinderIndexerQueue::add('com_weblinks.weblink', $item->id, JFactory::getDate()->toMySQL()); - } - } - } - - /** - * Method to remove the link information for items that have been deleted. - * - * @param string $context The context of the action being performed. - * @param JTable $table A JTable object containing the record to be deleted - * - * @return boolean True on success. - * - * @since 2.5 - * @throws Exception on database error. - */ - public function onContentAfterDelete($context, $table) - { - if ($context == 'com_weblinks.weblink') - { - $id = $table->id; - } - elseif ($context == 'com_finder.index') - { - $id = $table->link_id; - } - else - { - return true; - } - // Remove the items. - return $this->remove($id); - } - - /** - * Method to determine if the access level of an item changed. - * - * @param string $context The context of the content passed to the plugin. - * @param JTable $row A JTable object - * @param boolean $isNew If the content has just been created - * - * @return boolean True on success. - * - * @since 2.5 - * @throws Exception on database error. - */ - public function onContentAfterSave($context, $row, $isNew) - { - // We only want to handle web links here - if ($context == 'com_weblinks.weblink') - { - // Check if the access levels are different - if (!$isNew && $this->old_access != $row->access) - { - $sql = clone($this->_getStateQuery()); - $sql->where('a.id = ' . (int) $row->id); - - // Get the access level. - $this->db->setQuery($sql); - $item = $this->db->loadObject(); - - // Set the access level. - $temp = max($row->access, $item->cat_access); - - // Update the item. - $this->change((int) $row->id, 'access', $temp); - } - - // Queue the item to be reindexed. - FinderIndexerQueue::add($context, $row->id, JFactory::getDate()->toMySQL()); - } - - // Check for access changes in the category - if ($context == 'com_categories.category') - { - // Check if the access levels are different - if (!$isNew && $this->old_cataccess != $row->access) - { - $sql = clone($this->_getStateQuery()); - $sql->where('c.id = ' . (int) $row->id); - - // Get the access level. - $this->db->setQuery($sql); - $items = $this->db->loadObjectList(); - - // Adjust the access level for each item within the category. - foreach ($items as $item) - { - // Set the access level. - $temp = max($item->access, $row->access); - - // Update the item. - $this->change((int) $item->id, 'access', $temp); - - // Queue the item to be reindexed. - FinderIndexerQueue::add('com_weblinks.weblink', $row->id, JFactory::getDate()->toMySQL()); - } - } - } - - return true; - } - - /** - * Method to reindex the link information for an item that has been saved. - * This event is fired before the data is actually saved so we are going - * to queue the item to be indexed later. - * - * @param string $context The context of the content passed to the plugin. - * @param JTable $row A JTable object - * @param boolean $isNew If the content is just about to be created - * - * @return boolean True on success. - * - * @since 2.5 - * @throws Exception on database error. - */ - public function onContentBeforeSave($context, $row, $isNew) - { - // We only want to handle web links here - if ($context == 'com_weblinks.weblink') - { - // Query the database for the old access level if the item isn't new - if (!$isNew) - { - $query = $this->db->getQuery(true); - $query->select($this->db->quoteName('access')); - $query->from($this->db->quoteName('#__weblinks')); - $query->where($this->db->quoteName('id') . ' = ' . $row->id); - $this->db->setQuery($query); - - // Store the access level to determine if it changes - $this->old_access = $this->db->loadResult(); - } - } - - // Check for access levels from the category - if ($context == 'com_categories.category') - { - // Query the database for the old access level if the item isn't new - if (!$isNew) - { - $query = $this->db->getQuery(true); - $query->select($this->db->quoteName('access')); - $query->from($this->db->quoteName('#__categories')); - $query->where($this->db->quoteName('id') . ' = ' . $row->id); - $this->db->setQuery($query); - - // Store the access level to determine if it changes - $this->old_cataccess = $this->db->loadResult(); - } - } - - return true; - } - - /** - * Method to update the link information for items that have been changed - * from outside the edit screen. This is fired when the item is published, - * unpublished, archived, or unarchived from the list view. - * - * @param string $context The context for the content passed to the plugin. - * @param array $pks A list of primary key ids of the content that has changed state. - * @param integer $value The value of the state that the content has been changed to. - * - * @return void - * - * @since 2.5 - */ - public function onContentChangeState($context, $pks, $value) - { - // We only want to handle web links here - if ($context != 'com_weblinks.weblink') - { - // The web link published state is tied to the category - // published state so we need to look up all published states - // before we change anything. - foreach ($pks as $pk) - { - $sql = clone($this->_getStateQuery()); - $sql->where('a.id = ' . (int) $pk); - - // Get the published states. - $this->db->setQuery($sql); - $item = $this->db->loadObject(); - - // Translate the state. - $temp = $this->translateState($value, $item->cat_state); - - // Update the item. - $this->change($pk, 'state', $temp); - - // Queue the item to be reindexed. - FinderIndexerQueue::add($context, $pk, JFactory::getDate()->toMySQL()); - } - } - - // Handle when the plugin is disabled - if ($context == 'com_plugins.plugin' && $value === 0) - { - // Since multiple plugins may be disabled at a time, we need to check first - // that we're handling web links - foreach ($pks as $pk) - { - if ($this->getPluginType($pk) == 'weblinks') - { - // Get all of the web links to unindex them - $sql = clone($this->_getStateQuery()); - $this->db->setQuery($sql); - $items = $this->db->loadColumn(); - - // Remove each item - foreach ($items as $item) - { - $this->remove($item); - } - } - } - } - } - - /** - * Method to index an item. The item must be a FinderIndexerResult object. - * - * @param FinderIndexerResult $item The item to index as an FinderIndexerResult object. - * - * @return void - * - * @since 2.5 - * @throws Exception on database error. - */ - protected function index(FinderIndexerResult $item) - { - // Check if the extension is enabled - if (JComponentHelper::isEnabled($this->extension) == false) - { - return; - } - - // Initialize the item parameters. - $registry = new JRegistry; - $registry->loadString($item->params); - $item->params = $registry; - - // Build the necessary route and path information. - $item->url = $this->getURL($item->id, $this->extension, $this->layout); - $item->route = WeblinksHelperRoute::getWeblinkRoute($item->slug, $item->catslug); - $item->path = FinderIndexerHelper::getContentPath($item->route); - - // Handle the link to the meta-data. - $item->addInstruction(FinderIndexer::META_CONTEXT, 'link'); - - // Set the language. - $item->language = FinderIndexerHelper::getDefaultLanguage(); - - // Add the type taxonomy data. - $item->addTaxonomy('Type', 'Web Link'); - - // Add the category taxonomy data. - if (!empty($item->category)) - { - $item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access); - } - - // Get content extras. - FinderIndexerHelper::getContentExtras($item); - - // Index the item. - FinderIndexer::index($item); - } - - /** - * Method to setup the indexer to be run. - * - * @return boolean True on success. - * - * @since 2.5 - */ - protected function setup() - { - // Load dependent classes. - require_once JPATH_SITE . '/includes/application.php'; - require_once JPATH_SITE . '/components/com_weblinks/helpers/route.php'; - - return true; - } - - /** - * Method to get the SQL query used to retrieve the list of content items. - * - * @param mixed $sql A JDatabaseQuery object or null. - * - * @return JDatabaseQuery A database object. - * - * @since 2.5 - */ - protected function getListQuery($sql = null) - { - $db = JFactory::getDbo(); - // Check if we can use the supplied SQL query. - $sql = is_a($sql, 'JDatabaseQuery') ? $sql : $db->getQuery(true); - $sql->select('a.id, a.catid, a.title, a.alias, a.url AS link, a.description AS summary'); - $sql->select('a.publish_up AS publish_start_date, a.publish_down AS publish_end_date'); - $sql->select('a.state AS state, a.ordering, a.access, a.approved, a.created AS start_date, a.params'); - $sql->select('c.title AS category, c.published AS cat_state, c.access AS cat_access'); - $sql->select('CASE WHEN CHAR_LENGTH(a.alias) THEN ' . $sql->concatenate(array('a.id', 'a.alias'), ':') . ' ELSE a.id END as slug'); - $sql->select('CASE WHEN CHAR_LENGTH(c.alias) THEN ' . $sql->concatenate(array('c.id', 'c.alias'), ':') . ' ELSE c.id END as catslug'); - $sql->from('#__weblinks AS a'); - $sql->join('LEFT', '#__categories AS c ON c.id = a.catid'); - $sql->where('a.approved = 1'); - - return $sql; - } - - /** - * Method to get the query clause for getting items to update by time. - * - * @param string $time The modified timestamp. - * - * @return JDatabaseQuery A database object. - * - * @since 2.5 - */ - protected function getUpdateQueryByTime($time) - { - // Build an SQL query based on the modified time. - $sql = $this->db->getQuery(true); - $sql->where('a.date >= ' . $this->db->quote($time)); - - return $sql; - } - - /** - * Method to get a SQL query to load the published and access states for - * an web link and category. - * - * @return JDatabaseQuery A database object. - * - * @since 2.5 - */ - private function _getStateQuery() - { - $sql = $this->db->getQuery(true); - $sql->select('a.id'); - $sql->select('a.state AS state, c.published AS cat_state'); - $sql->select('a.access AS access, c.access AS cat_access'); - $sql->from('#__weblinks AS a'); - $sql->join('LEFT', '#__categories AS c ON c.id = a.catid'); - - return $sql; - } -} +loadLanguage(); + } + + /** + * Method to update the item link information when the item category is + * changed. This is fired when the item category is published or unpublished + * from the list view. + * + * @param string $extension The extension whose category has been updated. + * @param array $pks A list of primary key ids of the content that has changed state. + * @param integer $value The value of the state that the content has been changed to. + * + * @return void + * + * @since 2.5 + */ + public function onCategoryChangeState($extension, $pks, $value) + { + // Make sure we're handling com_weblinks categories + if ($extension != 'com_weblinks') + { + return; + } + + // The web link published state is tied to the category + // published state so we need to look up all published states + // before we change anything. + foreach ($pks as $pk) + { + $sql = clone($this->_getStateQuery()); + $sql->where('c.id = ' . (int) $pk); + + // Get the published states. + $this->db->setQuery($sql); + $items = $this->db->loadObjectList(); + + // Adjust the state for each item within the category. + foreach ($items as $item) + { + // Translate the state. + $temp = $this->translateState($item->state, $value); + + // Update the item. + $this->change($item->id, 'state', $temp); + + // Queue the item to be reindexed. + FinderIndexerQueue::add('com_weblinks.weblink', $item->id, JFactory::getDate()->toMySQL()); + } + } + } + + /** + * Method to remove the link information for items that have been deleted. + * + * @param string $context The context of the action being performed. + * @param JTable $table A JTable object containing the record to be deleted + * + * @return boolean True on success. + * + * @since 2.5 + * @throws Exception on database error. + */ + public function onContentAfterDelete($context, $table) + { + if ($context == 'com_weblinks.weblink') + { + $id = $table->id; + } + elseif ($context == 'com_finder.index') + { + $id = $table->link_id; + } + else + { + return true; + } + // Remove the items. + return $this->remove($id); + } + + /** + * Method to determine if the access level of an item changed. + * + * @param string $context The context of the content passed to the plugin. + * @param JTable $row A JTable object + * @param boolean $isNew If the content has just been created + * + * @return boolean True on success. + * + * @since 2.5 + * @throws Exception on database error. + */ + public function onContentAfterSave($context, $row, $isNew) + { + // We only want to handle web links here + if ($context == 'com_weblinks.weblink') + { + // Check if the access levels are different + if (!$isNew && $this->old_access != $row->access) + { + $sql = clone($this->_getStateQuery()); + $sql->where('a.id = ' . (int) $row->id); + + // Get the access level. + $this->db->setQuery($sql); + $item = $this->db->loadObject(); + + // Set the access level. + $temp = max($row->access, $item->cat_access); + + // Update the item. + $this->change((int) $row->id, 'access', $temp); + } + + // Queue the item to be reindexed. + FinderIndexerQueue::add($context, $row->id, JFactory::getDate()->toMySQL()); + } + + // Check for access changes in the category + if ($context == 'com_categories.category') + { + // Check if the access levels are different + if (!$isNew && $this->old_cataccess != $row->access) + { + $sql = clone($this->_getStateQuery()); + $sql->where('c.id = ' . (int) $row->id); + + // Get the access level. + $this->db->setQuery($sql); + $items = $this->db->loadObjectList(); + + // Adjust the access level for each item within the category. + foreach ($items as $item) + { + // Set the access level. + $temp = max($item->access, $row->access); + + // Update the item. + $this->change((int) $item->id, 'access', $temp); + + // Queue the item to be reindexed. + FinderIndexerQueue::add('com_weblinks.weblink', $row->id, JFactory::getDate()->toMySQL()); + } + } + } + + return true; + } + + /** + * Method to reindex the link information for an item that has been saved. + * This event is fired before the data is actually saved so we are going + * to queue the item to be indexed later. + * + * @param string $context The context of the content passed to the plugin. + * @param JTable $row A JTable object + * @param boolean $isNew If the content is just about to be created + * + * @return boolean True on success. + * + * @since 2.5 + * @throws Exception on database error. + */ + public function onContentBeforeSave($context, $row, $isNew) + { + // We only want to handle web links here + if ($context == 'com_weblinks.weblink') + { + // Query the database for the old access level if the item isn't new + if (!$isNew) + { + $query = $this->db->getQuery(true); + $query->select($this->db->quoteName('access')); + $query->from($this->db->quoteName('#__weblinks')); + $query->where($this->db->quoteName('id') . ' = ' . $row->id); + $this->db->setQuery($query); + + // Store the access level to determine if it changes + $this->old_access = $this->db->loadResult(); + } + } + + // Check for access levels from the category + if ($context == 'com_categories.category') + { + // Query the database for the old access level if the item isn't new + if (!$isNew) + { + $query = $this->db->getQuery(true); + $query->select($this->db->quoteName('access')); + $query->from($this->db->quoteName('#__categories')); + $query->where($this->db->quoteName('id') . ' = ' . $row->id); + $this->db->setQuery($query); + + // Store the access level to determine if it changes + $this->old_cataccess = $this->db->loadResult(); + } + } + + return true; + } + + /** + * Method to update the link information for items that have been changed + * from outside the edit screen. This is fired when the item is published, + * unpublished, archived, or unarchived from the list view. + * + * @param string $context The context for the content passed to the plugin. + * @param array $pks A list of primary key ids of the content that has changed state. + * @param integer $value The value of the state that the content has been changed to. + * + * @return void + * + * @since 2.5 + */ + public function onContentChangeState($context, $pks, $value) + { + // We only want to handle web links here + if ($context != 'com_weblinks.weblink') + { + // The web link published state is tied to the category + // published state so we need to look up all published states + // before we change anything. + foreach ($pks as $pk) + { + $sql = clone($this->_getStateQuery()); + $sql->where('a.id = ' . (int) $pk); + + // Get the published states. + $this->db->setQuery($sql); + $item = $this->db->loadObject(); + + // Translate the state. + $temp = $this->translateState($value, $item->cat_state); + + // Update the item. + $this->change($pk, 'state', $temp); + + // Queue the item to be reindexed. + FinderIndexerQueue::add($context, $pk, JFactory::getDate()->toMySQL()); + } + } + + // Handle when the plugin is disabled + if ($context == 'com_plugins.plugin' && $value === 0) + { + // Since multiple plugins may be disabled at a time, we need to check first + // that we're handling web links + foreach ($pks as $pk) + { + if ($this->getPluginType($pk) == 'weblinks') + { + // Get all of the web links to unindex them + $sql = clone($this->_getStateQuery()); + $this->db->setQuery($sql); + $items = $this->db->loadColumn(); + + // Remove each item + foreach ($items as $item) + { + $this->remove($item); + } + } + } + } + } + + /** + * Method to index an item. The item must be a FinderIndexerResult object. + * + * @param FinderIndexerResult $item The item to index as an FinderIndexerResult object. + * + * @return void + * + * @since 2.5 + * @throws Exception on database error. + */ + protected function index(FinderIndexerResult $item) + { + // Check if the extension is enabled + if (JComponentHelper::isEnabled($this->extension) == false) + { + return; + } + + // Initialize the item parameters. + $registry = new JRegistry; + $registry->loadString($item->params); + $item->params = $registry; + + $registry = new JRegistry; + $registry->loadString($item->metadata); + $item->metadata = $registry; + + // Build the necessary route and path information. + $item->url = $this->getURL($item->id, $this->extension, $this->layout); + $item->route = WeblinksHelperRoute::getWeblinkRoute($item->slug, $item->catslug); + $item->path = FinderIndexerHelper::getContentPath($item->route); + /* + * Add the meta-data processing instructions based on the newsfeeds + * configuration parameters. + */ + // Add the meta-author. + $item->metaauthor = $item->metadata->get('author'); + + // Handle the link to the meta-data. + $item->addInstruction(FinderIndexer::META_CONTEXT, 'link'); + $item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey'); + $item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc'); + $item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor'); + $item->addInstruction(FinderIndexer::META_CONTEXT, 'author'); + $item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_alias'); + // Set the language. + $item->language = FinderIndexerHelper::getDefaultLanguage(); + + // Add the type taxonomy data. + $item->addTaxonomy('Type', 'Web Link'); + + // Add the category taxonomy data. + $item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access); + + // Add the language taxonomy data. + $item->addTaxonomy('Language', $item->language); + + // Get content extras. + FinderIndexerHelper::getContentExtras($item); + + // Index the item. + FinderIndexer::index($item); + } + + /** + * Method to setup the indexer to be run. + * + * @return boolean True on success. + * + * @since 2.5 + */ + protected function setup() + { + // Load dependent classes. + require_once JPATH_SITE . '/includes/application.php'; + require_once JPATH_SITE . '/components/com_weblinks/helpers/route.php'; + + return true; + } + + /** + * Method to get the SQL query used to retrieve the list of content items. + * + * @param mixed $sql A JDatabaseQuery object or null. + * + * @return JDatabaseQuery A database object. + * + * @since 2.5 + */ + protected function getListQuery($sql = null) + { + $db = JFactory::getDbo(); + // Check if we can use the supplied SQL query. + $sql = is_a($sql, 'JDatabaseQuery') ? $sql : $db->getQuery(true); + $sql->select('a.id, a.catid, a.title, a.alias, a.url AS link, a.description AS summary'); + $sql->select('a.publish_up AS publish_start_date, a.publish_down AS publish_end_date'); + $sql->select('a.state AS state, a.ordering, a.access, a.approved, a.created AS start_date, a.params'); + $sql->select('a.metakey, a.metadesc, a.metadata, a.language'); + $sql->select('a.created_by, a.created_by_alias, a.modified, a.modified_by'); + $sql->select('c.title AS category, c.published AS cat_state, c.access AS cat_access'); + $sql->select('CASE WHEN CHAR_LENGTH(a.alias) THEN ' . $sql->concatenate(array('a.id', 'a.alias'), ':') . ' ELSE a.id END as slug'); + $sql->select('CASE WHEN CHAR_LENGTH(c.alias) THEN ' . $sql->concatenate(array('c.id', 'c.alias'), ':') . ' ELSE c.id END as catslug'); + $sql->from('#__weblinks AS a'); + $sql->join('LEFT', '#__categories AS c ON c.id = a.catid'); + $sql->where('a.approved = 1'); + + return $sql; + } + + /** + * Method to get the query clause for getting items to update by time. + * + * @param string $time The modified timestamp. + * + * @return JDatabaseQuery A database object. + * + * @since 2.5 + */ + protected function getUpdateQueryByTime($time) + { + // Build an SQL query based on the modified time. + $sql = $this->db->getQuery(true); + $sql->where('a.date >= ' . $this->db->quote($time)); + + return $sql; + } + + /** + * Method to get a SQL query to load the published and access states for + * an web link and category. + * + * @return JDatabaseQuery A database object. + * + * @since 2.5 + */ + private function _getStateQuery() + { + $sql = $this->db->getQuery(true); + $sql->select('a.id'); + $sql->select('a.state AS state, c.published AS cat_state'); + $sql->select('a.access AS access, c.access AS cat_access'); + $sql->from('#__weblinks AS a'); + $sql->join('LEFT', '#__categories AS c ON c.id = a.catid'); + + return $sql; + } +}