setting proper mime-type on files in the trunk

git-svn-id: https://svn.cakephp.org/repo/trunk/cake@292 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2005-06-30 02:09:47 +00:00
parent 217e177abf
commit 55da45ec77
14 changed files with 2345 additions and 2345 deletions

View file

@ -1,25 +1,25 @@
<?PHP <?PHP
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// + $Id$ // + $Id$
// +------------------------------------------------------------------+ // // +------------------------------------------------------------------+ //
// + Cake <https://developers.nextco.com/cake/> + // // + Cake <https://developers.nextco.com/cake/> + //
// + Copyright: (c) 2005, Cake Authors/Developers + // // + Copyright: (c) 2005, Cake Authors/Developers + //
// +------------------------------------------------------------------+ // // +------------------------------------------------------------------+ //
// + Licensed under The MIT License + // // + Licensed under The MIT License + //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/** /**
* This file is application-wide controller file. You can put all * This file is application-wide controller file. You can put all
* application-wide controller-related methods here. * application-wide controller-related methods here.
* *
* Add your application-wide methods in the class below, your controllers * Add your application-wide methods in the class below, your controllers
* will inherit them. * will inherit them.
* *
* @package cake * @package cake
* @subpackage cake.app * @subpackage cake.app
*/ */
class AppController extends Controller { class AppController extends Controller {
} }
?> ?>

View file

@ -1,25 +1,25 @@
<?PHP <?PHP
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// + $Id$ // + $Id$
// +------------------------------------------------------------------+ // // +------------------------------------------------------------------+ //
// + Cake <https://developers.nextco.com/cake/> + // // + Cake <https://developers.nextco.com/cake/> + //
// + Copyright: (c) 2005, Cake Authors/Developers + // // + Copyright: (c) 2005, Cake Authors/Developers + //
// +------------------------------------------------------------------+ // // +------------------------------------------------------------------+ //
// + Licensed under The MIT License + // // + Licensed under The MIT License + //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/** /**
* This file is application-wide model file. You can put all * This file is application-wide model file. You can put all
* application-wide model-related methods here. * application-wide model-related methods here.
* *
* Add your application-wide methods in the class below, your models * Add your application-wide methods in the class below, your models
* will inherit them. * will inherit them.
* *
* @package cake * @package cake
* @subpackage cake.app * @subpackage cake.app
*/ */
class AppModel extends Model { class AppModel extends Model {
} }
?> ?>

View file

@ -1,164 +1,164 @@
<?PHP <?PHP
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// + $Id$ // + $Id$
// +------------------------------------------------------------------+ // // +------------------------------------------------------------------+ //
// + Cake <https://developers.nextco.com/cake/> + // // + Cake <https://developers.nextco.com/cake/> + //
// + Copyright: (c) 2005, Cake Authors/Developers + // // + Copyright: (c) 2005, Cake Authors/Developers + //
// +------------------------------------------------------------------+ // // +------------------------------------------------------------------+ //
// + Licensed under The MIT License + // // + Licensed under The MIT License + //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/** /**
* In this file you set paths to different directories used by Cake. * In this file you set paths to different directories used by Cake.
* *
* @package cake * @package cake
* @subpackage cake.config * @subpackage cake.config
*/ */
/** /**
* If the index.php file is used instead of an .htaccess file * If the index.php file is used instead of an .htaccess file
* or if the user can not set the web root to use the public * or if the user can not set the web root to use the public
* directory we will define ROOT there, otherwise we set it * directory we will define ROOT there, otherwise we set it
* here. * here.
*/ */
if(!defined('ROOT')) if(!defined('ROOT'))
{ {
define ('ROOT', '../'); define ('ROOT', '../');
} }
/** /**
* Path to the application's directory. * Path to the application's directory.
*/ */
define ('APP', ROOT.'app'.DS); define ('APP', ROOT.'app'.DS);
/** /**
* Path to the application's models directory. * Path to the application's models directory.
*/ */
define ('MODELS', APP.'models'.DS); define ('MODELS', APP.'models'.DS);
/** /**
* Path to the application's controllers directory. * Path to the application's controllers directory.
*/ */
define ('CONTROLLERS', APP.'controllers'.DS); define ('CONTROLLERS', APP.'controllers'.DS);
/** /**
* Path to the application's helpers directory. * Path to the application's helpers directory.
*/ */
define ('HELPERS', APP.'helpers'.DS); define ('HELPERS', APP.'helpers'.DS);
/** /**
* Path to the application's views directory. * Path to the application's views directory.
*/ */
define ('VIEWS', APP.'views'.DS); define ('VIEWS', APP.'views'.DS);
/** /**
* Path to the application's view's layouts directory. * Path to the application's view's layouts directory.
*/ */
define ('LAYOUTS', APP.'views'.DS.'layouts'.DS); define ('LAYOUTS', APP.'views'.DS.'layouts'.DS);
/** /**
* Path to the application's view's elements directory. * Path to the application's view's elements directory.
* It's supposed to hold pieces of PHP/HTML that are used on multiple pages * It's supposed to hold pieces of PHP/HTML that are used on multiple pages
* and are not linked to a particular layout (like polls, footers and so on). * and are not linked to a particular layout (like polls, footers and so on).
*/ */
define ('ELEMENTS', APP.'views'.DS.'elements'.DS); define ('ELEMENTS', APP.'views'.DS.'elements'.DS);
/** /**
* Path to the configuration files directory. * Path to the configuration files directory.
*/ */
define ('CONFIGS', ROOT.'config'.DS); define ('CONFIGS', ROOT.'config'.DS);
/** /**
* Path to the libs directory. * Path to the libs directory.
*/ */
define ('LIBS', ROOT.'libs'.DS); define ('LIBS', ROOT.'libs'.DS);
/** /**
* Path to the logs directory. * Path to the logs directory.
*/ */
define ('LOGS', ROOT.'logs'.DS); define ('LOGS', ROOT.'logs'.DS);
/** /**
* Path to the modules directory. * Path to the modules directory.
*/ */
define ('MODULES', ROOT.'modules'.DS); define ('MODULES', ROOT.'modules'.DS);
/** /**
* Path to the public directory. * Path to the public directory.
*/ */
define ('WWW_ROOT', ROOT.'public'.DS); define ('WWW_ROOT', ROOT.'public'.DS);
/** /**
* Path to the public directory. * Path to the public directory.
*/ */
define ('CSS', WWW_ROOT.'css'.DS); define ('CSS', WWW_ROOT.'css'.DS);
/** /**
* Path to the scripts direcotry. * Path to the scripts direcotry.
*/ */
define('SCRIPTS', ROOT.'scripts'.DS); define('SCRIPTS', ROOT.'scripts'.DS);
/** /**
* Path to the tests directory. * Path to the tests directory.
*/ */
define ('TESTS', ROOT.'tests'.DS); define ('TESTS', ROOT.'tests'.DS);
/** /**
* Path to the controller test directory. * Path to the controller test directory.
*/ */
define ('CONTROLLER_TESTS',TESTS.'app'.DS.'controllers'.DS); define ('CONTROLLER_TESTS',TESTS.'app'.DS.'controllers'.DS);
/** /**
* Path to the helpers test directory. * Path to the helpers test directory.
*/ */
define ('HELPER_TESTS', TESTS.'app'.DS.'helpers'.DS); define ('HELPER_TESTS', TESTS.'app'.DS.'helpers'.DS);
/** /**
* Path to the models' test directory. * Path to the models' test directory.
*/ */
define ('MODEL_TESTS', TESTS.'app'.DS.'models'.DS); define ('MODEL_TESTS', TESTS.'app'.DS.'models'.DS);
/** /**
* Path to the lib test directory. * Path to the lib test directory.
*/ */
define ('LIB_TESTS', TESTS.'libs'.DS); define ('LIB_TESTS', TESTS.'libs'.DS);
/** /**
* Path to the temporary files directory. * Path to the temporary files directory.
*/ */
define ('TMP', ROOT.'tmp'.DS); define ('TMP', ROOT.'tmp'.DS);
/** /**
* Path to the cache files directory. It can be shared between hosts in a multi-server setup. * Path to the cache files directory. It can be shared between hosts in a multi-server setup.
*/ */
define('CACHE', TMP.'cache'.DS); define('CACHE', TMP.'cache'.DS);
/** /**
* Path to the vendors directory. * Path to the vendors directory.
*/ */
define ('VENDORS', ROOT.'vendors'.DS); define ('VENDORS', ROOT.'vendors'.DS);
/** /**
* Path to the Pear directory * Path to the Pear directory
* The purporse is to make it easy porting Pear libs into Cake * The purporse is to make it easy porting Pear libs into Cake
* without setting the include_path PHP variable. * without setting the include_path PHP variable.
*/ */
define ('PEAR', VENDORS.'Pear'.DS); define ('PEAR', VENDORS.'Pear'.DS);
/** /**
* Full url prefix * Full url prefix
*/ */
define('FULL_BASE_URL', 'http://'.$_SERVER['HTTP_HOST']); define('FULL_BASE_URL', 'http://'.$_SERVER['HTTP_HOST']);
/** /**
* Web path to the public images directory. * Web path to the public images directory.
*/ */
define ('IMAGES_URL', '/img/'); define ('IMAGES_URL', '/img/');
/** /**
* Web path to the CSS files directory. * Web path to the CSS files directory.
*/ */
define ('CSS_URL', '/css/'); define ('CSS_URL', '/css/');
?> ?>

View file

@ -1,139 +1,139 @@
<?PHP <?PHP
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// + $Id$ // + $Id$
// +------------------------------------------------------------------+ // // +------------------------------------------------------------------+ //
// + Cake <https://developers.nextco.com/cake/> + // // + Cake <https://developers.nextco.com/cake/> + //
// + Copyright: (c) 2005, Cake Authors/Developers + // // + Copyright: (c) 2005, Cake Authors/Developers + //
// +------------------------------------------------------------------+ // // +------------------------------------------------------------------+ //
// + Licensed under The MIT License + // // + Licensed under The MIT License + //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/** /**
* In this file, you can set up 'templates' for every tag generated by the tag * In this file, you can set up 'templates' for every tag generated by the tag
* generator. * generator.
* *
* @package cake * @package cake
* @subpackage cake.config * @subpackage cake.config
*/ */
/** /**
* Tag template for a link. * Tag template for a link.
*/ */
define('TAG_LINK', '<a href="%s"%s>%s</a>'); define('TAG_LINK', '<a href="%s"%s>%s</a>');
/** /**
* Tag template for a mailto: link. * Tag template for a mailto: link.
*/ */
define('TAG_MAILTO', '<a href="mailto:%s"%s>%s</a>'); define('TAG_MAILTO', '<a href="mailto:%s"%s>%s</a>');
/** /**
* Tag template for opening form tag. * Tag template for opening form tag.
*/ */
define('TAG_FORM', '<form %s>'); define('TAG_FORM', '<form %s>');
/** /**
* Tag template for an input type='text' tag. * Tag template for an input type='text' tag.
*/ */
define('TAG_INPUT', '<input name="data[%s]" %s/>'); define('TAG_INPUT', '<input name="data[%s]" %s/>');
/** /**
* Tag template for an input type='hidden' tag. * Tag template for an input type='hidden' tag.
*/ */
define('TAG_HIDDEN', '<input type="hidden" name="data[%s]" %s/>'); define('TAG_HIDDEN', '<input type="hidden" name="data[%s]" %s/>');
/** /**
* Tag template for a textarea tag. * Tag template for a textarea tag.
*/ */
define('TAG_AREA', '<textarea name="data[%s]"%s>%s</textarea>'); define('TAG_AREA', '<textarea name="data[%s]"%s>%s</textarea>');
/** /**
* Tag template for a input type='checkbox ' tag. * Tag template for a input type='checkbox ' tag.
*/ */
define('TAG_CHECKBOX', '<label for="tag_%s"><input type="checkbox" name="data[%s]" id="tag_%s" %s/>%s</label>'); define('TAG_CHECKBOX', '<label for="tag_%s"><input type="checkbox" name="data[%s]" id="tag_%s" %s/>%s</label>');
/** /**
* Tag template for a input type='radio' tag. * Tag template for a input type='radio' tag.
*/ */
define('TAG_RADIOS', '<label for="tag_%s"><input type="radio" name="data[%s]" id="tag_%s" %s/>%s</label>'); define('TAG_RADIOS', '<label for="tag_%s"><input type="radio" name="data[%s]" id="tag_%s" %s/>%s</label>');
/** /**
* Tag template for a select opening tag. * Tag template for a select opening tag.
*/ */
define('TAG_SELECT_START', '<select name="data[%s]"%s>'); define('TAG_SELECT_START', '<select name="data[%s]"%s>');
/** /**
* Tag template for an empty select option tag. * Tag template for an empty select option tag.
*/ */
define('TAG_SELECT_EMPTY', '<option value=""%s></option>'); define('TAG_SELECT_EMPTY', '<option value=""%s></option>');
/** /**
* Tag template for a select option tag. * Tag template for a select option tag.
*/ */
define('TAG_SELECT_OPTION','<option value="%s"%s>%s</option>'); define('TAG_SELECT_OPTION','<option value="%s"%s>%s</option>');
/** /**
* Tag template for a closing select tag. * Tag template for a closing select tag.
*/ */
define('TAG_SELECT_END', '</select>'); define('TAG_SELECT_END', '</select>');
/** /**
* Tag template for a password tag. * Tag template for a password tag.
*/ */
define('TAG_PASSWORD', '<input type="password" name="data[%s]" %s/>'); define('TAG_PASSWORD', '<input type="password" name="data[%s]" %s/>');
/** /**
* Tag template for a file input tag. * Tag template for a file input tag.
*/ */
define('TAG_FILE', '<input type="file" name="%s" %s/>'); define('TAG_FILE', '<input type="file" name="%s" %s/>');
/** /**
* Tag template for a submit button tag. * Tag template for a submit button tag.
*/ */
define('TAG_SUBMIT', '<input type="submit" %s/>'); define('TAG_SUBMIT', '<input type="submit" %s/>');
/** /**
* Tag template for an image tag. * Tag template for an image tag.
*/ */
define('TAG_IMAGE', '<img src="%s" alt="%s" %s/>'); define('TAG_IMAGE', '<img src="%s" alt="%s" %s/>');
/** /**
* Tag template for a table header tag. * Tag template for a table header tag.
*/ */
define('TAG_TABLE_HEADER', '<th%s>%s</th>'); define('TAG_TABLE_HEADER', '<th%s>%s</th>');
/** /**
* Tag template for table headers row tag. * Tag template for table headers row tag.
*/ */
define('TAG_TABLE_HEADERS','<tr%s>%s</tr>'); define('TAG_TABLE_HEADERS','<tr%s>%s</tr>');
/** /**
* Tag template for a table cell tag. * Tag template for a table cell tag.
*/ */
define('TAG_TABLE_CELL', '<td%s>%s</td>'); define('TAG_TABLE_CELL', '<td%s>%s</td>');
/** /**
* Tag template for a table row tag. * Tag template for a table row tag.
*/ */
define('TAG_TABLE_ROW', '<tr%s>%s</tr>'); define('TAG_TABLE_ROW', '<tr%s>%s</tr>');
/** /**
* Tag template for a CSS link tag. * Tag template for a CSS link tag.
*/ */
define('TAG_CSS', '<link rel="%s" type="text/css" href="%s" />'); define('TAG_CSS', '<link rel="%s" type="text/css" href="%s" />');
/** /**
* Tag template for a charset meta-tag. * Tag template for a charset meta-tag.
*/ */
define('TAG_CHARSET', '<meta http-equiv="Content-Type" content="text/html; charset=%s" />'); define('TAG_CHARSET', '<meta http-equiv="Content-Type" content="text/html; charset=%s" />');
/** /**
* Tag template for inline JavaScript. * Tag template for inline JavaScript.
*/ */
define('TAG_JAVASCRIPT', '<script language="javascript" type="text/javascript">%s</script>'); define('TAG_JAVASCRIPT', '<script language="javascript" type="text/javascript">%s</script>');
/** /**
* Tag template for included JavaScript. * Tag template for included JavaScript.
*/ */
define('TAG_JAVASCRIPT_INCLUDE', '<script language="javascript" type="text/javascript" src="%s"></script>'); define('TAG_JAVASCRIPT_INCLUDE', '<script language="javascript" type="text/javascript" src="%s"></script>');
?> ?>

File diff suppressed because it is too large Load diff

View file

@ -1,150 +1,150 @@
<?PHP <?PHP
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// + $Id$ // + $Id$
// +------------------------------------------------------------------+ // // +------------------------------------------------------------------+ //
// + Cake <https://developers.nextco.com/cake/> + // // + Cake <https://developers.nextco.com/cake/> + //
// + Copyright: (c) 2005, Cake Authors/Developers + // // + Copyright: (c) 2005, Cake Authors/Developers + //
// + Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com> + // // + Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com> + //
// + Larry E. Masters aka PhpNut <nut@phpnut.com> + // // + Larry E. Masters aka PhpNut <nut@phpnut.com> + //
// + Kamil Dzielinski aka Brego <brego.dk@gmail.com> + // // + Kamil Dzielinski aka Brego <brego.dk@gmail.com> + //
// +------------------------------------------------------------------+ // // +------------------------------------------------------------------+ //
// + Licensed under The MIT License + // // + Licensed under The MIT License + //
// + Redistributions of files must retain the above copyright notice. + // // + Redistributions of files must retain the above copyright notice. + //
// + See: http://www.opensource.org/licenses/mit-license.php + // // + See: http://www.opensource.org/licenses/mit-license.php + //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/** /**
* Purpose: Cache * Purpose: Cache
* Description: * Description:
* *
* @filesource * @filesource
* @author Cake Authors/Developers * @author Cake Authors/Developers
* @copyright Copyright (c) 2005, Cake Authors/Developers * @copyright Copyright (c) 2005, Cake Authors/Developers
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers * @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
* @package cake * @package cake
* @subpackage cake.libs * @subpackage cake.libs
* @since Cake v 0.2.9 * @since Cake v 0.2.9
* @version $Revision$ * @version $Revision$
* @modifiedby $LastChangedBy$ * @modifiedby $LastChangedBy$
* @lastmodified $Date$ * @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License * @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/ */
/** /**
* Enter description here... * Enter description here...
* *
*/ */
uses('model'); uses('model');
/** /**
* Enter description here... * Enter description here...
* *
* @package cake * @package cake
* @subpackage cake.libs * @subpackage cake.libs
* @since Cake v 0.2.9 * @since Cake v 0.2.9
*/ */
class Cache extends Model { class Cache extends Model {
/** /**
* Identifier. Either an MD5 string or NULL. * Identifier. Either an MD5 string or NULL.
* *
* @var unknown_type * @var unknown_type
*/ */
var $id = null; var $id = null;
/** /**
* Content container for cache data. * Content container for cache data.
* *
* @var unknown_type * @var unknown_type
*/ */
var $data = null; var $data = null;
/** /**
* Content to be cached. * Content to be cached.
* *
* @var unknown_type * @var unknown_type
*/ */
var $for_caching = null; var $for_caching = null;
/** /**
* Name of the database table used for caching. * Name of the database table used for caching.
* *
* @var unknown_type * @var unknown_type
*/ */
var $use_table = 'cache'; var $use_table = 'cache';
/** /**
* Constructor. Generates an md5'ed id for internal use. Calls the constructor on Model as well. * Constructor. Generates an md5'ed id for internal use. Calls the constructor on Model as well.
* *
* @param unknown_type $id * @param unknown_type $id
*/ */
function __construct ($id) { function __construct ($id) {
$this->id = (md5($id)); $this->id = (md5($id));
parent::__construct($this->id); parent::__construct($this->id);
} }
/** /**
* Returns this object's id after setting it. If no $id is given then $this->id is returned. * Returns this object's id after setting it. If no $id is given then $this->id is returned.
* *
* @param unknown_type $id * @param unknown_type $id
* @return unknown * @return unknown
*/ */
function id ($id=null) { function id ($id=null) {
if (!$id) return $this->id; if (!$id) return $this->id;
return ($this->id = $id); return ($this->id = $id);
} }
/** /**
* Save $content in cache for $keep_for seconds. * Save $content in cache for $keep_for seconds.
* *
* @param string $content Content to keep in cache. * @param string $content Content to keep in cache.
* @param int $keep_for Number of seconds to keep data in cache. * @param int $keep_for Number of seconds to keep data in cache.
* @return unknown * @return unknown
*/ */
function remember ($content, $keep_for=CACHE_PAGES_FOR) { function remember ($content, $keep_for=CACHE_PAGES_FOR) {
$data = addslashes($this->for_caching.$content); $data = addslashes($this->for_caching.$content);
$expire = date("Y-m-d H:i:s",time()+($keep_for>0? $keep_for: 999999999)); $expire = date("Y-m-d H:i:s",time()+($keep_for>0? $keep_for: 999999999));
return $this->query("REPLACE {$this->use_table} (id,data,expire) VALUES ('{$this->id}', '{$data}', '{$expire}')"); return $this->query("REPLACE {$this->use_table} (id,data,expire) VALUES ('{$this->id}', '{$data}', '{$expire}')");
} }
/** /**
* Returns content from the Cache object itself, if the Cache object has a non-empty data property. Else from the database cache. * Returns content from the Cache object itself, if the Cache object has a non-empty data property. Else from the database cache.
* *
* @return unknown * @return unknown
*/ */
function restore() { function restore() {
if (empty($this->data['data'])) if (empty($this->data['data']))
return $this->find("id='{$this->id}' AND expire>NOW()"); return $this->find("id='{$this->id}' AND expire>NOW()");
return $this->data['data']; return $this->data['data'];
} }
/** /**
* Returns true if the cache data property has current (non-stale) content for given id. * Returns true if the cache data property has current (non-stale) content for given id.
* *
* @return boolean * @return boolean
*/ */
function has() { function has() {
return is_array($this->data = $this->find("id='{$this->id}' AND expire>NOW()")); return is_array($this->data = $this->find("id='{$this->id}' AND expire>NOW()"));
} }
/** /**
* Appends $string to the for_caching property of the Cache object. * Appends $string to the for_caching property of the Cache object.
* *
* @param string $string * @param string $string
*/ */
function append($string) { function append($string) {
$this->for_caching .= $string; $this->for_caching .= $string;
} }
/** /**
* Clears the cache database table. * Clears the cache database table.
* *
* @return unknown * @return unknown
*/ */
function clear() { function clear() {
return $this->query("DELETE FROM {$this->use_table}"); return $this->query("DELETE FROM {$this->use_table}");
} }
} }
?> ?>

View file

@ -1,112 +1,112 @@
<?PHP <?PHP
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// + $Id$ // + $Id$
// +------------------------------------------------------------------+ // // +------------------------------------------------------------------+ //
// + Cake <https://developers.nextco.com/cake/> + // // + Cake <https://developers.nextco.com/cake/> + //
// + Copyright: (c) 2005, Cake Authors/Developers + // // + Copyright: (c) 2005, Cake Authors/Developers + //
// + Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com> + // // + Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com> + //
// + Larry E. Masters aka PhpNut <nut@phpnut.com> + // // + Larry E. Masters aka PhpNut <nut@phpnut.com> + //
// + Kamil Dzielinski aka Brego <brego.dk@gmail.com> + // // + Kamil Dzielinski aka Brego <brego.dk@gmail.com> + //
// +------------------------------------------------------------------+ // // +------------------------------------------------------------------+ //
// + Licensed under The MIT License + // // + Licensed under The MIT License + //
// + Redistributions of files must retain the above copyright notice. + // // + Redistributions of files must retain the above copyright notice. + //
// + See: http://www.opensource.org/licenses/mit-license.php + // // + See: http://www.opensource.org/licenses/mit-license.php + //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/** /**
* Purpose: Error Messages Defines * Purpose: Error Messages Defines
* *
* @filesource * @filesource
* @author Cake Authors/Developers * @author Cake Authors/Developers
* @copyright Copyright (c) 2005, Cake Authors/Developers * @copyright Copyright (c) 2005, Cake Authors/Developers
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers * @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
* @package cake * @package cake
* @subpackage cake.libs * @subpackage cake.libs
* @since Cake v 0.2.9 * @since Cake v 0.2.9
* @version $Revision$ * @version $Revision$
* @modifiedby $LastChangedBy$ * @modifiedby $LastChangedBy$
* @lastmodified $Date$ * @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License * @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/ */
/** /**
* Error string for when the specified database driver can not be found. * Error string for when the specified database driver can not be found.
*/ */
define ('ERROR_UNKNOWN_DATABASE_DRIVER', '[DbFactory] Specified database driver (%s) not found'); define ('ERROR_UNKNOWN_DATABASE_DRIVER', '[DbFactory] Specified database driver (%s) not found');
/** /**
* Error string for when the dispatcher can not find a default controller. * Error string for when the dispatcher can not find a default controller.
*/ */
define ('ERROR_NO_CONTROLLER_SET', '[Dispatcher] No default controller, can\'t continue, check routes config'); define ('ERROR_NO_CONTROLLER_SET', '[Dispatcher] No default controller, can\'t continue, check routes config');
/** /**
* Error string for when the dispatcher can not find a default action. * Error string for when the dispatcher can not find a default action.
*/ */
define ('ERROR_NO_ACTION_SET', '[Dispatcher] No default action, can\'t continue, check routes config'); define ('ERROR_NO_ACTION_SET', '[Dispatcher] No default action, can\'t continue, check routes config');
/** /**
* Error string for when the dispatcher can not find given controller. * Error string for when the dispatcher can not find given controller.
*/ */
define ('ERROR_UNKNOWN_CONTROLLER', '[Dispatcher] Specified controller "%s" doesn\'t exist, create it first'); define ('ERROR_UNKNOWN_CONTROLLER', '[Dispatcher] Specified controller "%s" doesn\'t exist, create it first');
/** /**
* Error string for when the dispatcher can not find expected action in controller. * Error string for when the dispatcher can not find expected action in controller.
*/ */
define ('ERROR_NO_ACTION', '[Dispatcher] Action "%s" is not defined in the "%s" controller, create it first'); define ('ERROR_NO_ACTION', '[Dispatcher] Action "%s" is not defined in the "%s" controller, create it first');
/** /**
* Error string for errors in view. * Error string for errors in view.
*/ */
define ('ERROR_IN_VIEW', '[Controller] Error in view "%s", got: <blockquote>%s</blockquote>'); define ('ERROR_IN_VIEW', '[Controller] Error in view "%s", got: <blockquote>%s</blockquote>');
/** /**
* Error string for when the controller can not find expected view. * Error string for when the controller can not find expected view.
*/ */
define ('ERROR_NO_VIEW', '[Controller] No template file for view "%s" (expected "%s"), create it first'); define ('ERROR_NO_VIEW', '[Controller] No template file for view "%s" (expected "%s"), create it first');
/** /**
* Error string for errors in layout. * Error string for errors in layout.
*/ */
define ('ERROR_IN_LAYOUT', '[Controller] Error in layout "%s", got: <blockquote>"%s"</blockquote>'); define ('ERROR_IN_LAYOUT', '[Controller] Error in layout "%s", got: <blockquote>"%s"</blockquote>');
/** /**
* Error string for when the controller can not find expected layout. * Error string for when the controller can not find expected layout.
*/ */
define ('ERROR_NO_LAYOUT', '[Controller] Couln\'t find layout "%s" (expected "%s"), create it first'); define ('ERROR_NO_LAYOUT', '[Controller] Couln\'t find layout "%s" (expected "%s"), create it first');
/** /**
* Error string for database not being able to access the table list. * Error string for database not being able to access the table list.
*/ */
define ('ERROR_NO_TABLE_LIST', '[Database] Couldn\'t get table list, check database config'); define ('ERROR_NO_TABLE_LIST', '[Database] Couldn\'t get table list, check database config');
/** /**
* Error string for no corresponding database table found for model. * Error string for no corresponding database table found for model.
*/ */
define ('ERROR_NO_MODEL_TABLE', '[Model] No DB table for model "%s" (expected "%s"), create it first'); define ('ERROR_NO_MODEL_TABLE', '[Model] No DB table for model "%s" (expected "%s"), create it first');
/** /**
* Error string for Field not present in table. * Error string for Field not present in table.
*/ */
define ('ERROR_NO_FIELD_IN_MODEL_DB', '[Model::set()] Field "%s" is not present in table "%s", check database schema'); define ('ERROR_NO_FIELD_IN_MODEL_DB', '[Model::set()] Field "%s" is not present in table "%s", check database schema');
/** /**
* Error string short short error message. * Error string short short error message.
*/ */
define ('SHORT_ERROR_MESSAGE', '<div class="error_message"><i>%s</i></div>'); define ('SHORT_ERROR_MESSAGE', '<div class="error_message"><i>%s</i></div>');
/** /**
* Error string for when original image can not be loaded. * Error string for when original image can not be loaded.
*/ */
define ('ERROR_CANT_GET_ORIGINAL_IMAGE', '[Image] Couldn\'t load original image %s (tried from "%s")'); define ('ERROR_CANT_GET_ORIGINAL_IMAGE', '[Image] Couldn\'t load original image %s (tried from "%s")');
/** /**
* Error string for error 404. * Error string for error 404.
*/ */
define ('ERROR_404', "The requested address /%s was not found on this server."); // second %s contains short error message define ('ERROR_404', "The requested address /%s was not found on this server."); // second %s contains short error message
/** /**
* Error string for error 500. * Error string for error 500.
*/ */
define ('ERROR_500', "Application error, sorry."); define ('ERROR_500', "Application error, sorry.");
?> ?>

View file

@ -1,321 +1,321 @@
<?PHP <?PHP
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// + $Id$ // + $Id$
// +------------------------------------------------------------------+ // // +------------------------------------------------------------------+ //
// + Cake <https://developers.nextco.com/cake/> + // // + Cake <https://developers.nextco.com/cake/> + //
// + Copyright: (c) 2005, Cake Authors/Developers + // // + Copyright: (c) 2005, Cake Authors/Developers + //
// + Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com> + // // + Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com> + //
// + Larry E. Masters aka PhpNut <nut@phpnut.com> + // // + Larry E. Masters aka PhpNut <nut@phpnut.com> + //
// + Kamil Dzielinski aka Brego <brego.dk@gmail.com> + // // + Kamil Dzielinski aka Brego <brego.dk@gmail.com> + //
// +------------------------------------------------------------------+ // // +------------------------------------------------------------------+ //
// + Licensed under The MIT License + // // + Licensed under The MIT License + //
// + Redistributions of files must retain the above copyright notice. + // // + Redistributions of files must retain the above copyright notice. + //
// + See: http://www.opensource.org/licenses/mit-license.php + // // + See: http://www.opensource.org/licenses/mit-license.php + //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/** /**
* Purpose: Flay * Purpose: Flay
* Text-to-html parser, similar to Textile or RedCloth, only with somehow different syntax. * Text-to-html parser, similar to Textile or RedCloth, only with somehow different syntax.
* *
* @filesource * @filesource
* @author Cake Authors/Developers * @author Cake Authors/Developers
* @copyright Copyright (c) 2005, Cake Authors/Developers * @copyright Copyright (c) 2005, Cake Authors/Developers
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers * @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
* @package cake * @package cake
* @subpackage cake.libs * @subpackage cake.libs
* @since Cake v 0.2.9 * @since Cake v 0.2.9
* @version $Revision$ * @version $Revision$
* @modifiedby $LastChangedBy$ * @modifiedby $LastChangedBy$
* @lastmodified $Date$ * @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License * @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/ */
/** /**
* Enter description here... * Enter description here...
*/ */
uses('object'); uses('object');
/** /**
* Text-to-html parser, similar to Textile or RedCloth, only with a little different syntax. * Text-to-html parser, similar to Textile or RedCloth, only with a little different syntax.
* *
* @package cake * @package cake
* @subpackage cake.libs * @subpackage cake.libs
* @since Cake v 0.2.9 * @since Cake v 0.2.9
*/ */
class Flay extends Object class Flay extends Object
{ {
/** /**
* Enter description here... * Enter description here...
* *
* @var string * @var string
*/ */
var $text = null; var $text = null;
/** /**
* Enter description here... * Enter description here...
* *
* @var boolean * @var boolean
*/ */
var $allow_html = false; var $allow_html = false;
/** /**
* Constructor. * Constructor.
* *
* @param unknown_type $text * @param unknown_type $text
*/ */
function __construct ($text=null) { function __construct ($text=null) {
$this->text = $text; $this->text = $text;
parent::__construct(); parent::__construct();
} }
/** /**
* Returns $text translated to HTML using the Flay syntax. * Returns $text translated to HTML using the Flay syntax.
* *
* @param string $text Text to format * @param string $text Text to format
* @param boolean $bare * @param boolean $bare
* @param boolean $allowHtml Set this to trim whitespace and disable all HTML * @param boolean $allowHtml Set this to trim whitespace and disable all HTML
* @return string Formatted text * @return string Formatted text
*/ */
function toHtml ($text=null, $bare=false, $allowHtml=false) { function toHtml ($text=null, $bare=false, $allowHtml=false) {
if (empty($text) && empty($this->text)) if (empty($text) && empty($this->text))
return false; return false;
$text = $text? $text: $this->text; $text = $text? $text: $this->text;
// trim whitespace and disable all HTML // trim whitespace and disable all HTML
if ($allowHtml) if ($allowHtml)
$text = trim($text); $text = trim($text);
else else
$text = str_replace('<', '&lt;', str_replace('>', '&gt;', trim($text))); $text = str_replace('<', '&lt;', str_replace('>', '&gt;', trim($text)));
if (!$bare) { if (!$bare) {
// multi-paragraph functions // multi-paragraph functions
$text = preg_replace('#(?:[\n]{0,2})"""(.*)"""(?:[\n]{0,2})#s', "\n\n%BLOCKQUOTE%\n\n\\1\n\n%ENDBLOCKQUOTE%\n\n", $text); $text = preg_replace('#(?:[\n]{0,2})"""(.*)"""(?:[\n]{0,2})#s', "\n\n%BLOCKQUOTE%\n\n\\1\n\n%ENDBLOCKQUOTE%\n\n", $text);
$text = preg_replace('#(?:[\n]{0,2})===(.*)===(?:[\n]{0,2})#s', "\n\n%CENTER%\n\n\\1\n\n%ENDCENTER%\n\n", $text); $text = preg_replace('#(?:[\n]{0,2})===(.*)===(?:[\n]{0,2})#s', "\n\n%CENTER%\n\n\\1\n\n%ENDCENTER%\n\n", $text);
} }
// pre-parse newlines // pre-parse newlines
$text = preg_replace("#\r\n#", "\n", $text); $text = preg_replace("#\r\n#", "\n", $text);
$text = preg_replace("#[\n]{2,}#", "%PARAGRAPH%", $text); $text = preg_replace("#[\n]{2,}#", "%PARAGRAPH%", $text);
$text = preg_replace('#[\n]{1}#', "%LINEBREAK%", $text); $text = preg_replace('#[\n]{1}#', "%LINEBREAK%", $text);
// split into paragraphs and parse // split into paragraphs and parse
$out = ''; $out = '';
foreach (split('%PARAGRAPH%', $text) as $line) { foreach (split('%PARAGRAPH%', $text) as $line) {
if ($line) { if ($line) {
if (!$bare) { if (!$bare) {
// pre-parse links // pre-parse links
$links = array(); $links = array();
$regs = null; $regs = null;
if (preg_match_all('#\[([^\[]{4,})\]#', $line, $regs)) { if (preg_match_all('#\[([^\[]{4,})\]#', $line, $regs)) {
foreach ($regs[1] as $reg) { foreach ($regs[1] as $reg) {
$links[] = $reg; $links[] = $reg;
$line = str_replace("[{$reg}]",'%LINK'.(count($links)-1).'%', $line); $line = str_replace("[{$reg}]",'%LINK'.(count($links)-1).'%', $line);
} }
} }
// MAIN TEXT FUNCTIONS // MAIN TEXT FUNCTIONS
// bold // bold
$line = ereg_replace("\*([^\*]*)\*", "<strong>\\1</strong>", $line); $line = ereg_replace("\*([^\*]*)\*", "<strong>\\1</strong>", $line);
// italic // italic
$line = ereg_replace("_([^_]*)_", "<em>\\1</em>", $line); $line = ereg_replace("_([^_]*)_", "<em>\\1</em>", $line);
} }
// entities // entities
$line = str_replace(' - ', ' &ndash; ', $line); $line = str_replace(' - ', ' &ndash; ', $line);
$line = str_replace(' -- ', ' &mdash; ', $line); $line = str_replace(' -- ', ' &mdash; ', $line);
$line = str_replace('(C)', '&copy;', $line); $line = str_replace('(C)', '&copy;', $line);
$line = str_replace('(R)', '&reg;', $line); $line = str_replace('(R)', '&reg;', $line);
$line = str_replace('(TM)', '&trade;', $line); $line = str_replace('(TM)', '&trade;', $line);
// guess e-mails // guess e-mails
$emails = null; $emails = null;
if (preg_match_all("#([_A-Za-z0-9+-+]+(?:\.[_A-Za-z0-9+-]+)*@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*)#", $line, $emails)) { if (preg_match_all("#([_A-Za-z0-9+-+]+(?:\.[_A-Za-z0-9+-]+)*@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*)#", $line, $emails)) {
foreach ($emails[1] as $email) { foreach ($emails[1] as $email) {
$line = str_replace($email, "<a href=\"mailto:{$email}\">{$email}</a>", $line); $line = str_replace($email, "<a href=\"mailto:{$email}\">{$email}</a>", $line);
} }
} }
if (!$bare) { if (!$bare) {
// guess links // guess links
$urls = null; $urls = null;
if (preg_match_all("#((?:http|https|ftp|nntp)://[^ ]+)#", $line, $urls)) if (preg_match_all("#((?:http|https|ftp|nntp)://[^ ]+)#", $line, $urls))
{ {
foreach ($urls[1] as $url) foreach ($urls[1] as $url)
{ {
$line = str_replace($url, "<a href=\"{$url}\">{$url}</a>", $line); $line = str_replace($url, "<a href=\"{$url}\">{$url}</a>", $line);
} }
} }
if (preg_match_all("#(www\.[^\n\%\ ]+[^\n\%\,\.\ ])#", $line, $urls)) if (preg_match_all("#(www\.[^\n\%\ ]+[^\n\%\,\.\ ])#", $line, $urls))
{ {
foreach ($urls[1] as $url) foreach ($urls[1] as $url)
{ {
$line = str_replace($url, "<a href=\"http://{$url}\">{$url}</a>", $line); $line = str_replace($url, "<a href=\"http://{$url}\">{$url}</a>", $line);
} }
} }
// re-parse links // re-parse links
if (count($links)) { if (count($links)) {
for ($ii=0; $ii<count($links); $ii++) { for ($ii=0; $ii<count($links); $ii++) {
if (preg_match("#^(http|https|ftp|nntp)://#", $links[$ii])) if (preg_match("#^(http|https|ftp|nntp)://#", $links[$ii]))
{ {
$prefix = null; $prefix = null;
} }
else else
{ {
$prefix = 'http://'; $prefix = 'http://';
} }
if (preg_match('#^[^\ ]+\.(jpg|jpeg|gif|png)$#', $links[$ii])) if (preg_match('#^[^\ ]+\.(jpg|jpeg|gif|png)$#', $links[$ii]))
{ {
$with = "<img src=\"{$prefix}{$links[$ii]}\" alt=\"\" />"; $with = "<img src=\"{$prefix}{$links[$ii]}\" alt=\"\" />";
} }
elseif (preg_match('#^([^\]\ ]+)(?:\ ([^\]]+))?$#', $links[$ii], $regs)) elseif (preg_match('#^([^\]\ ]+)(?:\ ([^\]]+))?$#', $links[$ii], $regs))
{ {
if (isset($regs[2])) if (isset($regs[2]))
{ {
if (preg_match('#\.(jpg|jpeg|gif|png)$#', $regs[2])) if (preg_match('#\.(jpg|jpeg|gif|png)$#', $regs[2]))
$body = "<img src=\"{$prefix}{$regs[2]}\" alt=\"\" />"; $body = "<img src=\"{$prefix}{$regs[2]}\" alt=\"\" />";
else else
$body = $regs[2]; $body = $regs[2];
} }
else else
{ {
$body = $links[$ii]; $body = $links[$ii];
} }
$with = "<a href=\"{$prefix}{$regs[1]}\" target=\"_blank\">{$body}</a>"; $with = "<a href=\"{$prefix}{$regs[1]}\" target=\"_blank\">{$body}</a>";
} }
else else
{ {
$with = $prefix.$links[$ii]; $with = $prefix.$links[$ii];
} }
$line = str_replace("%LINK{$ii}%", $with, $line); $line = str_replace("%LINK{$ii}%", $with, $line);
} }
} }
} }
// re-parse newlines // re-parse newlines
$out .= str_replace('%LINEBREAK%', "<br />\n", "<p>{$line}</p>\n"); $out .= str_replace('%LINEBREAK%', "<br />\n", "<p>{$line}</p>\n");
} }
} }
if (!$bare) { if (!$bare) {
// re-parse multilines // re-parse multilines
$out = str_replace('<p>%BLOCKQUOTE%</p>', "<blockquote>", $out); $out = str_replace('<p>%BLOCKQUOTE%</p>', "<blockquote>", $out);
$out = str_replace('<p>%ENDBLOCKQUOTE%</p>', "</blockquote>", $out); $out = str_replace('<p>%ENDBLOCKQUOTE%</p>', "</blockquote>", $out);
$out = str_replace('<p>%CENTER%</p>', "<center>", $out); $out = str_replace('<p>%CENTER%</p>', "<center>", $out);
$out = str_replace('<p>%ENDCENTER%</p>', "</center>", $out); $out = str_replace('<p>%ENDCENTER%</p>', "</center>", $out);
} }
return $out; return $out;
} }
/** /**
* Enter description here... * Enter description here...
* *
* @param unknown_type $string * @param unknown_type $string
* @return unknown * @return unknown
*/ */
function extractWords ($string) { function extractWords ($string) {
return preg_split('/[\s,\.:\/="!\(\)<>~\[\]]+/', $string); return preg_split('/[\s,\.:\/="!\(\)<>~\[\]]+/', $string);
} }
/** /**
* Enter description here... * Enter description here...
* *
* @param unknown_type $words * @param unknown_type $words
* @param unknown_type $string * @param unknown_type $string
* @param unknown_type $max_snippets * @param unknown_type $max_snippets
* @return unknown * @return unknown
*/ */
function markedSnippets ($words, $string, $max_snippets=5) { function markedSnippets ($words, $string, $max_snippets=5) {
$string = strip_tags($string); $string = strip_tags($string);
$snips = array(); $snips = array();
$rest = $string; $rest = $string;
foreach ($words as $word) { foreach ($words as $word) {
if (preg_match_all("/[\s,]+.{0,40}{$word}.{0,40}[\s,]+/i", $rest, $r)) { if (preg_match_all("/[\s,]+.{0,40}{$word}.{0,40}[\s,]+/i", $rest, $r)) {
foreach ($r as $result) foreach ($r as $result)
$rest = str_replace($result, '', $rest); $rest = str_replace($result, '', $rest);
$snips = array_merge($snips, $r[0]); $snips = array_merge($snips, $r[0]);
} }
} }
if (count($snips) > $max_snippets) $snips = array_slice($snips, 0, $max_snippets); if (count($snips) > $max_snippets) $snips = array_slice($snips, 0, $max_snippets);
$joined = join(' <b>...</b> ', $snips); $joined = join(' <b>...</b> ', $snips);
$snips = $joined? "<b>...</b> {$joined} <b>...</b>": substr($string, 0, 80).'<b>...</b>'; $snips = $joined? "<b>...</b> {$joined} <b>...</b>": substr($string, 0, 80).'<b>...</b>';
return Flay::colorMark($words, $snips); return Flay::colorMark($words, $snips);
} }
/** /**
* Enter description here... * Enter description here...
* *
* @param unknown_type $words * @param unknown_type $words
* @param unknown_type $string * @param unknown_type $string
* @return unknown * @return unknown
*/ */
function colorMark($words, $string) function colorMark($words, $string)
{ {
$colors = array('yl','gr','rd','bl','fu','cy'); $colors = array('yl','gr','rd','bl','fu','cy');
$nextColorIndex = 0; $nextColorIndex = 0;
foreach ($words as $word) foreach ($words as $word)
{ {
$string = preg_replace("/({$word})/i", '<em class="'.$colors[$nextColorIndex%count($colors)]."\">\\1</em>", $string); $string = preg_replace("/({$word})/i", '<em class="'.$colors[$nextColorIndex%count($colors)]."\">\\1</em>", $string);
$nextColorIndex++; $nextColorIndex++;
} }
return $string; return $string;
} }
/** /**
* Enter description here... * Enter description here...
* *
* @param unknown_type $text * @param unknown_type $text
* @return unknown * @return unknown
*/ */
function toClean ($text) function toClean ($text)
{ {
return strip_tags(html_entity_decode($text, ENT_QUOTES)); return strip_tags(html_entity_decode($text, ENT_QUOTES));
} }
function toParsedAndClean ($text) function toParsedAndClean ($text)
{ {
return Flay::toClean(Flay::toHtml($text)); return Flay::toClean(Flay::toHtml($text));
} }
/** /**
* Enter description here... * Enter description here...
* *
* @param unknown_type $text * @param unknown_type $text
* @param unknown_type $length * @param unknown_type $length
* @param unknown_type $elipsis * @param unknown_type $elipsis
* @return unknown * @return unknown
*/ */
function fragment ($text, $length, $elipsis='...') { function fragment ($text, $length, $elipsis='...') {
$soft=$length-5; $soft=$length-5;
$hard=$length+5; $hard=$length+5;
$rx = '/(.{'.$soft.','.$hard.'})[\s,\.:\/="!\(\)<>~\[\]]+.*/'; $rx = '/(.{'.$soft.','.$hard.'})[\s,\.:\/="!\(\)<>~\[\]]+.*/';
if (preg_match($rx, $text, $r)) { if (preg_match($rx, $text, $r)) {
$out = $r[1]; $out = $r[1];
} }
else { else {
$out = substr($text,0,$length); $out = substr($text,0,$length);
} }
$out = $out.(strlen($out)<strlen($text)? $elipsis: null); $out = $out.(strlen($out)<strlen($text)? $elipsis: null);
return $out; return $out;
} }
} }
?> ?>

View file

@ -1,255 +1,255 @@
<?PHP <?PHP
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// + $Id$ // + $Id$
// +------------------------------------------------------------------+ // // +------------------------------------------------------------------+ //
// + Cake <https://developers.nextco.com/cake/> + // // + Cake <https://developers.nextco.com/cake/> + //
// + Copyright: (c) 2005, Cake Authors/Developers + // // + Copyright: (c) 2005, Cake Authors/Developers + //
// + Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com> + // // + Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com> + //
// + Larry E. Masters aka PhpNut <nut@phpnut.com> + // // + Larry E. Masters aka PhpNut <nut@phpnut.com> + //
// + Kamil Dzielinski aka Brego <brego.dk@gmail.com> + // // + Kamil Dzielinski aka Brego <brego.dk@gmail.com> + //
// +------------------------------------------------------------------+ // // +------------------------------------------------------------------+ //
// + Licensed under The MIT License + // // + Licensed under The MIT License + //
// + Redistributions of files must retain the above copyright notice. + // // + Redistributions of files must retain the above copyright notice. + //
// + See: http://www.opensource.org/licenses/mit-license.php + // // + See: http://www.opensource.org/licenses/mit-license.php + //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/** /**
* Purpose: Folder * Purpose: Folder
* Folder structure browser, lists folders and files. * Folder structure browser, lists folders and files.
* *
* @filesource * @filesource
* @author Cake Authors/Developers * @author Cake Authors/Developers
* @copyright Copyright (c) 2005, Cake Authors/Developers * @copyright Copyright (c) 2005, Cake Authors/Developers
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers * @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
* @package cake * @package cake
* @subpackage cake.libs * @subpackage cake.libs
* @since Cake v 0.2.9 * @since Cake v 0.2.9
* @version $Revision$ * @version $Revision$
* @modifiedby $LastChangedBy$ * @modifiedby $LastChangedBy$
* @lastmodified $Date$ * @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License * @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/ */
uses('object'); uses('object');
/** /**
* Folder structure browser, lists folders and files. * Folder structure browser, lists folders and files.
* *
* @package cake * @package cake
* @subpackage cake.libs * @subpackage cake.libs
* @since Cake v 0.2.9 * @since Cake v 0.2.9
*/ */
class Folder extends Object { class Folder extends Object {
/** /**
* Enter description here... * Enter description here...
* *
* @var string * @var string
*/ */
var $path = null; var $path = null;
/** /**
* Enter description here... * Enter description here...
* *
* @var boolean * @var boolean
*/ */
var $sort = false; var $sort = false;
/** /**
* Constructor. * Constructor.
* *
* @param string $path * @param string $path
*/ */
function __construct ($path=false) { function __construct ($path=false) {
if (empty($path)) $path = getcwd(); if (empty($path)) $path = getcwd();
$this->cd($path); $this->cd($path);
} }
/** /**
* Return current path. * Return current path.
* *
* @return string Current path * @return string Current path
*/ */
function pwd () { function pwd () {
return $this->path; return $this->path;
} }
/** /**
* Change directory to $desired_path. * Change directory to $desired_path.
* *
* @param string $desired_path Path to the directory to change to * @param string $desired_path Path to the directory to change to
* @return string The new path. Returns false on failure * @return string The new path. Returns false on failure
*/ */
function cd ($desired_path) { function cd ($desired_path) {
$desired_path = realpath($desired_path); $desired_path = realpath($desired_path);
$new_path = Folder::isAbsolute($desired_path)? $new_path = Folder::isAbsolute($desired_path)?
$desired_path: $desired_path:
Folder::addPathElement($this->path, $desired_path); Folder::addPathElement($this->path, $desired_path);
return is_dir($new_path)? $this->path = $new_path: false; return is_dir($new_path)? $this->path = $new_path: false;
} }
/** /**
* Returns an array of the contents of the current directory, or false on failure. * Returns an array of the contents of the current directory, or false on failure.
* The returned array holds two arrays: one of dirs and one of files. * The returned array holds two arrays: one of dirs and one of files.
* *
* @param boolean $sort * @param boolean $sort
* @return array * @return array
*/ */
function ls($sort=true) { function ls($sort=true) {
$dir = opendir($this->path); $dir = opendir($this->path);
if ($dir) { if ($dir) {
$dirs = $files = array(); $dirs = $files = array();
while (false !== ($n = readdir($dir))) { while (false !== ($n = readdir($dir))) {
if (!preg_match('#^\.+$#', $n)) { if (!preg_match('#^\.+$#', $n)) {
if (is_dir($this->addPathElement($this->path, $n))) if (is_dir($this->addPathElement($this->path, $n)))
$dirs[] = $n; $dirs[] = $n;
else else
$files[] = $n; $files[] = $n;
} }
} }
if ($sort || $this->sort) { if ($sort || $this->sort) {
sort($dirs); sort($dirs);
sort($files); sort($files);
} }
return array($dirs,$files); return array($dirs,$files);
} }
else { else {
return false; return false;
} }
} }
/** /**
* Returns an array of all matching files in current directory * Returns an array of all matching files in current directory
* *
* @param string $pattern Preg_match pattern (Defaults to: .*) * @param string $pattern Preg_match pattern (Defaults to: .*)
* @return array * @return array
*/ */
function find ($regexp_pattern='.*') function find ($regexp_pattern='.*')
{ {
$data = $this->ls(); $data = $this->ls();
if (!is_array($data)) if (!is_array($data))
return array(); return array();
list($dirs, $files) = $data; list($dirs, $files) = $data;
$found = array(); $found = array();
foreach ($files as $file) foreach ($files as $file)
{ {
if (preg_match("/^{$regexp_pattern}$/i", $file)) if (preg_match("/^{$regexp_pattern}$/i", $file))
{ {
$found[] = $file; $found[] = $file;
} }
} }
return $found; return $found;
} }
/** /**
* Returns an array of all matching files in and below current directory * Returns an array of all matching files in and below current directory
* *
* @param string $pattern Preg_match pattern (Defaults to: .*) * @param string $pattern Preg_match pattern (Defaults to: .*)
* @return array Files matching $pattern * @return array Files matching $pattern
*/ */
function findRecursive ($pattern='.*') { function findRecursive ($pattern='.*') {
$starts_on = $this->path; $starts_on = $this->path;
$out = $this->_findRecursive($pattern); $out = $this->_findRecursive($pattern);
$this->cd($starts_on); $this->cd($starts_on);
return $out; return $out;
} }
/** /**
* Private helper function for findRecursive. * Private helper function for findRecursive.
* *
* @param string $pattern * @param string $pattern
* @return array Files matching pattern * @return array Files matching pattern
*/ */
function _findRecursive ($pattern) { function _findRecursive ($pattern) {
list($dirs, $files) = $this->ls(); list($dirs, $files) = $this->ls();
$found = array(); $found = array();
foreach ($files as $file) { foreach ($files as $file) {
if (preg_match("/^{$pattern}$/i", $file)) { if (preg_match("/^{$pattern}$/i", $file)) {
$found[] = $this->addPathElement($this->path, $file); $found[] = $this->addPathElement($this->path, $file);
} }
} }
$start = $this->path; $start = $this->path;
foreach ($dirs as $dir) { foreach ($dirs as $dir) {
$this->cd($this->addPathElement($start, $dir)); $this->cd($this->addPathElement($start, $dir));
$found = array_merge($found, $this->findRecursive($pattern)); $found = array_merge($found, $this->findRecursive($pattern));
} }
return $found; return $found;
} }
/** /**
* Returns true if given $path is a Windows path. * Returns true if given $path is a Windows path.
* *
* @param string $path Path to check * @param string $path Path to check
* @return boolean * @return boolean
*/ */
function isWindowsPath ($path) { function isWindowsPath ($path) {
return preg_match('#^[A-Z]:\\\#i', $path)? true: false; return preg_match('#^[A-Z]:\\\#i', $path)? true: false;
} }
/** /**
* Returns true if given $path is an absolute path. * Returns true if given $path is an absolute path.
* *
* @param string $path Path to check * @param string $path Path to check
* @return boolean * @return boolean
*/ */
function isAbsolute ($path) { function isAbsolute ($path) {
return preg_match('#^\/#', $path) || preg_match('#^[A-Z]:\\\#i', $path); return preg_match('#^\/#', $path) || preg_match('#^[A-Z]:\\\#i', $path);
} }
/** /**
* Returns true if given $path ends in a slash (i.e. is slash-terminated). * Returns true if given $path ends in a slash (i.e. is slash-terminated).
* *
* @param string $path Path to check * @param string $path Path to check
* @return boolean * @return boolean
*/ */
function isSlashTerm ($path) { function isSlashTerm ($path) {
return preg_match('#[\\\/]$#', $path)? true: false; return preg_match('#[\\\/]$#', $path)? true: false;
} }
/** /**
* Returns a correct set of slashes for given $path. (\\ for Windows paths and / for other paths.) * Returns a correct set of slashes for given $path. (\\ for Windows paths and / for other paths.)
* *
* @param string $path Path to check * @param string $path Path to check
* @return string Set of slashes ("\\" or "/") * @return string Set of slashes ("\\" or "/")
*/ */
function correctSlashFor ($path) { function correctSlashFor ($path) {
return Folder::isWindowsPath($path)? '\\': '/'; return Folder::isWindowsPath($path)? '\\': '/';
} }
/** /**
* Returns $path with added terminating slash (corrected for Windows or other OS). * Returns $path with added terminating slash (corrected for Windows or other OS).
* *
* @param string $path Path to check * @param string $path Path to check
* @return string * @return string
*/ */
function slashTerm ($path) { function slashTerm ($path) {
return $path . (Folder::isSlashTerm($path)? null: Folder::correctSlashFor($path)); return $path . (Folder::isSlashTerm($path)? null: Folder::correctSlashFor($path));
} }
/** /**
* Returns $path with $element added, with correct slash in-between. * Returns $path with $element added, with correct slash in-between.
* *
* @param string $path * @param string $path
* @param string $element * @param string $element
* @return string * @return string
*/ */
function addPathElement ($path, $element) { function addPathElement ($path, $element) {
return Folder::slashTerm($path).$element; return Folder::slashTerm($path).$element;
} }
} }
?> ?>

View file

@ -1,224 +1,224 @@
<?PHP <?PHP
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// + $Id$ // + $Id$
// +------------------------------------------------------------------+ // // +------------------------------------------------------------------+ //
// + Cake <https://developers.nextco.com/cake/> + // // + Cake <https://developers.nextco.com/cake/> + //
// + Copyright: (c) 2005, Cake Authors/Developers + // // + Copyright: (c) 2005, Cake Authors/Developers + //
// + Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com> + // // + Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com> + //
// + Larry E. Masters aka PhpNut <nut@phpnut.com> + // // + Larry E. Masters aka PhpNut <nut@phpnut.com> + //
// + Kamil Dzielinski aka Brego <brego.dk@gmail.com> + // // + Kamil Dzielinski aka Brego <brego.dk@gmail.com> + //
// +------------------------------------------------------------------+ // // +------------------------------------------------------------------+ //
// + Licensed under The MIT License + // // + Licensed under The MIT License + //
// + Redistributions of files must retain the above copyright notice. + // // + Redistributions of files must retain the above copyright notice. + //
// + See: http://www.opensource.org/licenses/mit-license.php + // // + See: http://www.opensource.org/licenses/mit-license.php + //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/** /**
* Purpose: Inflector * Purpose: Inflector
* I'm trying to port RoR Inflector class here. * I'm trying to port RoR Inflector class here.
* Inflector pluralizes and singularizes English nouns. * Inflector pluralizes and singularizes English nouns.
* Test with $i = new Inflector(); $i->test(); * Test with $i = new Inflector(); $i->test();
* *
* @filesource * @filesource
* @author Cake Authors/Developers * @author Cake Authors/Developers
* @copyright Copyright (c) 2005, Cake Authors/Developers * @copyright Copyright (c) 2005, Cake Authors/Developers
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers * @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
* @package cake * @package cake
* @subpackage cake.libs * @subpackage cake.libs
* @since Cake v 0.2.9 * @since Cake v 0.2.9
* @version $Revision$ * @version $Revision$
* @modifiedby $LastChangedBy$ * @modifiedby $LastChangedBy$
* @lastmodified $Date$ * @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License * @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/ */
/** /**
* This is a port of Ruby on Rails' Inflector class. * This is a port of Ruby on Rails' Inflector class.
* Inflector pluralizes and singularizes English nouns. * Inflector pluralizes and singularizes English nouns.
* Test with $i = new Inflector(); $i->test(); * Test with $i = new Inflector(); $i->test();
* *
* @package cake * @package cake
* @subpackage cake.libs * @subpackage cake.libs
* @since Cake v 0.2.9 * @since Cake v 0.2.9
*/ */
class Inflector extends Object class Inflector extends Object
{ {
/** /**
* Constructor. * Constructor.
* *
*/ */
function __construct () { function __construct () {
parent::__construct(); parent::__construct();
} }
/** /**
* Return $word in plural form. * Return $word in plural form.
* *
* @param string $word Word in singular * @param string $word Word in singular
* @return string Word in plural * @return string Word in plural
*/ */
function pluralize ($word) { function pluralize ($word) {
$plural_rules = array( $plural_rules = array(
'/(x|ch|ss|sh)$/' => '\1es', # search, switch, fix, box, process, address '/(x|ch|ss|sh)$/' => '\1es', # search, switch, fix, box, process, address
'/series$/' => '\1series', '/series$/' => '\1series',
'/([^aeiouy]|qu)ies$/' => '\1y', '/([^aeiouy]|qu)ies$/' => '\1y',
'/([^aeiouy]|qu)y$/' => '\1ies', # query, ability, agency '/([^aeiouy]|qu)y$/' => '\1ies', # query, ability, agency
'/(?:([^f])fe|([lr])f)$/' => '\1\2ves', # half, safe, wife '/(?:([^f])fe|([lr])f)$/' => '\1\2ves', # half, safe, wife
'/sis$/' => 'ses', # basis, diagnosis '/sis$/' => 'ses', # basis, diagnosis
'/([ti])um$/' => '\1a', # datum, medium '/([ti])um$/' => '\1a', # datum, medium
'/person$/' => 'people', # person, salesperson '/person$/' => 'people', # person, salesperson
'/man$/' => 'men', # man, woman, spokesman '/man$/' => 'men', # man, woman, spokesman
'/child$/' => 'children', # child '/child$/' => 'children', # child
'/s$/' => 's', # no change (compatibility) '/s$/' => 's', # no change (compatibility)
'/$/' => 's' '/$/' => 's'
); );
foreach ($plural_rules as $rule => $replacement) { foreach ($plural_rules as $rule => $replacement) {
if (preg_match($rule, $word)) { if (preg_match($rule, $word)) {
return preg_replace($rule, $replacement, $word); return preg_replace($rule, $replacement, $word);
} }
} }
return false; return false;
} }
/** /**
* Return $word in singular form. * Return $word in singular form.
* *
* @param string $word Word in plural * @param string $word Word in plural
* @return string Word in singular * @return string Word in singular
*/ */
function singularize ($word) { function singularize ($word) {
$singular_rules = array( $singular_rules = array(
'/(x|ch|ss)es$/' => '\1', '/(x|ch|ss)es$/' => '\1',
'/movies$/' => 'movie', '/movies$/' => 'movie',
'/series$/' => 'series', '/series$/' => 'series',
'/([^aeiouy]|qu)ies$/' => '\1y', '/([^aeiouy]|qu)ies$/' => '\1y',
'/([lr])ves$/' => '\1f', '/([lr])ves$/' => '\1f',
'/([^f])ves$/' => '\1fe', '/([^f])ves$/' => '\1fe',
'/(analy|ba|diagno|parenthe|progno|synop|the)ses$/' => '\1sis', '/(analy|ba|diagno|parenthe|progno|synop|the)ses$/' => '\1sis',
'/([ti])a$/' => '\1um', '/([ti])a$/' => '\1um',
'/people$/' => 'person', '/people$/' => 'person',
'/men$/' => 'man', '/men$/' => 'man',
'/status$/' => 'status', '/status$/' => 'status',
'/children$/' => 'child', '/children$/' => 'child',
'/news$/' => 'news', '/news$/' => 'news',
'/s$/' => '' '/s$/' => ''
); );
foreach ($singular_rules as $rule => $replacement) { foreach ($singular_rules as $rule => $replacement) {
if (preg_match($rule, $word)) { if (preg_match($rule, $word)) {
return preg_replace($rule, $replacement, $word); return preg_replace($rule, $replacement, $word);
} }
} }
return false; return false;
} }
/** /**
* Returns given $lower_case_and_underscored_word as a camelCased word. * Returns given $lower_case_and_underscored_word as a camelCased word.
* *
* @param string $lower_case_and_underscored_word Word to camelize * @param string $lower_case_and_underscored_word Word to camelize
* @return string Camelized word. likeThis. * @return string Camelized word. likeThis.
*/ */
function camelize($lower_case_and_underscored_word) { function camelize($lower_case_and_underscored_word) {
return str_replace(" ","",ucwords(str_replace("_"," ",$lower_case_and_underscored_word))); return str_replace(" ","",ucwords(str_replace("_"," ",$lower_case_and_underscored_word)));
} }
/** /**
* Returns an underscore-syntaxed ($like_this_dear_reader) version of the $camel_cased_word. * Returns an underscore-syntaxed ($like_this_dear_reader) version of the $camel_cased_word.
* *
* @param string $camel_cased_word Camel-cased word to be "underscorized" * @param string $camel_cased_word Camel-cased word to be "underscorized"
* @return string Underscore-syntaxed version of the $camel_cased_word * @return string Underscore-syntaxed version of the $camel_cased_word
*/ */
function underscore($camel_cased_word) { function underscore($camel_cased_word) {
$camel_cased_word = preg_replace('/([A-Z]+)([A-Z])/','\1_\2',$camel_cased_word); $camel_cased_word = preg_replace('/([A-Z]+)([A-Z])/','\1_\2',$camel_cased_word);
return strtolower(preg_replace('/([a-z])([A-Z])/','\1_\2',$camel_cased_word)); return strtolower(preg_replace('/([a-z])([A-Z])/','\1_\2',$camel_cased_word));
} }
/** /**
* Returns a human-readable string from $lower_case_and_underscored_word, * Returns a human-readable string from $lower_case_and_underscored_word,
* by replacing underscores with a space, and by upper-casing the initial characters. * by replacing underscores with a space, and by upper-casing the initial characters.
* *
* @param string $lower_case_and_underscored_word String to be made more readable * @param string $lower_case_and_underscored_word String to be made more readable
* @return string Human-readable string * @return string Human-readable string
*/ */
function humanize($lower_case_and_underscored_word) { function humanize($lower_case_and_underscored_word) {
return ucwords(str_replace("_"," ",$lower_case_and_underscored_word)); return ucwords(str_replace("_"," ",$lower_case_and_underscored_word));
} }
/** /**
* Returns corresponding table name for given $class_name. * Returns corresponding table name for given $class_name.
* *
* @param string $class_name Name of class to get database table name for * @param string $class_name Name of class to get database table name for
* @return string Name of the database table for given class * @return string Name of the database table for given class
*/ */
function tableize($class_name) { function tableize($class_name) {
return Inflector::pluralize(Inflector::underscore($class_name)); return Inflector::pluralize(Inflector::underscore($class_name));
} }
/** /**
* Returns Cake class name ("Post" for the database table "posts".) for given database table. * Returns Cake class name ("Post" for the database table "posts".) for given database table.
* *
* @param string $table_name Name of database table to get class name for * @param string $table_name Name of database table to get class name for
* @return string * @return string
*/ */
function classify($table_name) function classify($table_name)
{ {
return Inflector::camelize(Inflector::singularize($table_name)); return Inflector::camelize(Inflector::singularize($table_name));
} }
/** /**
* Returns $class_name in underscored form, with "_id" tacked on at the end. * Returns $class_name in underscored form, with "_id" tacked on at the end.
* This is for use in dealing with the database. * This is for use in dealing with the database.
* *
* @param string $class_name * @param string $class_name
* @return string * @return string
*/ */
function foreignKey($class_name) function foreignKey($class_name)
{ {
return Inflector::underscore($class_name) . "_id"; return Inflector::underscore($class_name) . "_id";
} }
function toControllerFilename($name) function toControllerFilename($name)
{ {
return CONTROLLERS.Inflector::underscore($name).'.php'; return CONTROLLERS.Inflector::underscore($name).'.php';
} }
function toHelperFilename($name) function toHelperFilename($name)
{ {
return HELPERS.Inflector::underscore($name).'.php'; return HELPERS.Inflector::underscore($name).'.php';
} }
function toFullName($name, $correct) function toFullName($name, $correct)
{ {
if (strstr($name, '_') && (strtolower($name) == $name)) if (strstr($name, '_') && (strtolower($name) == $name))
{ {
return Inflector::camelize($name); return Inflector::camelize($name);
} }
if (preg_match("/^(.*)({$correct})$/i", $name, $reg)) if (preg_match("/^(.*)({$correct})$/i", $name, $reg))
{ {
if ($reg[2] == $correct) if ($reg[2] == $correct)
{ {
return $name; return $name;
} }
else else
{ {
return ucfirst($reg[1].$correct); return ucfirst($reg[1].$correct);
} }
} }
else else
{ {
return ucfirst($name.$correct); return ucfirst($name.$correct);
} }
} }
function toLibraryFilename ($name) function toLibraryFilename ($name)
{ {
return LIBS.Inflector::underscore($name).'.php'; return LIBS.Inflector::underscore($name).'.php';
} }
} }
?> ?>

View file

@ -1,78 +1,78 @@
<?PHP <?PHP
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// + $Id$ // + $Id$
// +------------------------------------------------------------------+ // // +------------------------------------------------------------------+ //
// + Cake <https://developers.nextco.com/cake/> + // // + Cake <https://developers.nextco.com/cake/> + //
// + Copyright: (c) 2005, Cake Authors/Developers + // // + Copyright: (c) 2005, Cake Authors/Developers + //
// + Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com> + // // + Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com> + //
// + Larry E. Masters aka PhpNut <nut@phpnut.com> + // // + Larry E. Masters aka PhpNut <nut@phpnut.com> + //
// + Kamil Dzielinski aka Brego <brego.dk@gmail.com> + // // + Kamil Dzielinski aka Brego <brego.dk@gmail.com> + //
// +------------------------------------------------------------------+ // // +------------------------------------------------------------------+ //
// + Licensed under The MIT License + // // + Licensed under The MIT License + //
// + Redistributions of files must retain the above copyright notice. + // // + Redistributions of files must retain the above copyright notice. + //
// + See: http://www.opensource.org/licenses/mit-license.php + // // + See: http://www.opensource.org/licenses/mit-license.php + //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/** /**
* with this hack you can use clone() in PHP4 code * with this hack you can use clone() in PHP4 code
* use "clone($object)" not "clone $object"! the former works in both PHP4 and PHP5 * use "clone($object)" not "clone $object"! the former works in both PHP4 and PHP5
* *
* *
* @filesource * @filesource
* @author Cake Authors/Developers * @author Cake Authors/Developers
* @copyright Copyright (c) 2005, Cake Authors/Developers * @copyright Copyright (c) 2005, Cake Authors/Developers
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers * @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
* @package cake * @package cake
* @subpackage cake.libs * @subpackage cake.libs
* @since Cake v 0.2.9 * @since Cake v 0.2.9
* @version $Revision$ * @version $Revision$
* @modifiedby $LastChangedBy$ * @modifiedby $LastChangedBy$
* @lastmodified $Date$ * @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License * @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/ */
if (version_compare(phpversion(), '5.0') < 0) { if (version_compare(phpversion(), '5.0') < 0) {
eval(' eval('
function clone($object) { function clone($object) {
return $object; return $object;
} }
'); ');
} }
/** /**
* Replace file_get_contents() * Replace file_get_contents()
* *
* @category PHP * @category PHP
* @package PHP_Compat * @package PHP_Compat
* @link http://php.net/function.file_get_contents * @link http://php.net/function.file_get_contents
* @author Aidan Lister <aidan@php.net> * @author Aidan Lister <aidan@php.net>
* @internal resource_context is not supported * @internal resource_context is not supported
* @since PHP 5 * @since PHP 5
* @require PHP 4.0.0 (user_error) * @require PHP 4.0.0 (user_error)
*/ */
if (!function_exists('file_get_contents')) { if (!function_exists('file_get_contents')) {
function file_get_contents($filename, $incpath = false) function file_get_contents($filename, $incpath = false)
{ {
if (false === $fh = fopen($filename, 'rb', $incpath)) { if (false === $fh = fopen($filename, 'rb', $incpath)) {
user_error('file_get_contents() failed to open stream: No such file or directory', user_error('file_get_contents() failed to open stream: No such file or directory',
E_USER_WARNING); E_USER_WARNING);
return false; return false;
} }
clearstatcache(); clearstatcache();
if ($fsize = @filesize($filename)) { if ($fsize = @filesize($filename)) {
$data = fread($fh, $fsize); $data = fread($fh, $fsize);
} else { } else {
$data = ''; $data = '';
while (!feof($fh)) { while (!feof($fh)) {
$data .= fread($fh, 8192); $data .= fread($fh, 8192);
} }
} }
fclose($fh); fclose($fh);
return $data; return $data;
} }
} }
?> ?>

View file

@ -1,173 +1,173 @@
<?PHP <?PHP
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// + $Id$ // + $Id$
// +------------------------------------------------------------------+ // // +------------------------------------------------------------------+ //
// + Cake <https://developers.nextco.com/cake/> + // // + Cake <https://developers.nextco.com/cake/> + //
// + Copyright: (c) 2005, Cake Authors/Developers + // // + Copyright: (c) 2005, Cake Authors/Developers + //
// + Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com> + // // + Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com> + //
// + Larry E. Masters aka PhpNut <nut@phpnut.com> + // // + Larry E. Masters aka PhpNut <nut@phpnut.com> + //
// + Kamil Dzielinski aka Brego <brego.dk@gmail.com> + // // + Kamil Dzielinski aka Brego <brego.dk@gmail.com> + //
// +------------------------------------------------------------------+ // // +------------------------------------------------------------------+ //
// + Licensed under The MIT License + // // + Licensed under The MIT License + //
// + Redistributions of files must retain the above copyright notice. + // // + Redistributions of files must retain the above copyright notice. + //
// + See: http://www.opensource.org/licenses/mit-license.php + // // + See: http://www.opensource.org/licenses/mit-license.php + //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/** /**
* Purpose: Router * Purpose: Router
* Parses the request URL into controller, action, and parameters. * Parses the request URL into controller, action, and parameters.
* *
* @filesource * @filesource
* @author Cake Authors/Developers * @author Cake Authors/Developers
* @copyright Copyright (c) 2005, Cake Authors/Developers * @copyright Copyright (c) 2005, Cake Authors/Developers
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers * @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
* @package cake * @package cake
* @subpackage cake.libs * @subpackage cake.libs
* @since Cake v 0.2.9 * @since Cake v 0.2.9
* @version $Revision$ * @version $Revision$
* @modifiedby $LastChangedBy$ * @modifiedby $LastChangedBy$
* @lastmodified $Date$ * @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License * @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/ */
uses('object', 'narray'); uses('object', 'narray');
/** /**
* Parses the request URL into controller, action, and parameters. * Parses the request URL into controller, action, and parameters.
* *
* @package cake * @package cake
* @subpackage cake.libs * @subpackage cake.libs
* @since Cake v 0.2.9 * @since Cake v 0.2.9
* *
*/ */
class Router extends Object { class Router extends Object {
/** /**
* Array of routes * Array of routes
* *
* @var array * @var array
*/ */
var $routes = array(); var $routes = array();
/** /**
* TODO: Better description. Returns this object's routes array. Returns false if there are no routes available. * TODO: Better description. Returns this object's routes array. Returns false if there are no routes available.
* *
* @param string $route An empty string, or a route string "/" * @param string $route An empty string, or a route string "/"
* @param array $default NULL or an array describing the default route * @param array $default NULL or an array describing the default route
* @see routes * @see routes
* @return array Array of routes * @return array Array of routes
*/ */
function connect ($route, $default=null) { function connect ($route, $default=null) {
$parsed = $names = array (); $parsed = $names = array ();
$r = null; $r = null;
if (($route == '') || ($route == '/')) { if (($route == '') || ($route == '/')) {
$regexp = '/^[\/]*$/'; $regexp = '/^[\/]*$/';
$this->routes[] = array($route, $regexp, array(), $default); $this->routes[] = array($route, $regexp, array(), $default);
} }
else { else {
$elements = array(); $elements = array();
foreach (explode('/', $route) as $element) foreach (explode('/', $route) as $element)
if (trim($element)) $elements[] = $element; if (trim($element)) $elements[] = $element;
if (!count($elements)) if (!count($elements))
return false; return false;
foreach ($elements as $element) { foreach ($elements as $element) {
if (preg_match('/^:(.+)$/', $element, $r)) { if (preg_match('/^:(.+)$/', $element, $r)) {
$parsed[] = '(?:\/([^\/]+))?'; $parsed[] = '(?:\/([^\/]+))?';
$names[] = $r[1]; $names[] = $r[1];
} }
elseif (preg_match('/^\*$/', $element, $r)) { elseif (preg_match('/^\*$/', $element, $r)) {
$parsed[] = '(?:\/(.*))?'; $parsed[] = '(?:\/(.*))?';
} }
else { else {
$parsed[] = '/'.$element; $parsed[] = '/'.$element;
} }
} }
$regexp = '#^'.join('', $parsed).'[\/]*$#'; $regexp = '#^'.join('', $parsed).'[\/]*$#';
$this->routes[] = array($route, $regexp, $names, $default); $this->routes[] = array($route, $regexp, $names, $default);
} }
return $this->routes; return $this->routes;
} }
/** /**
* TODO: Better description. Returns an array of routes. * TODO: Better description. Returns an array of routes.
* *
* @param string $url URL to be parsed * @param string $url URL to be parsed
* @return array * @return array
*/ */
function parse ($url) function parse ($url)
{ {
// An URL should start with a '/', mod_rewrite doesn't respect that, but no-mod_rewrite version does. // An URL should start with a '/', mod_rewrite doesn't respect that, but no-mod_rewrite version does.
// Here's the fix. // Here's the fix.
if ($url && ('/' != $url[0])) if ($url && ('/' != $url[0]))
{ {
$url = '/'.$url; $url = '/'.$url;
} }
$out = array(); $out = array();
$r = null; $r = null;
$default_route = array $default_route = array
( (
'/:controller/:action/* (default)', '/:controller/:action/* (default)',
"#^(?:\/(?:([a-z0-9_\-]+)(?:\/([a-z0-9_\-]+)(?:\/(.*))?)?))[\/]*$#", "#^(?:\/(?:([a-z0-9_\-]+)(?:\/([a-z0-9_\-]+)(?:\/(.*))?)?))[\/]*$#",
array('controller', 'action'), array('controller', 'action'),
array() array()
); );
$this->routes[] = $default_route; $this->routes[] = $default_route;
foreach ($this->routes as $route) foreach ($this->routes as $route)
{ {
list($route, $regexp, $names, $defaults) = $route; list($route, $regexp, $names, $defaults) = $route;
if (preg_match($regexp, $url, $r)) if (preg_match($regexp, $url, $r))
{ {
// $this->log($url.' matched '.$regexp, 'note'); // $this->log($url.' matched '.$regexp, 'note');
// remove the first element, which is the url // remove the first element, which is the url
array_shift($r); array_shift($r);
// hack, pre-fill the default route names // hack, pre-fill the default route names
foreach ($names as $name) foreach ($names as $name)
$out[$name] = null; $out[$name] = null;
$ii = 0; $ii = 0;
if (is_array($defaults)) if (is_array($defaults))
{ {
foreach ($defaults as $name=>$value) foreach ($defaults as $name=>$value)
{ {
if (preg_match('#[a-z_\-]#i', $name)) if (preg_match('#[a-z_\-]#i', $name))
$out[$name] = $value; $out[$name] = $value;
else else
$out['pass'][] = $value; $out['pass'][] = $value;
} }
} }
foreach ($r as $found) { foreach ($r as $found) {
// if $found is a named url element (i.e. ':action') // if $found is a named url element (i.e. ':action')
if (isset($names[$ii])) if (isset($names[$ii]))
{ {
$out[$names[$ii]] = $found; $out[$names[$ii]] = $found;
} }
// unnamed elements go in as 'pass' // unnamed elements go in as 'pass'
else else
{ {
$pass = new Narray(explode('/', $found)); $pass = new Narray(explode('/', $found));
$pass->cleanup(); $pass->cleanup();
$out['pass'] = $pass->value; $out['pass'] = $pass->value;
} }
$ii++; $ii++;
} }
break; break;
} }
} }
return $out; return $out;
} }
} }
?> ?>

View file

@ -1,53 +1,53 @@
<?PHP <?PHP
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// + $Id$ // + $Id$
// +------------------------------------------------------------------+ // // +------------------------------------------------------------------+ //
// + Cake <https://developers.nextco.com/cake/> + // // + Cake <https://developers.nextco.com/cake/> + //
// + Copyright: (c) 2005, Cake Authors/Developers + // // + Copyright: (c) 2005, Cake Authors/Developers + //
// + Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com> + // // + Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com> + //
// + Larry E. Masters aka PhpNut <nut@phpnut.com> + // // + Larry E. Masters aka PhpNut <nut@phpnut.com> + //
// + Kamil Dzielinski aka Brego <brego.dk@gmail.com> + // // + Kamil Dzielinski aka Brego <brego.dk@gmail.com> + //
// +------------------------------------------------------------------+ // // +------------------------------------------------------------------+ //
// + Licensed under The MIT License + // // + Licensed under The MIT License + //
// + Redistributions of files must retain the above copyright notice. + // // + Redistributions of files must retain the above copyright notice. + //
// + See: http://www.opensource.org/licenses/mit-license.php + // // + See: http://www.opensource.org/licenses/mit-license.php + //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/** /**
* Purpose: Tort Validators * Purpose: Tort Validators
* Used to validate data in Models. * Used to validate data in Models.
* *
* @filesource * @filesource
* @author Cake Authors/Developers * @author Cake Authors/Developers
* @copyright Copyright (c) 2005, Cake Authors/Developers * @copyright Copyright (c) 2005, Cake Authors/Developers
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers * @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
* @package cake * @package cake
* @subpackage cake.libs * @subpackage cake.libs
* @since Cake v 0.2.9 * @since Cake v 0.2.9
* @version $Revision$ * @version $Revision$
* @modifiedby $LastChangedBy$ * @modifiedby $LastChangedBy$
* @lastmodified $Date$ * @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License * @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/ */
/** /**
* Not empty. * Not empty.
*/ */
define('VALID_NOT_EMPTY', '/.+/'); define('VALID_NOT_EMPTY', '/.+/');
/** /**
* Numbers [0-9] only. * Numbers [0-9] only.
*/ */
define('VALID_NUMBER', '/^[0-9]+$/'); define('VALID_NUMBER', '/^[0-9]+$/');
/** /**
* A valid email address. * A valid email address.
*/ */
define('VALID_EMAIL', '/^([a-z0-9][a-z0-9_\-\.\+]*)@([a-z0-9][a-z0-9\.\-]{0,63}\.[a-z]{2,3})$/i'); define('VALID_EMAIL', '/^([a-z0-9][a-z0-9_\-\.\+]*)@([a-z0-9][a-z0-9\.\-]{0,63}\.[a-z]{2,3})$/i');
/** /**
* A valid year (1000-2999). * A valid year (1000-2999).
*/ */
define('VALID_YEAR', '/^[12][0-9]{3}$/'); define('VALID_YEAR', '/^[12][0-9]{3}$/');
?> ?>

View file

@ -1,110 +1,110 @@
BODY { BODY {
font-size: 76%; font-size: 76%;
} }
BODY, INPUT, TEXTAREA { BODY, INPUT, TEXTAREA {
font-family:sans-serif; font-family:sans-serif;
} }
H1 { H1 {
font-size:2.1em; font-size:2.1em;
color: #fff; color: #fff;
text-align: left; text-align: left;
position: absolute; position: absolute;
padding-left: 15%; padding-left: 15%;
top: 0.35em; top: 0.35em;
left: 0; left: 0;
height: 4em; height: 4em;
} }
H2 { H2 {
font-size:1.7em; font-size:1.7em;
color: #383; color: #383;
} }
H3 { H3 {
font-size:1.4em; font-size:1.4em;
color: #553; color: #553;
} }
H4 { H4 {
font-size:1.15em; font-size:1.15em;
color: #338; color: #338;
} }
P { P {
font-size:1em; font-size:1em;
margin-bottom:.5em; margin-bottom:.5em;
} }
A { A {
white-space:nowrap; white-space:nowrap;
text-decoration:underline; text-decoration:underline;
} }
A:HOVER { A:HOVER {
background-color:#EEE; background-color:#EEE;
} }
CODE, PRE { CODE, PRE {
font-family:monospace; font-family:monospace;
font-size:1.1em !important; font-size:1.1em !important;
font-size:.95em; font-size:.95em;
color:#44A; color:#44A;
margin:0; margin:0;
} }
CODE { CODE {
color:#227; color:#227;
white-space:nowrap; white-space:nowrap;
margin:0 .2em; margin:0 .2em;
} }
PRE { PRE {
margin-left:1em; margin-left:1em;
} }
ACRONYM { ACRONYM {
border-bottom:1px dotted; border-bottom:1px dotted;
} }
HR { HR {
height:0; height:0;
border-top:1px solid #AAA; border-top:1px solid #AAA;
} }
#container { #container {
margin: 0 auto; margin: 0 auto;
border-top: solid 5em #69c; border-top: solid 5em #69c;
color: #333; color: #333;
font: normal 1.1em Verdana; font: normal 1.1em Verdana;
padding: 0 15%; padding: 0 15%;
} }
#content { #content {
padding-top: 1em; padding-top: 1em;
width: 100%; width: 100%;
text-align: left; text-align: left;
line-height: 170%; line-height: 170%;
} }
.notice { .notice {
padding: 1em; padding: 1em;
background: #ffd; background: #ffd;
border: solid 2px #eeb; border: solid 2px #eeb;
display: block; display: block;
font-family: Verdana; font-family: Verdana;
} }
.tip { .tip {
background: #efe; background: #efe;
padding: 1em; padding: 1em;
border: solid 2px #cdc; border: solid 2px #cdc;
} }
.error { .error {
background: #fee; background: #fee;
padding: 1em; padding: 1em;
border: solid 2px #dcc; border: solid 2px #dcc;
} }