Links im Kalender

Hier bekommst Du deutschsprachigen Support bezüglich offizieller Module für phpwcms. Keine Fehlermeldungen oder Erweiterungswünsche bitte!
Post Reply
HajoT
Posts: 37
Joined: Sat 17. Jan 2009, 23:16
Location: Neustadt in Holstein

Links im Kalender

Post by HajoT »

Hallo,

Ist es möglich, im Kalender, nur die Objekte zu verlinken, für die im Feld AID/Alias/URL eine Angabe gemacht wurde?

Grüße

André
martin-144
Posts: 18
Joined: Mon 26. Jan 2009, 22:17

Re: Links im Kalender

Post by martin-144 »

Hallo,

ich stehe gerade vor einem ähnlichen Problem. Deine Frage scheint lösbar zu sein, wenn man im Kalender RT die Angabe "href" weglässt, werden nur Links bei ausgefülltem Feld "AID/Alias/URL" erzeugt. Leider akzeptiert das Feld nur Zahlen und verlinkt dann auch nicht auf die richtige Artikel-ID.

Soweit meine Erkenntnisse,
Martin
User avatar
flip-flop
Moderator
Posts: 8178
Joined: Sat 21. May 2005, 21:25
Location: HAMM (Germany)
Contact:

Re: Links im Kalender

Post by flip-flop »

Hi,

lasse ich die die Angabe "href" weg, wird bei mir nichts verlinkt wenn im Feld "AID/Alias/URL" ein Alias, eine ID oder eine URL steht.
Kann auch nicht funktionieren, da in der frontend_render Datei "include/inc_module/mod_calendar/inc/calendar.class.php" folgendes steht:

Code: Select all

$href	= $this->href ? $this->href . '&show_date='.date('Y-m-d', $date['calendar_start_date']).'_'.$date['calendar_id'] : '';
HREF ist aus meiner Sicht eher für einen Teaser gedacht, der dann direkt das Datum in der Liste anspringen kann. (Was allerdings ohne eine Erweiterung auch noch nicht funktioniert).

Folgende Paramter müssen dazu im Template eingeführt werden, dann ist auch "AID/Alias/URL" verfügbar, hat also mit href nichts zu tun.

Code: Select all

[URL]{URL}[/URL]
und
[TARGET]{TARGET}[/TARGET]


Z.B.:

Code: Select all

[URL]<a href="{URL}" [TARGET]{TARGET}[/TARGET]> >>Artikellink >></a>[/URL]
Z.B. mit dem Eintrag im Modul im Feld "AID/Alias/URL" :

Code: Select all

articlealias _blank
Der Kalender überzeugt durch seine Einfachheit, ein großes Plus.
Allerdings ist er leider nicht so ganz komplett (muss also erweitert werden), es fehlen einige Dinge, wie z.B. eine brauchbare BE Kurzübersicht oder die Einbindung des Wysiwyg Textes oder des Bildes.
Z.B. wüßte ich nicht wie so ein "more"-Link generiert werden soll mit dem vorhandenen Code. Bsp.: http://www.iba-stadtumbau.de/index.php?kalender-2008 (16.04.2008) Natürlich geht alles, jedoch muss das dann hinzuprogrammiert werden.

Eine Alternative die funktioniert: http://web.casa-loca.com/index.php?module - wesentlich komplexer bei der Einrichtung und den Funktionen.

Knut
>> HowTo | DOCU | FAQ | TEMPLATES/DOCS << ( SITE )
martin-144
Posts: 18
Joined: Mon 26. Jan 2009, 22:17

Re: Links im Kalender

Post by martin-144 »

Sorry Flip-Flop,

deiner Aussage muss ich widersprechen. Mittlerweile funktioniert es bei mir, dass bei einer Eingabe der Artikel-ID im Feld "AID/Alias/URL" ein Link erzeugt wird. Dies funktioniert allerdings nur bei Eingabe der Artikel-ID (AID) als reine Zahl. Alle Eingaben mit Buchstaben drin werden gelöscht.

Zur Sicherheit noch meine Konfigurationsdateien, die sich von deinen auch zu unterscheiden scheinen:

phpwcmsCalendar.class.php

Code: Select all

<?php
/*************************************************************************************
   Copyright notice
   
   (c) 2002-2008 Oliver Georgi (oliver@phpwcms.de) // All rights reserved.

This script is part of PHPWCMS. The PHPWCMS web content management system 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.

The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
A copy is found in the textfile GPL.txt and important notices to the license
from the author is found in LICENSE.txt distributed with these scripts.

This script 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.

This copyright notice MUST APPEAR in all copies of the script!
*************************************************************************************/

/**
 * phpwcms Calendar frontend render class
 */
class phpwcmsCalendar {

	var $mode		= 'simple';
	var $dates		= array();
	
	/**
	 * Initialize class
	 */
	function phpwcmsCalendar() {
	
		// current
		$this->current_date	= getdate();
		
		// set today 00:00:00 as start date
		$this->date_start	= mktime(0, 0, 0, $this->current_date['mon'], $this->current_date['mday'], $this->current_date['year']);
		
		// by default date_start + 1 year
		$this->date_end		= mktime(0, 0, 0, $this->current_date['mon'], $this->current_date['mday'], $this->current_date['year'] + 1) - 1;
		
		$this->dbReset();
	}
	
	/**
	 * Reset db base vars
	 */
	function dbReset() {
		$this->where	= '';
		$this->select	= '*';
		$this->join_on	= '';
		$this->group_by	= '';
		$this->order_by	= 'calendar_start ASC';
		$this->limit	= 0;
	}
	
	function defaultTemplate() {
		$this->template = '';
		$this->href		= '';
	}

	/**
	 * search string for calendar tag and parse
	 */
	function parse(& $string) {
		
		if( preg_match_all('/\{CALENDAR:(.*?)\}/s', $string, $matches) ) {
		
			if( isset($matches[1]) ) {
			
				foreach($matches[1] as $key => $value) {
			
					$this->parse_match($value);
					$result = $this->render();
					
					// replace calendar by result
					$string = str_replace($matches[0][$key], $result, $string);
			
				}
				
				$string = html_parser($string);
			
			}
		}
	
	}
	
	function render() {

		$items		= array();
		
		foreach($this->dates as $key => $date) {
			
			$date['calendar_refid'] = intval($date['calendar_refid']);
			
			if($date['calendar_refid'] > 0) {
				$href = 'index.php?aid='.$date['calendar_refid'];
			} else {
				$href = $this->href ? $this->href . '&show_date='.date('Y-m-d', $date['calendar_start_date']).'_'.$date['calendar_id'] : '';
			}
		
			$items[$key] = $this->template;
			$items[$key] = render_cnt_template($items[$key], 'HREF', $href);
			$items[$key] = render_cnt_template($items[$key], 'TITLE', html_specialchars($date['calendar_title']));
			$items[$key] = render_cnt_template($items[$key], 'TEXT', plaintext_htmlencode($date['calendar_teaser']));
			$items[$key] = render_cnt_template($items[$key], 'PLACE', html_specialchars($date['calendar_where']));
			$items[$key] = render_cnt_date($items[$key], $date['calendar_start_date'], $date['calendar_start_date'], $date['calendar_end_date']);
//---------------
// 0   :1       :2   :3        :4    :5     :6      :7       :8
// dbid:filename:hash:extension:width:height:caption:position:zoom
// $image		= ($crow["acontent_image"]) ? explode(":", $crow["acontent_image"]) : false ;

			// http://de.php.net/manual/de/function.serialize.php
			// http://de.php.net/unserialize
			$image_temp = @unserialize($date['calendar_object']);
//			dumpVar ($image_temp);

			$image_id    = $image_temp['image']['id'];
			$image_name  = $image_temp['image']['name'];
			$image_zoom  = getImageCaption($image_temp['image']['zoom']);
			$image_light = getImageCaption($image_temp['image']['lightbox']);
			
			// following is default for the exploded $caption
			// [0] caption text
			// [1] alt text for image
			// [2] link -> array(0 => link, 1 => target)
			// [3] title text -> if empty alt text will be used
			// [4] copyright information
			$image_capt = getImageCaption($image_temp['image']['caption']);
//			dumpVar ($image_capt);

			$image_text  = $image_capt[0];
			$image_alt   = $image_capt[1];
			$image_link  = $image_capt[2];
			$image_title = $image_capt[3];
			$image_copyr = $image_capt[4];
			


// get segments: cmsimage.php/%WIDTH%x%HEIGHT%x%CROP%x%QUALITY%/%HASH%.%EXT%
			$image_calendar = '<img src="'.PHPWCMS_URL.'img/cmsimage.php/100x100/'.$image_id.'" alt="'.$image_alt.'" />';
// dumpVar ($image_calendar);

// Bildaufbereitung f�r zoom u. LightBox siehe Bilder div
// /include/inc_front/content/cnt29.article.inc.php

//----------------
			// KH Wysiwyg  http://forum.phpwcms.org/viewtopic.php?p=107020#p107020
			$items[$key] = render_cnt_template($items[$key], 'TEXTLONG', $date['calendar_text']);
			// KH Bilder   http://forum.phpwcms.org/viewtopic.php?p=107159#p107159
			$items[$key] = render_cnt_template($items[$key], 'IMAGE_CALENDAR', $image_calendar);
			
		}
		
		return implode(LF, $items);
		
	}
	
	/**
	 * Parse matched replacement tag
	 */
	function parse_match($match='') {
	
		$default		= array();
		$match			= trim($match);
		
		// set query defaults
		$this->dbReset();
		$this->defaultTemplate();

		if($match !== '' && strpos($match, '=') !== FALSE ) {
		
			// oh yes fix, in case LF was converted to <br /> by phpwcms
			$match = str_replace('<br />', LF, $match);
			
			// result is a normal array
			$match = parse_ini_str($match, false);
			
			$default['items']		= isset($match['items']) ? intval($match['items']) : 0;
			$default['template']	= empty($match['template']) ? '' : trim($match['template']);
			$default['lang']		= empty($match['lang']) ? '' : trim($match['lang']);
			$default['tag']			= empty($match['tag']) ? '' : trim($match['tag']);
			$default['tagmode']		= empty($match['tagmode']) ? 'OR' : ( trim($match['tagmode']) == 'AND' ? 'AND' : 'OR' );
			$default['href']		= empty($match['href']) ? '' : trim($match['href']);
		
		} else {
			
			// base format
			// 2,main_page.tmpl,de en, href, tag1, tag2 tag2, tag3
			// [item count,[template[,language(en de - separated by space)[, href, tags, tag, tag, tag]]]]
			$match = explode(',', $match, 5);
			
			$default['items']		= intval($match[0]);
			$default['lang']		= empty($match[1]) ? '' : $match[1];
			$default['template']	= empty($match[2]) ? '' : trim($match[2]) ;
			$default['href']		= empty($match[3]) ? '' : trim($match[3]);
			$default['tag']			= empty($match[4]) ? '' : $match[4];
			$default['tagmode']		= 'OR';
		
		}
		
		$this->limit = $default['items'];
		$this->href  = $default['href'];
		
		if($default['template'] !== '') {
			$default['template'] = preg_replace('/[\/\\:]/', '', $default['template']);
			if(is_file(PHPWCMS_TEMPLATE.'calendar/'.$default['template'])) {
				$this->template = file_get_contents(PHPWCMS_TEMPLATE.'calendar/'.$default['template']);
				$this->template = str_replace('{STARTDATE', '{LIVEDATE', $this->template);
				$this->template = str_replace('{ENDDATE', '{KILLDATE', $this->template);
			} else {
				$default['template'] = '';
			}
		}

		$where = array();
		
		if($default['lang'] !== '') {

			$default['lang']	= str_replace(',', ' ', preg_replace('/[^a-z\-]/', '', strtolower($default['lang'])));
			$default['lang']	= array_intersect( convertStringToArray( $default['lang'], ' '), $GLOBALS['phpwcms']['allowed_lang']);

			if(count($default['lang'])) {
				$where[]			= "calendar_lang IN ('" . implode("','", $default['lang']) . "')";
			}
		}
		
		if($default['tag'] !== '') {

			$default['tag'] = convertStringToArray( strtolower( $default['tag'] ), ',');

			if(count($default['tag'])) {
				
				$tag_where = array();
	
				foreach($default['tag'] as $tag) {
					
					$tag_where[]		= "cat_name='".aporeplace($tag)."'";
				
				}
				
				if(count($tag_where)) {
				
					$where[]		= '(' . implode(' '.$default['tagmode'] . ' ', $tag_where) . ')';
					
					$this->join_on	= 'LEFT JOIN '.DB_PREPEND.'phpwcms_categories ON cat_pid=calendar_id';
					$this->group_by	= 'calendar_id';
				}
			
			};
		}
	
		$this->where = implode(' AND ', $where);
		
		$this->getDate();
		
		return $default;
	
	}
	

	function getDate() {
	
		// 1 daily
		// 2 Every weekday (Mon-Fri)
		// 3 Every Mon., Wed. and Fri.
		// 4 Every Tues. and Thurs.
		// 5 Weekly
		// 6 Monthly
		// 7 yearly
	
		if(is_string($this->order_by) && trim($this->order_by) != '') {
			$this->order_by = '  ORDER BY '.$this->order_by;
		} else {
			$this->order_by = '';
		}
		if(is_int($this->limit) && $this->limit > 0) {
			$this->limit = ' LIMIT '.$this->limit;
		} else {
			$this->limit = '';
		}
		if(is_string($this->group_by) && trim($this->group_by) != '') {
			$this->group_by = '  GROUP BY '.$this->group_by;
		} else {
			$this->group_by = '';
		}
		
	
		$sql  = 'SELECT '. $this->select .', ';
		$sql .= "UNIX_TIMESTAMP(calendar_start) AS calendar_start_date, ";
		$sql .= "UNIX_TIMESTAMP(calendar_end) AS calendar_end_date ";
		$sql .= ' FROM '.DB_PREPEND.'phpwcms_calendar pc ';
		$sql .= $this->join_on;
		$sql .= ' WHERE ';
		$sql .= 'calendar_status = 1 AND ';
		$sql .= "calendar_start >= '".aporeplace( date('Y-m-d H:i:s', $this->date_start) )."' AND ";
		$sql .= "calendar_start <= '".aporeplace( date('Y-m-d H:i:s', $this->date_end) )."'";
		if(!empty($this->where)) {
			$sql .= ' AND ' . $this->where;
		}
		$sql .= $this->group_by;
		$sql .= $this->order_by;
		$sql .= $this->limit;
		
		$this->dates = _dbQuery($sql);
		if( !$this->dates ) {
			$this->dates = array();
		}
	}

}


?>
init-calendar.php

Code: Select all

<?php
/*************************************************************************************
   Copyright notice
   
   (c) 2002-2008 Oliver Georgi (oliver@phpwcms.de) // All rights reserved.

This script is part of PHPWCMS. The PHPWCMS web content management system 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.

The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
A copy is found in the textfile GPL.txt and important notices to the license
from the author is found in LICENSE.txt distributed with these scripts.

This script 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.

This copyright notice MUST APPEAR in all copies of the script!
*************************************************************************************/


/**
 * Usage: sample Replacement Tag
 * 
 * {CALENDAR:
 *	items=100
 *	template=dates_list_de.html
 *	lang=de
 *	tagmode=OR
 *	href=index.php?calendar
 * }
 * 
 * OR
 * 
 * {CALENDAR:2,main_page.tmpl,de en, href, tag1, tag2 tag2, tag3}    
 * [item count,[template[,language(en de - separated by space)[, href, tags, tag, tag, tag]]]]
 * 
 **/  

if(strpos($content['all'], '{CALENDAR:')) {

	$GLOBALS['block']['css']['calendar'] = 'calendar.css'; // +kh: including the css file 

	include(PHPWCMS_TEMPLATE.'inc_script/phpwcmsCalendar.class.php');
		
	$myCal = & new phpwcmsCalendar();
	$myCal->parse($content['all']);

}


?>
Mein Template:

Code: Select all

<div class="calendar">
        <div class="date">
        <div style="float:left;"><img src="{SITE}img/cmsimage.php/25x25/524" valign=center /></div>
        <div style="margin-left: 35px;"><strong>{STARTDATE:l lang=DE} <br> {STARTDATE:d.m.}</strong><strong class="year">{STARTDATE:Y}</strong></div>
        </div>

        {SPACER:100x5}

        [TITLE]<h3>[HREF]<a href="{HREF}">[/HREF]{TITLE}[HREF]</a>[/HREF]</h3>[/TITLE]
	[TEXT]<div class="teaser">{TEXT}</div>[/TEXT]
        <!-- [TEXTLONG]<div class="textlong">{TEXTLONG}</div>[/TEXTLONG] -->

        {SPACER:100x5}


        [PLACE]<p class="place">Ort: {PLACE}</p>[/PLACE]
	[IMAGE_CALENDAR]<div class="image_teaser">{IMAGE_CALENDAR}</div>[/IMAGE_CALENDAR]
</div>
soweit, so gut,
Martin
User avatar
flip-flop
Moderator
Posts: 8178
Joined: Sat 21. May 2005, 21:25
Location: HAMM (Germany)
Contact:

Re: Links im Kalender

Post by flip-flop »

Du verwendest eine ältere Version:

tausche

Code: Select all

         $date['calendar_refid'] = intval($date['calendar_refid']);
         
         if($date['calendar_refid'] > 0) {
            $href = 'index.php?aid='.$date['calendar_refid'];
         } else {
            $href = $this->href ? $this->href . '&show_date='.date('Y-m-d', $date['calendar_start_date']).'_'.$date['calendar_id'] : '';
         }
      
         $items[$key] = $this->template;
         $items[$key] = render_cnt_template($items[$key], 'HREF', $href);
gegen

Code: Select all

			$url	= '';
			$target	= '';
			$href	= $this->href ? $this->href . '&show_date='.date('Y-m-d', $date['calendar_start_date']).'_'.$date['calendar_id'] : '';
	
			if(!empty($date['calendar_refid'])) {
						
				$date['calendar_refid']			= get_redirect_link($date['calendar_refid'], ' ', '');
				$date['calendar_refid']['link']	= trim($date['calendar_refid']['link']);
				$date['calendar_refid']['link']	= trim($date['calendar_refid']['link'], '#');
				
				$target							= $date['calendar_refid']['target'];
				
				if(is_intval($date['calendar_refid']['link'])) {
					$url = rel_url(array(), array(), 'aid='.$date['calendar_refid']['link']); //'index.php?aid='.$date['calendar_refid']['link'];
					
				} elseif(strpos($date['calendar_refid']['link'], '://') || strpos($date['calendar_refid']['link'], '?') || strpos($date['calendar_refid']['link'], '.')) {
					$url = $date['calendar_refid']['link'];
					
				} elseif(!empty($date['calendar_refid']['link'])) {
					$url = rel_url(array(), array(), $date['calendar_refid']['link']);
				
				}
			}
		
			$items[$key] = $this->template;
			$items[$key] = render_cnt_template($items[$key], 'HREF', $href);
			$items[$key] = render_cnt_template($items[$key], 'URL', $url);
			$items[$key] = render_cnt_template($items[$key], 'TARGET', $target);
nun sollten auch die Tags URL und Target vorhanden sein.

Nicht getestet bitte probieren.

Knut
>> HowTo | DOCU | FAQ | TEMPLATES/DOCS << ( SITE )
martin-144
Posts: 18
Joined: Mon 26. Jan 2009, 22:17

Re: Links im Kalender

Post by martin-144 »

Hallo zusammen,

für mich funktioniert mittlerweile eigentlich alles, was ich haben will. Daher keine großen Basteleien.
Ich wollte mit meinem Beitrag eigentlich dem Thread-Ersteller helfen, vielleicht sollte sich der nochmal zu Wort melden.

Aber: bei mr funktionieren in den html-Templates keine <?php?> oder {SITE} RTs, was kann das sein?
Genau geht es um

Code: Select all

<img src="{SITE}img/cmsimage.php/25x25/524" />
oder auch

Code: Select all

<img src="<?=PHPWCMS_URL ?>img/cmsimage.php/25x25/524" />
was nicht funktioniert. Was ist da faul? Prinzipiell geht es darum, ein normales Bild zu bekommen, ohne Kalender-Bezug.

Grüsse, Martin
User avatar
flip-flop
Moderator
Posts: 8178
Joined: Sat 21. May 2005, 21:25
Location: HAMM (Germany)
Contact:

Re: Links im Kalender

Post by flip-flop »

{Site} ist normalerweise nicht notwendig. Ich habe allerdings keine Ahnung, weshalb der SITE Tag nicht funktioniert.

direkt nach:

Code: Select all

$items[$key] = render_cnt_date($items[$key], $date['calendar_start_date'], $date['calendar_start_date'], $date['calendar_end_date']);
einfügen:

Code: Select all

$items[$key] = render_cnt_template($items[$key], 'SITE', PHPWCMS_URL);

<?= .......... ?> geht grundsätzlich nicht in phpwcms.
[PHP].........[/PHP] damit noch ein Rest Sicherheit vorhanden ist.

Knut
>> HowTo | DOCU | FAQ | TEMPLATES/DOCS << ( SITE )
martin-144
Posts: 18
Joined: Mon 26. Jan 2009, 22:17

Re: Links im Kalender

Post by martin-144 »

Servus nochmal,

Danke Flip-Flop, das hats gebracht. Jetzt funktioniert der {SITE}-Tag wie erwartet.

Danke,
Martin
Post Reply