diff --git a/README.md b/README.md new file mode 100644 index 0000000..bcb941b --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +contao-random-ce +====================== + +About +----- + +Provides a wrapper (like accordion) for content elements to show a different, random element on each reload of the page. + + +Screenshot +----------- + +![Editing a single store](https://contao.org/files/repository/storelocator/10010009/picture.jpg) + + +Dependencies +------------------- + +* [Contao](https://github.com/contao/core) 3.0 or higher \ No newline at end of file diff --git a/system/modules/random_ce/classes/ContentElementTest.php b/system/modules/random_ce/classes/ContentElementTest.php new file mode 100644 index 0000000..cd94433 --- /dev/null +++ b/system/modules/random_ce/classes/ContentElementTest.php @@ -0,0 +1,34 @@ + + * @license LGPL + * @copyright 2014 numero2 - Agentur für Internetdienstleistungen + */ + + +namespace RandomCE; + + +class ContentElementTest extends \Controller +{ + + /** + * Check if this content element should be visible this time + * @param $row + * @param $strBuffer + */ + public function checkContentElement( $row, $strBuffer ) + { + + if( TL_MODE == 'BE' || empty($GLOBALS['random_ce_hide']) || !in_array($row->id,$GLOBALS['random_ce_hide']) ) + return $strBuffer; + + return ''; + } +} \ No newline at end of file diff --git a/system/modules/random_ce/config/autoload.ini b/system/modules/random_ce/config/autoload.ini new file mode 100644 index 0000000..ebf5d0f --- /dev/null +++ b/system/modules/random_ce/config/autoload.ini @@ -0,0 +1,14 @@ +;; +; Configure what you want the autoload creator to register +;; +register_namespaces = true +register_classes = true +register_templates = true + +;; +; Override the default configuration for certain sub directories +;; +[vendor/*] +register_namespaces = false +register_classes = false +register_templates = false \ No newline at end of file diff --git a/system/modules/random_ce/config/autoload.php b/system/modules/random_ce/config/autoload.php new file mode 100644 index 0000000..e6c0f5f --- /dev/null +++ b/system/modules/random_ce/config/autoload.php @@ -0,0 +1,33 @@ + + * @license LGPL + * @copyright 2014 numero2 - Agentur für Internetdienstleistungen + */ + + +/** + * Register the namespaces + */ +ClassLoader::addNamespaces(array +( + 'RandomCE', +)); + + +/** + * Register the classes + */ +ClassLoader::addClasses(array +( + // Elements + 'RandomCE\ContentElementTest' => 'system/modules/random_ce/classes/ContentElementTest.php', + 'RandomCE\ContentRandomCEStart' => 'system/modules/random_ce/elements/ContentRandomCEStart.php', + 'RandomCE\ContentRandomCEStop' => 'system/modules/random_ce/elements/ContentRandomCEStop.php', +)); \ No newline at end of file diff --git a/system/modules/random_ce/config/config.php b/system/modules/random_ce/config/config.php new file mode 100644 index 0000000..eb14885 --- /dev/null +++ b/system/modules/random_ce/config/config.php @@ -0,0 +1,34 @@ + + * @license LGPL + * @copyright 2014 numero2 - Agentur für Internetdienstleistungen + */ + + +/** + * Content elements + */ +$GLOBALS['TL_CTE']['random_ce'] = array( + 'randomCEStart' => 'ContentRandomCEStart', + 'randomCEStop' => 'ContentRandomCEStop' +); + + +/** + * Wrapper elements + */ +$GLOBALS['TL_WRAPPERS']['start'][] = 'randomCEStart'; +$GLOBALS['TL_WRAPPERS']['stop'][] = 'randomCEStop'; + + +/** + * Hooks + */ +$GLOBALS['TL_HOOKS']['getContentElement'][] = array('ContentElementTest','checkContentElement'); \ No newline at end of file diff --git a/system/modules/random_ce/dca/tl_content.php b/system/modules/random_ce/dca/tl_content.php new file mode 100644 index 0000000..8aa2a5d --- /dev/null +++ b/system/modules/random_ce/dca/tl_content.php @@ -0,0 +1,19 @@ + + * @license LGPL + * @copyright 2014 numero2 - Agentur für Internetdienstleistungen + */ + + +/** + * Table tl_content + */ +$GLOBALS['TL_DCA']['tl_content']['palettes']['randomCEStart'] = '{type_legend},type;{expert_legend:hide},guests,cssID,space;{invisible_legend:hide},invisible,start,stop'; +$GLOBALS['TL_DCA']['tl_content']['palettes']['randomCEStop'] = '{type_legend},type;{expert_legend:hide},guests,cssID,space;{invisible_legend:hide},invisible,start,stop'; \ No newline at end of file diff --git a/system/modules/random_ce/elements/ContentRandomCEStart.php b/system/modules/random_ce/elements/ContentRandomCEStart.php new file mode 100644 index 0000000..d40c15b --- /dev/null +++ b/system/modules/random_ce/elements/ContentRandomCEStart.php @@ -0,0 +1,54 @@ + + * @license LGPL + * @copyright 2014 numero2 - Agentur für Internetdienstleistungen + */ + + +namespace RandomCE; + + +class ContentRandomCEStart extends \ContentElement +{ + + /** + * Generate the content element + */ + protected function compile() + { + if (TL_MODE == 'BE') + { + $this->strTemplate = 'be_wildcard'; + $this->Template = new \BackendTemplate($this->strTemplate); + + } else { + + // determine which element should be shown this time + $closingElement = \Database::getInstance()->prepare("SELECT id,sorting FROM tl_content WHERE pid = ? AND sorting > ? AND type = 'randomCEStop'")->limit(1)->execute( $this->pid, $this->sorting ); + + if( $closingElement->id ) { + + $contentElements = \Database::getInstance()->prepare("SELECT id FROM tl_content WHERE pid = ? AND sorting > ? AND sorting < ?")->execute( $this->pid, $this->sorting, $closingElement->sorting ); + + $aElementIDs = $contentElements->fetchAllAssoc(); + $GLOBALS['random_ce_hide'] = array(); + + // decide which will be shown + $toBeShown = mt_rand(0, (count($aElementIDs)-1)); + + foreach( $aElementIDs as $i => $v ) { + + if( $i != $toBeShown ) + $GLOBALS['random_ce_hide'][] = $v['id']; + } + } + } + } +} \ No newline at end of file diff --git a/system/modules/random_ce/elements/ContentRandomCEStop.php b/system/modules/random_ce/elements/ContentRandomCEStop.php new file mode 100644 index 0000000..4f53172 --- /dev/null +++ b/system/modules/random_ce/elements/ContentRandomCEStop.php @@ -0,0 +1,31 @@ + + * @license LGPL + * @copyright 2014 numero2 - Agentur für Internetdienstleistungen + */ + + +namespace RandomCE; + + +class ContentRandomCEStop extends \ContentElement +{ + /** + * Generate the content element + */ + protected function compile() + { + if (TL_MODE == 'BE') + { + $this->strTemplate = 'be_wildcard'; + $this->Template = new \BackendTemplate($this->strTemplate); + } + } +} \ No newline at end of file diff --git a/system/modules/random_ce/languages/de/default.xlf b/system/modules/random_ce/languages/de/default.xlf new file mode 100644 index 0000000..48f0679 --- /dev/null +++ b/system/modules/random_ce/languages/de/default.xlf @@ -0,0 +1,26 @@ + + + + + Random Content Element + Zufälliges Inhaltselement + + + Wrapper start + Umschlag Anfang + + + Generates the opening part of the random element wrapper. + Erzeugt den öffnenden Teil des zufälligen Inhaltsemenet-Umschlags. + + + Wrapper stop + Umschlag Ende + + + Generates the closing part of the random element wrapper. + Erzeugt den schließenden Teil des zufälligen Inhaltsemenet-Umschlags. + + + + \ No newline at end of file diff --git a/system/modules/random_ce/languages/de/tl_content.xlf b/system/modules/random_ce/languages/de/tl_content.xlf new file mode 100644 index 0000000..f09ab4c --- /dev/null +++ b/system/modules/random_ce/languages/de/tl_content.xlf @@ -0,0 +1,774 @@ + + + + + Element type + Elementtyp + + + Please choose the type of content element. + Bitte wählen Sie den Typ des Inhaltselements. + + + Headline + Überschrift + + + Here you can add a headline to the content element. + Hier können Sie dem Inhaltselement eine Überschrift hinzufügen. + + + Text + Text + + + You can use HTML tags to format the text. + Sie können HTML-Tags verwenden, um den Text zu formatieren. + + + Add an image + Ein Bild hinzufügen + + + Add an image to the content element. + Dem Inhaltselement ein Bild hinzufügen. + + + Source file + Quelldatei + + + Please select a file or folder from the files directory. + Bitte wählen Sie eine Datei oder einen Ordner aus der Dateiübersicht. + + + Alternate text + Alternativer Text + + + Here you can enter an alternate text for the image (<em>alt</em> attribute). + Hier können Sie einen alternativen Text für das Bild eingeben (<em>alt</em>-Attribut). + + + Title + Titel + + + Here you can enter the image title (<em>title</em> attribute). + Hier können Sie den Titel des Bildes eingeben (<em>title</em>-Attribut). + + + Image width and height + Bildbreite und Bildhöhe + + + Here you can set the image dimensions and the resize mode. + Hier können Sie die Abmessungen des Bildes und den Skalierungsmodus festlegen. + + + Image margin + Bildabstand + + + Here you can enter the top, right, bottom and left margin. + Hier können Sie den oberen, rechten, unteren und linken Bildabstand eingeben. + + + Image link target + Bildlink-Adresse + + + A custom image link target will override the lightbox link, so the image cannot be viewed fullsize anymore. + Eine eigene Bildlink-Adresse überschreibt den Lightbox-Link, so dass das Bild nicht mehr in der Großansicht dargestellt werden kann. + + + Full-size view/new window + Großansicht/Neues Fenster + + + Open the full-size image in a lightbox or the link in a new browser window. + Großansicht des Bildes in einer Lightbox bzw. den Link in einem neuem Browserfenster öffnen. + + + Image alignment + Bildausrichtung + + + Please specify how to align the image. + Bitte legen Sie fest, wie das Bild ausgerichtet werden soll. + + + Image caption + Bildunterschrift + + + Here you can enter a short text that will be displayed below the image. + Hier können Sie einen kurzen Text eingeben, der unterhalb des Bildes angezeigt wird. + + + HTML code + HTML-Code + + + You can modify the list of allowed HTML tags in the back end settings. + Sie können die Liste der erlaubten HTML-Tags in den Backend-Einstellungen ändern. + + + List type + Listentyp + + + Please choose the type of list. + Bitte wählen Sie den Typ der Liste. + + + List items + Listeneinträge + + + If JavaScript is disabled, make sure to save your changes before modifying the order. + Wenn JavaScript deaktiviert ist, speichern Sie unbedingt Ihre Änderungen bevor Sie die Reihenfolge ändern. + + + Table items + Tabelleneinträge + + + If JavaScript is disabled, make sure to save your changes before modifying the order. + Wenn JavaScript deaktiviert ist, speichern Sie unbedingt Ihre Änderungen bevor Sie die Reihenfolge ändern. + + + Table summary + Zusammenfassung + + + Please enter a short summary of the table and describe its purpose or structure. + Bitte geben Sie eine kurze Zusammenfassung des Inhalts und der Struktur der Tabelle ein. + + + Add table header + Kopfzeile hinzufügen + + + Make the first row of the table the table header. + Die erste Reihe der Tabelle als Kopfzeile verwenden. + + + Add table footer + Fußzeile hinzufügen + + + Make the last row of the table the table footer. + Die letzte Reihe der Tabelle als Fußzeile verwenden. + + + Use row headers + Reihenüberschriften hinzufügen + + + Define the left column as row header. + Die linke Spalte als Reihenüberschrift definieren. + + + Sortable table + Sortierbare Tabelle + + + Make the table sortable (requires JavaScript and a table header). + Die Tabelle sortierbar machen (benötigt JavaScript und eine Kopfzeile). + + + Sort index + Sortierindex + + + The number of the default sort column. + Die Nummer der Spalte, nach der standardmäßig sortiert wird. + + + Sort order + Sortierreihenfolge + + + Please choose the sort order. + Bitte wählen Sie die Sortierreihenfolge aus. + + + Operation mode + Betriebsart + + + Please select the operation mode of the accordion element. + Bitte wählen Sie die Betriebsart des Akkordeon-Elements. + + + Wrapper start + Umschlag-Anfang + + + Marks the beginning of an accordion pane that spans several content elements. + Markiert den Anfang eines Akkordeon-Fensters, das mehrere Inhaltselemente umfasst. + + + Wrapper stop + Umschlag-Ende + + + Marks the end of an accordion pane that spans several content elements. + Markiert das Ende eines Akkordeon-Fensters, das mehrere Inhaltselemente umfasst. + + + Single element + Einzelnes Element + + + Behaves like a single text element that is inside an accordion pane. + Entspricht einem Text-Inhaltselement in einem Akkordeon-Fenster. + + + Section headline + Bereichsüberschrift + + + Please enter the headline of the content pane. HTML tags are allowed. + Bitte geben Sie die Überschrift des Akkordeon-Fensters ein. HTML-Tags sind erlaubt. + + + CSS format + CSS-Format + + + Here you can format the section headline using CSS code. + Hier können Sie die Bereichsüberschrift mittels CSS-Code formatieren. + + + Element classes + Klassennamen + + + Leave blank to use the default classes or enter a custom toggler and accordion class. + Lassen Sie das Feld leer, um die Standard-Klassennamen zu verwenden, oder geben Sie eigene Toggler- und Accordion-Klassen ein. + + + Configuration + Konfiguration + + + Here you can configure the syntax highlighter (e.g. <em>gutter: false;</em>). + Hier können Sie den Syntax-Highlighter konfigurieren (z.B. <em>gutter: false;</em>). + + + Syntax highlighting + Syntaxhervorhebung + + + Please choose a scripting language. + Bitte wählen Sie eine Skriptsprache aus. + + + Code + Code + + + Note that the code will not be executed. Use F11 to toggle the fullscreen mode if you are using the code editor. + Beachten Sie, dass der Code nicht ausgeführt wird. Mit F11 können Sie den Vollbildmodus aufrufen, wenn Sie den Code-Editor nutzen. + + + Link text + Link-Text + + + The link text will be displayed instead of the target URL. + Der Link-Text wird anstelle der Link-Adresse angezeigt. + + + Link title + Link-Titel + + + The link title is added as <em>title</em> attribute in the HTML markup. + Der Link-Titel wird als <em>title</em>-Attribut im HTML-Markup eingefügt. + + + Embed the link + Den Link einbetten + + + Use the wildcard "%s" to embed the link in a phrase (e.g. <em>For more information please visit %s</em>). + Verwenden Sie den Platzhalter "%s", um den Link in einen Text einzubetten (z.B. <em>Für mehr Informationen besuchen Sie %s</em>). + + + Lightbox + Lightbox + + + To trigger the lightbox, enter a <em>rel</em> attribute here. + Hier können Sie ein <em>rel</em>-Attribut eingeben, um die Lightbox anzusteuern. + + + Create an image link + Einen Bildlink erstellen + + + Use an image instead of the link title. + Ein Bild anstatt des Link-Textes verwenden. + + + Source files + Quelldateien + + + Please select one or more files or folders from the files directory. If you select a folder, its files will be included automatically. + Bitte wählen Sie eine oder mehr Dateien oder Ordner aus der Dateiübersicht. Wenn Sie einen Ordner auswählen, werden die darin enthaltenen Dateien automatisch eingefügt. + + + Sort order + Sortierreihenfolge + + + The sort order of the items. + Die Sortierreihenfolge der Elemente. + + + Use home directory + Benutzerverzeichnis verwenden + + + Use the home directory as file source if there is an authenticated user. + Das Benutzerverzeichnis als Dateiquelle verwenden, wenn sich ein Benutzer angemeldet hat. + + + Thumbnails per row + Vorschaubilder pro Reihe + + + The number of image thumbnails per row. + Die Anzahl an Vorschaubildern pro Reihe. + + + Items per page + Elemente pro Seite + + + The number of items per page. Set to 0 to disable pagination. + Die Anzahl an Elementen pro Seite. Geben Sie 0 ein, um den automatischen Seitenumbruch zu deaktivieren. + + + Total number of images + Gesamtzahl der Bilder + + + Here you can limit the total number of images. Set to 0 to show all. + Hier können Sie die Gesamtzahl der Bilder begrenzen. Geben Sie 0 ein, um alle anzuzeigen. + + + Order by + Sortieren nach + + + Please choose the sort order. + Bitte wählen Sie eine Sortierreihenfolge aus. + + + Gallery template + Galerietemplate + + + Here you can select the gallery template. + Hier können Sie das Galerietemplate auswählen. + + + Video/audio files + Video-/Audio-Dateien + + + Here you can add the video/audio file or multiple files if you are using different codecs. + Hier können Sie die Video-/Audio-Datei bzw. – wenn Sie verschiedene Codecs verwenden – die Video-/Audio-Dateien hinzufügen. + + + YouTube ID + YouTube-ID + + + Please enter the YouTube video ID (e.g. <em>nsqh9jHkHlM</em>). + Bitte geben Sie die YouTube-Video-ID ein (z.B. <em>nsqh9jHkHlM</em>). + + + Preview image + Vorschaubild + + + Show this image instead of the first frame of the video before playback. + Das Bild statt des ersten Frame des Videos vor dem Abspielen anzeigen. + + + Player size + Player-Größe + + + Width and height of the media player in pixels (e.g. 640x480). + Breite und Höhe des Mediaplayers in Pixeln (z.B. 640x480). + + + Autoplay + Autoplay + + + Automatically play the video when the page loads. + Das Video automatisch beim Laden der Seite abspielen. + + + Sliding interval + Slide-Intervall + + + The time in milliseconds between slides (1000 = 1s). Set to 0 to disable auto sliding. + Der Zeitraum in Millisekunden zwischen den Slides (1000 = 1s). 0 deaktiviert den automatischen Wechsel. + + + Transition speed + Übergangsgeschwindigkeit + + + The transition speed in milliseconds (1000 = 1s). Defaults to 300. + Die Übergangsgeschwindigkeit in Millisekunden (1000 = 1s). Standard: 300. + + + Slide offset + Slide-Versatz + + + Here you can make the slider start with a particular slide (counting starts at 0). + Den Slider mit einer bestimmten Folie beginnen (die Zählung beginnt bei 0). + + + Continuous + Kontinuierlich + + + Make the slider continuous (start all over when reaching the end). + Einen kontinuierlichen Slider erstellen (beim Erreichen des Endes von vorne beginnen). + + + Referenced element + Bezogenes Inhaltselement + + + Please choose the content element you want to insert. + Bitte wählen Sie das Inhaltselement aus, das Sie einfügen möchten. + + + Referenced article + Bezogener Artikel + + + Please choose the article you want to insert. + Bitte wählen Sie den Artikel aus, den Sie einfügen möchten. + + + Article + Artikel + + + Please select an article. + Bitte wählen Sie einen Artikel aus. + + + Form + Formular + + + Please select a form. + Bitte wählen Sie ein Formular aus. + + + Module + Modul + + + Please select a module. + Bitte wählen Sie ein Modul aus. + + + Protect element + Element schützen + + + Show the content element to certain member groups only. + Das Inhaltselement nur bestimmten Gruppen anzeigen. + + + Allowed member groups + Erlaubte Mitgliedergruppen + + + These groups will be able to see the content element. + Diese Gruppen können das Inhaltselement sehen. + + + Show to guests only + Nur Gästen anzeigen + + + Hide the content element if a member is logged in. + Das Inhaltselement verstecken, sobald ein Mitglied angemeldet ist. + + + CSS ID/class + CSS-ID/Klasse + + + Here you can set an ID and one or more classes. + Hier können Sie eine ID und beliebig viele Klassen eingeben. + + + Space in front and after + Abstand davor und dahinter + + + Here you can enter the spacing in front of and after the content element in pixel. You should try to avoid inline styles and define the spacing in a style sheet, though. + 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. + + + Invisible + Unsichtbar + + + Hide the element on the website. + Das Element auf der Webseite nicht anzeigen. + + + Show from + Anzeigen ab + + + Do not show the element on the website before this day. + Das Element erst ab diesem Tag auf der Webseite anzeigen. + + + Show until + Anzeigen bis + + + Do not show the element on the website on and after this day. + Das Element nur bis zu diesem Tag auf der Webseite anzeigen. + + + Element type + Elementtyp + + + Text/HTML/Code + Text/HTML/Code + + + Image settings + Bild-Einstellungen + + + Slider settings + Slider-Einstellungen + + + List items + Listeneinträge + + + Table items + Tabelleneinträge + + + Table configuration + Tabellenkonfiguration + + + Sorting options + Sortieroptionen + + + Accordion settings + Akkordeon-Einstellungen + + + Hyperlink settings + Hyperlink-Einstellungen + + + Image link settings + Bildlink-Einstellungen + + + Files and folders + Dateien und Ordner + + + Download settings + Download-Einstellungen + + + Include settings + Include-Einstellungen + + + Access protection + Zugriffsschutz + + + Expert settings + Experten-Einstellungen + + + Template settings + Template-Einstellungen + + + Player settings + Player-Einstellungen + + + Preview image + Vorschaubild + + + Visibility + Sichtbarkeit + + + ordered list + nummerierte Liste + + + unordered list + unnummerierte Liste + + + File name (ascending) + Dateiname (aufsteigend) + + + File name (descending) + Dateiname (absteigend) + + + Date (ascending) + Datum (aufsteigend) + + + Date (descending) + Datum (absteigend) + + + Custom order + Individuelle Reihenfolge + + + Random order + Zufällige Reihenfolge + + + The <em>%s</em> template needs to be included in the page layout. + Das <em>%s</em>-Template muss im Seitenlayout eingebunden sein. + + + The <em>%s</em> or <em>%s</em> template needs to be included in the page layout. + Das <em>%s</em>- oder <em>%s</em>-Template muss im Seitenlayout eingebunden sein. + + + New element + Neues Element + + + Add a new content element + Ein neues Element erstellen + + + Element details + Elementdetails + + + Show the details of content element ID %s + Details des Inhaltselements ID %s anzeigen + + + Move element + Element verschieben + + + Move content element ID %s + Inhaltselement ID %s verschieben + + + Duplicate element + Element duplizieren + + + Duplicate content element ID %s + Inhaltselement ID %s duplizieren + + + Delete element + Element löschen + + + Delete content element ID %s + Inhaltselement ID %s löschen + + + Edit element + Element bearbeiten + + + Edit content element ID %s + Inhaltselement ID %s bearbeiten + + + Edit article settings + Artikel bearbeiten + + + Edit the settings of the article + Die Artikeleinstellungen bearbeiten + + + Paste at the top + Oben einfügen + + + Paste after content element ID %s + Nach dem Inhaltselement ID %s einfügen + + + Add new at the top + Neues Element oben erstellen + + + Add new after content element ID %s + Neues Element nach dem Inhaltselement ID %s erstellen + + + Toggle visibility + Sichtbarkeit ändern + + + Toggle the visibility of element ID %s + Die Sichtbarkeit des Inhaltselements ID %s ändern + + + Edit source element + Quellelement bearbeiten + + + Edit the source element ID %s + Das Quellelement ID %s bearbeiten + + + Edit article + Artikel bearbeiten + + + Edit article ID %s + Artikel ID %s bearbeiten + + + + \ No newline at end of file