/** * Функция для инициализации блока * @return null */ public function init() { $content = $this->settings['content']; if ($this->settings['type'] == 'bbcode') { $content = bbcodes::o()->format_text($content); } else { $content = display::o()->html_decode($content); } print $content; }
/** * Отправка ЛС пользователю * @param string $title заголовок сообщения * @param string $body тело сообщения * @param int $uid ID пользователя * @param string $email E-mail получателя * @param int $sender ID отправителя * @return bool статус отправки */ public function send_message($title, $body, $uid, $email = null, $sender = null) { if (!$sender) { $sender = users::o()->v('id'); } $uid = (int) $uid; if (!$title) { $title = lang::o()->v('pmessage_empty_subject'); } $id = db::o()->insert(array("subject" => $title, "text" => $body, "sender" => $sender, "receiver" => $uid, "time" => time()), "pmessages"); if ($email) { $link = furl::o()->construct("pm", array("act" => "read", "id" => $id)); $this->send_mail($email, "getted_pm", array("link" => $link, "subject" => $title, "body" => bbcodes::o()->format_text($body, "SIMPLE"))); } return (bool) $id; }
/** * Получение объекта класса * @return bbcodes $this */ public static function o() { if (!self::$o) { self::$singletoned = true; self::$o = new self(); self::$singletoned = false; } return self::$o; }
/** * Подготовка мета тегов * @param array $row данные контента * @return null */ protected function show_meta($row) { $this->title .= ' "' . $row['title'] . '"'; tpl::o()->assign("overall_keywords", $row['tags']); if ($row['content']) { $what = array("\n", "\r", " "); $with = array(" ", " ", " "); $meta = str_replace($what, $with, $row['title'] . " " . $row['content']); $meta = display::o()->cut_text($meta, config::o()->v('max_meta_descr_symb')); tpl::o()->assign("overall_descr", bbcodes::o()->remove_tags($meta)); } }
/** * Функция получения контента цитируемого комментария * @param int $id ID комментария * @return string тело комментария */ public function quote($id) { if (!$this->state) { return; } users::o()->check_perms('comment', 2, 2); $id = longval($id); $q = db::o()->p($id)->query('SELECT text FROM comments WHERE id = ? LIMIT 1'); $comment = db::o()->fetch_assoc($q); return bbcodes::o()->format_text($comment['text'], "QUOTE"); }
/** * Обработчик параметров * @param array $params массив параметров * @return string HTML код параметров */ public function selector($params) { $val = $params['val']; $key = $params['key']; $k = $params['k']; $s = $params['s']; $langvar = $params['langvar']; $after = ''; $cs = $s[1]; $html = ''; $unlim = false; switch ($cs) { case "integer": case "string": $html .= '<input type="text" name="key[' . $k . '][]" size="' . ($cs == 'integer' ? 7 : 25) . '" value="' . $key . '"> ⇒ '; case self::unlimited: $unlim = true; default: if ($cs) { $after = "[]"; } break; } $cs = $s[0]; $name = 'value[' . $k . ']'; $namea = $name . $after; switch ($cs) { case "integer": case "string": $html .= '<input type="text" name="' . $namea . '" size="' . ($cs == 'integer' ? 7 : 25) . '" value="' . $val . '">'; break; case "text": $html .= bbcodes::o()->input_form($name, $val); break; default: if (!is_array($cs)) { break; } if ($cs == array(0, 1)) { $html .= '<input type="checkbox" name="' . $namea . '" value="1"' . ($val ? " checked='checked'" : '') . '>'; } else { $a = array(); foreach ($cs as $i) { $lv = lang::o()->v($langvar . '_' . $i, true); $a[$i] = $lv ? $lv : $i; } $html .= input::o()->scurrent($val)->skeyed()->simple_selector($namea, $a); } break; } tpl::o()->assign('unlim', $unlim); return $html; }
} tpl::o()->assign('groups', users::o()->get_group()); tpl::o()->assign('curlang', users::o()->get_lang()); tpl::o()->assign('curtheme', users::o()->get_theme()); tpl::o()->assign('curtheme_color', users::o()->get_theme(true)); tpl::o()->assign('curuser', users::o()->v('username')); tpl::o()->assign('curgroup', users::o()->v('group')); } if (!defined('DELAYED_UINIT')) { users_init(); } tpl::o()->assign('URL_PATTERN', display::url_pattern); tpl::o()->assign('slbox_mbinited', false); // Кой-чаво для Smarty // Для модификаторов нет описания, ибо проще посмотреть сами функции. $bbcodes = bbcodes::o(); $input = input::o(); $display = display::o(); if (config::o()->v('torrents_on')) { lang::o()->get('torrents', null, true, true); } /* @var $blocks blocks */ $blocks = n("blocks"); /* @var $message message */ $message = n("message"); tpl::o()->register_modifier('unserialize', 'unserialize'); tpl::o()->register_modifier('arr_current', 'current'); tpl::o()->register_modifier('arr_key', 'key'); tpl::o()->register_modifier('l2ip', 'long2ip'); tpl::o()->register_modifier('long', 'longval'); tpl::o()->register_modifier('is', 'is');
/** * Обработка поля шаблона * @param array $el поле шаблона * @return string HTML код поля */ public function patternfield_compile($el) { $html = ''; $rname = $el['rname']; $s = false; switch ($el['type']) { case "input": $size = $el['size'] ? $el['size'] : 55; $html .= '<input type="text" name="' . $rname . '" size="' . $size . '">'; break; case "textarea": $html .= bbcodes::o()->input_form($rname); break; case "select": $html .= '<select name="' . $rname . '">'; $s = true; case "radio": foreach ($el['values'] as $value) { if (is_array($value)) { $key = $value[0]; $value = $value[1]; } else { $key = $value; } if ($s) { $html .= '<option value="' . $key . '">' . $value . '</option>'; } else { $html .= ' <input type="radio" name="' . $rname . '" value="' . $key . '">' . $value; } } if ($s) { $html .= '</select>'; } break; case "html": $html .= $el['html']; break; } return $html; }