Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Commits on Source (4)
Showing
with 327 additions and 1448 deletions
- ticket #115072 : [Magasin de thèmes] Ajout du flux RSS pour l'agenda
\ No newline at end of file
- ticket #116591 : Magasin Thème : amélioration de la maintenance des profils grâce à un système d'exportation et d'importation des données en JSON.
\ No newline at end of file
......@@ -550,6 +550,14 @@ class Admin_ProfilController extends ZendAfi_Controller_Action {
}
public function exportAction() {
$this->getHelper('ViewRenderer')->setNoRender();
$this->_response->setHeader('Content-Type', 'application/json');
$export = new Class_Profil_Export($this->_profil);
$this->_response->setBody($export->toString());
}
private function _splitArg($item) {
if (false === strpos($item, '='))
return false;
......
<?php
/**
* Copyright (c) 2012-2020, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_Profil_Export {
use Trait_StormFileSystem;
protected
$_profile,
$_path_temp;
public function __construct($profile) {
$this->_profile = $profile;
$this->_path_temp = PATH_TEMP . sprintf('profiles/%d.json', $profile->getId());
}
public function export() {
$this->getFileSystem()->filePutContents($this->_path_temp, $this->toString());
return $this;
}
public function toString() {
$raw_attributes = $this->_profile->getRawAttributes();
$raw_attributes['cfg_accueil'] = $this->_cleanData($this->_profile->getCfgAccueilAsArray());
$raw_attributes['cfg_menus'] = $this->_cleanMenus($this->_cleanData($this->_profile->getCfgMenusAsArray()));
$raw_attributes['cfg_modules'] = $this->_cleanData($this->_profile->getCfgModulesAsArray());
return json_encode($raw_attributes, JSON_PRETTY_PRINT);
}
protected function _cleanData($data) {
$data = array_filter($data,
function($value)
{
return '' !== $value && '0' !== $value;
});
foreach ($data as $key => $value) {
$data[$key] = is_array($value)
? $this->_cleanData($value)
: $value;
}
return $data;
}
protected function _cleanMenus($menus) {
foreach($menus as $k => $menu)
$menus[$k] = (new Class_Systeme_Widget_Menu_Datas())->clean($menu);
return $menus;
}
}
<?php
/**
* Copyright (c) 2012-2020, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_Profil_Import {
use Trait_StormFileSystem;
protected
$_profile,
$_path_temp;
public function __construct($profile) {
$this->_profile = $profile;
}
public function import($path) {
if (!$attributes = json_decode($this->getFileSystem()->fileGetContents($path), true))
return $this;
$attributes = $this->_transformProfileId($attributes);
unset($attributes['id']);
unset($attributes['id_profil']);
unset($attributes['parent_id']);
unset($attributes['id_site']);
unset($attributes['mail_site']);
$this->_profile->updateAttributes($attributes);
return $this;
}
protected function _transformProfileId($attributes) {
if ((!$source = $attributes['id'])
|| (!$destination = $this->_profile->getId())
|| !isset($attributes['cfg_accueil']['modules']))
return $attributes;
foreach($attributes['cfg_accueil']['modules'] as $k => $widget)
$attributes['cfg_accueil']['modules'][$k] = $this->_transformWidgetProfileId($widget,
$source,
$destination);
return $attributes;
}
protected function _transformWidgetProfileId($widget, $source, $destination) {
if (isset($widget['profile_id']))
$widget['profile_id'] = $destination;
if (isset($widget['preferences']['profile_id']))
$widget['preferences']['profile_id'] = $destination;
if (isset($widget['type_module'])
&& 'MENU' == $widget['type_module']
&& isset($widget['preferences']['menu']))
$widget['preferences']['menu'] = str_replace($source . '-',
$destination . '-',
$widget['preferences']['menu']);
return $widget;
}
}
......@@ -40,8 +40,13 @@ class Class_Systeme_ModulesMenu extends Class_Systeme_ModulesAbstract {
public static function isModuleAccueil($menu) {
$type_menu = is_array($menu) ? $menu['type_menu'] : $menu;
return (false !== strpos($type_menu, self::MODULE_ACCUEIL_PREFIX));
if (!is_array($menu))
return (false !== strpos($menu, self::MODULE_ACCUEIL_PREFIX));
if (!isset($menu['type_menu']))
return false;
return static::isModuleAccueil($menu['type_menu']);
}
......
......@@ -94,65 +94,6 @@ class Class_Systeme_Report_Headers extends Class_Systeme_Report_Abstract {
class Class_Systeme_Report_Portal extends Class_Systeme_Report_Abstract {
use Trait_SimpleWebClient;
const EXTERNAL_IP_URL = 'http://myexternalip.com/raw';
public function acceptVisitor($visitor) {
$visitor->visitData('url', $this->_('URL principale'), Class_Url::absolute('', null, true));
$visitor->visitData('ip', $this->_('IP publique'),
$this->getWebClient()->open_url(static::EXTERNAL_IP_URL));
$visitor->visitData('label', $this->_('Libellé principal'), Class_Profil::getPortail()->getLibelle());
$visitor->visitDataArray('skins', $this->_('Thèmes utilisés'), $this->_profilSkins());
$visitor->visitDataArray('boxes', $this->_('Boites utilisées'), $this->_profilBoxes());
$visitor->visitDataArray('tags', $this->_('Tags'), $this->_fetchTags());
}
protected function _profilSkins() {
return
array_values(
array_unique((new Storm_Model_Collection(Class_Profil::findTopProfils()))
->collect('skin')
->getArrayCopy()));
}
protected function _profilBoxes() {
$list = [];
foreach (Class_Profil::getAllModules() as $modules)
$list = $this->_boxTypeFrom($modules, $list);
return array_values(array_filter($list));
}
protected function _boxTypeFrom($modules, $list) {
foreach ($modules as $module)
if (isset($module['type_module']))
$list[$module['type_module']] = $module['type_module'];
return $list;
}
protected function _fetchTags() {
$tags = (string)Class_AdminVar::get('STATUS_REPORT_TAGS');
if (defined('STATUS_REPORT_TAGS'))
$tags = (string)constant('STATUS_REPORT_TAGS') . ',' . $tags;
return
array_values(
array_filter(
array_map('trim',
preg_split(
'/[|;,"\']+/', $tags))));
}
}
class Class_Systeme_Report_Records extends Class_Systeme_Report_Abstract {
public function acceptVisitor($visitor) {
$visitor->visitCounter('all', $this->_('Tous'), Class_Notice::count());
......
<?php
/**
* Copyright (c) 2012-2020, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_Systeme_Report_Portal extends Class_Systeme_Report_Abstract {
use Trait_SimpleWebClient;
const EXTERNAL_IP_URL = 'http://myexternalip.com/raw';
public function acceptVisitor($visitor) {
$visitor->visitData('url', $this->_('URL principale'), Class_Url::absolute('', null, true));
$visitor->visitData('ip', $this->_('IP publique'),
$this->getWebClient()->open_url(static::EXTERNAL_IP_URL));
$visitor->visitData('label', $this->_('Libellé principal'), Class_Profil::getPortail()->getLibelle());
$visitor->visitDataArray('skins', $this->_('Thèmes utilisés'), $this->_profilSkins());
$visitor->visitDataArray('boxes', $this->_('Boites utilisées'), $this->_profilBoxes());
$visitor->visitDataArray('tags', $this->_('Tags'), $this->_fetchTags());
}
protected function _profilSkins() {
return
array_values(
array_unique((new Storm_Model_Collection(Class_Profil::findTopProfils()))
->collect('skin')
->getArrayCopy()));
}
protected function _profilBoxes() {
$list = [];
foreach (Class_Profil::getAllModules() as $modules)
$list = $this->_boxTypeFrom($modules, $list);
return array_values(array_filter($list));
}
protected function _boxTypeFrom($modules, $list) {
foreach ($modules as $module)
if (isset($module['type_module']))
$list[$module['type_module']] = $module['type_module'];
return $list;
}
protected function _fetchTags() {
$tags = (string)Class_AdminVar::get('STATUS_REPORT_TAGS');
if (defined('STATUS_REPORT_TAGS'))
$tags = (string)constant('STATUS_REPORT_TAGS') . ',' . $tags;
return
array_values(
array_filter(
array_map('trim',
preg_split(
'/[|;,"\']+/', $tags))));
}
}
......@@ -179,7 +179,12 @@ abstract class Class_Systeme_Widget_Abstract extends Class_Entity {
$datas = [];
foreach($children as $index => $child) {
$item = $this->_getResourcesDefinition(isset($child['type_menu']) ? $child['type_menu'] : $child['type_module']);
if (!isset($child['type_menu']) && !isset($child['type_module']))
continue;
$item = $this->_getResourcesDefinition(isset($child['type_menu'])
? $child['type_menu']
: $child['type_module']);
$datas[] = (new Class_Entity())
->setId($child['id_module'])
......
......@@ -102,16 +102,11 @@ class Class_Systeme_Widget_Menu extends Class_Systeme_Widget_Abstract {
}
protected function _update() {
$datas = array_merge($this->getLocalSettings(),
$this->getNewDatas());
if(isset($datas['preferences']))
unset($datas['preferences']);
$datas['preferences'] = $datas;
unset($datas['preferences']['menus']);
unset($datas['preferences']['sous_menus']);
protected function _update() {
$datas = (new Class_Systeme_Widget_Menu_Datas)->clean(array_merge($this->getLocalSettings(),
$this->getNewDatas()));
$sub_menus = null;
if(isset($datas['children']))
......
<?php
/**
* Copyright (c) 2012-2020, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_Systeme_Widget_Menu_Datas {
public function clean($datas) {
$root_properties = ['libelle' => '',
'picto' => '',
'action' => '',
'menus' => '',
'sous_menus' => '',
'children' => '',
'preferences' => '',
'type_menu' => '',
'id_module' => '',
'type_module' => ''];
$cleaned_datas = array_intersect_key($datas, $root_properties);
if ($cleaned_preferences = array_diff_key($datas, $root_properties))
$cleaned_datas['preferences'] = $cleaned_preferences;
if (!Class_Systeme_ModulesMenu::isModuleAccueil($cleaned_datas)) {
unset($cleaned_datas['id_module']);
unset($cleaned_datas['type_module']);
}
$cleaned_datas = $this->_cleanSubLevel('menus', $cleaned_datas);
$cleaned_datas = $this->_cleanSubLevel('sous_menus', $cleaned_datas);
return $cleaned_datas;
}
protected function _cleanSubLevel($level, $datas) {
if (!isset($datas[$level]))
return $datas;
$submemus = $datas[$level];
$datas[$level] = [];
foreach($submemus as $id_menu => $submenu)
$datas[$level][$id_menu] = $this->clean($submenu);
return $datas;
}
}
# ZFDebug - a debug bar for Zend Framework
ZFDebug is a plugin for the Zend Framework for PHP5, providing useful debug information displayed in a small bar at the bottom of every page.
Time spent, memory usage and number of database queries are presented at a glance. Additionally, included files, a listing of available view variables and the complete SQL command of all queries are shown in separate panels:
![](http://jokke.dk/media/2011-zfdebug.png)
The available plugins at this point are:
* Cache: Information on Zend_Cache and APC.
* Database: Full listing of SQL queries from Zend_Db and the time for each.
* Exception: Error handling of errors and exceptions.
* File: Number and size of files included with complete list.
* Html: Number of external stylesheets and javascripts. Link to validate with W3C.
for custom memory measurements.
* Log: Timing information of current request, time spent in action controller and custom timers. Also average, min and max time for requests.
* Variables: View variables, request info and contents of `$_COOKIE`, `$_POST` and `$_SESSION`
Installation & Usage
------------
To install, place the folder 'ZFDebug' in your library path, next to the Zend
folder. Then add the following method to your bootstrap class (in ZF1.8+):
protected function _initZFDebug()
{
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('ZFDebug');
$options = array(
'plugins' => array('Variables',
'Database' => array('adapter' => $db),
'File' => array('basePath' => '/path/to/project'),
'Cache' => array('backend' => $cache->getBackend()),
'Exception')
);
$debug = new ZFDebug_Controller_Plugin_Debug($options);
$this->bootstrap('frontController');
$frontController = $this->getResource('frontController');
$frontController->registerPlugin($debug);
}
Further documentation will follow as the github move progresses.
\ No newline at end of file
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initZFDebug()
{
// Setup autoloader with namespace
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('ZFDebug');
// Ensure the front controller is initialized
$this->bootstrap('FrontController');
// Retrieve the front controller from the bootstrap registry
$front = $this->getResource('FrontController');
// Only enable zfdebug if options have been specified for it
if ($this->hasOption('zfdebug'))
{
// Create ZFDebug instance
$zfdebug = new ZFDebug_Controller_Plugin_Debug($this->getOption('zfdebug'));
// Register ZFDebug with the front controller
$front->registerPlugin($zfdebug);
}
// In application.ini do the following:
//
// [development : production]
// zfdebug.plugins.Variables = null
// zfdebug.plugins.Time = null
// zfdebug.plugins.Memory = null
// ...
// Plugins that take objects as parameters like Database and Cache
// need to be registered manually:
// $zfdebug->registerPlugin(new ZFDebug_Controller_Plugin_Debug_Plugin_Database($db));
// Alternative configuration without application.ini
// $options = array(
// 'plugins' => array('variables', 'database',
// 'file' => array('basePath' => '/Library/WebServer/Documents/budget', 'myLibrary' => 'Scienta'),
// 'memory', 'time', 'registry',
// //'auth',
// //'cache' => array('backend' => $cache->getBackend()),
// 'exception')
// );
// $zfdebug = new ZFDebug_Controller_Plugin_Debug($options);
// Register ZFDebug with the front controller
// $front->registerPlugin($zfdebug);
}
}
<?php
/**
* Defining bootstrap for Zend Framework pre-1.8
*/
// Leave 'Database' options empty to rely on Zend_Db_Table default adapter
$options = array(
// 'jquery_path' => 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js',
'plugins' => array('Variables',
'Constants',
'Html',
'Database' => array('adapter' => array('standard' => $db)),
'File' => array('basePath' => 'path/to/application/root'),
'Memory',
'Time',
'Registry',
'Cache' => array('backend' => $cache->getBackend()),
'Exception')
);
$debug = new ZFDebug_Controller_Plugin_Debug($options);
$frontController->registerPlugin($debug);
// Alternative registration of plugins, also possible elsewhere in dispatch process
// $zfdebug = Zend_Controller_Front::getInstance()->getPlugin('ZFDebug_Controller_Plugin_Debug');
// $zfdebug->registerPlugin(new ZFDebug_Controller_Plugin_Debug_Plugin_Database($optionsArray));
/**
* Registering other plugins and start dispatch
*/
<?php
/**
* ZFDebug Zend Additions
*
* @category ZFDebug
* @package ZFDebug_Controller
* @subpackage Plugins
* @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug)
* @license http://code.google.com/p/zfdebug/wiki/License New BSD License
* @version $Id: $
*/
/**
* @category ZFDebug
* @package ZFDebug_Controller
* @subpackage Plugins
* @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug)
* @license http://code.google.com/p/zfdebug/wiki/License New BSD License
*/
class ZFDebug_Controller_Plugin_Debug_Plugin
{
protected $_closingBracket = null;
public function getLinebreak()
{
return '<br'.$this->getClosingBracket();
}
public function getIconData()
{
return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHhSURBVDjLpZI9SJVxFMZ/r2YFflw/kcQsiJt5b1ije0tDtbQ3GtFQYwVNFbQ1ujRFa1MUJKQ4VhYqd7K4gopK3UIly+57nnMaXjHjqotnOfDnnOd/nt85SURwkDi02+ODqbsldxUlD0mvHw09ubSXQF1t8512nGJ/Uz/5lnxi0tB+E9QI3D//+EfVqhtppGxUNzCzmf0Ekojg4fS9cBeSoyzHQNuZxNyYXp5ZM5Mk1ZkZT688b6thIBenG/N4OB5B4InciYBCVyGnEBHO+/LH3SFKQuF4OEs/51ndXMXC8Ajqknrcg1O5PGa2h4CJUqVES0OO7sYevv2qoFBmJ/4gF4boaOrg6rPLYWaYiVfDo0my8w5uj12PQleB0vcp5I6HsHAUoqUhR29zH+5B4IxNTvDmxljy3x2YCYUwZVlbzXJh9UKeQY6t2m0Lt94Oh5loPdqK3EkjzZi4MM/Y9Db3MTv/mYWVxaqkw9IOATNR7B5ABHPrZQrtg9sb8XDKa1+QOwsri4zeHD9SAzE1wxBTXz9xtvMc5ZU5lirLSKIz18nJnhOZjb22YKkhd4odg5icpcoyL669TAAujlyIvmPHSWXY1ti1AmZ8mJ3ElP1ips1/YM3H300g+W+51nc95YPEX8fEbdA2ReVYAAAAAElFTkSuQmCC';
}
public function getClosingBracket()
{
if (!$this->_closingBracket) {
if ($this->_isXhtml()) {
$this->_closingBracket = ' />';
} else {
$this->_closingBracket = '>';
}
}
return $this->_closingBracket;
}
protected function _isXhtml()
{
$view = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view;
$doctype = $view->doctype();
return $doctype->isXhtml();
}
/**
* Transforms data into readable format
*
* @param array $values
* @return string
*/
protected function _cleanData($values)
{
$linebreak = $this->getLinebreak();
if (is_array($values)) {
ksort($values);
}
$retVal = '<div class="pre">';
foreach ($values as $key => $value)
{
$key = htmlspecialchars($key);
if (is_numeric($value)) {
$retVal .= $key.' => '.$value.$linebreak;
}
else if (is_string($value)) {
$retVal .= $key.' => \''.htmlspecialchars($value).'\''.$linebreak;
}
else if (is_array($value))
{
$retVal .= $key.' => '.self::_cleanData($value);
}
else if (is_object($value))
{
$retVal .= $key.' => '.get_class($value).' Object()'.$linebreak;
}
else if (is_null($value))
{
$retVal .= $key.' => NULL'.$linebreak;
}
}
return $retVal.'</div>';
}
}
\ No newline at end of file
<?php
/**
* ZFDebug Zend Additions
*
* @category ZFDebug
* @package ZFDebug_Controller
* @subpackage Plugins
* @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug)
* @license http://code.google.com/p/zfdebug/wiki/License New BSD License
* @version $Id: $
*/
/**
* @category ZFDebug
* @package ZFDebug_Controller
* @subpackage Plugins
* @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug)
* @license http://code.google.com/p/zfdebug/wiki/License New BSD License
*/
class ZFDebug_Controller_Plugin_Debug_Plugin_Auth implements ZFDebug_Controller_Plugin_Debug_Plugin_Interface
{
/**
* Contains plugin identifier name
*
* @var string
*/
protected $_identifier = 'auth';
/**
* Contains Zend_Auth object
*
* @var Zend_Auth
*/
protected $_auth;
/**
* Contains "column name" for the username
*
* @var string
*/
protected $_user = 'user';
/**
* Contains "column name" for the role
*
* @var string
*/
protected $_role = 'role';
/**
* Contains Acls for this application
*
* @var Zend_Acl
*/
protected $_acl;
/**
* Create ZFDebug_Controller_Plugin_Debug_Plugin_Auth
*
* @var string $user
* @var string $role
* @return void
*/
public function __construct(array $options = array())
{
$this->_auth = Zend_Auth::getInstance();
if (isset($options['user'])) {
$this->_user = $options['user'];
}
if (isset($options['role'])) {
$this->_role = $options['role'];
}
}
/**
* Gets identifier for this plugin
*
* @return string
*/
public function getIdentifier()
{
return $this->_identifier;
}
/**
* Returns the base64 encoded icon
*
* @return string
**/
public function getIconData()
{
return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAJ3SURBVDjLpZNtSNNRFIcNKunF1rZWBMJqKaSiX9RP1dClsjldA42slW0q5oxZiuHrlqllLayoaJa2jbm1Lc3QUZpKFmmaTMsaRp+kMgjBheSmTL2//kqMBJlFHx44XM7vOfdyuH4A/P6HFQ9zo7cpa/mM6RvCrVDzaVDy6C5JJKv6rwSnIhlFd0R0Up/GwF2KWyl01CTSkM/dQoQRzAurCjRCGnRUUE2FaoSL0HExiYVzsQwcj6RNrSqo4W5Gh6Yc4+1qDDTkIy+GhYK4nTgdz0H2PrrHUJzs71NQn86enPn+CVN9GnzruoYR63mMPbkC59gQzDl7pt7rc9f7FNyUhPY6Bx9gwt4E9zszhWWpdg6ZcS8j3O7zCTuEpnXB+3MNZkUUZu0NmHE8XsL91oSWwiiEc3MeseLrN6woYCWa/Zl8ozyQ3w3Hl2lYy0SwlCUvsVi/Gv2JwITnYPDun2Hy6jYuEzAF1jUBCVYpO6kXo+NuGMeBAgcgfwNkvgBOPgUqXgKvP7rBFvRhE1crp8Vq1noFYSlacVyqGk0D86gbART9BDk9BFnPCNJbCY5aCFL1Cyhtp0RWAp74MsKSrkq9guHyvfMTtmLc1togpZoyqYmyNoITzVTYRJCiXYBIQ3CwFqi83o3JDhX6C0M8XsGIMoQ4OyuRlq1DdZcLkmbgGDX1iIEKNxAcbgTEOqC4ZRaJ6Ub86K7CYFEo8Qo+GBQlQyXBczLZpbloaQ9k1NUz/kD2myBBKxRZpa5hVcQslalatoUxizxAVVrN3CW21bFj9F858Q9dnIRmDyeuybM71uxmH9BNBB1q6zybV7H9s1Ue4PM3/gu/AEbfqfWy2twsAAAAAElFTkSuQmCC';
}
/**
* Gets menu tab for the Debugbar
*
* @return string
*/
public function getTab()
{
$username = 'Not Authed';
$role = 'Unknown Role';
if (!$this->_auth->hasIdentity()) {
return 'Not authorized';
}
$identity = $this->_auth->getIdentity();
if (is_object($identity)) {
$username = $this->_auth->getIdentity()->{$this->_user};
$role = $this->_auth->getIdentity()->{$this->_role};
} else {
$username = $this->_auth->getIdentity();
$role = '';
}
return $username . ' (' . $role . ')';
}
/**
* Gets content panel for the Debugbar
*
* @return string
*/
public function getPanel()
{
return '';
}
}
\ No newline at end of file
<?php
/**
* ZFDebug Zend Additions
*
* @category ZFDebug
* @package ZFDebug_Controller
* @subpackage Plugins
* @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug)
* @license http://code.google.com/p/zfdebug/wiki/License New BSD License
* @version $Id$
*/
/**
* @category ZFDebug
* @package ZFDebug_Controller
* @subpackage Plugins
* @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug)
* @license http://code.google.com/p/zfdebug/wiki/License New BSD License
*/
class ZFDebug_Controller_Plugin_Debug_Plugin_Cache
extends ZFDebug_Controller_Plugin_Debug_Plugin
implements ZFDebug_Controller_Plugin_Debug_Plugin_Interface
{
/**
* Contains plugin identifier name
*
* @var string
*/
protected $_identifier = 'cache';
/**
* @var Zend_Cache_Backend_ExtendedInterface
*/
protected $_cacheBackends = array();
/**
* Create ZFDebug_Controller_Plugin_Debug_Plugin_Cache
*
* @param array $options
* @return void
*/
public function __construct(array $options = array())
{
if (!isset($options['backend'])) {
throw new Zend_Exception("ZFDebug: Cache plugin needs 'backend' parameter");
}
is_array($options['backend']) || $options['backend'] = array($options['backend']);
foreach ($options['backend'] as $name => $backend) {
if ($backend instanceof Zend_Cache_Backend_ExtendedInterface ) {
$this->_cacheBackends[$name] = $backend;
}
}
}
/**
* Gets identifier for this plugin
*
* @return string
*/
public function getIdentifier()
{
return $this->_identifier;
}
/**
* Returns the base64 encoded icon
*
* @return string
**/
public function getIconData()
{
return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAI/SURBVDjLjZPbS9NhHMYH+zNidtCSQrqwQtY5y2QtT2QGrTZf13TkoYFlzsWa/tzcoR3cSc2xYUlGJfzAaIRltY0N12H5I+jaOxG8De+evhtdOP1hu3hv3sPzPO/z4SsBIPnfuvG8cbBlWiEVO5OUItA0VS8oxi9EdhXo+6yV3V3UGHRvVXHNfNv6zRfNuBZVoiFcB/3LdnQ8U+Gk+bhPVKB3qUOuf6/muaQR/qwDkZ9BRFdCmMr5EPz6BN7lMYylLGgNNaKqt3K0SKDnQ7us690t3rNsxeyvaUz+8OJpzo/QNzd8WTtcaQ7WlBmPvxhx1V2Pg7oDziIBimwwf3qAGWESkVwQ7owNujk1ztvk+cg4NnAUTT4FrrjqUKHdF9jxBfXr1rgjaSk4OlMcLrnOrJ7latxbL1V2lgvlbG9MtMTrMw1r1PImtfyn1n5q47TlBLf90n5NmalMtUdKZoyQMkLKlIGLjMyYhFpmlz3nGEVmFJlRZNaf7pIaEndM24XIjCOzjX9mm2S2JsqdkMYIqbB1j5C6yWzVk7YRFTsGFu7l+4nveExIA9aMCcOJh6DIoMigyOh+o4UryRWQOtIjaJtoziM1FD0mpE4uZcTc72gBaUyYKEI6khgqINXO3saR7kM8IZUVCRDS0Ucf+xFbCReQhr97MZ51wpWxYnhpCD3zOrT4lTisr+AJqVx0Fiiyr4/vhP4VyyMFIUWNqRrV96vWKXKckBoIqWzXYcoPDrUslDJoopuEVEpIB0sR+AuErIiZ6OqMKAAAAABJRU5ErkJggg==';
}
/**
* Gets menu tab for the Debugbar
*
* @return string
*/
public function getTab()
{
return 'Cache';
}
/**
* Gets content panel for the Debugbar
*
* @return string
*/
public function getPanel()
{
$panel = '';
$linebreak = $this->getLinebreak();
# Support for APC
if (function_exists('apc_sma_info') && ini_get('apc.enabled')) {
$mem = apc_sma_info();
$memSize = $mem['num_seg'] * $mem['seg_size'];
$memAvail = $mem['avail_mem'];
$memUsed = $memSize - $memAvail;
$cache = apc_cache_info();
$panel .= '<h4>APC '.phpversion('apc').' Enabled</h4>';
$panel .= round($memAvail/1024/1024, 1) . 'M available, '
. round($memUsed/1024/1024, 1) . 'M used' . $linebreak
. $cache['num_entries'].' Files cached ('
. round($cache['mem_size']/1024/1024, 1) . 'M)' . $linebreak
. $cache['num_hits'] . ' Hits ('
. round($cache['num_hits'] * 100 / ($cache['num_hits'] + $cache['num_misses']), 1) . '%)'
. $linebreak
. $cache['expunges'] . ' Expunges (cache full count)';
}
foreach ($this->_cacheBackends as $name => $backend) {
$fillingPercentage = $backend->getFillingPercentage();
$ids = $backend->getIds();
# Print full class name, backends might be custom
$panel .= '<h4>Cache '.$name.' ('.get_class($backend).')</h4>';
$panel .= count($ids).' Entr'.(count($ids)>1?'ies':'y').''.$linebreak
. 'Filling Percentage: '.$backend->getFillingPercentage().'%'.$linebreak;
$cacheSize = 0;
foreach ($ids as $id) {
# Calculate valid cache size
$memPre = memory_get_usage();
if ($cached = $backend->load($id)) {
$memPost = memory_get_usage();
$cacheSize += $memPost - $memPre;
unset($cached);
}
}
$panel .= 'Valid Cache Size: ' . round($cacheSize/1024, 1) . 'K';
}
return $panel;
}
}
\ No newline at end of file
<?php
/**
* ZFDebug Zend Additions
*
* @category ZFDebug
* @package ZFDebug_Controller
* @subpackage Plugins
* @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug)
* @license http://code.google.com/p/zfdebug/wiki/License New BSD License
* @version $Id$
*/
/**
* @category ZFDebug
* @package ZFDebug_Controller
* @subpackage Plugins
* @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug)
* @license http://code.google.com/p/zfdebug/wiki/License New BSD License
*/
class ZFDebug_Controller_Plugin_Debug_Plugin_Constants extends ZFDebug_Controller_Plugin_Debug_Plugin implements ZFDebug_Controller_Plugin_Debug_Plugin_Interface
{
/**
* Contains plugin identifier name
*
* @var string
*/
protected $_identifier = 'constants';
/**
* @var Zend_Controller_Request_Abstract
*/
protected $_request;
/**
*
* @var array
*/
protected $_userConstants;
/**
* Create ZFDebug_Controller_Plugin_Debug_Plugin_Variables
*
* @return void
*/
public function __construct()
{
}
/**
* Gets identifier for this plugin
*
* @return string
*/
public function getIdentifier()
{
return $this->_identifier;
}
/**
* Returns the base64 encoded icon
*
* @return string
**/
public function getIconData()
{
return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAFWSURBVBgZBcE/SFQBAAfg792dppJeEhjZn80MChpqdQ2iscmlscGi1nBPaGkviKKhONSpvSGHcCrBiDDjEhOC0I68sjvf+/V9RQCsLHRu7k0yvtN8MTMPICJieaLVS5IkafVeTkZEFLGy0JndO6vWNGVafPJVh2p8q/lqZl60DpIkaWcpa1nLYtpJkqR1EPVLz+pX4rj47FDbD2NKJ1U+6jTeTRdL/YuNrkLdhhuAZVP6ukqbh7V0TzmtadSEDZXKhhMG7ekZl24jGDLgtwEd6+jbdWAAEY0gKsPO+KPy01+jGgqlUjTK4ZroK/UVKoeOgJ5CpRyq5e2qjhF1laAS8c+Ymk1ZrVXXt2+9+fJBYUwDpZ4RR7Wtf9u9m2tF8Hwi9zJ3/tg5pW2FHVv7eZJHd75TBPD0QuYze7n4Zdv+ch7cfg8UAcDjq7mfwTycew1AEQAAAMB/0x+5JQ3zQMYAAAAASUVORK5CYII=';
}
/**
* Gets menu tab for the Debugbar
*
* @return string
*/
public function getTab()
{
//pseudo constructor to catch more constants
$constants = get_defined_constants(true);
$this->_userConstants = $constants['user'];
$count = count($this->_userConstants);
return "Constants ($count)";
}
/**
* Gets content panel for the Debugbar
*
* @return string
*/
public function getPanel()
{
$this->_request = Zend_Controller_Front::getInstance()->getRequest();
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
$vars = '<div style="width:50%;float:left;">';
$vars .= '<h4>Constants</h4>';
$vars .= '<div id="ZFDebug_Constants" style="margin-left:-22px">';
$vars .= '<div class="pre">';
foreach($this->_userConstants as $constant => $value) {
$vars .= $constant . " => " . print_r($value, true);
$vars .= '<br />';
}
$vars .= '</div></div>';
$vars .= '</div><div style="clear:both">&nbsp;</div>';
return $vars;
}
}
\ No newline at end of file
<?php
/**
* ZFDebug Zend Additions
*
* @category ZFDebug
* @package ZFDebug_Controller
* @subpackage Plugins
* @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug)
* @license http://code.google.com/p/zfdebug/wiki/License New BSD License
* @version $Id$
*/
/**
* @see Zend_Db_Table_Abstract
*/
require_once 'Zend/Db/Table/Abstract.php';
/**
* @category ZFDebug
* @package ZFDebug_Controller
* @subpackage Plugins
* @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug)
* @license http://code.google.com/p/zfdebug/wiki/License New BSD License
*/
class ZFDebug_Controller_Plugin_Debug_Plugin_Database
extends ZFDebug_Controller_Plugin_Debug_Plugin
implements ZFDebug_Controller_Plugin_Debug_Plugin_Interface
{
/**
* Contains plugin identifier name
*
* @var string
*/
protected $_identifier = 'database';
/**
* @var array
*/
protected $_db = array();
protected $_explain = false;
/**
* Create ZFDebug_Controller_Plugin_Debug_Plugin_Variables
*
* @param Zend_Db_Adapter_Abstract|array $adapters
* @return void
*/
public function __construct(array $options = array())
{
if (!isset($options['adapter']) || !count($options['adapter'])) {
if (Zend_Db_Table_Abstract::getDefaultAdapter()) {
$this->_db[0] = Zend_Db_Table_Abstract::getDefaultAdapter();
$this->_db[0]->getProfiler()->setEnabled(true);
}
} else if ($options['adapter'] instanceof Zend_Db_Adapter_Abstract ) {
$this->_db[0] = $options['adapter'];
$this->_db[0]->getProfiler()->setEnabled(true);
} else {
foreach ($options['adapter'] as $name => $adapter) {
if ($adapter instanceof Zend_Db_Adapter_Abstract) {
$adapter->getProfiler()->setEnabled(true);
$this->_db[$name] = $adapter;
}
}
}
if (isset($options['explain'])) {
$this->_explain = (bool)$options['explain'];
}
}
/**
* Gets identifier for this plugin
*
* @return string
*/
public function getIdentifier()
{
return $this->_identifier;
}
/**
* Returns the base64 encoded icon
*
* @return string
**/
public function getIconData()
{
return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAEYSURBVBgZBcHPio5hGAfg6/2+R980k6wmJgsJ5U/ZOAqbSc2GnXOwUg7BESgLUeIQ1GSjLFnMwsKGGg1qxJRmPM97/1zXFAAAAEADdlfZzr26miup2svnelq7d2aYgt3rebl585wN6+K3I1/9fJe7O/uIePP2SypJkiRJ0vMhr55FLCA3zgIAOK9uQ4MS361ZOSX+OrTvkgINSjS/HIvhjxNNFGgQsbSmabohKDNoUGLohsls6BaiQIMSs2FYmnXdUsygQYmumy3Nhi6igwalDEOJEjPKP7CA2aFNK8Bkyy3fdNCg7r9/fW3jgpVJbDmy5+PB2IYp4MXFelQ7izPrhkPHB+P5/PjhD5gCgCenx+VR/dODEwD+A3T7nqbxwf1HAAAAAElFTkSuQmCC';
}
/**
* Gets menu tab for the Debugbar
*
* @return string
*/
public function getTab()
{
if (!$this->_db)
return 'No adapter';
foreach ($this->_db as $adapter) {
$profiler = $adapter->getProfiler();
$adapterInfo[] = $profiler->getTotalNumQueries() . ' in '
. round($profiler->getTotalElapsedSecs()*1000, 2) . ' ms';
}
$html = implode(' / ', $adapterInfo);
return $html;
}
/**
* Gets content panel for the Debugbar
*
* @return string
*/
public function getPanel()
{
if (!$this->_db)
return '';
$html = '<h4>Database queries';
// @TODO: This is always on?
if (Zend_Db_Table_Abstract::getDefaultMetadataCache()) {
$html .= ' – Metadata cache ENABLED';
} else {
$html .= ' – Metadata cache DISABLED';
}
$html .= '</h4>';
return $html . $this->getProfile();
}
public function getProfile()
{
$queries = '';
foreach ($this->_db as $name => $adapter) {
if ($profiles = $adapter->getProfiler()->getQueryProfiles()) {
$adapter->getProfiler()->setEnabled(false);
if (1 < count($this->_db)) {
$queries .= '<h4>Adapter '.$name.'</h4>';
}
$queries .='<table cellspacing="0" cellpadding="0" width="100%">';
foreach ($profiles as $profile) {
$queries .= "<tr>\n<td style='text-align:right;padding-right:2em;' nowrap>\n"
. sprintf('%0.2f', $profile->getElapsedSecs()*1000)
. "ms</td>\n<td>";
$params = $profile->getQueryParams();
array_walk($params, array($this, '_addQuotes'));
$paramCount = count($params);
if ($paramCount) {
$queries .= htmlspecialchars(preg_replace(array_fill(0, $paramCount, '/\?/'), $params, $profile->getQuery(), 1));
} else {
$queries .= htmlspecialchars($profile->getQuery());
}
$supportedAdapter = ($adapter instanceof Zend_Db_Adapter_Mysqli ||
$adapter instanceof Zend_Db_Adapter_Pdo_Mysql);
# Run explain if enabled, supported adapter and SELECT query
if ($this->_explain && $supportedAdapter) {
$queries .= "</td><td style='color:#7F7F7F;padding-left:2em;' nowrap>";
foreach ($adapter->fetchAll('EXPLAIN '.$profile->getQuery()) as $explain) {
$queries .= "<div style='padding-bottom:0.5em'>";
$explainData = array(
'Type' => $explain['select_type'] . ', ' . $explain['type'],
'Table' => $explain['table'],
'Possible keys' => str_replace(',', ', ', $explain['possible_keys']),
'Key used' => $explain['key'],
);
if ($explain['Extra']) {
$explainData['Extra'] = $explain['Extra'];
}
$explainData['Rows'] = $explain['rows'];
$explainEnd = end($explainData);
foreach ($explainData as $key => $value) {
$queries .= "$key: <span style='color:#ffb13e'>$value</span><br>\n";
}
$queries .= "</div>";
}
}
$queries .= "</td>\n</tr>\n";
}
$queries .= "</table>\n";
}
}
return $queries;
}
// For adding quotes to query params
protected function _addQuotes(&$value, $key)
{
$value = "'" . $value . "'";
}
}
\ No newline at end of file