merging all changes done in sandbox for next release into the trunk

git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1057 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2005-10-03 04:48:00 +00:00
parent ab1db2532e
commit d44a364285
169 changed files with 2739 additions and 2166 deletions

View file

@ -1,5 +1,5 @@
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>

5
app/.htaccess Normal file
View file

@ -0,0 +1,5 @@
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>

View file

@ -31,6 +31,16 @@
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
if(function_exists('apache_get_modules'))
{
$modules = apache_get_modules();
if(!in_array('mod_rewrite', $modules) || !is_file('.htaccess'))
{
define ('BASE_URL', $_SERVER['SCRIPT_NAME']);
}
}
/**
* Set debug level here:
* - 0: production
@ -54,6 +64,16 @@ define('COMPRESS_CSS', false);
*/
define('AUTO_OUTPUT', false);
/**
* If set to false, session would not automatically be started.
*/
define('AUTO_SESSION', true);
/**
* Set the max size of file to use md5() .
*/
define('MAX_MD5SIZE', (5*1024)*1024 );
/**
* To use Access Control Lists with Cake...
*/

View file

@ -39,110 +39,125 @@
*/
if(!defined('ROOT'))
{
define('ROOT', '../');
define ('ROOT', '../');
}
if(!defined('WEBROOT_DIR'))
{
define ('WEBROOT_DIR', 'webroot');
}
/**
* Path to the application's directory.
*/
define('APP', ROOT.'app'.DS);
define ('CAKE', ROOT.'cake'.DS);
/**
* Path to the application's directory.
*/
define ('APP', ROOT.APP_DIR.DS);
/**
* Path to the application's models directory.
*/
define('MODELS', APP.'models'.DS);
define ('MODELS', APP.'models'.DS);
/**
* Path to the application's controllers directory.
*/
define('CONTROLLERS', APP.'controllers'.DS);
/**
* Path to the application's helpers directory.
*/
define('HELPERS', APP.'helpers'.DS);
define ('CONTROLLERS', APP.'controllers'.DS);
/**
* Path to the application's views directory.
*/
define('VIEWS', APP.'views'.DS);
define ('VIEWS', APP.'views'.DS);
/**
* Path to the application's helpers directory.
*/
define ('HELPERS', VIEWS.'helpers'.DS);
/**
* 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.
* 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).
*/
define('ELEMENTS', APP.'views'.DS.'elements'.DS);
define ('ELEMENTS', APP.'views'.DS.'elements'.DS);
/**
* Path to the configuration files directory.
*/
define('CONFIGS', ROOT.'config'.DS);
define ('CONFIGS', APP.'config'.DS);
/**
* Path to the libs directory.
*/
define ('LIBS', ROOT.'libs'.DS);
define ('LIBS', CAKE.'libs'.DS);
/**
* Path to the logs directory.
*/
define('LOGS', ROOT.'logs'.DS);
define ('LOGS', ROOT.'logs'.DS);
/**
* Path to the modules directory.
*/
define('MODULES', ROOT.'modules'.DS);
define ('MODULES', ROOT.'modules'.DS);
/**
* Path to the public directory.
*/
define('WWW_ROOT', ROOT.'public'.DS);
define ('WWW_ROOT', APP.WEBROOT_DIR.DS);
/**
* Path to the public directory.
*/
define('CSS', WWW_ROOT.'css'.DS);
define ('CSS', WWW_ROOT.'css'.DS);
/**
* Path to the public directory.
*/
define ('JS', WWW_ROOT.'js'.DS);
/**
* Path to the scripts direcotry.
*/
define('SCRIPTS', ROOT.'scripts'.DS);
define('SCRIPTS', CAKE.'scripts'.DS);
/**
* Path to the tests directory.
*/
define('TESTS', ROOT.'tests'.DS);
define ('TESTS', ROOT.'tests'.DS);
/**
* Path to the controller test directory.
*/
define('CONTROLLER_TESTS', TESTS.'app'.DS.'controllers'.DS);
define ('CONTROLLER_TESTS',TESTS.APP_DIR.'controllers'.DS);
/**
* Path to the helpers test directory.
*/
define('HELPER_TESTS', TESTS.'app'.DS.'helpers'.DS);
define ('HELPER_TESTS', TESTS.APP_DIR.'helpers'.DS);
/**
* Path to the models' test directory.
*/
define('MODEL_TESTS', TESTS.'app'.DS.'models'.DS);
define ('MODEL_TESTS', TESTS.APP_DIR.'models'.DS);
/**
* Path to the lib test directory.
*/
define('LIB_TESTS', TESTS.'libs'.DS);
define ('LIB_TESTS', TESTS.'libs'.DS);
/**
* 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.
@ -152,15 +167,14 @@ define('CACHE', TMP.'cache'.DS);
/**
* Path to the vendors directory.
*/
define('VENDORS', ROOT.'vendors'.DS);
define ('VENDORS', ROOT.'vendors'.DS);
/**
* Path to the Pear directory
* The purporse is to make it easy porting Pear libs into Cake
* without setting the include_path PHP variable.
*/
define('PEAR', VENDORS.'Pear'.DS);
define ('PEAR', VENDORS.'Pear'.DS);
/**
* Full url prefix
@ -170,16 +184,17 @@ define('FULL_BASE_URL', 'http://'.$_SERVER['HTTP_HOST']);
/**
* Web path to the public images directory.
*/
define('IMAGES_URL', '/img/');
define ('IMAGES_URL', 'img/');
/**
* Web path to the CSS files directory.
*/
define('CSS_URL', '/css/');
define ('CSS_URL', 'css/');
/**
* Web path to the js files directory.
*/
define('JS_URL', '/js/');
define ('JS_URL', 'js/');
?>

View file

@ -1,67 +0,0 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
*
* Long description for file
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
* Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @author CakePHP Authors/Developers
* @copyright Copyright (c) 2005, CakePHP Authors/Developers
* @link https://trac.cakephp.org/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.app.controllers
* @since CakePHP v 0.2.9
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Short description for class.
*
* Long description for class
*
* @package cake
* @subpackage cake.app.controllers
*/
class TestsController extends TestsHelper {
function index ()
{
$this->layout = null;
require_once TESTS.'index.php';
}
function groups ()
{
$this->layout = null;
$_GET['show'] = 'groups';
require_once TESTS.'index.php';
exit();
}
function cases ()
{
$this->layout = null;
$_GET['show'] = 'cases';
require_once TESTS.'index.php';
exit();
}
}
?>

View file

@ -1,47 +0,0 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
*
* In this file you can extend the TestsController.
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
* Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @author CakePHP Authors/Developers
* @copyright Copyright (c) 2005, CakePHP Authors/Developers
* @link https://trac.cakephp.org/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.app.helpers
* @since CakePHP v 0.2.9
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Short description for class.
*
* Long description for class
*
* @package cake
* @subpackage cake.app.helpers
*/
class TestsHelper extends AppController
{
}
?>

View file

@ -2,10 +2,6 @@
/* SVN FILE: $Id$ */
/**
* Short description for file.
*
* In this file you can extend the PagesController.
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
@ -23,25 +19,12 @@
* @copyright Copyright (c) 2005, CakePHP Authors/Developers
* @link https://trac.cakephp.org/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.app.helpers
* @since CakePHP v 0.2.9
* @subpackage cake.libs
* @since CakePHP v 0.10.0.1036
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*
/**
* Short description for class.
*
* Long description for class
*
* @package cake
* @subpackage cake.app.helpers
*/
class PagesHelper extends AppController
{
}
include_once('webroot'.DIRECTORY_SEPARATOR.'index.php');
?>

View file

@ -1 +0,0 @@
<?=$content_for_layout?>

View file

@ -1,19 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo $title_for_layout?></title>
<?php echo $html->charsetTag('UTF-8')?>
<?php echo $html->cssTag('default')?>
<?php echo $html->cssTag('forms')?>
</head>
<body>
<div id="main">
<?php echo $content_for_layout?>
<p>
<a id="logo" href="http://www.cakephp.org/" target="_new"><img src="<?php echo $html->url("/img/pbcake.gif"); ?>" width="120" height="28" alt="CakePHP : Rapid Development Framework" /></a>
</p>
</div>
</body>
</html>

View file

@ -1,11 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head>
<title><?=$code?> <?=$name?></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<h1><?=$name?></h1>
<p><?=$message?></p>
</body>
</html>

View file

@ -1,91 +0,0 @@
<html>
<head>
<style type="text/css"><!--
BODY {
font:normal .9em Arial,sans-serif;
color:Black;
}
TABLE {
margin-left:3em;
border-collapse:collapse;
border:2px solid #DDD;
}
TH, TD {
font:normal .8em Tahoma, sans-serif;
}
TH {
text-align:left;
padding:.4em .3em .1em .3em;
}
TH B {
font:bold 1.2em Arial,sans-serif;
}
TD {
padding:.1em .55em;
}
TR.fail TD {
font-weight:bold;
color:#FFF;
background-color:#F31;
}
TR.info TD {
background-color:#F8F8F8;
padding:.5em 1em .5em 2em;
}
TR.info .ok {
color:Green;
}
TR.info .not {
color:Red;
}
TR.info EM {
color:Gray;
font-style:normal;
}
TR.unkn TD {
background-color:#FF0;
}
TR.pass TD, TR.expected TD {
color:Green;
}
CODE {
font-size:1.2em;
}
CODE.expected {
color: green;
}
CODE.actual {
color: red;
}
.typeinfo {
color: gray;
}
.box {
font-size:3em;
text-align:center;
margin-top:1em;
}
.box B {
color:#FFF;
padding:.3em .6em;
background-color:#BBB;
}
#ok B {
background-color:#82AF15;
}
#error B {
background-color:#C2361B;
}
--></style>
<body>
<?=$content_for_layout?>
</body>
</html>

View file

@ -1,29 +0,0 @@
<h1>CakePHP <em>Works!</em></h1><br/>
<hr/>
Your database configuration file is <?php echo file_exists(CONFIGS.'database.php') ? 'present.'. $filePresent = ' ' : 'not present.';?><br/>
<?php $db = DboFactory::getInstance(); ?>
<?php if (!empty($filePresent)):?>
Cake <?php echo $db->connected ? "is able to" : "is not able to" ?> connect to the database.
<?php endif; ?>
<hr/>
<br/>
<h2>Editing <em>this Page</em></h2>
<p>
To change the content of this page, edit <code>/app/views/pages/home.thtml</code>. To change it's layout, edit <code>/app/views/layouts/default.thtml</code>. You can also edit the CSS styles for this page at <code>/public/css/default.css</code>.
</p><br/>
<h2>Introducing <em>Cake</em></h2>
<p>Cake is a rapid development framework for PHP: a structure of libraries, classes and run-time infrastructure for programmers creating web applications. Our primary goal is to enable you to work in a structured and rapid manner within a framework - without loss of flexibility. </p><br/>
<p>Tired of repeating yourself? Ever copy and pasted code? Want to get your app in production quicker? Cake is for you. </p><br/>
<h2>Get <em>Involved</em></h2>
<p>Cake PHP needs you! We have an active user base and are always open to new bug reports or feature ideas!</p><br/>
<?php echo $html->linkOut('Google Group','http://groups-beta.google.com/group/cake-php')?> &ndash; for public discussions about everything Cake.<br/>
<?php echo $html->linkOut('Wiki','https://trac.cakephp.org/wiki')?> &ndash; fastest way of getting newest information on Cake PHP.<br/>
<?php echo $html->linkOut('Report a bug or feature request','https://trac.cakephp.org/newticket')?>.<br/>
<?php echo $html->linkOut('Roadmap','https://trac.cakephp.org/roadmap')?> &ndash; check our plans for the bright future.<br/>
#cakephp on irc.euirc.net for quick help<br/>
</p>
<br/>
<p>Cake 0.9.2</p>

View file

@ -1,4 +0,0 @@
<?php
/* empty view
* output is handle by the test suite
*/ ?>

View file

@ -1,30 +0,0 @@
<?php /* if ($success) { ?>
<p class="box" id="ok"><b>PASSED</b></p>
<?php } else { ?>
<p class="box" id="error"><b>FAILED</b></p>
<?php } ?>
<table>
<?php foreach ($results as $r) {
$performed = $r['result']['tests'];
if ($performed||1) {
?>
<tr><th><b><?=$r['name']?></b> <?=$performed?> test<?=$performed==1?'':'s'?></th></tr>
<?php if ($r['result']['tests']) {
foreach ($r['result']['details'] as $detail) {
if ($detail['failed']) { ?>
<tr class="fail"><td><?=$r['name']?>::<?=$detail['method']?></td></tr>
<?php foreach ($detail['errors'] as $error) { ?>
<tr class="info"><td>
<span class="ok"><?=$error['expected'][0]?></span> <em><?=$error['expected'][1]?></em><br />
<span class="not"><?=$error['actual'][0]?></span> <em><?=$error['actual'][1]?></em>
</td></tr>
<?php
}
}
else { ?>
<tr class="pass"><td><?=$r['name']?>::<?=$detail['method']?></td></tr>
<?php } } } } } ?>
</table>
<?php */ ?>

5
app/webroot/.htaccess Normal file
View file

@ -0,0 +1,5 @@
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>

View file

@ -0,0 +1,167 @@
body
{
margin: 0;
font:small "Trebuchet MS",Verdana,Arial,Sans-serif;
background: #F2F5F5 url('../img/cake.bg.body.gif') top center repeat-y;
}
h1
{
margin: 4px;
padding: 0;
color: #71300F;
font-size: 30px;
}
h1 em {
color: #DBA941;
font-style: normal;
font-weight: normal;
font-variant: normal;
}
h2
{
margin-top: 20px;
margin-bottom: 6px;
padding: 0;
color: #71300F;
}
h2 em {
color: #DBA941;
font-style: normal;
font-weight: bold;
font-variant: normal;
}
h3
{
margin-top: 20px;
margin-bottom: 6px;
color: #71300F;
}
acronym
{
border-bottom: 1px dotted #DBA941;
}
ul
{
font-family: Helvetica;
margin-top: 2px;
margin-bottom: 6px;
padding: 2px 30px;
}
ul li
{
list-style-image: url(../img/cake.redbox.gif);
padding-bottom: 8px;
}
p
{
font-family: Helvetica;
margin-top: 2px;
margin-left: 4px;
margin-bottom: 6px;
}
#main
{
width: 752px;
margin-top: 0px;
margin-left: auto;
margin-right: auto;
padding-bottom: 20px;
background-color: #EFF1F1;
border-top: 4px solid #fff;
/*border-bottom: 1px solid #D2D7D8;*/
/*border-top: 1px solid #C9CFD1;
border-bottom: 1px solid #C9CFD1;
border-left: 1px solid #C9CFD1;
border-right: 1px solid #C9CFD1;*/
}
#header
{
padding: 0px;
height: 112px;
background: #fff url(../img/cake.bg.header.gif) repeat-x;
border-bottom: 1px solid #D2D7D8;
}
#headerLogo
{
float: left;
}
#headerNav
{
float: left;
margin-top: 56px;
margin-left: 10px;
}
#headerNav a {
padding: 4px 10px;
font-weight: bold;
}
#headerSubNav
{
float: left;
margin-top: 12px;
margin-left: 10px;
}
#headerSubNav a {
padding: 4px 10px;
font-weight: bold;
}
#content
{
margin: 20px 20px;
padding: 0px 28px 40px 22px;
background-color: #fff;
border-top: 1px solid #D2D7D8;
border-left: 1px solid #D2D7D8;
border-right: 1px solid #D2D7D8;
border-bottom: 1px solid #D2D7D8;
}
a
{
color: #71300F;
text-decoration: none;
font-weight: bold;
}
a:hover
{
color: #71300F;
text-decoration: underline;
font-weight: bold;
}
#footer
{
padding-bottom: 40px;
}
.active {
background-color: #D2D7D8;
padding: 10px;
}
***Please Leave Powered by Cake****/
#pb-cake {
width: 752px;
margin-top: 0px;
margin-left: auto;
margin-right: auto;
padding-right: 6px;
text-align: right;
}
#pb-cake a{
padding: 0;
}

View file

@ -1,13 +1,6 @@
/* form.css */
* {
margin: 0px;
padding: 0px;
}
form {
margin: 0px;
padding: 0px;
font-size: 100%;
min-width: 560px;
max-width: 620px;
@ -20,14 +13,12 @@ form fieldset {
border-width: 1px 0px 0px 0px;
border-style: solid none none none;
padding: 10px;
margin: 0px 0px 0px 0px;
}
form fieldset legend {
font-size: 150%;
font-weight: normal;
color: #000000;
margin: 0px 0px 0px 0px;
color: #000;
padding: 0px 5px;
}
@ -43,7 +34,7 @@ label u {
input, select, textarea {
font-family: Tahoma, Arial, sans-serif;
font-size: 100%;
color: #000000;
color: #000;
}
textarea {
@ -65,9 +56,9 @@ form fieldset div.notes {
height: auto;
margin: 0px 0px 10px 10px;
padding: 5px;
border: 1px solid #666666;
border: 1px solid #666;
background-color: #ffffe1;
color: #666666;
color: #666;
font-size: 88%;
}
@ -78,14 +69,14 @@ form fieldset div.notes h4 {
padding: 3px 0px 3px 27px;
border-width: 0px 0px 1px 0px;
border-style: solid;
border-color: #666666;
color: #666666;
border-color: #666;
color: #666;
font-size: 110%;
}
form fieldset div.notes p {
margin: 0em 0em 1.2em 0em;
color: #666666;
color: #666;
}
form fieldset div.notes p.last {
@ -96,7 +87,7 @@ form div fieldset {
clear: none;
border-width: 1px;
border-style: solid;
border-color: #666666;
border-color: #666;
margin: 0px 0px 0px 142px;
padding: 0px 5px 5px 5px;
width: 197px;
@ -133,7 +124,6 @@ form div label.labelCheckbox, form div label.labelRadio {
display: block;
width: 200px;
height: expression('1%');
padding: 0px;
margin: 0px 0px 5px 142px;
text-align: left;
}
@ -144,13 +134,13 @@ form div fieldset label.labelCheckbox, form div fieldset label.labelRadio {
}
p.error {
background-color: #ff0000;
background-color: #f00;
background-image: url(/images/icon_error.gif);
background-repeat: no-repeat;
background-position: 3px 3px;
color: #ffffff;
padding: 3px 3px 5px 27px;
border: 1px solid #000000;
border: 1px solid #000;
margin: auto 100px;
}
@ -159,8 +149,8 @@ form div.error {
background-image: url(/images/required_bg.gif);
background-repeat: no-repeat;
background-position: top left;
color: #666666;
border: 1px solid #ff0000;
color: #666;
border: 1px solid #f00;
}
form div.error p.error {
@ -172,7 +162,7 @@ form div.error p.error {
font-weight: bold;
margin: 0px 0px 0px 118px;
width: 200px;
color: #ff0000;
color: #f00;
}
form div input, form div select, form div textarea {
@ -196,8 +186,6 @@ form div input.inputCheckbox, form div input.inputRadio, input.inputCheckbox, in
width: 14px;
background-color: transparent;
border-width: 0px;
padding: 0px;
margin: 0px 0px 0px 0px;
}
form div.submit {
@ -208,7 +196,6 @@ form div.submit {
}
div.submit input {
align:center;
text-align:center;
font-weight: bold;
color: #fff;
@ -227,8 +214,6 @@ form div.submit div {
float: left;
text-align: left;
width: auto;
padding: 0px;
margin: 0px;
}
form div input.inputSubmit, form div input.inputButton, input.inputSubmit, input.inputButton {
@ -236,7 +221,6 @@ form div input.inputSubmit, form div input.inputButton, input.inputSubmit, input
color: #000000;
width: auto;
padding: 0px 6px;
margin: 0px;
}
form div.submit div input.inputSubmit, form div.submit div input.inputButton {
@ -259,7 +243,7 @@ form fieldset legend {
}
form input, form select, form textarea {
background-color: #ffffff;
background-color: #fff;
}
form textarea.expanding {
@ -286,7 +270,7 @@ form div label.labelCheckbox, form div label.labelRadio, label.labelCheckbox, la
}
form div label.labelCheckbox input.inputCheckbox, form div label.labelRadio input.inputRadio, label.labelCheckbox input.inputCheckbox, label.labelRadio input.inputRadio {
margin: 0px 0px 0px 0px;
margin: 0;
}
form div fieldset input.inputText, form div fieldset input.inputPassword, form div fieldset input.inputFile, form div fieldset textarea.inputTextarea {
@ -300,7 +284,7 @@ form div label.compact {
width: auto;
padding: 4px 10px 0px 0px;
text-indent: 0px;
margin: 0px 0px 0px 0px;
margin: 0;
}
form div.wide label {
@ -314,7 +298,7 @@ form div label.wide {
form div.wide input.inputText, form div.wide input.inputPassword, form div.wide input.inputFile, form div.wide select, form div.wide textarea {
width: 344px;
margin: 0px;
margin: 0;
}
form div.notes p, form div small {
@ -334,5 +318,5 @@ select.autoWidth {
}
option {
padding-left:1em;
}
padding-left:1em;
}

View file

@ -0,0 +1,161 @@
/* CSS Document */
* {
margin: 0;
padding: 0;
}
body {
color: #333;
font: 76% Verdana, Arial, Helvetica, sans-serif;
}
h1 {
color: #69c;
font-size:2.1em;
}
h2 {
color: #383;
clear: both;
display:block;
font-size:1.7em;
float:left;
margin-top:5px;
}
h3 {
color: #553;
font-size:1.4em;
}
h4 {
color: #338;
font-size:1.15em;
}
a {
text-decoration:underline;
white-space:nowrap;
}
a:hover {
background-color:#eee;
}
code, pre {
color:#44a;
font-family:monospace;
font-size:1.15em;
}
code {
color:#227;
margin:0 .2em;
white-space:nowrap;
}
pre {
margin-left:1em;
}
acronym {
border-bottom:1px dotted #666;
}
ul {
margin-top:1em;
list-style:none;
}
li {
margin-left:2em;
}
#container {
color: #333;
margin: 2em auto;
width:80%;
}
.notice {
background: #ffd;
border: solid 2px #eeb;
display: block;
font-family: Verdana;
padding: 1em;
}
.tip {
background: #efe;
border: solid 2px #cdc;
padding: 1em;
}
.error {
background: #fee;
border: solid 2px #dcc;
padding: 1em;
}
ul.actions {
float:left;
list-style: none;
text-align:right;
margin:2em 0;
}
ul.actions li {
border: 1px solid #333;
float:left;
margin-left:1em;
width:10em;
}
ul.actions li a, ul.actions li input {
background-color:#3297FC;
border:1px solid #3297FC;
clear: both;
color: #fff;
display:block;
font-weight: bold;
text-align:center;
text-decoration: none;
}
td.listactions {
width:17em;
}
td.listactions a {
text-align:center;
font-weight: bold;
color: #fff;
background-color:#3297FC;
display:block;
float:left;
text-decoration: none;
margin-bottom:3px;
margin-right: 3px;
border: 1px;
width:5em;
}
table {
background-color: #fff;
border: 1px solid #686E74;
clear:both;
margin: 1em 0 2em 0;
width: 100%;
}
th {
background-color: #ccc;
border-top: 1px solid #fff;
border-right: 1px solid #666;
border-bottom: 1px solid #666;
text-align: left;
padding:3px;
white-space:nowrap;
}
table tr td {
border-right: 1px solid #ccc;
padding:2px 0;
vertical-align:top;
}
table tr.altRow td {
background: #EBF4FD;
}
div.related {
clear:both;
display:block;
float:left;
}
dl {
line-height:2em;
margin:1em;
}
dt {
font-weight: bold;
vertical-align:top;
}
dd {
margin-left:10em;
margin-top:-2em;
vertical-align:top;
}

BIN
app/webroot/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 B

View file

Before

Width:  |  Height:  |  Size: 531 B

After

Width:  |  Height:  |  Size: 531 B

View file

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View file

Before

Width:  |  Height:  |  Size: 45 B

After

Width:  |  Height:  |  Size: 45 B

View file

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View file

@ -32,11 +32,6 @@
*/
/**
* Enter description here...
*/
$url = empty($_GET['url'])? null: $_GET['url'];
/**
* Get Cake's root directory
*/
@ -54,25 +49,70 @@ if (!defined('ROOT'))
* Enter description here...
*
*/
define('ROOT', dirname(dirname(__FILE__)).DS);
define('ROOT', dirname(dirname(dirname(__FILE__))).DS);
}
if (!defined('APP_DIR'))
{
define ('APP_DIR', basename(dirname(dirname(__FILE__))));
}
if (!defined('WEBROOT_DIR'))
{
define ('WEBROOT_DIR', basename(dirname(__FILE__)));
}
/**
* Configuration, directory layout and standard libraries
*/
require_once ROOT.APP_DIR.DS.'config'.DS.'core.php';
require_once ROOT.APP_DIR.DS.'config'.DS.'paths.php';
require_once CAKE.'basics.php';
require_once LIBS.'log.php';
require_once LIBS.'object.php';
require_once LIBS.'neat_array.php';
require_once LIBS.'inflector.php';
/**
* Enter description here...
*/
if (empty($uri) && defined('BASE_URL'))
{
$uri = setUri();
if ($uri === '/' || $uri === '/index.php' || $uri === '/app/')
{
$_GET['url'] = '/';
$url = '/';
}
else
{
$elements = explode('/index.php', $uri);
if(!empty($elements[1]))
{
$_GET['url'] = $elements[1];
$url = $elements[1];
}
else
{
$_GET['url'] = '/';
$url = '/';
}
}
}
else
{
$url = empty($_GET['url'])? null: $_GET['url'];
}
if (strpos($url, 'ccss/') === 0)
{
include ROOT.'public'.DS.'css.php';
die;
}
/**
* Configuration, directory layout and standard libraries
*/
require_once ROOT.'config/core.php';
require_once ROOT.'config/paths.php';
require_once ROOT.'libs/basics.php';
require_once ROOT.'libs/log.php';
require_once ROOT.'libs/object.php';
require_once ROOT.'libs/neat_array.php';
require_once ROOT.'libs/inflector.php';
DEBUG? error_reporting(E_ALL): error_reporting(0);
if (DEBUG)
@ -82,9 +122,15 @@ if (DEBUG)
$TIME_START = getMicrotime();
uses('folder', 'dispatcher', 'dbo_factory');
uses('folder');
require_once CAKE.'dispatcher.php';
require_once LIBS.'model'.DS.'dbo'.DS.'dbo_factory.php';
session_start();
if(!defined('AUTO_SESSION') || AUTO_SESSION == true)
{
// Starts the session unless AUTO_SESSION is explicitly set to false in config/core
session_start();
}
config('database');
@ -93,14 +139,16 @@ if (class_exists('DATABASE_CONFIG'))
loadModels();
}
//RUN THE SCRIPT
if(isset($_GET['url']) && $_GET['url'] === 'favicon.ico')
{
}else{
$DISPATCHER = new Dispatcher ();
$DISPATCHER->dispatch($url);
$Dispatcher= new Dispatcher ();
$Dispatcher->dispatch($url);
}
//CLEANUP
if (DEBUG) {
echo "<!-- ". round(getMicrotime() - $TIME_START, 2) ."s -->";
}

View file

@ -51,11 +51,18 @@ define('YEAR', 365 * DAY);
*/
function loadModels ()
{
require (APP.'app_model.php');
foreach (listClasses(MODELS) as $model_fn)
{
require_once (MODELS.$model_fn);
}
if(file_exists(APP.'app_model.php'))
{
require_once(APP.'app_model.php');
}
else
{
require_once(CAKE.'app_model.php');
}
foreach (listClasses(MODELS) as $model_fn)
{
require_once (MODELS.$model_fn);
}
}
/**
@ -67,18 +74,20 @@ function loadModels ()
* @uses CONTROLLERS
*/
function loadControllers ()
{
require (APP.'app_controller.php');
foreach (listClasses(HELPERS) as $helper)
{
require_once (HELPERS.$helper.'.php');
}
foreach (listClasses(CONTROLLERS) as $controller)
{
require_once (CONTROLLERS.$controller.'.php');
}
{
if(file_exists(APP.'app_controller.php'))
{
require_once(APP.'app_controller.php');
}
else
{
require_once(CAKE.'app_controller.php');
}
foreach (listClasses(CONTROLLERS) as $controller)
{
require_once (CONTROLLERS.$controller.'.php');
}
}
/**
@ -89,15 +98,29 @@ function loadControllers ()
*/
function loadController ($name)
{
$controller_fn = CONTROLLERS.Inflector::underscore($name).'_controller.php';
$helper_fn = HELPERS.Inflector::underscore($name).'_helper.php';
require_once(APP.'app_controller.php');
if (file_exists($helper_fn))
require_once($helper_fn);
return file_exists($controller_fn)? require_once($controller_fn): false;
if(file_exists(CONTROLLERS.Inflector::underscore($name).'_controller.php'))
{
$controller_fn = CONTROLLERS.Inflector::underscore($name).'_controller.php';
}
elseif(file_exists(LIBS.'controller'.DS.Inflector::underscore($name).'_controller.php'))
{
$controller_fn = LIBS.'controller'.DS.Inflector::underscore($name).'_controller.php';
}
else
{
$controller_fn = false;
}
if(file_exists(APP.'app_controller.php'))
{
require_once(APP.'app_controller.php');
}
else
{
require_once(CAKE.'app_controller.php');
}
return file_exists($controller_fn)? require_once($controller_fn): false;
}
/**
@ -335,4 +358,23 @@ function params($p)
}
function setUri() {
if (isset($_SERVER['REQUEST_URI']))
{
$uri = $_SERVER['REQUEST_URI'];
}
else
{
if (isset($_SERVER['argv']))
{
$uri = $_SERVER['PHP_SELF'] .'/'. $_SERVER['argv'][0];
}
else
{
$uri = $_SERVER['PHP_SELF'] .'/'. $_SERVER['QUERY_STRING'];
}
}
return $uri;
}
?>

View file

@ -35,7 +35,7 @@
/**
* Add Description
*/
uses('error_messages', 'object', 'router', 'controller', 'scaffold');
uses('error_messages', 'object', 'router', '/controller/controller', '/controller/scaffold');
/**
* Short description for class.
@ -85,7 +85,6 @@ class Dispatcher extends Object
$params['render'] = 0;
}
if (empty($params['controller']))
{
$missingController = true;
@ -103,15 +102,16 @@ class Dispatcher extends Object
if ($missingController)
{
$ctrlClass = 'AppController';
$controller = new $ctrlClass($this);
$controller =& new AppController();
$params['action'] = 'missingController';
$params['controller'] = Inflector::camelize($params['controller']."Controller");
$controller->missingController = $params['controller'];
$controller->webroot = $this->webroot;
return $this->_invoke($controller, $params );
}
else
{
$controller = new $ctrlClass($this);
$controller =& new $ctrlClass($this);
}
$classMethods = get_class_methods($controller);
@ -129,6 +129,7 @@ class Dispatcher extends Object
$controller->base = $this->base;
$controller->here = $this->base.'/'.$url;
$controller->webroot = $this->webroot;
$controller->params = $params;
$controller->action = $params['action'];
$controller->data = empty($params['data'])? null: $params['data'];
@ -235,21 +236,76 @@ class Dispatcher extends Object
*/
function baseUrl()
{
if (defined('BASE_URL'))
{
return BASE_URL;
}
$base = null;
if (defined('BASE_URL'))
{
$base = BASE_URL;
}
$docRoot = $_SERVER['DOCUMENT_ROOT'];
$scriptName = $_SERVER['PHP_SELF'];
// if document root ends with 'public', it's probably correctly set
// if document root ends with 'webroot', it's probably correctly set
$r = null;
if (ereg('/^.*/public(\/)?$/', $docRoot))
return preg_match('/^(.*)\/index\.php$/', $scriptName, $r)? $r[1]: false;
if (preg_match('/\\/'.APP_DIR.'\/'.WEBROOT_DIR.'(\/)?$/i', $docRoot))
{
$this->webroot = DS;
//return preg_match('/\\/index.php(\/)?$/i', $scriptName, $r)? $base.$r[1]: $base;
if (preg_match('/\\/index.php(\/)?$/i', $scriptName, $r))
{
if(!empty($r[1]))
{
return $base.$r[1];
}
else
{
return $base;
}
}
else
{
return $base;
}
}
else
// document root is probably not set to Cake 'public' dir
return preg_match('/^(.*)\/public\/index\.php$/', $scriptName, $r)? $r[1]: false;
{
if(empty($base)){
$isDir = explode('/', setUri());
$first = $isDir[1];
$webPath[] = DS.$first.DS;
foreach ($isDir as $dirName)
{
if(!empty($dirName) && is_dir($docRoot.$first.DS.$dirName))
{
$webPath[] = $dirName.DS;
}
}
$webroot = implode('', $webPath);
$base = substr($webroot, 0, -1);
}
else
{
$webroot =setUri();
}
$this->webroot = preg_replace('/(?:'.APP_DIR.'(.*)|index\\.php(.*))/i', '', $webroot).APP_DIR.DS.WEBROOT_DIR.DS;
// document root is probably not set to Cake 'webroot' dir
if (preg_match('/\\/index.php(\/)?$/i', $scriptName, $r))
{
if(!empty($r[1]))
{
return $base.$r[1];
}
else
{
return $base;
}
}
else
{
return $base;
}
}
}

View file

@ -32,8 +32,7 @@
/**
* Include files
*/
uses('model', 'inflector', 'folder', 'view', 'helper');
uses('/model/model', 'inflector', 'folder', '/view/view', '/view/helper');
/**
* Controller
@ -374,6 +373,7 @@ class Controller extends Object
*/
function missingController()
{
$this->autoLayout = true;
$this->pageTitle = 'Missing Controller';
$this->render('../errors/missingController');
}
@ -384,6 +384,7 @@ class Controller extends Object
*/
function missingAction()
{
$this->autoLayout = true;
$this->pageTitle = 'Missing Method in Controller';
$this->render('../errors/missingAction');
}
@ -394,6 +395,7 @@ class Controller extends Object
*/
function missingDatabase()
{
$this->autoLayout = true;
$this->pageTitle = 'Scaffold Missing Database Connection';
//We are simulating action call below, this is not a filename!
$this->render('../errors/missingScaffolddb');
@ -405,18 +407,47 @@ class Controller extends Object
*/
function missingTable($tableName)
{
$this->autoLayout = true;
$this->missingTableName = $tableName;
$this->pageTitle = 'Missing Database Table';
//We are simulating action call below, this is not a filename!
$this->render('../errors/missingTable');
}
/**
* Renders the Missing Helper file web page.
*
*/
function missingHelperFile($file)
{
$this->missingHelperFile = $file;
$this->missingHelperClass = Inflector::camelize($file) . "Helper";
$this->pageTitle = 'Missing Helper File';
//We are simulating action call below, this is not a filename!
$this->render('../errors/missingHelperFile');
}
/**
* Renders the Missing Helper class web page.
*
*/
function missingHelperClass($class)
{
$this->missingHelperClass = Inflector::camelize($class) . "Helper";
$this->missingHelperFile = Inflector::underscore($class);
$this->pageTitle = 'Missing Helper Class';
//We are simulating action call below, this is not a filename!
$this->render('../errors/missingHelperClass');
}
/**
* Renders the Missing Table web page.
*
*/
function missingConnection()
{
$this->autoLayout = true;
$this->pageTitle = 'Missing Database Connection';
//We are simulating action call below, this is not a filename!
$this->render('../errors/missingDatabase');
@ -480,7 +511,18 @@ class Controller extends Object
$this->set('pause', $pause);
$this->set('page_title', $message);
$this->render(null,false,VIEWS.'layouts'.DS.'flash.thtml');
if(file_exists(VIEWS.'layouts'.DS.'flash.thtml'))
{
$flash = VIEWS.'layouts'.DS.'flash.thtml';
}
else if(file_exists(LIBS.'view'.DS.'templates'.DS."layouts".DS.'flash.thtml'))
{
$flash = LIBS.'view'.DS.'templates'.DS."layouts".DS.'flash.thtml';
}
$this->render(null,false,$flash);
}
/**

View file

@ -45,7 +45,7 @@
* @package cake
* @subpackage cake.app.controllers
*/
class PagesController extends PagesHelper{
class PagesController extends AppController{
/**
* Enter description here...
@ -72,7 +72,6 @@ class PagesController extends PagesHelper{
{
$this->redirect('/');
}
$this->set('page', $path[0]);
$this->set('subpage', empty($path[1])? null: $path[1]);
$this->set('title', ucfirst($path[count($path)-1]));

View file

@ -34,7 +34,7 @@
/**
* Enter description here...
*/
uses('model', 'template', 'inflector', 'object');
uses('/model/model', 'inflector', 'object');
/**
* Scaffolding is a set of automatic views, forms and controllers for starting web development work faster.
@ -145,7 +145,7 @@ class Scaffold extends Object {
$this->controllerClass->params['data'] = $this->controllerClass->models[$this->modelKey]->read();
$this->controllerClass->set('data', $this->controllerClass->params['data'] );
$this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames( $this->controllerClass->params['data'], false ) );
$this->controllerClass->render($this->actionView, '', LIBS.'controllers'.DS.'templates'.DS.'scaffolds'.DS.'show.thtml');
$this->controllerClass->render($this->actionView, '', LIBS.'controller'.DS.'templates'.DS.'scaffolds'.DS.'show.thtml');
}
/**
@ -157,7 +157,7 @@ class Scaffold extends Object {
{
$this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames(null,false) );
$this->controllerClass->set('data', $this->controllerClass->models[$this->modelKey]->findAll());
$this->controllerClass->render($this->actionView, '', LIBS.'controllers'.DS.'templates'.DS.'scaffolds'.DS.'list.thtml');
$this->controllerClass->render($this->actionView, '', LIBS.'controller'.DS.'templates'.DS.'scaffolds'.DS.'list.thtml');
}
/**
@ -168,7 +168,7 @@ class Scaffold extends Object {
function _scaffoldNew($params)
{
$this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames() );
$this->controllerClass->render($this->actionView, '', LIBS.'controllers'.DS.'templates'.DS.'scaffolds'.DS.'new.thtml');
$this->controllerClass->render($this->actionView, '', LIBS.'controller'.DS.'templates'.DS.'scaffolds'.DS.'new.thtml');
}
/**
@ -182,7 +182,7 @@ class Scaffold extends Object {
// generate the field names.
$this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames($this->controllerClass->params['data']) );
$this->controllerClass->set('data', $this->controllerClass->params['data']);
$this->controllerClass->render($this->actionView, '', LIBS.'controllers'.DS.'templates'.DS.'scaffolds'.DS.'edit.thtml');
$this->controllerClass->render($this->actionView, '', LIBS.'controller'.DS.'templates'.DS.'scaffolds'.DS.'edit.thtml');
}
@ -204,7 +204,7 @@ class Scaffold extends Object {
{
$this->controllerClass->set('data', $this->controllerClass->params['data']);
$this->controllerClass->validateErrors($this->controllerClass->models[$this->modelKey]);
$this->controllerClass->render($this->actionView, '', LIBS.'controllers'.DS.'templates'.DS.'scaffolds'.DS.'new.thtml');
$this->controllerClass->render($this->actionView, '', LIBS.'controller'.DS.'templates'.DS.'scaffolds'.DS.'new.thtml');
}
}
@ -263,6 +263,11 @@ class Scaffold extends Object {
*/
function _scaffoldView ($params)
{
if(!in_array('form', $this->controllerClass->helpers))
{
$this->controllerClass->helpers[] = 'form';
}
$isDataBaseSet = DboFactory::getInstance($this->controllerClass->useDbConfig);
if(!empty($isDataBaseSet))
{

View file

@ -1,13 +1,10 @@
<?php
uses('helpers/form');
$form = new FormHelper();
echo $html->formTag('/'.Inflector::underscore($this->name).'/update');
echo $form->generateFields( $html, $fieldNames );
echo $form->generateFields( $fieldNames );
echo $form->generateSubmitDiv( $html, 'Save' )
echo $form->generateSubmitDiv( 'Save' )
?>
<ul class='actions'>

View file

@ -0,0 +1,7 @@
<?php
echo $html->formTag('/'.Inflector::underscore($this->name).'/create');
echo $form->generateFields( $fieldNames );
echo $form->generateSubmitDiv( 'Add' )
?>

View file

@ -0,0 +1,15 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title><?php echo $title_for_layout; ?></title>
<?php echo $html->charsetTag('UTF-8'); ?>
<?php echo $html->cssTag('cake.scaffold'); ?>
<?php echo $html->cssTag('cake.forms'); ?>
</head>
<body>
<div id="container">
<h1><?php echo $title_for_layout; ?></h1>
<?php echo $content_for_layout; ?>
</div>
</body>
</html>

View file

@ -94,7 +94,7 @@ define ('ERROR_NO_FIELD_IN_MODEL_DB', '[Model::set()] Field "%s" is not present
/**
* 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">%s</div>');
/**
* Error string for when original image can not be loaded.

348
cake/libs/file.php Normal file
View file

@ -0,0 +1,348 @@
<?php
/* SVN FILE: $Id$ */
/**
* Convenience class for reading, writing and appending to files.
*
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
* Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @author CakePHP Authors/Developers
* @copyright Copyright (c) 2005, CakePHP Authors/Developers
* @link https://trac.cakephp.org/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.libs
* @since CakePHP v 0.2.9
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Enter description here...
*
*/
uses('object');
/**
* Convenience class for reading, writing and appending to files.
*
*
* @package cake
* @subpackage cake.libs
* @since CakePHP v 0.2.9
*/
class File extends Object
{
/**
* Folder of the File
*
* @var Folder
*/
var $folder = null;
/**
* Filename
*
* @var string
*/
var $name = null;
/**
* Constructor
*
* @param string $path
* @param boolean $create Create file if it does not exist
* @return File
*/
function File ($path , $create = false )
{
$this->folder = new Folder( dirname( realpath($path) ) , $create );
$this->name = basename( realpath($path) );
if ( !$this->exists() )
{
if ( $create === true )
{
if ( !$this->create() )
{
return false;
}
}
else
{
return false;
}
}
}
/**
* Return the contents of this File as a string.
*
* @return string Contents
*/
function read ()
{
return file_get_contents( $this->getFullPath() );
}
/**
* Append given data string to this File.
*
* @param string $data Data to write
* @return boolean Success
*/
function append ($data)
{
return $this->write($data, 'a');
}
/**
* Write given data to this File.
*
* @param string $data Data to write to this File.
* @param string $mode Mode of writing. {@link http://php.net/fwrite See fwrite()}.
* @return boolean Success
*/
function write ($data, $mode = 'w')
{
$file = $this->getFullPath();
if (!($handle = fopen( $file , $mode)))
{
print ("[File] Could not open $file with mode $mode!");
return false;
}
if (!fwrite($handle, $data))
return false;
if (!fclose($handle))
return false;
return true;
}
/**
* Get md5 Checksum of file with previous check of Filesize
*
* @param string $force Data to write to this File.
* @return string md5 Checksum {@link http://php.net/md5_file See md5_file()}
*/
function getMd5 ($force = false)
{
$md5 = '';
if ( $force == true || $this->getSize(false) < MAX_MD5SIZE )
{
$md5 = md5_file( $this->getFullPath() );
}
return $md5;
}
/**
* Get the Filesize
*
* @param boolean $humanReadeble Data to write to this File.
* @return string|int filesize as int or as humand readable string
*/
function getSize ()
{
$size = filesize( $this->getFullPath() );
return $size;
}
/**
* Get the Fileextension
*
* @return string The Fileextension
*/
function getExt ()
{
$ext = '';
$parts = explode('.', $this->getName() );
if ( count($parts) > 1 )
{
$ext = array_pop( $parts );
}
else
{
$ext = '';
}
return $ext;
}
/**
* Get the Filename
*
* @return string The Filename
*/
function getName ()
{
return $this->name;
}
/**
* get the File owner
*
* @return int the Fileowner
*/
function getOwner ()
{
return fileowner( $this->getFullPath() );
}
/**
* get the File owner
*
* @return int the Filegroup
*/
function getGroup ()
{
return filegroup( $this->getFullPath() );
}
/**
* creates the File
*
* @return boolean
*/
function create ()
{
$dir = $this->folder->pwd();
if ( file_exists( $dir ) && is_dir($dir) && is_writable($dir) && !$this->exists() )
{
if ( !touch( $this->getFullPath() ) )
{
print ("[File] Could not create $this->getName()!");
return false;
}
else
{
return true;
}
}
else
{
print ("[File] Could not create $this->getName()!");
return false;
}
}
/**
* deletes the File
*
* @return boolean
*/
function exists ()
{
return file_exists( $this->getFullPath() );
}
/**
* deletes the File
*
* @return boolean
*/
function delete ()
{
return unlink( $this->getFullPath() );
}
/**
* check if the File writable
*
* @return boolean
*/
function writable ()
{
return is_writable( $this->getFullPath() );
}
/**
* check if the File executable
*
* @return boolean
*/
function executable ()
{
return is_executable( $this->getFullPath() );
}
/**
* check if the File readable
*
* @return boolean
*/
function readable ()
{
return is_readable( $this->getFullPath() );
}
/**
* get last access time
*
* @return int timestamp
*/
function lastAccess ()
{
return fileatime( $this->getFullPath() );
}
/**
* get last access time
*
* @return int timestamp
*/
function lastChange ()
{
return filemtime( $this->getFullPath() );
}
/**
* get the current folder
*
* @return Folder
*/
function getFolder ()
{
return $this->folder;
}
/**
* get the chmod of the File
*
* @return string
*/
function getChmod ( )
{
return substr(sprintf('%o', fileperms($this->getFullPath())), -4);
}
/**
* get the chmod of the File
*
* @return string
*/
function getFullPath ( )
{
return Folder::slashTerm($this->folder->pwd()).$this->getName();
}
}
?>

View file

@ -46,7 +46,7 @@ uses('object');
* @since CakePHP v 0.2.9
*/
class Folder extends Object {
/**
* Enter description here...
*
@ -65,22 +65,28 @@ class Folder extends Object {
* Constructor.
*
* @param string $path
* @param bollean $path
*/
function __construct ($path=false)
function Folder ($path=false , $create = false)
{
if (empty($path))
{
$path = getcwd();
}
$this->cd($path);
}
if (empty($path))
{
$path = getcwd();
}
if ( !file_exists( $path ) && $create==true )
{
$this->mkdirr($path);
}
$this->cd($path);
}
/**
* Return current path.
*
* @return string Current path
*/
function pwd ()
function pwd ()
{
return $this->path;
}
@ -91,12 +97,12 @@ class Folder extends Object {
* @param string $desired_path Path to the directory to change to
* @return string The new path. Returns false on failure
*/
function cd ($desired_path)
function cd ($desired_path)
{
$desired_path = realpath($desired_path);
$new_path = Folder::isAbsolute($desired_path)?
$desired_path:
Folder::addPathElement($this->path, $desired_path);
$new_path = Folder::isAbsolute($desired_path)?
$desired_path:
Folder::addPathElement($this->path, $desired_path);
return is_dir($new_path)? $this->path = $new_path: false;
}
@ -107,41 +113,42 @@ class Folder extends Object {
* The returned array holds two arrays: one of dirs and one of files.
*
* @param boolean $sort
* @param boolean $noDotFiles
* @return array
*/
function ls($sort=true)
function ls($sort=true , $noDotFiles = false)
{
$dir = opendir($this->path);
if ($dir)
if ($dir)
{
$dirs = $files = array();
while (false !== ($n = readdir($dir)))
while (false !== ($n = readdir($dir)))
{
if (!preg_match('#^\.+$#', $n))
if ( (!preg_match('#^\.+$#', $n) && $noDotFiles == false) || ( $noDotFiles == true && !preg_match('#^\.(.*)$#', $n) ) )
{
if (is_dir($this->addPathElement($this->path, $n)))
{
$dirs[] = $n;
}
else
{
{
$files[] = $n;
}
}
}
if ($sort || $this->sort)
if ($sort || $this->sort)
{
sort($dirs);
sort($files);
}
closedir($dir);
return array($dirs,$files);
}
else
else
{
return false;
}
@ -154,21 +161,21 @@ class Folder extends Object {
* @param string $pattern Preg_match pattern (Defaults to: .*)
* @return array
*/
function find ($regexp_pattern='.*')
function find ($regexp_pattern='.*')
{
$data = $this->ls();
if (!is_array($data))
{
return array();
}
list($dirs, $files) = $data;
$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;
}
@ -184,7 +191,7 @@ class Folder extends Object {
* @param string $pattern Preg_match pattern (Defaults to: .*)
* @return array Files matching $pattern
*/
function findRecursive ($pattern='.*')
function findRecursive ($pattern='.*')
{
$starts_on = $this->path;
$out = $this->_findRecursive($pattern);
@ -199,21 +206,21 @@ class Folder extends Object {
* @return array Files matching pattern
* @access private
*/
function _findRecursive ($pattern)
function _findRecursive ($pattern)
{
list($dirs, $files) = $this->ls();
$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);
}
}
$start = $this->path;
foreach ($dirs as $dir)
foreach ($dirs as $dir)
{
$this->cd($this->addPathElement($start, $dir));
$found = array_merge($found, $this->findRecursive($pattern));
@ -227,8 +234,9 @@ class Folder extends Object {
*
* @param string $path Path to check
* @return boolean
* @static
*/
function isWindowsPath ($path)
function isWindowsPath ($path)
{
return preg_match('#^[A-Z]:\\\#i', $path)? true: false;
}
@ -238,8 +246,9 @@ class Folder extends Object {
*
* @param string $path Path to check
* @return boolean
* @static
*/
function isAbsolute ($path)
function isAbsolute ($path)
{
return preg_match('#^\/#', $path) || preg_match('#^[A-Z]:\\\#i', $path);
}
@ -249,8 +258,9 @@ class Folder extends Object {
*
* @param string $path Path to check
* @return boolean
* @static
*/
function isSlashTerm ($path)
function isSlashTerm ($path)
{
return preg_match('#[\\\/]$#', $path)? true: false;
}
@ -260,8 +270,9 @@ class Folder extends Object {
*
* @param string $path Path to check
* @return string Set of slashes ("\\" or "/")
* @static
*/
function correctSlashFor ($path)
function correctSlashFor ($path)
{
return Folder::isWindowsPath($path)? '\\': '/';
}
@ -271,8 +282,9 @@ class Folder extends Object {
*
* @param string $path Path to check
* @return string
* @static
*/
function slashTerm ($path)
function slashTerm ($path)
{
return $path . (Folder::isSlashTerm($path)? null: Folder::correctSlashFor($path));
}
@ -283,11 +295,145 @@ class Folder extends Object {
* @param string $path
* @param string $element
* @return string
* @static
*/
function addPathElement ($path, $element)
function addPathElement ($path, $element)
{
return Folder::slashTerm($path).$element;
}
/**
* check if the File is in a given CakePath
*
* @return boolean
*/
function inCakePath ( $path = '' )
{
$dir = substr( Folder::slashTerm(ROOT) , 0 , -1 );
$newdir = Folder::slashTerm($dir.$path);
return $this->inPath( $newdir );
}
/**
* check if the File is in a given Path
*
* @return boolean
*/
function inPath ( $path = '' )
{
$dir = substr( Folder::slashTerm($path) , 0 , -1 );
$return = preg_match('/^'.preg_quote(Folder::slashTerm($dir),'/').'(.*)/' , Folder::slashTerm($this->pwd()) );
if ( $return == 1 )
{
return true;
}
else
{
return false;
}
}
/**
* Create a directory structure recursively
*
* @author Aidan Lister <aidan@php.net>
* @version 1.0.0
* @param string $pathname The directory structure to create
* @return bool Returns TRUE on success, FALSE on failure
*/
function mkdirr($pathname, $mode = null)
{
// Check if directory already exists
if (is_dir($pathname) || empty($pathname))
{
return true;
}
// Ensure a file does not already exist with the same name
if (is_file($pathname))
{
trigger_error('mkdirr() File exists', E_USER_WARNING);
return false;
}
// Crawl up the directory tree
$next_pathname = substr($pathname, 0, strrpos($pathname, DIRECTORY_SEPARATOR));
if (mkdirr($next_pathname, $mode))
{
if (!file_exists($pathname))
{
return mkdir($pathname, $mode);
}
}
return false;
}
/**
* Get the size of a directory.
*
* @author Aidan Lister <aidan@php.net>
* @version 1.0.0
* @param string $directory Path to directory
*/
function dirsize()
{
// Init
$size = 0;
$directory = Folder::slashTerm($this->path);
// Creating the stack array
$stack = array($directory);
// Iterate stack
for ($i = 0, $j = count($stack); $i < $j; ++$i)
{
// Add to total size
if (is_file($stack[$i]))
{
$size += filesize($stack[$i]);
}
// Add to stack
elseif (is_dir($stack[$i]))
{
// Read directory
$dir = dir($stack[$i]);
while (false !== ($entry = $dir->read()))
{
// No pointers
if ($entry == '.' || $entry == '..')
{
continue;
}
// Add to stack
$add = $stack[$i] . $entry;
if (is_dir($stack[$i] . $entry))
{
$add = Folder::slashTerm($add);
}
$stack[] = $add;
}
// Clean up
$dir->close();
}
// Recount stack
$j = count($stack);
}
return $size;
}
}
?>

Some files were not shown because too many files have changed in this diff Show more