Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Routing: Legacy Router Rule for com_newsfeeds #5503

Closed
wants to merge 60 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
56e680e
Implementing JComponentRouterAdvanced class
Hackwar Dec 16, 2014
3b80c54
Merge branch 'staging' of https://github.com/joomla/joomla-cms into c…
Hackwar Dec 16, 2014
4082a78
Implementing JComponentRouterRulesMenu class to find right Itemid
Hackwar Dec 16, 2014
72cd9e0
Call-time pass-by-reference has been removed
Hackwar Dec 16, 2014
62a056b
Merge branch 'componentrouteradvanced' of github.com:Hackwar/joomla-c…
Hackwar Dec 16, 2014
ea8ea8a
Removing JError, using Exception instead
Hackwar Dec 16, 2014
de17a6b
protecting $name and renaming register() to registerView()
Hackwar Dec 17, 2014
e3f6963
Codestyle and minor bug
Hackwar Dec 17, 2014
b3c81bb
Merge branch 'staging' of https://github.com/joomla/joomla-cms into c…
Hackwar Dec 19, 2014
0309e22
Adding removeRule, getRules and renamed $id to $key in register method
Hackwar Dec 19, 2014
fd05703
Merge branch 'componentrouteradvanced' of github.com:Hackwar/joomla-c…
Hackwar Dec 19, 2014
dc9203b
Implementing legacy router for com_newsfeeds
Hackwar Dec 23, 2014
6e9171e
Codestyle
Hackwar Dec 23, 2014
6f89554
Changing component router to retrieve, since the com_content router i…
Hackwar Dec 24, 2014
8d17e7a
Making method names consistent
Hackwar Dec 27, 2014
f0f5d5f
Merge branch 'staging' of https://github.com/joomla/joomla-cms into c…
Hackwar Dec 29, 2014
68d9424
Implementing JComponentRouterViewconfiguration for configuration of v…
Hackwar Dec 29, 2014
dacdc2e
Merge branch 'staging' of https://github.com/joomla/joomla-cms into c…
Hackwar Dec 30, 2014
260a007
Codestyle, smaller improvements, unittests for all component router c…
Hackwar Dec 30, 2014
0133947
Removing ability to have one view with different names and implementi…
Hackwar Dec 31, 2014
a677ef3
Merge branch 'componentrouteradvanced' of github.com:Hackwar/joomla-c…
Hackwar Dec 31, 2014
4ef551f
Fixes to JComponentRouterRulesMenu
Hackwar Jan 1, 2015
9ccdbb2
Small fixes and unittests for JComponentRouterRulesMenu
Hackwar Jan 1, 2015
2ae969b
Codestyle
Hackwar Jan 1, 2015
dcb5e74
Implementing new view registering method in com_newsfeeds
Hackwar Jan 1, 2015
340b1d0
Merge branch 'componentrulesitemid' of github.com:Hackwar/joomla-cms …
Hackwar Jan 1, 2015
534b640
Merge branch 'com_newsfeed_router_legacy' of github.com:Hackwar/jooml…
Hackwar Jan 1, 2015
a4f443c
Unittest improvements
Hackwar Jan 3, 2015
4932ee6
Adding get<View>Slug() and get<View>Key() methods to JComponentRouter…
Hackwar Jan 3, 2015
4621c8f
Updating unittest
Hackwar Jan 3, 2015
0d42c94
Small fixes
Hackwar Jan 4, 2015
453c652
Adding back in platform check
Hackwar Jan 4, 2015
a93ac45
Adding back in platform check
Hackwar Jan 4, 2015
4fac464
Adding back in platform check
Hackwar Jan 4, 2015
e8890a8
Adding back in platform check
Hackwar Jan 4, 2015
37615fe
Merge branch 'staging' of https://github.com/joomla/joomla-cms into c…
Hackwar Jan 9, 2015
c70fe94
Merge branch 'componentrouteradvanced' of github.com:Hackwar/joomla-c…
Hackwar Jan 9, 2015
b9e505c
Merge branch 'staging' of https://github.com/joomla/joomla-cms into c…
Hackwar Jan 9, 2015
a8326b9
Implementing feedback so far
Hackwar Jan 21, 2015
8249dbd
Merge branch 'staging' of https://github.com/joomla/joomla-cms into c…
Hackwar Mar 22, 2015
7d3d30a
Adding "covers" notation for unittests
Hackwar Mar 22, 2015
cc24aa3
Merge branch 'componentrouteradvanced' of github.com:Hackwar/joomla-c…
Hackwar Mar 22, 2015
8547041
Implementing JComponentRouterAdvanced class. Fixes #5444
Hackwar Dec 16, 2014
cd63132
Updating to latest changes to JComponentRouterView
Hackwar Mar 27, 2015
773e959
Merge branch '3.5-dev' of https://github.com/joomla/joomla-cms into c…
Hackwar Mar 27, 2015
69078a8
Joomla! Update notification email plugin. Fixes #6886.
May 2, 2015
a9a367e
Merge branch '6886' into 3.5-dev
wilsonge May 4, 2015
d543e02
Merge branch 'staging' into 3.5-dev
wilsonge May 9, 2015
1f2cfac
Merge branch 'staging' into 3.5-dev
May 9, 2015
29c7cff
Merge branch 'staging' into 3.5-dev
wilsonge May 14, 2015
834ad2c
Update to String package 1.3. Fixes #6600.
wilsonge May 14, 2015
b9b2cf3
Missing file from 834ad2c6d3cf1819a2479a451723e52cd26b1886 (Fix #6989)
mbabker May 19, 2015
53b4727
Fix unit test failure in JComponentRouterViewTest
mbabker May 19, 2015
8822d1c
Merge pull request #6990 from mbabker/35testFix
wilsonge May 20, 2015
a0df476
Merge branch 'staging' of https://github.com/joomla/joomla-cms into c…
Hackwar May 22, 2015
09b7edd
Merge branch '3.5-dev' of https://github.com/joomla/joomla-cms into c…
Hackwar May 22, 2015
7f2eb08
Fixing unittests of JComponentRouterRulesMenuTest
Hackwar May 22, 2015
1930e5f
Merge branch 'componentrulesitemid' of github.com:Hackwar/joomla-cms …
Hackwar May 27, 2015
d86ee5f
Modifying com_newsfeed to work with JComponentRouterView instead of J…
Hackwar May 27, 2015
03ffd88
Codestyle
Hackwar May 27, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
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
(452, 'plg_system_updatenotification', 'plugin', 'updatenotification', 'system', 0, 1, 1, 0, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0);
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
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
(452, 'plg_system_updatenotification', 'plugin', 'updatenotification', 'system', 0, 1, 1, 0, '', '', '', '', 0, '1970-01-01 00:00:00', 0, 0);
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SET IDENTITY_INSERT [#__extensions] ON;

INSERT [#__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])
SELECT 452, 'plg_system_updatenotification', 'plugin', 'updatenotification', 'system', 0, 1, 1, 0, '', '', '', '', 0, '1900-01-01 00:00:00', 0, 0;

SET IDENTITY_INSERT [#__extensions] OFF;
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
; Joomla! Project
; Copyright (C) 2005 - 2015 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8

PLG_SYSTEM_UPDATENOTIFICATION="System - Joomla! Update Notification"
PLG_SYSTEM_UPDATENOTIFICATION_DESCRIPTION="This plugin periodically checks for the availability of new Joomla! versions. When one is found it will send you an email, reminding you to update Joomla!. Pro Tip: You can customise the email message by overriding the language string keys PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT and PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY."

PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_LBL="Super User Emails"
PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_DESC="A comma separated list of the email addresses which will receive the update notification emails. The addresses in the list MUST belong to existing users of your site who have the Super User privilege. If none of the listed emails belogns to Super Users, or if it's left blank, all Super Users of this site will receive the update notification email."
PLG_SYSTEM_UPDATENOTIFICATION_LANGUAGE_OVERRIDE_LBL="Email language"
PLG_SYSTEM_UPDATENOTIFICATION_LANGUAGE_OVERRIDE_DESC="If you choose Auto (default), the update notification email to Super Users will be in the logged in user's front-end language at the time the plugin is triggered. In multi-language sites this can create confusion: the user's language may be one the Super User receiving the email doesn't speak. By selecting a language here you are forcing the update notification emails to be sent in this specific language."
PLG_SYSTEM_UPDATENOTIFICATION_LANGUAGE_OVERRIDE_NONE="Auto"

; You can use the following merge codes:
; [NEWVERSION] New Joomla! version, e.g. 1.2.3
; [CURVERSION] Currently installed Joomla! version, e.g. 1.2.0
; [SITENAME] Site name, as set in Global Configuration.
; [URL] URL of the site's front-end page.
; [LINK] Update URL (link to com_joomlaupdate, will request login if the Super User isn't already logged in).
; \n Newline character. Use it to start a new line in the email. NO LINE SHOULD EXCEED 300 CHARACTERS!
PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT="Joomla! Update available for [SITENAME] – [URL]"
PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY="This email IS NOT sent by Joomla.org It is sent automatically by your own site,\n[SITENAME]\n\n================================================================================\nUPDATE INFORMATION\n================================================================================\n\nYour site has discovered that there is an updated version of Joomla! available\nfor download.\n\nJoomla! version currently installed: [CURVERSION]\nJoomla! version available for installation: [NEWVERSION]\n\nThis email is sent to you by your site to remind you of this fact. The Joomla!\nproject will never contact you directly about available updates of Joomla! on\nyour site.\n\n================================================================================\nUPDATE INSTRUCTIONS\n================================================================================\n\nTo install the update on [SITENAME] please click the following link. (If the URL\nis not a link, simply copy & paste it to your browser).\n\nUpdate link: [LINK]\n\n================================================================================\nWHY AM I RECEIVING THIS EMAIL?\n================================================================================\n\nThis email has been automatically sent by a plugin provided by Joomla!, the\nsoftware which powers your site. This plugin looks for updated versions of\nJoomla! and sends an email notification to its administrators. You will receive\nseveral similar emails from your site until you either update the software or\ndisable these emails.\n\nTo disable these emails, please unpublish the 'System - Joomla! Update\nNotification' plugin in the Plugin Manager on your site.\n\nIf you do not understand what is Joomla! and what you need to do please do not\ncontact the Joomla! project. They are NOT sending you this email and they cannot\nhelp you. Instead, please contact the person who built or manages your site.\n\nIf you are the person who built or manages your website, please note that this\nplugin may have been activated automatically when you installed or updated Joomla!\non your site.\n\n================================================================================\nWHO SENT ME THIS EMAIL?\n================================================================================\n\nThis email is sent to you by your own site, [SITENAME]"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
; Joomla! Project
; Copyright (C) 2005 - 2015 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8

PLG_SYSTEM_UPDATENOTIFICATION="System - Joomla! Update Notification"
PLG_SYSTEM_UPDATENOTIFICATION_DESCRIPTION="This plugin periodically checks for the availability of new Joomla! versions. When one is found it will send you an email, reminding you to update Joomla!. Pro Tip: You can customise the email message by overriding the language string keys PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT and PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY."
273 changes: 273 additions & 0 deletions components/com_newsfeeds/helpers/legacyrouter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

/**
* Legacy routing rules class from com_newsfeeds
*
* @since 3.4
* @deprecated 4.0
*/
class NewsfeedsRouterRulesLegacy implements JComponentRouterRulesInterface
{
/**
* Constructor for this legacy router
*
* @param JComponentRouterAdvanced $router The router this rule belongs to
*
* @return void
*
* @since 3.4
* @deprecated 4.0
*/
public function __construct($router)
{
$this->router = $router;
}

/**
* Preprocess the route for the com_newsfeeds component
*
* @param array &$query An array of URL arguments
*
* @return void
*
* @since 3.4
* @deprecated 4.0
*/
public function preprocess(&$query)
{
}

/**
* Build the route for the com_newsfeeds component
*
* @param array &$query An array of URL arguments
* @param array &$segments The URL arguments to use to assemble the subsequent URL.
*
* @return void
*
* @since 3.4
* @deprecated 4.0
*/
public function build(&$query, &$segments)
{
// Get a menu item based on Itemid or currently active
$params = JComponentHelper::getParams('com_newsfeeds');
$advanced = $params->get('sef_advanced_link', 0);

if (empty($query['Itemid']))
{
$menuItem = $this->router->menu->getActive();
}
else
{
$menuItem = $this->router->menu->getItem($query['Itemid']);
}

$mView = (empty($menuItem->query['view'])) ? null : $menuItem->query['view'];
$mId = (empty($menuItem->query['id'])) ? null : $menuItem->query['id'];

if (isset($query['view']))
{
$view = $query['view'];

if (empty($query['Itemid']) || empty($menuItem) || $menuItem->component != 'com_newsfeeds')
{
$segments[] = $query['view'];
}

unset($query['view']);
}

// Are we dealing with an newsfeed that is attached to a menu item?
if (isset($query['view']) && ($mView == $query['view']) and (isset($query['id'])) and ($mId == (int) $query['id']))
{
unset($query['view']);
unset($query['catid']);
unset($query['id']);

return;
}

if (isset($view) and ($view == 'category' or $view == 'newsfeed'))
{
if ($mId != (int) $query['id'] || $mView != $view)
{
if ($view == 'newsfeed' && isset($query['catid']))
{
$catid = $query['catid'];
}
elseif (isset($query['id']))
{
$catid = $query['id'];
}

$menuCatid = $mId;
$categories = JCategories::getInstance('Newsfeeds');
$category = $categories->get($catid);

if ($category)
{
$path = $category->getPath();
$path = array_reverse($path);

$array = array();

foreach ($path as $id)
{
if ((int) $id == (int) $menuCatid)
{
break;
}

if ($advanced)
{
list($tmp, $id) = explode(':', $id, 2);
}

$array[] = $id;
}

$segments = array_merge($segments, array_reverse($array));
}

if ($view == 'newsfeed')
{
if ($advanced)
{
list($tmp, $id) = explode(':', $query['id'], 2);
}
else
{
$id = $query['id'];
}

$segments[] = $id;
}
}

unset($query['id']);
unset($query['catid']);
}

if (isset($query['layout']))
{
if (!empty($query['Itemid']) && isset($menuItem->query['layout']))
{
if ($query['layout'] == $menuItem->query['layout'])
{
unset($query['layout']);
}
}
else
{
if ($query['layout'] == 'default')
{
unset($query['layout']);
}
}
}

$total = count($segments);

for ($i = 0; $i < $total; $i++)
{
$segments[$i] = str_replace(':', '-', $segments[$i]);
}
}

/**
* Parse the segments of a URL.
*
* @param array &$segments The segments of the URL to parse.
* @param array &$vars The URL attributes to be used by the application.
*
* @return void
*
* @since 3.4
* @deprecated 4.0
*/
public function parse(&$segments, &$vars)
{
$total = count($segments);

for ($i = 0; $i < $total; $i++)
{
$segments[$i] = preg_replace('/-/', ':', $segments[$i], 1);
}

// Get the active menu item.
$item = $this->router->menu->getActive();
$params = JComponentHelper::getParams('com_newsfeeds');
$advanced = $params->get('sef_advanced_link', 0);

// Count route segments
$count = count($segments);

// Standard routing for newsfeeds.
if (!isset($item))
{
$vars['view'] = $segments[0];
$vars['id'] = $segments[$count - 1];

return;
}

// From the categories view, we can only jump to a category.
$id = (isset($item->query['id']) && $item->query['id'] > 1) ? $item->query['id'] : 'root';
$categories = JCategories::getInstance('Newsfeeds')->get($id)->getChildren();
$vars['catid'] = $id;
$vars['id'] = $id;
$found = 0;

foreach ($segments as $segment)
{
$segment = $advanced ? str_replace(':', '-', $segment) : $segment;

foreach ($categories as $category)
{
if ($category->slug == $segment || $category->alias == $segment)
{
$vars['id'] = $category->id;
$vars['catid'] = $category->id;
$vars['view'] = 'category';
$categories = $category->getChildren();
$found = 1;
break;
}
}

if ($found == 0)
{
if ($advanced)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('id'))
->from('#__newsfeeds')
->where($db->quoteName('catid') . ' = ' . (int) $vars['catid'])
->where($db->quoteName('alias') . ' = ' . $db->quote($segment));
$db->setQuery($query);
$nid = $db->loadResult();
}
else
{
$nid = $segment;
}

$vars['id'] = $nid;
$vars['view'] = 'newsfeed';
}

$found = 0;
}
}
}
Loading