Location: PHPKode > projects > Site-Assistant > sas/sas/plugs/simple_link.php
<?php
class simple_link extends plug {
	// Bezeichnung des Plugs
	var $cache_output = FALSE;
	var $label = "Einfacher Verweis";
	var $form_notice = "Angaben im Feld Adresse bitte mit Angabe des Protokolls,
		also <strong>'http://www.firma.de/'</strong>
		oder <strong>'mailto:hide@address.com'.</strong><br />Verweise auf Seiten dieser Website durch einfache Angabe des Seitennamens.";

	var $form = array (
		"main" => array (
			"property" => array("url", "headline", "description", "new_window")
		)
	);

  // Parameter die in Datenbank gespeichert werden
	var $property =	array (
   	"id" => array("type" => "INT NOT NULL AUTO_INCREMENT PRIMARY KEY", "save_as" => "none", "label" => ""),
 		"url" => array("type" => "VARCHAR(255)", "save_as" => "string", "label" => "Adresse"),
 		"headline" => array("type" => "VARCHAR(64)", "save_as" => "string", "label" => "Überschrift", "editable" => TRUE),
 		"description" => array("type" => "TEXT", "save_as" => "string", "label" => "Beschreibung", "editable" => TRUE),
 		"new_window" => array("type" => "TINYINT", "save_as" => "number", "label" => "Adresse in neuem Fenster öffnen?", "options" => "Im selben Fenster|In neuem Fenster öffnen")
	);

function output($content_id, $content_list) {
	global $paths;

	extract($this->get_content_editable($content_id));
	$description = nl2br($description);

	// Größe der Ausgabe anpassen
	if ($content_list->width < DISCRIMINATE_WIDTH) {
		$seperator = "<br />";
		$img = "<img alt=\"Link - $headline\" src=\"template/simple_link_s.gif\" />";
	}
	else {
		$img = "<img alt=\"Link - $headline\" src=\"img_si/simple_link.gif\" />";
		$seperator = "&nbsp; - &nbsp;";
	}

  // Soll Link in neuem Fenster geöffnet werden?
	if ($new_window)
		$link = "<a class=\"slHeadline\" href=\"javascript:openURL('$url')\">";
	else
		$link = "<a class=\"slHeadline\" href=\"$url\">";

	$str = "$link$headline</a>$seperator$description";

	return $str;
}

function form_prepare($instance_id, &$values, $form_id) {
	global $tbl_pages,$core;

	// Bei internem Verweis label auslesen
	if (substr($values['url'], 0, 10) == "index.php?") {
		parse_str(substr($values['url'], 10));
		$values[url] = $core->sv_query("SELECT label FROM $tbl_pages WHERE id=$page_id");
	}
}

function form_test(&$POST_VARS, &$error_text) {
	global $tbl_pages,$core;

	// Verweist URL auf interne Seite ?
	$url = strtolower(trim($POST_VARS['url']));
	$cnt_labels = $core->sv_query("SELECT COUNT(*) FROM $tbl_pages WHERE LOWER(label) = '$url'");
	if ($cnt_labels == 1) {
		$dest_page = $core->sv_query("SELECT id FROM $tbl_pages WHERE LOWER(label) = '$url'");
		$POST_VARS['url'] = "index.php?page_id=$dest_page";
	}
	elseif ($cnt_labels > 1) {
		$error_text = "Das Feld url verweist auf mehr als eine Seite!";
		return FALSE;
	}
	return TRUE;
}

function output_javascript() {
	return;
}
}
?>
Return current item: Site-Assistant