summaryrefslogtreecommitdiff
path: root/buildscripts
diff options
context:
space:
mode:
authorwei <>2006-09-13 23:33:41 +0000
committerwei <>2006-09-13 23:33:41 +0000
commit9f2905f5e2a6d0ab33e4e2d82162183cfd63a042 (patch)
tree19ac593839f1003ef91d8b4a0d7e8e25fbf460e3 /buildscripts
parent348fb25264f6cc9251f5ae9cb8c7a8a1013e2d67 (diff)
Fixed #376
Diffstat (limited to 'buildscripts')
-rw-r--r--buildscripts/texbuilder/Page2Tex.php107
-rw-r--r--buildscripts/texbuilder/quickstart/build.php229
-rw-r--r--buildscripts/texbuilder/quickstart/pages.php12
-rw-r--r--buildscripts/texbuilder/quickstart/quickstart.tex6
4 files changed, 79 insertions, 275 deletions
diff --git a/buildscripts/texbuilder/Page2Tex.php b/buildscripts/texbuilder/Page2Tex.php
index c8cad6c9..feda4873 100644
--- a/buildscripts/texbuilder/Page2Tex.php
+++ b/buildscripts/texbuilder/Page2Tex.php
@@ -1,6 +1,6 @@
<?php
-class Page2Tex
+class Page2Tex
{
private $_current_page;
private static $header_count = 0;
@@ -16,7 +16,7 @@ class Page2Tex
$this->_current_page = $current;
$this->_dir = $dir;
}
-
+
function setCurrentPage($current)
{
$this->_current_page = $current;
@@ -24,22 +24,24 @@ class Page2Tex
function escape_verbatim($matches)
{
- return "\begin{verbatim}".str_replace($this->_verb_find, $this->_verb_replace, $matches[1])."\end{verbatim}\n";
+ return "\begin{small}\begin{verbatim}".
+ str_replace($this->_verb_find, $this->_verb_replace, $matches[1]).
+ "\end{verbatim}\end{small}\n";
}
-
+
function escape_verb($matches)
{
$text = str_replace($this->_verb_find, $this->_verb_replace, $matches[1]);
- return '\verb<'.$text.'<';
+ return '\begin{small}\verb<'.$text.'< \end{small}';
}
-
+
function include_image($matches)
{
-
+
$current_path = $this->_current_page;
-
+
$image = dirname($current_path).'/'.trim($matches[1]);
-
+
$file = realpath($image);
$info = getimagesize($file);
switch($info[2])
@@ -51,7 +53,7 @@ class Page2Tex
case 3: $im = imagecreatefrompng($file); break;
}
$base = $this->_base;
-
+
if(isset($im))
{
$prefix = strtolower(str_replace(realpath($base), '', $file));
@@ -64,7 +66,7 @@ class Page2Tex
return $this->include_figure($info, $filename);
}
}
-
+
function include_figure($info, $filename)
{
$width = sprintf('%0.2f', $info[0]/(135/2.54));
@@ -76,18 +78,18 @@ class Page2Tex
\end{figure}
';
}
-
+
function anchor($matches)
{
$page = $this->get_current_path();
return '\hypertarget{'.$page.'/'.strtolower($matches[1]).'}{}';
}
-
+
function texttt($matches)
{
return '\texttt{'.str_replace(array('#','_'),array('\#','\_'), $matches[1]).'}';
}
-
+
function get_current_path()
{
$current_path = $this->_current_page;
@@ -95,7 +97,7 @@ class Page2Tex
$page = strtolower(substr(str_replace($base, '', $current_path),1));
return $page;
}
-
+
function make_link($matches)
{
if(is_int(strpos($matches[1], '#')))
@@ -120,62 +122,60 @@ class Page2Tex
}
return '\href{'.$matches[1].'}{'.$matches[2].'}';
}
-
+
function parse_html($page,$html)
{
-
-
$html = preg_replace('/<\/?com:TContent[^>]*>/', '', $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);
//escape %
$html = str_replace('%', '\%', $html);
-
+
//codes
$html = str_replace('$', '\$', $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>
$html = preg_replace_callback('/<code>([^<]*)<\/code>/', array($this,'escape_verb'), $html);
-
+
//runbar
$html = preg_replace('/<com:RunBar\s+PagePath="([^"]*)"\s+\/>/',
'\href{http://www.pradosoft.com/demos/quickstart/index.php?page=$1}{$1 Demo}', $html);
-
+
//DocLink
$html = preg_replace('/<com:DocLink\s+ClassPath="([^"]*)[.]([^.]*)"\s+\/>/',
'\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('/<(b|strong)[^>]*>([^<]*)<\/(b|strong)>/', '\textbf{$2}', $html);
$html = preg_replace('/<i[^>]*>([^<]*)<\/i>/', '\emph{$1}', $html);
$html = preg_replace_callback('/<tt>([^<]*)<\/tt>/', array($this,'texttt'), $html);
-
+
//links
$html = preg_replace_callback('/<a[^>]+href="([^"]*)"[^>]*>([^<]*)<\/a>/',
array($this,'make_link'), $html);
//anchor
$html = preg_replace_callback('/<a[^>]+name="([^"]*)"[^>]*><\/a>/', array($this,'anchor'), $html);
-
+
//description <dl>
$html = preg_replace('/<dt>([^<]*)<\/dt>/', '\item[$1]', $html);
$html = preg_replace('/<\/?dd>/', '', $html);
$html = preg_replace('/<dl>/', '\begin{description}', $html);
$html = preg_replace('/<\/dl>/', '\end{description}', $html);
-
+
//item lists
$html = preg_replace('/<ul[^>]*>/', '\begin{itemize}', $html);
$html = preg_replace('/<\/ul>/', '\end{itemize}', $html);
@@ -183,25 +183,28 @@ class Page2Tex
$html = preg_replace('/<\/ol>/', '\end{enumerate}', $html);
$html = preg_replace('/<li[^>]*>/', '\item ', $html);
$html = preg_replace('/<\/li>/', '', $html);
-
+
//headings
$html = preg_replace('/<h1(\s+id="[^"]+")?>([^<]+)<\/h1>/', '\section{$2}', $html);
$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);
-
+ array($this, 'mbox'), $html);
+
//tabular
$html = preg_replace_callback('/<!--\s*tabular:([^-]*)-->\s*<table[^>]*>((.|\n)*?)<\/table>/',
array($this, 'tabular'), $html);
-
+
+ $html = preg_replace('/<!--(.*)-->/', '', $html);
+
+
$html = html_entity_decode($html);
-
+
return $html;
}
-
+
function tabular($matches)
{
$options = array();
@@ -210,13 +213,13 @@ class Page2Tex
$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]);
@@ -224,11 +227,11 @@ class Page2Tex
$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];
@@ -239,24 +242,24 @@ class Page2Tex
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).'}{}';
}
-
+
function get_section_label($section)
{
$section = str_replace('.page', '', $section);
return '\hypertarget{'.str_replace('/', '.', $section).'}{}';
}
-
-
+
+
function set_header_id($content, $count)
{
self::$header_count = $count*100;
@@ -265,22 +268,22 @@ class Page2Tex
$content = preg_replace_callback('/<h3>/', array($this,"h3"), $content);
return $content;
}
-
+
function h1($matches)
{
return "<h1 id=\"".(++self::$header_count)."\">";
}
-
+
function h2($matches)
{
return "<h2 id=\"".(++self::$header_count)."\">";
}
-
+
function h3($matches)
{
return "<h3 id=\"".(++self::$header_count)."\">";
}
-
+
}
?> \ No newline at end of file
diff --git a/buildscripts/texbuilder/quickstart/build.php b/buildscripts/texbuilder/quickstart/build.php
index 79d6d7ec..b5ee7841 100644
--- a/buildscripts/texbuilder/quickstart/build.php
+++ b/buildscripts/texbuilder/quickstart/build.php
@@ -10,223 +10,11 @@ $mainTexFile = dirname(__FILE__).'/quickstart.tex';
//page root location
$base = realpath(dirname(__FILE__).'/../../../demos/quickstart/protected/pages/');
-//-------------- END CONFIG ------------------
-
$pages = include('pages.php');
-function escape_verbatim($matches)
-{
- return "\begin{verbatim}".str_replace('\$', '$', $matches[2])."\end{verbatim}\n";
-}
-
-function escape_verb($matches)
-{
- $text = str_replace(array('\{', '\}'), array('{','}'), $matches[1]);
- return '\verb<'.$text.'<';
-}
-
-function include_image($matches)
-{
- global $current_path;
-
- $image = dirname($current_path).'/'.trim($matches[1]);
-
- $file = realpath($image);
- $info = getimagesize($file);
- switch($info[2])
- {
- case 1:
- $im = imagecreatefromgif($file);
- break;
- case 2: $im = imagecreatefromjpeg($file); break;
- case 3: $im = imagecreatefrompng($file); break;
- }
- global $base;
-
- if(isset($im))
- {
- $prefix = strtolower(str_replace(realpath($base), '', $file));
- $filename = preg_replace('/\\\|\//', '_', substr($prefix,1));
- $filename = substr($filename, 0, strrpos($filename,'.')).'.png';
- $newfile = dirname(__FILE__).'/'.$filename;
- imagepng($im,$newfile);
- imagedestroy($im);
-
- return include_figure($info, $filename);
- }
-}
-
-function include_figure($info, $filename)
-{
- $width = sprintf('%0.2f', $info[0]/(135/2.54));
- return '
-\begin{figure}[ht]
- \centering
- \includegraphics[width='.$width.'cm]{'.$filename.'}
- \label{fig:'.$filename.'}
-\end{figure}
-';
-}
-
-function anchor($matches)
-{
- $page = get_current_path();
- return '\hypertarget{'.$page.'/'.strtolower($matches[1]).'}{}';
-}
-
-function texttt($matches)
-{
- return '\texttt{'.str_replace(array('#','_'),array('\#','\_'), $matches[1]).'}';
-}
-
-function get_current_path()
-{
- global $current_path, $base;
- $page = strtolower(substr(str_replace($base, '', $current_path),1));
- return $page;
-}
-
-function make_link($matches)
-{
- if(is_int(strpos($matches[1], '#')))
- {
- if(strpos($matches[1],'?') ===false)
- {
- $target = get_current_path().'/'.substr($matches[1],1);
- return '\hyperlink{'.$target.'}{'.$matches[2].'}';
- }
- else
- {
- $page = strtolower(str_replace('?page=', '', $matches[1]));
- $page = str_replace('.','/',$page);
- $page = str_replace('#','.page/',$page);
- return '\hyperlink{'.$page.'}{'.$matches[2].'}';
- }
- }
- else if(is_int(strpos($matches[1],'?')))
- {
- $page = str_replace('?page=','',$matches[1]);
- return '\hyperlink{'.$page.'}{'.$matches[2].'}';
- }
- return '\href{'.$matches[1].'}{'.$matches[2].'}';
-}
-
-function parse_html($page,$html)
-{
- $html = preg_replace('/<\/?com:TContent[^>]*>/', '', $html);
- $html = preg_replace('/<\/?p>/m', '', $html);
-
- //escape { and }
- $html = preg_replace('/([^\s]+){([^}]*)}([^\s]+)/', '$1\\\{$2\\\}$3', $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', 'escape_verbatim', $html);
- $html = preg_replace_callback('/(<div class="source">)([^<]*)(<\/div>)/', 'escape_verbatim', $html);
- $html = preg_replace_callback('/(<pre>)([^<]*)(<\/pre>)/', 'escape_verbatim', $html);
-
- //<code>
- $html = preg_replace_callback('/<code>([^<]*)<\/code>/', 'escape_verb', $html);
-
- $html = preg_replace_callback('/<img\s+src="?<%~([^"]*)%>"?[^\\/]*\/>/', 'include_image', $html);
-
- //runbar
- $html = preg_replace('/<com:RunBar\s+PagePath="([^"]*)"\s+\/>/',
- '\href{http://www.pradosoft.com/demos/quickstart/index.php?page=$1}{$1 Demo}', $html);
-
- //DocLink
- $html = preg_replace('/<com:DocLink\s+ClassPath="([^"]*)[.]([^.]*)"\s+\/>/',
- '\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_callback('/<tt>([^<]*)<\/tt>/', 'texttt', $html);
-
- //links
- $html = preg_replace_callback('/<a[^>]+href="([^"]*)"[^>]*>([^<]*)<\/a>/',
- 'make_link', $html);
- //anchor
- $html = preg_replace_callback('/<a[^>]+name="([^"]*)"[^>]*><\/a>/', 'anchor', $html);
-
- //description <dl>
- $html = preg_replace('/<dt>([^<]*)<\/dt>/', '\item[$1]', $html);
- $html = preg_replace('/<\/?dd>/', '', $html);
- $html = preg_replace('/<dl>/', '\begin{description}', $html);
- $html = preg_replace('/<\/dl>/', '\end{description}', $html);
-
- //item lists
- $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>/', '\end{enumerate}', $html);
- $html = preg_replace('/<li>/', '\item ', $html);
- $html = preg_replace('/<\/li>/', '', $html);
-
- //headings
- $html = preg_replace('/<h1\s+id="[^"]+">([^<]+)<\/h1>/', '\section{$1}', $html);
- $html = preg_replace('/<h2\s+id="[^"]+">([^<]+)<\/h2>/', '\subsection{$1}', $html);
- $html = preg_replace('/<h3\s+id="[^"]+">([^<]+)<\/h3>/', '\subsubsection{$1}', $html);
-
-
-
- $html = html_entity_decode($html);
-
-
- return $html;
-}
-
-function get_chapter_label($chapter)
-{
- return '\hypertarget{'.str_replace(' ', '', $chapter).'}{}';
-}
-
-function get_section_label($section)
-{
- $section = str_replace('.page', '', $section);
- return '\hypertarget{'.str_replace('/', '.', $section).'}{}';
-}
-
-
-function set_header_id($content, $count)
-{
- global $header_count;
- $header_count = $count*100;
- $content = preg_replace_callback('/<h1>/', "h1", $content);
- $content = preg_replace_callback('/<h2>/', "h2", $content);
- $content = preg_replace_callback('/<h3>/', "h3", $content);
- return $content;
-}
-
-function h1($matches)
-{
- global $header_count;
- return "<h1 id=\"".(++$header_count)."\">";
-}
-
-function h2($matches)
-{
- global $header_count;
- return "<h2 id=\"".(++$header_count)."\">";
-}
-
-function h3($matches)
-{
- global $header_count;
- return "<h3 id=\"".(++$header_count)."\">";
-}
-
-$header_count = 0;
-
-//--------------- BEGIN PROCESSING -------------------
-
-
-//--------------- Indexer -------------------
+//-------------- END CONFIG ------------------
-//require_once('create_index.php');
-//$indexer = new quickstart_index($index_dir);
+include(dirname(__FILE__).'.../../../texbuilder/Page2Tex.php');
// ---------------- Create the Tex files ---------
$count = 1;
@@ -234,9 +22,11 @@ $j = 1;
$current_path = '';
echo "Compiling .page files to Latex files\n\n";
+$parser = new Page2Tex($base, dirname(__FILE__));
+
foreach($pages as $chapter => $sections)
{
- $content = '\chapter{'.$chapter.'}'.get_chapter_label($chapter);
+ $content = '\chapter{'.$chapter.'}'.$parser->get_chapter_label($chapter);
echo "Creating ch{$count}.txt => Chapter {$count}: {$chapter}\n";
echo str_repeat('-',60)."\n";
foreach($sections as $section)
@@ -244,15 +34,16 @@ foreach($pages as $chapter => $sections)
echo " Adding $section\n";
$page = $base.'/'.$section;
$current_path = $page;
+ $parser->setCurrentPage($current_path);
//add id to <h1>, <h2>, <3>
- $tmp_content = set_header_id(file_get_contents($page),$j++);
- file_put_contents($page, $tmp_content);
+ $tmp_content = $parser->set_header_id(file_get_contents($page),$j++);
+// file_put_contents($page, $tmp_content);
- $content .= get_section_label($section);
+ $content .= $parser->get_section_label($section);
$file_content = file_get_contents($page);
$tex =
- $content .= parse_html($page,$file_content);
+ $content .= $parser->parse_html($page,$file_content);
}
//var_dump($content);
diff --git a/buildscripts/texbuilder/quickstart/pages.php b/buildscripts/texbuilder/quickstart/pages.php
index 9b8a97ad..c237a179 100644
--- a/buildscripts/texbuilder/quickstart/pages.php
+++ b/buildscripts/texbuilder/quickstart/pages.php
@@ -1,6 +1,6 @@
<?php
/*
- * Created on 11/05/2006
+ * $Id$
*/
//list page into chapters
@@ -74,6 +74,15 @@ $pages['Control Reference : Data Controls'] = array(
'Controls/DataGrid.page',
'Controls/Repeater.page');
+$pages['Control Reference : Active Controls (AJAX)'] = array(
+ 'ActiveControls/ActiveButton.page',
+ 'ActiveControls/ActiveCheckBox.page',
+ 'ActiveControls/ActiveCustomValidator.page');
+
+$pages['Active Control Overview'] = array(
+ 'ActiveControls/Home.page',
+ 'ActiveControls/Introduction.page');
+
$pages['Write New Controls'] = array(
'Controls/NewControl.page');
@@ -96,7 +105,6 @@ $pages['Client-side Scripting'] = array(
'Advanced/Scripts2.page',
'Advanced/Scripts3.page');
-
return $pages;
//-------------- END CONFIG ----------------
diff --git a/buildscripts/texbuilder/quickstart/quickstart.tex b/buildscripts/texbuilder/quickstart/quickstart.tex
index a0553658..264f9c85 100644
--- a/buildscripts/texbuilder/quickstart/quickstart.tex
+++ b/buildscripts/texbuilder/quickstart/quickstart.tex
@@ -42,7 +42,7 @@
%----------------- TITLE --------------
-\title{\Huge \bfseries PRADO v3.0.3 Quickstart Tutorial
+\title{\Huge \bfseries PRADO v3.1 Quickstart Tutorial
\thanks{Copyright 2005-2006. All Rights Reserved.}
}
\author{Qiang Xue and Wei Zhuo}
@@ -68,7 +68,7 @@ Prado quick start doc
\chapter*{License}
\addcontentsline{toc}{chapter}{License}
PRADO is free software released under the terms of the following BSD license.\\
-Copyright 2004-2006, The PRADO Group (http://www.pradosoft.com)\\
+Copyright 2004-2006, The PRADO Group (http://www.pradosoft.com)
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -118,5 +118,7 @@ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\include{ch11}
\include{ch12}
\include{ch13}
+\include{ch14}
+\include{ch15}
\end{document}