Skip to content

Commit

Permalink
adding ability to pass vars to the method [#100]
Browse files Browse the repository at this point in the history
  • Loading branch information
dogmatic69 committed Jan 13, 2010
1 parent f37e97f commit 7b3c68c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
23 changes: 12 additions & 11 deletions config/schema/infinitas.sql
Expand Up @@ -4,7 +4,7 @@
--
-- Host: localhost:3306

-- Generation Time: Jan 13, 2010 at 10:05 PM
-- Generation Time: Jan 13, 2010 at 10:25 PM
-- Server version: 5.1.34
-- PHP Version: 5.2.9-2

Expand Down Expand Up @@ -495,6 +495,7 @@ CREATE TABLE `core_routes` (
`controller` varchar(50) DEFAULT NULL,
`action` varchar(50) DEFAULT NULL,
`values` text NOT NULL,
`pass` varchar(100) DEFAULT NULL,
`rules` text NOT NULL,
`force_backend` tinyint(1) NOT NULL DEFAULT '0',
`force_frontend` tinyint(1) NOT NULL DEFAULT '0',
Expand All @@ -510,16 +511,16 @@ CREATE TABLE `core_routes` (
-- Dumping data for table `core_routes`
--

INSERT INTO `core_routes` VALUES(7, 0, 'Home Page', '/', '', 'blog', 'posts', '', '', '', 0, 0, 1, 2, 1, '2010-01-13 16:50:39', '2010-01-13 16:50:39');
INSERT INTO `core_routes` VALUES(8, 0, 'Pages', '/pages/*', '', '0', 'pages', 'display', '', '', 0, 0, 1, 3, 1, '2010-01-13 18:26:36', '2010-01-13 18:26:36');
INSERT INTO `core_routes` VALUES(9, 0, 'Admin Home', '/admin', 'admin', 'management', 'management', 'dashboard', '', '', 1, 0, 1, 4, 1, '2010-01-13 18:36:50', '2010-01-13 18:36:50');
INSERT INTO `core_routes` VALUES(11, 0, 'Management Home', '/admin/management', 'admin', 'management', 'management', 'dashboard', '', '', 1, 0, 1, 6, 1, '2010-01-13 18:40:23', '2010-01-13 18:42:53');
INSERT INTO `core_routes` VALUES(12, 0, 'Blog Home - Backend', '/admin/blog', 'admin', 'blog', 'posts', 'dashboard', '', '', 1, 0, 1, 7, 1, '2010-01-13 18:45:23', '2010-01-13 19:02:17');
INSERT INTO `core_routes` VALUES(13, 0, 'Blog Home - Frontend', '/blog', '', 'blog', 'posts', '', '', '', 0, 1, 1, 8, 1, '2010-01-13 18:47:07', '2010-01-13 19:10:00');
INSERT INTO `core_routes` VALUES(14, 0, 'Cms Home - Backend', '/admin/cms', 'admin', 'cms', 'categories', 'dashboard', '', '', 1, 0, 1, 9, 1, '2010-01-13 19:01:14', '2010-01-13 19:04:59');
INSERT INTO `core_routes` VALUES(15, 0, 'Cms Home - Frontend', '/cms', '', 'cms', 'contentFrontpages', '', '', '', 0, 1, 1, 10, 1, '2010-01-13 19:05:28', '2010-01-13 19:11:14');
INSERT INTO `core_routes` VALUES(16, 0, 'Newsletter Home - Backend', '/admin/newsletter', 'admin', 'newsletter', 'newsletters', 'dashboard', '', '', 1, 0, 1, 11, 1, '2010-01-13 19:18:16', '2010-01-13 19:18:16');
INSERT INTO `core_routes` VALUES(18, 0, 'Blog Test', '/p/:year/:month/:day', '', 'blog', 'posts', '', 'day:null', 'year:[12][0-9]{3}\r\nmonth:0[1-9]|1[012]\r\nday:0[1-9]|[12][0-9]|3[01]\r\n', 0, 1, 1, 12, 0, '2010-01-13 19:36:31', '2010-01-13 20:26:33');
INSERT INTO `core_routes` VALUES(7, 0, 'Home Page', '/', '', 'blog', 'posts', '', '', NULL, '', 0, 0, 1, 2, 1, '2010-01-13 16:50:39', '2010-01-13 16:50:39');
INSERT INTO `core_routes` VALUES(8, 0, 'Pages', '/pages/*', '', '0', 'pages', 'display', '', NULL, '', 0, 0, 1, 3, 1, '2010-01-13 18:26:36', '2010-01-13 18:26:36');
INSERT INTO `core_routes` VALUES(9, 0, 'Admin Home', '/admin', 'admin', 'management', 'management', 'dashboard', '', NULL, '', 1, 0, 1, 4, 1, '2010-01-13 18:36:50', '2010-01-13 18:36:50');
INSERT INTO `core_routes` VALUES(11, 0, 'Management Home', '/admin/management', 'admin', 'management', 'management', 'dashboard', '', NULL, '', 1, 0, 1, 6, 1, '2010-01-13 18:40:23', '2010-01-13 18:42:53');
INSERT INTO `core_routes` VALUES(12, 0, 'Blog Home - Backend', '/admin/blog', 'admin', 'blog', 'posts', 'dashboard', '', NULL, '', 1, 0, 1, 7, 1, '2010-01-13 18:45:23', '2010-01-13 19:02:17');
INSERT INTO `core_routes` VALUES(13, 0, 'Blog Home - Frontend', '/blog', '', 'blog', 'posts', '', '', NULL, '', 0, 1, 1, 8, 1, '2010-01-13 18:47:07', '2010-01-13 19:10:00');
INSERT INTO `core_routes` VALUES(14, 0, 'Cms Home - Backend', '/admin/cms', 'admin', 'cms', 'categories', 'dashboard', '', NULL, '', 1, 0, 1, 9, 1, '2010-01-13 19:01:14', '2010-01-13 19:04:59');
INSERT INTO `core_routes` VALUES(15, 0, 'Cms Home - Frontend', '/cms', '', 'cms', 'contentFrontpages', '', '', NULL, '', 0, 1, 1, 10, 1, '2010-01-13 19:05:28', '2010-01-13 19:11:14');
INSERT INTO `core_routes` VALUES(16, 0, 'Newsletter Home - Backend', '/admin/newsletter', 'admin', 'newsletter', 'newsletters', 'dashboard', '', NULL, '', 1, 0, 1, 11, 1, '2010-01-13 19:18:16', '2010-01-13 19:18:16');
INSERT INTO `core_routes` VALUES(18, 0, 'Blog Test', '/p/:year/:month/:day', '', 'blog', 'posts', '', 'day:null', NULL, 'year:[12][0-9]{3}\r\nmonth:0[1-9]|1[012]\r\nday:0[1-9]|[12][0-9]|3[01]\r\n', 0, 1, 1, 12, 1, '2010-01-13 19:36:31', '2010-01-13 20:26:33');

-- --------------------------------------------------------

Expand Down
11 changes: 9 additions & 2 deletions infinitas/management/models/route.php
Expand Up @@ -63,6 +63,7 @@ function getRoutes(){
'Route.controller',
'Route.action',
'Route.values',
'Route.pass',
'Route.rules',
'Route.force_backend',
'Route.force_frontend'
Expand All @@ -84,7 +85,7 @@ function getRoutes(){
$routingRules[]['Route'] = array(
'url' => $array['Route']['url'],
'values' => $this->_getValues($array['Route']),
'regex' => $this->_getRegex($array['Route']['rules'])
'regex' => $this->_getRegex($array['Route']['rules'], $array['Route']['pass'])
);
}

Expand Down Expand Up @@ -137,7 +138,7 @@ function _getValues($route = array()){
return $values;
}

function _getRegex($field){
function _getRegex($field, $pass = null){
$values = array();
if (!empty($field)) {
$_v = explode("\n", $field);
Expand All @@ -150,6 +151,12 @@ function _getRegex($field){
}
}
}

if ($pass) {
$_values = explode( ',', $pass);
$values = array_merge((array)$values, (array)$_values);
}

return $values;
}

Expand Down
1 change: 1 addition & 0 deletions infinitas/management/views/routes/admin_add.ctp
Expand Up @@ -25,6 +25,7 @@
echo $this->Form->input( 'plugin' );
echo $this->Form->input( 'controller' );
echo $this->Form->input( 'action' );
echo $this->Form->input( 'pass' );
echo $this->Form->input( 'values' );
echo $this->Form->input( 'rules' );
echo $this->Form->input( 'force_backend' );
Expand Down
1 change: 1 addition & 0 deletions infinitas/management/views/routes/admin_edit.ctp
Expand Up @@ -26,6 +26,7 @@
echo $this->Form->input( 'plugin' );
echo $this->Form->input( 'controller' );
echo $this->Form->input( 'action' );
echo $this->Form->input( 'pass' );
echo $this->Form->input( 'values' );
echo $this->Form->input( 'rules' );
echo $this->Form->input( 'force_backend' );
Expand Down

0 comments on commit 7b3c68c

Please sign in to comment.