ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilRatingCategoryGUI Class Reference

Class ilRatingCategoryGUI. More...

+ Collaboration diagram for ilRatingCategoryGUI:

Public Member Functions

 __construct ($a_parent_id, $a_export_callback=null, $a_export_subobj_title=null)
executeCommand ()
 execute command

Protected Member Functions

 listCategories ()
 initCategoryForm ($a_id=null)
 add ($a_form=null)
 save ()
 edit ($a_form=null)
 update ()
 updateOrder ()
 confirmDelete ()
 delete ()
 export ()

Protected Attributes

 $parent_id
 $export_callback
 $export_subobj_title

Detailed Description

Class ilRatingCategoryGUI.

User interface class for rating categories.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 14 of file class.ilRatingCategoryGUI.php.

Constructor & Destructor Documentation

ilRatingCategoryGUI::__construct (   $a_parent_id,
  $a_export_callback = null,
  $a_export_subobj_title = null 
)

Definition at line 20 of file class.ilRatingCategoryGUI.php.

References $_REQUEST, $lng, and $parent_id.

{
global $lng;
$this->parent_id = (int)$a_parent_id;
$this->export_callback = $a_export_callback;
$this->export_subobj_title = $a_export_subobj_title;
$lng->loadLanguageModule("rating");
if($_REQUEST["cat_id"])
{
$cat = new ilRatingCategory($_REQUEST["cat_id"]);
if($cat->getParentId() == $this->parent_id)
{
$this->cat_id = $cat->getId();
}
}
}

Member Function Documentation

ilRatingCategoryGUI::add (   $a_form = null)
protected

Definition at line 116 of file class.ilRatingCategoryGUI.php.

References $tpl, and initCategoryForm().

Referenced by save(), and update().

{
global $tpl;
if(!$a_form)
{
$a_form = $this->initCategoryForm();
}
$tpl->setContent($a_form->getHTML());
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilRatingCategoryGUI::confirmDelete ( )
protected

Definition at line 208 of file class.ilRatingCategoryGUI.php.

References $ilCtrl, $lng, $tpl, and listCategories().

{
global $tpl, $ilCtrl, $lng;
if(!$this->cat_id)
{
return $this->listCategories();
}
include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
$cgui = new ilConfirmationGUI();
$cgui->setHeaderText($lng->txt("rating_category_delete_sure")."<br/>".
$lng->txt("info_delete_warning_no_trash"));
$cgui->setFormAction($ilCtrl->getFormAction($this));
$cgui->setCancel($lng->txt("cancel"), "listCategories");
$cgui->setConfirm($lng->txt("confirm"), "delete");
$cat = new ilRatingCategory($this->cat_id);
$cgui->addItem("cat_id", $this->cat_id, $cat->getTitle());
$tpl->setContent($cgui->getHTML());
}

+ Here is the call graph for this function:

ilRatingCategoryGUI::delete ( )
protected

Definition at line 232 of file class.ilRatingCategoryGUI.php.

References $ilCtrl, $lng, ilRatingCategory\getAllForObject(), and ilUtil\sendSuccess().

{
global $ilCtrl, $lng;
if($this->cat_id)
{
ilRatingCategory::delete($this->cat_id);
ilUtil::sendSuccess($lng->txt("rating_category_deleted"), true);
}
// fix order
$cnt = 0;
foreach(ilRatingCategory::getAllForObject($this->parent_id) as $item)
{
$cnt += 10;
$cat = new ilRatingCategory($item["id"]);
$cat->setPosition($cnt);
$cat->update();
}
$ilCtrl->redirect($this, "listCategories");
}

+ Here is the call graph for this function:

ilRatingCategoryGUI::edit (   $a_form = null)
protected

Definition at line 150 of file class.ilRatingCategoryGUI.php.

References $ilCtrl, $tpl, and initCategoryForm().

{
global $tpl, $ilCtrl;
$ilCtrl->setParameter($this, "cat_id", $this->cat_id);
if(!$a_form)
{
$a_form = $this->initCategoryForm($this->cat_id);
}
$tpl->setContent($a_form->getHTML());
}

+ Here is the call graph for this function:

& ilRatingCategoryGUI::executeCommand ( )

execute command

Definition at line 43 of file class.ilRatingCategoryGUI.php.

References $cmd, and $ilCtrl.

{
global $ilCtrl;
$next_class = $ilCtrl->getNextClass($this);
$cmd = $ilCtrl->getCmd("listCategories");
switch($next_class)
{
default:
return $this->$cmd();
break;
}
}
ilRatingCategoryGUI::export ( )
protected

Definition at line 256 of file class.ilRatingCategoryGUI.php.

References $lng, $row, $title, ilObject\_lookupTitle(), ilObject\_lookupType(), ilRatingCategory\getAllForObject(), and ilRating\getExportData().

{
global $lng;
$title = ilObject::_lookupTitle($this->parent_id);
include_once "./Services/Excel/classes/class.ilExcelUtils.php";
include_once "./Services/Excel/classes/class.ilExcelWriterAdapter.php";
$adapter = new ilExcelWriterAdapter($title.".xls", true);
// restrict to currently active (probably not needed - see delete())
$active = array();
foreach(ilRatingCategory::getAllForObject($this->parent_id) as $item)
{
$active[$item["id"]] = $item["title"];
}
ob_start();
$workbook = $adapter->getWorkbook();
$worksheet = $workbook->addWorksheet();
var_dump();
// title row
$row = 0;
$worksheet->write($row, 0, $this->export_subobj_title." (".$lng->txt("id").")");
$worksheet->write($row, 1, $this->export_subobj_title);
$worksheet->write($row, 2, $lng->txt("rating_export_category")." (".$lng->txt("id").")");
$worksheet->write($row, 3, $lng->txt("rating_export_category"));
$worksheet->write($row, 4, $lng->txt("rating_export_date"));
$worksheet->write($row, 5, $lng->txt("rating_export_rating"));
// content rows
foreach(ilRating::getExportData($this->parent_id, ilObject::_lookupType($this->parent_id), array_keys($active)) as $item)
{
$row++;
$sub_obj_title = $item["sub_obj_type"];
if($this->export_callback)
{
$sub_obj_title = call_user_func($this->export_callback, $item["sub_obj_id"], $item["sub_obj_type"]);
}
$worksheet->write($row, 0, $item["sub_obj_id"]);
$worksheet->write($row, 1, $sub_obj_title);
$worksheet->write($row, 2, $item["category_id"]);
$worksheet->write($row, 3, $active[$item["category_id"]]);
$worksheet->write($row, 4, date("Y-m-d H:i:s", $item["tstamp"]));
$worksheet->write($row, 5, $item["rating"]);
}
ob_end_clean();
$workbook->close();
}

+ Here is the call graph for this function:

ilRatingCategoryGUI::initCategoryForm (   $a_id = null)
protected

Definition at line 76 of file class.ilRatingCategoryGUI.php.

References $ilCtrl, $lng, ilTextAreaInputGUI\setCols(), and ilTextInputGUI\setMaxLength().

Referenced by add(), edit(), save(), and update().

{
global $lng, $ilCtrl;
include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
$form = new ilPropertyFormGUI();
$form->setTarget("_top");
$form->setFormAction($ilCtrl->getFormAction($this, "save"));
$form->setTitle($lng->txt("rating_category_".($a_id ? "edit" : "create")));
// title
$ti = new ilTextInputGUI($lng->txt("title"), "title");
$ti->setMaxLength(128);
$ti->setSize(40);
$ti->setRequired(true);
$form->addItem($ti);
// description
$ta = new ilTextAreaInputGUI($lng->txt("description"), "desc");
$ta->setCols(40);
$ta->setRows(2);
$form->addItem($ta);
if(!$a_id)
{
$form->addCommandButton("save", $lng->txt("rating_category_add"));
}
else
{
$cat = new ilRatingCategory($a_id);
$ti->setValue($cat->getTitle());
$ta->setValue($cat->getDescription());
$form->addCommandButton("update", $lng->txt("rating_category_update"));
}
$form->addCommandButton("listCategories", $lng->txt("cancel"));
return $form;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilRatingCategoryGUI::listCategories ( )
protected

Definition at line 58 of file class.ilRatingCategoryGUI.php.

References $ilCtrl, $lng, and $tpl.

Referenced by confirmDelete().

{
global $tpl, $ilToolbar, $lng, $ilCtrl;
$ilToolbar->addButton($lng->txt("rating_add_category"),
$ilCtrl->getLinkTarget($this, "add"));
$ilToolbar->addSeparator();
$ilToolbar->addButton($lng->txt("export"),
$ilCtrl->getLinkTarget($this, "export"));
include_once "Services/Rating/classes/class.ilRatingCategoryTableGUI.php";
$table = new ilRatingCategoryTableGUI($this, "listCategories", $this->parent_id);
$tpl->setContent($table->getHTML());
}

+ Here is the caller graph for this function:

ilRatingCategoryGUI::save ( )
protected

Definition at line 128 of file class.ilRatingCategoryGUI.php.

References $ilCtrl, $lng, add(), initCategoryForm(), and ilUtil\sendSuccess().

{
global $ilCtrl, $lng;
$form = $this->initCategoryForm("create");
if($form->checkInput())
{
include_once "Services/Rating/classes/class.ilRatingCategory.php";
$cat = new ilRatingCategory();
$cat->setParentId($this->parent_id);
$cat->setTitle($form->getInput("title"));
$cat->setDescription($form->getInput("desc"));
$cat->save();
ilUtil::sendSuccess($lng->txt("rating_category_created"));
$ilCtrl->redirect($this, "listCategories");
}
$form->setValuesByPost();
$this->add($form);
}

+ Here is the call graph for this function:

ilRatingCategoryGUI::update ( )
protected

Definition at line 164 of file class.ilRatingCategoryGUI.php.

References $ilCtrl, $lng, add(), initCategoryForm(), and ilUtil\sendSuccess().

{
global $ilCtrl, $lng;
$form = $this->initCategoryForm($this->cat_id);
if($form->checkInput())
{
include_once "Services/Rating/classes/class.ilRatingCategory.php";
$cat = new ilRatingCategory($this->cat_id);
$cat->setTitle($form->getInput("title"));
$cat->setDescription($form->getInput("desc"));
$cat->update();
ilUtil::sendSuccess($lng->txt("rating_category_updated"));
$ilCtrl->redirect($this, "listCategories");
}
$form->setValuesByPost();
$this->add($form);
}

+ Here is the call graph for this function:

ilRatingCategoryGUI::updateOrder ( )
protected

Definition at line 185 of file class.ilRatingCategoryGUI.php.

References $_POST, $ilCtrl, $lng, $parent_id, and ilUtil\sendSuccess().

{
global $ilCtrl, $lng;
$order = $_POST["pos"];
asort($order);
$cnt = 0;
foreach($order as $id => $pos)
{
$cat = new ilRatingCategory($id);
if($cat->getParentId() == $this->parent_id)
{
$cnt += 10;
$cat->setPosition($cnt);
$cat->update();
}
}
ilUtil::sendSuccess($lng->txt("settings_saved"), true);
$ilCtrl->redirect($this, "listCategories");
}

+ Here is the call graph for this function:

Field Documentation

ilRatingCategoryGUI::$export_callback
protected

Definition at line 17 of file class.ilRatingCategoryGUI.php.

ilRatingCategoryGUI::$export_subobj_title
protected

Definition at line 18 of file class.ilRatingCategoryGUI.php.

ilRatingCategoryGUI::$parent_id
protected

Definition at line 16 of file class.ilRatingCategoryGUI.php.

Referenced by __construct(), and updateOrder().


The documentation for this class was generated from the following file: