mirror of
https://github.com/brmlab/brmsklad.git
synced 2025-08-02 22:23:38 +02:00
Upgrade CakePHP from 2.2.5 to 2.9.5
This commit is contained in:
parent
5a580df460
commit
235a541597
793 changed files with 60746 additions and 23753 deletions
|
@ -1,18 +1,18 @@
|
|||
<?php
|
||||
/**
|
||||
* PHP 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @since CakePHP(tm) v2.1
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
/**
|
||||
* ViewBlock implements the concept of Blocks or Slots in the View layer.
|
||||
* Slots or blocks are combined with extending views and layouts to afford slots
|
||||
|
@ -24,7 +24,21 @@
|
|||
class ViewBlock {
|
||||
|
||||
/**
|
||||
* Block content. An array of blocks indexed by name.
|
||||
* Append content
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const APPEND = 'append';
|
||||
|
||||
/**
|
||||
* Prepend content
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const PREPEND = 'prepend';
|
||||
|
||||
/**
|
||||
* Block content. An array of blocks indexed by name.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
|
@ -37,20 +51,53 @@ class ViewBlock {
|
|||
*/
|
||||
protected $_active = array();
|
||||
|
||||
/**
|
||||
* Should the currently captured content be discarded on ViewBlock::end()
|
||||
*
|
||||
* @var bool
|
||||
* @see ViewBlock::end()
|
||||
* @see ViewBlock::startIfEmpty()
|
||||
*/
|
||||
protected $_discardActiveBufferOnEnd = false;
|
||||
|
||||
/**
|
||||
* Start capturing output for a 'block'
|
||||
*
|
||||
* Blocks allow you to create slots or blocks of dynamic content in the layout.
|
||||
* view files can implement some or all of a layout's slots.
|
||||
*
|
||||
* You can end capturing blocks using View::end(). Blocks can be output
|
||||
* You can end capturing blocks using View::end(). Blocks can be output
|
||||
* using View::get();
|
||||
*
|
||||
* @param string $name The name of the block to capture for.
|
||||
* @throws CakeException When starting a block twice
|
||||
* @return void
|
||||
*/
|
||||
public function start($name) {
|
||||
if (in_array($name, $this->_active)) {
|
||||
throw new CakeException(__d('cake', "A view block with the name '%s' is already/still open.", $name));
|
||||
}
|
||||
$this->_active[] = $name;
|
||||
ob_start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Start capturing output for a 'block' if it is empty
|
||||
*
|
||||
* Blocks allow you to create slots or blocks of dynamic content in the layout.
|
||||
* view files can implement some or all of a layout's slots.
|
||||
*
|
||||
* You can end capturing blocks using View::end(). Blocks can be output
|
||||
* using View::get();
|
||||
*
|
||||
* @param string $name The name of the block to capture for.
|
||||
* @return void
|
||||
*/
|
||||
public function start($name) {
|
||||
$this->_active[] = $name;
|
||||
public function startIfEmpty($name) {
|
||||
if (empty($this->_blocks[$name])) {
|
||||
return $this->start($name);
|
||||
}
|
||||
$this->_discardActiveBufferOnEnd = true;
|
||||
ob_start();
|
||||
}
|
||||
|
||||
|
@ -61,6 +108,11 @@ class ViewBlock {
|
|||
* @see ViewBlock::start()
|
||||
*/
|
||||
public function end() {
|
||||
if ($this->_discardActiveBufferOnEnd) {
|
||||
$this->_discardActiveBufferOnEnd = false;
|
||||
ob_end_clean();
|
||||
return;
|
||||
}
|
||||
if (!empty($this->_active)) {
|
||||
$active = end($this->_active);
|
||||
$content = ob_get_clean();
|
||||
|
@ -73,7 +125,36 @@ class ViewBlock {
|
|||
}
|
||||
|
||||
/**
|
||||
* Append to an existing or new block. Appending to a new
|
||||
* Concat content to an existing or new block.
|
||||
* Concating to a new block will create the block.
|
||||
*
|
||||
* Calling concat() without a value will create a new capturing
|
||||
* block that needs to be finished with View::end(). The content
|
||||
* of the new capturing context will be added to the existing block context.
|
||||
*
|
||||
* @param string $name Name of the block
|
||||
* @param mixed $value The content for the block
|
||||
* @param string $mode If ViewBlock::APPEND content will be appended to existing content.
|
||||
* If ViewBlock::PREPEND it will be prepended.
|
||||
* @return void
|
||||
*/
|
||||
public function concat($name, $value = null, $mode = ViewBlock::APPEND) {
|
||||
if (isset($value)) {
|
||||
if (!isset($this->_blocks[$name])) {
|
||||
$this->_blocks[$name] = '';
|
||||
}
|
||||
if ($mode === ViewBlock::PREPEND) {
|
||||
$this->_blocks[$name] = $value . $this->_blocks[$name];
|
||||
} else {
|
||||
$this->_blocks[$name] .= $value;
|
||||
}
|
||||
} else {
|
||||
$this->start($name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Append to an existing or new block. Appending to a new
|
||||
* block will create the block.
|
||||
*
|
||||
* Calling append() without a value will create a new capturing
|
||||
|
@ -83,51 +164,48 @@ class ViewBlock {
|
|||
* @param string $name Name of the block
|
||||
* @param string $value The content for the block.
|
||||
* @return void
|
||||
* @throws CakeException when you use non-string values.
|
||||
* @deprecated 3.0.0 As of 2.3 use ViewBlock::concat() instead.
|
||||
*/
|
||||
public function append($name, $value = null) {
|
||||
if (isset($value)) {
|
||||
if (!is_string($value)) {
|
||||
throw new CakeException(__d('cake_dev', '$value must be a string.'));
|
||||
}
|
||||
if (!isset($this->_blocks[$name])) {
|
||||
$this->_blocks[$name] = '';
|
||||
}
|
||||
$this->_blocks[$name] .= $value;
|
||||
} else {
|
||||
$this->start($name);
|
||||
}
|
||||
$this->concat($name, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the content for a block. This will overwrite any
|
||||
* Set the content for a block. This will overwrite any
|
||||
* existing content.
|
||||
*
|
||||
* @param string $name Name of the block
|
||||
* @param string $value The content for the block.
|
||||
* @param mixed $value The content for the block.
|
||||
* @return void
|
||||
* @throws CakeException when you use non-string values.
|
||||
*/
|
||||
public function set($name, $value) {
|
||||
if (!is_string($value)) {
|
||||
throw new CakeException(__d('cake_dev', 'Blocks can only contain strings.'));
|
||||
}
|
||||
$this->_blocks[$name] = $value;
|
||||
$this->_blocks[$name] = (string)$value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the content for a block.
|
||||
*
|
||||
* @param string $name Name of the block
|
||||
* @return The block content or '' if the block does not exist.
|
||||
* @param string $default Default string
|
||||
* @return string The block content or $default if the block does not exist.
|
||||
*/
|
||||
public function get($name) {
|
||||
public function get($name, $default = '') {
|
||||
if (!isset($this->_blocks[$name])) {
|
||||
return '';
|
||||
return $default;
|
||||
}
|
||||
return $this->_blocks[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a block exists
|
||||
*
|
||||
* @param string $name Name of the block
|
||||
* @return bool
|
||||
*/
|
||||
public function exists($name) {
|
||||
return isset($this->_blocks[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the names of all the existing blocks.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue