From 5a4d97ca9a4be9ecf4d4764c4fd16bffb0070b33 Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 31 Dec 2013 09:59:19 -0800 Subject: [PATCH] Bootstrap3 news and search-menu template fixes. New thumb.php placeholder feature added. New {GLYPH} shortcode added. Usage: {GLYPH=time} --- .../shortcodes/batch/news_shortcodes.php | 18 ++++-- .../shortcodes/batch/page_shortcodes.php | 2 +- e107_core/shortcodes/single/glyph.php | 8 +++ e107_core/templates/menu_template.php | 4 +- e107_handlers/e_parse_class.php | 33 +++++++++-- e107_handlers/emailprint_class.php | 6 +- .../blogcalendar_menu/blogcalendar_menu.php | 2 +- .../news/templates/news_menu_template.php | 8 +-- e107_plugins/news/templates/news_template.php | 42 ++++++++++++-- e107_plugins/search_menu/search_menu.php | 57 +++++++++++++++---- e107_themes/bootstrap3/style.css | 7 ++- e107_themes/bootstrap3/theme.xml | 3 +- thumb.php | 53 +++++++++++++++-- 13 files changed, 199 insertions(+), 44 deletions(-) create mode 100644 e107_core/shortcodes/single/glyph.php diff --git a/e107_core/shortcodes/batch/news_shortcodes.php b/e107_core/shortcodes/batch/news_shortcodes.php index 7e8dfe092..423f6c1e6 100644 --- a/e107_core/shortcodes/batch/news_shortcodes.php +++ b/e107_core/shortcodes/batch/news_shortcodes.php @@ -352,13 +352,19 @@ class news_shortcodes extends e_shortcode function sc_newsimage($parm = '') { $tp = e107::getParser(); + if(!$this->news_item['news_thumbnail']) { - return ''; + if($parm == 'placeholder') + { + $src = $tp->thumbUrl(); // placeholder; + } + else + { + return; + } } - - - if($this->news_item['news_thumbnail'][0] == '{' ) // Always resize. Use {SETIMAGE: w=x&y=x&crop=0} PRIOR to calling shortcode to change. + elseif($this->news_item['news_thumbnail'][0] == '{' ) // Always resize. Use {SETIMAGE: w=x&y=x&crop=0} PRIOR to calling shortcode to change. { $src = $tp->thumbUrl($this->news_item['news_thumbnail']); } @@ -369,6 +375,8 @@ class news_shortcodes extends e_shortcode } + ; + switch($parm) { case 'src': @@ -381,7 +389,7 @@ class news_shortcodes extends e_shortcode case 'url': default: - return "news_item)."'>"; + return "news_item)."'>"; break; } } diff --git a/e107_core/shortcodes/batch/page_shortcodes.php b/e107_core/shortcodes/batch/page_shortcodes.php index a95c826a6..4a1c844f9 100644 --- a/e107_core/shortcodes/batch/page_shortcodes.php +++ b/e107_core/shortcodes/batch/page_shortcodes.php @@ -189,7 +189,7 @@ class cpage_shortcodes extends e_shortcode $size = vartrue($options['size'], ""); $inc = ($size) ? " btn-".$size : ""; - return ''.$text.''; + return ''.$text.''; } diff --git a/e107_core/shortcodes/single/glyph.php b/e107_core/shortcodes/single/glyph.php new file mode 100644 index 000000000..d7e76c4f5 --- /dev/null +++ b/e107_core/shortcodes/single/glyph.php @@ -0,0 +1,8 @@ +toGlyph($file,false); +} diff --git a/e107_core/templates/menu_template.php b/e107_core/templates/menu_template.php index 7821793d3..5b4c81255 100644 --- a/e107_core/templates/menu_template.php +++ b/e107_core/templates/menu_template.php @@ -9,12 +9,12 @@ $MENU_TEMPLATE['default']['end'] = ''; $MENU_TEMPLATE['button']['start'] = '
'; - $MENU_TEMPLATE['button']['body'] = '{CMENUBODY}{CPAGEBUTTON}'; + $MENU_TEMPLATE['button']['body'] = '{CMENUBODY}
{CPAGEBUTTON}'; $MENU_TEMPLATE['button']['end'] = '
'; ### Additional control over image thumbnailing is possible via SETIMAGE e.g. {SETIMAGE: w=200&h=150&crop=1} $MENU_TEMPLATE['buttom-image']['start'] = '
'; - $MENU_TEMPLATE['buttom-image']['body'] = '{CMENUIMAGE}{CPAGEBUTTON}'; + $MENU_TEMPLATE['buttom-image']['body'] = '{CMENUIMAGE}
{CPAGEBUTTON}'; $MENU_TEMPLATE['buttom-image']['end'] = '
'; diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php index d60185b03..80f132e6d 100644 --- a/e107_handlers/e_parse_class.php +++ b/e107_handlers/e_parse_class.php @@ -1907,12 +1907,13 @@ class e_parse extends e_parser /** - * @param $url - * @param $options ?? + * Generate an auto-sized Image URL. + * @param $url - path to image or leave blank for a placeholder. + * @param $options - width and height, but leaving this empty and using $this->thumbWidth() and $this->thumbHeight() is preferred. ie. {SETWIDTH: w=x&y=x} * @param $raw ?? * @param $full */ - public function thumbUrl($url, $options = array(), $raw = false, $full = false) + public function thumbUrl($url=null, $options = array(), $raw = false, $full = false) { if(substr($url,0,3)=="{e_") // Fix for broken links that use {e_MEDIA} etc. { @@ -2669,14 +2670,36 @@ class e_parser return false; } - if(substr($text,-6) == '.glyph') // Bootstrap or Font-Awesome. + // Bootstrap 3 Glyph names. + $bs3 = array( + 'adjust','align-center','align-justify','align-left','align-right','arrow-down','arrow-left','arrow-right','arrow-up','asterisk','backward','ban-circle','barcode','bell','bold','book + ','bookmark','briefcase','bullhorn','calendar','camera','certificate','check','chevron-down','chevron-left','chevron-right','chevron-up','circle-arrow-down','circle-arrow-left','circle-arrow-right + ','circle-arrow-up','cloud','cloud-download','cloud-upload','cog','collapse-down','collapse-up','comment','compressed','copyright-mark','credit-card','cutlery','dashboard','download','download-alt + ','earphone','edit','eject','envelope','euro','exclamation-sign','expand','export','eye-close','eye-open','facetime-video','fast-backward','fast-forward','file','film','filter','fire','flag + ','flash','floppy-disk','floppy-open','floppy-remove','floppy-save','floppy-saved','folder-close','folder-open','font','forward','fullscreen','gbp','gift + ','glass','globe','hand-down','hand-left','hand-right','hand-up','hd-video','hdd','header','headphones','heart','heart-empty','home','import','inbox','indent-left','indent-right','info-sign','italic','leaf','link','list + ','list-alt','lock','log-in','log-out','magnet','map-marker','minus','minus-sign','move','music','new-window','off','ok','ok-circle','ok-sign','open','paperclip','pause','pencil','phone','phone-alt','picture + ','plane','play','play-circle','plus','plus-sign','print','pushpin','qrcode','question-sign','random','record','refresh','registration-mark','remove','remove-circle','remove-sign','repeat','resize-full','resize-horizontal + ','resize-small','resize-vertical','retweet','road','save','saved','screenshot','sd-video','search','send','share','share-alt','shopping-cart','signal','sort','sort-by-alphabet','sort-by-alphabet-alt + ','sort-by-attributes','sort-by-attributes-alt','sort-by-order','sort-by-order-alt','sound-5-1','sound-6-1','sound-7-1','sound-dolby','sound-stereo','star','stats','step-backward','step-forward','stop + ','subtitles','tag','tags','tasks','text-height','text-width','th','th-large','th-list','thumbs-down','thumbs-up','time','tint','tower','transfer','trash','tree-conifer','tree-deciduous','unchecked','upload + ','usd','user','volume-down','volume-off','volume-up','warning-sign','wrench','zoom-in','zoom-out' + ); + + + if(substr($text,-6) == '.glyph' || strpos($text,".")==false) // Bootstrap or Font-Awesome. { list($cls,$tmp) = explode('.glyph',$text); + $id = str_replace("icon-","",$cls); - if(deftrue('FONTAWESOME') == 4) // Convert FontAwesome 3 to 4. + if(deftrue('FONTAWESOME') == 4 && !in_array($id ,$bs3)) // Convert FontAwesome 3 to 4. { $cls = str_replace('icon-', 'fa fa-', $cls); } + elseif(defset("BOOTSTRAP")===3) + { + $cls = str_replace('icon-', 'glyphicon glyphicon-', $cls); + } $text = (deftrue('BOOTSTRAP') === 3) ? "" : ""; // retain space. $text .= ($space !== false) ? $space : ""; diff --git a/e107_handlers/emailprint_class.php b/e107_handlers/emailprint_class.php index 208cf46b4..deef75b9c 100644 --- a/e107_handlers/emailprint_class.php +++ b/e107_handlers/emailprint_class.php @@ -26,7 +26,7 @@ class emailprint // $look = 0 --->display all icons // $look = 1 --->display email icon only // $look = 2 --->display print icon only - + $tp = e107::getParser(); $text_emailprint = ""; @@ -60,8 +60,8 @@ class emailprint if(deftrue('BOOTSTRAP')) { - $genericMail = ""; - $genericPrint = ""; + $genericMail = $tp->toGlyph('icon-envelope',false); // ""; + $genericPrint = $tp->toGlyph('icon-print',false); // ""; } else // BC { diff --git a/e107_plugins/blogcalendar_menu/blogcalendar_menu.php b/e107_plugins/blogcalendar_menu/blogcalendar_menu.php index 84ce98f62..0c035a8de 100644 --- a/e107_plugins/blogcalendar_menu/blogcalendar_menu.php +++ b/e107_plugins/blogcalendar_menu/blogcalendar_menu.php @@ -180,7 +180,7 @@ if(false === $cached) $menu .= ""; $menu .= " "; diff --git a/e107_plugins/news/templates/news_menu_template.php b/e107_plugins/news/templates/news_menu_template.php index ec211ad20..14d39892c 100644 --- a/e107_plugins/news/templates/news_menu_template.php +++ b/e107_plugins/news/templates/news_menu_template.php @@ -61,10 +61,10 @@ $NEWS_MENU_TEMPLATE['other']['start'] = "
{SETIMAGE: w=400&h=200&crop=1}"; // set the {NEWSIMAGE} dimensions. $NEWS_MENU_TEMPLATE['other']['item'] = '
- {NEWSIMAGE} + {NEWSIMAGE=placeholder}

{NEWSTITLE}

{NEWSSUMMARY}

-

'.LAN_READ_MORE.' »

+

'.LAN_READ_MORE.' »

'; $NEWS_MENU_TEMPLATE['other']['end'] = "
"; @@ -80,9 +80,9 @@ $NEWS_MENU_TEMPLATE['other']['end'] = ""; $NEWS_MENU_TEMPLATE['other2']['caption'] = TD_MENU_L2; $NEWS_MENU_TEMPLATE['other2']['start'] = "