-<?php
-/*
- * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2009 The Nucleus Group
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- * (see nucleus/documentation/index.html#license for more info)
- */
-
-/**
- * Part of the code for the Nucleus admin area
- *
- * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2009 The Nucleus Group
- * @version $Id: ENCAPSULATE.php 1624 2012-01-09 11:36:20Z sakamocchi $
- */
-
-class ENCAPSULATE {
- /**
- * Uses $call to call a function using parameters $params
- * This function should return the amount of entries shown.
- * When entries are show, batch operation handlers are shown too.
- * When no entries were shown, $errormsg is used to display an error
- *
- * Passes on the amount of results found (for further encapsulation)
- */
- function doEncapsulate($call, $params, $errorMessage = _ENCAPSULATE_ENCAPSULATE_NOENTRY) {
- // start output buffering
- ob_start();
-
- $nbOfRows = call_user_func_array($call, $params);
-
- // get list contents and stop buffering
- $list = ob_get_contents();
- ob_end_clean();
-
- if ($nbOfRows > 0) {
- $this->showHead();
- echo $list;
- $this->showFoot();
- } else {
- echo $errorMessage;
- }
-
- return $nbOfRows;
- }
-}
-
-/**
- * A class used to encapsulate a list of some sort inside next/prev buttons
- */
-class NAVLIST extends ENCAPSULATE {
-
- function NAVLIST($action, $start, $amount, $minamount, $maxamount, $blogid, $search, $itemid) {
- $this->action = $action;
- $this->start = $start;
- $this->amount = $amount;
- $this->minamount = $minamount;
- $this->maxamount = $maxamount;
- $this->blogid = $blogid;
- $this->search = $search;
- $this->itemid = $itemid;
- }
-
- function showBatchList($batchtype, $query, $type, $template, $errorMessage = _LISTS_NOMORE) {
- $batch = new BATCH($batchtype);
-
- $this->doEncapsulate(
- array(&$batch, 'showlist'),
- array(&$query, $type, $template),
- $errorMessage
- );
-
- }
-
-
- function showHead() {
- $this->showNavigation();
- }
- function showFoot() {
- $this->showNavigation();
- }
-
- /**
- * Displays a next/prev bar for long tables
- */
- function showNavigation() {
- $action = $this->action;
- $start = $this->start;
- $amount = $this->amount;
- $minamount = $this->minamount;
- $maxamount = $this->maxamount;
- $blogid = $this->blogid;
- $search = i18n::hsc($this->search);
- $itemid = $this->itemid;
-
- $prev = $start - $amount;
- if ($prev < $minamount) $prev=$minamount;
-
- // maxamount not used yet
- // if ($start + $amount <= $maxamount)
- $next = $start + $amount;
- // else
- // $next = $start;
-
- ?>
- <table class="navigation">
- <tr><td>
- <form method="post" action="index.php"><div>
- <input type="submit" value="<< <?php echo _LISTS_PREV?>" />
- <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
- <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
- <input type="hidden" name="action" value="<?php echo $action; ?>" />
- <input type="hidden" name="amount" value="<?php echo $amount; ?>" />
- <input type="hidden" name="search" value="<?php echo $search; ?>" />
- <input type="hidden" name="start" value="<?php echo $prev; ?>" />
- </div></form>
- </td><td>
- <form method="post" action="index.php"><div>
- <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
- <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
- <input type="hidden" name="action" value="<?php echo $action; ?>" />
- <input name="amount" size="3" value="<?php echo $amount; ?>" /> <?php echo _LISTS_PERPAGE?>
- <input type="hidden" name="start" value="<?php echo $start; ?>" />
- <input type="hidden" name="search" value="<?php echo $search; ?>" />
- <input type="submit" value="> <?php echo _LISTS_CHANGE?>" />
- </div></form>
- </td><td>
- <form method="post" action="index.php"><div>
- <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
- <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
- <input type="hidden" name="action" value="<?php echo $action; ?>" />
- <input type="hidden" name="amount" value="<?php echo $amount; ?>" />
- <input type="hidden" name="start" value="0" />
- <input type="text" name="search" value="<?php echo $search; ?>" size="7" />
- <input type="submit" value="> <?php echo _LISTS_SEARCH?>" />
- </div></form>
- </td><td>
- <form method="post" action="index.php"><div>
- <input type="submit" value="<?php echo _LISTS_NEXT?> > >" />
- <input type="hidden" name="search" value="<?php echo $search; ?>" />
- <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
- <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
- <input type="hidden" name="action" value="<?php echo $action; ?>" />
- <input type="hidden" name="amount" value="<?php echo $amount; ?>" />
- <input type="hidden" name="start" value="<?php echo $next; ?>" />
- </div></form>
- </td></tr>
- </table>
- <?php }
-
-
-}
-
-
-/**
- * A class used to encapsulate a list of some sort in a batch selection
- */
-class BATCH extends ENCAPSULATE {
- function BATCH($type) {
- $this->type = $type;
- }
-
- function showHead() {
- ?>
- <form method="post" action="index.php">
- <?php
-// TODO: get a list op operations above the list too
-// (be careful not to use the same names for the select...)
-// $this->showOperationList();
- }
-
- function showFoot() {
- $this->showOperationList();
- ?>
- </form>
- <?php }
-
- function showOperationList() {
- global $manager;
- ?>
- <div class="batchoperations">
- <?php echo _BATCH_WITH_SEL ?>
- <select name="batchaction">
- <?php $options = array();
- switch($this->type) {
- case 'item':
- $options = array(
- 'delete' => _BATCH_ITEM_DELETE,
- 'move' => _BATCH_ITEM_MOVE
- );
- break;
- case 'member':
- $options = array(
- 'delete' => _BATCH_MEMBER_DELETE,
- 'setadmin' => _BATCH_MEMBER_SET_ADM,
- 'unsetadmin' => _BATCH_MEMBER_UNSET_ADM
- );
- break;
- case 'team':
- $options = array(
- 'delete' => _BATCH_TEAM_DELETE,
- 'setadmin' => _BATCH_TEAM_SET_ADM,
- 'unsetadmin' => _BATCH_TEAM_UNSET_ADM,
- );
- break;
- case 'category':
- $options = array(
- 'delete' => _BATCH_CAT_DELETE,
- 'move' => _BATCH_CAT_MOVE,
- );
- break;
- case 'comment':
- $options = array(
- 'delete' => _BATCH_COMMENT_DELETE,
- );
- break;
- }
- foreach ($options as $option => $label) {
- echo '<option value="',$option,'">',$label,'</option>';
- }
- ?>
- </select>
- <input type="hidden" name="action" value="batch<?php echo $this->type?>" />
- <?php
- $manager->addTicketHidden();
-
- // add hidden fields for 'team' and 'comment' batchlists
- if ($this->type == 'team')
- {
- echo '<input type="hidden" name="blogid" value="',intRequestVar('blogid'),'" />';
- }
- if ($this->type == 'comment')
- {
- echo '<input type="hidden" name="itemid" value="',intRequestVar('itemid'),'" />';
- }
-
- echo '<input type="submit" value="',_BATCH_EXEC,'" />';
- ?>(
- <a href="" onclick="if (event && event.preventDefault) event.preventDefault(); return batchSelectAll(1); "><?php echo _BATCH_SELECTALL?></a> -
- <a href="" onclick="if (event && event.preventDefault) event.preventDefault(); return batchSelectAll(0); "><?php echo _BATCH_DESELECTALL?></a>
- )
- </div>
- <?php }
-
- // shortcut :)
- function showList($query, $type, $template, $errorMessage = _LISTS_NOMORE) {
- return $this->doEncapsulate( 'showlist',
- array($query, $type, $template),
- $errorMessage
- );
- }
-
-}
-?>
+<?php\r
+/*\r
+ * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)\r
+ * Copyright (C) 2002-2012 The Nucleus Group\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ * (see nucleus/documentation/index.html#license for more info)\r
+ */\r
+\r
+/**\r
+ * Part of the code for the Nucleus admin area\r
+ *\r
+ * @license http://nucleuscms.org/license.txt GNU General Public License\r
+ * @copyright Copyright (C) 2002-2012 The Nucleus Group\r
+ * @version $Id: ENCAPSULATE.php 1624 2012-01-09 11:36:20Z sakamocchi $\r
+ */\r
+\r
+class Encapsulate\r
+{\r
+ /**\r
+ * Uses $call to call a function using parameters $params\r
+ * This function should return the amount of entries shown.\r
+ * When entries are show, batch operation handlers are shown too.\r
+ * When no entries were shown, $errormsg is used to display an error\r
+ *\r
+ * Passes on the amount of results found (for further encapsulation)\r
+ */\r
+ function doEncapsulate($call, $params, $errorMessage = _Encapsulate_Encapsulate_NOENTRY)\r
+ {\r
+ if ( isset($params[3]) && !empty($params[3]) )\r
+ {\r
+ $templateName = $params[3];\r
+ }\r
+ else\r
+ {\r
+ $templateName = '';\r
+ }\r
+ $params[4] = $errorMessage;\r
+ // start output buffering\r
+ ob_start();\r
+ \r
+ $nbOfRows = call_user_func_array($call, $params);\r
+\r
+ // get list contents and stop buffering\r
+ $list = ob_get_contents();\r
+ ob_end_clean();\r
+\r
+ if ( $nbOfRows > 0 )\r
+ {\r
+ $this->showHead($templateName);\r
+ echo $list;\r
+ $this->showFoot($templateName);\r
+ }\r
+ else\r
+ {\r
+ echo $errorMessage;\r
+ }\r
+\r
+ return $nbOfRows;\r
+ }\r
+}\r
+\r
+/**\r
+ * A class used to encapsulate a list of some sort inside next/prev buttons\r
+ */\r
+class NavList extends Encapsulate\r
+{\r
+ function __construct($action, $start, $amount, $minamount, $maxamount, $blogid, $search, $itemid)\r
+ {\r
+ $this->action = $action;\r
+ $this->start = $start;\r
+ $this->amount = $amount;\r
+ $this->minamount = $minamount;\r
+ $this->maxamount = $maxamount;\r
+ $this->blogid = $blogid;\r
+ $this->search = $search;\r
+ $this->itemid = $itemid;\r
+ }\r
+\r
+ function showBatchList($batchtype, $query, $type, $template, $errorMessage = _LISTS_NOMORE, $templateName = '')\r
+ {\r
+ $batch = new Batch($batchtype);\r
+\r
+ $this->doEncapsulate(\r
+ array(&$batch, 'showlist'),\r
+ array(&$query, $type, $template, $templateName),\r
+ $errorMessage\r
+ );\r
+\r
+ }\r
+\r
+\r
+ function showHead()\r
+ {\r
+ $this->showNavigation();\r
+ }\r
+ function showFoot()\r
+ {\r
+ $this->showNavigation();\r
+ }\r
+\r
+ /**\r
+ * Displays a next/prev bar for long tables\r
+ */\r
+ function showNavigation()\r
+ {\r
+ $action = $this->action;\r
+ $start = $this->start;\r
+ $amount = $this->amount;\r
+ $minamount = $this->minamount;\r
+ $maxamount = $this->maxamount;\r
+ $blogid = $this->blogid;\r
+ $search = Entity::hsc($this->search);\r
+ $itemid = $this->itemid;\r
+\r
+ $prev = $start - $amount;\r
+ if ( $prev < $minamount )\r
+ {\r
+ $prev=$minamount;\r
+ }\r
+\r
+ // maxamount not used yet\r
+ // if ($start + $amount <= $maxamount)\r
+ $next = $start + $amount;\r
+ // else\r
+ // $next = $start;\r
+\r
+ ?>\r
+ <table class="navigation">\r
+ <tr><td>\r
+ <form method="post" action="index.php"><div>\r
+ <input type="submit" value="<< <?php echo _LISTS_PREV?>" />\r
+ <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />\r
+ <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />\r
+ <input type="hidden" name="action" value="<?php echo $action; ?>" />\r
+ <input type="hidden" name="amount" value="<?php echo $amount; ?>" />\r
+ <input type="hidden" name="search" value="<?php echo $search; ?>" />\r
+ <input type="hidden" name="start" value="<?php echo $prev; ?>" />\r
+ </div></form>\r
+ </td><td>\r
+ <form method="post" action="index.php"><div>\r
+ <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />\r
+ <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />\r
+ <input type="hidden" name="action" value="<?php echo $action; ?>" />\r
+ <input name="amount" size="3" value="<?php echo $amount; ?>" /> <?php echo _LISTS_PERPAGE?>\r
+ <input type="hidden" name="start" value="<?php echo $start; ?>" />\r
+ <input type="hidden" name="search" value="<?php echo $search; ?>" />\r
+ <input type="submit" value="> <?php echo _LISTS_CHANGE?>" />\r
+ </div></form>\r
+ </td><td>\r
+ <form method="post" action="index.php"><div>\r
+ <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />\r
+ <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />\r
+ <input type="hidden" name="action" value="<?php echo $action; ?>" />\r
+ <input type="hidden" name="amount" value="<?php echo $amount; ?>" />\r
+ <input type="hidden" name="start" value="0" />\r
+ <input type="text" name="search" value="<?php echo $search; ?>" size="7" />\r
+ <input type="submit" value="> <?php echo _LISTS_SEARCH?>" />\r
+ </div></form>\r
+ </td><td>\r
+ <form method="post" action="index.php"><div>\r
+ <input type="submit" value="<?php echo _LISTS_NEXT?> > >" />\r
+ <input type="hidden" name="search" value="<?php echo $search; ?>" />\r
+ <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />\r
+ <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />\r
+ <input type="hidden" name="action" value="<?php echo $action; ?>" />\r
+ <input type="hidden" name="amount" value="<?php echo $amount; ?>" />\r
+ <input type="hidden" name="start" value="<?php echo $next; ?>" />\r
+ </div></form>\r
+ </td></tr>\r
+ </table>\r
+ <?php }\r
+\r
+\r
+}\r
+\r
+\r
+/**\r
+ * A class used to encapsulate a list of some sort in a batch selection\r
+ */\r
+class Batch extends Encapsulate\r
+{\r
+ function __construct($type)\r
+ {\r
+ $this->type = $type;\r
+ }\r
+\r
+ function showHead($templateName = '')\r
+ {\r
+ ?>\r
+ <form method="post" action="index.php">\r
+ <?php\r
+// TODO: get a list op operations above the list too\r
+// (be careful not to use the same names for the select...)\r
+// $this->showOperationList();\r
+ }\r
+\r
+ function showFoot($templateName = '')\r
+ {\r
+ $this->showOperationList();\r
+?>\r
+ </form>\r
+<?php\r
+ }\r
+\r
+ function showOperationList()\r
+ {\r
+ global $manager;\r
+?>\r
+ <div class="batchoperations">\r
+ <?php echo _BATCH_WITH_SEL ?>\r
+ <select name="batchaction">\r
+ <?php $options = array();\r
+ switch($this->type) {\r
+ case 'item':\r
+ $options = array(\r
+ 'delete' => _BATCH_ITEM_DELETE,\r
+ 'move' => _BATCH_ITEM_MOVE\r
+ );\r
+ break;\r
+ case 'member':\r
+ $options = array(\r
+ 'delete' => _BATCH_MEMBER_DELETE,\r
+ 'setadmin' => _BATCH_MEMBER_SET_ADM,\r
+ 'unsetadmin' => _BATCH_MEMBER_UNSET_ADM\r
+ );\r
+ break;\r
+ case 'team':\r
+ $options = array(\r
+ 'delete' => _BATCH_TEAM_DELETE,\r
+ 'setadmin' => _BATCH_TEAM_SET_ADM,\r
+ 'unsetadmin' => _BATCH_TEAM_UNSET_ADM,\r
+ );\r
+ break;\r
+ case 'category':\r
+ $options = array(\r
+ 'delete' => _BATCH_CAT_DELETE,\r
+ 'move' => _BATCH_CAT_MOVE,\r
+ );\r
+ break;\r
+ case 'comment':\r
+ $options = array(\r
+ 'delete' => _BATCH_COMMENT_DELETE,\r
+ );\r
+ break;\r
+ }\r
+ foreach ($options as $option => $label) {\r
+ echo '<option value="',$option,'">',$label,'</option>';\r
+ }\r
+ ?>\r
+ </select>\r
+ <input type="hidden" name="action" value="batch<?php echo $this->type?>" />\r
+ <?php\r
+ $manager->addTicketHidden();\r
+\r
+ // add hidden fields for 'team' and 'comment' batchlists\r
+ if ($this->type == 'team')\r
+ {\r
+ echo '<input type="hidden" name="blogid" value="',intRequestVar('blogid'),'" />';\r
+ }\r
+ if ($this->type == 'comment')\r
+ {\r
+ echo '<input type="hidden" name="itemid" value="',intRequestVar('itemid'),'" />';\r
+ }\r
+\r
+ echo '<input type="submit" value="',_BATCH_EXEC,'" />';\r
+ ?>(\r
+ <a href="" onclick="if (event && event.preventDefault) event.preventDefault(); return batchSelectAll(1); "><?php echo _BATCH_SELECTALL?></a> -\r
+ <a href="" onclick="if (event && event.preventDefault) event.preventDefault(); return batchSelectAll(0); "><?php echo _BATCH_DESELECTALL?></a>\r
+ )\r
+ </div>\r
+ <?php }\r
+\r
+ // shortcut :)\r
+ function showList($query, $type, $template, $templateName = '', $errorMessage = _LISTS_NOMORE)\r
+ {\r
+ return $this->doEncapsulate( 'showlist',\r
+ array($query, $type, $template, $templateName),\r
+ $errorMessage\r
+ );\r
+ }\r
+\r
+}\r
+?>\r