diff --git a/e107_admin/image.php b/e107_admin/image.php index 8461e45e3..69e8f3195 100644 --- a/e107_admin/image.php +++ b/e107_admin/image.php @@ -40,6 +40,35 @@ if(isset($_POST['submit_cancel_show'])) include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_'.e_PAGE); +if($_GET['action'] == 'nav' && e_AJAX_REQUEST) //XXX Doesn't work correctly inside the class for some reaosn. +{ + define("e_IFRAME",true); + // require_once(e_ADMIN."auth.php"); + $bbcodeMode = ($_GET['bbcode']=='img') ? 'bbcode=img' : FALSE; + + if($_GET['from']) + { + $bbcodeMode .= "&from=".intval($_GET['from']); + } + + $bbcodeMode .= "&nav=1"; + + $tag = ($bbcodeMode===false) ? false : $_GET['tagid']; // eg. news, news-thumbnail + + if($_GET['search']) + { + $bbcodeMode .= "&search=".preg_replace("/[^a-z0-9]/i","",$_GET['search']); + } + + echo e107::getMedia()->mediaSelect($_GET['for'],$tag,$bbcodeMode); + + // require_once(e_ADMIN."footer.php"); + exit; + +} + + + $e_sub_cat = 'image'; @@ -589,7 +618,15 @@ class media_admin_ui extends e_admin_ui //FIXME TODO - clear thumbnail cache when prefs are saved/updated. // e107::getCache()->clearAll('image'); + // print_a($_GET); + if($_GET['action'] == 'nav' ) + { + //echo $this->navPage();\ + // $this->getResponse()->setIframeMod(); // disable header/footer menus etc. + // print_a($_GET); + + } @@ -639,37 +676,9 @@ class media_admin_ui extends e_admin_ui if($this->getQuery('iframe')) { - - - /* - if($this->getQuery('bbcode')) - { - //TODO this is not really used when jquery is running. - e107::getJS()->headerInline(" - - // Send the generated IMG bbcode back to the textarea/window - function saveBB() - { - - - var add = document.getElementById('bbcode_holder').value; - var html = document.getElementById('html_holder').value; - // tinyMCE.execCommand('mceInsertContent',false,add); - tinyMCE.execCommand('mceInsertRawHTML',false,html); - tinyMCEPopup.close(); - - - //addtext(add); - //parent.e107Widgets.DialogManagerDefault.getWindow('e-dialog').close(); - return false; - } - - "); - - } - */ $this->getResponse()->setIframeMod(); // disable header/footer menus etc. + if(!$this->getQuery('for')) { $this->setPosted('media_category', "_common"); @@ -699,6 +708,30 @@ class media_admin_ui extends e_admin_ui // } + + function navPage() // no functioning correctly - see e_AJAX_REQUEST above. + { + + + $bbcodeMode = ($this->getQuery('bbcode')=='img') ? 'bbcode=img' : FALSE; + + if($_GET['from']) + { + $bbcodeMode .= "&from=".intval($_GET['from']); + } + + $bbcodeMode .= "&nav=1"; + + $tag = ($bbcodeMode) ? "" : $this->getQuery('tagid'); + echo e107::getMedia()->mediaSelect($this->getQuery('for'),$this->getQuery('tagid'),$bbcodeMode); // eg. news, news-thumbnail + + return; + } + + + + + function dialogPage() // Popup dialogPage for Image Selection. { $cat = $this->getQuery('for'); @@ -725,6 +758,9 @@ class media_admin_ui extends e_admin_ui echo $this->imageSelectUpload(); } + + + function uploadPage() { if(!ADMIN){ exit; } //TODO check for upload-access in perms. diff --git a/e107_core/bbcodes/bb_youtube.php b/e107_core/bbcodes/bb_youtube.php index 80a4054e5..979479ef9 100644 --- a/e107_core/bbcodes/bb_youtube.php +++ b/e107_core/bbcodes/bb_youtube.php @@ -271,10 +271,10 @@ class bb_youtube extends e_bb_base default: // maximum 1920 x 1080 (+25) $dim = explode(',', $dimensions, 2); $params['w'] = (integer) varset($dim[0], 445); - if($params['w'] > 1920 || $params['w'] < 200) $params['w'] = 640; + if($params['w'] > 1920 || $params['w'] < 100) $params['w'] = 640; $params['h'] = (integer) varset($dim[1], 364); - if($params['h'] > 1105 || $params['h'] < 137) $params['h'] = 385; + if($params['h'] > 1105 || $params['h'] < 67) $params['h'] = 385; break; } @@ -344,25 +344,29 @@ class bb_youtube extends e_bb_base $class = "bbcode ".e107::getBB()->getClass('youtube'); // consistent classes across all themes. - $ret = ' - - - - + $ret = "\n"; // <-- DO NOT MODIFY - used for detection by bbcode handler. + $ret .= ' '; - // Not XHTML - but needed for compatibility. + + // Not XHTML - but needed for compatibility. $ret .= ''; + $ret .= ''; - $ret .= ' - + $ret .= ""; // <-- DO NOT MODIFY. + -'; return $ret; } + + // Wysiwyg representation of bbcode render. + function toWYSIWYG($code_text,$parm) + { + //eg. an image of the video thumbnail + } } ?> \ No newline at end of file diff --git a/e107_files/jslib/core/admin.jquery.js b/e107_files/jslib/core/admin.jquery.js index 6ca2650ff..31878b4d5 100644 --- a/e107_files/jslib/core/admin.jquery.js +++ b/e107_files/jslib/core/admin.jquery.js @@ -219,49 +219,9 @@ $(document).ready(function() }); - $(".e-nav").click(function(){ // should be run before ajax. - - var src = $(this).attr("data-src"); - var inc = parseInt($(this).attr("data-nav-inc")); - var dir = $(this).attr("data-nav-dir"); - var tot = parseInt($(this).attr("data-nav-total")); - var val = src.match(/from=(\d+)/); - var amt = parseInt(val[1]); - - var oldVal = 'from='+ amt; - - var sub = amt - inc; - var add = amt + inc; - - $(this).show(); - - if(add > tot) - { - add = amt; - } - - if(sub < 0) - { - sub = 0 - } - - if(dir == 'down') - { - var newVal = 'from='+ sub; - } - else - { - var newVal = 'from='+ add; - } - - - src = src.replace(oldVal, newVal); - $(".e-nav").attr("data-src",src); - }); - - + $(".e-shake" ).effect("shake",{times: 10, distance: 2},20); diff --git a/e107_files/jslib/core/all.jquery.js b/e107_files/jslib/core/all.jquery.js index 1f2d4671e..1beb450c5 100644 --- a/e107_files/jslib/core/all.jquery.js +++ b/e107_files/jslib/core/all.jquery.js @@ -420,17 +420,19 @@ $(document).ready(function() $(id).html(""); } - if(src == null) // old way - href='myscript.php#id-to-target + if(src === null) // old way - href='myscript.php#id-to-target { var tmp = src.split('#'); id = tmp[1]; src = tmp[0]; } // var effect = $(this).attr("data-effect"); - + // alert(src); + $(id).load(src,function() { // alert(src); - // $(id).effect("slide"); + //$(this).hide(); + // $(this).fadeIn(); }); diff --git a/e107_files/jslib/core/mediaManager.js b/e107_files/jslib/core/mediaManager.js index a7475c088..870603735 100644 --- a/e107_files/jslib/core/mediaManager.js +++ b/e107_files/jslib/core/mediaManager.js @@ -105,7 +105,7 @@ $(document).ready(function() // $(".e-media-select").click(function () { $(".e-media-select").live("click", function(){ - + // console.log(this); var id = $(this).attr('data-id'); @@ -116,6 +116,8 @@ $(document).ready(function() var bbcode = $(this).attr('data-bbcode'); var name = $(this).attr('data-name'); + //alert(target); + $(this).addClass("media-select-active"); $(this).closest("img").addClass("active"); @@ -168,6 +170,138 @@ $(document).ready(function() }); + $(".e-nav").click(function(){ // should be run before ajax. + + var src = $(this).attr("data-src"); + var inc = parseInt($(this).attr("data-nav-inc")); + var dir = $(this).attr("data-nav-dir"); + var tot = parseInt($(this).attr("data-nav-total")); + var val = src.match(/from=(\d+)/); + var amt = parseInt(val[1]); + + var oldVal = 'from='+ amt; + + var sub = amt - inc; + var add = amt + inc; + + $(this).show(); + + if(add > tot) + { + add = amt; + } + + if(sub < 0) + { + sub = 0 + } + + if(dir == 'down') + { + var newVal = 'from='+ sub; + } + else + { + var newVal = 'from='+ add; + } + + + src = src.replace(oldVal, newVal); + $(".e-nav").attr("data-src",src); + + }); + + + + $(".e-media-nav").click(function(){ + + return mediaNav(this); + /* + var id = $(this).attr("href"); + var src = $(this).attr("data-src"); + var target = $(this).attr("data-target"); // support for input buttons etc. + var loading = $(this).attr('data-loading'); // image to show loading. + var search = $('#media-search').val(); // image to show loading. + + if(target != null) + { + id = '#' + target; + } + + if(loading != null) + { + $(id).html(""); + } + + if(src === null) // old way - href='myscript.php#id-to-target + { + var tmp = src.split('#'); + id = tmp[1]; + src = tmp[0]; + } + + if(search !== null) + { + src = src + '&search='+search; + } + // var effect = $(this).attr("data-effect"); + // alert(src); + + $(id).load(src,function() { + // alert(src); + // $(this).hide(); + // $(this).SlideUp(); + }); + + */ + }); + + $("#media-search").keyup(function(){ + mediaNav(this); + + }); + + + function mediaNav(e) + { + var id = $(e).attr("href"); + var src = $(e).attr("data-src"); + var target = $(e).attr("data-target"); // support for input buttons etc. + var loading = $(e).attr('data-loading'); // image to show loading. + var search = $('#media-search').val(); // image to show loading. + + if(target != null) + { + id = '#' + target; + } + + if(loading != null) + { + $(id).html(""); + } + + if(src === null) // old way - href='myscript.php#id-to-target + { + var tmp = src.split('#'); + id = tmp[1]; + src = tmp[0]; + } + + if(search !== null) + { + src = src + '&search='+search; + } + + $(id).load(src,function() { + // alert(src); + // $(this).hide(); + // $(this).SlideUp(); + }); + + + + } + // ----------------- Upload -------------------------------------- diff --git a/e107_handlers/bbcode_handler.php b/e107_handlers/bbcode_handler.php index b4ed7c69b..0eebbbc01 100644 --- a/e107_handlers/bbcode_handler.php +++ b/e107_handlers/bbcode_handler.php @@ -550,7 +550,11 @@ class e_bbcode { return $text; } - + + // Youtube conversion (TinyMce) + $text = preg_replace('/([^/i',"[youtube=$1]$4[/youtube]",$text); + $text = preg_replace('/.*/i','[youtube=$1]$2[/youtube]',$text); + $text = preg_replace("/(.*?)<\/a>/i","[file=$2]$3[/file]",$text); $text = preg_replace("/(.*?)<\/a>/i","[link=$1]$2[/link]",$text); diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index cc9a038d9..77f483a9e 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -2754,8 +2754,11 @@ class e107 } // This should avoid further checks - NOTE: used in js_manager.php - define('e_ADMIN_AREA', ($inAdminDir && !deftrue('USER_AREA'))); //Force USER_AREA added - + if(!defined('e_ADMIN_AREA')) + { + define('e_ADMIN_AREA', ($inAdminDir && !deftrue('USER_AREA'))); //Force USER_AREA added + } + define('ADMINDIR', $ADMIN_DIRECTORY); define('SITEURLBASE', $this->HTTP_SCHEME.'://'.$_SERVER['HTTP_HOST']); diff --git a/e107_handlers/media_class.php b/e107_handlers/media_class.php index c2be6a2d9..080bba8ec 100644 --- a/e107_handlers/media_class.php +++ b/e107_handlers/media_class.php @@ -263,9 +263,10 @@ class e_media * Return the total number of Images in a particular category * */ - public function countImages($cat) + public function countImages($cat,$search=null) { - $inc = array(); + $inc = array(); + $searchinc = array(); if(strpos($cat,"+") || !$cat) { @@ -277,9 +278,22 @@ class e_media $inc[] = "media_category REGEXP '(^|,)(".$cat.")(,|$)' "; // for multiple category field. } + if($search) + { + $searchinc[] = "media_name LIKE '%".$search."%' "; + $searchinc[] = "media_description LIKE '%".$search."%' "; + $searchinc[] = "media_caption LIKE '%".$search."%' "; + $searchinc[] = "media_tags LIKE '%".$search."%' "; + } + $query = "SELECT * FROM #core_media WHERE media_userclass IN (".USERCLASS_LIST.") AND ( ".implode(" OR ",$inc)." )" ; + if($search) + { + $query .= " AND ( ".implode(" OR ",$searchinc)." ) " ; + } + return e107::getDb()->db_Select_gen($query); } @@ -288,9 +302,10 @@ class e_media * Return an array of Images in a particular category * @param string $cat : category name. use + to include _common eg. 'news+' */ - public function getImages($cat='', $from=0, $amount=null) + public function getImages($cat='', $from=0, $amount=null,$search=null) { - $inc = array(); + $inc = array(); + $searchinc = array(); if(strpos($cat,"+") || !$cat) { @@ -303,10 +318,26 @@ class e_media $inc[] = "media_category REGEXP '(^|,)(".$cat.")(,|$)' "; // for multiple category field. } // TODO check the category is valid. + + if($search) + { + $searchinc[] = "media_name LIKE '%".$search."%' "; + $searchinc[] = "media_description LIKE '%".$search."%' "; + $searchinc[] = "media_caption LIKE '%".$search."%' "; + $searchinc[] = "media_tags LIKE '%".$search."%' "; + } + $ret = array(); - $query = "SELECT * FROM #core_media WHERE media_userclass IN (".USERCLASS_LIST.") AND ( ".implode(" OR ",$inc) ; - $query .= " ) ORDER BY media_datestamp DESC"; + $query = "SELECT * FROM #core_media WHERE media_userclass IN (".USERCLASS_LIST.") AND ( ".implode(" OR ",$inc)." ) " ; + + if($search) + { + $query .= " AND ( ".implode(" OR ",$searchinc)." ) " ; + } + + $query .= " ORDER BY media_datestamp DESC"; + if($amount) { @@ -405,18 +436,15 @@ class e_media parse_str($att,$option); $cat = ($category) ? '&for='.$category : ""; + if(!$label) $label = ' Upload an image or file'; if($option['tagid']) $cat .= '&tagid='.$option['tagid']; - if($option['bbcode']) $cat .= '&bbcode=1'; - - + if($option['bbcode']) $cat .= '&bbcode='.$option['bbcode']; $cat .= ($option['limit']) ? "&limit=".$option['limit'] : ""; - $cat .= ($option['frm']) ? "&frm=".$option['frm'] : ""; - - $url = e_ADMIN_ABS."image.php?mode=main&action=dialog".$cat; + $url = e_ADMIN_ABS."image.php?mode=main&action=nav&iframe=1".$cat; return $url; } @@ -431,16 +459,19 @@ class e_media $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); + $images = $this->getImages($cat,$frm,$limit,$search); $class = "media-select-image"; $w = 120; $h = 100; - $total = $this->countImages($cat); + $total = $this->countImages($cat,$search); } else // Icons { @@ -464,14 +495,20 @@ class e_media // $text .= "CAT=".$cat; $dipTotal = (($frm + $limit) < $total) ? ($frm + $limit) : $total; - $text .= "
Filter: "; - $text .= " "; // Manual filter, if onkeyup ajax fails for some reason. - // $text .= ""; // see previous page of images. - $text .= "«"; // see next page of images. + if($navMode === false) + { + $text .= "
Filter: "; + $text .= " "; // Manual filter, if onkeyup ajax fails for some reason. + // $text .= ""; // see previous page of images. + $text .= ""; // see next page of images. - $text .= " »"; // see next page of images. - $text .= "
-
+ $text .= " "; // see next page of images. + $text .= "
+
"; + } + + + $text .= "
Displaying ".($frm +1)."-".($dipTotal)." of ".$total." images.
\n"; if($bbcode == null) // e107 Media Manager - new-image mode. @@ -546,7 +583,11 @@ class e_media $text .= "
"; $mes = e107::getMessage(); $mes->addDebug("Target: {$tagid}"); - $text .= "
"; + + if($navMode === false) + { + $text .= "
"; + } return $text; }