Skip to content

Commit

Permalink
Added settings for manual sorting of category entries
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.ilias.de/svn/ilias/trunk@14849 21b2c9ec-7c21-0410-8b45-9bfb8ed2bfc5
  • Loading branch information
smeyer-ilias committed Sep 25, 2007
1 parent 8a4ce0c commit cfe0808
Show file tree
Hide file tree
Showing 7 changed files with 251 additions and 2 deletions.
48 changes: 48 additions & 0 deletions Modules/Category/classes/class.ilObjCategoryGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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"])
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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
Expand Down
160 changes: 160 additions & 0 deletions Services/Container/classes/class.ilContainerSortingSettings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
<?php
/*
+-----------------------------------------------------------------------------+
| ILIAS open source |
+-----------------------------------------------------------------------------+
| Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
| |
| You should have received a copy of the GNU General Public License |
| along with this program; if not, write to the Free Software |
| Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
+-----------------------------------------------------------------------------+
*/

/**
* @defgroup ServicesContainer Services/Container
*
* @author Stefan Meyer <[email protected]>
* @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;
}
}

}


?>
22 changes: 22 additions & 0 deletions classes/class.ilObjectDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ function getTranslationType($a_obj_name)

return $this->obj_data[$a_obj_name]["translate"];
}


/**
* Does object permits stopping inheritance?
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -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;
}
}

Expand Down
7 changes: 6 additions & 1 deletion lang/ilias_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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
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.
7 changes: 6 additions & 1 deletion lang/ilias_en.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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
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.
2 changes: 2 additions & 0 deletions objects.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@
<action name="link">link</action>
<action name="paste">paste</action>
<action name="clear">clear</action>
<sorting mode="title" />
<sorting mode="manual" />
</object>
<object name="dbk" class_name="DlBook" location="Modules/LearningModule/classes" module="Modules/LearningModule" checkbox="1" inherit="1" translate="0" allow_link="1" rbac="1">
<subobj name="rolf" max="1">rolf</subobj>
Expand Down
7 changes: 7 additions & 0 deletions setup/sql/dbupdate_02.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;

0 comments on commit cfe0808

Please sign in to comment.