* @license PHP License * @package WB * @subpackage content */ /** * Load base class */ WBClass::load( 'WBContent' , 'WBContent_Session' ); /** * Content component: Session_Keeper * * Copy request parameter into session to keep them * * @version 0.1.1 * @package WB * @subpackage content */ class WBContent_Session_Keeper extends WBContent_Session { /** * Configuration Parameter * * Useable parameter: * - requiredgroup: default is any * - prefix: request parameter prefix to store in session (may be empty) * - accept: list of accepted parameter * * @var array */ protected $config = array( 'prefix' => 'kis_', 'accept' => array(), 'requiredgroup' => parent::GROUP_ANON ); /** * Run * * Just copy request parameter to session * * @return array parameter list */ public function run() { // just don't do anything if not allowed if (!$this->isUserInGroup($this->config['requiredgroup'])) { return $this->config; } // normalize parameter: accept if (!is_array($this->config['accept'])) { $this->config['accept'] = array($this->config['accept']); } if (empty($this->config['accept'])) { return $this->config; } // normalize parameter: prefix $pre = trim($this->config['prefix']); if (empty($pre)) { $pre = ''; } foreach ($this->config['accept'] as $accept) { $value = $this->req->get($pre . $accept, ''); if (empty($value)) { continue; } $this->sess->set($accept, $value); } return $this->config; } /** * Receive Output * * Output is always empty * * @return string */ public function getString() { return ''; } }