1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 20:58:30 +01:00

Bootstrap 3 email and print styling. New Social share shortcode added.

This commit is contained in:
Cameron 2014-01-23 09:18:40 -08:00
parent 7f38b232cb
commit 7bb19a0a40
7 changed files with 163 additions and 24 deletions

View File

@ -187,17 +187,31 @@ class news_shortcodes extends e_shortcode
return vartrue($this->news_item['user_id']) ? e107::getParser()->parseTemplate("{USER_AVATAR=".$this->news_item['user_id']."}",true) : ''; return vartrue($this->news_item['user_id']) ? e107::getParser()->parseTemplate("{USER_AVATAR=".$this->news_item['user_id']."}",true) : '';
} }
/**
* {NEWSCOMMENTLINK: glyph=comments&class=btn btn-default btn-sm}
*/
function sc_newscommentlink($parm) function sc_newscommentlink($parm)
{ {
return ($this->news_item['news_allow_comments'] ? $this->param['commentoffstring'] : " <a href='".e107::getUrl()->create('news/view/item', $this->news_item)."'>".$this->param['commentlink'].'</a>');
$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>');
return $text;
} }
/**
* {NEWSCOMMENTCOUNT: glyph=x}
*/
function sc_newscommentcount($parm) function sc_newscommentcount($parm)
{ {
return $this->news_item['news_comment_total']; $text = varset($parm['glyph']) ? e107::getParser()->toGlyph($parm['glyph']) : "";
$text .= $this->news_item['news_comment_total'];
return $text;
} }
function sc_emailicon($parm) /**
* {EMAILICON: class=x}
*/
function sc_emailicon($parm=array())
{ {
$pref = e107::getPref(); $pref = e107::getPref();
if (!check_class(varset($pref['email_item_class'],e_UC_MEMBER))) if (!check_class(varset($pref['email_item_class'],e_UC_MEMBER)))
@ -205,13 +219,16 @@ class news_shortcodes extends e_shortcode
return ''; return '';
} }
require_once(e_HANDLER.'emailprint_class.php'); require_once(e_HANDLER.'emailprint_class.php');
return emailprint::render_emailprint('news', $this->news_item['news_id'], 1); return emailprint::render_emailprint('news', $this->news_item['news_id'], 1, $parm);
} }
function sc_printicon() /**
* {PRINTICON: class=x}
*/
function sc_printicon($parm=array())
{ {
require_once(e_HANDLER.'emailprint_class.php'); require_once(e_HANDLER.'emailprint_class.php');
return emailprint::render_emailprint('news', $this->news_item['news_id'], 2); return emailprint::render_emailprint('news', $this->news_item['news_id'], 2, $parm);
} }
function sc_pdficon() function sc_pdficon()
@ -226,16 +243,22 @@ class news_shortcodes extends e_shortcode
return $this->news_item['news_id']; return $this->news_item['news_id'];
} }
function sc_adminoptions() /**
* {ADMINOPTIONS: class=x}
*/
function sc_adminoptions($parm=array())
{ {
$tp = e107::getParser(); $tp = e107::getParser();
if (ADMIN && getperms('H')) if (ADMIN && getperms('H'))
{ {
//TODO - discuss - a pref for 'new browser window' loading, or a parm or leave 'new browser window' as default? //TODO - discuss - a pref for 'new browser window' loading, or a parm or leave 'new browser window' as default?
$default = (deftrue('BOOTSTRAP')) ? $tp->toGlyph('icon-edit.glyph',false) : "<img src='".e_IMAGE_ABS."admin_images/edit_16.png' alt='".LAN_NEWS_25."' class='icon' />"; $default = (deftrue('BOOTSTRAP')) ? $tp->toGlyph('icon-edit',false) : "<img src='".e_IMAGE_ABS."admin_images/edit_16.png' alt='".LAN_NEWS_25."' class='icon' />";
$adop_icon = (file_exists(THEME."images/newsedit.png") ? "<img src='".THEME_ABS."images/newsedit.png' alt='".LAN_NEWS_25."' class='icon' />" : $default); $adop_icon = (file_exists(THEME."images/newsedit.png") ? "<img src='".THEME_ABS."images/newsedit.png' alt='".LAN_NEWS_25."' class='icon' />" : $default);
return " <a rel='external' href='".e_ADMIN_ABS."newspost.php?action=create&amp;sub=edit&amp;id=".$this->news_item['news_id']."' title=\"".LAN_NEWS_25."\">".$adop_icon."</a>\n";
$class = varset($parm['class']);
return "<a class='e-tip ".$class."' rel='external' href='".e_ADMIN_ABS."newspost.php?action=create&amp;sub=edit&amp;id=".$this->news_item['news_id']."' title=\"".LAN_NEWS_25."\">".$adop_icon."</a>\n";
} }
else else
{ {

View File

@ -1734,6 +1734,16 @@ class e107
*/ */
public static function meta($name = null, $content = null, $extended = array()) public static function meta($name = null, $content = null, $extended = array())
{ {
if($name == 'description')
{
e107::getUrl()->response()->addMetaDescription($content); //Cam: TBD
}
if($name == 'keywords')
{
e107::getUrl()->response()->addMetaKeywords($content); //Cam: TBD
}
return e107::getUrl()->response()->addMeta($name, $content, $extended); return e107::getUrl()->response()->addMeta($name, $content, $extended);
} }

View File

@ -21,7 +21,7 @@ include_lan(e_LANGUAGEDIR.e_LANGUAGE."/lan_email.php");
class emailprint class emailprint
{ {
function render_emailprint($mode, $id, $look = 0) function render_emailprint($mode, $id, $look = 0,$parm=array())
{ {
// $look = 0 --->display all icons // $look = 0 --->display all icons
// $look = 1 --->display email icon only // $look = 1 --->display email icon only
@ -61,12 +61,14 @@ class emailprint
if(deftrue('BOOTSTRAP')) if(deftrue('BOOTSTRAP'))
{ {
$genericMail = $tp->toGlyph('icon-envelope',false); // "<i class='icon-envelope'></i>"; $genericMail = $tp->toGlyph('icon-envelope',false); // "<i class='icon-envelope'></i>";
$genericPrint = $tp->toGlyph('icon-print',false); // "<i class='icon-print'></i>"; $genericPrint = $tp->toGlyph('fa-print',false); // "<i class='icon-print'></i>";
$class = varset($parm['class']) ? $parm['class'] : "";
} }
else // BC else // BC
{ {
$genericMail = "<img src='".e_IMAGE_ABS."generic/email.png' alt='".LAN_EMAIL_7."' />"; $genericMail = "<img src='".e_IMAGE_ABS."generic/email.png' alt='".LAN_EMAIL_7."' />";
$genericPrint = "<img src='".e_IMAGE_ABS."generic/printer.png' alt='".LAN_PRINT_1."' />"; $genericPrint = "<img src='".e_IMAGE_ABS."generic/printer.png' alt='".LAN_PRINT_1."' />";
$class = "";
} }
@ -74,13 +76,13 @@ class emailprint
{ {
$ico_mail = (defined("ICONMAIL") && file_exists(THEME."images/".ICONMAIL) ? "<img src='".THEME_ABS."images/".ICONMAIL."' alt='".LAN_EMAIL_7."' />" : $genericMail); $ico_mail = (defined("ICONMAIL") && file_exists(THEME."images/".ICONMAIL) ? "<img src='".THEME_ABS."images/".ICONMAIL."' alt='".LAN_EMAIL_7."' />" : $genericMail);
//TDOD CSS class //TDOD CSS class
$text_emailprint .= "<a href='".e_HTTP."email.php?".$email.".".$id."' title='".LAN_EMAIL_7."'>".$ico_mail."</a> "; $text_emailprint .= "<a class='e-tip ".$class."' href='".e_HTTP."email.php?".$email.".".$id."' title='".LAN_EMAIL_7."'>".$ico_mail."</a> ";
} }
if ($look == 0 || $look == 2) if ($look == 0 || $look == 2)
{ {
$ico_print = (defined("ICONPRINT") && file_exists(THEME."images/".ICONPRINT) ? "<img src='".THEME_ABS."images/".ICONPRINT."' alt='".LAN_PRINT_1."' />" : $genericPrint); $ico_print = (defined("ICONPRINT") && file_exists(THEME."images/".ICONPRINT) ? "<img src='".THEME_ABS."images/".ICONPRINT."' alt='".LAN_PRINT_1."' />" : $genericPrint);
//TODO CSS class //TODO CSS class
$text_emailprint .= "<a href='".e_HTTP."print.php?".$print.".".$id."' title='".LAN_PRINT_1."'>".$ico_print."</a>"; $text_emailprint .= "<a class='e-tip ".$class."' href='".e_HTTP."print.php?".$print.".".$id."' title='".LAN_PRINT_1."'>".$ico_print."</a>";
} }
return $text_emailprint; return $text_emailprint;
} }

View File

@ -63,5 +63,7 @@ define("LAN_ENTER", "Enter");
define("LAN_ENTER_CODE", "Enter code"); define("LAN_ENTER_CODE", "Enter code");
define("LAN_INVALID_CODE", "Incorrect code entered."); define("LAN_INVALID_CODE", "Incorrect code entered.");
define("LAN_SEARCH", "Search"); define("LAN_SEARCH", "Search");
define("LAN_SHARE", "Share");
?> ?>

View File

@ -103,13 +103,12 @@ $NEWS_TEMPLATE['default']['item'] = '
###### Default view item (temporary) - TODO rewrite news, template standards ###### ###### Default view item (temporary) ######
//$NEWS_MENU_TEMPLATE['view']['start'] = '<ul class="nav nav-list news-menu-months">'; //$NEWS_MENU_TEMPLATE['view']['start'] = '<ul class="nav nav-list news-menu-months">';
//$NEWS_MENU_TEMPLATE['view']['end'] = '</ul>'; //$NEWS_MENU_TEMPLATE['view']['end'] = '</ul>';
// As displayed by news.php?extend.1 // As displayed by news.php?extend.1
//XXX TODO GEt this looking good in the default Bootstrap theme.
$NEWS_TEMPLATE['view']['item'] = ' $NEWS_TEMPLATE['view']['item'] = '
{SETIMAGE: w=900&h=300} {SETIMAGE: w=900&h=300}
<div class="view-item"> <div class="view-item">
@ -131,16 +130,19 @@ $NEWS_TEMPLATE['view']['item'] = '
{EXTENDED} {EXTENDED}
</div> </div>
<hr> <hr>
<div class="options">
<span class="category ">{GLYPH=comments} {NEWSCOMMENTCOUNT} &nbsp; {EMAILICON} &nbsp; {PRINTICON} &nbsp; {PDFICON} &nbsp; {ADMINOPTIONS}</span> <div class="options ">
</div> <div class="btn-group">{NEWSCOMMENTLINK: glyph=comments&class=btn btn-default} &nbsp; {PRINTICON: class=btn btn-default} {PDFICON} {ADMINOPTIONS: class=btn btn-default} {SOCIALSHARE: dropdown=1}</div>
</div>
</div> </div>
{NEWSRELATED} {NEWSRELATED}
<hr>
'; ';
//$NEWS_MENU_TEMPLATE['view']['separator'] = '<br />'; //$NEWS_MENU_TEMPLATE['view']['separator'] = '<br />';
###### news_categories.sc (temporary) - TODO rewrite news ###### news_categories.sc
$NEWS_TEMPLATE['category']['body'] = ' $NEWS_TEMPLATE['category']['body'] = '
<div style="padding:5px"><div style="border-bottom:1px inset black; padding-bottom:1px;margin-bottom:5px"> <div style="padding:5px"><div style="border-bottom:1px inset black; padding-bottom:1px;margin-bottom:5px">
{NEWSCATICON}&nbsp;{NEWSCATEGORY} {NEWSCATICON}&nbsp;{NEWSCATEGORY}

View File

@ -10,6 +10,11 @@ if (!defined('e107_INIT')) { exit; }
class social_shortcodes extends e_shortcode class social_shortcodes extends e_shortcode
{ {
/**
* {XURL_ICONS: size=2x}
*/
function sc_xurl_icons($parm='') function sc_xurl_icons($parm='')
{ {
@ -38,7 +43,7 @@ class social_shortcodes extends e_shortcode
if($data['href'] != '') if($data['href'] != '')
{ {
$text .= '<a rel="external" href="'.$data['href'].'" class="social-icon social-'.$id.'"> $text .= '<a rel="external" href="'.$data['href'].'" class="e-tip social-icon social-'.$id.'">
<span class="fa fa-'.$id.' '.$class.'"></span> <span class="fa fa-'.$id.' '.$class.'"></span>
</a>'; </a>';
@ -54,6 +59,97 @@ class social_shortcodes extends e_shortcode
} }
/**
* {SOCIALSHARE: url=x&title=y}
*/
function sc_socialshare($parm='') // Designed so that no additional JS required.
{
$tp = e107::getParser();
$url = varset($parm['url'], e_REQUEST_URL);
$title = varset($parm['title'], deftrue('e_PAGETITLE'));
$description = varset($parm['title'], e107::getUrl()->response()->getMetaDescription());
$media = "";
$label = varset($parm['label'], defset('LAN_SHARE',"Share"));
$size = varset($parm['size'],'md');
//TODO LANS ie. "Share on [x]"
$providers = array(
'email' => array('icon' => 'fa-envelope-o', 'title'=>"Email to someone", 'url' => "mailto:EMAIL_RECIPIENT?subject=[t]&body=[u]"),
'facebook-like' => array('icon' => 'fa-thumbs-o-up', 'title'=>"Like on Facebook", 'url' => "http://www.facebook.com/plugins/like.php?href=[u]"),
'facebook-share' => array('icon' => 'fa-facebook', 'title'=>"Share on Facebook", 'url' => "http://www.facebook.com/sharer.php?u=[u]&t=[t]"),
'twitter' => array('icon' => 'fa-twitter', 'title'=>"Share on Twitter", 'url' => "http://twitter.com/share?url=[u]&text=[t]"),
'google-plus1' => array('icon' => 'fa-google-plus', 'title'=>"+1 on Google", 'url' => "https://apis.google.com/_/+1/fastbutton?usegapi=1&size=large&hl=en&url=[u]"),
// 'google-plus' => array('icon' => 'fa-google-plus', 'title'=>"On Google Plus", 'url' => "https://plusone.google.com/_/+1/confirm?hl=en&url=[u]"),
'linkedin' => array('icon' => 'fa-linkedin', 'title'=>"Share on LinkedIn", 'url' => "http://www.linkedin.com/shareArticle?mini=true&url=[u]"),
'pinterest' => array('icon' => 'fa-pinterest', 'title'=>"Share on Pinterest", 'url' => "http://www.pinterest.com/pin/create/button/?url=[u]&description=[t]&media=[m]"),
// 'thumblr' => array('icon' => 'fa-tumblr', 'title'=>"On Tumblr", 'url' => "http://www.tumblr.com/share/link?url=[u]&name=[t]&description=[d]"),
// 'stumbleupon' => array('icon' => 'fa-stumbleupon', 'title'=>"On Tumblr", 'url' => "http://www.stumbleupon.com/submit?url=[u]&title=[t]"), // no fa icon available.
//http://reddit.com/submit?url=http%3A%2F%2Fwebsite.com&title=Website%20Title // no fa icon available
//http://www.digg.com/submit?url=http%3A%2F%2Fwebsite.com // no fa icon available
);
$data = array('u'=> rawurlencode($url), 't'=> rawurlencode($title), 'd' => rawurlencode($description), 'm' => rawurlencode($media));
if(!vartrue($parm['dropdown']))
{
$butSize = ($size == 'lg' || $size == 'sm' || $size == 'xs') ? 'btn-'.$size : '';
}
else
{
$butSize = 'btn-lg';
}
$opt = array();
foreach($providers as $val)
{
$shareUrl = $tp->lanVars($val['url'],$data);
$opt[] = "<a class='e-tip btn ".$butSize." btn-default social-share' target='_blank' title='".$val["title"]."' href='".$shareUrl."'>".$tp->toIcon($val["icon"])."</a>";
}
if(vartrue($parm['dropdown']))
{
$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>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel" style="min-width:355px">
<li><div class="btn-group" style="padding-left: 7px;">'.implode("\n",$opt).'</div></li>
</ul>
</div>';
return $text;
}
else
{
return '<div class="btn-group text-center"><button class="btn btn-sm btn-default disabled">'.$label.'</button>'.implode("\n",$opt)."</div>";
}
}
} }
?> ?>

View File

@ -8,14 +8,18 @@ define("BOOTSTRAP", 3);
define("FONTAWESOME", 4); define("FONTAWESOME", 4);
define('VIEWPORT', "width=device-width, initial-scale=1.0"); define('VIEWPORT', "width=device-width, initial-scale=1.0");
e107::js("url", "//netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"); e107::js("url", "//netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js");
e107::css('url', '//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css'); e107::css('url', '//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css');
e107::css('url', "//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css"); e107::css('url', "//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css");
e107::js("footer-inline", "$('.e-tip').tooltip({container: 'body'})"); // activate bootstrap tooltips.
define('OTHERNEWS_COLS',false); // no tables, only divs. define('OTHERNEWS_COLS',false); // no tables, only divs.
define('OTHERNEWS_LIMIT', 3); // Limit to 3. define('OTHERNEWS_LIMIT', 3); // Limit to 3.
define('OTHERNEWS2_COLS',false); // no tables, only divs. define('OTHERNEWS2_COLS',false); // no tables, only divs.
define('OTHERNEWS2_LIMIT', 3); // Limit to 3. define('OTHERNEWS2_LIMIT', 3); // Limit to 3.
define('COMMENTLINK', $tp->toGlyph('fa-comment'));
define('COMMENTOFFSTRING', '');
define('PRE_EXTENDEDSTRING', '<br />'); define('PRE_EXTENDEDSTRING', '<br />');