/** * Displays edit form and performs according actions upon submit * * @param int $id Id of the smiley to edit * @param String $view View to return to after editing */ public function edit_action($id, $view) { PageLayout::setTitle(_('Smiley bearbeiten')); $smiley = Smiley::getById($id); if (Request::submitted('edit')) { $success = true; $name = Request::get('name', $smiley->name); if ($smiley->name != $name) { // rename smiley if (Smiley::getByName($name)->id) { $error = sprintf(_('Es existiert bereits eine Datei mit dem Namen "%s".'), $name . '.gif'); PageLayout::postMessage(MessageBox::error($error)); $success = false; } elseif (!$smiley->rename($name)) { $error = sprintf(_('Die Datei "%s" konnte nicht umbenannt werden.'), $smiley->name . '.gif'); PageLayout::postMessage(MessageBox::error($error)); $success = false; } else { PageLayout::postMessage(MessageBox::success(_('Smiley erfolgreich umbenannt.'))); } } $short = Request::get('short', $smiley->short); if (!$message and $smiley->short != $short) { // rename short if (Smiley::getByShort($short)->id) { $error = sprintf(_('Es gibt bereits einen Smileys mit dem Kürzel "%s".'), $short); PageLayout::postMessage(MessageBox::error($error)); $success = false; } else { $smiley->short = $short; $smiley->store(); PageLayout::postMessage(MessageBox::success(_('Kürzel erfolgreich geändert.'))); } } if ($success) { $this->redirect('admin/smileys?view=' . $smiley->name[0] . '#smiley' . $smiley->id); } else { $this->redirect($this->url_for('admin/smileys/edit', $id, $view)); } } $this->smiley = $smiley; $this->view = $view; }
/** * calls Stud.IP's kill_format and additionally removes any found smiley-tag * * @param string $text the text to parse * @return string the text without format-tags and without smileys */ static function killFormat($text) { $text = kill_format($text); // find stuff which is enclosed between to colons preg_match('/:.*:/U', $text, $matches); // remove the match if it is a smiley foreach ($matches as $match) { if (Smiley::getByName($match) || Smiley::getByShort($match)) { $text = str_replace($match, '', $text); } } return $text; }