From cfe0808ada8239b88c282f542437c85cc2a2ae2a Mon Sep 17 00:00:00 2001 From: Stefan Meyer Date: Tue, 25 Sep 2007 10:42:27 +0000 Subject: [PATCH] Added settings for manual sorting of category entries git-svn-id: http://svn.ilias.de/svn/ilias/trunk@14849 21b2c9ec-7c21-0410-8b45-9bfb8ed2bfc5 --- .../classes/class.ilObjCategoryGUI.php | 48 ++++++ .../class.ilContainerSortingSettings.php | 160 ++++++++++++++++++ classes/class.ilObjectDefinition.php | 22 +++ lang/ilias_de.lang | 7 +- lang/ilias_en.lang | 7 +- objects.xml | 2 + setup/sql/dbupdate_02.php | 7 + 7 files changed, 251 insertions(+), 2 deletions(-) create mode 100644 Services/Container/classes/class.ilContainerSortingSettings.php diff --git a/Modules/Category/classes/class.ilObjCategoryGUI.php b/Modules/Category/classes/class.ilObjCategoryGUI.php index 83b6d8c35d8c..6fe7eb3296fa 100755 --- a/Modules/Category/classes/class.ilObjCategoryGUI.php +++ b/Modules/Category/classes/class.ilObjCategoryGUI.php @@ -218,6 +218,8 @@ function createObject() //add template for buttons $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html"); + $this->showSortingSettings(); + // only in administration // to do: make this in repository work if (false) @@ -426,6 +428,12 @@ function saveObject() $newObj->addTranslation(ilUtil::stripSlashes($val["title"]),ilUtil::stripSlashes($val["desc"]),$val["lang"],$default); } + + include_once('Services/Container/classes/class.ilContainerSortingSettings.php'); + $settings = new ilContainerSortingSettings($newObj->getId()); + $settings->setSortMode((int) $_POST['sorting']); + $settings->save(); + // always send a message ilUtil::sendInfo($this->lng->txt("cat_added"),true); @@ -454,6 +462,7 @@ function editObject() include_once "./Services/MetaData/classes/class.ilMDLanguageItem.php"; $this->getTemplateFile("edit",''); + $this->showSortingSettings(); $array_push = true; if ($_SESSION["error_post_vars"]) @@ -652,6 +661,11 @@ function updateObject() $this->update = $this->object->update(); } + + include_once('Services/Container/classes/class.ilContainerSortingSettings.php'); + $settings = new ilContainerSortingSettings($this->object->getId()); + $settings->setSortMode((int) $_POST['sorting']); + $settings->update(); ilUtil::sendInfo($this->lng->txt("msg_obj_modified"),true); ilUtil::redirect($this->getReturnLocation("update",$this->ctrl->getTargetScript()."?".$this->link_params)); @@ -1471,6 +1485,40 @@ function _goto($a_target) $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL); } + + /** + * show sorting settings + * + * @access protected + */ + protected function showSortingSettings() + { + $this->tpl->setVariable('TXT_SORTING',$this->lng->txt('sorting_header')); + $this->tpl->setVariable('TXT_SORT_TITLE',$this->lng->txt('sorting_title_header')); + $this->tpl->setVariable('INFO_SORT_TITLE',$this->lng->txt('sorting_info_title')); + $this->tpl->setVariable('TXT_SORT_MANUAL',$this->lng->txt('sorting_manual_header')); + $this->tpl->setVariable('INFO_SORT_MANUAL',$this->lng->txt('sorting_info_manual')); + + include_once('Services/Container/classes/class.ilContainerSortingSettings.php'); + if($this->getCreationMode()) + { + $settings = new ilContainerSortingSettings(0); + } + else + { + $settings = new ilContainerSortingSettings($this->object->getId()); + } + + + $this->tpl->setVariable('RADIO_SORT_TITLE',ilUtil::formRadioButton( + $settings->getSortMode() == ilContainerSortingSettings::MODE_TITLE, + 'sorting', + ilContainerSortingSettings::MODE_TITLE)); + $this->tpl->setVariable('RADIO_SORT_MANUAL',ilUtil::formRadioButton( + $settings->getSortMode() == ilContainerSortingSettings::MODE_MANUAL, + 'sorting', + ilContainerSortingSettings::MODE_MANUAL)); + } } // END class.ilObjCategoryGUI diff --git a/Services/Container/classes/class.ilContainerSortingSettings.php b/Services/Container/classes/class.ilContainerSortingSettings.php new file mode 100644 index 000000000000..a6f08c9c1e07 --- /dev/null +++ b/Services/Container/classes/class.ilContainerSortingSettings.php @@ -0,0 +1,160 @@ + +* @version $Id$ +* +* +* @ingroup ServicesContainer +*/ +class ilContainerSortingSettings +{ + const MODE_TITLE = 0; + const MODE_MANUAL = 1; + const MODE_ACTIVATION = 2; + + protected $obj_id; + protected $sort_mode; + + protected $db; + + /** + * Constructor + * + * @access public + * @param + * + */ + public function __construct($a_obj_id) + { + global $ilDB; + + $this->obj_id = $a_obj_id; + $this->db = $ilDB; + + $this->read(); + } + + /** + * lookup sort mode + * + * @access public + * @static + * + * @param int obj_id + */ + public static function _lookupSortMode($a_obj_id) + { + global $ilDB; + + $query = "SELECT * FROM container_sorting_settings ". + "WHERE obj_id = ".$ilDB->quote($a_obj_id)." "; + $res = $ilDB->query($query); + while($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) + { + return $row->sort_mode; + } + return self::MODE_TITLE; + } + + /** + * get sort mode + * + * @access public + * + */ + public function getSortMode() + { + return $this->sort_mode ? $this->sort_mode : 0; + } + + /** + * set sort mode + * + * @access public + * @param int MODE_TITLE | MODE_MANUAL | MODE_ACTIVATION + * + */ + public function setSortMode($a_mode) + { + $this->sort_mode = (int) $a_mode; + } + + /** + * Update + * + * @access public + * + */ + public function update() + { + $query = "REPLACE INTO container_sorting_settings ". + "SET obj_id = ".$this->db->quote($this->obj_id).", ". + "sort_mode = ".$this->db->quote($this->sort_mode)." "; + $this->db->query($query); + } + + /** + * save settings + * + * @access public + * + */ + public function save() + { + $query = "INSERT INTO container_sorting_settings ". + "SET obj_id = ".$this->db->quote($this->obj_id).", ". + "sort_mode = ".$this->db->quote($this->sort_mode)." "; + $this->db->query($query); + } + + /** + * read settings + * + * @access private + * @param + * + */ + private function read() + { + if(!$this->obj_id) + { + return true; + } + + $query = "SELECT * FROM container_sorting_settings ". + "WHERE obj_id = ".$this->db->quote($this->obj_id)." "; + $res = $this->db->query($query); + while($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) + { + $this->sort_mode = $row->sort_mode; + } + } + +} + + +?> \ No newline at end of file diff --git a/classes/class.ilObjectDefinition.php b/classes/class.ilObjectDefinition.php index e5574df652bf..d3c7e8d12daf 100755 --- a/classes/class.ilObjectDefinition.php +++ b/classes/class.ilObjectDefinition.php @@ -158,6 +158,7 @@ function getTranslationType($a_obj_name) return $this->obj_data[$a_obj_name]["translate"]; } + /** * Does object permits stopping inheritance? @@ -322,6 +323,22 @@ function allowCopy($a_obj_name) return (bool) $this->obj_data[$a_obj_name]["allow_copy"]; } + /** + * get content item sorting modes + * + * @access public + * @param + * + */ + public function getContentItemSortingModes($a_obj_name) + { + if(isset($this->obj_data[$a_obj_name]['sorting'])) + { + return $this->obj_data[$a_obj_name]['sorting']['modes'] ? $this->obj_data[$a_obj_name]['sorting']['modes'] : array(); + } + return array(); + } + /** * get all subobjects by type * @@ -646,6 +663,11 @@ function handlerBeginTag($a_xml_parser,$a_name,$a_attribs) $this->current_tag_name = $a_attribs["name"]; $this->obj_data[$this->parent_tag_name]["actions"][$this->current_tag_name]["name"] = $a_attribs["name"]; break; + + case 'sorting': + $this->current_tag = 'sorting'; + $this->obj_data[$this->parent_tag_name]['sorting']['modes'][] = $a_attribs['mode']; + break; } } diff --git a/lang/ilias_de.lang b/lang/ilias_de.lang index d9154c100bfa..44dde32c8a86 100755 --- a/lang/ilias_de.lang +++ b/lang/ilias_de.lang @@ -7608,4 +7608,9 @@ meta#:#md_copyrights_deleted#:#Die ausgewählten Vorgaben wurden entfernt. meta#:#meta_cp_own#:#Eigene Angabe: meta#:#md_adv_desc_show#:#Beschreibung anzeigen meta#:#md_adv_show#:#Anzeigen -common#:#udf_type_date#:#Datumsfeld \ No newline at end of file +common#:#udf_type_date#:#Datumsfeld +common#:#sorting_header#:#Sortierung +common#:#sorting_title_header#:#Nach Titel +common#:#sorting_info_title#:#Wählen Sie diese Einstellung, um die Materialien automatisch nach ihrem Titel zu sortieren. +common#:#sorting_manual_header#:#Manuelle Sortierung +common#:#sorting_info_manual#:#Wenn ausgewählt, können die Materialien manuell in beliebiger Reihenfolge sortiert werden. \ No newline at end of file diff --git a/lang/ilias_en.lang b/lang/ilias_en.lang index d3b7654683b2..468865d4c9c6 100755 --- a/lang/ilias_en.lang +++ b/lang/ilias_en.lang @@ -7648,4 +7648,9 @@ meta#:#md_copyrights_deleted#:#Deleted Copyright meta#:#meta_cp_own#:#Own Copyright Information: meta#:#md_adv_desc_show#:#Show Description meta#:#md_adv_show#:#Show -common#:#udf_type_date#:#Date Field \ No newline at end of file +common#:#udf_type_date#:#Date Field +common#:#sorting_header#:#Content Item Sorting +common#:#sorting_title_header#:#Sort by Title +common#:#sorting_info_title#:#Choose this mode to sort items automatically by title. +common#:#sorting_manual_header#:#Sort Manually +common#:#sorting_info_manual#:#This mode offers you the possibility to sort items manually. \ No newline at end of file diff --git a/objects.xml b/objects.xml index 2f789f686678..093d19fc6c52 100755 --- a/objects.xml +++ b/objects.xml @@ -74,6 +74,8 @@ link paste clear + + rolf diff --git a/setup/sql/dbupdate_02.php b/setup/sql/dbupdate_02.php index f9be4bbb874a..87dfde351f39 100644 --- a/setup/sql/dbupdate_02.php +++ b/setup/sql/dbupdate_02.php @@ -2583,3 +2583,10 @@ <#1090> TRUNCATE TABLE `adv_md_substitutions`; + +<#1091> +CREATE TABLE `container_sorting_settings` ( +`obj_id` INT( 11 ) NOT NULL , +`sort_mode` TINYINT( 1 ) DEFAULT '0' NOT NULL , +PRIMARY KEY ( `obj_id` ) +) TYPE = MYISAM ;