summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwei <>2006-07-14 05:27:35 +0000
committerwei <>2006-07-14 05:27:35 +0000
commit26c3775697fc94086269d54099576679137e5eda (patch)
tree349d684c5b1a4db7e09e79f3376cad7ef391a0ee
parent873b2586d6d4ccb8416cd5aac132d992656c1ef5 (diff)
Fixed #284
-rw-r--r--.gitattributes5
-rw-r--r--buildscripts/texbuilder/Page2Tex.php86
-rw-r--r--framework/Web/UI/WebControls/TCustomValidator.php10
-rw-r--r--framework/Web/UI/WebControls/TTextHighlighter.php2
-rw-r--r--tests/FunctionalTests/tickets/protected/pages/Ticket284.page14
-rw-r--r--tests/FunctionalTests/tickets/protected/pages/Ticket284.php11
-rw-r--r--tests/FunctionalTests/tickets/protected/pages/Ticket284Component.php94
-rw-r--r--tests/FunctionalTests/tickets/protected/pages/Ticket284Component.tpl94
-rw-r--r--tests/FunctionalTests/tickets/tests/Ticket284TestCase.php14
-rw-r--r--tests/test_tools/simpletest/test_case.php2
10 files changed, 314 insertions, 18 deletions
diff --git a/.gitattributes b/.gitattributes
index 27b9374e..b64fa5e1 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1627,6 +1627,10 @@ tests/FunctionalTests/tickets/protected/pages/Ticket239.php -text
tests/FunctionalTests/tickets/protected/pages/Ticket27.page -text
tests/FunctionalTests/tickets/protected/pages/Ticket28.page -text
tests/FunctionalTests/tickets/protected/pages/Ticket28.php -text
+tests/FunctionalTests/tickets/protected/pages/Ticket284.page -text
+tests/FunctionalTests/tickets/protected/pages/Ticket284.php -text
+tests/FunctionalTests/tickets/protected/pages/Ticket284Component.php -text
+tests/FunctionalTests/tickets/protected/pages/Ticket284Component.tpl -text
tests/FunctionalTests/tickets/protected/pages/Ticket54.page -text
tests/FunctionalTests/tickets/protected/pages/Ticket54Master.php -text
tests/FunctionalTests/tickets/protected/pages/Ticket54Master.tpl -text
@@ -1644,6 +1648,7 @@ tests/FunctionalTests/tickets/tests/Ticket191TestCase.php -text
tests/FunctionalTests/tickets/tests/Ticket21TestCase.php -text
tests/FunctionalTests/tickets/tests/Ticket239TestCase.php -text
tests/FunctionalTests/tickets/tests/Ticket27TestCase.php -text
+tests/FunctionalTests/tickets/tests/Ticket284TestCase.php -text
tests/FunctionalTests/tickets/tests/Ticket28TestCase.php -text
tests/FunctionalTests/tickets/tests/Ticket54TestCase.php -text
tests/FunctionalTests/tickets/tests/Ticket72TestCase.php -text
diff --git a/buildscripts/texbuilder/Page2Tex.php b/buildscripts/texbuilder/Page2Tex.php
index 94567816..c8cad6c9 100644
--- a/buildscripts/texbuilder/Page2Tex.php
+++ b/buildscripts/texbuilder/Page2Tex.php
@@ -7,8 +7,8 @@ class Page2Tex
private $_base;
private $_dir;
- private $_verb_find = array('\$','\%', '\{', '\}', "\t");
- private $_verb_replace = array('$', '%', '{','}', " ");
+ private $_verb_find = array('\$','\%', '\{', '\}', "\t",'``');
+ private $_verb_replace = array('$', '%', '{','}', " ",'"');
function __construct($base, $dir, $current='')
{
@@ -24,7 +24,7 @@ class Page2Tex
function escape_verbatim($matches)
{
- return "\begin{verbatim}".str_replace($this->_verb_find, $this->_verb_replace, $matches[2])."\end{verbatim}\n";
+ return "\begin{verbatim}".str_replace($this->_verb_find, $this->_verb_replace, $matches[1])."\end{verbatim}\n";
}
function escape_verb($matches)
@@ -123,23 +123,29 @@ class Page2Tex
function parse_html($page,$html)
{
+
+
$html = preg_replace('/<\/?com:TContent[^>]*>/', '', $html);
- $html = preg_replace('/<\/?p[^<]*>/m', '', $html);
+ $html = preg_replace('/<\/?p [^>]*>/', '', $html);
+ $html = preg_replace('/<\/?p>/', '', $html);
+ $html = preg_replace('/(\s+|\(+|\[+)"/', '$1``', $html);
+
//escape { and }
$html = preg_replace('/([^\s]+){([^}]*)}([^\s]+)/', '$1\\\{$2\\\}$3', $html);
- $html = preg_replace_callback('/<img\s+src="?<%~([^"]*)%>"?[^\\/]*\/>/', array($this, 'include_image'), $html);
+ $html = preg_replace_callback('/<img\s+src="?<%~([^"]*)%>"?[^>]*\/>/', array($this, 'include_image'), $html);
//escape %
$html = str_replace('%', '\%', $html);
//codes
$html = str_replace('$', '\$', $html);
- $html = preg_replace('/<com:TTextHighlighter[^>]*>/', '`1`', $html);
- $html = preg_replace('/<\/com:TTextHighlighter>/', '`2`', $html);
- $html = preg_replace_callback('/(`1`)([^`]*)(`2`)/m', array($this,'escape_verbatim'), $html);
- $html = preg_replace_callback('/(<div class="source">)([^<]*)(<\/div>)/', array($this,'escape_verbatim'), $html);
+
+ $html = preg_replace_callback('/<com:TTextHighlighter[^>]*>((.|\n)*?)<\/com:TTextHighlighter>/', array($this,'escape_verbatim'), $html);
+// $html = preg_replace('/<\/com:TTextHighlighter>/', '`2`', $html);
+// $html = preg_replace_callback('/(`1`)([^`]*)(`2`)/m', array($this,'escape_verbatim'), $html);
+ $html = preg_replace_callback('/(<div class="source">)((.|\n)*?)(<\/div>)/', array($this,'escape_verbatim'), $html);
$html = preg_replace_callback('/(<pre>)([^<]*)(<\/pre>)/', array($this,'escape_verbatim'), $html);
//<code>
@@ -154,8 +160,8 @@ class Page2Tex
'\href{http://www.pradosoft.com/docs/manual/$1/$2.html}{$1.$2 API Reference}', $html);
//text modifiers
- $html = preg_replace('/<b>([^<]*)<\/b>/', '\textbf{$1}', $html);
- $html = preg_replace('/<i>([^<]*)<\/i>/', '\emph{$1}', $html);
+ $html = preg_replace('/<b[^>]*>([^<]*)<\/b>/', '\textbf{$1}', $html);
+ $html = preg_replace('/<i[^>]*>([^<]*)<\/i>/', '\emph{$1}', $html);
$html = preg_replace_callback('/<tt>([^<]*)<\/tt>/', array($this,'texttt'), $html);
//links
@@ -171,11 +177,11 @@ class Page2Tex
$html = preg_replace('/<\/dl>/', '\end{description}', $html);
//item lists
- $html = preg_replace('/<ul>/', '\begin{itemize}', $html);
+ $html = preg_replace('/<ul[^>]*>/', '\begin{itemize}', $html);
$html = preg_replace('/<\/ul>/', '\end{itemize}', $html);
- $html = preg_replace('/<ol>/', '\begin{enumerate}', $html);
+ $html = preg_replace('/<ol[^>]*>/', '\begin{enumerate}', $html);
$html = preg_replace('/<\/ol>/', '\end{enumerate}', $html);
- $html = preg_replace('/<li>/', '\item ', $html);
+ $html = preg_replace('/<li[^>]*>/', '\item ', $html);
$html = preg_replace('/<\/li>/', '', $html);
//headings
@@ -183,14 +189,62 @@ class Page2Tex
$html = preg_replace('/<h2(\s+id="[^"]+")?>([^<]+)<\/h2>/', '\subsection{$2}', $html);
$html = preg_replace('/<h3(\s+id="[^"]+")?>([^<]+)<\/h3>/', '\subsubsection{$2}', $html);
-
+ //div box
+ $html = preg_replace_callback('/<div class="[tipnofe]*?">((.|\n)*?)<\/div>/',
+ array($this, 'mbox'), $html);
+
+ //tabular
+ $html = preg_replace_callback('/<!--\s*tabular:([^-]*)-->\s*<table[^>]*>((.|\n)*?)<\/table>/',
+ array($this, 'tabular'), $html);
$html = html_entity_decode($html);
-
return $html;
}
+ function tabular($matches)
+ {
+ $options = array();
+ foreach(explode(',', $matches[1]) as $string)
+ {
+ $sub = explode('=', trim($string));
+ $options[trim($sub[0])] = trim($sub[1]);
+ }
+
+ $widths = explode(' ',preg_replace('/\(|\)/', '', $options['width']));
+ $this->_tabular_widths = $widths;
+
+ $this->_tabular_total = count($widths);
+ $this->_tabular_col = 0;
+
+ $begin = "\begin{table}[!hpt]\centering \n \begin{tabular}{".$options['align']."}\\hline";
+ $end = "\end{tabular} \n \end{table}\n";
+ $table = preg_replace('/<\/tr>/', '\\\\\\\\ \hline', $matches[2]);
+ $table = preg_replace('/<tr>/', '', $table);
+ $table = preg_replace('/<th>([^<]+)<\/th>/', '\textbf{$1} &', $table);
+ $table = preg_replace_callback('/<td>((.|\n)*?)<\/td>/', array($this, 'table_column'), $table);
+ $table = preg_replace('/<br \/>/', ' \\\\\\\\', $table);
+
+ $table = preg_replace('/&\s*\\\\\\\\/', '\\\\\\\\', $table);
+ return $begin.$table.$end;
+ }
+
+ function table_column($matches)
+ {
+ $width = $this->_tabular_widths[$this->_tabular_col];
+ if($this->_tabular_col >= $this->_tabular_total-1)
+ $this->_tabular_col = 0;
+ else
+ $this->_tabular_col++;
+ return '\begin{minipage}{'.$width.'\textwidth}\vspace{3mm}'.
+ $matches[1].'\vspace{3mm}\end{minipage} & ';
+ }
+
+ function mbox($matches)
+ {
+ return "\n\begin{mybox}\n".$matches[1]."\n\end{mybox}\n";
+ }
+
function get_chapter_label($chapter)
{
return '\hypertarget{'.str_replace(' ', '', $chapter).'}{}';
diff --git a/framework/Web/UI/WebControls/TCustomValidator.php b/framework/Web/UI/WebControls/TCustomValidator.php
index 32510f89..2afa48dc 100644
--- a/framework/Web/UI/WebControls/TCustomValidator.php
+++ b/framework/Web/UI/WebControls/TCustomValidator.php
@@ -120,6 +120,16 @@ class TCustomValidator extends TBaseValidator
$options['ClientValidationFunction']=$clientJs;
return $options;
}
+
+ /**
+ * Only register the client-side validator if
+ * {@link setClientValidationFunction ClientValidationFunction} is set.
+ */
+ protected function registerClientScriptValidator()
+ {
+ if($this->getClientValidationFunction()!=='')
+ parent::registerClientScriptValidator();
+ }
}
/**
diff --git a/framework/Web/UI/WebControls/TTextHighlighter.php b/framework/Web/UI/WebControls/TTextHighlighter.php
index a9ccf5bb..f4e72895 100644
--- a/framework/Web/UI/WebControls/TTextHighlighter.php
+++ b/framework/Web/UI/WebControls/TTextHighlighter.php
@@ -136,7 +136,7 @@ class TTextHighlighter extends TTextProcessor
$geshi->enable_classes();
if($this->getEnableCopyCode())
$geshi->set_header_content($this->getHeaderTemplate());
-
+
return $geshi->parse_code();
}
diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket284.page b/tests/FunctionalTests/tickets/protected/pages/Ticket284.page
new file mode 100644
index 00000000..ff25e3fb
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected/pages/Ticket284.page
@@ -0,0 +1,14 @@
+<com:TContent ID="Content">
+
+
+<com:Application.pages.Ticket284Component ID="fooBar" ShowHours="true" ShowMinutes="true" />
+<com:TCustomValidator
+ ControlToValidate="fooBar"
+ OnServerValidate="checkUserAvailability"
+ Display="Dynamic"
+ Text="Unavailable."
+ CssClass="inlineError" />
+<com:TButton Text="POST it!" />
+
+</com:TContent>
+
diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket284.php b/tests/FunctionalTests/tickets/protected/pages/Ticket284.php
new file mode 100644
index 00000000..332789ff
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected/pages/Ticket284.php
@@ -0,0 +1,11 @@
+<?php
+
+class Ticket284 extends TPage
+{
+ function checkUserAvailability()
+ {
+
+ }
+}
+
+?> \ No newline at end of file
diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket284Component.php b/tests/FunctionalTests/tickets/protected/pages/Ticket284Component.php
new file mode 100644
index 00000000..892bdc87
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected/pages/Ticket284Component.php
@@ -0,0 +1,94 @@
+<?php
+
+class Ticket284Component extends TTemplateControl implements IValidatable
+{
+ public function onPreRender($param)
+ {
+ if (!$this->ShowHours && $this->ShowMinutes)
+ {
+ throw new TConfigurationException(
+ 'Invalid OPSDatePicker Config: You cannot specify ShowMinutes="true" while ShowHours="false"'
+ );
+ }
+ }
+
+ public function getDatePicker()
+ {
+ $this->ensureChildControls();
+ return $this->getRegisteredObject('datePicker');
+ }
+
+ public function getHourPicker()
+ {
+ $this->ensureChildControls();
+ return $this->getRegisteredObject('hourPicker');
+ }
+
+ public function getMinutePicker()
+ {
+ $this->ensureChildControls();
+ return $this->getRegisteredObject('minutePicker');
+ }
+
+ public function getShowHours()
+ {
+ return $this->HourPicker->Visible;
+ }
+
+ public function setShowHours($value)
+ {
+ $this->HourPicker->Visible = TPropertyValue::ensureBoolean($value);
+ }
+
+ public function getShowMinutes()
+ {
+ return $this->MinutePicker->Visible;
+ }
+
+ public function setShowMinutes($value)
+ {
+ $this->MinutePicker->Visible = TPropertyValue::ensureBoolean($value);
+ }
+
+ public function getTimeStamp()
+ {
+ return strtotime($this->Date);
+ }
+
+ public function setTimeStamp($value)
+ {
+ $ts = TPropertyValue::ensureInteger($value);
+ $this->DatePicker->TimeStamp = $ts;
+ $this->HourPicker->SelectedValue = date('H', $ts);
+ $this->MinutePicker->SelectedValue = date('i', $ts);
+ }
+
+ public function getDate()
+ {
+ $dateStr = $this->DatePicker->Date;
+ if ($this->ShowHours){
+ $dateStr .= ' '.$this->HourPicker->SelectedValue;
+ }
+ if ($this->ShowMinutes){
+ $dateStr .= ':'.$this->MinutePicker->SelectedValue;
+ }
+ return $dateStr;
+ }
+
+ public function setDate($value)
+ {
+ $dateStr = TPropertyValue::ensureString($value);
+ $this->TimeStamp = strtotime($dateStr);
+ }
+
+ public function getValidationPropertyValue()
+ {
+ if ($this->DatePicker->Date === ''){
+ return '';
+ }
+ else{
+ return $this->TimeStamp;
+ }
+ }
+}
+?> \ No newline at end of file
diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket284Component.tpl b/tests/FunctionalTests/tickets/protected/pages/Ticket284Component.tpl
new file mode 100644
index 00000000..ed787287
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected/pages/Ticket284Component.tpl
@@ -0,0 +1,94 @@
+<com:TDatePicker ID="datePicker"
+ Style.width="68px"
+ Mode="ImageButton"
+ DateFormat="MM/dd/yyyy" />
+
+<com:TDropDownList ID="hourPicker" Style.width="40px" Visible="false">
+ <com:TListItem Text="00" Value="00" />
+ <com:TListItem Text="01" Value="01" />
+ <com:TListItem Text="02" Value="02" />
+ <com:TListItem Text="03" Value="03" />
+ <com:TListItem Text="04" Value="04" />
+ <com:TListItem Text="05" Value="05" />
+ <com:TListItem Text="06" Value="06" />
+ <com:TListItem Text="07" Value="07" />
+ <com:TListItem Text="08" Value="08" />
+ <com:TListItem Text="09" Value="09" />
+ <com:TListItem Text="10" Value="10" />
+ <com:TListItem Text="11" Value="11" />
+ <com:TListItem Text="12" Value="12" />
+ <com:TListItem Text="13" Value="13" />
+ <com:TListItem Text="14" Value="14" />
+ <com:TListItem Text="15" Value="15" />
+ <com:TListItem Text="16" Value="16" />
+ <com:TListItem Text="17" Value="17" />
+ <com:TListItem Text="18" Value="18" />
+ <com:TListItem Text="19" Value="19" />
+ <com:TListItem Text="20" Value="20" />
+ <com:TListItem Text="21" Value="21" />
+ <com:TListItem Text="22" Value="22" />
+ <com:TListItem Text="23" Value="23" />
+</com:TDropDownList>
+
+<com:TDropDownList ID="minutePicker" Style.width="40px" Visible="false">
+ <com:TListItem Text="00" Value="00" />
+ <com:TListItem Text="01" Value="01" />
+ <com:TListItem Text="02" Value="02" />
+ <com:TListItem Text="03" Value="03" />
+ <com:TListItem Text="04" Value="04" />
+ <com:TListItem Text="05" Value="05" />
+ <com:TListItem Text="06" Value="06" />
+ <com:TListItem Text="07" Value="07" />
+ <com:TListItem Text="08" Value="08" />
+ <com:TListItem Text="09" Value="09" />
+ <com:TListItem Text="10" Value="10" />
+ <com:TListItem Text="11" Value="11" />
+ <com:TListItem Text="12" Value="12" />
+ <com:TListItem Text="13" Value="13" />
+ <com:TListItem Text="14" Value="14" />
+ <com:TListItem Text="15" Value="15" />
+ <com:TListItem Text="16" Value="16" />
+ <com:TListItem Text="17" Value="17" />
+ <com:TListItem Text="18" Value="18" />
+ <com:TListItem Text="19" Value="19" />
+ <com:TListItem Text="20" Value="20" />
+ <com:TListItem Text="21" Value="21" />
+ <com:TListItem Text="22" Value="22" />
+ <com:TListItem Text="23" Value="23" />
+ <com:TListItem Text="24" Value="24" />
+ <com:TListItem Text="25" Value="25" />
+ <com:TListItem Text="26" Value="26" />
+ <com:TListItem Text="27" Value="27" />
+ <com:TListItem Text="28" Value="28" />
+ <com:TListItem Text="29" Value="29" />
+ <com:TListItem Text="30" Value="30" />
+ <com:TListItem Text="31" Value="31" />
+ <com:TListItem Text="32" Value="32" />
+ <com:TListItem Text="33" Value="33" />
+ <com:TListItem Text="34" Value="34" />
+ <com:TListItem Text="35" Value="35" />
+ <com:TListItem Text="36" Value="36" />
+ <com:TListItem Text="37" Value="37" />
+ <com:TListItem Text="38" Value="38" />
+ <com:TListItem Text="39" Value="39" />
+ <com:TListItem Text="40" Value="40" />
+ <com:TListItem Text="41" Value="41" />
+ <com:TListItem Text="42" Value="42" />
+ <com:TListItem Text="43" Value="43" />
+ <com:TListItem Text="44" Value="44" />
+ <com:TListItem Text="45" Value="45" />
+ <com:TListItem Text="46" Value="46" />
+ <com:TListItem Text="47" Value="47" />
+ <com:TListItem Text="48" Value="48" />
+ <com:TListItem Text="49" Value="49" />
+ <com:TListItem Text="50" Value="50" />
+ <com:TListItem Text="51" Value="51" />
+ <com:TListItem Text="52" Value="52" />
+ <com:TListItem Text="53" Value="53" />
+ <com:TListItem Text="54" Value="54" />
+ <com:TListItem Text="55" Value="55" />
+ <com:TListItem Text="56" Value="56" />
+ <com:TListItem Text="57" Value="57" />
+ <com:TListItem Text="58" Value="58" />
+ <com:TListItem Text="59" Value="59" />
+</com:TDropDownList> \ No newline at end of file
diff --git a/tests/FunctionalTests/tickets/tests/Ticket284TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket284TestCase.php
new file mode 100644
index 00000000..9a6fa7c3
--- /dev/null
+++ b/tests/FunctionalTests/tickets/tests/Ticket284TestCase.php
@@ -0,0 +1,14 @@
+<?php
+
+class Ticket284TestCase extends SeleniumTestCase
+{
+ function test()
+ {
+ $this->open('tickets/index.php?page=Ticket284');
+ $this->assertTextPresent('Verifying Ticket 284');
+ $this->click('ctl0_Content_ctl1');
+
+ }
+}
+
+?> \ No newline at end of file
diff --git a/tests/test_tools/simpletest/test_case.php b/tests/test_tools/simpletest/test_case.php
index e3a1aff5..1bf49789 100644
--- a/tests/test_tools/simpletest/test_case.php
+++ b/tests/test_tools/simpletest/test_case.php
@@ -478,7 +478,7 @@
*/
function _requireWithError($file) {
$this->_enableErrorReporting();
- include($file);
+ include_once($file);
$error = isset($php_errormsg) ? $php_errormsg : false;
$this->_disableErrorReporting();
$self_inflicted_errors = array(