From cd8ea61bd93fe93b2660fe354951346aabac8ffd Mon Sep 17 00:00:00 2001 From: Cameron Date: Wed, 1 Jun 2016 18:36:16 -0700 Subject: [PATCH] Theme options and fixes. Load Theme JS in the footer by default. New blockquote alt. style added to TinyMce. Updated news shortcodes. Option to hide search form from results page. --- e107_admin/prefs.php | 2 +- .../shortcodes/batch/news_shortcodes.php | 21 ++++- e107_handlers/e107_class.php | 2 +- e107_handlers/js_manager.php | 14 +++ e107_handlers/news_class.php | 2 +- e107_handlers/search_class.php | 2 +- e107_plugins/news/e_url.php | 43 +++++++++ e107_plugins/news/news_months_menu.php | 11 ++- e107_plugins/social/e_shortcode.php | 7 +- e107_plugins/tinymce4/wysiwyg.php | 2 +- search.php | 88 ++----------------- 11 files changed, 98 insertions(+), 96 deletions(-) create mode 100644 e107_plugins/news/e_url.php diff --git a/e107_admin/prefs.php b/e107_admin/prefs.php index f6d9e80bd..9bb2d8394 100644 --- a/e107_admin/prefs.php +++ b/e107_admin/prefs.php @@ -377,7 +377,7 @@ $text .= " - ".$frm->imagepicker('sitelogo',$pref['sitelogo'],'','help='.PRFLAN_226)." + ".$frm->imagepicker('sitelogo',$pref['sitelogo'],'','w=200&help='.PRFLAN_226)." diff --git a/e107_core/shortcodes/batch/news_shortcodes.php b/e107_core/shortcodes/batch/news_shortcodes.php index a522831b3..104a2201e 100644 --- a/e107_core/shortcodes/batch/news_shortcodes.php +++ b/e107_core/shortcodes/batch/news_shortcodes.php @@ -332,6 +332,11 @@ class news_shortcodes extends e_shortcode return $this->sc_newscommentcount($parm); } + public function sc_news_comment_label($parm=null) + { + return ($this->news_item['news_comment_total'] == 1) ? COMLAN_8 : LAN_COMMENTS; + } + public function sc_news_date($parm=null) { return $this->sc_newsdate($parm); @@ -342,6 +347,11 @@ class news_shortcodes extends e_shortcode return $this->sc_newsavatar($parm); } + public function sc_news_url($parm=null) + { + return $this->sc_newsurl($parm); + } + public function sc_news_image($parm=null) { return $this->sc_newsimage($parm); @@ -885,7 +895,7 @@ class news_shortcodes extends e_shortcode return "param['itemlink'] : 'null')."' href='{$url}'>".e107::getParser()->toHTML($this->news_item['news_title'], TRUE, "TITLE").''; } - function sc_newsurl() + function sc_newsurl($parm=null) { return e107::getUrl()->create('news/view/item', $this->news_item); } @@ -976,6 +986,8 @@ class news_shortcodes extends e_shortcode { $tmp = explode(",",$this->news_item['news_meta_keywords']); $words = array(); + $class = (!empty($parm['class'])) ? $parm['class'] : 'news-tag'; + $separator = (isset($parm['separator'])) ? $parm['separator'] : ', '; if($parm == 'label') { @@ -987,7 +999,7 @@ class news_shortcodes extends e_shortcode { $start = ""; $end = ""; - $sep = ", "; + $sep = $separator; } foreach($tmp as $val) @@ -995,10 +1007,11 @@ class news_shortcodes extends e_shortcode if(trim($val)) { $url = e107::getUrl()->create('news/list/tag',array('tag'=>$val)); // e_BASE."news.php?tag=".$val - $words[] = "".$start.$val.$end.""; + $words[] = "".$start.$val.$end.""; } } - + + if(count($words)) { return implode($sep,$words); diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index d798d32d2..279a3e490 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -1777,7 +1777,7 @@ class e107 case 'theme': // data is e.g. 'jslib/mytheme.js' if(null !== $zone) $jshandler->headerTheme($data, $zone, $pre, $post); - else $jshandler->headerTheme($data, 5, $pre, $post); + else $jshandler->footerTheme($data, 5, $pre, $post); break; case 'inline': diff --git a/e107_handlers/js_manager.php b/e107_handlers/js_manager.php index 43aa2a510..d1ed0400a 100644 --- a/e107_handlers/js_manager.php +++ b/e107_handlers/js_manager.php @@ -572,6 +572,20 @@ class e_jsmanager return $this; } + + /** + * Add Theme JS file for inclusion in site footer (preferred), shorthand of footerFile() method + * + * @param string $file_path relative to theme root folder + * @param integer $zone 1-5 (see header.php) + * @return e_jsmanager + */ + public function footerTheme($file_path, $zone = 5, $pre = '', $post = '') + { + $this->footerFile(THEME.trim($file_path, '/'), $zone, $pre, $post); + return $this; + } + /** * Add Plugin JS file for inclusion in site header, shorthand of headerFile() method * diff --git a/e107_handlers/news_class.php b/e107_handlers/news_class.php index a46b27869..59ffa06ef 100644 --- a/e107_handlers/news_class.php +++ b/e107_handlers/news_class.php @@ -383,7 +383,7 @@ class news { 'perms' => '0', 'shortcodes' => array( 'news_title' => array('field'=>'news_title', 'type'=>'text', 'container'=>'span'), - 'news_description' => array('field'=>'news_meta_description','type'=>'text', 'container'=>'div'), + 'news_description' => array('field'=>'news_meta_description','type'=>'text', 'container'=>'span'), 'news_body' => array('field'=>'news_body', 'type'=>'html', 'container'=>'div'), 'news_summary' => array('field'=>'news_summary', 'type'=>'text', 'container'=>'span'), ) diff --git a/e107_handlers/search_class.php b/e107_handlers/search_class.php index 970ae9022..63051d666 100644 --- a/e107_handlers/search_class.php +++ b/e107_handlers/search_class.php @@ -218,7 +218,7 @@ class e_search if(e_DEBUG) { - echo e107::getMessage()->addDebug("Using MYSQL Sort Method")->render(); + e107::getDebug()->log("Using MYSQL Sort Method"); } $this -> query = str_replace('"', '"', $this -> query); diff --git a/e107_plugins/news/e_url.php b/e107_plugins/news/e_url.php new file mode 100644 index 000000000..59b41edd7 --- /dev/null +++ b/e107_plugins/news/e_url.php @@ -0,0 +1,43 @@ + '^gallery/?$', // matched against url, and if true, redirected to 'redirect' below. + 'sef' => (!empty($pref[e_LAN]['news'])) ? $pref[e_LAN]['news'] : 'news', // used by e107::url(); to create a url from the db table. + 'redirect' => '{e_BASE}news.php', // file-path of what to load when the regex returns true. + + ); + + + return $config; + } + + + +} \ No newline at end of file diff --git a/e107_plugins/news/news_months_menu.php b/e107_plugins/news/news_months_menu.php index 15f8fe993..77ccc5ea3 100644 --- a/e107_plugins/news/news_months_menu.php +++ b/e107_plugins/news/news_months_menu.php @@ -23,7 +23,7 @@ if(!empty($parm)) } } - +$cached = false; if(false === $cached) { @@ -87,12 +87,12 @@ if(false === $cached) $month_links = array(); $sql->db_Mark_Time('News months menu'); - if(!$sql->db_Select("news", "news_id, news_datestamp", "news_class IN (".USERCLASS_LIST.") AND news_datestamp > ".intval($start)." AND news_datestamp < ".intval($end)." ORDER BY news_datestamp DESC")) + if(!$sql->select("news", "news_id, news_datestamp", "news_class IN (".USERCLASS_LIST.") AND news_datestamp > ".intval($start)." AND news_datestamp < ".intval($end)." ORDER BY news_datestamp DESC")) { e107::getCache()->set($cString, ''); return ''; } - while ($news = $sql->db_Fetch()) + while ($news = $sql->fetch()) { $xmonth = date("n", $news['news_datestamp']); if ((!isset($month_links[$xmonth]) || !$month_links[$xmonth])) @@ -102,7 +102,10 @@ if(false === $cached) } $xmonth_cnt[$xmonth]++; } - + + + e107::getDebug()->log($month_links); + // go over the link array and create the option fields $menu_text = array(); $template = e107::getTemplate('news', 'news_menu', 'months'); diff --git a/e107_plugins/social/e_shortcode.php b/e107_plugins/social/e_shortcode.php index db786eea8..bd8179bf7 100644 --- a/e107_plugins/social/e_shortcode.php +++ b/e107_plugins/social/e_shortcode.php @@ -259,6 +259,7 @@ class social_shortcodes extends e_shortcode $twitterAccount = basename(XURL_TWITTER); + $btnClass = varset($parm['btnClass'], 'btn btn-default social-share'); // return print_a($hashtags,true); foreach($providers as $k=>$val) @@ -289,7 +290,7 @@ class social_shortcodes extends e_shortcode - $opt[$k] = "".$tp->toIcon($val["icon"], array('fw'=>1)).""; + $opt[$k] = "".$tp->toIcon($val["icon"], array('fw'=>1)).""; } // Show only Email, Facebook, Twitter and Google. @@ -335,9 +336,9 @@ class social_shortcodes extends e_shortcode else { - $class = varset($parm['class'],'btn-group social-share'); + $class = varset($parm['class'],'text-center btn-group social-share'); - return '
'.implode("\n",$opt)."
"; + return '
'.implode("\n",$opt)."
"; } diff --git a/e107_plugins/tinymce4/wysiwyg.php b/e107_plugins/tinymce4/wysiwyg.php index 1856fa125..2efc40eb8 100644 --- a/e107_plugins/tinymce4/wysiwyg.php +++ b/e107_plugins/tinymce4/wysiwyg.php @@ -453,8 +453,8 @@ class wysiwyg {title: 'Blocks', items: [ {title: 'Paragraph', block: 'p'}, {title: 'Blockquote', block: 'blockquote'}, + {title: 'Blockquote alt.', block: 'blockquote', classes: 'blockquote-alt blockquote__alternative'}, {title: 'Div', block: 'div'}, - {title: 'Pre', block: 'pre'}, {title: 'Code Highlighted', block: 'pre', classes: 'prettyprint linenums' } ]}, diff --git a/search.php b/search.php index 8862e13ef..5746b456a 100644 --- a/search.php +++ b/search.php @@ -143,6 +143,8 @@ class search extends e_shortcode { $tp = e107::getParser(); $value = isset($_GET['q']) ? $tp->post_toForm($_GET['q']) : ""; + + $text = "
@@ -822,7 +824,9 @@ class search extends e_shortcode $ns->tablerender(LAN_SEARCH_11." ".$res_display." ".LAN_SEARCH_13." ".(isset($_GET[$advanced_caption['id']]) ? $advanced_caption['title'][$_GET[$advanced_caption['id']]] : $this->search_info[$key]['qtype']), $text, 'search_result'); } + } + } } @@ -1286,93 +1290,17 @@ $text .= $SEARCH_VARS->SEARCH_MESSAGE ? $tp->simpleParse($SEARCH_TABLE_MSG, $SEA //$text .= preg_replace("/\{(.*?)\}/e", '$\1', $SEARCH_BOT_TABLE); $text .= $tp->simpleParse($SEARCH_BOT_TABLE, $SEARCH_VARS); - - -e107::getRender()->tablerender(PAGE_NAME." ".SITENAME, $text, 'search_head'); +if(!isset($_GET['nf'])) // no form flag. +{ + e107::getRender()->tablerender(PAGE_NAME." ".SITENAME, $text, 'search_head'); +} // parse search $SEARCH_VARS = new e_vars(); if ($perform_search) { - $srchObj->renderResults(); - - - /* - $_GET['q'] = rawurlencode($_GET['q']); - $_GET['t'] = preg_replace('/[^\w\-]/i', '', $_GET['t']); - foreach ($search_info as $key => $a) - { - if (isset($searchtype[$key]) || isset($searchtype['all'])) - { - unset($text); - //if (file_exists($search_info[$key]['sfile'])) - { - $pre_title = ($search_info[$key]['pre_title'] == 2) ? $search_info[$key]['pre_title_alt'] : $search_info[$key]['pre_title']; - $search_chars = $search_info[$key]['chars']; - $search_res = $search_info[$key]['results']; - - - e107::getAddon(); - - if(vartrue($search_info[$key]['sfile']) && file_exists($search_info[$key]['sfile'])) // Legacy - { - $text .= '
'; - @require_once($search_info[$key]['sfile']); - $text .= '
'; - } - else// New v2 standard. @see chatbox_menu/e_search.php - { - - $className = $key."_search"; - - $obj = new $className; - - $where = (method_exists($obj,'where')) ? $obj->where($_GET) : ""; - - $ps = $obj->parsesearch($search_info[$key]['table'], $search_info[$key]['return_fields'], $search_info[$key]['search_fields'], $search_info[$key]['weights'], 'self', varset($search_info[$key]['no_results'],LAN_198), $where , $search_info[$key]['order']); - - $text .= '
'; - $text .= $ps['text']; - $text .= '
'; - $results = $ps['results']; - - } - - - $parms = $results.",".$search_res.",".$_GET['r'].",".e_REQUEST_SELF."?q=".$_GET['q']."&t=".$key."&r=[FROM]"; - - $core_parms = array('r' => '', 'q' => '', 't' => '', 's' => ''); - foreach ($_GET as $pparm_key => $pparm_value) - { - $temp = preg_replace('/[^\w_]/i','',$pparm_key); - $temp1 = preg_replace('/[^\w_ +]/i','',$pparm_value); // Filter 'non-word' charcters in search term - if (($temp == $pparm_key) && !isset($core_parms[$pparm_key])) - { - $parms .= "&".$pparm_key."=".$temp1; - } - } - if ($results > $search_res) - { - $nextprev = ($results > $search_res) ? $tp -> parseTemplate("{NEXTPREV={$parms}}") : ""; - $text .= ""; - } - if ($results > 0) - { - $res_from = $_GET['r'] + 1; - $res_to = ($_GET['r'] + $search_res) > $results ? $results : ($_GET['r'] + $search_res); - $res_display = $res_from." - ".$res_to." ".LAN_SEARCH_12." ".$results; - } - else - { - $res_display = ""; - } - $ns->tablerender(LAN_SEARCH_11." ".$res_display." ".LAN_SEARCH_13." ".(isset($_GET[$advanced_caption['id']]) ? $advanced_caption['title'][$_GET[$advanced_caption['id']]] : $search_info[$key]['qtype']), $text, 'search_result'); - } - } - }*/ - }