本文整理汇总了PHP中ilObjStyleSheet::getImagesDirectory方法的典型用法代码示例。如果您正苦于以下问题:PHP ilObjStyleSheet::getImagesDirectory方法的具体用法?PHP ilObjStyleSheet::getImagesDirectory怎么用?PHP ilObjStyleSheet::getImagesDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilObjStyleSheet
的用法示例。
在下文中一共展示了ilObjStyleSheet::getImagesDirectory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: importXmlRepresentation
function importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
{
// see ilStyleExporter::getXmlRepresentation()
if (preg_match("/<StyleSheetExport><ImagePath>(.+)<\\/ImagePath>/", $a_xml, $hits)) {
$path = $hits[1];
$a_xml = str_replace($hits[0], "", $a_xml);
$a_xml = str_replace("</StyleSheetExport>", "", $a_xml);
}
// temp xml-file
$tmp_file = $this->getImportDirectory() . "/sty_" . $a_id . ".xml";
file_put_contents($tmp_file, $a_xml);
include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
$style = new ilObjStyleSheet();
$style->createFromXMLFile($tmp_file);
$new_id = $style->getId();
unlink($tmp_file);
// images
if ($path) {
$source = $this->getImportDirectory() . "/" . $path;
if (is_dir($source)) {
$target = $style->getImagesDirectory();
if (!is_dir($target)) {
ilUtil::makeDirParents($target);
}
ilUtil::rCopy($source, $target);
}
}
$a_mapping->addMapping("Services/Style", "sty", $a_id, $new_id);
}
示例2: getXmlRepresentation
public function getXmlRepresentation($a_entity, $a_schema_version, $a_id)
{
include_once "Services/Style/classes/class.ilObjStyleSheet.php";
$style = new ilObjStyleSheet($a_id, false);
// images
$target = $this->getAbsoluteExportDirectory();
if ($target && !is_dir($target)) {
ilUtil::makeDirParents($target);
}
ilUtil::rCopy($style->getImagesDirectory(), $target);
return "<StyleSheetExport>" . "<ImagePath>" . $this->getRelativeExportDirectory() . "</ImagePath>" . $style->getXML() . "</StyleSheetExport>";
}
示例3: create
/**
* Create a new style
*/
function create($a_from_style = 0, $a_import_mode = false)
{
global $ilDB;
parent::create();
if ($a_from_style == 0) {
if (!$a_import_mode) {
// copy styles from basic style
$this->createFromXMLFile(self::$basic_style_file, true);
// copy images from basic style
$this->createImagesDirectory();
ilUtil::rCopy(self::$basic_style_image_dir, $this->getImagesDirectory());
}
} else {
// get style parameter records
$def = array();
$q = "SELECT * FROM style_parameter WHERE style_id = " . $ilDB->quote($a_from_style, "integer");
$par_set = $ilDB->query($q);
while ($par_rec = $ilDB->fetchAssoc($par_set)) {
$def[] = array("tag" => $par_rec["tag"], "class" => $par_rec["class"], "parameter" => $par_rec["parameter"], "value" => $par_rec["value"], "type" => $par_rec["type"]);
}
// get style characteristics records
$chars = array();
$q = "SELECT * FROM style_char WHERE style_id = " . $ilDB->quote($a_from_style, "integer");
$par_set = $ilDB->query($q);
while ($par_rec = $ilDB->fetchAssoc($par_set)) {
$chars[] = array("type" => $par_rec["type"], "characteristic" => $par_rec["characteristic"]);
}
// default style settings
foreach ($def as $sty) {
$id = $ilDB->nextId("style_parameter");
$q = "INSERT INTO style_parameter (id, style_id, tag, class, parameter, value, type) VALUES " . "(" . $ilDB->quote($id, "integer") . "," . $ilDB->quote($this->getId(), "integer") . "," . $ilDB->quote($sty["tag"], "text") . "," . $ilDB->quote($sty["class"], "text") . "," . $ilDB->quote($sty["parameter"], "text") . "," . $ilDB->quote($sty["value"], "text") . "," . $ilDB->quote($sty["type"], "text") . ")";
$ilDB->manipulate($q);
}
// insert style characteristics
foreach ($chars as $char) {
$q = "INSERT INTO style_char (style_id, type, characteristic) VALUES " . "(" . $ilDB->quote($this->getId(), "integer") . "," . $ilDB->quote($char["type"], "text") . "," . $ilDB->quote($char["characteristic"], "text") . ")";
$ilDB->manipulate($q);
}
// add style_data record
$q = "INSERT INTO style_data (id, uptodate, category) VALUES " . "(" . $ilDB->quote($this->getId(), "integer") . ", 0," . $ilDB->quote((int) $this->getScope(), "integer") . ")";
$ilDB->manipulate($q);
// copy images
$from_style = new ilObjStyleSheet($a_from_style);
$this->createImagesDirectory();
ilUtil::rCopy($from_style->getImagesDirectory(), $this->getImagesDirectory());
// copy colors
$colors = $from_style->getColors();
foreach ($colors as $c) {
$this->addColor($c["name"], $c["code"]);
}
// copy templates
$tcts = ilObjStyleSheet::_getTemplateClassTypes();
foreach ($tcts as $tct => $v) {
$templates = $from_style->getTemplates($tct);
foreach ($templates as $t) {
$this->addTemplate($tct, $t["name"], $t["classes"]);
}
}
}
$this->read();
if (!$a_import_mode) {
$this->writeCSSFile();
}
}