* Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************
- $Id: trombi.inc.php,v 1.1 2004-10-28 20:28:41 x2000habouzit Exp $
+ $Id: trombi.inc.php,v 1.2 2004-10-29 01:51:32 x2000habouzit Exp $
***************************************************************************/
require_once('xorg.plugin.inc.php');
function setAdmin() { $this->admin = true; }
function show() {
+ /* this point is nasty... but since show() is called from the template ...
+ * I can't see any more clever way to achieve that
+ */
global $page;
- $offset = empty($_GET['offset']) ? 0 : intval($_GET['offset']);
+ $offset = $this->get_value('offset');
list($total, $list) = call_user_func($this->_callback, $offset, $this->limit);
$page_max = intval(($total-1)/$this->limit);
* Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************
- $Id: xorg.plugin.inc.php,v 1.1 2004-10-28 20:28:42 x2000habouzit Exp $
+ $Id: xorg.plugin.inc.php,v 1.2 2004-10-29 01:51:32 x2000habouzit Exp $
***************************************************************************/
+
+/** class used for plugins whose behavior depends only from the GET.
+ */
class XOrgPlugin {
+ /** have to override, contents the fields names used to drive the plugin */
var $_get_vars = Array();
+ /** some polymorphism at low cost, may be used, or not */
var $_callback;
-
- function XOrgPlugin($funcname) {
+
+ /** constructor.
+ * the constructor override $_get_vars settings by prefixing the names with $prefix
+ */
+ function XOrgPlugin($funcname='',$prefix='') {
$this->_callback = $funcname;
+ $this->_prefix = $prefix;
+ foreach($this->_get_vars as $key=>$val) $this->_get_vars[$key] = $prefix.$val;
+ }
+
+ /** transparent access to $_GET, wrt the right $prefix
+ */
+ function get_value($key) {
+ if(empty($_GET[$this->_prefix.$key])) return '';
+ return $_GET[$this->_prefix.$key];
}
+ /** construct an url with the given parameters to drive the plugin.
+ * leave all other GET params alone
+ */
function make_url($params) {
$get = Array();
$args = empty($params) ? Array() : $params;
return $_SERVER['PHP_SELF'] . '?' . join('&',$get);
}
+
+ /** need to be overriden. */
+ function show () { return ''; }
}
?>