<?php
/**
- * $Horde: incubator/operator/graphgen.php,v 1.11 2009/07/09 08:18:18 slusarz Exp $
- *
- * Copyright 2008 The Horde Project <http://www.horde.org>
+ * Copyright 2008-2010 The Horde Project <http://www.horde.org>
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
* @author Ben Klang <ben@alkaloid.net>
*/
-@define('OPERATOR_BASE', dirname(__FILE__));
-require_once OPERATOR_BASE . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
-// Load PEAR's Image_Graph library
-require_once 'Image/Graph.php';
+$operator = new Operator_Application(array('init' => true));
+$cache = &$GLOBALS['cache'];
#setlocale(LC_ALL, Horde_Nls::select());
-setlocale(LC_ALL, 'en_US');
+#setlocale(LC_ALL, 'en_US');
$graphtype = Horde_Util::getFormData('graph');
$graphinfo = Operator::getGraphInfo($graphtype);
$graphinfo['legendsplit'] = 90;
}
-$canvas =& Image_Canvas::factory('png', array('width' => $graphinfo['imageX'], 'height' => $graphinfo['imageY'], 'antialias' => true));
+$canvas =& Image_Canvas::factory('png', array('width' => $graphinfo['imageX'],
+ 'height' => $graphinfo['imageY'],
+ 'antialias' => true));
$graph =& Image_Graph::factory('graph', $canvas);
if (isset($graphinfo['orientation']) &&
$Font->setSize(8);
$graph->setFont($Font);
}
-
-
+
// create the plotarea layout
if ($graph->horizontal) {
- $plotarea =& Image_Graph::factory('plotarea', array('Image_Graph_Axis_Category', 'Image_Graph_Axis', 'horizontal'));
+ $plotarea = Image_Graph::factory('plotarea',
+ array('Image_Graph_Axis_Category',
+ 'Image_Graph_Axis', 'horizontal'));
} else {
- $plotarea =& Image_Graph::factory('plotarea', array('Image_Graph_Axis_Category', 'Image_Graph_Axis', 'vertical'));
+ $plotarea = Image_Graph::factory('plotarea',
+ array('Image_Graph_Axis_Category',
+ 'Image_Graph_Axis',
+ 'vertical'));
}
$graph->add(
),
5
)
-);
+);
$plotarea->setAxisPadding(array('top' => 20));
-
+
// make the legend use the plotarea (or implicitly its plots)
-$legend->setPlotarea($plotarea);
-
+$legend->setPlotarea($plotarea);
+
// create a grid and assign it to the secondary Y axis
-$gridY2 =& $plotarea->addNew('line_grid', IMAGE_GRAPH_AXIS_Y_SECONDARY);
+$gridY2 =& $plotarea->addNew('line_grid', IMAGE_GRAPH_AXIS_Y_SECONDARY);
#$gridY2->setLineColor('black');
#$gridY2->setFillStyle(
# Image_Graph::factory(
-# 'gradient',
+# 'gradient',
# array(IMAGE_GRAPH_GRAD_HORIZONTAL, 'white', 'lightgrey')
# )
-#);
+#);
$linecolor = 0x000042;
$increment = 0x173147;
$marker->setBorderColor(false);
$marker->setFillColor(false);
// and use the marker on the 1st plot
- $plot->setMarker($PointingMarker);
-
+ $plot->setMarker($PointingMarker);
+
#if (!empty($graphinfo['numberformat'])) {
# $marker->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', $graphinfo['numberformat']));
#}
}
// create an area plot using a random dataset
-#$dataset2 =& Image_Graph::factory('random', array(8, 1, 10, true));
+#$dataset2 =& Image_Graph::factory('random', array(8, 1, 10, true));
#$plot2 =& $plotarea->addNew(
-# 'Image_Graph_Plot_Area',
-# $dataset2,
+# 'Image_Graph_Plot_Area',
+# $dataset2,
# IMAGE_GRAPH_AXIS_Y_SECONDARY
#);
-
+
#$plot2->setLineColor('gray');
#$plot2->setFillColor('blue@0.2');
#$plot2->setTitle('Secondary Axis');
-
+
$axisX =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
$axisY =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
if ($graph->horizontal) {
$axisX->setTitle($graphinfo['axisX'], 'vertical');
- $axisY->setTitle($graphinfo['axisY'], 'horizontal');
+ $axisY->setTitle($graphinfo['axisY'], 'horizontal');
} else {
$axisX->setTitle($graphinfo['axisX'], 'horizontal');
- $axisY->setTitle($graphinfo['axisY'], 'vertical');
+ $axisY->setTitle($graphinfo['axisY'], 'vertical');
}
$axisY->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Function', 'axis2human'));
#$axisYsecondary =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_Y_SECONDARY);
-#$axisYsecondary->setTitle('Pears', 'vertical2');
-
+#$axisYsecondary->setTitle('Pears', 'vertical2');
+
// output the Graph
$graph->done();
exit;
<?php
/**
- * $Horde: incubator/operator/index.php,v 1.4 2009/01/06 17:51:06 jan Exp $
- *
- * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
+ * Copyright 2008-2010 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
* @author Ben Klang <ben@alkaloid.net>
*/
-@define('OPERATOR_BASE', dirname(__FILE__));
-$operator_configured = (is_readable(OPERATOR_BASE . '/config/conf.php'));
-
-if (!$operator_configured) {
- require OPERATOR_BASE . '/../lib/Test.php';
- Horde_Test::configFilesMissing('Operator', OPERATOR_BASE,
- array('conf.php'));
-}
-
-require OPERATOR_BASE . '/viewgraph.php';
+require 'viewgraph.php';
--- /dev/null
+<?php
+/**
+ * Shout application interface.
+ *
+ * This file defines Shout's application interface.
+ *
+ * Copyright 2006-2010 Alkaloid Networks (http://projects.alkaloid.net/)
+ *
+ * See the enclosed file LICENSE for license information (BSD). If you did not
+ * did not receive this file, see
+ * http://www.opensource.org/licenses/bsd-license.html.
+ *
+ * @author Ben Klang <ben@alkaloid.net>
+ * @package Shout
+ */
+if (!defined('OPERATOR_BASE')) {
+ define('OPERATOR_BASE', dirname(__FILE__). '/..');
+}
+
+if (!defined('HORDE_BASE')) {
+ /* If horde does not live directly under the app directory, the HORDE_BASE
+ * constant should be defined in config/horde.local.php. */
+ if (file_exists(OPERATOR_BASE. '/config/horde.local.php')) {
+ include OPERATOR_BASE . '/config/horde.local.php';
+ } else {
+ define('HORDE_BASE', OPERATOR_BASE . '/..');
+ }
+}
+
+/* Load the Horde Framework core (needed to autoload
+ * Horde_Registry_Application::). */
+require_once HORDE_BASE . '/lib/core.php';
+
+class Operator_Application extends Horde_Registry_Application
+{
+ public $version = 'H4 (1.0-git)';
+ public $driver = null;
+
+ public function __construct($args = array())
+ {
+ if (!empty($args['init'])) {
+ // Registry.
+ $GLOBALS['registry'] = Horde_Registry::singleton();
+ $registry = &$GLOBALS['registry'];
+
+ try {
+ $registry->pushApp('operator', !defined('AUTH_HANDLER'));
+ } catch (Horde_Exception $e) {
+ if ($e->getCode() == 'permission_denied') {
+ Horde::authenticationFailureRedirect();
+ }
+ Horde::fatal($e, __FILE__, __LINE__, false);
+ }
+ $conf = &$GLOBALS['conf'];
+ @define('OPERATOR_TEMPLATES', $registry->get('templates'));
+
+ // Notification system.
+ $GLOBALS['notification'] = &Horde_Notification::singleton();
+ $notification = &$GLOBALS['notification'];
+ $notification->attach('status');
+
+ // Define the base file path of Operator.
+ @define('OPERATOR_BASE', dirname(__FILE__) . '/..');
+
+ // Operator base library
+ require_once OPERATOR_BASE . '/lib/Operator.php';
+
+ // Operator backend.
+ require_once OPERATOR_BASE . '/lib/Driver.php';
+ $this->driver = Operator_Driver::factory();
+
+ // Caching system for storing DB results
+ $GLOBALS['cache'] = &Horde_Cache::singleton($conf['cache']['driver'],
+ Horde::getDriverConfig('cache', $conf['cache']['driver']));
+
+ // Start output compression.
+ Horde::compressOutput();
+ }
+ }
+
+ public function perms()
+ {
+ static $perms = array();
+
+ if (!empty($perms)) {
+ return $perms;
+ }
+
+ $perms['tree']['operator']['accountcodes'] = false;
+ $perms['title']['operator:accountcodes'] = _("Account Codes");
+
+ $accountcodes = Operator::getAccountCodes();
+ foreach ($accountcodes as $accountcode) {
+ $perms['tree']['operator']['accountcodes'][$accountcode] = false;
+ $perms['title']['operator:accountcodes:' . $accountcode] = $accountcode;
+ }
+
+ return $perms;
+ }
+}
// Find the first day of the next month
$start->month++;
- $start->correct();
}
$info = Operator::getGraphInfo('numcalls');
+++ /dev/null
-<?php
-/**
- * Operator base application file.
- *
- * $Horde: incubator/operator/lib/base.php,v 1.8 2009/07/13 20:05:48 slusarz Exp $
- *
- * This file brings in all of the dependencies that every Operator script will
- * need, and sets up objects that all scripts use.
- *
- * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
- *
- * @author Ben Klang <ben@alkaloid.net>
- */
-
-// Check for a prior definition of HORDE_BASE (perhaps by an auto_prepend_file
-// definition for site customization).
-if (!defined('HORDE_BASE')) {
- @define('HORDE_BASE', dirname(__FILE__) . '/../../..');
-}
-
-// Load the Horde Framework core, and set up inclusion paths.
-require_once HORDE_BASE . '/lib/core.php';
-
-// Registry.
-$registry = Horde_Registry::singleton();
-try {
- $registry->pushApp('operator', !defined('AUTH_HANDLER'));
-} catch (Horde_Exception $e) {
- if ($e->getCode() == 'permission_denied') {
- Horde::authenticationFailureRedirect();
- }
- Horde::fatal($e, __FILE__, __LINE__, false);
-}
-$conf = &$GLOBALS['conf'];
-@define('OPERATOR_TEMPLATES', $registry->get('templates'));
-
-// Notification system.
-$notification = &Horde_Notification::singleton();
-$notification->attach('status');
-
-// Define the base file path of Operator.
-@define('OPERATOR_BASE', dirname(__FILE__) . '/..');
-
-// Operator base library
-require_once OPERATOR_BASE . '/lib/Operator.php';
-
-// Operator backend.
-require_once OPERATOR_BASE . '/lib/Driver.php';
-$GLOBALS['operator_driver'] = Operator_Driver::factory();
-
-// Caching system for storing DB results
-$cache = &Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'],
- Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
-
-// Start output compression.
-Horde::compressOutput();
* @author Ben Klang <ben@alkaloid.net>
*/
-@define('OPERATOR_BASE', dirname(__FILE__));
-require_once OPERATOR_BASE . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+
+$operator = new Operator_Application(array('init' => true));
+$cache = &$GLOBALS['cache'];
-// Form libraries.
-require_once 'Horde/Form.php';
-require_once 'Horde/Form/Renderer.php';
require_once OPERATOR_BASE . '/lib/Form/SearchCDR.php';
$renderer = new Horde_Form_Renderer();
* @author Ben Klang <ben@alkaloid.net>
*/
-@define('OPERATOR_BASE', dirname(__FILE__));
-require_once OPERATOR_BASE . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+
+$operator = new Operator_Application(array('init' => true));
+$cache = &$GLOBALS['cache'];
-// Form libraries.
-require_once 'Horde/Form.php';
-require_once 'Horde/Form/Renderer.php';
require_once OPERATOR_BASE . '/lib/Form/SearchCDR.php';
$renderer = new Horde_Form_Renderer();