* @license PHP License * @package WB * @subpackage base */ WBClass::load('WBXinha_Dialog'); /** * Xinha Dialog Module * * * * @version 0.1.0 * @package WB * @subpackage base */ class WBXinha_Dialog_Smiley extends WBXinha_Dialog { /** * list of known smilies * @var array */ protected $smileys = array( 'angry' => 'Angry', 'blushing' => 'Blushing', 'cool' => 'Cool', 'crying' => 'Crying', 'happy' => 'Happy', 'laughing' => 'Laughing', 'nerd' => 'Nerd', 'sad' => 'Sad', 'sick' => 'Sick', 'smileface' => 'Smile face', 'smile' => 'Smiley', 'surprised' => 'Surprised', 'tongue' => 'Tongue', 'winking' => 'Winking' ); /** * Run dialog * * @param bool $submit * @return bool whehther dialog was successful and may be closed */ public function run($submit = true) { if ($submit && $this->onSubmit()) { return true; } $this->loadTemplates('list'); $list = array(); foreach ($this->smileys as $value => $title) { $list[] = array( 'value' => $value, 'title' => $title ); } $this->tmpl->addRows('list_entry', $list); return false; } /** * select proper value on submit * * Prepare to-be-inserted HTML snippet, or return false when * selection was not successful * * @return bool sucess */ protected function onSubmit() { $this->insert = ''; $smiley = $this->req->get('smiley'); if (!isset($this->smileys[$smiley])) { return false; } $this->loadTemplates('insert'); $this->tmpl->addGlobalVar('value', $smiley); $this->tmpl->addGlobalVar('title', $this->smileys[$smiley]); $this->insert = $this->tmpl->getParsedTemplate('snippet'); return true; } } ?>