re syncing all sandboxes and updated trunk with all the latest changes

git-svn-id: https://svn.cakephp.org/repo/trunk/cake@634 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2005-08-22 04:15:57 +00:00
parent 650c85809a
commit 184e0d06e8
7 changed files with 456 additions and 465 deletions

View file

@ -3,7 +3,9 @@
<head> <head>
<title><?=$page_title?></title> <title><?=$page_title?></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<?php if(DEBUG == 0) { ?>
<meta http-equiv="Refresh" content="<?=$time?>;url=<?=$url?>" /> <meta http-equiv="Refresh" content="<?=$time?>;url=<?=$url?>" />
<?php } ?>
<style><!-- <style><!--
P { text-align:center; font:bold 1.1em sans-serif } P { text-align:center; font:bold 1.1em sans-serif }
A { color:#444; text-decoration:none } A { color:#444; text-decoration:none }

View file

@ -138,6 +138,8 @@ class Folder extends Object {
sort($files); sort($files);
} }
closedir($dir);
return array($dirs,$files); return array($dirs,$files);
} }
else else

View file

@ -49,416 +49,423 @@ uses('helpers/html', 'helpers/javascript');
class AjaxHelper extends Helper class AjaxHelper extends Helper
{ {
/** /**
* Returns link to remote action * Returns link to remote action
* *
* Returns a link to a remote action defined by <i>options[url]</i> * Returns a link to a remote action defined by <i>options[url]</i>
* (using the urlFor format) that's called in the background using * (using the urlFor format) that's called in the background using
* XMLHttpRequest. The result of that request can then be inserted into a * XMLHttpRequest. The result of that request can then be inserted into a
* DOM object whose id can be specified with <i>options[update]</i>. * DOM object whose id can be specified with <i>options[update]</i>.
* Usually, the result would be a partial prepared by the controller with * Usually, the result would be a partial prepared by the controller with
* either renderPartial or renderPartialCollection. * either renderPartial or renderPartialCollection.
* *
* Examples: * Examples:
* <code> * <code>
* linkToRemote("Delete this post", * linkToRemote("Delete this post",
* array("update" => "posts", "url" => "delete/{$postid->id}")); * array("update" => "posts", "url" => "delete/{$postid->id}"));
* linkToRemote(imageTag("refresh"), * linkToRemote(imageTag("refresh"),
* array("update" => "emails", "url" => "list_emails" )); * array("update" => "emails", "url" => "list_emails" ));
* </code> * </code>
* *
* By default, these remote requests are processed asynchronous during * By default, these remote requests are processed asynchronous during
* which various callbacks can be triggered (for progress indicators and * which various callbacks can be triggered (for progress indicators and
* the likes). * the likes).
* *
* Example: * Example:
* <code> * <code>
* linkToRemote (word, * linkToRemote (word,
* array("url" => "undo", "n" => word_counter), * array("url" => "undo", "n" => word_counter),
* array("complete" => "undoRequestCompleted(request)")); * array("complete" => "undoRequestCompleted(request)"));
* </code> * </code>
* *
* The callbacks that may be specified are: * The callbacks that may be specified are:
* *
* - <i>loading</i>:: Called when the remote document is being * - <i>loading</i>:: Called when the remote document is being
* loaded with data by the browser. * loaded with data by the browser.
* - <i>loaded</i>:: Called when the browser has finished loading * - <i>loaded</i>:: Called when the browser has finished loading
* the remote document. * the remote document.
* - <i>interactive</i>:: Called when the user can interact with the * - <i>interactive</i>:: Called when the user can interact with the
* remote document, even though it has not * remote document, even though it has not
* finished loading. * finished loading.
* - <i>complete</i>:: Called when the XMLHttpRequest is complete. * - <i>complete</i>:: Called when the XMLHttpRequest is complete.
* *
* If you for some reason or another need synchronous processing (that'll * If you for some reason or another need synchronous processing (that'll
* block the browser while the request is happening), you can specify * block the browser while the request is happening), you can specify
* <i>options[type] = synchronous</i>. * <i>options[type] = synchronous</i>.
* *
* You can customize further browser side call logic by passing * You can customize further browser side call logic by passing
* in Javascript code snippets via some optional parameters. In * in Javascript code snippets via some optional parameters. In
* their order of use these are: * their order of use these are:
* *
* - <i>confirm</i>:: Adds confirmation dialog. * - <i>confirm</i>:: Adds confirmation dialog.
* -<i>condition</i>:: Perform remote request conditionally * -<i>condition</i>:: Perform remote request conditionally
* by this expression. Use this to * by this expression. Use this to
* describe browser-side conditions when * describe browser-side conditions when
* request should not be initiated. * request should not be initiated.
* - <i>before</i>:: Called before request is initiated. * - <i>before</i>:: Called before request is initiated.
* - <i>after</i>:: Called immediately after request was * - <i>after</i>:: Called immediately after request was
* initiated and before <i>loading</i>. * initiated and before <i>loading</i>.
* *
* @param HtmlHelper $html The HtmlHelper object which is creating link. * @param HtmlHelper $html The HtmlHelper object which is creating link.
* @param string $title title of link * @param string $title title of link
* @param array $options options for javascript function * @param array $options options for javascript function
* @param array $html_options options for link * @param array $html_options options for link
* @return string html code for link to remote action * @return string html code for link to remote action
*/ */
function linkToRemote ($html, $title, $options = null, $html_options = null) { function linkToRemote ($html, $title, $options = null, $html_options = null) {
return $html->link($title, $this->remoteFunction($html, $options), $html_options); // mouse click should call our remote function
} $html_options['onclick'] = $this->remoteFunction($html, $options);
/** // generate actual link
* Creates javascript function for remote AJAX call return $html->link($title, '#', $html_options);
* }
* This function creates the javascript needed to make a remote call
* it is primarily used as a helper for linkToRemote.
*
* @see linkToRemote() for docs on options parameter.
*
* @param array $options options for javascript
* @return string html code for link to remote action
*/
function remoteFunction ($html, $options = null) {
$javascript_options = $this->__optionsForAjax($options);
$func = isset($options['update']) ? "new Ajax.Updater('{$options['update']}', " : "new Ajax.Request(";
$func .= "'" . $html->url(isset($options['url']) ? $options['url'] : "") . "'"; /**
$func .= ", $javascript_options)"; * Creates javascript function for remote AJAX call
*
* This function creates the javascript needed to make a remote call
* it is primarily used as a helper for linkToRemote.
*
* @see linkToRemote() for docs on options parameter.
*
* @param array $options options for javascript
* @return string html code for link to remote action
*/
function remoteFunction ($html, $options = null) {
$javascript_options = $this->__optionsForAjax($options);
$func = isset($options['update']) ? "new Ajax.Updater('{$options['update']}', " : "new Ajax.Request(";
if (isset($options['before'])) { $func .= "'" . $html->url(isset($options['url']) ? $options['url'] : "") . "'";
$func .= "{$options['before']}; $function"; $func .= ", $javascript_options)";
}
if (isset($options['after'])) {
$func .= "$func; {$options['before']};";
}
if (isset($options['condition'])) {
$func .= "if ({$options['condition']}) { $func; }";
}
if (isset($options['confirm'])) {
$func .= "if (confirm('" . $this->escapeScript($options['confirm']) . "')) { $func; }";
}
return $func;
}
/** if (isset($options['before'])) {
* Periodically call remote url via AJAX. $func .= "{$options['before']}; $function";
* }
* Periodically calls the specified url (<i>options[url]</i>) every <i>options[frequency]</i> seconds (default is 10). if (isset($options['after'])) {
* Usually used to update a specified div (<i>options[update]</i>) with the results of the remote call. $func .= "$func; {$options['before']};";
* The options for specifying the target with url and defining callbacks is the same as linkToRemote. }
* if (isset($options['condition'])) {
* @param JavascriptHelper $script script helper generating the block $func .= "if ({$options['condition']}) { $func; }";
* @param array $options callback options }
* @return string javascript code if (isset($options['confirm'])) {
*/ $func .= "if (confirm('" . $this->escapeScript($options['confirm']) . "')) { $func; }";
function remoteTimer ($script, $options = null) }
{ return $func;
$frequency = (isset($options['frequency']))? $options['frequency'] : 10; }
$code = "new PeriodicalExecuter(function() {" . $this->remote_function($options) . "}, $frequency)";
return $script->codeBlock($code);
}
/** /**
* Returns form tag that will submit using Ajax. * Periodically call remote url via AJAX.
* *
* Returns a form tag that will submit using XMLHttpRequest in the background instead of the regular * Periodically calls the specified url (<i>options[url]</i>) every <i>options[frequency]</i> seconds (default is 10).
* reloading POST arrangement. Even though it's using Javascript to serialize the form elements, the form submission * Usually used to update a specified div (<i>options[update]</i>) with the results of the remote call.
* will work just like a regular submission as viewed by the receiving side (all elements available in params). * The options for specifying the target with url and defining callbacks is the same as linkToRemote.
* The options for specifying the target with :url and defining callbacks is the same as link_to_remote. *
* * @param JavascriptHelper $script script helper generating the block
* @param HtmlHelper $html HtmlHelper creating this form * @param array $options callback options
* @param JavascriptHelper $script JavascriptHelper creating this form * @return string javascript code
* @param string $id form id */
* @param array $options callback options function remoteTimer ($script, $options = null)
* @return string javascript code {
*/ $frequency = (isset($options['frequency']))? $options['frequency'] : 10;
function form ($html, $script, $id, $options = null) { $code = "new PeriodicalExecuter(function() {" . $this->remote_function($options) . "}, $frequency)";
$options['form'] = true; return $script->codeBlock($code);
$options['html']['id'] = $id; }
//$options['html']['onsubmit'] = $this->remoteFunction($options) . "; return false;";
return $html->formTag(null, "post", $options) . $script->event("$('$id')", "submit", "function(){" . $this->remoteFunction($options) . "; return false;}");
}
/** /**
* Returns a button input tag that will submit using Ajax * Returns form tag that will submit using Ajax.
* *
* Returns a button input tag that will submit form using XMLHttpRequest in the background instead of regular * Returns a form tag that will submit using XMLHttpRequest in the background instead of the regular
* reloading POST arrangement. <i>options</i> argument is the same as in <i>form_remote_tag</i> * reloading POST arrangement. Even though it's using Javascript to serialize the form elements, the form submission
* * will work just like a regular submission as viewed by the receiving side (all elements available in params).
* @param HtmlHelper $html * The options for specifying the target with :url and defining callbacks is the same as link_to_remote.
* @param string $name input button name *
* @param string $value input button value * @param HtmlHelper $html HtmlHelper creating this form
* @param array $options callback options * @param JavascriptHelper $script JavascriptHelper creating this form
* @return string ajaxed input button * @param string $id form id
*/ * @param array $options callback options
function submit ($html, $name, $value, $options = null) * @return string javascript code
{ */
$options['with'] = 'Form.serialize(this.form)'; function form ($html, $script, $id, $options = null) {
$options['html']['type'] = 'button'; $options['form'] = true;
$options['html']['onclick'] = $this->remoteFunction($html, $options) . "; return false;"; $options['html']['id'] = $id;
$options['html']['name'] = $name; //$options['html']['onsubmit'] = $this->remoteFunction($options) . "; return false;";
$options['html']['value'] = $value; return $html->formTag(null, "post", $options) . $script->event("$('$id')", "submit", "function(){" . $this->remoteFunction($options) . "; return false;}");
return $html->tag("input", $options['html'], false); }
}
/** /**
* Observe field and call ajax on change. * Returns a button input tag that will submit using Ajax
* *
* Observes the field with the DOM ID specified by <i>field_id</i> and makes * Returns a button input tag that will submit form using XMLHttpRequest in the background instead of regular
* an Ajax when its contents have changed. * reloading POST arrangement. <i>options</i> argument is the same as in <i>form_remote_tag</i>
* *
* Required +options+ are: * @param HtmlHelper $html
* - <i>frequency</i>:: The frequency (in seconds) at which changes to * @param string $name input button name
* this field will be detected. * @param string $value input button value
* - <i>url</i>:: @see urlFor() -style options for the action to call * @param array $options callback options
* when the field has changed. * @return string ajaxed input button
* */
* Additional options are: function submit ($html, $name, $value, $options = null)
* - <i>update</i>:: Specifies the DOM ID of the element whose {
* innerHTML should be updated with the $options['with'] = 'Form.serialize(this.form)';
* XMLHttpRequest response text. $options['html']['type'] = 'button';
* - <i>with</i>:: A Javascript expression specifying the $options['html']['onclick'] = $this->remoteFunction($html, $options) . "; return false;";
* parameters for the XMLHttpRequest. This defaults $options['html']['name'] = $name;
* to Form.Element.serialize('$field_id'), which can be $options['html']['value'] = $value;
* accessed from params['form']['field_id']. return $html->tag("input", $options['html'], false);
* }
* Additionally, you may specify any of the options documented in
* @see linkToRemote().
*
* @param JavaScriptHelper $script
* @param string $field_id DOM ID of field to observe
* @param array $options ajax options
* @return string ajax script
*/
function observeField ($html, $script, $field_id, $options = null) {
if (!isset($options['with'])) {
$options['with'] = "Form.Element.serialize('$field_id')";
}
return $script->codeBlock($this->__buildObserver($html, 'Form.Element.Observer', $field_id, $options));
}
/** /**
* Observe entire form and call ajax on change. * Observe field and call ajax on change.
* *
* Like @see observeField(), but operates on an entire form identified by the * Observes the field with the DOM ID specified by <i>field_id</i> and makes
* DOM ID <b>form_id</b>. <b>options</b> are the same as <b>observe_field</b>, except * an Ajax when its contents have changed.
* the default value of the <i>with</i> option evaluates to the *
* serialized (request string) value of the form. * Required +options+ are:
* * - <i>frequency</i>:: The frequency (in seconds) at which changes to
* @param JavaScriptHelper $script * this field will be detected.
* @param string $field_id DOM ID of field to observe * - <i>url</i>:: @see urlFor() -style options for the action to call
* @param array $options ajax options * when the field has changed.
* @return string ajax script *
*/ * Additional options are:
function observeForm ($html, $script, $field_id, $options = array()) { * - <i>update</i>:: Specifies the DOM ID of the element whose
if (!isset($options['with'])) { * innerHTML should be updated with the
$options['with'] = 'Form.serialize(this.form)'; * XMLHttpRequest response text.
} * - <i>with</i>:: A Javascript expression specifying the
return $script->codeBlock($this->__buildObserver($html, 'Form.Observer', $field_id, $options)); * parameters for the XMLHttpRequest. This defaults
} * to Form.Element.serialize('$field_id'), which can be
* accessed from params['form']['field_id'].
*
* Additionally, you may specify any of the options documented in
* @see linkToRemote().
*
* @param JavaScriptHelper $script
* @param string $field_id DOM ID of field to observe
* @param array $options ajax options
* @return string ajax script
*/
function observeField ($html, $script, $field_id, $options = null) {
if (!isset($options['with'])) {
$options['with'] = "Form.Element.serialize('$field_id')";
}
return $script->codeBlock($this->__buildObserver($html, 'Form.Element.Observer', $field_id, $options));
}
/** /**
* Create a text field with Autocomplete. * Observe entire form and call ajax on change.
* *
* Creates an autocomplete field with the given ID and options * Like @see observeField(), but operates on an entire form identified by the
* * DOM ID <b>form_id</b>. <b>options</b> are the same as <b>observe_field</b>, except
* options['with'] defaults to "Form.Element.serialize('$field_id')", * the default value of the <i>with</i> option evaluates to the
* but can be any valid javascript expression defining the * serialized (request string) value of the form.
* *
* @param HtmlHelper $html * @param JavaScriptHelper $script
* @param JavascriptHelper $script * @param string $field_id DOM ID of field to observe
* @param string $field_id DOM ID of field to observe * @param array $options ajax options
* @param array $options ajax options * @return string ajax script
* @return string ajax script */
*/ function observeForm ($html, $script, $field_id, $options = array()) {
function autoComplete ($html, $script, $field, $url = "", $options = array()) if (!isset($options['with'])) {
{ $options['with'] = 'Form.serialize(this.form)';
if (!isset($options['id'])) { }
$options['id'] = str_replace("/", "_", $field); return $script->codeBlock($this->__buildObserver($html, 'Form.Observer', $field_id, $options));
} }
$htmlOptions = $options; /**
$ajaxOptions = array('with', 'asynchronous', 'synchronous', 'method', 'position', 'form'); * Create a text field with Autocomplete.
foreach($ajaxOptions as $key) { *
if(isset($htmlOptions[$key])) { * Creates an autocomplete field with the given ID and options
unset($htmlOptions[$key]); *
} * options['with'] defaults to "Form.Element.serialize('$field_id')",
} * but can be any valid javascript expression defining the
$htmlOptions['autocomplete'] = "off"; *
* @param HtmlHelper $html
* @param JavascriptHelper $script
* @param string $field_id DOM ID of field to observe
* @param array $options ajax options
* @return string ajax script
*/
function autoComplete ($html, $script, $field, $url = "", $options = array())
{
if (!isset($options['id'])) {
$options['id'] = str_replace("/", "_", $field);
}
foreach($ajaxOptions as $key) { $htmlOptions = $options;
if(isset($options[$key])) { $ajaxOptions = array('with', 'asynchronous', 'synchronous', 'method', 'position', 'form');
$ajaxOptions[$key] = $options[$key]; foreach($ajaxOptions as $key) {
} else { if(isset($htmlOptions[$key])) {
unset($ajaxOptions[$key]); unset($htmlOptions[$key]);
} }
} }
$htmlOptions['autocomplete'] = "off";
$divOptions = array('id' => $options['id'] . "_autoComplete", 'class' => "auto_complete"); foreach($ajaxOptions as $key) {
return $html->input($field, $htmlOptions) . if(isset($options[$key])) {
$html->tag("div", $divOptions, true) . "</div>" . $ajaxOptions[$key] = $options[$key];
$script->codeBlock("new Ajax.Autocompleter('" . $options['id'] . "', '" . $divOptions['id'] . "', '" . $html->url($url) . "', " . $this->__optionsForAjax($ajaxOptions) . ");"); } else {
} unset($ajaxOptions[$key]);
}
}
function drag($script, $id, $options = array()) $divOptions = array('id' => $options['id'] . "_autoComplete", 'class' => "auto_complete");
{ return $html->input($field, $htmlOptions) .
return $script->codeBlock("new Draggable('$id', " . $this->__optionsForDraggable($options) . ");"); $html->tag("div", $divOptions, true) . "</div>" .
} $script->codeBlock("new Ajax.Autocompleter('" . $options['id'] . "', '" . $divOptions['id'] . "', '" . $html->url($url) . "', " . $this->__optionsForAjax($ajaxOptions) . ");");
}
/** /**
* For a reference on the options for this function, check out *
* http://wiki.script.aculo.us/scriptaculous/show/Droppables.add */
* function drag($script, $id, $options = array())
*/ {
function drop($html, $script, $id, $options = array()) return $script->codeBlock("new Draggable('$id', " . $this->__optionsForDraggable($options) . ");");
{ }
return $script->codeBlock("Droppables.add('$id', " . $this->__optionsForDroppable($options) . ");");
} /**
* For a reference on the options for this function, check out
* http://wiki.script.aculo.us/scriptaculous/show/Droppables.add
*
*/
function drop($html, $script, $id, $options = array())
{
return $script->codeBlock("Droppables.add('$id', " . $this->__optionsForDroppable($options) . ");");
}
function dropRemote($html, $script, $id, $options = array(), $ajaxOptions = array()) function dropRemote($html, $script, $id, $options = array(), $ajaxOptions = array())
{ {
$options['onDrop'] = "function(element){" . $this->remoteFunction($html, $ajaxOptions) . "}"; $options['onDrop'] = "function(element){" . $this->remoteFunction($html, $ajaxOptions) . "}";
} }
function __optionsForDraggable ($options) function __optionsForDraggable ($options)
{ {
$opts = array("handle" => "", "revert" => "true", "constraint" => "", "change" => ""); $opts = array("handle" => "", "revert" => "true", "constraint" => "", "change" => "");
foreach($opts as $key => $val) { foreach($opts as $key => $val) {
if(isset($options[$key])) { if(isset($options[$key])) {
$opts[$key] = $options[$key]; $opts[$key] = $options[$key];
} else { } else {
if($val == "") { unset($opts[$key]); } if($val == "") { unset($opts[$key]); }
} }
} }
if(isset($opts['handle'])) { $opts['handle'] = "'" . $opts['handle'] . "'"; } if(isset($opts['handle'])) { $opts['handle'] = "'" . $opts['handle'] . "'"; }
if(isset($opts['constraint'])) { $opts['constraint'] = "'" . $opts['constraint'] . "'"; } if(isset($opts['constraint'])) { $opts['constraint'] = "'" . $opts['constraint'] . "'"; }
$out = array(); $out = array();
foreach ($opts as $k => $v) foreach ($opts as $k => $v)
{ {
$out[] = "$k:$v"; $out[] = "$k:$v";
} }
$out = join(', ', $out); $out = join(', ', $out);
$out = '{' . $out . '}'; $out = '{' . $out . '}';
return $out; return $out;
} }
function __optionsForDroppable ($options) function __optionsForDroppable ($options)
{ {
$opts = array("accept" => "", "containment" => "", "overlap" => "", "greedy" => "", "hoverclass" => "", "onHover" => "", "onDrop" => ""); $opts = array("accept" => "", "containment" => "", "overlap" => "", "greedy" => "", "hoverclass" => "", "onHover" => "", "onDrop" => "");
foreach($opts as $key => $val) { foreach($opts as $key => $val) {
if(isset($options[$key])) { if(isset($options[$key])) {
$opts[$key] = $options[$key]; $opts[$key] = $options[$key];
} else { } else {
if($val == "") { unset($opts[$key]); } if($val == "") { unset($opts[$key]); }
} }
} }
if(isset($opts['accept'])) { $opts['accept'] = "'" . $opts['accept'] . "'"; } if(isset($opts['accept'])) { $opts['accept'] = "'" . $opts['accept'] . "'"; }
if(isset($opts['overlap'])) { $opts['overlap'] = "'" . $opts['overlap'] . "'"; } if(isset($opts['overlap'])) { $opts['overlap'] = "'" . $opts['overlap'] . "'"; }
if(isset($opts['hoverclass'])) { $opts['hoverclass'] = "'" . $opts['hoverclass'] . "'"; } if(isset($opts['hoverclass'])) { $opts['hoverclass'] = "'" . $opts['hoverclass'] . "'"; }
$out = array(); $out = array();
foreach ($opts as $k => $v) foreach ($opts as $k => $v)
{ {
$out[] = "$k:$v"; $out[] = "$k:$v";
} }
$out = join(', ', $out); $out = join(', ', $out);
$out = '{' . $out . '}'; $out = '{' . $out . '}';
return $out; return $out;
} }
/** /**
* Javascript helper function (private). * Javascript helper function (private).
* *
*/ */
function __optionsForAjax ($options) function __optionsForAjax ($options)
{ {
$js_options = $this->__buildCallbacks($options); $js_options = $this->__buildCallbacks($options);
$js_options['asynchronous'] = 'true'; $js_options['asynchronous'] = 'true';
if (isset($options['type'])) { if (isset($options['type'])) {
if ($options['type'] == 'synchronous') { if ($options['type'] == 'synchronous') {
$js_options['asynchronous'] = 'false'; $js_options['asynchronous'] = 'false';
} }
} }
if (isset($options['method'])) { if (isset($options['method'])) {
$js_options['method'] = $this->__methodOptionToString($options['method']); $js_options['method'] = $this->__methodOptionToString($options['method']);
} }
if (isset($options['position'])) { if (isset($options['position'])) {
$js_options['insertion'] = "Insertion." . Inflector::camelize($options['position']); $js_options['insertion'] = "Insertion." . Inflector::camelize($options['position']);
} }
if (isset($options['form'])) { if (isset($options['form'])) {
$js_options['parameters'] = 'Form.serialize(this)'; $js_options['parameters'] = 'Form.serialize(this)';
} elseif (isset($options['with'])) { } elseif (isset($options['with'])) {
$js_options['parameters'] = $options['with']; $js_options['parameters'] = $options['with'];
} }
if (isset($options['evalScripts'])) { if (isset($options['evalScripts'])) {
$js_options['evalScripts'] = "true"; $js_options['evalScripts'] = "true";
} else { } else {
$js_options['evalScripts'] = "false"; $js_options['evalScripts'] = "false";
} }
$out = array(); $out = array();
foreach ($js_options as $k => $v) foreach ($js_options as $k => $v)
{ {
$out[] = "$k:$v"; $out[] = "$k:$v";
} }
$out = join(', ', $out); $out = join(', ', $out);
$out = '{' . $out . '}'; $out = '{' . $out . '}';
return $out; return $out;
} }
function __methodOptionToString ($method) function __methodOptionToString ($method)
{ {
return (is_string($method) && !$method[0]=="'") ? $method : "'$method'"; return (is_string($method) && !$method[0]=="'") ? $method : "'$method'";
} }
function __buildObserver ($html, $klass, $name, $options=null) function __buildObserver ($html, $klass, $name, $options=null)
{ {
if(!isset($options['with']) && isset($options['update'])) if(!isset($options['with']) && isset($options['update']))
{ {
$options['with'] = 'value'; $options['with'] = 'value';
} }
$callback = $this->remoteFunction($html, $options); $callback = $this->remoteFunction($html, $options);
$javascript = "new $klass('$name', "; $javascript = "new $klass('$name', ";
$javascript .= (isset($options['frequency']) ? $options['frequency'] : 2) . ", function(element, value) {"; $javascript .= (isset($options['frequency']) ? $options['frequency'] : 2) . ", function(element, value) {";
$javascript .= "$callback})"; $javascript .= "$callback})";
return $javascript; return $javascript;
} }
function __buildCallbacks($options) function __buildCallbacks($options)
{ {
$actions = array('uninitialized', 'loading', 'loaded', 'interactive', 'complete'); $actions = array('uninitialized', 'loading', 'loaded', 'interactive', 'complete');
$callbacks = array(); $callbacks = array();
foreach($actions as $callback) foreach($actions as $callback)
{ {
if(isset($options[$callback])) if(isset($options[$callback]))
{ {
$name = 'on' . ucfirst($callback); $name = 'on' . ucfirst($callback);
$code = $options[$callback]; $code = $options[$callback];
$callbacks[$name] = "function(request){".$code."}"; $callbacks[$name] = "function(request){".$code."}";
} }
} }
return $callbacks; return $callbacks;
} }
} }

View file

@ -311,7 +311,7 @@ class HtmlHelper extends Helper
$this->setFormTag($fieldName); $this->setFormTag($fieldName);
$this->tagValue($fieldName)? $htmlAttributes['checked'] = 'checked': null; $this->tagValue($fieldName)? $htmlAttributes['checked'] = 'checked': null;
$title = $title? $title: ucfirst($fieldName); $title = $title? $title: ucfirst($fieldName);
return $this->output(sprintf(TAG_CHECKBOX, $this->model, $this->field, return $this->output(sprintf($this->tags['checkbox'], $this->model, $this->field,
$this->field, $this->field, $this->field, $this->field,
$this->_parseAttributes($htmlAttributes, null, '', ' '), $title), $return); $this->_parseAttributes($htmlAttributes, null, '', ' '), $title), $return);
} }
@ -347,7 +347,7 @@ class HtmlHelper extends Helper
*/ */
function file($fieldName, $htmlAttributes = null, $return = false) function file($fieldName, $htmlAttributes = null, $return = false)
{ {
return $this->output(sprintf(TAG_FILE, $fieldName, return $this->output(sprintf($this->tags['file'], $fieldName,
$this->_parseAttributes($htmlAttributes, null, '', ' ')), $return); $this->_parseAttributes($htmlAttributes, null, '', ' ')), $return);
} }
@ -470,7 +470,7 @@ class HtmlHelper extends Helper
$opt_value==$value? $options_here['checked'] = 'checked': null; $opt_value==$value? $options_here['checked'] = 'checked': null;
$parsed_options = $this->parseHtmlOptions(array_merge($htmlAttributes, $options_here), null, '', ' '); $parsed_options = $this->parseHtmlOptions(array_merge($htmlAttributes, $options_here), null, '', ' ');
$individual_tag_name = "{$this->field}_{$opt_value}"; $individual_tag_name = "{$this->field}_{$opt_value}";
$out[] = sprintf(TAG_RADIOS, $individual_tag_name, $this->model, $this->field, $individual_tag_name, $parsed_options, $opt_title); $out[] = sprintf($this->tags['radio'], $individual_tag_name, $this->model, $this->field, $individual_tag_name, $parsed_options, $opt_title);
} }
$out = join($inbetween, $out); $out = join($inbetween, $out);
@ -478,32 +478,23 @@ class HtmlHelper extends Helper
} }
/** /**
* Returns a row of formatted and named TABLE headers. * Returns a row of formatted and named TABLE headers.
* *
* @param array $names * @param array $names
* @param array $tr_options * @param array $tr_options
* @param array $th_options * @param array $th_options
* @return string * @return string
*/ */
function tableHeaders($names, $tr_options=null, $th_options=null) function tableHeaders($names, $tr_options=null, $th_options=null)
{ {
$out = array(); $out = array();
foreach ($names as $arg) foreach ($names as $arg)
{ {
$out[] = sprintf(TAG_TABLE_HEADER, $this->parseHtmlOptions($th_options), $arg); $out[] = sprintf($this->tags['tableHeader'], $this->parseHtmlOptions($th_options), $arg);
} }
return sprintf(TAG_TABLE_HEADERS, $this->parseHtmlOptions($tr_options), join(' ', $out)); return sprintf($this->tags['tableHeader'], $this->parseHtmlOptions($tr_options), join(' ', $out));
} }
/** /**
@ -528,11 +519,11 @@ class HtmlHelper extends Helper
$cells_out = array(); $cells_out = array();
foreach ($line as $cell) foreach ($line as $cell)
{ {
$cells_out[] = sprintf(TAG_TABLE_CELL, null, $cell); $cells_out[] = sprintf($this->tags['tableCell'], null, $cell);
} }
$options = $this->parseHtmlOptions($count%2? $odd_tr_options: $even_tr_options); $options = $this->parseHtmlOptions($count%2? $odd_tr_options: $even_tr_options);
$out[] = sprintf(TAG_TABLE_ROW, $options, join(' ', $cells_out)); $out[] = sprintf($this->tags['tableRow'], $options, join(' ', $cells_out));
} }
return join("\n", $out); return join("\n", $out);
@ -1152,7 +1143,7 @@ class HtmlHelper extends Helper
// plaintext // plaintext
if (empty($options['encode']) || !empty($match[2])) if (empty($options['encode']) || !empty($match[2]))
{ {
return sprintf(TAG_MAILTO, $email, $this->parseHtmlOptions($options), $title); return sprintf($this->tags['mailto'], $email, $this->parseHtmlOptions($options), $title);
} }
// encoded to avoid spiders // encoded to avoid spiders
else else
@ -1176,7 +1167,7 @@ class HtmlHelper extends Helper
$title_encoded .= preg_match('/^[A-Za-z0-9]$/', $title[$ii])? '&#x' . bin2hex($title[$ii]).';': $title[$ii]; $title_encoded .= preg_match('/^[A-Za-z0-9]$/', $title[$ii])? '&#x' . bin2hex($title[$ii]).';': $title[$ii];
} }
return sprintf(TAG_MAILTO, $email_encoded, $this->parseHtmlOptions($options, array('encode')), $title_encoded); return sprintf($this->tags['mailto'], $email_encoded, $this->parseHtmlOptions($options, array('encode')), $title_encoded);
} }
} }

View file

@ -54,6 +54,13 @@ class Object
*/ */
var $db = null; var $db = null;
/**
* Log object
*
* @var object
*/
var $_log = null;
/** /**
* A hack to support __construct() on PHP 4 * A hack to support __construct() on PHP 4
* Hint: descendant classes have no PHP4 class_name() constructors, * Hint: descendant classes have no PHP4 class_name() constructors,
@ -103,7 +110,7 @@ class Object
*/ */
function log ($msg, $type=LOG_ERROR) function log ($msg, $type=LOG_ERROR)
{ {
if (!$this->_log) if (is_null($this->_log))
{ {
$this->_log = new Log (); $this->_log = new Log ();
} }

View file

@ -187,9 +187,9 @@ class View extends Object
} }
/** /**
* Enter description here... * Returns a view instance (singleton)
* *
* @return unknown * @return object
*/ */
function getInstance() function getInstance()
{ {
@ -201,24 +201,6 @@ class View extends Object
return $instance[0]; return $instance[0];
} }
/**
* Displays a flash message. A flash message is feedback to the user that displays after editing actions, among other things.
*
* @param string $message Text to display to the user
* @param string $url URL fragment
* @param int $time Display time, in seconds
*/
function flash($message, $url, $time=1)
{
$this->autoRender = false;
$this->autoLayout = false;
$this->set('url', $this->base.$url);
$this->set('message', $message);
$this->set('time', $time);
$this->render(null,false,VIEWS.'layouts'.DS.'flash.thtml');
}
/** /**
* Render view for given action and layout. If $file is given, that is used * Render view for given action and layout. If $file is given, that is used

View file

@ -37,8 +37,6 @@
*/ */
$url = empty($_GET['url'])? null: $_GET['url']; $url = empty($_GET['url'])? null: $_GET['url'];
session_start();
/** /**
* Get Cake's root directory * Get Cake's root directory
*/ */
@ -82,6 +80,8 @@ $TIME_START = getMicrotime();
uses('folder', 'dispatcher', 'dbo_factory'); uses('folder', 'dispatcher', 'dbo_factory');
session_start();
config('database'); config('database');
if (class_exists('DATABASE_CONFIG')) if (class_exists('DATABASE_CONFIG'))