00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00035 require_once "class.ilObjectGUI.php";
00036
00037 class ilObjStyleSheetGUI extends ilObjectGUI
00038 {
00039 var $cmd_update;
00040 var $cmd_new_par;
00041 var $cmd_refresh;
00042 var $cmd_delete;
00043
00048 function ilObjStyleSheetGUI($a_data,$a_id,$a_call_by_reference, $a_prep = true)
00049 {
00050 global $ilCtrl, $lng, $tpl;
00051
00052 $this->ctrl =& $ilCtrl;
00053 $this->lng =& $lng;
00054
00055 $this->type = "sty";
00056 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, $a_prep);
00057 }
00058
00062 function &executeCommand()
00063 {
00064 $next_class = $this->ctrl->getNextClass($this);
00065 $cmd = $this->ctrl->getCmd();
00066
00067 switch($next_class)
00068 {
00069 default:
00070 $cmd.= "Object";
00071 $ret =& $this->$cmd();
00072 break;
00073 }
00074
00075 return $ret;
00076 }
00077
00078 function viewObject()
00079 {
00080 $this->editObject();
00081 }
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00107 function createObject()
00108 {
00109 global $rbacsystem, $lng, $tpl;
00110
00111 $this->setTabs();
00112
00113 $this->lng =& $lng;
00114
00115 $this->getTemplateFile("create", "sty");
00116 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("create_stylesheet"));
00117 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00118 $this->tpl->setVariable("TXT_DESC", $this->lng->txt("description"));
00119 $this->tpl->parseCurrentBlock();
00120 $this->ctrl->setParameter($this, "new_type", "sty");
00121 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00122 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
00123 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00124 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00125
00126 }
00127
00131 function editObject()
00132 {
00133 global $rbacsystem, $lng;
00134
00135 $this->setTabs();
00136
00137
00138 $this->tpl->setCurrentBlock("ContentStyle");
00139 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00140 $this->object->getContentStylePath($this->object->getId()));
00141 $this->tpl->parseCurrentBlock();
00142
00143 $this->getTemplateFile("edit", "sty");
00144 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("edit_stylesheet"));
00145
00146
00147 $avail_pars = $this->object->getAvailableParameters();
00148 $style = $this->object->getStyle();
00149 foreach($style as $tag)
00150 {
00151 foreach($tag as $par)
00152 {
00153 $this->tpl->setCurrentBlock("StyleParameter");
00154 $this->tpl->setVariable("PAR_ID", $par["id"]);
00155 $this->tpl->setVariable("TXT_PAR", $par["parameter"]);
00156 if (count($avail_pars[$par["parameter"]]) == 0)
00157 {
00158 $input = "<input type=\"text\" size=\"30\" maxlength=\"100\" ".
00159 "name=\"styval[".$par["id"]."]\" value=\"".$par["value"]."\"";
00160 }
00161 else
00162 {
00163 $sel_avail_vals = array();
00164 foreach($avail_pars[$par["parameter"]] as $key => $val)
00165 {
00166 $sel_avail_vals[$val] = $val;
00167 }
00168 $input = ilUtil::formSelect($par["value"], "styval[".$par["id"]."]", $sel_avail_vals, false, true);
00169 }
00170 $this->tpl->setVariable("INPUT_VAL", $input);
00171 $this->tpl->parseCurrentBlock();
00172 }
00173 if ((!is_int(strpos($tag[0]["class"], ":hover"))) &&
00174 (!is_int(strpos($tag[0]["class"], ":visited"))) &&
00175 (!is_int(strpos($tag[0]["class"], ":active")))
00176 )
00177 {
00178 $this->tpl->setCurrentBlock("Example_".$tag[0]["tag"]);
00179 $this->tpl->setVariable("EX_CLASS", "ilc_".$tag[0]["class"]);
00180 $this->tpl->setVariable("EX_TEXT", "ABC abc 123");
00181 $this->tpl->parseCurrentBlock();
00182 }
00183
00184 $this->tpl->setCurrentBlock("StyleTag");
00185 $this->tpl->setVariable("TXT_TAG", $tag[0]["tag"].".".$tag[0]["class"]);
00186 $this->tpl->setVariable("STY_ROWSPAN", (count($tag) + 1));
00187 $this->tpl->setVariable("TXT_PARAMETER", $this->lng->txt("parameter"));
00188 $this->tpl->setVariable("TXT_VALUE", $this->lng->txt("value"));
00189 $this->tpl->parseCurrentBlock();
00190 }
00191
00192
00193 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00194 $this->tpl->setVariable(strtoupper("TITLE"), $this->object->getTitle());
00195 $this->tpl->setVariable("TXT_DESC", $this->lng->txt("description"));
00196 $this->tpl->setVariable(strtoupper("DESCRIPTION"), $this->object->getDescription());
00197 $this->tpl->parseCurrentBlock();
00198
00199
00200 $temptags = $this->object->getAvailableTags();
00201 $tags = array();
00202 foreach($temptags as $key => $val)
00203 {
00204 $tags[$val] = $val;
00205 }
00206 $tag_select = ilUtil::formSelect("", "tag", $tags, false, true);
00207 foreach($avail_pars as $key => $val)
00208 {
00209 $sel_avail_pars[$key] = $key;
00210 }
00211 $this->tpl->setVariable("SELECT_TAG", $tag_select);
00212 $par_select = ilUtil::formSelect("", "parameter", $sel_avail_pars, false, true);
00213 $this->tpl->setVariable("SELECT_PAR", $par_select);
00214 $this->tpl->setVariable("TXT_NEW_PAR", $this->lng->txt("add"));
00215
00216 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00217 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save_return"));
00218 $this->tpl->setVariable("BTN_SAVE", "update");
00219 $this->tpl->setVariable("TXT_REFRESH", $this->lng->txt("save_refresh"));
00220 $this->tpl->setVariable("BTN_REFRESH", "refresh");
00221 $this->tpl->setVariable("TXT_DELETE", $this->lng->txt("delete_selected"));
00222 $this->tpl->setVariable("BTN_DELETE", "deleteStyleParameter");
00223 $this->tpl->setVariable("BTN_NEW_PAR", "newStyleParameter");
00224 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00225 }
00226
00230 function newStyleParameterObject()
00231 {
00232 $this->object->addParameter($_POST["tag"], $_POST["parameter"]);
00233 $this->editObject();
00234 }
00235
00239 function refreshObject()
00240 {
00241
00242
00243 $this->object->setTitle($_POST["style_title"]);
00244 $this->object->setDescription($_POST["style_description"]);
00245
00246 foreach($_POST["styval"] as $id => $value)
00247 {
00248 $this->object->updateStyleParameter($id, $value);
00249 }
00250 $this->object->update();
00251 $this->editObject();
00252 }
00253
00259 function deleteObject($a_error = false)
00260 {
00261 $this->setTabs();
00262
00263 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html");
00264
00265 if(!$a_error)
00266 {
00267 sendInfo($this->lng->txt("info_delete_sure"));
00268 }
00269
00270 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00271
00272
00273 $this->tpl->setCurrentBlock("table_header");
00274 $this->tpl->setVariable("TEXT", $this->lng->txt("objects"));
00275 $this->tpl->parseCurrentBlock();
00276
00277
00278
00279
00280 $counter = 0;
00281
00282 $this->tpl->setCurrentBlock("table_row");
00283 $this->tpl->setVariable("IMG_OBJ",ilUtil::getImagePath("icon_styf.gif"));
00284 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
00285 $this->tpl->setVariable("TEXT_CONTENT",ilObject::_lookupTitle($this->object->getId()));
00286 $this->tpl->parseCurrentBlock();
00287
00288
00289
00290
00291 $buttons = array("confirmedDelete" => $this->lng->txt("confirm"),
00292 "cancelDelete" => $this->lng->txt("cancel"));
00293 foreach ($buttons as $name => $value)
00294 {
00295 $this->tpl->setCurrentBlock("operation_btn");
00296 $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
00297 $this->tpl->setVariable("BTN_NAME",$name);
00298 $this->tpl->setVariable("BTN_VALUE",$value);
00299 $this->tpl->parseCurrentBlock();
00300 }
00301 }
00302
00303
00307 function cancelDeleteObject()
00308 {
00309 $this->ctrl->returnToParent($this);
00310 }
00311
00315 function confirmedDeleteObject()
00316 {
00317 global $ilias;
00318
00319 $this->object->delete();
00320
00321 $this->ctrl->returnToParent($this);
00322 }
00323
00327 function deleteStyleParameterObject()
00328 {
00329 if (is_array($_POST["sty_select"]))
00330 {
00331 foreach($_POST["sty_select"] as $id => $dummy)
00332 {
00333 $this->object->deleteParameter($id);
00334 }
00335 }
00336 $this->object->read();
00337 $this->object->writeCSSFile();
00338 $this->editObject();
00339 }
00340
00344 function saveObject()
00345 {
00346
00347 $class_name = "ilObjStyleSheet";
00348 require_once("classes/class.ilObjStyleSheet.php");
00349 $newObj = new ilObjStyleSheet();
00350 $newObj->setTitle($_POST["style_title"]);
00351 $newObj->setDescription($_POST["style_description"]);
00352 $newObj->create();
00353
00354
00355
00356 if ($_GET["ref_id"] > 0)
00357 {
00358
00359 $fold =& ilObjectFactory::getInstanceByRefId($_GET["ref_id"]);
00360 if ($fold->getType() == "stys")
00361 {
00362 $fold->addStyle($newObj->getId());
00363 $fold->update();
00364
00365
00366 ilUtil::redirect("adm_object.php?ref_id=".$_GET["ref_id"]);
00367 }
00368 }
00369
00370 return $newObj->getId();
00371 }
00372
00376 function updateObject()
00377 {
00378
00379
00380 $this->object->setTitle($_POST["style_title"]);
00381 $this->object->setDescription($_POST["style_description"]);
00382
00383 foreach($_POST["styval"] as $id => $value)
00384 {
00385 $this->object->updateStyleParameter($id, $value);
00386 }
00387 $this->object->update();
00388
00389
00390 if ($_GET["ref_id"] > 0)
00391 {
00392
00393 $fold =& ilObjectFactory::getInstanceByRefId($_GET["ref_id"]);
00394 if ($fold->getType() == "stys")
00395 {
00396 ilUtil::redirect("adm_object.php?ref_id=".$_GET["ref_id"]);
00397 }
00398 }
00399
00400 $this->ctrl->returnToParent($this);
00401 }
00402
00406 function cancelObject()
00407 {
00408 global $lng;
00409
00410
00411 if ($_GET["ref_id"] > 0)
00412 {
00413
00414 $fold =& ilObjectFactory::getInstanceByRefId($_GET["ref_id"]);
00415 if ($fold->getType() == "stys")
00416 {
00417 ilUtil::redirect("adm_object.php?ref_id=".$_GET["ref_id"]);
00418 }
00419 }
00420
00421 sendInfo($lng->txt("msg_cancel"), true);
00422 $this->ctrl->returnToParent($this);
00423 }
00424
00428 function setTabs()
00429 {
00430 global $lng;
00431
00432
00433 include_once("classes/class.ilTabsGUI.php");
00434 $tabs_gui =& new ilTabsGUI();
00435 $this->getTabs($tabs_gui);
00436 $this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00437
00438 if (strtolower(get_class($this->object)) == "ilobjstylesheet")
00439 {
00440 $this->tpl->setVariable("HEADER", $this->object->getTitle());
00441 }
00442 else
00443 {
00444 $this->tpl->setVariable("HEADER", $lng->txt("create_stylesheet"));
00445 }
00446 }
00447
00453 function getTabs(&$tabs_gui)
00454 {
00455
00456 if ($_GET["ref_id"] > 0)
00457 {
00458
00459 $fold =& ilObjectFactory::getInstanceByRefId($_GET["ref_id"]);
00460 if ($fold->getType() == "stys")
00461 {
00462
00463 $tabs_gui->addTarget("back",
00464 "adm_object.php?ref_id=".$_GET["ref_id"], "",
00465 "");
00466 return;
00467 }
00468 }
00469
00470
00471 $tabs_gui->addTarget("cont_back",
00472 $this->ctrl->getParentReturn($this), "",
00473 "");
00474 }
00475
00476
00477 }
00478 ?>