New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 1.3.0 #47

Merged
merged 74 commits into from Sep 25, 2016
Commits
Jump to file or symbol
Failed to load files and symbols.
+42 −46
Diff settings

Always

Just for now

Viewing a subset of changes. View all

Update PHPCS code style

  • Loading branch information...
emulienfou committed Sep 16, 2016
commit c6d3bce017f8b097d482ba95dda94e724ad2b418
Copy path View file
@@ -1,36 +1,34 @@
<?php
/**
* base plugin class.
*
* Base plugin class.
* you have to implement the <em>process()</em> method, it will receive the parameters that
* are in the template 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.
*
* @author Jordi Boggiano <j.boggiano@seld.be>
* @author David Sanchez <david38sanchez@gmail.com>
* @copyright 2008-2013 Jordi Boggiano
* @copyright 2013-2016 David Sanchez
* @license http://dwoo.org/LICENSE Modified BSD License
*
* @link http://dwoo.org/
*
* @version 1.2.3
* @date 2016-10-15
* @category Library
* @package Dwoo
* @author Jordi Boggiano <j.boggiano@seld.be>
* @author David Sanchez <david38sanchez@gmail.com>
* @copyright 2008-2013 Jordi Boggiano
* @copyright 2013-2016 David Sanchez
* @license http://dwoo.org/LICENSE Modified BSD License
* @version Release: 1.2.4
* @date 2016-10-16
* @link http://dwoo.org/
*/
abstract class Dwoo_Plugin
{
/**
* the dwoo instance that runs this plugin.
* The dwoo instance that runs this plugin.
*
* @var Dwoo
*/
protected $dwoo;
/**
* constructor, if you override it, call parent::__construct($dwoo); or assign
* Constructor, if you override it, call parent::__construct($dwoo); or assign
* the dwoo instance yourself if you need it.
*
* @param Dwoo_Core $dwoo the dwoo instance that runs this plugin
@@ -51,18 +49,19 @@ public function __construct(Dwoo_Core $dwoo)
// see => http://bugs.php.net/bug.php?id=44043
/**
* utility function that converts an array of compiled parameters (or rest array) to a string of xml/html tag attributes.
*
* this is to be used in preProcessing or postProcessing functions, example :
* Utility function that converts an array of compiled parameters (or rest array) to a string of xml/html tag
* attributes. this is to be used in preProcessing or postProcessing functions, example :
* $p = $compiler->getCompiledParams($params);
* // get only the rest array as attributes
* $attributes = Dwoo_Plugin::paramsToAttributes($p['*']);
* // get all the parameters as attributes (if there is a rest array, it will be included)
* $attributes = Dwoo_Plugin::paramsToAttributes($p);
*
* @param array $params an array of attributeName=>value items that will be compiled to be ready for inclusion in a php string
* @param array $params an array of attributeName=>value items that will be compiled to be ready for
* inclusion in a php string
* @param string $delim the string delimiter you want to use (defaults to ')
* @param Dwoo_Compiler $compiler the compiler instance (optional for BC, but recommended to pass it for proper escaping behavior)
* @param Dwoo_Compiler $compiler the compiler instance (optional for BC, but recommended to pass it for proper
* escaping behavior)
*
* @return string
*/
@@ -75,26 +74,24 @@ public static function paramsToAttributes(array $params, $delim = '\'', Dwoo_Com
$out = '';
foreach ($params as $attr => $val) {
$out .= ' '.$attr.'=';
$out .= ' ' . $attr . '=';
if (trim($val, '"\'') == '' || $val == 'null') {
$out .= str_replace($delim, '\\'.$delim, '""');
} elseif (substr($val, 0, 1) === $delim && substr($val, -1) === $delim) {
$out .= str_replace($delim, '\\'.$delim, '"'.substr($val, 1, -1).'"');
$out .= str_replace($delim, '\\' . $delim, '""');
} elseif (substr($val, 0, 1) === $delim && substr($val, - 1) === $delim) {
$out .= str_replace($delim, '\\' . $delim, '"' . substr($val, 1, - 1) . '"');
} else {
if (!$compiler) {
// disable double encoding since it can not be determined if it was encoded
$escapedVal = '.(is_string($tmp2='.$val.') ? htmlspecialchars($tmp2, ENT_QUOTES, $this->charset, false) : $tmp2).';
$escapedVal = '.(is_string($tmp2=' . $val . ') ? htmlspecialchars($tmp2, ENT_QUOTES, $this->charset, false) : $tmp2).';
} elseif (!$compiler->getAutoEscape() || false === strpos($val, 'isset($this->scope')) {
// escape if auto escaping is disabled, or there was no variable in the string
$escapedVal = '.(is_string($tmp2='.$val.') ? htmlspecialchars($tmp2, ENT_QUOTES, $this->charset) : $tmp2).';
$escapedVal = '.(is_string($tmp2=' . $val . ') ? htmlspecialchars($tmp2, ENT_QUOTES, $this->charset) : $tmp2).';
} else {
// print as is
$escapedVal = '.'.$val.'.';
$escapedVal = '.' . $val . '.';
}
$out .= str_replace($delim, '\\'.$delim, '"').
$delim.$escapedVal.$delim.
str_replace($delim, '\\'.$delim, '"');
$out .= str_replace($delim, '\\' . $delim, '"') . $delim . $escapedVal . $delim . str_replace($delim, '\\' . $delim, '"');
}
}
Copy path View file
@@ -1,44 +1,43 @@
<?php
/**
* base class for processors.
*
* Base class for processors.
* 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.
*
* @author Jordi Boggiano <j.boggiano@seld.be>
* @author David Sanchez <david38sanchez@gmail.com>
* @copyright 2008-2013 Jordi Boggiano
* @copyright 2013-2016 David Sanchez
* @license http://dwoo.org/LICENSE Modified BSD License
*
* @link http://dwoo.org/
*
* @version 1.2.3
* @date 2016-10-15
* @category Library
* @package Dwoo
* @author Jordi Boggiano <j.boggiano@seld.be>
* @author David Sanchez <david38sanchez@gmail.com>
* @copyright 2008-2013 Jordi Boggiano
* @copyright 2013-2016 David Sanchez
* @license http://dwoo.org/LICENSE Modified BSD License
* @version Release: 1.2.4
* @date 2016-10-16
* @link http://dwoo.org/
*/
abstract class Dwoo_Processor
{
/**
* the compiler instance that runs this processor.
* The compiler instance that runs this processor.
*
* @var Dwoo
*/
protected $compiler;
/**
* constructor, if you override it, call parent::__construct($dwoo); or assign
* Constructor, if you override it, call parent::__construct($dwoo); or assign
* the dwoo instance yourself if you need it.
*
* @param Dwoo_Compiler $compiler
* @param Dwoo_Compiler $compiler the compiler class
*/
public function __construct(Dwoo_Compiler $compiler)
{
$this->compiler = $compiler;
}
/**
* processes the input and returns it filtered.
* Processes the input and returns it filtered.
*
* @param string $input the template to process
*
ProTip! Use n and p to navigate between commits in a pull request.