1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 04:38:27 +01:00

news_render_type fixes. Path fix for othernews menus.

This commit is contained in:
CaMer0n 2012-11-01 02:21:58 +00:00
parent f0d232a639
commit 7030f69f46
9 changed files with 77 additions and 50 deletions

View File

@ -307,7 +307,7 @@ class news_admin_ui extends e_admin_ui
'news_end' => array('title' => "End", 'type' => 'datestamp', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'parms' => 'mask=%A %d %B %Y'),
'news_class' => array('title' => NWSLAN_22, 'type' => 'userclasses', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'batch'=>true, 'filter'=>true),
'news_render_type' => array('title' => LAN_TEMPLATE, 'type' => 'dropdown', 'data' => 'str', 'width' => 'auto', 'thclass' => 'center', 'class' => null, 'nosort' => false, 'batch'=>true, 'filter'=>true),
'news_render_type' => array('title' => LAN_TEMPLATE, 'type' => 'dropdown', 'data' => 'comma', 'width' => 'auto', 'thclass' => 'center', 'class' => null, 'nosort' => false, 'batch'=>true, 'filter'=>true),
'news_sticky' => array('title' => LAN_NEWS_28, 'type' => 'boolean', 'width' => 'auto', 'thclass' => 'center', 'class' => 'center', 'nosort' => false, 'batch'=>true, 'filter'=>true),
'news_allow_comments' => array('title' => NWSLAN_15, 'type' => 'boolean', 'width' => 'auto', 'thclass' => 'center', 'class' => 'center', 'nosort' => false,'batch'=>true, 'filter'=>true,'readParms'=>'reverse=1','writeParms'=>'reverse=1'),
'news_comment_total' => array('title' => LAN_NEWS_60, 'type' => 'number', 'width' => '10%', 'thclass' => '', 'class' => null, 'nosort' => false),
@ -320,6 +320,18 @@ class news_admin_ui extends e_admin_ui
protected $cats = array();
protected $newspost;
protected $news_renderTypes = array(
'0' => "Default",
'1' => "Default - Title",
'4' => "Default - Title/Summary",
'2' => "Sidebar - Othernews",
'3' => "Sidebar - Othernews 2",
'5' => "Featurebox"
);
function init()
{
@ -332,9 +344,15 @@ class news_admin_ui extends e_admin_ui
}
asort($this->cats);
$this->fields['news_category']['writeParms'] = $this->cats;
$this->fields['news_render_type']['writeParms'] = array(NWSLAN_75,NWSLAN_76,NWSLAN_77,NWSLAN_77." 2","Featurebox");
$this->fields['news_render_type']['writeParms'] = $this->news_renderTypes; // array(NWSLAN_75,NWSLAN_76,NWSLAN_77,NWSLAN_77." 2","Featurebox");
$this->newspost = new admin_newspost;
$this->newspost->news_renderTypes = $this->news_renderTypes;
$this->newspost->observer();
@ -541,7 +559,7 @@ function headerjs()
</script>";
*/
// TODO - move this to external JS when news becomes a plugin
// TODO - REMOVE
$ret .= "
<script type='text/javascript'>
if(typeof e107Admin == 'undefined') var e107Admin = {}
@ -721,7 +739,8 @@ class admin_newspost
var $_sort_link;
var $fieldpref;
var $news_categories;
var $news_renderTypes = array();
public $news_renderTypes = array();
public $error = false;
@ -742,29 +761,29 @@ class admin_newspost
$this->fieldpref = varset($user_pref['admin_news_columns'], array('news_id', 'news_title', 'news_author', 'news_render_type', 'options'));
$this->fields = array(
'checkboxes' => array('title' => '', 'type' => null, 'width' => '3%', 'thclass' => 'center first', 'class' => 'center', 'nosort' => true, 'toggle' => 'news_selected', 'forced' => TRUE),
'news_id' => array('title' => LAN_NEWS_45, 'type' => 'number', 'width' => '5%', 'thclass' => 'center', 'class' => 'center', 'nosort' => false),
'news_thumbnail' => array('title' => NWSLAN_67, 'type' => 'image', 'width' => '110px', 'thclass' => 'center', 'class' => "center", 'nosort' => false, 'readParms'=>'thumb=60&thumb_urlraw=0&thumb_aw=60','writeParams' => 'path={e_MEDIA}','readonly'=>false),
'news_title' => array('title' => NWSLAN_40, 'type' => 'text', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
'news_summary' => array('title' => LAN_NEWS_27, 'type' => 'text', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
'checkboxes' => array('title' => '', 'type' => null, 'data'=> false, 'width' => '3%', 'thclass' => 'center first', 'class' => 'center', 'nosort' => true, 'toggle' => 'news_selected', 'forced' => TRUE),
'news_id' => array('title' => LAN_NEWS_45, 'type' => 'number', 'data'=> 'int', 'width' => '5%', 'thclass' => 'center', 'class' => 'center', 'nosort' => false),
'news_thumbnail' => array('title' => NWSLAN_67, 'type' => 'image', 'data'=> 'str', 'width' => '110px', 'thclass' => 'center', 'class' => "center", 'nosort' => false, 'readParms'=>'thumb=60&thumb_urlraw=0&thumb_aw=60','writeParams' => 'path={e_MEDIA}','readonly'=>false),
'news_title' => array('title' => NWSLAN_40, 'type' => 'text', 'data'=> 'str','width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
'news_summary' => array('title' => LAN_NEWS_27, 'type' => 'text', 'data'=> 'str','width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
'news_meta_keywords' => array('title' => LAN_KEYWORDS, 'type' => 'text', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
'news_meta_description' => array('title' => LAN_DESCRIPTION,'type' => 'text', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
'news_sef' => array('title' => 'SEF URL', 'type' => 'text', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
'user_name' => array('title' => LAN_NEWS_50, 'type' => 'text', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
'news_datestamp' => array('title' => LAN_NEWS_32, 'type' => 'datestamp', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'parms' => 'mask=%A %d %B %Y'),
'category_name' => array('title' => NWSLAN_6, 'type' => 'text', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
'news_meta_keywords' => array('title' => LAN_KEYWORDS, 'type' => 'text', 'data'=> 'str','width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
'news_meta_description' => array('title' => LAN_DESCRIPTION,'type' => 'text', 'data'=> 'str','width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
'news_sef' => array('title' => 'SEF URL', 'type' => 'text', 'data'=> 'str','width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
'user_name' => array('title' => LAN_NEWS_50, 'type' => 'text', 'data'=> 'str','width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
'news_datestamp' => array('title' => LAN_NEWS_32, 'type' => 'datestamp', 'data'=> 'str','width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'parms' => 'mask=%A %d %B %Y'),
'category_name' => array('title' => NWSLAN_6, 'type' => 'text', 'data'=> 'str','width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
'news_start' => array('title' => "Start", 'type' => 'datestamp', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'parms' => 'mask=%A %d %B %Y'),
'news_end' => array('title' => "End", 'type' => 'datestamp', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'parms' => 'mask=%A %d %B %Y'),
'news_start' => array('title' => "Start", 'type' => 'datestamp', 'data'=> 'str','width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'parms' => 'mask=%A %d %B %Y'),
'news_end' => array('title' => "End", 'type' => 'datestamp', 'data'=> 'str','width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'parms' => 'mask=%A %d %B %Y'),
'news_class' => array('title' => NWSLAN_22, 'type' => 'userclass', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
'news_render_type' => array('title' => LAN_NEWS_49, 'type' => 'number', 'width' => 'auto', 'thclass' => 'center', 'class' => null, 'nosort' => false),
'news_sticky' => array('title' => LAN_NEWS_28, 'type' => 'boolean', 'width' => 'auto', 'thclass' => 'center', 'class' => 'center', 'nosort' => false),
'news_allow_comments' => array('title' => NWSLAN_15, 'type' => 'boolean', 'width' => 'auto', 'thclass' => 'center', 'class' => 'center', 'nosort' => false),
'news_comment_total' => array('title' => LAN_NEWS_60, 'type' => 'number', 'width' => '10%', 'thclass' => '', 'class' => null, 'nosort' => false),
'options' => array('title' => LAN_OPTIONS, 'type' => null, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center', 'nosort' => true, 'forced' => TRUE)
'news_class' => array('title' => NWSLAN_22, 'type' => 'userclass', 'data'=> 'str', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
'news_render_type' => array('title' => LAN_NEWS_49, 'type' => 'dropdown', 'data'=> 'comma', 'width' => 'auto', 'thclass' => 'center', 'class' => null, 'nosort' => false),
'news_sticky' => array('title' => LAN_NEWS_28, 'type' => 'boolean', 'data'=> 'int', 'width' => 'auto', 'thclass' => 'center', 'class' => 'center', 'nosort' => false),
'news_allow_comments' => array('title' => NWSLAN_15, 'type' => 'boolean', 'data'=> 'int', 'width' => 'auto', 'thclass' => 'center', 'class' => 'center', 'nosort' => false),
'news_comment_total' => array('title' => LAN_NEWS_60, 'type' => 'number', 'data'=> 'int', 'width' => '10%', 'thclass' => '', 'class' => null, 'nosort' => false),
'options' => array('title' => LAN_OPTIONS, 'type' => null, 'data'=> false, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center', 'nosort' => true, 'forced' => TRUE)
);
@ -776,8 +795,9 @@ class admin_newspost
$this->news_renderTypes[$key] = $value;
}*/
$this->news_renderTypes = array('0'=>NWSLAN_75,'1'=>NWSLAN_76,'2'=>NWSLAN_77,'3'=>NWSLAN_77." 2",'4'=>"Featurebox");
// $this->news_renderTypes = array('0'=>NWSLAN_75,'1'=>NWSLAN_76,'2'=>NWSLAN_77,'3'=>NWSLAN_77." 2",'4'=>"Featurebox");
// $this->news_renderTypes = array('0'=>"FrontPage",'1'=>"FrontPage - Linkonly",'2'=>"Othernews Sidebar",'3'=>"Othernews Sidebar"." 2",'4'=>"Featurebox");
}
function parseRequest($qry)
@ -1077,7 +1097,6 @@ class admin_newspost
$_POST['news_start'] = vartrue(e107::getDate()->convert($_POST['news_start'],'inputdatetime'), 0);
// echo "date=".$_POST['news_start'];
if($_POST['news_start'])
{
// $_POST['news_start'] = e107::getDate()->convert($_POST['news_start']);
@ -1930,9 +1949,21 @@ class admin_newspost
</tr>
<tr>
<td class='label'>".LAN_TEMPLATE.":</td>
<td class='control'>
";
//XXX multiple-selections at once. (comma separated) - working
$text .= $frm->selectbox('news_render_type', $this->news_renderTypes, $_POST['news_render_type'], "multiple=1",array(NWSLAN_74))."
<div class='field-help'>
".NWSLAN_74."
</div>
</td>
</tr>
";
// -------- News Author ---------------------
$text .="
@ -2136,18 +2167,7 @@ class admin_newspost
</div>
</td>
</tr>
<tr>
<td class='label'>".LAN_TEMPLATE.":</td>
<td class='control'>
";
//TODO multiple-selections at once. (comma separated)
$text .= $frm->selectbox('news_render_type', $this->news_renderTypes, intval($_POST['news_render_type']), "multiple=1",array(NWSLAN_74))."
<div class='field-help'>
".NWSLAN_74."
</div>
</td>
</tr>
<tr>
<td class='label'>".NWSLAN_19.":</td>
<td class='control'>

View File

@ -343,7 +343,10 @@ function update_706_to_800($type='')
array('oldpath' => 'counter_menu', 'newpath' => 'siteinfo', 'menu' => 'counter_menu'),
array('oldpath' => 'usertheme_menu', 'newpath' => 'user_menu', 'menu' => 'usertheme_menu'),
array('oldpath' => 'userlanguage_menu', 'newpath' => 'user_menu', 'menu' => 'userlanguage_menu'),
array('oldpath' => 'lastseen_menu', 'newpath' => 'online', 'menu' => 'lastseen_menu')
array('oldpath' => 'lastseen_menu', 'newpath' => 'online', 'menu' => 'lastseen_menu'),
array('oldpath' => 'other_news_menu', 'newpath' => 'news', 'menu' => 'other_news_menu'),
array('oldpath' => 'other_news_menu', 'newpath' => 'news', 'menu' => 'other_news2_menu')
);

View File

@ -1719,7 +1719,7 @@ class e_form
case 'dropdown':
// XXX - should we use readParams at all here? see writeParms check below
if($parms && is_array($parms)) // FIXME - add support for multi-level arrays (option groups)
{
$value = vartrue($parms['pre']).vartrue($parms[$value]).vartrue($parms['post']);
@ -1735,7 +1735,7 @@ class e_form
$opts = $wparms['__options'];
unset($wparms['__options']);
if($opts['multiple'])
if($opts['multiple'] || $attributes['data']=='comma')
{
$ret = array();
$value = is_array($value) ? $value : explode(',', $value);
@ -1752,6 +1752,8 @@ class e_form
$value = $ret;
}
$value = ($value ? vartrue($parms['pre']).defset($value, $value).vartrue($parms['post']) : '');
// return ;
break;
case 'radio':
@ -2198,6 +2200,7 @@ class e_form
break;
case 'dropdown':
$eloptions = vartrue($parms['__options'], array());
if(is_string($eloptions)) parse_str($eloptions, $eloptions);
unset($parms['__options']);

View File

@ -151,6 +151,7 @@ class news {
return $data;
}
// Calculate short strings for admin logging - no need to clog up the log with potentially long items
$logData = $data['data'];
if (isset($logData['news_body'])) $logData['news_body'] = $tp->text_truncate($tp->toDB($logData['news_body']),300,'...');

View File

@ -40,7 +40,7 @@ class news_featurebox // include plugin-folder in the name.
$fbox = array();
$nobody_regexp = "'(^|,)(".str_replace(",", "|", e_UC_NOBODY).")(,|$)'";
$query = "SELECT * FROM #news WHERE news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (news_class REGEXP ".$nobody_regexp.") AND FIND_IN_SET(4,news_render_type) ORDER BY news_datestamp DESC LIMIT 10";
$query = "SELECT * FROM #news WHERE news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (news_class REGEXP ".$nobody_regexp.") AND FIND_IN_SET(5,news_render_type) ORDER BY news_datestamp DESC LIMIT 10";
if($sql->db_Select_gen($query))
{

View File

@ -91,7 +91,7 @@ $nbr_cols = OTHERNEWS2_COLS;
$query = "SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n
LEFT JOIN #user AS u ON n.news_author = u.user_id
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
WHERE n.news_class IN (".USERCLASS_LIST.") AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().") AND n.news_render_type=3 ORDER BY n.news_datestamp DESC LIMIT 0,".OTHERNEWS2_LIMIT;
WHERE n.news_class IN (".USERCLASS_LIST.") AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().") AND FIND_IN_SET(3, n.news_render_type) ORDER BY n.news_datestamp DESC LIMIT 0,".OTHERNEWS2_LIMIT;
if ($sql->db_Select_gen($query)) {
$text = "<table style='width:100%' cellpadding='0' cellspacing='".OTHERNEWS2_SPACING."'>";

View File

@ -88,7 +88,7 @@ $nbr_cols = OTHERNEWS_COLS;
$query = "SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n
LEFT JOIN #user AS u ON n.news_author = u.user_id
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
WHERE n.news_class IN (".USERCLASS_LIST.") AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().") AND n.news_render_type=2 ORDER BY n.news_datestamp DESC LIMIT 0,".OTHERNEWS_LIMIT;
WHERE n.news_class IN (".USERCLASS_LIST.") AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().") AND FIND_IN_SET(2, n.news_render_type) ORDER BY n.news_datestamp DESC LIMIT 0,".OTHERNEWS_LIMIT;
if ($sql->db_Select_gen($query)){
$text = "<table style='width:100%' cellpadding='0' cellspacing='".OTHERNEWS_SPACING."'>";

View File

@ -204,14 +204,14 @@ class rssCreate
}
$path='';
$render = ($pref['rss_othernews'] != 1) ? "AND n.news_render_type < 2" : "";
$render = ($pref['rss_othernews'] != 1) ? "AND (FIND_IN_SET('0', n.news_render_type) OR FIND_IN_SET(1, n.news_render_type))" : "";
$nobody_regexp = "'(^|,)(".str_replace(",", "|", e_UC_NOBODY).")(,|$)'";
$this -> rssQuery = "
SELECT n.*, u.user_id, u.user_name, u.user_email, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n
LEFT JOIN #user AS u ON n.news_author = u.user_id
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
WHERE n.news_class IN (".USERCLASS_LIST.") AND NOT (n.news_class REGEXP ".$nobody_regexp.") AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().") {$render} {$topic} ORDER BY news_datestamp DESC LIMIT 0,".$this -> limit;
WHERE n.news_class IN (".USERCLASS_LIST.") AND NOT (n.news_class REGEXP ".$nobody_regexp.") AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().") {$render} {$topic} ORDER BY n.news_datestamp DESC LIMIT 0,".$this -> limit;
$sql->db_Select_gen($this -> rssQuery);
$tmp = $sql->db_getList();
$this -> rssItems = array();

View File

@ -495,7 +495,7 @@ switch ($action)
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$nobody_regexp.")
AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().")
AND n.news_render_type<2 AND n.news_datestamp > {$startdate} AND n.news_datestamp < {$enddate}
AND (FIND_IN_SET('0', n.news_render_type) OR FIND_IN_SET(1, n.news_render_type)) AND n.news_datestamp > {$startdate} AND n.news_datestamp < {$enddate}
ORDER BY ".$order." DESC LIMIT ".intval($newsfrom).",".ITEMVIEW;
break;
@ -523,7 +523,7 @@ switch ($action)
LEFT JOIN #trackback AS tb ON tb.trackback_pid = n.news_id
WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$nobody_regexp.")
AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().")
AND n.news_render_type<2
AND (FIND_IN_SET('0', n.news_render_type) OR FIND_IN_SET(1, n.news_render_type))
GROUP by n.news_id
ORDER BY news_sticky DESC, ".$order." DESC LIMIT ".intval($newsfrom).",".$pref['newsposts'];
}
@ -537,7 +537,7 @@ switch ($action)
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$nobody_regexp.")
AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().")
AND n.news_render_type<2
AND (FIND_IN_SET('0', n.news_render_type) OR FIND_IN_SET(1, n.news_render_type))
ORDER BY n.news_sticky DESC, ".$order." DESC LIMIT ".intval($newsfrom).",".$pref['newsposts'];
}
} // END - switch($action)