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

classes/class.ilObjStyleSettingsGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2006 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 
00035 include_once "class.ilObjectGUI.php";
00036 
00037 class ilObjStyleSettingsGUI extends ilObjectGUI
00038 {
00043         function ilObjStyleSettingsGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output = true)
00044         {
00045                 global $lng;
00046                 
00047                 $this->type = "stys";
00048                 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
00049                 
00050                 $lng->loadLanguageModule("style");
00051         }
00052         
00053         function &executeCommand()
00054         {
00055                 $next_class = $this->ctrl->getNextClass($this);
00056                 $cmd = $this->ctrl->getCmd();
00057                 $this->prepareOutput();
00058 
00059 //echo "-$next_class-$cmd-"; exit;
00060                 
00061                 switch($next_class)
00062                 {
00063                         case 'ilpermissiongui':
00064                                 include_once("./classes/class.ilPermissionGUI.php");
00065                                 $perm_gui =& new ilPermissionGUI($this);
00066                                 $ret =& $this->ctrl->forwardCommand($perm_gui);
00067                                 break;
00068 
00069                         default:
00070                                 if ($cmd == "" || $cmd == "view")
00071                                 {
00072                                         $cmd = "editBasicSettings";
00073                                 }
00074                                 $cmd .= "Object";
00075                                 $this->$cmd();
00076 
00077                                 break;
00078                 }
00079                 return true;
00080         }
00081         
00086         function saveObject()
00087         {
00088                 global $rbacadmin;
00089 
00090                 // create and insert forum in objecttree
00091                 $newObj = parent::saveObject();
00092 
00093                 // setup rolefolder & default local roles
00094                 //$roles = $newObj->initDefaultRoles();
00095 
00096                 // ...finally assign role to creator of object
00097                 //$rbacadmin->assignUser($roles[0], $newObj->getOwner(), "y");
00098 
00099                 // put here object specific stuff
00100                         
00101                 // always send a message
00102                 ilUtil::sendInfo($this->lng->txt("object_added"),true);
00103                 
00104                 ilUtil::redirect($this->getReturnLocation("save",$this->ctrl->getLinkTarget($this,"")));
00105         }
00106         
00110         function editBasicSettingsObject()
00111         {
00112                 global $rbacsystem;
00113 
00114                 if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
00115                 {
00116                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00117                 }
00118                 
00119                 $this->tpl->addBlockfile("ADM_CONTENT", "style_basic_settings", "tpl.stys_basic_settings.html");
00120                 $this->tpl->setCurrentBlock("style_settings");
00121 
00122                 $settings = $this->ilias->getAllSettings();
00123 
00124                 $this->tpl->setVariable("FORMACTION_STYLESETTINGS", $this->ctrl->getFormAction($this));
00125 
00126                 $this->tpl->setVariable("TXT_TREE_FRAME", $this->lng->txt("tree_frame"));
00127                 $this->tpl->setVariable("TXT_TREE_FRAME_INFO", $this->lng->txt("tree_frame_info"));
00128                 $this->tpl->setVariable("TXT_FRAME_LEFT", $this->lng->txt("tree_left"));
00129                 $this->tpl->setVariable("TXT_FRAME_RIGHT", $this->lng->txt("tree_right"));
00130 
00131                 $this->tpl->setVariable("TXT_STYLE_SETTINGS", $this->lng->txt("basic_settings"));
00132                 $this->tpl->setVariable("TXT_ICONS_IN_TYPED_LISTS", $this->lng->txt("icons_in_typed_lists"));
00133                 $this->tpl->setVariable("TXT_ICONS_IN_HEADER", $this->lng->txt("icons_in_header"));
00134                 $this->tpl->setVariable("TXT_ICONS_IN_ITEM_ROWS", $this->lng->txt("icons_in_item_rows"));
00135                 $this->tpl->setVariable("TXT_ICONS_IN_TYPED_LISTS_INFO", $this->lng->txt("icons_in_typed_lists_info"));
00136                 
00137                 $this->tpl->setVariable("TXT_ENABLE_CUSTOM_ICONS", $this->lng->txt("enable_custom_icons"));
00138                 $this->tpl->setVariable("TXT_ENABLE_CUSTOM_ICONS_INFO", $this->lng->txt("enable_custom_icons_info"));
00139                 $this->tpl->setVariable("TXT_CUSTOM_ICON_SIZE_BIG", $this->lng->txt("custom_icon_size_big"));
00140                 $this->tpl->setVariable("TXT_CUSTOM_ICON_SIZE_SMALL", $this->lng->txt("custom_icon_size_standard"));
00141                 $this->tpl->setVariable("TXT_CUSTOM_ICON_SIZE_TINY", $this->lng->txt("custom_icon_size_tiny"));
00142                 $this->tpl->setVariable("TXT_WIDTH_X_HEIGHT", $this->lng->txt("width_x_height"));
00143                 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
00144                 
00145                 // set current values
00146                 if ($settings["tree_frame"] == "right")
00147                 {
00148                         $this->tpl->setVariable("SEL_FRAME_RIGHT","selected=\"selected\"");
00149                 }
00150                 else
00151                 {
00152                         $this->tpl->setVariable("SEL_FRAME_LEFT","selected=\"selected\"");
00153                 }
00154                 
00155                 if ($settings["custom_icons"])
00156                 {
00157                         $this->tpl->setVariable("CHK_CUSTOM_ICONS","checked=\"checked\"");
00158                 }
00159                 if ($settings["icon_position_in_lists"] == "item_rows")
00160                 {
00161                         $this->tpl->setVariable("SEL_ICON_POS_ITEM_ROWS","selected=\"selected\"");
00162                 }
00163                 else
00164                 {
00165                         $this->tpl->setVariable("SEL_ICON_POS_HEADER","selected=\"selected\"");
00166                 }
00167                 $this->tpl->setVariable("CUST_ICON_BIG_WIDTH", $settings["custom_icon_big_width"]);
00168                 $this->tpl->setVariable("CUST_ICON_BIG_HEIGHT", $settings["custom_icon_big_height"]);
00169                 $this->tpl->setVariable("CUST_ICON_SMALL_WIDTH", $settings["custom_icon_small_width"]);
00170                 $this->tpl->setVariable("CUST_ICON_SMALL_HEIGHT", $settings["custom_icon_small_height"]);
00171                 $this->tpl->setVariable("CUST_ICON_TINY_WIDTH", $settings["custom_icon_tiny_width"]);
00172                 $this->tpl->setVariable("CUST_ICON_TINY_HEIGHT", $settings["custom_icon_tiny_height"]);
00173 
00174                 $this->tpl->parseCurrentBlock();
00175         }
00176         
00180         function saveBasicStyleSettingsObject()
00181         {
00182                 $this->ilias->setSetting("tree_frame", $_POST["tree_frame"]);
00183                 $this->ilias->setSetting("icon_position_in_lists", $_POST["icon_position_in_lists"]);
00184                 $this->ilias->setSetting("custom_icons", $_POST["custom_icons"]);
00185                 $this->ilias->setSetting("custom_icon_big_width", (int) $_POST["custom_icon_big_width"]);
00186                 $this->ilias->setSetting("custom_icon_big_height", (int) $_POST["custom_icon_big_height"]);
00187                 $this->ilias->setSetting("custom_icon_small_width", (int) $_POST["custom_icon_small_width"]);
00188                 $this->ilias->setSetting("custom_icon_small_height", (int) $_POST["custom_icon_small_height"]);
00189                 $this->ilias->setSetting("custom_icon_tiny_width", (int) $_POST["custom_icon_tiny_width"]);
00190                 $this->ilias->setSetting("custom_icon_tiny_height", (int) $_POST["custom_icon_tiny_height"]);
00191                 ilUtil::sendInfo($this->lng->txt("msg_obj_modified"), true);
00192                 ilUtil::redirect($this->ctrl->getLinkTarget($this,"editBasicSettings"));                
00193         }
00194         
00198         function editContentStylesObject()
00199         {
00200                 global $rbacsystem, $ilias;
00201                 
00202                 if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
00203                 {
00204                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00205                 }
00206                 
00207                 include_once "./Services/Table/classes/class.ilTableGUI.php";
00208 
00209                 // load template content style settings
00210                 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.styf_content_styles.html");
00211 
00212                 // load template for table
00213                 $this->tpl->addBlockfile("STYLE_TABLE", "style_table", "tpl.table.html");
00214                 
00215                 // load template for table content data
00216                 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.styf_row.html");
00217 
00218                 $num = 0;
00219 
00220                 $this->tpl->setVariable("FORMACTION",
00221                         $this->ctrl->getFormAction($this));
00222 
00223                 // create table
00224                 $tbl = new ilTableGUI();
00225 
00226                 // title & header columns
00227                 $tbl->setTitle($this->lng->txt("content_styles"),"icon_sty.gif",
00228                         $this->lng->txt("content_styles"));
00229 
00230                 //$tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
00231 
00232                 // title
00233                 $header_names = array("", $this->lng->txt("title"),
00234                         $this->lng->txt("sty_nr_learning_modules"),
00235                         $this->lng->txt("purpose"), $this->lng->txt("sty_scope"),
00236                         $this->lng->txt("active"));
00237                 $tbl->setHeaderNames($header_names);
00238 
00239                 $header_params = array("ref_id" => $this->ref_id);
00240                 $tbl->setHeaderVars(array("", "title", "nr_lms", "purpose", "scope", "active"), $header_params);
00241                 $tbl->setColumnWidth(array("1px", "", "", "", ""));
00242 
00243                 // control
00244                 $tbl->setOrderColumn($_GET["sort_by"]);
00245                 $tbl->setOrderDirection($_GET["sort_order"]);
00246                 $tbl->setLimit($_GET["limit"]);
00247                 $tbl->setOffset($_GET["offset"]);
00248                 $tbl->disable("sort");
00249                 
00250                 // get style ids
00251                 $style_entries = array();
00252                 $styles = $this->object->getStyles();
00253                 foreach($styles as $style)
00254                 {
00255                         $style_entries[$style["title"].":".$style["id"]]
00256                                 = $style;
00257                 }
00258                 ksort($style_entries);
00259                 $from_styles = $to_styles = array();
00260                 // this may not be cool, if styles are organised as (independent) Service
00261                 include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
00262 
00263                 // number of individual styles
00264                 if ($fixed_style <= 0)
00265                 {
00266                         $style_entries[-1] = 
00267                                 array("title" => $this->lng->txt("sty_individual_styles"),
00268                                         "id" => 0, "nr" => ilObjContentObject::_getNrLMsIndividualStyles());
00269                         $from_styles[-1] = $this->lng->txt("sty_individual_styles");
00270                 }
00271                 
00272                 // number of default style (fallback default style)
00273                 if ($default_style <= 0 && $fixed_style <= 0)
00274                 {
00275                         $style_entries[0] = 
00276                                 array("title" => $this->lng->txt("sty_default_style"),
00277                                         "id" => 0, "nr" => ilObjContentObject::_getNrLMsNoStyle());
00278                         $from_styles[0] = $this->lng->txt("sty_default_style");
00279                         $to_styles[0] = $this->lng->txt("sty_default_style");
00280                 }
00281                 
00282                 // todo
00283                 $tbl->setMaxCount(count($style_entries));
00284 
00285                 $this->tpl->setVariable("COLUMN_COUNTS", 6);
00286 
00287                 // footer
00288                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
00289 
00290                 $this->showActions(true);
00291                 $table_empty = true;
00292 
00293                 include_once ("classes/class.ilObjStyleSheet.php");
00294                 
00295                 $fixed_style = $ilias->getSetting("fixed_content_style_id");
00296                 $default_style = $ilias->getSetting("default_content_style_id");
00297                 
00298                 foreach ($style_entries as $style)
00299                 {
00300                         // color changing
00301                         $css_row = ($css_row == "tblrow2")
00302                                 ? "tblrow1"
00303                                 : "tblrow2";
00304 
00305                         // command checkbox
00306                         if ($style["id"] > 0)
00307                         {
00308                                 $this->tpl->setCurrentBlock("check_box");
00309                                 $this->tpl->setVariable("CHECKBOX_ID", $style["id"]);
00310                                 $this->tpl->parseCurrentBlock();
00311                         }
00312                         
00313                         // activation checkbox
00314                         if ($fixed_style <= 0 && $style["id"] > 0)
00315                         {
00316                                 $this->tpl->setCurrentBlock("active_box");
00317                                 if (ilObjStyleSheet::_lookupActive($style["id"]))
00318                                 {
00319                                         $this->tpl->setVariable("CHECKED_STY", 'checked="checked"');
00320                                 }
00321                                 $this->tpl->setVariable("ACTIVE_ID", $style["id"]);
00322                                 $this->tpl->parseCurrentBlock();
00323                         }
00324                         
00325                         // link to style edit screen
00326                         if ($style["id"] > 0)
00327                         {
00328                                 $this->ctrl->setParameterByClass("ilobjstylesheetgui", "obj_id", $style["id"]);
00329                                 $this->tpl->setCurrentBlock("linka");
00330                                 $this->tpl->setVariable("TXT_TITLE", $style["title"]);
00331                                 $this->tpl->setVariable("LINK_STYLE",
00332                                         $this->ctrl->getLinkTargetByClass("ilobjstylesheetgui"), "view");
00333                                 $this->tpl->parseCurrentBlock();
00334                         }
00335                         else
00336                         {
00337                                 $this->tpl->setCurrentBlock("texta");
00338                                 $this->tpl->setVariable("TXT_TEXT", $style["title"]);
00339                                 $this->tpl->parseCurrentBlock();
00340                         }
00341                         
00342                         $this->tpl->setCurrentBlock("style_row");
00343 
00344                         // number of assigned lms
00345                         if ($style["id"] > 0)
00346                         {
00347                                 $nr_lm = ilObjContentObject::_getNrOfAssignedLMs($style["id"]);
00348                                 
00349                                 // fill from/to array
00350                                 if ($nr_lm > 0)
00351                                 {
00352                                         $from_styles[$style["id"]] = $style["title"];
00353                                 }
00354                                 if (ilObjStyleSheet::_lookupActive($style["id"]))
00355                                 {
00356                                         $to_styles[$style["id"]] = $style["title"];
00357                                 }
00358                                 
00359                                 $this->tpl->setVariable("TXT_NR_LEARNING_MODULES", $nr_lm);
00360                                 $this->tpl->setVariable("TXT_DESC", ilObject::_lookupDescription($style["id"]));
00361                         }
00362                         else
00363                         {
00364                                 $this->tpl->setVariable("TXT_NR_LEARNING_MODULES", $style["nr"]);
00365                         }
00366  
00367                         $this->tpl->setVariable("ROWCOL", $css_row);
00368                         
00369                         // purpose and scope
00370                         if ($style["id"] > 0)
00371                         {
00372                                 if ($style["id"] == $fixed_style)
00373                                 {
00374                                         $this->tpl->setVariable("TXT_PURPOSE", $this->lng->txt("global_fixed"));
00375                                 }
00376                                 if ($style["id"] == $default_style)
00377                                 {
00378                                         $this->tpl->setVariable("TXT_PURPOSE", $this->lng->txt("global_default"));
00379                                 }
00380                                 if ($style["category"] > 0)
00381                                 {
00382                                         $this->tpl->setVariable("TXT_SCOPE",
00383                                                 ilObject::_lookupTitle(
00384                                                 ilObject::_lookupObjId($style["category"])
00385                                                 ));
00386                                 }
00387                         }
00388                         $this->tpl->parseCurrentBlock();
00389 
00390                         $this->tpl->setCurrentBlock("tbl_content");
00391                         $this->tpl->parseCurrentBlock();
00392 
00393                 } //if is_array
00394 
00395                 if (count($style_entries) == 0)
00396                 {
00397             $tbl->disable("header");
00398                         $tbl->disable("footer");
00399                         
00400                         $this->tpl->setCurrentBlock("text");
00401                         $this->tpl->setVariable("TXT_CONTENT", $this->lng->txt("obj_not_found"));
00402                         $this->tpl->parseCurrentBlock();
00403                         
00404                         $this->tpl->setCurrentBlock("tbl_content");
00405                         $this->tpl->parseCurrentBlock();
00406                 }
00407 
00408                 // render table
00409                 $tbl->render();
00410                 
00411                 
00412                 // move form
00413                 $this->tpl->setCurrentBlock("adm_content");
00414                 $this->tpl->setVariable("TXT_MOVE_LM_STYLE", $this->lng->txt("sty_move_lm_styles"));
00415                 $this->tpl->setVariable("TXT_FROM", $this->lng->txt("from"));
00416                 $this->tpl->setVariable("TXT_TO", $this->lng->txt("to"));
00417                 $this->tpl->setVariable("TXT_MOVE_LM_STYLE", $this->lng->txt("sty_move_lm_styles"));
00418                 $this->tpl->setVariable("TXT_MOVE_STYLE", $this->lng->txt("sty_move_style"));
00419                 $this->tpl->setVariable("SELECT_FROM",
00420                         ilUtil::formSelect("", "from_style", $from_styles, false, true));
00421                 $this->tpl->setVariable("SELECT_TO",
00422                         ilUtil::formSelect("", "to_style", $to_styles, false, true));
00423                 $this->tpl->setVariable("FORMACTION2", $this->ctrl->getFormAction($this));
00424                 $this->tpl->parseCurrentBlock();
00425         }
00426         
00430         function moveLMStylesObject()
00431         {
00432                 if ($_POST["from_style"] == -1)
00433                 {
00434                         $this->confirmDeleteIndividualStyles();
00435                         return;
00436                 }
00437                 
00438                 include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
00439                 ilObjContentObject::_moveLMStyles($_POST["from_style"], $_POST["to_style"]);
00440                 $this->ctrl->redirect($this, "editContentStyles");
00441         }
00442         
00443         
00447         function moveIndividualStylesObject()
00448         {
00449                 include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
00450                 ilObjContentObject::_moveLMStyles(-1, $_GET["to_style"]);
00451                 $this->ctrl->redirect($this, "editContentStyles");
00452         }
00453         
00454         
00458         function confirmDeleteIndividualStyles()
00459         {
00460                 // load template content style settings
00461                 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.confirm.html");
00462                 $this->tpl->setVariable("CMD_OK", "moveIndividualStyles");
00463                 $this->tpl->setVariable("TXT_OK", $this->lng->txt("ok"));
00464                 $this->tpl->setVariable("CMD_CANCEL", "editContentStyles");
00465                 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00466                 $this->tpl->setVariable("TXT_CONFIRM", $this->lng->txt("sty_confirm_del_ind_styles"));
00467                 $this->tpl->setVariable("TXT_CONTENT",
00468                         sprintf($this->lng->txt("sty_confirm_del_ind_styles_desc"),
00469                         ilObject::_lookupTitle($_POST["to_style"])));
00470                 $this->ctrl->setParameter($this, "to_style", $_POST["to_style"]);
00471                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormaction($this));
00472                 $this->tpl->parseCurrentBlock();
00473         }
00474         
00475         
00479         function editSystemStylesObject()
00480         {
00481                 global $rbacsystem, $ilias, $styleDefinition;;
00482                 
00483                 if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
00484                 {
00485                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00486                 }
00487                 
00488                 $this->tpl->addBlockfile("ADM_CONTENT", "style_settings", "tpl.stys_settings.html");
00489                 $this->tpl->setCurrentBlock("style_settings");
00490 
00491                 $settings = $this->ilias->getAllSettings();
00492 
00493                 $this->tpl->setVariable("FORMACTION_STYLESETTINGS", $this->ctrl->getFormAction($this));         
00494                 $this->tpl->setVariable("TXT_STYLE_SETTINGS", $this->lng->txt("system_style_settings"));
00495                 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
00496                 $this->tpl->setVariable("TXT_DEFAULT_SKIN_STYLE", $this->lng->txt("default_skin_style"));
00497                 $this->tpl->setVariable("TXT_SKIN_STYLE_ACTIVATION", $this->lng->txt("style_activation"));
00498                 $this->tpl->setVariable("TXT_NUMBER_OF_USERS", $this->lng->txt("num_users"));
00499                 $this->tpl->setVariable("TXT_MOVE_USERS_TO_STYLE", $this->lng->txt("move_users_to_style"));
00500                 
00501                 // get all templates
00502                 $templates = $styleDefinition->getAllTemplates();
00503 
00504                 $all_styles = array();
00505                 
00506                 foreach ($templates as $template)
00507                 {
00508                         // get styles definition for template
00509                         $styleDef =& new ilStyleDefinition($template["id"]);
00510                         $styleDef->startParsing();
00511                         $styles = $styleDef->getStyles();
00512 
00513                         foreach ($styles as $style)
00514                         {
00515                                 if ($this->ilias->ini->readVariable("layout","skin") == $template["id"] &&
00516                                         $this->ilias->ini->readVariable("layout","style") == $style["id"])
00517                                 {
00518                                         $this->tpl->setVariable("SKINSELECTED", "selected=\"selected\"");
00519                                 }
00520 
00521                                 // default selection list
00522                                 $this->tpl->setCurrentBlock("selectskin");
00523                                 $this->tpl->setVariable("SKINVALUE", $template["id"].":".$style["id"]);
00524                                 $this->tpl->setVariable("SKINOPTION", $styleDef->getTemplateName()." / ".$style["name"]);
00525                                 $this->tpl->parseCurrentBlock();
00526                                 
00527                                 // can be optimized
00528                                 foreach ($templates as $template2)
00529                                 {
00530                                         // get styles definition for template
00531                                         $styleDef2 =& new ilStyleDefinition($template2["id"]);
00532                                         $styleDef2->startParsing();
00533                                         $styles2 = $styleDef2->getStyles();
00534                 
00535                                         foreach ($styles2 as $style2)
00536                                         {
00537                                                 if (ilObjStyleSettings::_lookupActivatedStyle($template2["id"], $style2["id"]))
00538                                                 {
00539                                                         $this->tpl->setCurrentBlock("move_to_skin");
00540                                                         $this->tpl->setVariable("TOSKINVALUE", $template2["id"].":".$style2["id"]);
00541                                                         $this->tpl->setVariable("TOSKINOPTION", $styleDef2->getTemplateName()." / ".$style2["name"]);
00542                                                         $this->tpl->parseCurrentBlock();
00543                                                 }
00544                                         }
00545                                 }
00546                                 
00547                                 // activation checkbox
00548                                 $this->tpl->setCurrentBlock("activation_checkbox");
00549                                 $this->tpl->setVariable("VAL_SKIN_STYLE", $template["id"].":".$style["id"]);
00550                                 if (ilObjStyleSettings::_lookupActivatedStyle($template["id"], $style["id"]))
00551                                 {
00552                                         $this->tpl->setVariable("CHK_SKIN_STYLE", " checked=\"1\" ");
00553                                 }
00554                                 $this->tpl->parseCurrentBlock();
00555                                 
00556                                 // activation row
00557                                 $this->tpl->setCurrentBlock("style_activation");
00558                                 $this->tpl->setVariable("VAL_MOVE_SKIN_STYLE", $template["id"].":".$style["id"]);
00559                                 $this->tpl->setVariable("TXT_SKIN_STYLE_TITLE", 
00560                                         $styleDef->getTemplateName()." / ".$style["name"]);
00561                                 $num_users = ilObjUser::_getNumberOfUsersForStyle($template["id"], $style["id"]);
00562                                 $this->tpl->setVariable("VAL_NUM_USERS", $num_users);
00563                                 $this->tpl->parseCurrentBlock();
00564                                 
00565                                 $all_styles[] = $template["id"].":".$style["id"];
00566                         }
00567                 }
00568                 
00569                 // get all user assigned styles
00570                 $all_user_styles = ilObjUser::_getAllUserAssignedStyles();
00571                 
00572                 // output "other" row for all users, that are not assigned to
00573                 // any existing style
00574                 $users_missing_styles = 0;
00575                 foreach($all_user_styles as $style)
00576                 {
00577                         if (!in_array($style, $all_styles))
00578                         {
00579                                 $style_arr = explode(":", $style);
00580                                 $users_missing_styles += ilObjUser::_getNumberOfUsersForStyle($style_arr[0], $style_arr[1]);
00581                         }
00582                 }
00583 
00584                 if ($users_missing_styles > 0)
00585                 {                       
00586                         // can be optimized
00587                         foreach ($templates as $template2)
00588                         {
00589                                 // get styles definition for template
00590                                 $styleDef2 =& new ilStyleDefinition($template2["id"]);
00591                                 $styleDef2->startParsing();
00592                                 $styles2 = $styleDef2->getStyles();
00593         
00594                                 foreach ($styles2 as $style2)
00595                                 {
00596                                         if (ilObjStyleSettings::_lookupActivatedStyle($template2["id"], $style2["id"]))
00597                                         {
00598                                                 $this->tpl->setCurrentBlock("move_to_skin");
00599                                                 $this->tpl->setVariable("TOSKINVALUE", $template2["id"].":".$style2["id"]);
00600                                                 $this->tpl->setVariable("TOSKINOPTION", $styleDef2->getTemplateName()." / ".$style2["name"]);
00601                                                 $this->tpl->parseCurrentBlock();
00602                                         }
00603                                 }
00604                         }
00605                         
00606                         $this->tpl->setCurrentBlock("style_activation");
00607                         $this->tpl->setVariable("TXT_SKIN_STYLE_TITLE",
00608                                 $this->lng->txt("other"));
00609                         $this->tpl->setVariable("VAL_NUM_USERS",
00610                                 $users_missing_styles);
00611                         $this->tpl->setVariable("VAL_MOVE_SKIN_STYLE", "other");
00612                         $this->tpl->parseCurrentBlock();
00613                 }
00614 
00615                 $this->tpl->parseCurrentBlock();
00616         }
00617         
00618 
00622         function saveStyleSettingsObject()
00623         {
00624                 global $styleDefinition;
00625                 
00626                 // check if one style is activated
00627                 if (count($_POST["st_act"]) < 1)
00628                 {
00629                         $this->ilias->raiseError($this->lng->txt("at_least_one_style"), $this->ilias->error_obj->MESSAGE);
00630                 }
00631                 
00632                 // check if a style should be deactivated, that still has
00633                 // a user assigned to
00634                 $templates = $styleDefinition->getAllTemplates();
00635                 $all_styles = array();
00636                 foreach ($templates as $template)
00637                 {
00638                         // get styles definition for template
00639                         $styleDef =& new ilStyleDefinition($template["id"]);
00640                         $styleDef->startParsing();
00641                         $styles = $styleDef->getStyles();
00642                         foreach ($styles as $style)
00643                         {
00644                                 if (!isset($_POST["st_act"][$template["id"].":".$style["id"]]))
00645                                 {
00646                                         if (ilObjUser::_getNumberOfUsersForStyle($template["id"], $style["id"]) > 1)
00647                                         {
00648                                                 $this->ilias->raiseError($this->lng->txt("cant_deactivate_if_users_assigned"), $this->ilias->error_obj->MESSAGE);
00649                                         }
00650                                         else
00651                                         {
00652                                                 ilObjStyleSettings::_deactivateStyle($template["id"], $style["id"]);
00653                                         }
00654                                 }
00655                                 else
00656                                 {
00657                                         ilObjStyleSettings::_activateStyle($template["id"], $style["id"]);
00658                                 }
00659                                 $all_styles[] = $template["id"].":".$style["id"];
00660                         }
00661                 }
00662                 
00663                 // move users to other skin
00664                 foreach($_POST["move_users"] as $key => $value)
00665                 {
00666                         if ($value != "")
00667                         {
00668                                 $to = explode(":", $value);
00669                                 
00670                                 if ($key != "other")
00671                                 {
00672                                         $from = explode(":", $key);
00673                                         ilObjUser::_moveUsersToStyle($from[0],$from[1],$to[0],$to[1]);
00674                                 }
00675                                 else
00676                                 {
00677                                         // get all user assigned styles
00678                                         $all_user_styles = ilObjUser::_getAllUserAssignedStyles();
00679                                         
00680                                         // move users that are not assigned to
00681                                         // currently existing style
00682                                         foreach($all_user_styles as $style)
00683                                         {
00684                                                 if (!in_array($style, $all_styles))
00685                                                 {
00686                                                         $style_arr = explode(":", $style);
00687                                                         ilObjUser::_moveUsersToStyle($style_arr[0],$style_arr[1],$to[0],$to[1]);
00688                                                 }
00689                                         }
00690                                 }
00691                         }
00692                 }
00693                 
00694                 //set default skin and style
00695                 if ($_POST["default_skin_style"] != "")
00696                 {
00697                         $sknst = explode(":", $_POST["default_skin_style"]);
00698 
00699                         if ($this->ilias->ini->readVariable("layout","style") != $sknst[1] ||
00700                                 $this->ilias->ini->readVariable("layout","skin") != $sknst[0])
00701                         {
00702                                 $this->ilias->ini->setVariable("layout","skin", $sknst[0]);
00703                                 $this->ilias->ini->setVariable("layout","style",$sknst[1]);
00704                         }
00705                 }
00706                 $this->ilias->ini->write();
00707 //echo "redirect-".$this->ctrl->getLinkTarget($this,"editSystemStyles")."-";
00708                 ilUtil::sendInfo($this->lng->txt("msg_obj_modified"), true);
00709                 ilUtil::redirect($this->ctrl->getLinkTarget($this,"editSystemStyles"));
00710         }
00711         
00717         function deleteStyleObject($a_error = false)
00718         {
00719                 if (!isset($_POST["id"]))
00720                 {
00721                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00722                 }
00723 
00724                 // SAVE POST VALUES
00725                 $_SESSION["saved_post"] = $_POST["id"];
00726 
00727                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html");
00728 
00729                 if(!$a_error)
00730                 {
00731                         ilUtil::sendInfo($this->lng->txt("info_delete_sure"));
00732                 }
00733 
00734                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00735 
00736                 // BEGIN TABLE HEADER
00737                 $this->tpl->setCurrentBlock("table_header");
00738                 $this->tpl->setVariable("TEXT", $this->lng->txt("objects"));
00739                 $this->tpl->parseCurrentBlock();
00740                 
00741                 // END TABLE HEADER
00742 
00743                 // BEGIN TABLE DATA
00744                 $counter = 0;
00745 
00746                 foreach ($_POST["id"] as $id)
00747                 {
00748                         $this->tpl->setCurrentBlock("table_row");
00749                         $this->tpl->setVariable("IMG_OBJ",ilUtil::getImagePath("icon_sty.gif"));
00750                         $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
00751                         $this->tpl->setVariable("TEXT_CONTENT",ilObject::_lookupTitle($id));
00752                         $this->tpl->parseCurrentBlock();
00753                 }
00754                 
00755                 // END TABLE DATA
00756 
00757                 // BEGIN OPERATION_BTN
00758                 $buttons = array("confirmedDelete"  => $this->lng->txt("confirm"),
00759                         "cancelDelete"  => $this->lng->txt("cancel"));
00760                 foreach ($buttons as $name => $value)
00761                 {
00762                         $this->tpl->setCurrentBlock("operation_btn");
00763                         $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
00764                         $this->tpl->setVariable("BTN_NAME",$name);
00765                         $this->tpl->setVariable("BTN_VALUE",$value);
00766                         $this->tpl->parseCurrentBlock();
00767                 }
00768         }
00769         
00770         
00774         function confirmedDeleteObject()
00775         {
00776                 global $ilias;
00777                 
00778                 foreach($_SESSION["saved_post"] as $id)
00779                 {
00780                         $this->object->removeStyle($id);
00781                         $style_obj =& $ilias->obj_factory->getInstanceByObjId($id);
00782                         $style_obj->delete();
00783                 }
00784                 $this->object->update();
00785                 
00786                 ilUtil::redirect($this->getReturnLocation("delete",
00787                         $this->ctrl->getLinkTarget($this,"editContentStyles")));
00788         }
00789         
00790         
00796         function toggleGlobalDefaultObject()
00797         {
00798                 global $ilias;
00799                 
00800                 if (!isset($_POST["id"]))
00801                 {
00802                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00803                 }
00804                 if(count($_POST["id"]) > 1)
00805                 {
00806                         $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
00807                 }
00808 
00809                 $ilias->deleteSetting("fixed_content_style_id");
00810                 $def_style = $ilias->getSetting("default_content_style_id");
00811                 
00812                 if ($def_style != $_POST["id"][0])
00813                 {
00814                         $ilias->setSetting("default_content_style_id", $_POST["id"][0]);
00815                 }
00816                 else
00817                 {
00818                         $ilias->deleteSetting("default_content_style_id");
00819                 }
00820                 
00821                 ilUtil::redirect($this->ctrl->getLinkTarget($this, "editContentStyles"));
00822         }
00823 
00829         function toggleGlobalFixedObject()
00830         {
00831                 global $ilias;
00832                 
00833                 if (!isset($_POST["id"]))
00834                 {
00835                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00836                 }
00837                 if(count($_POST["id"]) > 1)
00838                 {
00839                         $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
00840                 }
00841 
00842                 $ilias->deleteSetting("default_content_style_id");
00843                 $fixed_style = $ilias->getSetting("fixed_content_style_id");
00844                 if ($fixed_style == $_POST["id"][0])
00845                 {
00846                         $ilias->deleteSetting("fixed_content_style_id");
00847                 }
00848                 else
00849                 {
00850                         $ilias->setSetting("fixed_content_style_id", $_POST["id"][0]);
00851                 }
00852                 ilUtil::redirect($this->ctrl->getLinkTarget($this, "editContentStyles"));
00853         }
00854         
00855         
00859         function saveActiveStylesObject()
00860         {
00861                 include_once("classes/class.ilObjStyleSheet.php");
00862                 $styles = $this->object->getStyles();
00863                 foreach($styles as $style)
00864                 {
00865                         if ($_POST["std_".$style["id"]] == 1)
00866                         {
00867                                 ilObjStyleSheet::_writeActive($style["id"], 1);
00868                         }
00869                         else
00870                         {
00871                                 ilObjStyleSheet::_writeActive($style["id"], 0);
00872                         }
00873                 }
00874                 ilUtil::redirect($this->ctrl->getLinkTarget($this, "editContentStyles"));
00875         }
00876         
00883         function showActions($with_subobjects = false)
00884         {
00885 
00886                 // delete
00887                 $this->tpl->setCurrentBlock("tbl_action_btn");
00888                 $this->tpl->setVariable("BTN_NAME", "deleteStyle");
00889                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
00890                 $this->tpl->parseCurrentBlock();
00891 
00892                 // set global default
00893                 $this->tpl->setCurrentBlock("tbl_action_btn");
00894                 $this->tpl->setVariable("BTN_NAME", "toggleGlobalDefault");
00895                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("toggleGlobalDefault"));
00896                 $this->tpl->parseCurrentBlock();
00897                 
00898                 // set global default
00899                 $this->tpl->setCurrentBlock("tbl_action_btn");
00900                 $this->tpl->setVariable("BTN_NAME", "toggleGlobalFixed");
00901                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("toggleGlobalFixed"));
00902                 $this->tpl->parseCurrentBlock();
00903 
00904                 // set global default
00905                 $this->tpl->setCurrentBlock("tbl_action_btn");
00906                 $this->tpl->setVariable("BTN_NAME", "setScope");
00907                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("sty_set_scope"));
00908                 $this->tpl->parseCurrentBlock();
00909 
00910                 // save active styles
00911                 $this->tpl->setCurrentBlock("tbl_action_btn");
00912                 $this->tpl->setVariable("BTN_NAME", "saveActiveStyles");
00913                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("sty_save_active_styles"));
00914                 $this->tpl->parseCurrentBlock();
00915 
00916                 if ($with_subobjects === true)
00917                 {
00918                         $this->showPossibleSubObjects();
00919                 }
00920                 
00921                 $this->tpl->setCurrentBlock("tbl_action_row");
00922                 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00923                 $this->tpl->parseCurrentBlock();
00924         }
00925 
00931         function cancelDeleteObject()
00932         {
00933                 session_unregister("saved_post");
00934 
00935                 ilUtil::sendInfo($this->lng->txt("msg_cancel"),true);
00936                 $this->ctrl->redirect($this, "editContentStyles");
00937 
00938         }
00939 
00940         function setScopeObject()
00941         {
00942                 //$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html");
00943                 //$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.explorer.html");
00944                 
00945                 include_once ("classes/class.ilStyleScopeExplorer.php");
00946                 $exp = new ilStyleScopeExplorer("repository.php?cmd=goto");
00947                 $exp->setExpandTarget("repository.php?cmd=showTree");
00948                 $exp->setTargetGet("ref_id");
00949                 $exp->setFilterMode(IL_FM_POSITIVE);
00950                 $exp->forceExpandAll(true, false);
00951                 $exp->addFilter("root");
00952                 $exp->addFilter("cat");
00953 
00954                 if ($_GET["expand"] == "")
00955                 {
00956                         $expanded = $this->tree->readRootId();
00957                 }
00958                 else
00959                 {
00960                         $expanded = $_GET["expand"];
00961                 }
00962 
00963                 $exp->setExpand($expanded);
00964 
00965                 // build html-output
00966                 $exp->setOutput(0);
00967                 $output = $exp->getOutput();
00968 
00969                 $this->tpl->setVariable("ADM_CONTENT", $output);
00970         }
00971         
00975         function saveScopeObject()
00976         {
00977                 global $ilias;
00978                 
00979                 include_once("classes/class.ilObjStyleSheet.php");
00980                 if ($_GET["cat"] == 0)
00981                 {
00982                         $_GET["cat"] == "";
00983                 }
00984                 ilObjStyleSheet::_writeScope($_GET["style_id"], $_GET["cat"]);
00985                 
00986                 ilUtil::redirect($this->ctrl->getLinkTarget($this, "editContentStyles"));
00987         }
00988 
00989         
00990         function setTabs()
00991         {
00992                 echo "settings_setTabs";
00993         }
00994         
00995         function getAdminTabs(&$tabs_gui)
00996         {
00997                 $this->getTabs($tabs_gui);
00998         }
00999                 
01005         function getTabs(&$tabs_gui)
01006         {
01007                 global $rbacsystem;
01008 
01009                 if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
01010                 {
01011                         $tabs_gui->addTarget("basic_settings",
01012                                 $this->ctrl->getLinkTarget($this, "editBasicSettings"), array("editBasicSettings","", "view"), "", "");
01013 
01014                         $tabs_gui->addTarget("system_styles",
01015                                 $this->ctrl->getLinkTarget($this, "editSystemStyles"), "editSystemStyles", "", "");
01016                                 
01017                         $tabs_gui->addTarget("content_styles",
01018                                 $this->ctrl->getLinkTarget($this, "editContentStyles"), "editContentStyles", "", "");
01019                 }
01020 
01021                 if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
01022                 {
01023                         $tabs_gui->addTarget("perm_settings",
01024                                 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
01025                 }
01026         }
01027 } // END class.ilObjStyleSettingsGUI
01028 ?>

Generated on Fri Dec 13 2013 17:56:48 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1