public function __construct(Core $core, HttpRequest $httpRequest, Route $route)
 {
     parent::__construct($core, $httpRequest, $route);
     $this->pageModel = new PageModel($this->db);
     $this->routeModel = new RouteModel($this->db);
     $this->markHtmlIdAsActive('routes');
 }
Example #2
0
 public function __construct(Core $core, HttpRequest $httpRequest, Route $route)
 {
     parent::__construct($core, $httpRequest, $route);
     $this->pageModel = new PageModel($this->db);
     $this->logger = FrameworkLoggerFactory::getLogger($this);
     $this->markHtmlIdAsActive('pages');
     $cacheDir = $this->core->getSiteCacheDir() . 'templates' . DIRECTORY_SEPARATOR;
     $templateBaseDir = $this->core->getSiteRoot() . 'templates' . DIRECTORY_SEPARATOR;
     $tplCache = new DirectoryTemplateCache($cacheDir, $templateBaseDir);
     $this->moduleView = new CmsView(new CmsTemplateEngine($tplCache, 'tst'), $templateBaseDir . $this->currentDomain->template . DIRECTORY_SEPARATOR . 'elements' . DIRECTORY_SEPARATOR);
 }
 public function __construct(Core $core, HttpRequest $httpRequest, Route $route)
 {
     parent::__construct($core, $httpRequest, $route);
     $this->logger = FrameworkLoggerFactory::getLogger($this);
     $this->markHtmlIdAsActive('elements');
 }
 public function __construct(Core $core, HttpRequest $httpRequest, Route $route)
 {
     parent::__construct($core, $httpRequest, $route);
 }
Example #5
0
 protected function getNavigations(BackendController $backendController)
 {
     $stmntNavs = $backendController->getDB()->prepare("\n\t\t\tSELECT ID, name FROM navigation ORDER BY name\n\t\t");
     $resNavs = $backendController->getDB()->select($stmntNavs);
     $catsArr = array();
     foreach ($resNavs as $c) {
         $catsArr[$c->ID] = $c->name;
     }
     return $catsArr;
 }
Example #6
0
    /**
     * @param BackendController $backendController
     * @param int $pageID
     *
     * @return string
     */
    public function generateRevisionBox(BackendController $backendController, $pageID)
    {
        $revisionPath = $backendController->getCore()->getSiteRoot() . 'revision' . DIRECTORY_SEPARATOR . $this->identifier . DIRECTORY_SEPARATOR;
        $modIDStr = 'mod-' . $this->ID . '-' . $pageID;
        $i = 0;
        $htmlOpts = '';
        $currentRevision = null;
        if (is_dir($revisionPath) === true) {
            $files = scandir($revisionPath, 1);
            $fileNamePattern = $this->identifier . '.' . $this->ID . '-' . $pageID . '.';
            $fileNamePatternLength = strlen($fileNamePattern);
            $dateTimeFormat = $backendController->getLocaleHandler()->getDateTimeFormat();
            foreach ($files as $f) {
                if (($offset = strpos($f, $fileNamePattern)) === false) {
                    continue;
                }
                $fileNameCropped = substr($f, $offset + $fileNamePatternLength);
                $revInfo = explode('.', $fileNameCropped);
                $selected = null;
                $currentStr = null;
                $currentRevision = null;
                if ($revInfo[0] == $this->revision || $this->revision === null && $i === 0) {
                    $selected = ' disabled';
                    $currentStr = ' - current';
                    $currentRevision = $revInfo[0];
                }
                $df = new \DateTime($revInfo[0]);
                $htmlOpts .= '<option value="' . $this->identifier . DIRECTORY_SEPARATOR . $f . '"' . $selected . '>' . $revInfo[1] . ' (' . $df->format($dateTimeFormat) . ')' . $currentStr . '</option>';
                ++$i;
            }
        }
        $html = '<form method="post" class="mod-config-form" element="' . $modIDStr . '">
			<p>There are ' . $i . ' revisions for this element.</p>
			<p>Current revision: ' . $currentRevision . '</p>
			<dl>
				<dt><label for="revision">Revision</label></dt>
				<dd><select id="revision" name="revision">
					<option>- please chose -</option>' . $htmlOpts . '
				</select></dd>
			</dl>
		</form>';
        return $html;
    }
    /**
     * Generates the HTML config form for the element
     * 
     * @param BackendController $backendController
     * @param int $pageID The current pages ID
     *
     * @return string The config box as HTML
     * @throws CMSException
     * @throws \Exception
     */
    public function generateConfigBox(BackendController $backendController, $pageID)
    {
        $lang = $backendController->getLocaleHandler()->getLanguage();
        $configFilePath = $backendController->getCore()->getSiteRoot() . 'settings' . DIRECTORY_SEPARATOR . 'elements' . DIRECTORY_SEPARATOR;
        $configFile = $configFilePath . $this->identifier . '.config.json';
        if (file_exists($configFile) === false) {
            throw new CMSException('No settings found for this module: ' . $this->identifier);
        }
        try {
            $jsonConfig = JsonUtils::decode(file_get_contents($configFile));
            if (!isset($jsonConfig->settings)) {
                return 500;
            }
        } catch (\Exception $e) {
            throw $e;
        }
        $modIDStr = 'mod-' . $this->ID . '-' . $pageID;
        $boxHtml = '<form method="post" class="mod-config-form" element="' . $modIDStr . '"><fieldset><legend>Element specific</legend>';
        foreach ($jsonConfig->settings as $key => $entry) {
            $fld = null;
            $hintHtml = isset($entry->hint) ? '<abbr title="' . $entry->hint->{$lang} . '">?</abbr>' : null;
            $settingValue = isset($this->settings->{$key}) ? $this->settings->{$key} : null;
            $idStr = 'mod-' . $this->ID . '-' . $pageID . '-' . $key;
            $requiredHtml = $entry->required ? '<em title="required">*</em>' : null;
            $requiredAttr = $entry->required ? ' required' : null;
            if (in_array($entry->type, array('select', 'option', 'select-multi', 'multi-option'))) {
                $multiple = null;
                $multiBrackets = null;
                if (in_array($entry->type, array('select-multi', 'multi-option'))) {
                    $multiple = ' multiple';
                    $multiBrackets = '[]';
                }
                $fld .= '<dl><dt><label for="' . $idStr . '">' . $entry->label->{$lang} . $requiredHtml . '</label></dt>
				<dd><select name="' . $key . $multiBrackets . '" id="' . $idStr . '"' . $requiredAttr . $multiple . '>';
                $values = $this->getValues($entry->options, $backendController);
                foreach ($values as $optKey => $optVal) {
                    if (in_array($entry->type, array('select-multi', 'multi-option'))) {
                        $selected = in_array($optKey, $this->settings->{$key}) ? ' selected' : null;
                    } else {
                        $selected = $this->settings->{$key} == $optKey ? ' selected' : null;
                    }
                    $fld .= '<option value="' . $optKey . '"' . $selected . '>' . $optVal . '</option>';
                }
                $fld .= '</select>' . $hintHtml . '</dd></dl>';
            } elseif (in_array($entry->type, array('input', 'email', 'number', 'url', 'regex', 'string', 'text', 'file'))) {
                $dataAttrs = null;
                if (in_array($entry->type, array('input', 'text', 'string', 'number', 'regex'))) {
                    $typeStr = 'text';
                    $dataAttrs = ' data-type="string"';
                } elseif ($entry->type === 'file') {
                    $typeStr = 'text';
                    $dataAttrs = ' class="filechooser"';
                } else {
                    $typeStr = $entry->type;
                    $dataAttrs = ' data-type="' . $entry->type . '"';
                }
                if ($entry->type === 'regex' && isset($entry->regex)) {
                    $dataAttrs = ' data-type="regex" regex="' . $entry->regex . '"';
                }
                if ($entry->type === 'number') {
                    $minStr = isset($entry->min) ? ' min="' . $entry->min . '"' : null;
                    $maxStr = isset($entry->max) ? ' max="' . $entry->max . '"' : null;
                    if ($minStr !== null || $maxStr !== null) {
                        $dataAttrs = $minStr . $maxStr;
                    }
                }
                if (in_array($entry->type, array('input', 'text', 'string'))) {
                    $minStr = isset($entry->minLength) ? ' minlength="' . $entry->minLength . '"' : null;
                    $maxStr = isset($entry->maxLength) ? ' maxlength="' . $entry->maxLength . '"' : null;
                    if ($minStr !== null || $maxStr !== null) {
                        $dataAttrs = $minStr . $maxStr;
                    }
                }
                $sizeClass = StringUtils::afterFirst($entry->type, '-');
                $sizeClassStr = $sizeClass !== '' ? ' class="' . $sizeClass . '"' : null;
                $fld .= '<dl><dt><label for="' . $idStr . '">' . $entry->label->{$lang} . $requiredHtml . '</label></dt>
				<dd><input type="' . $typeStr . '" name="' . $key . '" id="' . $idStr . '" value="' . $settingValue . '"' . $sizeClassStr . '' . $requiredAttr . '' . $dataAttrs . '>' . $hintHtml . '</dd></dl>';
            } elseif (in_array($entry->type, array('radio', 'multi-checkbox'))) {
                $values = $this->getValues($entry->options, $backendController);
                $type = null;
                $multiBrackets = in_array($entry->type, array('multi-checkbox')) ? '[]' : null;
                $selectedArr = is_array($this->settings->{$key}) ? $this->settings->{$key} : array($this->settings->{$key});
                if ($entry->type === 'radio') {
                    $type = 'radio';
                } elseif ($entry->type === 'multi-checkbox') {
                    $type = 'checkbox';
                }
                $fld .= '<dl><dt>' . $entry->label->{$lang} . '</dt>
				<dd><ul>';
                foreach ($values as $optKey => $optVal) {
                    $checked = in_array($optKey, $selectedArr) ? ' checked' : null;
                    $fld .= '<li><label><input type="' . $type . '" name="' . $key . $multiBrackets . '" value="' . $optKey . '"' . $checked . '>' . $optVal . '</label></li>';
                }
                $fld .= '</ul></dd></dl>';
            } elseif ($entry->type == 'toggle') {
                $checked = $this->settings->{$key} == 1 ? ' checked' : null;
                $fld .= '<dl><dt><label for="' . $idStr . '">' . $entry->label->{$lang} . $requiredHtml . '</label></dt>
				<dd><input type="checkbox" name="' . $key . '" id="' . $idStr . '" value="1"' . $requiredAttr . $checked . '>' . $hintHtml . '</dd></dl>';
            } elseif ($entry->type === 'wysiwyg') {
                $fld .= '<dl><dt><label for="' . $idStr . '">' . $entry->label->{$lang} . $requiredHtml . '</label></dt>
				<dd><textarea class="ckeditor" name="' . $key . '" id="' . $idStr . '"' . $requiredAttr . '>' . $settingValue . '</textarea>' . $hintHtml . '</dd></dl>';
            } else {
                throw new CMSException('Unknow settings data-type: ' . $entry->type);
            }
            $boxHtml .= $fld;
        }
        $boxHtml .= '</fieldset><fieldset><legend>General</legend>
			<dl><dt>Pass on</dt>
				<dd><ul>
					<li><label><input type="checkbox" value="1">Override children\'s settings</label></li>
				</ul></dd>
			</dl>';
        if ($this->settingsSelf) {
            $boxHtml .= '<dl>
				<dt>Delete</dt>
				<dd><ul>
					<li><label><input name="delete_settings" type="checkbox" value="1">Delete specific element settings on this page</label></li>
				</ul></dd>
			</dl>';
        }
        $boxHtml .= '</fieldset></form>
		<script src="/js/ckeditor/ckeditor.js"></script>
		<script src="/js/ckeditor/config.js"></script>
		<script src="/js/jquery.filechooser.js"></script>
		<script src="/js/cms.settingsbox.js"></script>';
        return $boxHtml;
    }
 public function __construct(Core $core, HttpRequest $httpRequest, Route $route)
 {
     parent::__construct($core, $httpRequest, $route);
     $this->markHtmlIdAsActive('users');
 }