Skip to content
This repository has been archived by the owner on Sep 13, 2018. It is now read-only.

Commit

Permalink
Created configs dir and included user inflections, routes and databas…
Browse files Browse the repository at this point in the history
…e settings

Finished paths.php and started dispatcher.php
  • Loading branch information
pksunkara committed Apr 23, 2010
1 parent 12e00a1 commit 7171bf5
Show file tree
Hide file tree
Showing 8 changed files with 703 additions and 4 deletions.
7 changes: 7 additions & 0 deletions app/config.php → app/configs/config.php
Expand Up @@ -36,6 +36,13 @@
*/
Configure::write('rewrite',$redirection);

/**
* Base script for all URL's
* generally index.php
* If changed here, It needs to be changed in .htaccess too
*/
Configure::write('App.base', 'index.php');

/**
* Configuration for Access control lists
* Usage: "$ACL->"
Expand Down
27 changes: 27 additions & 0 deletions app/configs/database.php
@@ -0,0 +1,27 @@
<?php
/**
* sunFW(tm) : PHP Web Development Framework (http://www.suncoding.com)
* Copyright 2010, Sun Web Dev, Inc.
*
* Licensed under The GPLv3 License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright 2010, Sun Web Dev, Inc. (http://www.suncoding.com)
* @version 1.0.0
* @modifiedby Pavan Kumar Sunkara
* @lastmodified Apr 10, 2010
* @license GPLv3
*/

define('DB_HOST', 'localhost');

define('DB_USER', 'user');

define('DB_PASS', 'password');

define('DB_NAME', 'database_name');

define('DB_PREFIX', 'prefix_');

?>
65 changes: 65 additions & 0 deletions app/configs/inflections.php
@@ -0,0 +1,65 @@
<?php
/**
* sunFW(tm) : PHP Web Development Framework (http://www.suncoding.com)
* Copyright 2010, Sun Web Dev, Inc.
*
* Licensed under The GPLv3 License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright 2010, Sun Web Dev, Inc. (http://www.suncoding.com)
* @version 1.0.0
* @modifiedby Pavan Kumar Sunkara
* @lastmodified Apr 10, 2010
* @license GPLv3
*/

/**
* This is a key => value array of regex used to match words.
* If key matches then the value is returned.
*
* $pluralRules = array('/(s)tatus$/i' => '\1\2tatuses', '/^(ox)$/i' => '\1\2en', '/([m|l])ouse$/i' => '\1ice');
*/
$pluralRules = array();

/**
* This is a key only array of plural words that should not be inflected.
* Notice the last comma
*
* $uninflectedPlural = array('.*[nrlm]ese', '.*deer', '.*fish', '.*measles', '.*ois', '.*pox');
*/
$uninflectedPlural = array();

/**
* This is a key => value array of plural irregular words.
* If key matches then the value is returned.
*
* $irregularPlural = array('atlas' => 'atlases', 'beef' => 'beefs', 'brother' => 'brothers')
*/
$irregularPlural = array();

/**
* This is a key => value array of regex used to match words.
* If key matches then the value is returned.
*
* $singularRules = array('/(s)tatuses$/i' => '\1\2tatus', '/(matr)ices$/i' =>'\1ix','/(vert|ind)ices$/i')
*/
$singularRules = array();

/**
* This is a key only array of singular words that should not be inflected.
* You should not have to change this value below if you do change it use same format
* as the $uninflectedPlural above.
*/
$uninflectedSingular = $uninflectedPlural;

/**
* This is a key => value array of singular irregular words.
* Most of the time this will be a reverse of the above $irregularPlural array
* You should not have to change this value below if you do change it use same format
*
* $irregularSingular = array('atlases' => 'atlas', 'beefs' => 'beef', 'brothers' => 'brother')
*/
$irregularSingular = array_flip($irregularPlural);

?>
23 changes: 23 additions & 0 deletions app/configs/routes.php
@@ -0,0 +1,23 @@
<?php
/**
* sunFW(tm) : PHP Web Development Framework (http://www.suncoding.com)
* Copyright 2010, Sun Web Dev, Inc.
*
* Licensed under The GPLv3 License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright 2010, Sun Web Dev, Inc. (http://www.suncoding.com)
* @version 1.0.0
* @modifiedby Pavan Kumar Sunkara
* @lastmodified Apr 10, 2010
* @license GPLv3
*/

/**
* Here, we are connecting '/' (base path) to controller called 'Pages' and action 'home'
* (in this case, /app/views/pages/home.ctp)...
*/
Router::connect('/', array('controller' => 'pages', 'action' => 'home'));

?>
8 changes: 7 additions & 1 deletion sun/boot.php
Expand Up @@ -27,7 +27,7 @@
require_once CORE.'configure.php';

// File for configuration in webAPP
require_once APP.'config.php';
require_once CONFIGS.'config.php';

/**
* Basic class for Access control lists
Expand Down Expand Up @@ -183,4 +183,10 @@
require_once CORE.'xml.php';
}

//File for inflections in webAPP
require_once CONFIGS.'inflections.php';

//File for routing in webAPP
require_once CONFIGS.'routes.php';

?>
73 changes: 72 additions & 1 deletion sun/dispatcher.php
Expand Up @@ -16,11 +16,82 @@

class Dispatcher extends Object {

/**
* URL base
*/
var $base = null;

/**
* Parameters for the URL
*/
var $params = null;

/**
* The main URL
*/
var $url = null;

/**
* Constructor.
*/
function __construct() {
function __construct($url = null) {
$this->url = $url;
if (Configure::read('rewrite')) {
$this->base = HOST;
} else {
$this->base = HOST. Configure::read('App.base') .DS;
}
$this->params = $this->extract();
return $this->dispatch();
}

/**
* Main Dispatcher
* @return array $params Array with keys 'controller', 'action', 'params'
* @return boolean Success
*/
function dispatch() {

}

/**
* Extracting controller, action and parameters from the URL
* @param mixed $url relative URL, like "/products/edit/92" or "/presidents/elect/4"
* @return array $params Array with keys 'controller', 'action', 'params'
*/
function extract() {
$params = array();
$url = explode('/',$this->url);

if (empty($url[0])) {
array_shift($url);
}

if (empty($url[0])) {
$params['controller'] = 'pages';
} else {
$params['controller'] = $url[0];
}

array_shift($url);

if (empty($url[0])) {
$params['action'] = 'index';
} else {
$params['action'] = $url[0];
}

array_shift($url);

foreach ($url as $key=>$val) {
if (!empty($val)) {
$params['params'][$key] = $val;
} else {
break;
}
}

return $params;
}

}
Expand Down

0 comments on commit 7171bf5

Please sign in to comment.