* @access public * @since Classe available since 0.9.2 */ class XOrgPlugin { // {{{ properties /** 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() /** 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; } } // }}} // {{{ function get_value() /** transparent access to $_GET, wrt the right $prefix */ function get_value($key) { return Get::get($this->_prefix.$key); } // }}} // {{{ function make_url() /** construct an url with the given parameters to drive the plugin. * leave all other GET params alone */ function make_url($params) { $get = Array(); $args = isset($params) ? $params : Array(); if (!is_array($args)) { $args = array($this->_get_vars[0]=>$params); } foreach ($_GET as $key=>$val) { if ($key == 'p') { continue; } if (in_array($key, $this->_get_vars) && array_key_exists($key, $args)) { continue; } $get[] = urlencode($key) . '=' . urlencode($val); } foreach ($this->_get_vars as $key) { if (array_key_exists($key, $args)) { if ($args[$key]) { $get[] = urlencode($key) . '=' . urlencode($args[$key]); } } elseif (Get::has('key')) { $get[] = urlencode($key) . '=' . urlencode(Get::get($key)); } } return pl_self() . '?' . join('&', $get); } // }}} // {{{ function show() /** need to be overriden. */ function show () { return ''; } // }}} } // }}} // vim:set et sw=4 sts=4 sws=4 foldmethod=marker: ?>