Commit c230e277 authored by Patrick Müller's avatar Patrick Müller

feat: Tiefe Projekt-Einstellungs-Suche

parent 631837f8
......@@ -21,7 +21,9 @@
</tr>
<tr class="{cycle values="odd,even"}">
<td class="first">
{t}quiqqer/system projects.project.settings.panel.mediaSettings.maxUploadSize{/t}
<label>
{t}quiqqer/system projects.project.settings.panel.mediaSettings.maxUploadSize{/t}
</label>
</td>
<td>
<input type="number" name="media_maxUploadSize" />
......@@ -47,10 +49,13 @@
</tr>
</thead>
<tbody>
<tr>
<tr class="{cycle values="odd,even"}">
<td class="first">
{t}quiqqer/system projects.project.settings.panel.mediaSettings.watermark{/t}
<label>
{t}quiqqer/system projects.project.settings.panel.mediaSettings.watermark{/t}
</label>
</td>
<td>
<input type="text" class="media-image" name="media_watermark" />
......@@ -58,7 +63,9 @@
</tr>
<tr class="{cycle values="odd,even"}">
<td class="first">
{t}quiqqer/system projects.project.settings.panel.mediaSettings.watermark.position{/t}
<label>
{t}quiqqer/system projects.project.settings.panel.mediaSettings.watermark.position{/t}
</label>
</td>
<td>
<select name="media_watermark_position">
......@@ -95,7 +102,9 @@
</tr>
<tr class="{cycle values="odd,even"}">
<td class="first">
{t}quiqqer/system projects.project.settings.panel.mediaSettings.watermark.ratio{/t}
<label>
{t}quiqqer/system projects.project.settings.panel.mediaSettings.watermark.ratio{/t}
</label>
</td>
<td>
<input type="number" name="media_watermark_ratio" />
......@@ -123,13 +132,17 @@
<tbody>
<tr class="{cycle values="odd,even" reset=true}">
<td class="first">
{t}quiqqer/system projects.project.site.media.manager.general.recalc.md5{/t}
<label>
{t}quiqqer/system projects.project.site.media.manager.general.recalc.md5{/t}
</label>
</td>
<td class="md5hash"></td>
</tr>
<tr class="{cycle values="odd,even"}">
<td class="first">
{t}quiqqer/system projects.project.site.media.manager.general.recalc.sha1{/t}
<label>
{t}quiqqer/system projects.project.site.media.manager.general.recalc.sha1{/t}
</label>
</td>
<td class="sha1hash"></td>
</tr>
......
......@@ -80,7 +80,8 @@ define('controls/projects/project/Settings', [
],
options: {
project: ''
project : '',
category: false // open category on settings panel load
},
initialize: function (options) {
......@@ -233,8 +234,20 @@ define('controls/projects/project/Settings', [
self.$config = result[0];
self.$defaults = result[1];
self.getCategoryBar().firstChild().click();
self.Loader.hide();
if (self.getAttribute('category')) {
var Wanted = self.getCategoryBar().getElement(
self.getAttribute('category')
);
if (Wanted) {
Wanted.click();
return;
}
}
self.getCategoryBar().firstChild().click();
});
},
......
......@@ -968,7 +968,6 @@ class Manager
}
}
QUI\Cache\Manager::set('qui/projects/', $list);
return $list;
......
......@@ -533,6 +533,12 @@ class Builder
$params['groupLabel'] = json_encode($params['groupLabel']);
}
if (isset($params['searchdata'])
&& is_array($params['searchdata'])
) {
$params['searchdata'] = json_encode($params['searchdata']);
}
$params['lang'] = $lang;
QUI::getDataBase()->insert($this->getTable(), $params);
......
......@@ -4,82 +4,72 @@ namespace QUI\Workspace\Search\Provider;
use QUI;
use QUI\Workspace\Search\ProviderInterface;
use QUI\Workspace\Search\Builder;
use QUI\Utils\Text\XML;
use QUI\Utils\DOM as DOMUtils;
class Projects implements ProviderInterface
{
const GROUP_WEBSITES = 'websites';
const GROUP_PROJECT_SETTINGS = 'project_settings';
/**
* Build the cache
*
* @return mixed
* @return void
*/
public function buildCache()
{
}
/**
* Execute a search
*
* @param string $search
* @param array $params
* @return mixed
*/
public function search($search, $params = array())
{
if (!in_array(Sites::FILTER_SITES, $params['filterGroups'])) {
return array();
}
$projects = QUI::getProjectManager()->getProjectList();
$results = array();
$Builder = Builder::getInstance();
$locales = $Builder->getLocales();
/** @var QUI\Projects\Project $Project */
foreach ($projects as $Project) {
$siteIds = $Project->getSitesIds(array(
'where' => array(
'active' => -1
),
'where_or' => array(
'title' => array(
'type' => '%LIKE%',
'value' => $search
),
'name' => array(
'type' => '%LIKE%',
'value' => $search
)
),
'limit' => isset($params['limit']) ? (int)$params['limit'] : null
));
$projectName = $Project->getName();
$projectLang = $Project->getLang();
$groupLabel = QUI::getLocale()->get(
'quiqqer/quiqqer',
'search.provider.sites.group.label',
array(
'projectName' => $projectName,
'projectLang' => $projectLang
$entry = array(
'id' => $projectName,
'title' => $projectName . ' (' . $projectLang . ')',
'icon' => 'fa fa-globe',
'groupLabel' => QUI::getLocale()->get(
'quiqqer/quiqqer',
'search.provider.projects.group.label'
),
'group' => self::GROUP_WEBSITES,
'filterGroup' => Sites::FILTER_SITES,
'search' => $projectName,
'searchdata' => array(
'require' => 'controls/projects/project/Settings',
'params' => array(
'project' => $projectName
)
)
);
$group = 'project-' . $projectName . '-' . $projectLang;
/** @var QUI\Locale $Locale */
foreach ($locales as $Locale) {
$Builder->addEntry($entry, $Locale->getCurrent());
$settingsEntries = $this->getProjectSettingsSearchTerms($Project, $Locale);
foreach ($siteIds as $row) {
$siteId = $row['id'];
$Site = $Project->get($siteId);
$results[] = array(
'id' => $projectName . '-' . $projectLang . '-' . $siteId,
'title' => $Site->getAttribute('title'),
'description' => $Site->getUrlRewritten(),
'icon' => 'fa fa-file-o',
'groupLabel' => $groupLabel,
'group' => $group
);
foreach ($settingsEntries as $settingsEntry) {
$Builder->addEntry($settingsEntry, $Locale->getCurrent());
}
return;
}
}
}
return $results;
/**
* Execute a search
*
* @param string $search
* @param array $params
* @return mixed
*/
public function search($search, $params = array())
{
}
/**
......@@ -90,18 +80,6 @@ class Projects implements ProviderInterface
*/
public function getEntry($id)
{
$data = explode('-', $id);
return array(
'searchdata' => json_encode(array(
'require' => 'package/quiqqer/quiqqer/bin/QUI/controls/workspace/search/provider/Sites',
'params' => array(
'projectName' => $data[0],
'projectLang' => $data[1],
'siteId' => $data[2]
)
))
);
}
/**
......@@ -112,14 +90,206 @@ class Projects implements ProviderInterface
*/
public function getFilterGroups()
{
return array(
return array();
}
/**
* Get all search entries from project settings
*
* @param QUI\Projects\Project $Project
* @param QUI\Locale $Locale
* @return array - search strings
*/
protected function getProjectSettingsSearchTerms($Project, $Locale)
{
$dataEntries = array();
$projectName = $Project->getName();
$description = $Locale->get(
'quiqqer/quiqqer',
'search.provider.projects.settings.description',
array(
'group' => self::FILTER_SITES,
'label' => array(
'quiqqer/quiqqer',
'search.provider.sites.filter.sites.label'
)
'project' => $projectName
)
);
$group = 'settings-' . $projectName;
$groupLabel = $Locale->get(
'quiqqer/quiqqer',
'search.provider.projects.settings.group.label',
array(
'project' => $projectName
)
);
// parse standard project settings templates (HARDCODED)
$templateFiles = array(
SYS_DIR . 'template/project/settings.html',
SYS_DIR . 'template/project/settingsAdmin.html',
SYS_DIR . 'template/project/settingsMedia.html'
);
// prepare Engine object for parsing
$Engine = QUI::getTemplateManager()->getEngine(true);
$Engine->assign(array(
'QUI' => new \QUI(),
'Project' => $Project
));
$Doc = new \DOMDocument();
foreach ($templateFiles as $template) {
$html = $Engine->fetch($template);
$search = array(); // search terms
$Doc->loadHTML($html);
$Path = new \DOMXPath($Doc);
// table headers
$titles = $Path->query('//table/thead/tr/th');
foreach ($titles as $Title) {
$search[] = utf8_decode(trim(DOMUtils::getTextFromNode($Title)));
}
// labels
$labels = $Path->query('//label');
/** @var \DOMNode $Label */
foreach ($labels as $Label) {
$search[] = utf8_decode(trim(DOMUtils::getTextFromNode($Label)));
}
$templateName = basename($template, '.html');
switch ($templateName) {
case 'settings':
$text = $Locale->get('quiqqer/system', 'projects.project.panel.settings.btn.settings');
$icon = 'fa fa-gear';
$category = 'settings';
break;
case 'settingsAdmin':
$text = $Locale->get('quiqqer/system', 'projects.project.panel.settings.btn.adminSettings');
$icon = 'fa fa-gear';
$category = 'adminSettings';
break;
case 'settingsMedia':
$text = $Locale->get('quiqqer/system', 'projects.project.panel.settings.btn.media');
$icon = 'fa fa-picture-o';
$category = 'mediaSettings';
break;
}
$entry = array(
'title' => $text,
'description' => $description,
'searchdata' => array(
'require' => 'controls/projects/project/Settings',
'params' => array(
'project' => $projectName,
'category' => $category
)
),
'search' => implode(' ', $search),
'icon' => $icon,
'group' => $group,
'filterGroup' => SettingsCategories::TYPE_SETTINGS_CONTENT,
'groupLabel' => $groupLabel
);
$dataEntries[] = $entry;
}
// parse xml files that extend the standard project settings
$xmlFiles = QUI::getProjectManager()->getRelatedSettingsXML($Project);
foreach ($xmlFiles as $xmlFile) {
if (!file_exists($xmlFile)) {
QUI\System\Log::addWarning(
self::class . ' :: parseSearchStringFromSettingsXml -> XML file ' . $xmlFile . ' does not exist.'
);
continue;
}
$Dom = XML::getDomFromXml($xmlFile);
$Path = new \DOMXPath($Dom);
$categories = $Path->query("//settings/window/categories/category");
/** @var \DOMElement $Category */
foreach ($categories as $Category) {
$category = false;
if ($Category->hasAttribute('name')) {
$category = $Category->getAttribute('name');
}
$entry = array(
'searchdata' => array(
'require' => 'controls/projects/project/Settings',
'params' => array(
'project' => $projectName,
'category' => $category
)
),
'icon' => '',
'group' => $group,
'filterGroup' => SettingsCategories::TYPE_SETTINGS_CONTENT,
'groupLabel' => $groupLabel
);
$searchStringParts = array();
/** @var \DOMNode $Child */
foreach ($Category->childNodes as $Child) {
if ($Child->nodeName == '#text') {
continue;
}
if ($Child->nodeName == 'title' || $Child->nodeName == 'text') {
$nodeText = DOMUtils::getTextFromNode($Child);
$entry['title'] = $nodeText;
$entry['description'] = $description;
$searchStringParts[] = $nodeText;
continue;
}
if ($Child->nodeName == 'icon') {
$entry['icon'] = $Child->nodeValue;
continue;
}
if ($Child->nodeName == 'settings') {
/** @var \DOMNode $SettingChild */
foreach ($Child->childNodes as $SettingChild) {
if ($SettingChild->nodeName == 'title' || $SettingChild->nodeName == 'text') {
$searchStringParts[] = DOMUtils::getTextFromNode($SettingChild);
continue;
}
if ($SettingChild->nodeName == 'title' || $SettingChild->nodeName == 'text') {
$searchStringParts[] = DOMUtils::getTextFromNode($SettingChild);
continue;
}
if ($SettingChild->hasChildNodes()) {
foreach ($SettingChild->childNodes as $SettingInputChild) {
if ($SettingInputChild->nodeName == 'title' || $SettingInputChild->nodeName == 'text') {
$searchStringParts[] = DOMUtils::getTextFromNode($SettingInputChild);
break;
}
}
}
}
}
}
$entry['search'] = implode(' ', $searchStringParts);
$dataEntries[] = $entry;
}
}
return $dataEntries;
}
}
......@@ -233,7 +233,7 @@ class SettingsCategories implements ProviderInterface
$categories = $Path->query("//settings/window/categories/category");
$descPrefix = $Locale->get('quiqqer/system', 'settings') . ' -> ' . $item['text'];
// ad menu entry for settings
// add menu entry for settings
$dataEntries[] = array(
'title' => $item['text'],
'description' => $item['description'],
......
......@@ -625,6 +625,20 @@
<en><![CDATA[Website: [projectName] ([projectLang])]]></en>
</locale>
<!-- Provider: Projects -->
<locale name="search.provider.projects.group.label">
<de><![CDATA[Webseiten]]></de>
<en><![CDATA[Websites]]></en>
</locale>
<locale name="search.provider.projects.settings.group.label">
<de><![CDATA[Webseiten-Einstellungen: [project]]]></de>
<en><![CDATA[Website settings: [project]]]></en>
</locale>
<locale name="search.provider.projects.settings.description">
<de><![CDATA[Einstellungen -> Projekteinstellungen -> [project]]]></de>
<en><![CDATA[Settings -> Project settings -> [project]]]></en>
</locale>
<!-- Provider: Media -->
<locale name="search.provider.media.filter.folder.label">
<de><![CDATA[Ordner]]></de>
......@@ -2093,10 +2107,6 @@ Folgende Zeichen sind erlaubt: 0-9 a-z A-Z _ -</p>]]></de>
<de><![CDATA[Löschen]]></de>
<en><![CDATA[Delete]]></en>
</locale>
<locale name="projects.project.panel.settings.btn.settings">
<de><![CDATA[Einstellungen]]></de>
<en><![CDATA[Settings]]></en>
</locale>
<locale name="projects.project.panel.settings.btn.meta">
<de><![CDATA[Meta Angaben]]></de>
<en><![CDATA[Meta data]]></en>
......@@ -6845,6 +6855,10 @@ Folgende Zeichen sind erlaubt: 0-9 a-z A-Z _ -</p>]]></de>
<de><![CDATA[Backend-Einstellungen]]></de>
<en><![CDATA[Backend settings]]></en>
</locale>
<locale name="projects.project.panel.settings.btn.settings">
<de><![CDATA[Einstellungen]]></de>
<en><![CDATA[Settings]]></en>
</locale>
<locale name="projects.project.settings.panel.adminSettings.title">
<de><![CDATA[Projekteinstellungen für das Backend]]></de>
<en><![CDATA[Project settings for the backend]]></en>
......
......@@ -25,6 +25,7 @@
<desktopSearch src="\QUI\Workspace\Search\Provider\Media" />
<desktopSearch src="\QUI\Workspace\Search\Provider\SettingsCategories" />
<desktopSearch src="\QUI\Workspace\Search\Provider\UsersAndGroups" />
<desktopSearch src="\QUI\Workspace\Search\Provider\Projects" />
</provider>
</package>
</quiqqer>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment