mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Some changes to allow calling a method from another controller in the view.
helpers can now use this like a url to get methods return value: $helpername->renderMethod('/controller/action/param/'); Refactored dispatcher. Adding bug fix by nate in [894] [896] Added extra param View::renderMethod() Fixed bug related to #72, #111, #113, #209 Some of those tickets where closed as duplicates already git-svn-id: https://svn.cakephp.org/repo/trunk/cake@900 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
1a93ab942f
commit
5f1d672d5e
4 changed files with 23 additions and 9 deletions
|
@ -129,6 +129,22 @@ class Helper extends Object
|
||||||
$this->tags[$keyName]);
|
$this->tags[$keyName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Allow calling a controllers method from a helper
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param unknown_type $url
|
||||||
|
* @param unknown_type $extra
|
||||||
|
* @return unknown
|
||||||
|
*/
|
||||||
|
function renderMethod ($url, $extra = false)
|
||||||
|
{
|
||||||
|
$dispatcher = new Dispatcher();
|
||||||
|
return $dispatcher->dispatch($url, array('bare'=>1));
|
||||||
|
}
|
||||||
|
|
||||||
function readConfigFile ($fileName)
|
function readConfigFile ($fileName)
|
||||||
{
|
{
|
||||||
$fileLineArray = file($fileName);
|
$fileLineArray = file($fileName);
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
* @subpackage cake.libs.helpers
|
* @subpackage cake.libs.helpers
|
||||||
* @since CakePHP v 0.9.2
|
* @since CakePHP v 0.9.2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class JavascriptHelper extends Helper
|
class JavascriptHelper extends Helper
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -53,14 +54,15 @@ class JavascriptHelper extends Helper
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a JavaScript include tag (LINK element)
|
* Returns a JavaScript include tag (SCRIPT element)
|
||||||
*
|
*
|
||||||
* @param string $url URL to JavaScript file.
|
* @param string $url URL to JavaScript file.
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function link($url)
|
function link($url)
|
||||||
{
|
{
|
||||||
return sprintf($this->tags['javascriptlink'], $this->base.$url);
|
if(strpos($url, ".") === false) $url .= ".js";
|
||||||
|
return sprintf($this->tags['javascriptlink'], $this->base . JS_URL . $url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,6 +73,7 @@ class JavascriptHelper extends Helper
|
||||||
*/
|
*/
|
||||||
function linkOut($url)
|
function linkOut($url)
|
||||||
{
|
{
|
||||||
|
if(strpos($url, ".") === false) $url .= ".js";
|
||||||
return sprintf($this->tags['javascriptlink'], $url);
|
return sprintf($this->tags['javascriptlink'], $url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1270,8 +1270,8 @@ class Model extends Object
|
||||||
$joins = count($joins)? join(' ', $joins): null;
|
$joins = count($joins)? join(' ', $joins): null;
|
||||||
$whers = count($whers)? '('.join(' AND ', $whers).')': null;
|
$whers = count($whers)? '('.join(' AND ', $whers).')': null;
|
||||||
$conditions .= ($conditions && $whers? ' AND ': null).$whers;
|
$conditions .= ($conditions && $whers? ' AND ': null).$whers;
|
||||||
|
|
||||||
$offset = $page > 1? $page*$limit: 0;
|
$offset = $page > 1? ($page-1) * $limit: 0;
|
||||||
|
|
||||||
$limit_str = $limit
|
$limit_str = $limit
|
||||||
? $this->db->selectLimit($limit, $offset)
|
? $this->db->selectLimit($limit, $offset)
|
||||||
|
|
|
@ -553,11 +553,6 @@ class View extends Object
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetch ($url)
|
|
||||||
{
|
|
||||||
$dispatcher = new Dispatcher();
|
|
||||||
return $dispatcher->dispatch($url, array('bare'=>1));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Reference in a new issue