-<?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
- // 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
- $this->showHead();\r
- echo $list;\r
- $this->showFoot();\r
- } else {\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
- $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) {\r
- $batch = new Batch($batchtype);\r
-\r
- $this->doEncapsulate(\r
- array(&$batch, 'showlist'),\r
- array(&$query, $type, $template),\r
- $errorMessage\r
- );\r
-\r
- }\r
-\r
-\r
- function showHead() {\r
- $this->showNavigation();\r
- }\r
- function showFoot() {\r
- $this->showNavigation();\r
- }\r
-\r
- /**\r
- * Displays a next/prev bar for long tables\r
- */\r
- function showNavigation() {\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) $prev=$minamount;\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
- $this->type = $type;\r
- }\r
-\r
- function showHead() {\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() {\r
- $this->showOperationList();\r
- ?>\r
- </form>\r
- <?php }\r
-\r
- function showOperationList() {\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, $errorMessage = _LISTS_NOMORE) {\r
- return $this->doEncapsulate( 'showlist',\r
- array($query, $type, $template),\r
- $errorMessage\r
- );\r
- }\r
-\r
-}\r
-?>\r