summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
Diffstat (limited to 'framework')
-rw-r--r--framework/Web/Javascripts/colorpicker/colorpicker.js4
-rwxr-xr-xframework/Web/Javascripts/colorpicker/spacer.gifbin0 -> 43 bytes
-rw-r--r--framework/Web/Javascripts/datepicker/datepicker.js8
-rw-r--r--framework/Web/Javascripts/js/colorpicker.js4
-rw-r--r--framework/Web/Javascripts/js/datepicker.js6
-rw-r--r--framework/Web/UI/WebControls/THtmlArea.php2
-rwxr-xr-xframework/prado-cli.php413
7 files changed, 425 insertions, 12 deletions
diff --git a/framework/Web/Javascripts/colorpicker/colorpicker.js b/framework/Web/Javascripts/colorpicker/colorpicker.js
index 06cfb037..acf5531c 100644
--- a/framework/Web/Javascripts/colorpicker/colorpicker.js
+++ b/framework/Web/Javascripts/colorpicker/colorpicker.js
@@ -68,7 +68,7 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
{
var constructor = mode == "Basic" ? "getBasicPickerContainer": "getFullPickerContainer"
this.element = this[constructor](this.options['ID'], this.options['Palette'])
- document.body.appendChild(this.element);
+ this.input.parentNode.appendChild(this.element);
this.element.style.display = "none";
if(Prado.Browser().ie)
@@ -90,7 +90,7 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
{
if(!this.showing)
{
- var pos = Position.cumulativeOffset(this.input);
+ var pos = Position.positionedOffset(this.input);
pos[1] += this.input.offsetHeight;
this.element.style.top = (pos[1]-1) + "px";
diff --git a/framework/Web/Javascripts/colorpicker/spacer.gif b/framework/Web/Javascripts/colorpicker/spacer.gif
new file mode 100755
index 00000000..fc256098
--- /dev/null
+++ b/framework/Web/Javascripts/colorpicker/spacer.gif
Binary files differ
diff --git a/framework/Web/Javascripts/datepicker/datepicker.js b/framework/Web/Javascripts/datepicker/datepicker.js
index 11bee07e..4525c1ba 100644
--- a/framework/Web/Javascripts/datepicker/datepicker.js
+++ b/framework/Web/Javascripts/datepicker/datepicker.js
@@ -247,10 +247,10 @@ Prado.WebUI.TDatePicker.prototype =
this.iePopUp.style.position = "absolute"
this.iePopUp.scrolling="no"
this.iePopUp.frameBorder="0"
- document.body.appendChild(this.iePopUp);
+ this.control.parentNode.appendChild(this.iePopUp);
}
- document.body.appendChild(this._calDiv);
+ this.control.parentNode.appendChild(this._calDiv);
this.update();
this.updateHeader();
@@ -542,8 +542,8 @@ Prado.WebUI.TDatePicker.prototype =
if(!this.showing)
{
- var pos = Position.cumulativeOffset(this.control);
-
+ var pos = Position.positionedOffset(this.control);
+
pos[1] += this.getDatePickerOffsetHeight();
this._calDiv.style.display = "block";
diff --git a/framework/Web/Javascripts/js/colorpicker.js b/framework/Web/Javascripts/js/colorpicker.js
index 47949239..8429b5e6 100644
--- a/framework/Web/Javascripts/js/colorpicker.js
+++ b/framework/Web/Javascripts/js/colorpicker.js
@@ -33,7 +33,7 @@ Event.observe(this.button,"click",this._buttonOnClick);Event.observe(this.input,
{var mode=this.options['Mode'];if(this.element==null)
{var constructor=mode=="Basic"?"getBasicPickerContainer":"getFullPickerContainer"
this.element=this[constructor](this.options['ID'],this.options['Palette'])
-document.body.appendChild(this.element);this.element.style.display="none";if(Prado.Browser().ie)
+this.input.parentNode.appendChild(this.element);this.element.style.display="none";if(Prado.Browser().ie)
{this.iePopUp=document.createElement('iframe');this.iePopUp.src=Prado.WebUI.TColorPicker.UIImages['button.gif'];this.iePopUp.style.position="absolute"
this.iePopUp.scrolling="no"
this.iePopUp.frameBorder="0"
@@ -42,7 +42,7 @@ if(mode=="Full")
this.initializeFullPicker();}
this.show(mode);},show:function(type)
{if(!this.showing)
-{var pos=Position.cumulativeOffset(this.input);pos[1]+=this.input.offsetHeight;this.element.style.top=(pos[1]-1)+"px";this.element.style.left=pos[0]+"px";this.element.style.display="block";this.ieHack(type);this._documentClickEvent=this.hideOnClick.bindEvent(this,type);this._documentKeyDownEvent=this.keyPressed.bindEvent(this,type);Event.observe(document.body,"click",this._documentClickEvent);Event.observe(document,"keydown",this._documentKeyDownEvent);this.showing=true;if(type=="Full")
+{var pos=Position.positionedOffset(this.input);pos[1]+=this.input.offsetHeight;this.element.style.top=(pos[1]-1)+"px";this.element.style.left=pos[0]+"px";this.element.style.display="block";this.ieHack(type);this._documentClickEvent=this.hideOnClick.bindEvent(this,type);this._documentKeyDownEvent=this.keyPressed.bindEvent(this,type);Event.observe(document.body,"click",this._documentClickEvent);Event.observe(document,"keydown",this._documentKeyDownEvent);this.showing=true;if(type=="Full")
{this.observeMouseMovement();var color=Rico.Color.createFromHex(this.input.value);this.inputs.oldColor.style.backgroundColor=color.asHex();this.setColor(color,true);}}},hide:function(event)
{if(this.showing)
{if(this.iePopUp)
diff --git a/framework/Web/Javascripts/js/datepicker.js b/framework/Web/Javascripts/js/datepicker.js
index 090f3cbd..bbf81293 100644
--- a/framework/Web/Javascripts/js/datepicker.js
+++ b/framework/Web/Javascripts/js/datepicker.js
@@ -22,8 +22,8 @@ div=document.createElement("div");div.className="calendarFooter";this._calDiv.ap
{this.iePopUp=document.createElement('iframe');this.iePopUp.src=Prado.WebUI.TDatePicker.spacer;this.iePopUp.style.position="absolute"
this.iePopUp.scrolling="no"
this.iePopUp.frameBorder="0"
-document.body.appendChild(this.iePopUp);}
-document.body.appendChild(this._calDiv);this.update();this.updateHeader();this.ieHack(true);previousMonth.hideFocus=true;nextMonth.hideFocus=true;todayButton.hideFocus=true;Event.observe(previousMonth,"click",this.prevMonth.bindEvent(this));Event.observe(nextMonth,"click",this.nextMonth.bindEvent(this));Event.observe(todayButton,"click",this.selectToday.bindEvent(this));Event.observe(this._monthSelect,"change",this.monthSelect.bindEvent(this));Event.observe(this._yearSelect,"change",this.yearSelect.bindEvent(this));Event.observe(this._calDiv,"mousewheel",this.mouseWheelChange.bindEvent(this));Event.observe(calendarBody,"click",this.selectDate.bindEvent(this));Prado.Element.focus(this.control);},ieHack:function(cleanup)
+this.control.parentNode.appendChild(this.iePopUp);}
+this.control.parentNode.appendChild(this._calDiv);this.update();this.updateHeader();this.ieHack(true);previousMonth.hideFocus=true;nextMonth.hideFocus=true;todayButton.hideFocus=true;Event.observe(previousMonth,"click",this.prevMonth.bindEvent(this));Event.observe(nextMonth,"click",this.nextMonth.bindEvent(this));Event.observe(todayButton,"click",this.selectToday.bindEvent(this));Event.observe(this._monthSelect,"change",this.monthSelect.bindEvent(this));Event.observe(this._yearSelect,"change",this.yearSelect.bindEvent(this));Event.observe(this._calDiv,"mousewheel",this.mouseWheelChange.bindEvent(this));Event.observe(calendarBody,"click",this.selectDate.bindEvent(this));Prado.Element.focus(this.control);},ieHack:function(cleanup)
{if(this.iePopUp)
{this.iePopUp.style.display="block";this.iePopUp.style.top=(this._calDiv.offsetTop-1)+"px";this.iePopUp.style.left=(this._calDiv.offsetLeft-1)+"px";this.iePopUp.style.width=Math.abs(this._calDiv.offsetWidth-2)+"px";this.iePopUp.style.height=(this._calDiv.offsetHeight+1)+"px";if(cleanup)this.iePopUp.style.display="none";}},keyPressed:function(ev)
{if(!this.showing)return;if(!ev)ev=document.parentWindow.event;var kc=ev.keyCode!=null?ev.keyCode:ev.charCode;if(kc==Event.KEY_RETURN||kc==Event.KEY_SPACEBAR||kc==Event.KEY_TAB)
@@ -92,7 +92,7 @@ this.onChange();},getElement:function()
{if(this.options.InputMode=="TextBox")
return this.control.offsetHeight;var control=Prado.WebUI.TDatePicker.getDayListControl(this.control);if(control)return control.offsetHeight;var control=Prado.WebUI.TDatePicker.getMonthListControl(this.control);if(control)return control.offsetHeight;var control=Prado.WebUI.TDatePicker.getYearListControl(this.control);if(control)return control.offsetHeight;return 0;},show:function()
{this.create();if(!this.showing)
-{var pos=Position.cumulativeOffset(this.control);pos[1]+=this.getDatePickerOffsetHeight();this._calDiv.style.display="block";this._calDiv.style.top=(pos[1]-1)+"px";this._calDiv.style.left=pos[0]+"px";this.ieHack(false);this.documentClickEvent=this.hideOnClick.bindEvent(this);this.documentKeyDownEvent=this.keyPressed.bindEvent(this);Event.observe(document.body,"click",this.documentClickEvent);var date=this.getDateFromInput();if(date)
+{var pos=Position.positionedOffset(this.control);pos[1]+=this.getDatePickerOffsetHeight();this._calDiv.style.display="block";this._calDiv.style.top=(pos[1]-1)+"px";this._calDiv.style.left=pos[0]+"px";this.ieHack(false);this.documentClickEvent=this.hideOnClick.bindEvent(this);this.documentKeyDownEvent=this.keyPressed.bindEvent(this);Event.observe(document.body,"click",this.documentClickEvent);var date=this.getDateFromInput();if(date)
{this.selectedDate=date;this.setSelectedDate(date);}
Event.observe(document,"keydown",this.documentKeyDownEvent);this.showing=true;}},getDateFromInput:function()
{if(this.options.InputMode=="TextBox")
diff --git a/framework/Web/UI/WebControls/THtmlArea.php b/framework/Web/UI/WebControls/THtmlArea.php
index 8b214b69..77a774c4 100644
--- a/framework/Web/UI/WebControls/THtmlArea.php
+++ b/framework/Web/UI/WebControls/THtmlArea.php
@@ -219,7 +219,7 @@ class THtmlArea extends TTextBox
*/
protected function addAttributesToRender($writer)
{
- if($this->getEnableVisualEdit())
+ if($this->getEnableVisualEdit() && $this->getEnabled(true))
{
$writer->addAttribute('id',$this->getClientID());
$this->registerEditorClientScript($writer);
diff --git a/framework/prado-cli.php b/framework/prado-cli.php
new file mode 100755
index 00000000..f8ce826c
--- /dev/null
+++ b/framework/prado-cli.php
@@ -0,0 +1,413 @@
+#!/usr/bin/php
+<?php
+
+/**
+ * Prado command line developer tools.
+ */
+
+if(!isset($_SERVER['argv']))
+ die('Must be run from the command line');
+
+//command line options.
+$options['create'] = array('c:', 'create=', '<directory>', 'create a new project <directory>');
+$console = new ConsoleOptions($options, $_SERVER['argv']);
+
+if($console->hasOptions())
+{
+ if($dir = $console->getOption('create'))
+ create_new_prado_project($dir);
+}
+else
+{
+ $details = $console->renderOptions();
+echo <<<EOD
+Usage: php prado-cli.php [-c] <directory>
+Options:
+$details
+Example: php prado-cli.php -c ./example1
+
+
+EOD;
+}
+
+/**
+ * Functions to create new prado project.
+ */
+
+function create_new_prado_project($dir)
+{
+ if(strlen(trim($dir)) == 0)
+ return;
+
+ $rootPath = realpath(dirname(trim($dir)));
+
+ $basePath = $rootPath.'/'.basename($dir);
+ $assetPath = $basePath.'/assets';
+ $protectedPath = $basePath.'/protected';
+ $runtimePath = $basePath.'/protected/runtime';
+ $pagesPath = $protectedPath.'/pages';
+
+ $indexFile = $basePath.'/index.php';
+ $htaccessFile = $protectedPath.'/.htaccess';
+ $defaultPageFile = $pagesPath.'/Home.page';
+
+ create_directory($basePath, 0755);
+ create_directory($assetPath,0777);
+ create_directory($protectedPath,0755);
+ create_directory($runtimePath,0777);
+ create_directory($pagesPath,0755);
+
+ file_put_contents($indexFile, render_index_file());
+ file_put_contents($htaccessFile, render_htaccess_file());
+ file_put_contents($defaultPageFile, render_default_page());
+}
+
+function create_directory($dir, $mask)
+{
+ if(!is_dir($dir))
+ mkdir($dir);
+ if(is_dir($dir))
+ chmod($dir, $mask);
+}
+
+function render_index_file()
+{
+ $framework = realpath(dirname(__FILE__)).'/prado.php';
+return '<?php
+
+$basePath=dirname(__FILE__);
+$frameworkPath="'.$framework.'";
+$assetsPath=$basePath."/assets";
+$runtimePath=$basePath."/protected/runtime";
+
+if(!is_file($frameworkPath))
+ die("Unable to find prado framework path $frameworkPath.");
+if(!is_writable($assetsPath))
+ die("Please make sure that the directory $assetsPath is writable by Web server process.");
+if(!is_writable($runtimePath))
+ die("Please make sure that the directory $runtimePath is writable by Web server process.");
+
+require_once($frameworkPath);
+
+$application=new TApplication;
+$application->run();
+
+?>';
+}
+
+function render_htaccess_file()
+{
+ return 'deny from all';
+}
+
+
+function render_default_page()
+{
+return <<<EOD
+<h1>Welcome to Prado!</h1>
+EOD;
+}
+
+/* vim: set expandtab tabstop=4 shiftwidth=4: */
+// +----------------------------------------------------------------------+
+// | PHP Version 4 |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2003 The PHP Group |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 3.0 of the PHP license, |
+// | that is bundled with this package in the file LICENSE, and is |
+// | available through the world-wide-web at the following url: |
+// | http://www.php.net/license/3_0.txt. |
+// | If you did not receive a copy of the PHP license and are unable to |
+// | obtain it through the world-wide-web, please send a note to |
+// | license@php.net so we can mail you a copy immediately. |
+// +----------------------------------------------------------------------+
+// | Author: Andrei Zmievski <andrei@php.net> |
+// +----------------------------------------------------------------------+
+//
+// $Id: Getopt.php,v 1.21.4.7 2003/12/05 21:57:01 andrei Exp $
+
+/**
+ * Command-line options parsing class.
+ *
+ * @author Andrei Zmievski <andrei@php.net>
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ */
+class ConsoleOptions
+{
+ private $_short_options;
+ private $_long_options;
+ private $_options;
+ private $_args;
+ private $_values;
+
+ /**
+ * @param array list of options with the following format
+ * <tt>option['name'] = array('short', 'long', 'parameter', 'description')</tt>
+ * see @link setOptions} for details on 'short' and 'long' string details.
+ */
+ public function __construct($options, $args)
+ {
+ $short = '';
+ $long = array();
+ foreach($options as $option)
+ {
+ $short .= $option[0];
+ $long[] = $option[1];
+ }
+ $this->setOptions($short,$long);
+ $this->_options = $options;
+ $this->_args = $args;
+ }
+
+ /**
+ * The second parameter is a string of allowed short options. Each of the
+ * option letters can be followed by a colon ':' to specify that the option
+ * requires an argument, or a double colon '::' to specify that the option
+ * takes an optional argument.
+ *
+ * The third argument is an optional array of allowed long options. The
+ * leading '--' should not be included in the option name. Options that
+ * require an argument should be followed by '=', and options that take an
+ * option argument should be followed by '=='.
+ *
+ * @param string $short_options specifies the list of allowed short options
+ * @param array $long_options specifies the list of allowed long options
+ */
+ protected function setOptions($short_options, $long_options=null)
+ {
+ $this->_short_options = $short_options;
+ $this->_long_options = $long_options;
+ }
+
+ /**
+ * @return string list of options and its descriptions
+ */
+ public function renderOptions()
+ {
+ $options = array();
+ $descriptions = array();
+ $max = 0;
+ foreach($this->_options as $option)
+ {
+ $short = str_replace(':','',$option[0]);
+ $long = str_replace('=','',$option[1]);
+ $desc = $option[2];
+ $details = " -{$short}, --{$long} {$desc}";
+ if(($len = strlen($details)) > $max)
+ $max = $len;
+ $options[] = $details;
+ $descriptions[] = $option[3];
+ }
+
+ $content = '';
+ for($i = 0, $k = count($options); $i < $k; $i++)
+ $content .= str_pad($options[$i],$max+3).$descriptions[$i]."\n";
+ return $content;
+ }
+
+ /**
+ * @param string argument name
+ * @return string argument value
+ */
+ public function getOption($name)
+ {
+ if(is_null($this->_values))
+ $this->_values = $this->getNamedOptions();
+ return isset($this->_values[$name]) ? $this->_values[$name] : null;
+ }
+
+ /**
+ * @return array list of all options given.
+ */
+ public function getOptions()
+ {
+ if(is_null($this->_values))
+ $this->_values = $this->getNamedOptions();
+ return $this->_values;
+ }
+
+ /**
+ * @return boolean true if one or more options are given.
+ */
+ public function hasOptions()
+ {
+ if(is_null($this->_values))
+ $this->_values = $this->getNamedOptions();
+ return count($this->_values) > 0;
+ }
+
+ /**
+ * Parse the options from args into named arguements.
+ */
+ protected function getNamedOptions()
+ {
+ $options = array();
+ $values = $this->parseOptions($this->_args);
+ foreach($values[0] as $value)
+ {
+ foreach($this->_options as $name => $option)
+ {
+ if(strpos($option[0],$value[0]) !== false
+ || strpos($option[1], $value[0]) !== false)
+ $options[$name] = $value[1];
+ }
+ }
+ return $options;
+ }
+
+ /**
+ * Gets the command-line options.
+ *
+ * The parameter to this function should be the list of command-line
+ * arguments without the leading reference to the running program.
+ *
+ * The return value is an array of two elements: the list of parsed
+ * options and the list of non-option command-line arguments. Each entry in
+ * the list of parsed options is a pair of elements - the first one
+ * specifies the option, and the second one specifies the option argument,
+ * if there was one.
+ *
+ * Long and short options can be mixed.
+ *
+ * @param array $args an array of command-line arguments
+ * @return array two-element array containing the list of parsed options and
+ * the non-option arguments
+ */
+ public function parseOptions($args)
+ {
+ if (empty($args))
+ return array(array(), array());
+
+ $short_options = $this->_short_options;
+ $long_options = $this->_long_options;
+
+ $opts = array();
+ $non_opts = array();
+
+ settype($args, 'array');
+
+ if ($long_options)
+ sort($long_options);
+
+ if (isset($args[0]{0}) && $args[0]{0} != '-')
+ array_shift($args);
+
+ reset($args);
+
+ while (list($i, $arg) = each($args))
+ {
+
+ /* The special element '--' means explicit end of
+ options. Treat the rest of the arguments as non-options
+ and end the loop. */
+ if ($arg == '--') {
+ $non_opts = array_merge($non_opts, array_slice($args, $i + 1));
+ break;
+ }
+
+ if ($arg{0} != '-' || (strlen($arg) > 1 && $arg{1} == '-' && !$long_options))
+ {
+ $non_opts = array_merge($non_opts, array_slice($args, $i));
+ break;
+ }
+ elseif (strlen($arg) > 1 && $arg{1} == '-')
+ $this->parseLongOption(substr($arg, 2), $long_options, $opts, $args);
+ else
+ $this->parseShortOption(substr($arg, 1), $short_options, $opts, $args);
+ }
+
+ return array($opts, $non_opts);
+ }
+
+ private function parseShortOption($arg, $short_options, &$opts, &$args)
+ {
+ for ($i = 0; $i < strlen($arg); $i++)
+ {
+ $opt = $arg{$i};
+ $opt_arg = null;
+
+ /* Try to find the short option in the specifier string. */
+ if (($spec = strstr($short_options, $opt)) === false || $arg{$i} == ':')
+ throw new Exception("Console_Getopt: unrecognized option -- $opt");
+
+ if (strlen($spec) > 1 && $spec{1} == ':')
+ {
+ if (strlen($spec) > 2 && $spec{2} == ':')
+ {
+ if ($i + 1 < strlen($arg))
+ {
+ /* Option takes an optional argument. Use the remainder of
+ the arg string if there is anything left. */
+ $opts[] = array($opt, substr($arg, $i + 1));
+ break;
+ }
+ }
+ else
+ {
+ /* Option requires an argument. Use the remainder of the arg
+ string if there is anything left. */
+ if ($i + 1 < strlen($arg))
+ {
+ $opts[] = array($opt, substr($arg, $i + 1));
+ break;
+ }
+ else if (list(, $opt_arg) = each($args))
+ /* Else use the next argument. */;
+ else
+ throw new Exception("Console_Getopt: option requires an argument -- $opt");
+ }
+ }
+
+ $opts[] = array($opt, $opt_arg);
+ }
+ }
+
+ private function parseLongOption($arg, $long_options, &$opts, &$args)
+ {
+ @list($opt, $opt_arg) = explode('=', $arg);
+ $opt_len = strlen($opt);
+
+ for ($i = 0; $i < count($long_options); $i++)
+ {
+ $long_opt = $long_options[$i];
+ $opt_start = substr($long_opt, 0, $opt_len);
+
+ /* Option doesn't match. Go on to the next one. */
+ if ($opt_start != $opt)
+ continue;
+
+ $opt_rest = substr($long_opt, $opt_len);
+
+ /* Check that the options uniquely matches one of the allowed
+ options. */
+ if ($opt_rest != '' && $opt{0} != '=' &&
+ $i + 1 < count($long_options) &&
+ $opt == substr($long_options[$i+1], 0, $opt_len))
+ {
+ throw new Exception("Console_Getopt: option --$opt is ambiguous");
+ }
+
+ if (substr($long_opt, -1) == '=')
+ {
+ if (substr($long_opt, -2) != '==')
+ {
+ /* Long option requires an argument.
+ Take the next argument if one wasn't specified. */;
+ if (!strlen($opt_arg) && !(list(, $opt_arg) = each($args)))
+ throw new Exception("Console_Getopt: option --$opt requires an argument");
+ }
+ }
+ else if ($opt_arg)
+ throw new Exception("Console_Getopt: option --$opt doesn't allow an argument");
+
+ $opts[] = array($opt, $opt_arg);
+ return;
+ }
+
+ throw new Exception("Console_Getopt: unrecognized option --$opt");
+ }
+}
+
+
+?> \ No newline at end of file