From d128b5257620eded05dbf0fd7a5481800246d508 Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 7 Apr 2015 19:49:11 -0700 Subject: [PATCH] New Addon: e_admin.php - extends the admin area fields and processing. Replacement for the old e_hook and e_event addons which were doing the same, but were not compatible with the v2.x admin-ui. --- e107_admin/newspost.php | 1164 +++++++++++++++++++--------- e107_handlers/admin_ui.php | 56 +- e107_handlers/form_handler.php | 9 +- e107_handlers/news_class.php | 58 +- e107_handlers/plugin_class.php | 1 + e107_plugins/social/e_admin.php | 70 ++ e107_plugins/social/e_event.php | 84 +- e107_plugins/trackback/e_admin.php | 127 +++ 8 files changed, 1036 insertions(+), 533 deletions(-) create mode 100644 e107_plugins/social/e_admin.php create mode 100644 e107_plugins/trackback/e_admin.php diff --git a/e107_admin/newspost.php b/e107_admin/newspost.php index 8dcdc1398..730f80e5e 100644 --- a/e107_admin/newspost.php +++ b/e107_admin/newspost.php @@ -18,21 +18,8 @@ if (!getperms('H|N')) exit; } -//include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_'.e_PAGE); e107::coreLan('newspost', true); -// ------------------------------ -// 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. -$newspost = new admin_newspost(e_QUERY); -e107::setRegistry('_newspost_admin', $newspost); -$gen = new convert(); - - -//Handle Ajax Calls -if($newspost->ajax_observer()) exit; - -// e107::js('core','core/admin.js','prototype'); -//e107::getJs()->requireCoreLib('core/admin.js'); class news_admin extends e_admin_dispatcher { @@ -110,11 +97,11 @@ class news_cat_ui extends e_admin_ui protected $fieldpref = array('checkboxes', 'category_icon', 'category_id', 'category_name', 'category_description','category_manager', 'category_order', 'options'); - protected $newspost; + // protected $newspost; function init() { - $this->newspost = new admin_newspost; + // $this->newspost = new admin_newspost; } // function createPage() @@ -132,6 +119,7 @@ class news_cat_ui extends e_admin_ui { $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}'")) @@ -216,7 +204,7 @@ class news_sub_ui extends e_admin_ui function init() { $sql = e107::getDb(); - $sql->db_Select_gen("SELECT category_id,category_name FROM #news_category"); + $sql->gen("SELECT category_id,category_name FROM #news_category"); while($row = $sql->fetch()) { $cat = $row['category_id']; @@ -224,7 +212,7 @@ class news_sub_ui extends e_admin_ui } asort($this->cats); $this->fields['submitnews_category']['writeParms'] = $this->cats; - $this->newspost = new admin_newspost; + // $this->newspost = new admin_newspost; } // function createPage() @@ -263,7 +251,7 @@ class news_sub_form_ui extends e_admin_form_ui // $text .= ""; - $text .= ""; + $text = ""; $text .= $tp->toHTML($submitnews_title,FALSE,'emotes_off, no_make_clickable'); $text .= ''; @@ -326,7 +314,7 @@ class news_sub_form_ui extends e_admin_form_ui } - $text .= $this->submit_image('etrigger_delete['.$id.']', $id, 'delete', LAN_DELETE.' [ ID: '.$id.' ]', array('class' => 'btn btn-large action delete'.$delcls)); + $text .= $this->submit_image('etrigger_delete['.$id.']', $id, 'delete', LAN_DELETE.' [ ID: '.$id.' ]', array('class' => 'btn btn-large action delete')); $text .= ""; return $text; } @@ -345,6 +333,7 @@ class news_admin_ui extends e_admin_ui { protected $pluginTitle = ADLAN_0; // "News" protected $pluginName = 'core'; + protected $eventName = 'news'; protected $table = "news"; protected $pid = "news_id"; protected $perPage = 10; //no limit @@ -353,6 +342,10 @@ class news_admin_ui extends e_admin_ui protected $batchLink = true; protected $listOrder = "news_id desc"; // true for 'vars' value means use same var + + protected $tabs = array(LAN_NEWS_52, 'SEO', LAN_NEWS_53); + + protected $url = array( 'route'=>'news/view/item', 'name' => 'news_title', @@ -365,33 +358,45 @@ class news_admin_ui extends e_admin_ui protected $fields = array( - 'checkboxes' => array('title' => '', 'type' => null, 'width' => '3%', 'thclass' => 'center first', 'class' => 'center', 'nosort' => true, 'toggle' => 'news_selected', 'forced' => TRUE), - 'news_id' => array('title' => LAN_ID, 'type' => 'text', 'width' => '5%', 'thclass' => 'center', 'class' => 'center', 'nosort' => false, 'readParms'=>'link=sef&target=blank'), - '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), - 'news_title' => array('title' => LAN_TITLE, 'type' => 'text', 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), - '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), - 'news_sef' => array('title' => LAN_SEFURL, 'type' => 'text', 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), - 'user_name' => array('title' => LAN_AUTHOR, 'type' => 'text', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'noedit' => true), - '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), - 'news_category' => array('title' => NWSLAN_6, 'type' => 'dropdown', 'data' => 'int', 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'batch'=>true, 'filter'=>true), - - 'news_start' => array('title' => "Start", 'type' => 'datestamp', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'parms' => 'mask=%A %d %B %Y'), - 'news_end' => array('title' => "End", 'type' => 'datestamp', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'parms' => 'mask=%A %d %B %Y'), - - 'news_class' => array('title' => LAN_VISIBILITY, 'type' => 'userclasses', 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'batch'=>true, 'filter'=>true), - 'news_render_type' => array('title' => LAN_TEMPLATE, 'type' => 'comma', 'inline'=>false, 'width' => 'auto', 'thclass' => 'center', 'class' => null, 'nosort' => false, 'batch'=>true, 'filter'=>true), - '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'), - '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) + 'checkboxes' => array('title' => '', 'type' => null, 'width' => '3%', 'thclass' => 'center first', 'class' => 'center', 'nosort' => true, 'toggle' => 'news_selected', 'forced' => TRUE), + 'news_id' => array('title' => LAN_ID, 'type' => 'text', 'width' => '5%', 'thclass' => 'center', 'class' => 'center', 'nosort' => false, 'readParms'=>'link=sef&target=blank'), + '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), + 'news_title' => array('title' => LAN_TITLE, 'type' => 'text', 'tab'=>0, 'writeParms'=> array('required'=> 1, 'size'=>'block-level'), 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), + 'news_summary' => array('title' => LAN_NEWS_27, 'type' => 'text', 'tab'=>0, 'writeParms'=>'size=block-level', 'width' => 'auto', 'thclass' => 'left', 'class' => 'left', 'nosort' => false), + 'news_body' => array('title' => "", 'type' => 'method', 'tab'=>0, 'nolist'=>true, 'writeParms'=>'nolabel=1','data'=>'str', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), + 'news_extended' => array('title' => "", 'type' => 'hidden', 'tab'=>0, 'nolist'=>true, 'writeParms'=>'nolabel=1','data'=>'str', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), + + 'news_meta_keywords' => array('title' => LAN_KEYWORDS, 'type' => 'tags', 'tab'=>1, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), + 'news_meta_description' => array('title' => LAN_DESCRIPTION,'type' => 'textarea', 'tab'=>1, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), + 'news_sef' => array('title' => LAN_SEFURL, 'type' => 'text', 'tab'=>1, 'writeParms'=>'size=xxlarge', 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), + 'news_ping' => array('title' => 'Ping', 'type' => 'checkbox', 'tab'=>1, 'data'=>false, 'writeParms'=>'value=0', 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), + + 'news_author' => array('title' => LAN_AUTHOR, 'type' => 'method', 'tab'=>0, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), + 'news_datestamp' => array('title' => LAN_NEWS_32, 'type' => 'datestamp', 'tab'=>2, 'writeParms'=>'type=datetime', 'data' => 'int', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'parms' => 'mask=%A %d %B %Y', 'filter'=>true), + 'news_category' => array('title' => NWSLAN_6, 'type' => 'dropdown', 'tab'=>0, 'data' => 'int', 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'batch'=>true, 'filter'=>true), + 'news_start' => array('title' => "Starting", 'type' => 'datestamp', 'tab'=>2, 'writeParms'=>'type=datetime', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'parms' => 'mask=%A %d %B %Y'), + 'news_end' => array('title' => "Ending", 'type' => 'datestamp', 'tab'=>2, 'writeParms'=>'type=datetime', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'parms' => 'mask=%A %d %B %Y'), + 'news_class' => array('title' => LAN_VISIBILITY, 'type' => 'userclasses','tab'=>2, 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'batch'=>true, 'filter'=>true), + 'news_render_type' => array('title' => LAN_TEMPLATE, 'type' => 'dropdown', 'tab'=>0, 'data'=> 'str', 'inline'=>false, 'width' => 'auto', 'thclass' => 'left', 'class' => 'left', 'nosort' => false, 'batch'=>true, 'filter'=>true), + 'news_sticky' => array('title' => LAN_NEWS_28, 'type' => 'boolean', 'tab'=>2, 'data' => 'int' , 'width' => 'auto', 'thclass' => 'center', 'class' => 'center', 'nosort' => false, 'batch'=>true, 'filter'=>true), + 'news_allow_comments' => array('title' => NWSLAN_15, 'type' => 'boolean', 'tab'=>2, 'writeParms'=>'inverse=1', 'data' => 'int', 'width' => 'auto', 'thclass' => 'center', 'class' => 'center', 'nosort' => false,'batch'=>true, 'filter'=>true,'readParms'=>'reverse=1','writeParms'=>'inverse=1'), + 'news_comment_total' => array('title' => LAN_NEWS_60, 'type' => 'number', 'tab'=>2, 'noedit'=>true, '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) ); protected $fieldpref = array('checkboxes','news_id', 'news_thumbnail', 'news_title', 'news_datestamp', 'news_category', 'options'); - + + /* //TODO + protected $prefs = array( + + 'news_category' => array('title' => NWSLAN_127, 'type' => 'dropdown', 'help'=> "Determines how the default news page should appear."), + 'news_ping_services' => array('title' => "Ping Services", 'type' => 'textarea', 'data'=> 'help'=> ">Notify these services when you create/update news items.
One per line."), + + + + ); + */ protected $cats = array(); protected $newspost; @@ -406,49 +411,195 @@ class news_admin_ui extends e_admin_ui '5' => "Carousel", //'5' => "Featurebox" ); - + + public function beforeCreate($new_data) + { + $new_data['news_thumbnail'] = $this->processThumbs($new_data['news_thumbnail']); + + if(empty($new_data['news_datestamp'])) + { + $new_data['news_datestamp'] = time(); + } + + $new_data['news_sef'] = empty($new_data['news_sef']) ? eHelper::title2sef($new_data['news_title']) : eHelper::secureSef($new_data['news_sef']); + + $tmp = explode(chr(35), $new_data['news_author']); + $new_data['news_author'] = intval($tmp[0]); + + + + return $new_data; + } + + + public function beforeUpdate($new_data, $old_data, $id) + { + $new_data['news_thumbnail'] = $this->processThumbs($new_data['news_thumbnail']); + + if(empty($new_data['news_datestamp'])) + { + $new_data['news_datestamp'] = time(); + } + + if(empty($new_data['news_sef'])) + { + $new_data['news_sef'] = eHelper::title2sef($new_data['news_title']); + } + + $tmp = explode(chr(35), $new_data['news_author']); + $new_data['news_author'] = intval($tmp[0]); + + return $new_data; + } + + + public function afterCreate($new_data, $old_data, $id) + { + e107::getEvent()->trigger('newspost',$new_data); + e107::getEvent()->trigger('admin_news_created',$new_data); + $evdata = array('method'=>'create', 'table'=>'news', 'id'=>$id, 'plugin'=>'news', 'function'=>'submit_item'); + e107::getMessage()->addInfo(e107::getEvent()->triggerHook($evdata)); + $this->clearCache(); + } + + + + public function afterUpdate($new_data, $old_data, $id) + { + e107::getEvent()->trigger('newsupd', $new_data); + e107::getEvent()->trigger('admin_news_updated',$new_data); + + $this->clearCache(); + + //$ecache->clear("nq_news_"); - supported by cache::clear() now + //$ecache->clear("nomd5_news_"); supported by cache::clear() now + + + $evdata = array('method'=>'update', 'table'=>'news', 'id'=>$id, 'plugin'=>'news', 'function'=>'submit_item'); + e107::getMessage()->addInfo(e107::getEvent()->triggerHook($evdata)); + } + + + + public function afterDelete() + { + $this->clearCache(); + } + + function clearCache() + { + $ecache = e107::getCache(); + $ecache->clear("news.php"); //TODO change it to 'news_*' everywhere + $ecache->clear("news_", false, true); //NEW global news cache prefix + $ecache->clear("othernews"); //TODO change it to 'news_othernews' everywhere + $ecache->clear("othernews2"); //TODO change it to 'news_othernews2' everywhere + + //$ecache->clear("nq_news_"); - supported by cache::clear() now + //$ecache->clear("nomd5_news_"); supported by cache::clear() now + return $this; + } + + /** + * For future use: multiple-images. + */ + private function processThumbs($postedImage) + { + if(is_array($postedImage)) + { + return implode(",",array_filter($postedImage)); + } + else + { + return $postedImage; + } + + } + + +// + + + function ukfield($a, $b) // custom sort order on create/edit pags. + { + + $newOrder = array ( + 'checkboxes', + 'news_id', + 'news_category', + 'news_title' , + 'news_summary', + 'news_render_type', + 'news_author' , + 'news_body', + 'news_extended', + 'news_thumbnail', + + 'news_sef' , + 'news_meta_keywords', + 'news_meta_description' , + 'news_ping', + + 'news_allow_comments' , + 'news_start' , + 'news_end' , + 'news_datestamp' , + 'news_class', + 'news_sticky', + + 'news_comment_total' , + 'options' ); + + + $addons = e107::getAddonConfig('e_admin',null, 'config',$this); + foreach($addons as $plug=>$config) + { + foreach($config['fields'] as $field=>$tmp) + { + $newOrder[] = "x_".$plug."_".$field; + // echo $field; + } + } + + + + $order = array_flip($newOrder); + + if ($order[$a] == $order[$b]) + { + return 0; + } + return ($order[$a] < $order[$b]) ? -1 : 1; + + } + function init() { - // Ping Changes to Services. - $pingServices = e107::getPref('news_ping_services'); - //TODO Use Ajax with progress-bar. - - $mes = e107::getMessage(); - - if(vartrue($_POST['news_ping'],false) && (count($pingServices)>0) && in_array(e_UC_PUBLIC, $_POST['news_userclass'])) + if(!empty($_POST['save_prefs'])) { - $mes->addDebug("Initiating ping",'default',true); - - include (e_HANDLER.'xmlrpc/xmlrpc.inc.php'); - include (e_HANDLER.'xmlrpc/xmlrpcs.inc.php'); - include (e_HANDLER.'xmlrpc/xmlrpc_wrappers.inc.php'); - - $extendedServices = array('blogsearch.google.com'); - - $port = 80; - - foreach($pingServices as $fullUrl) - { - $fullUrl = str_replace("http://","", trim($fullUrl)); - list($server,$path) = explode("/",$fullUrl, 2); - - $path = "/".$path; - - $weblog_name = SITENAME; - $weblog_url = $_SERVER['HTTP_HOST'].e_HTTP; - $changes_url = $_SERVER['HTTP_HOST'].e107::getUrl()->create('news/view/item', $_POST); // $_SERVER['HTTP_HOST'].e_HTTP."news.php?extend.".$_POST['news_id']; - $cat_or_rss = $_SERVER['HTTP_HOST'].e_PLUGIN_ABS."rss_menu/rss.php?1.2"; - $extended = (in_array($server, $extendedServices)) ? true : false; - - if($this->ping($server, $port, $path, $weblog_name, $weblog_url, $changes_url, $cat_or_rss, $extended)) - { - e107::getMessage()->addDebug("Successfully Pinged: ".$server .' with '.$changes_url , 'default', true); - } - - } - + $this->saveSettings(); } + + if($this->getAction() == 'create' || $this->getAction() == 'edit') + { + uksort($this->fields, array($this, 'ukfield')); + + // $fieldKeys = array_keys($this->fields); + // print_a($fieldKeys); + + if(!empty($_GET['sub'])) + { + $this->loadSubmitted($_GET['sub']); + } + + } + + // $mod = $this->getModel(); + // $info = print_a($mod, true); + + // e107::getMessage()->addInfo($info); + + $this->processPings(); $sql = e107::getDb(); @@ -460,12 +611,97 @@ class news_admin_ui extends e_admin_ui } asort($this->cats); $this->fields['news_category']['writeParms'] = $this->cats; - - $this->fields['news_render_type']['writeParms'] = $this->news_renderTypes; // array(NWSLAN_75,NWSLAN_76,NWSLAN_77,NWSLAN_77." 2","Featurebox"); - $this->newspost = new admin_newspost; - $this->newspost->news_renderTypes = $this->news_renderTypes; - $this->newspost->observer(); + $this->fields['news_render_type']['writeParms']['optArray'] = $this->news_renderTypes; // array(NWSLAN_75,NWSLAN_76,NWSLAN_77,NWSLAN_77." 2","Featurebox"); + $this->fields['news_render_type']['writeParms']['multiple'] = 1; + // $this->newspost = new admin_newspost; + // $this->newspost->news_renderTypes = $this->news_renderTypes; + // $this->newspost->observer(); + } + + + function saveSettings() + { + if(!getperms('0')) + { + $this->noPermissions(); + } + + + $temp = array(); + $temp['newsposts'] = intval($_POST['newsposts']); + $temp['newsposts_archive'] = intval($_POST['newsposts_archive']); + $temp['newsposts_archive_title'] = e107::getParser()->toDB($_POST['newsposts_archive_title']); + $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']); + $temp['news_subheader'] = e107::getParser()->toDB($_POST['news_subheader']); + $temp['news_newdateheader'] = intval($_POST['news_newdateheader']); + $temp['news_unstemplate'] = intval($_POST['news_unstemplate']); + $temp['news_editauthor'] = intval($_POST['news_editauthor']); + $temp['news_ping_services'] = explode("\n",$_POST['news_ping_services']); + $temp['news_default_template'] = preg_replace('#[^\w\pL\-]#u', '', $_POST['news_default_template']); + $temp['news_list_limit'] = intval($_POST['news_list_limit']); + + e107::getConfig()->updatePref($temp); + + if(e107::getConfig()->save(false)) + { + e107::getAdminLog()->logArrayDiffs($temp, e107::getPref(), 'NEWS_06'); + $this->clearCache(); + } + } + + + + + function processPings() + { + + // Ping Changes to Services. + $pingServices = e107::getPref('news_ping_services'); + //TODO Use Ajax with progress-bar. + + $mes = e107::getMessage(); + + if(vartrue($_POST['news_ping'],false) && (count($pingServices)>0) && in_array(e_UC_PUBLIC, $_POST['news_userclass'])) + { + $mes->addDebug("Initiating ping",'default',true); + + include (e_HANDLER.'xmlrpc/xmlrpc.inc.php'); + include (e_HANDLER.'xmlrpc/xmlrpcs.inc.php'); + include (e_HANDLER.'xmlrpc/xmlrpc_wrappers.inc.php'); + + $extendedServices = array('blogsearch.google.com'); + + $port = 80; + + foreach($pingServices as $fullUrl) + { + $fullUrl = str_replace("http://","", trim($fullUrl)); + list($server,$path) = explode("/",$fullUrl, 2); + + $path = "/".$path; + + $weblog_name = SITENAME; + $weblog_url = $_SERVER['HTTP_HOST'].e_HTTP; + $changes_url = $_SERVER['HTTP_HOST'].e107::getUrl()->create('news/view/item', $_POST); // $_SERVER['HTTP_HOST'].e_HTTP."news.php?extend.".$_POST['news_id']; + $cat_or_rss = $_SERVER['HTTP_HOST'].e_PLUGIN_ABS."rss_menu/rss.php?1.2"; + $extended = (in_array($server, $extendedServices)) ? true : false; + + if($this->ping($server, $port, $path, $weblog_name, $weblog_url, $changes_url, $cat_or_rss, $extended)) + { + e107::getMessage()->addDebug("Successfully Pinged: ".$server .' with '.$changes_url , 'default', true); + } + + } + + } + + } @@ -574,34 +810,35 @@ class news_admin_ui extends e_admin_ui - - function createPage() - { - // print_a($_POST); - if(isset($_GET['sub'])) + /* + function createPage() { - $id = intval($_GET['sub']); - - $this->loadSubmitted($id); - } - else - { - $this->preCreate(); - } - - $this->newspost->show_create_item(); - } - function categoryPage() - { - if(!getperms('0|7')) - { - $this->noPermissions(); + // print_a($_POST); + if(isset($_GET['sub'])) + { + $id = intval($_GET['sub']); + + $this->loadSubmitted($id); + } + else + { + $this->preCreate(); + } + + $this->newspost->show_create_item(); } - $this->newspost->show_categories(); - // $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(); @@ -611,10 +848,181 @@ class news_admin_ui extends e_admin_ui { } + + private function _optrange($num, $zero = true) + { + $tmp = range(0, $num < 0 ? 0 : $num); + if(!$zero) unset($tmp[0]); + return $tmp; + } function settingsPage() { - return $this->newspost->show_news_prefs(); + // return $this->newspost->show_news_prefs(); + + $pref = e107::getPref(); + $frm = e107::getForm(); + + $sefbaseDiz = str_replace(array("[br]","[","]"), array("
","",""), NWSLAN_128 ); + $pingOpt = array('placeholder'=>'eg. blogsearch.google.com/ping/RPC2'); + $pingVal = (!empty($pref['news_ping_services'])) ? implode("\n",$pref['news_ping_services']) : ''; + $newsTemplates = array('default'=>'Default', 'list'=>'List'); //TODO 'category'=>'Categories'? research 'Use non-standard template for news layout' and integrate here. + + $text = " +
"; + + $tab1 = " + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + "; + + $tab2 = "
".NWSLAN_127." + ".$frm->select('news_default_template', $newsTemplates, $pref['news_default_template'])." +
Determines how the default news page should appear.
+
Ping Services + ".$frm->textarea('news_ping_services', $pingVal, 4, 100, $pingOpt)." +
Notify these services when you create/update news items.
One per line.
+
".NWSLAN_86." + ".$frm->radio_switch('news_cats', $pref['news_cats'])." +
".NWSLAN_87." + ".$frm->select('nbr_cols', $this->_optrange(6, false), $pref['nbr_cols'], 'class=tbox')." +
".NWSLAN_88." + ".$frm->select('newsposts', $this->_optrange(50, false), $pref['newsposts'], 'class=tbox')." +
Limit for News-Listing Pages + ".$frm->select('news_list_limit', $this->_optrange(50, false), $pref['news_list_limit'], 'class=tbox')." +
eg. news.php?all or news.php?cat.1 or news.php?tag=xxx
+
".NWSLAN_115." + ".$frm->select('newsposts_archive', $this->_optrange(intval($pref['newsposts']) - 1), intval($pref['newsposts_archive']), 'class=tbox')." +
".NWSLAN_116."
+
".NWSLAN_117." + ".$frm->text('newsposts_archive_title', $pref['newsposts_archive_title'])." +
".LAN_NEWS_51." + ".$frm->uc_select('news_editauthor', vartrue($pref['news_editauthor']), 'nobody,main,admin,classes')." +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
".NWSLAN_106." + ".$frm->uc_select('subnews_class', $pref['subnews_class'], 'nobody,public,guest,member,admin,classes')." +
".NWSLAN_107." + ".$frm->radio_switch('subnews_htmlarea', $pref['subnews_htmlarea'])." +
".NWSLAN_100." + ".$frm->radio_switch('subnews_attach', $pref['subnews_attach'])." +
".NWSLAN_101." + ".$frm->number('subnews_resize', $pref['subnews_resize'], 5, 'size=6&class=tbox')." +
".NWSLAN_102."
+
".NWSLAN_120." + ".$frm->bbarea('news_subheader', stripcslashes(vartrue($pref['news_subheader'])), 2, 'helpb')." +
+ "; + + $tab1 .= " + + ".NWSLAN_111." + +
+ ".$frm->radio_switch('news_newdateheader', $pref['news_newdateheader'])." +
".NWSLAN_112."
+
+ + + + ".NWSLAN_113." + +
+ ".$frm->radio_switch('news_unstemplate', vartrue($pref['news_unstemplate']))." +
".NWSLAN_114."
+
+ + + + + "; + + $text .= $frm->tabs(array( + 'general' => array('caption'=>'General', 'text'=>$tab1), + 'subnews' => array('caption'=>'Submit News', 'text'=>$tab2) + )); + + + $text .= " + +
+ ".$frm->admin_button('save_prefs', LAN_UPDATE, 'update')." +
+ +
+ "; + return e107::getMessage()->render().$text; + // e107::getRender()->tablerender(NWSLAN_90, e107::getMessage()->render().$text); + } @@ -638,46 +1046,34 @@ class news_admin_ui extends e_admin_ui $tp = e107::getParser(); if ($sql->select("submitnews", "*", "submitnews_id=".intval($id))) + { + $row = $sql->fetch(); + $data['news_title'] = $tp->dataFilter($row['submitnews_title']); + $data['news_body'] = $row['submitnews_item']; + $data['news_category'] = intval( $row['submitnews_category']); + $data['news_body'] .= "\n[[b]".NWSLAN_49." {$row['submitnews_name']}[/b]]"; + + if($row['submitnews_file']) { - - //list($id, $submitnews_name, $submitnews_email, $_POST['news_title'], $submitnews_category, $_POST['news_body'], $submitnews_datestamp, $submitnews_ip, $submitnews_auth, $submitnews_file) = $sql->fetch(); - $row = $sql->fetch(); - $_POST['news_title'] = $row['submitnews_title']; - $_POST['news_body'] = $row['submitnews_item']; - $_POST['cat_id'] = $row['submitnews_category']; - - // 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'] .= "
".NWSLAN_49." {$row['submitnews_name']}"; - // $_POST['news_body'] .= ($row['submitnews_file'])? "

": ''; - // } - // else - { - $_POST['news_body'] .= "\n[[b]".NWSLAN_49." {$row['submitnews_name']}[/b]]"; - - if($row['submitnews_file']) + $files = explode(",",$row['submitnews_file']); + foreach($files as $f) { - $files = explode(",",$row['submitnews_file']); - foreach($files as $f) + if($bbpath = e107::getMedia()->importFile($f,'news')) { - if($bbpath = e107::getMedia()->importFile($f,'news')) - { - $_POST['news_body'] .= "\n\n[img]".$bbpath."[/img]"; - } - - } + $data['news_body'] .= "\n\n[img]".$bbpath."[/img]"; + } + } - - - - } - $_POST['data'] = $tp->dataFilter($_POST['data']); // Filter any nasties - $_POST['news_title'] = $tp->dataFilter($_POST['news_title']); } + + foreach($data as $k=>$v) + { + $this->getModel()->setData($k, $v); // Override Table data. + } + } - + + } @@ -732,39 +1128,179 @@ class news_admin_ui extends e_admin_ui class news_form_ui extends e_admin_form_ui { + + + function news_author($curVal, $mode) + { + + $pref = e107::pref('core'); + $sql = e107::getDb(); + $frm = e107::getForm(); + $text = ""; + + if(!getperms('0') && !check_class($pref['news_editauthor'])) + { + $auth = ($curVal) ? intval($curVal) : USERID; + $sql->select("user", "user_name", "user_id={$auth} LIMIT 1"); + $row = $sql->fetch(MYSQL_ASSOC); + $text .= ""; + $text .= "".$row['user_name']).""; + } + else // allow master admin to + { + $text .= $frm->select_open('news_author'); + $qry = "SELECT user_id,user_name FROM #user WHERE user_perms = '0' OR user_perms = '0.' OR user_perms REGEXP('(^|,)(H)(,|$)') "; + 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 + { + $qry .= " OR FIND_IN_SET(".intval($pref['subnews_class']).", user_class) "; + } + } + + // print_a($pref['subnews_class']); + + $sql->gen($qry); + while($row = $sql->fetch()) + { + if(vartrue($curVal)) + { + $sel = ($curVal == $row['user_id']); + } + else + { + $sel = (USERID == $row['user_id']); + } + $text .= $frm->option($row['user_name'], $row['user_id'].chr(35).$row['user_name'], $sel); + } + + $text .= " + "; + } + + return $text; + + } + + + + + + + + function news_body($curVal,$mode) + { + $frm = e107::getForm(); + $tp = e107::getParser(); + + if($mode == 'read') + { + return '...'; + } + + + $curValExt = $this->getController()->getModel()->get('news_extended'); + + + $text = ' +
'; + + + $val = strstr($curVal, "[img]http") ? $curVal : str_replace("[img]../", "[img]", $curVal); + $text .= "
"; + $text .= $frm->bbarea('news_body', $val, 'news', 'news', 'large'); + $text .= "
"; + $text .= "
"; + + $val = (strstr($curValExt, "[img]http") ? $curValExt : str_replace("[img]../", "[img]",$curValExt)); + $text .= $frm->bbarea('news_extended', $val, 'extended', 'news','large'); + + $text .= "
+
"; + + return $text; + + } + + + + + function news_thumbnail($curval,$mode) { - if(!vartrue($curval)) return; - - - if(strpos($curval, ",")!==false) - { - $tmp = explode(",",$curval); - $curval = $tmp[0]; - } - - - - $vparm = array('thumb'=>'tag','w'=> 80); - - if($thumb = e107::getParser()->toVideo($curval,$vparm)) + if($mode == 'read') { - return $thumb; + if(!vartrue($curval)) return; + + if(strpos($curval, ",")!==false) + { + $tmp = explode(",",$curval); + $curval = $tmp[0]; + } + + $vparm = array('thumb'=>'tag','w'=> 80); + + if($thumb = e107::getParser()->toVideo($curval,$vparm)) + { + return $thumb; + } + + if($curval[0] != "{") + { + $curval = "{e_IMAGE}newspost_images/".$curval; + } + + $url = e107::getParser()->thumbUrl($curval,'aw=80'); + $link = e107::getParser()->replaceConstants($curval); + + return "{$curval}"; } - - - if($curval[0] != "{") + + + if($mode == 'write') { - $curval = "{e_IMAGE}newspost_images/".$curval; + $tp = e107::getParser(); + $frm = e107::getForm(); + + // $text .= $frm->imagepicker('news_thumbnail[0]', $curval ,'','media=news&video=1'); + $thumbTmp = explode(",",$curval); + + foreach($thumbTmp as $key=>$path) + { + if(!empty($path) && (strpos($path, ",") == false) && $path[0] != "{" && $tp->isVideo($path) === false )//BC compat + { + $thumbTmp[$key] = "{e_IMAGE}newspost_images/".$path; + } + } + + $text = $frm->imagepicker('news_thumbnail[0]', varset($thumbTmp[0]),'','media=news&video=1'); + $text .= $frm->imagepicker('news_thumbnail[1]', varset($thumbTmp[1]),'','media=news&video=1'); + $text .= $frm->imagepicker('news_thumbnail[2]', varset($thumbTmp[2]),'','media=news&video=1'); + $text .= $frm->imagepicker('news_thumbnail[3]', varset($thumbTmp[3]),'','media=news&video=1'); + $text .= $frm->imagepicker('news_thumbnail[4]', varset($thumbTmp[4]),'','media=news&video=1'); + + return $text; } - - $url = e107::getParser()->thumbUrl($curval,'aw=80'); - $link = e107::getParser()->replaceConstants($curval); - - return "{$curval}"; + + + } - + + + + function news_title($value, $mode) { if($mode == 'read') @@ -780,6 +1316,9 @@ class news_form_ui extends e_admin_form_ui new news_admin(); require_once(e_ADMIN."auth.php"); e107::getAdminUI()->runPage(); + + + if(!e_AJAX_REQUEST) require_once("footer.php"); exit; @@ -792,165 +1331,7 @@ class news_form_ui extends e_admin_form_ui -function headerjs() -{ - return; - $newspost = e107::getRegistry('_newspost_admin'); -/* - $ret .= ""; - -*/ - // TODO - REMOVE - $ret .= " - - "; - - if($newspost->getAction() == 'cat') - { - $ret .= " - - "; - } - elseif ($newspost->getAction() == 'pref') - { - $ret .= " - - "; - } - $ret .= $newspost->_cal->load_files(); - - return $ret; -} $e_sub_cat = 'news'; require_once('auth.php'); @@ -980,6 +1361,7 @@ function fclear() { require_once("footer.php"); exit; +/* class admin_newspost { @@ -1038,18 +1420,8 @@ class admin_newspost ); -/* $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; - }*/ - - // $this->news_renderTypes = array('0'=>NWSLAN_75,'1'=>NWSLAN_76,'2'=>NWSLAN_77,'3'=>NWSLAN_77." 2",'4'=>"Featurebox"); - // $this->news_renderTypes = array('0'=>"FrontPage",'1'=>"FrontPage - Linkonly",'2'=>"Othernews Sidebar",'3'=>"Othernews Sidebar"." 2",'4'=>"Featurebox"); - - } - + }*/ +/* function parseRequest($qry) { $tmp = explode(".", $qry); @@ -1076,12 +1448,12 @@ class admin_newspost function getAction() { return $this->_request[0]; - } + }*/ /** * @param string $action * @return admin_newspost - */ + *//* function setAction($action) { $this->_request[0] = $action; @@ -1091,27 +1463,27 @@ class admin_newspost function getSubAction() { return $this->_request[1]; - } + }*/ /** * @param string $action * @return admin_newspost - */ + *//* function setSubAction($action) { $this->_request[1] = $action; return $this; - } - + }*/ +/* function getId() { return $this->_request[2]; - } + }*/ /** * @param integer $id * @return admin_newspost - */ + *//* function setId($id) { $this->_request[2] = intval($id); @@ -1162,8 +1534,10 @@ class admin_newspost return true; } return false; - } + }*/ + +/* function observer() { e107::getDb()->db_Mark_Time('News Administration'); @@ -1221,8 +1595,8 @@ class admin_newspost { // $this->_observe_saveColumns(); } - } - + }*/ +/* function show_page() { @@ -1266,8 +1640,8 @@ class admin_newspost $this->show_existing_items(); break; } - } - + }*/ +/* function _observe_delete() { $admin_log = e107::getAdminLog(); @@ -1280,6 +1654,7 @@ class admin_newspost $e107 = e107::getInstance(); + switch ($delete) { case 'main': @@ -1345,13 +1720,13 @@ class admin_newspost return true; } - +*/ /** * For future use: multiple-images. - */ + *//* private function processThumbs($postedImage) { if(is_array($postedImage)) @@ -1363,7 +1738,7 @@ class admin_newspost return $postedImage; } - } + }*/ @@ -1371,7 +1746,10 @@ class admin_newspost -// In USE. +// In USE. + /* + + function _observe_submit_item($sub_action, $id) { // ##### Format and submit item to DB @@ -1412,7 +1790,7 @@ class admin_newspost - + */ /* $matches = array(); @@ -1431,7 +1809,7 @@ class admin_newspost } */ - + /* if ($id && $sub_action != "sn" && $sub_action != "upload") { $_POST['news_id'] = $id; @@ -1449,13 +1827,13 @@ class admin_newspost if(!isset($this->news_categories[$_POST['news_category']])) { $this->noPermissions(); - } + }*/ /*if(isset($_POST['news_thumbnail'])) { $_POST['news_thumbnail'] = urldecode(basename($_POST['news_thumbnail'])); }*/ - +/* $_POST['news_render_type'] = implode(",",$_POST['news_render_type']); // print_a($_POST); // exit; @@ -1489,7 +1867,11 @@ class admin_newspost header('Location:'.e_SELF); exit; } - } + }*/ + + +/* + function _observe_create_category() { @@ -1585,6 +1967,10 @@ class admin_newspost } } +*/ + + +/* function _observe_update_category() { if(!getperms('0|7')) @@ -1778,7 +2164,7 @@ class admin_newspost resize_image(e_NEWSIMAGE.$uploaded[$key]['name'], e_NEWSIMAGE.$uploaded[$key]['name'], $_POST['resize_value'], "copy"); } } - } + }*/ /* function _observe_saveColumns() @@ -2075,7 +2461,8 @@ class admin_newspost */ - // In Use. + // In Use. + /* function _pre_create() { @@ -2115,7 +2502,12 @@ class admin_newspost } } } - } + }*/ + + + + +/* function show_create_item() { @@ -2164,7 +2556,7 @@ class admin_newspost $_POST['data'] = $tp->dataFilter($_POST['data']); // Filter any nasties $_POST['news_title'] = $tp->dataFilter($_POST['news_title']); } - } + }*/ /* if ($sub_action == "upload" && !varset($_POST['preview'])) @@ -2181,7 +2573,7 @@ class admin_newspost } } */ - +/* $text .= "