commit b7101a005ff019c8043b811ed34ae1df5accf034
parent d39bf00dee9f5d6838d405220077bdd97378b06d
Author: Jan Dankert <devnull@localhost>
Date: Sat, 4 Oct 2014 00:25:14 +0200
Neues Makro "LastChanges" und weitere Verbesserungen der HTML-Ausgabe bei Makros.
Diffstat:
2 files changed, 156 insertions(+), 13 deletions(-)
diff --git a/macro/ClassicMenu.class.php b/macro/ClassicMenu.class.php
@@ -34,14 +34,12 @@ class ClassicMenu extends Macro
/**
* Zeichenkette, die vor einem aktiven Menuepunkt gezeigt wird
*/
- var $beforeEntry = '<li><strong>';
- var $afterEntry = '</strong></li>';
- var $csspraefix = 'menu';
+ var $css_class = 'macro-classicmenu';
var $onlySameTemplate = true;
// Erstellen des Hauptmenues
- function execute()
+ public function execute()
{
$rootId = $this->getRootObjectId();
// Erstellen eines Untermenues
@@ -49,12 +47,12 @@ class ClassicMenu extends Macro
$f = new Folder( $this->page->parentid );
$this->parentFolders = $f->parentObjectFileNames(false,true);
- $this->showFolder( $rootId,0 );
+ $this->showFolder( $rootId );
}
- function showFolder( $oid,$level )
+ private function showFolder( $oid )
{
- $this->outputLn('<ul class="'.$this->csspraefix.$level.'">');
+ $this->outputLn('<ul class="'.$this->css_class.'">');
$f = new Folder( $oid );
// Schleife ueber alle Objekte im aktuellen Ordner
@@ -75,14 +73,14 @@ class ClassicMenu extends Macro
// Wenn aktuelle Seite, dann markieren, sonst Link
if ( $this->page->objectid == $fp->objectid )
// aktuelle Seite
- $this->outputLn( '<li class="'.$this->csspraefix.$level.'"><strong class="'.$this->csspraefix.$level.'">'.$o->name.'</strong>' );
+ $this->outputLn( '<li class="active">'.$o->name.'' );
else
// Link erzeugen
- $this->outputLn( '<li class="'.$this->csspraefix.$level.'"><a class="'.$this->csspraefix.$level.'" href="'.$this->pathToObject($fp->objectid).'">'.$o->name.'</a>' );
+ $this->outputLn( '<li><a href="'.$this->pathToObject($fp->objectid).'">'.$o->name.'</a>' );
if ( in_array($o->objectid,array_keys($this->parentFolders)) )
{
- $this->showFolder($o->objectid,$level+1);
+ $this->showFolder($o->objectid);
}
$this->outputLn( '</li>' );
@@ -103,13 +101,13 @@ class ClassicMenu extends Macro
// Wenn aktuelle Seite, dann markieren, sonst Link
if ( $this->getObjectId() == $o->objectid)
// aktuelle Seite
- $this->output( '<li class="'.$this->csspraefix.$level.'"><strong class="'.$this->csspraefix.$level.'">'.$o->name.'</strong></li>' );
+ $this->output( '<li class="active">'.$o->name.'</li>' );
elseif ( $o->isLink )
// Link mit HTML-Sonderzeichenumwandlung erzeugen
- $this->output( '<li class="'.$this->csspraefix.$level.'"><a class="'.$this->csspraefix.$level.'" href="'.htmlspecialchars($this->pathToObject($o->objectid)).'">'.$o->name.'</a></li>' );
+ $this->output( '<li><a href="'.htmlspecialchars($this->pathToObject($o->objectid)).'">'.$o->name.'</a></li>' );
else
// Link erzeugen
- $this->output( '<li class="'.$this->csspraefix.$level.'"><a class="'.$this->csspraefix.$level.'" href="'.$this->pathToObject($o->objectid).'">'.$o->name.'</a></li>' );
+ $this->output( '<li><a href="'.$this->pathToObject($o->objectid).'">'.$o->name.'</a></li>' );
}
}
$this->output('</ul>');
diff --git a/macro/LastChanges.class.php b/macro/LastChanges.class.php
@@ -0,0 +1,144 @@
+<?php
+// OpenRat Content Management System
+// Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+
+/**
+ * Erstellen einer Teaser-Liste.
+ *
+ * @author Jan Dankert
+ */
+class LastChanges extends Macro
+{
+ var $title_html_tag = 'h3';
+ var $css_class = 'macro-lastchanges';
+ var $teaserElementId = '';
+ var $teaserMaxLength = 100;
+ var $plaintext = 'true';
+ var $linktitle = 'true';
+ var $linktext = 'true';
+ var $timeelementid = 0;
+ var $folderid = 0;
+ var $showPages = true;
+ var $showLinks = false;
+
+ /**
+ * Bitte immer eine Beschreibung benutzen, dies ist fuer den Web-Developer hilfreich.
+ * @type String
+ */
+ var $description = 'Creates a teaser list of pages in a folder';
+
+ //
+ function execute()
+ {
+ $project = Session::getProject();
+
+ if ( $this->folderid === 'self' )
+ {
+ $page = $this->getPage();
+ $page->load();
+ $folderid = $page->parentid;
+ $f = new Folder( $folderid );
+ $changes = $f->getLastChanges();
+ }
+ elseif ( $this->folderid > 0 )
+ {
+ $f = new folder( $this->folderid );
+ $changes = $f->getLastChanges();
+ }
+ else
+ $changes = $project->getLastChanges();
+
+ foreach( $changes as $o )
+ {
+ if ($o['objectid'] == $this->getObjectId() )
+ continue;
+
+ if ( ($o['is_page']==1 && istrue($this->showPages)) ||
+ ($o['is_link']==1 && istrue($this->showLinks)) ) // Nur wenn gewünschter Typ
+ {
+ if ( $o['is_link']==1 ) {
+ $l = new Link( $o['objectid'] );
+ $l->load();
+ if ( !$l->isLinkToObject)
+ continue;
+
+ $p = new Page( $l->linkedObjectId );
+ }
+ elseif ( $o['is_page']==1 )
+ {
+ $p = new Page( $o['objectid'] );
+ }
+ else
+ continue;
+
+ $p->load();
+
+ $desc = $p->desc;
+ $p->generate_elements();
+
+ if ( !empty($this->teaserElementId) )
+ {
+ $value = $p->values[$this->teaserElementId];
+ $desc = $value->value;
+ if ( istrue($this->plaintext) )
+ {
+ $desc = strip_tags($desc);
+ // Und nur wenn die Tags raus sind duerfen wir nun den Text kuerzen.
+ // (sonst drohen offene Tags)
+ if ( is_numeric($this->teaserMaxLength) && $this->teaserMaxLength > 0 )
+ $desc = Text::maxLength($desc,$this->teaserMaxLength);
+ }
+ }
+
+ $time = '';
+ if ( !empty($this->timeelementid) )
+ {
+ $value = $p->values[$this->timeelementid];
+ $time = $value->value;
+ }
+
+ $this->output('<div class="'.$this->css_class.'">');
+
+ if ( istrue($this->linktitle) )
+ {
+ $url = $this->pathToObject($o['objectid']);
+ $this->output( '<a href="'.$url.'"><div>' );
+ }
+
+ $this->output('<h6>'.$time.'</h6>');
+
+
+ $this->output( '<h3>');
+ $this->output( $p->name );
+ $this->output( '</h3>' );
+
+ $this->output( '<p>' );
+ $this->output( $desc );
+ $this->output( '</p>' );
+
+ if ( istrue($this->linktitle) )
+ {
+ $this->output( '</div></a>' );
+ }
+
+ $this->output( '</div>' );
+ }
+ }
+ }
+}+
\ No newline at end of file