2006-12-02 04:36:16 +00:00
< ? php
/*
2008-12-02 16:50:16 +00:00
* e107 website system
*
* Copyright ( C ) 2001 - 2008 e107 Inc ( e107 . org )
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
* News Administration
*
* $Source : / cvs_backup / e107_0 . 8 / e107_admin / newspost . php , v $
2009-09-13 16:37:18 +00:00
* $Revision : 1.52 $
* $Date : 2009 - 09 - 13 16 : 37 : 17 $
2009-09-10 19:15:43 +00:00
* $Author : secretr $
2006-12-02 04:36:16 +00:00
*/
require_once ( " ../class2.php " );
2009-08-05 14:35:47 +00:00
if ( ! getperms ( " H|7|N " ))
2008-12-07 13:08:54 +00:00
{
2009-01-15 15:42:24 +00:00
header ( " Location: " . e_BASE . " index.php " );
2006-12-02 04:36:16 +00:00
exit ;
}
2009-01-13 17:09:30 +00:00
2009-08-28 16:11:02 +00:00
include_lan ( e_LANGUAGEDIR . e_LANGUAGE . '/admin/lan_' . e_PAGE );
2009-01-13 17:09:30 +00:00
2009-01-15 15:42:24 +00:00
// -------- Presets. ------------ // always load before auth.php
require_once ( e_HANDLER . " preset_class.php " );
$pst = new e_preset ();
$pst -> form = " core-newspost-create-form " ; // form id of the form that will have it's values saved.
$pst -> page = " newspost.php?create " ; // display preset options on which page(s).
$pst -> id = " admin_newspost " ;
// ------------------------------
2009-07-18 10:17:56 +00:00
// done in class2: require_once(e_LANGUAGEDIR.e_LANGUAGE."/admin/lan_admin.php"); // maybe this should be put in class2.php when 'admin' is detected.
2009-01-15 15:42:24 +00:00
$newspost = new admin_newspost ( e_QUERY , $pst );
2009-07-03 02:27:03 +00:00
$gen = new convert ();
2009-01-17 22:48:14 +00:00
//Handle Ajax Calls
if ( $newspost -> ajax_observer ()) exit ;
2008-12-07 13:08:54 +00:00
function headerjs ()
{
2009-01-13 17:09:30 +00:00
global $newspost ;
require_once ( e_HANDLER . 'js_helper.php' );
2009-07-03 06:48:43 +00:00
$ret .= " <script type='text/javascript'>
function UpdateForm ( id )
{
new e107Ajax . Updater ( 'filterValue' , '".e_SELF."?searchValue' , {
method : 'post' ,
evalScripts : true ,
parameters : { filtertype : id }
});
}
</ script > " ;
$ret .= "
2009-01-13 17:09:30 +00:00
< script type = 'text/javascript' >
if ( typeof e107Admin == 'undefined' ) var e107Admin = {}
/**
* OnLoad Init Control
*/
e107Admin . initRules = {
'Helper' : true ,
'AdminMenu' : false
}
2009-09-12 18:25:41 +00:00
//custom expand
Element . addMethods ( {
newsDescToggle : function ( element ) {
element = \ $ ( element );
if ( ! element . visible ())
element . fxToggle ();
return element ;
},
newsScrollToMe : function ( element ) {
element = \ $ ( element );
new Effect . ScrollTo ( element );
return element ;
},
newsUpdateButtonSpan : function ( element , str , swapClass ) {
element = \ $ ( element );
if ( swapClass ) {
var swapO = swapClass . split ( '::' );
element . removeClassName ( swapO [ 0 ]) . addClassName ( swapO [ 1 ]);
}
if ( element . down ( 'span' )) {
element . down ( 'span' ) . update ( str );
}
return element ;
}
});
2009-01-16 17:57:57 +00:00
//fix form action if needed
document . observe ( 'dom:loaded' , function () {
2009-09-12 18:25:41 +00:00
if ( \ $ ( 'core-newspost-create-form' )) {
\ $ ( 'core-newspost-create-form' ) . observe ( 'submit' , function ( event ) {
2009-01-16 17:57:57 +00:00
var form = event . element ();
action = form . readAttribute ( 'action' ) + document . location . hash ;
2009-09-12 18:25:41 +00:00
//if(\$('create-edit-stay-1') && \$('create-edit-stay-1').checked)
2009-01-16 17:57:57 +00:00
form . writeAttribute ( 'action' , action );
});
}
});
2009-01-13 17:09:30 +00:00
</ script >
< script type = 'text/javascript' src = '".e_FILE_ABS."jslib/core/admin.js' ></ script >
2009-07-03 06:48:43 +00:00
2009-01-13 17:09:30 +00:00
" ;
2009-04-27 21:23:37 +00:00
2009-01-17 22:48:14 +00:00
if ( $newspost -> getAction () == 'cat' )
{
$ret .= "
< script type = 'text/javascript' >
2009-09-12 18:25:41 +00:00
var e_npadmin_ajaxsave = function ( action , element ) {
var id = element . name . gsub ( / [ ^ \d ] / , '' ),
cl = element . value ,
url = '#{e_ADMIN}newspost.php?' + action + '.' + id + '.' + cl ;
element . startLoading ();
new e107Ajax . Request ( url . parsePath (), {
onComplete : function ( transport ) {
element . stopLoading ();
if ( transport . responseText )
alert ( transport . responseText ); //error
}
});
}
//e107 onload custom event
e107 . runOnLoad ( function ( event ) {
var celement = event . memo [ 'element' ] ? \ $ ( event . memo . element ) : \ $\ $ ( 'body' )[ 0 ];
//Unobtrusive AJAX category list reload
if ( \ $ ( 'trigger-list-refresh' )) {
\ $ ( 'trigger-list-refresh' ) . observe ( 'click' , function ( event ) {
event . stop ();
\ $ ( 'core-newspost-cat-list-form' ) . submitForm (
'core-newspost-cat-list-cont' ,
{ overlayPage : \ $\ $ ( 'body' )[ 0 ] },
\ $ ( 'core-newspost-cat-list-form' ) . action + '_list_refresh'
);
});
}
//Unobtrusive AJAX save category manage permissions
celement . select ( 'select[name^=multi_category_manager]' ) . invoke ( 'observe' , 'change' , function ( event ) {
e_npadmin_ajaxsave ( 'catmanager' , event . element ());
});
//Category order fields - user convenience
celement . select ( 'input[name^=multi_category_order]' ) . invoke ( 'observe' , 'focus' , function ( event ) {
event . element () . select ();
});
//Unobtrusive AJAX save category order
celement . select ( 'input[name^=multi_category_order]' ) . invoke ( 'observe' , 'blur' , function ( event ) {
e_npadmin_ajaxsave ( 'catorder' , event . element ());
});
//Fill form - click observer (Unobtrusive AJAX edit category)
2009-04-27 21:23:37 +00:00
\ $\ $ ( 'a.action[id^=core-news-catedit-]' ) . each ( function ( element ) {
2009-01-17 22:48:14 +00:00
element . observe ( 'click' , function ( event ) {
event . stop ();
var el = event . findElement ( 'a' );
$ ( 'core-newspost-cat-create-form' ) . fillForm ( \ $\ $ ( 'body' )[ 0 ], { handler : el . readAttribute ( 'href' ) });
});
});
2009-09-12 18:25:41 +00:00
}, null , true );
2009-01-17 22:48:14 +00:00
</ script >
" ;
}
elseif ( $newspost -> getAction () == 'pref' )
{
$ret .= "
< script type = 'text/javascript' >
2009-04-27 21:23:37 +00:00
document . observe ( 'dom:loaded' , function (){
2009-07-23 08:01:48 +00:00
\ $ ( 'newsposts' ) . observe ( 'change' , function ( event ) {
2009-01-17 22:48:14 +00:00
new e107Ajax . Updater (
2009-04-27 21:23:37 +00:00
'newsposts-archive-cont' ,
'".e_SELF."?pref_archnum.' + ( event . element () . selectedIndex + 1 ) + '.' + event . element () . readAttribute ( 'tabindex' ),
2009-01-17 22:48:14 +00:00
{ overlayElement : 'newsposts-archive-cont' }
);
});
});
</ script >
" ;
}
2009-01-13 17:09:30 +00:00
$ret .= $newspost -> _cal -> load_files ();
2006-12-02 04:36:16 +00:00
2009-01-13 17:09:30 +00:00
return $ret ;
2006-12-02 04:36:16 +00:00
}
$e_sub_cat = 'news' ;
2009-05-08 21:50:19 +00:00
require_once ( 'auth.php' );
require_once ( e_HANDLER . 'message_handler.php' );
2006-12-02 04:36:16 +00:00
2009-01-13 17:09:30 +00:00
/*
* Observe for delete action
*/
$newspost -> observer ();
2006-12-02 04:36:16 +00:00
2009-01-15 15:42:24 +00:00
/*
* Show requested page
*/
$newspost -> show_page ();
2006-12-02 04:36:16 +00:00
2008-06-15 20:20:28 +00:00
2009-01-15 15:42:24 +00:00
/* OLD JS ? Can ' t find references to this func
2006-12-02 04:36:16 +00:00
echo "
< script type = \ " text/javascript \" >
function fclear () {
2009-01-15 15:42:24 +00:00
document . getElementById ( 'core-newspost-create-form' ) . data . value = \ " \" ;
document . getElementById ( 'core-newspost-create-form' ) . news_extended . value = \ " \" ;
2006-12-02 04:36:16 +00:00
}
</ script > \n " ;
2009-01-15 15:42:24 +00:00
*/
2006-12-02 04:36:16 +00:00
require_once ( " footer.php " );
exit ;
2008-06-15 20:20:28 +00:00
2009-01-13 17:09:30 +00:00
class admin_newspost
2007-10-26 21:51:05 +00:00
{
2009-01-13 17:09:30 +00:00
var $_request = array ();
var $_cal = array ();
2009-01-15 15:42:24 +00:00
var $_pst ;
2009-07-03 06:48:43 +00:00
var $_fields ;
2009-07-14 11:05:54 +00:00
var $_sort_order ;
var $_sort_link ;
2009-07-17 07:53:13 +00:00
var $fieldpref ;
2009-09-10 19:15:43 +00:00
public $error = false ;
2006-12-02 04:36:16 +00:00
2009-09-10 19:15:43 +00:00
function __construct ( $qry , $pstobj )
2007-10-26 21:51:05 +00:00
{
2009-07-17 07:53:13 +00:00
global $user_pref ;
2009-01-13 17:09:30 +00:00
$this -> parseRequest ( $qry );
2008-12-02 16:50:16 +00:00
2009-09-12 18:25:41 +00:00
require_once ( e_HANDLER . " cache_handler.php " );
require_once ( e_HANDLER . " news_class.php " );
2009-01-13 17:09:30 +00:00
require_once ( e_HANDLER . " calendar/calendar_class.php " );
$this -> _cal = new DHTML_Calendar ( true );
2009-01-15 15:42:24 +00:00
$this -> _pst = & $pstobj ;
2009-08-24 08:34:55 +00:00
$this -> fieldpref = varset ( $user_pref [ 'admin_news_columns' ], array ( 'news_id' , 'news_title' , 'news_author' , 'news_render_type' , 'options' ));
2009-07-17 07:53:13 +00:00
2009-07-03 06:48:43 +00:00
$this -> _fields = array (
2009-07-14 11:05:54 +00:00
" checkboxes " => array ( " title " => " " , " forced " => TRUE , " width " => " 3% " , " thclass " => " center first " , " url " => " " ),
" news_id " => array ( " title " => LAN_NEWS_45 , " type " => " number " , " width " => " 5% " , " thclass " => " center " , " url " => e_SELF . " ?main.news_id. " . $this -> _sort_link . " . " . $this -> getFrom ()),
" news_title " => array ( " title " => NWSLAN_40 , " type " => " text " , " width " => " 30% " , " thclass " => " " , " url " => e_SELF . " ?main.news_title. " . $this -> _sort_link . " . " . $this -> getFrom ()),
2009-07-03 06:48:43 +00:00
" news_author " => array ( " title " => LAN_NEWS_50 , " type " => " user " , " width " => " 10% " , " thclass " => " " , " url " => " " ),
" news_datestamp " => array ( " title " => LAN_NEWS_32 , " type " => " datestamp " , " width " => " 15% " , " thclass " => " " , " url " => " " ),
" news_category " => array ( " title " => NWSLAN_6 , " type " => " dropdown " , " width " => " auto " , " thclass " => " " , " url " => " " ),
" news_class " => array ( " title " => NWSLAN_22 , " type " => " userclass " , " width " => " auto " , " thclass " => " " , " url " => " " ),
" news_render_type " => array ( " title " => LAN_NEWS_49 , " type " => " dropdown " , " width " => " auto " , " thclass " => " center " , " url " => " " ),
" news_thumbnail " => array ( " title " => LAN_NEWS_22 , " width " => " auto " , " thclass " => " " , " url " => " " ),
" news_sticky " => array ( " title " => LAN_NEWS_28 , " type " => " boolean " , " width " => " auto " , " thclass " => " " , " url " => " " ),
" news_allow_comments " => array ( " title " => NWSLAN_15 , " type " => " boolean " , " width " => " auto " , " thclass " => " " , " url " => " " ),
" news_comment_total " => array ( " title " => LAN_NEWS_60 , " type " => " number " , " width " => " auto " , " thclass " => " " , " url " => " " ),
2009-07-17 07:53:13 +00:00
" options " => array ( " title " => LAN_OPTIONS , " width " => " 10% " , " thclass " => " center last " , " url " => " " , 'forced' => TRUE )
2009-07-03 06:48:43 +00:00
);
2009-01-13 17:09:30 +00:00
}
function parseRequest ( $qry )
{
$tmp = explode ( " . " , $qry );
$action = varsettrue ( $tmp [ 0 ], 'main' );
2009-01-18 00:27:10 +00:00
$sub_action = varset ( $tmp [ 1 ], '' );
2009-01-13 17:09:30 +00:00
$id = isset ( $tmp [ 2 ]) && is_numeric ( $tmp [ 2 ]) ? intval ( $tmp [ 2 ]) : 0 ;
2009-07-14 11:05:54 +00:00
$this -> _sort_order = isset ( $tmp [ 2 ]) && ! is_numeric ( $tmp [ 2 ]) ? $tmp [ 2 ] : 'desc' ;
2009-01-13 17:09:30 +00:00
$from = intval ( varset ( $tmp [ 3 ], 0 ));
unset ( $tmp );
2009-07-14 11:05:54 +00:00
if ( $this -> _sort_order != 'asc' ) $this -> _sort_order = 'desc' ;
$this -> _sort_link = ( $this -> _sort_order ) == 'asc' ? 'desc' : 'asc' ;
2009-01-13 17:09:30 +00:00
$this -> _request = array ( $action , $sub_action , $id , $sort_order , $from );
}
function getAction ()
{
return $this -> _request [ 0 ];
}
2009-09-10 19:15:43 +00:00
/**
* @ param string $action
* @ return admin_newspost
*/
function setAction ( $action )
{
$this -> _request [ 0 ] = $action ;
return $this ;
}
2009-01-13 17:09:30 +00:00
function getSubAction ()
{
return $this -> _request [ 1 ];
}
2009-09-10 19:15:43 +00:00
/**
* @ param string $action
* @ return admin_newspost
*/
function setSubAction ( $action )
{
$this -> _request [ 1 ] = $action ;
return $this ;
}
2009-01-13 17:09:30 +00:00
function getId ()
{
return $this -> _request [ 2 ];
}
2009-09-10 19:15:43 +00:00
/**
* @ param integer $id
* @ return admin_newspost
*/
function setId ( $id )
{
$this -> _request [ 2 ] = intval ( $id );
return $this ;
}
2009-01-13 17:09:30 +00:00
function getSortOrder ()
{
return $this -> _request [ 3 ];
}
function getFrom ()
{
return $this -> _request [ 4 ];
}
function clear_cache ()
{
2009-09-12 18:25:41 +00:00
$ecache = e107 :: getCache ();
$ecache -> clear ( " news.php " );
$ecache -> clear ( " othernews " );
$ecache -> clear ( " othernews2 " );
return $this ;
}
function clear_rwcache ( $sefstr = '' )
{
/* if ( $sefstr ) $sefstr = md5 ( $sefstr );
ecache :: clear_sys ( " news_sefurl " . $sefstr ); */
news :: clearRewriteCache ( $sefstr );
}
function set_rwcache ( $sefstr , $data )
{
/** $sefstr = md5 ( $sefstr );
if ( is_array ( $data )) $data = e107 :: getArrayStorage () -> WriteArray ( $data , false );
ecache :: set_sys ( " news_sefurl " . $sefstr , $data , true ); */
news :: setRewriteCache ( $sefstr , $data );
2009-01-13 17:09:30 +00:00
}
2009-04-27 21:23:37 +00:00
2009-01-17 22:48:14 +00:00
function ajax_observer ()
{
$method = 'ajax_exec_' . $this -> getAction ();
2009-07-03 06:48:43 +00:00
2009-01-17 22:48:14 +00:00
if ( e_AJAX_REQUEST && method_exists ( $this , $method ))
{
$this -> $method ();
return true ;
}
return false ;
}
2009-01-13 17:09:30 +00:00
function observer ()
{
2009-09-10 19:15:43 +00:00
e107 :: getDb () -> db_Mark_Time ( 'News Administration' );
2009-01-15 15:42:24 +00:00
//Required on create & savepreset action triggers
if ( isset ( $_POST [ 'news_userclass' ]) && is_array ( $_POST [ 'news_userclass' ]))
{
2009-04-29 20:55:33 +00:00
$_POST [ 'news_class' ] = implode ( " , " , $_POST [ 'news_userclass' ]);
2009-01-15 15:42:24 +00:00
unset ( $_POST [ 'news_userclass' ]);
}
2009-01-13 17:09:30 +00:00
if ( isset ( $_POST [ 'delete' ]) && is_array ( $_POST [ 'delete' ]))
{
$this -> _observe_delete ();
}
elseif ( isset ( $_POST [ 'submit_news' ]))
{
$this -> _observe_submit_item ( $this -> getSubAction (), $this -> getId ());
}
elseif ( isset ( $_POST [ 'create_category' ]))
{
$this -> _observe_create_category ();
}
elseif ( isset ( $_POST [ 'update_category' ]))
{
$this -> _observe_update_category ();
}
2009-09-12 18:25:41 +00:00
elseif ( isset ( $_POST [ 'multi_update_category' ]))
{
$this -> _observe_multi_create_category ();
}
2009-01-13 17:09:30 +00:00
elseif ( isset ( $_POST [ 'save_prefs' ]))
2007-10-26 21:51:05 +00:00
{
2009-01-13 17:09:30 +00:00
$this -> _observe_save_prefs ();
}
elseif ( isset ( $_POST [ 'submitupload' ]))
{
$this -> _observe_upload ();
}
2009-05-08 21:50:19 +00:00
elseif ( isset ( $_POST [ 'news_comments_recalc' ]))
{
$this -> _observe_newsCommentsRecalc ();
}
2009-07-03 02:27:03 +00:00
elseif ( isset ( $_POST [ 'submit-e-columns' ]))
{
$this -> _observe_saveColumns ();
}
2009-01-13 17:09:30 +00:00
}
2006-12-02 04:36:16 +00:00
2009-01-15 15:42:24 +00:00
function show_page ()
{
switch ( $this -> getAction ()) {
case 'savepreset' :
case 'clr_preset' :
$this -> _pst -> save_preset ( 'news_datestamp' , false ); // save and render result using unique name. Don't save item datestamp
$_POST = array ();
$this -> parseRequest ( '' );
$this -> show_existing_items ();
break ;
case 'create' :
$this -> _pst -> read_preset ( 'admin_newspost' ); //only works here because $_POST is used.
$this -> show_create_item ();
break ;
case 'cat' :
$this -> show_categories ();
break ;
case 'sn' :
$this -> show_submitted_news ();
break ;
case 'pref' :
$this -> show_news_prefs ();
break ;
2009-05-08 21:50:19 +00:00
case 'maint' :
$this -> showMaintenance ();
break ;
2009-01-15 15:42:24 +00:00
default :
$this -> show_existing_items ();
break ;
}
}
2009-01-13 17:09:30 +00:00
function _observe_delete ()
{
global $admin_log ;
2009-09-12 18:25:41 +00:00
//FIXME - SEF URL cache
2009-01-13 17:09:30 +00:00
$tmp = array_keys ( $_POST [ 'delete' ]);
list ( $delete , $del_id ) = explode ( " _ " , $tmp [ 0 ]);
$del_id = intval ( $del_id );
if ( ! $del_id ) return false ;
2009-09-12 18:25:41 +00:00
$e107 = e107 :: getInstance ();
2009-01-13 17:09:30 +00:00
switch ( $delete ) {
case 'main' :
2009-09-12 18:25:41 +00:00
//clear rewrite cache
if ( e107 :: getDb () -> db_Select ( 'news_rewrite' , 'news_rewrite_id, news_rewrite_string' , 'news_rewrite_source=' . $del_id . ' AND news_rewrite_type=1' ))
{
$tmp = e107 :: getDb () -> db_Fetch ();
e107 :: getDb () -> db_Delete ( 'news_rewrite' , 'news_rewrite_id=' . $tmp [ 'news_rewrite_id' ]);
$this -> clear_rwcache ( $tmp [ 'news_rewrite_string' ]);
unset ( $tmp );
}
2009-01-13 17:09:30 +00:00
if ( $e107 -> sql -> db_Count ( 'news' , '(*)' , " WHERE news_id= { $del_id } " ))
{
2009-09-12 18:25:41 +00:00
e107 :: getEvent () -> trigger ( " newsdel " , $del_id );
2009-01-13 17:09:30 +00:00
if ( $e107 -> sql -> db_Delete ( " news " , " news_id= { $del_id } " ))
{
$admin_log -> log_event ( 'NEWS_01' , $del_id , E_LOG_INFORMATIVE , '' );
$this -> show_message ( NWSLAN_31 . " # " . $del_id . " " . NWSLAN_32 , E_MESSAGE_SUCCESS );
$this -> clear_cache ();
$data = array ( 'method' => 'delete' , 'table' => 'news' , 'id' => $del_id , 'plugin' => 'news' , 'function' => 'delete' );
2009-01-15 15:42:24 +00:00
$this -> show_message ( $e107 -> e_event -> triggerHook ( $data ), E_MESSAGE_WARNING );
2009-01-13 17:09:30 +00:00
admin_purge_related ( " news " , $del_id );
}
}
break ;
case 'category' :
2009-09-12 18:25:41 +00:00
//clear rewrite cache
if ( e107 :: getDb () -> db_Select ( 'news_rewrite' , 'news_rewrite_id, news_rewrite_string' , 'news_rewrite_source=' . $del_id . ' AND news_rewrite_type=2' ))
{
$tmp = e107 :: getDb () -> db_Fetch ();
e107 :: getDb () -> db_Delete ( 'news_rewrite' , 'news_rewrite_id=' . $tmp [ 'news_rewrite_id' ]);
$this -> clear_rwcache ( $tmp [ 'news_rewrite_string' ]);
unset ( $tmp );
}
if ( $e107 -> sql -> db_Count ( 'news_category' , '(*)' , " WHERE category_id= { $del_id } " ))
{
e107 :: getEvent () -> trigger ( " newscatdel " , $del_id );
2009-01-13 17:09:30 +00:00
if ( $e107 -> sql -> db_Delete ( " news_category " , " category_id= { $del_id } " ))
{
$admin_log -> log_event ( 'NEWS_02' , $del_id , E_LOG_INFORMATIVE , '' );
$this -> show_message ( NWSLAN_33 . " # " . $del_id . " " . NWSLAN_32 , E_MESSAGE_SUCCESS );
$this -> clear_cache ();
}
2009-09-12 18:25:41 +00:00
}
2009-01-13 17:09:30 +00:00
break ;
case 'sn' :
2009-09-12 18:25:41 +00:00
if ( $e107 -> sql -> db_Delete ( " submitnews " , " submitnews_id= { $del_id } " ))
{
$admin_log -> log_event ( 'NEWS_03' , $del_id , E_LOG_INFORMATIVE , '' );
$this -> show_message ( NWSLAN_34 . " # " . $del_id . " " . NWSLAN_32 );
$this -> clear_cache ();
}
2009-01-13 17:09:30 +00:00
break ;
default :
return false ;
2006-12-02 04:36:16 +00:00
}
2009-01-13 17:09:30 +00:00
return true ;
}
function _observe_submit_item ( $sub_action , $id )
{
// ##### Format and submit item to DB
$ix = new news ;
2006-12-02 04:36:16 +00:00
2009-01-13 17:09:30 +00:00
if ( $_POST [ 'news_start' ])
{
$tmp = explode ( " / " , $_POST [ 'news_start' ]);
$_POST [ 'news_start' ] = mktime ( 0 , 0 , 0 , $tmp [ 1 ], $tmp [ 0 ], $tmp [ 2 ]);
}
else
{
$_POST [ 'news_start' ] = 0 ;
}
2006-12-02 04:36:16 +00:00
2009-01-13 17:09:30 +00:00
if ( $_POST [ 'news_end' ])
{
$tmp = explode ( " / " , $_POST [ 'news_end' ]);
$_POST [ 'news_end' ] = mktime ( 0 , 0 , 0 , $tmp [ 1 ], $tmp [ 0 ], $tmp [ 2 ]);
}
else
{
$_POST [ 'news_end' ] = 0 ;
}
2006-12-02 04:36:16 +00:00
2009-01-13 17:09:30 +00:00
$matches = array ();
if ( preg_match ( '#(.*?)/(.*?)/(.*?) (.*?):(.*?):(.*?)$#' , $_POST [ 'news_datestamp' ], $matches ))
{
$_POST [ 'news_datestamp' ] = mktime ( $matches [ 4 ], $matches [ 5 ], $matches [ 6 ], $matches [ 2 ], $matches [ 1 ], $matches [ 3 ]);
}
else
{
$_POST [ 'news_datestamp' ] = time ();
}
2006-12-02 04:36:16 +00:00
2009-01-13 17:09:30 +00:00
if ( $_POST [ 'update_datestamp' ])
{
$_POST [ 'news_datestamp' ] = time ();
}
2006-12-02 04:36:16 +00:00
2009-01-13 17:09:30 +00:00
if ( $id && $sub_action != " sn " && $sub_action != " upload " )
{
$_POST [ 'news_id' ] = $id ;
}
else
{
2009-09-12 18:25:41 +00:00
e107 :: getDb () -> db_Update ( 'submitnews' , " submitnews_auth=1 WHERE submitnews_id = { $id } " );
e107 :: getAdminLog () -> log_event ( 'NEWS_07' , $id , E_LOG_INFORMATIVE , '' );
2009-01-13 17:09:30 +00:00
}
2009-09-12 18:25:41 +00:00
if ( ! isset ( $_POST [ 'cat_id' ]))
2009-01-13 17:09:30 +00:00
{
2009-09-12 18:25:41 +00:00
$_POST [ 'cat_id' ] = 0 ;
2009-01-13 17:09:30 +00:00
}
2009-09-12 18:25:41 +00:00
$_POST [ 'news_category' ] = $_POST [ 'cat_id' ];
2009-01-13 17:09:30 +00:00
2009-01-16 17:57:57 +00:00
if ( isset ( $_POST [ 'news_thumbnail' ]))
{
$_POST [ 'news_thumbnail' ] = urldecode ( basename ( $_POST [ 'news_thumbnail' ]));
}
2009-01-15 15:42:24 +00:00
$tmp = explode ( chr ( 35 ), $_POST [ 'news_author' ]);
$_POST [ 'news_author' ] = $tmp [ 0 ];
2009-01-13 17:09:30 +00:00
2009-09-12 18:25:41 +00:00
$ret = $ix -> submit_item ( $_POST , ! vartrue ( $_POST [ 'create_edit_stay' ]));
if ( $ret [ 'error' ])
{
eMessage :: getInstance () -> mergeWithSession (); //merge with session messages
eMessage :: getInstance () -> add (( $id ? LAN_UPDATED_FAILED : LAN_CREATED_FAILED ), E_MESSAGE_ERROR );
return false ;
}
2009-01-18 20:31:14 +00:00
$this -> clear_cache ();
2009-01-18 00:27:10 +00:00
if ( isset ( $_POST [ 'create_edit_stay' ]) && ! empty ( $_POST [ 'create_edit_stay' ]))
{
if ( $this -> getSubAction () != 'edit' )
{
session_write_close ();
$rurl = e_SELF . ( varsettrue ( $ret [ 'id' ]) ? " ?create.edit. " . $ret [ 'id' ] : '' );
header ( 'Location:' . ( $rurl ? $rurl : e_SELF ));
exit ;
}
}
else
2009-01-16 17:57:57 +00:00
{
2009-01-18 20:31:14 +00:00
session_write_close ();
2009-01-16 17:57:57 +00:00
header ( 'Location:' . e_SELF );
exit ;
}
2009-01-13 17:09:30 +00:00
}
function _observe_create_category ()
{
2009-09-10 19:15:43 +00:00
//FIXME - lan, e_model based news administration model
$this -> error = false ;
if ( empty ( $_POST [ 'category_name' ]))
2009-01-13 17:09:30 +00:00
{
2009-09-10 19:15:43 +00:00
$this -> show_message ( 'Validation Error: Missing Category name' , E_MESSAGE_ERROR );
$this -> error = true ;
}
if ( ! empty ( $_POST [ 'news_rewrite_string' ]) && preg_match ( '#[^\w\pL\-]#u' , $_POST [ 'news_rewrite_string' ]))
{
$this -> show_message ( 'Validation Error: Bad value for Category friendly URL' , E_MESSAGE_ERROR );
$this -> error = true ;
}
if ( ! $this -> error )
{
$inserta = array ();
2009-09-12 18:25:41 +00:00
/* Why ? Categoty Icon is not required field
2009-09-10 19:15:43 +00:00
if ( empty ( $_POST [ 'category_icon' ]))
2009-01-13 17:09:30 +00:00
{
$handle = opendir ( e_IMAGE . " icons " );
while ( $file = readdir ( $handle ))
{
if ( $file != " . " && $file != " .. " && $file != " / " && $file != " null.txt " && $file != " CVS " ) {
$iconlist [] = $file ;
}
}
closedir ( $handle );
2009-09-10 19:15:43 +00:00
$inserta [ 'category_icon' ] = $iconlist [ 0 ];
}
else
{
$inserta [ 'category_icon' ] = e107 :: getParser () -> toDB ( $_POST [ 'category_icon' ]);
} */
$inserta [ 'data' ][ 'category_icon' ] = $_POST [ 'category_icon' ];
$inserta [ '_FIELD_TYPES' ][ 'category_icon' ] = 'todb' ;
$inserta [ 'data' ][ 'category_name' ] = $_POST [ 'category_name' ];
$inserta [ '_FIELD_TYPES' ][ 'category_name' ] = 'todb' ;
$inserta [ 'data' ][ 'category_meta_description' ] = strip_tags ( $_POST [ 'category_meta_description' ]);
$inserta [ '_FIELD_TYPES' ][ 'category_meta_description' ] = 'str' ;
$inserta [ 'data' ][ 'category_meta_keywords' ] = $_POST [ 'category_meta_keywords' ];
$inserta [ '_FIELD_TYPES' ][ 'category_meta_keywords' ] = 'str' ;
$inserta [ 'data' ][ 'category_manager' ] = $_POST [ 'category_manager' ];
$inserta [ '_FIELD_TYPES' ][ 'category_manager' ] = 'int' ;
$inserta [ 'data' ][ 'category_order' ] = $_POST [ 'category_order' ];
$inserta [ '_FIELD_TYPES' ][ 'category_order' ] = 'int' ;
//e107::getDb()->db_Insert('news_category', "'0', '{$_POST['category_name']}', '{$_POST['category_icon']}'");
$id = e107 :: getDb () -> db_Insert ( 'news_category' , $inserta );
if ( $id )
{
2009-09-13 16:37:18 +00:00
$inserta [ 'data' ][ 'category_id' ] = $id ;
2009-09-10 19:15:43 +00:00
//Manage rewrite
if ( ! empty ( $_POST [ 'news_rewrite_string' ]))
{
2009-09-12 18:25:41 +00:00
$rwinserta = array ();
$rwinserta [ 'data' ][ 'news_rewrite_source' ] = $id ;
$rwinserta [ '_FIELD_TYPES' ][ 'news_rewrite_source' ] = 'int' ;
2009-09-10 19:15:43 +00:00
2009-09-12 18:25:41 +00:00
$rwinserta [ 'data' ][ 'news_rewrite_string' ] = $_POST [ 'news_rewrite_string' ];
$rwinserta [ '_FIELD_TYPES' ][ 'news_rewrite_string' ] = 'todb' ;
2009-09-10 19:15:43 +00:00
2009-09-12 18:25:41 +00:00
$rwinserta [ 'data' ][ 'news_rewrite_type' ] = 2 ;
$rwinserta [ '_FIELD_TYPES' ][ 'news_rewrite_type' ] = 'int' ;
2009-09-10 19:15:43 +00:00
2009-09-13 16:37:18 +00:00
$rid = e107 :: getDb () -> db_Insert ( 'news_rewrite' , $rwinserta );
$rwinserta [ 'data' ][ 'news_rewrite_id' ] = $rid ;
2009-09-12 18:25:41 +00:00
if ( e107 :: getDb () -> getLastErrorNumber ())
2009-09-10 19:15:43 +00:00
{
$this -> error = true ;
2009-09-12 18:25:41 +00:00
$this -> show_message ( 'Category friendly URL string related problem detected!' , E_MESSAGE_ERROR );
if ( 1052 == e107 :: getDb () -> getLastErrorNumber ())
2009-09-10 19:15:43 +00:00
{
2009-09-12 18:25:41 +00:00
$this -> show_message ( 'Category friendly URL string should be unique! ' , E_MESSAGE_ERROR );
2009-09-10 19:15:43 +00:00
}
2009-09-12 18:25:41 +00:00
$this -> show_message ( 'mySQL error #' . e107 :: getDb () -> getLastErrorNumber () . ': ' . e107 :: getDb () -> getLastErrorText (), E_MESSAGE_DEBUG );
2009-09-10 19:15:43 +00:00
return ;
}
2009-09-13 16:37:18 +00:00
2009-09-12 18:25:41 +00:00
$this -> set_rwcache ( $_POST [ 'news_rewrite_string' ], $rwinserta [ 'data' ]);
2009-09-13 16:37:18 +00:00
e107 :: getAdminLog () -> log_event ( 'NEWS_10' , $rwinserta , E_LOG_INFORMATIVE , '' );
2009-09-10 19:15:43 +00:00
}
//admin log now supports DB array and method chaining
2009-09-13 16:37:18 +00:00
e107 :: getAdminLog () -> log_event ( 'NEWS_04' , $inserta , E_LOG_INFORMATIVE , '' );
2009-09-10 19:15:43 +00:00
$this -> show_message ( NWSLAN_35 , E_MESSAGE_SUCCESS );
$this -> clear_cache ();
2009-09-12 18:25:41 +00:00
//TODO - add to WIKI docs
e107 :: getEvent () -> trigger ( " newscatpost " , array_merge ( $inserta [ 'data' ], $rwinserta [ 'data' ]));
2009-01-13 17:09:30 +00:00
}
else
{
2009-09-10 19:15:43 +00:00
//debug + error message
2009-09-12 18:25:41 +00:00
if ( e107 :: getDb () -> getLastErrorNumber ())
2009-09-10 19:15:43 +00:00
{
$this -> error = true ;
$this -> show_message ( 'mySQL Error detected!' , E_MESSAGE_ERROR );
2009-09-12 18:25:41 +00:00
eMessage :: getInstance () -> addS ( 'mySQL error #' . e107 :: getDb () -> getLastErrorNumber () . ': ' . e107 :: getDb () -> getLastErrorText (), E_MESSAGE_DEBUG );
2009-09-10 19:15:43 +00:00
}
2009-01-13 17:09:30 +00:00
}
}
}
2009-09-10 19:15:43 +00:00
2009-01-13 17:09:30 +00:00
function _observe_update_category ()
2009-09-10 19:15:43 +00:00
{
$this -> setId ( intval ( $_POST [ 'category_id' ]));
if ( ! $this -> getId ())
2009-01-13 17:09:30 +00:00
{
2009-09-10 19:15:43 +00:00
return ;
}
//FIXME - lan, e_model based news administration model
$this -> error = false ;
if ( empty ( $_POST [ 'category_name' ]))
{
$this -> show_message ( 'Validation Error: Missing Category name' , E_MESSAGE_ERROR );
$this -> error = true ;
}
if ( ! empty ( $_POST [ 'news_rewrite_string' ]) && preg_match ( '#[^\w\pL\-]#u' , $_POST [ 'news_rewrite_string' ]))
{
$this -> show_message ( 'Validation Error: Bad value for Category friendly URL' , E_MESSAGE_ERROR );
$this -> error = true ;
}
if ( ! $this -> error )
{
$updatea = array ();
$updatea [ 'data' ][ 'category_icon' ] = $_POST [ 'category_icon' ];
$updatea [ '_FIELD_TYPES' ][ 'category_icon' ] = 'todb' ;
$updatea [ 'data' ][ 'category_name' ] = $_POST [ 'category_name' ];
$updatea [ '_FIELD_TYPES' ][ 'category_name' ] = 'todb' ;
$updatea [ 'data' ][ 'category_meta_description' ] = strip_tags ( $_POST [ 'category_meta_description' ]);
$updatea [ '_FIELD_TYPES' ][ 'category_meta_description' ] = 'str' ;
$updatea [ 'data' ][ 'category_meta_keywords' ] = $_POST [ 'category_meta_keywords' ];
$updatea [ '_FIELD_TYPES' ][ 'category_meta_keywords' ] = 'str' ;
$updatea [ 'data' ][ 'category_manager' ] = $_POST [ 'category_manager' ];
$updatea [ '_FIELD_TYPES' ][ 'category_manager' ] = 'int' ;
2009-09-12 18:25:41 +00:00
2009-09-10 19:15:43 +00:00
$updatea [ 'data' ][ 'category_order' ] = $_POST [ 'category_order' ];
$updatea [ '_FIELD_TYPES' ][ 'category_order' ] = 'int' ;
$updatea [ 'WHERE' ] = 'category_id=' . $this -> getId ();
2009-09-12 18:25:41 +00:00
$inserta = array ();
$rid = isset ( $_POST [ 'news_rewrite_id' ]) ? $_POST [ 'news_rewrite_id' ] : 0 ;
$inserta [ 'data' ][ 'news_rewrite_id' ] = $rid ;
$inserta [ '_FIELD_TYPES' ][ 'news_rewrite_id' ] = 'int' ;
$inserta [ 'data' ][ 'news_rewrite_source' ] = $this -> getId ();
$inserta [ '_FIELD_TYPES' ][ 'news_rewrite_source' ] = 'int' ;
$inserta [ 'data' ][ 'news_rewrite_string' ] = $_POST [ 'news_rewrite_string' ];
$inserta [ '_FIELD_TYPES' ][ 'news_rewrite_string' ] = 'todb' ;
$inserta [ 'data' ][ 'news_rewrite_type' ] = 2 ;
$inserta [ '_FIELD_TYPES' ][ 'news_rewrite_type' ] = 'int' ;
2009-09-13 16:37:18 +00:00
$oldsef = array ();
//'news_rewrite_source='.intval($this->getId()).' AND news_rewrite_type=2'
if ( e107 :: getDb () -> db_Select ( 'news_rewrite' , '*' , 'news_rewrite_id=' . intval ( $rid )))
{
$oldsef = e107 :: getDb () -> db_Fetch ();
}
2009-09-12 18:25:41 +00:00
$upcheck = e107 :: getDb () -> db_Update ( " news_category " , $updatea );
$rwupcheck = false ;
if ( $upcheck || ! e107 :: getDb () -> getLastErrorNumber ())
2009-09-10 19:15:43 +00:00
{
//Manage rewrite
if ( ! empty ( $_POST [ 'news_rewrite_string' ]))
{
2009-09-12 18:25:41 +00:00
if ( $rid )
{
$inserta [ 'WHERE' ] = 'news_rewrite_id=' . intval ( $rid );
$rwupcheck = e107 :: getDb () -> db_Update ( 'news_rewrite' , $inserta );
}
else
{
$rwupcheck = e107 :: getDb () -> db_Insert ( 'news_rewrite' , $inserta );
2009-09-13 16:37:18 +00:00
$inserta [ 'data' ][ 'news_rewrite_id' ] = $rwupcheck ;
2009-09-12 18:25:41 +00:00
}
if ( e107 :: getDb () -> getLastErrorNumber ())
2009-09-10 19:15:43 +00:00
{
$this -> error = true ;
$this -> setSubAction ( 'edit' );
2009-09-12 18:25:41 +00:00
$this -> show_message ( 'Category friendly URL string related problem detected!' , E_MESSAGE_ERROR );
if ( 1062 == e107 :: getDb () -> getLastErrorNumber ()) //detect duplicate mysql errnum
2009-09-10 19:15:43 +00:00
{
2009-09-12 18:25:41 +00:00
$this -> show_message ( 'Category friendly URL string should be unique! ' , E_MESSAGE_ERROR );
2009-09-10 19:15:43 +00:00
}
2009-09-12 18:25:41 +00:00
$this -> show_message ( 'mySQL error #' . e107 :: getDb () -> getLastErrorNumber () . ': ' . e107 :: getDb () -> getLastErrorText (), E_MESSAGE_DEBUG );
2009-09-10 19:15:43 +00:00
return ;
}
}
else
{
2009-09-12 18:25:41 +00:00
//remove SEF if required
2009-09-13 16:37:18 +00:00
if ( $oldsef )
2009-09-12 18:25:41 +00:00
{
2009-09-13 16:37:18 +00:00
$this -> clear_rwcache ( $oldsef [ 'news_rewrite_string' ]);
e107 :: getDb () -> db_Delete ( 'news_rewrite' , 'news_rewrite_id=' . $oldsef [ 'news_rewrite_id' ]);
e107 :: getAdminLog () -> log_event ( 'NEWS_11' , $oldsef , E_LOG_INFORMATIVE , '' );
2009-09-12 18:25:41 +00:00
$inserta = array ( 'data' => array ());
$rwupcheck = true ;
}
2009-09-10 19:15:43 +00:00
}
2009-09-12 18:25:41 +00:00
if ( $upcheck || $rwupcheck )
{
//admin log now supports DB array and method chaining
2009-09-13 16:37:18 +00:00
$updatea [ 'data' ][ 'category_id' ] = $this -> getId ();
if ( $upcheck ) e107 :: getAdminLog () -> log_event ( 'NEWS_05' , $updatea [ 'data' ], E_LOG_INFORMATIVE , '' );
if ( $rwupcheck && $inserta [ 'data' ]) e107 :: getAdminLog () -> log_event ( 'NEWS_10' , $inserta [ 'data' ], E_LOG_INFORMATIVE , '' );
2009-09-12 18:25:41 +00:00
$this -> show_message ( NWSLAN_36 , E_MESSAGE_SUCCESS );
$this -> clear_cache ();
2009-09-10 19:15:43 +00:00
2009-09-12 18:25:41 +00:00
//TODO - add to WIKI docs
e107 :: getEvent () -> trigger ( " newscatupd " , array_merge ( $updatea [ 'data' ], $inserta [ 'data' ]));
}
else
{
$this -> show_message ( LAN_NO_CHANGE );
}
2009-09-13 16:37:18 +00:00
if ( varset ( $oldsef [ 'news_rewrite_string' ])) $this -> clear_rwcache ( $oldsef [ 'news_rewrite_string' ]);
if ( $_POST [ 'news_rewrite_string' ]) $this -> set_rwcache ( $_POST [ 'news_rewrite_string' ], $inserta [ 'data' ]);
2009-09-10 19:15:43 +00:00
$this -> setId ( 0 );
}
else
{
2009-09-12 18:25:41 +00:00
$this -> error = true ;
$this -> setSubAction ( 'edit' );
$this -> show_message ( 'mySQL Error detected!' , E_MESSAGE_ERROR );
$this -> show_message ( '#' . e107 :: getDb () -> getLastErrorNumber () . ': ' . e107 :: getDb () -> getLastErrorText (), E_MESSAGE_DEBUG );
return ;
2009-09-10 19:15:43 +00:00
}
2009-01-13 17:09:30 +00:00
}
2006-12-02 04:36:16 +00:00
}
2009-09-12 18:25:41 +00:00
function _observe_multi_create_category ()
{
$cnt = 0 ;
foreach ( $_POST [ 'multi_category_manager' ] as $cid => $val )
{
$order = $_POST [ 'multi_category_order' ][ $cid ];
$cnt += ( int ) e107 :: getDb () -> db_Update ( 'news_category' , 'category_manager=' . intval ( $val ) . ', category_order=' . intval ( $order ) . ' WHERE category_id=' . intval ( $cid ));
}
if ( $cnt ) eMessage :: getInstance () -> add ( LAN_UPDATED , E_MESSAGE_SUCCESS );
}
2006-12-02 04:36:16 +00:00
2009-01-13 17:09:30 +00:00
function _observe_save_prefs ()
{
$temp = array ();
$temp [ 'newsposts' ] = intval ( $_POST [ 'newsposts' ]);
$temp [ 'newsposts_archive' ] = intval ( $_POST [ 'newsposts_archive' ]);
2009-09-13 16:37:18 +00:00
$temp [ 'newsposts_archive_title' ] = e107 :: getParser () -> toDB ( $_POST [ 'newsposts_archive_title' ]);
2009-01-13 17:09:30 +00:00
$temp [ 'news_cats' ] = intval ( $_POST [ 'news_cats' ]);
$temp [ 'nbr_cols' ] = intval ( $_POST [ 'nbr_cols' ]);
$temp [ 'subnews_attach' ] = intval ( $_POST [ 'subnews_attach' ]);
$temp [ 'subnews_resize' ] = intval ( $_POST [ 'subnews_resize' ]);
$temp [ 'subnews_class' ] = intval ( $_POST [ 'subnews_class' ]);
$temp [ 'subnews_htmlarea' ] = intval ( $_POST [ 'subnews_htmlarea' ]);
2009-09-13 16:37:18 +00:00
$temp [ 'news_subheader' ] = e107 :: getParser () -> toDB ( $_POST [ 'news_subheader' ]);
2009-01-13 17:09:30 +00:00
$temp [ 'news_newdateheader' ] = intval ( $_POST [ 'news_newdateheader' ]);
$temp [ 'news_unstemplate' ] = intval ( $_POST [ 'news_unstemplate' ]);
$temp [ 'news_editauthor' ] = intval ( $_POST [ 'news_editauthor' ]);
2009-09-13 16:37:18 +00:00
$temp [ 'news_sefbase' ] = preg_replace ( '#[^\w\pL\-]#u' , '' , $_POST [ 'news_sefbase' ]);
2009-07-18 10:17:56 +00:00
2009-09-13 16:37:18 +00:00
e107 :: getConfig () -> updatePref ( $temp );
if ( e107 :: getConfig () -> save ( false ))
2009-01-13 17:09:30 +00:00
{
2009-09-13 16:37:18 +00:00
e107 :: getAdminLog () -> logArrayDiffs ( $temp , e107 :: getPref (), 'NEWS_06' );
2009-01-13 17:09:30 +00:00
$this -> clear_cache ();
2009-09-13 16:37:18 +00:00
//$this->show_message(NWSLAN_119, E_MESSAGE_SUCCESS);
2009-01-13 17:09:30 +00:00
}
}
2007-10-26 21:51:05 +00:00
2009-01-13 17:09:30 +00:00
function _observe_upload ()
2008-12-07 13:08:54 +00:00
{
2009-01-13 17:09:30 +00:00
//$pref['upload_storagetype'] = "1";
require_once ( e_HANDLER . " upload_handler.php " );
2006-12-02 04:36:16 +00:00
2009-01-26 08:19:44 +00:00
$uploaded = file_upload ( e_NEWSIMAGE );
2009-01-13 17:09:30 +00:00
foreach ( $_POST [ 'uploadtype' ] as $key => $uploadtype )
{
if ( $uploadtype == " thumb " )
{
2009-01-26 08:19:44 +00:00
rename ( e_NEWSIMAGE . $uploaded [ $key ][ 'name' ], e_NEWSIMAGE . " thumb_ " . $uploaded [ $key ][ 'name' ]);
2009-01-13 17:09:30 +00:00
}
if ( $uploadtype == " file " )
{
2009-01-26 08:19:44 +00:00
rename ( e_NEWSIMAGE . $uploaded [ $key ][ 'name' ], e_DOWNLOAD . $uploaded [ $key ][ 'name' ]);
2009-01-13 17:09:30 +00:00
}
if ( $uploadtype == " resize " && $_POST [ 'resize_value' ])
{
require_once ( e_HANDLER . " resize_handler.php " );
2009-01-26 08:19:44 +00:00
resize_image ( e_NEWSIMAGE . $uploaded [ $key ][ 'name' ], e_NEWSIMAGE . $uploaded [ $key ][ 'name' ], $_POST [ 'resize_value' ], " copy " );
2009-01-13 17:09:30 +00:00
}
2006-12-02 04:36:16 +00:00
}
2009-01-13 17:09:30 +00:00
}
2006-12-02 04:36:16 +00:00
2009-07-03 02:27:03 +00:00
function _observe_saveColumns ()
{
2009-07-04 13:36:15 +00:00
global $user_pref , $admin_log ;
$user_pref [ 'admin_news_columns' ] = $_POST [ 'e-columns' ];
save_prefs ( 'user' );
2009-07-17 07:53:13 +00:00
$this -> fieldpref = $user_pref [ 'admin_news_columns' ];
2009-07-03 02:27:03 +00:00
}
2009-01-13 17:09:30 +00:00
function show_existing_items ()
{
2009-07-04 13:36:15 +00:00
global $user_pref , $gen ;
2009-07-03 02:27:03 +00:00
2009-08-05 14:35:47 +00:00
if ( ! getperms ( 'H' ))
{
return ;
}
2009-01-13 17:09:30 +00:00
require_once ( e_HANDLER . " form_handler.php " );
$frm = new e_form ( true ); //enable inner tabindex counter
2006-12-02 04:36:16 +00:00
2009-07-14 11:05:54 +00:00
// Effectively toggle setting for headings
2009-01-13 17:09:30 +00:00
$amount = 10 ; //TODO - pref
2006-12-02 04:36:16 +00:00
2009-07-04 13:36:15 +00:00
if ( ! is_array ( $user_pref [ 'admin_news_columns' ]))
{
$user_pref [ 'admin_news_columns' ] = array ( " news_id " , " news_title " , " news_author " , " news_render_type " );
}
2009-07-03 06:48:43 +00:00
$field_columns = $this -> _fields ;
2009-01-13 17:09:30 +00:00
$e107 = & e107 :: getInstance ();
2009-07-03 02:27:03 +00:00
// Grab news Category Names;
$e107 -> sql -> db_Select ( 'news_category' , '*' );
$newscatarray = $e107 -> sql -> db_getList ();
$news_category = array ();
foreach ( $newscatarray as $val )
{
$news_category [ $val [ 'category_id' ]] = $val [ 'category_name' ];
}
2009-07-03 06:48:43 +00:00
// ------ Search Filter ------
$text .= "
< form method = 'post' action = '".e_SELF."' >
< div class = 'center' style = 'padding:20px' >
< table style = 'width:auto' cellspacing = '2' >
< tr >
< td class = 'left' > " .
$frm -> admin_button ( 'dupfield' , " Add Filter " , 'action' , '' , array ( 'other' => 'onclick="duplicateHTML(\'filterline\',\'srch_container\');"' ))
. " </td>
< td >
< div id = 'srch_container' class = 'nowrap' >< span id = 'filterline' > " . $frm->filterType ( $field_columns ). " < span id = 'filterValue' > " . $frm->filterValue (). " </ span ></ span ></ div >
</ td >
< td > " .
$frm -> admin_button ( 'searchsubmit' , NWSLAN_63 , 'search' ) . "
</ td >
</ tr >
</ table >
</ div ></ form >
" ;
// --------------------------------------------
2009-07-03 02:27:03 +00:00
2009-01-17 01:30:35 +00:00
if ( varsettrue ( $_POST [ 'searchquery' ]))
2009-01-13 17:09:30 +00:00
{
2009-01-17 01:30:35 +00:00
$query = " news_title REGEXP(' " . $_POST [ 'searchquery' ] . " ') OR news_body REGEXP(' " . $_POST [ 'searchquery' ] . " ') OR news_extended REGEXP(' " . $_POST [ 'searchquery' ] . " ') ORDER BY news_datestamp DESC " ;
2009-01-13 17:09:30 +00:00
}
else
{
2009-07-14 11:05:54 +00:00
$query = " ORDER BY " . ( $this -> getSubAction () ? $this -> getSubAction () : " news_datestamp " ) . " " . strtoupper ( $this -> _sort_order ) . " LIMIT " . $this -> getFrom () . " , { $amount } " ;
2009-01-13 17:09:30 +00:00
}
if ( $e107 -> sql -> db_Select ( 'news' , '*' , $query , ( $_POST [ 'searchquery' ] ? 0 : " nowhere " )))
{
$newsarray = $e107 -> sql -> db_getList ();
2009-07-03 02:27:03 +00:00
2009-07-03 06:48:43 +00:00
$text .= "
2009-01-13 17:09:30 +00:00
< form action = '".e_SELF."' id = 'newsform' method = 'post' >
< fieldset id = 'core-newspost-list' >
< legend class = 'e-hideme' > " .NWSLAN_4. " </ legend >
< table cellpadding = '0' cellspacing = '0' class = 'adminlist' >
2009-07-17 07:53:13 +00:00
" . $frm->colGroup ( $this->_fields , $this->fieldpref ).
$frm -> thead ( $this -> _fields , $this -> fieldpref , " main.[FIELD].[ASC].[FROM] " ) . "
< tbody > " ;
2009-07-03 02:27:03 +00:00
2009-01-13 17:09:30 +00:00
$ren_type = array ( " default " , " title " , " other-news " , " other-news 2 " );
2009-07-03 02:27:03 +00:00
foreach ( $newsarray as $field => $row )
2009-01-13 17:09:30 +00:00
{
2009-07-03 02:27:03 +00:00
$author = get_user_data ( $row [ 'news_author' ]);
$thumbnail = ( $row [ 'news_thumbnail' ] && is_readable ( e_NEWSIMAGE . $row [ 'news_thumbnail' ])) ? " <img src=' " . e_NEWSIMAGE . $row [ 'news_thumbnail' ] . " ' alt='' /> " : " " ;
$sticky = ( $row [ 'news_sticky' ] == 1 ) ? ADMIN_TRUE_ICON : " " ;
$comments = ( $row [ 'news_allow_comments' ] == 1 ) ? ADMIN_TRUE_ICON : " " ;
$text .= " <tr> \n " ;
// Below must be in the same order as the field_columns above.
2009-07-14 11:05:54 +00:00
$rowid = " news_selected[ " . $row [ " news_id " ] . " ] " ;
$text .= " <td class='center'> " . $frm -> checkbox ( $rowid , $row [ 'news_id' ]) . " </td> \n " ;
2009-07-04 13:36:15 +00:00
$text .= ( in_array ( " news_id " , $user_pref [ 'admin_news_columns' ])) ? " <td class='center'> " . $row [ 'news_id' ] . " </td> \n " : " " ;
$text .= ( in_array ( " news_title " , $user_pref [ 'admin_news_columns' ])) ? " <td><a href=' " . $e107 -> url -> getUrl ( 'core:news' , 'main' , " action=item&value1= { $row [ 'news_id' ] } &value2= { $row [ 'news_category' ] } " ) . " '> " . ( $row [ 'news_title' ] ? $e107 -> tp -> toHTML ( $row [ 'news_title' ], false , " TITLE " ) : " [ " . NWSLAN_42 . " ] " ) . " </a></td> \n " : " " ;
$text .= ( in_array ( " news_author " , $user_pref [ 'admin_news_columns' ])) ? " <td> " . $author [ 'user_name' ] . " </td> \n " : " " ;
$text .= ( in_array ( " news_datestamp " , $user_pref [ 'admin_news_columns' ])) ? " <td> " . $gen -> convert_date ( $row [ 'news_datestamp' ], 'short' ) . " </td> \n " : " " ;
$text .= ( in_array ( " news_category " , $user_pref [ 'admin_news_columns' ])) ? " <td> " . $news_category [ $row [ 'news_category' ]] . " </td> \n " : " " ;
$text .= ( in_array ( " news_class " , $user_pref [ 'admin_news_columns' ])) ? " <td class='nowrap'> " . r_userclass_name ( $row [ 'news_class' ]) . " </td> \n " : " " ;
$text .= ( in_array ( " news_render_type " , $user_pref [ 'admin_news_columns' ])) ? " <td class='center nowrap'> " . $ren_type [ $row [ 'news_render_type' ]] . " </td> \n " : " " ;
$text .= ( in_array ( " news_thumbnail " , $user_pref [ 'admin_news_columns' ])) ? " <td class='center nowrap'> " . $thumbnail . " </td> \n " : " " ;
$text .= ( in_array ( " news_sticky " , $user_pref [ 'admin_news_columns' ])) ? " <td class='center'> " . $sticky . " </td> \n " : " " ;
$text .= ( in_array ( " news_allow_comments " , $user_pref [ 'admin_news_columns' ])) ? " <td class='center'> " . $comments . " </td> \n " : " " ;
$text .= ( in_array ( " news_comment_total " , $user_pref [ 'admin_news_columns' ])) ? " <td class='center'> " . $row [ 'news_comment_total' ] . " </td> \n " : " " ;
2009-07-03 02:27:03 +00:00
2009-01-13 17:09:30 +00:00
$text .= "
2009-07-03 02:27:03 +00:00
< td class = 'center' >
< a class = 'action' href = '".e_SELF."?create.edit.{$row[' news_id ']}' tabindex = '".$frm->getNext()."' > " .ADMIN_EDIT_ICON. " </ a >
" . $frm->submit_image ( " delete [ main_ { $row [ 'news_id' ]}] " , LAN_DELETE, 'delete', NWSLAN_39. " [ ID : { $row [ 'news_id' ]}] " ). "
</ td >
</ tr >
2009-01-13 17:09:30 +00:00
" ;
}
$text .= "
</ tbody >
</ table >
</ fieldset >
</ form >
" ;
}
else
{
2009-01-17 01:30:35 +00:00
$text .= " <div class='center'> " . isset ( $_POST [ 'searchquery' ]) ? sprintf ( NWSLAN_121 , '<em>"' . $_POST [ 'searchquery' ]) . " "</em> <a href=' " . e_SELF . " '>« " . LAN_BACK . " </a> " : NWSLAN_43 . " </div> " ;
2006-12-02 04:36:16 +00:00
}
2009-01-13 17:09:30 +00:00
$newsposts = $e107 -> sql -> db_Count ( 'news' );
2006-12-02 04:36:16 +00:00
2009-01-13 17:09:30 +00:00
if ( ! varset ( $_POST [ 'searchquery' ]))
{
2009-07-14 11:05:54 +00:00
$parms = $newsposts . " , " . $amount . " , " . $this -> getFrom () . " , " . e_SELF . " ? " . $this -> getAction () . '.' . ( $this -> getSubAction () ? $this -> getSubAction () : 0 ) . '.' . $this -> _sort_order . " .[FROM] " ;
2009-01-13 17:09:30 +00:00
$nextprev = $e107 -> tp -> parseTemplate ( " { NEXTPREV= { $parms } } " );
if ( $nextprev ) $text .= " <div class='nextprev-bar'> " . $nextprev . " </div> " ;
}
$emessage = & eMessage :: getInstance ();
$e107 -> ns -> tablerender ( NWSLAN_4 , $emessage -> render () . $text );
2006-12-02 04:36:16 +00:00
}
2009-01-13 17:09:30 +00:00
2009-01-15 15:42:24 +00:00
function _pre_create ()
{
2009-01-13 17:09:30 +00:00
2009-09-12 18:25:41 +00:00
if ( $this -> getSubAction () == " edit " && ! $_POST [ 'preview' ])
2009-01-15 15:42:24 +00:00
{
2009-09-12 18:25:41 +00:00
if ( ! isset ( $_POST [ 'submit_news' ]))
2009-01-15 15:42:24 +00:00
{
2009-09-12 18:25:41 +00:00
if ( e107 :: getDb () -> db_Select ( 'news' , '*' , 'news_id=' . intval ( $this -> getId ())))
{
$row = e107 :: getDb () -> db_Fetch ();
$_POST [ 'news_title' ] = $row [ 'news_title' ];
$_POST [ 'data' ] = $row [ 'news_body' ];
$_POST [ 'news_author' ] = $row [ 'news_author' ];
$_POST [ 'news_extended' ] = $row [ 'news_extended' ];
$_POST [ 'news_allow_comments' ] = $row [ 'news_allow_comments' ];
$_POST [ 'news_class' ] = $row [ 'news_class' ];
$_POST [ 'news_summary' ] = $row [ 'news_summary' ];
$_POST [ 'news_sticky' ] = $row [ 'news_sticky' ];
$_POST [ 'news_datestamp' ] = ( $_POST [ 'news_datestamp' ]) ? $_POST [ 'news_datestamp' ] : $row [ 'news_datestamp' ];
$_POST [ 'cat_id' ] = $row [ 'news_category' ];
$_POST [ 'news_start' ] = $row [ 'news_start' ];
$_POST [ 'news_end' ] = $row [ 'news_end' ];
$_POST [ 'comment_total' ] = e107 :: getDb () -> db_Count ( " comments " , " (*) " , " WHERE comment_item_id= { $row [ 'news_id' ] } AND comment_type='0' " );
$_POST [ 'news_rendertype' ] = $row [ 'news_render_type' ];
$_POST [ 'news_thumbnail' ] = $row [ 'news_thumbnail' ];
$_POST [ 'news_meta_keywords' ] = $row [ 'news_meta_keywords' ];
$_POST [ 'news_meta_description' ] = $row [ 'news_meta_description' ];
}
}
$row = array ();
if ( e107 :: getDb () -> db_Select ( 'news_rewrite' , '*' , 'news_rewrite_source=' . intval ( $this -> getId ()) . ' AND news_rewrite_type=1' ))
{
$row = e107 :: getDb () -> db_Fetch ();
2009-01-15 15:42:24 +00:00
}
2009-09-12 18:25:41 +00:00
$_POST [ 'news_rewrite_id' ] = varset ( $row [ 'news_rewrite_id' ], 0 );
$_POST [ 'news_rewrite_source' ] = $this -> getId ();
$_POST [ 'news_rewrite_string' ] = isset ( $_POST [ 'news_rewrite_string' ]) ? $_POST [ 'news_rewrite_string' ] : varset ( $row [ 'news_rewrite_string' ], '' );
$_POST [ 'news_rewrite_type' ] = 1 ;
2009-01-15 15:42:24 +00:00
}
}
function show_create_item ()
2006-12-02 04:36:16 +00:00
{
2009-01-13 17:09:30 +00:00
global $pref ;
2009-01-15 15:42:24 +00:00
$this -> _pre_create ();
require_once ( e_HANDLER . " userclass_class.php " );
2009-01-13 17:09:30 +00:00
require_once ( e_HANDLER . " form_handler.php " );
$frm = new e_form ( true ); //enable inner tabindex counter
2009-01-15 15:42:24 +00:00
$text = '' ;
if ( isset ( $_POST [ 'preview' ]))
{
$text = $this -> preview_item ( $this -> getId ());
}
2009-01-13 17:09:30 +00:00
$sub_action = $this -> getSubAction ();
2009-01-18 19:02:07 +00:00
$id = $this -> getSubAction () != 'sn' && $this -> getSubAction () != 'upload' ? $this -> getId () : 0 ;
2006-12-02 04:36:16 +00:00
2009-09-12 18:25:41 +00:00
$e107 = e107 :: getInstance ();
$tp = e107 :: getParser ();
$sql = e107 :: getDb ();
2009-01-13 17:09:30 +00:00
if ( $sub_action == " sn " && ! varset ( $_POST [ 'preview' ]))
2008-06-15 20:20:28 +00:00
{
2009-09-12 18:25:41 +00:00
if ( $sql -> db_Select ( " submitnews " , " * " , " submitnews_id= " . $this -> getId (), TRUE ))
2009-01-13 17:09:30 +00:00
{
//list($id, $submitnews_name, $submitnews_email, $_POST['news_title'], $submitnews_category, $_POST['data'], $submitnews_datestamp, $submitnews_ip, $submitnews_auth, $submitnews_file) = $sql->db_Fetch();
2009-09-12 18:25:41 +00:00
$row = $sql -> db_Fetch ();
2009-01-13 17:09:30 +00:00
$_POST [ 'news_title' ] = $row [ 'submitnews_title' ];
$_POST [ 'data' ] = $row [ 'submitnews_item' ];
$_POST [ 'cat_id' ] = $row [ 'submitnews_category' ];
2006-12-02 04:36:16 +00:00
2009-01-15 15:42:24 +00:00
if ( defsettrue ( 'e_WYSIWYG' ))
2006-12-02 04:36:16 +00:00
{
2008-05-31 17:55:31 +00:00
if ( substr ( $_POST [ 'data' ], - 7 , 7 ) == '[/html]' ) $_POST [ 'data' ] = substr ( $_POST [ 'data' ], 0 , - 7 );
if ( substr ( $_POST [ 'data' ], 0 , 6 ) == '[html]' ) $_POST [ 'data' ] = substr ( $_POST [ 'data' ], 6 );
2009-01-13 17:09:30 +00:00
$_POST [ 'data' ] .= " <br /><b> " . NWSLAN_49 . " { $row [ 'submitnews_name' ] } </b> " ;
2009-01-26 08:01:05 +00:00
$_POST [ 'data' ] .= ( $row [ 'submitnews_file' ]) ? " <br /><br /><img src=' { e_NEWSIMAGE} { $row [ 'submitnews_file' ] } ' class='f-right' /> " : '' ;
2006-12-02 04:36:16 +00:00
}
else
{
2009-01-13 17:09:30 +00:00
$_POST [ 'data' ] .= " \n [[b] " . NWSLAN_49 . " { $row [ 'submitnews_name' ] } [/b]] " ;
2009-01-26 08:01:05 +00:00
$_POST [ 'data' ] .= ( $row [ 'submitnews_file' ]) ? " \n \n [img] { e_NEWSIMAGE} { $row [ 'submitnews_file' ] } [/img] " : " " ;
2006-12-02 04:36:16 +00:00
}
2009-01-13 17:09:30 +00:00
2006-12-02 04:36:16 +00:00
}
2009-01-13 17:09:30 +00:00
}
2006-12-02 04:36:16 +00:00
2009-01-13 17:09:30 +00:00
if ( $sub_action == " upload " && ! varset ( $_POST [ 'preview' ]))
{
2009-09-12 18:25:41 +00:00
if ( $sql -> db_Select ( 'upload' , '*' , " upload_id= " . $this -> getId ())) {
$row = $sql -> db_Fetch ();
2009-01-13 17:09:30 +00:00
$post_author_id = substr ( $row [ 'upload_poster' ], 0 , strpos ( $row [ 'upload_poster' ], " . " ));
$post_author_name = substr ( $row [ 'upload_poster' ], ( strpos ( $row [ 'upload_poster' ], " . " ) + 1 ));
$match = array ();
//XXX DB UPLOADS STILL SUPPORTED?
$upload_file = " pub_ " . ( preg_match ( '#Binary\s(.*?)\/#' , $row [ 'upload_file' ], $match ) ? $match [ 1 ] : $row [ 'upload_file' ]);
$_POST [ 'news_title' ] = LAN_UPLOAD . " : " . $row [ 'upload_name' ];
2009-01-18 19:02:07 +00:00
$_POST [ 'data' ] = $row [ 'upload_description' ] . " \n [b] " . NWSLAN_49 . " [link= " . $e107 -> url -> getUrl ( 'core:user' , 'main' , 'id=' . $post_author_id ) . " ] " . $post_author_name . " [/link][/b] \n \n [file=request.php? " . $upload_file . " ] { $row [ 'upload_name' ] } [/file] \n " ;
2006-12-02 04:36:16 +00:00
}
2009-01-13 17:09:30 +00:00
}
2006-12-02 04:36:16 +00:00
2009-01-15 15:42:24 +00:00
$text .= "
2009-01-16 17:57:57 +00:00
< div class = 'admintabs' id = 'tab-container' >
< ul class = 'e-tabs e-hideme' id = 'core-emote-tabs' >
< li id = 'tab-general' >< a href = '#core-newspost-create' > " .LAN_NEWS_52. " </ a ></ li >
2009-09-12 18:25:41 +00:00
< li id = 'tab-seo' >< a href = '#core-newspost-seo' > SEO </ a ></ li >
2009-01-16 17:57:57 +00:00
< li id = 'tab-advanced' >< a href = '#core-newspost-edit-options' > " .LAN_NEWS_53. " </ a ></ li >
</ ul >
2009-01-15 15:42:24 +00:00
< form method = 'post' action = '".e_SELF."?".e_QUERY."' id = 'core-newspost-create-form' " .(FILE_UPLOADS ? " enctype = 'multipart/form-data' " : " " ). " >
< fieldset id = 'core-newspost-create' >
2009-01-13 17:09:30 +00:00
< legend > " .LAN_NEWS_52. " </ legend >
< table cellpadding = '0' cellspacing = '0' class = 'adminedit' >
< colgroup span = '2' >
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
< tbody >
< tr >
< td class = 'label' > " .NWSLAN_6. " : </ td >
< td class = 'control' >
" ;
2006-12-02 04:36:16 +00:00
2009-09-12 18:25:41 +00:00
if ( ! $sql -> db_Select ( 'news_category' ))
2007-02-07 18:48:27 +00:00
{
2006-12-02 04:36:16 +00:00
$text .= NWSLAN_10 ;
2007-02-07 18:48:27 +00:00
}
else
{
2009-01-13 17:09:30 +00:00
$text .= "
" . $frm->select_open ('cat_id'). "
" ;
2006-12-02 04:36:16 +00:00
2009-09-12 18:25:41 +00:00
while ( $row = $sql -> db_Fetch ())
2007-02-07 18:48:27 +00:00
{
2009-09-12 18:25:41 +00:00
if ( ADMINPERMS === '0' || check_class ( $row [ 'category_manager' ]))
{
$text .= $frm -> option ( $tp -> toHTML ( $row [ 'category_name' ], FALSE , " LINKTEXT " ), $row [ 'category_id' ], varset ( $_POST [ 'cat_id' ]) == $row [ 'category_id' ]);
}
2006-12-02 04:36:16 +00:00
}
2009-01-13 17:09:30 +00:00
$text .= "
</ select >
" ;
2006-12-02 04:36:16 +00:00
}
2009-01-13 17:09:30 +00:00
$text .= "
</ td >
</ tr >
< tr >
< td class = 'label' > " .NWSLAN_12. " :</ td >
< td class = 'control' >
2009-09-12 18:25:41 +00:00
" . $frm->text ('news_title', $tp->post_toForm ( $_POST['news_title'] )). "
2009-01-13 17:09:30 +00:00
</ td >
</ tr >
< tr >
< td class = 'label' > " .LAN_NEWS_27. " :</ td >
< td class = 'control' >
2009-09-12 18:25:41 +00:00
" . $frm->text ('news_summary', $tp->post_toForm ( $_POST['news_summary'] ), 250). "
2009-01-13 17:09:30 +00:00
</ td >
</ tr >
" ;
2008-05-18 16:34:28 +00:00
2008-06-15 20:20:28 +00:00
// -------- News Author ---------------------
2009-01-13 17:09:30 +00:00
$text .= "
< tr >
< td class = 'label' >
" .LAN_NEWS_50. " :
</ td >
< td class = 'control' >
" ;
2008-05-18 16:34:28 +00:00
if ( ! getperms ( '0' ) && ! check_class ( $pref [ 'news_editauthor' ]))
{
2009-01-13 17:09:30 +00:00
$auth = ( $_POST [ 'news_author' ]) ? intval ( $_POST [ 'news_author' ]) : USERID ;
$e107 -> sql -> db_Select ( " user " , " user_name " , " user_id= { $auth } LIMIT 1 " );
$row = $e107 -> sql -> db_Fetch ( MYSQL_ASSOC );
$text .= " <input type='hidden' name='news_author' value=' " . $auth . chr ( 35 ) . $row [ 'user_name' ] . " ' /> " ;
$text .= " <a href=' " . $e107 -> url -> getUrl ( 'core:user' , 'main' , 'id=' . $_POST [ 'news_author' ]) . " '> " . $row [ 'user_name' ] . " </a> " ;
2008-05-18 16:34:28 +00:00
}
else // allow master admin to
{
2009-01-13 17:09:30 +00:00
$text .= $frm -> select_open ( 'news_author' );
2009-04-27 21:23:37 +00:00
$qry = " SELECT user_id,user_name FROM #user WHERE user_perms = '0' OR user_perms = '0.' OR user_perms REGEXP('(^|,)(H)(,| $ )') " ;
2008-05-18 16:34:28 +00:00
if ( $pref [ 'subnews_class' ] && $pref [ 'subnews_class' ] != e_UC_GUEST && $pref [ 'subnews_class' ] != e_UC_NOBODY )
{
if ( $pref [ 'subnews_class' ] == e_UC_MEMBER )
{
$qry .= " OR user_ban != 1 " ;
}
elseif ( $pref [ 'subnews_class' ] == e_UC_ADMIN )
{
$qry .= " OR user_admin = 1 " ;
}
else
{
2009-01-13 17:09:30 +00:00
$qry .= " OR FIND_IN_SET( " . intval ( $pref [ 'subnews_class' ]) . " , user_class) " ;
2008-05-18 16:34:28 +00:00
}
}
2009-09-12 18:25:41 +00:00
$sql -> db_Select_gen ( $qry );
while ( $row = $sql -> db_Fetch ())
2008-05-18 16:34:28 +00:00
{
if ( $_POST [ 'news_author' ])
{
2009-01-13 17:09:30 +00:00
$sel = ( $_POST [ 'news_author' ] == $row [ 'user_id' ]);
2008-05-18 16:34:28 +00:00
}
else
{
2009-01-13 17:09:30 +00:00
$sel = ( USERID == $row [ 'user_id' ]);
2008-05-18 16:34:28 +00:00
}
2009-01-13 17:09:30 +00:00
$text .= $frm -> option ( $row [ 'user_name' ], $row [ 'user_id' ] . chr ( 35 ) . $row [ 'user_name' ], $sel );
2008-05-18 16:34:28 +00:00
}
$text .= " </select>
" ;
}
2008-06-15 20:20:28 +00:00
2008-05-18 16:34:28 +00:00
$text .= "
2009-01-13 17:09:30 +00:00
</ td >
</ tr >
< tr >
< td class = 'label' > " .NWSLAN_13. " :< br /></ td >
< td class = 'control' > " ;
2009-09-12 18:25:41 +00:00
$val = ( strstr ( $tp -> post_toForm ( $_POST [ 'data' ]), " [img]http " ) ? $tp -> post_toForm ( $_POST [ 'data' ]) : str_replace ( " [img]../ " , " [img] " , $tp -> post_toForm ( $_POST [ 'data' ])));
2009-01-13 17:09:30 +00:00
$text .= $frm -> bbarea ( 'data' , $val , 'news' , 'helpb' );
// Extended news form textarea
// Fixes Firefox issue with hidden wysiwyg textarea.
// XXX - WYSIWYG is already plugin, this should go
2009-07-14 11:05:54 +00:00
// if(defsettrue('e_WYSIWYG')) $ff_expand = "tinyMCE.execCommand('mceResetDesignMode')";
2009-09-12 18:25:41 +00:00
$val = ( strstr ( $tp -> post_toForm ( $_POST [ 'news_extended' ]), " [img]http " ) ? $tp -> post_toForm ( $_POST [ 'news_extended' ]) : str_replace ( " [img]../ " , " [img] " , $tp -> post_toForm ( $_POST [ 'news_extended' ])));
2006-12-02 04:36:16 +00:00
$text .= "
2009-01-13 17:09:30 +00:00
</ td >
</ tr >
< tr >
< td class = 'label' > " .NWSLAN_14. " :</ td >
< td class = 'control' >
2009-01-15 15:42:24 +00:00
< a href = '#news-extended-cont' class = 'e-expandit' onclick = \ " $ff_expand\ " > " .NWSLAN_83. " </ a >
< div class = 'e-hideme' id = 'news-extended-cont' >
2009-01-13 17:09:30 +00:00
" . $frm->bbarea ('news_extended', $val , 'extended', 'helpc'). "
</ div >
</ td >
</ tr >
< tr >
< td class = 'label' > " .NWSLAN_66. " :</ td >
< td class = 'control' >
2009-01-15 15:42:24 +00:00
< a href = '#news-upload-cont' class = 'e-expandit' > " .NWSLAN_69. " </ a >
< div class = 'e-hideme' id = 'news-upload-cont' >
2009-01-13 17:09:30 +00:00
" ;
2006-12-02 04:36:16 +00:00
if ( ! FILE_UPLOADS )
{
$text .= " <b> " . LAN_UPLOAD_SERVEROFF . " </b> " ;
}
else
{
2009-01-26 08:01:05 +00:00
if ( ! is_writable ( e_DOWNLOAD ))
2006-12-02 04:36:16 +00:00
{
2009-01-26 08:01:05 +00:00
$text .= LAN_UPLOAD_777 . " <b> " . str_replace ( " ../ " , " " , e_DOWNLOAD ) . " </b><br /><br /> " ;
2006-12-02 04:36:16 +00:00
}
2009-01-26 08:01:05 +00:00
if ( ! is_writable ( e_NEWSIMAGE ))
2006-12-02 04:36:16 +00:00
{
2009-01-26 08:01:05 +00:00
$text .= LAN_UPLOAD_777 . " <b> " . str_replace ( " ../ " , " " , e_NEWSIMAGE ) . " </b><br /><br /> " ;
2006-12-02 04:36:16 +00:00
}
2009-01-13 17:09:30 +00:00
$up_name = array ( LAN_NEWS_24 , NWSLAN_67 , LAN_NEWS_22 , NWSLAN_68 );
$up_value = array ( " resize " , " image " , " thumb " , " file " );
2006-12-02 04:36:16 +00:00
2009-01-13 17:09:30 +00:00
$text .= "
2009-01-15 15:42:24 +00:00
< div class = 'field-spacer' >
" . $frm->admin_button ('dupfield', LAN_NEWS_26, 'action', '', array('other' => 'onclick= " duplicateHTML ( \ 'upline\',\'up_container\');"' )) . "
</ div >
< div id = 'up_container' class = 'field-spacer' >
< div id = 'upline' class = 'left nowrap' >
2009-01-13 17:09:30 +00:00
" . $frm->file ('file_userfile[]'). "
" . $frm->select_open ('uploadtype[]'). "
" ;
2009-04-27 21:23:37 +00:00
2006-12-02 04:36:16 +00:00
for ( $i = 0 ; $i < count ( $up_value ); $i ++ )
{
2009-01-13 17:09:30 +00:00
$text .= $frm -> option ( $up_name [ $i ], $up_value [ $i ], varset ( $_POST [ 'uploadtype' ]) == $up_value [ $i ]);
2009-01-17 01:30:35 +00:00
}
2009-01-13 17:09:30 +00:00
//FIXME - upload shortcode, flexible enough to be used everywhere
2009-01-26 08:01:05 +00:00
// Note from Cameron: should include iframe and use ajax as to not require a full refresh of the page.
2009-04-27 21:23:37 +00:00
2009-01-13 17:09:30 +00:00
$text .= "
</ select >
2009-01-15 15:42:24 +00:00
</ div >
</ div >
< div class = 'field-spacer' >
< span class = 'smalltext' > " .LAN_NEWS_25. " </ span >& nbsp ; " . $frm->text ('resize_value', ( $_POST['resize_value'] ? $_POST['resize_value'] : '100'), 4, 'size=3&class=tbox'). " & nbsp ; px
</ div >
< div class = 'field-spacer' >
" . $frm->admin_button ('submitupload', NWSLAN_66, 'upload'). "
2009-01-13 17:09:30 +00:00
</ div >
" ;
2006-12-02 04:36:16 +00:00
}
2009-01-13 17:09:30 +00:00
$text .= "
</ div >
</ td >
</ tr >
< tr >
< td class = 'label' > " .NWSLAN_67. " :</ td >
< td class = 'control' >
2009-01-15 15:42:24 +00:00
< a href = '#news-images-cont' class = 'e-expandit' > " .LAN_NEWS_23. " </ a >
< div class = 'e-hideme' id = 'news-images-cont' >
2009-01-13 17:09:30 +00:00
" ;
2006-12-02 04:36:16 +00:00
2008-02-19 19:33:45 +00:00
$parms = " name=news_thumbnail " ;
2009-01-26 08:01:05 +00:00
$parms .= " &path= " . e_NEWSIMAGE ;
2009-01-15 15:42:24 +00:00
$parms .= " &filter=0 " ;
$parms .= " &fullpath=1 " ;
2009-01-16 17:57:57 +00:00
$parms .= " &default= " . urlencode ( basename ( $_POST [ 'news_thumbnail' ]));
2009-01-15 15:42:24 +00:00
$parms .= " &multiple=FALSE " ;
2006-12-02 04:36:16 +00:00
$parms .= " &label=-- " . LAN_NEWS_48 . " -- " ;
2009-01-15 15:42:24 +00:00
$parms .= " &subdirs=0 " ;
$parms .= " &tabindex= " . $frm -> getNext ();
//$parms .= "&click_target=data";
//$parms .= "&click_prefix=[img][[e_IMAGE]]newspost_images/";
//$parms .= "&click_postfix=[/img]";
2008-03-18 00:39:02 +00:00
2009-09-12 18:25:41 +00:00
$text .= " <div class='field-section'> " . $tp -> parseTemplate ( " { IMAGESELECTOR= { $parms } &scaction=select} " ) . " </div> " ;
$text .= " <div class='field-spacer'> " . $tp -> parseTemplate ( " { IMAGESELECTOR= { $parms } &scaction=preview} " ) . " </div> " ;
2006-12-02 04:36:16 +00:00
2009-01-13 17:09:30 +00:00
$text .= "
</ div >
</ td >
</ tr >
</ tbody >
</ table >
</ fieldset >
2006-12-02 04:36:16 +00:00
" ;
2009-09-12 18:25:41 +00:00
//BEGIN SEO block
$text .= "
< fieldset id = 'core-newspost-seo' >
< legend > SEO </ legend >
< table cellpadding = '0' cellspacing = '0' class = 'adminedit' >
< colgroup span = '2' >
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
< tbody >
< tr >
< td class = 'label' > Friendly URL string : </ td >
< td class = 'control' >
" . $frm->text ('news_rewrite_string', $tp->post_toForm ( $_POST['news_rewrite_string'] ), 255). "
" . $frm->hidden ('news_rewrite_id', intval( $_POST['news_rewrite_id'] )). "
< div class = 'field-help' > To make this work , you need to enable 'SEF URLs' config profile from < a href = '".e_ADMIN_ABS."eurl.php' > URL Configuration area </ a ></ div >
</ td >
</ tr >
< tr >
< td class = 'label' > Meta keywords : </ td >
< td class = 'control' > " . $frm->text ('news_meta_keywords', $tp->post_toForm ( $_POST['news_meta_keywords'] ), 255). " </ td >
</ tr >
< tr >
< td class = 'label' > Meta description : </ td >
< td class = 'control' > " . $frm->textarea ('news_meta_description', $tp->post_toForm ( $_POST['news_meta_description'] ), 7). " </ td >
</ tr >
</ tbody >
</ table >
</ fieldset >
" ;
2006-12-02 04:36:16 +00:00
2009-09-12 18:25:41 +00:00
//BEGIN Options block
2009-01-13 17:09:30 +00:00
$text .= "
< fieldset id = 'core-newspost-edit-options' >
2009-01-15 15:42:24 +00:00
< legend > " .LAN_NEWS_53. " </ legend >
2009-01-13 17:09:30 +00:00
< table cellpadding = '0' cellspacing = '0' class = 'adminedit' >
< colgroup span = '2' >
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
< tbody >
< tr >
< td class = 'label' > " .NWSLAN_15. " :</ td >
< td class = 'control' >
2009-08-24 08:34:55 +00:00
" . $frm->radio ('news_allow_comments', 0, ! $_POST['news_allow_comments'] ). " " . $frm->label (LAN_ENABLED, 'news_allow_comments', 0). " & nbsp ; & nbsp ;
2009-05-10 17:31:51 +00:00
" . $frm->radio ('news_allow_comments', 1, $_POST['news_allow_comments'] ). " " . $frm->label (LAN_DISABLED, 'news_allow_comments', 1). "
2009-01-15 15:42:24 +00:00
< div class = 'field-help' >
" .NWSLAN_18. "
2009-01-13 17:09:30 +00:00
</ div >
</ td >
</ tr >
< tr >
< td class = 'label' > " .NWSLAN_73. " :</ td >
< td class = 'control' >
" ;
2006-12-02 04:36:16 +00:00
$ren_type = array ( NWSLAN_75 , NWSLAN_76 , NWSLAN_77 , NWSLAN_77 . " 2 " );
2009-01-13 17:09:30 +00:00
$r_array = array ();
2006-12-02 04:36:16 +00:00
foreach ( $ren_type as $key => $value ) {
2009-01-13 17:09:30 +00:00
$r_array [ $key ] = $value ;
2006-12-02 04:36:16 +00:00
}
2009-01-13 17:09:30 +00:00
$text .= "
" . $frm->radio_multi ('news_rendertype', $r_array , $_POST['news_rendertype'] , true). "
2009-01-15 15:42:24 +00:00
< div class = 'field-help' >
" .NWSLAN_74. "
</ div >
2009-01-13 17:09:30 +00:00
</ td >
</ tr >
< tr >
< td class = 'label' > " .NWSLAN_19. " :</ td >
< td class = 'control' >
2009-01-15 15:42:24 +00:00
< div class = 'field-spacer' > " .NWSLAN_21. " :</ div >
< div class = 'field-spacer' >
2009-01-13 17:09:30 +00:00
" ;
2006-12-02 04:36:16 +00:00
$_startdate = ( $_POST [ 'news_start' ] > 0 ) ? date ( " d/m/Y " , $_POST [ 'news_start' ]) : " " ;
$cal_options [ 'showsTime' ] = false ;
$cal_options [ 'showOthers' ] = false ;
$cal_options [ 'weekNumbers' ] = false ;
$cal_options [ 'ifFormat' ] = " %d/%m/%Y " ;
$cal_attrib [ 'class' ] = " tbox " ;
$cal_attrib [ 'size' ] = " 10 " ;
$cal_attrib [ 'name' ] = " news_start " ;
$cal_attrib [ 'value' ] = $_startdate ;
2009-01-15 15:42:24 +00:00
$cal_attrib [ 'tabindex' ] = $frm -> getNext ();
2009-01-13 17:09:30 +00:00
$text .= $this -> _cal -> make_input_field ( $cal_options , $cal_attrib );
2006-12-02 04:36:16 +00:00
$text .= " - " ;
$_enddate = ( $_POST [ 'news_end' ] > 0 ) ? date ( " d/m/Y " , $_POST [ 'news_end' ]) : " " ;
unset ( $cal_options );
unset ( $cal_attrib );
$cal_options [ 'showsTime' ] = false ;
$cal_options [ 'showOthers' ] = false ;
$cal_options [ 'weekNumbers' ] = false ;
$cal_options [ 'ifFormat' ] = " %d/%m/%Y " ;
$cal_attrib [ 'class' ] = " tbox " ;
$cal_attrib [ 'size' ] = " 10 " ;
$cal_attrib [ 'name' ] = " news_end " ;
$cal_attrib [ 'value' ] = $_enddate ;
2009-01-15 15:42:24 +00:00
$cal_attrib [ 'tabindex' ] = $frm -> getNext ();
2009-01-13 17:09:30 +00:00
$text .= $this -> _cal -> make_input_field ( $cal_options , $cal_attrib );
2006-12-02 04:36:16 +00:00
$text .= "
2009-01-15 15:42:24 +00:00
</ div >
< div class = 'field-help' >
" .NWSLAN_72. "
2009-01-13 17:09:30 +00:00
</ div >
</ td >
</ tr >
< tr >
< td class = 'label' > " .LAN_NEWS_32. " :</ td >
< td class = 'control' >
2009-01-15 15:42:24 +00:00
< div class = 'field-spacer' >
2009-01-13 17:09:30 +00:00
" ;
2006-12-02 04:36:16 +00:00
$_update_datestamp = ( $_POST [ 'news_datestamp' ] > 0 && ! strpos ( $_POST [ 'news_datestamp' ], " / " )) ? date ( " d/m/Y H:i:s " , $_POST [ 'news_datestamp' ]) : trim ( $_POST [ 'news_datestamp' ]);
unset ( $cal_options );
unset ( $cal_attrib );
$cal_options [ 'showsTime' ] = true ;
$cal_options [ 'showOthers' ] = true ;
$cal_options [ 'weekNumbers' ] = false ;
$cal_options [ 'ifFormat' ] = " %d/%m/%Y %H:%M:%S " ;
$cal_options [ 'timeFormat' ] = " 24 " ;
$cal_attrib [ 'class' ] = " tbox " ;
$cal_attrib [ 'name' ] = " news_datestamp " ;
$cal_attrib [ 'value' ] = $_update_datestamp ;
2009-01-13 17:09:30 +00:00
$text .= $this -> _cal -> make_input_field ( $cal_options , $cal_attrib );
2006-12-02 04:36:16 +00:00
2009-01-13 17:09:30 +00:00
$text .= "
2009-01-15 15:42:24 +00:00
</ div >
< div class = 'field-spacer' >
" . $frm->checkbox ('update_datestamp', '1', $_POST['update_datestamp'] ). $frm->label (NWSLAN_105, 'update_datestamp', '1'). "
</ div >
< div class = 'field-help' >
" .LAN_NEWS_33. "
2009-01-13 17:09:30 +00:00
</ div >
</ td >
</ tr >
" ;
2006-12-02 04:36:16 +00:00
2008-05-18 16:34:28 +00:00
// --------------------- News Userclass ---------------------------
2006-12-02 04:36:16 +00:00
2009-01-13 17:09:30 +00:00
$text .= "
< tr >
< td class = 'label' > " .NWSLAN_22. " :</ td >
2009-01-20 22:37:49 +00:00
< td class = 'control' >
2009-04-29 21:46:16 +00:00
" . $frm->uc_checkbox ('news_userclass', $_POST['news_class'] , 'nobody,public,guest,member,admin,classes,language', 'description=1'). "
2009-01-15 15:42:24 +00:00
< div class = 'field-help' >
" .NWSLAN_84. "
2009-01-13 17:09:30 +00:00
</ div >
</ td >
</ tr >
< tr >
< td class = 'label' > " .LAN_NEWS_28. " :</ td >
< td class = 'control' >
2009-01-15 15:42:24 +00:00
" . $frm->checkbox ('news_sticky', '1', $_POST['news_sticky'] ). $frm->label (LAN_NEWS_30, 'news_sticky', '1'). "
< div class = 'field-help' >
" .LAN_NEWS_29. "
2009-01-13 17:09:30 +00:00
</ div >
</ td >
</ tr >
2006-12-02 04:36:16 +00:00
" ;
if ( $pref [ 'trackbackEnabled' ]){
2009-01-13 17:09:30 +00:00
$text .= "
< tr >
< td class = 'label' > " .LAN_NEWS_34. " :</ td >
< td class = 'control' >
< a class = 'e-pointer' onclick = 'expandit(this);' > " .LAN_NEWS_35. " </ a >
< div class = 'e-hideme' >
< div class = 'field-spacer' >
< span class = 'smalltext' > " .LAN_NEWS_37. " </ span >
</ div >
< div class = 'field-spacer' >
< textarea class = 'tbox textarea' name = 'trackback_urls' style = 'width:95%' cols = '80' rows = '5' > " . $_POST['trackback_urls'] . " </ textarea >
</ div >
</ div >
</ td >
</ tr >
" ;
2006-12-02 04:36:16 +00:00
}
2008-12-29 20:51:24 +00:00
//triggerHook
$data = array ( 'method' => 'form' , 'table' => 'news' , 'id' => $id , 'plugin' => 'news' , 'function' => 'create_item' );
2009-01-13 17:09:30 +00:00
$hooks = $e107 -> e_event -> triggerHook ( $data );
2008-12-29 20:51:24 +00:00
if ( ! empty ( $hooks ))
{
2009-01-13 17:09:30 +00:00
$text .= "
< tr >
< td colspan = '2' > " .LAN_HOOKS. " </ td >
</ tr >
" ;
2008-12-29 20:51:24 +00:00
foreach ( $hooks as $hook )
{
if ( ! empty ( $hook ))
{
$text .= "
2009-01-13 17:09:30 +00:00
< tr >
< td class = 'label' > " . $hook['caption'] . " </ td >
< td class = 'control' > " . $hook['text'] . " </ td >
</ tr >
" ;
2008-12-29 20:51:24 +00:00
}
}
}
2006-12-02 04:36:16 +00:00
2009-01-13 17:09:30 +00:00
$text .= "
</ tbody >
</ table >
</ fieldset >
< div class = 'buttons-bar center' >
" . $frm->admin_button ('preview', isset( $_POST['preview'] ) ? NWSLAN_24 : NWSLAN_27 , 'submit'). "
" . $frm->admin_button ('submit_news', ( $id && $sub_action != " sn " && $sub_action != " upload " ) ? NWSLAN_25 : NWSLAN_26 , 'update'). "
2009-01-16 17:57:57 +00:00
" . $frm->checkbox ('create_edit_stay', 1, isset( $_POST['create_edit_stay'] )). $frm->label (LAN_NEWS_54, 'create_edit_stay', 1). "
2009-01-13 17:09:30 +00:00
< input type = 'hidden' name = 'news_id' value = '{$id}' />
</ div >
</ form >
2009-01-16 17:57:57 +00:00
</ div >
2006-12-02 04:36:16 +00:00
2009-01-13 17:09:30 +00:00
" ;
2009-01-15 15:42:24 +00:00
2009-09-12 18:25:41 +00:00
$emessage = eMessage :: getInstance ();
2009-01-17 01:30:35 +00:00
$e107 -> ns -> tablerender ( $this -> getSubAction () == 'edit' ? NWSLAN_29a : NWSLAN_29 , $emessage -> render () . $text );
2006-12-02 04:36:16 +00:00
}
2009-01-13 17:09:30 +00:00
function preview_item ( $id )
2008-12-07 13:08:54 +00:00
{
2009-01-15 15:42:24 +00:00
$ix = new news ;
$e107 = & e107 :: getInstance ();
$_POST [ 'news_title' ] = $e107 -> tp -> toDB ( $_POST [ 'news_title' ]);
$_POST [ 'news_summary' ] = $e107 -> tp -> toDB ( $_POST [ 'news_summary' ]);
2006-12-02 04:36:16 +00:00
$_POST [ 'news_id' ] = $id ;
if ( $_POST [ 'news_start' ])
{
$tmp = explode ( " / " , $_POST [ 'news_start' ]);
$_POST [ 'news_start' ] = mktime ( 0 , 0 , 0 , $tmp [ 1 ], $tmp [ 0 ], $tmp [ 2 ]);
}
else
{
$_POST [ 'news_start' ] = 0 ;
}
if ( $_POST [ 'news_end' ])
{
$tmp = explode ( " / " , $_POST [ 'news_end' ]);
$_POST [ 'news_end' ] = mktime ( 0 , 0 , 0 , $tmp [ 1 ], $tmp [ 0 ], $tmp [ 2 ]);
}
else
{
$_POST [ 'news_end' ] = 0 ;
}
2009-01-15 15:42:24 +00:00
$matches = array ();
2006-12-02 04:36:16 +00:00
if ( preg_match ( " #(.*?)/(.*?)/(.*?) (.*?):(.*?):(.*?) $ # " , $_POST [ 'news_datestamp' ], $matches ))
{
$_POST [ 'news_datestamp' ] = mktime ( $matches [ 4 ], $matches [ 5 ], $matches [ 6 ], $matches [ 2 ], $matches [ 1 ], $matches [ 3 ]);
}
else
{
$_POST [ 'news_datestamp' ] = time ();
}
if ( $_POST [ 'update_datestamp' ])
{
$_POST [ 'news_datestamp' ] = time ();
}
2009-01-15 15:42:24 +00:00
$e107 -> sql -> db_Select ( " news_category " , " * " , " category_id=' " . intval ( $_POST [ 'cat_id' ]) . " ' " );
list ( $_POST [ 'category_id' ], $_POST [ 'category_name' ], $_POST [ 'category_icon' ]) = $e107 -> sql -> db_Fetch ();
list ( $_POST [ 'user_id' ], $_POST [ 'user_name' ]) = explode ( chr ( 35 ), $_POST [ 'news_author' ]);
2008-05-18 16:34:28 +00:00
$_POST [ 'news_author' ] = $_POST [ 'user_id' ];
2009-01-18 19:02:07 +00:00
$_POST [ 'comment_total' ] = $id ? $e107 -> sql -> db_Count ( " comments " , " (*) " , " WHERE comment_item_id= { $id } AND comment_type='0' " ) : 0 ;
2006-12-02 04:36:16 +00:00
$_PR = $_POST ;
2009-01-15 15:42:24 +00:00
$_PR [ 'news_body' ] = $e107 -> tp -> post_toHTML ( $_PR [ 'data' ], FALSE );
$_PR [ 'news_title' ] = $e107 -> tp -> post_toHTML ( $_PR [ 'news_title' ], FALSE , " emotes_off, no_make_clickable " );
$_PR [ 'news_summary' ] = $e107 -> tp -> post_toHTML ( $_PR [ 'news_summary' ]);
$_PR [ 'news_extended' ] = $e107 -> tp -> post_toHTML ( $_PR [ 'news_extended' ]);
2006-12-02 04:36:16 +00:00
$_PR [ 'news_file' ] = $_POST [ 'news_file' ];
2009-01-16 17:57:57 +00:00
$_PR [ 'news_thumbnail' ] = basename ( $_POST [ 'news_thumbnail' ]);
2006-12-02 04:36:16 +00:00
2009-01-15 15:42:24 +00:00
//$ix->render_newsitem($_PR);
return "
< fieldset id = 'core-newspost-preview' >
< legend > " .NWSLAN_27. " </ legend >
< table cellpadding = '0' cellspacing = '0' class = 'admininfo' >
< tbody >
< tr >
< td class = 'label' colspan = '2' >
" . $e107->tp ->parseTemplate(' { NEWSINFO}'). $ix->render_newsitem ( $_PR , 'return'). "
</ td >
</ tr >
</ tbody >
</ table >
</ fieldset >
" ;
2006-12-02 04:36:16 +00:00
}
2009-04-27 21:23:37 +00:00
2009-01-17 22:48:14 +00:00
function ajax_exec_cat ()
2008-12-07 13:08:54 +00:00
{
2009-01-17 22:48:14 +00:00
require_once ( e_HANDLER . 'js_helper.php' );
$e107 = & e107 :: getInstance ();
2009-04-27 21:23:37 +00:00
2009-01-17 22:48:14 +00:00
$category = array ();
2009-04-27 21:23:37 +00:00
if ( $e107 -> sql -> db_Select ( " news_category " , " * " , " category_id= " . $this -> getId ()))
2009-01-17 22:48:14 +00:00
{
$category = $e107 -> sql -> db_Fetch ();
}
if ( empty ( $category ))
{
e_jshelper :: sendAjaxError ( 404 , 'Page not found!' , 'Requested news category was not found in the DB.' , true );
}
$jshelper = new e_jshelper ();
2009-04-27 21:23:37 +00:00
2009-09-10 19:15:43 +00:00
$jshelper -> addResponseAction ( 'fill-form' , $category );
2009-09-12 18:25:41 +00:00
//reset if required
$category_rewrite = array (
'news_rewrite_id' => 0 ,
'news_rewrite_source' => 0 ,
'news_rewrite_string' => '' ,
'news_rewrite_type' => 0
);
if ( $e107 -> sql -> db_Select ( 'news_rewrite' , '*' , 'news_rewrite_source=' . $this -> getId () . ' AND news_rewrite_type=2' ))
2009-09-10 19:15:43 +00:00
{
$category_rewrite = $e107 -> sql -> db_Fetch ();
}
2009-09-12 18:25:41 +00:00
$jshelper -> addResponseAction ( 'fill-form' , $category_rewrite );
2009-01-17 22:48:14 +00:00
2009-09-12 18:25:41 +00:00
//show cancel and update, hide create buttons; disable create button (just in case)
$jshelper -> addResponseAction ( 'element-invoke-by-id' , array (
'show' => 'category-clear,update-category' ,
'disabled,1' => 'create-category' ,
'hide' => 'create-category' ,
'newsScrollToMe' => 'core-newspost-cat-create'
));
2009-04-27 21:23:37 +00:00
2009-01-17 22:48:14 +00:00
//Send the prefered response type
2009-09-10 19:15:43 +00:00
$jshelper -> sendResponse ( 'fill-form' );
2006-12-02 04:36:16 +00:00
}
2009-09-12 18:25:41 +00:00
function ajax_exec_cat_list_refresh ()
{
echo $this -> show_categoriy_list ();
}
function ajax_exec_catorder ()
{
//interactive category order
2009-09-13 16:37:18 +00:00
$check = e107 :: getDb () -> db_Update ( 'news_category' , 'category_order=' . intval ( $this -> getId ()) . ' WHERE category_id=' . intval ( $this -> getSubAction ()));
2009-09-12 18:25:41 +00:00
if ( e107 :: getDb () -> getLastErrorNumber ())
{
echo 'mySQL Error #' . e107 :: getDb () -> getLastErrorNumber () . ': ' . e107 :: getDb () -> getLastErrorText ();
2009-09-13 16:37:18 +00:00
return ;
}
if ( $check )
{
e107 :: getAdminLog () -> log_event ( 'NEWS_05' , 'category_id=' . intval ( $this -> getSubAction ()) . ', category_order=' . intval ( $this -> getId ()), E_LOG_INFORMATIVE , '' );
2009-09-12 18:25:41 +00:00
}
}
function ajax_exec_catmanager ()
{
//interactive category manage permissions
2009-09-13 16:37:18 +00:00
$check = e107 :: getDb () -> db_Update ( 'news_category' , 'category_manager=' . intval ( $this -> getId ()) . ' WHERE category_id=' . intval ( $this -> getSubAction ()));
2009-09-12 18:25:41 +00:00
if ( e107 :: getDb () -> getLastErrorNumber ())
{
echo 'mySQL Error #' . e107 :: getDb () -> getLastErrorNumber () . ': ' . e107 :: getDb () -> getLastErrorText ();
2009-09-13 16:37:18 +00:00
retrun ;
}
if ( $check )
{
$class_name = e107 :: getUserClass () -> uc_get_classname ( $this -> getId ());
e107 :: getAdminLog () -> log_event ( 'NEWS_05' , 'category_id=' . intval ( $this -> getSubAction ()) . ', category_manager=' . intval ( $this -> getId ()) . ' (' . $class_name . ')' , E_LOG_INFORMATIVE , '' );
2009-09-12 18:25:41 +00:00
}
}
2006-12-02 04:36:16 +00:00
2009-01-16 17:57:57 +00:00
function show_categories ()
2008-12-07 13:08:54 +00:00
{
2009-01-16 17:57:57 +00:00
require_once ( e_HANDLER . " form_handler.php " );
$frm = new e_form ( true ); //enable inner tabindex counter
2006-12-02 04:36:16 +00:00
2009-09-10 19:15:43 +00:00
$e107 = e107 :: getInstance ();
2009-04-27 21:23:37 +00:00
2009-01-16 17:57:57 +00:00
$category = array ();
2009-09-10 19:15:43 +00:00
$category_rewrite = array ();
if ( $this -> getSubAction () == " edit " && ! isset ( $_POST [ 'update_category' ]))
2009-01-17 22:48:14 +00:00
{
2009-09-10 19:15:43 +00:00
if ( e107 :: getDb () -> db_Select ( " news_category " , " * " , " category_id= " . $this -> getId ()))
2009-01-17 22:48:14 +00:00
{
2009-09-10 19:15:43 +00:00
$category = e107 :: getDb () -> db_Fetch ();
}
if ( $category && e107 :: getDb () -> db_Select ( 'news_rewrite' , '*' , 'news_rewrite_source=' . $this -> getId () . ' AND news_rewrite_type=2' ))
{
$category_rewrite = e107 :: getDb () -> db_Fetch ();
}
}
if ( $this -> error && ( isset ( $_POST [ 'update_category' ]) || isset ( $_POST [ 'create_category' ])))
{
foreach ( $_POST as $k => $v )
{
if ( strpos ( $k , 'category_' ) === 0 )
{
$category [ $k ] = e107 :: getParser () -> post_toForm ( $v );
continue ;
}
if ( strpos ( $k , 'news_rewrite_' ) === 0 )
{
$category_rewrite [ $k ] = e107 :: getParser () -> post_toForm ( $v );
continue ;
}
2006-12-02 04:36:16 +00:00
}
}
2009-09-10 19:15:43 +00:00
//FIXME - lan
2009-01-13 17:09:30 +00:00
$text = "
2009-01-16 17:57:57 +00:00
< form method = 'post' action = '".e_SELF."?cat' id = 'core-newspost-cat-create-form' >
2009-01-15 15:42:24 +00:00
< fieldset id = 'core-newspost-cat-create' >
2009-01-13 17:09:30 +00:00
< legend > " .NWSLAN_56. " </ legend >
< table cellpadding = '0' cellspacing = '0' class = 'adminform' >
< colgroup span = '2' >
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
< tbody >
< tr >
< td class = 'label' > " .NWSLAN_52. " </ td >
< td class = 'control' >
2009-01-16 17:57:57 +00:00
" . $frm->text ('category_name', $category['category_name'] , 200). "
2009-09-10 19:15:43 +00:00
< div class = 'field-help' > Required field </ div >
</ td >
</ tr >
< tr >
< td class = 'label' > Category friendly URL string </ td >
< td class = 'control' >
" . $frm->text ('news_rewrite_string', varset( $category_rewrite['news_rewrite_string'] ), 255). "
< div class = 'field-help' > To make this work , you need to enable 'SEF URLs' config profile from < a href = '".e_ADMIN_ABS."eurl.php' > URL Configuration area </ a ></ div >
</ td >
</ tr >
< tr >
< td class = 'label' > Category meta keywords </ td >
< td class = 'control' >
" . $frm->text ('category_meta_keywords', $category['category_meta_keywords'] , 255). "
< div class = 'field-help' > Used on news categoty list page </ div >
</ td >
</ tr >
< tr >
< td class = 'label' > Category meta description </ td >
< td class = 'control' >
" . $frm->textarea ('category_meta_description', $category['category_meta_description'] , 5). "
< div class = 'field-help' > Used on news categoty list page </ div >
</ td >
</ tr >
< tr >
< td class = 'label' > Category management permissions </ td >
< td class = 'control' >
" . $frm->uc_select ('category_manager', vartrue( $category['category_manager'] , e_UC_ADMIN), 'main,admin,classes'). "
< div class = 'field-help' > Which group of site administrators are able to manage this category related news </ div >
2009-01-13 17:09:30 +00:00
</ td >
</ tr >
< tr >
< td class = 'label' > " .NWSLAN_53. " </ td >
< td class = 'control' >
2009-09-10 19:15:43 +00:00
" . $frm->iconpicker ('category_icon', $category['category_icon'] , NWSLAN_54). "
" . $frm->hidden ('category_order', $category['category_order'] ). "
" . $frm->hidden ('news_rewrite_id', $category_rewrite['news_rewrite_id'] ). "
2009-01-13 17:09:30 +00:00
</ td >
</ tr >
</ tbody >
</ table >
< div class = 'buttons-bar center' >
" ;
2009-09-10 19:15:43 +00:00
if ( $this -> getId ())
2009-01-16 17:57:57 +00:00
{
2009-01-13 17:09:30 +00:00
$text .= "
" . $frm->admin_button ('update_category', NWSLAN_55, 'update'). "
2009-01-16 17:57:57 +00:00
" . $frm->admin_button ('category_clear', LAN_CANCEL, 'cancel'). "
" . $frm->hidden ( " category_id " , $this->getId ()). "
2009-01-13 17:09:30 +00:00
" ;
2009-01-16 17:57:57 +00:00
}
else
{
2009-01-13 17:09:30 +00:00
$text .= "
" . $frm->admin_button ('create_category', NWSLAN_56, 'create'). "
2009-01-17 22:48:14 +00:00
" . $frm->admin_button ('update_category', NWSLAN_55, 'update', '', 'other=style= " display : none " '). "
" . $frm->admin_button ('category_clear', LAN_CANCEL, 'cancel', '', 'other=style= " display : none " '). "
" . $frm->hidden ( " category_id " , 0). "
2009-01-13 17:09:30 +00:00
" ;
2006-12-02 04:36:16 +00:00
}
2009-01-13 17:09:30 +00:00
$text .= "
</ div >
</ fieldset >
</ form >
2009-09-12 18:25:41 +00:00
< div id = 'core-newspost-cat-list-cont' >
" . $this->show_categoriy_list (). "
</ div >
2009-01-13 17:09:30 +00:00
" ;
2006-12-02 04:36:16 +00:00
2009-09-12 18:25:41 +00:00
$emessage = & eMessage :: getInstance ();
$e107 -> ns -> tablerender ( NWSLAN_46a , $emessage -> render () . $text );
}
function show_categoriy_list ()
{
require_once ( e_HANDLER . " form_handler.php " );
$frm = new e_form ( false );
2009-09-10 19:15:43 +00:00
//FIXME - lan
2009-09-12 18:25:41 +00:00
$text = "
2009-01-17 22:48:14 +00:00
< form action = '".e_SELF."?cat' id = 'core-newspost-cat-list-form' method = 'post' >
2009-01-13 17:09:30 +00:00
< fieldset id = 'core-newspost-cat-list' >
< legend > " .NWSLAN_51. " </ legend >
< table cellpadding = '0' cellspacing = '0' class = 'adminlist' >
2009-09-10 19:15:43 +00:00
< colgroup span = '6' >
2009-01-13 17:09:30 +00:00
< col style = 'width: 5%' ></ col >
< col style = 'width: 10%' ></ col >
2009-09-10 19:15:43 +00:00
< col style = 'width: 40%' ></ col >
< col style = 'width: 20%' ></ col >
2009-01-13 17:09:30 +00:00
< col style = 'width: 15%' ></ col >
2009-09-10 19:15:43 +00:00
< col style = 'width: 10%' ></ col >
2009-01-13 17:09:30 +00:00
</ colgroup >
< thead >
< tr >
< th class = 'center' > " .LAN_NEWS_45. " </ th >
2009-01-17 22:48:14 +00:00
< th class = 'center' > " .NWSLAN_122. " </ th >
2009-09-10 19:15:43 +00:00
< th > " .NWSLAN_6. " / SEF String </ th >
< th > Manage Permissions </ th >
2009-01-13 17:09:30 +00:00
< th class = 'center last' > " .LAN_OPTIONS. " </ th >
2009-09-10 19:15:43 +00:00
< th class = 'center' > Order </ th >
2009-01-13 17:09:30 +00:00
</ tr >
</ thead >
< tbody >
" ;
2009-09-12 18:25:41 +00:00
if ( $category_total = e107 :: getDb () -> db_Select_gen ( " SELECT ncat.*, nrewr.news_rewrite_string FROM #news_category AS ncat LEFT JOIN #news_rewrite AS nrewr ON ncat.category_id=nrewr.news_rewrite_source AND nrewr.news_rewrite_type=2 ORDER BY ncat.category_order ASC " ))
2009-09-10 19:15:43 +00:00
{
2009-09-12 18:25:41 +00:00
$tindex = 100 ;
while ( $category = e107 :: getDb () -> db_Fetch ()) {
2006-12-02 04:36:16 +00:00
2009-09-12 18:25:41 +00:00
$icon = '' ;
if ( $category [ 'category_icon' ])
{
$icon = ( strstr ( $category [ 'category_icon' ], " images/ " ) ? THEME_ABS . $category [ 'category_icon' ] : ( strpos ( $category [ 'category_icon' ], '{' ) === 0 ? e107 :: getParser () -> replaceConstants ( $category [ 'category_icon' ], 'abs' ) : e_IMAGE_ABS . " icons/ " . $category [ 'category_icon' ]));
$icon = " <img class='icon action' src=' { $icon } ' alt='' /> " ;
2006-12-02 04:36:16 +00:00
}
2009-09-12 18:25:41 +00:00
$sefstr = $category [ 'news_rewrite_string' ] ? " <br />SEF: <strong> { $category [ 'news_rewrite_string' ] } </strong> " : '' ;
2009-01-13 17:09:30 +00:00
$text .= "
< tr >
2009-01-17 22:48:14 +00:00
< td class = 'center middle' > { $category [ 'category_id' ]} </ td >
2009-09-12 18:25:41 +00:00
< td class = 'center middle' > { $icon } </ td >
< td class = 'middle' > { $category [ 'category_name' ]}{ $sefstr } </ td >
< td class = 'middle' > " . $frm->uc_select ('multi_category_manager['. $category['category_id'] .']', vartrue( $category['category_manager'] , e_UC_ADMIN), 'main,admin,classes'). " </ td >
2009-01-17 22:48:14 +00:00
< td class = 'center middle' >
< a class = 'action' id = 'core-news-catedit-{$category[' category_id ']}' href = '".e_SELF."?cat.edit.{$category[' category_id ']}' tabindex = '".$frm->getNext()."' > " .ADMIN_EDIT_ICON. " </ a >
2009-09-12 18:25:41 +00:00
" . $frm->submit_image ( " delete [ category_ { $category [ 'category_id' ]}] " , $category['category_id'] , 'delete', e107::getParser()->toJS(NWSLAN_37. " [ ID : { $category [ 'category_id' ]} ] " )). "
2009-01-13 17:09:30 +00:00
</ td >
2009-09-12 18:25:41 +00:00
< td class = 'middle center' > " . $frm->text ('multi_category_order['. $category['category_id'] .']', $category['category_order'] , 3, 'size=2&tabindex='. $tindex ). " </ td >
2009-01-13 17:09:30 +00:00
</ tr >
" ;
2009-09-12 18:25:41 +00:00
$tindex ++ ;
2006-12-02 04:36:16 +00:00
}
2009-09-12 18:25:41 +00:00
2009-01-13 17:09:30 +00:00
$text .= "
</ tbody >
</ table >
2009-09-12 18:25:41 +00:00
< div class = 'buttons-bar center' >
" . $frm->admin_button ('multi_update_category', LAN_UPDATE, 'update e-hide-if-js'). "
" . $frm->admin_button ('trigger_list_refresh', 'Refresh List', 'refresh'). "
</ div >
2009-01-13 17:09:30 +00:00
" ;
2009-09-12 18:25:41 +00:00
}
else
{
$text .= " <div class='center'> " . NWSLAN_10 . " </div> " ;
}
2009-01-13 17:09:30 +00:00
$text .= "
2009-09-12 18:25:41 +00:00
</ fieldset >
</ form >
2009-01-13 17:09:30 +00:00
" ;
2009-09-12 18:25:41 +00:00
return $text ;
2006-12-02 04:36:16 +00:00
}
2009-09-12 18:25:41 +00:00
function _optrange ( $num , $zero = true )
2009-01-17 22:48:14 +00:00
{
$tmp = range ( 0 , $num < 0 ? 0 : $num );
if ( ! $zero ) unset ( $tmp [ 0 ]);
2008-12-07 13:08:54 +00:00
2009-01-17 22:48:14 +00:00
return $tmp ;
}
2009-04-27 21:23:37 +00:00
2009-01-17 22:48:14 +00:00
function ajax_exec_pref_archnum ()
{
require_once ( e_HANDLER . " form_handler.php " );
$frm = new e_form ();
2009-04-27 21:23:37 +00:00
2009-09-12 18:25:41 +00:00
echo $frm -> selectbox ( 'newsposts_archive' , $this -> _optrange ( intval ( $this -> getSubAction ()) - 1 ), intval ( e107 :: getPref ( 'newsposts_archive' )), 'class=tbox&tabindex=' . intval ( $this -> getId ()));
2009-01-17 22:48:14 +00:00
}
2009-07-03 06:48:43 +00:00
function ajax_exec_searchValue ()
{
require_once ( e_HANDLER . " form_handler.php " );
$frm = new e_form ( true );
2009-09-10 19:15:43 +00:00
echo $frm -> filterValue ( $_POST [ 'filtertype' ], $this -> _fields );
2009-07-03 06:48:43 +00:00
}
2009-07-18 10:17:56 +00:00
2009-04-27 21:23:37 +00:00
2009-01-13 17:09:30 +00:00
function show_news_prefs ()
2008-12-07 13:08:54 +00:00
{
2009-01-18 19:02:07 +00:00
global $pref ;
2009-04-27 21:23:37 +00:00
2009-01-17 22:48:14 +00:00
require_once ( e_HANDLER . " form_handler.php " );
$frm = new e_form ( true ); //enable inner tabindex counter
2009-01-13 17:09:30 +00:00
2009-09-13 16:37:18 +00:00
$e107 = e107 :: getInstance ();
2009-04-27 21:23:37 +00:00
2009-01-13 17:09:30 +00:00
$text = "
2009-01-15 15:42:24 +00:00
< form method = 'post' action = '".e_SELF."?pref' id = 'core-newspost-settings-form' >
2009-01-13 17:09:30 +00:00
< fieldset id = 'core-newspost-settings' >
< legend class = 'e-hideme' > " .NWSLAN_90. " </ legend >
< table cellpadding = '0' cellspacing = '0' class = 'adminform' >
< colgroup span = '2' >
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
< tbody >
2009-09-13 16:37:18 +00:00
< tr >
< td class = 'label' > " .NWSLAN_127. " </ td >
< td class = 'control' >
" . $frm->text ('news_sefbase', $pref['news_sefbase'] ). "
< div class = 'field-help' > " .sprintf(NWSLAN_128, e_ADMIN_ABS.'eurl.php').'<strong>'.SITEURL.( $pref['news_sefbase'] ? $pref['news_sefbase'] .'/' : ''). " </ strong ></ div >
</ td >
</ tr >
2009-01-13 17:09:30 +00:00
< tr >
< td class = 'label' > " .NWSLAN_86. " </ td >
< td class = 'control' >
2009-01-17 22:48:14 +00:00
" . $frm->checkbox_switch ('news_cats', 1, $pref['news_cats'] ). "
2009-01-13 17:09:30 +00:00
</ td >
</ tr >
< tr >
< td class = 'label' > " .NWSLAN_87. " </ td >
< td class = 'control' >
2009-01-17 22:48:14 +00:00
" . $frm->selectbox ('nbr_cols', $this->_optrange (6, false), $pref['nbr_cols'] , 'class=tbox'). "
2009-01-13 17:09:30 +00:00
</ td >
</ tr >
< tr >
< td class = 'label' > " .NWSLAN_88. " </ td >
< td class = 'control' >
2009-01-17 22:48:14 +00:00
" . $frm->selectbox ('newsposts', $this->_optrange (50, false), $pref['newsposts'] , 'class=tbox'). "
2009-01-13 17:09:30 +00:00
</ td >
</ tr >
" ;
2006-12-02 04:36:16 +00:00
2008-05-31 17:55:31 +00:00
2006-12-02 04:36:16 +00:00
// ##### ADDED FOR NEWS ARCHIVE --------------------------------------------------------------------
// the possible archive values are from "0" to "< $pref['newsposts']"
// this should really be made as an onchange event on the selectbox for $pref['newsposts'] ...
2009-01-17 22:48:14 +00:00
//SecretR - Done
2006-12-02 04:36:16 +00:00
$text .= "
2009-01-13 17:09:30 +00:00
< tr >
< td class = 'label' > " .NWSLAN_115. " </ td >
< td class = 'control' >
2009-01-17 22:48:14 +00:00
< div id = 'newsposts-archive-cont' > " . $frm->selectbox ('newsposts_archive', $this->_optrange (intval( $pref['newsposts'] ) - 1), intval( $pref['newsposts_archive'] ), 'class=tbox'). " </ div >
2009-01-13 17:09:30 +00:00
< div class = 'field-help' > " .NWSLAN_116. " </ div >
</ td >
</ tr >
< tr >
< td class = 'label' > " .NWSLAN_117. " </ td >
< td class = 'control' >
" . $frm->text ('newsposts_archive_title', $pref['newsposts_archive_title'] ). "
</ td >
</ tr >
2006-12-02 04:36:16 +00:00
" ;
// ##### END --------------------------------------------------------------------------------------
2008-05-18 16:34:28 +00:00
$text .= "
2009-01-13 17:09:30 +00:00
< tr >
< td class = 'label' > " .LAN_NEWS_51. " </ td >
< td class = 'control' >
2009-01-20 22:37:49 +00:00
" . $frm->uc_select ('news_editauthor', $pref['news_editauthor'] , 'nobody,main,admin,classes'). "
2009-01-13 17:09:30 +00:00
</ td >
</ tr >
< tr >
< td class = 'label' > " .NWSLAN_106. " </ td >
< td class = 'control' >
2009-01-20 22:37:49 +00:00
" . $frm->uc_select ('subnews_class', $pref['subnews_class'] , 'nobody,public,guest,member,admin,classes'). "
2009-01-13 17:09:30 +00:00
</ td >
</ tr >
< tr >
< td class = 'label' > " .NWSLAN_107. " </ td >
< td class = 'control' >
2009-01-17 22:48:14 +00:00
" . $frm->checkbox_switch ('subnews_htmlarea', '1', $pref['subnews_htmlarea'] ). "
2009-01-13 17:09:30 +00:00
</ td >
</ tr >
< tr >
< td class = 'label' > " .NWSLAN_100. " </ td >
< td class = 'control' >
2009-01-17 22:48:14 +00:00
" . $frm->checkbox_switch ('subnews_attach', '1', $pref['subnews_attach'] ). "
2009-01-13 17:09:30 +00:00
</ td >
</ tr >
< tr >
< td class = 'label' > " .NWSLAN_101. " </ td >
< td class = 'control' >
2009-01-17 22:48:14 +00:00
" . $frm->text ('subnews_resize', $pref['subnews_resize'] , 5, 'size=6&class=tbox'). "
< div class = 'field-help' > " .NWSLAN_102. " </ div >
2009-01-13 17:09:30 +00:00
</ td >
</ tr >
< tr >
< td class = 'label' > " .NWSLAN_111. " </ td >
< td class = 'control' >
2009-01-17 22:48:14 +00:00
< div class = 'auto-toggle-area autocheck' >
" . $frm->checkbox_switch ('news_newdateheader', '1', $pref['news_newdateheader'] ). "
< div class = 'field-help' > " .NWSLAN_112. " </ div >
</ div >
2009-01-13 17:09:30 +00:00
</ td >
</ tr >
< tr >
< td class = 'label' > " .NWSLAN_113. " </ td >
< td class = 'control' >
2009-01-17 22:48:14 +00:00
< div class = 'auto-toggle-area autocheck' >
" . $frm->checkbox_switch ('news_unstemplate', '1', $pref['news_unstemplate'] ). "
< div class = 'field-help' > " .NWSLAN_114. " </ div >
</ div >
2009-01-13 17:09:30 +00:00
</ td >
</ tr >
< tr >
< td class = 'label' > " .NWSLAN_120. " </ td >
< td class = 'control' >
2009-01-17 22:48:14 +00:00
" . $frm->bbarea ('news_subheader', stripcslashes( $pref['news_subheader'] ), 2, 'helpb'). "
2009-01-13 17:09:30 +00:00
</ td >
</ tr >
</ tbody >
</ table >
< div class = 'buttons-bar center' >
" . $frm->admin_button ('save_prefs', NWSLAN_89, 'update'). "
</ div >
</ fieldset >
</ form >
" ;
2009-01-20 21:29:23 +00:00
$emessage = & eMessage :: getInstance ();
$e107 -> ns -> tablerender ( NWSLAN_90 , $emessage -> render () . $text );
2006-12-02 04:36:16 +00:00
}
2009-05-08 21:50:19 +00:00
2009-01-15 15:42:24 +00:00
function show_submitted_news ()
2008-05-31 17:55:31 +00:00
{
2009-01-18 19:02:07 +00:00
2009-01-18 00:27:10 +00:00
$e107 = & e107 :: getInstance ();
2009-01-18 20:31:14 +00:00
2009-01-18 00:27:10 +00:00
require_once ( e_HANDLER . " form_handler.php " );
$frm = new e_form ( true ); //enable inner tabindex counter
2009-01-15 15:42:24 +00:00
2009-01-18 19:02:07 +00:00
if ( $e107 -> sql -> db_Select ( " submitnews " , " * " , " submitnews_id !='' ORDER BY submitnews_id DESC " ))
2008-05-31 17:55:31 +00:00
{
2009-01-13 17:09:30 +00:00
$text .= "
< form action = '".e_SELF."?sn' method = 'post' >
< fieldset id = 'core-newspost-sn-list' >
< legend class = 'e-hideme' > " .NWSLAN_47. " </ legend >
< table cellpadding = '0' cellspacing = '0' class = 'adminlist' >
< colgroup span = '6' >
< col style = 'width: 5%' ></ col >
< col style = 'width: 75%' ></ col >
< col style = 'width: 20%' ></ col >
</ colgroup >
< thead >
< tr >
< th class = 'center' > ID </ th >
< th > " .NWSLAN_57. " </ th >
< th class = 'center last' > " .LAN_OPTIONS. " </ th >
</ tr >
</ thead >
< tbody >
" ;
2009-01-18 19:02:07 +00:00
while ( $row = $e107 -> sql -> db_Fetch ())
2009-01-13 17:09:30 +00:00
{
2009-01-18 19:02:07 +00:00
$buttext = ( $row [ 'submitnews_auth' ] == 0 ) ? NWSLAN_58 : NWSLAN_103 ;
2009-01-13 17:09:30 +00:00
2009-01-18 19:02:07 +00:00
if ( substr ( $row [ 'submitnews_item' ], - 7 , 7 ) == '[/html]' ) $row [ 'submitnews_item' ] = substr ( $row [ 'submitnews_item' ], 0 , - 7 );
if ( substr ( $row [ 'submitnews_item' ], 0 , 6 ) == '[html]' ) $row [ 'submitnews_item' ] = substr ( $row [ 'submitnews_item' ], 6 );
2009-01-13 17:09:30 +00:00
$text .= "
< tr >
2009-01-18 19:02:07 +00:00
< td class = 'center' > { $row [ 'submitnews_id' ]} </ td >
2009-01-13 17:09:30 +00:00
< td >
2009-01-18 19:02:07 +00:00
< strong > " . $e107->tp ->toHTML( $row['submitnews_title'] , FALSE, " TITLE " ). " </ strong >< br /> " . $e107->tp ->toHTML( $row['submitnews_item'] ). "
2009-01-13 17:09:30 +00:00
</ td >
< td >
2009-01-18 19:02:07 +00:00
< div class = 'field-spacer' >< strong > " .NWSLAN_123. " :</ strong > " .(( $row['submitnews_auth'] == 0) ? LAN_NO : LAN_YES). " </ div >
< div class = 'field-spacer' >< strong > " .LAN_DATE. " :</ strong > " .date( " D dS M y , g : ia " , $row['submitnews_datestamp'] ). " </ div >
< div class = 'field-spacer' >< strong > " .NWSLAN_124. " :</ strong > { $row [ 'submitnews_name' ]} </ div >
< div class = 'field-spacer' >< strong > " .NWSLAN_125. " :</ strong > { $row [ 'submitnews_email' ]} </ div >
< div class = 'field-spacer' >< strong > " .NWSLAN_126. " :</ strong > " . $e107->ipDecode ( $row['submitnews_ip'] ). " </ div >
2009-01-13 17:09:30 +00:00
< br />
< div class = 'field-spacer center' >
2009-01-18 19:02:07 +00:00
" . $frm->admin_button ( " category_edit_ { $row [ 'submitnews_id' ]} " , $buttext , 'action', '', array('id'=>false, 'other'=> " onclick = \ " document.location=' " . e_SELF . " ?create.sn. { $row [ 'submitnews_id' ] } ' \" " )) . "
" . $frm->admin_button ( " delete [ sn_ { $row [ 'submitnews_id' ]}] " , LAN_DELETE, 'delete', '', array('id'=>false, 'title'=> $e107->tp ->toJS(NWSLAN_38. " [ " .LAN_NEWS_45. " : { $row [ 'submitnews_id' ]} ] " ))). "
2009-01-13 17:09:30 +00:00
</ div >
</ td >
</ tr >
" ;
2006-12-02 04:36:16 +00:00
}
2009-01-13 17:09:30 +00:00
$text .= "
</ tbody >
</ table >
</ fieldset >
</ form >
" ;
2008-05-31 17:55:31 +00:00
}
2008-12-02 16:50:16 +00:00
else
2008-05-31 17:55:31 +00:00
{
2009-01-18 19:02:07 +00:00
$text .= " <div class='center'> " . NWSLAN_59 . " </div> " ;
2006-12-02 04:36:16 +00:00
}
2009-01-20 21:29:23 +00:00
$emessage = & eMessage :: getInstance ();
$e107 -> ns -> tablerender ( NWSLAN_47 , $emessage -> render () . $text );
2006-12-02 04:36:16 +00:00
}
2009-04-27 21:23:37 +00:00
2009-01-17 22:48:14 +00:00
2009-05-08 21:50:19 +00:00
2009-07-18 10:17:56 +00:00
function showMaintenance ()
2009-05-08 21:50:19 +00:00
{
require_once ( e_HANDLER . " form_handler.php " );
$frm = new e_form ( true ); //enable inner tabindex counter
$e107 = & e107 :: getInstance ();
$text = "
< form method = 'post' action = '".e_SELF."?maint' id = 'core-newspost-maintenance-form' >
2009-05-10 17:31:51 +00:00
< fieldset id = 'core-newspost-maintenance' >
< legend class = 'e-hideme' > " .LAN_NEWS_59. " </ legend >
< table class = 'adminform' cellpadding = '0' cellspacing = '0' >
< colgroup span = '2' >
2009-05-10 17:52:13 +00:00
< col class = 'col-label' ></ col >
< col class = 'col-control' ></ col >
2009-07-18 10:17:56 +00:00
</ colgroup >
2009-05-10 17:31:51 +00:00
< tbody >
< tr >
< td class = 'label' > " .LAN_NEWS_56. " </ td >
< td class = 'control' >
" . $frm->admin_button ('news_comments_recalc', LAN_NEWS_57, 'update'). "
</ td >
</ tr >
</ tbody >
</ table >
</ fieldset >
</ form >
" ;
2009-05-08 21:50:19 +00:00
$emessage = & eMessage :: getInstance ();
$e107 -> ns -> tablerender ( LAN_NEWS_59 , $emessage -> render () . $text );
}
function _observe_newsCommentsRecalc ()
{
global $sql2 ;
$e107 = & e107 :: getInstance ();
2009-07-18 10:17:56 +00:00
$qry = " SELECT
2009-05-08 21:50:19 +00:00
COUNT ( `comment_id` ) AS c_count ,
`comment_item_id`
FROM `#comments`
WHERE ( `comment_type` = '0' ) OR ( `comment_type` = 'news' )
GROUP BY `comment_item_id` " ;
2009-07-18 10:17:56 +00:00
2009-05-08 21:50:19 +00:00
if ( $e107 -> sql -> db_Select_gen ( $qry ))
{
while ( $row = $e107 -> sql -> db_Fetch ( MYSQL_ASSOC ))
{
$sql2 -> db_Update ( 'news' , 'news_comment_total = ' . $row [ 'c_count' ] . ' WHERE news_id=' . $row [ 'comment_item_id' ]);
}
}
$this -> show_message ( LAN_NEWS_58 , E_MESSAGE_SUCCESS );
}
2009-01-17 22:48:14 +00:00
function show_message ( $message , $type = E_MESSAGE_INFO , $session = false )
{
// ##### Display comfort ---------
2009-09-10 19:15:43 +00:00
eMessage :: getInstance () -> add ( $message , $type , $session );
2009-01-17 22:48:14 +00:00
}
2006-12-02 04:36:16 +00:00
2009-01-13 17:09:30 +00:00
function show_options ()
{
$e107 = & e107 :: getInstance ();
$var [ 'main' ][ 'text' ] = NWSLAN_44 ;
$var [ 'main' ][ 'link' ] = e_SELF ;
2009-08-05 14:35:47 +00:00
$var [ 'main' ][ 'perm' ] = " H " ;
2009-01-13 17:09:30 +00:00
$var [ 'create' ][ 'text' ] = NWSLAN_45 ;
$var [ 'create' ][ 'link' ] = e_SELF . " ?create " ;
2009-08-05 14:35:47 +00:00
$var [ 'create' ][ 'perm' ] = " H " ;
2009-01-13 17:09:30 +00:00
$var [ 'cat' ][ 'text' ] = NWSLAN_46 ;
$var [ 'cat' ][ 'link' ] = e_SELF . " ?cat " ;
$var [ 'cat' ][ 'perm' ] = " 7 " ;
$var [ 'pref' ][ 'text' ] = NWSLAN_90 ;
$var [ 'pref' ][ 'link' ] = e_SELF . " ?pref " ;
$var [ 'pref' ][ 'perm' ] = " N " ;
2009-04-27 21:23:37 +00:00
2009-01-18 19:02:07 +00:00
$c = $e107 -> sql -> db_Count ( 'submitnews' );
if ( $c ) {
$var [ 'sn' ][ 'text' ] = NWSLAN_47 . " ( { $c } ) " ;
2009-01-13 17:09:30 +00:00
$var [ 'sn' ][ 'link' ] = e_SELF . " ?sn " ;
$var [ 'sn' ][ 'perm' ] = " N " ;
}
2009-05-08 21:50:19 +00:00
if ( getperms ( '0' ))
{
$var [ 'maint' ][ 'text' ] = LAN_NEWS_55 ;
$var [ 'maint' ][ 'link' ] = e_SELF . " ?maint " ;
$var [ 'maint' ][ 'perm' ] = " N " ;
}
2009-01-13 17:09:30 +00:00
e_admin_menu ( NWSLAN_48 , $this -> getAction (), $var );
}
2006-12-02 04:36:16 +00:00
}
2009-01-13 17:09:30 +00:00
function newspost_adminmenu ()
2008-12-07 13:08:54 +00:00
{
2006-12-02 04:36:16 +00:00
global $newspost ;
2009-01-13 17:09:30 +00:00
$newspost -> show_options ();
2006-12-02 04:36:16 +00:00
}