mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
- Two standard controllers -- PageController and TestsController
- Helpers for controllers -- each controller has it's own helper in the /app/helpers directory - /logs and /modules directories - The application runs just fine without /config/database.php if controllers don't ask for db access - Changed the name of /public/dispatch.php to /public/index.php, it's nicer and more standard, won't you agree? Kamil's fix for no-mod_rewrite needs to be re-implemented - Cleanups, fixes, and even one or two comments ;) git-svn-id: https://svn.cakephp.org/repo/trunk/cake@158 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
3dd8d77b09
commit
4a87a75332
47 changed files with 5096 additions and 4748 deletions
|
@ -42,4 +42,4 @@
|
||||||
class AppController extends Controller {
|
class AppController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -42,4 +42,4 @@
|
||||||
class AppModel extends Model {
|
class AppModel extends Model {
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
22
app/controllers/pages_controller.php
Normal file
22
app/controllers/pages_controller.php
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?PHP
|
||||||
|
|
||||||
|
class PagesController extends PagesHelper {
|
||||||
|
|
||||||
|
function view () {
|
||||||
|
|
||||||
|
if (!func_num_args())
|
||||||
|
$this->redirect('/');
|
||||||
|
|
||||||
|
$path = func_get_args();
|
||||||
|
if (!count($path))
|
||||||
|
$this->redirect('/');
|
||||||
|
|
||||||
|
$this->set('page', $path[0]);
|
||||||
|
$this->set('subpage', empty($path[1])? null: $path[1]);
|
||||||
|
$this->set('title', ucfirst($path[count($path)-1]));
|
||||||
|
$this->render(join('/', $path));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
43
app/controllers/tests_controller.php
Normal file
43
app/controllers/tests_controller.php
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
<?PHP
|
||||||
|
|
||||||
|
uses('test', 'folder', 'inflector');
|
||||||
|
|
||||||
|
class TestsController extends TestsHelper {
|
||||||
|
|
||||||
|
function test_all () {
|
||||||
|
|
||||||
|
$this->layout = 'test';
|
||||||
|
|
||||||
|
$tests_folder = new Folder('../tests');
|
||||||
|
|
||||||
|
$results = array();
|
||||||
|
$total_errors = 0;
|
||||||
|
foreach ($tests_folder->findRecursive('.*\.php') as $test) {
|
||||||
|
if (preg_match('/^(.+)\.php/i', basename($test), $r)) {
|
||||||
|
require_once($test);
|
||||||
|
$test_name = Inflector::Camelize($r[1]);
|
||||||
|
if (preg_match('/^(.+)Test$/i', $test_name, $r)) {
|
||||||
|
$module_name = $r[1];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$module_name = $test_name;
|
||||||
|
}
|
||||||
|
$suite = new TestSuite($test_name);
|
||||||
|
$result = TestRunner::run($suite);
|
||||||
|
|
||||||
|
$total_errors += $result['errors'];
|
||||||
|
|
||||||
|
$results[] = array(
|
||||||
|
'name'=>$module_name,
|
||||||
|
'result'=>$result,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->set('success', !$total_errors);
|
||||||
|
$this->set('results', $results);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -8,6 +8,8 @@
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
<h1><?=$title_for_layout?></h1>
|
||||||
|
|
||||||
<?=$content_for_layout?>
|
<?=$content_for_layout?>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
91
app/views/layouts/test.thtml
Normal file
91
app/views/layouts/test.thtml
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
<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>
|
27
app/views/pages/home.thtml
Normal file
27
app/views/pages/home.thtml
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<h2>Cake works!</h2>
|
||||||
|
|
||||||
|
<p>Your installation of Cake is functional. Edit <code>/app/views/pages/home.thtml</code> to change the contents of this page.</p>
|
||||||
|
|
||||||
|
<h2>Introducing Cake</h2>
|
||||||
|
|
||||||
|
<p>Cake is a structure of libraries, classes and run-time infrastructure for PHP programmers. It's also what I use at work. It's based on certain conventions, so you may find it rigid at first. The directory structure is already layed out, and it's different from what most people use. From what I've experienced, great many PHP programmers start as web- or graphic-designers, i.e. they are not university-educated programmers as many in the C++ and Java-land. They invent their own, peculiar ways of solving problems and stick to them. Perhaps that's why so few people use Pear and Pecl libraries – they don't usually re-use their code. And I was one of them. (<?=$this->linkOut('continued...','http://sputnik.pl/docs/intro')?>)</p>
|
||||||
|
|
||||||
|
<h2>Features</h2>
|
||||||
|
|
||||||
|
<p><ul>
|
||||||
|
<li>compatibile with PHP4 and PHP5</li>
|
||||||
|
<li>supplies integrated <acronym title="Create, Read, Update, Delete">CRUD</acronym> for database and simplified querying so you shouldn't need to write SQL for basic operations (although <em>some</em> familiarity with SQL is strongly recommended)</li>
|
||||||
|
<li>request dispatcher with good looking, custom URLs</li>
|
||||||
|
<li>fast, flexible templating (PHP syntax with helper methods)</li>
|
||||||
|
<li>works from a website subdirectory, with very little Apache configuration involved (requires <code>.htaccess</code> files and <code>mod_rewrite</code> to work; these are available on most web servers)</li>
|
||||||
|
</ul></p>
|
||||||
|
|
||||||
|
<p>Cake is in it's early infancy, but it works and I'm using it on a few projects. Currently the Dispatcher is working, the Model has <acronym title="Create, Read, Update, Delete">CRUD</acronym> functionality but with no joins between tables yet. The Controller is working and has the most basic functions (including <code>render()</code> for templating).</p>
|
||||||
|
|
||||||
|
<h2>Getting involved</h2>
|
||||||
|
|
||||||
|
<p><b>NEW! <?=$this->linkOut('My Amazon Wishlish','http://www.amazon.com/gp/registry/registry.html?id=NODP8QT6LFTO')?></b> for when you'll want to show your appreciation.</p>
|
||||||
|
|
||||||
|
<p><?=$this->linkOut('Cake PHP Google Group','http://groups-beta.google.com/group/cake-php')?> · <?=$this->linkOut('Cake Wiki (temporary)','http://cake.bplusf.net/')?> · <?=$this->linkOut('Cake TRAC (SVN repository, etc.)','https://developers.nextco.com/cake')?><a href=""></a></p>
|
||||||
|
|
||||||
|
<p>See <?=$this->linkOut('Cake website','http://sputnik.pl/cake')?> for more information.</p>
|
29
app/views/tests/test_all.thtml
Normal file
29
app/views/tests/test_all.thtml
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
<?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>
|
|
@ -36,6 +36,6 @@
|
||||||
* - 1: development
|
* - 1: development
|
||||||
* - 2: full debug with sql
|
* - 2: full debug with sql
|
||||||
*/
|
*/
|
||||||
define ('DEBUG', 0);
|
define ('DEBUG', 1);
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -36,60 +36,68 @@
|
||||||
* here
|
* here
|
||||||
*/
|
*/
|
||||||
if( !defined('ROOT') ){
|
if( !defined('ROOT') ){
|
||||||
define ('ROOT', '../');
|
define ('ROOT', '../');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path to the application directory.
|
* Path to the application directory.
|
||||||
*/
|
*/
|
||||||
define ('APP', ROOT.'app'.DS);
|
define ('APP', ROOT.'app'.DS);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path to the application models directory.
|
* Path to the application models directory.
|
||||||
*/
|
*/
|
||||||
define ('MODELS', APP.'models'.DS);
|
define ('MODELS', APP.'models'.DS);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path to the application controllers directory.
|
* Path to the application controllers directory.
|
||||||
*/
|
*/
|
||||||
define ('CONTROLLERS', APP.'controllers'.DS);
|
define ('CONTROLLERS', APP.'controllers'.DS);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path to the application helpers directory.
|
* Path to the application helpers directory.
|
||||||
*/
|
*/
|
||||||
define ('HELPERS', APP.'helpers'.DS);
|
define ('HELPERS', APP.'helpers'.DS);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path to the application views directory.
|
* Path to the application views directory.
|
||||||
*/
|
*/
|
||||||
define ('VIEWS', APP.'views'.DS);
|
define ('VIEWS', APP.'views'.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);
|
||||||
define ('LOGS', ROOT.'logs'.DS);
|
|
||||||
define ('MODULES', ROOT.'modules'.DS);
|
/**
|
||||||
|
* Path to the logs directory.
|
||||||
|
*/
|
||||||
|
define ('LOGS', ROOT.'logs'.DS);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Path to the modules directory.
|
||||||
|
*/
|
||||||
|
define ('MODULES', ROOT.'modules'.DS);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path to the public directory.
|
* Path to the public directory.
|
||||||
*/
|
*/
|
||||||
define ('PUBLIC', ROOT.'public'.DS);
|
define ('PUBLIC', ROOT.'public'.DS);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path to the tests directory.
|
* Path to the tests directory.
|
||||||
*/
|
*/
|
||||||
define ('TESTS', ROOT.'tests'.DS);
|
define ('TESTS', ROOT.'tests'.DS);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path to the vendors directory.
|
* Path to the vendors directory.
|
||||||
*/
|
*/
|
||||||
define ('VENDORS', ROOT.'vendors'.DS);
|
define ('VENDORS', ROOT.'vendors'.DS);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path to the controller test directory.
|
* Path to the controller test directory.
|
||||||
|
@ -99,16 +107,16 @@ 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);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,47 +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 + //
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In this file, you set up routes to your controllers and their actions.
|
* In this file, you set up routes to your controllers and their actions.
|
||||||
* Routes are very important mechanism that allows you to freely connect
|
* Routes are very important mechanism that allows you to freely connect
|
||||||
* different urls to chosen controllers and their actions (functions).
|
* different urls to chosen controllers and their actions (functions).
|
||||||
*
|
*
|
||||||
* @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.config
|
* @subpackage cake.config
|
||||||
* @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
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Here, we are connecting '/' (base path) to controller called 'Pages', and
|
* Here, we are connecting '/' (base path) to controller called 'Pages', and
|
||||||
* its action called 'index' - note there are no additional params passed.
|
* its action called 'index' - note there are no additional params passed.
|
||||||
*/
|
*/
|
||||||
$Route->connect ('/', array('controller'=>'Pages', 'action'=>'index'));
|
$Route->connect ('/', array('controller'=>'Pages', 'action'=>'view', 'home'));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Here we connect url '/test' to our test controller. This is helpfull in
|
* Here we connect url '/test' to our test controller. This is helpfull in
|
||||||
* developement.
|
* developement.
|
||||||
*/
|
*/
|
||||||
$Route->connect ('/test', array('controller'=>'Tests', 'action'=>'test_all'));
|
$Route->connect ('/test', array('controller'=>'Tests', 'action'=>'test_all'));
|
||||||
|
|
||||||
?>
|
/**
|
||||||
|
* Now we connect the rest of Pages controller's urls
|
||||||
|
* This needs to be the last one, as it takes in any and all remaining urls
|
||||||
|
*/
|
||||||
|
$Route->connect ('/*', array('controller'=>'Pages', 'action'=>'view'));
|
||||||
|
|
||||||
|
?>
|
|
@ -44,4 +44,4 @@ $Route->connect ('/', array('controller'=>'Pages', 'action'=>'index'));
|
||||||
*/
|
*/
|
||||||
$Route->connect ('/test', array('controller'=>'Tests', 'action'=>'test_all'));
|
$Route->connect ('/test', array('controller'=>'Tests', 'action'=>'test_all'));
|
||||||
|
|
||||||
?>
|
?>
|
33
index.php
33
index.php
|
@ -1,4 +1,4 @@
|
||||||
<?php
|
<?PHP
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// + $Id$
|
// + $Id$
|
||||||
// +------------------------------------------------------------------+ //
|
// +------------------------------------------------------------------+ //
|
||||||
|
@ -16,27 +16,32 @@
|
||||||
/**
|
/**
|
||||||
* This file collects requests if no mod_rewrite is avilable and / is used
|
* This file collects requests if no mod_rewrite is avilable and / is used
|
||||||
* instead of /public/ as a web root.
|
* instead of /public/ as a web root.
|
||||||
*
|
*
|
||||||
* @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
|
||||||
* @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
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Get Cake's root directory
|
||||||
*/
|
*/
|
||||||
|
define ('DS', DIRECTORY_SEPARATOR);
|
||||||
|
define ('ROOT', dirname(__FILE__).DS);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We need to redefine some constants and variables, so that Cake knows it is
|
* We need to redefine some constants and variables, so that Cake knows it is
|
||||||
* working without mod_rewrite.
|
* working without mod_rewrite.
|
||||||
*/
|
*/
|
||||||
define ('BASE_URL', $_SERVER['SCRIPT_NAME']);
|
define ('BASE_URL', $_SERVER['SCRIPT_NAME']);
|
||||||
define ('ROOT', dirname($_SERVER['SCRIPT_FILENAME']).'/');
|
|
||||||
|
|
||||||
$_GET['url'] = ltrim($_SERVER['PATH_INFO'],'/');
|
$_GET['url'] = ltrim($_SERVER['PATH_INFO'],'/');
|
||||||
|
|
||||||
require ROOT.'public/dispatch.php';
|
require (ROOT.'public/dispatch.php');
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -149,6 +149,9 @@ class %sTest extends TestCase {
|
||||||
$this->stdout = fopen('php://stdout', 'w');
|
$this->stdout = fopen('php://stdout', 'w');
|
||||||
$this->stderr = fopen('php://stderr', 'w');
|
$this->stderr = fopen('php://stderr', 'w');
|
||||||
|
|
||||||
|
// Output directory name
|
||||||
|
fwrite($this->stderr, "\n".substr(ROOT,0,strlen(ROOT)-1).":\n".str_repeat('-',strlen(ROOT)+1)."\n");
|
||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
|
|
||||||
case 'model':
|
case 'model':
|
||||||
|
@ -201,10 +204,10 @@ class %sTest extends TestCase {
|
||||||
*/
|
*/
|
||||||
function newView ($controller, $name) {
|
function newView ($controller, $name) {
|
||||||
$dir = Inflector::underscore($controller);
|
$dir = Inflector::underscore($controller);
|
||||||
$path = "{$dir}/".strtolower($name).".thtml";
|
$path = $dir.DS.strtolower($name).".thtml";
|
||||||
$this->createDir(VIEWS.$dir);
|
$this->createDir(VIEWS.$dir);
|
||||||
$fn = VIEWS.$path;
|
$fn = VIEWS.$path;
|
||||||
$this->createFile($fn, sprintf($this->template('view'), "<p>Edit <b>app/views/{$path}</b> to change this message.</p>"));
|
$this->createFile($fn, sprintf($this->template('view'), "<p>Edit <b>app".DS."views".DS."{$path}</b> to change this message.</p>"));
|
||||||
$this->actions++;
|
$this->actions++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,11 +455,12 @@ class %sTest extends TestCase {
|
||||||
* @uses Bake::stderr
|
* @uses Bake::stderr
|
||||||
*/
|
*/
|
||||||
function createFile ($path, $contents) {
|
function createFile ($path, $contents) {
|
||||||
|
$shortPath = str_replace(ROOT,null,$path);
|
||||||
|
|
||||||
if (is_file($path) && !$this->dontAsk) {
|
if (is_file($path) && !$this->dontAsk) {
|
||||||
fwrite($this->stdout, "File {$path} exists, overwrite? (yNaq) ");
|
fwrite($this->stdout, "File {$shortPath} exists, overwrite? (yNaq) ");
|
||||||
$key = trim(fgets($this->stdin));
|
$key = trim(fgets($this->stdin));
|
||||||
|
|
||||||
if ($key=='q') {
|
if ($key=='q') {
|
||||||
fwrite($this->stdout, "Quitting.\n");
|
fwrite($this->stdout, "Quitting.\n");
|
||||||
exit;
|
exit;
|
||||||
|
@ -467,7 +471,7 @@ class %sTest extends TestCase {
|
||||||
elseif ($key=='y') {
|
elseif ($key=='y') {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fwrite($this->stdout, "Skip {$path}\n");
|
fwrite($this->stdout, "Skip {$shortPath}\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -475,12 +479,12 @@ class %sTest extends TestCase {
|
||||||
if ($f = fopen($path, 'w')) {
|
if ($f = fopen($path, 'w')) {
|
||||||
fwrite($f, $contents);
|
fwrite($f, $contents);
|
||||||
fclose($f);
|
fclose($f);
|
||||||
fwrite($this->stdout, "Wrote {$path}\n");
|
fwrite($this->stdout, "Wrote {$shortPath}\n");
|
||||||
// debug ("Wrote {$path}");
|
// debug ("Wrote {$path}");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fwrite($this->stderr, "Error! Couldn't open {$path} for writing.\n");
|
fwrite($this->stderr, "Error! Couldn't open {$shortPath} for writing.\n");
|
||||||
// debug ("Error! Couldn't open {$path} for writing.");
|
// debug ("Error! Couldn't open {$path} for writing.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -499,13 +503,15 @@ class %sTest extends TestCase {
|
||||||
if (is_dir($path))
|
if (is_dir($path))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
$shortPath = str_replace(ROOT, null, $path);
|
||||||
|
|
||||||
if (mkdir($path)) {
|
if (mkdir($path)) {
|
||||||
fwrite($this->stdout, "Created {$path}\n");
|
fwrite($this->stdout, "Created {$shortPath}\n");
|
||||||
// debug ("Created {$path}");
|
// debug ("Created {$path}");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fwrite($this->stderr, "Error! Couldn't create dir {$path}\n");
|
fwrite($this->stderr, "Error! Couldn't create dir {$shortPath}\n");
|
||||||
// debug ("Error! Couldn't create dir {$path}");
|
// debug ("Error! Couldn't create dir {$path}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
558
libs/basics.php
558
libs/basics.php
|
@ -1,276 +1,282 @@
|
||||||
<?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 + //
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic Cake functionalities.
|
* Basic Cake functionalities.
|
||||||
*
|
*
|
||||||
* @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
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads all models.
|
* Loads all models.
|
||||||
*
|
*
|
||||||
* @uses listModules()
|
* @uses listModules()
|
||||||
* @uses APP
|
* @uses APP
|
||||||
* @uses MODELS
|
* @uses MODELS
|
||||||
*/
|
*/
|
||||||
function loadModels () {
|
function loadModels () {
|
||||||
require (APP.'app_model.php');
|
require (APP.'app_model.php');
|
||||||
foreach (listClasses(MODELS) as $model_fn) {
|
foreach (listClasses(MODELS) as $model_fn) {
|
||||||
require (MODELS.$model_fn);
|
require (MODELS.$model_fn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads all controllers.
|
* Loads all controllers.
|
||||||
*
|
*
|
||||||
* @uses APP
|
* @uses APP
|
||||||
* @uses listModules()
|
* @uses listModules()
|
||||||
* @uses HELPERS
|
* @uses HELPERS
|
||||||
* @uses CONTROLLERS
|
* @uses CONTROLLERS
|
||||||
*/
|
*/
|
||||||
function loadControllers () {
|
function loadControllers () {
|
||||||
require (APP.'app_controller.php');
|
require (APP.'app_controller.php');
|
||||||
|
|
||||||
foreach (listClasses(HELPERS) as $helper) {
|
foreach (listClasses(HELPERS) as $helper) {
|
||||||
require (HELPERS.$helper.'.php');
|
require (HELPERS.$helper.'.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (listClasses(CONTROLLERS) as $controller) {
|
foreach (listClasses(CONTROLLERS) as $controller) {
|
||||||
require (CONTROLLERS.$controller.'.php');
|
require (CONTROLLERS.$controller.'.php');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a controller and it's helper libraries
|
* Loads a controller and it's helper libraries
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function loadController ($name) {
|
function loadController ($name) {
|
||||||
$controller_fn = CONTROLLERS.Inflector::underscore($name).'_controller.php';
|
$controller_fn = CONTROLLERS.Inflector::underscore($name).'_controller.php';
|
||||||
$helper_fn = HELPERS.Inflector::underscore($name).'_helper.php';
|
$helper_fn = HELPERS.Inflector::underscore($name).'_helper.php';
|
||||||
|
|
||||||
require(APP.'app_controller.php');
|
require(APP.'app_controller.php');
|
||||||
|
|
||||||
if (file_exists($helper_fn))
|
if (file_exists($helper_fn))
|
||||||
require($helper_fn);
|
require($helper_fn);
|
||||||
|
|
||||||
return file_exists($controller_fn)? require($controller_fn): false;
|
return file_exists($controller_fn)? require($controller_fn): false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists PHP files in a specified directory
|
* Lists PHP files in a specified directory
|
||||||
*
|
*
|
||||||
* @param string $path
|
* @param string $path
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function listClasses($path) {
|
function listClasses($path) {
|
||||||
$modules = new Folder($path);
|
$modules = new Folder($path);
|
||||||
return $modules->find('(.+)\.php');
|
return $modules->find('(.+)\.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads configuration files
|
* Loads configuration files
|
||||||
*/
|
*/
|
||||||
function config () {
|
function config () {
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
foreach ($args as $arg) {
|
foreach ($args as $arg) {
|
||||||
require_once (CONFIGS.$arg.'.php');
|
if (file_exists(CONFIGS.$arg.'.php')) {
|
||||||
}
|
require_once (CONFIGS.$arg.'.php');
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
/**
|
else {
|
||||||
* Loads component/components from LIBS.
|
return false;
|
||||||
*
|
}
|
||||||
* Example:
|
}
|
||||||
* <code>
|
}
|
||||||
* uses('inflector', 'object');
|
|
||||||
* </code>
|
/**
|
||||||
*
|
* Loads component/components from LIBS.
|
||||||
* @uses LIBS
|
*
|
||||||
*/
|
* Example:
|
||||||
function uses () {
|
* <code>
|
||||||
$args = func_get_args();
|
* uses('inflector', 'object');
|
||||||
foreach ($args as $arg) {
|
* </code>
|
||||||
require_once (LIBS.strtolower($arg).'.php');
|
*
|
||||||
}
|
* @uses LIBS
|
||||||
}
|
*/
|
||||||
|
function uses () {
|
||||||
/**
|
$args = func_get_args();
|
||||||
* Setup a debug point.
|
foreach ($args as $arg) {
|
||||||
*
|
require_once (LIBS.strtolower($arg).'.php');
|
||||||
* @param boolean $var
|
}
|
||||||
* @param boolean $show_html
|
}
|
||||||
*/
|
|
||||||
function debug($var = false, $show_html = false) {
|
/**
|
||||||
if (DEBUG) {
|
* Setup a debug point.
|
||||||
print "\n<pre>\n";
|
*
|
||||||
if ($show_html) $var = str_replace('<', '<', str_replace('>', '>', $var));
|
* @param boolean $var
|
||||||
print_r($var);
|
* @param boolean $show_html
|
||||||
print "\n</pre>\n";
|
*/
|
||||||
}
|
function debug($var = false, $show_html = false) {
|
||||||
}
|
if (DEBUG) {
|
||||||
|
print "\n<pre>\n";
|
||||||
|
if ($show_html) $var = str_replace('<', '<', str_replace('>', '>', $var));
|
||||||
if (!function_exists('getMicrotime')) {
|
print_r($var);
|
||||||
|
print "\n</pre>\n";
|
||||||
/**
|
}
|
||||||
* Returns microtime for execution time checking.
|
}
|
||||||
*
|
|
||||||
* @return integer
|
|
||||||
*/
|
if (!function_exists('getMicrotime')) {
|
||||||
function getMicrotime() {
|
|
||||||
list($usec, $sec) = explode(" ", microtime());
|
/**
|
||||||
return ((float)$usec + (float)$sec);
|
* Returns microtime for execution time checking.
|
||||||
}
|
*
|
||||||
}
|
* @return integer
|
||||||
if (!function_exists('sortByKey')) {
|
*/
|
||||||
/**
|
function getMicrotime() {
|
||||||
* Sorts given $array by key $sortby.
|
list($usec, $sec) = explode(" ", microtime());
|
||||||
*
|
return ((float)$usec + (float)$sec);
|
||||||
* @param array $array
|
}
|
||||||
* @param string $sortby
|
}
|
||||||
* @param string $order
|
if (!function_exists('sortByKey')) {
|
||||||
* @param integer $type
|
/**
|
||||||
* @return mixed
|
* Sorts given $array by key $sortby.
|
||||||
*/
|
*
|
||||||
function sortByKey(&$array, $sortby, $order='asc', $type=SORT_NUMERIC) {
|
* @param array $array
|
||||||
|
* @param string $sortby
|
||||||
if( is_array($array) ) {
|
* @param string $order
|
||||||
|
* @param integer $type
|
||||||
foreach( $array AS $key => $val )
|
* @return mixed
|
||||||
$sa[$key] = $val[$sortby];
|
*/
|
||||||
|
function sortByKey(&$array, $sortby, $order='asc', $type=SORT_NUMERIC) {
|
||||||
if( $order == 'asc' )
|
|
||||||
asort($sa, $type);
|
if( is_array($array) ) {
|
||||||
else
|
|
||||||
arsort($sa, $type);
|
foreach( $array AS $key => $val )
|
||||||
|
$sa[$key] = $val[$sortby];
|
||||||
foreach( $sa as $key=>$val )
|
|
||||||
$out[] = $array[$key];
|
if( $order == 'asc' )
|
||||||
|
asort($sa, $type);
|
||||||
return $out;
|
else
|
||||||
|
arsort($sa, $type);
|
||||||
}
|
|
||||||
else
|
foreach( $sa as $key=>$val )
|
||||||
return null;
|
$out[] = $array[$key];
|
||||||
}
|
|
||||||
}
|
return $out;
|
||||||
|
|
||||||
if (!function_exists('array_combine')) {
|
}
|
||||||
/**
|
else
|
||||||
* Combines given identical arrays by using the first array's values as keys,
|
return null;
|
||||||
* and second one's values as values.
|
}
|
||||||
*
|
}
|
||||||
* @param array $a1
|
|
||||||
* @param array $a2
|
if (!function_exists('array_combine')) {
|
||||||
* @return mixed Outputs either combined array or false.
|
/**
|
||||||
*/
|
* Combines given identical arrays by using the first array's values as keys,
|
||||||
function array_combine($a1, $a2) {
|
* and second one's values as values.
|
||||||
$a1 = array_values($a1);
|
*
|
||||||
$a2 = array_values($a2);
|
* @param array $a1
|
||||||
$c1 = count($a1);
|
* @param array $a2
|
||||||
$c2 = count($a2);
|
* @return mixed Outputs either combined array or false.
|
||||||
|
*/
|
||||||
if ($c1 != $c2) return false; // different lenghts
|
function array_combine($a1, $a2) {
|
||||||
if ($c1 <= 0) return false; // arrays are the same and both are empty
|
$a1 = array_values($a1);
|
||||||
|
$a2 = array_values($a2);
|
||||||
$output = array();
|
$c1 = count($a1);
|
||||||
|
$c2 = count($a2);
|
||||||
for ($i = 0; $i < $c1; $i++) {
|
|
||||||
$output[$a1[$i]] = $a2[$i];
|
if ($c1 != $c2) return false; // different lenghts
|
||||||
}
|
if ($c1 <= 0) return false; // arrays are the same and both are empty
|
||||||
|
|
||||||
return $output;
|
$output = array();
|
||||||
}
|
|
||||||
}
|
for ($i = 0; $i < $c1; $i++) {
|
||||||
|
$output[$a1[$i]] = $a2[$i];
|
||||||
/**
|
}
|
||||||
* Class used for internal manipulation of multiarrays (arrays of arrays)
|
|
||||||
*
|
return $output;
|
||||||
* @package cake
|
}
|
||||||
* @subpackage cake.libs
|
}
|
||||||
* @since Cake v 0.2.9
|
|
||||||
*/
|
/**
|
||||||
class NeatArray {
|
* Class used for internal manipulation of multiarrays (arrays of arrays)
|
||||||
/**
|
*
|
||||||
* Value of NeatArray.
|
* @package cake
|
||||||
*
|
* @subpackage cake.libs
|
||||||
* @var array
|
* @since Cake v 0.2.9
|
||||||
* @access public
|
*/
|
||||||
*/
|
class NeatArray {
|
||||||
var $value;
|
/**
|
||||||
|
* Value of NeatArray.
|
||||||
/**
|
*
|
||||||
* Constructor.
|
* @var array
|
||||||
*
|
* @access public
|
||||||
* @param array $value
|
*/
|
||||||
* @access public
|
var $value;
|
||||||
* @uses NeatArray::value
|
|
||||||
*/
|
/**
|
||||||
function NeatArray ($value) {
|
* Constructor.
|
||||||
$this->value = $value;
|
*
|
||||||
}
|
* @param array $value
|
||||||
|
* @access public
|
||||||
/**
|
* @uses NeatArray::value
|
||||||
* Checks wheter $fieldName with $value exists in this NeatArray object.
|
*/
|
||||||
*
|
function NeatArray ($value) {
|
||||||
* @param string $fieldName
|
$this->value = $value;
|
||||||
* @param string $value
|
}
|
||||||
* @return mixed
|
|
||||||
* @access public
|
/**
|
||||||
* @uses NeatArray::value
|
* Checks wheter $fieldName with $value exists in this NeatArray object.
|
||||||
*/
|
*
|
||||||
function findIn ($fieldName, $value) {
|
* @param string $fieldName
|
||||||
$out = false;
|
* @param string $value
|
||||||
foreach ($this->value as $k=>$v) {
|
* @return mixed
|
||||||
if (isset($v[$fieldName]) && ($v[$fieldName] == $value)) {
|
* @access public
|
||||||
$out[$k] = $v;
|
* @uses NeatArray::value
|
||||||
}
|
*/
|
||||||
}
|
function findIn ($fieldName, $value) {
|
||||||
|
$out = false;
|
||||||
return $out;
|
foreach ($this->value as $k=>$v) {
|
||||||
}
|
if (isset($v[$fieldName]) && ($v[$fieldName] == $value)) {
|
||||||
|
$out[$k] = $v;
|
||||||
/**
|
}
|
||||||
* Checks if $this->value is array, and removes all empty elements.
|
}
|
||||||
*
|
|
||||||
* @access public
|
return $out;
|
||||||
* @uses NeatArray::value
|
}
|
||||||
*/
|
|
||||||
function cleanup () {
|
/**
|
||||||
$out = is_array($this->value)? array(): null;
|
* Checks if $this->value is array, and removes all empty elements.
|
||||||
foreach ($this->value as $k=>$v) {
|
*
|
||||||
if ($v) {
|
* @access public
|
||||||
$out[$k] = $v;
|
* @uses NeatArray::value
|
||||||
}
|
*/
|
||||||
}
|
function cleanup () {
|
||||||
$this->value = $out;
|
$out = is_array($this->value)? array(): null;
|
||||||
}
|
foreach ($this->value as $k=>$v) {
|
||||||
}
|
if ($v) {
|
||||||
|
$out[$k] = $v;
|
||||||
?>
|
}
|
||||||
|
}
|
||||||
|
$this->value = $out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
|
@ -39,11 +39,9 @@ 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 {
|
||||||
|
|
||||||
|
|
1169
libs/controller.php
1169
libs/controller.php
File diff suppressed because it is too large
Load diff
819
libs/dbo.php
819
libs/dbo.php
|
@ -1,411 +1,410 @@
|
||||||
<?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: DBO/ADO
|
* Purpose: DBO/ADO
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* A MySQL functions wrapper. Provides ability to get results as arrays
|
* A MySQL functions wrapper. Provides ability to get results as arrays
|
||||||
* and query logging (with execution time).
|
* and query logging (with execution time).
|
||||||
*
|
*
|
||||||
* Example usage:
|
* Example usage:
|
||||||
*
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* require('dbo_mysql.php'); // or 'dbo_postgres.php'
|
* require('dbo_mysql.php'); // or 'dbo_postgres.php'
|
||||||
*
|
*
|
||||||
* // create and connect the object
|
* // create and connect the object
|
||||||
* $db = new DBO_MySQL(array( // or 'DBO_Postgres'
|
* $db = new DBO_MySQL(array( // or 'DBO_Postgres'
|
||||||
* 'host'=>'localhost',
|
* 'host'=>'localhost',
|
||||||
* 'login'=>'username',
|
* 'login'=>'username',
|
||||||
* 'password'=>'password',
|
* 'password'=>'password',
|
||||||
* 'database'=>'database'));
|
* 'database'=>'database'));
|
||||||
*
|
*
|
||||||
* // read the whole query result array (of rows)
|
* // read the whole query result array (of rows)
|
||||||
* $all_rows = $db->all("SELECT a,b,c FROM table");
|
* $all_rows = $db->all("SELECT a,b,c FROM table");
|
||||||
*
|
*
|
||||||
* // read the first row with debugging on
|
* // read the first row with debugging on
|
||||||
* $first_row_only = $db->one("SELECT a,b,c FROM table WHERE a=1", TRUE);
|
* $first_row_only = $db->one("SELECT a,b,c FROM table WHERE a=1", TRUE);
|
||||||
*
|
*
|
||||||
* // emulate the usual way of reading query results
|
* // emulate the usual way of reading query results
|
||||||
* if ($db->query("SELECT a,b,c FROM table")) {
|
* if ($db->query("SELECT a,b,c FROM table")) {
|
||||||
* while ( $row = $db->farr() ) {
|
* while ( $row = $db->farr() ) {
|
||||||
* print $row['a'].$row['b'].$row['c'];
|
* print $row['a'].$row['b'].$row['c'];
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* // show a log of all queries, sorted by execution time
|
* // show a log of all queries, sorted by execution time
|
||||||
* $db->showLog(TRUE);
|
* $db->showLog(TRUE);
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @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');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 DBO extends Object {
|
class DBO extends Object {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var unknown_type
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $connected=FALSE;
|
var $connected=FALSE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var unknown_type
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $debug=FALSE;
|
var $debug=FALSE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var unknown_type
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $fullDebug=FALSE;
|
var $fullDebug=FALSE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var unknown_type
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $error=NULL;
|
var $error=NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var unknown_type
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $affected=NULL;
|
var $affected=NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var unknown_type
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $numRows=NULL;
|
var $numRows=NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var unknown_type
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $took=NULL;
|
var $took=NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var unknown_type
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $_conn=NULL;
|
var $_conn=NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var unknown_type
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $_result=NULL;
|
var $_result=NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var unknown_type
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $_queriesCnt=0;
|
var $_queriesCnt=0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var unknown_type
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $_queriesTime=NULL;
|
var $_queriesTime=NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var unknown_type
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $_queriesLog=array();
|
var $_queriesLog=array();
|
||||||
|
|
||||||
// specific for each database, implemented in db drivers
|
// specific for each database, implemented in db drivers
|
||||||
function connect ($config) { die('Please implement DBO::connect() first.'); }
|
function connect ($config) { die('Please implement DBO::connect() first.'); }
|
||||||
function disconnect () { die('Please implement DBO::disconnect() first.'); }
|
function disconnect () { die('Please implement DBO::disconnect() first.'); }
|
||||||
function execute ($sql) { die('Please implement DBO::execute() first.'); }
|
function execute ($sql) { die('Please implement DBO::execute() first.'); }
|
||||||
function fetchRow ($result) { die('Please implement DBO::fetchRow() first.'); }
|
function fetchRow ($result) { die('Please implement DBO::fetchRow() first.'); }
|
||||||
function tables() { die('Please implement DBO::tables() first.'); }
|
function tables() { die('Please implement DBO::tables() first.'); }
|
||||||
function fields ($table_name) { die('Please implement DBO::fields() first.'); }
|
function fields ($table_name) { die('Please implement DBO::fields() first.'); }
|
||||||
function prepare ($data) { die('Please implement DBO::prepare() first.'); }
|
function prepare ($data) { die('Please implement DBO::prepare() first.'); }
|
||||||
function lastError () { die('Please implement DBO::lastError() first.'); }
|
function lastError () { die('Please implement DBO::lastError() first.'); }
|
||||||
function lastAffected () { die('Please implement DBO::lastAffected() first.'); }
|
function lastAffected () { die('Please implement DBO::lastAffected() first.'); }
|
||||||
function lastNumRows ($result){ die('Please implement DBO::lastNumRows() first.'); }
|
function lastNumRows ($result){ die('Please implement DBO::lastNumRows() first.'); }
|
||||||
function lastInsertId () { die('Please implement DBO::lastInsertId() first.'); }
|
function lastInsertId () { die('Please implement DBO::lastInsertId() first.'); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $config
|
* @param unknown_type $config
|
||||||
* @param unknown_type $DEBUG
|
* @param unknown_type $DEBUG
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function __construct ($config=NULL) {
|
function __construct ($config=NULL) {
|
||||||
$this->debug = DEBUG > 0;
|
$this->debug = DEBUG > 0;
|
||||||
$this->fullDebug = DEBUG > 1;
|
$this->fullDebug = DEBUG > 1;
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
return $this->connect($config);
|
return $this->connect($config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function __destructor () {
|
function __destructor () {
|
||||||
$this->close();
|
$this->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $db_name
|
* @param unknown_type $db_name
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function useDb ($db_name) {
|
function useDb ($db_name) {
|
||||||
return $this->query("USE {$db_name}");
|
return $this->query("USE {$db_name}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function close () {
|
function close () {
|
||||||
if ($this->fullDebug) $this->showLog();
|
if ($this->fullDebug) $this->showLog();
|
||||||
$this->disconnect();
|
$this->disconnect();
|
||||||
$this->_conn = NULL;
|
$this->_conn = NULL;
|
||||||
$this->connected = false;
|
$this->connected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $sql
|
* @param unknown_type $sql
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function rawQuery ($sql) {
|
function rawQuery ($sql) {
|
||||||
$this->took = $this->error = $this->numRows = false;
|
$this->took = $this->error = $this->numRows = false;
|
||||||
return $this->execute($sql);
|
return $this->execute($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $sql
|
* @param unknown_type $sql
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function query($sql) {
|
function query($sql) {
|
||||||
$t = getMicrotime();
|
$t = getMicrotime();
|
||||||
$this->_result = $this->execute($sql);
|
$this->_result = $this->execute($sql);
|
||||||
$this->affected = $this->lastAffected();
|
$this->affected = $this->lastAffected();
|
||||||
$this->took = round((getMicrotime()-$t)*1000, 0);
|
$this->took = round((getMicrotime()-$t)*1000, 0);
|
||||||
$this->error = $this->lastError();
|
$this->error = $this->lastError();
|
||||||
$this->numRows = $this->lastNumRows($this->_result);
|
$this->numRows = $this->lastNumRows($this->_result);
|
||||||
$this->logQuery($sql);
|
$this->logQuery($sql);
|
||||||
if (($this->debug && $this->error) || ($this->fullDebug))
|
if (($this->debug && $this->error) || ($this->fullDebug))
|
||||||
$this->showQuery($sql);
|
$this->showQuery($sql);
|
||||||
|
|
||||||
return $this->error? false: $this->_result;
|
return $this->error? false: $this->_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a single row of results from the _last_ query
|
* Returns a single row of results from the _last_ query
|
||||||
*
|
*
|
||||||
* @param unknown_type $results
|
* @param resource $res
|
||||||
* @param unknown_type $type
|
* @return unknown
|
||||||
* @return unknown
|
*/
|
||||||
*/
|
function farr ($res=false) {
|
||||||
function farr ($res=false) {
|
return $this->fetchRow($res? $res: $this->_result);
|
||||||
return $this->fetchRow($res? $res: $this->_result);
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Returns a single row of results for a _given_ query
|
||||||
* Returns a single row of results for a _given_ query
|
*
|
||||||
*
|
* @param unknown_type $sql
|
||||||
* @param unknown_type $sql
|
* @return unknown
|
||||||
* @return unknown
|
*/
|
||||||
*/
|
function one ($sql) {
|
||||||
function one ($sql) {
|
return $this->query($sql)? $this->farr(): false;
|
||||||
return $this->query($sql)? $this->farr(): false;
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Returns all result rows for a given query
|
||||||
* Returns all result rows for a given query
|
*
|
||||||
*
|
* @param unknown_type $sql
|
||||||
* @param unknown_type $sql
|
* @return unknown
|
||||||
* @return unknown
|
*/
|
||||||
*/
|
function all ($sql) {
|
||||||
function all ($sql) {
|
if($this->query($sql)) {
|
||||||
if($this->query($sql)) {
|
$out=array();
|
||||||
$out=array();
|
while($item = $this->farr()) $out[] = $item;
|
||||||
while($item = $this->farr()) $out[] = $item;
|
return $out;
|
||||||
return $out;
|
}
|
||||||
}
|
else {
|
||||||
else {
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Returns a single field of the first of query results for a given sql query
|
||||||
* Enter description here...
|
*
|
||||||
*
|
* @param unknown_type $name
|
||||||
* @param unknown_type $name
|
* @param unknown_type $sql
|
||||||
* @param unknown_type $sql
|
* @return unknown
|
||||||
* @return unknown
|
*/
|
||||||
*/
|
function field ($name, $sql) {
|
||||||
function field ($name, $sql) {
|
$data = $this->one($sql);
|
||||||
$data = $this->one($sql);
|
return empty($data[$name])? false: $data[$name];
|
||||||
return empty($data[$name])? false: $data[$name];
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Checks if the specified table contains any record matching specified SQL
|
||||||
* Enter description here...
|
*
|
||||||
*
|
* @param unknown_type $table
|
||||||
* @param unknown_type $table
|
* @param unknown_type $sql
|
||||||
* @param unknown_type $sql
|
* @return unknown
|
||||||
* @return unknown
|
*/
|
||||||
*/
|
function hasAny($table, $sql) {
|
||||||
function hasAny($table, $sql) {
|
$out = $this->one("SELECT COUNT(*) AS count FROM {$table}".($sql? " WHERE {$sql}":""));
|
||||||
$out = $this->one("SELECT COUNT(*) AS count FROM {$table}".($sql? " WHERE {$sql}":""));
|
return is_array($out)? $out['count']: false;
|
||||||
return is_array($out)? $out['count']: false;
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Enter description here...
|
||||||
* Enter description here...
|
*
|
||||||
*
|
* @return unknown
|
||||||
* @return unknown
|
*/
|
||||||
*/
|
function isConnected() {
|
||||||
function isConnected() {
|
return $this->connected;
|
||||||
return $this->connected;
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Enter description here...
|
||||||
* Enter description here...
|
*
|
||||||
*
|
* @return unknown
|
||||||
* @return unknown
|
*/
|
||||||
*/
|
function prepareArray($data) {
|
||||||
function prepareArray($data) {
|
$out = null;
|
||||||
$out = null;
|
foreach ($data as $key=>$item) {
|
||||||
foreach ($data as $key=>$item) {
|
$out[$key] = $this->prepare($item);
|
||||||
$out[$key] = $this->prepare($item);
|
}
|
||||||
}
|
return $out;
|
||||||
return $out;
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Enter description here...
|
||||||
* Enter description here...
|
*
|
||||||
*
|
* @param unknown_type $sorted
|
||||||
* @param unknown_type $sorted
|
*/
|
||||||
*/
|
function showLog($sorted=false) {
|
||||||
function showLog($sorted=false) {
|
$log = $sorted?
|
||||||
$log = $sorted?
|
sortByKey($this->_queriesLog, 'took', 'desc', SORT_NUMERIC):
|
||||||
sortByKey($this->_queriesLog, 'took', 'desc', SORT_NUMERIC):
|
$this->_queriesLog;
|
||||||
$this->_queriesLog;
|
|
||||||
|
print("<table border=1>\n<tr><th colspan=7>{$this->_queriesCnt} queries took {$this->_queriesTime} ms</th></tr>\n");
|
||||||
print("<table border=1>\n<tr><th colspan=7>{$this->_queriesCnt} queries took {$this->_queriesTime} ms</th></tr>\n");
|
print("<tr><td>Nr</td><td>Query</td><td>Error</td><td>Affected</td><td>Num. rows</td><td>Took (ms)</td></tr>\n");
|
||||||
print("<tr><td>Nr</td><td>Query</td><td>Error</td><td>Affected</td><td>Num. rows</td><td>Took (ms)</td></tr>\n");
|
|
||||||
|
foreach($log AS $k=>$i) {
|
||||||
foreach($log AS $k=>$i) {
|
print("<tr><td>".($k+1)."</td><td>{$i['query']}</td><td>{$i['error']}</td><td align='right'>{$i['affected']}</td><td align='right'>{$i['numRows']}</td><td align='right'>{$i['took']}</td></tr>\n");
|
||||||
print("<tr><td>".($k+1)."</td><td>{$i['query']}</td><td>{$i['error']}</td><td align='right'>{$i['affected']}</td><td align='right'>{$i['numRows']}</td><td align='right'>{$i['took']}</td></tr>\n");
|
}
|
||||||
}
|
|
||||||
|
print("</table>\n");
|
||||||
print("</table>\n");
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Enter description here...
|
||||||
* Enter description here...
|
*
|
||||||
*
|
* @param unknown_type $q
|
||||||
* @param unknown_type $q
|
*/
|
||||||
*/
|
function logQuery($sql) {
|
||||||
function logQuery($sql) {
|
$this->_queriesCnt++;
|
||||||
$this->_queriesCnt++;
|
$this->_queriesTime += $this->took;
|
||||||
$this->_queriesTime += $this->took;
|
$this->_queriesLog[] = array(
|
||||||
$this->_queriesLog[] = array(
|
'query'=>$sql,
|
||||||
'query'=>$sql,
|
'error'=>$this->error,
|
||||||
'error'=>$this->error,
|
'affected'=>$this->affected,
|
||||||
'affected'=>$this->affected,
|
'numRows'=>$this->numRows,
|
||||||
'numRows'=>$this->numRows,
|
'took'=>$this->took
|
||||||
'took'=>$this->took
|
);
|
||||||
);
|
|
||||||
|
if ($this->error)
|
||||||
if ($this->error)
|
false; // shouldn't we be logging errors somehow?
|
||||||
false; // shouldn't we be logging errors somehow?
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Enter description here...
|
||||||
* Enter description here...
|
*
|
||||||
*
|
* @param unknown_type $q
|
||||||
* @param unknown_type $q
|
*/
|
||||||
*/
|
function showQuery($sql) {
|
||||||
function showQuery($sql) {
|
$error = $this->error;
|
||||||
$error = $this->error;
|
|
||||||
|
if (strlen($sql)>200 && !$this->fullDebug)
|
||||||
if (strlen($sql)>200 && !$this->fullDebug)
|
$sql = substr($sql, 0, 200) .'[...]';
|
||||||
$sql = substr($sql, 0, 200) .'[...]';
|
|
||||||
|
if ($this->debug || $error) {
|
||||||
if ($this->debug || $error) {
|
print("<p style=\"text-align:left\"><b>Query:</b> {$sql} <small>[Aff:{$this->affected} Num:{$this->numRows} Took:{$this->took}ms]</small>");
|
||||||
print("<p style=\"text-align:left\"><b>Query:</b> {$sql} <small>[Aff:{$this->affected} Num:{$this->numRows} Took:{$this->took}ms]</small>");
|
if($error) {
|
||||||
if($error) {
|
print("<br /><span style=\"color:Red;text-align:left\"><b>ERROR:</b> {$this->error}</span>");
|
||||||
print("<br /><span style=\"color:Red;text-align:left\"><b>ERROR:</b> {$this->error}</span>");
|
}
|
||||||
}
|
print('</p>');
|
||||||
print('</p>');
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -1,170 +1,170 @@
|
||||||
<?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: DBO_AdoDB
|
* Purpose: DBO_AdoDB
|
||||||
* AdoDB layer for DBO
|
* AdoDB layer for DBO
|
||||||
*
|
*
|
||||||
* @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...
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
require_once(VENDORS.'adodb/adodb.inc.php');
|
require_once(VENDORS.'adodb/adodb.inc.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 DBO_AdoDB extends DBO {
|
class DBO_AdoDB extends DBO {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $config
|
* @param unknown_type $config
|
||||||
*/
|
*/
|
||||||
function connect ($config) {
|
function connect ($config) {
|
||||||
if($this->config = $config) {
|
if($this->config = $config) {
|
||||||
if(isset($this->config['driver'])) {
|
if(isset($this->config['driver'])) {
|
||||||
$this->_adodb = NewADOConnection($this->config['driver']);
|
$this->_adodb = NewADOConnection($this->config['driver']);
|
||||||
|
|
||||||
$adodb =& $this->_adodb;
|
$adodb =& $this->_adodb;
|
||||||
$this->connected = $adodb->Connect($this->config['host'],$this->config['login'],$this->config['password'],$this->config['database']);
|
$this->connected = $adodb->Connect($this->config['host'],$this->config['login'],$this->config['password'],$this->config['database']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$this->connected)
|
if(!$this->connected)
|
||||||
die('Could not connect to DB.');
|
die('Could not connect to DB.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function disconnect () {
|
function disconnect () {
|
||||||
return $this->_adodb->close();
|
return $this->_adodb->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $sql
|
* @param unknown_type $sql
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function execute ($sql) {
|
function execute ($sql) {
|
||||||
return $this->_adodb->execute($sql);
|
return $this->_adodb->execute($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $res
|
* @param unknown_type $res
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function fetchRow ($res) {
|
function fetchRow ($res) {
|
||||||
return $res->FetchRow();
|
return $res->FetchRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function tables() {
|
function tables() {
|
||||||
$tables = $this->_adodb->MetaTables('TABLES');
|
$tables = $this->_adodb->MetaTables('TABLES');
|
||||||
|
|
||||||
if (!sizeof($tables)>0) {
|
if (!sizeof($tables)>0) {
|
||||||
trigger_error(ERROR_NO_TABLE_LIST, E_USER_NOTICE);
|
trigger_error(ERROR_NO_TABLE_LIST, E_USER_NOTICE);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
return $tables;
|
return $tables;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $table_name
|
* @param unknown_type $table_name
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function fields ($table_name) {
|
function fields ($table_name) {
|
||||||
$data = $this->_adodb->MetaColumns($table_name);
|
$data = $this->_adodb->MetaColumns($table_name);
|
||||||
$fields = false;
|
$fields = false;
|
||||||
|
|
||||||
foreach ($data as $item)
|
foreach ($data as $item)
|
||||||
$fields[] = array('name'=>$item->name, 'type'=>$item->type);
|
$fields[] = array('name'=>$item->name, 'type'=>$item->type);
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $data
|
* @param unknown_type $data
|
||||||
*/
|
*/
|
||||||
function prepare ($data) { die('Please implement DBO::prepare() first.'); }
|
function prepare ($data) { die('Please implement DBO::prepare() first.'); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function lastError () {
|
function lastError () {
|
||||||
return $this->_adodb->ErrorMsg();
|
return $this->_adodb->ErrorMsg();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function lastAffected () {
|
function lastAffected () {
|
||||||
return $this->_adodb->Affected_Rows();
|
return $this->_adodb->Affected_Rows();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function lastNumRows () {
|
function lastNumRows () {
|
||||||
return $this->_result? $this->_result->RecordCount(): false;
|
return $this->_result? $this->_result->RecordCount(): false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function lastInsertId () { die('Please implement DBO::lastInsertId() first.'); }
|
function lastInsertId () { die('Please implement DBO::lastInsertId() first.'); }
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -45,6 +45,8 @@ uses('object');
|
||||||
class DboFactory extends Object {
|
class DboFactory extends Object {
|
||||||
|
|
||||||
function make ($activeConfig) {
|
function make ($activeConfig) {
|
||||||
|
if (!class_exists('DATABASE_CONFIG')) return false;
|
||||||
|
|
||||||
$config = DATABASE_CONFIG::$activeConfig();
|
$config = DATABASE_CONFIG::$activeConfig();
|
||||||
|
|
||||||
// special case for AdoDB -- driver name in the form of 'adodb_drivername'
|
// special case for AdoDB -- driver name in the form of 'adodb_drivername'
|
||||||
|
|
|
@ -1,189 +1,189 @@
|
||||||
<?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. + //
|
||||||
// + You may not use this file except in compliance with the License. + //
|
// + You may not use this file except in compliance with the License. + //
|
||||||
// + + //
|
// + + //
|
||||||
// + You may obtain a copy of the License at: + //
|
// + You may obtain a copy of the License at: + //
|
||||||
// + License page: http://www.opensource.org/licenses/mit-license.php + //
|
// + License page: http://www.opensource.org/licenses/mit-license.php + //
|
||||||
// +------------------------------------------------------------------+ //
|
// +------------------------------------------------------------------+ //
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose: DBO_MySQL
|
* Purpose: DBO_MySQL
|
||||||
* MySQL layer for DBO
|
* MySQL layer for DBO
|
||||||
*
|
*
|
||||||
* @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', 'dbo');
|
uses('object', 'dbo');
|
||||||
/**
|
/**
|
||||||
* 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 DBO_MySQL extends DBO {
|
class DBO_MySQL extends DBO {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $config
|
* @param unknown_type $config
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function connect ($config) {
|
function connect ($config) {
|
||||||
if($config) {
|
if($config) {
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->_conn = mysql_pconnect($config['host'],$config['login'],$config['password']);
|
$this->_conn = mysql_pconnect($config['host'],$config['login'],$config['password']);
|
||||||
}
|
}
|
||||||
$this->connected = $this->_conn? true: false;
|
$this->connected = $this->_conn? true: false;
|
||||||
|
|
||||||
if($this->connected)
|
if($this->connected)
|
||||||
Return mysql_select_db($config['database'], $this->_conn);
|
Return mysql_select_db($config['database'], $this->_conn);
|
||||||
else
|
else
|
||||||
die('Could not connect to DB.');
|
die('Could not connect to DB.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function disconnect () {
|
function disconnect () {
|
||||||
return mysql_close();
|
return mysql_close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $sql
|
* @param unknown_type $sql
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function execute ($sql) {
|
function execute ($sql) {
|
||||||
return mysql_query($sql);
|
return mysql_query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $res
|
* @param unknown_type $res
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function fetchRow ($res) {
|
function fetchRow ($res) {
|
||||||
return mysql_fetch_array($res);
|
return mysql_fetch_array($res);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function tables () {
|
function tables () {
|
||||||
$result = mysql_list_tables($this->config['database']);
|
$result = mysql_list_tables($this->config['database']);
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
trigger_error(ERROR_NO_TABLE_LIST, E_USER_NOTICE);
|
trigger_error(ERROR_NO_TABLE_LIST, E_USER_NOTICE);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$tables = array();
|
$tables = array();
|
||||||
while ($line = mysql_fetch_array($result)) {
|
while ($line = mysql_fetch_array($result)) {
|
||||||
$tables[] = $line[0];
|
$tables[] = $line[0];
|
||||||
}
|
}
|
||||||
return $tables;
|
return $tables;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $table_name
|
* @param unknown_type $table_name
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function fields ($table_name) {
|
function fields ($table_name) {
|
||||||
$data = $this->all("DESC {$table_name}");
|
$data = $this->all("DESC {$table_name}");
|
||||||
$fields = false;
|
$fields = false;
|
||||||
|
|
||||||
foreach ($data as $item)
|
foreach ($data as $item)
|
||||||
$fields[] = array('name'=>$item['Field'], 'type'=>$item['Type']);
|
$fields[] = array('name'=>$item['Field'], 'type'=>$item['Type']);
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $data
|
* @param unknown_type $data
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function prepare ($data) {
|
function prepare ($data) {
|
||||||
return "'".mysql_real_escape_string($data)."'";
|
return "'".mysql_real_escape_string($data)."'";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function lastError () {
|
function lastError () {
|
||||||
return mysql_errno()? mysql_errno().': '.mysql_error(): null;
|
return mysql_errno()? mysql_errno().': '.mysql_error(): null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function lastAffected () {
|
function lastAffected () {
|
||||||
return $this->_result? mysql_affected_rows(): false;
|
return $this->_result? mysql_affected_rows(): false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function lastNumRows () {
|
function lastNumRows () {
|
||||||
return $this->_result? @mysql_num_rows($this->_result): false;
|
return $this->_result? @mysql_num_rows($this->_result): false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function lastInsertId() {
|
function lastInsertId() {
|
||||||
Return mysql_insert_id();
|
Return mysql_insert_id();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -1,195 +1,195 @@
|
||||||
<?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: DBO_Postgres
|
* Purpose: DBO_Postgres
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @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 1.0.0.114
|
* @since Cake v 1.0.0.114
|
||||||
* @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', 'dbo');
|
uses('object', 'dbo');
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.libs
|
* @subpackage cake.libs
|
||||||
* @since Cake v 1.0.0.114
|
* @since Cake v 1.0.0.114
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class DBO_Postgres extends DBO {
|
class DBO_Postgres extends DBO {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $config
|
* @param unknown_type $config
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function connect ($config) {
|
function connect ($config) {
|
||||||
if($config) {
|
if($config) {
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->_conn = pg_pconnect("host={$config['host']} dbname={$config['database']} user={$config['login']} password={$config['password']}");
|
$this->_conn = pg_pconnect("host={$config['host']} dbname={$config['database']} user={$config['login']} password={$config['password']}");
|
||||||
}
|
}
|
||||||
$this->connected = $this->_conn? true: false;
|
$this->connected = $this->_conn? true: false;
|
||||||
|
|
||||||
if($this->connected)
|
if($this->connected)
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
die('Could not connect to DB.');
|
die('Could not connect to DB.');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function disconnect () {
|
function disconnect () {
|
||||||
return pg_close($this->_conn);
|
return pg_close($this->_conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $sql
|
* @param unknown_type $sql
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function execute ($sql) {
|
function execute ($sql) {
|
||||||
return pg_query($this->_conn, $sql);
|
return pg_query($this->_conn, $sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $res
|
* @param unknown_type $res
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function fetchRow ($res) {
|
function fetchRow ($res) {
|
||||||
return pg_fetch_array($res);
|
return pg_fetch_array($res);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function tables () {
|
function tables () {
|
||||||
$sql = "SELECT a.relname AS name
|
$sql = "SELECT a.relname AS name
|
||||||
FROM pg_class a, pg_user b
|
FROM pg_class a, pg_user b
|
||||||
WHERE ( relkind = 'r') and relname !~ '^pg_' AND relname !~ '^sql_'
|
WHERE ( relkind = 'r') and relname !~ '^pg_' AND relname !~ '^sql_'
|
||||||
AND relname !~ '^xin[vx][0-9]+' AND b.usesysid = a.relowner
|
AND relname !~ '^xin[vx][0-9]+' AND b.usesysid = a.relowner
|
||||||
AND NOT (EXISTS (SELECT viewname FROM pg_views WHERE viewname=a.relname));";
|
AND NOT (EXISTS (SELECT viewname FROM pg_views WHERE viewname=a.relname));";
|
||||||
|
|
||||||
$result = $this->all($sql);
|
$result = $this->all($sql);
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
trigger_error(ERROR_NO_TABLE_LIST, E_USER_ERROR);
|
trigger_error(ERROR_NO_TABLE_LIST, E_USER_ERROR);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$tables = array();
|
$tables = array();
|
||||||
foreach ($result as $item) $tables[] = $item['name'];
|
foreach ($result as $item) $tables[] = $item['name'];
|
||||||
return $tables;
|
return $tables;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $table_name
|
* @param unknown_type $table_name
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function fields ($table_name) {
|
function fields ($table_name) {
|
||||||
$sql = "SELECT c.relname, a.attname, t.typname FROM pg_class c, pg_attribute a, pg_type t WHERE c.relname = '{$table_name}' AND a.attnum > 0 AND a.attrelid = c.oid AND a.atttypid = t.oid";
|
$sql = "SELECT c.relname, a.attname, t.typname FROM pg_class c, pg_attribute a, pg_type t WHERE c.relname = '{$table_name}' AND a.attnum > 0 AND a.attrelid = c.oid AND a.atttypid = t.oid";
|
||||||
|
|
||||||
$fields = false;
|
$fields = false;
|
||||||
foreach ($this->all($sql) as $field) {
|
foreach ($this->all($sql) as $field) {
|
||||||
$fields[] = array(
|
$fields[] = array(
|
||||||
'name' => $field['attname'],
|
'name' => $field['attname'],
|
||||||
'type' => $field['typname']);
|
'type' => $field['typname']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $data
|
* @param unknown_type $data
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function prepare ($data) {
|
function prepare ($data) {
|
||||||
return "'".str_replace('"', '\"', str_replace('$', '$', $data))."'";
|
return "'".str_replace('"', '\"', str_replace('$', '$', $data))."'";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function lastError () {
|
function lastError () {
|
||||||
return pg_last_error()? pg_last_error(): null;
|
return pg_last_error()? pg_last_error(): null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function lastAffected () {
|
function lastAffected () {
|
||||||
return $this->_result? pg_affected_rows($this->_result): false;
|
return $this->_result? pg_affected_rows($this->_result): false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function lastNumRows () {
|
function lastNumRows () {
|
||||||
return $this->_result? pg_num_rows($this->_result): false;
|
return $this->_result? pg_num_rows($this->_result): false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $table
|
* @param unknown_type $table
|
||||||
* @param unknown_type $field
|
* @param unknown_type $field
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function lastInsertId ($table, $field='id') {
|
function lastInsertId ($table, $field='id') {
|
||||||
$sql = "SELECT CURRVAL('{$table}_{$field}_seq') AS max";
|
$sql = "SELECT CURRVAL('{$table}_{$field}_seq') AS max";
|
||||||
$res = $this->rawQuery($sql);
|
$res = $this->rawQuery($sql);
|
||||||
$data = $this->fetchRow($res);
|
$data = $this->fetchRow($res);
|
||||||
return $data['max'];
|
return $data['max'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -1,247 +1,247 @@
|
||||||
<?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: Dispatcher
|
* Purpose: Dispatcher
|
||||||
* Dispatches the request, creating aproppriate models and controllers.
|
* Dispatches the request, creating aproppriate models and controllers.
|
||||||
*
|
*
|
||||||
* @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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description:
|
* Description:
|
||||||
* Dispatches the request, creating aproppriate models and controllers.
|
* Dispatches the request, creating aproppriate models and controllers.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uses('error_messages', 'object', 'router', 'cache', 'controller');
|
uses('error_messages', 'object', 'router', 'controller');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 Dispatcher extends Object {
|
class Dispatcher extends Object {
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var unknown_type
|
||||||
*/
|
*/
|
||||||
var $base = false;
|
var $base = false;
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var unknown_type
|
||||||
*/
|
*/
|
||||||
var $passed_args = array();
|
var $passed_args = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function __construct () {
|
function __construct () {
|
||||||
$this->base = $this->baseUrl();
|
$this->base = $this->baseUrl();
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $url
|
* @param unknown_type $url
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function dispatch ($url) {
|
function dispatch ($url) {
|
||||||
global $_POST, $_GET, $_FILES, $_SESSION;
|
global $_POST, $_GET, $_FILES, $_SESSION;
|
||||||
|
|
||||||
$params = $this->parseParams($url);
|
$params = $this->parseParams($url);
|
||||||
|
|
||||||
// die if no controller set
|
// die if no controller set
|
||||||
if (empty($params['controller']))
|
if (empty($params['controller']))
|
||||||
$this->errorNoController($url);
|
$this->errorNoController($url);
|
||||||
|
|
||||||
$ctrl_name = ucfirst($params['controller']);
|
$ctrl_name = ucfirst($params['controller']);
|
||||||
$ctrl_class = $ctrl_name.'Controller';
|
$ctrl_class = $ctrl_name.'Controller';
|
||||||
|
|
||||||
// if specified controller class doesn't exist
|
// if specified controller class doesn't exist
|
||||||
if (!loadController($ctrl_name) || !class_exists($ctrl_class))
|
if (!loadController($ctrl_name) || !class_exists($ctrl_class))
|
||||||
$this->errorUnknownController($url, $ctrl_name);
|
$this->errorUnknownController($url, $ctrl_name);
|
||||||
|
|
||||||
$controller = new $ctrl_class ($this);
|
$controller = new $ctrl_class ($this);
|
||||||
$controller->cache = &$Cache;
|
$controller->cache = &$Cache;
|
||||||
$controller->base = $this->base;
|
$controller->base = $this->base;
|
||||||
|
|
||||||
// if action is not set, and the default Controller::index() method doesn't exist
|
// if action is not set, and the default Controller::index() method doesn't exist
|
||||||
if (empty($params['action'])) {
|
if (empty($params['action'])) {
|
||||||
if (method_exists($controller, 'index'))
|
if (method_exists($controller, 'index'))
|
||||||
$params['action'] = 'index';
|
$params['action'] = 'index';
|
||||||
else
|
else
|
||||||
$this->errorNoAction($url);
|
$this->errorNoAction($url);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the requested action doesn't exist
|
// if the requested action doesn't exist
|
||||||
if (!method_exists($controller, $params['action']))
|
if (!method_exists($controller, $params['action']))
|
||||||
$this->errorUnknownAction($url, $ctrl_class, $params['action']);
|
$this->errorUnknownAction($url, $ctrl_class, $params['action']);
|
||||||
|
|
||||||
$controller->params = $params;
|
$controller->params = $params;
|
||||||
$controller->action = $params['action'];
|
$controller->action = $params['action'];
|
||||||
$controller->data = empty($params['data'])? null: $params['data'];
|
$controller->data = empty($params['data'])? null: $params['data'];
|
||||||
$controller->passed_args = empty($params['pass'])? null: $params['pass'];
|
$controller->passed_args = empty($params['pass'])? null: $params['pass'];
|
||||||
|
|
||||||
// EXECUTE THE REQUESTED ACTION
|
// EXECUTE THE REQUESTED ACTION
|
||||||
call_user_func_array(array(&$controller, $params['action']), empty($params['pass'])? null: $params['pass']);
|
call_user_func_array(array(&$controller, $params['action']), empty($params['pass'])? null: $params['pass']);
|
||||||
|
|
||||||
if ($controller->autoRender)
|
if ($controller->autoRender)
|
||||||
$controller->render();
|
$controller->render();
|
||||||
|
|
||||||
return $params;
|
return $params;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $from_url
|
* @param unknown_type $from_url
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function parseParams ($from_url) {
|
function parseParams ($from_url) {
|
||||||
global $_POST, $_FILES;
|
global $_POST, $_FILES;
|
||||||
|
|
||||||
// load routes config
|
// load routes config
|
||||||
$Route = new Router();
|
$Route = new Router();
|
||||||
require CONFIGS.'routes.php';
|
require CONFIGS.'routes.php';
|
||||||
$params = $Route->parse ('/'.$from_url);
|
$params = $Route->parse ('/'.$from_url);
|
||||||
|
|
||||||
// add submitted form data
|
// add submitted form data
|
||||||
$params['form'] = $_POST;
|
$params['form'] = $_POST;
|
||||||
if (isset($_POST['data']))
|
if (isset($_POST['data']))
|
||||||
$params['data'] = $_POST['data'];
|
$params['data'] = $_POST['data'];
|
||||||
|
|
||||||
foreach ($_FILES as $name => $data)
|
foreach ($_FILES as $name => $data)
|
||||||
$params['form'][$name] = $data;
|
$params['form'][$name] = $data;
|
||||||
|
|
||||||
return $params;
|
return $params;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function baseUrl () {
|
function baseUrl () {
|
||||||
global $_SERVER;
|
global $_SERVER;
|
||||||
|
|
||||||
//non mod_rewrite use:
|
//non mod_rewrite use:
|
||||||
if (defined('BASE_URL')) return BASE_URL;
|
if (defined('BASE_URL')) return BASE_URL;
|
||||||
|
|
||||||
$doc_root = $_SERVER['DOCUMENT_ROOT'];
|
$doc_root = $_SERVER['DOCUMENT_ROOT'];
|
||||||
$script_name = $_SERVER['PHP_SELF'];
|
$script_name = $_SERVER['PHP_SELF'];
|
||||||
|
|
||||||
// if document root ends with 'public', it's probably correctly set
|
// if document root ends with 'public', it's probably correctly set
|
||||||
$r = null;
|
$r = null;
|
||||||
if (!ereg('/^.*/public(\/)?$/', $doc_root))
|
if (!ereg('/^.*/public(\/)?$/', $doc_root))
|
||||||
return preg_match('/^(.*)\/public\/dispatch\.php$/', $script_name, $r)? $r[1]: false;
|
return preg_match('/^(.*)\/public\/index\.php$/', $script_name, $r)? $r[1]: false;
|
||||||
// document root is probably not set to Cake 'public' dir
|
// document root is probably not set to Cake 'public' dir
|
||||||
else
|
else
|
||||||
return preg_match('/^(.*)\/dispatch\.php$/', $script_name, $r)? $r[1]: false;
|
return preg_match('/^(.*)\/index\.php$/', $script_name, $r)? $r[1]: false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $code
|
* @param unknown_type $code
|
||||||
* @param unknown_type $name
|
* @param unknown_type $name
|
||||||
* @param unknown_type $message
|
* @param unknown_type $message
|
||||||
*/
|
*/
|
||||||
function error ($code, $name, $message) {
|
function error ($code, $name, $message) {
|
||||||
$controller = new Controller ($this);
|
$controller = new Controller ($this);
|
||||||
$controller->base = $this->base;
|
$controller->base = $this->base;
|
||||||
$controller->error($code, $name, $message);
|
$controller->error($code, $name, $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $url
|
* @param unknown_type $url
|
||||||
* @param unknown_type $message
|
* @param unknown_type $message
|
||||||
*/
|
*/
|
||||||
function error404 ($url, $message) {
|
function error404 ($url, $message) {
|
||||||
$this->error('404', 'Not found', sprintf(ERROR_404, $url, $message));
|
$this->error('404', 'Not found', sprintf(ERROR_404, $url, $message));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $url
|
* @param unknown_type $url
|
||||||
*/
|
*/
|
||||||
function errorNoController ($url) {
|
function errorNoController ($url) {
|
||||||
DEBUG?
|
DEBUG?
|
||||||
trigger_error (ERROR_NO_CONTROLLER_SET, E_USER_ERROR):
|
trigger_error (ERROR_NO_CONTROLLER_SET, E_USER_ERROR):
|
||||||
$this->error404($url, "no controller set");
|
$this->error404($url, "no controller set");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $url
|
* @param unknown_type $url
|
||||||
* @param unknown_type $controller_class
|
* @param unknown_type $controller_class
|
||||||
*/
|
*/
|
||||||
function errorUnknownController ($url, $controller_class) {
|
function errorUnknownController ($url, $controller_class) {
|
||||||
DEBUG?
|
DEBUG?
|
||||||
trigger_error (sprintf(ERROR_UNKNOWN_CONTROLLER, $controller_class), E_USER_ERROR):
|
trigger_error (sprintf(ERROR_UNKNOWN_CONTROLLER, $controller_class), E_USER_ERROR):
|
||||||
$this->error404($url, "missing controller \"{$controller_class}\"");
|
$this->error404($url, "missing controller \"{$controller_class}\"");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $url
|
* @param unknown_type $url
|
||||||
*/
|
*/
|
||||||
function errorNoAction ($url) {
|
function errorNoAction ($url) {
|
||||||
DEBUG?
|
DEBUG?
|
||||||
trigger_error (ERROR_NO_ACTION_SET, E_USER_ERROR):
|
trigger_error (ERROR_NO_ACTION_SET, E_USER_ERROR):
|
||||||
$this->error404(sprintf(ERROR_404, $url, "no action set"));
|
$this->error404(sprintf(ERROR_404, $url, "no action set"));
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $url
|
* @param unknown_type $url
|
||||||
* @param unknown_type $controller_class
|
* @param unknown_type $controller_class
|
||||||
* @param unknown_type $action
|
* @param unknown_type $action
|
||||||
*/
|
*/
|
||||||
function errorUnknownAction ($url,$controller_class, $action) {
|
function errorUnknownAction ($url,$controller_class, $action) {
|
||||||
DEBUG?
|
DEBUG?
|
||||||
trigger_error (sprintf(ERROR_NO_ACTION, $action, $controller_class), E_USER_ERROR):
|
trigger_error (sprintf(ERROR_NO_ACTION, $action, $controller_class), E_USER_ERROR):
|
||||||
$this->error404($url, "missing controller \"{$controller_class}\"");
|
$this->error404($url, "missing controller \"{$controller_class}\"");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -1,122 +1,122 @@
|
||||||
<?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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
define ('ERROR_UNKNOWN_DATABASE_DRIVER', '[DbFactory] Specified database driver (%s) not found');
|
define ('ERROR_UNKNOWN_DATABASE_DRIVER', '[DbFactory] Specified database driver (%s) not found');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
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');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
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');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
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');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
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>');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
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');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
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>');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
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');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
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');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
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');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
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');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
define ('SHORT_ERROR_MESSAGE', '<div class="error_message"><i>%s</i></div>');
|
define ('SHORT_ERROR_MESSAGE', '<div class="error_message"><i>%s</i></div>');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
define ('ERROR_CANT_GET_ORIGINAL_IMAGE', '[Image] Couln\'t load original image %s (tried from "%s")');
|
define ('ERROR_CANT_GET_ORIGINAL_IMAGE', '[Image] Couln\'t load original image %s (tried from "%s")');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
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
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
define ('ERROR_500', "Application error, sorry.");
|
define ('ERROR_500', "Application error, sorry.");
|
||||||
|
|
||||||
?>
|
?>
|
348
libs/flay.php
348
libs/flay.php
|
@ -1,175 +1,175 @@
|
||||||
<?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.
|
||||||
* See Flay::test() for examples.
|
* See Flay::test() for examples.
|
||||||
* Test with $flay = new Flay(); $flay->test();
|
* Test with $flay = new Flay(); $flay->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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
uses('object');
|
uses('object');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 Flay extends Object {
|
class Flay extends Object {
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var unknown_type
|
||||||
*/
|
*/
|
||||||
var $text = null;
|
var $text = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var unknown_type
|
||||||
*/
|
*/
|
||||||
var $allow_html = false;
|
var $allow_html = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $text
|
* @param unknown_type $text
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function toHtml ($text=null) {
|
function toHtml ($text=null) {
|
||||||
$text = $text? $text: $this->text;
|
$text = $text? $text: $this->text;
|
||||||
|
|
||||||
// trim whitespace and disable all HTML
|
// trim whitespace and disable all HTML
|
||||||
$text = str_replace('<', '<', str_replace('>', '>', trim($text)));
|
$text = str_replace('<', '<', str_replace('>', '>', trim($text)));
|
||||||
|
|
||||||
// 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) {
|
||||||
|
|
||||||
// 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(' - ', ' – ', $line);
|
$line = str_replace(' - ', ' – ', $line);
|
||||||
$line = str_replace(' -- ', ' — ', $line);
|
$line = str_replace(' -- ', ' — ', $line);
|
||||||
$line = str_replace('(C)', '©', $line);
|
$line = str_replace('(C)', '©', $line);
|
||||||
$line = str_replace('(R)', '®', $line);
|
$line = str_replace('(R)', '®', $line);
|
||||||
$line = str_replace('(TM)', '™', $line);
|
$line = str_replace('(TM)', '™', $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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 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\.[^ ]+)#", $line, $urls)) {
|
if (preg_match_all("#(www\.[^ ]+)#", $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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 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('#\.(jpg|jpeg|gif|png)$#', $links[$ii]))
|
if (preg_match('#\.(jpg|jpeg|gif|png)$#', $links[$ii]))
|
||||||
$with = "<img src=\"{$links[$ii]}\" alt=\"\" />";
|
$with = "<img src=\"{$links[$ii]}\" alt=\"\" />";
|
||||||
elseif (preg_match('#^([^\]\ ]+)(?: ([^\]]+))?$#', $links[$ii], $regs))
|
elseif (preg_match('#^([^\]\ ]+)(?: ([^\]]+))?$#', $links[$ii], $regs))
|
||||||
$with = "<a href=\"{$regs[1]}\" target=\"_blank\">".(isset($regs[2])? $regs[2]: $regs[1])."</a>";
|
$with = "<a href=\"{$regs[1]}\" target=\"_blank\">".(isset($regs[2])? $regs[2]: $regs[1])."</a>";
|
||||||
else
|
else
|
||||||
$with = $links[$ii];
|
$with = $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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -1,4 +1,4 @@
|
||||||
<?PHP
|
<?PHP
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// + $Id$
|
// + $Id$
|
||||||
// +------------------------------------------------------------------+ //
|
// +------------------------------------------------------------------+ //
|
||||||
|
@ -34,18 +34,15 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
uses('object');
|
uses('object');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 Inflector extends Object {
|
class Inflector extends Object {
|
||||||
|
|
||||||
|
|
|
@ -39,4 +39,24 @@ if (version_compare(phpversion(), '5.0') < 0) {
|
||||||
');
|
');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// needed for old Plog v2
|
||||||
|
//
|
||||||
|
function old_lib ($name) {
|
||||||
|
old_libs ($name);
|
||||||
|
}
|
||||||
|
|
||||||
|
function old_libs () {
|
||||||
|
if (count($lib_names = func_get_args())) {
|
||||||
|
foreach ($lib_names as $lib_name) {
|
||||||
|
require (OLD_LIBS.$lib_name.'.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
1242
libs/model.php
1242
libs/model.php
File diff suppressed because it is too large
Load diff
|
@ -31,6 +31,16 @@ uses('log');
|
||||||
* @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('log');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enter description here...
|
||||||
|
*
|
||||||
|
* @package cake
|
||||||
|
* @subpackage cake.libs
|
||||||
|
* @since Cake v 0.2.9
|
||||||
|
*/
|
||||||
class Object {
|
class Object {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
336
libs/router.php
336
libs/router.php
|
@ -1,169 +1,169 @@
|
||||||
<?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 params
|
* Parses the request URL into controller, action, and params
|
||||||
*
|
*
|
||||||
* @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');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 Router extends Object {
|
class Router extends Object {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var unknown_type
|
||||||
*/
|
*/
|
||||||
var $routes = array();
|
var $routes = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function __construct () {
|
function __construct () {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $route
|
* @param unknown_type $route
|
||||||
* @param unknown_type $default
|
* @param unknown_type $default
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $url
|
* @param unknown_type $url
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function parse ($url) {
|
function parse ($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 NeatArray(explode('/', $found));
|
$pass = new NeatArray(explode('/', $found));
|
||||||
$pass->cleanup();
|
$pass->cleanup();
|
||||||
$out['pass'] = $pass->value;
|
$out['pass'] = $pass->value;
|
||||||
}
|
}
|
||||||
$ii++;
|
$ii++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -1,287 +1,287 @@
|
||||||
<?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: Renderer
|
* Purpose: Renderer
|
||||||
* Templating for Controller class.
|
* Templating for Controller class.
|
||||||
*
|
*
|
||||||
* @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');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 Template extends Object {
|
class Template extends Object {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var unknown_type
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $base = null;
|
var $base = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var unknown_type
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $layout = 'default';
|
var $layout = 'default';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var unknown_type
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $autoRender = true;
|
var $autoRender = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var unknown_type
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $autoLayout = true;
|
var $autoLayout = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var unknown_type
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $_view_vars = array();
|
var $_view_vars = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var unknown_type
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $_page_title = false;
|
var $_page_title = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function __construct () {
|
function __construct () {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $layout
|
* @param unknown_type $layout
|
||||||
*/
|
*/
|
||||||
function setLayout ($layout) {
|
function setLayout ($layout) {
|
||||||
$this->layout = $layout;
|
$this->layout = $layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $one
|
* @param unknown_type $one
|
||||||
* @param unknown_type $two
|
* @param unknown_type $two
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function set($one, $two=null) {
|
function set($one, $two=null) {
|
||||||
return $this->_setArray(is_array($one)? $one: array($one=>$two));
|
return $this->_setArray(is_array($one)? $one: array($one=>$two));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $value
|
* @param unknown_type $value
|
||||||
*/
|
*/
|
||||||
function setTitle ($value) {
|
function setTitle ($value) {
|
||||||
$this->_page_title = $value;
|
$this->_page_title = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $data
|
* @param unknown_type $data
|
||||||
*/
|
*/
|
||||||
function _setArray($data) {
|
function _setArray($data) {
|
||||||
foreach ($data as $name => $value) {
|
foreach ($data as $name => $value) {
|
||||||
if ($name == 'title')
|
if ($name == 'title')
|
||||||
$this->setTitle ($value);
|
$this->setTitle ($value);
|
||||||
else
|
else
|
||||||
$this->_view_vars[$name] = $value;
|
$this->_view_vars[$name] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $message
|
* @param unknown_type $message
|
||||||
* @param unknown_type $url
|
* @param unknown_type $url
|
||||||
* @param unknown_type $time
|
* @param unknown_type $time
|
||||||
*/
|
*/
|
||||||
function flash ($message, $url, $time=1) {
|
function flash ($message, $url, $time=1) {
|
||||||
$this->autoRender = false;
|
$this->autoRender = false;
|
||||||
$this->autoLayout = false;
|
$this->autoLayout = false;
|
||||||
|
|
||||||
$this->set('url', $this->base.$url);
|
$this->set('url', $this->base.$url);
|
||||||
$this->set('message', $message);
|
$this->set('message', $message);
|
||||||
$this->set('time', $time);
|
$this->set('time', $time);
|
||||||
|
|
||||||
$this->render(null,false,VIEWS.'layouts'.DS.'flash.thtml');
|
$this->render(null,false,VIEWS.'layouts'.DS.'flash.thtml');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $action
|
* @param unknown_type $action
|
||||||
* @param unknown_type $layout
|
* @param unknown_type $layout
|
||||||
* @param unknown_type $file
|
* @param unknown_type $file
|
||||||
*/
|
*/
|
||||||
function render ($action=null, $layout=null, $file=null) {
|
function render ($action=null, $layout=null, $file=null) {
|
||||||
$this->autoRender = false;
|
$this->autoRender = false;
|
||||||
|
|
||||||
if (!$action) $action = $this->action;
|
if (!$action) $action = $this->action;
|
||||||
if ($layout) $this->setLayout($layout);
|
if ($layout) $this->setLayout($layout);
|
||||||
|
|
||||||
$view_fn = $file? $file: $this->_getViewFn($action);
|
$view_fn = $file? $file: $this->_getViewFn($action);
|
||||||
|
|
||||||
if (!is_file($view_fn)) {
|
if (!is_file($view_fn)) {
|
||||||
DEBUG? trigger_error (sprintf(ERROR_NO_VIEW, $action, $view_fn), E_USER_ERROR)
|
DEBUG? trigger_error (sprintf(ERROR_NO_VIEW, $action, $view_fn), E_USER_ERROR)
|
||||||
: $this->error('404', 'Not found', sprintf(ERROR_404, '', "missing view \"{$action}\""));
|
: $this->error('404', 'Not found', sprintf(ERROR_404, '', "missing view \"{$action}\""));
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
$out = $this->_render($view_fn, $this->_view_vars, 0);
|
$out = $this->_render($view_fn, $this->_view_vars, 0);
|
||||||
|
|
||||||
if ($out !== false) {
|
if ($out !== false) {
|
||||||
if ($this->layout && $this->autoLayout)
|
if ($this->layout && $this->autoLayout)
|
||||||
$out = $this->renderLayout($out);
|
$out = $this->renderLayout($out);
|
||||||
print $out;
|
print $out;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$out = $this->_render($view_fn, $this->_view_vars, false);
|
$out = $this->_render($view_fn, $this->_view_vars, false);
|
||||||
trigger_error (sprintf(ERROR_IN_VIEW, $view_fn, $out), E_USER_ERROR);
|
trigger_error (sprintf(ERROR_IN_VIEW, $view_fn, $out), E_USER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $content_for_layout
|
* @param unknown_type $content_for_layout
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function renderLayout ($content_for_layout) {
|
function renderLayout ($content_for_layout) {
|
||||||
$layout_fn = $this->_getLayoutFn();
|
$layout_fn = $this->_getLayoutFn();
|
||||||
|
|
||||||
$data_for_layout = array_merge($this->_view_vars, array(
|
$data_for_layout = array_merge($this->_view_vars, array(
|
||||||
'title_for_layout'=>$this->_page_title !== false? $this->_page_title: ucfirst($this->name),
|
'title_for_layout'=>$this->_page_title !== false? $this->_page_title: ucfirst($this->name),
|
||||||
'content_for_layout'=>$content_for_layout));
|
'content_for_layout'=>$content_for_layout));
|
||||||
|
|
||||||
if (is_file($layout_fn)) {
|
if (is_file($layout_fn)) {
|
||||||
$out = $this->_render($layout_fn, $data_for_layout);
|
$out = $this->_render($layout_fn, $data_for_layout);
|
||||||
|
|
||||||
if ($out === false) {
|
if ($out === false) {
|
||||||
$out = $this->_render($layout_fn, $data_for_layout, false);
|
$out = $this->_render($layout_fn, $data_for_layout, false);
|
||||||
trigger_error (sprintf(ERROR_IN_LAYOUT, $layout_fn, $out), E_USER_ERROR);
|
trigger_error (sprintf(ERROR_IN_LAYOUT, $layout_fn, $out), E_USER_ERROR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
trigger_error (sprintf(ERROR_NO_LAYOUT, $this->layout, $layout_fn), E_USER_ERROR);
|
trigger_error (sprintf(ERROR_NO_LAYOUT, $this->layout, $layout_fn), E_USER_ERROR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function _getLayoutFn() {
|
function _getLayoutFn() {
|
||||||
return VIEWS."layouts".DS."{$this->layout}.thtml";
|
return VIEWS."layouts".DS."{$this->layout}.thtml";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $action
|
* @param unknown_type $action
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function _getViewFn($action) {
|
function _getViewFn($action) {
|
||||||
return VIEWS.$this->name.DS."{$action}.thtml";
|
return VIEWS.$this->name.DS."{$action}.thtml";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param unknown_type $___view_fn
|
* @param unknown_type $___view_fn
|
||||||
* @param unknown_type $___data_for_view
|
* @param unknown_type $___data_for_view
|
||||||
* @param unknown_type $___play_safe
|
* @param unknown_type $___play_safe
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function _render($___view_fn, $___data_for_view, $___play_safe = true) {
|
function _render($___view_fn, $___data_for_view, $___play_safe = true) {
|
||||||
extract($___data_for_view, EXTR_SKIP); # load all view variables
|
extract($___data_for_view, EXTR_SKIP); # load all view variables
|
||||||
$BASE = $this->base;
|
$BASE = $this->base;
|
||||||
$params = &$this->params;
|
$params = &$this->params;
|
||||||
$page_title = $this->_page_title;
|
$page_title = $this->_page_title;
|
||||||
ob_start(); # start caching output (eval outputs directly so we need to cache)
|
ob_start(); # start caching output (eval outputs directly so we need to cache)
|
||||||
|
|
||||||
# include the template
|
# include the template
|
||||||
$___play_safe? @include($___view_fn): include($___view_fn);
|
$___play_safe? @include($___view_fn): include($___view_fn);
|
||||||
|
|
||||||
$out = ob_get_contents(); # retrieve cached output
|
$out = ob_get_contents(); # retrieve cached output
|
||||||
ob_end_clean(); # end caching output
|
ob_end_clean(); # end caching output
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* trims a string to a specified length adding elipsis '..' if necessary
|
* trims a string to a specified length adding elipsis '..' if necessary
|
||||||
*
|
*
|
||||||
* @param unknown_type $string
|
* @param unknown_type $string
|
||||||
* @param unknown_type $length
|
* @param unknown_type $length
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function trimTo ($string, $length) {
|
function trimTo ($string, $length) {
|
||||||
return substr($string, 0, $length).(strlen($string)>$length? '..': null);
|
return substr($string, 0, $length).(strlen($string)>$length? '..': null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
2122
libs/test.php
2122
libs/test.php
File diff suppressed because it is too large
Load diff
|
@ -1,9 +1,13 @@
|
||||||
# Based on Rails 0.10.0 .htaccess (www.rubyonrails.com)
|
# Based on Rails 0.10.0 .htaccess (www.rubyonrails.com)
|
||||||
|
|
||||||
|
<IfModule mod_rewrite.c>
|
||||||
|
|
||||||
# Redirect all requests not available on the filesystem to Cake
|
# Redirect all requests not available on the filesystem to Cake
|
||||||
RewriteEngine On
|
RewriteEngine On
|
||||||
RewriteCond %{REQUEST_FILENAME} !-f
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
RewriteRule ^(.*)$ dispatch.php?url=$1 [QSA,L]
|
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
|
||||||
|
|
||||||
# In case Cake experiences terminal errors
|
# In case Cake experiences terminal errors
|
||||||
ErrorDocument 500 500.html
|
ErrorDocument 500 500.html
|
||||||
|
|
||||||
|
</IfModule>
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
BODY {
|
||||||
|
font-size:.9em;
|
||||||
|
}
|
||||||
|
|
||||||
|
BODY, INPUT, TEXTAREA {
|
||||||
|
font-family:sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
H1 {
|
||||||
|
font-size:2.1em;
|
||||||
|
text-align:center;
|
||||||
|
}
|
||||||
|
|
||||||
|
H2 {
|
||||||
|
font-size:1.8em;
|
||||||
|
}
|
||||||
|
|
||||||
|
H3 {
|
||||||
|
font-size:1.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
P {
|
||||||
|
font-size:1em;
|
||||||
|
margin-bottom:.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
A {
|
||||||
|
white-space:nowrap;
|
||||||
|
text-decoration:underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
CODE, PRE {
|
||||||
|
font-family:monospace;
|
||||||
|
font-size:1.1em !important;
|
||||||
|
font-size:.95em;
|
||||||
|
color:#44A;
|
||||||
|
margin:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
CODE {
|
||||||
|
color:#227;
|
||||||
|
white-space:nowrap;
|
||||||
|
margin:0 .2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
PRE {
|
||||||
|
margin-left:1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
ACRONYM {
|
||||||
|
border-bottom:1px dotted;
|
||||||
|
}
|
||||||
|
|
||||||
|
HR {
|
||||||
|
height:0;
|
||||||
|
border-top:1px solid #AAA;
|
||||||
|
}
|
|
@ -1,67 +0,0 @@
|
||||||
<?PHP
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
// + $Id$
|
|
||||||
// +------------------------------------------------------------------+ //
|
|
||||||
// + Cake <https://developers.nextco.com/cake/> + //
|
|
||||||
// + Copyright: (c) 2005, Cake 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. + //
|
|
||||||
// + See: http://www.opensource.org/licenses/mit-license.php + //
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Purpose: Dispatch
|
|
||||||
* The main "loop"
|
|
||||||
*
|
|
||||||
* @filesource
|
|
||||||
* @author Cake Authors/Developers
|
|
||||||
* @copyright Copyright (c) 2005, Cake Authors/Developers
|
|
||||||
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
|
|
||||||
* @package cake
|
|
||||||
* @subpackage cake.public
|
|
||||||
* @since Cake v 0.2.9
|
|
||||||
* @version $Revision$
|
|
||||||
* @modifiedby $LastChangedBy$
|
|
||||||
* @lastmodified $Date$
|
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
|
||||||
*/
|
|
||||||
|
|
||||||
session_start();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Cake's root directory
|
|
||||||
*/
|
|
||||||
define ('DS', DIRECTORY_SEPARATOR);
|
|
||||||
define ('ROOT', substr(__FILE__, 0, strrpos(dirname(__FILE__), DS)+1));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Directory layout and basic functions
|
|
||||||
*/
|
|
||||||
require (ROOT.'config/core.php');
|
|
||||||
require (ROOT.'config/paths.php');
|
|
||||||
require (ROOT.'libs/basics.php');
|
|
||||||
|
|
||||||
DEBUG? error_reporting(E_ALL): error_reporting(0);
|
|
||||||
|
|
||||||
$TIME_START = getMicrotime();
|
|
||||||
|
|
||||||
uses ('folder', 'dispatcher', 'dbo_factory');
|
|
||||||
config ('tags', 'database');
|
|
||||||
|
|
||||||
$DB = DboFactory::make('devel');
|
|
||||||
|
|
||||||
loadModels ();
|
|
||||||
|
|
||||||
## RUN THE SCRIPT
|
|
||||||
$url = empty($_GET['url'])? null: $_GET['url'];
|
|
||||||
$DISPATCHER = new Dispatcher ();
|
|
||||||
$DISPATCHER->dispatch($url);
|
|
||||||
|
|
||||||
## CLEANUP
|
|
||||||
if (DEBUG) echo "<!-- ". round(getMicrotime() - $TIME_START, 2) ."s -->";
|
|
||||||
|
|
||||||
?>
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?php
|
<?PHP
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// + $Id$
|
// + $Id$
|
||||||
// +------------------------------------------------------------------+ //
|
// +------------------------------------------------------------------+ //
|
||||||
|
@ -14,24 +14,54 @@
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Purpose: Dispatch
|
||||||
*
|
* The main "loop"
|
||||||
* @filesource
|
*
|
||||||
* @author Cake Authors/Developers
|
* @filesource
|
||||||
* @copyright Copyright (c) 2005, Cake Authors/Developers
|
* @author Cake Authors/Developers
|
||||||
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
|
* @copyright Copyright (c) 2005, Cake Authors/Developers
|
||||||
* @package cake
|
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
|
||||||
* @subpackage cake.public
|
* @package cake
|
||||||
* @since Cake v 0.2.9
|
* @subpackage cake.public
|
||||||
* @version $Revision$
|
* @since Cake v 0.2.9
|
||||||
* @modifiedby $LastChangedBy$
|
* @version $Revision$
|
||||||
* @lastmodified $Date$
|
* @modifiedby $LastChangedBy$
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
* @lastmodified $Date$
|
||||||
*/
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||||
|
*/
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Get Cake's root directory
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
header ('dispatch.php?url='.ltrim($_SERVER['PATH_INFO'],'/'));
|
define ('DS', DIRECTORY_SEPARATOR);
|
||||||
?>
|
define ('ROOT', dirname(dirname(__FILE__)).DS);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Directory layout and basic functions
|
||||||
|
*/
|
||||||
|
require (ROOT.'config/core.php');
|
||||||
|
require (ROOT.'config/paths.php');
|
||||||
|
require (ROOT.'libs/basics.php');
|
||||||
|
|
||||||
|
DEBUG? error_reporting(E_ALL): error_reporting(0);
|
||||||
|
|
||||||
|
$TIME_START = getMicrotime();
|
||||||
|
|
||||||
|
uses ('folder', 'dispatcher', 'dbo_factory');
|
||||||
|
config ('tags', 'database');
|
||||||
|
|
||||||
|
$DB = DboFactory::make('devel');
|
||||||
|
|
||||||
|
loadModels ();
|
||||||
|
|
||||||
|
## RUN THE SCRIPT
|
||||||
|
$url = empty($_GET['url'])? null: $_GET['url'];
|
||||||
|
$DISPATCHER = new Dispatcher ();
|
||||||
|
$DISPATCHER->dispatch($url);
|
||||||
|
|
||||||
|
## CLEANUP
|
||||||
|
if (DEBUG) echo "<!-- ". round(getMicrotime() - $TIME_START, 2) ."s -->";
|
||||||
|
|
||||||
|
?>
|
37
public/index_no_mod_rewrite.php
Normal file
37
public/index_no_mod_rewrite.php
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
<?PHP
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
// + $Id$
|
||||||
|
// +------------------------------------------------------------------+ //
|
||||||
|
// + Cake <https://developers.nextco.com/cake/> + //
|
||||||
|
// + Copyright: (c) 2005, Cake 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. + //
|
||||||
|
// + See: http://www.opensource.org/licenses/mit-license.php + //
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enter description here...
|
||||||
|
*
|
||||||
|
* @filesource
|
||||||
|
* @author Cake Authors/Developers
|
||||||
|
* @copyright Copyright (c) 2005, Cake Authors/Developers
|
||||||
|
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
|
||||||
|
* @package cake
|
||||||
|
* @subpackage cake.public
|
||||||
|
* @since Cake v 0.2.9
|
||||||
|
* @version $Revision$
|
||||||
|
* @modifiedby $LastChangedBy$
|
||||||
|
* @lastmodified $Date$
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Re-routes the request to dispatch.php
|
||||||
|
*/
|
||||||
|
include('dispatch.php')
|
||||||
|
// header ('dispatch.php?url='.ltrim($_SERVER['PATH_INFO'],'/'));
|
||||||
|
?>
|
|
@ -1 +0,0 @@
|
||||||
@php -q scripts/add.php %1 %2 %3 %4 %5 %6 %7 %8 %9
|
|
1
scripts/bake.bat
Normal file
1
scripts/bake.bat
Normal file
|
@ -0,0 +1 @@
|
||||||
|
@php -q add.php %1 %2 %3 %4 %5 %6 %7 %8 %9
|
|
@ -1,48 +1,48 @@
|
||||||
#!/usr/local/bin/php
|
#!/usr/local/bin/php
|
||||||
<?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 + //
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @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.scripts
|
* @subpackage cake.scripts
|
||||||
* @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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* START-UP
|
* START-UP
|
||||||
*/
|
*/
|
||||||
define ('DS', DIRECTORY_SEPARATOR);
|
define ('DS', DIRECTORY_SEPARATOR);
|
||||||
define ('ROOT', substr(__FILE__, 0, strrpos(dirname(__FILE__), DS)+1));
|
define ('ROOT', dirname(dirname(__FILE__)).DS);
|
||||||
|
|
||||||
require (ROOT.'config'.DS.'paths.php');
|
require (ROOT.'config'.DS.'paths.php');
|
||||||
require (LIBS.'basics.php');
|
require (LIBS.'basics.php');
|
||||||
uses ('bake');
|
uses ('bake');
|
||||||
|
|
||||||
$waste = array_shift($argv);
|
$waste = array_shift($argv);
|
||||||
$product = array_shift($argv);
|
$product = array_shift($argv);
|
||||||
|
|
||||||
$bake = new Bake ($product, $argv);
|
$bake = new Bake ($product, $argv);
|
||||||
|
|
||||||
?>
|
?>
|
0
tests/app/helpers/put_helper_tests_here
Normal file
0
tests/app/helpers/put_helper_tests_here
Normal file
0
tests/app/models/put_model_tests_here
Normal file
0
tests/app/models/put_model_tests_here
Normal file
|
@ -26,22 +26,25 @@ class DboFactoryTest extends TestCase {
|
||||||
|
|
||||||
|
|
||||||
function testMake () {
|
function testMake () {
|
||||||
$output = $this->abc->make('test');
|
if (class_exists(DATABASE_CONFIG)) {
|
||||||
$this->assertTrue(is_object($output));
|
|
||||||
|
|
||||||
$config = DATABASE_CONFIG::test();
|
$output = $this->abc->make('test');
|
||||||
if (preg_match('#^(adodb)_.*$#i', $config['driver'], $res)) {
|
$this->assertTrue(is_object($output));
|
||||||
$desired_driver_name = $res[1];
|
|
||||||
|
$config = DATABASE_CONFIG::test();
|
||||||
|
if (preg_match('#^(adodb)_.*$#i', $config['driver'], $res)) {
|
||||||
|
$desired_driver_name = $res[1];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$desired_driver_name = $config['driver'];
|
||||||
|
|
||||||
|
$desired_class_name = 'dbo_'.strtolower($desired_driver_name);
|
||||||
|
$output_class_name = is_object($output)? get_class($output): false;
|
||||||
|
|
||||||
|
$this->assertEquals($output_class_name, $desired_class_name);
|
||||||
|
|
||||||
|
$this->assertTrue($output->connected);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
$desired_driver_name = $config['driver'];
|
|
||||||
|
|
||||||
$desired_class_name = 'dbo_'.strtolower($desired_driver_name);
|
|
||||||
$output_class_name = is_object($output)? get_class($output): false;
|
|
||||||
|
|
||||||
$this->assertEquals($output_class_name, $desired_class_name);
|
|
||||||
|
|
||||||
$this->assertTrue($output->connected);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// this test expect an E_USER_ERROR to occur during it's run
|
// this test expect an E_USER_ERROR to occur during it's run
|
||||||
|
|
|
@ -22,10 +22,14 @@ class DboTest extends TestCase {
|
||||||
// this function is defined in PHPUnit_TestCase and overwritten
|
// this function is defined in PHPUnit_TestCase and overwritten
|
||||||
// here
|
// here
|
||||||
function tearDown() {
|
function tearDown() {
|
||||||
|
if (!$this->abc) return false;
|
||||||
|
|
||||||
$this->dropTemporaryTable();
|
$this->dropTemporaryTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
function createTemporaryTable () {
|
function createTemporaryTable () {
|
||||||
|
if (!$this->abc) return false;
|
||||||
|
|
||||||
if ($this->abc->config['driver'] == 'postgres')
|
if ($this->abc->config['driver'] == 'postgres')
|
||||||
$sql = 'CREATE TABLE __test (id serial NOT NULL, body CHARACTER VARYING(255))';
|
$sql = 'CREATE TABLE __test (id serial NOT NULL, body CHARACTER VARYING(255))';
|
||||||
else
|
else
|
||||||
|
@ -35,10 +39,14 @@ class DboTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
function dropTemporaryTable () {
|
function dropTemporaryTable () {
|
||||||
|
if (!$this->abc) return false;
|
||||||
|
|
||||||
return $this->abc->query("DROP TABLE __test");
|
return $this->abc->query("DROP TABLE __test");
|
||||||
}
|
}
|
||||||
|
|
||||||
function testHasImplementation () {
|
function testHasImplementation () {
|
||||||
|
if (!$this->abc) return false;
|
||||||
|
|
||||||
$functions = array(
|
$functions = array(
|
||||||
'connect',
|
'connect',
|
||||||
'disconnect',
|
'disconnect',
|
||||||
|
@ -59,15 +67,21 @@ class DboTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
function testConnectivity () {
|
function testConnectivity () {
|
||||||
|
if (!$this->abc) return false;
|
||||||
|
|
||||||
$this->assertTrue($this->abc->connected);
|
$this->assertTrue($this->abc->connected);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testFields () {
|
function testFields () {
|
||||||
|
if (!$this->abc) return false;
|
||||||
|
|
||||||
$fields = $this->abc->fields('__test');
|
$fields = $this->abc->fields('__test');
|
||||||
$this->assertEquals(count($fields), 2, 'equals');
|
$this->assertEquals(count($fields), 2, 'equals');
|
||||||
}
|
}
|
||||||
|
|
||||||
function testTables () {
|
function testTables () {
|
||||||
|
if (!$this->abc) return false;
|
||||||
|
|
||||||
$this->assertTrue(in_array('__test', $this->abc->tables()));
|
$this->assertTrue(in_array('__test', $this->abc->tables()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ class FolderTest extends TestCase {
|
||||||
|
|
||||||
function testLs () {
|
function testLs () {
|
||||||
$result = $this->abc->ls();
|
$result = $this->abc->ls();
|
||||||
$expected = array(array('css', 'files', 'img'),array('.htaccess', '500.html', 'dispatch.php'));
|
$expected = array(array('css', 'files', 'img'),array('.htaccess', '500.html', 'index.php', 'index_no_mod_rewrite.php'));
|
||||||
$this->assertEquals($result, $expected);
|
$this->assertEquals($result, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,8 +48,8 @@ class FolderTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
function testFindRecursive () {
|
function testFindRecursive () {
|
||||||
$result = $this->abc->findRecursive('.*\.php');
|
$result = $this->abc->findRecursive('.*ex\.php');
|
||||||
$expected = array(Folder::addPathElement($this->abc->pwd(), 'dispatch.php'));
|
$expected = array(Folder::addPathElement($this->abc->pwd(), 'index.php'));
|
||||||
$this->assertEquals($result, $expected);
|
$this->assertEquals($result, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
0
vendors/put_vendor_libraries_here
vendored
Normal file
0
vendors/put_vendor_libraries_here
vendored
Normal file
Loading…
Add table
Reference in a new issue