function display_help($tagid = "helpb", $mode = 1, $addtextfunc = "addtext", $helpfunc = "help", $helpsize = '') { return e107::getBB()->renderButtons($mode, 'data'); // guessing the name of the textarea as 'data' no indicator unfortunately. // may cause pre-image and pre-file selector issues. // if(defsettrue('e_WYSIWYG')) { return; } global $tp, $pref, $eplug_bb, $bbcode_func, $register_bb, $bbcode_help, $bbcode_helpactive, $bbcode_helptag, $bbcode_helpsize; $bbcode_helpsize = $helpsize; $bbcode_func = $addtextfunc; $bbcode_help = $helpfunc; $bbcode_helptag = $tagid; // $arr = get_defined_vars(); // print_a($arr); // load the template if (is_readable(THEME . "bbcode_template.php")) { include THEME . "bbcode_template.php"; } else { include e_THEME . "templates/bbcode_template.php"; } if ($mode != 2 && $mode != "forum") { $bbcode_helpactive = TRUE; } // Load the Plugin bbcode AFTER the templates, so they can modify or replace. if (!empty($pref['e_bb_list'])) { foreach ($pref['e_bb_list'] as $val) { if (is_readable(e_PLUGIN . $val . "/e_bb.php")) { require e_PLUGIN . $val . "/e_bb.php"; } } } $temp = array(); $temp['news'] = $BBCODE_TEMPLATE_NEWSPOST; $temp['submitnews'] = $BBCODE_TEMPLATE_SUBMITNEWS; $temp['extended'] = $BBCODE_TEMPLATE_NEWSPOST; $temp['admin'] = $BBCODE_TEMPLATE_ADMIN; $temp['mailout'] = $BBCODE_TEMPLATE_MAILOUT; $temp['page'] = $BBCODE_TEMPLATE_CPAGE; $temp['maintenance'] = $BBCODE_TEMPLATE_ADMIN; $temp['comment'] = $BBCODE_TEMPLATE; $temp['signature'] = $BBCODE_TEMPLATE_SIGNATURE; if (isset($temp[$mode])) { $BBCODE_TEMPLATE = $temp[$mode]; } $visible = deftrue('e_WYSIWYG') ? "style='display:none'" : ""; if (is_readable(e_CORE . "shortcodes/batch/bbcode_shortcodes.php")) { $sc = e107::getScBatch('bbcode'); if ($tagid == 'data') { $tagid = 'data_'; } $data = array('tagid' => $tagid, 'template' => $mode, 'trigger' => $addtextfunc, 'hint_func' => $helpfunc, 'hint_active' => $bbcode_helpactive, 'size' => $helpsize); $sc->setVars($data); return "<div id='bbcode-panel-" . $tagid . "' class='mceToolbar bbcode-panel' {$visible}>" . $tp->parseTemplate($BBCODE_TEMPLATE) . "</div>"; } else { return "ERROR: " . e_CORE . "shortcodes/batch/bbcode_shortcodes.php IS NOT READABLE."; } }
function sc_newsbody($parm) { e107::getBB()->setClass("news"); $news_body = $this->e107->tp->toHTML($this->news_item['news_body'], true, 'BODY, fromadmin', $this->news_item['news_author']); if ($this->news_item['news_extended'] && (isset($_POST['preview']) || $this->param['current_action'] == 'extend') && $parm != 'noextend') { $news_body .= $this->e107->tp->toHTML($this->news_item['news_extended'], true, 'BODY, fromadmin', $this->news_item['news_author']); } e107::getBB()->clearClass(); return $news_body; }
/** * Translate to <p> tag */ function toHTML($code_text, $parm) { if ($parm && !strpos($parm, '=')) { $parm = 'class=' . $parm; } $code_text = trim($code_text); $parms = eHelper::scParams($parm); $class = " " . e107::getBB()->getClass('p'); // consistent classes across all themes. $id = varsettrue($parms['id']) ? ' id="' . eHelper::secureIdAttr($parms['id']) . '"' : ''; $style = varsettrue($parms['style']) ? ' style="' . eHelper::secureStyleAttr($parms['style']) . '"' : ''; return "<p{$id}{$class}{$style}>" . $code_text . '</p>'; }
/** * Send output to browser. */ function toHTML($code_text, $parm) { global $e107cache; $class = e107::getBB()->getClass('code'); $pref = e107::getPref(); $tp = e107::getParser(); if ($pref['smiley_activate']) { if (!is_object($tp->e_emote)) { $tp->e_emote = new e_emoteFilter(); } $code_text = $tp->e_emote->filterEmotesRev($code_text); } $search = array(E_NL, '\', '$', '<'); $replace = array("\r\n", "\\", '$', '<'); $code_text = str_replace($search, $replace, $code_text); if (isset($pref['useGeshi']) && $pref['useGeshi'] && file_exists(e_PLUGIN . "geshi/geshi.php")) { $code_md5 = md5($code_text); if (!($CodeCache = $e107cache->retrieve('GeshiParsed_' . $code_md5))) { require_once e_PLUGIN . "geshi/geshi.php"; if ($parm) { $geshi = new GeSHi($code_text, $parm, e_PLUGIN . "geshi/geshi/"); } else { $geshi = new GeSHi($code_text, $pref['defaultLanGeshi'] ? $pref['defaultLanGeshi'] : 'php', e_PLUGIN . "geshi/geshi/"); } $geshi->line_style1 = "font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;"; $geshi->set_encoding('utf-8'); $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS); $geshi->set_header_type(GESHI_HEADER_DIV); $CodeCache = $geshi->parse_code(); $e107cache->set('GeshiParsed_' . $code_md5, $CodeCache); } $ret = "<code class='code_highlight code-box {$class}' style='unicode-bidi: embed; direction: ltr'>" . str_replace("&", "&", $CodeCache) . "</code>"; } else { $code_text = html_entity_decode($code_text, ENT_QUOTES, 'utf-8'); $code_text = trim($code_text); $code_text = htmlspecialchars($code_text, ENT_QUOTES, 'utf-8'); $srch = array('{', '}'); $repl = array('{', '}'); $code_text = str_replace($srch, $repl, $code_text); // avoid code getting parsed as templates or shortcodes. if ($parm == 'inline') { return "<code style='unicode-bidi: embed; direction: ltr'>" . $code_text . "</code>"; } // $highlighted_text = highlight_string($code_text, TRUE); // highlighted_text = str_replace(array("<code>","</code>"),"",$highlighted_text); $divClass = $parm ? $parm : 'code_highlight'; $ret = "<pre class='prettyprint linenums " . $tp->toAttribute($divClass) . " code-box {$class}' style='unicode-bidi: embed; direction: ltr'>" . $code_text . "</pre>"; } $ret = str_replace("[", "[", $ret); return $ret; }
function sc_newsbody($parm = null) { $tp = e107::getParser(); e107::getBB()->setClass("news"); // For automatic bbcode image resizing. if ($parm != 'extended') { $news_body = $tp->toHTML($this->news_item['news_body'], true, 'BODY, fromadmin', $this->news_item['news_author']); } if ($this->news_item['news_extended'] && (isset($_POST['preview']) || $this->param['current_action'] == 'extend') && ($parm != 'noextend' && $parm != 'body')) { $news_body .= $tp->toHTML($this->news_item['news_extended'], true, 'BODY, fromadmin', $this->news_item['news_author']); } e107::getBB()->clearClass(); return $news_body; }
/** * Translate youtube bbcode into the appropriate HTML */ function toHTML($code_text, $parm) { // transform to class, equal sign at 0 position is not well formed parm string if ($parm && !strpos($parm, '=')) { $parm = 'class=' . $parm; } $parms = eHelper::scParams($parm); $class = " " . e107::getBB()->getClass('block'); $id = varsettrue($parms['id']) ? ' id=' . eHelper::secureIdAttr($parms['id']) : ''; $style = varsettrue($parms['style']) ? ' style="' . eHelper::secureStyleAttr($parms['style']) . '"' : ''; if (empty($code_text)) { $code_text = '<!-- -->'; } return '<div' . $id . $class . $style . '>' . $code_text . '</div>'; }
/** * Translate to <h*> tag */ function toHTML($code_text, $parm) { $code_text = trim($code_text); if (empty($code_text)) { return ''; } $bparms = eHelper::scDualParams($parm); $h = 'h' . ($bparms[1] ? intval($bparms[1]) : 2); $parms = $bparms[2]; unset($bparms); $class = " " . e107::getBB()->getClass('h2'); // consistent classes across all themes. $id = varsettrue($parms['id']) ? ' id=' . eHelper::secureIdAttr($parms['id']) : ''; $style = varsettrue($parms['style']) ? ' style="' . eHelper::secureStyleAttr($parms['style']) . '"' : ''; return "<{$h}{$id}{$class}{$style}>" . $code_text . "</{$h}>"; }
public function parsePage() { $tp = e107::getParser(); e107::getBB()->setClass("page"); $this->pageTitles = array(); // Notice removal if (preg_match_all('/\\[newpage.*?\\]/si', $this->pageText, $pt)) { if (substr($this->pageText, 0, 6) == '[html]') { // Need to strip html bbcode from wysiwyg on multi-page docs (handled automatically on single pages) if (substr($this->pageText, -7, 7) == '[/html]') { $this->pageText = substr($this->pageText, 6, -7); } else { $this->pageText = substr($this->pageText, 6); } } $pages = preg_split("/\\[newpage.*?\\]/si", $this->pageText, -1, PREG_SPLIT_NO_EMPTY); $this->multipageFlag = TRUE; } else { // $this->pageToRender = $tp->toHTML($this->pageText, TRUE, 'BODY'); // Remove double parsing - it breaks HTML (inserts <br> as [html] is already removed) $this->pageToRender = $this->pageText; return; } foreach ($pt[0] as $title) { $this->pageTitles[] = $title; } if (!trim($pages[0])) { $count = 0; foreach ($pages as $page) { $pages[$count] = $pages[$count + 1]; $count++; } unset($pages[count($pages) - 1]); } $pageCount = count($pages); $titleCount = count($this->pageTitles); /* if the vars above don't match, page 1 has no [newpage] tag, so we need to create one ... */ if ($pageCount != $titleCount) { array_unshift($this->pageTitles, "[newpage]"); } /* ok, titles now match pages, rename the titles if needed ... */ $count = 0; foreach ($this->pageTitles as $title) { $titlep = preg_replace("/\\[newpage=(.*?)\\]/", "\\1", $title); $this->pageTitles[$count] = $titlep == "[newpage]" ? LAN_PAGE_13 . " " . ($count + 1) : $tp->toHTML($titlep, TRUE, 'TITLE'); $count++; } $this->pageToRender = $tp->toHTML($pages[$this->pageSelected], TRUE, 'BODY'); $this->title = substr($this->pageTitles[$this->pageSelected], -1) == ";" ? "" : $this->pageTitles[$this->pageSelected]; if ($this->debug) { echo "<b>multipageFlag</b> " . $this->multipageFlag . " <br />"; if ($this->multipageFlag) { echo "<pre>"; print_r($pages); echo "</pre>"; echo "<b>pageCount</b> " . $pageCount . " <br />"; echo "<b>titleCount</b> " . $titleCount . " <br />"; echo "<pre>"; print_r($this->pageTitles); echo "</pre>"; } } e107::getBB()->clearClass(); }
<?php /* * e107 website system * * Copyright (C) e107 Inc (e107.org) * Released under the terms and conditions of the * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * * $URL: https://e107.svn.sourceforge.net/svnroot/e107/trunk/e107_0.8/e107_handlers/bbcode_handler.php $ * $Id: bbcode_handler.php 12778 2012-06-02 08:12:16Z e107coders $ */ require_once "../../../../class2.php"; if ($_POST['mode'] == 'tohtml') { $content = $tp->toDB($_POST['content']); e107::getBB()->setClass($_SESSION['media_category']); echo $tp->toHtml($content, true); e107::getBB()->clearClass(); } if ($_POST['mode'] == 'tobbcode') { // echo $_POST['content']; $content = stripslashes($_POST['content']); echo e107::getBB()->htmltoBBcode($content); }
function setNewsFrontMeta($news, $type = 'news') { $tp = e107::getParser(); if ($type == 'news') { if ($news['news_title'] && !defined('e_PAGETITLE')) { define('e_PAGETITLE', $news['news_title']); e107::meta('og:title', $news['news_title']); e107::meta('og:type', 'article'); } if ($news['news_meta_description'] && !defined('META_DESCRIPTION')) { e107::meta('description', $news['news_meta_description']); e107::meta('og:description', $news['news_meta_description']); //define('META_DESCRIPTION', $news['news_meta_description']); // deprecated } elseif ($news['news_summary']) { e107::meta('og:description', $news['news_summary']); } // grab all images in news-body and add to meta. $images = e107::getBB()->getContent('img', $news['news_body'], SITEURL . e_IMAGE . "newspost_images/"); foreach ($images as $im) { e107::meta('og:image', $im); } // grab all youtube videos in news-body and add thumbnails to meta. $youtube = e107::getBB()->getContent('youtube', $news['news_body']); foreach ($youtube as $yt) { list($img, $tmp) = explode("?", $yt); e107::meta('og:image', "http://img.youtube.com/vi/" . $img . "/0.jpg"); } // include news-thumbnail/image in meta. if ($news['news_thumbnail']) { $iurl = substr($news['news_thumbnail'], 0, 3) == "{e_" ? $tp->replaceConstants($news['news_thumbnail'], 'full') : SITEURL . e_IMAGE . "newspost_images/" . $news['news_thumbnail']; $tmp = explode(",", $iurl); foreach ($tmp as $mimg) { if (substr($mimg, -8) == '.youtube') { continue; } e107::meta('og:image', $mimg); } } $url = e107::getUrl()->create('news/view/item', $news, 'full=1'); e107::meta('og:url', $url); e107::meta('article:section', $news['category_name']); if ($news['news_meta_keywords'] && !defined('META_KEYWORDS')) { e107::meta('keywords', $news['news_meta_keywords']); $tmp = explode(",", $news['news_meta_keywords']); foreach ($tmp as $t) { e107::meta('article:tag', trim($t)); } // define('META_KEYWORDS', $news['news_meta_keywords']); // deprecated } /* Facebook reference. * http://developers.facebook.com/docs/opengraph/objects/builtin/ */ return; } if ($news['category_name'] && !defined('e_PAGETITLE')) { define('e_PAGETITLE', $tp->toHtml($news['category_name'], false, 'TITLE_PLAIN')); } if ($news['category_meta_keywords'] && !defined('META_KEYWORDS')) { define('META_KEYWORDS', $news['category_meta_keywords']); } if ($news['category_meta_description'] && !defined('META_DESCRIPTION')) { define('META_DESCRIPTION', $news['category_meta_description']); } }
public function mediaSelect($category = '', $tagid = null, $att = null) { parse_str($att, $option); // grab 'onclick' . $frm = $option['from'] ? $option['from'] : 0; $limit = $option['limit'] ? $option['limit'] : 20; $newfrm = $frm + $limit; $bbcode = $option['bbcode'] ? $option['bbcode'] : null; $navMode = $option['nav'] ? TRUE : FALSE; $search = $option['search'] ? $option['search'] : null; if ($category != '_icon') { $cat = $category ? $category . "+" : ""; // the '+' loads category '_common' as well as the chosen category. $images = $this->getImages($cat, $frm, $limit, $search); $class = "media-select-image"; $w = 120; $h = 100; $total = $this->countImages($cat, $search); } else { $cat = ""; $images = $this->getIcons($cat, 0, 200); $class = "media-select-icon"; $w = 64; $h = 64; $total = 500; // $total = $this->countIcons($cat); //TODO } // $total_images = $this->getImages($cat); // for use by next/prev in filter at some point. $att = 'aw=120&ah=100'; $prevId = $tagid . "_prev"; // EXAMPLE of FILTER GUI. // $text .= "CAT=".$cat; $dipTotal = $frm + $limit < $total ? $frm + $limit : $total; if ($navMode === false) { /* * <div class="input-append"> <input class="span2" id="appendedInputButtons" type="text"> <button class="btn" type="button">Search</button> <button class="btn" type="button">Options</button> </div> */ $text .= "<div style='margin-top:10px'>Filter: <input type='text' id='media-search' title='Enter some text to filter results' name='search' value='' class='e-tip' data-target='media-select-container' data-src='" . $this->mediaSelectNav($category, "tagid=" . $tagid . "&bbcode=" . $bbcode) . "&from=0' />"; // $text .= "<input type='button' value='Go' class='btn btn-primary e-media-nav' data-target='media-select-container' data-src='".$this->mediaSelectNav($category,"tagid=".$tagid."&bbcode=".$bbcode)."&from=0' /> "; // Manual filter, if onkeyup ajax fails for some reason. $text .= "<button type='button' value='Go' class='btn btn-primary e-media-nav' data-target='media-select-container' data-src='" . $this->mediaSelectNav($category, "tagid=" . $tagid . "&bbcode=" . $bbcode) . "&from=0' >Go</button>"; // Manual filter, if onkeyup ajax fails for some reason. $text .= " <button type='button' title='previous page' class='btn button e-nav e-media-nav e-tip' data-target='media-select-container' data-nav-total='" . $total . "' data-nav-dir='down' data-nav-inc='" . $limit . "' data-src='" . $this->mediaSelectNav($category, "tagid=" . $tagid . "&bbcode=" . $bbcode) . "&from=0' >«</button>"; // see next page of images. $text .= "<button type='button' title='next page' class='btn button e-nav e-media-nav e-tip' style='text-align:center' data-target='media-select-container' data-nav-total='" . $total . "' data-nav-dir='up' data-nav-inc='" . $limit . "' data-src='" . $this->mediaSelectNav($category, "tagid=" . $tagid . "&bbcode=" . $bbcode) . "&from=0' >»</button>"; // see next page of images. $text .= "</div>\r\n\t\t\t<div id='media-select-container'>"; } $text .= "\r\n\t\t<div style='text-align:right; display:block'> Displaying " . ($frm + 1) . "-" . $dipTotal . " of " . $total . " images.</div>\n"; if ($bbcode == null) { $onclick_clear = "parent.document.getElementById('{$tagid}').value = '';\r\n\t\t \tparent.document.getElementById('" . $prevId . "').src = '" . e_IMAGE_ABS . "generic/blank.gif';\r\n\t\t \t return false;"; $text .= "<a class='{$class} media-select-none e-dialog-close' data-src='{$im['media_url']}' style='vertical-align:middle;display:block;float:left;' href='#' onclick=\"{$onclick_clear}\" >\r\n\t\t\t<div style='text-align:center;position: relative; top: 30%'>No image</div>\r\n\t\t\t</a>"; } $srch = array("{MEDIA_URL}", "{MEDIA_PATH}"); $w = false; $h = false; if ($bbcode) { e107::getBB()->setClass($category); $w = e107::getBB()->resizeWidth(); // resize the image according to prefs. $h = e107::getBB()->resizeHeight(); e107::getBB()->clearclass(); } $tp = e107::getParser(); // e107::getParser() foreach ($images as $im) { $class = $category != '_icon' ? "media-select-image" : "media-select-icon"; $media_path = $w || $h ? $tp->thumbUrl($im['media_url'], "w={$w}&h={$h}") : $tp->replaceConstants($im['media_url'], 'full'); // max-size $realPath = $tp->thumbUrl($im['media_url'], $att); $diz = $tp->toAttribute($im['media_title']) . "\n" . $im['media_dimensions']; $repl = array($im['media_url'], $media_path); if ($bbcode == null) { $onclicki = "parent.document.getElementById('{$tagid}').value = '{$im['media_url']}';\r\n\t\t \t\tparent.document.getElementById('" . $prevId . "').src = '{$realPath}';\r\n\t\t \t\treturn false;"; //$onclicki = ""; $class .= " e-media-select e-dialog-close"; } else { //TODO Add a preview window $onclicki = "document.getElementById('src').value = '{$im['media_url']}';\r\n\t\t\t\tdocument.getElementById('preview').src = '{$realPath}';\r\n\t\t \t\t\r\n\t\t\t\treturn false;"; //$onclicki = ""; $class .= " e-media-select"; $onclicki = ""; } $data_bb = $bbcode ? "img" : ""; $img_url = $cat != '_icon' ? e107::getParser()->thumbUrl($im['media_url'], $att) : $media_path; $text .= "<a class='{$class} e-tip' data-id='{$im['media_id']}' data-src='{$media_path}' data-bbcode='{$data_bb}' data-target='{$tagid}' data-path='{$im['media_url']}' data-preview='{$realPath}' title=\"" . $diz . "\" style='float:left' href='#' onclick=\"{$onclicki}\" >"; $text .= "<img src='" . $img_url . "' alt=\"" . $im['media_title'] . "\" title=\"{$diz}\" />"; $text .= "</a>\n\n"; } $text .= "<div style='clear:both'><!-- --></div>"; $mes = e107::getMessage(); $mes->addDebug("Target: {$tagid}"); if ($navMode === false) { $text .= "</div>"; } return $text; }
/** * Bbcode Area. Name, value, template, media-Cat, size, options array eg. counter * IMPORTANT: $$mediaCat is also used is the media-manager category identifier * @param $name * @param $value * @param $template * @param $mediaCat _common * @param $size : small | medium | large * @param $options array(); */ function bbarea($name, $value, $template = '', $mediaCat = '_common', $size = 'large', $options = array()) { if (is_string($options)) { parse_str($options, $options); } //size - large|medium|small //width should be explicit set by current admin theme // $size = 'input-large'; switch ($size) { case 'tiny': $rows = '3'; // $height = "style='height:250px'"; // inline required for wysiwyg break; case 'small': $rows = '7'; $height = "style='height:230px'"; // inline required for wysiwyg $size = "input-block-level"; break; case 'medium': $rows = '10'; $height = "style='height:375px'"; // inline required for wysiwyg $size = "input-block-level"; break; case 'large': default: $rows = '15'; $size = 'large input-block-level'; // $height = "style='height:500px;width:1025px'"; // inline required for wysiwyg break; } // auto-height support $options['class'] = 'tbox bbarea ' . ($size ? ' ' . $size : '') . ' e-wysiwyg e-autoheight form-control'; $bbbar = ''; $help_tagid = $this->name2id($name) . "--preview"; if (e107::wysiwyg(true) === false) { $options['other'] = "onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);' {$height}"; } else { $options['other'] = " " . $height; } $counter = vartrue($options['counter'], false); $ret = "<div class='bbarea {$size}'>\r\n\t\t<div class='field-spacer'><!-- --></div>\n"; $ret .= e107::getBB()->renderButtons($template, $help_tagid); $ret .= $this->textarea($name, $value, $rows, 70, $options, $counter); // higher thank 70 will break some layouts. $ret .= "</div>\n"; $_SESSION['media_category'] = $mediaCat; // used by TinyMce. return $ret; // Quick fix - hide TinyMCE links if not installed, dups are handled by JS handler /* e107::getJs()->footerInline(" if(typeof tinyMCE === 'undefined') { \$$('a.e-wysiwyg-switch').invoke('hide'); } "); */ }
public function mediaSelect($category = '', $tagid = null, $att = null) { if (is_string($att)) { parse_str($att, $option); // grab 'onclick' . } else { $option = $att; } $frm = varset($option['from']) ? $option['from'] : 0; $limit = varset($option['limit']) ? $option['limit'] : 20; $newfrm = $frm + $limit; $bbcode = varset($option['bbcode']) ? $option['bbcode'] : null; $navMode = varset($option['nav']) ? TRUE : FALSE; $search = varset($option['search']) ? $option['search'] : null; if ($category != '_icon') { $cat = $category ? $category . "+" : ""; // the '+' loads category '_common' as well as the chosen category. $images = $this->getImages($cat, $frm, $limit, $search); $class = "media-select-image"; $w = 120; $h = 100; $total = $this->countImages($cat, $search); } else { $cat = ""; $images = $this->getIcons($cat, 0, 200); $class = "media-select-icon"; $w = 64; $h = 64; $total = 500; $total = $this->countImages("_icon_16|_icon_32|_icon_48|_icon_64", $search); // $total = $this->countIcons($cat); //TODO } // $total_images = $this->getImages($cat); // for use by next/prev in filter at some point. $prevAtt = '&aw=' . vartrue($option['w'], $w); // .'&ah=100'; // Image Parsed back to Form as PREVIEW image. $prevId = $tagid . "_prev"; // ID of image in Form. $thumbAtt = 'aw=120&ah=120'; // Thumbnail of the Media-Manager Preview. // EXAMPLE of FILTER GUI. $text = ""; $dipTotal = $frm + $limit < $total ? $frm + $limit : $total; if ($navMode === false) { // $data_src = $this->mediaSelectNav($category,$tagid, "bbcode=".$bbcode)."&from=0"; $data_src = $this->mediaSelectNav($category, $tagid, $option); // ."&from=0"; // Inline style to override jquery-ui stuff. $text .= "<div>\r\n\t\t\t<div id='admin-ui-media-manager-search' class='input-append form-inline' style='margin-top:10px;font-size:12px'>\r\n\t\t\t<input type='text' id='media-search' placeholder='Search...' name='search' value='' class='e-tip' data-target='media-select-container' data-src='" . $data_src . "' />\r\n\t\t\t"; // $text .= "<input type='button' value='Go' class='btn btn-primary e-media-nav' data-target='media-select-container' data-src='".$this->mediaSelectNav($category,"tagid=".$tagid."&bbcode=".$bbcode)."&from=0' /> "; // Manual filter, if onkeyup ajax fails for some reason. $text .= "<button type='button' class='btn btn-primary e-media-nav' data-target='media-select-container' data-src='" . $data_src . "' >Go</button>"; // Manual filter, if onkeyup ajax fails for some reason. $text .= "<button id='admin-ui-media-nav-down' type='button' title='previous page' class='btn btn-default e-nav e-media-nav e-tip' style='outline:0' data-target='media-select-container' data-nav-total='" . $total . "' data-nav-dir='down' data-nav-inc='" . $limit . "' data-src='" . $data_src . "'>«</button>"; // see next page of images. $text .= "<button id='admin-ui-media-nav-up' type='button' title='next page' class='btn btn-default e-nav e-media-nav e-tip' style='outline:0;text-align:center' data-target='media-select-container' data-nav-total='" . $total . "' data-nav-dir='up' data-nav-inc='" . $limit . "' data-src='" . $data_src . "' >»</button>"; // see next page of images. $text .= "</div></div>"; $text .= "<div id='admin-ui-media-select-count' class='media-select-count' style='text-align:right; display:block'> Displaying " . ($frm + 1) . "-" . $dipTotal . " of " . $total . " images.</div>\n"; $text .= "\r\n\t\t\t<div id='media-select-container'>"; } $text .= "<div id='admin-ui-media-select-count-hidden' class='media-select-count' data-media-select-current-limit='" . $dipTotal . "' style='text-align:right; display:none'> Displaying " . ($frm + 1) . "-" . $dipTotal . " of " . $total . " images.</div>\n"; if ($bbcode == null) { $onclick_clear = "parent.document.getElementById('{$tagid}').value = '';\r\n\t\t \tparent.document.getElementById('" . $prevId . "').src = '" . e_IMAGE_ABS . "generic/blank.gif';\r\n\t\t \t return false;"; $text .= "<a class='thumbnail {$class} media-select-none e-dialog-close' data-src='" . varset($im['media_url']) . "' style='vertical-align:middle;display:block;float:left;' href='#' onclick=\"{$onclick_clear}\" >\r\n\t\t\t<div style='text-align:center;position: relative; top: 30%'>No image</div>\r\n\t\t\t</a>"; } $srch = array("{MEDIA_URL}", "{MEDIA_PATH}"); $w = false; // $h = false; $defaultResizeWidth = 400; if ($bbcode) { e107::getBB()->setClass($category); $defaultResizeWidth = e107::getBB()->resizeWidth(); // resize the image according to prefs. $h = e107::getBB()->resizeHeight(); e107::getBB()->clearclass(); } // print_a($option); $tp = e107::getParser(); /* $media_path : Inserted into html tags eg. <img src='here'... */ // print_a($images); // return; foreach ($images as $im) { list($dbWidth, $dbHeight) = explode(" x ", $im['media_dimensions']); $w = $dbWidth > $defaultResizeWidth ? $defaultResizeWidth : intval($dbWidth); // $w = vartrue($w,0); // $h = vartrue($w,0); $class = $category != '_icon' ? "media-select-image" : "media-select-icon"; $media_path = $w || $h ? $tp->thumbUrl($im['media_url'], "&w={$w}") : $tp->thumbUrl($im['media_url']); // $tp->replaceConstants($im['media_url'],'full'); // max-size $realPath = $tp->thumbUrl($im['media_url'], $prevAtt); // Parsed back to Form as Preview Image. $diz = $tp->toAttribute(varset($im['media_name'])) . " (" . str_replace(" ", "", varset($im['media_dimensions'])) . ")"; $repl = array($im['media_url'], $media_path); $media_alt = $tp->toAttribute(vartrue($im['media_caption'])); if ($bbcode == null) { $onclicki = "parent.document.getElementById('{$tagid}').value = '{$im['media_url']}';\r\n\t\t\t\tparent.document.getElementById('" . $prevId . "').src = '{$realPath}';\r\n\t\t\t\treturn false;"; //$onclicki = ""; $class .= " e-media-select e-dialog-close"; } else { //TODO Add a preview window $onclicki = "document.getElementById('src').value = '{$im['media_url']}';\r\n\t\t\t\tdocument.getElementById('preview').src = '{$realPath}';\r\n\t\t \t\t\r\n\t\t\t\treturn false;"; //$onclicki = ""; $class .= " e-media-select"; $onclicki = ""; } $data_bb = $bbcode ? "img" : ""; $img_url = $cat != '_icon' ? e107::getParser()->thumbUrl($im['media_url'], $thumbAtt) : $media_path; $text .= "<a data-toggle='context' class='thumbnail {$class} e-tip' data-id='{$im['media_id']}' data-width='{$w}' data-height='{$h}' data-src='{$media_path}' data-bbcode='{$data_bb}' data-target='{$tagid}' data-path='{$im['media_url']}' data-preview='{$realPath}' data-alt=\"" . $media_alt . "\" title=\"" . $diz . "\" style='float:left' href='#' onclick=\"{$onclicki}\" >"; $text .= "<img class='image-rounded' src='" . $img_url . "' alt=\"" . $im['media_title'] . "\" title=\"{$diz}\" />"; $text .= "</a>\n\n"; } $text .= "<div style='clear:both'><!-- --></div>"; //fixing tip icon when navigation prev/next page $text .= "<script>"; $text .= "\$(document).ready(function(){\r\n\t\t\t\t\t\t\$('.e-tip').each(function() {\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tvar tip = \$(this).attr('title');\r\n\t\t\t\t\t\t\tif(!tip)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\treturn;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tvar pos = \$(this).attr('data-placement'); \r\n\t\t\t\t\t\t\tif(!pos)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tpos = 'top';\t\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\$(this).tooltip({opacity:1.0,fade:true, placement: pos});\r\n\r\n\t\t\t\t\t\t});\t\r\n\t\t\t\t\t});\t\t\t\r\n\t\t"; $text .= "</script>"; $mes = e107::getMessage(); $mes->addDebug("Target: {$tagid}"); if ($navMode === false) { $text .= "</div>"; } return $text; }
function toBBcode($content) { // echo $_POST['content']; global $pref, $tp; $content = stripslashes($content); if (check_class($pref['post_html'])) { $srch = array('src="' . e_HTTP . 'thumb.php?', 'src="/{e_MEDIA_IMAGE}'); $repl = array('src="{e_BASE}thumb.php?', 'src="{e_BASE}thumb.php?src=e_MEDIA_IMAGE/'); $content = str_replace($srch, $repl, $content); // resize the thumbnail to match wysiwyg width/height. // $psrch = '/<img[^>]*src="{e_BASE}thumb.php\?src=([\S]*)w=([\d]*)&h=([\d]*)"(.*)width="([\d]*)" height="([\d]*)"/i'; // $prepl = '<img src="{e_BASE}thumb.php?src=$1w=$5&h=$6"$4width="$5" height="$6" '; // $content = preg_replace($psrch, $prepl, $content); $content = $this->updateImg($content); $content = $tp->parseBBTags($content, true); // replace html with bbcode equivalent if (strip_tags($content, '<i>') == ' ') { exit; } $text = $content ? "[html]" . $content . "[/html]" : ""; // Add the tags before saving to DB. } else { // [img width=400]/e107_2.0/thumb.php?src={e_MEDIA_IMAGE}2012-12/e107org_white_stripe.png&w=400&h=0[/img] // $content = str_replace("{e_BASE}","", $content); // We want {e_BASE} in the final data going to the DB, but not the editor. $text = e107::getBB()->htmltoBBcode($content); // not reliable enough yet. } return $text; }
/** * Translate youtube bbcode into the appropriate <EMBED> object */ function toHTML($code_text, $parm) { if (empty($code_text)) { return ''; } list($dimensions, $tmp) = explode('|', $parm, 2); if ($tmp) { parse_str(varset($tmp, ''), $bbparm); } if (strpos($code_text, "&") !== FALSE && strpos($code_text, "?") === FALSE) { $parms = explode('&', $code_text, 2); } else { $parms = explode('?', $code_text, 2); // CORRECT SEPARATOR } $code_text = $parms[0]; parse_str(varset($parms[1], ''), $params); // print_a($params); if (empty($dimensions)) { $dimensions = 'medium'; } // (default as per YouTube spec) // formula: width x (height+25px) switch ($dimensions) { case 'tiny': $params['w'] = 320; // 200; $params['h'] = 205; // 180; break; case 'small': $params['w'] = 560; // 445; $params['h'] = 340; // 364; break; case 'medium': $params['w'] = 640; // 500; $params['h'] = 385; // 405; break; case 'big': case 'large': $params['w'] = 853; // 660; $params['h'] = 505; // 525; break; case 'huge': $params['w'] = 1280; // 980; $params['h'] = 745; // 765; break; default: // maximum 1920 x 1080 (+25) $dim = explode(',', $dimensions, 2); $params['w'] = (int) varset($dim[0], 445); if ($params['w'] > 1920 || $params['w'] < 100) { $params['w'] = 640; } $params['h'] = (int) varset($dim[1], 364); if ($params['h'] > 1105 || $params['h'] < 67) { $params['h'] = 385; } break; } $yID = preg_replace('/[^0-9a-z\\-_\\&\\?]/i', '', $code_text); $url = isset($bbparm['privacy']) ? 'https://www.youtube-nocookie.com/v/' : 'https://www.youtube.com/v/'; $url .= $yID . '?'; if (isset($params['nofull']) || !varset($params['fs'])) { $fscr = 'false'; $url = $url . 'fs=' . intval($params['fs']); } else { $fscr = 'true'; $url = $url . 'fs=1'; } if (isset($params['border'])) { $url = $url . '&border=' . intval($params['border']); } if (isset($params['norel'])) { $url = $url . '&rel=0'; } elseif (isset($params['rel'])) { $url = $url . '&rel=' . intval($params['rel']); } if (isset($params['hd'])) { $url = $url . '&hd=' . intval($params['hd']); } $hl = 'en_US'; if (isset($params['hl'])) { $params['hl'] = preg_replace('/[^0-9a-z\\-_]/i', '', $params['hl']); if (strlen($params['hl']) == 2 || strlen($params['hl']) == 5) { $hl = $params['hl']; } } $url = $url . '&hl=' . $hl; $color = array(); if (isset($params['color1'])) { $color[1] = $params['color1']; } if (isset($params['color2'])) { $color[2] = $params['color2']; } foreach ($color as $key => $value) { if (ctype_xdigit($value) && strlen($value) == 6) { $url = $url . '&color' . $key . '=' . $value; } } if (isset($params['cc_load_policy'])) { $url .= "&cc_load_policy=" . intval($params['cc_load_policy']); } if (isset($params['autoplay'])) { $url .= "&autoplay=" . intval($params['autoplay']); } $class = "bbcode " . e107::getBB()->getClass('youtube'); // consistent classes across all themes. $ret = "<!-- Start YouTube-" . $dimensions . "-" . $yID . " -->\n"; // <-- DO NOT MODIFY - used for detection by bbcode handler. if (e107::getConfig()->get('youtube_bbcode_responsive') == 1) { $ret .= e107::getParser()->toVideo($yID . ".youtube"); } else { $ret .= '<object class="' . $class . '" width="' . $params['w'] . '" height="' . $params['h'] . '" > <param name="movie" value="' . $url . '" /> <param name="allowFullScreen" value="' . $fscr . '" /> <param name="allowscriptaccess" value="always" /> <param name="wmode" value="transparent" /> '; // Not XHTML - but needed for compatibility. $ret .= '<embed class="' . $class . '" src="' . $url . '" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="' . $fscr . '" wmode="transparent" width="' . $params['w'] . '" height="' . $params['h'] . '" />'; $ret .= '</object>'; } $ret .= "<!-- End YouTube -->"; // <-- DO NOT MODIFY. return $ret; }
function toHTML($code_text, $parm) { $tp = e107::getParser(); $pref = e107::getPref(); $class = e107::getBB()->getClass('img'); if (trim($code_text) == "") { return ""; } // Do nothing on empty file if (preg_match("#\\.php\\?.*#", $code_text)) { return ""; } $addlink = FALSE; // Automatic Img Resizing -- $w = e107::getBB()->resizeWidth(); // varies depending on the class set by external script. see admin->media-manager->prefs $h = e107::getBB()->resizeHeight(); if (strpos($code_text, "://") == false && ($w || $h)) { $code_text = $tp->thumbUrl($code_text, 'w=' . $w . '&h=' . $h); } // ------------------------ $search = array('"', '{E_IMAGE}', '{E_FILE}', '{e_IMAGE}', '{e_FILE}'); $replace = array(''', e_IMAGE_ABS, e_FILE_ABS, e_IMAGE_ABS, e_FILE_ABS); $replaceInt = array(''', e_IMAGE, e_FILE, e_IMAGE, e_FILE); $intName = str_replace($search, $replaceInt, $code_text); // Server-relative file names unset($imgParms); $imgParms['class'] = "bbcode {$class}"; // This will be overridden if a new class is specified $imgParms['alt'] = ''; $code_text = str_replace($search, $replace, $code_text); $code_text = $tp->toAttribute($code_text); $img_file = pathinfo($code_text); // 'External' file name. N.B. - might still contain a constant such as e_IMAGE if ($parm) { $parm = preg_replace('#onerror *=#i', '', $parm); $parm = str_replace("amp;", "&", $parm); parse_str($parm, $tmp); foreach ($tmp as $p => $v) { $imgParms[$p] = $v; } } $parmStr = ""; foreach ($imgParms as $k => $v) { $parmStr .= $tp->toAttribute($k) . "='" . $tp->toAttribute($v) . "' "; } // Select a random file if required if (strpos($img_file['basename'], '*') !== FALSE) { $fileList = array(); $intFile = pathinfo($intName); // N.B. - might still contain a constant such as e_IMAGE $matchString = '#' . str_replace('*', '.*?', $intFile['basename']) . '#'; $dirName = $tp->replaceConstants($intFile['dirname'] . '/'); // we want server-relative directory if (($h = opendir($dirName)) !== FALSE) { while (($f = readdir($h)) !== FALSE) { if (preg_match($matchString, $f)) { $fileList[] = $f; // Just need to note file names } } closedir($h); } else { echo "Error opening directory: {$dirName}<br />"; return ''; } if (count($fileList)) { $img_file['basename'] = $fileList[mt_rand(0, count($fileList) - 1)]; // Just change name of displayed file - no change on directory $code_text = $img_file['dirname'] . "/" . $img_file['basename']; } else { echo 'No file: ' . $code_text; return ''; } } // Check for whether we can display image down here - so we can show image name if appropriate if (!varsettrue($pref['image_post']) || !check_class($pref['image_post_class'])) { switch ($pref['image_post_disabled_method']) { case '1': return CORE_LAN17; case '2': return ''; } return CORE_LAN18 . $code_text; } // Check for link to main image if required if (strpos($img_file['basename'], 'th_') === 0) { $addlink = TRUE; $main_name = $img_file['dirname'] . "/" . substr($img_file['basename'], 3); // delete the 'th' prefix from file name } elseif (strpos($img_file['basename'], 'thumb_') === 0) { $addlink = TRUE; $main_name = $img_file['dirname'] . "/" . substr($img_file['basename'], 6); // delete the 'thumb' prefix from file name } if ($addlink) { return "<a href='" . $main_name . "' rel='external'><img src='" . $code_text . "' {$parmStr} /></a>"; } else { return "<img src='" . $code_text . "' {$parmStr} />"; } }
function toHTML($code_text, $parm) { $tp = e107::getParser(); $pref = e107::getPref(); if (trim($code_text) == "") { return ""; } // Do nothing on empty file if (substr($code_text, 0, 15) == '{e_MEDIA_IMAGE}' || substr($code_text, 0, 9) == '{e_MEDIA}' || substr($code_text, 0, 9) == '{e_THEME}') { return $this->mediaImage($code_text, $parm); } if (preg_match("#\\.php\\?.*#", $code_text)) { return ""; } //XXX Breaks MediaManager Images, so do it after mediaManager check. $addlink = FALSE; // Automatic Img Resizing -- $w = e107::getBB()->resizeWidth(); // varies depending on the class set by external script. see admin->media-manager->prefs $h = e107::getBB()->resizeHeight(); // No resizing on v1.x legacy images. if (strpos($code_text, "://") == false && ($w || $h) && strpos($code_text, "{e_IMAGE}custom") === false && strpos($code_text, "newspost_images/") === false) { $code_text = $tp->thumbUrl($code_text, 'w=' . $w . '&h=' . $h); } // ------------------------ $search = array('"', '{E_IMAGE}', '{E_FILE}', '{e_IMAGE}', '{e_FILE}'); $replace = array(''', e_IMAGE_ABS, e_FILE_ABS, e_IMAGE_ABS, e_FILE_ABS); $replaceInt = array(''', e_IMAGE, e_FILE, e_IMAGE, e_FILE); $intName = str_replace($search, $replaceInt, $code_text); // Server-relative file names $code_text = str_replace($search, $replace, $code_text); $code_text = $tp->toAttribute($code_text); $img_file = pathinfo($code_text); // 'External' file name. N.B. - might still contain a constant such as e_IMAGE $parmStr = $this->processParm($code_text, $parm, 'string'); // Select a random file if required if (strpos($img_file['basename'], '*') !== FALSE) { $fileList = array(); $intFile = pathinfo($intName); // N.B. - might still contain a constant such as e_IMAGE $matchString = '#' . str_replace('*', '.*?', $intFile['basename']) . '#'; $dirName = $tp->replaceConstants($intFile['dirname'] . '/'); // we want server-relative directory if (($h = opendir($dirName)) !== FALSE) { while (($f = readdir($h)) !== FALSE) { if (preg_match($matchString, $f)) { $fileList[] = $f; // Just need to note file names } } closedir($h); } else { echo "Error opening directory: {$dirName}<br />"; return ''; } if (count($fileList)) { $img_file['basename'] = $fileList[mt_rand(0, count($fileList) - 1)]; // Just change name of displayed file - no change on directory $code_text = $img_file['dirname'] . "/" . $img_file['basename']; } else { echo 'No file: ' . $code_text; return ''; } } // Check for whether we can display image down here - so we can show image name if appropriate if (!vartrue($pref['image_post']) || !check_class($pref['image_post_class'])) { switch ($pref['image_post_disabled_method']) { case '1': return CORE_LAN17; case '2': return ''; } return CORE_LAN18 . $code_text; } // Check for link to main image if required if (strpos($img_file['basename'], 'th_') === 0) { $addlink = TRUE; $main_name = $img_file['dirname'] . "/" . substr($img_file['basename'], 3); // delete the 'th' prefix from file name } elseif (strpos($img_file['basename'], 'thumb_') === 0) { $addlink = TRUE; $main_name = $img_file['dirname'] . "/" . substr($img_file['basename'], 6); // delete the 'thumb' prefix from file name } if ($addlink) { return "<a href='" . $main_name . "' rel='external'><img src='" . $code_text . "' {$parmStr} /></a>"; } else { return "<img src='" . $code_text . "' {$parmStr} />"; } }