* @license PHP License * @package WB * @subpackage base */ WBClass::load('WBWxml_Dialog'); /** * Wxml Dialog Module * * Embed * * @version 0.1.0 * @package WB * @subpackage base */ class WBWxml_Dialog_Embed extends WBWxml_Dialog { /** * storage for URL * @var WBDictionary_URL */ protected $dict; const CSS_CLASS_BASE = 'wb-wxml-dialog wb-wxml-dialog-embed'; /** * extend constructor * * * Load parent constructor and initialize URL dictionary */ public function __construct() { parent::__construct(); $this->dict = WBClass::create('WBDictionary_URL'); } /** * Start dialog using default values * */ public function start() { $values = array( 'text' => $this->select, 'urlid' => urldecode($this->getAttribute('urlid')), 'title' => $this->value, 'url' => urldecode($this->getAttribute('href')), 'class' => $this->getAttribute('class') ); // strip internal classes if (0 == strncmp($this::CSS_CLASS_BASE, $values['class'], strlen($this::CSS_CLASS_BASE))) { $values['class'] = trim(substr($values['class'], strlen($this::CSS_CLASS_BASE))); } // create URLid from URL/href if (empty($values['urlid']) && !empty($values['url'])) { $this->dict->addWord($values['url']); $values['urlid'] = $this->dict->getId(); } // load URL from dictionary if (!empty($values['urlid'])) { $this->dict->load($values['urlid']); $values['url'] = $this->dict->getWord(); $data = $this->dict->get(); if ($data['protocol'] == 'self') { $values['url'] = '[[PROTOCOL]]://[[SERVER]]'. $values['url']; } } $this->submit($values); } /** * Form "Url" validated * * mangle "internal" URLs as such and generate HTML snippet to * past into editor * * @param patForms $forn * @param array $values * @return bool always true - display valid-template */ protected function onEmbedValid($forn, $values) { // load URL from dictionary if (!empty($values['urlid'])) { $this->dict->load($values['urlid']); $values['url'] = $this->dict->getWord(); } if (empty($values['class'])) { $values['class'] = ''; } $this->tmpl->addGlobalVars($values); return true; } }