• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

classes/class.ilObjStyleSheetFolderGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2005 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00034 include_once "class.ilObjectGUI.php";
00035 
00036 class ilObjStyleSheetFolderGUI extends ilObjectGUI
00037 {
00042         function ilObjStyleSheetFolderGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output = true)
00043         {
00044                 $this->type = "styf";
00045                 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
00046         }
00047         
00052         function saveObject()
00053         {
00054                 global $rbacadmin;
00055 
00056                 // create and insert forum in objecttree
00057                 $newObj = parent::saveObject();
00058 
00059                 // setup rolefolder & default local roles
00060                 //$roles = $newObj->initDefaultRoles();
00061 
00062                 // ...finally assign role to creator of object
00063                 //$rbacadmin->assignUser($roles[0], $newObj->getOwner(), "y");
00064 
00065                 // put here object specific stuff
00066                         
00067                 // always send a message
00068                 sendInfo($this->lng->txt("object_added"),true);
00069                 
00070                 ilUtil::redirect($this->getReturnLocation("save",$this->ctrl->getLinkTarget($this,"")));
00071         }
00072         
00076         function viewObject()
00077         {
00078                 global $rbacsystem, $ilias;
00079                 
00080                 if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
00081                 {
00082                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00083                 }
00084                 
00085                 include_once "./classes/class.ilTableGUI.php";
00086 
00087                 // load template for table
00088                 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
00089                 
00090                 // load template for table content data
00091                 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.styf_row.html");
00092 
00093                 $num = 0;
00094 
00095                 $this->tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$this->ref_id."$obj_str&cmd=gateway");
00096 
00097                 // create table
00098                 $tbl = new ilTableGUI();
00099 
00100                 // title & header columns
00101                 $tbl->setTitle($this->object->getTitle(),"icon_styf.gif",
00102                         $this->lng->txt("obj_".$this->object->getType()));
00103 
00104                 //$tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
00105 
00106                 // title
00107                 $header_names = array("", $this->lng->txt("title"),
00108                         $this->lng->txt("purpose"));
00109                 $tbl->setHeaderNames($header_names);
00110 
00111                 $header_params = array("ref_id" => $this->ref_id);
00112                 $tbl->setHeaderVars(array("", "title", "purpose"), $header_params);
00113                 $tbl->setColumnWidth(array("0%", "80%", "20%"));
00114 
00115                 // control
00116                 $tbl->setOrderColumn($_GET["sort_by"]);
00117                 $tbl->setOrderDirection($_GET["sort_order"]);
00118                 $tbl->setLimit($_GET["limit"]);
00119                 $tbl->setOffset($_GET["offset"]);
00120                 
00121                 // get style ids
00122                 $style_entries = array();
00123                 $styles = $this->object->getStyles();
00124                 foreach($styles as $style)
00125                 {
00126                         $style_entries[$style["title"].":".$style["id"]]
00127                                 = $style;
00128                 }
00129                 ksort($style_entries);
00130                 
00131                 // todo
00132                 $tbl->setMaxCount(count($style_entries));
00133 
00134                 $this->tpl->setVariable("COLUMN_COUNTS", 3);
00135 
00136                 // footer
00137                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
00138 
00139                 $this->showActions(true);
00140 
00141                 include_once ("classes/class.ilObjStyleSheet.php");
00142                 
00143                 $fixed_style = $ilias->getSetting("fixed_content_style_id");
00144                 $default_style = $ilias->getSetting("default_content_style_id");
00145 
00146                 foreach ($style_entries as $style)
00147                 {
00148                         $this->tpl->setCurrentBlock("style_row");
00149                 
00150                         // color changing
00151                         $css_row = ($css_row == "tblrow2")
00152                                 ? "tblrow1"
00153                                 : "tblrow2";
00154 
00155                         $this->tpl->setVariable("CHECKBOX_ID", $style["id"]);
00156                         $this->tpl->setVariable("TXT_TITLE", $style["title"]);
00157                         $this->tpl->setVariable("TXT_DESC", ilObject::_lookupDescription($style["id"]));
00158                         $this->tpl->setVariable("LINK_STYLE",
00159                                 "adm_object.php?ref_id=".$_GET["ref_id"].
00160                                 "&obj_id=".$style["id"]);
00161                         $this->tpl->setVariable("ROWCOL", $css_row);
00162                         if ($style["id"] == $fixed_style)
00163                         {
00164                                 $this->tpl->setVariable("TXT_PURPOSE", $this->lng->txt("global_fixed"));
00165                         }
00166                         if ($style["id"] == $default_style)
00167                         {
00168                                 $this->tpl->setVariable("TXT_PURPOSE", $this->lng->txt("global_default"));
00169                         }
00170                         $this->tpl->parseCurrentBlock();
00171 
00172                         $this->tpl->setCurrentBlock("tbl_content");
00173                         $this->tpl->parseCurrentBlock();
00174 
00175                 } //if is_array
00176                 
00177                 if (count($style_entries) == 0)
00178                 {
00179             $tbl->disable("header");
00180                         $tbl->disable("footer");
00181                         
00182                         $this->tpl->setCurrentBlock("text");
00183                         $this->tpl->setVariable("TXT_CONTENT", $this->lng->txt("obj_not_found"));
00184                         $this->tpl->parseCurrentBlock();
00185                         
00186                         $this->tpl->setCurrentBlock("tbl_content");
00187                         $this->tpl->parseCurrentBlock();
00188                 }
00189                 
00190                 
00191 
00192                 // render table
00193                 $tbl->render();
00194         }
00195         
00201         function deleteStyleObject($a_error = false)
00202         {
00203                 if (!isset($_POST["id"]))
00204                 {
00205                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00206                 }
00207 
00208                 // SAVE POST VALUES
00209                 $_SESSION["saved_post"] = $_POST["id"];
00210 
00211                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html");
00212 
00213                 if(!$a_error)
00214                 {
00215                         sendInfo($this->lng->txt("info_delete_sure"));
00216                 }
00217 
00218                 $this->tpl->setVariable("FORMACTION", $this->getFormAction("delete",
00219                         "adm_object.php?ref_id=".$_GET["ref_id"]."&cmd=gateway"));
00220 
00221                 // BEGIN TABLE HEADER
00222                 $this->tpl->setCurrentBlock("table_header");
00223                 $this->tpl->setVariable("TEXT", $this->lng->txt("objects"));
00224                 $this->tpl->parseCurrentBlock();
00225                 
00226                 // END TABLE HEADER
00227 
00228                 // BEGIN TABLE DATA
00229                 $counter = 0;
00230 
00231                 foreach ($_POST["id"] as $id)
00232                 {
00233                         $this->tpl->setCurrentBlock("table_row");
00234                         $this->tpl->setVariable("IMG_OBJ",ilUtil::getImagePath("icon_styf.gif"));
00235                         $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
00236                         $this->tpl->setVariable("TEXT_CONTENT",ilObject::_lookupTitle($id));
00237                         $this->tpl->parseCurrentBlock();
00238                 }
00239                 
00240                 // END TABLE DATA
00241 
00242                 // BEGIN OPERATION_BTN
00243                 $buttons = array("confirmedDelete"  => $this->lng->txt("confirm"),
00244                         "cancelDelete"  => $this->lng->txt("cancel"));
00245                 foreach ($buttons as $name => $value)
00246                 {
00247                         $this->tpl->setCurrentBlock("operation_btn");
00248                         $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
00249                         $this->tpl->setVariable("BTN_NAME",$name);
00250                         $this->tpl->setVariable("BTN_VALUE",$value);
00251                         $this->tpl->parseCurrentBlock();
00252                 }
00253         }
00254         
00255         
00259         function confirmedDeleteObject()
00260         {
00261                 global $ilias;
00262                 
00263                 foreach($_SESSION["saved_post"] as $id)
00264                 {
00265                         $this->object->removeStyle($id);
00266                         $style_obj =& $ilias->obj_factory->getInstanceByObjId($id);
00267                         $style_obj->delete();
00268                 }
00269                 $this->object->update();
00270                 
00271                 ilUtil::redirect($this->getReturnLocation("delete",$this->ctrl->getLinkTarget($this,"")));
00272         }
00273         
00274         
00280         function toggleGlobalDefaultObject()
00281         {
00282                 global $ilias;
00283                 
00284                 if (!isset($_POST["id"]))
00285                 {
00286                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00287                 }
00288                 if(count($_POST["id"]) > 1)
00289                 {
00290                         $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
00291                 }
00292 
00293                 $ilias->deleteSetting("fixed_content_style_id");
00294                 $def_style = $ilias->getSetting("default_content_style_id");
00295                 
00296                 if ($def_style != $_POST["id"][0])
00297                 {
00298                         $ilias->setSetting("default_content_style_id", $_POST["id"][0]);
00299                 }
00300                 else
00301                 {
00302                         $ilias->deleteSetting("default_content_style_id");
00303                 }
00304                 
00305                 ilUtil::redirect($this->ctrl->getLinkTarget($this,"view"));
00306         }
00307 
00313         function toggleGlobalFixedObject()
00314         {
00315                 global $ilias;
00316                 
00317                 if (!isset($_POST["id"]))
00318                 {
00319                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00320                 }
00321                 if(count($_POST["id"]) > 1)
00322                 {
00323                         $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
00324                 }
00325 
00326                 $ilias->deleteSetting("default_content_style_id");
00327                 $fixed_style = $ilias->getSetting("fixed_content_style_id");
00328                 if ($fixed_style == $_POST["id"][0])
00329                 {
00330                         $ilias->deleteSetting("fixed_content_style_id");
00331                 }
00332                 else
00333                 {
00334                         $ilias->setSetting("fixed_content_style_id", $_POST["id"][0]);
00335                 }
00336                 ilUtil::redirect($this->ctrl->getLinkTarget($this,"view"));
00337         }
00338 
00339         
00346         function showActions($with_subobjects = false)
00347         {
00348 
00349                 // delete
00350                 $this->tpl->setCurrentBlock("tbl_action_btn");
00351                 $this->tpl->setVariable("BTN_NAME", "deleteStyle");
00352                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
00353                 $this->tpl->parseCurrentBlock();
00354 
00355                 // set global default
00356                 $this->tpl->setCurrentBlock("tbl_action_btn");
00357                 $this->tpl->setVariable("BTN_NAME", "toggleGlobalDefault");
00358                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("toggleGlobalDefault"));
00359                 $this->tpl->parseCurrentBlock();
00360                 
00361                 // set global default
00362                 $this->tpl->setCurrentBlock("tbl_action_btn");
00363                 $this->tpl->setVariable("BTN_NAME", "toggleGlobalFixed");
00364                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("toggleGlobalFixed"));
00365                 $this->tpl->parseCurrentBlock();
00366 
00367                 if ($with_subobjects === true)
00368                 {
00369                         $this->showPossibleSubObjects();
00370                 }
00371                 
00372                 $this->tpl->setCurrentBlock("tbl_action_row");
00373                 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00374                 $this->tpl->parseCurrentBlock();
00375         }
00376 
00377         
00383         function getTabs(&$tabs_gui)
00384         {
00385                 // tabs are defined manually here. The autogeneration via objects.xml will be deprecated in future
00386                 // for usage examples see ilObjGroupGUI or ilObjSystemFolderGUI
00387         }
00388 } // END class.ilObjStyleSheetFolder
00389 ?>

Generated on Fri Dec 13 2013 09:06:34 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1