Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Content elements can now be shown/hidden at a certain time (see #4187)
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed May 15, 2012
1 parent 372fa55 commit 4dcd40a
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 45 deletions.
79 changes: 47 additions & 32 deletions contao/dca/tl_content.php
Expand Up @@ -109,28 +109,28 @@
(
'__selector__' => array('type', 'mooType', 'addImage', 'sortable', 'useImage', 'protected'),
'default' => '{type_legend},type',
'headline' => '{type_legend},type,headline;{protected_legend:hide},protected;{expert_legend:hide},guests,invisible,cssID,space',
'text' => '{type_legend},type,headline;{text_legend},text;{image_legend},addImage;{protected_legend:hide},protected;{expert_legend:hide},guests,invisible,cssID,space',
'html' => '{type_legend},type;{text_legend},html;{protected_legend:hide},protected;{expert_legend:hide},guests,invisible',
'list' => '{type_legend},type,headline;{list_legend},listtype,listitems;{protected_legend:hide},protected;{expert_legend:hide},guests,invisible,cssID,space',
'table' => '{type_legend},type,headline;{table_legend},tableitems;{tconfig_legend},summary,thead,tfoot,tleft;{sortable_legend:hide},sortable;{protected_legend:hide},protected;{expert_legend:hide},guests,invisible,cssID,space',
'headline' => '{type_legend},type,headline;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space;{invisible_legend:hide},invisible,start,stop',
'text' => '{type_legend},type,headline;{text_legend},text;{image_legend},addImage;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space;{invisible_legend:hide},invisible,start,stop',
'html' => '{type_legend},type;{text_legend},html;{protected_legend:hide},protected;{expert_legend:hide},guests;{invisible_legend:hide},invisible,start,stop',
'list' => '{type_legend},type,headline;{list_legend},listtype,listitems;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space;{invisible_legend:hide},invisible,start,stop',
'table' => '{type_legend},type,headline;{table_legend},tableitems;{tconfig_legend},summary,thead,tfoot,tleft;{sortable_legend:hide},sortable;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space;{invisible_legend:hide},invisible,start,stop',
'accordion' => '{type_legend},type,mooType',
'accordionsingle' => '{type_legend},type,mooType;{moo_legend},mooHeadline,mooStyle,mooClasses;{text_legend},text;{image_legend},addImage;{protected_legend:hide},protected;{expert_legend:hide},guests,invisible,cssID,space',
'accordionstart' => '{type_legend},type,mooType;{moo_legend},mooHeadline,mooStyle,mooClasses;{protected_legend:hide},protected;{expert_legend:hide},guests,invisible,cssID,space',
'accordionstop' => '{type_legend},type,mooType;{moo_legend},mooClasses;{protected_legend:hide},protected;{expert_legend:hide},guests,invisible',
'code' => '{type_legend},type,headline;{text_legend},highlight,shClass,code;{protected_legend:hide},protected;{expert_legend:hide},guests,invisible,cssID,space',
'hyperlink' => '{type_legend},type,headline;{link_legend},url,target,linkTitle,rel,embed;{imglink_legend:hide},useImage;{protected_legend:hide},protected;{expert_legend:hide},guests,invisible,cssID,space',
'toplink' => '{type_legend},type,linkTitle;{protected_legend:hide},protected;{expert_legend:hide},guests,invisible,cssID,space',
'image' => '{type_legend},type,headline;{source_legend},singleSRC;{image_legend},alt,title,size,imagemargin,imageUrl,fullsize,caption;{protected_legend:hide},protected;{expert_legend:hide},guests,invisible,cssID,space',
'gallery' => '{type_legend},type,headline;{source_legend},multiSRC,sortBy,useHomeDir;{image_legend},size,imagemargin,perRow,fullsize,perPage,numberOfItems;{template_legend:hide},galleryTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,invisible,cssID,space',
'player' => '{type_legend},type,headline;{source_legend},playerSRC;{poster_legend:hide},posterSRC;{player_legend},playerSize,autoplay;{protected_legend:hide},protected;{expert_legend:hide},guests,invisible,cssID,space',
'download' => '{type_legend},type,headline;{source_legend},singleSRC;{dwnconfig_legend},linkTitle;{protected_legend:hide},protected;{expert_legend:hide},guests,invisible,cssID,space',
'downloads' => '{type_legend},type,headline;{source_legend},multiSRC,sortBy,useHomeDir;{protected_legend:hide},protected;{expert_legend:hide},guests,invisible,cssID,space',
'alias' => '{type_legend},type;{include_legend},cteAlias;{protected_legend:hide},protected;{expert_legend:hide},guests,invisible,cssID,space',
'article' => '{type_legend},type;{include_legend},articleAlias;{protected_legend:hide},protected',
'teaser' => '{type_legend},type;{include_legend},article;{protected_legend:hide},protected;{expert_legend:hide},guests,invisible,cssID,space',
'form' => '{type_legend},type,headline;{include_legend},form;{protected_legend:hide},protected;{expert_legend:hide},guests,invisible,cssID,space',
'module' => '{type_legend},type;{include_legend},module;{protected_legend:hide},protected;{expert_legend:hide},guests,invisible,cssID,space'
'accordionmooSingle' => '{type_legend},type,mooType;{moo_legend},mooHeadline,mooStyle,mooClasses;{text_legend},text;{image_legend},addImage;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space;{invisible_legend:hide},invisible,start,stop',
'accordionmooStart' => '{type_legend},type,mooType;{moo_legend},mooHeadline,mooStyle,mooClasses;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space;{invisible_legend:hide},invisible,start,stop',
'accordionmooStop' => '{type_legend},type,mooType;{moo_legend},mooClasses;{protected_legend:hide},protected;{expert_legend:hide},guests;{invisible_legend:hide},invisible,start,stop',
'code' => '{type_legend},type,headline;{text_legend},highlight,shClass,code;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space;{invisible_legend:hide},invisible,start,stop',
'hyperlink' => '{type_legend},type,headline;{link_legend},url,target,linkTitle,rel,embed;{imglink_legend:hide},useImage;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space;{invisible_legend:hide},invisible,start,stop',
'toplink' => '{type_legend},type,linkTitle;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space;{invisible_legend:hide},invisible,start,stop',
'image' => '{type_legend},type,headline;{source_legend},singleSRC;{image_legend},alt,title,size,imagemargin,imageUrl,fullsize,caption;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space;{invisible_legend:hide},invisible,start,stop',
'gallery' => '{type_legend},type,headline;{source_legend},multiSRC,sortBy,useHomeDir;{image_legend},size,imagemargin,perRow,fullsize,perPage,numberOfItems;{template_legend:hide},galleryTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space;{invisible_legend:hide},invisible,start,stop',
'player' => '{type_legend},type,headline;{source_legend},playerSRC;{poster_legend:hide},posterSRC;{player_legend},playerSize,autoplay;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space;{invisible_legend:hide},invisible,start,stop',
'download' => '{type_legend},type,headline;{source_legend},singleSRC;{dwnconfig_legend},linkTitle;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space;{invisible_legend:hide},invisible,start,stop',
'downloads' => '{type_legend},type,headline;{source_legend},multiSRC,sortBy,useHomeDir;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space;{invisible_legend:hide},invisible,start,stop',
'alias' => '{type_legend},type;{include_legend},cteAlias;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space;{invisible_legend:hide},invisible,start,stop',
'article' => '{type_legend},type;{include_legend},articleAlias;{protected_legend:hide},protected;{invisible_legend:hide},invisible,start,stop',
'teaser' => '{type_legend},type;{include_legend},article;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space;{invisible_legend:hide},invisible,start,stop',
'form' => '{type_legend},type,headline;{include_legend},form;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space;{invisible_legend:hide},invisible,start,stop',
'module' => '{type_legend},type;{include_legend},module;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space;{invisible_legend:hide},invisible,start,stop'
),

// Subpalettes
Expand Down Expand Up @@ -397,7 +397,7 @@
'default' => 'start',
'exclude' => true,
'inputType' => 'radio',
'options' => array('start', 'stop', 'single'),
'options' => array('mooStart', 'mooStop', 'mooSingle'),
'reference' => &$GLOBALS['TL_LANG']['tl_content'],
'eval' => array('helpwizard'=>true, 'submitOnChange'=>true),
'sql' => "varchar(32) NOT NULL default ''"
Expand Down Expand Up @@ -703,15 +703,6 @@
'eval' => array('tl_class'=>'w50'),
'sql' => "char(1) NOT NULL default ''"
),
'invisible' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_content']['invisible'],
'exclude' => true,
'filter' => true,
'inputType' => 'checkbox',
'eval' => array('tl_class'=>'w50'),
'sql' => "char(1) NOT NULL default ''"
),
'cssID' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_content']['cssID'],
Expand All @@ -727,6 +718,30 @@
'inputType' => 'text',
'eval' => array('multiple'=>true, 'size'=>2, 'rgxp'=>'digit', 'nospace'=>true, 'tl_class'=>'w50'),
'sql' => "varchar(64) NOT NULL default ''"
),
'invisible' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_content']['invisible'],
'exclude' => true,
'filter' => true,
'inputType' => 'checkbox',
'sql' => "char(1) NOT NULL default ''"
),
'start' => array
(
'exclude' => true,
'label' => &$GLOBALS['TL_LANG']['tl_content']['start'],
'inputType' => 'text',
'eval' => array('rgxp'=>'datim', 'datepicker'=>true, 'tl_class'=>'w50 wizard'),
'sql' => "varchar(10) NOT NULL default ''"
),
'stop' => array
(
'exclude' => true,
'label' => &$GLOBALS['TL_LANG']['tl_content']['stop'],
'inputType' => 'text',
'eval' => array('rgxp'=>'datim', 'datepicker'=>true, 'tl_class'=>'w50 wizard'),
'sql' => "varchar(10) NOT NULL default ''"
)
)
);
Expand Down Expand Up @@ -909,7 +924,7 @@ public function addCteType($arrRow)
$class = 'limit_height';

// Add the type of accordion element
if ($arrRow['type'] == 'accordion' && $arrRow['mooType'] != 'single')
if ($arrRow['type'] == 'accordion' && $arrRow['mooType'] != 'mooSingle')
{
$class = '';
$type .= ' [' . $GLOBALS['TL_LANG']['tl_content'][$arrRow['mooType']][0] . ']';
Expand Down
6 changes: 3 additions & 3 deletions contao/drivers/DC_Table.php
Expand Up @@ -3700,18 +3700,18 @@ protected function parentView()
}

// Accordion wrapper
if ($row[$i]['type'] == 'accordion' && $row[$i]['mooType'] == 'stop')
if ($row[$i]['type'] == 'accordion' && $row[$i]['mooType'] == 'mooStop')
{
$blnIndent = false;
}

$return .= '
<div class="tl_content'.((($row[$i]['type'] == 'accordion' && $row[$i]['mooType'] != 'single')) ? ' acc'.$row[$i]['mooType'] : '').($blnIndent ? ' indent' : '').(($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['child_record_class'] != '') ? ' ' . $GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['child_record_class'] : '').(($i%2 == 0) ? ' even' : ' odd').'" onmouseover="Theme.hoverDiv(this,1)" onmouseout="Theme.hoverDiv(this,0)">
<div class="tl_content'.((($row[$i]['type'] == 'accordion' && $row[$i]['mooType'] != 'mooSingle')) ? ' '.$row[$i]['mooType'] : '').($blnIndent ? ' indent' : '').(($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['child_record_class'] != '') ? ' ' . $GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['child_record_class'] : '').(($i%2 == 0) ? ' even' : ' odd').'" onmouseover="Theme.hoverDiv(this,1)" onmouseout="Theme.hoverDiv(this,0)">
<div class="tl_content_right">';

// Accordion wrapper
if ($row[$i]['type'] == 'accordion' && $row[$i]['mooType'] == 'start')
if ($row[$i]['type'] == 'accordion' && $row[$i]['mooType'] == 'mooStart')
{
$blnIndent = true;
}
Expand Down
4 changes: 2 additions & 2 deletions contao/elements/ContentAccordion.php
Expand Up @@ -41,7 +41,7 @@ class ContentAccordion extends \ContentElement
protected function compile()
{
// Accordion start
if ($this->mooType == 'start')
if ($this->mooType == 'mooStart')
{
if (TL_MODE == 'FE')
{
Expand All @@ -58,7 +58,7 @@ protected function compile()
}

// Accordion end
elseif ($this->mooType == 'stop')
elseif ($this->mooType == 'mooStop')
{
if (TL_MODE == 'FE')
{
Expand Down
5 changes: 5 additions & 0 deletions contao/elements/ContentElement.php
Expand Up @@ -126,6 +126,11 @@ public function __isset($strKey)
*/
public function generate()
{
if (!BE_USER_LOGGED_IN && ($this->invisible || ($this->start > 0 && $this->start > time()) || ($this->stop > 0 && $this->stop < time())))
{
return '';
}

if ($this->arrData['space'][0] != '')
{
$this->arrStyle[] = 'margin-top:'.$this->arrData['space'][0].'px;';
Expand Down
11 changes: 7 additions & 4 deletions contao/languages/de/tl_content.php
Expand Up @@ -14,7 +14,6 @@
/**
* Fields
*/
$GLOBALS['TL_LANG']['tl_content']['invisible'] = array('Unsichtbar', 'Das Element auf der Webseite nicht anzeigen.');
$GLOBALS['TL_LANG']['tl_content']['type'] = array('Elementtyp', 'Bitte wählen Sie den Typ des Inhaltselements.');
$GLOBALS['TL_LANG']['tl_content']['headline'] = array('Überschrift', 'Hier können Sie dem Inhaltselement eine Überschrift hinzufügen.');
$GLOBALS['TL_LANG']['tl_content']['text'] = array('Text', 'Sie können HTML-Tags verwenden, um den Text zu formatieren.');
Expand All @@ -40,9 +39,9 @@
$GLOBALS['TL_LANG']['tl_content']['sortIndex'] = array('Sortierindex', 'Die Nummer der Spalte, nach der standardmäßig sortiert wird.');
$GLOBALS['TL_LANG']['tl_content']['sortOrder'] = array('Sortierreihenfolge', 'Bitte wählen Sie die Sortierreihenfolge aus.');
$GLOBALS['TL_LANG']['tl_content']['mooType'] = array('Betriebsart', 'Bitte wählen Sie die Betriebsart des Akkordeon-Elements.');
$GLOBALS['TL_LANG']['tl_content']['single'] = array('Einzelnes Element', 'Entspricht einem Text-Inhaltselement in einem Akkordeon-Fenster.');
$GLOBALS['TL_LANG']['tl_content']['start'] = array('Umschlag-Anfang', 'Markiert den Anfang eines Akkordeon-Fensters, das mehrere Inhaltselemente umfasst.');
$GLOBALS['TL_LANG']['tl_content']['stop'] = array('Umschlag-Ende', 'Markiert das Ende eines Akkordeon-Fensters, das mehrere Inhaltselemente umfasst.');
$GLOBALS['TL_LANG']['tl_content']['mooStart'] = array('Umschlag-Anfang', 'Markiert den Anfang eines Akkordeon-Fensters, das mehrere Inhaltselemente umfasst.');
$GLOBALS['TL_LANG']['tl_content']['mooStop'] = array('Umschlag-Ende', 'Markiert das Ende eines Akkordeon-Fensters, das mehrere Inhaltselemente umfasst.');
$GLOBALS['TL_LANG']['tl_content']['mooSingle'] = array('Einzelnes Element', 'Entspricht einem Text-Inhaltselement in einem Akkordeon-Fenster.');
$GLOBALS['TL_LANG']['tl_content']['mooHeadline'] = array('Bereichsüberschrift', 'Bitte geben Sie die Überschrift des Akkordeon-Fensters ein. HTML-Tags sind erlaubt.');
$GLOBALS['TL_LANG']['tl_content']['mooStyle'] = array('CSS-Format', 'Hier können Sie die Bereichsüberschrift mittels CSS-Code formatieren.');
$GLOBALS['TL_LANG']['tl_content']['mooClasses'] = array('Klassennamen', 'Lassen Sie das Feld leer, um die Standard-Klassennamen zu verwenden, oder geben Sie eigene Toggler- und Accordion-Klassen ein.');
Expand Down Expand Up @@ -74,6 +73,9 @@
$GLOBALS['TL_LANG']['tl_content']['guests'] = array('Nur Gästen anzeigen', 'Das Inhaltselement verstecken sobald ein Mitglied angemeldet ist.');
$GLOBALS['TL_LANG']['tl_content']['cssID'] = array('CSS-ID/Klasse', 'Hier können Sie eine ID und beliebig viele Klassen eingeben.');
$GLOBALS['TL_LANG']['tl_content']['space'] = array('Abstand davor und dahinter', 'Hier können Sie den Abstand vor und nach dem Inhaltselement in Pixeln eingeben. Sie sollten Inline-Styles jedoch nach Möglichkeit vermeiden und den Abstand in einem Stylesheet definieren.');
$GLOBALS['TL_LANG']['tl_content']['invisible'] = array('Unsichtbar', 'Das Element auf der Webseite nicht anzeigen.');
$GLOBALS['TL_LANG']['tl_content']['start'] = array('Anzeigen ab', 'Das Element erst ab diesem Tag auf der Webseite anzeigen.');
$GLOBALS['TL_LANG']['tl_content']['stop'] = array('Anzeigen bis', 'Das Element nur bis zu diesem Tag auf der Webseite anzeigen.');


/**
Expand All @@ -97,6 +99,7 @@
$GLOBALS['TL_LANG']['tl_content']['template_legend'] = 'Template-Einstellungen';
$GLOBALS['TL_LANG']['tl_content']['player_legend'] = 'Player-Einstellungen';
$GLOBALS['TL_LANG']['tl_content']['poster_legend'] = 'Vorschaubild';
$GLOBALS['TL_LANG']['tl_content']['invisible_legend'] = 'Sichtbarkeit';


/**
Expand Down

0 comments on commit 4dcd40a

Please sign in to comment.