diff --git a/bricks.xml b/bricks.xml index b3b92bd2878d99e6fcd82f390f6a66fde480046f..bdff38d2d02f2f1b472b649addd095d5a95ad9cf 100644 --- a/bricks.xml +++ b/bricks.xml @@ -82,6 +82,72 @@ </settings> </brick> + <!-- Url list --> + <brick control="\QUI\Menu\UrlList"> + <title> + <locale group="quiqqer/menu" + var="menu.control.urlList.title"/> + </title> + <description> + <locale group="quiqqer/menu" + var="menu.control.urlList.description"/> + </description> + + <settings> + <setting name="display" type="select"> + <locale group="quiqqer/menu" + var="menu.control.urlList.setting.display"/> + + <option value="default"> + <locale group="quiqqer/menu" + var="menu.control.urlList.setting.display.default"/> + </option> + </setting> + + <setting name="headerText"> + <locale group="quiqqer/menu" + var="menu.control.urlList.setting.headerText"/> + </setting> + + <setting name="menuId" data-qui="package/quiqqer/menu/bin/Controls/Independent/Input" type="text"> + <locale group="quiqqer/menu" + var="menu.control.urlList.setting.menuId"/> + <description> + <locale group="quiqqer/menu" + var="menu.control.urlList.setting.menuId.desc"/> + </description> + </setting> + + <setting name="startId" class="project-site"> + <locale group="quiqqer/menu" + var="menu.control.urlList.setting.startId"/> + <description> + <locale group="quiqqer/menu" + var="menu.control.urlList.setting.startId.desc"/> + </description> + </setting> + + <setting name="icon" type="text" class="media-image" data-qui-options-cssclasses="1"> + <locale group="quiqqer/menu" + var="menu.control.urlList.setting.icon"/> + <description> + <locale group="quiqqer/menu" + var="menu.control.urlList.setting.icon.desc"/> + </description> + </setting> + + <setting name="resetLinkColor" type="checkbox"> + <locale group="quiqqer/menu" + var="menu.control.urlList.setting.resetLinkColor"/> + <description> + <locale group="quiqqer/menu" + var="menu.control.urlList.setting.resetLinkColor.desc"/> + </description> + </setting> + + </settings> + </brick> + <!-- one page nav --> <brick control="\QUI\Menu\OnePageNav"> <title> diff --git a/locale.xml b/locale.xml index 94cb1620556089c1b4a849dda310cebc3122257f..d18959ca3021122c6360e59477662fd8a14fbd78 100644 --- a/locale.xml +++ b/locale.xml @@ -148,6 +148,60 @@ <en><![CDATA[Also show pages that do not have the property Show in navigation.]]></en> </locale> + <!-- url list --> + <locale name="menu.control.urlList.title"> + <de><![CDATA[Menu: Url Liste]]></de> + <en><![CDATA[Menu: Url list]]></en> + </locale> + <locale name="menu.control.urlList.description"> + <de><![CDATA[Einfache Seitenliste, die man perfekt im Footer verwenden kann. Der Baustein wird nur die erste Ebene der Unterseiten aufbauen.]]></de> + <en><![CDATA[Simple page list that you can use perfectly in the footer. This control will build only the first level of the subpages.]]></en> + </locale> + <locale name="menu.control.urlList.setting.display"> + <de><![CDATA[Layout]]></de> + <en><![CDATA[Layout]]></en> + </locale> + <locale name="menu.control.urlList.setting.display.default"> + <de><![CDATA[Standard]]></de> + <en><![CDATA[Default]]></en> + </locale> + <locale name="menu.control.urlList.setting.headerText"> + <de><![CDATA[Titel über der Seitenliste]]></de> + <en><![CDATA[Titel above the url list]]></en> + </locale> + <locale name="menu.control.urlList.setting.menuId"> + <de><![CDATA[Menu ID]]></de> + <en><![CDATA[Menu ID]]></en> + </locale> + <locale name="menu.control.urlList.setting.menuId.desc"> + <de><![CDATA[Menu ID auswählen.]]></de> + <en><![CDATA[Select your menu]]></en> + </locale> + <locale name="menu.control.urlList.setting.startId"> + <de><![CDATA[Elternseite]]></de> + <en><![CDATA[Parent site]]></en> + </locale> + <locale name="menu.control.urlList.setting.startId.desc"> + <de><![CDATA[Bitte die Elternseite auswählen. <strong>Achtung!</strong> Wenn "Menu ID" ausgewählt ist, hat diese Option keine Auswirkung.]]></de> + <en><![CDATA[Select the parent site. <strong>Notice:</strong> if "Menu ID" is selected, this option has no effect.]]></en> + </locale> + <locale name="menu.control.urlList.setting.icon"> + <de><![CDATA[Icon]]></de> + <en><![CDATA[Icon]]></en> + </locale> + <locale name="menu.control.urlList.setting.icon.desc"> + <de><![CDATA[Wenn ein Icon ausgewählt ist, wird sie vor dem Link eingeblendet. Es werden nur FontAwesome Icons unterstützt. <strong>Tipp!</strong> Im Auswahl-Fenster kann man nach <code>right</code> filtern, falls man ein Icon in Pfeil-Stil benutzen möchte.]]></de> + <en><![CDATA[When an icon is selected, it is displayed in front of the link. Only FontAwesome icons are supported. In the selection window you can filter by <code>right</code> if you want to use an arrow-style icon.]]></en> + </locale> + <locale name="menu.control.urlList.setting.resetLinkColor"> + <de><![CDATA[Link Farbe zurücksetzen]]></de> + <en><![CDATA[Reset link color]]></en> + </locale> + <locale name="menu.control.urlList.setting.resetLinkColor.desc"> + <de><![CDATA[Wenn die Option aktiv ist, ist der Link in der gleichen Farbe, wie Seiteninhalt. Die Option beeinflusst den Mouse-Over effekt nicht. <strong>Achtung!</strong> Das benutzte Template kann die Einstellung überschreiben.]]></de> + <en><![CDATA[If the option is active, the link has the same color as the page content. This option does not affect the mouse-over effect. <strong>Caution!</strong> The template, you are using, can overwrite this setting.]]></en> + </locale> + <!-- one page nav --> <locale name="menu.control.OnePageNav.title"> <de><![CDATA[Menu: One Page Menü (für Landingpage)]]></de> diff --git a/src/QUI/Menu/UrlList.Default.css b/src/QUI/Menu/UrlList.Default.css new file mode 100644 index 0000000000000000000000000000000000000000..a839faa276017fc1f1cb1dfebc7d82a8531240b1 --- /dev/null +++ b/src/QUI/Menu/UrlList.Default.css @@ -0,0 +1,25 @@ +.quiqqer-urlList-entries { + padding-left: 0; + margin: 0 0 1em 0; +} + +.quiqqer-urlList-entry { + padding-left: 0; + margin: 0 0 0.5em 0; +} + +.quiqqer-urlList-entry-link__resetLinkColor { + display: inline-flex; +} + +/* icon */ +.quiqqer-urlList-entry-link-icon { + margin-right: 0.5em; + flex-shrink: 0; + line-height: inherit; +} + +/* reset link */ +.quiqqer-urlList-entry-link__resetLinkColor:not(:hover, :focus) { + color: inherit; +} \ No newline at end of file diff --git a/src/QUI/Menu/UrlList.Default.html b/src/QUI/Menu/UrlList.Default.html new file mode 100644 index 0000000000000000000000000000000000000000..4e3947a15a0454f3fab3b26053394a6f52b5d49d --- /dev/null +++ b/src/QUI/Menu/UrlList.Default.html @@ -0,0 +1,33 @@ +{if $this->getAttribute('showTitle') && $this->getAttribute('frontendTitle')} + <header class="control-header"> + <h2>{$this->getAttribute('frontendTitle')}</h2> + </header> +{/if} + +{if $this->getAttribute('content') != ""} + <div class="control-content"> + {$this->getAttribute('content')} + </div> +{/if} + +{if $headerText} + <h5 class="quiqqer-urlList-title"> + {$headerText} + </h5> +{/if} +{strip} + {if count($children)} + <ul class="quiqqer-urlList-entries list-unstyled"> + {foreach from=$children item=Child} + <li class="quiqqer-urlList-entry"> + <a href="{url site=$Child}" class="quiqqer-urlList-entry-link {$restLinkColorCss}"> + {if $icon} + <span class="{$icon} fa-fw quiqqer-urlList-entry-link-icon"></span> + {/if} + <span class="quiqqer-urlList-entry-link-text">{$Child->getAttribute('title')}</span> + </a> + </li> + {/foreach} + </ul> + {/if} +{/strip} diff --git a/src/QUI/Menu/UrlList.Independent.Default.html b/src/QUI/Menu/UrlList.Independent.Default.html new file mode 100644 index 0000000000000000000000000000000000000000..0e091f7506b622e0336e388231151ad9ab2b8123 --- /dev/null +++ b/src/QUI/Menu/UrlList.Independent.Default.html @@ -0,0 +1,45 @@ +{if $this->getAttribute('showTitle') && $this->getAttribute('frontendTitle')} + <header class="control-header"> + <h2>{$this->getAttribute('frontendTitle')}</h2> + </header> +{/if} + +{if $this->getAttribute('content') != ""} + <div class="control-content"> + {$this->getAttribute('content')} + </div> +{/if} + +{if $headerText} + <h5 class="quiqqer-urlList-title"> + {$headerText} + </h5> +{/if} +{strip} + {if count( $children )} + <ul class="quiqqer-urlList-entries list-unstyled"> + {foreach from=$children item=Child} + <li class="quiqqer-urlList-entry"> + {if $Child->getUrl()} + <a href="{$Child->getUrl()}" class="quiqqer-urlList-entry-link {$restLinkColorCss}" + title="{$Child->getTitleAttribute()|escape:'html'}" + {if $Child->getTarget()}target="{$Child->getTarget()}"{/if}> + {if $icon} + <span class="{$icon} fa-fw quiqqer-urlList-entry-link-icon"></span> + {/if} + <span class="quiqqer-urlList-entry-link-text">{$Child->getTitle()}</span> + </a> + {else} + <span class="quiqqer-urlList-entry-link" + title="{$Child->getTitleAttribute()|escape:'html'}"> + {if $icon} + <span class="{$icon} fa-fw quiqqer-urlList-entry-link-icon"></span> + {/if} + <span class="quiqqer-urlList-entry-link-text">{$Child->getTitle()}</span> + </span> + {/if} + </li> + {/foreach} + </ul> + {/if} +{/strip} \ No newline at end of file diff --git a/src/QUI/Menu/UrlList.php b/src/QUI/Menu/UrlList.php new file mode 100644 index 0000000000000000000000000000000000000000..889c191d68a62bdd35b4f5b2e9f5263412662fea --- /dev/null +++ b/src/QUI/Menu/UrlList.php @@ -0,0 +1,161 @@ +<?php + +/** + * This file contains \QUI\Menu\UrlList + */ + +namespace QUI\Menu; + +use QUI; +use QUI\Projects\Site\Utils; + +/** + * Class UrlList + * + * Simple url list. + * + * It creates a list of sites. + * This control is supposed to work with QUI Independent Menu, but you can use it with QUI Site. + * You have to pass a menu ID or a parent page. + * + * Only one level of sub sites will be displayed started from given page (or menu id). + * This control DO NOT support nested navigation structure. + * + * @package QUI\Menu + * @author www.pcsg.de (Michael Danielczok) + */ +class UrlList extends QUI\Control +{ + /** + * @param array $attributes + */ + public function __construct($attributes = []) + { + // defaults values + $this->setAttributes([ + 'class' => 'quiqqer-urlList', + 'headerText' => '', // title above the url list + 'startId' => false, // id or site link + 'menuId' => false, // id of an (independent) menu + 'display' => 'default', + 'icon' => '', // only fontawesome icons are supported + 'resetLinkColor' => false // if true, the link inherit color from parent + ]); + + parent::__construct($attributes); + + $this->setAttribute('cacheable', false); + } + + /** + * (non-PHPdoc) + * + * @see \QUI\Control::create() + */ + public function getBody() + { + $Engine = QUI::getTemplateManager()->getEngine(); + + if (!$this->getAttribute('menuId') && !$this->getAttribute('startId')) { + return ''; + } + + if ($this->getAttribute('menuId')) { + // independent menu + $children = $this->getChildrenForIndependentMenu(); + $template = dirname(__FILE__).'/UrlList.Independent.Default.html'; + } elseif ($this->getAttribute('startId')) { + // qui site + $children = $this->getChildrenForQUISite(); + $template = dirname(__FILE__).'/UrlList.Default.html'; + } else { + $children = []; + } + + $icon = ''; + + if ($this->getAttribute('icon') && strpos($this->getAttribute('icon'), 'fa ') === 0) { + $icon = $this->getAttribute('icon'); + } + + switch ($this->getAttribute('display')) { + default: + case 'default': + $this->addCSSClass('quiqqer-urlList__default'); + break; + } + + $restLinkColorCss = ''; + if ($this->getAttribute('resetLinkColor')) { + $restLinkColorCss = 'quiqqer-urlList-entry-link__resetLinkColor'; + + } + + $Engine->assign([ + 'this' => $this, + 'headerText' => $this->getAttribute('headerText'), + 'children' => $children, + 'icon' => $icon, + 'restLinkColorCss' => $restLinkColorCss + ]); + + $this->addCSSFile(dirname(__FILE__).'/UrlList.Default.css'); + + return $Engine->fetch($template); + } + + /** + * Get sites for independent menu + * + * @return array + * @throws QUI\Exception + */ + public function getChildrenForIndependentMenu() + { + $IndependentMenu = Independent\Handler::getMenu($this->getAttribute('menuId')); + + return $IndependentMenu->getChildren(); + } + + /** + * Get sites for QUI site + * + * @return array + * @throws QUI\Exception + */ + public function getChildrenForQUISite() + { + $Project = $this->getProject(); + + // start + try { + $startId = $this->getAttribute('startId'); + + if (Utils::isSiteLink($startId)) { + $Site = Utils::getSiteByLink($startId); + } else { + $Site = $Project->get((int)$startId); + } + } catch (QUI\Exception $Exception) { + QUI\System\Log::addWarning($Exception->getMessage()); + + return []; + } + + return $this->getChildren($Site); + } + + /** + * @param QUI\Projects\Site $Site + * @return array|int + * @throws QUI\Exception + */ + public function getChildren(QUI\Projects\Site $Site) + { + if (!$this->getAttribute('showAllChildren')) { + return $Site->getNavigation(); + } + + return $Site->getChildren(); + } +}