diff options
Diffstat (limited to 'site/cake/libs/view')
35 files changed, 6120 insertions, 0 deletions
diff --git a/site/cake/libs/view/helper.php b/site/cake/libs/view/helper.php new file mode 100644 index 0000000..6dad823 --- /dev/null +++ b/site/cake/libs/view/helper.php @@ -0,0 +1,167 @@ +<?php +/* SVN FILE: $Id: helper.php 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * Backend for helpers. + * + * Internal methods for the Helpers. + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view + * @since CakePHP(tm) v 0.2.9 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +/** + * Backend for helpers. + * + * Long description for class + * + * @package cake + * @subpackage cake.cake.libs.view + */ +class Helper extends Object { +/** + * Holds tag templates. + * + * @access public + * @var array + */ + var $tags = array('link' => '<a href="%s" %s>%s</a>', + 'mailto' => '<a href="mailto:%s" %s>%s</a>', + 'form' => '<form %s>', + 'input' => '<input name="data[%s][%s]" %s/>', + 'textarea' => '<textarea name="data[%s][%s]" %s>%s</textarea>', + 'hidden' => '<input type="hidden" name="data[%s][%s]" %s/>', + 'textarea' => '<textarea name="data[%s][%s]" %s>%s</textarea>', + 'checkbox' => '<input type="checkbox" name="data[%s][%s]" %s/>', + 'radio' => '<input type="radio" name="data[%s][%s]" id="%s" %s/>%s', + 'selectstart' => '<select name="data[%s][%s]" %s>', + 'selectmultiplestart' => '<select name="data[%s][%s][]" %s>', + 'selectempty' => '<option value="" %s> </option>', + 'selectoption' => '<option value="%s" %s>%s</option>', + 'selectend' => '</select>', + 'password' => '<input type="password" name="data[%s][%s]" %s/>', + 'file' => '<input type="file" name="data[%s][%s]" %s/>', + 'file_no_model' => '<input type="file" name="%s" %s/>', + 'submit' => '<input type="submit" %s/>', + 'image' => '<img src="%s" %s/>', + 'tableheader' => '<th%s>%s</th>', + 'tableheaderrow' => '<tr%s>%s</tr>', + 'tablecell' => '<td%s>%s</td>', + 'tablerow' => '<tr%s>%s</tr>', + 'block' => '<div%s>%s</div>', + 'blockstart' => '<div%s>', + 'blockend' => '</div>', + 'css' => '<link rel="%s" type="text/css" href="%s" %s/>', + 'style' => '<style type="text/css"%s>%s</style>', + 'charset' => '<meta http-equiv="Content-Type" content="text/html; charset=%s"/>', + 'javascriptblock' => '<script type="text/javascript">%s</script>', + 'javascriptlink' => '<script type="text/javascript" src="%s"></script>'); +/** + * Parses custom config/tags.ini.php and merges with $this->tags. + * + * @return html tags used by helpers + */ + function loadConfig() { + + if (file_exists(APP . 'config' . DS . 'tags.ini.php')) { + $tags = $this->readConfigFile(APP . 'config' . DS . 'tags.ini.php'); + $this->tags = am($this->tags, $tags); + } + return $this->tags; + } +/** + * Decides whether to output or return a string. + * + * Based on AUTO_OUTPUT and $return's value, this method decides whether to + * output a string, or return it. + * + * @param string $str String to be output or returned. + * @param boolean $return Whether this method should return a value or output it. + * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return. + */ + function output($str, $return = false) { + if (AUTO_OUTPUT && $return === false) { + echo $str; + } else { + return $str; + } + } +/** + * Assigns values to tag templates. + * + * Finds a tag template by $keyName, and replaces $values's keys with + * $values's keys. + * + * @param string $keyName Name of the key in the tag array. + * @param array $values Values to be inserted into tag. + * @return string Tag with inserted values. + */ + function assign($keyName, $values) { + return str_replace('%%' . array_keys($values) . '%%', array_values($values), $this->tags[$keyName]); + } +/** + * Returns an array of settings in given INI file. + * + * @param string $fileName ini file to read + * @return array of lines from the $fileName + */ + function readConfigFile($fileName) { + $fileLineArray = file($fileName); + + foreach ($fileLineArray as $fileLine) { + $dataLine = trim($fileLine); + $firstChar = substr($dataLine, 0, 1); + + if ($firstChar != ';' && $dataLine != '') { + if ($firstChar == '[' && substr($dataLine, -1, 1) == ']') { + // [section block] we might use this later do not know for sure + // this could be used to add a key with the section block name + // but it adds another array level + } else { + $delimiter = strpos($dataLine, '='); + + if ($delimiter > 0) { + $key = strtolower(trim(substr($dataLine, 0, $delimiter))); + $value = trim(stripcslashes(substr($dataLine, $delimiter + 1))); + + if (substr($value, 0, 1) == '"' && substr($value, -1) == '"') { + $value = substr($value, 1, -1); + } + + $iniSetting[$key] = $value; + + } else { + $iniSetting[strtolower(trim($dataLine))] = ''; + } + } + } else { + } + } + + return $iniSetting; + } +/** + * After render callback. Overridden in subclasses. + * + * @return void + */ + function afterRender() { + } +} +?> diff --git a/site/cake/libs/view/helpers/ajax.php b/site/cake/libs/view/helpers/ajax.php new file mode 100644 index 0000000..36c185b --- /dev/null +++ b/site/cake/libs/view/helpers/ajax.php @@ -0,0 +1,853 @@ +<?php +/* SVN FILE: $Id: ajax.php 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * Helper for AJAX operations. + * + * Helps doing AJAX using the Prototype library. + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.helpers + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +/** + * AjaxHelper library. + * + * Helps doing AJAX using the Prototype library. + * + * @package cake + * @subpackage cake.cake.libs.view.helpers + */ +class AjaxHelper extends Helper { +/** + * Included helpers. + * + * @var array + * @access public + */ + var $helpers = array('Html', 'Javascript'); +/** + * Names of Javascript callback functions. + * + * @var array + * @access public + */ + var $callbacks = array('uninitialized', 'loading', 'loaded', 'interactive', 'complete', 'success', 'failure'); +/** + * Names of AJAX options. + * + * @var array + * @access public + */ + var $ajaxOptions = array('type', 'confirm', 'condition', 'before', 'after', 'fallback', 'update', 'loading', 'loaded', 'interactive', 'complete', 'with', 'url', 'method', 'position', 'form', 'parameters', 'evalScripts', 'asynchronous', 'onComplete', 'onUninitialized', 'onLoading', 'onLoaded', 'onInteractive', 'success', 'failure', 'onSuccess', 'onFailure', 'insertion', 'requestHeaders'); +/** + * Options for draggable. + * + * @var array + * @access public + */ + var $dragOptions = array('handle', 'revert', 'constraint', 'change', 'ghosting'); +/** + * Options for droppable. + * + * @var array + * @access public + */ + var $dropOptions = array('accept', 'containment', 'overlap', 'greedy', 'hoverclass', 'onHover', 'onDrop'); +/** + * Options for sortable. + * + * @var array + * @access public + */ + var $sortOptions = array('tag', 'only', 'overlap', 'constraint', 'containment', 'handle', 'hoverclass', 'ghosting', 'dropOnEmpty', 'onUpdate', 'onChange'); +/** + * Options for slider. + * + * @var array + * @access public + */ + var $sliderOptions = array('axis', 'increment', 'maximum', 'minimum', 'alignX', 'alignY', 'sliderValue', 'disabled', 'handleImage', 'handleDisabled', 'values', 'onSlide', 'onChange'); +/** + * Options for in-place editor. + * + * @var array + * @access public + */ + var $editorOptions = array('okText', 'cancelText', 'savingText', 'formId', 'externalControl', 'rows', 'cols', 'size', 'highlightcolor', 'highlightendcolor', 'savingClassName', 'formClassName', 'loadTextURL', 'loadingText', 'callback', 'ajaxOptions', 'clickToEditText'); +/** + * Options for auto-complete editor. + * + * @var array + * @access public + */ + var $autoCompleteOptions = array('paramName', 'tokens', 'frequency', 'minChars', 'indicator', 'updateElement', 'afterUpdateElement', 'onShow', 'onHide'); +/** + * Output buffer for Ajax update content + * + * @var array + * @access private + */ + var $__ajaxBuffer = array(); +/** + * Returns link to remote action + * + * Returns a link to a remote action defined by <i>options[url]</i> + * (using the urlFor format) that's called in the background using + * XMLHttpRequest. The result of that request can then be inserted into a + * DOM object whose id can be specified with <i>options[update]</i>. + * + * Examples: + * <code> + * $ajax->link("Delete this post", "/posts/delete/{$post['Post']['id']}" + * array("update" => "posts", "loading"=>"Element.show('loading');", "complete"=>"Element.hide('loading');"), + * "Are you sure you want to delte this post?"); + * $ajax->link($html->img("refresh"), '/emails/refresh', + * array("update" => "posts", "loading"=>"Element.show('loading');", "complete"=>"Element.hide('loading');"), + * null, false); + * </code> + * + * By default, these remote requests are processed asynchronous during + * which various callbacks can be triggered (for progress indicators and + * the likes). + * + * The callbacks that may be specified are: + * + * - <i>loading</i>:: Called when the remote document is being + * loaded with data by the browser. + * - <i>loaded</i>:: Called when the browser has finished loading + * the remote document. + * - <i>interactive</i>:: Called when the user can interact with the + * remote document, even though it has not + * finished loading. + * - <i>complete</i>:: Called when the request is complete. + * + * If you for some reason or another need synchronous processing (that'll + * block the browser while the request is happening), you can specify + * <i>$options['type'] = synchronous</i>. + * + * You can customize further browser side call logic by passing + * in Javascript code snippets via some optional parameters. In + * their order of use these are: + * + * - <i>confirm</i> :: Adds confirmation dialog. + * - <i>condition</i> :: Perform remote request conditionally + * by this expression. Use this to + * describe browser-side conditions when + * request should not be initiated. + * - <i>before</i> :: Called before request is initiated. + * - <i>after</i> :: Called immediately after request was + * initiated and before <i>loading</i>. + * + * @link http://wiki.script.aculo.us/scriptaculous/show/Ajax.Updater + * @param string $title Title of link + * @param string $href href string "/products/view/12" + * @param array $options Options for JavaScript function + * @param string $confirm Confirmation message. Calls up a JavaScript confirm() message. + * @param boolean $escapeTitle Escaping the title string to HTML entities + * @return HTML code for link to remote action + * @access public + */ + function link($title, $href = null, $options = array(), $confirm = null, $escapeTitle = true) { + if (!isset($href)) { + $href = $title; + } + + if (!isset($options['url'])) { + $options['url'] = $href; + } + + if (isset($confirm)) { + $options['confirm'] = $confirm; + unset($confirm); + } + $htmlOptions = $this->__getHtmlOptions($options); + + if (empty($options['fallback']) || !isset($options['fallback'])) { + $options['fallback'] = $href; + } + + if (!isset($htmlOptions['id'])) { + $htmlOptions['id'] = 'link' . intval(rand()); + } + + if (!isset($htmlOptions['onclick'])) { + $htmlOptions['onclick'] = ''; + } + $htmlOptions['onclick'] .= ' event.returnValue = false; return false;'; + $return = $this->Html->link($title, $href, $htmlOptions, null, $escapeTitle); + $script = $this->Javascript->event("'{$htmlOptions['id']}'", "click", $this->remoteFunction($options)); + + if (is_string($script)) { + $return .= $script; + } + return $return; + } +/** + * 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 link. + * + * @link http://wiki.script.aculo.us/scriptaculous/show/Ajax.Updater + * @see link() for docs on options parameter. + * @param array $options options for javascript + * @return string html code for link to remote action + * @access public + */ + function remoteFunction($options = null) { + if (isset($options['update'])) { + if (!is_array($options['update'])) { + $func = "new Ajax.Updater('{$options['update']}',"; + } else { + $func = "new Ajax.Updater(document.createElement('div'),"; + } + if (!isset($options['requestHeaders'])) { + $options['requestHeaders'] = array(); + } + if (is_array($options['update'])) { + $options['update'] = join(' ', $options['update']); + } + $options['requestHeaders']['X-Update'] = $options['update']; + } else { + $func = "new Ajax.Request("; + } + + $func .= "'" . $this->Html->url(isset($options['url']) ? $options['url'] : "") . "'"; + $func .= ", " . $this->__optionsForAjax($options) . ")"; + + if (isset($options['before'])) { + $func = "{$options['before']}; $func"; + } + + if (isset($options['after'])) { + $func = "$func; {$options['after']};"; + } + + if (isset($options['condition'])) { + $func = "if ({$options['condition']}) { $func; }"; + } + + if (isset($options['confirm'])) { + $func = "if (confirm('" . $this->Javascript->escapeString($options['confirm']) + . "')) { $func; } else { event.returnValue = false; return false; }"; + } + return $func; + } +/** + * Periodically call remote url via AJAX. + * + * Periodically calls the specified url (<i>options['url']</i>) every <i>options['frequency']</i> seconds (default is 10). + * Usually used to update a specified div (<i>options['update']</i>) with the results of the remote call. + * The options for specifying the target with url and defining callbacks is the same as link. + * + * @link http://wiki.script.aculo.us/scriptaculous/show/Ajax.Updater + * @param array $options Callback options + * @return string Javascript codeblock + * @access public + */ + function remoteTimer($options = null) { + $frequency=(isset($options['frequency'])) ? $options['frequency'] : 10; + $code="new PeriodicalExecuter(function() {" . $this->remoteFunction($options) . "}, $frequency)"; + return $this->Javascript->codeBlock($code); + } +/** + * Returns form tag that will submit using Ajax. + * + * Returns a form tag that will submit using XMLHttpRequest in the background instead of the regular + * 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). + * The options for defining callbacks is the same as link(). + * + * @param array $params Form target + * @param array $type How form data is posted: 'get' or 'post' + * @param array $options Callback/HTML options + * @return string JavaScript/HTML code + * @access public + */ + function form($params = null, $type = 'post', $options = array()) { + if (is_array($params)) { + extract($params, EXTR_OVERWRITE); + + if (!isset($action)) { + $action = null; + } + + if (!isset($type)) { + $type = 'post'; + } + + if (!isset($options)) { + $options = array(); + } + } else { + $action = $params; + } + $htmlOptions = $this->__getHtmlOptions($options); + $htmlOptions['action'] = $action; + + if (!isset($htmlOptions['id'])) { + $htmlOptions['id'] = 'form' . intval(rand()); + } + $htmlOptions['onsubmit']="event.returnValue = false; return false;"; + + if (!isset($options['with'])) { + $options['with'] = "Form.serialize('{$htmlOptions['id']}')"; + } + $options['url']=$action; + + return $this->Html->formTag($htmlOptions['action'], $type, $htmlOptions) + . $this->Javascript->event("'" . $htmlOptions['id']. "'", "submit", $this->remoteFunction($options)); + } +/** + * Returns a button input tag that will submit using Ajax + * + * Returns a button input tag that will submit form using XMLHttpRequest in the background instead of regular + * reloading POST arrangement. <i>options</i> argument is the same as in <i>form_remote_tag</i> + * + * @param string $title Input button title + * @param array $options Callback options + * @return string Ajaxed input button + * @access public + */ + function submit($title = 'Submit', $options = array()) { + $htmlOptions =$this->__getHtmlOptions($options); + $htmlOptions['value']=$title; + + if (!isset($options['with'])) { + $options['with'] = 'Form.serialize(Event.element(event).form)'; + } + + if (!isset($htmlOptions['id'])) { + $htmlOptions['id'] = 'submit' . intval(rand()); + } + $htmlOptions['onclick']="event.returnValue = false; return false;"; + return $this->Html->submit($title, $htmlOptions) + . $this->Javascript->event('"' . $htmlOptions['id'] . '"', 'click', $this->remoteFunction($options)); + } +/** + * Observe field and call ajax on change. + * + * Observes the field with the DOM ID specified by <i>field_id</i> and makes + * an Ajax when its contents have changed. + * + * Required +options+ are: + * - <i>frequency</i>:: The frequency (in seconds) at which changes to + * this field will be detected. + * - <i>url</i>:: @see urlFor() -style options for the action to call + * when the field has changed. + * + * Additional options are: + * - <i>update</i>:: Specifies the DOM ID of the element whose + * innerHTML should be updated with the + * XMLHttpRequest response text. + * - <i>with</i>:: A Javascript expression specifying the + * parameters for the XMLHttpRequest. This defaults + * to Form.Element.serialize('$field_id'), which can be + * accessed from params['form']['field_id']. + * + * @see link(). + * @param string $field_id DOM ID of field to observe + * @param array $options ajax options + * @return string ajax script + * @access public + */ + function observeField($field_id, $options = array()) { + if (!isset($options['with'])) { + $options['with'] = "Form.Element.serialize('$field_id')"; + } + return $this->Javascript->codeBlock($this->_buildObserver('Form.Element.Observer', $field_id, $options)); + } +/** + * Observe entire form and call ajax on change. + * + * 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 + * the default value of the <i>with</i> option evaluates to the + * serialized (request string) value of the form. + * + * @param string $field_id DOM ID of field to observe + * @param array $options ajax options + * @return string ajax script + * @access public + */ + function observeForm($field_id, $options = array()) { + if (!isset($options['with'])) { + $options['with'] = 'Form.serialize("' . $field_id . '")'; + } + return $this->Javascript->codeBlock($this->_buildObserver('Form.Observer', $field_id, $options)); + } +/** + * Create a text field with Autocomplete. + * + * Creates an autocomplete field with the given ID and options. + * + * options['with'] defaults to "Form.Element.serialize('$field_id')", + * but can be any valid javascript expression defining the + * + * @link http://wiki.script.aculo.us/scriptaculous/show/Ajax.Autocompleter + * @param string $field_id DOM ID of field to observe + * @param string $url URL for the autocomplete action + * @param array $options Ajax options + * @return string Ajax script + * @access public + */ + function autoComplete($field, $url = "", $options = array()) { + $var = ''; + if (isset($options['var'])) { + $var = 'var ' . $options['var'] . ' = '; + unset($options['var']); + } + + if (!isset($options['id'])) { + $options['id'] = Inflector::camelize(r("/", "_", $field)); + } + $divOptions = array('id' => $options['id'] . "_autoComplete", 'class' => isset($options['class']) ? $options['class'] : 'auto_complete'); + + if (isset($options['div_id'])) { + $divOptions['id'] = $options['div_id']; + unset($options['div_id']); + } + $htmlOptions = $this->__getHtmlOptions($options); + $htmlOptions['autocomplete'] = "off"; + + foreach ($this->autoCompleteOptions as $opt) { + unset($htmlOptions[$opt]); + } + + if (isset($options['tokens'])) { + if (is_array($options['tokens'])) { + $options['tokens'] = $this->Javascript->object($options['tokens']); + } else { + $options['tokens'] = '"' . $options['tokens'] . '"'; + } + } + $options = $this->_optionsToString($options, array('paramName', 'indicator')); + $options = $this->_buildOptions($options, $this->autoCompleteOptions); + return $this->Html->input($field, $htmlOptions) . "\n" . + $this->Html->tag('div', $divOptions, true) . "</div>\n" . + $this->Javascript->codeBlock("{$var}new Ajax.Autocompleter('" . $htmlOptions['id'] + . "', '" . $divOptions['id'] . "', '" . $this->Html->url($url) . "', " . + $options . ");"); + } +/** + * Setup a Draggable Element. + * For a reference on the options for this function, check out + * + * @link http://wiki.script.aculo.us/scriptaculous/show/Draggable + * @param sting $id the DOM id to enable + * @param array $options a set of options + * @return string Javascript::codeBlock(); + * @access public + */ + function drag($id, $options = array()) { + return $this->Javascript->codeBlock("new Draggable('$id', " . $this->_optionsForDraggable($options) . ");"); + } +/** + * Creates an Ajax-updateable DIV element + * + * @param string $id options for javascript + * @param array $options a set of options + * @return string HTML code + * @access public + */ + function div($id, $options = array()) { + if (env('HTTP_X_UPDATE') != null) { + $divs = explode(' ', env('HTTP_X_UPDATE')); + if (in_array($id, $divs)) { + @ob_end_clean(); + ob_start(); + return ''; + } + } + $attr = $this->Html->_parseAttributes(am($options, array('id' => $id))); + return $this->output(sprintf($this->tags['blockstart'], $attr)); + } +/** + * Closes an Ajax-updateable DIV element + * + * @param string $id The DOM ID of the element + * @return string HTML code + * @access public + */ + function divEnd($id) { + if (env('HTTP_X_UPDATE') != null) { + $divs = explode(' ', env('HTTP_X_UPDATE')); + if (in_array($id, $divs)) { + $this->__ajaxBuffer[$id] = ob_get_contents(); + ob_end_clean(); + return ''; + } + } + return $this->output($this->tags['blockend']); + } +/** + * Protectd helper method to return an array of options for draggable. + * + * @param array $options + * @return array + * @access protected + */ + function _optionsForDraggable($options) { + $options = $this->_optionsToString($options, array('handle', 'constraint')); + return $this->_buildOptions($options, $this->dragOptions); + } +/** + * Setup a droppable element + * For a reference on the options for this function, check out + * + * @link http://wiki.script.aculo.us/scriptaculous/show/Droppables.add + * @param string $id + * @param array $options + * @return array + * @access public + */ + function drop($id, $options = array()) { + $options = $this->_optionsForDroppable($options); + return $this->Javascript->codeBlock("Droppables.add('$id', $options);"); + } +/** + * Protected helper method to return an array of options for droppable. + * + * @param string $options + * @return string String of Javascript array definition + * @access protected + */ + function _optionsForDroppable($options) { + $options = $this->_optionsToString($options, array('accept', 'overlap', 'hoverclass')); + return $this->_buildOptions($options, $this->dropOptions); + } +/** + * Setup a remote droppable element. + * + * @link http://wiki.script.aculo.us/scriptaculous/show/Droppables.add + * @see link() and remoteFunction() + * @param string $id DOM id of droppable + * @param array $options ame as drop() + * @param array $ajaxOptions same as remoteFunction() + * @return string Javascript::codeBlock() + * @access public + */ + function dropRemote($id, $options = array(), $ajaxOptions = array()) { + $options['onDrop'] = "function(element) {" . $this->remoteFunction($ajaxOptions) . "}"; + $options = $this->_optionsForDroppable($options); + return $this->Javascript->codeBlock("Droppables.add('$id', $options);"); + } +/** + * Makes a slider control. + * + * @link http://wiki.script.aculo.us/scriptaculous/show/Slider + * @param string $id DOM ID of slider handle + * @param string $track_id DOM ID of slider track + * @param array $options Array of options to control the slider + * @return string Javascript::codeBlock() + * @access public + */ + function slider($id, $track_id, $options = array()) { + $options = $this->_optionsToString($options, array('axis', 'handleImage', 'handleDisabled')); + + if (isset($options['change'])) { + $options['onChange'] = $options['change']; + unset($options['change']); + } + + if (isset($options['slide'])) { + $options['onSlide'] = $options['slide']; + unset($options['slide']); + } + + $options = $this->_buildOptions($options, $this->sliderOptions); + return $this->Javascript->codeBlock("var $id = new Control.Slider('$id', '$track_id', $options);"); + } +/** + * Makes an Ajax In Place editor control. + * + * @link http://wiki.script.aculo.us/scriptaculous/show/Ajax.InPlaceEditor + * @param string $id DOM ID of input element + * @param string $url Postback URL of saved data + * @param array $options Array of options to control the editor, including ajaxOptions (see link). + * @return string Javascript::codeBlock() + * @access public + */ + function editor($id, $url, $options = array()) { + $url = $this->Html->url($url); + $options['ajaxOptions'] = $this->__optionsForAjax($options); + + foreach ($this->ajaxOptions as $opt) { + if (isset($options[$opt])) { + unset($options[$opt]); + } + } + + if (isset($options['callback'])) { + $options['callback'] = 'function(form, value) {' . $options['callback'] . '}'; + } + + $options = $this->_optionsToString($options, array('okText', 'cancelText', 'savingText', 'formId', 'externalControl', 'highlightcolor', 'highlightendcolor', 'savingClassName', 'formClassName', 'loadTextURL', 'loadingText', 'clickToEditText')); + $options = $this->_buildOptions($options, $this->editorOptions); + return $this->Javascript->codeBlock("new Ajax.InPlaceEditor('{$id}', '{$url}', {$options});"); + } +/** + * Makes a list or group of floated objects sortable. + * + * @link http://wiki.script.aculo.us/scriptaculous/show/Sortable.create + * @param string $id DOM ID of parent + * @param array $options Array of options to control sort + * @return string Javascript::codeBlock() + * @access public + */ + function sortable($id, $options = array()) { + if (!empty($options['url'])) { + $options['with'] = "Sortable.serialize('$id')"; + $options['onUpdate'] = 'function(sortable) {' . $this->remoteFunction($options) . '}'; + } + + $options = $this->__optionsForSortable($options); + return $this->Javascript->codeBlock("Sortable.create('$id', $options);"); + } +/** + * Private method; generates sortables code from array options + * + * @param array $options + * @return string String of Javascript array definition + * @access private + */ + function __optionsForSortable($options) { + $options = $this->_optionsToString($options, array('handle', 'tag', 'constraint', 'ghosting', 'only', 'hoverclass')); + return $this->_buildOptions($options, $this->sortOptions); + } +/** + * Private helper function for Ajax. + * + * @param array $options + * @return string String of Javascript array definition + * @access private + */ + function __optionsForAjax($options = array()) { + + if (isset($options['indicator'])) { + if (isset($options['loading'])) { + $options['loading'] .= "Element.show('{$options['indicator']}');"; + } else { + $options['loading'] = "Element.show('{$options['indicator']}');"; + } + if (isset($options['complete'])) { + $options['complete'] .= "Element.hide('{$options['indicator']}');"; + } else { + $options['complete'] = "Element.hide('{$options['indicator']}');"; + } + unset($options['indicator']); + } + + $jsOptions = am( + array('asynchronous' => 'true', 'evalScripts' => 'true'), + $this->_buildCallbacks($options) + ); + $options = $this->_optionsToString($options, array('method')); + + foreach ($options as $key => $value) { + switch($key) { + case 'type': + $jsOptions['asynchronous'] = ife(($value == 'synchronous'), 'false', 'true'); + break; + case 'evalScripts': + $jsOptions['evalScripts'] = ife($value, 'true', 'false'); + break; + case 'position': + $jsOptions['insertion'] = "Insertion." . Inflector::camelize($options['position']); + break; + case 'with': + $jsOptions['parameters'] = $options['with']; + break; + case 'form': + $jsOptions['parameters'] = 'Form.serialize(this)'; + break; + case 'requestHeaders': + $keys = array(); + foreach ($value as $key => $val) { + $keys[] = "'" . $key . "'"; + $keys[] = "'" . $val . "'"; + } + $jsOptions['requestHeaders'] = '[' . join(', ', $keys) . ']'; + break; + } + } + return $this->_buildOptions($jsOptions, $this->ajaxOptions); + } +/** + * Private Method to return a string of html options + * option data as a JavaScript options hash. + * + * @param array $options Options in the shape of keys and values + * @param array $extra Array of legal keys in this options context + * @return array Array of html options + * @access private + */ + function __getHtmlOptions($options, $extra = array()) { + foreach ($this->ajaxOptions as $key) { + if (isset($options[$key])) { + unset($options[$key]); + } + } + + foreach ($extra as $key) { + if (isset($options[$key])) { + unset($options[$key]); + } + } + return $options; + } +/** + * Protected Method to return a string of JavaScript with the given + * option data as a JavaScript options hash. + * + * @param array $options Options in the shape of keys and values + * @param array $acceptable Array of legal keys in this options context + * @return string String of Javascript array definition + * @access protected + */ + function _buildOptions($options, $acceptable) { + if (is_array($options)) { + $out = array(); + + foreach ($options as $k => $v) { + if (in_array($k, $acceptable)) { + $out[] = "$k:$v"; + } + } + + $out = join(', ', $out); + $out = '{' . $out . '}'; + return $out; + } else { + return false; + } + } +/** + * Protected Method to return JavaScript text for an observer... + * + * @param string $klass Name of JavaScript class + * @param string $name + * @param array $options Ajax options + * @return string Formatted JavaScript + * @access protected + */ + function _buildObserver($klass, $name, $options = null) { + if (!isset($options['with']) && isset($options['update'])) { + $options['with'] = 'value'; + } + + $callback = $this->remoteFunction($options); + $javascript = "new $klass('$name', "; + $javascript .= (isset($options['frequency']) ? $options['frequency'] : 2) . ", function(element, value) {"; + $javascript .= "$callback})"; + return $javascript; + } +/** + * Protected Method to return JavaScript text for all callbacks... + * + * @param array $options + * @return array + * @access protected + */ + function _buildCallbacks($options) { + $callbacks = array(); + + foreach ($this->callbacks as $callback) { + if (isset($options[$callback])) { + $name = 'on' . ucfirst($callback); + $code = $options[$callback]; + $callbacks[$name] = "function(request) {" . $code . "}"; + } + } + return $callbacks; + } +/** + * Protected Method to return a string of JavaScript with a string representation + * of given options array. + * + * @param array $options Ajax options array + * @param array $stringOpts Options as strings in an array + * @access private + * @return array + * @access protected + */ + function _optionsToString($options, $stringOpts = array()) { + foreach ($stringOpts as $option) { + if (isset($options[$option]) && !$options[$option][0] != "'") { + if ($options[$option] === true || $options[$option] === 'true') { + $options[$option] = 'true'; + } elseif ($options[$option] === false || $options[$option] === 'false') { + $options[$option] = 'false'; + } else { + $options[$option] = "'{$options[$option]}'"; + } + } + } + return $options; + } +/** + * afterRender callback + * + * @return array + * @access public + */ + function afterRender() { + if (env('HTTP_X_UPDATE') != null && count($this->__ajaxBuffer) > 0) { + $data = array(); + $divs = explode(' ', env('HTTP_X_UPDATE')); + + foreach ($this->__ajaxBuffer as $key => $val) { + if (in_array($key, $divs)) { + $data[] = $key . ':"' . rawurlencode($val) . '"'; + } + } + + $out = 'var __ajaxUpdater__ = {' . join(', ', $data) . '};' . "\n"; + $out .= 'for (n in __ajaxUpdater__) { if (typeof __ajaxUpdater__[n] == "string" && $(n)) Element.update($(n), unescape(decodeURIComponent(__ajaxUpdater__[n]))); }'; + + @ob_end_clean(); + e($this->Javascript->codeBlock($out)); + exit(); + } + } +/** + * Replaced by AjaxHelper::link() + * + * @deprecated will not be avialable after 1.1.x.x + */ + function linkToRemote($title, $options = array(), $html_options = array()) { + trigger_error('Deprecated function: use AjaxHelper::link', E_USER_WARNING); + $href = '#'; + + if (!empty($options['fallback']) && isset($options['fallback'])) { + $href = $options['fallback']; + } + + if (isset($html_options['id'])) { + return $this->Html->link($title, $href, $html_options) . + $this->Javascript->event("$('{$html_options['id']}')", "click", $this->remoteFunction($options)); + } else { + $html_options['onclick'] = $this->remoteFunction($options) . "; event.returnValue = false; return false;"; + return $this->Html->link($title, $href, $html_options); + } + } +} + +?>
\ No newline at end of file diff --git a/site/cake/libs/view/helpers/cache.php b/site/cake/libs/view/helpers/cache.php new file mode 100644 index 0000000..a5ac934 --- /dev/null +++ b/site/cake/libs/view/helpers/cache.php @@ -0,0 +1,266 @@ +<?php +/* SVN FILE: $Id: cache.php 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * Short description for file. + * + * Long description for file + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.helpers + * @since CakePHP(tm) v 1.0.0.2277 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +/** + * Short description for file. + * + * Long description for file + * + * @package cake + * @subpackage cake.cake.libs.view.helpers + */ +class CacheHelper extends Helper{ +/** + * Array of strings replaced in cached views. + * The strings are found between <cake:nocache><cake:nocache> in views + * + * @var array + * @access private + */ + var $__replace = array(); +/** + * Array of string that are replace with there var replace above. + * The strings are any content inside <cake:nocache><cake:nocache> and includes the tags in views + * + * @var array + * @access private + */ + var $__match = array(); +/** + * holds the View object passed in final call to CacheHelper::cache() + * + * @var object + * @access public + */ + var $view; +/** + * Main method used to cache a view + * + * @param string $file File to cache + * @param string $out output to cache + * @param boolean $cache + * @return view ouput + */ + function cache($file, $out, $cache = false) { + if (is_array($this->cacheAction)) { + $check = str_replace('/', '_', $this->here); + $replace = str_replace('/', '_', $this->base); + $match = str_replace($this->base, '', $this->here); + $match = str_replace('//', '/', $match); + $match = str_replace('/' . $this->controllerName . '/', '', $match); + $check = str_replace($replace, '', $check); + $check = str_replace('_' . $this->controllerName . '_', '', $check); + $check = convertSlash($check); + $check = preg_replace('/^_+/', '', $check); + $keys = str_replace('/', '_', array_keys($this->cacheAction)); + $found = array_keys($this->cacheAction); + $index = null; + $count = 0; + + foreach ($keys as $key => $value) { + if (strpos($check, $value) === 0) { + $index = $found[$count]; + break; + } + $count++; + } + + if (isset($index)) { + $pos1 = strrpos($match, '/'); + $char = strlen($match) - 1; + + if ($pos1 == $char) { + $match = substr($match, 0, $char); + } + + $key = $match; + } elseif ($this->action == 'index') { + $index = 'index'; + } + if (isset($this->cacheAction[$index])) { + $cacheTime = $this->cacheAction[$index]; + } else { + $cacheTime = 0; + } + } else { + $cacheTime = $this->cacheAction; + } + + if ($cacheTime != '' && $cacheTime > 0) { + $this->__parseFile($file, $out); + + if ($cache === true) { + $cached = $this->__parseOutput($out); + $this->__writeFile($cached, $cacheTime); + } + return $out; + } else { + return $out; + } + } +/** + * Parse file searching for no cache tags + * + * @param string $file + * @param boolean $cache + * @access private + */ + function __parseFile($file, $cache) { + if (is_file($file)) { + $file = file_get_contents($file); + } elseif ($file = fileExistsInPath($file)) { + $file = file_get_contents($file); + } + + preg_match_all('/(<cake:nocache>(?<=<cake:nocache>)[\\s\\S]*?(?=<\/cake:nocache>)<\/cake:nocache>)/i', $cache, $oresult, PREG_PATTERN_ORDER); + preg_match_all('/(?<=<cake:nocache>)([\\s\\S]*?)(?=<\/cake:nocache>)/i', $file, $result, PREG_PATTERN_ORDER); + + if (!empty($result['0'])) { + $count = 0; + + foreach ($result['0'] as $result) { + if (isset($oresult['0'][$count])) { + $this->__replace[] = $result; + $this->__match[] = $oresult['0'][$count]; + } + $count++; + } + } + } +/** + * Parse the output and replace cache tags + * + * @param sting $cache + * @return string with all replacements made to <cake:nocache><cake:nocache> + * @access private + */ + function __parseOutput($cache) { + $count = 0; + if (!empty($this->__match)) { + + foreach ($this->__match as $found) { + $original = $cache; + $length = strlen($found); + $position = 0; + + for ($i = 1; $i <= 1; $i++) { + $position = strpos($cache, $found, $position); + + if ($position !== false) { + $cache = substr($original, 0, $position); + $cache .= $this->__replace[$count]; + $cache .= substr($original, $position + $length); + } else { + break; + } + } + $count++; + } + return $cache; + } + return $cache; + } +/** + * Write a cached version of the file + * + * @param string $content + * @param sting $timestamp + * @return cached view + * @access private + */ + function __writeFile($content, $timestamp) { + $now = time(); + + if (is_numeric($timestamp)) { + $cacheTime = $now + $timestamp; + } else { + $cacheTime = strtotime($timestamp, $now); + } + + $cache = convertSlash($this->here); + if (empty($cache)) { + return; + } + + $cache = $cache . '.php'; + $file = '<!--cachetime:' . $cacheTime . '--><?php'; + if (empty($this->plugin)) { + $file .= ' + loadController(\'' . $this->view->name. '\'); + loadModels(); + '; + } else { + $file .= ' + if (!class_exists(\'AppController\')) { + if (file_exists(\'' . APP . 'app_controller.php\')) { + require(\''. APP . 'app_controller.php\'); + } else { + require(\''.CAKE . 'app_controller.php\'); + } + } + loadPluginController(\''.$this->plugin.'\',\''.$this->view->name.'\'); + loadPluginModels(\''.$this->plugin.'\'); + '; + } + $file .= '$this->controller = new ' . $this->view->name . 'Controller(); + $this->controller->plugin = \''.$this->plugin.'\'; + $this->controller->_initComponents(); + $this->helpers = unserialize(\'' . serialize($this->view->helpers) . '\'); + $this->base = \'' . $this->view->base . '\'; + $this->layout = \'' . $this->view->layout. '\'; + $this->webroot = \'' . $this->view->webroot . '\'; + $this->here = \'' . $this->view->here . '\'; + $this->params = unserialize(stripslashes(\'' . addslashes(serialize($this->view->params)) . '\')); + $this->action = unserialize(\'' . serialize($this->view->action) . '\'); + $this->data = unserialize(stripslashes(\'' . addslashes(serialize($this->view->data)) . '\')); + $this->themeWeb = \'' . $this->view->themeWeb . '\'; + $this->plugin = \'' . $this->view->plugin . '\'; + $loadedHelpers = array(); + $loadedHelpers = $this->_loadHelpers($loadedHelpers, $this->helpers); + foreach (array_keys($loadedHelpers) as $helper) + { + $replace = strtolower(substr($helper, 0, 1)); + $camelBackedHelper = preg_replace(\'/\\w/\', $replace, $helper, 1); + ${$camelBackedHelper} =& $loadedHelpers[$helper]; + + if (isset(${$camelBackedHelper}->helpers) && is_array(${$camelBackedHelper}->helpers)) + { + foreach (${$camelBackedHelper}->helpers as $subHelper) + { + ${$camelBackedHelper}->{$subHelper} =& $loadedHelpers[$subHelper]; + } + } + $this->loaded[$camelBackedHelper] = (${$camelBackedHelper}); + } + ?>'; + $content = preg_replace("/(<\\?xml)/", "<?php echo '$1';?>",$content); + $file .= $content; + return cache('views' . DS . $cache, $file, $timestamp); + } +} +?>
\ No newline at end of file diff --git a/site/cake/libs/view/helpers/form.php b/site/cake/libs/view/helpers/form.php new file mode 100644 index 0000000..dbc8dc7 --- /dev/null +++ b/site/cake/libs/view/helpers/form.php @@ -0,0 +1,491 @@ +<?php +/* SVN FILE: $Id: form.php 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * Automatic generation of HTML FORMs from given data. + * + * Used for scaffolding. + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.helpers + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +/** + * Tag template for a div with a class attribute. + */ + define('TAG_DIV', '<div class="%s">%s</div>'); +/** + * Tag template for a paragraph with a class attribute. + */ + define('TAG_P_CLASS', '<p class="%s">%s</p>'); +/** + * Tag template for a label with a for attribute. + */ + define('TAG_LABEL', '<label for="%s">%s</label>'); +/** + * Tag template for a fieldset with a legend tag inside. + */ + define('TAG_FIELDSET', '<fieldset><legend>%s</legend>%s</label>'); +/** + * Form helper library. + * + * Automatic generation of HTML FORMs from given data. + * + * @package cake + * @subpackage cake.cake.libs.view.helpers + */ +class FormHelper extends Helper{ +/** + * Included helpers. + * + * @var array + * @access public + */ + var $helpers = array('Html'); +/** + * Returns a formatted error message for given FORM field, NULL if no errors. + * + * @param string $field This should be "Modelname/fieldname" + * @return bool If there are errors this method returns true, else false. + * @access public + */ + function isFieldError($field) { + $error=1; + $this->Html->setFormTag($field); + + if ($error == $this->Html->tagIsInvalid($this->Html->model, $this->Html->field)) { + return true; + } else { + return false; + } + } +/** + * Returns a formatted LABEL element for HTML FORMs. + * + * @param string $tagName This should be "Modelname/fieldname" + * @param string $text Text that will appear in the label field. + * @return string The formatted LABEL element + * @access public + */ + function labelTag($tagName, $text) { + return sprintf(TAG_LABEL, Inflector::camelize(str_replace('/', '_', $tagName)), $text); + } +/** + * Returns a formatted DIV tag for HTML FORMs. + * + * @param string $class CSS class name of the div element. + * @param string $text String content that will appear inside the div element. + * @return string The formatted DIV element + * @access public + */ + function divTag($class, $text) { + return sprintf(TAG_DIV, $class, $text); + } +/** + * Returns a formatted P tag with class for HTML FORMs. + * + * @param string $class CSS class name of the p element. + * @param string $text Text that will appear inside the p element. + * @return string The formatted P element + * @access public + */ + function pTag($class, $text) { + return sprintf(TAG_P_CLASS, $class, $text); + } +/** + * Returns a formatted INPUT tag for HTML FORMs. + * + * @param string $tagName This should be "Modelname/fieldname" + * @param string $prompt Text that will appear in the label field. + * @param bool $required True if this field is a required field. + * @param string $errorMsg Text that will appear if an error has occurred. + * @param int $size Size attribute for INPUT element + * @param array $htmlOptions HTML options array. + * @return string The formatted INPUT element, with a label and wrapped in a div. + * @access public + */ + function generateInputDiv($tagName, $prompt, $required = false, $errorMsg = null, $size = 20, $htmlOptions = null) { + $htmlAttributes = $htmlOptions; + $htmlAttributes['size'] = $size; + $str = $this->Html->input($tagName, $htmlAttributes); + $strLabel = $this->labelTag($tagName, $prompt); + $divClass = "optional"; + if ($required) { + $divClass = "required"; + } + $strError = ""; + + if ($this->isFieldError($tagName)) { + $strError = $this->pTag('error', $errorMsg); + $divClass = sprintf("%s error", $divClass); + } + $divTagInside = sprintf("%s %s %s", $strError, $strLabel, $str); + return $this->divTag($divClass, $divTagInside); + } +/** + * Returns a formatted CHECKBOX tag inside a DIV for HTML FORMs. + * + * @param string $tagName This should be "Modelname/fieldname" + * @param string $prompt Text that will appear in the label field. + * @param bool $required True if this field is a required field. + * @param string $errorMsg Text that will appear if an error has occurred. + * @param array $htmlOptions HTML options array. + * @return string The formatted checkbox div + * @access public + */ + function generateCheckboxDiv($tagName, $prompt, $required = false, $errorMsg = null, $htmlOptions = null) { + $htmlOptions['class'] = "inputCheckbox"; + $str = $this->Html->checkbox($tagName, null, $htmlOptions); + $strLabel = $this->labelTag($tagName, $prompt); + $divClass = "optional"; + if ($required) { + $divClass = "required"; + } + $strError = ""; + + if ($this->isFieldError($tagName)) { + $strError = $this->pTag('error', $errorMsg); + $divClass = sprintf("%s error", $divClass); + } + $divTagInside = sprintf("%s %s %s", $strError, $strLabel, $str); + return $this->divTag($divClass, $divTagInside); + } +/** + * Returns a formatted date option element for HTML FORMs. + * + * @param string $tagName This should be "Modelname/fieldname" + * @param string $prompt Text that will appear in the label field. + * @param bool $required True if this field is a required field. + * @param string $errorMsg Text that will appear if an error has occurred. + * @param int $size Not used. + * @param array $htmlOptions HTML options array + * @return string Date option wrapped in a div. + * @todo Remove the $size parameter from this method. + * @access public + */ + function generateDate($tagName, $prompt, $required = false, $errorMsg = null, $size = 20, $htmlOptions = null, $selected = null) { + $str = $this->Html->dateTimeOptionTag($tagName, 'MDY', 'NONE', $selected, $htmlOptions); + $strLabel = $this->labelTag($tagName, $prompt); + $divClass = "optional"; + if ($required) { + $divClass = "required"; + } + $strError = ""; + + if ($this->isFieldError($tagName)) { + $strError = $this->pTag('error', $errorMsg); + $divClass = sprintf("%s error", $divClass); + } + $divTagInside = sprintf("%s %s %s", $strError, $strLabel, $str); + $requiredDiv = $this->divTag($divClass, $divTagInside); + return $this->divTag("date", $requiredDiv); + } +/** + * Returns a formatted date option element for HTML FORMs. + * + * @param string $tagName This should be "Modelname/fieldname" + * @param string $prompt Text that will appear in the label field. + * @param bool $required True if this field is a required field. + * @param string $errorMsg Text that will appear if an error has occurred. + * @param int $size Not used. + * @param array $htmlOptions HTML options array + * @return string Date option wrapped in a div. + * @todo Remove the $size parameter from this method. + * @access public + */ + function generateTime($tagName, $prompt, $required = false, $errorMsg = null, $size = 20, $htmlOptions = null, $selected = null) { + $str = $this->Html->dateTimeOptionTag($tagName, 'NONE', '24', $selected, $htmlOptions); + $strLabel = $this->labelTag($tagName, $prompt); + $divClass = "optional"; + if ($required) { + $divClass = "required"; + } + $strError = ""; + + if ($this->isFieldError($tagName)) { + $strError = $this->pTag('error', $errorMsg); + $divClass = sprintf("%s error", $divClass); + } + $divTagInside = sprintf("%s %s %s", $strError, $strLabel, $str); + $requiredDiv = $this->divTag($divClass, $divTagInside); + return $this->divTag("time", $requiredDiv); + } +/** + * Returns a formatted year option element for HTML FORMs. + * + * @param string $tagName This should be "Modelname/fieldname" + * @param string $prompt Text that will appear in the label field. + * @param bool $required True if this field is a required field. + * @param string $errorMsg Text that will appear if an error has occurred. + * @param int $size Not used. + * @param array $htmlOptions HTML options array + * @return string Date option wrapped in a div. + * @todo Remove the $size parameter from this method. + * @access public + */ + function generateYear($tagName, $prompt, $required = false, $errorMsg = null, $size = 20, $htmlOptions = null, $selected = null) { + $str = $this->Html->dateTimeOptionTag($tagName, 'Y', 'NONE', $selected, $htmlOptions); + $strLabel = $this->labelTag($tagName, $prompt); + $divClass = "optional"; + if ($required) { + $divClass = "required"; + } + $strError = ""; + + if ($this->isFieldError($tagName)) { + $strError = $this->pTag('error', $errorMsg); + $divClass = sprintf("%s error", $divClass); + } + $divTagInside = sprintf("%s %s %s", $strError, $strLabel, $str); + $requiredDiv = $this->divTag($divClass, $divTagInside); + return $this->divTag("year", $requiredDiv); + } +/** + * Returns a formatted datetime option element for HTML FORMs. + * + * @param string $tagName This should be "Modelname/fieldname" + * @param string $prompt Text that will appear in the label field. + * @param bool $required True if this field is required. + * @param string $errorMsg Text that will appear if an error has occurred. + * @param int $size Not used. + * @param array $htmlOptions HTML options array + * @param array $selected Selected index in the dateTimeOption tag. + * @return string The formatted datetime option element wrapped in a div. + * @todo Remove the $size parameter from this method. + * @access public + */ + function generateDateTime($tagName, $prompt, $required = false, $errorMsg = null, $size = 20, $htmlOptions = null, $selected = null) { + $str = $this->Html->dateTimeOptionTag($tagName, 'MDY', '12', $selected, $htmlOptions); + $strLabel = $this->labelTag($tagName, $prompt); + $divClass = "optional"; + if ($required) { + $divClass = "required"; + } + $strError = ""; + + if ($this->isFieldError($tagName)) { + $strError = $this->pTag('error', $errorMsg); + $divClass = sprintf("%s error", $divClass); + } + $divTagInside = sprintf("%s %s %s", $strError, $strLabel, $str); + $requiredDiv = $this->divTag($divClass, $divTagInside); + return $this->divTag("date", $requiredDiv); + } +/** + * Returns a formatted TEXTAREA inside a DIV for use with HTML forms. + * + * @param string $tagName This should be "Modelname/fieldname" + * @param string $prompt Text that will appear in the label field. + * @param boolean $required True if this field is required. + * @param string $errorMsg ext that will appear if an error has occurred. + * @param integer $cols Number of columns. + * @param integer $rows Number of rows. + * @param array $htmlOptions HTML options array. + * @return string The formatted TEXTAREA element, wrapped in a div. + * @access public + */ + function generateAreaDiv($tagName, $prompt, $required = false, $errorMsg = null, $cols = 60, $rows = 10, $htmlOptions = null) { + $htmlAttributes = $htmlOptions; + $htmlAttributes['cols'] = $cols; + $htmlAttributes['rows'] = $rows; + $str = $this->Html->textarea($tagName, $htmlAttributes); + $strLabel = $this->labelTag($tagName, $prompt); + $divClass = "optional"; + + if ($required) { + $divClass="required"; + } + $strError = ""; + + if ($this->isFieldError($tagName)) { + $strError = $this->pTag('error', $errorMsg); + $divClass = sprintf("%s error", $divClass); + } + $divTagInside = sprintf("%s %s %s", $strError, $strLabel, $str); + return $this->divTag($divClass, $divTagInside); + } +/** + * Returns a formatted SELECT tag for HTML FORMs. + * + * @param string $tagName This should be "Modelname/fieldname" + * @param string $prompt Text that will appear in the label field + * @param array $options Options to be contained in SELECT element + * @param string $selected Currently selected item + * @param array $selectAttr Array of HTML attributes for the SELECT element + * @param array $optionAttr Array of HTML attributes for the OPTION elements + * @param bool $required True if this field is required + * @param string $errorMsg Text that will appear if an error has occurred + * @return string The formatted INPUT element, wrapped in a div + * @access public + */ + function generateSelectDiv($tagName, $prompt, $options, $selected = null, $selectAttr = null, $optionAttr = null, $required = false, $errorMsg = null) { + $str = $this->Html->selectTag($tagName, $options, $selected, $selectAttr, $optionAttr); + $strLabel = $this->labelTag($tagName, $prompt); + $divClass = "optional"; + + if ($required) { + $divClass = "required"; + } + $strError = ""; + + if ($this->isFieldError($tagName)) { + $strError=$this->pTag('error', $errorMsg); + $divClass=sprintf("%s error", $divClass); + } + $divTagInside = sprintf("%s %s %s", $strError, $strLabel, $str); + return $this->divTag($divClass, $divTagInside); + } +/** + * Returns a formatted submit widget for HTML FORMs. + * + * @param string $displayText Text that will appear on the widget + * @param array $htmlOptions HTML options array + * @return string The formatted submit widget + * @access public + */ + function generateSubmitDiv($displayText, $htmlOptions = null) { + return $this->divTag('submit', $this->Html->submit($displayText, $htmlOptions)); + } +/** + * Generates a form to go onto a HtmlHelper object. + * + * @param array $fields An array of form field definitions + * @param boolean $readOnly True if the form should be rendered as READONLY + * @return string The completed form specified by the $fields parameter + * @access public + */ + function generateFields($fields, $readOnly = false) { + $strFormFields = ''; + + foreach ($fields as $field) { + if (isset($field['type'])) { + + if (!isset($field['required'])) { + $field['required'] = false; + } + + if (!isset($field['errorMsg'])) { + $field['errorMsg'] = null; + } + + if (!isset($field['htmlOptions'])) { + $field['htmlOptions'] = array(); + } + + if ($readOnly) { + $field['htmlOptions']['READONLY'] = "readonly"; + } + + switch($field['type']) { + case "input": + if (!isset($field['size'])) { + $field['size'] = 40; + } + $strFormFields = $strFormFields . $this->generateInputDiv($field['tagName'], $field['prompt'], + $field['required'], $field['errorMsg'], $field['size'], $field['htmlOptions']); + break; + case "checkbox": + $strFormFields = $strFormFields . $this->generateCheckboxDiv($field['tagName'], $field['prompt'], + $field['required'], $field['errorMsg'], $field['htmlOptions']); + break; + case "select": + case "selectMultiple": + if ("selectMultiple" == $field['type']) { + $field['selectAttr']['multiple'] = 'multiple'; + $field['selectAttr']['class'] = 'selectMultiple'; + } + + if (!isset($field['selected'])) { + $field['selected'] = null; + } + + if (!isset($field['selectAttr'])) { + $field['selectAttr'] = null; + } + + if (!isset($field['optionsAttr'])) { + $field['optionsAttr'] = null; + } + + if ($readOnly) { + $field['selectAttr']['DISABLED'] = true; + } + + if (!isset($field['options'])) { + $field['options'] = null; + } + $strFormFields = $strFormFields . $this->generateSelectDiv($field['tagName'], $field['prompt'], $field['options'], + $field['selected'], $field['selectAttr'], $field['optionsAttr'], $field['required'], $field['errorMsg']); + break; + case "area": + if (!isset($field['rows'])) { + $field['rows'] = 10; + } + + if (!isset($field['cols'])) { + $field['cols'] = 60; + } + $strFormFields = $strFormFields . $this->generateAreaDiv($field['tagName'], $field['prompt'], + $field['required'], $field['errorMsg'], $field['cols'], $field['rows'], $field['htmlOptions']); + break; + case "fieldset": + $strFieldsetFields = $this->generateFields($field['fields']); + $strFieldSet = sprintf(' <fieldset><legend>%s</legend><div class="notes"><h4>%s</h4><p class="last">%s</p></div>%s</fieldset>', + $field['legend'], $field['noteHeading'], $field['note'], $strFieldsetFields); + $strFormFields = $strFormFields . $strFieldSet; + break; + case "hidden": + if (!isset($field['value'])) { + $field['value'] = null; + } + $strFormFields = $strFormFields . $this->Html->hidden($field['tagName'], $field['value']); + break; + case "date": + if (!isset($field['selected'])) { + $field['selected'] = null; + } + $strFormFields = $strFormFields . $this->generateDate($field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], null, $field['htmlOptions'], $field['selected']); + break; + case "datetime": + if (!isset($field['selected'])) { + $field['selected'] = null; + } + $strFormFields = $strFormFields . $this->generateDateTime($field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], null, $field['htmlOptions'], $field['selected']); + break; + case "time": + if (!isset($field['selected'])) { + $field['selected'] = null; + } + $strFormFields = $strFormFields . $this->generateTime($field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], null, $field['htmlOptions'], $field['selected']); + break; + case "year": + if (!isset($field['selected'])) { + $field['selected'] = null; + } + $strFormFields = $strFormFields . $this->generateYear($field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], null, $field['htmlOptions'], $field['selected']); + break; + default: + break; + } + } + } + return $strFormFields; + } +} +?>
\ No newline at end of file diff --git a/site/cake/libs/view/helpers/html.php b/site/cake/libs/view/helpers/html.php new file mode 100644 index 0000000..a69c7dd --- /dev/null +++ b/site/cake/libs/view/helpers/html.php @@ -0,0 +1,1257 @@ +<?php +/* SVN FILE: $Id: html.php 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * Html Helper class file. + * + * Simplifies the construction of HTML elements. + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.helpers + * @since CakePHP(tm) v 0.9.1 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +/** + * Html Helper class for easy use of HTML widgets. + * + * HtmlHelper encloses all methods needed while working with HTML pages. + * + * @package cake + * @subpackage cake.cake.libs.view.helpers + */ +class HtmlHelper extends Helper { +/** + * Base URL + * + * @var string + * @access public + */ + var $base = null; +/** + * URL to current action. + * + * @var string + * @access public + */ + var $here = null; +/** + * Parameter array. + * + * @var array + * @access public + */ + var $params = array(); +/** + * Current action. + * + * @var string + * @access public + */ + var $action = null; +/** + * Controller::data; + * + * @var array + * @access public + */ + var $data = null; +/** + * Name of model this helper is attached to. + * + * @var string + * @access public + */ + var $model = null; +/** + * + * @var string + * @access public + */ + var $field = null; +/** + * Breadcrumbs. + * + * @var array + * @access protected + */ + var $_crumbs = array(); +/** + * Adds a link to the breadcrumbs array. + * + * @param string $name Text for link + * @param string $link URL for link + * @return void + * @access public + */ + function addCrumb($name, $link) { + $this->_crumbs[] = array($name, $link); + } +/** + * Returns a charset META-tag. + * + * @param string $charset + * @param boolean $return Wheter this method should return a value or output it. This overrides AUTO_OUTPUT. + * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return. + * @access public + */ + function charset($charset = null, $return = false) { + if (is_null($charset)) { + $charset = 'utf-8'; + } + return $this->output(sprintf($this->tags['charset'], $charset), $return); + } +/** + * Finds URL for specified action. + * + * Returns an URL pointing to a combination of controller and action. Param + * $url can be: + * + Empty - the method will find adress to actuall controller/action. + * + '/' - the method will find base URL of application. + * + A combination of controller/action - the method will find url for it. + * + * @param string $url Cake-relative URL, like "/products/edit/92" or "/presidents/elect/4" + * @param boolean $return Wheter this method should return a value or output it. This overrides AUTO_OUTPUT. + * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return. + * @access public + */ + function url($url = null, $return = false) { + if (isset($this->plugin)) { + $base = strip_plugin($this->base, $this->plugin); + } else { + $base = $this->base; + } + + if (empty($url)) { + return $this->here; + } elseif ($url{0} == '/') { + $output = $base . $url; + } else { + $output = $base . '/' . Inflector::underscore($this->params['controller']) . '/' . $url; + } + + return $this->output($output, $return); + } +/** + * Creates an HTML link. + * + * If $url starts with "http://" this is treated as an external link. Else, + * it is treated as a path to controller/action and parsed with the + * HtmlHelper::url() method. + * + * If the $url is empty, $title is used instead. + * + * @param string $title The content of the A tag. + * @param string $url Cake-relative URL, or external URL (starts with http://) + * @param array $htmlAttributes Array of HTML attributes. + * @param string $confirmMessage Confirmation message. + * @param boolean $escapeTitle Whether or not the text in the $title variable should be HTML escaped. + * @param boolean $return Wheter this method should return a value or output it. This overrides AUTO_OUTPUT. + * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return. + * @access public + */ + function link($title, $url = null, $htmlAttributes = array(), $confirmMessage = false, $escapeTitle = true, $return = false) { + if ($escapeTitle === true) { + $title = htmlspecialchars($title, ENT_QUOTES); + } elseif (is_string($escapeTitle)) { + $title = htmlentities($title, ENT_QUOTES); + } + $url = $url ? $url : $title; + + if ($confirmMessage) { + $confirmMessage = str_replace("'", "\'", $confirmMessage); + $confirmMessage = str_replace('"', '\"', $confirmMessage); + $htmlAttributes['onclick']="return confirm('{$confirmMessage}');"; + } + + if (((strpos($url, '://')) || (strpos($url, 'javascript:') === 0) || (strpos($url, 'mailto:') === 0) || substr($url,0,1) == '#')) { + $output = sprintf($this->tags['link'], $url, $this->_parseAttributes($htmlAttributes), $title); + } else { + $output = sprintf($this->tags['link'], $this->url($url, true), $this->_parseAttributes($htmlAttributes), $title); + } + return $this->output($output, $return); + } +/** + * Creates a submit widget. + * + * @param string $caption Text on submit button + * @param array $htmlAttributes Array of HTML attributes. + * @param boolean $return Wheter this method should return a value or output it. This overrides AUTO_OUTPUT. + * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return. + * @access public + */ + function submit($caption = 'Submit', $htmlAttributes = array(), $return = false) { + $htmlAttributes['value'] = $caption; + return $this->output(sprintf($this->tags['submit'], $this->_parseAttributes($htmlAttributes, null, '', ' ')), $return); + } +/** + * Creates a password input widget. + * + * @param string $fieldName Name of a field, like this "Modelname/fieldname" + * @param array $htmlAttributes Array of HTML attributes. + * @param boolean $return Wheter this method should return a value or output it. This overrides AUTO_OUTPUT. + * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return. + * @access public + */ + function password($fieldName, $htmlAttributes = array(), $return = false) { + $this->setFormTag($fieldName); + if (!isset($htmlAttributes['value'])) { + $htmlAttributes['value'] = $this->tagValue($fieldName); + } + if (!isset($htmlAttributes['id'])) { + $htmlAttributes['id'] = $this->model . Inflector::camelize($this->field); + } + + if ($this->tagIsInvalid($this->model, $this->field)) { + if (isset($htmlAttributes['class']) && trim($htmlAttributes['class']) != "") { + $htmlAttributes['class'] .= ' form_error'; + } else { + $htmlAttributes['class'] = 'form_error'; + } + } + return $this->output(sprintf($this->tags['password'], $this->model, $this->field, $this->_parseAttributes($htmlAttributes, null, ' ', ' ')), $return); + } +/** + * Creates a textarea widget. + * + * @param string $fieldName Name of a field, like this "Modelname/fieldname" + * @param array $htmlAttributes Array of HTML attributes. + * @param boolean $return Wheter this method should return a value or output it. This overrides AUTO_OUTPUT. + * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return. + * @access public + */ + function textarea($fieldName, $htmlAttributes = array(), $return = false) { + $this->setFormTag($fieldName); + $value = $this->tagValue($fieldName); + if (!empty($htmlAttributes['value'])) { + $value = $htmlAttributes['value']; + unset($htmlAttributes['value']); + } + if (!isset($htmlAttributes['id'])) { + $htmlAttributes['id'] = $this->model . Inflector::camelize($this->field); + } + + if ($this->tagIsInvalid($this->model, $this->field)) { + if (isset($htmlAttributes['class']) && trim($htmlAttributes['class']) != "") { + $htmlAttributes['class'] .= ' form_error'; + } else { + $htmlAttributes['class'] = 'form_error'; + } + } + return $this->output(sprintf($this->tags['textarea'], $this->model, $this->field, $this->_parseAttributes($htmlAttributes, null, ' '), $value), $return); + } +/** + * Creates a checkbox widget. + * + * @param string $fieldName Name of a field, like this "Modelname/fieldname" + * @deprecated string $title + * @param array $htmlAttributes Array of HTML attributes. + * @param boolean $return Wheter this method should return a value or output it. This overrides AUTO_OUTPUT. + * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return. + * @access public + */ + function checkbox($fieldName, $title = null, $htmlAttributes = array(), $return = false) { + $value = $this->tagValue($fieldName); + $notCheckedValue = 0; + + if (!isset($htmlAttributes['id'])) { + $htmlAttributes['id'] = $this->model . Inflector::camelize($this->field); + } + + if (isset($htmlAttributes['checked'])) { + if ($htmlAttributes['checked'] == 'checked' || intval($htmlAttributes['checked']) === 1 || $htmlAttributes['checked'] === true) { + $htmlAttributes['checked'] = 'checked'; + } else { + $htmlAttributes['checked'] = null; + $notCheckedValue = -1; + } + } else { + if (isset($htmlAttributes['value']) || (!class_exists($this->model) && !loadModel($this->model))) { + $htmlAttributes['checked'] = ($htmlAttributes['value'] == $value) ? 'checked' : null; + + if ($htmlAttributes['value'] == '0') { + $notCheckedValue = -1; + } + } else { + $model = new $this->model; + $db =& ConnectionManager::getDataSource($model->useDbConfig); + $value = $db->boolean($value); + $htmlAttributes['checked'] = $value ? 'checked' : null; + $htmlAttributes['value'] = 1; + } + } + + $output = $this->hidden($fieldName, array('value' => $notCheckedValue, 'id' => $htmlAttributes['id'] . '_'), true); + $output .= sprintf($this->tags['checkbox'], $this->model, $this->field, $this->_parseAttributes($htmlAttributes, null, '', ' ')); + return $this->output($output, $return); + } +/** + * Creates a link element for CSS stylesheets. + * + * @param string $path Path to CSS file + * @param string $rel Rel attribute. Defaults to "stylesheet". + * @param array $htmlAttributes Array of HTML attributes. + * @param boolean $return Wheter this method should return a value or output it. This overrides AUTO_OUTPUT. + * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return. + * @access public + */ + function css($path, $rel = 'stylesheet', $htmlAttributes = array(), $return = false) { + $url = "{$this->webroot}" . (COMPRESS_CSS ? 'c' : '') . $this->themeWeb . CSS_URL . $path . ".css"; + + if ($rel == 'import') { + return $this->output(sprintf($this->tags['style'], $this->parseHtmlOptions($htmlAttributes, null, '', ' '), '@import url(' . $url . ');'), $return); + } else { + return $this->output(sprintf($this->tags['css'], $rel, $url, $this->parseHtmlOptions($htmlAttributes, null, '', ' ')), $return); + } + } +/** + * Creates file input widget. + * + * @param string $fieldName Name of a field, like this "Modelname/fieldname" + * @param array $htmlAttributes Array of HTML attributes. + * @param boolean $return Wheter this method should return a valueor output it. This overrides AUTO_OUTPUT. + * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return. + * @access public + */ + function file($fieldName, $htmlAttributes = array(), $return = false) { + if (strpos($fieldName, '/')) { + $this->setFormTag($fieldName); + if (!isset($htmlAttributes['id'])) { + $htmlAttributes['id'] = $this->model . Inflector::camelize($this->field); + } + return $this->output(sprintf($this->tags['file'], $this->model, $this->field, $this->_parseAttributes($htmlAttributes, null, '', ' ')), $return); + } + return $this->output(sprintf($this->tags['file_no_model'], $fieldName, $this->_parseAttributes($htmlAttributes, null, '', ' ')), $return); + } +/** + * Returns the breadcrumb trail as a sequence of »-separated links. + * + * @param string $separator Text to separate crumbs. + * @param string $startText This will be the first crumb, if false it defaults to first crumb in array + * @param boolean $return Wheter this method should return a value or output it. This overrides AUTO_OUTPUT. + * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return. If $this->_crumbs is empty, return null. + * @access public + */ + function getCrumbs($separator = '»', $startText = false, $return = false) { + if (count($this->_crumbs)) { + $out = array(); + if ($startText) { + $out[] = $this->link($startText, '/'); + } + + foreach ($this->_crumbs as $crumb) { + $out[] = $this->link($crumb[0], $crumb[1]); + } + return $this->output(join($separator, $out), $return); + } else { + return null; + } + } +/** + * Creates a hidden input field. + * + * @param string $fieldName Name of a field, like this "Modelname/fieldname" + * @param array $htmlAttributes Array of HTML attributes. + * @param boolean $return Wheter this method should return a value or output it. This overrides AUTO_OUTPUT. + * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return. + * @access public + */ + function hidden($fieldName, $htmlAttributes = array(), $return = false) { + $this->setFormTag($fieldName); + if (!isset($htmlAttributes['value'])) { + $htmlAttributes['value'] = $this->tagValue($fieldName); + } + if (!isset($htmlAttributes['id'])) { + $htmlAttributes['id'] = $this->model . Inflector::camelize($this->field); + } + return $this->output(sprintf($this->tags['hidden'], $this->model, $this->field, $this->_parseAttributes($htmlAttributes, null, ' ', ' ')), $return); + } +/** + * Creates a formatted IMG element. + * + * @param string $path Path to the image file, relative to the webroot/img/ directory. + * @param array $htmlAttributes Array of HTML attributes. + * @param boolean $return Wheter this method should return a value or output it. This overrides AUTO_OUTPUT. + * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return. + * @access public + */ + function image($path, $htmlAttributes = array(), $return = false) { + if (strpos($path, '://')) { + $url = $path; + } else { + $url = $this->webroot . $this->themeWeb . IMAGES_URL . $path; + } + return $this->output(sprintf($this->tags['image'], $url, $this->parseHtmlOptions($htmlAttributes, null, '', ' ')), $return); + } +/** + * Creates a text input widget. + * + * @param string $fieldNamem Name of a field, like this "Modelname/fieldname" + * @param array $htmlAttributes Array of HTML attributes. + * @param boolean $return Wheter this method should return a value or output it. This overrides AUTO_OUTPUT. + * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return. + * @access public + */ + function input($fieldName, $htmlAttributes = array(), $return = false) { + $this->setFormTag($fieldName); + if (!isset($htmlAttributes['value'])) { + $htmlAttributes['value'] = $this->tagValue($fieldName); + } + + if (!isset($htmlAttributes['type'])) { + $htmlAttributes['type'] = 'text'; + } + + if (!isset($htmlAttributes['id'])) { + $htmlAttributes['id'] = $this->model . Inflector::camelize($this->field); + } + + if ($this->tagIsInvalid($this->model, $this->field)) { + if (isset($htmlAttributes['class']) && trim($htmlAttributes['class']) != "") { + $htmlAttributes['class'] .= ' form_error'; + } else { + $htmlAttributes['class'] = 'form_error'; + } + } + return $this->output(sprintf($this->tags['input'], $this->model, $this->field, $this->_parseAttributes($htmlAttributes, null, ' ', ' ')), $return); + } + /** + * Returns a formatted SELECT element. + * + * @param string $fieldName Name attribute of the SELECT + * @param array $optionElements Array of the OPTION elements (as 'value'=>'Text' pairs) to be used in the SELECT element + * @param mixed $selected Selected option + * @param array $selectAttr Array of HTML options for the opening SELECT element + * @param array $optionAttr Array of HTML options for the enclosed OPTION elements + * @param boolean $show_empty If true, the empty select option is shown + * @param boolean $return Whether this method should return a value + * @return string Formatted SELECT element + * @access public + */ + function selectTag($fieldName, $optionElements, $selected = null, $selectAttr = array(), $optionAttr = null, $showEmpty = true, $return = false) { + $this->setFormTag($fieldName); + if ($this->tagIsInvalid($this->model, $this->field)) { + if (isset($selectAttr['class']) && trim($selectAttr['class']) != "") { + $selectAttr['class'] .= ' form_error'; + } else { + $selectAttr['class'] = 'form_error'; + } + } + if (!isset($selectAttr['id'])) { + $selectAttr['id'] = $this->model . Inflector::camelize($this->field); + } + + if (!is_array($optionElements)) { + return null; + } + + if (!isset($selected)) { + $selected = $this->tagValue($fieldName); + } + + if (isset($selectAttr) && array_key_exists("multiple", $selectAttr)) { + $select[] = sprintf($this->tags['selectmultiplestart'], $this->model, $this->field, $this->parseHtmlOptions($selectAttr)); + } else { + $select[] = sprintf($this->tags['selectstart'], $this->model, $this->field, $this->parseHtmlOptions($selectAttr)); + } + + if ($showEmpty == true) { + $select[] = sprintf($this->tags['selectempty'], $this->parseHtmlOptions($optionAttr)); + } + + foreach ($optionElements as $name => $title) { + $optionsHere = $optionAttr; + + if (($selected != null) && ($selected == $name)) { + $optionsHere['selected'] = 'selected'; + } elseif (is_array($selected) && in_array($name, $selected)) { + $optionsHere['selected'] = 'selected'; + } + + $select[] = sprintf($this->tags['selectoption'], $name, $this->parseHtmlOptions($optionsHere), h($title)); + } + + $select[] = sprintf($this->tags['selectend']); + return $this->output(implode("\n", $select), $return); + } +/** + * Creates a set of radio widgets. + * + * @param string $fieldName Name of a field, like this "Modelname/fieldname" + * @param array $options Radio button options array + * @param array $inbetween String that separates the radio buttons. + * @param array $htmlAttributes Array of HTML attributes. + * @param boolean $return Wheter this method should return a value or output it. This overrides AUTO_OUTPUT. + * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return. + * @access public + */ + function radio($fieldName, $options, $inbetween = null, $htmlAttributes = array(), $return = false) { + + $this->setFormTag($fieldName); + $value = isset($htmlAttributes['value']) ? $htmlAttributes['value'] : $this->tagValue($fieldName); + $out = array(); + + foreach ($options as $optValue => $optTitle) { + $optionsHere = array('value' => $optValue); + if ($value !== false && $optValue == $value) { + $optionsHere['checked'] = 'checked'; + } + $parsedOptions = $this->parseHtmlOptions(array_merge($htmlAttributes, $optionsHere), null, '', ' '); + $individualTagName = "{$this->field}_{$optValue}"; + $out[] = sprintf($this->tags['radio'], $this->model, $this->field, $individualTagName, $parsedOptions, $optTitle); + } + + $out = join($inbetween, $out); + return $this->output($out ? $out : null, $return); + } +/** + * Returns a SELECT element for days. + * + * @param string $tagName Prefix name for the SELECT element + * @deprecated string $value + * @param string $selected Option which is selected. + * @param array $optionAttr Attribute array for the option elements. + * @param boolean $showEmpty Show/hide the empty select option + * @return mixed + * @access public + */ + function dayOptionTag($tagName, $value = null, $selected = null, $selectAttr = null, $optionAttr = null, $showEmpty = true) { + if (empty($selected) && $this->tagValue($tagName)) { + $selected = date('d', strtotime($this->tagValue($tagName))); + } + $dayValue = empty($selected) ? ($showEmpty == true ? NULL : date('d')) : $selected; + $days = array('01' => '1', '02' => '2', '03' => '3', '04' => '4', '05' => '5', '06' => '6', '07' => '7', '08' => '8', '09' => '9', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20', '21' => '21', '22' => '22', '23' => '23', '24' => '24', '25' => '25', '26' => '26', '27' => '27', '28' => '28', '29' => '29', '30' => '30', '31' => '31'); + $option = $this->selectTag($tagName . "_day", $days, $dayValue, $selectAttr, $optionAttr, $showEmpty); + return $option; + } +/** + * Returns a SELECT element for years + * + * @param string $tagName Prefix name for the SELECT element + * @deprecated string $value + * @param integer $minYear First year in sequence + * @param integer $maxYear Last year in sequence + * @param string $selected Option which is selected. + * @param array $optionAttr Attribute array for the option elements. + * @param boolean $showEmpty Show/hide the empty select option + * @return mixed + * @access public + */ + function yearOptionTag($tagName, $value = null, $minYear = null, $maxYear = null, $selected = null, $selectAttr = null, $optionAttr = null, $showEmpty = true) { + if (empty($selected) && ($this->tagValue($tagName))) { + $selected = date('Y', strtotime($this->tagValue($tagName))); + } + + $yearValue = empty($selected) ? ($showEmpty ? NULL : date('Y')) : $selected; + $currentYear = date('Y'); + $maxYear = is_null($maxYear) ? $currentYear + 11 : $maxYear + 1; + $minYear = is_null($minYear) ? $currentYear - 60 : $minYear; + + if ($minYear > $maxYear) { + $tmpYear = $minYear; + $minYear = $maxYear; + $maxYear = $tmpYear; + } + + $minYear = $currentYear < $minYear ? $currentYear : $minYear; + $maxYear = $currentYear > $maxYear ? $currentYear : $maxYear; + + for ($yearCounter = $minYear; $yearCounter < $maxYear; $yearCounter++) { + $years[$yearCounter] = $yearCounter; + } + + return $this->selectTag($tagName . "_year", $years, $yearValue, $selectAttr, $optionAttr, $showEmpty); + } +/** + * Returns a SELECT element for months. + * + * @param string $tagName Prefix name for the SELECT element + * @deprecated string $value + * @param string $selected Option which is selected. + * @param array $optionAttr Attribute array for the option elements. + * @param boolean $showEmpty Show/hide the empty select option + * @return mixed + * @access public + */ + function monthOptionTag($tagName, $value = null, $selected = null, $selectAttr = null, $optionAttr = null, $showEmpty = true) { + if (empty($selected) && ($this->tagValue($tagName))) { + $selected = date('m', strtotime($this->tagValue($tagName))); + } + $monthValue = empty($selected) ? ($showEmpty ? NULL : date('m')) : $selected; + $months = array('01' => 'January', '02' => 'February', '03' => 'March', '04' => 'April', '05' => 'May', '06' => 'June', '07' => 'July', '08' => 'August', '09' => 'September', '10' => 'October', '11' => 'November', '12' => 'December'); + + return $this->selectTag($tagName . "_month", $months, $monthValue, $selectAttr, $optionAttr, $showEmpty); + } +/** + * Returns a SELECT element for hours. + * + * @param string $tagName Prefix name for the SELECT element + * @deprecated string $value + * @param boolean $format24Hours True for 24 hours format + * @param string $selected Option which is selected. + * @param array $optionAttr Attribute array for the option elements. + * @return mixed + * @access public + */ + function hourOptionTag($tagName, $value = null, $format24Hours = false, $selected = null, $selectAttr = null, $optionAttr = null, $showEmpty = true) { + if (empty($selected) && ($this->tagValue($tagName))) { + if ($format24Hours) { + $selected = date('H', strtotime($this->tagValue($tagName))); + } else { + $selected = date('g', strtotime($this->tagValue($tagName))); + } + } + if ($format24Hours) { + $hourValue = empty($selected) ? ($showEmpty ? NULL : date('H')) : $selected; + } else { + $hourValue = empty($selected) ? ($showEmpty ? NULL : date('g')) : $selected; + if (isset($selected) && intval($hourValue) == 0 && !$showEmpty) { + $hourValue = 12; + } + } + + if ($format24Hours) { + $hours = array('00' => '00', '01' => '01', '02' => '02', '03' => '03', '04' => '04', '05' => '05', '06' => '06', '07' => '07', '08' => '08', '09' => '09', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20', '21' => '21', '22' => '22', '23' => '23'); + } else { + $hours = array('01' => '1', '02' => '2', '03' => '3', '04' => '4', '05' => '5', '06' => '6', '07' => '7', '08' => '8', '09' => '9', '10' => '10', '11' => '11', '12' => '12'); + } + + $option = $this->selectTag($tagName . "_hour", $hours, $hourValue, $selectAttr, $optionAttr, $showEmpty); + return $option; + } +/** + * Returns a SELECT element for minutes. + * + * @param string $tagName Prefix name for the SELECT element + * @deprecated string $value + * @param string $selected Option which is selected. + * @param array $optionAttr Attribute array for the option elements. + * @return mixed + * @access public + */ + function minuteOptionTag($tagName, $value = null, $selected = null, $selectAttr = null, $optionAttr = null, $showEmpty = true) { + if (empty($selected) && ($this->tagValue($tagName))) { + $selected = date('i', strtotime($this->tagValue($tagName))); + } + $minValue = empty($selected) ? ($showEmpty ? NULL : date('i')) : $selected; + + for ($minCount = 0; $minCount < 60; $minCount++) { + $mins[sprintf('%02d', $minCount)] = sprintf('%02d', $minCount); + } + $option = $this->selectTag($tagName . "_min", $mins, $minValue, $selectAttr, $optionAttr, $showEmpty); + return $option; + } + +/** + * Returns a SELECT element for AM or PM. + * + * @param string $tagName Prefix name for the SELECT element + * @deprecated string $value + * @param string $selected Option which is selected. + * @param array $optionAttr Attribute array for the option elements. + * @return mixed + * @access public + */ + function meridianOptionTag($tagName, $value = null, $selected = null, $selectAttr = null, $optionAttr = null, $showEmpty = true) { + if (empty($selected) && ($this->tagValue($tagName))) { + $selected = date('a', strtotime($this->tagValue($tagName))); + } + $merValue = empty($selected) ? ($showEmpty ? NULL : date('a')) : $selected; + $meridians = array('am' => 'am', 'pm' => 'pm'); + + $option = $this->selectTag($tagName . "_meridian", $meridians, $merValue, $selectAttr, $optionAttr, $showEmpty); + return $option; + } +/** + * Returns a set of SELECT elements for a full datetime setup: day, month and year, and then time. + * + * @param string $tagName Prefix name for the SELECT element + * @param string $dateFormat DMY, MDY, YMD or NONE. + * @param string $timeFormat 12, 24, NONE + * @param string $selected Option which is selected. + * @param array $optionAttr Attribute array for the option elements. + * @return string The HTML formatted OPTION element + * @access public + */ + function dateTimeOptionTag($tagName, $dateFormat = 'DMY', $timeFormat = '12', $selected = null, $selectAttr = null, $optionAttr = null, $showEmpty = true) { + $day = null; + $month = null; + $year = null; + $hour = null; + $min = null; + $meridian = null; + + if (empty($selected)) { + $selected = $this->tagValue($tagName); + } + + if (!empty($selected)) { + + if (is_int($selected)) { + $selected = strftime('%Y-%m-%d %H:%M:%S', $selected); + } + + $meridian = 'am'; + $pos = strpos($selected, '-'); + if ($pos !== false) { + $date = explode('-', $selected); + $days = explode(' ', $date[2]); + $day = $days[0]; + $month = $date[1]; + $year = $date[0]; + } else { + $days[1] = $selected; + } + + if ($timeFormat != 'NONE' && !empty($timeFormat)) { + $time = explode(':', $days[1]); + $check = str_replace(':', '', $days[1]); + + if (($check > 115959) && $timeFormat == '12') { + $time[0] = $time[0] - 12; + $meridian = 'pm'; + } elseif ($time[0] > 12) { + $meridian = 'pm'; + } + + $hour = $time[0]; + $min = $time[1]; + } + } + + $elements = array('Day','Month','Year','Hour','Minute','Meridian'); + if (isset($selectAttr['id'])) { + if (is_string($selectAttr['id'])) { + // build out an array version + foreach ($elements as $element) { + $selectAttrName = 'select' . $element . 'Attr'; + ${$selectAttrName} = $selectAttr; + ${$selectAttrName}['id'] = $selectAttr['id'] . $element; + } + } elseif (is_array($selectAttr['id'])) { + // check for missing ones and build selectAttr for each element + foreach ($elements as $element) { + $selectAttrName = 'select' . $element . 'Attr'; + ${$selectAttrName} = $selectAttr; + ${$selectAttrName}['id'] = $selectAttr['id'][strtolower($element)]; + } + } + } else { + // build the selectAttrName with empty id's to pass + foreach ($elements as $element) { + $selectAttrName = 'select' . $element . 'Attr'; + ${$selectAttrName} = $selectAttr; + } + } + + switch($dateFormat) { + case 'DMY': // so uses the new selex + $opt = $this->dayOptionTag($tagName, null, $day, $selectDayAttr, $optionAttr, $showEmpty) . '-' . + $this->monthOptionTag($tagName, null, $month, $selectMonthAttr, $optionAttr, $showEmpty) . '-' . $this->yearOptionTag($tagName, null, null, null, $year, $selectYearAttr, $optionAttr, $showEmpty); + break; + case 'MDY': + $opt = $this->monthOptionTag($tagName, null, $month, $selectMonthAttr, $optionAttr, $showEmpty) . '-' . + $this->dayOptionTag($tagName, null, $day, $selectDayAttr, $optionAttr, $showEmpty) . '-' . $this->yearOptionTag($tagName, null, null, null, $year, $selectYearAttr, $optionAttr, $showEmpty); + break; + case 'YMD': + $opt = $this->yearOptionTag($tagName, null, null, null, $year, $selectYearAttr, $optionAttr, $showEmpty) . '-' . + $this->monthOptionTag($tagName, null, $month, $selectMonthAttr, $optionAttr, $showEmpty) . '-' . + $this->dayOptionTag($tagName, null, $day, $selectDayAttr, $optionAttr, $showEmpty); + break; + case 'Y': + $opt = $this->yearOptionTag($tagName, null, null, null, $selected, $selectYearAttr, $optionAttr, $showEmpty); + break; + case 'NONE': + default: + $opt = ''; + break; + } + + switch($timeFormat) { + case '24': + $opt .= $this->hourOptionTag($tagName, null, true, $hour, $selectHourAttr, $optionAttr, $showEmpty) . ':' . + $this->minuteOptionTag($tagName, null, $min, $selectMinuteAttr, $optionAttr, $showEmpty); + break; + case '12': + $opt .= $this->hourOptionTag($tagName, null, false, $hour, $selectHourAttr, $optionAttr, $showEmpty) . ':' . + $this->minuteOptionTag($tagName, null, $min, $selectMinuteAttr, $optionAttr, $showEmpty) . ' ' . + $this->meridianOptionTag($tagName, null, $meridian, $selectMeridianAttr, $optionAttr, $showEmpty); + break; + case 'NONE': + default: + $opt .= ''; + break; + } + return $opt; + } +/** + * Returns a row of formatted and named TABLE headers. + * + * @param array $names Array of tablenames. + * @param array $trOptions HTML options for TR elements. + * @param array $thOptions HTML options for TH elements. + * @param boolean $return Wheter this method should return a value + * @return string + * @access public + */ + function tableHeaders($names, $trOptions = null, $thOptions = null, $return = false) { + $out = array(); + foreach ($names as $arg) { + $out[] = sprintf($this->tags['tableheader'], $this->parseHtmlOptions($thOptions), $arg); + } + + $data = sprintf($this->tags['tablerow'], $this->parseHtmlOptions($trOptions), join(' ', $out)); + return $this->output($data, $return); + } +/** + * Returns a formatted string of table rows (TR's with TD's in them). + * + * @param array $data Array of table data + * @param array $oddTrOptionsHTML options for odd TR elements + * @param array $evenTrOptionsHTML options for even TR elements + * @param boolean $return Wheter this method should return a value + * @return string Formatted HTML + * @access public + */ + function tableCells($data, $oddTrOptions = null, $evenTrOptions = null, $return = false) { + if (empty($data[0]) || !is_array($data[0])) { + $data = array($data); + } + static $count = 0; + + foreach ($data as $line) { + $count++; + $cellsOut = array(); + + foreach ($line as $cell) { + $cellsOut[] = sprintf($this->tags['tablecell'], null, $cell); + } + $options = $this->parseHtmlOptions($count % 2 ? $oddTrOptions : $evenTrOptions); + $out[] = sprintf($this->tags['tablerow'], $options, join(' ', $cellsOut)); + } + return $this->output(join("\n", $out), $return); + } +/** + * Generates a nested unordered list tree from an array. + * + * @param array $data + * @param array $htmlAttributes + * @param string $bodyKey + * @param string $childrenKey + * @param boolean $return Wheter this method should return a value or output it. This overrides AUTO_OUTPUT. + * @return mixed Either string or echos the value, depends on AUTO_OUTPUT and $return. If $this->_crumbs is empty, return null. + * @access public + */ + function guiListTree($data, $htmlAttributes = array(), $bodyKey = 'body', $childrenKey = 'children', $return = false) { + $out="<ul" . $this->_parseAttributes($htmlAttributes) . ">\n"; + foreach ($data as $item) { + $out .= "<li>{$item[$bodyKey]}\n"; + if (isset($item[$childrenKey]) && is_array($item[$childrenKey]) && count($item[$childrenKey])) { + $out .= $this->guiListTree($item[$childrenKey], $htmlAttributes, $bodyKey, $childrenKey); + } + $out .= "</li>\n"; + } + $out .= "</ul>\n"; + return $this->output($out, $return); + } +/** + * Returns value of $fieldName. False if the tag does not exist. + * + * @param string $fieldName Fieldname as "Modelname/fieldname" string + * @return string htmlspecialchars Value of the named tag. + * @access public + */ + function tagValue($fieldName, $escape = false) { + $this->setFormTag($fieldName); + if (isset($this->params['data'][$this->model][$this->field])) { + return ife($escape, h($this->params['data'][$this->model][$this->field]), $this->params['data'][$this->model][$this->field]); + } elseif (isset($this->data[$this->model][$this->field])) { + return ife($escape, h($this->data[$this->model][$this->field]), $this->data[$this->model][$this->field]); + } + return false; + } +/** + * Returns false if given FORM field has no errors. Otherwise it returns the constant set in the array Model->validationErrors. + * + * @param string $model Model name as string + * @param string $field Fieldname as string + * @return boolean True on errors. + * @access public + */ + function tagIsInvalid($model, $field) { + return empty($this->validationErrors[$model][$field]) ? 0 : $this->validationErrors[$model][$field]; + } +/** + * Returns number of errors in a submitted FORM. + * + * @return int Number of errors + * @access public + */ + function validate() { + $args = func_get_args(); + $errors = call_user_func_array(array(&$this, 'validateErrors'), $args); + return count($errors); + } +/** + * Validates a FORM according to the rules set up in the Model. + * + * @return int Number of errors + * @access public + */ + function validateErrors() { + $objects = func_get_args(); + if (!count($objects)) { + return false; + } + + $errors = array(); + foreach ($objects as $object) { + $errors = array_merge($errors, $object->invalidFields($object->data)); + } + return $this->validationErrors = (count($errors) ? $errors : false); + } +/** + * Returns a formatted error message for given FORM field, NULL if no errors. + * + * @param string $field A field name, like "Modelname/fieldname" + * @param string $text Error message + * @return string If there are errors this method returns an error message, else NULL. + * @access public + */ + function tagErrorMsg($field, $text) { + $error = 1; + $this->setFormTag($field); + if ($error == $this->tagIsInvalid($this->model, $this->field)) { + return sprintf('<div class="error_message">%s</div>', is_array($text) ? (empty($text[$error - 1]) ? 'Error in field' : $text[$error - 1]) : $text); + } else { + return null; + } + } +/** + * Sets this helper's model and field properties to the slash-separated value-pair in $tagValue. + * + * @param string $tagValue A field name, like "Modelname/fieldname" + * @return + * @access public + */ + function setFormTag($tagValue) { + return list($this->model, $this->field) = explode("/", $tagValue); + } +/** + * Returns a space-delimited string with items of the $options array. If a + * key of $options array happens to be one of: + * + 'compact' + * + 'checked' + * + 'declare' + * + 'readonly' + * + 'disabled' + * + 'selected' + * + 'defer' + * + 'ismap' + * + 'nohref' + * + 'noshade' + * + 'nowrap' + * + 'multiple' + * + 'noresize' + * + * And its value is one of: + * + 1 + * + true + * + 'true' + * + * Then the value will be reset to be identical with key's name. + * If the value is not one of these 3, the parameter is not output. + * + * @param array $options Array of options. + * @param array $exclude Array of options to be excluded. + * @param string $insertBefore String to be inserted before options. + * @param string $insertAfter String to be inserted ater options. + * @return string + * @access protected + */ + function _parseAttributes($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) { + if (is_array($options)) { + $default = array ( + 'escape' => true + ); + $options = am($default, $options); + if (!is_array($exclude)) { + $exclude = array(); + } + $exclude = am($exclude, array('escape')); + $keys = array_diff(array_keys($options), $exclude); + $values = array_intersect_key(array_values($options), $keys); + $escape = $options['escape']; + $attributes = array(); + foreach ($keys as $index => $key) { + $attributes[] = $this->__formatAttribute($key, $values[$index], $escape); + } + $out = implode(' ', $attributes); + } else { + $out = $options; + } + return $out ? $insertBefore . $out . $insertAfter : ''; + } +/** + * @param string $key + * @param string $value + * @return string + * @access private + */ + function __formatAttribute($key, $value, $escape = true) { + $attribute = ''; + $attributeFormat = '%s="%s"'; + $minimizedAttributes = array('compact', 'checked', 'declare', 'readonly', 'disabled', 'selected', 'defer', 'ismap', 'nohref', 'noshade', 'nowrap', 'multiple', 'noresize'); + + if (in_array($key, $minimizedAttributes)) { + if ($value === 1 || $value === true || $value === 'true' || $value == $key) { + $attribute = sprintf($attributeFormat, $key, $key); + } + } else { + $attribute = sprintf($attributeFormat, $key, ife($escape, h($value), $value)); + } + return $attribute; + } +/** + * @deprecated Name changed to 'textarea'. Version 0.9.2. + * @see HtmlHelper::textarea() + */ + function areaTag($tagName, $cols = 60, $rows = 10, $htmlAttributes = array(), $return = false) { + $htmlAttributes['cols']=$cols; + $htmlAttributes['rows']=$rows; + return $this->textarea($tagName, $htmlAttributes, $return); + } +/** + * @deprecated Name changed to 'charset'. Version 0.9.2. + * @see HtmlHelper::charset() + */ + function charsetTag($charset, $return = false) { + return $this->charset($charset, $return); + } +/** + * @deprecated Name changed to 'checkbox'. Version 0.9.2. + * @see HtmlHelper::checkbox() + */ + function checkboxTag($fieldName, $title = null, $htmlAttributes = array(), $return = false) { + return $this->checkbox($fieldName, $title, $htmlAttributes, $return); + } +/** + * @deprecated Name changed to 'css'. Version 0.9.2. + * @see HtmlHelper::css() + */ + function cssTag($path, $rel = 'stylesheet', $htmlAttributes = array(), $return = false) { + return $this->css($path, $rel, $htmlAttributes, $return); + } +/** + * @deprecated Name changed to 'file'. Version 0.9.2. + * @see HtmlHelper::file() + */ + function fileTag($fieldName, $htmlAttributes = array(), $return = false) { + return $this->file($fieldName, $htmlAttributes, $return); + } +/** + * @deprecated Name changed to 'hidden'. Version 0.9.2. + * @see HtmlHelper::hidden() + */ + function hiddenTag($tagName, $value = null, $htmlOptions = null) { + $this->setFormTag($tagName); + $htmlOptions['value'] = $value ? $value : $this->tagValue($tagName); + return $this->output(sprintf($this->tags['hidden'], $this->model, $this->field, $this->parseHtmlOptions($htmlOptions, null, '', ' '))); + } +/** + * @deprecated Name changed to 'image'. Version 0.9.2. + * @see HtmlHelper::image() + */ + function imageTag($path, $alt = null, $htmlAttributes = array(), $return = false) { + $htmlAttributes['alt'] = $alt; + return $this->image($path, $htmlAttributes, $return); + } +/** + * @deprecated Name changed to 'input'. Version 0.9.2. + * @see HtmlHelper::input() + */ + function inputTag($tagName, $size = 20, $htmlOptions = null) { + $this->setFormTag($tagName); + $htmlOptions['value'] = isset($htmlOptions['value']) ? $htmlOptions['value'] : $this->tagValue($tagName); + $this->tagIsInvalid($this->model, $this->field) ? $htmlOptions['class'] = 'form_error' : null; + return $this->output(sprintf($this->tags['input'], $this->model, $this->field, $this->parseHtmlOptions($htmlOptions, null, '', ' '))); + } +/** + * @deprecated Unified with 'link'. Version 0.9.2. + * @see HtmlHelper::link() + */ + function linkOut($title, $url = null, $htmlAttributes = array(), $escapeTitle = true, $return = false) { + return $this->link($title, $url, $htmlAttributes, false, $escapeTitle, $return); + } +/** + * @deprecated Unified with 'link'. Version 0.9.2. + * @see HtmlHelper::link() + */ + function linkTo($title, $url, $htmlAttributes = array(), $confirmMessage = false, $escapeTitle = true, $return = false) { + return $this->link($title, $url, $htmlAttributes, $confirmMessage, $escapeTitle, $return); + } +/** + * @deprecated Name changed to '_parseAttributes'. Version 0.9.2. + * @see HtmlHelper::_parseAttributes() + */ + function parseHtmlOptions($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) { + if (!is_array($exclude)) + $exclude=array(); + + if (is_array($options)) { + $out=array(); + + foreach ($options as $k => $v) { + if (!in_array($k, $exclude)) { + $out[] = "{$k}=\"{$v}\""; + } + } + $out = join(' ', $out); + return $out ? $insertBefore . $out . $insertAfter : null; + } else { + return $options ? $insertBefore . $options . $insertAfter : null; + } + } +/** + * @deprecated Name changed to 'password'. Version 0.9.2. + * @see HtmlHelper::password() + */ + function passwordTag($fieldName, $size = 20, $htmlAttributes = array(), $return = false) { + $args = func_get_args(); + return call_user_func_array(array(&$this, + "password"), $args); + } +/** + * @deprecated Name changed to 'radio'. Version 0.9.2. + * @see HtmlHelper::radio() + */ + function radioTags($fieldName, $options, $inbetween = null, $htmlAttributes = array(), $return = false) { + return $this->radio($fieldName, $options, $inbetween, $htmlAttributes, $return); + } +/** + * @deprecated Name changed to 'url'. Version 0.9.2. + * @see HtmlHelper::url() + */ + function urlFor($url) { + return $this->url($url); + } +/** + * @deprecated Name changed to 'submit'. Version 0.9.2. + * @see HtmlHelper::submit() + */ + function submitTag() { + $args = func_get_args(); + return call_user_func_array(array(&$this, "submit"), $args); + } +/************************************************************************* + * Moved methods + *************************************************************************/ +/** + * @deprecated Moved to TextHelper. Version 0.9.2. + */ + function trim() { + die("Method HtmlHelper::trim() was moved to TextHelper::trim()."); + } +/** + * @deprecated Moved to JavascriptHelper. Version 0.9.2. + */ + function javascriptIncludeTag($url) { + die("Method HtmlHelper::javascriptIncludeTag() was moved to JavascriptHelper::link()."); + } +/** + * @deprecated Moved to JavascriptHelper. Version 0.9.2. + */ + function javascriptTag($script) { + die("Method HtmlHelper::javascriptTag() was moved to JavascriptHelper::codeBlock()."); + } +/** + * This is very WYSIWYG unfriendly, use HtmlHelper::url() to get contents of "action" attribute. Version 0.9.2. + * @deprecated Version 0.9.2. Will not be available after 1.1.x.x + * @see FormHelper::create() + */ + function formTag($target = null, $type = 'post', $htmlAttributes = array()) { + $htmlAttributes['action']=$this->urlFor ($target); + $htmlAttributes['method']=$type == 'get' ? 'get' : 'post'; + $type == 'file' ? $htmlAttributes['enctype'] = 'multipart/form-data' : null; + + $append = ''; + + if (isset($this->params['_Token']) && !empty($this->params['_Token'])) { + $append .= '<p style="display: inline; margin: 0px; padding: 0px;">'; + $append .= $this->hidden('_Token/key', array('value' => $this->params['_Token']['key'], 'id' => '_TokenKey' . mt_rand()), true); + $append .= '</p>'; + } + + return sprintf($this->tags['form'], $this->parseHtmlOptions($htmlAttributes, null, '')) . $append; + } +/** + * This should be done using a content filter. + * @deprecated Version 0.9.2. Will not be available after 1.1.x.x + */ + function linkEmail($title, $email = null, $options = null) { + // if no $email, then title contains the email. + if (empty($email)) + $email=$title; + + $match=array(); + + // does the address contain extra attributes? + preg_match('!^(.*)(\?.*)$!', $email, $match); + + // plaintext + if (empty($options['encode']) || !empty($match[2])) { + return sprintf($this->tags['mailto'], $email, $this->parseHtmlOptions($options), $title); + } + // encoded to avoid spiders + else { + $email_encoded=null; + + for ($ii = 0; $ii < strlen($email); $ii++) { + if (preg_match('!\w!', $email[$ii])) { + $email_encoded .= '%' . bin2hex($email[$ii]); + } else { + $email_encoded .= $email[$ii]; + } + } + + $title_encoded=null; + + for ($ii = 0; $ii < strlen($title); $ii++) { + $title_encoded .= preg_match('/^[A-Za-z0-9]$/', $title[$ii]) + ? '&#x' . bin2hex($title[$ii]) . ';' : $title[$ii]; + } + + return sprintf($this->tags['mailto'], $email_encoded, + $this->parseHtmlOptions($options, array('encode')), $title_encoded); + } + } + +/** + * @deprecated Version 0.9.2. Will not be available after 1.1.x.x + */ + function tag($name, $options = null, $open = false) { + $tag = "<$name " . $this->parseHtmlOptions($options); + $tag .= $open ? ">" : " >"; + return $tag; + } +/** + * @deprecated Version 0.9.2. Will not be available after 1.1.x.x + */ + function contentTag($name, $content, $options = null) { + return "<$name " . $this->parseHtmlOptions($options) . ">$content</$name>"; + } + +} +?> diff --git a/site/cake/libs/view/helpers/javascript.php b/site/cake/libs/view/helpers/javascript.php new file mode 100644 index 0000000..1a07a72 --- /dev/null +++ b/site/cake/libs/view/helpers/javascript.php @@ -0,0 +1,317 @@ +<?php +/* SVN FILE: $Id: javascript.php 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * Javascript Helper class file. + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.helpers + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +/** + * Javascript Helper class for easy use of JavaScript. + * + * JavascriptHelper encloses all methods needed while working with JavaScript. + * + * @package cake + * @subpackage cake.cake.libs.view.helpers + */ +class JavascriptHelper extends Helper{ + var $_cachedEvents = array(); + var $_cacheEvents = false; + var $_cacheToFile = false; + var $_cacheAll = false; + var $_rules = array(); +/** + * Returns a JavaScript script tag. + * + * @param string $script The JavaScript to be wrapped in SCRIPT tags. + * @param boolean $allowCache Allows the script to be cached if non-event caching is active + * @return string The full SCRIPT element, with the JavaScript inside it. + * @access public + */ + function codeBlock($script, $allowCache = true) { + if ($this->_cacheEvents && $this->_cacheAll && $allowCache) { + $this->_cachedEvents[] = $script; + } else { + return sprintf($this->tags['javascriptblock'], $script); + } + } +/** + * Returns a JavaScript include tag (SCRIPT element) + * + * @param string $url URL to JavaScript file. + * @return string + * @access public + */ + function link($url) { + if (strpos($url, '.js') === false) { + $url .= ".js"; + } + return sprintf($this->tags['javascriptlink'], $this->webroot . $this->themeWeb . JS_URL . $url); + } +/** + * Returns a JavaScript include tag for an externally-hosted script + * + * @param string $url URL to JavaScript file. + * @return string + * @access public + */ + function linkOut($url) { + if (strpos($url, '.js') === false && strpos($url, '?') === false) { + $url .= '.js'; + } + return sprintf($this->tags['javascriptlink'], $url); + } +/** + * Escape carriage returns and single and double quotes for JavaScript segments. + * + * @param string $script string that might have javascript elements + * @return string escaped string + * @access public + */ + function escapeScript($script) { + $script = r(array("\r\n", "\n", "\r"), '\n', $script); + $script = r(array('"', "'"), array('\"', "\\'"), $script); + return $script; + } +/** + * Escape a string to be JavaScript friendly. + * + * List of escaped ellements: + * + "\r\n" => '\n' + * + "\r" => '\n' + * + "\n" => '\n' + * + '"' => '\"' + * + "'" => "\\'" + * + * @param string $script String that needs to get escaped. + * @return string Escaped string. + * @access public + */ + function escapeString($string) { + $escape = array("\r\n" => '\n', "\r" => '\n', "\n" => '\n', '"' => '\"', "'" => "\\'"); + return r(array_keys($escape), array_values($escape), $string); + } +/** + * Attach an event to an element. Used with the Prototype library. + * + * @param string $object Object to be observed + * @param string $event event to observe + * @param string $observer function to call + * @param boolean $useCapture default true + * @return boolean true on success + * @access public + */ + function event($object, $event, $observer = null, $useCapture = false) { + + if ($useCapture == true) { + $useCapture = "true"; + } else { + $useCapture = "false"; + } + + if ($object == 'window' || strpos($object, '$(') !== false || strpos($object, '"') !== false || strpos($object, '\'') !== false) { + $b = "Event.observe($object, '$event', function(event) { $observer }, $useCapture);"; + } else { + $chars = array('#', ' ', ', ', '.', ':'); + $found = false; + foreach ($chars as $char) { + if (strpos($object, $char) !== false) { + $found = true; + break; + } + } + if ($found) { + $this->_rules[$object] = $event; + } else { + $b = "Event.observe(\$('$object'), '$event', function(event) { $observer }, $useCapture);"; + } + } + + if (isset($b) && !empty($b)) { + if ($this->_cacheEvents === true) { + $this->_cachedEvents[] = $b; + return; + } else { + return $this->codeBlock($b); + } + } + } +/** + * Cache JavaScript events created with event() + * + * @param boolean $file If true, code will be written to a file + * @param boolean $all If true, all code written with JavascriptHelper will be sent to a file + * @return void + * @access public + */ + function cacheEvents($file = false, $all = false) { + $this->_cacheEvents = true; + $this->_cacheToFile = $file; + $this->_cacheAll = $all; + } +/** + * Write cached JavaScript events + * + * @return string + * @access public + */ + function writeEvents() { + + $rules = array(); + if (!empty($this->_rules)) { + foreach ($this->_rules as $sel => $event) { + $rules[] = "\t'{$sel}': function(element, event) {\n\t\t{$event}\n\t}"; + } + $this->_cacheEvents = true; + } + + if ($this->_cacheEvents) { + + $this->_cacheEvents = false; + $events = $this->_cachedEvents; + $data = implode("\n", $events); + $this->_cachedEvents = array(); + + if (!empty($rules)) { + $data .= "\n\nvar SelectorRules = {\n" . implode(",\n\n", $rules) . "\n}\n"; + $data .= "\nEventSelectors.start(SelectorRules);\n"; + } + + if (!empty($events) || !empty($rules)) { + if ($this->_cacheToFile) { + $filename = md5($data); + if (!file_exists(JS . $filename . '.js')) { + cache(r(WWW_ROOT, '', JS) . $filename . '.js', $data, '+999 days', 'public'); + } + return $this->link($filename); + } else { + return $this->codeBlock("\n" . $data . "\n"); + } + } + } + } +/** + * Includes the Prototype Javascript library (and anything else) inside a single script tag. + * + * Note: The recommended approach is to copy the contents of + * javascripts into your application's + * public/javascripts/ directory, and use @see javascriptIncludeTag() to + * create remote script links. + * + * @param string $script name of script to include + * @return string script with all javascript in/javascripts folder + * @access public + */ + function includeScript($script = "") { + if ($script == "") { + $dh = opendir(JS); + while (false !== ($filename = readdir($dh))) { + $files[] = $filename; + } + sort($files); + $javascript = ''; + foreach ($files as $file) { + if (substr($file, -3) == '.js') { + $javascript .= file_get_contents(JS . "{$file}") . "\n\n"; + } + } + } else { + $javascript = file_get_contents(JS . "$script.js") . "\n\n"; + } + return $this->codeBlock("\n\n" . $javascript); + } +/** + * Generates a JavaScript object in JavaScript Object Notation (JSON) + * from an array + * + * @param array $data Data to be converted + * @param boolean $block Wraps return value in a <script/> block if true + * @param string $prefix Prepends the string to the returned data + * @param string $postfix Appends the string to the returned data + * @param array $stringKeys A list of array keys to be treated as a string + * @param boolean $quoteKeys If false, treats $stringKey as a list of keys *not* to be quoted + * @param string $q The type of quote to use + * @return string A JSON code block + * @access public + */ + function object($data = array(), $block = false, $prefix = '', $postfix = '', $stringKeys = array(), $quoteKeys = true, $q = "\"") { + if (is_object($data)) { + $data = get_object_vars($data); + } + + $out = array(); + $key = array(); + + if (is_array($data)) { + $keys = array_keys($data); + } + + $numeric = true; + if (!empty($keys)) { + $numeric = (array_values($keys) === array_keys(array_values($keys))); + } + + foreach ($data as $key => $val) { + if (is_array($val) || is_object($val)) { + $val = $this->object($val, false, '', '', $stringKeys, $quoteKeys, $q); + } else { + if ((!count($stringKeys) && !is_numeric($val) && !is_bool($val)) || ($quoteKeys && in_array($key, $stringKeys, true)) || (!$quoteKeys && !in_array($key, $stringKeys, true))) { + $val = $q . $this->escapeString($val) . $q; + } + if ($val === null) { + $val = 'null'; + } + if (is_bool($val)) { + $val = ife($val, 'true', 'false'); + } + } + + if (!$numeric) { + $val = $q . $key . $q . ':' . $val; + } + + $out[] = $val; + } + + if (!$numeric) { + $rt = '{' . join(', ', $out) . '}'; + } else { + $rt = '[' . join(', ', $out) . ']'; + } + $rt = $prefix . $rt . $postfix; + + if ($block) { + $rt = $this->codeBlock($rt); + } + + return $rt; + } +/** + * AfterRender callback. Writes any cached events to the view, or to a temp file. + * + * @return void + * @access public + */ + function afterRender() { + echo $this->writeEvents(); + } +} +?>
\ No newline at end of file diff --git a/site/cake/libs/view/helpers/number.php b/site/cake/libs/view/helpers/number.php new file mode 100644 index 0000000..0484d77 --- /dev/null +++ b/site/cake/libs/view/helpers/number.php @@ -0,0 +1,88 @@ +<?php +/* SVN FILE: $Id: number.php 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * Number Helper. + * + * Methods to make numbers more readable. + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.helpers + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +/** + * Number helper library. + * + * Methods to make numbers more readable. + * + * @package cake + * @subpackage cake.cake.libs.view.helpers + */ +class NumberHelper extends Helper { +/** + * Formats a number with a level of precision. + * + * @param float $number A floating point number. + * @param integer $precision The precision of the returned number. + * @return float Enter description here... + * @access public + */ + function precision($number, $precision = 3) { + return sprintf("%01.{$precision}f", $number); + } + +/** + * Returns a formatted-for-humans file size. + * + * @param integer $length Size in bytes + * @return string Human readable size + * @access public + */ + function toReadableSize($size) { + switch($size) { + case 0: + return '0 Bytes'; + case 1: + return '1 Byte'; + case $size < 1024: + return $size . ' Bytes'; + case $size < 1024 * 1024: + return NumberHelper::precision($size / 1024, 0) . ' KB'; + case $size < 1024 * 1024 * 1024: + return NumberHelper::precision($size / 1024 / 1024, 2) . ' MB'; + case $size < 1024 * 1024 * 1024 * 1024: + return NumberHelper::precision($size / 1024 / 1024 / 1024, 2) . ' GB'; + case $size < 1024 * 1024 * 1024 * 1024 * 1024: + return NumberHelper::precision($size / 1024 / 1024 / 1024 / 1024, 2) . ' TB'; + } + } + +/** + * Formats a number into a percentage string. + * + * @param float $number A floating point number + * @param integer $precision The precision of the returned number + * @return string Percentage string + * @access public + */ + function toPercentage($number, $precision = 2) { + return NumberHelper::precision($number, $precision) . '%'; + } +} +?>
\ No newline at end of file diff --git a/site/cake/libs/view/helpers/session.php b/site/cake/libs/view/helpers/session.php new file mode 100644 index 0000000..7b987b1 --- /dev/null +++ b/site/cake/libs/view/helpers/session.php @@ -0,0 +1,198 @@ +<?php +/* SVN FILE: $Id: session.php 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * Short description for file. + * + * Long description for file + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.helpers + * @since CakePHP(tm) v 1.1.7.3328 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +/** + * Session Helper. + * + * Session reading from the view. + * + * @package cake + * @subpackage cake.cake.libs.view.helpers + * + */ +if(!class_exists('cakesession')) { + uses('session'); +} +class SessionHelper extends CakeSession { +/** + * List of helpers used by this helper + * + * @var array + */ + var $helpers = null; +/** + * Used to determine if methods implementation is used, or bypassed + * + * @var boolean + */ + var $__active = true; +/** + * Class constructor + * + * @param string $base + */ + function __construct($base = null) { + if (!defined('AUTO_SESSION') || AUTO_SESSION === true) { + parent::__construct($base, false); + } else { + $this->__active = false; + } + } +/** + * Turn sessions on if 'Session.start' is set to false in core.php + * + * @param string $base + */ + function activate($base = null) { + $this->__active = true; + } +/** + * Used to read a session values set in a controller for a key or return values for all keys. + * + * In your view: $session->read('Controller.sessKey'); + * Calling the method without a param will return all session vars + * + * @param string $name the name of the session key you want to read + * + * @return values from the session vars + * @access public + */ + function read($name = null) { + if ($this->__active === true && $this->__start()) { + return parent::read($name); + } + return false; + } +/** + * Used to check is a session key has been set + * + * In your view: $session->check('Controller.sessKey'); + * + * @param string $name + * @return boolean + * @access public + */ + function check($name) { + if ($this->__active === true && $this->__start()) { + return parent::check($name); + } + return false; + } +/** + * Returns last error encountered in a session + * + * In your view: $session->error(); + * + * @return string last error + * @access public + */ + function error() { + if ($this->__active === true && $this->__start()) { + return parent::error(); + } + return false; + } +/** + * Used to render the message set in Controller::Session::setFlash() + * + * In your view: $session->flash('somekey'); + * Will default to flash if no param is passed + * + * @param string $key The [Message.]key you are rendering in the view. + * @return string Will echo the value if $key is set, or false if not set. + * @access public + */ + function flash($key = 'flash') { + if ($this->__active === true && $this->__start()) { + if (parent::check('Message.' . $key)) { + $flash = parent::read('Message.' . $key); + + if ($flash['layout'] == 'default') { + $out = '<div id="' . $key . 'Message" class="message">' . $flash['message'] . '</div>'; + } elseif ($flash['layout'] == '' || $flash['layout'] == null) { + $out = $flash['message']; + } else { + $view =& ClassRegistry::getObject('view'); + list($tmpLayout, $tmpVars, $tmpTitle) = array($view->layout, $view->viewVars, $view->pageTitle); + list($view->layout, $view->viewVars, $view->pageTitle) = array($flash['layout'], $flash['params'], ''); + $out = $view->renderLayout($flash['message']); + list($view->layout, $view->viewVars, $view->pageTitle) = array($tmpLayout, $tmpVars, $tmpTitle); + } + e($out); + parent::del('Message.' . $key); + return true; + } + } + return false; + } +/** + * Used to check is a session is valid in a view + * + * @return boolean + * @access public + */ + function valid() { + if ($this->__active === true && $this->__start()) { + return parent::valid(); + } + } +/** + * Override CakeSession::write(). + * This method should not be used in a view + * + * @return boolean + * @access public + */ + function write() { + trigger_error(__('You can not write to a Session from the view', true), E_USER_WARNING); + } +/** + * Session id + * + * @return string Session id + * @access public + */ + function id() { + return parent::id(); + } +/** + * Determine if Session has been started + * and attempt to start it if not + * + * @return boolean true if Session is already started, false if + * Session could not be started + * @access public + */ + function __start() { + if(!parent::started()) { + parent::start(); + } + return true; + } +} +?>
\ No newline at end of file diff --git a/site/cake/libs/view/helpers/text.php b/site/cake/libs/view/helpers/text.php new file mode 100644 index 0000000..4b67afa --- /dev/null +++ b/site/cake/libs/view/helpers/text.php @@ -0,0 +1,238 @@ +<?php +/* SVN FILE: $Id: text.php 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * Text Helper + * + * Text manipulations: Highlight, excerpt, truncate, strip of links, convert email addresses to mailto: links... + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.helpers + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +/** + * Included libraries. + * + */ +if (!class_exists('Flay')) { + uses('flay'); +} +if (!class_exists('HtmlHelper')) { + uses('view' . DS . 'helpers' . DS . 'html'); +} +/** + * Text helper library. + * + * Text manipulations: Highlight, excerpt, truncate, strip of links, convert email addresses to mailto: links... + * + * @package cake + * @subpackage cake.cake.libs.view.helpers + */ +class TextHelper extends Helper{ +/** + * Highlights a given phrase in a text. + * + * @param string $text Text to search the phrase in + * @param string $phrase The phrase that will be searched + * @param string $highlighter The piece of html with that the phrase will be highlighted + * @return string The highlighted text + * @access public + */ + function highlight($text, $phrase, $highlighter = '<span class="highlight">\1</span>') { + if (empty($phrase)) + return $text; + + if (is_array($phrase)) { + $replace=array(); + $with=array(); + + foreach ($phrase as $key => $value) { + if (empty($key)) { + $key =$value; + $value=$highlighter; + } + + $replace[]='|(' . $key . ')|i'; + $with[]=empty($value) ? $highlighter : $value; + } + + return preg_replace($replace, $with, $text); + } else { + return preg_replace("|({$phrase})|i", $highlighter, $text); + } + } +/** + * Strips given text of all links (<a href=....) + * + * @param string $text Text + * @return string The text without links + * @access public + */ + function stripLinks($text) { + return preg_replace('|<a.*>(.*)<\/a>|im', '\1', $text); + } +/** + * Adds links (<a href=....) to a given text, by finding text that begins with + * strings like http:// and ftp://. + * + * @param string $text Text to add links to + * @param array $htmlOptions Array of HTML options. + * @return string The text with links + * @access public + */ + function autoLinkUrls($text, $htmlOptions = array()) { + $options='array('; + + foreach ($htmlOptions as $option => $value) { + $options .= "'$option' => '$value', "; + } + + $options .= ')'; + + $text = preg_replace_callback('#(?<!href="|">)((?:http|https|ftp|nntp)://[^ <]+)#i', + create_function('$matches', + '$Html = new HtmlHelper(); $Html->tags = $Html->loadConfig(); return $Html->link($matches[0], $matches[0],' . $options . ');'), + $text); + return preg_replace_callback('#(?<!href="|">)(?<!http://|https://|ftp://|nntp://)(www\.[^\n\%\ <]+[^<\n\%\,\.\ <])#i', + create_function('$matches', + '$Html = new HtmlHelper(); $Html->tags = $Html->loadConfig(); return $Html->link($matches[0], "http://" . $matches[0],' . $options . ');'), + $text); + } +/** + * Adds email links (<a href="mailto:....) to a given text. + * + * @param string $text Text + * @param array $htmlOptions Array of HTML options. + * @return string The text with links + * @access public + */ + function autoLinkEmails($text, $htmlOptions = array()) { + $options='array('; + + foreach ($htmlOptions as $option => $value) { + $options .= "'$option' => '$value', "; + } + + $options .= ')'; + + return preg_replace_callback( + '#([_A-Za-z0-9+-]+(?:\.[_A-Za-z0-9+-]+)*@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*)#', + create_function('$matches', + '$Html = new HtmlHelper(); $Html->tags = $Html->loadConfig(); return $Html->linkEmail($matches[0], $matches[0],' . $options . ');'), + $text); + } +/** + * Convert all links and email adresses to HTML links. + * + * @param string $text Text + * @param array $htmlOptions Array of HTML options. + * @return string The text with links + * @access public + */ + function autoLink($text, $htmlOptions = array()) { + return $this->autoLinkEmails($this->autoLinkUrls($text, $htmlOptions), $htmlOptions); + } +/** + * Truncates text. + * + * Cuts a string to the length of $length and replaces the last characters + * with the ending if the text is longer than length. + * + * @param string $text String to truncate. + * @param integer $length Length of returned string, including ellipsis. + * @param string $ending Ending to be appended to the trimmed string. + * @param boolean $exact If false, $test will not be cut mid-word + * @return string Trimmed string. + * @access public + */ + function truncate($text, $length, $ending = '...', $exact = true) { + if (strlen($text) <= $length) { + return $text; + } else { + $truncate=substr($text, 0, $length - strlen($ending)); + + if (!$exact) { + $spacepos=strrpos($truncate, ' '); + + if (isset($spacepos)) { + return substr($truncate, 0, $spacepos) . $ending; + } + } + + return $truncate . $ending; + } + } +/** + * Alias for truncate(). + * + * @see TextHelper::truncate() + * @return Text::truncate() + * @access public + */ + function trim() { + $args=func_get_args(); + return call_user_func_array(array(&$this, + "truncate"), $args); + } +/** + * Extracts an excerpt from the text surrounding the phrase with a number of characters on each side determined by radius. + * + * @param string $text String to search the phrase in + * @param string $phrase Phrase that will be searched for + * @param integer $radius The amount of characters that will be returned on each side of the founded phrase + * @param string $ending Ending that will be appended + * @return string + * @access public + */ + function excerpt($text, $phrase, $radius = 100, $ending = "...") { + if (empty($text) or empty($phrase)) + return $this->truncate($text, $radius * 2, $ending); + + if ($radius < strlen($phrase)) + $radius=strlen($phrase); + + $pos =strpos($text, $phrase); + $startPos=$pos <= $radius ? 0 : $pos - $radius; + $endPos =$pos + strlen($phrase) + $radius >= strlen($text) + ? strlen($text) : $pos + strlen($phrase) + $radius; + + $excerpt =substr($text, $startPos, $endPos - $startPos); + + if ($startPos != 0) + $excerpt=substr_replace($excerpt, $ending, 0, strlen($phrase)); + + if ($endPos != strlen($text)) + $excerpt=substr_replace($excerpt, $ending, -strlen($phrase)); + + return $excerpt; + } +/** + * Text-to-html parser, similar to Textile or RedCloth, only with a little different syntax. + * + * @param string $text String to "flay" + * @param boolean $allowHtml Set to true if if html is allowed + * @return string "Flayed" text + * @todo Change this. We need a real Textile parser. + * @access public + */ + function flay($text, $allowHtml = false) { + return Flay::toHtml($text, false, $allowHtml); + } +} +?>
\ No newline at end of file diff --git a/site/cake/libs/view/helpers/time.php b/site/cake/libs/view/helpers/time.php new file mode 100644 index 0000000..e4fd82d --- /dev/null +++ b/site/cake/libs/view/helpers/time.php @@ -0,0 +1,397 @@ +<?php +/* SVN FILE: $Id: time.php 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * Time Helper class file. + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.helpers + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +/** + * Time Helper class for easy use of time data. + * + * Manipulation of time data. + * + * @package cake + * @subpackage cake.cake.libs.view.helpers + */ +class TimeHelper extends Helper { +/** + * Returns given string trimmed to given length, adding an ending (default: "..") if necessary. + * + * @param string $string String to trim + * @param integer $length Length of returned string, excluding ellipsis + * @param string $ending Ending to be appended after trimmed string + * @return string Trimmed string + * @access public + */ + function trim($string, $length, $ending = '..') { + return substr($string, 0, $length) . (strlen($string) > $length ? $ending : null); + } +/** + * Returns a UNIX timestamp, given either a UNIX timestamp or a valid strtotime() date string. + * + * @param string $date_string Datetime string + * @return string Formatted date string + * @access public + */ + function fromString($date_string) { + if (is_integer($date_string) || is_numeric($date_string)) { + return intval($date_string); + } else { + return strtotime($date_string); + } + } +/** + * Returns a nicely formatted date string for given Datetime string. + * + * @param string $date_string Datetime string or Unix timestamp + * @param boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT. + * @return string Formatted date string + * @access public + */ + function nice($date_string = null, $return = false) { + if ($date_string != null) { + $date = $this->fromString($date_string); + } else { + $date = time(); + } + + $ret = date("D, M jS Y, H:i", $date); + return $this->output($ret, $return); + } +/** + * Returns a formatted descriptive date string for given datetime string. + * + * If the given date is today, the returned string could be "Today, 16:54". + * If the given date was yesterday, the returned string could be "Yesterday, 16:54". + * If $date_string's year is the current year, the returned string does not + * include mention of the year. + * + * @param string $date_string Datetime string or Unix timestamp + * @param boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT. + * @return string Described, relative date string + * @access public + */ + function niceShort($date_string = null, $return = false) { + $date = $date_string ? $this->fromString($date_string) : time(); + $y = $this->isThisYear($date) ? '' : ' Y'; + + if ($this->isToday($date)) { + $ret = "Today, " . date("H:i", $date); + } elseif ($this->wasYesterday($date)) { + $ret = "Yesterday, " . date("H:i", $date); + } else { + $ret = date("M jS{$y}, H:i", $date); + } + + return $this->output($ret, $return); + } +/** + * Returns true if given datetime string is today. + * + * @param string $date_string Datetime string or Unix timestamp + * @param boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT. + * @return boolean True if datetime string is today + * @access public + */ + function isToday($date_string, $return = false) { + $date = $this->fromString($date_string); + $ret = date('Y-m-d', $date) == date('Y-m-d', time()); + return $this->output($ret, $return); + } +/** + * Returns a partial SQL string to search for all records between two dates. + * + * @param string $date_string Datetime string or Unix timestamp + * @param string $end Datetime string or Unix timestamp + * @param string $field_name Name of database field to compare with + * @param boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT. + * @return string Partial SQL string. + * @access public + */ + function daysAsSql($begin, $end, $field_name, $return = false) { + $begin = $this->fromString($begin); + $end = $this->fromString($end); + $begin = date('Y-m-d', $begin) . ' 00:00:00'; + $end = date('Y-m-d', $end) . ' 23:59:59'; + + return $this->output("($field_name >= '$begin') AND ($field_name <= '$end')", $return); + } +/** + * Returns a partial SQL string to search for all records between two times + * occurring on the same day. + * + * @param string $date_string Datetime string or Unix timestamp + * @param string $field_name Name of database field to compare with + * @param boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT. + * @return string Partial SQL string. + * @access public + */ + function dayAsSql($date_string, $field_name, $return = false) { + $date = $this->fromString($date_string); + $ret = $this->daysAsSql($date_string, $date_string, $field_name); + return $this->output($ret, $return); + } +/** + * Returns true if given datetime string is within current year. + * + * @param string $date_string Datetime string or Unix timestamp + * @param boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT. + * @return boolean True if datetime string is within current year + * @access public + */ + function isThisYear($date_string, $return = false) { + $date = $this->fromString($date_string); + $ret = date('Y', $date) == date('Y', time()); + return $this->output($ret, $return); + } +/** + * Returns true if given datetime string was yesterday. + * + * @param string $date_string Datetime string or Unix timestamp + * @param boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT. + * @return boolean True if datetime string was yesterday + * @access public + */ + function wasYesterday($date_string, $return = false) { + $date = $this->fromString($date_string); + $ret = date('Y-m-d', $date) == date('Y-m-d', strtotime('yesterday')); + return $this->output($ret, $return); + } +/** + * Returns true if given datetime string is tomorrow. + * + * @param string $date_string Datetime string or Unix timestamp + * @param boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT. + * @return boolean True if datetime string was yesterday + * @access public + */ + function isTomorrow($date_string, $return = false) { + $date = $this->fromString($date_string); + $ret = date('Y-m-d', $date) == date('Y-m-d', strtotime('tomorrow')); + return $this->output($ret, $return); + } +/** + * Returns a UNIX timestamp from a textual datetime description. Wrapper for PHP function strtotime(). + * + * @param string $date_string Datetime string to be represented as a Unix timestamp + * @param boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT. + * @return int Unix timestamp + * @access public + */ + function toUnix($date_string, $return = false) { + $ret = strtotime($date_string); + return $this->output($ret, $return); + } +/** + * Returns a date formatted for Atom RSS feeds. + * + * @param string $date_string Datetime string or Unix timestamp + * @param boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT. + * @return string Formatted date string + * @access public + */ + function toAtom($date_string, $return = false) { + $date = $this->fromString($date_string); + $ret = date('Y-m-d\TH:i:s\Z', $date); + return $this->output($ret, $return); + } +/** + * Formats date for RSS feeds + * + * @param string $date_string Datetime string or Unix timestamp + * @param boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT. + * @return string Formatted date string + * @access public + */ + function toRSS($date_string, $return = false) { + $date = $this->fromString($date_string); + $ret = date("r", $date); + return $this->output($ret, $return); + } +/** + * Returns either a relative date or a formatted date depending + * on the difference between the current time and given datetime. + * $datetime should be in a <i>strtotime</i>-parsable format, like MySQL's datetime datatype. + * + * Relative dates look something like this: + * 3 weeks, 4 days ago + * 15 seconds ago + * Formatted dates look like this: + * on 02/18/2004 + * + * The returned string includes 'ago' or 'on' and assumes you'll properly add a word + * like 'Posted ' before the function output. + * + * @param string $date_string Datetime string or Unix timestamp + * @param string $format Default format if timestamp is used in $date_string + * @param string $backwards False if $date_string is in the past, true if in the future + * @param boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT. + * @return string Relative time string. + * @access public + */ + function timeAgoInWords($datetime_string, $format = 'j/n/y', $backwards = false, $return = false) { + $datetime = $this->fromString($datetime_string); + + $in_seconds = $datetime; + if ($backwards) { + $diff = $in_seconds - time(); + } else { + $diff = time() - $in_seconds; + } + + $months = floor($diff / 2419200); + $diff -= $months * 2419200; + $weeks = floor($diff / 604800); + $diff -= $weeks * 604800; + $days = floor($diff / 86400); + $diff -= $days * 86400; + $hours = floor($diff / 3600); + $diff -= $hours * 3600; + $minutes = floor($diff / 60); + $diff -= $minutes * 60; + $seconds = $diff; + + if ($months > 0) { + // over a month old, just show date (mm/dd/yyyy format) + $relative_date = 'on ' . date($format, $in_seconds); + $old = true; + } else { + $relative_date = ''; + $old = false; + + if ($weeks > 0) { + // weeks and days + $relative_date .= ($relative_date ? ', ' : '') . $weeks . ' week' . ($weeks > 1 ? 's' : ''); + $relative_date .= $days > 0 ? ($relative_date ? ', ' : '') . $days . ' day' . ($days > 1 ? 's' : '') : ''; + } elseif ($days > 0) { + // days and hours + $relative_date .= ($relative_date ? ', ' : '') . $days . ' day' . ($days > 1 ? 's' : ''); + $relative_date .= $hours > 0 ? ($relative_date ? ', ' : '') . $hours . ' hour' . ($hours > 1 ? 's' : '') : ''; + } elseif ($hours > 0) { + // hours and minutes + $relative_date .= ($relative_date ? ', ' : '') . $hours . ' hour' . ($hours > 1 ? 's' : ''); + $relative_date .= $minutes > 0 ? ($relative_date ? ', ' : '') . $minutes . ' minute' . ($minutes > 1 ? 's' : '') : ''; + } elseif ($minutes > 0) { + // minutes only + $relative_date .= ($relative_date ? ', ' : '') . $minutes . ' minute' . ($minutes > 1 ? 's' : ''); + } else { + // seconds only + $relative_date .= ($relative_date ? ', ' : '') . $seconds . ' second' . ($seconds != 1 ? 's' : ''); + } + } + + $ret = $relative_date; + + // show relative date and add proper verbiage + if (!$backwards && !$old) { + $ret .= ' ago'; + } + return $this->output($ret, $return); + } +/** + * Alias for timeAgoInWords + * + * @param string $date_string Datetime string or Unix timestamp + * @param string $format Default format if timestamp is used in $date_string + * @param boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT. + * @return string Relative time string. + * @see Time::timeAgoInWords() + * @access public + */ + function relativeTime($datetime_string, $format = 'j/n/y', $return = false) { + $date = strtotime($datetime_string); + + if (strtotime("now") > $date) { + $ret = $this->timeAgoInWords($datetime_string, $format, false); + } else { + $ret = $this->timeAgoInWords($datetime_string, $format, true); + } + + return $this->output($ret, $return); + } +/** + * Returns true if specified datetime was within the interval specified, else false. + * + * @param mixed $timeInterval the numeric value with space then time type. Example of valid types: 6 hours, 2 days, 1 minute. + * @param mixed $date_string the datestring or unix timestamp to compare + * @param boolean $return Whether this method should return a value or output it. This overrides AUTO_OUTPUT. + * @return boolean + * @access public + */ + function wasWithinLast($timeInterval, $date_string, $return = false) { + $date = $this->fromString($date_string); + $result = preg_split('/\\s/', $timeInterval); + $numInterval = $result[0]; + $textInterval = $result[1]; + $currentTime = floor(time()); + $seconds = ($currentTime - floor($date)); + + switch($textInterval) { + case "seconds": + case "second": + $timePeriod = $seconds; + $ret = $return; + break; + case "minutes": + case "minute": + $minutes = floor($seconds / 60); + $timePeriod = $minutes; + break; + case "hours": + case "hour": + $hours = floor($seconds / 3600); + $timePeriod = $hours; + break; + case "days": + case "day": + $days = floor($seconds / 86400); + $timePeriod = $days; + break; + case "weeks": + case "week": + $weeks = floor($seconds / 604800); + $timePeriod = $weeks; + break; + case "months": + case "month": + $months = floor($seconds / 2629743.83); + $timePeriod = $months; + break; + case "years": + case "year": + $years = floor($seconds / 31556926); + $timePeriod = $years; + break; + default: + $days = floor($seconds / 86400); + $timePeriod = $days; + break; + } + if ($timePeriod <= $numInterval) { + $ret = true; + } else { + $ret = false; + } + return $this->output($ret, $return); + } +} +?>
\ No newline at end of file diff --git a/site/cake/libs/view/templates/elements/dump.thtml b/site/cake/libs/view/templates/elements/dump.thtml new file mode 100644 index 0000000..203414d --- /dev/null +++ b/site/cake/libs/view/templates/elements/dump.thtml @@ -0,0 +1,32 @@ +<?php +/* SVN FILE: $Id: dump.thtml 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.templates.elements + * @since CakePHP(tm) v 0.10.5.1782 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +?> +<div> + <h2>Controller dump:</h2> + <pre> + <?php print_r($this->controller); ?> + </pre> +</div>
\ No newline at end of file diff --git a/site/cake/libs/view/templates/errors/error404.thtml b/site/cake/libs/view/templates/errors/error404.thtml new file mode 100644 index 0000000..986cb1a --- /dev/null +++ b/site/cake/libs/view/templates/errors/error404.thtml @@ -0,0 +1,28 @@ +<?php +/* SVN FILE: $Id: error404.thtml 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.templates.errors + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +?> +<h1><?php echo $name; ?></h1> +<p><?php echo $message; ?></p>
\ No newline at end of file diff --git a/site/cake/libs/view/templates/errors/missing_action.thtml b/site/cake/libs/view/templates/errors/missing_action.thtml new file mode 100644 index 0000000..db91d34 --- /dev/null +++ b/site/cake/libs/view/templates/errors/missing_action.thtml @@ -0,0 +1,37 @@ +<?php +/* SVN FILE: $Id: missing_action.thtml 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.templates.errors + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +?> +<h1>Missing Method in <?php echo $controller;?></h1> +<p class="error">You are seeing this error because the action <em><?php echo $action;?></em> is not defined in controller <em><?php echo $controller;?></em></p> +<p><span class="notice">If you want to customize this error message, create <?php echo APP_DIR.DS."views/errors/missing_action.thtml"; ?>.</span></p> +<p><span class="notice"><strong>Fatal</strong>: Confirm you have created the <?php echo $controller;?>::<?php echo $action;?>() in file : <?php echo APP_DIR.DS."controllers".DS.Inflector::underscore($controller).".php"; ?></p> +<p><?php<br /> +class <?php echo $controller;?> extends AppController {<br /> + <strong>function <?php echo $action;?>() {<br /> + }</strong><br /> +}<br /> +?><br /> +</p>
\ No newline at end of file diff --git a/site/cake/libs/view/templates/errors/missing_component_class.thtml b/site/cake/libs/view/templates/errors/missing_component_class.thtml new file mode 100644 index 0000000..3bd40b1 --- /dev/null +++ b/site/cake/libs/view/templates/errors/missing_component_class.thtml @@ -0,0 +1,36 @@ +<?php +/* SVN FILE: $Id: missing_component_class.thtml 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.templates.errors + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +?> +<h1>Missing Component Class</h1> +<p class="error">You are seeing this error because the component class <em><?php echo $component."Component";?></em> +you have set in <?php echo $controller."Controller";?> can't be found or doesn't exist.</em></p> +<p><span class="notice"><strong>Notice:</strong> If you want to customize this error message, create <?php echo APP_DIR.DS."views/errors/missing_component_class.thtml"; ?>.</span></p> +<p><span class="notice"><strong>Fatal</strong>: Create the class below in file : <?php echo APP_DIR.DS."controllers".DS."components".DS.$file; ?></p> +<p><?php<br /> +class <?php echo $component;?>Component extends Object {<br /> +}<br /> +?><br /> +</p>
\ No newline at end of file diff --git a/site/cake/libs/view/templates/errors/missing_component_file.thtml b/site/cake/libs/view/templates/errors/missing_component_file.thtml new file mode 100644 index 0000000..0d2ec30 --- /dev/null +++ b/site/cake/libs/view/templates/errors/missing_component_file.thtml @@ -0,0 +1,35 @@ +<?php +/* SVN FILE: $Id: missing_component_file.thtml 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.templates.errors + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +?> +<h1>Missing Component File</h1> +<p class="error">You are seeing this error because the component file can't be found or doesn't exist.</p> +<p><span class="notice"><strong>Notice:</strong> If you want to customize this error message, create <?php echo APP_DIR.DS."views/errors/missing_component_file.thtml"; ?>.</span></p> +<p><span class="notice"><strong>Fatal</strong>: Create the class below in file : <?php echo APP_DIR.DS."controllers".DS."components".DS.$file; ?></p> +<p><?php<br /> +class <?php echo $component;?>Component extends Object {<br /> + +}<br /> +?><br /> </p>
\ No newline at end of file diff --git a/site/cake/libs/view/templates/errors/missing_connection.thtml b/site/cake/libs/view/templates/errors/missing_connection.thtml new file mode 100644 index 0000000..0c01595 --- /dev/null +++ b/site/cake/libs/view/templates/errors/missing_connection.thtml @@ -0,0 +1,30 @@ +<?php +/* SVN FILE: $Id: missing_connection.thtml 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.templates.errors + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +?> +<h1>Requires a Database Connection</h1> +<p class="error">Missing Database Connection: <?php echo $model;?> requires a database connection</p> +<p><span class="notice"><strong>Notice:</strong> If you want to customize this error message, create <?php echo APP_DIR.DS."views/errors/missing_database.thtml"; ?>.</span></p> +<p><span class="notice"><strong>Fatal</strong>: Confirm you have created the file : <?php echo APP_DIR.DS."config".DS."database.php"; ?></p>
\ No newline at end of file diff --git a/site/cake/libs/view/templates/errors/missing_controller.thtml b/site/cake/libs/view/templates/errors/missing_controller.thtml new file mode 100644 index 0000000..d480732 --- /dev/null +++ b/site/cake/libs/view/templates/errors/missing_controller.thtml @@ -0,0 +1,36 @@ +<?php +/* SVN FILE: $Id: missing_controller.thtml 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.templates.errors + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +?> +<h1>Missing controller</h1> +<p class="error">You are seeing this error because controller <em><?php echo $controller;?></em> could not be found.</p> +<p><span class="notice"><strong>Notice:</strong> If you want to customize this error message, create <?php echo APP_DIR.DS."views/errors/missing_controller.thtml"; ?>.</span></p> +<p><span class="notice"><strong>Fatal</strong>: Create the class below in file : <?php echo APP_DIR.DS."controllers".DS.Inflector::underscore($controller).".php"; ?></p> +<p><?php<br /> +class <?php echo $controller;?> extends AppController {<br /> + var $name = '<?php echo $controllerName;?>';<br /> +}<br /> +?><br /> +</p>
\ No newline at end of file diff --git a/site/cake/libs/view/templates/errors/missing_helper_class.thtml b/site/cake/libs/view/templates/errors/missing_helper_class.thtml new file mode 100644 index 0000000..0d588c5 --- /dev/null +++ b/site/cake/libs/view/templates/errors/missing_helper_class.thtml @@ -0,0 +1,35 @@ +<?php +/* SVN FILE: $Id: missing_helper_class.thtml 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.templates.errors + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +?> +<h1>Missing Helper Class</h1> +<p class="error">You are seeing this error because the view helper class <?php echo $helperClass;?> can't be found or doesn't exist.</p> +<p><span class="notice"><strong>Notice:</strong> If you want to customize this error message, create <?php echo APP_DIR.DS."views/errors/missing_helper_class.thtml"; ?>.</span></p> +<p><span class="notice"><strong>Fatal</strong>: Create the class below in file : <?php echo APP_DIR.DS."views".DS."helpers".DS.$file; ?></p> +<p><?php<br /> +class <?php echo $helperClass;?> extends Helper {<br /> +}<br /> +?><br /> +</p>
\ No newline at end of file diff --git a/site/cake/libs/view/templates/errors/missing_helper_file.thtml b/site/cake/libs/view/templates/errors/missing_helper_file.thtml new file mode 100644 index 0000000..a9e6508 --- /dev/null +++ b/site/cake/libs/view/templates/errors/missing_helper_file.thtml @@ -0,0 +1,35 @@ +<?php +/* SVN FILE: $Id: missing_helper_file.thtml 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.templates.errors + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +?> +<h1>Missing Helper File</h1> +<p class="error">You are seeing this error because the view helper file <?php echo APP_DIR.DS."views".DS."helpers".DS.$file; ?> can't be found or doesn't exist.</p> +<p><span class="notice"><strong>Notice:</strong> If you want to customize this error message, create <?php echo APP_DIR.DS."views/errors/missing_helper_file.thtml"; ?>.</span></p> +<p><span class="notice"><strong>Fatal</strong>: Create the class below in file : <?php echo APP_DIR.DS."views".DS."helpers".DS.$file; ?></p> +<p><?php<br /> +class <?php echo $helperClass;?> extends Helper {<br /> +}<br /> +?><br /> +</p>
\ No newline at end of file diff --git a/site/cake/libs/view/templates/errors/missing_layout.thtml b/site/cake/libs/view/templates/errors/missing_layout.thtml new file mode 100644 index 0000000..e35eb30 --- /dev/null +++ b/site/cake/libs/view/templates/errors/missing_layout.thtml @@ -0,0 +1,30 @@ +<?php +/* SVN FILE: $Id: missing_layout.thtml 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.templates.errors + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +?> +<h1>Missing Layout</h1> +<p class="error">You are seeing this error because the layout file <?php echo $file;?> can't be found or doesn't exist.</p> +<p><span class="notice"><strong>Notice:</strong> If you want to customize this error message, create <?php echo APP_DIR.DS."views/errors/missing_layout.thtml"; ?>.</span></p> +<p><span class="notice"><strong>Fatal</strong>: Confirm you have created the file : <?php echo $file;?></p>
\ No newline at end of file diff --git a/site/cake/libs/view/templates/errors/missing_model.thtml b/site/cake/libs/view/templates/errors/missing_model.thtml new file mode 100644 index 0000000..9fdb6bb --- /dev/null +++ b/site/cake/libs/view/templates/errors/missing_model.thtml @@ -0,0 +1,36 @@ +<?php +/* SVN FILE: $Id: missing_model.thtml 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.templates.errors + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +?> +<h1>Missing Model</h1> +<p class="error">No class found for the <em><?php echo $model;?></em> model</p> +<p><span class="notice"><strong>Notice:</strong> If you want to customize this error message, create <?php echo APP_DIR.DS."views/errors/missing_model.thtml"; ?>.</span></p> +<p><span class="notice"><strong>Fatal</strong>: Create the class below in file : <?php echo "app".DS."models".DS.Inflector::underscore($model).".php"; ?></p> +<p><?php<br /> +class <?php echo $model;?> extends AppModel {<br /> + var $name = '<?php echo $model;?>';<br /> +}<br /> +?><br /> +</p>
\ No newline at end of file diff --git a/site/cake/libs/view/templates/errors/missing_scaffolddb.thtml b/site/cake/libs/view/templates/errors/missing_scaffolddb.thtml new file mode 100644 index 0000000..842ab17 --- /dev/null +++ b/site/cake/libs/view/templates/errors/missing_scaffolddb.thtml @@ -0,0 +1,30 @@ +<?php +/* SVN FILE: $Id: missing_scaffolddb.thtml 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.templates.errors + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +?> +<h1>Scaffold Requires a Database Connection</h1> +<p class="error">Missing Database Connection: Scaffold Does not work without a database connection</p> +<p><span class="notice"><strong>Notice:</strong> If you want to customize this error message, create <?php echo APP_DIR.DS."views/errors/missing_scaffolddb.thtml"; ?>.</span></p> +<p><span class="notice"><strong>Fatal</strong>: Confirm you have created the file : <?php echo APP_DIR.DS."config".DS."database.php"; ?></p>
\ No newline at end of file diff --git a/site/cake/libs/view/templates/errors/missing_table.thtml b/site/cake/libs/view/templates/errors/missing_table.thtml new file mode 100644 index 0000000..209ca9b --- /dev/null +++ b/site/cake/libs/view/templates/errors/missing_table.thtml @@ -0,0 +1,29 @@ +<?php +/* SVN FILE: $Id: missing_table.thtml 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.templates.errors + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +?> +<h1>Missing Database Table</h1> +<p class="error">No Database table for model <?php echo $model;?> (expected "<?php echo $table;?>"), create it first.</p> +<p><span class="notice"><strong>Notice:</strong> If you want to customize this error message, create <?php echo APP_DIR.DS."views/errors/missing_table.thtml"; ?>.</span></p> diff --git a/site/cake/libs/view/templates/errors/missing_view.thtml b/site/cake/libs/view/templates/errors/missing_view.thtml new file mode 100644 index 0000000..a7a70da --- /dev/null +++ b/site/cake/libs/view/templates/errors/missing_view.thtml @@ -0,0 +1,30 @@ +<?php +/* SVN FILE: $Id: missing_view.thtml 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.templates.errors + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +?> +<h1>Missing view</h1> +<p class="error">You are seeing this error because the view for <em><?php echo $controller.'Controller';?>::<?php echo $action;?>()</em> could not be found.</p> +<p><span class="notice">If you want to customize this error message, create <?php echo APP_DIR.DS."views/errors/missing_view.thtml"; ?>.</span></p> +<p><span class="notice"><strong>Fatal</strong>: Confirm you have created the file : <?php echo $file;?></p>
\ No newline at end of file diff --git a/site/cake/libs/view/templates/errors/private_action.thtml b/site/cake/libs/view/templates/errors/private_action.thtml new file mode 100644 index 0000000..05845ed --- /dev/null +++ b/site/cake/libs/view/templates/errors/private_action.thtml @@ -0,0 +1,29 @@ +<?php +/* SVN FILE: $Id: private_action.thtml 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.templates.errors + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +?> +<h1>Private Method in <?php echo $controller;?></h1> +<p class="error">You are seeing this error because the private class method <em><?php echo $action;?></em> should not be accessed directly</p> +<p><span class="notice"><strong>Notice:</strong> If you want to customize this error message, create <?php echo APP_DIR.DS."views/errors/private_action.thtml"; ?>.</span></p> diff --git a/site/cake/libs/view/templates/errors/scaffold_error.thtml b/site/cake/libs/view/templates/errors/scaffold_error.thtml new file mode 100644 index 0000000..fe05686 --- /dev/null +++ b/site/cake/libs/view/templates/errors/scaffold_error.thtml @@ -0,0 +1,33 @@ +<?php +/* SVN FILE: $Id: scaffold_error.thtml 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.templates.errors + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +?> +<h1>Scaffold Error</h1> +<p class="error">Your must implement the following method in your controller</p> +<p><span class="notice"><strong>Notice:</strong> If you want to customize this error message, create <?php echo APP_DIR.DS."views/errors/scaffold_error.thtml"; ?>.</span></p> +<p> + function _scaffoldError() {<br /> + }<br /> +</p>
\ No newline at end of file diff --git a/site/cake/libs/view/templates/layouts/ajax.thtml b/site/cake/libs/view/templates/layouts/ajax.thtml new file mode 100644 index 0000000..16e9e96 --- /dev/null +++ b/site/cake/libs/view/templates/layouts/ajax.thtml @@ -0,0 +1,27 @@ +<?php +/* SVN FILE: $Id: ajax.thtml 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.templates.layouts + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +?> +<?php echo $content_for_layout; ?>
\ No newline at end of file diff --git a/site/cake/libs/view/templates/layouts/default.thtml b/site/cake/libs/view/templates/layouts/default.thtml new file mode 100644 index 0000000..b60fe84 --- /dev/null +++ b/site/cake/libs/view/templates/layouts/default.thtml @@ -0,0 +1,58 @@ +<?php +/* SVN FILE: $Id: default.thtml 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.templates.pages + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<title>CakePHP(tm) : <?php echo $title_for_layout; ?></title> +<?php echo $html->charset(); ?> +<link rel="icon" href="<?php echo $this->webroot . 'favicon.ico'; ?>" type="image/x-icon" /> +<link rel="shortcut icon" href="<?php echo $this->webroot . 'favicon.ico'; ?>" type="image/x-icon" /> +<?php echo $html->css('cake.generic'); ?> +</head> +<body> + <div id="container"> + <div id="header"> + <h1>CakePHP Rapid Development</h1> + </div> + <div id="content"> + <?php if ($session->check('Message.flash')) + { + $session->flash(); + } + echo $content_for_layout; + ?> + </div> + <div id="footer"> + + <a href="http://www.cakephp.org/" target="_new"> + <?php echo $html->image('cake.power.png', array('alt'=>"CakePHP(tm) : Rapid Development Framework", 'border'=>"0")); ?> + </a> + </div> + </div> + <?php echo $cakeDebug; ?> +</body> +</html>
\ No newline at end of file diff --git a/site/cake/libs/view/templates/layouts/flash.thtml b/site/cake/libs/view/templates/layouts/flash.thtml new file mode 100644 index 0000000..0d4db86 --- /dev/null +++ b/site/cake/libs/view/templates/layouts/flash.thtml @@ -0,0 +1,45 @@ +<?php +/* SVN FILE: $Id: flash.thtml 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.templates.layouts + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<title><?php echo $page_title; ?></title> +<?php echo $html->charset(); ?> + +<?php if (Configure::read() == 0) { ?> +<meta http-equiv="Refresh" content="<?php echo $pause; ?>;url=<?php echo $url; ?>"/> +<?php } ?> +<style><!-- +P { text-align:center; font:bold 1.1em sans-serif } +A { color:#444; text-decoration:none } +A:HOVER { text-decoration: underline; color:#44E } +--></style> +</head> +<body> +<p><a href="<?php echo $url; ?>"><?php echo $message; ?></a></p> +</body> +</html>
\ No newline at end of file diff --git a/site/cake/libs/view/templates/pages/home.thtml b/site/cake/libs/view/templates/pages/home.thtml new file mode 100644 index 0000000..39cda0a --- /dev/null +++ b/site/cake/libs/view/templates/pages/home.thtml @@ -0,0 +1,75 @@ +<?php +/* SVN FILE: $Id: home.thtml 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.templates.pages + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +?> +<p class="notice">Your database configuration file is <?php echo file_exists(CONFIGS.'database.php') ?' present.' . $filePresent = ' ' : ' not present.'; ?></p> +<?php if (!empty($filePresent)):?> +<?php uses('model' . DS . 'connection_manager'); $db = ConnectionManager::getInstance(); ?> +<?php $connected = $db->getDataSource('default'); ?> +<p class="notice">Cake<?php echo $connected->isConnected() ? ' is able to' : ' is not able to';?> connect to the database.</p> +<br /> +<?php endif; ?> +<h2>CakePHP release information is on CakeForge</h2> +<a href="https://trac.cakephp.org/wiki/notes/1.1.x.x">Read the release notes and get the latest version</a> +<h2>Editing this Page</h2> +<p> +To change the content of this page, create: /app/views/pages/home.thtml.<br /> +To change its layout, create: /app/views/layouts/default.thtml.<br /> +<a href="http://manual.cakephp.org/">See the views section of the manual for more info</a><br /> +You can also add some CSS styles for your pages at: app/webroot/css/. +</p> +<h2>More about Cake</h2> +<p> +CakePHP is a rapid development framework for PHP which uses commonly known design patterns like +Active Record, Association Data Mapping, Front Controller and MVC. +</p> +<p> +Our primary goal is to provide a structured framework that enables PHP users at all levels +to rapidly develop robust web applications, without any loss to flexibility. +</p> +<ul> + <li><a href="http://www.cakefoundation.org/">Cake Software Foundation</a> + <ul><li>Promoting development related to CakePHP</li></ul></li> + <li><a href="http://bakery.cakephp.org">The Bakery</a> + <ul><li>Everything CakePHP</li></ul></li> + <li><a href="http://astore.amazon.com/cakesoftwaref-20/">Book Store</a> + <ul><li>Recommended Software Books</li></ul></li> + <li><a href="http://www.cafepress.com/cakefoundation">CakeSchwag</a> + <ul><li>Get your own CakePHP gear - Doughnate to Cake</li></ul></li> + <li><a href="http://www.cakephp.org">CakePHP</a> + <ul><li>The Rapid Development Framework</li></ul></li> + <li><a href="http://manual.cakephp.org">CakePHP Manual</a> + <ul><li>Your Rapid Development Cookbook</li></ul></li> + <li><a href="http://api.cakephp.org">CakePHP API</a> + <ul><li>Docblock Your Best Friend</li></ul></li> + <li><a href="http://www.cakeforge.org">CakeForge</a> + <ul><li>Open Development for CakePHP</li></ul></li> + <li><a href="https://trac.cakephp.org/">CakePHP Trac</a> + <ul><li>For the Development of CakePHP (Tickets, SVN browser, Roadmap, Changelogs)</li></ul></li> + <li><a href="http://groups-beta.google.com/group/cake-php">CakePHP Google Group</a> + <ul><li>Community mailing list</li></ul></li> + <li><a href="irc://irc.freenode.net/cakephp">irc.freenode.net #cakephp</a> + <ul><li>Live chat about CakePHP</li></ul></li> +</ul>
\ No newline at end of file diff --git a/site/cake/libs/view/templates/scaffolds/add.thtml b/site/cake/libs/view/templates/scaffolds/add.thtml new file mode 100644 index 0000000..2c9852d --- /dev/null +++ b/site/cake/libs/view/templates/scaffolds/add.thtml @@ -0,0 +1,40 @@ +<?php +/* SVN FILE: $Id: add.thtml 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.templates.scaffolds + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +?> +<h1>New <?php echo Inflector::humanize($this->name)?></h1> +<?php +if (is_null($this->plugin)) { + $path = '/'; +} else { + $path = '/'.$this->plugin.'/'; +} +echo $html->formTag($path. Inflector::underscore($this->name).'/create'); +echo $form->generateFields( $fieldNames ); +echo $form->generateSubmitDiv( 'Add' );?> +</form> +<ul class='actions'> +<?php echo "<li>".$html->link('List '.Inflector::humanize($this->name), $path.$this->viewPath.'/index')."</li>"; ?> +</ul>
\ No newline at end of file diff --git a/site/cake/libs/view/templates/scaffolds/edit.thtml b/site/cake/libs/view/templates/scaffolds/edit.thtml new file mode 100644 index 0000000..056000f --- /dev/null +++ b/site/cake/libs/view/templates/scaffolds/edit.thtml @@ -0,0 +1,56 @@ +<?php +/* SVN FILE: $Id: edit.thtml 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.templates.scaffolds + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +$modelName = ucwords(Inflector::singularize($this->name)); +$modelKey = $modelName; +if (is_null($this->plugin)) { + $path = '/'; +} else { + $path = '/'.$this->plugin.'/'; +}?> +<h1><?php echo $type.' '.Inflector::humanize($modelName);?></h1> +<?php +if ($type == 'Edit') { + echo $html->formTag($path . Inflector::underscore($this->name) .'/update'); +} else { + echo $html->formTag($path. Inflector::underscore($this->name).'/create'); +} +echo $form->generateFields( $fieldNames ); +echo $form->generateSubmitDiv( 'Save' ); ?> +</form> +<ul class='actions'> +<?php +if ($type == 'Edit') { + echo "<li>".$html->link('Delete '.Inflector::humanize($modelName), $path.$this->viewPath.'/delete/'.$data[$modelKey][$this->controller->{$modelName}->primaryKey])."</li>"; +} +echo "<li>".$html->link('List '.Inflector::humanize($modelName), $path.$this->viewPath.'/index')."</li>"; +if ($type == 'Edit') { + foreach ($fieldNames as $field => $value) { + if (isset($value['foreignKey'])) { + echo "<li>".$html->link( "View ".Inflector::humanize($value['controller']), $path.Inflector::underscore($value['controller'])."/view/".$data[$modelKey][$field] )."</li>"; + } + } +}?> +</ul>
\ No newline at end of file diff --git a/site/cake/libs/view/templates/scaffolds/index.thtml b/site/cake/libs/view/templates/scaffolds/index.thtml new file mode 100644 index 0000000..0b6283a --- /dev/null +++ b/site/cake/libs/view/templates/scaffolds/index.thtml @@ -0,0 +1,95 @@ +<?php +/* SVN FILE: $Id: index.thtml 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.templates.scaffolds + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +?> +<h1>List <?php echo Inflector::humanize($this->name)?></h1> +<?php +$model = ucwords(Inflector::singularize($this->name)); +$modelKey = $model; +$humanName = Inflector::humanize($this->name); +$humanSingularName = Inflector::singularize( $humanName ); +if (is_null($this->plugin)) { + $path = '/'; +} else { + $path = '/'.$this->plugin.'/'; +} +if (!empty($this->controller->{$model}->modelToTable)) { + foreach ($this->controller->{$model}->modelToTable as $key => $value) { + $alias[] = $key; + } +}?> +<table class="inav" cellpadding="0" cellspacing="0"> +<thead> +<tr> +<?php +foreach ($fieldNames as $fieldName) {?> + <th><?php echo $fieldName['prompt'];?></th> +<?php }?> +<th>Actions</th> +</tr> +</thead> +<tbody> +<?php +$iRowIndex = 0; +if (is_array($data)) { + foreach ($data as $row) { + if ($iRowIndex++ % 2 == 0) { + echo "<tr>"; + } else { + echo "<tr class='altRow'>"; + } + $count = 0; + foreach ($fieldNames as $field=>$value) { ?> + <td> +<?php + if (isset($value['foreignKey'])) { + $otherModelKey = Inflector::underscore($value['modelKey']); + $otherControllerName = $value['controller']; + $otherModelObject =& ClassRegistry::getObject( $otherModelKey ); + if (is_object($otherModelObject)) { + $displayText = $row[$alias[$count]][ $otherModelObject->getDisplayField() ]; + } else { + $displayText = $row[$alias[$count]][$field]; + } + echo $html->link( $displayText, $path.Inflector::underscore($otherControllerName)."/view/".$row[$modelKey][$field] ); + $count++; + } else { + echo $row[$modelKey][$field]; + }?> + </td> +<?php } ?> + <td class="listactions"><?php echo $html->link('View',$path.$this->viewPath."/view/{$row[$modelKey][$this->controller->{$model}->primaryKey]}/")?> + <?php echo $html->link('Edit',$path.$this->viewPath."/edit/{$row[$modelKey][$this->controller->{$model}->primaryKey]}/")?> + <?php echo $html->link('Delete',$path.$this->viewPath."/delete/{$row[$modelKey][$this->controller->{$model}->primaryKey]}/", null, 'Are you sure you want to delete id '.$row[$modelKey][$this->controller->{$model}->primaryKey].' ?')?> + </td> + </tr> +<?php + } +}?> +</tbody> +</table> +<ul class="actions"> + <li><?php echo $html->link('New '.$humanSingularName, $path.$this->viewPath.'/add'); ?></li> +</ul>
\ No newline at end of file diff --git a/site/cake/libs/view/templates/scaffolds/view.thtml b/site/cake/libs/view/templates/scaffolds/view.thtml new file mode 100644 index 0000000..e00d2ee --- /dev/null +++ b/site/cake/libs/view/templates/scaffolds/view.thtml @@ -0,0 +1,166 @@ +<?php +/* SVN FILE: $Id: view.thtml 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view.templates.scaffolds + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +?> +<?php +$modelName = ucwords(Inflector::singularize($this->name)); +$modelKey = Inflector::underscore($modelName); +$objModel =& ClassRegistry::getObject($modelKey); +if (is_null($this->plugin)) { + $path = '/'; +} else { + $path = '/'.$this->plugin.'/'; +} +if (!empty($objModel->modelToTable)) { + foreach ($objModel->modelToTable as $key => $value) { + $alias[] = $key; + } + $count = 0; +}?> +<h1>View +<?php echo Inflector::humanize($modelName)?> +</h1> +<dl> +<?php +foreach ($fieldNames as $field => $value) { + echo "<dt>".$value['prompt']."</dt>"; + if (isset($value['foreignKey'])) { + $otherModelObject =& ClassRegistry::getObject(Inflector::underscore($objModel->tableToModel[$value['table']])); + $displayField = $otherModelObject->getDisplayField(); + $displayText = $data[$alias[$count]][$displayField]; + if (!empty($data[$objModel->tableToModel[$objModel->table]][$field]) && (isset($displayText))) { + echo "<dd>".$html->link($displayText, $path.Inflector::underscore($value['controller']).'/view/' + .$data[$objModel->tableToModel[$objModel->table]][$field] )."</dd>"; + } else { + echo "<dd> </dd>"; + } + $count++; + } else { + if ( !empty($data[$objModel->tableToModel[$objModel->table]][$field])) { + echo "<dd>".$data[$objModel->tableToModel[$objModel->table]][$field]."</dd>"; + } else { + echo "<dd> </dd>"; + } + } +}?> +</dl> +<ul class='actions'> +<?php +echo "<li>".$html->link('Edit '.Inflector::humanize($objModel->name), $path.$this->viewPath.'/edit/'.$data[$objModel->tableToModel[$objModel->table]][$this->controller->{$modelName}->primaryKey])."</li>"; +echo "<li>".$html->link('Delete '.Inflector::humanize($objModel->name), $path.$this->viewPath.'/delete/'.$data[$objModel->tableToModel[$objModel->table]][$this->controller->{$modelName}->primaryKey], null, 'Are you sure you want to delete id '.$data[$objModel->tableToModel[$objModel->table]][$this->controller->{$modelName}->primaryKey].' ?')."</li>"; +echo "<li>".$html->link('List '.Inflector::humanize($objModel->name), $path.$this->viewPath.'/index')."</li>"; +echo "<li>".$html->link('New '.Inflector::humanize($objModel->name), $path.$this->viewPath.'/add')."</li>"; + +foreach ( $fieldNames as $field => $value ) { + if ( isset( $value['foreignKey'] ) ) { + echo "<li>".$html->link( "List ".Inflector::humanize($value['controller']), $path.Inflector::underscore($value['controller'])."/index/")."</li>"; + } +}?> +</ul> + +<!--hasOne relationships --> +<?php +foreach ($objModel->hasOne as $association => $relation) { + $model = $relation['className']; + $otherModelName = $objModel->tableToModel[$objModel->{$model}->table]; + $controller = Inflector::pluralize($model); + $new = true; + echo "<div class='related'><H2>Related ".Inflector::humanize($association)."</H2>"; + echo "<dl>"; + if (isset($data[$association]) && is_array($data[$association])) { + foreach ($data[$association] as $field => $value) { + if (isset($value)) { + echo "<dt>".Inflector::humanize($field)."</dt>"; + if (!empty($value)) { + echo "<dd>".$value."</dd>"; + } else { + echo "<dd> </dd>"; + } + $new = null; + } + } + echo "</dl>"; + if ($new == null) { + echo "<ul class='actions'><li>".$html->link('Edit '.Inflector::humanize($association),$path.Inflector::underscore($controller)."/edit/{$data[$association][$objModel->{$model}->primaryKey]}")."</li></ul></div>"; + } else { + echo "<ul class='actions'><li>".$html->link('New '.Inflector::humanize($association),$path.Inflector::underscore($controller)."/add/{$data[$association][$objModel->{$model}->primaryKey]}")."</li></ul></div>"; + } + } +} +?> + +<!-- HAS MANY AND HASANDBELONGSTOMANY --> +<?php +$relations = array_merge($objModel->hasMany, $objModel->hasAndBelongsToMany); +foreach ($relations as $association => $relation) { + $model = $relation['className']; + $count = 0; + $otherModelName = Inflector::singularize($model); + $controller = Inflector::pluralize($model); + + echo "<div class='related'><H2>Related ".Inflector::humanize(Inflector::pluralize($association))."</H2>"; + if (isset($data[$association][0]) && is_array($data[$association])) {?> + <table class="inav" cellspacing="0"> + <tr> +<?php + $bFound = false; + foreach ($data[$association][0] as $column=>$value) { + echo "<th>".Inflector::humanize($column)."</th>"; + }?> + <th>Actions</th> + </tr> +<?php + foreach ($data[$association] as $row) { + echo "<tr>"; + foreach ($row as $column=>$value) { + echo "<td>".$value."</td>"; + } + if (isset($this->controller->{$modelName}->{$association})) {?> + <td class="listactions"><?php echo $html->link('View',$path.Inflector::underscore($controller). + "/view/{$row[$this->controller->{$modelName}->{$association}->primaryKey]}/")?> + <?php echo $html->link('Edit',$path.Inflector::underscore($controller). + "/edit/{$row[$this->controller->{$modelName}->{$association}->primaryKey]}/")?> + <?php echo $html->link('Delete',$path.Inflector::underscore($controller). + "/delete/{$row[$this->controller->{$modelName}->{$association}->primaryKey]}/", null, 'Are you sure you want to delete id '.$row[$this->controller->{$modelName}->{$association}->primaryKey].' ?')?> + </td> +<?php + } else {?> + <td class="listactions"><?php echo $html->link('View',$path.Inflector::underscore($controller). + "/view/{$row[$this->controller->{$modelName}->primaryKey]}/")?> + <?php echo $html->link('Edit',$path.Inflector::underscore($controller). + "/edit/{$row[$this->controller->{$modelName}->primaryKey]}/")?> + <?php echo $html->link('Delete',$path.Inflector::underscore($controller). + "/delete/{$row[$this->controller->{$modelName}->primaryKey]}/", null, 'Are you sure you want to delete id '.$row[$this->controller->{$modelName}->primaryKey].' ?')?> + </td> +<?php + } + echo "</tr>"; + }?> + </table> +<?php }?> +<ul class="actions"> +<?php echo "<li>".$html->link('New '.Inflector::humanize($association),$path.Inflector::underscore($controller)."/add/")."</li>";?> +</ul></div> +<?php }?>
\ No newline at end of file diff --git a/site/cake/libs/view/view.php b/site/cake/libs/view/view.php new file mode 100644 index 0000000..46700ad --- /dev/null +++ b/site/cake/libs/view/view.php @@ -0,0 +1,765 @@ +<?php +/* SVN FILE: $Id: view.php 6305 2008-01-02 02:33:56Z phpnut $ */ +/** + * Methods for displaying presentation data in the view. + * + * PHP versions 4 and 5 + * + * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs.view + * @since CakePHP(tm) v 0.10.0.1076 + * @version $Revision: 6305 $ + * @modifiedby $LastChangedBy: phpnut $ + * @lastmodified $Date: 2008-01-01 20:33:56 -0600 (Tue, 01 Jan 2008) $ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +/** + * Included libraries. + */ +uses ('view' . DS . 'helper', 'class_registry'); +/** + * View, the V in the MVC triad. + * + * Class holding methods for displaying presentation data. + * + * @package cake + * @subpackage cake.cake.libs.view + */ +class View extends Object{ +/** + * Name of the controller. + * + * @var string Name of controller + * @access public + */ + var $name = null; +/** + * Stores the current URL (for links etc.) + * + * @var string Current URL + * @access public + */ + var $here = null; +/** + * Action to be performed. + * + * @var string Name of action + * @access public + */ + var $action = null; +/** + * An array of names of built-in helpers to include. + * + * @var mixed A single name as a string or a list of names as an array. + * @access public + */ + var $helpers = array('Html'); +/** + * Path to View. + * + * @var string Path to View + * @access public + */ + var $viewPath; +/** + * Replaced with public var viewVars + * @access protected + * @deprecated + */ + var $_viewVars = array(); +/** + * Variables for the view + * + * @var array + * @access public + */ + var $viewVars = array(); +/** + * Title HTML element of this View. + * + * @var boolean + * @access public + */ + var $pageTitle = false; +/** + * Path parts for creating links in views. + * + * @var string Base URL + * @access public + */ + var $base = null; +/** + * Name of layout to use with this View. + * + * @var string + * @access public + */ + var $layout = 'default'; +/** + * Turns on or off Cake's conventional mode of rendering views. On by default. + * + * @var boolean + * @access public + */ + var $autoRender = true; +/** + * Turns on or off Cake's conventional mode of finding layout files. On by default. + * + * @var boolean + * @access public + */ + var $autoLayout = true; +/** + * Array of parameter data + * + * @var array Parameter data + * @access public + */ + var $params; +/** + * True when the view has been rendered. + * + * @var boolean + * @access protected + */ + var $_hasRendered = null; +/** + * @deprecated will not be avialable after 1.1.x.x + */ + var $controller = null; +/** + * Array of loaded view helpers. + * + * @var array + * @access public + */ + var $loaded = array(); +/** + * File extension. Defaults to Cake's conventional ".thtml". + * + * @var array + * @access public + */ + var $ext = '.thtml'; +/** + * Sub-directory for this view file. + * + * @var string + * @access public + */ + var $subDir = null; +/** + * The directory where theme web accessible content is stored + * + * @var array + * @access public + */ + var $themeWeb = null; +/** + * Plugin name. A Plugin is a sub-application. + * This is used to set the correct paths for views + * + * @var string + * @access public + */ + var $plugin = null; +/** + * Creates system path to plugin: plugins . DS . plugin_name . DS + * + * @var string + */ + var $pluginPath = null; +/** + * Holds an array of plugin paths. + * VIEWS . $this->pluginPath + * APP . $this->pluginPath . views . DS + * + * @var array + */ + var $pluginPaths = array(); +/** + * List of variables to collect from the associated controller + * + * @var array + * @access protected + */ + var $_passedVars = array('viewVars', 'action', 'autoLayout', 'autoRender', 'ext', 'base', 'webroot', 'helpers', 'here', 'layout', 'modelNames', 'name', 'pageTitle', 'viewPath', 'params', 'data', 'webservices', 'plugin'); +/** + * Constructor + * + * Instance is created in Controller::render() and is never called directly + * + * @var object instance of the calling controller + */ + function __construct(&$controller) { + if (is_object($controller)) { + $this->controller =& $controller; + $c = count($this->_passedVars); + + for ($j = 0; $j < $c; $j++) { + $var = $this->_passedVars[$j]; + $this->{$var} = $controller->{$var}; + } + $this->_viewVars =& $this->viewVars; + } + if (!is_null($this->plugin)) { + $this->pluginPath = 'plugins'. DS . $this->plugin . DS; + $this->pluginPaths = array( + VIEWS . $this->pluginPath, + APP . $this->pluginPath . 'views' . DS, + ); + + } + parent::__construct(); + ClassRegistry::addObject('view', $this); + } +/** + * Renders view for given action and layout. If $file is given, that is used + * for a view filename (e.g. customFunkyView.thtml). + * + * @param string $action Name of action to render for + * @param string $layout Layout to use + * @param string $file Custom filename for view + * @return mixed returns an error if View::render() fails to find a related template. + * boolean on successful render + * @access public + */ + function render($action = null, $layout = null, $file = null) { + + if (isset($this->_hasRendered) && $this->_hasRendered) { + return true; + } else { + $this->_hasRendered = false; + } + + if (!$action) { + $action = $this->action; + } + $tempLayout = $this->layout; + + if ($layout) { + $this->setLayout($layout); + } + + if ($file) { + $viewFileName = $file; + } else { + $viewFileName = $this->_getViewFileName($action); + } + + if (!is_null($this->plugin) && is_null($file)) { + return $this->pluginView($action, $layout); + } + + if (!is_file($viewFileName) && !fileExistsInPath($viewFileName) || $viewFileName === '/' || $viewFileName === '\\') { + if (strpos($action, 'missingAction') !== false) { + $errorAction = 'missingAction'; + } else { + $errorAction = 'missingView'; + } + + foreach (array($this->name, 'errors') as $viewDir) { + $errorAction = Inflector::underscore($errorAction); + + if (file_exists(VIEWS . $viewDir . DS . $errorAction . $this->ext)) { + $missingViewFileName = VIEWS . $viewDir . DS . $errorAction . $this->ext; + } elseif ($missingViewFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . $viewDir . DS . $errorAction . '.thtml')) { + } else { + $missingViewFileName = false; + } + + $missingViewExists = is_file($missingViewFileName); + + if ($missingViewExists) { + break; + } + } + + if (strpos($action, 'missingView') === false) { + return $this->cakeError('missingView', array(array('className' => $this->controller->name, + 'action' => $action, + 'file' => $viewFileName, + 'base' => $this->base))); + + $isFatal = isset($this->isFatal) ? $this->isFatal : false; + + if (!$isFatal) { + $viewFileName = $missingViewFileName; + } + } else { + $missingViewExists = false; + } + + if (!$missingViewExists || $isFatal) { + if (Configure::read() > 0) { + trigger_error(sprintf("No template file for view %s (expected %s), create it first'", $action, $viewFileName), E_USER_ERROR); + } else { + $this->error('404', 'Not found', sprintf("The requested address %s was not found on this server.", '', "missing view \"{$action}\"")); + } + die(); + } + } + + if ($viewFileName && !$this->_hasRendered) { + if (substr($viewFileName, -5) === 'thtml') { + $out = View::_render($viewFileName, $this->viewVars); + } else { + $out = $this->_render($viewFileName, $this->viewVars); + } + + if ($out !== false) { + if ($this->layout && $this->autoLayout) { + $out = $this->renderLayout($out); + if (isset($this->loaded['cache']) && ((isset($this->controller) && $this->controller->cacheAction != false)) && (defined('CACHE_CHECK') && CACHE_CHECK === true)) { + $replace = array('<cake:nocache>', '</cake:nocache>'); + $out = str_replace($replace, '', $out); + } + } + + print $out; + $this->setLayout($tempLayout); + $this->_hasRendered = true; + } else { + $out = $this->_render($viewFileName, $this->viewVars); + trigger_error(sprintf("Error in view %s, got: <blockquote>%s</blockquote>", $viewFileName, $out), E_USER_ERROR); + } + return true; + } + } +/** + * Renders a piece of PHP with provided parameters and returns HTML, XML, or any other string. + * + * This realizes the concept of Elements, (or "partial layouts") + * and the $params array is used to send data to be used in the Element. + * + * @param string $name Name of template file in the/app/views/elements/ folder + * @param array $params Array of data to be made available to the for rendered view (i.e. the Element) + * @return string Rendered output + * @access public + */ + function renderElement($name, $params = array()) { + if (isset($params['plugin'])) { + $this->plugin = $params['plugin']; + $this->pluginPath = 'plugins' . DS . $this->plugin . DS; + $this->pluginPaths = array( + VIEWS . $this->pluginPath, + APP . $this->pluginPath . 'views' . DS, + ); + } + + $paths = Configure::getInstance(); + $viewPaths = am($this->pluginPaths, $paths->viewPaths); + + $file = null; + foreach ($viewPaths as $path) { + if (file_exists($path . 'elements' . DS . $name . $this->ext)) { + $file = $path . 'elements' . DS . $name . $this->ext; + break; + } elseif (file_exists($path . 'elements' . DS . $name . '.ctp')) { + $file = $path . 'elements' . DS . $name . '.ctp'; + break; + } + } + + if (!is_null($file)) { + $params = array_merge_recursive($params, $this->loaded); + return $this->_render($file, array_merge($this->viewVars, $params), false); + } + + if (!is_null($this->pluginPath)) { + $file = APP . $this->pluginPath . 'views' . DS . 'elements' . DS . $name . $this->ext; + } else { + $file = VIEWS . 'elements' . DS . $name . $this->ext; + } + + if (Configure::read() > 0) { + return "Element Not Found: " . $file; + } + } +/** + * Wrapper for View::renderElement(); + * + * @param string $name Name of template file in the/app/views/elements/ folder + * @param array $params Array of data to be made available to the for rendered view (i.e. the Element) + * @return string View::renderElement() + * @access public + */ + function element($name, $params = array()) { + return $this->renderElement($name, $params); + } +/** + * Renders a layout. Returns output from _render(). Returns false on error. + * + * @param string $contentForLayout Content to render in a view, wrapped by the surrounding layout. + * @return mixed Rendered output, or false on error + * @access public + */ + function renderLayout($contentForLayout) { + $layoutFilename = $this->_getLayoutFileName(); + + if (Configure::read() > 2 && $this->controller != null) { + $debug = View::_render(LIBS . 'view' . DS . 'templates' . DS . 'elements' . DS . 'dump.thtml', array('controller' => $this->controller), false); + } else { + $debug = ''; + } + + if ($this->pageTitle !== false) { + $pageTitle = $this->pageTitle; + } else { + $pageTitle = Inflector::humanize($this->viewPath); + } + + $dataForLayout = array_merge($this->viewVars, array('title_for_layout' => $pageTitle, + 'content_for_layout' => $contentForLayout, + 'cakeDebug' => $debug)); + + if (is_file($layoutFilename)) { + if (empty($this->loaded) && !empty($this->helpers)) { + $loadHelpers = true; + } else { + $loadHelpers = false; + $dataForLayout = array_merge($dataForLayout, $this->loaded); + } + + if (substr($layoutFilename, -5) === 'thtml') { + $out = View::_render($layoutFilename, $dataForLayout, $loadHelpers, true); + } else { + $out = $this->_render($layoutFilename, $dataForLayout, $loadHelpers); + } + + if ($out === false) { + $out = $this->_render($layoutFilename, $dataForLayout); + trigger_error(sprintf("Error in layout %s, got: <blockquote>%s</blockquote>", $layoutFilename, $out), E_USER_ERROR); + return false; + } else { + return $out; + } + } else { + return $this->cakeError('missingLayout', array(array('layout' => $this->layout, + 'file' => $layoutFilename, + 'base' => $this->base))); + } + } +/** + * Sets layout to be used when rendering. + * + * @param string $layout Name of layout. + * @return void + * @access public + * @deprecated in 1.2.x.x + */ + function setLayout($layout) { + $this->layout = $layout; + } +/** + * Displays an error page to the user. Uses layouts/error.html to render the page. + * + * @param int $code HTTP Error code (for instance: 404) + * @param string $name Name of the error (for instance: Not Found) + * @param string $message Error message as a web page + * @return rendered error message + * @access public + * + */ + function error($code, $name, $message) { + header ("HTTP/1.0 {$code} {$name}"); + print ($this->_render(VIEWS . 'layouts/error.thtml', array('code' => $code, + 'name' => $name, + 'message' => $message))); + } +/** + * Returns filename of given action's template file (.thtml) as a string. CamelCased action names will be under_scored! This means that you can have LongActionNames that refer to long_action_names.thtml views. + * + * @param string $action Controller action to find template filename for + * @return string Template filename + * @access protected + */ + function _getViewFileName($action) { + $action = Inflector::underscore($action); + + if (!is_null($this->webservices)) { + $type = strtolower($this->webservices) . DS; + } else { + $type = null; + } + + $position = strpos($action, '..'); + if ($position !== false) { + $action = explode('/', $action); + $i = array_search('..', $action); + unset($action[$i - 1]); + unset($action[$i]); + $action = '..' . DS . implode(DS, $action); + } + + $paths = Configure::getInstance(); + $viewPaths = am($this->pluginPaths, $paths->viewPaths); + + $name = $this->viewPath . DS . $this->subDir . $type . $action; + foreach ($viewPaths as $path) { + if (file_exists($path . $name . $this->ext)) { + return $path . $name . $this->ext; + } elseif (file_exists($path . $name . '.ctp')) { + return $path . $name . '.ctp'; + } + } + + if ($viewFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . 'errors' . DS . $type . $action . '.thtml')) { + return $viewFileName; + } elseif ($viewFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . $this->viewPath . DS . $type . $action . '.thtml')) { + return $viewFileName; + } else { + if (!is_null($this->pluginPath)) { + $viewFileName = APP . $this->pluginPath . 'views' . DS . $name . $this->ext; + } else { + $viewFileName = VIEWS . $name . $this->ext; + } + } + return $viewFileName; + } +/** + * Returns layout filename for this template as a string. + * + * @return string Filename for layout file (.thtml). + * @access protected + */ + function _getLayoutFileName() { + if (isset($this->webservices) && !is_null($this->webservices)) { + $type = strtolower($this->webservices) . DS; + } else { + $type = null; + } + + $paths = Configure::getInstance(); + $viewPaths = am($this->pluginPaths, $paths->viewPaths); + + $name = $this->subDir . $type . $this->layout; + foreach ($viewPaths as $path) { + if (file_exists($path . 'layouts' . DS . $name . $this->ext)) { + return $path . 'layouts' . DS . $name . $this->ext; + } elseif (file_exists($path . 'layouts' . DS . $name . '.ctp')) { + return $path . 'layouts' . DS . $name . '.ctp'; + } + } + + if (!is_null($this->pluginPath)) { + $layoutFileName = APP . $this->pluginPath . 'views' . DS . 'layouts' . DS . $name . $this->ext; + } else { + $layoutFileName = VIEWS . 'layouts' . DS . $name . $this->ext; + } + + $layoutFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . 'layouts' . DS . $type . $this->layout . '.thtml'); + if (empty($layoutFileName) && !empty($type)) { + $layoutFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . 'layouts' . DS . $type . 'default.thtml'); + } + return $layoutFileName; + } + +/** + * Renders and returns output for given view filename with its array of data. + * + * @param string $___viewFn Filename of the view + * @param array $___dataForView Data to include in rendered view + * @return string Rendered output + * @access protected + */ + function _render($___viewFn, $___dataForView, $loadHelpers = true, $cached = false) { + if ($this->helpers != false && $loadHelpers === true) { + $loadedHelpers = array(); + $loadedHelpers = $this->_loadHelpers($loadedHelpers, $this->helpers); + + foreach (array_keys($loadedHelpers) as $helper) { + $replace = strtolower(substr($helper, 0, 1)); + $camelBackedHelper = preg_replace('/\\w/', $replace, $helper, 1); + + ${$camelBackedHelper} =& $loadedHelpers[$helper]; + + if (isset(${$camelBackedHelper}->helpers) && is_array(${$camelBackedHelper}->helpers)) { + foreach (${$camelBackedHelper}->helpers as $subHelper) { + ${$camelBackedHelper}->{$subHelper} =& $loadedHelpers[$subHelper]; + } + } + $this->loaded[$camelBackedHelper] =& ${$camelBackedHelper}; + } + } + extract($___dataForView, EXTR_SKIP); + $BASE = $this->base; + $params =& $this->params; + + ob_start(); + + if (Configure::read() > 0) { + include ($___viewFn); + } else { + @include ($___viewFn); + } + + if ($this->helpers != false && $loadHelpers === true) { + foreach ($loadedHelpers as $helper) { + if (is_object($helper)) { + if (is_subclass_of($helper, 'Helper') || is_subclass_of($helper, 'helper')) { + $helper->afterRender(); + } + } + } + } + $out = ob_get_clean(); + + if (isset($this->loaded['cache']) && ((isset($this->controller) && $this->controller->cacheAction != false)) && (defined('CACHE_CHECK') && CACHE_CHECK === true)) { + if (is_a($this->loaded['cache'], 'CacheHelper')) { + $cache =& $this->loaded['cache']; + + if ($cached === true) { + $cache->view = &$this; + } + + $cache->base = $this->base; + $cache->here = $this->here; + $cache->action = $this->action; + $cache->controllerName = $this->params['controller']; + $cache->cacheAction = $this->controller->cacheAction; + $cache->cache($___viewFn, $out, $cached); + } + } + return $out; + } +/** + * Loads helpers, with their dependencies. + * + * @param array $loaded List of helpers that are already loaded. + * @param array $helpers List of helpers to load. + * @return array + * @access protected + */ + function &_loadHelpers(&$loaded, $helpers) { + static $tags; + $helpers[] = 'Session'; + if (empty($tags)) { + $helperTags = new Helper(); + $tags = $helperTags->loadConfig(); + } + + foreach ($helpers as $helper) { + $parts = preg_split('/\/|\./', $helper); + + if (count($parts) === 1) { + $plugin = $this->plugin; + } else { + $plugin = Inflector::underscore($parts['0']); + $helper = $parts[count($parts) - 1]; + } + $helperCn = $helper . 'Helper'; + + if (in_array($helper, array_keys($loaded)) !== true) { + if (!class_exists($helperCn)) { + if (is_null($plugin) || !loadPluginHelper($plugin, $helper)) { + if (!loadHelper($helper)) { + $this->cakeError('missingHelperFile', array(array( + 'helper' => $helper, + 'file' => Inflector::underscore($helper) . '.php', + 'base' => $this->base))); + exit(); + } + } + if (!class_exists($helperCn)) { + $this->cakeError('missingHelperClass', array(array( + 'helper' => $helper, + 'file' => Inflector::underscore($helper) . '.php', + 'base' => $this->base))); + exit(); + } + } + + $camelBackedHelper = Inflector::variable($helper); + + ${$camelBackedHelper} =& new $helperCn; + ${$camelBackedHelper}->view =& $this; + ${$camelBackedHelper}->tags = $tags; + + $vars = array('base', 'webroot', 'here', 'params', 'action', 'data', 'themeWeb', 'plugin'); + $c = count($vars); + for ($j = 0; $j < $c; $j++) { + ${$camelBackedHelper}->{$vars[$j]} = $this->{$vars[$j]}; + } + + if (!empty($this->validationErrors)) { + ${$camelBackedHelper}->validationErrors = $this->validationErrors; + } + + $loaded[$helper] =& ${$camelBackedHelper}; + + if (isset(${$camelBackedHelper}->helpers) && is_array(${$camelBackedHelper}->helpers)) { + $loaded = &$this->_loadHelpers($loaded, ${$camelBackedHelper}->helpers); + } + } + } + return $loaded; + } +/** + * Returns a plugin view + * + * @param string $action Name of action to render for + * @param string $layout Layout to use + * @return mixed View::render() if template is found, error if template is missing + * @access public + */ + function pluginView($action, $layout) { + $viewFileName = APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . $this->viewPath . DS . $action . $this->ext; + + if (file_exists($viewFileName)) { + $this->render($action, $layout, $viewFileName); + } else { + return $this->cakeError('missingView', array(array( + 'className' => $this->controller->name, + 'action' => $action, + 'file' => $viewFileName, + 'base' => $this->base))); + } + } +/** + * Renders a cached view if timestamp in file is less or equal to current time. + * + * If $layout is xml content type will be set before rendering the cache + * + * @param string $filename + * @param int $timeStart + * @return mixed outputs view, or returns void if timestamp has expired + * @access public + */ + function renderCache($filename, $timeStart) { + ob_start(); + include ($filename); + + if (Configure::read() > 0 && $this->layout != 'xml') { + echo "<!-- Cached Render Time: " . round(getMicrotime() - $timeStart, 4) . "s -->"; + } + $out = ob_get_clean(); + + if (preg_match('/^<!--cachetime:(\\d+)-->/', $out, $match)) { + if (time() >= $match['1']) { + @unlink($filename); + unset ($out); + return; + } else { + if ($this->layout === 'xml') { + header('Content-type: text/xml'); + } + $out = str_replace('<!--cachetime:'.$match['1'].'-->', '', $out); + e($out); + die(); + } + } + } +} +?>
\ No newline at end of file |