protected function initBuilding() { $this->id = $this->getId(); $this->urlId = util::strToLowerURL($this->name); $this->urlIdFr = util::strToLowerURL($this->nameFr); $this->upperId = strtoupper($this->id); $this->camelCaseId = util::strToCamelCase($this->id); $this->dir = $this->modules_dir . '/' . $this->id; $this->makeHeader(); $this->common_replacements = array('##header##' => $this->header, '##module_id##' => $this->id, '##module_url_id##' => $this->urlId, '##module_url_id_fr##' => $this->urlIdFr, '##module_upper_id##' => $this->upperId, '##module_camel_case_id##' => $this->camelCaseId, '##module_name##' => $this->name, '##module_description##' => $this->description, '##module_name_fr##' => $this->nameFr, '##module_description_fr##' => $this->descriptionFr, '##module_author##' => $this->author, '##module_version##' => $this->version, '##date##' => date('Y-m-d'), '##year##' => date('Y'), '##l10n_en_1##' => $this->locales['en'][1], '##l10n_en_2##' => $this->locales['en'][2], '##l10n_en_3##' => $this->locales['en'][3], '##l10n_en_4##' => $this->locales['en'][4], '##l10n_en_5##' => $this->locales['en'][5], '##l10n_en_6##' => $this->locales['en'][6], '##l10n_en_7##' => $this->locales['en'][7], '##l10n_en_8##' => $this->locales['en'][8], '##l10n_en_9##' => $this->locales['en'][9], '##l10n_en_10##' => $this->locales['en'][10], '##l10n_fr_1##' => $this->locales['fr'][1], '##l10n_fr_2##' => $this->locales['fr'][2], '##l10n_fr_3##' => $this->locales['fr'][3], '##l10n_fr_4##' => $this->locales['fr'][4], '##l10n_fr_5##' => $this->locales['fr'][5], '##l10n_fr_6##' => $this->locales['fr'][6], '##l10n_fr_7##' => $this->locales['fr'][7], '##l10n_fr_8##' => $this->locales['fr'][8], '##l10n_fr_9##' => $this->locales['fr'][9], '##l10n_fr_10##' => $this->locales['fr'][10], '##l10n_fr_fem##' => $this->locales['fem'] ? 'e' : ''); }
/** * Permet de créer un thème vierge. * * @param string $sId */ public function bootstrapTheme($sName, $sId = null) { if (empty($sId)) { $sId = util::strToLowerURL($sName, false); } $this->getThemesList(); if (isset($this->aThemes[$sId])) { return $sId; } $sThemePath = $this->sPath . '/' . $sId; $aSearch = array('{{theme_id}}', '{{theme_name}}'); $aReplace = array($sId, html::escapeHTML($sName)); try { # required files files::makeDir($sThemePath); file_put_contents($sThemePath . '/_define.php', str_replace($aSearch, $aReplace, file_get_contents(OKT_INC_PATH . '/admin/configuration/themes/templates/_define.tpl'))); file_put_contents($sThemePath . '/index.php', str_replace($aSearch, $aReplace, file_get_contents(OKT_INC_PATH . '/admin/configuration/themes/templates/index.tpl'))); file_put_contents($sThemePath . '/oktTheme.php', str_replace($aSearch, $aReplace, file_get_contents(OKT_INC_PATH . '/admin/configuration/themes/templates/oktTheme.tpl'))); copy(OKT_INC_PATH . '/admin/configuration/themes/templates/locked_files.txt', $sThemePath . '/locked_files.txt'); # css files files::makeDir($sThemePath . '/css'); copy(OKT_INC_PATH . '/admin/configuration/themes/templates/definitions.less.tpl', $sThemePath . '/css/definitions.less'); copy(OKT_INC_PATH . '/admin/configuration/themes/templates/index.html.tpl', $sThemePath . '/css/index.html'); copy(OKT_INC_PATH . '/admin/configuration/themes/templates/overload.less.tpl', $sThemePath . '/css/overload.less'); # images files files::makeDir($sThemePath . '/images'); copy(OKT_INC_PATH . '/admin/configuration/themes/templates/index.html.tpl', $sThemePath . '/images/index.html'); # js files::makeDir($sThemePath . '/js'); copy(OKT_INC_PATH . '/admin/configuration/themes/templates/index.html.tpl', $sThemePath . '/js/index.html'); # locales files files::makeDir($sThemePath . '/locales'); files::makeDir($sThemePath . '/locales/fr'); copy(OKT_INC_PATH . '/admin/configuration/themes/templates/index.html.tpl', $sThemePath . '/locales/fr/index.html'); # modules files files::makeDir($sThemePath . '/modules'); copy(OKT_INC_PATH . '/admin/configuration/themes/templates/index.html.tpl', $sThemePath . '/modules/index.html'); # templates files files::makeDir($sThemePath . '/templates'); copy(OKT_INC_PATH . '/admin/configuration/themes/templates/index.html.tpl', $sThemePath . '/templates/index.html'); copy(OKT_THEMES_PATH . '/default/templates/layout.php', $sThemePath . '/templates/layout.php'); return $sId; } catch (Exception $e) { throw new Exception($e->getMessage()); } }
$p_tpl_desc = $aTemplateInfo['desc']; $p_tpl_version = $aTemplateInfo['version']; $p_tpl_author = $aTemplateInfo['author']; $p_tpl_tags = $aTemplateInfo['tags']; } /* Traitements ----------------------------------------------------------*/ # formulaire envoyé if (!empty($_POST['form_sent']) && $sThemeId) { $p_tpl_id = !empty($_POST['p_tpl_id']) ? $_POST['p_tpl_id'] : ''; $p_tpl_name = !empty($_POST['p_tpl_name']) ? $_POST['p_tpl_name'] : ''; $p_tpl_desc = !empty($_POST['p_tpl_desc']) ? $_POST['p_tpl_desc'] : ''; $p_tpl_version = !empty($_POST['p_tpl_version']) ? $_POST['p_tpl_version'] : ''; $p_tpl_author = !empty($_POST['p_tpl_author']) ? $_POST['p_tpl_author'] : ''; $p_tpl_tags = !empty($_POST['p_tpl_tags']) ? $_POST['p_tpl_tags'] : ''; $p_tpl_id = util::strToLowerURL($p_tpl_id, false); $sTemplate = str_replace(array($sBasicTemplateTheme . '/templates', $sBasicTemplateId . '/template.php'), array($sThemeId . '/templates', $p_tpl_id . '/template.php'), $sBasicTemplate); $sTemplatePath = OKT_THEMES_PATH . $sTemplate; if (empty($p_tpl_id)) { $okt->error->set(__('c_a_te_error_must_tpl_id')); } elseif ($p_tpl_id == $sBasicTemplateId) { $okt->error->set(__('c_a_te_error_same_tpl_id')); } elseif (file_exists($sTemplatePath)) { $okt->error->set(sprintf(__('c_a_te_error_tpl_%s_allready_exists'), $sTemplate)); } if ($okt->error->isEmpty()) { util::rcopy(dirname($sBasicTemplatePath), dirname($sTemplatePath)); file_put_contents(dirname($sTemplatePath) . '/_define.php', '<?php' . "\n\n" . '$this->aCurrent = array(' . "\n" . ' \'name\' => \'' . addslashes($p_tpl_name) . '\',' . "\n" . ' \'desc\' => \'' . addslashes($p_tpl_desc) . '\',' . "\n" . ' \'version\' => \'' . addslashes($p_tpl_version) . '\',' . "\n" . ' \'author\' => \'' . addslashes($p_tpl_author) . '\',' . "\n" . ' \'tags\' => \'' . addslashes($p_tpl_tags) . '\'' . "\n" . ');' . "\n"); $okt->redirect('configuration.php?action=theme_editor&theme=' . $sThemeId . '&file=' . rawurlencode(str_replace('/' . $sThemeId . '/templates', '/templates', $sTemplate))); } }
public function delFile($question_id, $filename) { $rs = $this->getQuestion($question_id); if ($rs->isEmpty()) { $this->error->set('La question n\'existe pas.'); return false; } $i18n = $this->getQuestionI18n($question_id); # suppression du fichier sur le disque if (file_exists($this->upload_dir . $filename)) { unlink($this->upload_dir . $filename); } # suppression du nom dans les infos de la question $files_db = unserialize($rs->files); foreach ($files_db as $locale => $files) { foreach ($files as $k => $v) { if ($v == $filename) { unset($files_db[$locale][$k]); } } } foreach ($files_db as $locale => $files) { $files_db[$locale] = array_values($files); } foreach ($files_db as $locale => $files) { while ($i18n->fetch()) { if ($i18n->language == $locale) { $slug = $i18n->slug; } } foreach ($files as $k => $v) { $sExtension = pathinfo($v, PATHINFO_EXTENSION); $question_name = util::strToLowerURL($slug, false) . '-' . $locale . '-' . ($k + 1) . '.' . $sExtension; if (file_exists($this->upload_dir . $v)) { rename($this->upload_dir . $v, $this->upload_dir . $question_name); } $files_db[$locale][$k] = $question_name; } } $query = 'UPDATE ' . $this->t_faq . ' SET ' . 'files=\'' . $this->db->escapeStr(serialize($files_db)) . '\' ' . 'WHERE id=' . (int) $question_id; if (!$this->db->execute($query)) { return false; } return true; }