* @license PHP License * @package WB * @subpackage content */ /** * Load base class */ WBClass::load('WBContent' ,'WBContent_SEO'); /** * Content component: SEO Metatag * * * Set Meta Tags title, description and keywords as bubbles. * Also implements an administation interface utilising TableEdtor * * @version 1.0.1 * @package WB * @subpackage content */ class WBContent_SEO_Metatag extends WBContent_SEO { /** * my parameter list * @var array */ protected $config = array( 'mode' => 'display', 'requiredgroup' => parent::GROUP_ANON, 'action' => 'list', 'id' => '__new', 'goto' => '', 'translator' => 'no', // default meta tags 'description' => '', 'title' => '', 'keywords' => '' ); const TABLE = 'pagemetatag'; /** * @var WBContent_TableEditor */ private $te; /** * @var WBDatesource_Table */ private $table; /** * run * * run component * * @see sendAndExit() * @return array parameter list */ public function run() { switch ($this->config['mode']) { case 'admin': $this->runAdmin(); break; default: case 'show': $this->runShow(); break; } return $this->config; } private function runAdmin() { $this->te = WBClass::create('WBContent_TableEditor'); $config = array( 'table' => self::TABLE, 'requiredgroup' => $this->config['requiredgroup'], 'action' => $this->config['action'], 'addcurrentuser' => 'never', 'goto' => $this->config['goto'], 'id' => $this->config['id'], 'searchfields' => array(), 'usefilter' => 0, 'translator' => $this->config['translator'] ); $this->te->configure($this->part, $config, $this->bubbles); $this->te->run(); } private function runShow() { $this->table = WBClass::create('WBDatasource_Table'); $path = $this->req->path; if (empty($path) || '/' == $path) { $path = '__index'; } $clause = array(); $clause[] = array( 'field' => 'enabled', 'value' => 1 ); $clause[] = array( 'field' => 'pagepath', 'value' => $path ); $tag = array('title', 'keywords', 'description'); $list = $this->table->get(self::TABLE, null, null, $clause); if (1 != count($list)) { foreach ($tag as $t) { if (empty($this->config[$t])) { continue; } $this->bubbles[$t] = $this->config[$t]; } return; } $list = $list[0]; foreach ($tag as $t) { if (empty($list[$t])) { continue; } $this->bubbles[$t] = $list[$t]; } } public function getString() { switch ($this->config['mode']) { case 'admin': return $this->te->getString(); break; default: case 'show': break; } return ''; } }