2006-12-02 04:36:16 +00:00
< ? php
/*
2008-12-02 16:50:16 +00:00
* e107 website system
*
2011-12-10 00:00:15 +00:00
* Copyright ( C ) e107 Inc ( e107 . org )
2008-12-02 16:50:16 +00:00
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
* News Administration
*
2011-12-10 00:00:15 +00:00
* $URL $
* $Id $
2006-12-02 04:36:16 +00:00
*/
2010-01-11 21:18:13 +00:00
require_once ( '../class2.php' );
if ( ! getperms ( 'H|N' ))
2008-12-07 13:08:54 +00:00
{
2010-01-11 21:18:13 +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
2012-12-17 16:57:24 +02:00
//include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_'.e_PAGE);
e107 :: coreLan ( 'newspost' , true );
2009-01-13 17:09:30 +00:00
2009-01-15 15:42:24 +00:00
// ------------------------------
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.
2013-02-25 17:45:19 -08:00
$newspost = new admin_newspost ( e_QUERY );
2009-10-23 18:14:42 +00:00
e107 :: setRegistry ( '_newspost_admin' , $newspost );
2009-07-03 02:27:03 +00:00
$gen = new convert ();
2009-01-17 22:48:14 +00:00
2011-12-10 00:00:15 +00:00
2009-01-17 22:48:14 +00:00
//Handle Ajax Calls
if ( $newspost -> ajax_observer ()) exit ;
2013-02-25 02:47:23 -08:00
// e107::js('core','core/admin.js','prototype');
2012-05-15 09:55:27 +00:00
//e107::getJs()->requireCoreLib('core/admin.js');
2011-12-10 00:00:15 +00:00
2012-05-17 09:19:44 +00:00
class news_admin extends e_admin_dispatcher
{
protected $modes = array (
'main' => array (
'controller' => 'news_admin_ui' ,
'path' => null ,
'ui' => 'news_form_ui' ,
'uipath' => null
),
'cat' => array (
'controller' => 'news_cat_ui' ,
'path' => null ,
'ui' => 'news_cat_form_ui' ,
'uipath' => null
),
'sub' => array (
'controller' => 'news_sub_ui' ,
'path' => null ,
'ui' => 'news_sub_form_ui' ,
'uipath' => null
)
);
protected $adminMenu = array (
2013-02-22 21:34:06 -08:00
'main/list' => array ( 'caption' => LAN_LIST , 'perm' => 'H' ),
2012-05-17 09:19:44 +00:00
'main/create' => array ( 'caption' => NWSLAN_45 , 'perm' => 'H' ), // Create/Edit News Item
// 'cat/list' => array('caption'=> NWSLAN_46, 'perm' => '7'), // Category List
2013-02-22 21:34:06 -08:00
'cat/list' => array ( 'caption' => LAN_CATEGORIES , 'perm' => 'H' ), // Create Category.
2013-01-21 17:18:35 +02:00
'cat/create' => array ( 'caption' => " Create Category " , 'perm' => 'H' ), // Category List
2012-05-17 09:19:44 +00:00
'main/settings' => array ( 'caption' => LAN_PREFS , 'perm' => '0' ), // Preferences
2012-11-27 14:38:38 -08:00
// 'main/submitted' => array('caption'=> "Old Submitted ", 'perm' => 'N'), // Submitted News
2012-05-17 09:19:44 +00:00
'sub/list' => array ( 'caption' => NWSLAN_47 , 'perm' => 'N' ), // Submitted News
// 'main/maint' => array('caption'=> LAN_NEWS_55, 'perm' => '0') // Maintenance
);
protected $adminMenuAliases = array (
'main/edit' => 'main/list' ,
'cat/edit' => 'cat/list'
);
protected $menuTitle = " News " ;
}
class news_cat_ui extends e_admin_ui
{
2013-02-22 21:34:06 -08:00
protected $pluginTitle = ADLAN_0 ; // "News"
2012-05-17 09:19:44 +00:00
protected $pluginName = 'core' ;
protected $table = " news_category " ;
protected $pid = " category_id " ;
protected $perPage = 0 ; //no limit
protected $batchDelete = false ;
2013-02-19 18:36:58 +02:00
protected $sortField = 'category_order' ;
protected $listOrder = " category_order ASC " ;
2012-05-17 09:19:44 +00:00
protected $fields = array (
'checkboxes' => array ( 'title' => '' , 'type' => null , 'width' => '5%' , 'forced' => TRUE , 'thclass' => 'center' , 'class' => 'center' ),
'category_id' => array ( 'title' => LAN_ID , 'type' => 'number' , 'width' => '5%' , 'forced' => TRUE , 'readonly' => TRUE ),
'category_icon' => array ( 'title' => LAN_ICON , 'type' => 'icon' , 'data' => 'str' , 'width' => '100px' , 'thclass' => 'center' , 'class' => 'center' , 'readParms' => 'thumb=60&thumb_urlraw=0&thumb_aw=60' , 'readonly' => FALSE , 'batch' => FALSE , 'filter' => FALSE ),
2013-02-19 18:36:58 +02:00
'category_name' => array ( 'title' => LAN_TITLE , 'type' => 'text' , 'width' => 'auto' , 'thclass' => 'left' , 'readonly' => FALSE , 'validate' => true , 'inline' => true ),
2012-05-17 09:19:44 +00:00
'category_meta_description' => array ( 'title' => LAN_DESCRIPTION , 'type' => 'textarea' , 'width' => 'auto' , 'thclass' => 'left' , 'readParms' => 'expand=...&truncate=150&bb=1' , 'readonly' => FALSE ),
'category_meta_keywords' => array ( 'title' => " Meta Keywords " , 'type' => 'text' , 'width' => 'auto' , 'thclass' => 'left' , 'readonly' => FALSE ),
'category_sef' => array ( 'title' => " SEF Url String " , 'type' => 'text' , 'width' => 'auto' , 'readonly' => FALSE ), // Display name
'category_manager' => array ( 'title' => " Manage Permissions " , 'type' => 'userclass' , 'width' => 'auto' , 'data' => 'int' , 'batch' => TRUE , 'filter' => TRUE ),
'category_order' => array ( 'title' => LAN_ORDER , 'type' => 'text' , 'width' => 'auto' , 'thclass' => 'right' , 'class' => 'right' ),
2013-02-19 18:36:58 +02:00
'options' => array ( 'title' => LAN_OPTIONS , 'type' => null , 'width' => '10%' , 'forced' => TRUE , 'thclass' => 'center last' , 'class' => 'center' , 'sort' => true )
2012-05-17 09:19:44 +00:00
);
protected $fieldpref = array ( 'checkboxes' , 'category_icon' , 'category_id' , 'category_name' , 'category_description' , 'category_manager' , 'category_order' , 'options' );
protected $newspost ;
function init ()
{
$this -> newspost = new admin_newspost ;
}
// function createPage()
// {
// $this->newspost->show_categories();
// }
public function beforeCreate ( $new_data )
{
2013-02-19 18:36:58 +02:00
if ( empty ( $new_data [ 'category_sef' ]))
{
$new_data [ 'category_sef' ] = eHelper :: title2sef ( $new_data [ 'category_name' ]);
}
else
{
$new_data [ 'category_sef' ] = eHelper :: secureSef ( $new_data [ 'category_sef' ]);
}
$sef = e107 :: getParser () -> toDB ( $new_data [ 'category_sef' ]);
if ( e107 :: getDb () -> count ( 'news_category' , '(*)' , " category_sef=' { $sef } ' " ))
{
e107 :: getMessage () -> addError ( 'Please choose unique SEF URL string for this category' );
return false ;
}
if ( empty ( $new_data [ 'category_order' ]))
{
$c = e107 :: getDb () -> count ( 'news_category' );
$new_data [ 'category_order' ] = $c ? $c : 0 ;
}
return $new_data ;
2012-05-17 09:19:44 +00:00
}
public function beforeUpdate ( $new_data , $old_data , $id )
{
2013-02-19 18:36:58 +02:00
if ( empty ( $new_data [ 'category_sef' ]))
{
$new_data [ 'category_sef' ] = eHelper :: title2sef ( $new_data [ 'category_name' ]);
}
$sef = e107 :: getParser () -> toDB ( $new_data [ 'category_sef' ]);
if ( e107 :: getDb () -> count ( 'news_category' , '(*)' , " category_sef=' { $sef } ' AND category_id!= " . intval ( $id )))
{
e107 :: getMessage () -> addError ( 'Please choose unique SEF URL string for this category' );
return false ;
}
return $new_data ;
2012-05-17 09:19:44 +00:00
}
}
class news_cat_form_ui extends e_admin_form_ui
{
}
// Submitted News Area.
class news_sub_ui extends e_admin_ui
{
2013-02-22 21:34:06 -08:00
protected $pluginTitle = ADLAN_0 ; // "News"
2012-05-17 09:19:44 +00:00
protected $pluginName = 'core' ;
protected $table = " submitnews " ;
protected $pid = " submitnews_id " ;
2012-12-03 13:57:02 -08:00
protected $perPage = 10 ; //no limit
2012-05-17 09:19:44 +00:00
protected $batchDelete = true ;
protected $formQuery = " mode=main&action=create " ;
protected $listOrder = " submitnews_id desc " ;
// submitnews_id submitnews_name submitnews_email submitnews_title submitnews_category submitnews_item submitnews_datestamp submitnews_ip submitnews_auth submitnews_file
protected $fields = array (
'checkboxes' => array ( 'title' => '' , 'type' => null , 'width' => '5%' , 'forced' => TRUE , 'thclass' => 'center' , 'class' => 'center' ),
'submitnews_id' => array ( 'title' => LAN_ID , 'type' => 'number' , 'width' => '5%' , 'forced' => TRUE , 'readonly' => TRUE ),
2013-02-25 12:07:56 -08:00
'submitnews_title' => array ( 'title' => LAN_TITLE , 'type' => 'method' , 'width' => '35%' , 'thclass' => 'left' , 'readonly' => TRUE ),
'submitnews_datestamp' => array ( 'title' => LAN_NEWS_32 , 'type' => 'datestamp' , 'width' => 'auto' , 'thclass' => '' , 'class' => null , 'nosort' => false , 'parms' => 'mask=%A %d %B %Y' ),
2012-05-17 09:19:44 +00:00
'submitnews_category' => array ( 'title' => LAN_CATEGORY , 'type' => 'dropdown' , 'width' => 'auto' , 'thclass' => 'left' , 'readonly' => FALSE ),
// 'submitnews_item' => array('title'=> LAN_DESCRIPTION, 'type' => 'method', 'width' => 'auto', 'thclass' => 'left','readParms' => 'expand=...&truncate=150&bb=1', 'readonly'=>TRUE),
'submitnews_name' => array ( 'title' => LAN_AUTHOR , 'type' => 'text' , 'width' => 'auto' , 'thclass' => 'left' , 'readonly' => TRUE ),
'submitnews_ip' => array ( 'title' => " IP " , 'type' => 'text' , 'width' => 'auto' , 'thclass' => 'left' , 'readonly' => TRUE ),
'submitnews_auth' => array ( 'title' => " User " , 'type' => 'user' , 'width' => 'auto' , 'thclass' => 'right' , 'class' => 'right' ),
'options' => array ( 'title' => LAN_OPTIONS , 'type' => " method " , 'width' => '10%' , 'forced' => TRUE , 'thclass' => 'center last' , 'class' => 'center' )
);
protected $fieldpref = array ( 'checkboxes' , 'submitnews_id' , 'submitnews_title' , 'submitnews_category' , 'options' );
protected $newspost ;
protected $cats ;
function init ()
{
$sql = e107 :: getDb ();
$sql -> db_Select_gen ( " SELECT category_id,category_name FROM #news_category " );
while ( $row = $sql -> db_Fetch ())
{
$cat = $row [ 'category_id' ];
$this -> cats [ $cat ] = $row [ 'category_name' ];
}
asort ( $this -> cats );
$this -> fields [ 'submitnews_category' ][ 'writeParms' ] = $this -> cats ;
$this -> newspost = new admin_newspost ;
}
// function createPage()
// {
// $this->newspost->show_categories();
// }
public function beforeCreate ( $new_data )
{
}
public function beforeUpdate ( $new_data , $old_data , $id )
{
}
}
class news_sub_form_ui extends e_admin_form_ui
{
function submitnews_title ( $cur , $val )
{
$tp = e107 :: getParser ();
$row = $this -> getController () -> getListModel ();
$submitnews_id = $row -> get ( 'submitnews_id' );
$submitnews_title = $row -> get ( 'submitnews_title' );
$submitnews_file = $row -> get ( 'submitnews_file' );
$submitnews_item = $row -> get ( 'submitnews_item' );
2013-02-25 11:29:38 -08:00
// $text .= "<a href='#submitted_".$submitnews_id."' class='e-modal' >";
2012-05-17 09:19:44 +00:00
2013-02-25 11:29:38 -08:00
$text .= " <a data-toggle='modal' href='#submitted_ " . $submitnews_id . " ' data-cache='false' data-target='#submitted_ " . $submitnews_id . " ' class='e-tip' title=' " . LAN_PREVIEW . " '> " ;
$text .= $tp -> toHTML ( $submitnews_title , FALSE , 'emotes_off, no_make_clickable' );
2012-05-17 09:19:44 +00:00
$text .= '</a>' ;
2013-02-25 11:29:38 -08:00
$text .= '
< div id = " submitted_'. $submitnews_id .' " class = " modal hide fade " tabindex = " -1 " role = " dialog " aria - hidden = " true " >
< div class = " modal-header " >
< button type = " button " class = " close " data - dismiss = " modal " aria - hidden = " true " >& times ; </ button >
< h4 > '.$tp->toHtml($submitnews_title,false,' TITLE ').' </ h4 >
</ div >
< div class = " modal-body " >
< p > ' ;
$text .= $tp -> toHTML ( $submitnews_item , TRUE );
2012-05-17 09:19:44 +00:00
if ( $submitnews_file )
{
$tmp = explode ( ',' , $submitnews_file );
2013-02-25 11:29:38 -08:00
2012-05-17 09:19:44 +00:00
$text .= " <br /> " ;
2013-02-25 11:29:38 -08:00
2012-05-17 09:19:44 +00:00
foreach ( $tmp as $imgfile )
2013-02-25 11:29:38 -08:00
{
$url = $tp -> thumbUrl ( e_UPLOAD . $imgfile , array ( 'aw' => 400 ), true );
$text .= " <br /><img src=' " . $url . " ' alt=' " . $imgfile . " ' /> " ;
2012-05-17 09:19:44 +00:00
}
}
2013-02-25 11:29:38 -08:00
$text .= ' </ p >
</ div >
< div class = " modal-footer " >
< a href = " # " data - dismiss = " modal " class = " btn btn-primary " > Close </ a >
</ div >
</ div > ' ;
return $text ;
2012-05-17 09:19:44 +00:00
}
// Override the default Options field.
function options ( $parms , $value , $id , $attributes )
{
2013-02-25 11:29:38 -08:00
2012-05-17 09:19:44 +00:00
if ( $attributes [ 'mode' ] == 'read' )
{
2013-02-25 11:29:38 -08:00
$text = " <div class='btn-group'> " ;
2012-05-17 09:19:44 +00:00
$approved = $this -> getController () -> getListModel () -> get ( 'submitnews_auth' ); // approved;
if ( $approved == 0 )
{
2013-02-25 11:29:38 -08:00
//$text = $this->submit_image('submitnews['.$id.']', 1, 'execute', NWSLAN_58);
$text = " <a href=' " . e_SELF . " ?mode=main&action=create&sub= { $id } '> " . ADMIN_EXECUTE_ICON . " </a> " ;
2012-05-17 09:19:44 +00:00
// NWSLAN_103;
}
else // Already submitted;
{
}
$text .= $this -> submit_image ( 'etrigger_delete[' . $id . ']' , $id , 'delete' , LAN_DELETE . ' [ ID: ' . $id . ' ]' , array ( 'class' => 'action delete' . $delcls ));
2013-02-25 11:29:38 -08:00
$text .= " </div> " ;
2012-05-17 09:19:44 +00:00
return $text ;
}
}
}
// Main News Area.
class news_admin_ui extends e_admin_ui
{
2012-05-22 04:38:28 +00:00
protected $pluginTitle = ADLAN_0 ; // "News"
protected $pluginName = 'core' ;
protected $table = " news " ;
protected $pid = " news_id " ;
2012-12-03 13:57:02 -08:00
protected $perPage = 10 ; //no limit
2012-05-22 04:38:28 +00:00
protected $batchDelete = true ;
protected $batchCopy = true ;
protected $listOrder = " news_id desc " ;
2012-05-17 09:19:44 +00:00
2012-05-22 04:38:28 +00:00
protected $listQry = " SELECT n.*,u.user_id,u.user_name FROM #news AS n LEFT JOIN #user AS u ON n.news_author = u.user_id " ; // without any Order or Limit.
2012-05-17 09:19:44 +00:00
2012-05-22 04:38:28 +00:00
protected $fields = array (
2012-05-17 09:19:44 +00:00
'checkboxes' => array ( 'title' => '' , 'type' => null , 'width' => '3%' , 'thclass' => 'center first' , 'class' => 'center' , 'nosort' => true , 'toggle' => 'news_selected' , 'forced' => TRUE ),
'news_id' => array ( 'title' => LAN_NEWS_45 , 'type' => 'number' , 'width' => '5%' , 'thclass' => 'center' , 'class' => 'center' , 'nosort' => false ),
2012-07-15 03:01:30 +00:00
'news_thumbnail' => array ( 'title' => NWSLAN_67 , 'type' => 'method' , 'width' => '110px' , 'thclass' => 'center' , 'class' => " center " , 'nosort' => false , 'readParms' => 'thumb=60&thumb_urlraw=0&thumb_aw=60' , 'readonly' => false ),
2013-02-25 13:12:40 +01:00
'news_title' => array ( 'title' => LAN_TITLE , 'type' => 'method' , 'width' => 'auto' , 'thclass' => '' , 'class' => null , 'nosort' => false , 'readParms' => 'link={e_BASE}news.php?extend.[id]&dialog=1' ),
2012-05-17 09:19:44 +00:00
'news_summary' => array ( 'title' => LAN_NEWS_27 , 'type' => 'text' , 'width' => 'auto' , 'thclass' => '' , 'class' => null , 'nosort' => false ),
'news_meta_keywords' => array ( 'title' => LAN_KEYWORDS , 'type' => 'text' , 'width' => 'auto' , 'thclass' => '' , 'class' => null , 'nosort' => false ),
'news_meta_description' => array ( 'title' => LAN_DESCRIPTION , 'type' => 'text' , 'width' => 'auto' , 'thclass' => '' , 'class' => null , 'nosort' => false ),
2013-02-22 21:34:06 -08:00
'news_sef' => array ( 'title' => LAN_SEFURL , 'type' => 'text' , 'width' => 'auto' , 'thclass' => '' , 'class' => null , 'nosort' => false ),
'user_name' => array ( 'title' => LAN_AUTHOR , 'type' => 'text' , 'width' => 'auto' , 'thclass' => '' , 'class' => null , 'nosort' => false ),
2012-12-01 00:03:48 -08:00
'news_datestamp' => array ( 'title' => LAN_NEWS_32 , 'type' => 'datestamp' , 'data' => 'int' , 'width' => 'auto' , 'thclass' => '' , 'class' => null , 'nosort' => false , 'parms' => 'mask=%A %d %B %Y' , 'filter' => true ),
2013-02-22 02:17:19 -08:00
'news_category' => array ( 'title' => NWSLAN_6 , 'type' => 'dropdown' , 'data' => 'int' , 'inline' => true , 'width' => 'auto' , 'thclass' => '' , 'class' => null , 'nosort' => false , 'batch' => true , 'filter' => true ),
2012-05-17 09:19:44 +00:00
'news_start' => array ( 'title' => " Start " , 'type' => 'datestamp' , 'width' => 'auto' , 'thclass' => '' , 'class' => null , 'nosort' => false , 'parms' => 'mask=%A %d %B %Y' ),
'news_end' => array ( 'title' => " End " , 'type' => 'datestamp' , 'width' => 'auto' , 'thclass' => '' , 'class' => null , 'nosort' => false , 'parms' => 'mask=%A %d %B %Y' ),
2013-02-22 21:34:06 -08:00
'news_class' => array ( 'title' => LAN_VISIBILITY , 'type' => 'userclasses' , 'data' => 'int' , 'inline' => true , 'width' => 'auto' , 'thclass' => '' , 'class' => null , 'nosort' => false , 'batch' => true , 'filter' => true ),
2012-12-17 16:57:24 +02:00
'news_render_type' => array ( 'title' => LAN_TEMPLATE , 'type' => 'comma' , 'width' => 'auto' , 'thclass' => 'center' , 'class' => null , 'nosort' => false , 'batch' => true , 'filter' => true ),
2012-12-01 00:03:48 -08:00
'news_sticky' => array ( 'title' => LAN_NEWS_28 , 'type' => 'boolean' , 'data' => 'int' , 'width' => 'auto' , 'thclass' => 'center' , 'class' => 'center' , 'nosort' => false , 'batch' => true , 'filter' => true ),
'news_allow_comments' => array ( 'title' => NWSLAN_15 , 'type' => 'boolean' , 'data' => 'int' , 'width' => 'auto' , 'thclass' => 'center' , 'class' => 'center' , 'nosort' => false , 'batch' => true , 'filter' => true , 'readParms' => 'reverse=1' , 'writeParms' => 'reverse=1' ),
2012-05-17 09:19:44 +00:00
'news_comment_total' => array ( 'title' => LAN_NEWS_60 , 'type' => 'number' , 'width' => '10%' , 'thclass' => '' , 'class' => null , 'nosort' => false ),
'options' => array ( 'title' => LAN_OPTIONS , 'type' => null , 'width' => '10%' , 'thclass' => 'center last' , 'class' => 'center' , 'nosort' => true , 'forced' => TRUE )
2012-05-22 04:38:28 +00:00
);
protected $fieldpref = array ( 'checkboxes' , 'news_id' , 'news_thumbnail' , 'news_title' , 'news_datestamp' , 'news_category' , 'options' );
2012-05-17 09:19:44 +00:00
protected $cats = array ();
protected $newspost ;
2012-11-01 02:21:58 +00:00
protected $news_renderTypes = array (
'0' => " Default " ,
'1' => " Default - Title " ,
'4' => " Default - Title/Summary " ,
'2' => " Sidebar - Othernews " ,
'3' => " Sidebar - Othernews 2 " ,
'5' => " Featurebox "
);
2012-05-17 09:19:44 +00:00
function init ()
{
2013-01-12 16:27:54 -08:00
//TODO Handle Ping Services // see e107_plugins/gsitemap/e_module.php =
// needs to be integrated into core and removed from gsitemap.
// Loop through $pref['news_ping_services'] and ping.
if ( vartrue ( $_POST [ 'news_ping' ], false ))
{
$mes = e107 :: getMessage ();
$mes -> addDebug ( " Ping not yet implemented " , 'default' , true );
}
2012-05-17 09:19:44 +00:00
$sql = e107 :: getDb ();
$sql -> db_Select_gen ( " SELECT category_id,category_name FROM #news_category " );
while ( $row = $sql -> db_Fetch ())
{
$cat = $row [ 'category_id' ];
$this -> cats [ $cat ] = $row [ 'category_name' ];
}
asort ( $this -> cats );
$this -> fields [ 'news_category' ][ 'writeParms' ] = $this -> cats ;
2013-01-12 16:27:54 -08:00
2012-11-01 02:21:58 +00:00
$this -> fields [ 'news_render_type' ][ 'writeParms' ] = $this -> news_renderTypes ; // array(NWSLAN_75,NWSLAN_76,NWSLAN_77,NWSLAN_77." 2","Featurebox");
2012-05-17 09:19:44 +00:00
$this -> newspost = new admin_newspost ;
2012-11-01 02:21:58 +00:00
$this -> newspost -> news_renderTypes = $this -> news_renderTypes ;
2012-05-17 09:19:44 +00:00
$this -> newspost -> observer ();
2013-01-12 16:27:54 -08:00
2012-05-17 09:19:44 +00:00
}
function createPage ()
{
// print_a($_POST);
2013-02-25 11:29:38 -08:00
if ( isset ( $_GET [ 'sub' ]))
2012-05-17 09:19:44 +00:00
{
2013-02-25 11:29:38 -08:00
$id = intval ( $_GET [ 'sub' ]);
2012-05-17 09:19:44 +00:00
$this -> loadSubmitted ( $id );
}
else
{
$this -> preCreate ();
}
$this -> newspost -> show_create_item ();
}
function categoryPage ()
{
if ( ! getperms ( '0|7' ))
{
$this -> noPermissions ();
}
$this -> newspost -> show_categories ();
// $newspost->show_create_item();
}
function submittedPage ()
{
$this -> newspost -> show_submitted_news ();
}
function maintPage ()
{
}
function settingsPage ()
{
2013-02-22 02:17:19 -08:00
return $this -> newspost -> show_news_prefs ();
2012-05-17 09:19:44 +00:00
}
function noPermissions ( $qry = '' )
{
$url = e_SELF . ( $qry ? '?' . $qry : '' );
if ( $qry !== e_QUERY )
{
$mes = e107 :: getMessage ();
$this -> show_message ( 'Insufficient permissions!' , E_MESSAGE_ERROR , true );
session_write_close ();
header ( 'Location: ' . $url );
}
exit ;
}
function loadSubmitted ( $id )
{
$sql = e107 :: getDb ();
$tp = e107 :: getParser ();
2013-02-25 11:29:38 -08:00
if ( $sql -> select ( " submitnews " , " * " , " submitnews_id= " . intval ( $id )))
2012-05-17 09:19:44 +00:00
{
2013-02-25 11:29:38 -08:00
2012-05-17 09:19:44 +00:00
//list($id, $submitnews_name, $submitnews_email, $_POST['news_title'], $submitnews_category, $_POST['news_body'], $submitnews_datestamp, $submitnews_ip, $submitnews_auth, $submitnews_file) = $sql->db_Fetch();
2013-02-25 11:29:38 -08:00
$row = $sql -> fetch ();
2012-05-17 09:19:44 +00:00
$_POST [ 'news_title' ] = $row [ 'submitnews_title' ];
$_POST [ 'news_body' ] = $row [ 'submitnews_item' ];
$_POST [ 'cat_id' ] = $row [ 'submitnews_category' ];
2013-02-25 11:29:38 -08:00
// if (defsettrue('e_WYSIWYG'))
// {
// if (substr($_POST['news_body'],-7,7) == '[/html]') $_POST['news_body'] = substr($_POST['news_body'],0,-7);
// if (substr($_POST['news_body'],0,6) == '[html]') $_POST['news_body'] = substr($_POST['news_body'],6);
// $_POST['news_body'] .= "<br /><b>".NWSLAN_49." {$row['submitnews_name']}</b>";
// $_POST['news_body'] .= ($row['submitnews_file'])? "<br /><br /><img src='{e_NEWSIMAGE}{$row['submitnews_file']}' class='f-right' />": '';
// }
// else
2012-05-17 09:19:44 +00:00
{
$_POST [ 'news_body' ] .= " \n [[b] " . NWSLAN_49 . " { $row [ 'submitnews_name' ] } [/b]] " ;
if ( $row [ 'submitnews_file' ])
{
$files = explode ( " , " , $row [ 'submitnews_file' ]);
foreach ( $files as $f )
{
if ( $bbpath = e107 :: getMedia () -> importFile ( $f , 'news' ))
{
$_POST [ 'news_body' ] .= " \n \n [img] " . $bbpath . " [/img] " ;
}
}
}
}
$_POST [ 'data' ] = $tp -> dataFilter ( $_POST [ 'data' ]); // Filter any nasties
$_POST [ 'news_title' ] = $tp -> dataFilter ( $_POST [ 'news_title' ]);
}
}
function preCreate ()
{
if ( $_GET [ 'action' ] == " edit " && ! $_POST [ 'preview' ])
{
if ( ! isset ( $_POST [ 'submit_news' ]))
{
if ( e107 :: getDb () -> db_Select ( 'news' , '*' , 'news_id=' . intval ( $_GET [ 'id' ])))
{
$row = e107 :: getDb () -> db_Fetch ();
// if(!isset($this->news_categories[$row['news_category']]))
{
// $this->noPermissions();
}
$_POST [ 'news_title' ] = $row [ 'news_title' ];
$_POST [ 'news_sef' ] = $row [ 'news_sef' ];
$_POST [ 'news_body' ] = $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_render_type' ] = $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' ];
}
}
}
}
}
class news_form_ui extends e_admin_form_ui
{
2012-07-15 03:01:30 +00:00
function news_thumbnail ( $curval , $mode )
{
if ( ! vartrue ( $curval )) return ;
if ( $curval [ 0 ] != " { " )
{
$curval = " { e_IMAGE}newspost_images/ " . $curval ;
}
$url = e107 :: getParser () -> thumbUrl ( $curval , 'aw=80' );
$link = e107 :: getParser () -> replaceConstants ( $curval );
return " <a class='e-dialog' href=' { $link } '><img src=' { $url } ' alt=' { $curval } ' /></a> " ;
}
2012-12-21 10:26:32 +02:00
function news_title ( $value , $mode )
{
if ( $mode == 'read' )
{
$news_item = $this -> getController () -> getListModel () -> toArray ();
$url = e107 :: getUrl () -> create ( 'news/view/item' , $news_item );
return " <a class='e-tip' href=' { $url } ' title='Open in new tab' rel='external'> " . $value . " </a> " ;
}
return $value ;
}
2012-05-17 09:19:44 +00:00
}
new news_admin ();
require_once ( e_ADMIN . " auth.php " );
e107 :: getAdminUI () -> runPage ();
if ( ! e_AJAX_REQUEST ) require_once ( " footer.php " );
exit ;
2011-12-10 00:00:15 +00:00
2008-12-07 13:08:54 +00:00
function headerjs ()
{
2012-05-28 13:06:09 +00:00
return ;
2009-10-23 18:14:42 +00:00
$newspost = e107 :: getRegistry ( '_newspost_admin' );
/*
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 > " ;
2009-10-23 18:14:42 +00:00
*/
2012-11-01 02:21:58 +00:00
// TODO - REMOVE
2009-07-03 06:48:43 +00:00
$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
}
2010-03-16 17:00:44 +00:00
2009-09-12 18:25:41 +00:00
//custom expand
Element . addMethods ( {
newsDescToggle : function ( element ) {
element = \ $ ( element );
if ( ! element . visible ())
element . fxToggle ();
2010-03-16 17:00:44 +00:00
2009-09-12 18:25:41 +00:00
return element ;
},
2010-03-16 17:00:44 +00:00
2009-09-12 18:25:41 +00:00
newsScrollToMe : function ( element ) {
element = \ $ ( element );
new Effect . ScrollTo ( element );
return element ;
},
2010-03-16 17:00:44 +00:00
2009-09-12 18:25:41 +00:00
newsUpdateButtonSpan : function ( element , str , swapClass ) {
element = \ $ ( element );
if ( swapClass ) {
var swapO = swapClass . split ( '::' );
element . removeClassName ( swapO [ 0 ]) . addClassName ( swapO [ 1 ]);
}
2010-03-16 17:00:44 +00:00
2009-09-12 18:25:41 +00:00
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 >
" ;
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 ;
2010-03-16 17:00:44 +00:00
2009-09-12 18:25:41 +00:00
element . startLoading ();
new e107Ajax . Request ( url . parsePath (), {
onComplete : function ( transport ) {
element . stopLoading ();
if ( transport . responseText )
alert ( transport . responseText ); //error
}
});
}
2010-03-16 17:00:44 +00:00
2009-09-12 18:25:41 +00:00
//e107 onload custom event
e107 . runOnLoad ( function ( event ) {
var celement = event . memo [ 'element' ] ? \ $ ( event . memo . element ) : \ $\ $ ( 'body' )[ 0 ];
2010-03-16 17:00:44 +00:00
2009-09-12 18:25:41 +00:00
//Unobtrusive AJAX category list reload
if ( \ $ ( 'trigger-list-refresh' )) {
\ $ ( 'trigger-list-refresh' ) . observe ( 'click' , function ( event ) {
event . stop ();
\ $ ( 'core-newspost-cat-list-form' ) . submitForm (
2010-03-16 17:00:44 +00:00
'core-newspost-cat-list-cont' ,
{ overlayPage : \ $\ $ ( 'body' )[ 0 ] },
2009-09-12 18:25:41 +00:00
\ $ ( 'core-newspost-cat-list-form' ) . action + '_list_refresh'
);
});
}
2010-03-16 17:00:44 +00:00
2009-09-12 18:25:41 +00:00
//Unobtrusive AJAX save category manage permissions
celement . select ( 'select[name^=multi_category_manager]' ) . invoke ( 'observe' , 'change' , function ( event ) {
e_npadmin_ajaxsave ( 'catmanager' , event . element ());
});
2010-03-16 17:00:44 +00:00
2009-09-12 18:25:41 +00:00
//Category order fields - user convenience
celement . select ( 'input[name^=multi_category_order]' ) . invoke ( 'observe' , 'focus' , function ( event ) {
event . element () . select ();
});
2010-03-16 17:00:44 +00:00
2009-09-12 18:25:41 +00:00
//Unobtrusive AJAX save category order
celement . select ( 'input[name^=multi_category_order]' ) . invoke ( 'observe' , 'blur' , function ( event ) {
e_npadmin_ajaxsave ( 'catorder' , event . element ());
});
2010-03-16 17:00:44 +00:00
2009-09-12 18:25:41 +00:00
//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' ) });
});
});
2010-03-16 17:00:44 +00:00
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 (){
2010-03-16 17:00:44 +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' );
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-10-20 07:39:40 +00:00
var $news_categories ;
2012-11-01 02:21:58 +00:00
public $news_renderTypes = array ();
2010-03-16 17:00:44 +00:00
2009-09-10 19:15:43 +00:00
public $error = false ;
2006-12-02 04:36:16 +00:00
2013-02-25 17:45:19 -08:00
function __construct ( $qry = '' )
2007-10-26 21:51:05 +00:00
{
2009-07-17 07:53:13 +00:00
global $user_pref ;
2011-06-17 01:47:35 +00:00
2012-05-22 13:32:49 +00:00
$qry = " " ;
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 " );
2012-06-01 08:09:14 +00:00
2009-01-13 17:09:30 +00:00
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-10-26 07:26:53 +00:00
$this -> fields = array (
2012-11-01 02:21:58 +00:00
'checkboxes' => array ( 'title' => '' , 'type' => null , 'data' => false , 'width' => '3%' , 'thclass' => 'center first' , 'class' => 'center' , 'nosort' => true , 'toggle' => 'news_selected' , 'forced' => TRUE ),
'news_id' => array ( 'title' => LAN_NEWS_45 , 'type' => 'number' , 'data' => 'int' , 'width' => '5%' , 'thclass' => 'center' , 'class' => 'center' , 'nosort' => false ),
'news_thumbnail' => array ( 'title' => NWSLAN_67 , 'type' => 'image' , 'data' => 'str' , 'width' => '110px' , 'thclass' => 'center' , 'class' => " center " , 'nosort' => false , 'readParms' => 'thumb=60&thumb_urlraw=0&thumb_aw=60' , 'writeParams' => 'path={e_MEDIA}' , 'readonly' => false ),
2013-02-25 13:12:40 +01:00
'news_title' => array ( 'title' => LAN_TITLE , 'type' => 'text' , 'data' => 'str' , 'width' => 'auto' , 'thclass' => '' , 'class' => null , 'nosort' => false ),
2012-11-01 02:21:58 +00:00
'news_summary' => array ( 'title' => LAN_NEWS_27 , 'type' => 'text' , 'data' => 'str' , 'width' => 'auto' , 'thclass' => '' , 'class' => null , 'nosort' => false ),
2012-04-19 03:53:58 +00:00
2012-11-01 02:21:58 +00:00
'news_meta_keywords' => array ( 'title' => LAN_KEYWORDS , 'type' => 'text' , 'data' => 'str' , 'width' => 'auto' , 'thclass' => '' , 'class' => null , 'nosort' => false ),
'news_meta_description' => array ( 'title' => LAN_DESCRIPTION , 'type' => 'text' , 'data' => 'str' , 'width' => 'auto' , 'thclass' => '' , 'class' => null , 'nosort' => false ),
2013-02-22 21:34:06 -08:00
'news_sef' => array ( 'title' => LAN_SEFURL , 'type' => 'text' , 'data' => 'str' , 'width' => 'auto' , 'thclass' => '' , 'class' => null , 'nosort' => false ),
'user_name' => array ( 'title' => LAN_AUTHOR , 'type' => 'text' , 'data' => 'str' , 'width' => 'auto' , 'thclass' => '' , 'class' => null , 'nosort' => false ),
2012-11-01 02:21:58 +00:00
'news_datestamp' => array ( 'title' => LAN_NEWS_32 , 'type' => 'datestamp' , 'data' => 'str' , 'width' => 'auto' , 'thclass' => '' , 'class' => null , 'nosort' => false , 'parms' => 'mask=%A %d %B %Y' ),
'category_name' => array ( 'title' => NWSLAN_6 , 'type' => 'text' , 'data' => 'str' , 'width' => 'auto' , 'thclass' => '' , 'class' => null , 'nosort' => false ),
2012-04-19 03:53:58 +00:00
2012-11-01 02:21:58 +00:00
'news_start' => array ( 'title' => " Start " , 'type' => 'datestamp' , 'data' => 'str' , 'width' => 'auto' , 'thclass' => '' , 'class' => null , 'nosort' => false , 'parms' => 'mask=%A %d %B %Y' ),
'news_end' => array ( 'title' => " End " , 'type' => 'datestamp' , 'data' => 'str' , 'width' => 'auto' , 'thclass' => '' , 'class' => null , 'nosort' => false , 'parms' => 'mask=%A %d %B %Y' ),
2012-04-19 03:53:58 +00:00
2013-02-22 21:34:06 -08:00
'news_class' => array ( 'title' => LAN_VISIBILITY , 'type' => 'userclass' , 'data' => 'str' , 'width' => 'auto' , 'thclass' => '' , 'class' => null , 'nosort' => false ),
2012-11-01 02:21:58 +00:00
'news_render_type' => array ( 'title' => LAN_NEWS_49 , 'type' => 'dropdown' , 'data' => 'comma' , 'width' => 'auto' , 'thclass' => 'center' , 'class' => null , 'nosort' => false ),
'news_sticky' => array ( 'title' => LAN_NEWS_28 , 'type' => 'boolean' , 'data' => 'int' , 'width' => 'auto' , 'thclass' => 'center' , 'class' => 'center' , 'nosort' => false ),
'news_allow_comments' => array ( 'title' => NWSLAN_15 , 'type' => 'boolean' , 'data' => 'int' , 'width' => 'auto' , 'thclass' => 'center' , 'class' => 'center' , 'nosort' => false ),
'news_comment_total' => array ( 'title' => LAN_NEWS_60 , 'type' => 'number' , 'data' => 'int' , 'width' => '10%' , 'thclass' => '' , 'class' => null , 'nosort' => false ),
'options' => array ( 'title' => LAN_OPTIONS , 'type' => null , 'data' => false , 'width' => '10%' , 'thclass' => 'center last' , 'class' => 'center' , 'nosort' => true , 'forced' => TRUE )
2009-07-03 06:48:43 +00:00
);
2010-03-16 17:00:44 +00:00
2012-04-19 03:53:58 +00:00
2009-10-20 07:39:40 +00:00
/* $ren_type = array ( NWSLAN_75 , NWSLAN_76 , NWSLAN_77 , NWSLAN_77 . " 2 " );
$r_array = array ();
foreach ( $ren_type as $key => $value )
{
$this -> news_renderTypes [ $key ] = $value ;
} */
2012-11-01 02:21:58 +00:00
// $this->news_renderTypes = array('0'=>NWSLAN_75,'1'=>NWSLAN_76,'2'=>NWSLAN_77,'3'=>NWSLAN_77." 2",'4'=>"Featurebox");
// $this->news_renderTypes = array('0'=>"FrontPage",'1'=>"FrontPage - Linkonly",'2'=>"Othernews Sidebar",'3'=>"Othernews Sidebar"." 2",'4'=>"Featurebox");
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 );
2012-04-18 21:07:20 +00:00
$action = vartrue ( $_GET [ 'action' ], 'main' );
$sub_action = varset ( $_GET [ 'sub' ], '' );
$id = isset ( $_GET [ 'id' ]) && is_numeric ( $_GET [ 'id' ]) ? intval ( $_GET [ 'id' ]) : 0 ;
$this -> _sort_order = isset ( $_GET [ 'id' ]) && ! is_numeric ( $_GET [ 'id' ]) ? $_GET [ 'id' ] : 'desc' ;
$from = intval ( varset ( $_GET [ 'frm' ], 0 ));
2009-01-13 17:09:30 +00:00
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' ;
2012-05-22 13:32:49 +00:00
$sort_order = 'desc' ;
2009-01-13 17:09:30 +00:00
$this -> _request = array ( $action , $sub_action , $id , $sort_order , $from );
}
function getAction ()
{
return $this -> _request [ 0 ];
}
2010-03-16 17:00:44 +00:00
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 ];
}
2010-03-16 17:00:44 +00:00
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 ];
}
2010-03-16 17:00:44 +00:00
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 ();
2009-09-25 20:20:23 +00:00
$ecache -> clear ( " news.php " ); //TODO change it to 'news_*' everywhere
2010-03-16 17:00:44 +00:00
2009-09-25 20:20:23 +00:00
$ecache -> clear ( " news_ " , false , true ); //NEW global news cache prefix
//$ecache->clear("nq_news_"); - supported by cache::clear() now
//$ecache->clear("nomd5_news_"); supported by cache::clear() now
2010-03-16 17:00:44 +00:00
2009-09-25 20:20:23 +00:00
$ecache -> clear ( " othernews " ); //TODO change it to 'news_othernews' everywhere
$ecache -> clear ( " othernews2 " ); //TODO change it to 'news_othernews2' everywhere
2009-09-12 18:25:41 +00:00
return $this ;
}
2010-03-16 17:00:44 +00:00
2009-09-12 18:25:41 +00:00
function clear_rwcache ( $sefstr = '' )
{
2011-12-10 00:00:15 +00:00
// obsolete
2009-09-12 18:25:41 +00:00
}
2010-03-16 17:00:44 +00:00
2009-09-12 18:25:41 +00:00
function set_rwcache ( $sefstr , $data )
{
2011-12-10 00:00:15 +00:00
// obsolete
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-10-23 18:14:42 +00:00
$this -> news_categories = array ();
if ( e107 :: getDb () -> db_Select ( 'news_category' , '*' , ( getperms ( '0' ) ? '' : 'category_manager IN (' . USERCLASS_LIST . ')' )))
{
$this -> news_categories = e107 :: getDb () -> db_getList ( 'ALL' , FALSE , FALSE , 'category_id' );
}
2010-03-16 17:00:44 +00:00
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-10-23 18:14:42 +00:00
$main = getperms ( '0' );
2009-01-13 17:09:30 +00:00
if ( isset ( $_POST [ 'delete' ]) && is_array ( $_POST [ 'delete' ]))
{
$this -> _observe_delete ();
}
2009-10-20 07:39:40 +00:00
elseif ( isset ( $_POST [ 'execute_batch' ]))
{
$this -> process_batch ( $_POST [ 'news_selected' ]);
}
2009-01-13 17:09:30 +00:00
elseif ( isset ( $_POST [ 'submit_news' ]))
{
$this -> _observe_submit_item ( $this -> getSubAction (), $this -> getId ());
}
2009-10-23 18:14:42 +00:00
elseif ( $main && isset ( $_POST [ 'create_category' ]))
2009-01-13 17:09:30 +00:00
{
$this -> _observe_create_category ();
}
2009-10-23 18:14:42 +00:00
elseif ( $main && isset ( $_POST [ 'update_category' ]))
2009-01-13 17:09:30 +00:00
{
$this -> _observe_update_category ();
}
2009-10-23 18:14:42 +00:00
elseif ( $main && isset ( $_POST [ 'multi_update_category' ]))
2009-09-12 18:25:41 +00:00
{
$this -> _observe_multi_create_category ();
}
2009-10-23 18:14:42 +00:00
elseif ( $main && 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 ();
}
2010-03-16 17:00:44 +00:00
if ( isset ( $_POST [ 'etrigger_ecolumns' ])) //elseif fails.
2009-07-03 02:27:03 +00:00
{
2013-01-15 14:37:36 -08:00
// $this->_observe_saveColumns();
2009-07-03 02:27:03 +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
function show_page ()
{
2011-06-17 01:47:35 +00:00
2011-07-06 23:37:49 +00:00
// print_a($POST);
2011-06-17 01:47:35 +00:00
2009-01-15 15:42:24 +00:00
switch ( $this -> getAction ()) {
case 'create' :
$this -> _pst -> read_preset ( 'admin_newspost' ); //only works here because $_POST is used.
$this -> show_create_item ();
break ;
case 'cat' :
2009-10-23 18:14:42 +00:00
if ( ! getperms ( '0|7' ))
{
$this -> noPermissions ();
}
2009-01-15 15:42:24 +00:00
$this -> show_categories ();
break ;
case 'sn' :
$this -> show_submitted_news ();
break ;
case 'pref' :
2009-10-23 18:14:42 +00:00
if ( ! getperms ( '0' ))
{
$this -> noPermissions ();
}
2009-01-15 15:42:24 +00:00
$this -> show_news_prefs ();
break ;
2009-05-08 21:50:19 +00:00
case 'maint' :
2009-10-23 18:14:42 +00:00
if ( ! getperms ( '0' ))
{
$this -> noPermissions ();
}
2009-05-08 21:50:19 +00:00
$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 ()
{
2011-12-10 00:00:15 +00:00
$admin_log = e107 :: getAdminLog ();
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' :
2011-06-17 05:45:22 +00:00
2011-12-10 00:00:15 +00:00
if ( $e107 -> sql -> db_Count ( 'news' , '(*)' , " news_id= { $del_id } " ))
2009-01-13 17:09:30 +00:00
{
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-09-25 20:20:23 +00:00
$this -> show_message ( e107 :: getEvent () -> triggerHook ( $data ), E_MESSAGE_WARNING );
2009-01-13 17:09:30 +00:00
admin_purge_related ( " news " , $del_id );
}
}
break ;
case 'category' :
2011-06-17 05:45:22 +00:00
2009-10-23 18:14:42 +00:00
if ( ! getperms ( '0|7' )) $this -> noPermissions ();
2010-03-16 17:00:44 +00:00
2011-12-10 00:00:15 +00:00
if (( $count = $e107 -> sql -> db_Count ( 'news' , '(news_id)' , " news_category= { $del_id } " )) === false || $count > 0 )
{
$this -> show_message ( 'Category is in used in <strong>' . $count . '</strong> news items and cannot be deleted.' , E_MESSAGE_ERROR );
return false ;
}
2011-06-17 01:47:35 +00:00
2011-12-10 00:00:15 +00:00
if ( $e107 -> sql -> db_Count ( 'news_category' , '(*)' , " category_id= { $del_id } " ))
2009-09-12 18:25:41 +00:00
{
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 ;
}
2012-10-11 02:24:43 +00:00
// In USE.
2009-01-13 17:09:30 +00:00
function _observe_submit_item ( $sub_action , $id )
{
// ##### Format and submit item to DB
2011-07-06 23:37:49 +00:00
2009-01-13 17:09:30 +00:00
$ix = new news ;
2013-02-06 11:23:57 +02:00
// jQuery UI temporary date-time fix - inputdatetime -> inputdate
$_POST [ 'news_start' ] = vartrue ( e107 :: getDate () -> convert ( $_POST [ 'news_start' ], 'inputdate' ), 0 );
2012-05-26 12:21:39 +00:00
2009-01-13 17:09:30 +00:00
if ( $_POST [ 'news_start' ])
{
2012-05-26 12:21:39 +00:00
// $_POST['news_start'] = e107::getDate()->convert($_POST['news_start']);
2009-01-13 17:09:30 +00:00
}
else
{
2012-05-26 12:21:39 +00:00
// $_POST['news_start'] = 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
if ( $_POST [ 'news_end' ])
{
2013-02-06 11:23:57 +02:00
$_POST [ 'news_end' ] = e107 :: getDate () -> convert ( $_POST [ 'news_end' ], 'inputdate' );
2009-01-13 17:09:30 +00:00
}
else
{
$_POST [ 'news_end' ] = 0 ;
}
2012-05-26 12:21:39 +00:00
if ( $_POST [ 'news_datestamp' ])
{
2013-02-06 11:23:57 +02:00
$_POST [ 'news_datestamp' ] = e107 :: getDate () -> convert ( $_POST [ 'news_datestamp' ], 'inputdate' );
2012-05-26 12:21:39 +00:00
}
else
{
$_POST [ 'news_datestamp' ] = time ();
}
2012-10-11 02:24:43 +00:00
2012-05-26 12:21:39 +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 ();
}
2012-05-26 12:21:39 +00:00
2009-01-13 17:09:30 +00:00
if ( $_POST [ 'update_datestamp' ])
{
$_POST [ 'news_datestamp' ] = time ();
}
2012-05-26 12:21:39 +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-10-23 18:14:42 +00:00
if ( ! isset ( $this -> news_categories [ $_POST [ 'news_category' ]]))
{
$this -> noPermissions ();
}
2009-01-13 17:09:30 +00:00
2010-03-16 17:00:44 +00:00
/* if ( isset ( $_POST [ 'news_thumbnail' ]))
2009-01-16 17:57:57 +00:00
{
$_POST [ 'news_thumbnail' ] = urldecode ( basename ( $_POST [ 'news_thumbnail' ]));
2010-03-16 17:00:44 +00:00
} */
2009-01-16 17:57:57 +00:00
2012-10-11 02:24:43 +00:00
$_POST [ 'news_render_type' ] = implode ( " , " , $_POST [ 'news_render_type' ]);
// print_a($_POST);
// exit;
2009-01-15 15:42:24 +00:00
$tmp = explode ( chr ( 35 ), $_POST [ 'news_author' ]);
$_POST [ 'news_author' ] = $tmp [ 0 ];
2011-07-06 23:37:49 +00:00
2009-09-12 18:25:41 +00:00
$ret = $ix -> submit_item ( $_POST , ! vartrue ( $_POST [ 'create_edit_stay' ]));
if ( $ret [ 'error' ])
{
2011-12-10 00:00:15 +00:00
e107 :: getMessage () -> mergeWithSession () //merge with session messages
-> add (( $id ? LAN_UPDATED_FAILED : LAN_CREATED_FAILED ), E_MESSAGE_ERROR );
$_POST [ 'news_sef' ] = $ret [ 'data' ][ 'news_sef' ];
2009-09-12 18:25:41 +00:00
return false ;
}
2009-01-18 20:31:14 +00:00
$this -> clear_cache ();
2013-02-06 11:46:20 +02:00
2009-01-18 00:27:10 +00:00
if ( isset ( $_POST [ 'create_edit_stay' ]) && ! empty ( $_POST [ 'create_edit_stay' ]))
{
2013-02-06 11:46:20 +02:00
if ( $this -> getAction () != 'edit' )
2009-01-18 00:27:10 +00:00
{
session_write_close ();
2013-02-06 11:46:20 +02:00
$rurl = e_SELF . ( vartrue ( $ret [ 'news_id' ]) ? '?mode=' . $_GET [ 'mode' ] . '&action=edit&id=' . $ret [ 'news_id' ] : '' );
header ( 'Location: ' . $rurl );
2009-01-18 00:27:10 +00:00
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-10-23 18:14:42 +00:00
if ( ! getperms ( '0|7' ))
{
$this -> noPermissions ();
}
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 ;
2011-12-10 00:00:15 +00:00
if ( ! empty ( $_POST [ 'category_sef' ]))
{
$_POST [ 'category_sef' ] = eHelper :: secureSef ( $_POST [ 'category_sef' ]);
}
2009-09-10 19:15:43 +00:00
}
2011-12-10 00:00:15 +00:00
else
{
// first format sef...
if ( empty ( $_POST [ 'category_sef' ]))
{
$_POST [ 'category_sef' ] = eHelper :: title2sef ( $_POST [ 'category_name' ]);
}
else
{
$_POST [ 'category_sef' ] = eHelper :: secureSef ( $_POST [ 'category_sef' ]);
}
}
// ...then check it
if ( empty ( $_POST [ 'category_sef' ]))
2009-09-10 19:15:43 +00:00
{
2011-12-10 00:00:15 +00:00
$this -> error = true ;
$this -> show_message ( 'Validation error: News Category SEF URL value is required field and can\'t be empty!' , E_MESSAGE_ERROR );
}
elseif ( e107 :: getDb () -> db_Count ( 'news_category' , '(category_id)' , " category_sef=' " . e107 :: getParser () -> toDB ( $_POST [ 'category_sef' ]) . " ' " ))
{
$this -> error = true ;
$this -> show_message ( 'Validation error: News Category SEF URL is unique field - current value already in use! Please choose another SEF URL value.' , E_MESSAGE_ERROR );
2009-09-10 19:15:43 +00:00
}
if ( ! $this -> error )
{
$inserta = array ();
2010-03-16 17:00:44 +00:00
2009-09-10 19:15:43 +00:00
$inserta [ 'data' ][ 'category_icon' ] = $_POST [ 'category_icon' ];
$inserta [ '_FIELD_TYPES' ][ 'category_icon' ] = 'todb' ;
2010-03-16 17:00:44 +00:00
2009-09-10 19:15:43 +00:00
$inserta [ 'data' ][ 'category_name' ] = $_POST [ 'category_name' ];
$inserta [ '_FIELD_TYPES' ][ 'category_name' ] = 'todb' ;
2011-12-10 00:00:15 +00:00
$inserta [ 'data' ][ 'category_sef' ] = $_POST [ 'category_sef' ];
$inserta [ '_FIELD_TYPES' ][ 'category_sef' ] = 'todb' ;
2010-03-16 17:00:44 +00:00
2011-12-10 00:00:15 +00:00
$inserta [ 'data' ][ 'category_meta_description' ] = eHelper :: formatMetaDescription ( $_POST [ 'category_meta_description' ]);
$inserta [ '_FIELD_TYPES' ][ 'category_meta_description' ] = 'todb' ;
2010-03-16 17:00:44 +00:00
2011-12-10 00:00:15 +00:00
$inserta [ 'data' ][ 'category_meta_keywords' ] = eHelper :: formatMetaKeys ( $_POST [ 'category_meta_keywords' ]);
$inserta [ '_FIELD_TYPES' ][ 'category_meta_keywords' ] = 'todb' ;
2010-03-16 17:00:44 +00:00
2009-09-10 19:15:43 +00:00
$inserta [ 'data' ][ 'category_manager' ] = $_POST [ 'category_manager' ];
$inserta [ '_FIELD_TYPES' ][ 'category_manager' ] = 'int' ;
2010-03-16 17:00:44 +00:00
2009-09-10 19:15:43 +00:00
$inserta [ 'data' ][ 'category_order' ] = $_POST [ 'category_order' ];
$inserta [ '_FIELD_TYPES' ][ 'category_order' ] = 'int' ;
2010-03-16 17:00:44 +00:00
2009-09-10 19:15:43 +00:00
$id = e107 :: getDb () -> db_Insert ( 'news_category' , $inserta );
if ( $id )
{
2009-09-13 16:37:18 +00:00
$inserta [ 'data' ][ 'category_id' ] = $id ;
2011-07-06 23:37:49 +00:00
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 , '' );
2010-03-16 17:00:44 +00:00
2009-09-10 19:15:43 +00:00
$this -> show_message ( NWSLAN_35 , E_MESSAGE_SUCCESS );
$this -> clear_cache ();
2010-03-16 17:00:44 +00:00
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
}
}
}
2010-03-16 17:00:44 +00:00
2009-01-13 17:09:30 +00:00
function _observe_update_category ()
2010-03-16 17:00:44 +00:00
{
2009-10-23 18:14:42 +00:00
if ( ! getperms ( '0|7' ))
{
$this -> noPermissions ();
}
2009-09-10 19:15:43 +00:00
$this -> setId ( intval ( $_POST [ 'category_id' ]));
2010-03-16 17:00:44 +00:00
2009-09-10 19:15:43 +00:00
if ( ! $this -> getId ())
2009-01-13 17:09:30 +00:00
{
2009-09-10 19:15:43 +00:00
return ;
}
2010-03-16 17:00:44 +00:00
2009-09-10 19:15:43 +00:00
//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 ;
2011-12-10 00:00:15 +00:00
if ( ! empty ( $_POST [ 'category_sef' ]))
{
$_POST [ 'category_sef' ] = eHelper :: secureSef ( $_POST [ 'category_sef' ]);
}
}
else
{
// first format sef...
if ( empty ( $_POST [ 'category_sef' ]))
{
$_POST [ 'category_sef' ] = eHelper :: title2sef ( $_POST [ 'category_name' ]);
}
else
{
$_POST [ 'category_sef' ] = eHelper :: secureSef ( $_POST [ 'category_sef' ]);
}
}
// ...then check it
if ( empty ( $_POST [ 'category_sef' ]))
{
$this -> error = true ;
$this -> show_message ( 'Validation error: News Category SEF URL value is required field and can\'t be empty!' , E_MESSAGE_ERROR );
}
elseif ( e107 :: getDb () -> db_Count ( 'news_category' , '(category_id)' , " category_id<> " . $this -> getId () . " AND category_sef=' " . ( e107 :: getParser () -> toDB ( $_POST [ 'category_sef' ]) . " ' " )))
{
$this -> error = true ;
$this -> show_message ( 'Validation error: News Category SEF URL is unique field - current value already in use! Please choose another SEF URL value.' , E_MESSAGE_ERROR );
2009-09-10 19:15:43 +00:00
}
2010-03-16 17:00:44 +00:00
2009-09-10 19:15:43 +00:00
if ( ! $this -> error )
{
$updatea = array ();
$updatea [ 'data' ][ 'category_icon' ] = $_POST [ 'category_icon' ];
$updatea [ '_FIELD_TYPES' ][ 'category_icon' ] = 'todb' ;
2010-03-16 17:00:44 +00:00
2009-09-10 19:15:43 +00:00
$updatea [ 'data' ][ 'category_name' ] = $_POST [ 'category_name' ];
$updatea [ '_FIELD_TYPES' ][ 'category_name' ] = 'todb' ;
2011-12-10 00:00:15 +00:00
$updatea [ 'data' ][ 'category_sef' ] = $_POST [ 'category_sef' ];
$updatea [ '_FIELD_TYPES' ][ 'category_sef' ] = 'todb' ;
2009-09-10 19:15:43 +00:00
$updatea [ 'data' ][ 'category_meta_description' ] = strip_tags ( $_POST [ 'category_meta_description' ]);
$updatea [ '_FIELD_TYPES' ][ 'category_meta_description' ] = 'str' ;
2010-03-16 17:00:44 +00:00
2009-09-10 19:15:43 +00:00
$updatea [ 'data' ][ 'category_meta_keywords' ] = $_POST [ 'category_meta_keywords' ];
$updatea [ '_FIELD_TYPES' ][ 'category_meta_keywords' ] = 'str' ;
2010-03-16 17:00:44 +00:00
2009-09-10 19:15:43 +00:00
$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 ();
2010-03-16 17:00:44 +00:00
2009-09-12 18:25:41 +00:00
$inserta = array ();
2011-07-06 23:37:49 +00:00
$rid = 0 ;
2010-03-16 17:00:44 +00:00
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
{
2011-07-06 23:37:49 +00:00
2010-03-16 17:00:44 +00:00
if ( $upcheck || $rwupcheck )
{
2009-09-12 18:25:41 +00:00
//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 , '' );
2010-03-16 17:00:44 +00:00
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 ();
2010-03-16 17:00:44 +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' ]));
}
2010-03-16 17:00:44 +00:00
else
2009-09-12 18:25:41 +00:00
{
$this -> show_message ( LAN_NO_CHANGE );
}
2010-03-16 17:00:44 +00:00
2011-07-06 23:37:49 +00:00
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
}
2010-03-16 17:00:44 +00:00
2009-09-12 18:25:41 +00:00
function _observe_multi_create_category ()
{
2009-10-23 18:14:42 +00:00
if ( ! getperms ( '0|7' ))
{
$this -> noPermissions ();
}
2009-09-12 18:25:41 +00:00
$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 ()
{
2009-10-23 18:14:42 +00:00
if ( ! getperms ( '0' ))
{
$this -> noPermissions ();
}
2013-01-12 16:27:54 -08:00
2009-01-13 17:09:30 +00:00
$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' ]);
2013-01-12 16:27:54 -08:00
$temp [ 'news_ping_services' ] = explode ( " \n " , $_POST [ 'news_ping_services' ]);
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 );
2010-03-16 17:00:44 +00:00
2009-09-13 16:37:18 +00:00
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 ();
2013-02-22 21:34:06 -08:00
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
2012-10-11 02:24:43 +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 ()
{
2011-12-10 00:00:15 +00:00
$user_pref = e107 :: getUser () -> getPref ();
2012-04-18 21:07:20 +00:00
$sql = e107 :: getDb ();
2009-08-05 14:35:47 +00:00
if ( ! getperms ( 'H' ))
{
return ;
}
2011-12-10 00:00:15 +00:00
//require_once(e_HANDLER."form_handler.php");
$frm = e107 :: getForm ( 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
2009-10-26 07:26:53 +00:00
$field_columns = $this -> fields ;
2009-07-03 06:48:43 +00:00
2009-10-23 18:14:42 +00:00
$e107 = e107 :: getInstance ();
2009-07-03 06:48:43 +00:00
// ------ Search Filter ------
$text .= "
2012-04-18 21:07:20 +00:00
< form method = 'get' action = '".e_SELF."' >
2009-10-20 07:39:40 +00:00
< div class = 'left' style = 'padding:20px' >
2012-04-18 21:07:20 +00:00
< input type = 'text' name = 'srch' value = '".$_GET[' srch ']."' /> \n " ;
$text .= " <select class='tbox' name='filter' onchange='this.form.submit()' >
< option value = '' > All Categories </ option > \n " ; // TODO LAN
foreach ( $this -> news_categories as $arr )
{
$key = $arr [ 'category_id' ];
$val = $arr [ 'category_name' ];
$sel = ( $_GET [ 'filter' ] == $key ) ? " selected='selected' " : " " ;
$text .= " <option value=' $key ' { $sel } > " . $val . " </option> \n " ;
}
$text .= " </select> " ;
2009-10-20 07:39:40 +00:00
$text .= $frm -> admin_button ( 'searchsubmit' , NWSLAN_63 , 'search' );
$text .= "
2009-07-03 06:48:43 +00:00
</ div ></ form >
" ;
// --------------------------------------------
2009-07-03 02:27:03 +00:00
2009-10-23 18:14:42 +00:00
$query = "
2011-11-26 18:17:42 +00:00
SELECT n .* , nc .* , u . user_name , u . user_id FROM #news AS n
2009-10-23 18:14:42 +00:00
LEFT JOIN #news_category AS nc ON n.news_category=nc.category_id
LEFT JOIN #user AS u ON n.news_author=u.user_id
" ;
2010-03-16 17:00:44 +00:00
2009-10-23 18:14:42 +00:00
$check_perms = ! getperms ( '0' ) ? " nc.category_manager IN ( " . USERCLASS_LIST . " ) " : '' ;
2012-04-18 21:07:20 +00:00
// Quick qry fix.
$check_perms .= ( vartrue ( $_GET [ 'filter' ])) ? " n.news_category = " . intval ( $_GET [ 'filter' ]) . " " : " " ;
if ( vartrue ( $_GET [ 'srch' ]))
2009-01-13 17:09:30 +00:00
{
2012-04-18 21:07:20 +00:00
$query .= " WHERE { $check_perms } n.news_title REGEXP(' " . $_GET [ 'srch' ] . " ') OR n.news_body REGEXP(' " . $_GET [ 'srch' ] . " ') OR n.news_extended REGEXP(' " . $_GET [ 'srch' ] . " ') ORDER BY n.news_datestamp DESC " ;
2009-01-13 17:09:30 +00:00
}
else
{
2010-03-16 17:00:44 +00:00
$ordfield = 'n.news_datestamp' ;
2011-07-06 23:37:49 +00:00
if ( $this -> getSubAction () == 'user_name' )
2009-10-23 18:14:42 +00:00
{
$ordfield = " u.user_name " ;
}
elseif ( strpos ( $this -> getSubAction (), 'category_' ))
{
$ordfield = 'nc.' . $this -> getSubAction ();
}
elseif ( $this -> getSubAction ())
{
$ordfield = 'n.' . $this -> getSubAction ();
}
2010-03-16 17:00:44 +00:00
2012-04-18 21:07:20 +00:00
$query .= ( $check_perms ? " WHERE { $check_perms } " : '' ) . " ORDER BY { $ordfield } " . strtoupper ( $this -> _sort_order );
2009-01-13 17:09:30 +00:00
}
2010-03-16 17:00:44 +00:00
2012-04-18 21:07:20 +00:00
$newsposts = $sql -> db_Select_gen ( $query );
//echo "sql=".$query;
if ( $sql -> db_Select_gen ( $query . " LIMIT " . $this -> getFrom () . " , { $amount } " ))
2009-01-13 17:09:30 +00:00
{
$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 >
2012-11-26 14:41:32 -08:00
< table class = 'table adminlist' >
2009-10-26 07:26:53 +00:00
" . $frm->colGroup ( $this->fields , $this->fieldpref ). "
2012-04-18 21:07:20 +00:00
" . $frm->thead ( $this->fields , $this->fieldpref , 'action=main&sub=[FIELD]&id=[ASC]&filter='.intval( $_GET['filter'] ).'&srch='. $_GET['srch'] .'&frm=[FROM]'). "
2009-07-17 07:53:13 +00:00
< tbody > " ;
2009-07-03 02:27:03 +00:00
2011-07-06 23:37:49 +00:00
$ren_type = array ( " default " , " title " , " other-news " , " other-news 2 " ); // Shortened
2009-10-23 18:14:42 +00:00
foreach ( $newsarray as $row )
2009-01-13 17:09:30 +00:00
{
2009-10-23 18:14:42 +00:00
// PREPARE SOME DATA
2011-11-26 18:17:42 +00:00
// safe to pass $row as it contains username and id only (no sensitive data), user_id and user_name will be internal converted to 'id', 'name' vars
2012-04-19 03:53:58 +00:00
$row [ 'user_name' ] = " <a href=' " . e107 :: getUrl () -> create ( 'user/profile/view' , $row ) . " ' title=' { $row [ 'user_name' ] } '> { $row [ 'user_name' ] } </a> " ;
2011-11-26 18:17:42 +00:00
$row [ 'news_title' ] = " <a href=' " . e107 :: getUrl () -> create ( 'news/view/item' , $row ) . " '> " . $e107 -> tp -> toHTML ( $row [ 'news_title' ], false , 'TITLE' ) . " </a> " ;
$row [ 'category_name' ] = " <a href=' " . e107 :: getUrl () -> create ( 'news/list/items' , $row ) . " '> " . $row [ 'category_name' ] . " </a> " ;
2009-10-23 18:14:42 +00:00
$row [ 'news_render_type' ] = $ren_type [ $row [ 'news_render_type' ]];
2011-07-06 23:37:49 +00:00
2009-10-23 18:14:42 +00:00
$row [ 'news_allow_comments' ] = ! $row [ 'news_allow_comments' ] ? true : false ; // old reverse logic
$row [ 'options' ] = "
2012-04-18 21:14:04 +00:00
< a class = 'action' href = '".e_SELF."?action=create&sub=edit&id={$row[' news_id ']}' tabindex = '".$frm->getNext()."' > " .ADMIN_EDIT_ICON. " </ a >
2009-10-23 18:14:42 +00:00
" . $frm->submit_image ( " delete [ main_ { $row [ 'news_id' ]}] " , LAN_DELETE, 'delete', NWSLAN_39. " [ ID : { $row [ 'news_id' ]}] " ). "
" ;
$row [ 'checkboxes' ] = $row [ 'news_id' ];
2012-04-19 03:53:58 +00:00
2010-03-16 17:00:44 +00:00
2009-10-23 18:14:42 +00:00
// AUTO RENDER
2009-11-05 17:32:19 +00:00
$text .= $frm -> renderTableRow ( $this -> fields , $this -> fieldpref , $row , 'news_id' );
2009-01-13 17:09:30 +00:00
}
$text .= "
</ tbody >
2009-10-20 07:39:40 +00:00
</ table > " ;
2010-03-16 17:00:44 +00:00
$text .= " <div class='buttons-bar center'> " . $this -> show_batch_options () . " </div> " ;
2009-10-20 07:39:40 +00:00
$text .= "
2009-01-13 17:09:30 +00:00
</ fieldset >
</ form >
" ;
2010-03-16 17:00:44 +00:00
2009-01-13 17:09:30 +00:00
}
else
{
2009-10-23 18:14:42 +00:00
$tmp = NWSLAN_43 ;
2012-04-18 21:07:20 +00:00
if ( vartrue ( $_GET [ 'srch' ]))
2009-10-23 18:14:42 +00:00
{
2012-04-18 21:07:20 +00:00
$tmp = sprintf ( NWSLAN_121 , '<em>"' . $_GET [ 'srch' ]) . " "</em> <a href=' " . e_SELF . " '>« " . LAN_BACK . " </a> " ;
2009-10-23 18:14:42 +00:00
}
$text = " <div class='center warning'> { $tmp } </div> " ;
2006-12-02 04:36:16 +00:00
}
2009-10-20 07:39:40 +00:00
2012-04-18 21:07:20 +00:00
// $newsposts = $e107->sql->db_Count('news');
2006-12-02 04:36:16 +00:00
2012-04-20 07:21:15 +00:00
if ( $newsposts > $amount )
2009-01-13 17:09:30 +00:00
{
2012-04-18 21:07:20 +00:00
// $parms = $newsposts.",".$amount.",".$this->getFrom().",".e_SELF."?".$this->getAction().'.'.($this->getSubAction() ? $this->getSubAction() : 0).'.'.$this->_sort_order.".[FROM]";
$parms = $newsposts . " , " . $amount . " , " . $this -> getFrom () . " , " . e_SELF . " ?action= " . $this -> getAction () . '&sub=' . ( $this -> getSubAction () ? $this -> getSubAction () : 0 ) . '&id=' . $this -> _sort_order . '&filter=' . intval ( $_GET [ 'filter' ]) . '&srch=' . $_GET [ 'srch' ] . " &frm=[FROM] " ;
2009-01-13 17:09:30 +00:00
$nextprev = $e107 -> tp -> parseTemplate ( " { NEXTPREV= { $parms } } " );
if ( $nextprev ) $text .= " <div class='nextprev-bar'> " . $nextprev . " </div> " ;
}
2009-10-23 18:14:42 +00:00
e107 :: getRender () -> tablerender ( NWSLAN_4 , e107 :: getMessage () -> render () . $text );
2006-12-02 04:36:16 +00:00
}
2012-10-11 02:24:43 +00:00
2009-10-20 07:39:40 +00:00
function show_batch_options ()
{
2009-10-23 18:14:42 +00:00
$classes = e107 :: getUserClass () -> uc_get_classlist ();
2010-03-16 17:00:44 +00:00
2009-10-23 18:14:42 +00:00
// Grab news Category Names;
e107 :: getDb () -> db_Select ( 'news_category' , '*' );
$newscatarray = e107 :: getDb () -> db_getList ();
$news_category = $news_manage = array ();
foreach ( $newscatarray as $val )
2009-10-20 07:39:40 +00:00
{
2009-10-23 18:14:42 +00:00
$news_category [ $val [ 'category_id' ]] = $val [ 'category_name' ];
$news_manage [ $val [ 'category_id' ]] = $val [ 'category_manager' ];
2009-10-20 07:39:40 +00:00
}
2010-03-16 17:00:44 +00:00
2009-10-23 18:14:42 +00:00
$comments_array = array ( 'Allow Comments' , 'Disable Comments' , 'Reverse Allow/Disalow' );
$sticky_array = array ( 1 => 'Sticky' , 0 => 'Not Sticky' , 2 => 'Reverse Them' ); // more proper controls order
2010-03-16 17:00:44 +00:00
2009-10-23 18:14:42 +00:00
return e107 :: getForm () -> batchoptions (
2009-10-20 07:39:40 +00:00
array (
2009-10-23 18:14:42 +00:00
'delete_selected' => LAN_DELETE ,
'category' => array ( 'Modify Category' , $news_category ),
'sticky_selected' => array ( 'Modify Sticky' , $sticky_array ),
'rendertype' => array ( 'Modify Render-type' , $this -> news_renderTypes ),
'comments' => array ( 'Modify Comments' , $comments_array ),
'__check_class' => array ( 'category' => $news_manage )
2009-10-20 07:39:40 +00:00
),
2009-10-30 17:59:32 +00:00
array (
2009-10-23 18:14:42 +00:00
'userclass' => array ( 'Assign Visibility...' , $classes ),
2009-10-20 07:39:40 +00:00
)
);
}
2009-10-23 18:14:42 +00:00
function batch_category ( $ids , $value )
2009-10-20 07:39:40 +00:00
{
2009-10-23 18:14:42 +00:00
if ( ! isset ( $this -> news_categories [ $value ]))
{
$this -> noPermissions ();
}
2009-10-20 07:39:40 +00:00
$sql = e107 :: getDb ();
$count = $sql -> db_Update ( " news " , " news_category = " . $value . " WHERE news_id IN ( " . implode ( " , " , $ids ) . " ) " );
}
2010-03-16 17:00:44 +00:00
2009-10-23 18:14:42 +00:00
function batch_comments ( $ids , $value )
2009-10-20 07:39:40 +00:00
{
$sql = e107 :: getDb ();
2009-10-23 18:14:42 +00:00
$value = intval ( $value );
if ( 2 === $value ) //reverse it
{
$count = $sql -> db_Update ( " news " , " news_allow_comments=1-news_allow_comments WHERE news_id IN ( " . implode ( " , " , $ids ) . " ) " );
}
else //set it
{
$count = $sql -> db_Update ( " news " , " news_allow_comments= " . $value . " WHERE news_id IN ( " . implode ( " , " , $ids ) . " ) " );
}
2009-10-20 07:39:40 +00:00
}
2010-03-16 17:00:44 +00:00
2009-10-23 18:14:42 +00:00
function batch_rendertype ( $ids , $value )
2009-10-20 07:39:40 +00:00
{
$sql = e107 :: getDb ();
$count = $sql -> db_Update ( " news " , " news_render_type = " . $value . " WHERE news_id IN ( " . implode ( " , " , $ids ) . " ) " );
}
2010-03-16 17:00:44 +00:00
2009-10-23 18:14:42 +00:00
function batch_userclass ( $ids , $value )
2009-10-20 07:39:40 +00:00
{
$sql = e107 :: getDb ();
$count = $sql -> db_Update ( " news " , " news_class = " . $value . " WHERE news_id IN ( " . implode ( " , " , $ids ) . " ) " );
}
2010-03-16 17:00:44 +00:00
2009-10-23 18:14:42 +00:00
function batch_delete ( $ids , $value )
2009-10-20 07:39:40 +00:00
{
$sql = e107 :: getDb ();
$count = $sql -> db_Delete ( " news " , " news_id IN ( " . implode ( " , " , $ids ) . " ) " );
}
2011-01-04 10:51:12 +00:00
function batch_subdelete ( $ids , $value )
{
$sql = e107 :: getDb ();
$count = $sql -> db_Delete ( " submitnews " , " submitnews_id IN ( " . implode ( " , " , $ids ) . " ) " );
}
function batch_subcategory ( $ids , $value )
{
if ( ! isset ( $this -> news_categories [ $value ]))
{
$this -> noPermissions ();
}
$sql = e107 :: getDb ();
$count = $sql -> db_Update ( " submitnews " , " submitnews_category = " . $value . " WHERE submitnews_id IN ( " . implode ( " , " , $ids ) . " ) " );
}
2010-03-16 17:00:44 +00:00
2009-10-23 18:14:42 +00:00
function batch_sticky ( $ids , $value )
{
$sql = e107 :: getDb ();
$value = intval ( $value );
if ( 2 === $value ) //reverse it
{
$count = $sql -> db_Update ( " news " , " news_sticky=1-news_sticky WHERE news_id IN ( " . implode ( " , " , $ids ) . " ) " );
}
else //set it
{
$count = $sql -> db_Update ( " news " , " news_sticky= " . $value . " WHERE news_id IN ( " . implode ( " , " , $ids ) . " ) " );
}
}
2009-10-20 07:39:40 +00:00
function process_batch ( $id_array )
{
2009-10-23 18:14:42 +00:00
list ( $type , $tmp , $value ) = explode ( " _ " , $_POST [ 'execute_batch' ]);
2009-10-20 07:39:40 +00:00
$method = " batch_ " . $type ;
if ( method_exists ( $this , $method ) && isset ( $id_array ) )
{
$this -> $method ( $id_array , $value );
}
}
2012-10-11 02:24:43 +00:00
*/
2009-10-20 07:39:40 +00:00
2012-10-11 02:24:43 +00:00
// In Use.
2009-01-15 15:42:24 +00:00
function _pre_create ()
{
2012-10-11 02:24:43 +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 ();
2010-03-16 17:00:44 +00:00
2009-10-23 18:14:42 +00:00
if ( ! isset ( $this -> news_categories [ $row [ 'news_category' ]]))
{
$this -> noPermissions ();
}
2010-03-16 17:00:44 +00:00
2009-09-12 18:25:41 +00:00
$_POST [ 'news_title' ] = $row [ 'news_title' ];
2011-12-10 00:00:15 +00:00
$_POST [ 'news_sef' ] = $row [ 'news_sef' ];
2009-09-14 18:22:16 +00:00
$_POST [ 'news_body' ] = $row [ 'news_body' ];
2009-09-12 18:25:41 +00:00
$_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' ];
2010-03-16 17:00:44 +00:00
2009-09-12 18:25:41 +00:00
$_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' " );
2011-07-06 23:37:49 +00:00
$_POST [ 'news_render_type' ] = $row [ 'news_render_type' ];
2009-09-12 18:25:41 +00:00
$_POST [ 'news_thumbnail' ] = $row [ 'news_thumbnail' ];
$_POST [ 'news_meta_keywords' ] = $row [ 'news_meta_keywords' ];
$_POST [ 'news_meta_description' ] = $row [ 'news_meta_description' ];
}
}
2009-01-15 15:42:24 +00:00
}
}
function show_create_item ()
2006-12-02 04:36:16 +00:00
{
2011-12-10 00:00:15 +00:00
$pref = e107 :: getPref ();
2009-01-15 15:42:24 +00:00
$this -> _pre_create ();
require_once ( e_HANDLER . " userclass_class.php " );
2012-06-02 08:12:16 +00:00
// require_once(e_HANDLER."form_handler.php");
2012-05-28 13:06:09 +00:00
// $frm = new e_form(true); //enable inner tabindex counter
$frm = e107 :: getForm ();
2009-01-13 17:09:30 +00:00
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
{
2009-09-14 18:22:16 +00:00
//list($id, $submitnews_name, $submitnews_email, $_POST['news_title'], $submitnews_category, $_POST['news_body'], $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' ];
2009-09-14 18:22:16 +00:00
$_POST [ 'news_body' ] = $row [ 'submitnews_item' ];
2009-01-13 17:09:30 +00:00
$_POST [ 'cat_id' ] = $row [ 'submitnews_category' ];
2010-03-16 17:00:44 +00:00
2009-01-15 15:42:24 +00:00
if ( defsettrue ( 'e_WYSIWYG' ))
2006-12-02 04:36:16 +00:00
{
2009-09-14 18:22:16 +00:00
if ( substr ( $_POST [ 'news_body' ], - 7 , 7 ) == '[/html]' ) $_POST [ 'news_body' ] = substr ( $_POST [ 'news_body' ], 0 , - 7 );
if ( substr ( $_POST [ 'news_body' ], 0 , 6 ) == '[html]' ) $_POST [ 'news_body' ] = substr ( $_POST [ 'news_body' ], 6 );
$_POST [ 'news_body' ] .= " <br /><b> " . NWSLAN_49 . " { $row [ 'submitnews_name' ] } </b> " ;
$_POST [ 'news_body' ] .= ( $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-09-14 18:22:16 +00:00
$_POST [ 'news_body' ] .= " \n [[b] " . NWSLAN_49 . " { $row [ 'submitnews_name' ] } [/b]] " ;
$_POST [ 'news_body' ] .= ( $row [ 'submitnews_file' ]) ? " \n \n [img] { e_NEWSIMAGE} { $row [ 'submitnews_file' ] } [/img] " : " " ;
2006-12-02 04:36:16 +00:00
}
2010-09-06 12:34:06 +00:00
$_POST [ 'data' ] = $tp -> dataFilter ( $_POST [ 'data' ]); // Filter any nasties
$_POST [ 'news_title' ] = $tp -> dataFilter ( $_POST [ 'news_title' ]);
2006-12-02 04:36:16 +00:00
}
2009-01-13 17:09:30 +00:00
}
2012-05-28 13:06:09 +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' ];
2011-11-26 18:17:42 +00:00
$_POST [ 'news_body' ] = $row [ 'upload_description' ] . " \n [b] " . NWSLAN_49 . " [link= " . $e107 -> url -> create ( 'user/profile/view' , 'id=' . $post_author_id . '&name=' . $post_author_name ) . " ] " . $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
}
2012-05-28 13:06:09 +00:00
*/
2006-12-02 04:36:16 +00:00
2009-01-15 15:42:24 +00:00
$text .= "
2013-02-24 18:06:53 -08:00
< ul class = 'nav nav-tabs' >
< li class = 'active' >< a href = '#core-newspost-create' data - toggle = 'tab' > " .LAN_NEWS_52. " </ a ></ li >
< li >< a href = '#core-newspost-seo' data - toggle = 'tab' > SEO </ a ></ li >
< li >< a href = '#core-newspost-edit-options' data - toggle = 'tab' > " .LAN_NEWS_53. " </ a ></ li >
</ ul >
< form method = 'post' action = '".e_SELF."?".e_QUERY."' id = 'core-newspost-create-form' " .(FILE_UPLOADS ? " enctype = 'multipart/form-data' " : " " ). " >
< div class = 'tab-content' >
< div class = 'tab-pane active' id = 'core-newspost-create' >
< fieldset >
2009-01-13 17:09:30 +00:00
< legend > " .LAN_NEWS_52. " </ legend >
2012-11-28 15:00:05 -08:00
< table class = 'table adminform' >
2012-05-13 05:26:11 +00:00
< colgroup >
2009-01-13 17:09:30 +00:00
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
< tbody >
< tr >
2010-01-12 17:25:20 +00:00
< td > " .NWSLAN_6. " : </ td >
< td >
2009-01-13 17:09:30 +00:00
" ;
2010-03-16 17:00:44 +00:00
2009-10-23 18:14:42 +00:00
if ( ! $this -> news_categories )
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
{
2012-05-28 13:06:09 +00:00
// $text .= $frm->selectbox("cat_id",$this->news_category,$_POST['cat_id']);
2013-02-20 17:38:34 -08:00
$catopt = array ();
foreach ( $this -> news_categories as $row )
{
$catopt [ $row [ 'category_id' ]] = $tp -> toHTML ( $row [ 'category_name' ], FALSE , " LINKTEXT " );
}
$text .= $frm -> selectbox ( " cat_id " , $catopt , $_POST [ 'cat_id' ]);
/*
2012-05-28 13:06:09 +00:00
$text .= $frm -> select_open ( 'cat_id' );
2006-12-02 04:36:16 +00:00
2009-10-23 18:14:42 +00:00
foreach ( $this -> news_categories as $row )
2007-02-07 18:48:27 +00:00
{
2009-09-12 18:25:41 +00:00
$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
}
2012-05-28 13:06:09 +00:00
$text .= " </select> " ;
2013-02-20 17:38:34 -08:00
*/
2006-12-02 04:36:16 +00:00
}
2009-01-13 17:09:30 +00:00
$text .= "
</ td >
</ tr >
< tr >
2010-01-12 17:25:20 +00:00
< td > " .NWSLAN_12. " :</ td >
< td >
2012-12-08 13:52:05 +01:00
< input type = 'text' name = 'news_title' value = \ " " . $tp -> post_toForm ( vartrue ( $_POST [ 'news_title' ])) . " \" class='tbox' style='width:90%' required='required' />
2012-07-07 06:04:04 +00:00
" .
// TOO short -> $frm->text('news_title', $tp->post_toForm($_POST['news_title']),200,array('size'=>300)).
"
2009-01-13 17:09:30 +00:00
</ td >
</ tr >
< tr >
2010-01-12 17:25:20 +00:00
< td > " .LAN_NEWS_27. " :</ td >
< td >
2012-12-08 13:52:05 +01:00
< input type = 'text' name = 'news_summary' value = \ " " . $tp -> post_toForm ( vartrue ( $_POST [ 'news_summary' ])) . " \" class='tbox' style='width:90%' />
2012-07-07 06:04:04 +00:00
" .
// $frm->text('news_summary', $tp->post_toForm($_POST['news_summary']), 250).
"
2009-01-13 17:09:30 +00:00
</ td >
</ tr >
2012-06-02 08:12:16 +00:00
2012-11-01 02:21:58 +00:00
< tr >
2012-11-26 14:41:32 -08:00
< td > " .LAN_TEMPLATE. " :</ td >
< td >
2012-11-01 02:21:58 +00:00
" ;
2013-02-23 03:15:13 -08:00
//XXX multiple -selections at once. (comma separated) - working
2013-02-20 17:38:34 -08:00
$text .= $frm -> selectbox ( 'news_render_type' , $this -> news_renderTypes , vartrue ( $_POST [ 'news_render_type' ]), " multiple=1 " ) . "
2012-11-01 02:21:58 +00:00
< div class = 'field-help' >
" .NWSLAN_74. "
</ div >
</ td >
</ tr >
2009-01-13 17:09:30 +00:00
" ;
2008-05-18 16:34:28 +00:00
2012-11-01 02:21:58 +00:00
2008-06-15 20:20:28 +00:00
// -------- News Author ---------------------
2009-01-13 17:09:30 +00:00
$text .= "
< tr >
2013-02-22 21:34:06 -08:00
< td > " .LAN_AUTHOR. " :</ td >
2010-01-12 17:25:20 +00:00
< td >
2009-01-13 17:09:30 +00:00
" ;
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' ] . " ' /> " ;
2011-11-26 18:17:42 +00:00
$text .= " <a href=' " . $e107 -> url -> create ( 'user/profile/view' , 'name=' . $row [ 'user_name' ] . '&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
{
2012-12-08 13:52:05 +01:00
if ( vartrue ( $_POST [ 'news_author' ]))
2008-05-18 16:34:28 +00:00
{
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
2012-05-28 13:06:09 +00:00
$text .= " </td></tr> \n " ;
// -----
$text .= " <tr>
2012-11-28 21:07:23 -08:00
< td colspan = '2' > \n " ;
2012-05-28 13:06:09 +00:00
2013-02-24 18:06:53 -08:00
$text .= ' < ul class = " nav nav-tabs " >
< li class = " active " >< a href = " #news-body-container " data - toggle = " tab " > '.NWSLAN_13.' </ a ></ li >
< li >< a href = " #news-extended-container " data - toggle = " tab " > '.NWSLAN_14.' </ a ></ li >
</ ul >
< div class = " tab-content " > ' ;
2012-05-28 13:06:09 +00:00
2013-02-24 18:06:53 -08:00
$val = ( strstr ( $tp -> post_toForm ( vartrue ( $_POST [ 'news_body' ])), " [img]http " ) ? $tp -> post_toForm ( vartrue ( $_POST [ 'news_body' ])) : str_replace ( " [img]../ " , " [img] " , $tp -> post_toForm ( $_POST [ 'news_body' ])));
$text .= " <div id='news-body-container' class='tab-pane active'> " ;
$text .= $frm -> bbarea ( 'news_body' , $val , 'news' , 'news' );
$text .= " </div> " ;
$text .= " <div id='news-extended-container' class='tab-pane'> " ;
2012-12-08 13:52:05 +01:00
$val = ( strstr ( $tp -> post_toForm ( vartrue ( $_POST [ 'news_extended' ])), " [img]http " ) ? $tp -> post_toForm ( $_POST [ 'news_extended' ]) : str_replace ( " [img]../ " , " [img] " , $tp -> post_toForm ( $_POST [ 'news_extended' ])));
2012-07-07 22:04:49 +00:00
$text .= $frm -> bbarea ( 'news_extended' , $val , 'extended' , 'news' , 'large' );
2012-05-28 13:06:09 +00:00
$text .= " </div>
</ div ></ td ></ tr > " ;
2013-02-24 18:06:53 -08:00
2012-05-28 13:06:09 +00:00
//-----------
/*
$text .= "
2009-01-13 17:09:30 +00:00
< tr >
2010-01-12 17:25:20 +00:00
< td > " .NWSLAN_13. " :< br /></ td >
2012-05-28 13:06:09 +00:00
< td >
" ;
2009-01-13 17:09:30 +00:00
2009-09-14 18:22:16 +00:00
$val = ( strstr ( $tp -> post_toForm ( $_POST [ 'news_body' ]), " [img]http " ) ? $tp -> post_toForm ( $_POST [ 'news_body' ]) : str_replace ( " [img]../ " , " [img] " , $tp -> post_toForm ( $_POST [ 'news_body' ])));
$text .= $frm -> bbarea ( 'news_body' , $val , 'news' , 'helpb' );
2009-01-13 17:09:30 +00:00
// 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 >
2010-01-12 17:25:20 +00:00
< td > " .NWSLAN_14. " :</ td >
< td >
2010-03-16 17:00:44 +00:00
" . $frm->bbarea ('news_extended', $val , 'extended', 'helpc'). "
<!-- < div class = 'field-help' > " .NWSLAN_83. " </ div > -->
2009-01-13 17:09:30 +00:00
</ td >
2012-04-28 01:31:30 +00:00
</ tr > " ;
2012-05-28 13:06:09 +00:00
/*
2012-04-28 01:31:30 +00:00
/*
$text .= "
< tr >
< td > " .NWSLAN_66. " :</ td >
< td > " ;
$text .= $frm -> mediaUrl ( 'news' , NWSLAN_69 );
$text .= "
</ td >
</ tr > " ;
*/
$text .= "
< tr >
< td > " .NWSLAN_67. " :< br />
" . $frm->help (LAN_NEWS_23). " </ td >
< td >
" ;
2012-07-15 03:01:30 +00:00
if ( vartrue ( $_POST [ 'news_thumbnail' ]) && $_POST [ 'news_thumbnail' ][ 0 ] != " { " ) //BC compat
{
$_POST [ 'news_thumbnail' ] = " { e_IMAGE}newspost_images/ " . $_POST [ 'news_thumbnail' ];
}
2012-04-28 01:31:30 +00:00
2010-03-16 17:00:44 +00:00
$text .= $frm -> imagepicker ( 'news_thumbnail' , $_POST [ 'news_thumbnail' ], '' , 'news' );
2010-01-12 17:25:20 +00:00
2009-01-13 17:09:30 +00:00
$text .= "
</ td >
</ tr >
</ tbody >
</ table >
2013-02-24 18:06:53 -08:00
</ fieldset ></ div >
2006-12-02 04:36:16 +00:00
" ;
2010-03-16 17:00:44 +00:00
2009-09-12 18:25:41 +00:00
//BEGIN SEO block
2013-02-24 18:06:53 -08:00
$text .= " <div class='tab-pane' id='core-newspost-seo'>
< fieldset >
2009-09-12 18:25:41 +00:00
< legend > SEO </ legend >
2012-11-28 15:00:05 -08:00
< table class = 'table adminform' >
2012-05-13 05:26:11 +00:00
< colgroup >
2009-09-12 18:25:41 +00:00
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
2011-12-10 00:00:15 +00:00
< tbody >
2011-06-08 03:18:50 +00:00
2009-09-12 18:25:41 +00:00
< tr >
2012-11-26 14:41:32 -08:00
< td > Friendly URL string : </ td >
< td >
2012-12-08 13:52:05 +01:00
" . $frm->text ('news_sef', $tp->post_toForm (vartrue( $_POST['news_sef'] )), 255). "
2011-12-10 00:00:15 +00:00
< div class = 'field-help' > If left empty will be automatically created from current News Title based on your current < a href = '".e_ADMIN_ABS."eurl.php?mode=main&action=settings' title = 'To URL settings area' rel = 'external' > URL settings </ a ></ div >
2009-09-12 18:25:41 +00:00
</ td >
2011-12-10 00:00:15 +00:00
</ tr >
2009-09-12 18:25:41 +00:00
< tr >
2012-11-26 14:41:32 -08:00
< td > " .LAN_KEYWORDS. " : </ td >
2012-12-08 13:52:05 +01:00
< td > " . $frm->tags ('news_meta_keywords', $tp->post_toForm (vartrue( $_POST['news_meta_keywords'] )), 255). "
2012-06-02 08:12:16 +00:00
< div class = 'field-help' > Keywords / tags associated to associate with this news item </ div >
</ td >
2009-09-12 18:25:41 +00:00
</ tr >
2012-06-02 08:12:16 +00:00
2009-09-12 18:25:41 +00:00
< tr >
2012-11-26 14:41:32 -08:00
< td > Meta description : </ td >
2012-12-08 13:52:05 +01:00
< td > " . $frm->textarea ('news_meta_description', $tp->post_toForm (vartrue( $_POST['news_meta_description'] )), 7). " </ td >
2009-09-12 18:25:41 +00:00
</ tr >
2013-01-12 16:27:54 -08:00
< tr >
< td > Notify Ping Services : </ td >
< td > " . $frm->checkbox ('news_ping',1, 1). " </ td >
</ tr >
2009-09-12 18:25:41 +00:00
</ tbody >
</ table >
2013-02-24 18:06:53 -08:00
</ fieldset ></ div >
2009-09-12 18:25:41 +00:00
" ;
2006-12-02 04:36:16 +00:00
2009-09-12 18:25:41 +00:00
//BEGIN Options block
2013-02-24 18:06:53 -08:00
$text .= " <div class='tab-pane' id='core-newspost-edit-options'>
< fieldset >
2009-01-15 15:42:24 +00:00
< legend > " .LAN_NEWS_53. " </ legend >
2012-11-28 15:00:05 -08:00
< table class = 'table adminform' >
2012-05-13 05:26:11 +00:00
< colgroup >
2009-01-13 17:09:30 +00:00
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
< tbody >
< tr >
2012-11-26 14:41:32 -08:00
< td > " .NWSLAN_15. " :</ td >
< td >
2012-12-08 13:52:05 +01:00
" . $frm->radio ('news_allow_comments', 0, !vartrue( $_POST['news_allow_comments'] )). " " . $frm->label (LAN_ENABLED, 'news_allow_comments', 0). " & nbsp ; & nbsp ;
" . $frm->radio ('news_allow_comments', 1, vartrue( $_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 >
2012-11-01 02:21:58 +00:00
2009-01-13 17:09:30 +00:00
< tr >
2012-11-26 14:41:32 -08:00
< td > " .NWSLAN_19. " :</ td >
< td >
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
" ;
2012-05-28 13:06:09 +00:00
2012-05-26 12:21:39 +00:00
2012-12-08 13:52:05 +01:00
$text .= $frm -> datepicker ( " news_start " , vartrue ( $_POST [ 'news_start' ]), " type=datetime " );
2006-12-02 04:36:16 +00:00
$text .= " - " ;
2012-12-08 13:52:05 +01:00
$text .= $frm -> datepicker ( " news_end " , vartrue ( $_POST [ 'news_end' ]), " type=datetime " );
2006-12-02 04:36:16 +00:00
2012-05-28 13:06:09 +00:00
$text .= " </div>
2009-01-15 15:42:24 +00:00
< div class = 'field-help' >
" .NWSLAN_72. "
2009-01-13 17:09:30 +00:00
</ div >
</ td >
</ tr >
< tr >
2012-11-26 14:41:32 -08:00
< td > " .LAN_NEWS_32. " :</ td >
< td >
2009-01-15 15:42:24 +00:00
< div class = 'field-spacer' >
2009-01-13 17:09:30 +00:00
" ;
2012-05-28 13:06:09 +00:00
2013-02-20 17:38:34 -08:00
$text .= $frm -> datepicker ( " news_datestamp " , vartrue ( $_POST [ 'news_datestamp' ]), " type=date " ); //XXX should be 'datetime' when working correctly.
2006-12-02 04:36:16 +00:00
2012-05-28 13:06:09 +00:00
$text .= " </div> " ;
/*
$text .= " <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. "
</ div > " ;
*/
$text .= "
</ td >
2009-01-13 17:09:30 +00:00
</ 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 >
2013-02-22 21:34:06 -08:00
< td > " .LAN_VISIBILITY. " :</ td >
2012-11-26 14:41:32 -08:00
< td >
2012-07-09 01:07:51 +00:00
" . $frm->uc_select ('news_userclass[]', vartrue( $_POST['news_class'] ,0), 'nobody,public,guest,member,admin,classes,language', 'description=1&multiple=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 >
2012-11-26 14:41:32 -08:00
< td > " .LAN_NEWS_28. " :</ td >
< td >
2012-12-08 13:52:05 +01:00
" . $frm->checkbox ('news_sticky', '1', vartrue( $_POST['news_sticky'] )). $frm->label (LAN_NEWS_29, 'news_sticky', '1'). "
2009-01-15 15:42:24 +00:00
< div class = 'field-help' >
2012-06-02 08:12:16 +00:00
" .LAN_NEWS_30. "
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 >
2012-11-26 14:41:32 -08:00
< td > " .LAN_NEWS_34. " :</ td >
< td >
2009-01-13 17:09:30 +00:00
< 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
}
2012-11-30 20:47:26 -08:00
2008-12-29 20:51:24 +00:00
//triggerHook
2012-11-30 20:47:26 -08:00
$data = array ( 'method' => 'form' , 'table' => 'news' , 'id' => $id , 'plugin' => 'news' , 'function' => 'create_item' );
$text .= $frm -> renderHooks ( $data );
2013-02-24 18:06:53 -08:00
$text .= " </tbody>
2009-01-13 17:09:30 +00:00
</ table >
</ fieldset >
2013-02-24 18:06:53 -08:00
</ div >
2009-01-13 17:09:30 +00:00
< div class = 'buttons-bar center' >
2012-11-27 14:38:38 -08:00
" . $frm->admin_button ('preview', isset( $_POST['preview'] ) ? NWSLAN_24 : NWSLAN_27 , 'other'). "
2009-01-13 17:09:30 +00:00
" . $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
2013-02-26 16:20:01 +01:00
$mes = e107 :: getMessage ();
echo $mes -> render () . $text ;
2012-05-17 09:19:44 +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-09-14 18:22:16 +00:00
$_PR [ 'news_body' ] = $e107 -> tp -> post_toHTML ( $_PR [ 'news_body' ], FALSE );
2009-01-15 15:42:24 +00:00
$_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 >
2012-05-13 05:26:11 +00:00
< table class = 'admininfo' >
2009-01-15 15:42:24 +00:00
< tbody >
< tr >
2012-11-26 14:41:32 -08:00
< td colspan = '2' >
2009-01-15 15:42:24 +00:00
" . $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-10-23 18:14:42 +00:00
if ( ! getperms ( '0|7' ))
{
exit ;
}
2011-12-10 00:00:15 +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 );
2010-03-16 17:00:44 +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'
));
2010-03-16 17:00:44 +00:00
2009-04-27 21:23:37 +00:00
2009-01-17 22:48:14 +00:00
//Send the prefered response type
2010-03-16 17:33:21 +00:00
$jshelper -> sendResponse ( 'XML' );
2006-12-02 04:36:16 +00:00
}
2010-03-16 17:00:44 +00:00
2009-09-12 18:25:41 +00:00
function ajax_exec_cat_list_refresh ()
{
2009-10-23 18:14:42 +00:00
if ( ! getperms ( '0|7' ))
{
exit ;
}
2009-09-12 18:25:41 +00:00
echo $this -> show_categoriy_list ();
}
2010-03-16 17:00:44 +00:00
2009-09-12 18:25:41 +00:00
function ajax_exec_catorder ()
{
2009-10-23 18:14:42 +00:00
if ( ! getperms ( '0|7' ))
{
exit ;
}
2009-09-12 18:25:41 +00:00
//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 )
{
2010-03-16 17:00:44 +00:00
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
}
}
2010-03-16 17:00:44 +00:00
2009-09-12 18:25:41 +00:00
function ajax_exec_catmanager ()
{
2009-10-23 18:14:42 +00:00
if ( ! getperms ( '0|7' ))
{
exit ;
}
2009-09-12 18:25:41 +00:00
//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 ());
2010-03-16 17:00:44 +00:00
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
{
2006-12-02 04:36:16 +00:00
2009-10-23 18:14:42 +00:00
$frm = e107 :: getForm ( false , true );
2009-04-27 21:23:37 +00:00
2009-01-16 17:57:57 +00:00
$category = array ();
2011-06-17 05:45:22 +00:00
2009-09-10 19:15:43 +00:00
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 ();
}
2011-06-17 05:45:22 +00:00
2009-09-10 19:15:43 +00:00
}
2010-03-16 17:00:44 +00:00
2009-09-10 19:15:43 +00:00
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 ;
}
2010-03-16 17:00:44 +00:00
2009-09-10 19:15:43 +00:00
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 >
2012-11-26 14:41:32 -08:00
< table class = 'table adminform' >
2012-05-13 05:26:11 +00:00
< colgroup >
2009-01-13 17:09:30 +00:00
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
< tbody >
< tr >
2012-11-26 14:41:32 -08:00
< td > " .NWSLAN_52. " </ td >
< td >
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 >
2011-12-10 00:00:15 +00:00
</ tr >
< tr >
2012-11-26 14:41:32 -08:00
< td > Category friendly URL string </ td >
< td >
2011-12-10 00:00:15 +00:00
" . $frm->text ('category_sef', $category['category_sef'] , 200). "
< div class = 'field-help' > If left empty will be automatically created from current Category Title based on your current < a href = '".e_ADMIN_ABS."eurl.php?mode=main&action=settings' title = 'To URL settings area' rel = 'external' > URL settings </ a ></ div >
</ td >
</ tr >
2009-09-10 19:15:43 +00:00
< tr >
2012-11-26 14:41:32 -08:00
< td > Category meta keywords </ td >
< td >
2009-09-10 19:15:43 +00:00
" . $frm->text ('category_meta_keywords', $category['category_meta_keywords'] , 255). "
< div class = 'field-help' > Used on news categoty list page </ div >
</ td >
</ tr >
< tr >
2012-11-26 14:41:32 -08:00
< td > Category meta description </ td >
< td >
2009-09-10 19:15:43 +00:00
" . $frm->textarea ('category_meta_description', $category['category_meta_description'] , 5). "
< div class = 'field-help' > Used on news categoty list page </ div >
</ td >
</ tr >
< tr >
2012-11-26 14:41:32 -08:00
< td > Category management permissions </ td >
< td >
2009-09-10 19:15:43 +00:00
" . $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 >
2012-11-26 14:41:32 -08:00
< td > " .NWSLAN_53. " </ td >
< td >
2009-09-10 19:15:43 +00:00
" . $frm->iconpicker ('category_icon', $category['category_icon'] , NWSLAN_54). "
" . $frm->hidden ('category_order', $category['category_order'] ). "
2011-06-17 05:45:22 +00:00
2009-01-13 17:09:30 +00:00
</ td >
</ tr >
</ tbody >
</ table >
< div class = 'buttons-bar center' >
" ;
2010-03-16 17:00:44 +00:00
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
2010-03-16 17:00:44 +00:00
2012-05-17 09:19:44 +00:00
echo e107 :: getMessage () -> render () . $text ;
// e107::getRender()->tablerender(NWSLAN_46a, e107::getMessage()->render().$text);
2009-09-12 18:25:41 +00:00
}
2010-03-16 17:00:44 +00:00
2009-09-12 18:25:41 +00:00
function show_categoriy_list ()
{
2009-10-23 18:14:42 +00:00
$frm = e107 :: getForm ();
2010-03-16 17:00:44 +00:00
2009-09-10 19:15:43 +00:00
//FIXME - lan
2009-09-12 18:25:41 +00:00
$text = "
2010-03-16 17:00:44 +00:00
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 >
2012-11-26 14:41:32 -08:00
< table class = 'table adminlist' >
2012-05-13 05:26:11 +00:00
< colgroup >
< col style = 'width: 5%' />
< col style = 'width: 10%' />
< col style = 'width: 40%' />
< col style = 'width: 20%' />
< col style = 'width: 15%' />
< col style = 'width: 10%' />
2009-01-13 17:09:30 +00:00
</ colgroup >
< thead >
< tr >
< th class = 'center' > " .LAN_NEWS_45. " </ th >
2013-02-22 21:34:06 -08:00
< th class = 'center' > " .LAN_ICON. " </ th >
2011-12-10 00:00:15 +00:00
< th > " .NWSLAN_6. " </ th >
2009-09-10 19:15:43 +00:00
< 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 >
" ;
2013-02-22 21:34:06 -08:00
if ( $category_total = e107 :: getDb () -> gen ( " SELECT ncat.* FROM #news_category AS ncat ORDER BY ncat.category_order ASC " ))
2009-09-10 19:15:43 +00:00
{
2009-09-12 18:25:41 +00:00
$tindex = 100 ;
2013-02-22 21:34:06 -08:00
while ( $category = e107 :: getDb () -> fetch ()) {
2006-12-02 04:36:16 +00:00
2009-09-12 18:25:41 +00:00
$icon = '' ;
2010-03-16 17:00:44 +00:00
if ( $category [ 'category_icon' ])
2009-09-12 18:25:41 +00:00
{
$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
}
2010-03-16 17:00:44 +00:00
2011-12-10 00:00:15 +00:00
$url = '<a href="' . e107 :: getUrl () -> create ( 'news/list/category' , $category ) . '" title="' . $category [ 'category_name' ] . '" rel="external">' . $category [ 'category_name' ] . '</a>' ;
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 >
2011-12-10 00:00:15 +00:00
< td class = 'middle' > { $url } </ td >
2009-09-12 18:25:41 +00:00
< td class = 'middle' > " . $frm->uc_select ('multi_category_manager['. $category['category_id'] .']', vartrue( $category['category_manager'] , e_UC_ADMIN), 'main,admin,classes'). " </ td >
2012-05-17 09:19:44 +00:00
< td class = 'center middle' > " ;
$text .= " <a class='action' id='core-news-catedit- { $category [ 'category_id' ] } ' href=' " . e_SELF . " ?mode=cat&action=edit&id= { $category [ 'category_id' ] } ' tabindex=' " . $frm -> getNext () . " '> " . defset ( 'ADMIN_EDIT_ICON' , '<img src="' . e_IMAGE_ABS . 'admin_images/edit_16.png" alt="Edit" />' ) . " </a> " ;
// $text .= "<a class='action' id='core-news-catedit-{$category['category_id']}' href='".e_SELF."?cat.edit.{$category['category_id']}' tabindex='".$frm->getNext()."'>".defset('ADMIN_EDIT_ICON', '<img src="'.e_IMAGE_ABS.'admin_images/edit_16.png" alt="Edit" />')."</a>";
$text .= "
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
}
2010-03-16 17:00:44 +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
" ;
2010-03-16 17:00:44 +00:00
}
else
2009-09-12 18:25:41 +00:00
{
$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
" ;
2010-03-16 17:00:44 +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 ()
{
2009-10-23 18:14:42 +00:00
$frm = e107 :: getForm ();
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
2009-10-23 18:14:42 +00:00
/*
2009-07-03 06:48:43 +00:00
function ajax_exec_searchValue ()
{
2009-10-23 18:14:42 +00:00
$frm = e107 :: getForm ();
2009-10-26 07:26:53 +00:00
echo $frm -> filterValue ( $_POST [ 'filtertype' ], $this -> fields );
2009-07-03 06:48:43 +00:00
}
2009-10-23 18:14:42 +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-10-23 18:14:42 +00:00
$pref = e107 :: getPref ();
$frm = e107 :: getForm ();
2009-04-27 21:23:37 +00:00
2013-02-22 21:34:06 -08:00
$sefbaseDiz = str_replace ( array ( " [br] " , " [ " , " ] " ), array ( " <br /> " , " <a href=' " . e_ADMIN_ABS . " eurl.php'> " , " </a> " ), NWSLAN_128 );
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 >
2012-11-26 14:41:32 -08:00
< table class = 'table adminform' >
2012-05-13 05:26:11 +00:00
< colgroup >
2009-01-13 17:09:30 +00:00
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
< tbody >
2009-09-13 16:37:18 +00:00
< tr >
2012-11-26 14:41:32 -08:00
< td > " .NWSLAN_127. " </ td >
< td >
2009-09-13 16:37:18 +00:00
" . $frm->text ('news_sefbase', $pref['news_sefbase'] ). "
2013-02-22 21:34:06 -08:00
< div class = 'field-help' > " . $sefbaseDiz .'<strong>'.SITEURL.( $pref['news_sefbase'] ? $pref['news_sefbase'] .'/' : ''). " </ strong ></ div >
2009-09-13 16:37:18 +00:00
</ td >
</ tr >
2013-01-12 16:27:54 -08:00
< tr >
< td > Ping Services </ td >
< td >
" . $frm->textarea ('news_ping_services', implode( " \n " , $pref['news_ping_services'] ), 4, 100). "
< div class = 'field-help' > Notify these services when you create / update news items .</ div >
</ td >
</ tr >
2009-01-13 17:09:30 +00:00
< tr >
2012-11-26 14:41:32 -08:00
< td > " .NWSLAN_86. " </ td >
< td >
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 >
2012-11-26 14:41:32 -08:00
< td > " .NWSLAN_87. " </ td >
< td >
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 >
2012-11-26 14:41:32 -08:00
< td > " .NWSLAN_88. " </ td >
< td >
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 >
2012-11-26 14:41:32 -08:00
< td > " .NWSLAN_115. " </ td >
2013-01-12 16:27:54 -08:00
< td id = 'newsposts-archive-cont' >
" . $frm->selectbox ('newsposts_archive', $this->_optrange (intval( $pref['newsposts'] ) - 1), intval( $pref['newsposts_archive'] ), 'class=tbox'). "
2009-01-13 17:09:30 +00:00
< div class = 'field-help' > " .NWSLAN_116. " </ div >
</ td >
</ tr >
< tr >
2012-11-26 14:41:32 -08:00
< td > " .NWSLAN_117. " </ td >
< td >
2009-01-13 17:09:30 +00:00
" . $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 >
2012-11-26 14:41:32 -08:00
< td > " .LAN_NEWS_51. " </ td >
< td >
2012-12-08 13:52:05 +01:00
" . $frm->uc_select ('news_editauthor', vartrue( $pref['news_editauthor'] ), 'nobody,main,admin,classes'). "
2009-01-13 17:09:30 +00:00
</ td >
</ tr >
< tr >
2012-11-26 14:41:32 -08:00
< td > " .NWSLAN_106. " </ td >
< td >
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 >
2012-11-26 14:41:32 -08:00
< td > " .NWSLAN_107. " </ td >
< td >
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 >
2012-11-26 14:41:32 -08:00
< td > " .NWSLAN_100. " </ td >
< td >
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 >
2012-11-26 14:41:32 -08:00
< td > " .NWSLAN_101. " </ td >
< td >
2012-11-03 00:57:29 +00:00
" . $frm->number ('subnews_resize', $pref['subnews_resize'] , 5, 'size=6&class=tbox'). "
2009-01-17 22:48:14 +00:00
< div class = 'field-help' > " .NWSLAN_102. " </ div >
2009-01-13 17:09:30 +00:00
</ td >
</ tr >
< tr >
2012-11-26 14:41:32 -08:00
< td > " .NWSLAN_111. " </ td >
< td >
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 >
2012-11-26 14:41:32 -08:00
< td > " .NWSLAN_113. " </ td >
< td >
2009-01-17 22:48:14 +00:00
< div class = 'auto-toggle-area autocheck' >
2012-12-08 13:52:05 +01:00
" . $frm->checkbox_switch ('news_unstemplate', '1', vartrue( $pref['news_unstemplate'] )). "
2009-01-17 22:48:14 +00:00
< div class = 'field-help' > " .NWSLAN_114. " </ div >
</ div >
2009-01-13 17:09:30 +00:00
</ td >
</ tr >
< tr >
2012-11-26 14:41:32 -08:00
< td > " .NWSLAN_120. " </ td >
< td >
2012-12-08 13:52:05 +01:00
" . $frm->bbarea ('news_subheader', stripcslashes(vartrue( $pref['news_subheader'] )), 2, 'helpb'). "
2009-01-13 17:09:30 +00:00
</ td >
</ tr >
</ tbody >
</ table >
< div class = 'buttons-bar center' >
2013-02-05 18:18:28 +01:00
" . $frm->admin_button ('save_prefs', LAN_UPDATE, 'update'). "
2009-01-13 17:09:30 +00:00
</ div >
</ fieldset >
</ form >
" ;
2013-02-22 02:17:19 -08:00
return e107 :: getMessage () -> render () . $text ;
2012-05-17 09:19:44 +00:00
// e107::getRender()->tablerender(NWSLAN_90, e107::getMessage()->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 ()
2011-01-04 10:51:12 +00:00
{
//TODO - image upload path should be e_MEDIA and using generic upload handler on submitnews.php.
2009-10-23 18:14:42 +00:00
$e107 = e107 :: getInstance ();
$frm = e107 :: getForm ();
2011-01-04 10:51:12 +00:00
$tp = e107 :: getParser ();
$sql = e107 :: getDb ();
$newsCat = array ();
$sql -> db_Select ( 'news_category' );
while ( $row = $sql -> db_Fetch ())
{
$newsCat [ $row [ 'category_id' ]] = $tp -> toHTML ( $row [ 'category_name' ], FALSE , 'TITLE' );
}
if ( $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 >
2012-11-28 15:00:05 -08:00
< table class = 'table adminlist' >
2012-05-13 05:26:11 +00:00
< colgroup >
< col style = 'width: 2%' />
< col style = 'width: 5%' />
< col style = 'width: 60%' />
< col style = 'width: auto' />
< col style = 'width: auto' />
< col style = 'width: auto' />
< col style = 'width: auto' />
< col style = 'width: 20%' />
2009-01-13 17:09:30 +00:00
</ colgroup >
< thead >
< tr >
2011-01-04 10:51:12 +00:00
< th class = 'center' >& nbsp ; </ th >
2009-01-13 17:09:30 +00:00
< th class = 'center' > ID </ th >
< th > " .NWSLAN_57. " </ th >
2011-01-04 10:51:12 +00:00
< th > " .LAN_DATE. " </ th >
< th > " .LAN_AUTHOR. " </ th >
< th > " .NWSLAN_6. " </ th >
< th > " .NWSLAN_123. " </ th >
< th class = 'center last' > " .LAN_OPTIONS. " </ th >
2009-01-13 17:09:30 +00:00
</ tr >
</ thead >
< tbody >
" ;
2011-01-04 10:51:12 +00:00
while ( $row = $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 >
2011-01-04 10:51:12 +00:00
< td class = 'center' >< input type = 'checkbox' name = 'news_selected[".$row[' submitnews_id ']."]' value = '".$row[' submitnews_id ']."' /></ td >
2009-01-18 19:02:07 +00:00
< td class = 'center' > { $row [ 'submitnews_id' ]} </ td >
2009-01-13 17:09:30 +00:00
< td >
2011-01-04 10:51:12 +00:00
< a href = \ " javascript:expandit('submitted_ " . $row [ 'submitnews_id' ] . " ') \" > " ;
$text .= $tp -> toHTML ( $row [ 'submitnews_title' ], FALSE , 'TITLE' );
$text .= '</a>' ;
// $text .= [ '.NWSLAN_104.' '.$submitnews_name.' '.NWSLAN_108.' '.date('D dS M y, g:ia', $submitnews_datestamp).']<br />';
$text .= " <div id='submitted_ " . $row [ 'submitnews_id' ] . " ' style='display:none'> " . $tp -> toHTML ( $row [ 'submitnews_item' ], TRUE );
$text .= ( $row [ 'submitnews_file' ]) ? " <br /><img src=' " . e_IMAGE_ABS . " newspost_images/ " . $row [ 'submitnews_file' ] . " ' alt= \" " . $row [ 'submitnews_file' ] . " \" /> " : " " ;
$text .= "
</ div >
</ td > " ;
$text .= " <td class='nowrap'> " . date ( 'D jS M, Y, g:ia' , $row [ 'submitnews_datestamp' ]) . " </td>
2012-01-02 22:06:22 +00:00
< td >< a href = \ " mailto: " . $row [ 'submitnews_email' ] . " ?subject=[ " . SITENAME . " ] " . trim ( $row [ 'submitnews_title' ]) . " \" title=' " . $row [ 'submitnews_email' ] . " - " . e107 :: getIPHandler () -> ipDecode ( $row [ 'submitnews_ip' ]) . " '> " . $row [ 'submitnews_name' ] . " </a></td>
2011-01-04 10:51:12 +00:00
< td > " . $newsCat[$row['submitnews_category'] ]. " </ td >
< td class = 'center' > " .( $row['submitnews_auth'] == 0 ? " - " : ADMIN_TRUE_ICON). " </ td >
2009-01-13 17:09:30 +00:00
< td >
2011-01-04 10:51:12 +00:00
< div class = 'field-spacer center nowrap' >
" . $frm->admin_button ( " category_view_ { $row [ 'submitnews_id' ]} " , NWSLAN_27, 'action', '', array('id'=>false, 'other'=> " onclick = \ " expandit('submitted_ " . $row [ 'submitnews_id' ] . " ') \" " )) . "
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
}
2011-01-04 10:51:12 +00:00
2009-01-13 17:09:30 +00:00
$text .= "
</ tbody >
2011-01-04 10:51:12 +00:00
</ table > " ;
$text .= " <div class='buttons-bar center'> " ;
$text .= e107 :: getForm () -> batchoptions ( array (
'subdelete_selected' => LAN_DELETE ,
'subcategory' => array ( 'Modify Category' , $newsCat )
));
$text .= " </div>
2009-01-13 17:09:30 +00:00
</ fieldset >
2011-01-04 10:51:12 +00:00
2009-01-13 17:09:30 +00:00
</ 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-10-23 18:14:42 +00:00
e107 :: getRender () -> tablerender ( NWSLAN_47 , e107 :: getMessage () -> 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 " );
2009-10-23 18:14:42 +00:00
$frm = e107 :: getForm ();
2009-05-08 21:50:19 +00:00
$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 >
2012-11-26 14:41:32 -08:00
< table class = 'table adminform' >
2012-05-13 05:26:11 +00:00
< colgroup >
< col class = 'col-label' />
< col class = 'col-control' />
< col class = 'col-control' />
2009-07-18 10:17:56 +00:00
</ colgroup >
2009-05-10 17:31:51 +00:00
< tbody >
< tr >
2012-11-26 14:41:32 -08:00
< td > " .LAN_NEWS_56. " </ td >
< td >
2011-11-17 21:16:28 +00:00
" . $frm->checkbox ('newsdeletecomments', '1', '0').LAN_NEWS_61. "
</ td >
2012-11-26 14:41:32 -08:00
< td >
2009-05-10 17:31:51 +00:00
" . $frm->admin_button ('news_comments_recalc', LAN_NEWS_57, 'update'). "
</ td >
</ tr >
</ tbody >
</ table >
</ fieldset >
</ form >
" ;
2009-05-08 21:50:19 +00:00
2009-10-23 18:14:42 +00:00
e107 :: getRender () -> tablerender ( LAN_NEWS_59 , e107 :: getMessage () -> render () . $text );
2009-05-08 21:50:19 +00:00
}
function _observe_newsCommentsRecalc ()
{
2009-10-23 18:14:42 +00:00
if ( ! getperms ( '0' ))
{
$this -> noPermissions ();
}
2011-11-17 21:16:28 +00:00
$qry = " SELECT
2009-05-08 21:50:19 +00:00
COUNT ( `comment_id` ) AS c_count ,
2011-11-17 21:16:28 +00:00
`news_id` , `news_comment_total` , `news_allow_comments`
2011-11-18 22:06:30 +00:00
FROM `#news` LEFT JOIN `#comments` ON `news_id` = `comment_item_id`
WHERE ( `comment_type` = '0' ) OR ( `comment_type` = 'news' )
GROUP BY `comment_item_id` " ;
2009-07-18 10:17:56 +00:00
2011-11-17 21:16:28 +00:00
$deleteCount = 0 ;
$updateCount = 0 ;
$canDelete = isset ( $_POST [ 'newsdeletecomments' ]);
if ( $result = e107 :: getDb () -> db_Select_gen ( $qry ))
2009-05-08 21:50:19 +00:00
{
2009-10-23 18:14:42 +00:00
while ( $row = e107 :: getDb () -> db_Fetch ( MYSQL_ASSOC ))
2009-05-08 21:50:19 +00:00
{
2011-11-17 21:16:28 +00:00
if ( $canDelete && ( $row [ 'news_allow_comments' ] != 0 ) && ( $row [ 'c_count' ] > 0 )) // N.B. sense of 'news_allow_comments' is 0 = allow!!!
{ // Delete comments
e107 :: getDb ( 'sql2' ) -> db_Delete ( 'comments' , 'comment_item_id=' . $row [ 'news_id' ]);
$deleteCount = $deleteCount + $row [ 'c_count' ];
$row [ 'c_count' ] = 0 ; // Forces update of news table if necessary
}
if ( $row [ 'news_comment_total' ] != $row [ 'c_count' ])
{
e107 :: getDb ( 'sql2' ) -> db_Update ( 'news' , 'news_comment_total = ' . $row [ 'c_count' ] . ' WHERE news_id=' . $row [ 'news_id' ]);
$updateCount ++ ;
}
2009-05-08 21:50:19 +00:00
}
2011-11-17 21:16:28 +00:00
$this -> show_message ( str_replace ( array ( '--UPDATE--' , '--DELETED--' ), array ( $updateCount , $deleteCount ), LAN_NEWS_58 ), E_MESSAGE_SUCCESS );
}
else
{
2011-11-18 22:06:30 +00:00
$this -> show_message ( LAN_NEWS_62 , E_MESSAGE_WARNING );
2009-05-08 21:50:19 +00:00
}
}
2009-01-17 22:48:14 +00:00
function show_message ( $message , $type = E_MESSAGE_INFO , $session = false )
{
// ##### Display comfort ---------
2009-10-23 18:14:42 +00:00
e107 :: getMessage () -> add ( $message , $type , $session );
}
2010-03-16 17:00:44 +00:00
2009-10-23 18:14:42 +00:00
function noPermissions ( $qry = '' )
{
$url = e_SELF . ( $qry ? '?' . $qry : '' );
if ( $qry !== e_QUERY )
{
$this -> show_message ( 'Insufficient permissions!' , E_MESSAGE_ERROR , true );
session_write_close ();
header ( 'Location: ' . $url );
}
exit ;
2009-01-17 22:48:14 +00:00
}
2012-05-28 13:06:09 +00:00
/*
2006-12-02 04:36:16 +00:00
2009-01-13 17:09:30 +00:00
function show_options ()
{
2009-09-19 15:27:26 +00:00
$e107 = e107 :: getInstance ();
2009-01-13 17:09:30 +00:00
$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 ;
2012-04-18 21:07:20 +00:00
$var [ 'create' ][ 'link' ] = e_SELF . " ?action=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 ;
2012-04-18 21:07:20 +00:00
$var [ 'cat' ][ 'link' ] = e_SELF . " ?action=cat " ;
2009-01-13 17:09:30 +00:00
$var [ 'cat' ][ 'perm' ] = " 7 " ;
$var [ 'pref' ][ 'text' ] = NWSLAN_90 ;
2012-04-18 21:07:20 +00:00
$var [ 'pref' ][ 'link' ] = e_SELF . " ?action=pref " ;
2009-10-23 18:14:42 +00:00
$var [ 'pref' ][ 'perm' ] = " 0 " ;
2009-04-27 21:23:37 +00:00
2009-10-26 07:26:53 +00:00
//TODO remove commented code before release.
// $c = $e107->sql->db_Count('submitnews');
// if ($c) {
2009-01-18 19:02:07 +00:00
$var [ 'sn' ][ 'text' ] = NWSLAN_47 . " ( { $c } ) " ;
2012-04-18 21:07:20 +00:00
$var [ 'sn' ][ 'link' ] = e_SELF . " ?action=sn " ;
2009-01-13 17:09:30 +00:00
$var [ 'sn' ][ 'perm' ] = " N " ;
2009-10-26 07:26:53 +00:00
// }
2009-01-13 17:09:30 +00:00
2009-05-08 21:50:19 +00:00
if ( getperms ( '0' ))
{
$var [ 'maint' ][ 'text' ] = LAN_NEWS_55 ;
2012-04-18 21:07:20 +00:00
$var [ 'maint' ][ 'link' ] = e_SELF . " ?action=maint " ;
2009-05-08 21:50:19 +00:00
$var [ 'maint' ][ 'perm' ] = " N " ;
}
2012-12-03 01:40:47 -08:00
e107 :: getNav () -> admin ( NWSLAN_48 , $this -> getAction (), $var );
2009-01-13 17:09:30 +00:00
}
2012-05-28 13:06:09 +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
function newspost_adminmenu ()
2008-12-07 13:08:54 +00:00
{
2012-05-28 13:06:09 +00:00
// e107::getRegistry('_newspost_admin')->show_options();
2006-12-02 04:36:16 +00:00
}