From c82fc9269c2dba90fe30262bbebcc9d799871102 Mon Sep 17 00:00:00 2001 From: CaMer0n Date: Tue, 20 Oct 2009 07:39:40 +0000 Subject: [PATCH] Cleaned up the search in admin -> newspost . Added batch options. Made batch form element more flexible. --- e107_admin/newspost.php | 146 ++++++++++++++++++++++++++------- e107_handlers/form_handler.php | 52 +++++++----- 2 files changed, 151 insertions(+), 47 deletions(-) diff --git a/e107_admin/newspost.php b/e107_admin/newspost.php index e1747fe89..831b150da 100644 --- a/e107_admin/newspost.php +++ b/e107_admin/newspost.php @@ -9,9 +9,9 @@ * News Administration * * $Source: /cvs_backup/e107_0.8/e107_admin/newspost.php,v $ - * $Revision: 1.57 $ - * $Date: 2009-10-09 15:06:44 $ - * $Author: secretr $ + * $Revision: 1.58 $ + * $Date: 2009-10-20 07:39:40 $ + * $Author: e107coders $ */ require_once("../class2.php"); @@ -241,6 +241,8 @@ class admin_newspost var $_sort_order; var $_sort_link; var $fieldpref; + var $news_categories; + var $news_renderTypes = array(); public $error = false; @@ -274,6 +276,15 @@ class admin_newspost 'options' => array('title' => LAN_OPTIONS, 'width' => '10%', 'width' => null, 'thclass' => 'center last', 'class' => null, 'url' => '', 'forced' => TRUE) ); + +/* $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(NWSLAN_75,NWSLAN_76,NWSLAN_77,NWSLAN_77." 2"); } @@ -404,6 +415,10 @@ class admin_newspost { $this->_observe_delete(); } + elseif(isset($_POST['execute_batch'])) + { + $this->process_batch($_POST['news_selected']); + } elseif(isset($_POST['submit_news'])) { $this->_observe_submit_item($this->getSubAction(), $this->getId()); @@ -432,7 +447,8 @@ class admin_newspost { $this->_observe_newsCommentsRecalc(); } - elseif(isset($_POST['submit-e-columns'])) + + if(isset($_POST['submit-e-columns'])) //elseif fails. { $this->_observe_saveColumns(); } @@ -1014,33 +1030,23 @@ class admin_newspost $news_category[$val['category_id']] = $val['category_name']; } + $this->news_categories = $news_category; // ------ Search Filter ------ $text .= "
-
- - - - - - - -
". - $frm->admin_button('dupfield', "Add Filter", 'action', '', array('other' => 'onclick="duplicateHTML(\'filterline\',\'srch_container\');"')) - ." -
".$frm->filterType($field_columns)."".$frm->filterValue()."
-
". - $frm->admin_button('searchsubmit', NWSLAN_63, 'search')." -
+
+ "; + $text .= $frm->admin_button('searchsubmit', NWSLAN_63, 'search'); + $text .= "
"; // -------------------------------------------- - if (varsettrue($_POST['searchquery'])) + if (vartrue($_POST['searchquery'])) { $query = "news_title REGEXP('".$_POST['searchquery']."') OR news_body REGEXP('".$_POST['searchquery']."') OR news_extended REGEXP('".$_POST['searchquery']."') ORDER BY news_datestamp DESC"; } @@ -1101,16 +1107,21 @@ class admin_newspost $text .= " - + "; + $text .= "
".$this->show_batch_options()."
"; + $text .= " "; + } else { $text .= "
".isset($_POST['searchquery']) ? sprintf(NWSLAN_121, '"'.$_POST['searchquery'])."" « ".LAN_BACK."" : NWSLAN_43."
"; } + + $newsposts = $e107->sql->db_Count('news'); if (!varset($_POST['searchquery'])) @@ -1125,6 +1136,90 @@ class admin_newspost $e107->ns->tablerender(NWSLAN_4, $emessage->render().$text); } + function show_batch_options() + { + $e107 = e107::getInstance(); + $classObj = $e107->getUserClass(); + $frm = new e_form(); + $classes = $classObj->uc_get_classlist(); + +/* + $assignClasses = array(); // Userclass list of userclasses that can be assigned + foreach ($classes as $key => $val) + { + if ($classObj->isEditableClass($key)) + { + $assignClasses[$key] = $classes[$key]; + } + } + unset($assignClasses[0]); + + $removeClasses = $assignClasses; // Userclass list of userclasses that can be removed + $removeClasses[0] = array('userclass_name'=>array('userclass_id'=>0, 'userclass_name'=>USRLAN_220)); +*/ + + $comments_array = array("Disable Comments","Allow Comments"); + + + return $frm->batchoptions( + array( + 'delete_selected' => LAN_DELETE, + 'category' => array('Modify Category', $this->news_categories), + 'rendertype' => array('Modify Render-type', $this->news_renderTypes), + 'comments' => array('Modify Comments', $comments_array) + ), + array( + 'userclass' => array('Assign Visibility...',$classes), + ) + ); + } + + function batch_category($ids,$value) + { + $sql = e107::getDb(); + $count = $sql->db_Update("news","news_category = ".$value." WHERE news_id IN (".implode(",",$ids).") "); + } + + function batch_comments($ids,$value) + { + $sql = e107::getDb(); + $count = $sql->db_Update("news","news_allow_comments = ".$value." WHERE news_id IN (".implode(",",$ids).") "); + } + + function batch_rendertype($ids,$value) + { + $sql = e107::getDb(); + $count = $sql->db_Update("news","news_render_type = ".$value." WHERE news_id IN (".implode(",",$ids).") "); + } + + function batch_userclass($ids,$value) + { + $sql = e107::getDb(); + $count = $sql->db_Update("news","news_class = ".$value." WHERE news_id IN (".implode(",",$ids).") "); + } + + function batch_delete($ids,$value) + { + $sql = e107::getDb(); + $count = $sql->db_Delete("news","news_id IN (".implode(",",$ids).") "); + } + + + + + function process_batch($id_array) + { + list($type,$tmp,$value) = explode("_",$_POST['execute_batch']); + $method = "batch_".$type; + + if (method_exists($this,$method) && isset($id_array) ) + { + $this->$method($id_array,$value); + } + } + + + function _pre_create() { @@ -1525,15 +1620,10 @@ class admin_newspost "; - $ren_type = array(NWSLAN_75,NWSLAN_76,NWSLAN_77,NWSLAN_77." 2"); - $r_array = array(); - foreach($ren_type as $key=>$value) { - $r_array[$key] = $value; - } - + $text .= " - ".$frm->radio_multi('news_rendertype', $r_array, $_POST['news_rendertype'], true)." + ".$frm->radio_multi('news_rendertype', $this->news_renderTypes, $_POST['news_rendertype'], true)."
".NWSLAN_74."
diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index ff48e04b3..01dd463c3 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -9,9 +9,9 @@ * Form Handler * * $Source: /cvs_backup/e107_0.8/e107_handlers/form_handler.php,v $ - * $Revision: 1.47 $ - * $Date: 2009-10-09 15:06:44 $ - * $Author: secretr $ + * $Revision: 1.48 $ + * $Date: 2009-10-20 07:39:40 $ + * $Author: e107coders $ * */ @@ -247,8 +247,8 @@ class e_form if($classnum == e_UC_BLANK) return ''; - $tmp = explode(',', $current_value); - + $tmp = explode(',', $current_value); //TODO add support for when $current_value is an array. + $class = $style = ''; if($nest_level == 0) { @@ -835,26 +835,40 @@ class e_form