From d9fe5c8410053f2da07eeb29933645e3aafab72f Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 31 Jan 2017 14:50:55 -0800 Subject: [PATCH] Fix for SVG icon import. --- e107_admin/plugin.php | 8 +++++++ e107_admin/update_routines.php | 20 ++++++++++++++-- e107_handlers/e_parse_class.php | 4 ++-- e107_handlers/media_class.php | 42 +++++++++++++++++---------------- 4 files changed, 50 insertions(+), 24 deletions(-) diff --git a/e107_admin/plugin.php b/e107_admin/plugin.php index d84e448d0..ef2dd90c2 100644 --- a/e107_admin/plugin.php +++ b/e107_admin/plugin.php @@ -1481,6 +1481,8 @@ class pluginManager{ $med = e107::getMedia(); $icons = $med->listIcons(e_PLUGIN.$plug['plugin_path']); + $iconText = ''; + if(count($icons)>0) { foreach($icons as $key=>$val) @@ -1488,6 +1490,8 @@ class pluginManager{ $iconText .= ""; } + $iconText = '
'.$iconText.'
'; + $opts['delete_ipool'] = array( 'label' => EPL_ADLAN_231, 'preview' => $iconText, @@ -1495,8 +1499,12 @@ class pluginManager{ 'itemList' => array(1=>LAN_YES,0=>LAN_NO), 'itemDefault' => 1 ); + + } + + if(is_readable(e_PLUGIN.$plug['plugin_path']."/".$plug['plugin_path']."_setup.php")) { include_once(e_PLUGIN.$plug['plugin_path']."/".$plug['plugin_path']."_setup.php"); diff --git a/e107_admin/update_routines.php b/e107_admin/update_routines.php index 68b8755b5..c2b590d06 100644 --- a/e107_admin/update_routines.php +++ b/e107_admin/update_routines.php @@ -123,7 +123,7 @@ if (!$dont_check_update) $LAN_UPDATE_5 = deftrue('LAN_UPDATE_5', "Core database structure"); - // $dbupdate['212_to_213'] = array('master'=>false, 'title'=> e107::getParser()->lanVars($LAN_UPDATE_4, array('2.1.2','2.1.3')), 'message'=> null, 'hide_when_complete'=>true); + $dbupdate['214_to_215'] = array('master'=>false, 'title'=> e107::getParser()->lanVars($LAN_UPDATE_4, array('2.1.4','2.1.5')), 'message'=> null, 'hide_when_complete'=>true); $dbupdate['706_to_800'] = array('master'=>true, 'title'=> e107::getParser()->lanVars($LAN_UPDATE_4, array('1.x','2.0')), 'message'=> LAN_UPDATE_29, 'hide_when_complete'=>true); @@ -556,13 +556,29 @@ function update_core_database($type = '') * @param string $type * @return bool true = no update required, and false if update required. */ - function update_212_to_213($type='') + function update_214_to_215($type='') { $sql = e107::getDb(); $log = e107::getLog(); $just_check = ($type == 'do') ? false : true; + + if(!$sql->select('core_media_cat', 'media_cat_id', "media_cat_category = '_icon_svg' LIMIT 1")) + { + if($just_check) + { + return update_needed("Missing Media-category for SVG"); + } + + $query = "INSERT INTO `#core_media_cat` (media_cat_id, media_cat_owner, media_cat_category, media_cat_title, media_cat_sef, media_cat_diz, media_cat_class, media_cat_image, media_cat_order) VALUES (NULL, '_icon', '_icon_svg', 'Icons SVG', '', 'Available where icons are used in admin.', '253', '', '0');"; + + return $sql->gen($query); + + } + + + // List of changed menu locations. /* $changeMenuPaths = array( diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php index 4b8cfea65..563e6c7bb 100644 --- a/e107_handlers/e_parse_class.php +++ b/e107_handlers/e_parse_class.php @@ -3867,9 +3867,9 @@ class e_parser public function toIcon($icon='',$parm = array()) { - if(!vartrue($icon)) + if(empty($icon)) { - return; + return null; } if(strpos($icon,'e_MEDIA_IMAGE')!==false) diff --git a/e107_handlers/media_class.php b/e107_handlers/media_class.php index 14d9fe0b3..e049ee4f0 100644 --- a/e107_handlers/media_class.php +++ b/e107_handlers/media_class.php @@ -242,7 +242,7 @@ class e_media $path = $tp->createConstants($epath, 'rel'); - $status = ($sql->gen("SELECT * FROM `#core_media` WHERE `media_url` LIKE '".$path."%' AND media_category REGEXP '_icon_16|_icon_32|_icon_48|_icon_64,_icon_svg' ")) ? TRUE : FALSE; + $status = ($sql->gen("SELECT * FROM `#core_media` WHERE `media_url` LIKE '".$path."%' AND media_category REGEXP '_icon_16|_icon_32|_icon_48|_icon_64|_icon_svg' ")) ? TRUE : FALSE; while ($row = $sql->fetch()) { $ret[] = $row['media_url']; @@ -669,7 +669,7 @@ class e_media $w = 64; $h = 64; $total = 500; - $total = $this->countImages("_icon_16|_icon_32|_icon_48|_icon_64",$search); + $total = $this->countImages("_icon_16|_icon_32|_icon_48|_icon_64|_icon_svg",$search); $onclick_clear = "parent.document.getElementById('{$tagid}').value = ''; parent.document.getElementById('".$prevId."').innerHTML= ''; return false;"; @@ -721,15 +721,11 @@ class e_media if($bbcode == null) // e107 Media Manager - new-image mode. { - - // TODO LAN. $text .= " ".$tp->toGlyph('fa-ban')." "; } - $srch = array("{MEDIA_URL}","{MEDIA_PATH}"); - $w = false; // $h = false; $defaultResizeWidth = 400; @@ -751,25 +747,32 @@ class e_media $media_path : Inserted into html tags eg. $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. + + if($category === '_icon') + { + $class = "media-select-icon"; + $media_path = $tp->replaceConstants($im['media_url']); // $tp->replaceConstants($im['media_url'],'full'); // max-size + $realPath = $media_path; + $img_url = $media_path; + + } + else // Regular image. + { + + $class = "media-select-image"; + $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. + $img_url = e107::getParser()->thumbUrl($im['media_url'], $thumbAtt); + + } + $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) // e107 Media Manager @@ -794,8 +797,7 @@ class e_media } $data_bb = ($bbcode) ? "img" : ""; - - $img_url = (!empty($cat)) ? e107::getParser()->thumbUrl($im['media_url'], $thumbAtt) : $media_path; + $text .= ""; $text .= "\"".$im['media_title']."\"";