Sortierreihenfolge im JAX Calendar

Gesperrt
mreif
Beiträge: 192
Registriert: Mi 12. Okt 2005, 16:32
Wohnort: Weiterstadt
Kontaktdaten:

Sortierreihenfolge im JAX Calendar

Beitrag von mreif »

Hallo,

ich habe den JAX Kalender als Modul eingebunden und muss sagen - super herzlichen Dank.
Der ist echt klasse gemacht !!! :-)

Da im Forum schon die ersten Problems besprochen wurden, lief der Kalender per sofort.

Eine Frage hierzu hätte ich aber dann doch noch.
Wenn ich Termine in den Kalender eintrage und diese anzeigen lasse, erscheinen die Termine in der Reihenfolge der Eingabe.
Kann man irgendwo die Sortierreihenfolge noch einstellen - habe keinen Punkt hierzu finden können.
(Entweder was es gestern schon zu spät oder heute Morgen zu früh - liegt wahrscheinlich an der Nachtblindheit, wenn die Bildschirm langsam dunkel wird).

Die Sortierreihenfolge würde ich gerne nach
"Ereigniszeitraum - Anfang"
sortieren.

Im Voraus vielen Dank für Eure Tipps.

Gruß
Michael
emergence
Beiträge: 10653
Registriert: Mo 28. Jul 2003, 12:49
Wohnort: Austria
Kontaktdaten:

Beitrag von emergence »

wie sieht den das output modul aus ? (ich hab das teil nirgendwo im einsatz)
*** make your own tools (wishlist :: thx)
mreif
Beiträge: 192
Registriert: Mi 12. Okt 2005, 16:32
Wohnort: Weiterstadt
Kontaktdaten:

Beitrag von mreif »

Input:
echo "<table cellspacing=\"0\" cellpadding=\"2\" border=\"0\">

<tr>
<td></td> <td></td><td width=\"120\">Kalender Nr.[0-4] : </td><td></td>";
$wert[1] = ("CMS_VALUE[1]" == '') ? ('0') : ("CMS_VALUE[1]");
echo"<td><input type=\"text\" name=\"CMS_VAR[1]\" value=\"{$wert[1]}\"></td></tr></table>";


Output:
<?
$con_cal_number = 'CMS_VALUE[1]';
require($cfg['path']['contenido']."plugins/calendar/jax_calendar1.php");
?>


jax_calendar1.php:
<?php include_once( "main.inc2.php"); /*to include BEFORE other Jax-Calendar-moduls!*/ ?>

<?php include_once( "eventlist_full_year.inc.php" ); /*require( "nextevent.inc.php" ); /*displays the Event Kalendar!*/ ?>



Gruß
Michael
felicitas
Beiträge: 2
Registriert: Di 7. Feb 2006, 12:05
Wohnort: Darmstadt
Kontaktdaten:

Sortierreihenfolge im Jax-Kalender

Beitrag von felicitas »

Hallo an alle, die dieses lästeige Sortierproblem auch hatten / haben.
Ich baue gerade die neue Internetpräsenz einer Schule auf, und wollte mit dem Jax-Kalender die Termine anzeigen lassen. Das hat guch gut funktioniert, alle Links haben SOFORT funktioniert; ich habe sie in ein Template eingebaut (Kalendermodul und Terminmodul).

Nur waren die Termine vollkommen "unordentlich" sortiert. Mit "unordentlich" meine ich chaotisch, denn es war KEINE Logik erkennbar (weder id, event_start, etc.)

Zwar kann man mit der

Code: Alles auswählen

var $order_criterion = "ORDER BY 'event_start' ASC";
die Elemente sortiern, nur werden, das habe ich nach langem herumprobieren herausbekommen, die Attribute nicht an die Funktion

Code: Alles auswählen

get_entry()
in Zeile 182 in der mysql.inc.php weitergegeben.
Daher habe ich das

Code: Alles auswählen

var $order_criterion
in Zeile 24 auskommentiert, und die Zeile 193 wie nachfolgt geändert:

Code: Alles auswählen

$query = "SELECT * FROM " . $this->name ." ORDER BY 'event_start' DESC";
Weitere Ordnungskriterien kann man nun nach belieben hinzufügen...
Ich hoffe, das hilft weiter. Viele Grüße, Felix

P.S. Dies müßte auch die Frage von cibyl beantworden:
http://www.contenido.org/forum/viewtopi ... c&start=45

P.P.S. Hier nochmal die ganze mysql.inc.php:

Code: Alles auswählen

<?php //mysql.inc.php (table-xs v1.91) - (C) by Jack (tR) (http://www.jtr.de/scripting/php)

class mysql
/*
	The Data source is a mySQL database (table)

	first field of each table has to be defined as:

	id int(11) NOT NULL auto_increment
*/
{

	// public class variables which may be modified
	var $name            = "";
	var $handle          = "";
	var $server          = "";
	var $database        = "";
	var $login           = "";
	var $password        = "";
	var $captions        = array();
	var $tab_list        = array();
	var $list_next_pos   = 0;
	var $list_max_pos    = 0;
	//var $order_criterion = "ORDER BY 'event_start' ASC";
	var $eol             = false;

/*

//----------------------------------------------------------------------------
//				I N T E R F A C E
//----------------------------------------------------------------------------

	// returns the captions of the table rows
	array get_captions( );

	// opens the data source
	boolean open( string mode );

	// closes the data source
	boolean close();

	// initializes the data source
	boolean init();

	// returns the number of table entries
	int entries();

	// returns an entry from the table
	get_entry( int pos, reference array rows );

	// returns the next entry from the table
	get_next_entry( reference array rows );

	// returns several successive table entries
	get_entrylist( int start, int stop, reference array entrylist );

	// appends an entry to the table
	append( array data );

	// looks for the first appearance of a date in the table
	find_entry( string data );

	// looks for the next appearance of a date in the table
	find_next_entry( string data );

	// changes a line in the table
	change( int pos, array data );

	// removes an entry from the table
	delete( int pos )
*/


//-------------------------------- Help Functions ----------------------------

//improvement note:
//this version failes if table is empty
//use the PHP/MySQL functions instead for getting the column names!

	function get_captions()
	// Task:    returns the captions of the table rows
	//
	// Input:   none
	//
	// Output:  returns the table captions in global array $captions
	{
		$query = "SELECT * FROM " . $this->name;
		$result = mysql_query( $query, $this->handle );
		$num_fields = mysql_num_fields( $result );

		$i = 0;
		while ( $i < $num_fields )
		{
			$name = mysql_field_name( $result, $i );
			$this->captions[$i] = $name;
			$i++;
		}
	}

//-------------------------------- Implementation ----------------------------


	function open( $mode )
	// establishes the connection to the MySQL-RDBMS
	{
		if ( !$this->handle = @mysql_connect( $this->server, $this->login, $this->password ) )
		{
			echo "Error: Connection to mySQL-database at '$this->server' failed!";
			return false;
		}
		else
		{
			if ( @mysql_select_db( $this->database ) )
			{
				$query = "SELECT * FROM " . $this->name ." " .$this->order_criterion;
				//echo $query ."<br><br>";
				$result = mysql_query( $query, $this->handle );
				$num_entries = mysql_num_rows( $result );
				if ($num_entries == 0)
				{ $this->eol = true; }
				else
				{$this->eol = false;}

				return true;
			}
			else
			{
				echo "Error: Database '$this->database' not found!<br>";

				return false;
			}
		}
	}


	function close()
	// closes the connection to the mySQL-RDBMS
	{
		return mysql_close( $this->handle );
	}


	function init()
	// initializes the data source
	{
		if ( $this->open( "" ) AND $this->close() )
		{
			return true;
		}
		return false;

		unset( $this->$tab_list );
		$this->list_next_pos = 0;
	}


	function entries()
	// Task:   returns the number of table entries
	//
	// Input:  none
	//
	// Output: number of entries
	{

		$this->open("");

		$this->get_captions();

		$query = "SELECT id FROM " . $this->name;
		if ( ! $result = @mysql_query( $query, $this->handle )  )
		{
			echo "Error: Table '$this->database.$this->name' not found...";
			exit;
		}
		$num_entries = mysql_num_rows( $result );
		$this->close();

		return $num_entries;
	}


	function get_entry( $pos, &$rows )
	// Task:   returns an entry from the table
	//
	// Input:  $pos     = number of the line from where to fetch the data
	//
	// Output: $rows    = array containing the entries
	{
		$this->open( "r");

		$this->get_captions();

		$query = "SELECT * FROM " . $this->name ." ORDER BY 'event_start' DESC";
		//echo $query;
		$this->tab_list = mysql_query( $query, $this->handle );
		$this->list_max_pos = mysql_num_rows( $this->tab_list );

		if ($pos < $this->list_max_pos)
		{
			mysql_data_seek( $this->tab_list, $pos );

			$rows = mysql_fetch_array( $this->tab_list, MYSQL_ASSOC );
			$this->list_next_pos = $pos + 1;
		}
		else $this->eol = true;
	}

	function get_next_entry( &$rows )
	// Task:   returns the next entry from the table
	//
	// Output: $rows	= array containing the entries
	{
		if ($this->list_next_pos < $this->list_max_pos)
		{
			mysql_data_seek( $this->tab_list, $this->list_next_pos );

			$rows = mysql_fetch_array( $this->tab_list, MYSQL_ASSOC );

			$this->list_next_pos++;
		}
		else $this->eol = true;
	}


	function get_entrylist( $start, $stop, &$entrylist )
	// Task:   returns several successive table entries
	//
	// Input:  $start  = first entry to fetch
	//         $end    = last entry to fetch
	//
	// Output: $entrylist = two dimensional array containing
	//                      the red lines/entries
	{
		$this->open( "r" );

		$this->get_captions();

		$query = "SELECT * FROM " . $this->name ." " .$this->order_criterion;
		$this->tab_list = mysql_query( $query, $this->handle );
		$this->list_max_pos = mysql_num_rows( $this->tab_list );

		$result = mysql_query( $query, $this->handle );

		$this->list_max_pos = mysql_num_rows( $this->tab_list );

		$i=0;
		while ($i < $start && $start < $this->list_max_pos )
		{
			$tokens = mysql_fetch_array( $result, MYSQL_ASSOC );
			$i++;
		}

		while ($i <= $stop && $stop <= $this->list_max_pos)
		{
			$entrylist[$i] = mysql_fetch_array( $result, MYSQL_ASSOC );
			$i++;
		}
		$this->close();
	}


	function append( $data )
	// Task:   Appends an entry to the table
	//
	// Input:  $data	= array with the data to save
	//
	{
		$this->open( "a" );

		$query = "INSERT INTO " . $this->name ." ( ";

		$values = array_keys( $data );
		$preset_commata = false;
		foreach ($values as $val)
		{
			if (!$preset_commata)
			{
				$query .= $val;
				$preset_commata = true;
			}
			else
			{
				$query .= "," . $val;
			}
		}
		$query .= ") VALUES ( ";

		$values = array_keys( $data );
		$preset_commata = false;
		foreach ($values as $val)
		{
			if (!$preset_commata)
			{
				$query .= "'".$data[$val]."'";
				$preset_commata = true;
			}
			else
			{
				$query .= "," . "'" . $data[$val] . "'";
			}
		}
		$query .= " );";
		$result = mysql_query( $query, $this->handle );
	}


	function find_entry( $data )
	// Task:   Searches for the first appearance of a date in the table
	//
	// Input:  $data = array with the colums to find
	//
	{
		$entry = 0;
		$this->open( "r" );
		$this->get_captions();

		$query = "SELECT * FROM " . $this->name ." " .$this->order_criterion;
		$this->tab_list = mysql_query( $query, $this->handle );
		$this->list_max_pos = mysql_num_rows( $this->tab_list );

		while ( $entry <= $this->list_max_pos
		        && $row = mysql_fetch_array( $this->tab_list, MYSQL_ASSOC ) )
		{
			$equal = true;

			$keys = array_keys( $data );
			foreach ($keys as $key)
			{
				if ( $data[$key] != $row[$key] )
				{
					$equal = false;
					break;
				}
			}

			if ( $equal ) {	break; }

			$entry++;
		}

		$this->next_list_pos = $entry + 1;
		return $entry;
	}


	function find_next_entry( $data )
	// Task:   Searches for the next appearance of a date in the table
	//
	// Input:  $data 	= array with the columns to search
	//
	{
		$ok = false;
		$entry = $this->list_next_pos;

		if ($this->list_next_pos < $this->list_max_pos)
		{
			mysql_data_seek( $this->tab_list, $this->list_next_pos );

			while ( ($row = mysql_fetch_array( $this->tab_list, MYSQL_ASSOC ) ) )
			{
				$equal = true;

				$keys = array_keys( $data );
				foreach ($keys as $key)
				{
					if ( $data[$key] != $row[$key] )
					{
						$equal = false;
						break;
					}
				}

				if ( $equal )
				{
					break;
				}

				$entry++;
			}
		}

		$this->list_next_pos = $entry + 1;
		if ($this->list_next_pos > $this->list_max_pos) $this->eol = true;

		return $entry;
	}


	function change( $pos, $data )
	// Task:    Changes a line in the table
	//
	// Input:   $pos   = Position of the element
	//		    $data  = array containing the data to save
	//
	{
		$num_of_entries = $this->entries();

		$this->open( "r" );
		$this->get_captions();

		$i=0;
		$query = "SELECT * FROM " . $this->name ." " .$this->order_criterion;
		$result = mysql_query( $query, $this->handle );

		while ($i <= $pos)
		{
			$tokens = mysql_fetch_array( $result, MYSQL_ASSOC );
			$i++;
		}

		$id = $tokens["id"];

		$query = "UPDATE ".$this->name." SET ";

		$values = array_values( $this->captions );
		$preset_commata = false;
		foreach ($values as $val)
		{
			if ($val != "id" )
			{
				if (!$preset_commata)
				{
					$query .= $val ." = ". '"'.$data[$val].'"'; $preset_commata = true;
				}
				else
				{
					$query .= ", " . $val ." = ". '"' . $data[$val] .'"';
				}
			}
		}
		$query .= " WHERE id = ".$id;
		$result = mysql_query( $query, $this->handle );

		$this->close();
	}

	function delete( $pos )
	// Task:  Removes a line from the table
	//
	// Input: $pos  = Position of the Element
	//
	{
		$num_of_entries = $this->entries();

		$this->open( "r" );

		$i=0;
		$query = "SELECT * FROM " . $this->name ." " .$this->order_criterion;
		$result = mysql_query( $query, $this->handle );

		while ($i <= $pos)
		{
			$tokens = mysql_fetch_array( $result, MYSQL_ASSOC );
			$i++;
		}
		$id = $tokens["id"];

		$query = "DELETE FROM ".$this->name." WHERE id = ".$id;
		$result = mysql_query( $query, $this->handle );

		$this->close();
	}

	function insert ( $pos, $data )
	// Task:  Removes a line from the table
	//
	// Input: $pos	= Position of the Element
	//
	{
		$this->append( $data );
	}

	function eol()
	// Task:  Removes a line from the table
	//
	// Input: $pos	= Position of the Element
	//
	{
		return $this->eol;
	}

}

?>
Sch...technik, früher war alles aus Holz!
mreif
Beiträge: 192
Registriert: Mi 12. Okt 2005, 16:32
Wohnort: Weiterstadt
Kontaktdaten:

Beitrag von mreif »

Danke für das Posting des kompletten Codes.
Habe diesen auch bei mir umgesetzt und der Kalender läuft wie gewünscht.

Die Sortierung habe ich noch auf ASC geändert und alle sind glücklich.

Gruß
Michael
felicitas
Beiträge: 2
Registriert: Di 7. Feb 2006, 12:05
Wohnort: Darmstadt
Kontaktdaten:

Beitrag von felicitas »

Die Sortierung habe ich noch auf ASC geändert und alle sind glücklich.
Hehe, das habe ich dann auch noch gemacht... :wink:
Sch...technik, früher war alles aus Holz!
derSteffen
Beiträge: 847
Registriert: Mi 14. Dez 2005, 16:15
Wohnort: Königs Wusterhausen bei Berlin
Kontaktdaten:

Beitrag von derSteffen »

Habe recht herzlichen Dank, dass Du Dich um dieses Problem gekümmert hast und eine wunderbare Lösung zu Verfügung stellst! Super klasse! Hast Dir einen Orden verdient! :-)
tommo
Beiträge: 120
Registriert: So 27. Jun 2004, 21:34
Kontaktdaten:

Bitte um Hilfe

Beitrag von tommo »

Hallo zusammen,

bitte seht Euch mal mein Problem an, vielleicht habt Ihr ja das selbe und habt es schon gelöst:
http://contenido.org/forum/viewtopic.php?t=11620

Danke,
Tom
Gesperrt