[dev] [patch] Move whups' Actions class into horde.
Jason M. Felice
jfelice at cronosys.com
Thu Nov 13 16:48:48 PST 2003
This patch moves whups' Actions class into Horde so that it can be used from
other applications (I'm going to use it from Hermes). There are file additions
and deletions in here.
Patch summary:
D whups/templates/actions.inc
A lib/Actions.php
M whups/lib/base.php
M whups/admin.php
M whups/details.php
M whups/query.php
M whups/runquery.php
--
Jason M. Felice
Cronosys, LLC <http://www.cronosys.com/>
216.221.4600 x302
-------------- next part --------------
epm diff whups/templates/actions.inc
--- whups/templates/actions.inc 2003-11-13 19:34:46.000000000 -0500
+++ whups/templates/actions.inc 1969-12-31 19:00:00.000000000 -0500
@@ -1,84 +0,0 @@
-<?php
-/**
- * $Horde: whups/templates/actions.inc,v 1.9 2003/09/16 23:08:53 jan Exp $
- *
- * Copyright 2001 Robert E. Coyle <robertecoyle at hotmail.com>
- *
- * See the enclosed file LICENSE for license information (BSD). If you
- * did not receive this file, see http://www.horde.org/licenses/bsdl.php.
- *
- * @package whups
- */
-class Actions {
-
- function Actions()
- {
- $this->actions = array();
- $this->preserve = array();
- }
-
- function addAction($title, $link, $action = '')
- {
- $action = array('title' => $title, 'link' => $link, 'action' => $action);
- array_push($this->actions, $action);
- }
-
- function preserve($var, $value)
- {
- $preserve = array('var' => $var, 'value' => $value);
- array_push($this->preserve, $preserve);
- }
-
- function getTitleFromAction($action)
- {
- foreach ($this->actions as $ac) {
- if ($ac['action'] == $action) {
- return $ac['title'];
- }
- }
-
- return null;
- }
-
- function render($active)
- {
-?>
-<table width="100%" cellspacing="0" cellpadding="0" border="0">
-<tr><td>
- <table width="100%" cellspacing="2" cellpadding="1" border="0">
- <tr>
-<?php
- $width = 100.0 / sizeof($this->actions);
-
- foreach ($this->actions as $action) {
- $class = 'sect';
- $title = $action['title'];
- $link = $action['link'];
- $accesskey = Horde::getAccessKey($title);
-
- foreach ($this->preserve as $preserve) {
- $link = Util::addParameter($link, $preserve['var'], $preserve['value']);
- }
-
- if (!empty($action['action'])) {
- $link = Util::addParameter($link, 'action', $action['action']);
-
- if ($active == $action['action']) {
- $class = 'cursect';
- }
- }
-
- echo "<td width=\"$width%\" align=\"center\" class=\"$class\"><b>" . Horde::link(Horde::applicationUrl($link), $title, null, null, null, null, $accesskey) . Horde::highlightAccessKey($title, $accesskey) . '</a></b></td>';
- }
-?>
- </tr>
- </table>
-</td></tr>
-</table>
-
-<br />
-
-<?php
- }
-
-}
epm diff lib/Actions.php
--- lib/Actions.php 1969-12-31 19:00:00.000000000 -0500
+++ lib/Actions.php 2003-11-13 19:35:56.000000000 -0500
@@ -0,0 +1,84 @@
+<?php
+/**
+ * $Horde: whups/templates/actions.inc,v 1.9 2003/09/16 23:08:53 jan Exp $
+ *
+ * Copyright 2001 Robert E. Coyle <robertecoyle at hotmail.com>
+ *
+ * See the enclosed file LICENSE for license information (BSD). If you
+ * did not receive this file, see http://www.horde.org/licenses/bsdl.php.
+ *
+ * @package horde
+ */
+class Horde_Actions {
+
+ function Horde_Actions()
+ {
+ $this->actions = array();
+ $this->preserve = array();
+ }
+
+ function addAction($title, $link, $action = '')
+ {
+ $action = array('title' => $title, 'link' => $link, 'action' => $action);
+ array_push($this->actions, $action);
+ }
+
+ function preserve($var, $value)
+ {
+ $preserve = array('var' => $var, 'value' => $value);
+ array_push($this->preserve, $preserve);
+ }
+
+ function getTitleFromAction($action)
+ {
+ foreach ($this->actions as $ac) {
+ if ($ac['action'] == $action) {
+ return $ac['title'];
+ }
+ }
+
+ return null;
+ }
+
+ function render($active)
+ {
+?>
+<table width="100%" cellspacing="0" cellpadding="0" border="0">
+<tr><td>
+ <table width="100%" cellspacing="2" cellpadding="1" border="0">
+ <tr>
+<?php
+ $width = 100.0 / sizeof($this->actions);
+
+ foreach ($this->actions as $action) {
+ $class = 'sect';
+ $title = $action['title'];
+ $link = $action['link'];
+ $accesskey = Horde::getAccessKey($title);
+
+ foreach ($this->preserve as $preserve) {
+ $link = Util::addParameter($link, $preserve['var'], $preserve['value']);
+ }
+
+ if (!empty($action['action'])) {
+ $link = Util::addParameter($link, 'action', $action['action']);
+
+ if ($active == $action['action']) {
+ $class = 'cursect';
+ }
+ }
+
+ echo "<td width=\"$width%\" align=\"center\" class=\"$class\"><b>" . Horde::link(Horde::applicationUrl($link), $title, null, null, null, null, $accesskey) . Horde::highlightAccessKey($title, $accesskey) . '</a></b></td>';
+ }
+?>
+ </tr>
+ </table>
+</td></tr>
+</table>
+
+<br />
+
+<?php
+ }
+
+}
epm diff whups/lib/base.php
--- whups/lib/base.php 2003-11-13 19:38:30.000000000 -0500
+++ whups/lib/base.php 2003-11-13 19:39:14.000000000 -0500
@@ -62,8 +62,8 @@
require_once HORDE_BASE . '/lib/Form.php';
require_once HORDE_BASE . '/lib/Form/Renderer.php';
-// Whups UI classes.
-require_once WHUPS_TEMPLATES . '/actions.inc';
+// UI classes.
+require_once HORDE_BASE . '/lib/Actions.php';
// Whups backend.
$GLOBALS['whups'] = &Whups_Driver::factory();
epm diff whups/admin.php
--- whups/admin.php 2003-11-13 19:41:26.000000000 -0500
+++ whups/admin.php 2003-11-13 19:37:13.000000000 -0500
@@ -20,7 +20,7 @@
$showExtraForm = null;
// admin actions
-$AACTIONS = &new Actions();
+$AACTIONS = &new Horde_Actions();
$AACTIONS->addAction(_("Edit Modules"), 'admin.php', 'module');
$AACTIONS->addAction(_("Edit Types"), 'admin.php', 'type');
$AACTIONS->addAction(_("Edit Subjects"), 'admin.php', 'subject');
epm diff whups/details.php
--- whups/details.php 2003-11-13 19:41:42.000000000 -0500
+++ whups/details.php 2003-11-13 19:37:21.000000000 -0500
@@ -33,7 +33,7 @@
$showticketdetails = true;
// Ticket actions.
-$ACTIONS = &new Actions();
+$ACTIONS = &new Horde_Actions();
$ACTIONS->addAction(_("Add Comment"), 'details.php', 'ac');
$ACTIONS->addAction(_("Upload Attachment"), 'details.php', 'ua');
if (Auth::getAuth()) {
epm diff whups/query.php
--- whups/query.php 2003-11-13 19:42:22.000000000 -0500
+++ whups/query.php 2003-11-13 19:37:30.000000000 -0500
@@ -22,14 +22,14 @@
$showExtraForm = null;
// Query actions.
-$QACTIONS = &new Actions();
+$QACTIONS = &new Horde_Actions();
$QACTIONS->addAction(_("New Query"), 'query.php', 'new');
$QACTIONS->addAction(_("Execute Query"), 'runquery.php', '');
$QACTIONS->addAction(_("Load Query"), 'query.php', 'load');
$QACTIONS->addAction(_("Save Query"), 'query.php', 'save');
// Criterion form types.
-$CACTIONS = &new Actions();
+$CACTIONS = &new Horde_Actions();
$CACTIONS->addAction(_("Property Criteria"), 'query.php', 'props');
$CACTIONS->addAction(_("User Criteria"), 'query.php', 'user');
//$CACTIONS->addAction(_("Date Criteria"), 'query.php', 'date');
epm diff whups/runquery.php
--- whups/runquery.php 2003-11-13 19:42:47.000000000 -0500
+++ whups/runquery.php 2003-11-13 19:37:43.000000000 -0500
@@ -17,7 +17,7 @@
require WHUPS_TEMPLATES . '/searchresults.inc';
// execute actions
-$EACTIONS = new Actions();
+$EACTIONS = new Horde_Actions();
$EACTIONS->addAction(_("Edit Query"), 'query.php', '');
$EACTIONS->addAction(_("Re-execute Query"), 'runquery.php', '');
$EACTIONS->addAction(_("Load Query"), 'query.php', 'load');
More information about the dev
mailing list