mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Commenting is slow. I noticed some under_scored methods in db stuf... Goodnight.
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@141 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
ec0abbaac0
commit
3f7450435a
3 changed files with 420 additions and 384 deletions
156
libs/basics.php
156
libs/basics.php
|
@ -14,7 +14,6 @@
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose: Basics
|
|
||||||
* Basic Cake functionalities.
|
* Basic Cake functionalities.
|
||||||
*
|
*
|
||||||
* @filesource
|
* @filesource
|
||||||
|
@ -32,11 +31,13 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Loads all libs from LIBS directory.
|
||||||
*
|
*
|
||||||
|
* @uses listModules()
|
||||||
|
* @uses LIBS
|
||||||
*/
|
*/
|
||||||
function load_libs () {
|
function loadLibs () {
|
||||||
foreach (list_modules(LIBS) as $lib) {
|
foreach (listModules(LIBS) as $lib) {
|
||||||
if ($lib != 'basics') {
|
if ($lib != 'basics') {
|
||||||
include_once (LIBS.$lib.'.php');
|
include_once (LIBS.$lib.'.php');
|
||||||
}
|
}
|
||||||
|
@ -44,40 +45,47 @@ function load_libs () {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Loads all models.
|
||||||
*
|
*
|
||||||
|
* @uses listModules()
|
||||||
|
* @uses APP
|
||||||
|
* @uses MODELS
|
||||||
*/
|
*/
|
||||||
function load_models () {
|
function loadModels () {
|
||||||
require (APP.'app_model.php');
|
require (APP.'app_model.php');
|
||||||
foreach (list_modules(MODELS) as $model) {
|
foreach (listModules(MODELS) as $model) {
|
||||||
require (MODELS.$model.'.php');
|
require (MODELS.$model.'.php');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Loads all controllers.
|
||||||
*
|
*
|
||||||
|
* @uses APP
|
||||||
|
* @uses listModules()
|
||||||
|
* @uses HELPERS
|
||||||
|
* @uses CONTROLLERS
|
||||||
*/
|
*/
|
||||||
function load_controllers () {
|
function loadControllers () {
|
||||||
require (APP.'app_controller.php');
|
require (APP.'app_controller.php');
|
||||||
|
|
||||||
foreach (list_modules(HELPERS) as $helper) {
|
foreach (listModules(HELPERS) as $helper) {
|
||||||
require (HELPERS.$helper.'.php');
|
require (HELPERS.$helper.'.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (list_modules(CONTROLLERS) as $controller) {
|
foreach (listModules(CONTROLLERS) as $controller) {
|
||||||
require (CONTROLLERS.$controller.'.php');
|
require (CONTROLLERS.$controller.'.php');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Lists all .php files from a given path.
|
||||||
*
|
*
|
||||||
* @param unknown_type $path
|
* @param string $path
|
||||||
* @param unknown_type $sort
|
* @param boolean $sort
|
||||||
* @return unknown
|
* @return array
|
||||||
*/
|
*/
|
||||||
function list_modules($path, $sort=true) {
|
function listModules($path, $sort=true) {
|
||||||
if ($d = opendir($path)) {
|
if ($d = opendir($path)) {
|
||||||
$out = array();
|
$out = array();
|
||||||
$r = null;
|
$r = null;
|
||||||
|
@ -98,29 +106,36 @@ function list_modules($path, $sort=true) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Loads core config.
|
||||||
*
|
*
|
||||||
|
* @uses $TIME_START
|
||||||
|
* @uses CONFIGS
|
||||||
*/
|
*/
|
||||||
function uses_config () {
|
function usesConfig () {
|
||||||
global $TIME_START;
|
global $TIME_START;
|
||||||
|
|
||||||
require (CONFIGS.'core.php');
|
require (CONFIGS.'core.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Loads database connection identified by $level.
|
||||||
*
|
*
|
||||||
|
* @param string $level
|
||||||
|
* @uses $DB
|
||||||
|
* @uses DbFactory::make()
|
||||||
|
* @uses loadDatabaseConfig()
|
||||||
*/
|
*/
|
||||||
function uses_database ($level='devel') {
|
function usesDatabase ($level='devel') {
|
||||||
global $DB;
|
global $DB;
|
||||||
|
|
||||||
$DB = DbFactory::make(loadDatabaseConfig($level));
|
$DB = DbFactory::make(loadDatabaseConfig($level));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Loads database configuration identified by $level from CONFIGS/database.php.
|
||||||
*
|
*
|
||||||
* @return unknown
|
* @param string $level
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
function loadDatabaseConfig ($level='devel') {
|
function loadDatabaseConfig ($level='devel') {
|
||||||
if (file_exists(CONFIGS.'database.php'))
|
if (file_exists(CONFIGS.'database.php'))
|
||||||
|
@ -139,16 +154,23 @@ function loadDatabaseConfig ($level='devel') {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Loads tags configuration from CONFIGS/tags.php.
|
||||||
*
|
*
|
||||||
|
* @uses CONFIGS
|
||||||
*/
|
*/
|
||||||
function uses_tag_generator () {
|
function usesTagGenerator () {
|
||||||
require (CONFIGS.'tags.php');
|
require (CONFIGS.'tags.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Loads component/components from LIBS.
|
||||||
*
|
*
|
||||||
|
* Example:
|
||||||
|
* <code>
|
||||||
|
* uses('inflector', 'object');
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
|
* @uses LIBS
|
||||||
*/
|
*/
|
||||||
function uses () {
|
function uses () {
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
|
@ -158,12 +180,12 @@ function uses () {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Setup a debug point.
|
||||||
*
|
*
|
||||||
* @param unknown_type $var
|
* @param boolean $var
|
||||||
* @param unknown_type $show_html
|
* @param boolean $show_html
|
||||||
*/
|
*/
|
||||||
function debug($var = FALSE, $show_html = false) {
|
function debug($var = false, $show_html = false) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
print "\n<pre>\n";
|
print "\n<pre>\n";
|
||||||
if ($show_html) $var = str_replace('<', '<', str_replace('>', '>', $var));
|
if ($show_html) $var = str_replace('<', '<', str_replace('>', '>', $var));
|
||||||
|
@ -176,9 +198,9 @@ function debug($var = FALSE, $show_html = false) {
|
||||||
if (!function_exists('getMicrotime')) {
|
if (!function_exists('getMicrotime')) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Returns microtime for execution time checking.
|
||||||
*
|
*
|
||||||
* @return unknown
|
* @return integer
|
||||||
*/
|
*/
|
||||||
function getMicrotime() {
|
function getMicrotime() {
|
||||||
list($usec, $sec) = explode(" ", microtime());
|
list($usec, $sec) = explode(" ", microtime());
|
||||||
|
@ -187,13 +209,13 @@ if (!function_exists('getMicrotime')) {
|
||||||
}
|
}
|
||||||
if (!function_exists('sortByKey')) {
|
if (!function_exists('sortByKey')) {
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Sorts given $array by key $sortby.
|
||||||
*
|
*
|
||||||
* @param unknown_type $array
|
* @param array $array
|
||||||
* @param unknown_type $sortby
|
* @param string $sortby
|
||||||
* @param unknown_type $order
|
* @param string $order
|
||||||
* @param unknown_type $type
|
* @param integer $type
|
||||||
* @return unknown
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
function sortByKey(&$array, $sortby, $order='asc', $type=SORT_NUMERIC) {
|
function sortByKey(&$array, $sortby, $order='asc', $type=SORT_NUMERIC) {
|
||||||
|
|
||||||
|
@ -210,21 +232,22 @@ if (!function_exists('sortByKey')) {
|
||||||
foreach( $sa as $key=>$val )
|
foreach( $sa as $key=>$val )
|
||||||
$out[] = $array[$key];
|
$out[] = $array[$key];
|
||||||
|
|
||||||
Return $out;
|
return $out;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!function_exists('array_combine')) {
|
if (!function_exists('array_combine')) {
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Combines given identical arrays by using the first array's values as keys,
|
||||||
|
* and second one's values as values.
|
||||||
*
|
*
|
||||||
* @param unknown_type $a1
|
* @param array $a1
|
||||||
* @param unknown_type $a2
|
* @param array $a2
|
||||||
* @return unknown
|
* @return mixed Outputs either combined array or false.
|
||||||
*/
|
*/
|
||||||
function array_combine($a1, $a2) {
|
function array_combine($a1, $a2) {
|
||||||
$a1 = array_values($a1);
|
$a1 = array_values($a1);
|
||||||
|
@ -235,7 +258,7 @@ if (!function_exists('array_combine')) {
|
||||||
|
|
||||||
$output = array();
|
$output = array();
|
||||||
|
|
||||||
for ($i = 0; $i < count($a1); $i++) {
|
for ($i = 0, $c = count($a1); $i < $c; $i++) {
|
||||||
$output[$a1[$i]] = $a2[$i];
|
$output[$a1[$i]] = $a2[$i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,37 +267,45 @@ if (!function_exists('array_combine')) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Class used for internal manipulation with recordsets (?).
|
||||||
*
|
|
||||||
*
|
*
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.libs
|
* @subpackage cake.libs
|
||||||
* @since Cake v 0.2.9
|
* @since Cake v 0.2.9
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class NeatArray {
|
class NeatArray {
|
||||||
|
/**
|
||||||
|
* Value of NeatArray.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
var $value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param unknown_type $value
|
* @param array $value
|
||||||
* @return NeatArray
|
* @access public
|
||||||
|
* @uses NeatArray::value
|
||||||
*/
|
*/
|
||||||
function NeatArray ($value) {
|
function NeatArray ($value) {
|
||||||
$this->value = $value;
|
$this->value = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Checks wheter $fieldName with $value exists in this NeatArray object.
|
||||||
*
|
*
|
||||||
* @param unknown_type $field_name
|
* @param string $fieldName
|
||||||
* @param unknown_type $value
|
* @param string $value
|
||||||
* @return unknown
|
* @return mixed
|
||||||
|
* @access public
|
||||||
|
* @uses NeatArray::value
|
||||||
*/
|
*/
|
||||||
function findIn ($field_name, $value) {
|
function findIn ($fieldName, $value) {
|
||||||
$out = false;
|
$out = false;
|
||||||
foreach ($this->value as $k=>$v) {
|
foreach ($this->value as $k=>$v) {
|
||||||
if (isset($v[$field_name]) && ($v[$field_name] == $value)) {
|
if (isset($v[$fieldName]) && ($v[$fieldName] == $value)) {
|
||||||
$out[$k] = $v;
|
$out[$k] = $v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -283,13 +314,18 @@ class NeatArray {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Checks if $this->value is array, and removes all empty elements.
|
||||||
*
|
*
|
||||||
|
* @access public
|
||||||
|
* @uses NeatArray::value
|
||||||
*/
|
*/
|
||||||
function cleanup () {
|
function cleanup ()
|
||||||
|
{
|
||||||
$out = is_array($this->value)? array(): null;
|
$out = is_array($this->value)? array(): null;
|
||||||
foreach ($this->value as $k=>$v) {
|
foreach ($this->value as $k=>$v)
|
||||||
if ($v) {
|
{
|
||||||
|
if ($v)
|
||||||
|
{
|
||||||
$out[$k] = $v;
|
$out[$k] = $v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,12 +41,12 @@ require ('../config/paths.php');
|
||||||
require (LIBS.'basics.php');
|
require (LIBS.'basics.php');
|
||||||
|
|
||||||
uses ('dispatcher', 'db_factory');
|
uses ('dispatcher', 'db_factory');
|
||||||
uses_config();
|
usesConfig();
|
||||||
uses_database();
|
usesDatabase();
|
||||||
uses_tag_generator();
|
usesTagGenerator();
|
||||||
|
|
||||||
load_models ();
|
loadModels ();
|
||||||
load_controllers ();
|
loadControllers ();
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue