mirror of
https://github.com/e107inc/e107.git
synced 2025-04-22 13:41:52 +02:00
Issue #2795 Support multiple news 'view' layouts (requires database update)
This commit is contained in:
parent
9606105e24
commit
13d58de464
e107_admin
e107_core/sql
e107_handlers
e107_plugins/news
@ -443,14 +443,18 @@ class news_admin_ui extends e_admin_ui
|
||||
'news_sef' => array('title' => LAN_SEFURL, 'type' => 'text', 'batch'=>1, 'data'=>'str', 'tab'=>1, 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'writeParms'=>array('size'=>'xxlarge', 'show'=>1, 'sef'=>'news_title')),
|
||||
'news_ping' => array('title' => LAN_PING, 'type' => 'checkbox', 'tab'=>1, 'data'=>false, 'writeParms'=>'value=0', 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
|
||||
|
||||
'news_author' => array('title' => LAN_AUTHOR, 'type' => 'method', 'tab'=>0, 'readParms'=>'idField=user_id&nameField=user_name', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
|
||||
'news_author' => array('title' => LAN_AUTHOR, 'type' => 'method', 'tab'=>2, 'readParms'=>'idField=user_id&nameField=user_name', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
|
||||
'news_datestamp' => array('title' => LAN_NEWS_32, 'type' => 'datestamp', 'data'=>'int', 'tab'=>2, 'writeParms'=>'type=datetime', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'parms' => 'mask=%A %d %B %Y', 'filter'=>true),
|
||||
'news_category' => array('title' => NWSLAN_6, 'type' => 'dropdown', 'data'=>'int', 'tab'=>0, 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'batch'=>true, 'filter'=>true),
|
||||
'news_start' => array('title' => LAN_START, 'type' => 'datestamp', 'data'=>'int', 'tab'=>2, 'writeParms'=>'type=datetime', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'parms' => 'mask=%A %d %B %Y'),
|
||||
'news_end' => array('title' => LAN_END, 'type' => 'datestamp', 'data'=>'int', 'tab'=>2, 'writeParms'=>'type=datetime', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'parms' => 'mask=%A %d %B %Y'),
|
||||
'news_class' => array('title' => LAN_VISIBILITY, 'type' => 'userclass', 'tab'=>2, 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'batch'=>true, 'filter'=>true),
|
||||
'news_render_type' => array('title' => LAN_TEMPLATE, 'type' => 'dropdown', 'data'=>'str', 'tab'=>0, 'inline'=>true, 'readParms'=>array('type'=>'checkboxes'), 'width' => 'auto', 'thclass' => 'left', 'class' => 'left', 'nosort' => false, 'batch'=>true, 'filter'=>true),
|
||||
'news_sticky' => array('title' => LAN_NEWS_28, 'type' => 'boolean', 'data'=>'int', 'tab'=>2, 'width' => 'auto', 'thclass' => 'center', 'class' => 'center', 'nosort' => false, 'batch'=>true, 'filter'=>true),
|
||||
|
||||
'news_template' => array('title' => LAN_TEMPLATE, 'type' => 'method', 'data'=>'str', 'tab'=>0, 'inline'=>true, 'writeParms'=>'', 'width' => 'auto', 'thclass' => 'left', 'class' => 'left', 'nosort' => false, 'batch'=>true, 'filter'=>true),
|
||||
|
||||
'news_render_type' => array('title' => LAN_LOCATION, 'type' => 'dropdown', 'data'=>'str', 'tab'=>0, 'inline'=>true, 'readParms'=>array('type'=>'checkboxes'), 'width' => 'auto', 'thclass' => 'left', 'class' => 'left', 'nosort' => false, 'batch'=>true, 'filter'=>true),
|
||||
|
||||
'news_sticky' => array('title' => LAN_NEWS_28, 'type' => 'boolean', 'data'=>'int', 'tab'=>2, 'width' => 'auto', 'thclass' => 'center', 'class' => 'center', 'nosort' => false, 'batch'=>true, 'filter'=>true),
|
||||
'news_allow_comments' => array('title' => LAN_COMMENTS, 'type' => 'boolean', 'data'=>'int', 'tab'=>2, 'writeParms'=>'inverse=1', 'width' => 'auto', 'thclass' => 'center', 'class' => 'center', 'nosort' => false,'batch'=>true, 'filter'=>true,'readParms'=>'reverse=1'),
|
||||
'news_comment_total' => array('title' => LAN_NEWS_60, 'type' => 'number', 'data'=>'int', 'tab'=>2, 'noedit'=>true, 'width' => '10%', 'thclass' => '', 'class' => null, 'nosort' => false),
|
||||
// admin_news_notify
|
||||
@ -742,8 +746,9 @@ class news_admin_ui extends e_admin_ui
|
||||
'news_category',
|
||||
'news_title' ,
|
||||
'news_summary',
|
||||
'news_template',
|
||||
'news_render_type',
|
||||
'news_author' ,
|
||||
|
||||
'news_body',
|
||||
'news_extended',
|
||||
'news_thumbnail',
|
||||
@ -757,6 +762,7 @@ class news_admin_ui extends e_admin_ui
|
||||
'news_allow_comments' ,
|
||||
'news_start' ,
|
||||
'news_end' ,
|
||||
'news_author' ,
|
||||
'news_datestamp' ,
|
||||
'news_class',
|
||||
'news_sticky',
|
||||
@ -1442,6 +1448,39 @@ class news_admin_ui extends e_admin_ui
|
||||
class news_form_ui extends e_admin_form_ui
|
||||
{
|
||||
|
||||
function news_template($curVal,$mode)
|
||||
{
|
||||
if($mode === 'read')
|
||||
{
|
||||
return $curVal;
|
||||
}
|
||||
|
||||
|
||||
if($mode === 'write')
|
||||
{
|
||||
if($tmp = e107::getTemplate('news', 'news', 'view'))
|
||||
{
|
||||
return LAN_DEFAULT;
|
||||
}
|
||||
|
||||
if($tmp = e107::getTemplateInfo('news', 'news_view'))
|
||||
{
|
||||
$opt = array();
|
||||
foreach($tmp as $k=>$val)
|
||||
{
|
||||
$opt[$k] = $val['title'];
|
||||
|
||||
}
|
||||
return $this->select('news_template', $opt, $curVal, array('size'=>'xlarge'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
return LAN_DEFAULT;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function news_author($curVal, $mode)
|
||||
{
|
||||
@ -1476,7 +1515,7 @@ class news_form_ui extends e_admin_form_ui
|
||||
}
|
||||
else // allow master admin to
|
||||
{
|
||||
$text .= $this->select_open('news_author');
|
||||
$text .= $this->select_open('news_author', array('size'=>'xlarge'));
|
||||
$qry = "SELECT user_id,user_name,user_admin FROM #user WHERE user_perms = '0' OR user_perms = '0.' OR user_perms REGEXP('(^|,)(H)(,|$)') ";
|
||||
|
||||
if(!empty($curVal))
|
||||
|
@ -318,6 +318,7 @@ CREATE TABLE news (
|
||||
news_summary text NOT NULL,
|
||||
news_thumbnail text NOT NULL,
|
||||
news_sticky tinyint(3) unsigned NOT NULL default '0',
|
||||
news_template varchar(50) NOT NULL default '',
|
||||
PRIMARY KEY (news_id),
|
||||
KEY news_category (news_category),
|
||||
KEY news_start_end (news_start,news_end),
|
||||
|
@ -374,7 +374,7 @@ class news {
|
||||
|
||||
// Retrieve batch sc object, set required vars
|
||||
|
||||
$wrapperKey = (!empty($param['template_key'])) ? 'news/'.$param['template_key'].'/item' : 'news/view/item';
|
||||
$wrapperKey = (!empty($param['template_key'])) ? $param['template_key'].'/item' : 'news/view/item';
|
||||
|
||||
$editable = array(
|
||||
'table' => 'news',
|
||||
|
@ -854,7 +854,7 @@ class news_front
|
||||
$param['catlink'] = (defined("NEWSLIST_CATLINK")) ? NEWSLIST_CATLINK : "";
|
||||
$param['caticon'] = (defined("NEWSLIST_CATICON")) ? NEWSLIST_CATICON : defset('ICONSTYLE','');
|
||||
$param['current_action'] = $action;
|
||||
$param['template_key'] = 'list';
|
||||
$param['template_key'] = 'news/list';
|
||||
|
||||
// NEW - allow news batch shortcode override (e.g. e107::getScBatch('news', 'myplugin', true); )
|
||||
e107::getEvent()->trigger('news_list_parse', $newsList);
|
||||
@ -1053,7 +1053,7 @@ class news_front
|
||||
|
||||
$param = array();
|
||||
$param['current_action'] = $action;
|
||||
$param['template_key'] = 'view';
|
||||
$param['template_key'] = 'news/view';
|
||||
|
||||
if(vartrue($NEWSSTYLE))
|
||||
{
|
||||
@ -1066,6 +1066,14 @@ class news_front
|
||||
else
|
||||
{
|
||||
$tmp = e107::getTemplate('news', 'news', 'view');
|
||||
|
||||
if(empty($tmp))
|
||||
{
|
||||
$newsViewTemplate = !empty($news['news_template']) ? $news['news_template'] : 'default';
|
||||
$tmp = e107::getTemplate('news', 'news_view', $newsViewTemplate);
|
||||
$param['template_key'] = 'news_view/'.$newsViewTemplate;
|
||||
}
|
||||
|
||||
$template = $tmp['item'];
|
||||
unset($tmp);
|
||||
}
|
||||
@ -1480,7 +1488,7 @@ class news_front
|
||||
// #### normal newsitems, rendered via render_newsitem(), the $query is changed above (no other changes made) ---------
|
||||
$param = array();
|
||||
$param['current_action'] = $action;
|
||||
$param['template_key'] = 'default';
|
||||
$param['template_key'] = 'news/default';
|
||||
|
||||
// Get Correct Template
|
||||
// XXX we use $NEWSLISTSTYLE above - correct as we are currently in list mode - XXX No this is not NEWSLISTSTYLE - which provides only summaries.
|
||||
@ -1502,7 +1510,7 @@ class news_front
|
||||
{
|
||||
$tmpl = $layout['category'];
|
||||
$template = $tmpl['item'];
|
||||
$param['template_key'] = 'category';
|
||||
$param['template_key'] = 'news/category';
|
||||
}
|
||||
|
||||
|
||||
|
@ -131,7 +131,9 @@ $NEWS_TEMPLATE['category']['start'] = '<!-- Category News Template -->';
|
||||
|
||||
// As displayed by news.php?extend.1
|
||||
|
||||
//@XXX SEE news_view_template.php
|
||||
|
||||
/*
|
||||
$NEWS_WRAPPER['view']['item']['NEWSIMAGE: item=1'] = '<span class="news-images-main pull-left col-xs-12 col-sm-6 col-md-6">{---}</span>';
|
||||
|
||||
$NEWS_TEMPLATE['view']['item'] = '
|
||||
@ -197,7 +199,7 @@ $NEWS_TEMPLATE['view']['item'] = '
|
||||
{NEWSNAVLINK}
|
||||
|
||||
';
|
||||
|
||||
*/
|
||||
/*
|
||||
* <hr />
|
||||
<h3>About the Author</h3>
|
||||
|
96
e107_plugins/news/templates/news_view_template.php
Normal file
96
e107_plugins/news/templates/news_view_template.php
Normal file
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/**
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2017 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
$NEWS_VIEW_INFO = array(
|
||||
|
||||
'default' => array('title' => LAN_DEFAULT, 'description' => 'unused'),
|
||||
'videos' => array('title' => "Videos (experimental)", 'description' => 'unused'),
|
||||
);
|
||||
|
||||
|
||||
// Default
|
||||
$NEWS_VIEW_WRAPPER['default']['item']['NEWSIMAGE: item=1'] = '<span class="news-images-main pull-left col-xs-12 col-sm-6 col-md-6">{---}</span>';
|
||||
|
||||
$NEWS_VIEW_TEMPLATE['default']['item'] = '
|
||||
{SETIMAGE: w=900&h=600}
|
||||
<div class="view-item">
|
||||
<h2 class="news-title">{NEWS_TITLE: link=1}</h2>
|
||||
|
||||
<hr class="news-heading-sep">
|
||||
<div class="row">
|
||||
<div class="col-md-6"><small>{GLYPH=user} {NEWSAUTHOR} {GLYPH=time} {NEWSDATE=short} </small></div>
|
||||
<div class="col-md-6 text-right options"><small>{GLYPH=tags} {NEWSTAGS} {GLYPH=folder-open} {NEWSCATEGORY} </small></div>
|
||||
</div>
|
||||
<hr>
|
||||
|
||||
|
||||
<div class="body">
|
||||
{NEWSIMAGE: item=1}
|
||||
<p class="lead">{NEWS_SUMMARY}</p>
|
||||
<div class="text-justify">
|
||||
{NEWS_BODY=body}
|
||||
</div>
|
||||
<div class="news-videos-1">
|
||||
{NEWSVIDEO: item=1}
|
||||
{NEWSVIDEO: item=2}
|
||||
{NEWSVIDEO: item=3}
|
||||
</div>
|
||||
|
||||
|
||||
<br />
|
||||
{SETIMAGE: w=400&h=400}
|
||||
|
||||
<div class="row news-images-1">
|
||||
<div class="col-md-6">{NEWSIMAGE: item=2}</div>
|
||||
<div class="col-md-6">{NEWSIMAGE: item=3}</div>
|
||||
</div>
|
||||
<div class="row news-images-2">
|
||||
<div class="col-md-6">{NEWSIMAGE: item=4}</div>
|
||||
<div class="col-md-6">{NEWSIMAGE: item=5}</div>
|
||||
</div>
|
||||
|
||||
{NEWSVIDEO: item=4}
|
||||
{NEWSVIDEO: item=5}
|
||||
|
||||
<div class="body-extended text-justify">
|
||||
{NEWS_BODY=extended}
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="options hidden-print ">
|
||||
<div class="btn-group">{NEWSCOMMENTLINK: glyph=comments&class=btn btn-default}{PRINTICON: class=btn btn-default}{ADMINOPTIONS: class=btn btn-default}{SOCIALSHARE}</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
{NEWSRELATED}
|
||||
<hr>
|
||||
{NEWSNAVLINK}
|
||||
|
||||
';
|
||||
|
||||
|
||||
// @todo add more templates. eg. 'videos' , 'slideshow images', 'full width image' - help and ideas always appreciated.
|
||||
|
||||
|
||||
// Videos
|
||||
$NEWS_VIEW_TEMPLATE['videos']['item'] = '<div class="view-item"><div class="alert alert-warning">Empty news_view_template.php (videos) - have ideas? let us know.</div></div>';
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user