Ejemplo n.º 1
0
 public function getModulesWithFrontendController()
 {
     $stmntMods = $this->db->prepare("\n\t\t\tSELECT *\n\t\t\tFROM cms_mod_available\n\t\t\tWHERE active = 1\n\t\t\tAND frontendcontroller IS NOT NULL\n\t\t\tORDER BY name\n\t\t");
     $resMods = $this->db->select($stmntMods);
     foreach ($resMods as $mod) {
         $mod->manifest_content = JsonUtils::decode($mod->manifest_content);
     }
     return $resMods;
 }
Ejemplo n.º 2
0
 public function renderDestinationColumn($value, $record, $selector, $tableRenderer)
 {
     $lang = $this->getLocaleHandler()->getLanguage();
     $destination = null;
     if ($record->external_source !== null) {
         $destination = 'External: <a href="' . $record->external_source . '">' . $record->external_source . '</a>';
     } elseif ($record->redirect_route_IDFK !== null) {
         $destination = 'Route redirect: <a href="#">' . $record->rr_pattern . ' (#' . $record->rrID . ')</a>';
     } elseif ($record->page_ID !== null) {
         $pagePath = $this->pageModel->getPagePath($record->page_ID);
         $pagePathHtml = array();
         foreach ($pagePath as $id => $title) {
             $pagePathHtml[] = '<a href="/backend/page/' . $id . '">' . $title . '</a>';
         }
         $pagePathHtml[] = ' <a href="#">' . $record->page_title . ' (#' . $record->page_ID . ', ' . $record->page_lang . ')</a>';
         $destination = 'Page: ' . implode(' > ', $pagePathHtml);
     } else {
         $destination = null;
     }
     if ($record->mod_IDFK !== null) {
         $jsonMod = JsonUtils::decode($record->manifest_content);
         $destination .= ', Module: <a href="/backend/module/' . $record->mod_name . '">' . (isset($jsonMod->name->{$lang}) ? $jsonMod->name->{$lang} : $record->mod_name) . '</a>';
     }
     return $destination;
 }
 /**
  * @param string $keywords
  * @param string $language
  *
  * @return \stdClass[]
  */
 protected function getCmsSearchResults($keywords, $language)
 {
     $searchModel = new SearchModel($this->cmsController->getDB());
     $searchIndex = Lucene::open($this->cmsController->getCore()->getSiteRoot() . 'index' . DIRECTORY_SEPARATOR . $language);
     /*$query = new Boolean(); // new Fuzzy()
     		$query->addSubquery(QueryParser::parse(
     			$keywords
     		), true);*/
     QueryParser::suppressQueryParsingExceptions();
     $query = QueryParser::parse($keywords);
     //$hits = $searchIndex->find($query, 'score', SORT_NUMERIC, SORT_DESC);
     $hits = $searchIndex->find($query);
     //echo'<pre>'; var_dump(/*$hits, */$indexSize, $documents);
     $searchResultsArr = array();
     $highlighter = new CmsSearchHighlighter($keywords);
     //$highlighter = new DefaultHighlighter();
     foreach ($hits as $hit) {
         /** @var QueryHit $hit */
         $searchResult = new \stdClass();
         // Gibt Zend_Search_Lucene_Document Objekte für diesen Treffer zurück
         /** @var Document $document */
         $document = $hit->getDocument();
         $doc = $searchModel->getDocumentByID($document->getFieldUtf8Value('ID'));
         if ($doc->getID() === null) {
             continue;
         }
         $fldType = $doc->getType();
         if ($fldType !== 'core_page') {
             $contentChunks = $highlighter->highlightMatches(strip_tags($doc->getDescription()), 'UTF-8');
             if ($contentChunks == '') {
                 $contentChunks = null;
             }
             // Gibt ein Zend_Search_Lucene_Field Objekt von
             // Zend_Search_Lucene_Document zurück
             $searchResult->title = $highlighter->highlightMatches(strip_tags($doc->getTitle()), 'UTF-8');
             $searchResult->description = $contentChunks;
             $searchResult->url = $doc->getPath();
             if (isset($searchResultsArr[$fldType]) === false) {
                 $stmntModName = $this->cmsController->getDB()->prepare("\n\t\t\t\t\t\tSELECT manifest_content FROM cms_mod_available WHERE name = ?\n\t\t\t\t\t");
                 $resModName = $this->cmsController->getDB()->select($stmntModName, array($fldType));
                 $displayName = $fldType;
                 try {
                     $manifestObj = JsonUtils::decode($resModName[0]->manifest_content);
                     if (isset($manifestObj->name->{$language})) {
                         $displayName = $manifestObj->name->{$language};
                     } elseif (isset($manifestObj->name->en)) {
                         $displayName = $manifestObj->name->en;
                     }
                 } catch (\Exception $e) {
                 }
                 $searchResultsArr[$fldType] = new \stdClass();
                 $searchResultsArr[$fldType]->title = $displayName;
                 $searchResultsArr[$fldType]->results = array();
             }
             $searchResultsArr[$doc->getType()]->results[] = $searchResult;
         } else {
             $contentChunks = $this->createChunkedHighlighting($highlighter->highlightMatches(strip_tags($doc->getDescription()), 'UTF-8'));
             if ($contentChunks == '') {
                 $contentChunks = null;
             }
             // Gibt ein Zend_Search_Lucene_Field Objekt von
             // Zend_Search_Lucene_Document zurück
             $searchResult->title = $highlighter->highlightMatches(strip_tags($doc->getTitle()), 'UTF-8');
             $searchResult->description = $contentChunks;
             $searchResult->url = $doc->getPath();
             if (isset($searchResultsArr[$fldType]) === false) {
                 $searchResultsArr[$fldType] = new \stdClass();
                 $searchResultsArr[$fldType]->title = 'Andere Suchresultate';
                 $searchResultsArr[$fldType]->results = array();
             }
             $searchResultsArr[$doc->getType()]->results[] = $searchResult;
         }
     }
     return $searchResultsArr;
 }
Ejemplo n.º 4
0
 /**
  * Shows all the pages and their dependencies
  * 
  * @return HttpResponse
  */
 public function getModulesOverview()
 {
     if ($this->httpRequest->getVar('deactivate') !== null) {
         $this->setActivationOfModule($this->httpRequest->getVar('deactivate'), false);
     }
     if ($this->httpRequest->getVar('activate') !== null) {
         $this->setActivationOfModule($this->httpRequest->getVar('activate'), true);
     }
     $stmntMods = $this->db->prepare("\n\t\t\tSELECT ID, name identifier, active, path, manifest_content\n\t\t\tFROM cms_mod_available\n\t\t\tORDER BY name\n\t\t");
     $resMods = $this->db->select($stmntMods);
     $lang = $this->core->getLocaleHandler()->getLanguage();
     foreach ($resMods as $mod) {
         $mod->version = null;
         $mod->author = null;
         $mod->description = null;
         $mod->name = null;
         $mod->active_link = $mod->active == 1 ? 'yes [<a href="?deactivate=' . $mod->ID . '">deactivate</a>]' : 'no [<a href="?activate=' . $mod->ID . '">activate</a>]';
         try {
             $manifestObj = JsonUtils::decode($mod->manifest_content);
             if (isset($manifestObj->version)) {
                 $mod->version = $manifestObj->version;
             }
             if (isset($manifestObj->author->name)) {
                 $mod->author = $manifestObj->author->name;
             }
             if (isset($manifestObj->desciption->{$lang})) {
                 $mod->description = $manifestObj->description->{$lang};
             } elseif (isset($manifestObj->description->en)) {
                 $mod->description = $manifestObj->description->de;
             }
             if (isset($manifestObj->name->{$lang})) {
                 $mod->name = $manifestObj->name->{$lang};
             } elseif (isset($manifestObj->name->en)) {
                 $mod->name = $manifestObj->name->de;
             }
         } catch (\Exception $e) {
             $this->logger->error('Could not load module information from json string', $e);
             continue;
         }
     }
     return $this->generatePageFromTemplate('backend-modules-overview.html', array('modules' => $resMods, 'siteTitle' => 'Modules'));
 }
    /**
     * 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;
    }