Source for file Pxxo.php
Documentation is available at Pxxo.php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 fdm=marker encoding=utf8 :
* Pxxo - build self-supported and interoperable Web graphical components
* Copyright (c) 2008, Nicolas Thouvenin
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the author nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* @copyright Copyright (c) 2008 Nicolas Thouvenin
* @license http://opensource.org/licenses/bsd-license.php
define('PXXO_ZEND_PATH', realpath(rtrim(dirname(__FILE__
),DIRECTORY_SEPARATOR).
DIRECTORY_SEPARATOR.
'..'.
DIRECTORY_SEPARATOR.
'ZendFramework'));
$include_path =
ini_get('include_path');
require_once 'Zend/Cache.php';
* Caclul le md5 d'un tableau de chaines
* Elle donne à tous les objets la notion de cache, de trace et de bench.
* @copyright Copyright (c) 2008 Nicolas Thouvenin
* @license http://opensource.org/licenses/bsd-license.php
* Identifiant interne pour gérer le cache
* @var array tableau permettant de calculer un identifiant unique pour chaque action
* Options du cache par défaut
'convertStringType' =>
'strval',
'convertNumericType' =>
'strval',
'convertArrayType' =>
'array_md5',
'misses' =>
'cache.misses',
'entries' =>
'cache.entries',
'mode' =>
'normal', // (normal | refresh | force | ignore)
'backend' =>
'auto', // auto | File | APC
'write_control' =>
false,
'automatic_serialization' =>
false,
'automatic_cleaning_factor' =>
100,
'read_control_type' =>
'strlen',
'hashed_directory_level' =>
2,
'file_name_prefix' =>
'pxxo_cache',
protected $_bench =
array('timer'=>
null, 'profiler'=>
null);
* mode debug actif ou non
* Options pour le mode debug
* Options du cache par défaut
'filter' =>
'cpnt', // Permet d'obtenir une regex prédéfinie : all, cpnt, none
'regex' =>
'', // Expression régulière permettant de filtrer les messages de trace
'show' =>
'tree', // type d'affichage : tree, plain
'output' =>
'html', // type de sortie : html, text, firebug
* désactive le mode debug
* Affichage d'un message de trace de Debug
* @param string un message
for($i =
0; $i <
$l; $i++
) {
if ($l >
0) $p =
$s.
'|_ '.
$p;
if (empty($regex) or is_null($regex)) return;
if ($show ==
'tree') $msg =
$p.
$msg;
echo
str_replace(' ', ' ', '<pre style="display:inline">'.
$msg.
"</pre><br/>\n");
elseif ($output ==
'firebug') {
printf("<script type=\"text/javascript\">\n");
printf("var l = $l;\nvar lll = ll-l;\n if (ll >= l) {\nfor(i=0; i <= lll; i++) {\nconsole.groupEnd();\n}\n}\n");
foreach($msgtab as $item) {
if (preg_match(',(\w+)\((.*)\),', $item, $match)) {
if (!isset
($match[1]) or !isset
($match[2])) continue;
if ($section ==
'mode' and preg_match('/[^:]+:(.*),[^:]+:(.*)/', $match[2], $match)) {
if (isset
($match[1]) and !isset
($match[2])) continue;
foreach($values as $value) {
if ($pos ===
false) continue;
// printf("console.groupEnd();\n");
if ($show ==
'tree') $msg =
$p.
$msg;
* désactive la mise en cache
* true : le cache a été activé
* false : le cache a été désactivé
* null : le cache n' apas été réglé
* @return boolean true / false / null
* Le mode debug est-il actif
* Changer le niveau du cache
* ajout un niveau du cache
* retourne le niveau du cache
* permet de savoir si un niveau de cache est actif
* Choisir un identifiant de cache
* RAZ de l'identifiant de cache
* Création de l'objet de getsion du cache
$this->_cache =
Zend_Cache::factory($frontend, $backend, $frontendOptions, $backendOptions);
if ($backend ==
'File' && isset
($this->_cache_options['backendFile']['cache_dir'])) {
$p =
rtrim($this->_cache_options['backendFile']['cache_dir'], DIRECTORY_SEPARATOR).
DIRECTORY_SEPARATOR;
* Réinitilaise le cache (utile quand on a modifié en cours de route le paramètrage)
* Supprime le cache courant
return $this->_cache->clean();
* Retroune l'identifiant de cache courant
* Au passage on le calcul
* recupere les données stockés dans le cache
* @param string LEVEL niveau de cache
public function getinCache($id, $level =
P_C_USER)
if ($this->_cache->test($id) !==
false) {
return $this->_cache->get($id);