/**
  * Constructor
  */
 function __construct($a_parent_obj, $a_parent_cmd, $a_chars, $a_super_type, $a_style)
 {
     global $ilCtrl, $lng, $ilAccess, $lng, $rbacsystem;
     parent::__construct($a_parent_obj, $a_parent_cmd);
     $this->media_object = $a_media_object;
     $this->super_type = $a_super_type;
     $this->style = $a_style;
     $all_super_types = ilObjStyleSheet::_getStyleSuperTypes();
     $this->types = $all_super_types[$this->super_type];
     $this->core_styles = ilObjStyleSheet::_getCoreStyles();
     $this->setData($a_chars);
     $this->setTitle($lng->txt("sty_" . $a_super_type . "_char"));
     $this->setLimit(9999);
     // check, whether any of the types is expandable
     $this->expandable = false;
     $this->hideable = false;
     foreach ($this->types as $t) {
         if (ilObjStyleSheet::_isExpandable($t)) {
             $this->expandable = true;
         }
         if (ilObjStyleSheet::_isHideable($t)) {
             $this->hideable = true;
         }
     }
     //		if ($this->expandable)
     //		{
     $this->addColumn("", "", "1");
     // checkbox
     //		}
     $this->addColumn($this->lng->txt("sty_name"), "", "1");
     $this->addColumn($this->lng->txt("sty_type"), "", "");
     $this->addColumn($this->lng->txt("sty_example"), "", "");
     if ($this->hideable) {
         $this->addColumn($this->lng->txt("sty_hide"), "", "");
         // hide checkbox
     }
     $this->addColumn($this->lng->txt("sty_commands"), "", "1");
     $this->setEnableHeader(true);
     $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
     $this->setRowTemplate("tpl.style_row.html", "Services/Style");
     $this->disable("footer");
     if ($rbacsystem->checkAccess("write", (int) $_GET["ref_id"])) {
         // action commands
         if ($this->hideable) {
             $this->addCommandButton("saveHideStatus", $lng->txt("sty_save_hide_status"));
         }
         $this->addMultiCommand("copyCharacteristics", $lng->txt("copy"));
         // action commands
         if ($this->expandable) {
             $this->addMultiCommand("deleteCharacteristicConfirmation", $lng->txt("delete"));
             //$this->addCommandButton("addCharacteristicForm", $lng->txt("sty_add_characteristic"));
         }
     }
     $this->setEnableTitle(true);
 }
 /**
  * Add missing style classes to all styles
  */
 static function _addMissingStyleClassesToAllStyles($a_styles = "")
 {
     global $ilDB;
     if ($a_styles == "") {
         $styles = ilObject::_getObjectsDataForType("sty");
     } else {
         $styles = $a_styles;
     }
     $core_styles = ilObjStyleSheet::_getCoreStyles();
     $bdom = ilObjStyleSheet::_getBasicStyleDom();
     // get all core image files
     $core_images = array();
     $core_dir = self::$basic_style_image_dir;
     if (is_dir($core_dir)) {
         $dir = opendir($core_dir);
         while ($file = readdir($dir)) {
             if (substr($file, 0, 1) != "." && is_file($core_dir . "/" . $file)) {
                 $core_images[] = $file;
             }
         }
     }
     foreach ($styles as $style) {
         $id = $style["id"];
         foreach ($core_styles as $cs) {
             // check, whether core style class exists
             $set = $ilDB->queryF("SELECT * FROM style_char WHERE style_id = %s " . "AND type = %s AND characteristic = %s", array("integer", "text", "text"), array($id, $cs["type"], $cs["class"]));
             // if not, add core style class
             if (!($rec = $ilDB->fetchAssoc($set))) {
                 $ilDB->manipulateF("INSERT INTO style_char (style_id, type, characteristic) " . " VALUES (%s,%s,%s) ", array("integer", "text", "text"), array($id, $cs["type"], $cs["class"]));
                 $xpath = new DOMXPath($bdom);
                 $par_nodes = $xpath->query("/StyleSheet/Style[@Tag = '" . $cs["tag"] . "' and @Type='" . $cs["type"] . "' and @Class='" . $cs["class"] . "']/StyleParameter");
                 foreach ($par_nodes as $par_node) {
                     // check whether style parameter exists
                     $set = $ilDB->queryF("SELECT * FROM style_parameter WHERE style_id = %s " . "AND type = %s AND class = %s AND tag = %s AND parameter = %s", array("integer", "text", "text", "text", "text"), array($id, $cs["type"], $cs["class"], $cs["tag"], $par_node->getAttribute("Name")));
                     // if not, create style parameter
                     if (!($rec = $ilDB->fetchAssoc($set))) {
                         $spid = $ilDB->nextId("style_parameter");
                         $st = $ilDB->manipulateF("INSERT INTO style_parameter (id, style_id, type, class, tag, parameter, value) " . " VALUES (%s,%s,%s,%s,%s,%s,%s)", array("integer", "integer", "text", "text", "text", "text", "text"), array($spid, $id, $cs["type"], $cs["class"], $cs["tag"], $par_node->getAttribute("Name"), $par_node->getAttribute("Value")));
                     }
                 }
             }
         }
         // now check, whether some core image files are missing
         ilObjStyleSheet::_createImagesDirectory($id);
         $imdir = ilObjStyleSheet::_getImagesDirectory($id);
         reset($core_images);
         foreach ($core_images as $cim) {
             if (!is_file($imdir . "/" . $cim)) {
                 copy($core_dir . "/" . $cim, $imdir . "/" . $cim);
             }
         }
     }
 }
 /**
  * Message that appears, when user tries to delete core characteristics
  *
  * @param
  * @return
  */
 function deleteCoreCharMessage()
 {
     global $ilCtrl, $tpl, $lng;
     include_once "./Services/Utilities/classes/class.ilConfirmationGUI.php";
     $cgui = new ilConfirmationGUI();
     $cgui->setFormAction($ilCtrl->getFormAction($this));
     $core_styles = ilObjStyleSheet::_getCoreStyles();
     $cnt = 0;
     foreach ($_POST["char"] as $char) {
         if (!empty($core_styles[$char])) {
             $cnt++;
             $char_comp = explode(".", $char);
             $cgui->addItem("", "", $char_comp[2]);
         } else {
             $cgui->addHiddenItem("char[]", $char);
         }
     }
     $all_core_styles = $cnt == count($_POST["char"]) ? true : false;
     if ($all_core_styles) {
         $cgui->setHeaderText($lng->txt("sty_all_styles_obligatory"));
         $cgui->setCancel($lng->txt("back"), "cancelCharacteristicDeletion");
     } else {
         $cgui->setHeaderText($lng->txt("sty_some_styles_obligatory_delete_rest"));
         $cgui->setCancel($lng->txt("cancel"), "cancelCharacteristicDeletion");
         $cgui->setConfirm($lng->txt("sty_delete_other_selected"), "deleteCharacteristicConfirmation");
     }
     $tpl->setContent($cgui->getHTML());
 }