1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-30 19:30:25 +02:00

Fix for media-browser carousel issue. Fix for bbcode Youtube insert. Added [video] bbcode.

This commit is contained in:
Cameron
2014-01-23 15:56:53 -08:00
parent 7bb19a0a40
commit d2d58451cf
11 changed files with 185 additions and 80 deletions

View File

@@ -456,15 +456,17 @@ e107::getJs()->renderJs('header', 4);
e107::getJs()->renderJs('header_inline', 4);
// ---------- Favicon ---------
if (file_exists(THEME."favicon.ico"))
$sitetheme = e107::getPref('sitetheme');
if (file_exists(e_THEME.$sitetheme."/favicon.ico"))
{
echo "<link rel='icon' href='".THEME_ABS."favicon.ico' type='image/x-icon' />\n<link rel='shortcut icon' href='".THEME_ABS."favicon.ico' type='image/xicon' />\n";
echo "<link rel='icon' href='".e_THEME_ABS.$sitetheme."/favicon.ico' type='image/x-icon' />\n<link rel='shortcut icon' href='".e_THEME_ABS.$sitetheme."/favicon.ico' type='image/xicon' />\n";
}
elseif (file_exists(e_BASE."favicon.ico"))
{
echo "<link rel='icon' href='".SITEURL."favicon.ico' type='image/x-icon' />\n<link rel='shortcut icon' href='".SITEURL."favicon.ico' type='image/xicon' />\n";
}
unset($sitetheme);
//
// G: Send Theme Headers
//

View File

@@ -1010,7 +1010,7 @@ class media_admin_ui extends e_admin_ui
function mediaSelectUpload($type='image')
{
$frm = e107::getForm();
$videoActive = 'inactive';
$options = array();
$options['bbcode'] = ($this->getQuery('bbcode')=='img') ? 'img' : FALSE;
@@ -1018,13 +1018,17 @@ class media_admin_ui extends e_admin_ui
$text = "<ul class='nav nav-tabs'>\n";
$text .= "<li class='active'><a data-toggle='tab' href='#core-media-select'>Choose from Library</a></li>\n";
if($this->getQuery('bbcode') != 'video')
{
$text .= "<li class='active'><a data-toggle='tab' href='#core-media-select'>Choose from Library</a></li>\n";
}
else
{
$videoActive = 'active';
}
if($this->getQuery('bbcode') != 'video' && $this->getQuery('bbcode') !='glyph')
{
$text .= "<li><a data-toggle='tab' href='#core-media-upload'>Upload a File</a></li>";
}
@@ -1040,7 +1044,7 @@ class media_admin_ui extends e_admin_ui
if($this->getQuery('video') == 1 || $this->getQuery('bbcode') == 'video')
{
$text .= "<li><a data-toggle='tab' href='#core-media-video'>Youtube</a></li>\n";
$text .= "<li class='{$videoActive}'><a data-toggle='tab' href='#core-media-video'>Youtube</a></li>\n";
}
@@ -1054,36 +1058,20 @@ class media_admin_ui extends e_admin_ui
$text .= "
</ul>
<div class='tab-content'>
<div class='tab-pane active' id='core-media-select'>
<div class='tab-content'>";
<div class='table' style='display:block'>
";
if($this->getQuery('bbcode') != 'video')
{
$text .= "<div class='tab-pane active' id='core-media-select'>
<div class='table' style='display:block'>";
$text .= $this->imageTab($type,$options);
$text .= "</div></div>";
}
$tag = ($options['bbcode']) ? "" : $this->getQuery('tagid');
if(varset($_GET['w']))
{
$options['w'] = intval($_GET['w']);
}
if($type == 'file')
{
$this->perPage = 0;
$this->getTreeModel()->setParam('db_query', $this->_modifyListQry(false, false, false, false, $this->listQry))->load();
$text .= $this->getUI()->getList();
}
else
{
$text .= e107::getMedia()->mediaSelect($this->getQuery('for'),$this->getQuery('tagid'), $options); // eg. news, news-thumbnail
}
$text .= "
</div>
</div>
<div class='tab-pane' id='core-media-upload'>
$text .= "<div class='tab-pane' id='core-media-upload'>
";
$this->fields['media_category']['readonly'] = TRUE;
@@ -1175,7 +1163,7 @@ class media_admin_ui extends e_admin_ui
if($this->getQuery('video') || $this->getQuery('bbcode') == 'video')
{
$text .= "<div class='tab-pane clearfix' id='core-media-video' >";
$text .= "<div class='tab-pane clearfix {$videoActive}' id='core-media-video' >";
// $text .= "<div class='row-fluid'>";
$text .= $this->videoTab();
$text .= "</div>";
@@ -1219,6 +1207,36 @@ class media_admin_ui extends e_admin_ui
return $text;
}
function imageTab($type,$options)
{
$tag = ($options['bbcode']) ? "" : $this->getQuery('tagid');
if(varset($_GET['w']))
{
$options['w'] = intval($_GET['w']);
}
if($type == 'file')
{
$this->perPage = 0;
$this->getTreeModel()->setParam('db_query', $this->_modifyListQry(false, false, false, false, $this->listQry))->load();
$text = $this->getUI()->getList();
}
else
{
$text = e107::getMedia()->mediaSelect($this->getQuery('for'),$this->getQuery('tagid'), $options); // eg. news, news-thumbnail
}
return $text;
}
function glyphTab($parm='')
@@ -1327,7 +1345,7 @@ class media_admin_ui extends e_admin_ui
);
}
$parms = array('width' => 200, 'height'=>113, 'type'=>'image', 'tagid'=> $this->getQuery('tagid'), 'action'=>'youtube','searchPlaceholder'=>'Search Youtube');
$parms = array('width' => 200, 'height'=>113, 'type'=>'image', 'bbcode'=>'video', 'tagid'=> $this->getQuery('tagid'), 'action'=>'youtube','searchPlaceholder'=>'Search Youtube');
$text = e107::getMedia()->browserCarousel($items, $parms);

View File

@@ -0,0 +1,41 @@
<?php
/**
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
*
* DIV block bbcode
*/
if (!defined('e107_INIT')) { exit; }
// This is a generic and 'responsive' video bbcode. Handles Youtube and eventually html5 video tags.
class bb_video extends e_bb_base
{
/**
* Called prior to save
* Re-assemble the bbcode
*/
function toDB($code_text, $parm)
{
return '[video]'.$code_text.'[/video]';
}
/**
* Video tag.
* @param $code_text : xxxxxxx.youtube or xxxxxxx.mp4
*/
function toHTML($code_text, $parm='')
{
return e107::getParser()->toVideo($code_text);
}
}
?>

View File

@@ -124,11 +124,22 @@ class bbcode_shortcodes extends e_shortcode
function bb_youtube($id)
{
if($this->var['tagid'] == 'data_') // BC work-around for duplicate IDs.
{
$tag = "data";
}
else
{
list($tag,$tmp) = explode("--",$this->var['tagid']); // works with $frm->bbarea to detect textarea from first half of tag.
}
$data = "[youtube]*[/youtube]";
$event = $this->getEvent('addinput',$data,LANHELP_48);
$text = "<a {$event} class='btn ' id='{$id}' data-function='input' href='#{$this->var['tagid']}' title='".$this->br2nl(LANHELP_48)."' data-bbcode='{$data}'>";
// $text = "<a {$event} class='btn ' id='{$id}' data-function='input' href='#{$this->var['tagid']}' title='".$this->br2nl(LANHELP_48)."' data-bbcode='{$data}'>";
// $text .="<img class='btn btn-small bbcode bbcode_buttons e-pointer' src='".e_IMAGE_ABS."bbcode/youtube.png' alt='' title='".nl2br(LANHELP_48)."' />";
$text = "<a class='e-modal btn' data-modal-caption='Media Manager' data-target='#uiModal' title='Media Manager : ".$this->var['template']."' id='{$id}' href='".e_ADMIN."image.php?mode=main&action=dialog&for=".$this->var['template']."&tagid=".$tag."&iframe=1&bbcode=video' >";
$text .= $this->button(e_IMAGE_ABS."bbcode/youtube.png", 'youtube', LANHELP_48);
$text .= "</a>";

View File

@@ -29,10 +29,17 @@ class news_shortcodes extends e_shortcode
protected $e107;
//protected $param; - shouldn't be set - see __set/__get methods of e_shortcode & news::render_newsitem()
protected $commentsDisabled;
function __construct($eVars = null)
{
parent::__construct($eVars);
$this->e107 = e107::getInstance();
$pref = e107::getPref();
$this->commentsDisabled = vartrue($pref['comments_disabled']);
}
function sc_newstitle()
@@ -88,11 +95,11 @@ class news_shortcodes extends e_shortcode
$pref = e107::getPref();
$sql = e107::getDb();
if($pref['comments_disabled'] == 1)
if($this->commentsDisabled)
{
return "Disabled";
return;
}
$news_item = $this->news_item;
$param = $this->param;
@@ -192,6 +199,10 @@ class news_shortcodes extends e_shortcode
*/
function sc_newscommentlink($parm)
{
if($this->commentsDisabled)
{
return;
}
$class = varset($parm['class']) ? " ".$parm['class'] : "";
$text = ($this->news_item['news_allow_comments'] ? $this->param['commentoffstring'] : "<a title='".$this->sc_newscommentcount()." comments' class='e-tip".$class."' href='".e107::getUrl()->create('news/view/item', $this->news_item)."'>".$this->param['commentlink'].'</a>');
@@ -203,6 +214,11 @@ class news_shortcodes extends e_shortcode
*/
function sc_newscommentcount($parm)
{
if($this->commentsDisabled)
{
return;
}
$text = varset($parm['glyph']) ? e107::getParser()->toGlyph($parm['glyph']) : "";
$text .= $this->news_item['news_comment_total'];
return $text;

View File

@@ -42,9 +42,9 @@ class e_bbcode
'html', 'flash', 'link', 'email',
'url', 'quote', 'left', 'right',
'b', 'justify', 'file', 'stream',
'textarea', 'list', 'php', 'time',
'textarea', 'list', 'time',
'spoiler', 'hide', 'youtube', 'sanitised',
'p', 'h', 'nobr', 'block','table','th', 'tr','tbody','td','markdown'
'p', 'h', 'nobr', 'block','table','th', 'tr','tbody','td','markdown','video'
);
foreach($this->core_bb as $c)

View File

@@ -696,6 +696,7 @@ class e_form
*/
function userpicker($name_fld, $id_fld, $default_name, $default_id, $options = array())
{
$tp = e107::getParser();
if(!is_array($options)) parse_str($options, $options);
$default_name = vartrue($default_name, '');
@@ -706,11 +707,13 @@ class e_form
$fldid = $this->name2id($name_fld);
$hidden_fldid = $this->name2id($id_fld);
$ret = $this->text($name_fld,$default_name,20, "class=e-tip&title=Type name of user&typeahead=users&readonly=".vartrue($options['readonly']))
.$this->hidden($id_fld,$default_id, array('id' => $this->name2id($id_fld)))." id# <span id='{$fldid}-id'>".$default_id.'</span>';
$ret .= " <a href='#' id='{$fldid}-reset'>reset</a>";
$ret = '<div class="input-append">';
$ret .= $this->text($name_fld,$default_name,20, "class=e-tip&title=Type name of user&typeahead=users&readonly=".vartrue($options['readonly']))
.$this->hidden($id_fld,$default_id, array('id' => $this->name2id($id_fld)))."<span class='add-on'>".$tp->toGlyph('fa-user')." <span id='{$fldid}-id'>".$default_id.'</span></span>';
$ret .= "<a class='btn btn-inverse' href='#' id='{$fldid}-reset'>reset</a>
</div>";
e107::getJs()->footerInline("
e107::js('footer-inline', "
\$('#{$fldid}').blur(function () {
\$('#{$fldid}-id').html(\$('#{$hidden_fldid}').val());
});
@@ -718,6 +721,7 @@ class e_form
\$('#{$fldid}-id').html('0');
\$('#{$hidden_fldid}').val(0);
\$('#{$fldid}').val('');
return false;
});
");
@@ -3240,7 +3244,7 @@ class e_form
if(!isset($parms['__options'])) $parms['__options'] = array();
if(!is_array($parms['__options'])) parse_str($parms['__options'], $parms['__options']);
if((empty($value) && vartrue($parms['currentInit'])) || vartrue($parms['current']))
if((empty($value) && varset($parms['currentInit'],USERID)!==0) || vartrue($parms['current'])) // include current user by default.
{
$value = USERID;
if(vartrue($parms['current']))

View File

@@ -1025,7 +1025,8 @@ class e_media
'previewUrl' => $defaultThumb ,
'thumbUrl' => $defaultThumb,
'title' => '',
'gridClass' => 'span2'
'gridClass' => 'span2',
'bbcode' => ''
);
@@ -1044,7 +1045,7 @@ class e_media
<div class='well clearfix'>
<a data-toggle='context' class='e-media-select ".$close." e-tip' data-id='".$data['id']."' data-width='".$data['width']."' data-height='".$data['height']."' data-src='".$data['previewUrl']."' data-type='".$data['type']."' data-bbcode='{$bbcode}' data-target='".$data['tagid']."' data-path='".$data['saveValue']."' data-preview='".$data['previewUrl']."' title=\"".$data['title']."\" style='float:left' href='#' >";
<a data-toggle='context' class='e-media-select ".$close." e-tip' data-id='".$data['id']."' data-width='".$data['width']."' data-height='".$data['height']."' data-src='".$data['previewUrl']."' data-type='".$data['type']."' data-bbcode='".$data['bbcode']."' data-target='".$data['tagid']."' data-path='".$data['saveValue']."' data-preview='".$data['previewUrl']."' title=\"".$data['title']."\" style='float:left' href='#' >";
if($data['type'] == 'image')
{
@@ -1175,6 +1176,7 @@ class e_media
$val['id'] = $parm['id'];
$val['tagid'] = $parm['tagid'];
$val['type'] = $parm['type'];
$val['bbcode'] = $parm['bbcode'];
$val['gridClass'] = $parm['gridClass'];
$text .= $this->browserCarouselItem($val);
@@ -1208,10 +1210,12 @@ class e_media
$text .= ($c != 0) ? "</div>\n<!-- End Slide -->\n" : "";
$text .= "\n<!-- End Carousel -->\n<div class='clearfix'>&nbsp;</div>\n\n";
$text .= "</div>";
$text .= "\n<!-- End Carousel -->\n<div class='clearfix'>&nbsp;</div>\n\n";
if(!e_AJAX_REQUEST)
{
$text .= "</div></div>";

View File

@@ -72,10 +72,10 @@ class social_shortcodes extends e_shortcode
$tp = e107::getParser();
$url = varset($parm['url'], e_REQUEST_URL);
$title = varset($parm['title'], deftrue('e_PAGETITLE'));
$title = varset($parm['title'], deftrue('e_PAGETITLE'). " | ". SITENAME ) ;
$description = varset($parm['title'], e107::getUrl()->response()->getMetaDescription());
$media = "";
$label = varset($parm['label'], defset('LAN_SHARE',"Share"));
$label = varset($parm['label'], $tp->toGlyph('icon-share')." ".defset('LAN_SHARE',"Share"));
$size = varset($parm['size'],'md');
@@ -127,7 +127,7 @@ class social_shortcodes extends e_shortcode
$dir = ($parm['dropdown'] == 'right') ? 'pull-right' : '';
$text = '<div class="btn-group '.$dir.'">
<a class="e-tip btn btn-dropdown btn-default btn-'.$size.'" data-toggle="dropdown" href="#" title="Share">'.$label.' <b class="caret"></b></a>
<a class="e-tip btn btn-dropdown btn-default btn-'.$size.' dropdown-toggle" data-toggle="dropdown" href="#" title="Share">'.$label.' <b class="caret"></b></a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel" style="min-width:355px">

View File

@@ -328,7 +328,7 @@ $(document).ready(function()
// Tooltips for bbarea.
$(".bbcode_buttons").tooltip({placement: 'top',opacity: 1.0, fade: true,html: true});
$(".bbcode_buttons").tooltip({placement: 'top',opacity: 1.0, fade: true,html: true, container:'body'});
// $("a.e-tip").tipsy({gravity: 'w',opacity: 1.0, fade: true,html: true});
// var tabs = $('#tab-container').clone(true);
// $('#htmlEditor').append(tabs);

View File

@@ -6,12 +6,15 @@ $(document).ready(function()
var newval = $('#bbcode_holder').val();
var target = $(this).attr('data-target');
var bbcode = $(this).attr('data-bbcode'); // TinyMce/Textarea insert mode
if(!target || !bbcode){ return true; }
$('#' + target, window.top.document).atCaret('insert', newval); // http://code.google.com/p/jquery-at-caret/wiki/GettingStarted
// if(!target || !bbcode){ return true; }
if(target && newval)
{
$('#' + target, window.top.document).atCaret('insert', newval); // http://code.google.com/p/jquery-at-caret/wiki/GettingStarted
}
//var cursorIndex = $('#' + target, window.top.document).attr("selectionStart");
//var lStr = $('#' + target, window.top.document).attr('value').substr(0,cursorIndex) + " " + newval + " ";
//var rStr = $('#' + target, window.top.document).attr('value').substr(cursorIndex);
@@ -34,6 +37,7 @@ $(document).ready(function()
eMediaAttribute();
});
$("#float").change(function () {
eMediaAttribute();
@@ -42,7 +46,7 @@ $(document).ready(function()
function eMediaAttribute(e)
function eMediaAttribute(e, bbcode)
{
var style = '';
var bb = '';
@@ -112,19 +116,23 @@ $(document).ready(function()
style = style + 'height:' + height + 'px;';
}
bb = '[img';
if(style !='')
if(bbcode !== 'video')
{
bb = bb + ' style='+style;
}
bb = '[img';
if(style !='')
{
bb = bb + ' style='+style;
}
bb = bb + ']';
bb = bb + path;
bb = bb + '[/img]';
$('#bbcode_holder').val(bb); // Set the BBcode Value.
}
bb = bb + ']';
bb = bb + path;
bb = bb + '[/img]';
$('#bbcode_holder').val(bb); // Set the BBcode Value.
// var html = '<img style=\"' + style + '\" src=\"'+ src +'\" />';
@@ -162,7 +170,7 @@ $(document).ready(function()
{
bbpath = '[file='+ id +']'+ name + '[/file]';
$('#bbcode_holder').val(bbpath);
alert(bbpath); //FIXME bbcode - Insert into correct caret in text-area.
// alert(bbpath); //FIXME bbcode - Insert into correct caret in text-area.
return;
// $('input#' + target, window.top.document).attr('value',path); // set new value
// $('textarea#' + target, window.top.document).attr('value',bbpath);
@@ -173,11 +181,12 @@ $(document).ready(function()
//alert('hello');
}
if(bbcode == "img")
if(bbcode == "video")
{
// bbpath = '['+bbcode+']'+ path + '[/' + bbcode + ']';
//alert(bbpath);
bbpath = '['+bbcode+']'+ path + '[/' + bbcode + ']';
$('#bbcode_holder').val(bbpath);
}
@@ -209,9 +218,9 @@ $(document).ready(function()
{
preview = name;
}
else // image
else // image and video
{
eMediaAttribute(this);
eMediaAttribute(this,bbcode);
preview = $('#html_holder').val();
}