Skip to content
Code-Schnipsel Gruppen Projekte
Commit 15aa42fd erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

PSR-2 -> lib to src

Übergeordneter 741ffac0
No related branches found
No related tags found
Keine zugehörigen Merge Requests gefunden
werden angezeigt mit 1685 Ergänzungen und 0 Löschungen
<?php
/**
* This file contains \QUI\Bricks\Brick
*/
namespace QUI\Bricks;
use QUI;
/**
* Class Brick
* A Brick from the Brickmanager
*
* @author www.pcsg.de (Henning Leutz)
* @package quiqqer/bricks
*/
class Brick extends QUI\QDOM
{
/**
* internal brick id
*
* @var
*/
protected $id = false;
/**
* Brick settings
*
* @var array
*/
protected $settings = array();
/**
* Fields can be overwritten by another user
*
* @var array
*/
protected $customfields = array();
/**
* Internal control
*
* @var null
*/
protected $Control = null;
/**
* List of extra css classes
*
* @var array
*/
protected $cssClasses = array();
/**
* Constructor
*
* @param array $params - brick params
*/
public function __construct($params = array())
{
// default
$default = array(
'type' => 'content',
'content' => '',
'title' => '',
'description' => '',
'project' => '',
'areas' => '',
'height' => '',
'width' => '',
'classes' => ''
);
$this->setAttributes($default);
foreach ($default as $key => $value) {
if (isset($params[$key])) {
$this->setAttribute($key, $params[$key]);
}
}
if (isset($params['id'])) {
$this->id = $params['id'];
}
// default settings from control
$Control = $this->getControl();
$Manager = Manager::init();
$availableSettings = $Manager->getAvailableBrickSettingsByBrickType(
$this->getAttribute('type')
);
foreach ($availableSettings as $entry) {
$this->settings[$entry['name']] = false;
}
// control default settings
if (is_object($Control)) {
$controlSettings = $Control->getAttributes();
foreach ($this->settings as $key => $value) {
if (isset($controlSettings[$key])) {
$this->settings[$key] = $controlSettings[$key];
}
}
}
// settings from database
if (isset($params['settings'])) {
$settings = $params['settings'];
if (is_string($settings)) {
$settings = json_decode($settings, true);
}
if (is_array($settings)) {
foreach ($this->settings as $key => $value) {
if (isset($settings[$key])) {
$this->settings[$key] = $settings[$key];
}
}
}
}
// customfields
if (isset($params['customfields'])) {
$customfields = $params['customfields'];
if (is_string($customfields)) {
$customfields = json_decode($customfields, true);
}
if (is_array($customfields)) {
$this->customfields = $customfields;
}
}
}
/**
* Return the class type
*
* @return String
*/
public function getType()
{
$Control = $this->getControl();
if (is_object($Control)) {
return get_class($Control);
}
return get_class($this);
}
/**
* Check, if control canbe created
*
* @throws QUI\Exception
* @return QUI\Bricks\Brick
*/
public function check()
{
if ($this->getAttribute('type') == 'content') {
return $this;
}
$Control = $this->getControl();
if (!$Control) {
throw new QUI\Exception('Control not found. Brick could not be created');
}
return $this;
}
/**
* Return the HTML of the Brick
*
* @return string
*
* @throws QUI\Exception
*/
public function create()
{
if ($this->getAttribute('type') == 'content') {
$_classes = array(
'brick-' . $this->id
);
foreach ($this->cssClasses as $cssClass) {
$_classes[] = $cssClass;
}
if ($this->getAttribute('classes')) {
$classes = explode(' ', $this->getAttribute('classes'));
foreach ($classes as $class) {
$class = trim($class);
$class = preg_replace('/[^a-zA-Z0-9\-]/', '', $class);
$_classes[] = $class;
}
}
$_classes = array_unique($_classes);
$classesStr = implode($_classes, ' ');
$classesStr = 'class="' . $classesStr . '"';
return "<div {$classesStr}>{$this->getAttribute('content')}</div>";
}
$Control = $this->getControl();
if (!$Control) {
throw new QUI\Exception('Control not found. Brick could not be created');
}
$Control->setAttributes($this->getSettings());
if ($this->getAttribute('classes')) {
$classes = explode(' ', $this->getAttribute('classes'));
foreach ($classes as $class) {
$class = trim($class);
$class = preg_replace('/[^a-zA-Z0-9\-]/', '', $class);
$Control->addCSSClass($class);
}
}
if ($this->id) {
$Control->addCSSClass('brick-' . $this->id);
}
foreach ($this->cssClasses as $cssClass) {
$Control->addCSSClass($cssClass);
}
return $Control->create();
}
/**
* Return the internal control
*
* @return QUI\Control|Bool
*/
protected function getControl()
{
if ($this->Control) {
return $this->Control;
}
$Ctrl = $this->getAttribute('type');
if ($Ctrl === 'content') {
return true;
}
if (!is_callable($Ctrl) && !class_exists($Ctrl)) {
return false;
}
/* @var $Control \QUI\Control */
$Control = new $Ctrl($this->getSettings());
$Control->setAttribute('height', $this->getAttribute('height'));
$Control->setAttribute('width', $this->getAttribute('width'));
$Control->setAttribute('content', $this->getAttribute('content'));
if (!($Control instanceof QUI\Control) || !$Control) {
return false;
}
$this->Control = $Control;
return $Control;
}
/**
* Return the brick settings
*
* @return array
*/
public function getSettings()
{
return $this->settings;
}
/**
* Set brick settings
*
* @param array $settings - list of settings
*
* @return void
*/
public function setSettings($settings)
{
foreach ($settings as $key => $value) {
$this->setSetting($key, $value);
}
}
/**
* Return the setting of the brick
*
* @param String $name - Name of the setting
*
* @return boolean|string
*/
public function getSetting($name)
{
if (isset($this->settings[$name])) {
return $this->settings[$name];
}
return false;
}
/**
* Set a brick setting
*
* @param string $name - name of the setting
* @param string $value - value of the setting
*
* @return void
*/
public function setSetting($name, $value)
{
if (isset($this->settings[$name])) {
$this->settings[$name] = $value;
}
}
/**
* This fields can be overwritten by another user
*
* @return array
*/
public function getCustomFields()
{
return $this->customfields;
}
/**
* Add an exxtra CSS Class to the control
*
* @param string $cssClass - Name of the CSS Class
*
* @return void
*/
public function addCSSClass($cssClass)
{
$this->cssClasses[] = $cssClass;
}
/**
* Match pattern agains the css classes
*
* @param string $pattern - The shell wildcard pattern.
*
* @return boolean
*/
public function hasCSSClass($pattern)
{
if ($this->getAttribute('classes')
&& fnmatch($pattern, $this->getAttribute('classes'))
) {
return true;
}
if (empty($this->cssClasses)) {
return false;
}
foreach ($this->cssClasses as $cssClass) {
if (fnmatch($pattern, $cssClass)) {
return true;
}
}
return false;
}
}
.quiqqer-bricks-banner {
margin-bottom: 0;
padding: 4.5em 0;
text-align: center;
}
\ No newline at end of file
<header>
<h2>{$this->getAttribute('title')}</h2>
<p>
{$this->getAttribute('text')}
</p>
</header>
<?php
/**
* This file contains QUI\Bricks\Controls\Banner
*/
namespace QUI\Bricks\Controls;
use QUI;
/**
* Class Banner
*
* @package quiqqer/bricks
*/
class Banner extends QUI\Control
{
/**
* constructor
*
* @param array $attributes
*/
public function __construct($attributes = array())
{
// default options
$this->setAttributes(array(
'title' => '',
'text' => '',
'class' => 'quiqqer-bricks-banner',
'nodeName' => 'section'
));
$this->addCSSFile(
dirname(__FILE__).'/Banner.css'
);
parent::setAttributes($attributes);
}
/**
* (non-PHPdoc)
*
* @see \QUI\Control::create()
*/
public function getBody()
{
$Engine = QUI::getTemplateManager()->getEngine();
$Engine->assign(array(
'this' => $this
));
return $Engine->fetch(dirname(__FILE__).'/Banner.html');
}
}
\ No newline at end of file
.quiqqer-box-content {
width: 100%;
}
.box-content-entry {
float: left;
padding-top: 20px;
padding-bottom: 0px;
}
.box-content-entry h4 {
width: 100%;
white-space: nowrap;
overflow: hidden;
-ms-text-overflow: ellipsis;
text-overflow: ellipsis;
}
.box-content-entry-1 {
width: 100%;
}
.box-content-entry-2 {
width: 50%;
}
.box-content-entry-3 {
width: 33%;
}
.box-content-entry-4 {
width: 25%;
}
.box-content-entry-5 {
width: 20%;
}
.box-content-entry-6 {
width: 16.6666%;
}
.box-content-entry-7 {
width: 14.27%;
}
.box-content-entry-8 {
width: 12.5%;
}
.box-content-entry-9 {
width: 11.11%;
}
.box-content-entry-10 {
width: 10%;
}
@media screen and (max-width: 767px) {
.quiqqer-box-content {
padding-top: 20px;
}
.box-content-entry {
padding-top: 0;
padding-bottom: 40px;
text-align: center;
width: 50% !important;
}
}
@media screen and (max-width: 460px) {
.box-content-entry {
width: 100% !important;
}
}
\ No newline at end of file
<div class="quiqqer-box-content">
{if $this->getAttribute('content')}
<div class="grid-100 grid-parent">
{$this->getAttribute('content')}
</div>
{/if}
{foreach from=$entries item=entry}
<div class="box-content-entry{$extraClass}">
<h4 title="{$entry.title|escape:"html"}">
{$entry.title}
</h4>
<p>{$entry.text}</p>
</div>
{/foreach}
</div>
\ No newline at end of file
<?php
/**
* This file contains QUI\Bricks\Controls\BoxContent
*/
namespace QUI\Bricks\Controls;
use QUI;
/**
* Class BoxContent
*
* @package quiqqer/bricks
*/
class BoxContent extends QUI\Control
{
/**
* constructor
*
* @param array $attributes
*/
public function __construct($attributes = array())
{
// default options
$this->setAttributes(array(
'title' => 'Box Content',
'contentList' => false,
'entries' => array()
));
parent::__construct($attributes);
$this->addCSSFile(
dirname(__FILE__) . '/BoxContent.css'
);
}
/**
* (non-PHPdoc)
*
* @see \QUI\Control::create()
*/
public function getBody()
{
$Engine = QUI::getTemplateManager()->getEngine();
$entries = $this->getAttribute('entries');
if (is_string($entries)) {
$entries = json_decode($entries, true);
}
$count = count($entries);
$extraClass = '';
switch ($count) {
case 1:
$extraClass = ' box-content-entry-1';
break;
case 2:
$extraClass = ' box-content-entry-2';
break;
case 3:
$extraClass = ' box-content-entry-3';
break;
case 4:
$extraClass = ' box-content-entry-4';
break;
case 5:
$extraClass = ' box-content-entry-5';
break;
case 6:
$extraClass = ' box-content-entry-6';
break;
case 7:
$extraClass = ' box-content-entry-7';
break;
case 8:
$extraClass = ' box-content-entry-8';
break;
case 9:
$extraClass = ' box-content-entry-9';
break;
case 10:
$extraClass = ' box-content-entry-10';
break;
}
$Engine->assign(array(
'this' => $this,
'entries' => $entries,
'extraClass' => $extraClass
));
return $Engine->fetch(dirname(__FILE__) . '/BoxContent.html');
}
}
.content-switcher {
display: flex;
min-height: 360px;
align-items: center;
flex-direction: row;
}
.content-switcher-image {
height: 400px;
width: 50%;
padding:50px;
display: flex;
align-items: center;
justify-content: center
}
img.content-switcher-image-img {
height: auto;
max-width: 100%;
}
.content-switcher-content {
width: 50%;
padding: 50px 0;
}
@media screen and (max-width: 767px){
.content-switcher {
flex-direction: column;
border-bottom: 2px solid #f5f5f5;
}
.content-switcher:last-child {
border-bottom: none;
}
.content-switcher-image {
width: 100%;
height: auto;
padding: 20px 0;
}
.content-switcher-content {
width: 100%;
}
}
{if !$this->getAttribute('content') == ""}
<div class="grid-100 grid-parent">
{$this->getAttribute('content')}
</div>
{/if}
{foreach from=$entries item=entry key=key}
{assign var=img value=$entry.img}
<div class="content-switcher">
{assign var=modKey value=$key+1}
<div class="content-switcher-image {if $modKey && $modKey % 2 !== 0 }push-50 mobile-pull-100{/if}">
{if $img != ""}
{image src=$entry.img width=300 class="content-switcher-image-img"}
{/if}
</div>
<div class="content-switcher-content {if $modKey && $modKey % 2 !== 0 }pull-50 mobile-pull-100{/if}">
<h2>{$entry.title}</h2>
<p>{$entry.content}</p>
</div>
</div>
{/foreach}
\ No newline at end of file
<?php
/**
* This file contains QUI\Bricks\Controls\ContentSwitcher
*/
namespace QUI\Bricks\Controls;
use QUI;
/**
* Class ContentSwitcher
*
* @package quiqqer/bricks
*/
class ContentSwitcher extends QUI\Control
{
/**
* constructor
*
* @param array $attributes
*/
public function __construct($attributes = array())
{
// default options
$this->setAttributes(array(
'title' => 'Content Switcher',
'contentList' => false,
'entries' => array()
));
parent::__construct($attributes);
$this->addCSSFile(
dirname(__FILE__) . '/ContentSwitcher.css'
);
}
/**
* (non-PHPdoc)
*
* @see \QUI\Control::create()
*/
public function getBody()
{
$Engine = QUI::getTemplateManager()->getEngine();
$entries = $this->getAttribute('entries');
if (is_string($entries)) {
$entries = json_decode($entries, true);
}
$Engine->assign(array(
'this' => $this,
'entries' => $entries
));
return $Engine->fetch(dirname(__FILE__) . '/ContentSwitcher.html');
}
}
.brick-image-text {
margin-bottom: 40px;
}
.brick-image-picture-container {
text-align: center;
}
a.brick-image-link:hover {
outline: none;
background: none;
border: none;
box-shadow: none;
}
a.brick-image-link {
display: block;
}
.brick-image-picture {
max-width: 100%;
}
\ No newline at end of file
{assign var=img value=$brickImage}
{assign var=link value=$brickLink}
<dev class="content-body brick-image">
{if !$this->getAttribute('content') == ""}
<div class="grid-100 grid-parent brick-image-text">
{$this->getAttribute('content')}
</div>
{/if}
<div class="grid-100 grid-parent brick-image-picture-container">
{if $link != ""}
<a class="brick-image-link" href="{$link}">
{/if}
{image src=$img class="brick-image-picture"}
{if $link != ""}
</a>
{/if}
</div>
</dev>
\ No newline at end of file
<?php
/**
* This file contains QUI\Bricks\Controls\Image
*/
namespace QUI\Bricks\Controls;
use QUI;
/**
* Class Image
*
* @package quiqqer/bricks
*/
class Image extends QUI\Control
{
/**
* constructor
*
* @param array $attributes
*/
public function __construct($attributes = array())
{
// default options
$this->setAttributes(array(
'title' => 'Image Brick',
'contentList' => false
));
parent::__construct($attributes);
$this->addCSSFile(
dirname(__FILE__) . '/Image.css'
);
}
/**
* (non-PHPdoc)
*
* @see \QUI\Control::create()
*/
public function getBody()
{
$Engine = QUI::getTemplateManager()->getEngine();
$brickImage = $this->getAttribute('picture');
$brickLink = $this->getAttribute('link');
$Engine->assign(array(
'this' => $this,
'brickImage' => $brickImage,
'brickLink' => $brickLink
));
return $Engine->fetch(dirname(__FILE__) . '/Image.html');
}
}
@CHARSET "UTF-8";
.quiqqer-sheets-mobile select {
width: 100%;
}
.quiqqer-sheets-desktop {
clear: both;
float: left;
margin: 0;
width: calc(100% - 120px);
}
.quiqqer-sheets-desktop__100 {
width: 100%;
}
.quiqqer-sheets-desktop:last-child {
margin: 20px 0;
}
.quiqqer-sheets-desktop a,
.quiqqer-sheets-desktop span {
border: 1px solid #D0D3D3;
border-top: 1px solid #D0D3D3;
border-bottom: 1px solid #D0D3D3;
float: left;
line-height: 30px;
margin: 0;
text-align: center;
text-decoration: none;
}
.quiqqer-sheets-desktop-disabled {
color: #AAAAAA;
cursor: default;
border-color: #DDDDDD;
}
.quiqqer-sheets-desktop-current {
color: #FFFFFF;
cursor: default;
background: #666;
border-color: #666;
}
.quiqqer-sheets-desktop a:hover {
color: #FFFFFF;
text-decoration: none;
}
.quiqqer-sheets-desktop-limits {
float: right;
line-height: 40px;
text-align: center;
width: 120px;
}
.quiqqer-sheets-desktop .more {
border: none;
}
\ No newline at end of file
<div class="quiqqer-sheets-mobile hide-on-desktop">
<select name="select-sheet" class="hide-on-desktop" onchange="window.location = this.value">
{section name=sheets start=0 loop=$count}
{assign var=num value=$smarty.section.sheets.index+1}
{$getParams['limit'] = $limit}
{$getParams['sheet'] = $num}
<option value="{$Site->getUrl($pathParams, $getParams)}{$anchor}"
{if $num == $active}
selected="selected"
{/if}
>{locale group="quiqqer/bricks"
value="controls.pagination.mobile.option"
from=$num
max=$count
}</option>
{/section}
</select>
</div>
<div class="quiqqer-sheets-desktop hide-on-mobile{if !$this->getAttribute('showLimit')} quiqqer-sheets-desktop__100{/if}"
{if $this->getAttribute('useAjax')}style="opacity:0"{/if}
>
{if (!isset($smarty.request.sheet) || $active == 1)
&& $this->getAttribute('useAjax') === false
}
<span class="quiqqer-sheets-desktop-disabled fa fa-angle-double-left quiqqer-sheets-first"
title="{t}quiqqer/bricks controls.pagination.first.page{/t}">
</span>
{else}
{$getParams['limit'] = $limit}
{$getParams['sheet'] = false}
<a href="{$Site->getUrl($pathParams, $getParams)}{$anchor}"
class="fa fa-angle-double-left quiqqer-sheets-first"
title="{t}quiqqer/bricks controls.pagination.first.page{/t}">
</a>
{/if}
{if (!isset($smarty.request.sheet) || $active <= 1)
&& $this->getAttribute('useAjax') === false
}
<span class="quiqqer-sheets-desktop-disabled fa fa-angle-left quiqqer-sheets-prev"
title="{t}quiqqer/bricks controls.pagination.back{/t}">
</span>
{else}
{math assign=backward equation="x - y" x=$active y=1}
{if $backward == 1}
{$getParams['limit'] = $limit}
<a href="{$Site->getUrl($pathParams, $getParams)}{$anchor}"
class="fa fa-angle-left quiqqer-sheets-prev"
title="{t}quiqqer/bricks controls.pagination.back{/t}">
</a>
{else}
{$getParams['sheet'] = $backward}
<a href="{$Site->getUrl($pathParams, $getParams)}{$anchor}"
class="fa fa-angle-left quiqqer-sheets-prev"
title="{t}quiqqer/bricks controls.pagination.back{/t}">
</a>
{/if}
{/if}
{if $start > 1}
<span class="more">...</span>
{/if}
{section name=sheets start=$start loop=$end+1}
{assign var=num value=$smarty.section.sheets.index}
{if $num == $active}
{if $this->getAttribute('useAjax') === false}
<span class="quiqqer-sheets-desktop-current">{$num}</span>
{else}
{$getParams['limit'] = $limit}
<a href="{$Site->getUrl($pathParams, $getParams)}{$anchor}"
class="quiqqer-sheets-sheet quiqqer-sheets-desktop-current"
data-page="{$num}"
>
{$num}
</a>
{/if}
{else}
{$getParams['limit'] = $limit}
{if $num == 1}
{$getParams['sheet'] = false}
<a href="{$Site->getUrl($pathParams, $getParams)}{$anchor}"
class="quiqqer-sheets-sheet"
data-page="{$num}"
>
{$num}
</a>
{else}
{$getParams['sheet'] = $num}
<a href="{$Site->getUrl($pathParams, $getParams)}{$anchor}"
class="quiqqer-sheets-sheet"
data-page="{$num}"
>
{$num}
</a>
{/if}
{/if}
{/section}
{if $end < $count}
<span class="more">...</span>
{/if}
{if $active >= $count && $this->getAttribute('useAjax') === false}
<span class="quiqqer-sheets-desktop-disabled fa fa-angle-right quiqqer-sheets-next"
title="{t}quiqqer/bricks controls.pagination.next{/t}"
>
</span>
{else}
{math assign=forward equation="x + y" x=$active y=1 }
{$getParams['sheet'] = $forward}
<a href="{$Site->getUrl($pathParams, $getParams)}{$anchor}"
class="fa fa-angle-right quiqqer-sheets-next"
title="{t}quiqqer/bricks controls.pagination.next{/t}"
>
</a>
{/if}
{if $active >= $count && $this->getAttribute('useAjax') === false}
<span class="quiqqer-sheets-desktop-disabled fa fa-angle-double-right quiqqer-sheets-last"
title="{t}quiqqer/bricks controls.pagination.last.page{/t}"
></span>
{else}
{$getParams['sheet'] = $count}
<a href="{$Site->getUrl($pathParams, $getParams)}{$anchor}"
title="{t}quiqqer/bricks controls.pagination.last.page{/t}"
class="fa fa-angle-double-right quiqqer-sheets-last"
></a>
{/if}
</div>
{if $this->getAttribute('showLimit') && $limits}
<div class="quiqqer-sheets-desktop-limits">
{foreach from=$limits item=limitEntry name=limits}
{$getParams['limit'] = $limitEntry}
{$getParams['sheet'] = false}
<a href="{$Site->getUrl($pathParams, $getParams)}" data-limit="{$limitEntry}">
{$limitEntry}
</a>
{if not $smarty.foreach.limits.last} | {/if}
{/foreach}
</div>
{/if}
<?php
/**
* This file contains \QUI\Bricks\Controls\Pagination
*/
namespace QUI\Bricks\Controls;
use QUI;
/**
* Pagination
*
* @author www.pcsg.de (Henning Leutz)
* @licence For copyright and license information, please view the /README.md
*/
class Pagination extends QUI\Control
{
/**
* GET Params
*
* @var array
*/
protected $getParams = array();
/**
* URL Params
*
* @var array
*/
protected $urlParams = array();
/**
* constructor
*
* @param array $attributes
*/
public function __construct($attributes = array())
{
$this->setAttributes(array(
'showLimit' => false,
'limits' => '[10,20,50]',
'limit' => 10,
'order' => false,
'sheet' => 1,
'useAjax' => false,
'showmax' => 10,
'anchor' => false
));
parent::__construct($attributes);
$this->addCSSFile(
dirname(__FILE__) . '/Pagination.css'
);
if ($this->getAttribute('useAjax')) {
$this->setAttribute(
'data-qui',
'package/quiqqer/bricks/bin/Controls/Pagination'
);
} else {
$this->setAttribute('data-qui', false);
}
$this->setAttribute('class', 'quiqqer-pagination grid-100 grid-parent');
}
/**
* (non-PHPdoc)
*
* @see \QUI\Control::create()
*/
public function getBody()
{
$Engine = QUI::getTemplateManager()->getEngine();
$Site = $this->getAttribute('Site');
$Project = $Site->getProject();
$count = $this->getAttribute('sheets');
if ($count === false) {
if ($this->getAttribute('limit') &&
$this->getAttribute('count')
) {
$count = ceil(
(int)$this->getAttribute('count') /
(int)$this->getAttribute('limit')
);
$this->setAttribute('sheets', $count);
}
}
$showmax = $this->getAttribute('showmax');
$limits = $this->getAttribute('limits');
if ($this->getAttribute('useAjax')) {
$this->setAttribute(
'data-qui',
'package/quiqqer/bricks/bin/Controls/Pagination'
);
} else {
$this->setAttribute('data-qui', false);
}
if ($limits && is_string($limits)) {
$limits = json_decode($limits, true);
if (!is_array($limits)) {
$limits = false;
}
}
$active = $this->getAttribute('sheet');
$anchor = '';
if ($this->getAttribute('anchor')) {
$anchor = $this->getAttribute('anchor');
}
if ($showmax >= $count) {
$showmax = false;
}
if (!$showmax) {
$showmax = $count * 2;
}
$gap = floor($showmax / 2);
$start = $active - $gap;
$end = $active + $gap;
if ($showmax % 2 === 0) {
$end--; // -1, weil aktuelle seite nicht mit berechnet werden soll
}
if ($start <= 0) {
$start = 1;
$end = $showmax;
}
if ($end >= $count) {
$end = $count;
$start = $end - $showmax + 1;
if ($start <= 0) {
$start = 1;
}
}
// get params
$limit = $this->getAttribute('limit');
$order = $this->getAttribute('order');
$sheet = $this->getAttribute('sheet');
$this->getParams['sheet'] = $sheet;
$this->getParams['limit'] = $limit;
if (!empty($order)) {
$this->getParams['order'] = $order;
}
if ((!$count || $count == 1)
&& $this->getAttribute('limit') === false
) {
return '';
}
$Engine->assign(array(
'this' => $this,
'count' => $count,
'start' => $start,
'end' => $end,
'active' => $active,
'pathParams' => $this->urlParams,
'getParams' => $this->getParams,
'anchor' => $anchor,
'limit' => $limit,
'limits' => $limits,
'Site' => $Site,
'Project' => $Project
));
return $Engine->fetch(dirname(__FILE__) . '/Pagination.html');
}
/**
* Load the GET request variables into the sheet
*/
public function loadFromRequest()
{
$limit = $this->getAttribute('limit');
$order = $this->getAttribute('order');
$sheet = $this->getAttribute('sheet');
if (isset($_GET['limit']) && is_numeric($_GET['limit'])) {
$limit = (int)$_GET['limit'];
}
if (isset($_GET['order'])) {
$order = $_GET['order'];
}
if (isset($_GET['sheet'])) {
$sheet = $_GET['sheet'];
}
$this->setAttribute('limit', $limit);
$this->setAttribute('order', $order);
$this->setAttribute('sheet', $sheet);
$this->urlParams = QUI::getRewrite()->getUrlParamsList();
}
/**
* Return SQL params
*
* @example $this->getSQLParams() : array(
* 'limit' => '0,20',
* 'order' => 'field'
* )
*
* @return array
*/
public function getSQLParams()
{
$result = array();
if ($this->getAttribute('limit')) {
$result['limit'] = $this->getStart()
. ',' . $this->getAttribute('limit');
}
if ($this->getAttribute('order')) {
$result['order'] = $this->getAttribute('order');
}
return $result;
}
/**
* Return the start
*
* @return integer
*/
public function getStart()
{
$limit = $this->getAttribute('limit');
$sheet = $this->getAttribute('sheet');
return ($sheet - 1) * $limit;
}
/**
* Set GET parameter to the links
*
* @param $name
* @param $value
*/
public function setGetParams($name, $value)
{
$name = QUI\Utils\Security\Orthos::clear($name);
$value = QUI\Utils\Security\Orthos::clearFormRequest($value);
if (empty($value)) {
if (isset($this->getParams[$name])) {
unset($this->getParams[$name]);
}
return;
}
$this->getParams[$name] = urlencode($value);
}
/**
* Set URL parameter to the links
*
* @param $name
* @param $value
*/
public function setUrlParams($name, $value)
{
$name = QUI\Utils\Security\Orthos::clear($name);
$value = QUI\Utils\Security\Orthos::clear($value);
if (empty($value)) {
if (isset($this->urlParams[$name])) {
unset($this->urlParams[$name]);
}
return;
}
$this->urlParams[$name] = $value;
}
}
{if $this->getAttribute( 'showImage' ) && $Site->getAttribute('image_site')}
<a href="{url site=$Site}" class="image">
{image src=$Site->getAttribute('image_site') width=1400}
</a>
{/if}
{if $this->getAttribute( 'showTitle' ) || $this->getAttribute( 'showShort' )}
<header>
{if $this->getAttribute( 'showTitle' )}
<h2>
<a href="{url site=$Site}">
{$Site->getAttribute('title')}
</a>
</h2>
{/if}
{if $this->getAttribute( 'showShort' )}
<p>
{$Site->getAttribute('short')}
</p>
{/if}
</header>
{/if}
{if $this->getAttribute( 'showContent' )}
<p>
{$Site->getAttribute('content')}
</p>
{/if}
<footer>
<a href="{url site=$Site}" class="button">
{locale group="quiqqer/bricks" var="continue.reading"}
</a>
</footer>
<?php
/**
* This file contains QUI\Bricks\Controls\SideBox1
*/
namespace QUI\Bricks\Controls;
use QUI;
/**
* Class SocialBox
*
* @package quiqqer/bricks
*/
class SideBox1 extends QUI\Control
{
/**
* constructor
*
* @param array $attributes
*/
public function __construct($attributes = array())
{
// default options
$this->setAttributes(array(
'showImage' => true,
'showTitle' => true,
'showDescription' => true,
'showContent' => true,
'class' => 'quiqqer-bricks-sidebox1',
'nodeName' => 'article',
'site' => false,
'order' => 'release_from DESC'
));
parent::__construct($attributes);
}
/**
* (non-PHPdoc)
*
* @see \QUI\Control::create()
*/
public function getBody()
{
$Engine = QUI::getTemplateManager()->getEngine();
$Engine->assign(array(
'this' => $this,
'Site' => $this->getSite()
));
return $Engine->fetch(dirname(__FILE__) . '/SideBox1.html');
}
/**
* Return the site object
*
* @return QUI\Projects\Site
*/
protected function getSite()
{
$Project = $this->_getProject();
$site = $this->getAttribute('site');
if (is_numeric($site)) {
try {
return $Project->get((int)$site);
} catch (QUI\Exception $Exception) {
QUI\System\Log::addWarning($Exception->getMessage());
return $Project->firstChild();
}
}
// order
switch ($this->getAttribute('order')) {
case 'name ASC':
case 'name DESC':
case 'title ASC':
case 'title DESC':
case 'c_date ASC':
case 'c_date DESC':
case 'd_date ASC':
case 'd_date DESC':
case 'release_from ASC':
case 'release_from DESC':
$order = $this->getAttribute('order');
break;
default:
$order = 'release_from DESC';
break;
}
$children = QUI\Projects\Site\Utils::getSitesByInputList(
$this->getProject(),
$this->getAttribute('site'),
array(
'limit' => 1,
'order' => $order
)
);
if (isset($children[0])) {
return $children[0];
}
return $Project->firstChild();
}
}
<div class="{$this->getAttribute('grid-class-row')}">
{if $this->getAttribute('content')}
<div class="quiqqer-bricks-sidebox2-content">
{$this->getAttribute('content')}
</div>
{/if}
</div>
<div class="{$this->getAttribute('grid-class-row')}">
{foreach from=$children item=Child key=key}
<article class="{$this->getAttribute('grid-class-article')} quiqqer-bricks-sidebox-article">
{if $this->getAttribute( 'showImage' )}
<a href="{url site=$Child}" class="image">
{image src=$Child->getAttribute('image_site') width=640}
</a>
{/if}
{if $this->getAttribute( 'showTitle' ) || $this->getAttribute( 'showShort' )}
<header>
{if $this->getAttribute( 'showTitle' )}
<h3>
<a href="{url site=$Child}">
{$Child->getAttribute('title')}
</a>
</h3>
{/if}
</header>
{/if}
{if $this->getAttribute( 'showShort' )}
<p>
{text_passage text=$Child->getAttribute('short') start=0 end=120 striphtml=true append="..."}
</p>
{/if}
{if $this->getAttribute( 'showContent' )}
{$Child->getAttribute('content')}
{/if}
<footer class="article-button">
<a href="{url site=$Child}" class="button">
{locale group="quiqqer/bricks" var="continue.reading"}
</a>
</footer>
</article>
{assign var=modKey value=$key+1}
{if $modKey && $modKey % 2 === 0 && $Child@last}
</div>
<div class="{$this->getAttribute('grid-class-row')}">
{/if}
{/foreach}
</div>
<?php
/**
* This file contains QUI\Bricks\Controls\SideBox2
*/
namespace QUI\Bricks\Controls;
use QUI;
/**
* Class SocialBox
*
* @package quiqqer/bricks
*/
class SideBox2 extends QUI\Control
{
/**
* constructor
*
* @param array $attributes
*/
public function __construct($attributes = array())
{
// default options
$this->setAttributes(array(
'showImage' => true,
'showTitle' => true,
'showDescription' => true,
'showContent' => false,
'class' => 'quiqqer-bricks-sidebox2',
'nodeName' => 'section',
'site' => false,
'limit' => 2,
'order' => 'release_from DESC',
'grid-class-row' => 'row',
'grid-class-article' => '6u'
));
parent::__construct($attributes);
}
/**
* (non-PHPdoc)
*
* @see \QUI\Control::create()
*/
public function getBody()
{
$Engine = QUI::getTemplateManager()->getEngine();
$limit = $this->getAttribute('limit');
if (!$limit) {
$limit = 2;
}
// order
switch ($this->getAttribute('order')) {
case 'name ASC':
case 'name DESC':
case 'title ASC':
case 'title DESC':
case 'c_date ASC':
case 'c_date DESC':
case 'd_date ASC':
case 'd_date DESC':
case 'release_from ASC':
case 'release_from DESC':
$order = $this->getAttribute('order');
break;
default:
$order = 'release_from DESC';
break;
}
$children = QUI\Projects\Site\Utils::getSitesByInputList(
$this->getProject(),
$this->getAttribute('site'),
array(
'limit' => $limit,
'order' => $order
)
);
$Engine->assign(array(
'this' => $this,
'children' => $children
));
return $Engine->fetch(dirname(__FILE__) . '/SideBox2.html');
}
}
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren