Commit ea6d45d5 by Seldaek

* Added is_writable checks when changing the cache or compile directories

* Finished commenting plugins git-svn-id: svn://dwoo.org/dwoo/trunk@70 0598d79b-80c4-4d41-97ba-ac86fbbd088b
parent 7341faf0
......@@ -603,6 +603,8 @@ class Dwoo
public function setCacheDir($dir)
{
$this->cacheDir = rtrim($dir, '/\\').DIRECTORY_SEPARATOR;
if(is_writable($this->cacheDir) === false)
throw new Dwoo_Exception('The cache directory must be writable, chmod "'.$this->cacheDir.'" to make it writable');
}
/**
......@@ -623,6 +625,8 @@ class Dwoo
public function setCompileDir($dir)
{
$this->compileDir = rtrim($dir, '/\\').DIRECTORY_SEPARATOR;
if(is_writable($this->compileDir) === false)
throw new Dwoo_Exception('The compile directory must be writable, chmod "'.$this->compileDir.'" to make it writable');
}
/**
......@@ -1175,12 +1179,12 @@ class Dwoo
{
return $this->globals;
}
elseif($varstr === '_root' || $varstr === '__')
elseif($varstr === '__' || $varstr === '_root' )
{
return $this->data;
$varstr = substr($varstr, 6);
}
elseif($varstr === '_parent' || $varstr === '_')
elseif($varstr === '_' || $varstr === '_parent')
{
$varstr = '.'.$varstr;
$tree = $this->scopeTree;
......@@ -1255,13 +1259,13 @@ class Dwoo
array_shift($m[1]);
}
}
elseif($i === '_root' || $i === '__')
elseif($i === '__' || $i === '_root')
{
$cur = $this->data;
array_shift($m[2]);
array_shift($m[1]);
}
elseif($i === '_parent' || $i === '_')
elseif($i === '_' || $i === '_parent')
{
$tree = $this->scopeTree;
$cur = $this->data;
......@@ -1271,7 +1275,7 @@ class Dwoo
array_pop($tree);
array_shift($m[2]);
array_shift($m[1]);
if(current($m[2]) === '_parent' || current($m[2]) === '_')
if(current($m[2]) === '_' || current($m[2]) === '_parent')
continue;
while(($i = array_shift($tree)) !== null)
......@@ -1391,7 +1395,7 @@ class Dwoo
while(($bit = array_shift($scope)) !== null)
{
if($bit === '_parent' || $bit === '_')
if($bit === '_' || $bit === '_parent')
{
array_pop($this->scopeTree);
reset($this->scopeTree);
......@@ -1400,7 +1404,7 @@ class Dwoo
for($i=0;$i<$cnt;$i++)
$this->scope =& $this->scope[$this->scopeTree[$i]];
}
elseif($bit === '_root' || $bit === '__')
elseif($bit === '__' || $bit === '_root')
{
$this->scope =& $this->data;
$this->scopeTree = array();
......
......@@ -2,7 +2,9 @@
/**
* Overrides the compiler auto-escape setting within the block
*
* <pre>
* * enabled : if set to "on", "enable", true or 1 then the compiler autoescaping is enabled inside this block. set to "off", "disable", false or 0 to disable it
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......@@ -49,7 +51,7 @@ class Dwoo_Plugin_auto_escape extends Dwoo_Block_Plugin implements Dwoo_ICompila
default:
throw new Dwoo_Compilation_Exception('Auto_Escape : Invalid parameter ('.$params['enabled'].'), valid parameters are "enable"/true or "disable"/false');
}
self::$stack[] = $compiler->getAutoEscape();
$compiler->setAutoEscape($enable);
return '';
......
<?php
/**
* Captures all the output within this block and saves it into {$.capture.default} by default,
* or {$.capture.name} if you provide another name. If the cat parameter is true, the content
* Captures all the output within this block and saves it into {$.capture.default} by default,
* or {$.capture.name} if you provide another name.
* <pre>
* * name : capture name, used to read the value afterwards
* * assign : if set, the value is also saved in the given variable
* * cat : if true, the value is appended to the previous one (if any) instead of overwriting it
* </pre>
* If the cat parameter is true, the content
* will be appended to the existing content
*
*
* Example :
*
*
* <code>
* {capture "foo"}
* Anything in here won't show, it will be saved for later use..
......
......@@ -2,7 +2,13 @@
/**
* Similar to the php for block
*
* <pre>
* * name : foreach name to access it's iterator variables through {$.foreach.name.var} see {@link http://wiki.dwoo.org/index.php/IteratorVariables} for details
* * from : array to iterate from (which equals 0) or a number as a start value
* * to : value to stop iterating at (equals count($array) by default if you set an array in from)
* * step : defines the incrementation of the pointer at each iteration
* * skip : allows you to skip some entries at the start, mostly useless excepted for smarty compatibility
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
......@@ -2,11 +2,16 @@
/**
* Similar to the php foreach block, loops over an array
*
*
* Note that if you don't provide the item parameter, the key will act as item
*
* <pre>
* * from : the array that you want to iterate over
* * key : variable name for the key (or for the item if item is not defined)
* * item : variable name for each item
* * name : foreach name to access it's iterator variables through {$.foreach.name.var} see {@link http://wiki.dwoo.org/index.php/IteratorVariables} for details
* </pre>
* Example :
*
*
* <code>
* {foreach $array val}
* {$val.something}
......
......@@ -2,28 +2,31 @@
/**
* Loops over an array and moves the scope into each value, allowing for shorter loop constructs
*
* Note that to access the array key within a loop block, you have to use the {$_key} variable,
*
* Note that to access the array key within a loop block, you have to use the {$_key} variable,
* you can not specify it yourself.
*
* <pre>
* * from : the array that you want to iterate over
* * name : loop name to access it's iterator variables through {$.loop.name.var} see {@link http://wiki.dwoo.org/index.php/IteratorVariables} for details
* </pre>
* Example :
*
*
* instead of a foreach block such as :
*
*
* <code>
* {foreach $variable value}
* {$value.foo} {$value.bar}
* {/foreach}
* </code>
*
*
* you can do :
*
*
* <code>
* {loop $variable}
* {$foo} {$bar}
* {/loop}
* </code>
*
*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
<?php
/**
* Formats a string to the given format, you can wrap lines at a certain
* Formats a string to the given format, you can wrap lines at a certain
* length and indent them
*
* <pre>
* * wrap : maximum line length
* * wrap_char : the character(s) to use to break the line
* * wrap_cut : if true, the line is cut at the exact length instead of breaking at the nearest space
* * indent : amount of $indent_char to insert before every line
* * indent_char : character(s) to insert before every line
* * indent_first : amount of additional $indent_char to insert before the first line of each paragraphs
* * style : some predefined formatting styles that set up every required variables, can be "email" or "html"
* * assign : if set, the formatted text is assigned to that variable instead of being output
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
......@@ -3,28 +3,30 @@
/**
* Moves the scope down into the provided variable, allowing you to use shorter
* variable names if you repeatedly access values into a single array
*
* The with block won't display anything at all if the provided scope is empty,
*
* The with block won't display anything at all if the provided scope is empty,
* so in effect it acts as {if $var}*content*{/if}
*
* <pre>
* * var : the variable name to move into
* </pre>
* Example :
*
*
* instead of the following :
*
*
* <code>
* {if $long.boring.prefix}
* {$long.boring.prefix.val} - {$long.boring.prefix.secondVal} - {$long.boring.prefix.thirdVal}
* {/if}
* </code>
*
*
* you can use :
*
*
* <code>
* {with $long.boring.prefix}
* {$val} - {$secondVal} - {$thirdVal}
* {/with}
* </code>
*
*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
<?php
/**
* TOCOM
*
* Assigns a value to a variable
* <pre>
* * value : the value that you want to save
* * var : the variable name (without the leading $)
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
<?php
/**
* TOCOM
*
* Capitalizes the first letter of each word
* <pre>
* * value : the string to capitalize
* * numwords : if true, the words containing numbers are capitalized as well
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
<?php
/**
* TOCOM
*
* Concatenates any number of variables or strings fed into it
* <pre>
* * rest : two or more strings that will be merged into one
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
<?php
/**
* TOCOM
*
* Counts the characters in a string
* <pre>
* * value : the string to process
* * count_spaces : if true, the white-space characters are counted as well
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
<?php
/**
* TOCOM
*
* Counts the paragraphs in a string
* <pre>
* * value : the string to process
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
<?php
/**
* TOCOM
*
* Counts the sentences in a string
* <pre>
* * value : the string to process
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
<?php
/**
* TOCOM
*
* Counts the words in a string
* <pre>
* * value : the string to process
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
<?php
/**
* TOCOM
*
* Initiates a counter that is incremented every time you call it
* <pre>
* * name : the counter name, define it if you want to have multiple concurrent counters
* * start : the start value, if it's set, it will reset the counter to this value, defaults to 1
* * skip : the value to add to the counter at each call, defaults to 1
* * direction : "up" (default) or "down" to define whether the counter increments or decrements
* * print : if false, the counter will not output the current count, defaults to true
* * assign : if set, the counter is saved into the given variable and does not output anything, overriding the print parameter
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
......@@ -2,7 +2,7 @@
/**
* Cycles between several values and returns one of them on each call
*
* <pre>
* * name : the cycler name, specify if you need to have multiple concurrent cycles running
* * values : an array of values or a string of values delimited by $delimiter
* * print : if false, the pointer will go to the next one but not print anything
......@@ -10,7 +10,7 @@
* * delimiter : the delimiter used to split values if they are provided as a string
* * assign : if set, the value is saved in that variable instead of being output
* * reset : if true, the pointer is reset to the first value
*
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
......@@ -2,11 +2,11 @@
/**
* Formats a date
*
* <pre>
* * value : the date, as a unix timestamp, mysql datetime or whatever strtotime() can parse
* * format : output format, see {@link http://php.net/strftime} for details
* * default : a default timestamp value, if the first one is empty
*
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
......@@ -2,10 +2,10 @@
/**
* Returns a variable or a default value if it's empty
*
* <pre>
* * value : the variable to check
* * default : fallback value if the first one is empty
*
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
......@@ -2,9 +2,9 @@
/**
* Dumps values of the given variable, or the entire data if nothing provided
*
* <pre>
* * var : the variable to display
*
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
<?php
/**
* Returns the correct end of line character for the current operating system
* Returns the correct end of line character(s) for the current operating system
*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
......
......@@ -2,11 +2,11 @@
/**
* Applies various escaping schemes on the given string
*
* <pre>
* * value : the string to process
* * format : escaping format to use, valid formats are : html, htmlall, url, urlpathinfo, quotes, hex, hexentity, javascript and mail
* * charset : character set to use for the conversion (applies to some formats only), defaults to the current Dwoo charset
*
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
......@@ -2,17 +2,17 @@
/**
* Evaluates the given string as if it was a template
*
* Although this plugin is kind of optimized and will
*
* Although this plugin is kind of optimized and will
* not recompile your string each time, it is still not
* a good practice to use it. If you want to have templates
* stored in a database or something you should probably use
* the Dwoo_Template_String class or make another class that
* extends it
*
* <pre>
* * var : the string to use as a template
* * assign : if set, the output of the template will be saved in this variable instead of being output
*
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
......@@ -2,9 +2,9 @@
/**
* Extends another template, read more about template inheritance at {@link http://wiki.dwoo.org/index.php/TemplateInheritance}
*
* <pre>
* * file : the template to extend
*
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
......@@ -2,10 +2,10 @@
/**
* Reads a file
*
* <pre>
* * file : path or URI of the file to read (however reading from another website is not recommended for performance reasons)
* * assign : if set, the file will be saved in this variable instead of being output
*
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
......@@ -2,7 +2,7 @@
/**
* Inserts another template into the current one
*
* <pre>
* * file : the resource name of the template
* * cache_time : cache length in seconds
* * cache_id : cache identifier for the included template
......@@ -10,7 +10,7 @@
* * data : data to feed into the included template, it can be any array and will default to $_root (the current data)
* * assign : if set, the output of the included template will be saved in this variable instead of being output
* * rest : any additional parameter/value provided will be added to the data array
*
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
......@@ -2,11 +2,11 @@
/**
* Indents every line of a text by the given amount of characters
*
* <pre>
* * value : the string to indent
* * by : how many characters should be inserted before each line
* * char : the character(s) to insert
*
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
......@@ -2,9 +2,9 @@
/**
* Checks whether a variable is not null
*
* <pre>
* * var : variable to check
*
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
......@@ -2,9 +2,9 @@
/**
* Makes the input string lower cased
*
* * value : the string to process
*
* <pre>
* * value : the string to process
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
......@@ -2,9 +2,9 @@
/**
* Outputs a mailto link with optional spam-proof (okay probably not) encoding
*
* <pre>
* * address : target email address
* * text : display text to show for the link, defaults to the address if not provided
* * text : display text to show for the link, defaults to the address if not provided
* * subject : the email subject
* * encode : one of the available encoding (none, js, jscharcode or hex)
* * cc : address(es) to carbon copy, comma separated
......@@ -12,7 +12,7 @@
* * newsgroups : newsgroup(s) to post to, comma separated
* * followupto : address(es) to follow up, comma separated
* * extra : additional attributes to add to the &lt;a&gt; tag
*
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
......@@ -2,18 +2,18 @@
/**
* Computes a mathematical equation
*
* * equation : the equation to compute, it can include normal variables with $foo or special math variables without the dollar sign
* <pre>
* * equation : the equation to compute, it can include normal variables with $foo or special math variables without the dollar sign
* * format : output format, see {@link http://php.net/sprintf} for details
* * assign : if set, the output is assigned into the given variable name instead of being output
* * rest : all math specific variables that you use must be defined, see the example
*
* </pre>
* Example :
*
*
* <code>
* {$c=2}
* {math "(a+b)*$c/4" a=3 b=5}
*
*
* output is : 4 ( = (3+5)*2/4)
* </code>
*
......
......@@ -2,9 +2,9 @@
/**
* Converts line breaks into <br /> tags
*
* * value : the string to process
*
* <pre>
* * value : the string to process
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
......@@ -2,11 +2,11 @@
/**
* Replaces the search string by the replace string using regular expressions
*
* <pre>
* * value : the string to search into
* * search : the string to search for, must be a complete regular expression including delimiters
* * replace : the string to use as a replacement, must be a complete regular expression including delimiters
*
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
......@@ -2,11 +2,11 @@
/**
* Replaces the search string by the replace string
*
* <pre>
* * value : the string to search into
* * search : the string to search for
* * replace : the string to use as a replacement
*
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
<?php
/**
* Reverses a string or an array
*
* Reverses a string or an array
* <pre>
* * value : the string or array to reverse
* * preserve_keys : if value is an array and this is true, then the array keys are left intact
*
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
......@@ -2,9 +2,9 @@
/**
* Marks the variable as safe and removes the auto-escape function, only useful if you turned auto-escaping on
*
* <pre>
* * var : the variable to pass through untouched
*
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
......@@ -2,10 +2,10 @@
/**
* Adds spaces (or the given character(s)) between every character of a string
*
* <pre>
* * value : the string to process
* * space_char : the character(s) to insert between each character
*
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
......@@ -2,10 +2,10 @@
/**
* Formats a string using the sprintf function
*
* <pre>
* * value : the string to format
* * format : the format to use, see {@link http://php.net/sprintf} for details
*
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
......@@ -2,17 +2,17 @@
/**
* Replaces all white-space characters with the given string
*
* <pre>
* * value : the text to process
* * with : the replacement string, note that any number of consecutive white-space characters will be replaced by a single replacement string
*
* </pre>
* Example :
*
*
* <code>
* {"a b c d
*
*
* e"|strip}
*
*
* results in : a b c d e
* </code>
*
......
......@@ -2,10 +2,10 @@
/**
* Removes all html tags
*
* <pre>
* * value : the string to process
* * addspace : if true, a space is added in place of every removed tag
*
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
......@@ -2,13 +2,13 @@
/**
* Truncates a string at the given length
*
* <pre>
* * value : text to truncate
* * length : the maximum length for the string
* * etc : the characters that are added to show that the string was cut off
* * break : if true, the string will be cut off at the exact length, instead of cutting at the nearest space
* * middle : if true, the string will contain the beginning and the end, and the extra characters will be removed from the middle
*
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
......@@ -2,9 +2,9 @@
/**
* Makes a string uppercased
*
* <pre>
* * value : the text to uppercase
*
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
......@@ -2,12 +2,12 @@
/**
* Wraps a text at the given line length
*
* <pre>
* * value : the text to wrap
* * length : maximum line length
* * break : the character(s) to use to break the line
* * cut : if true, the line is cut at the exact length instead of breaking at the nearest space
*
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
......
......@@ -2,9 +2,11 @@
/**
* Builds an array with all the provided variables, use named parameters to make an associative array
*
* <pre>
* * rest : any number of variables, strings or anything that you want to store in the array
* </pre>
* Example :
*
*
* <code>
* {array(a, b, c)} results in array(0=>'a', 1=>'b', 2=>'c')
* {array(a=foo, b=5, c=array(4,5))} results in array('a'=>'foo', 'b'=>5, 'c'=>array(0=>4, 1=>5))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment