* @access public * @since Classe available since 0.9.2 */ class XOrgPlugin { /** have to override, contents the fields names used to drive the plugin */ public $_get_vars = array(); /** some polymorphism at low cost, may be used, or not */ public $_callback; /** constructor. * the constructor override $_get_vars settings by prefixing the names with $prefix */ public function __construct($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 */ public function get_value($key) { return Get::v($this->_prefix.$key); } /** construct an url with the given parameters to drive the plugin. * leave all other GET params alone */ public 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 == 'n') { 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::v($key)); } } return pl_self() . '?' . join('&', $get); } /** need to be overriden. */ public function show() { return ''; } } // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>