Location: PHPKode > projects > Site-Assistant > sas/sas/plugs/newslist.php
<?php
class newslist extends plug {
	// Bezeichnung des Plugs
	var $label = "Newsliste";
	var $form_notice = "Es sollte nur eine Newsliste angelegt werden!";
	var $min_width = WIDE_LIST;

	var $form = array (
		"main" => array (
			"property" => array("name", "heading")
		)
	);

  // Parameter die in Datenbank gespeichert werden
	var $property =	array (
 		"id" => array("type" => "INT NOT NULL AUTO_INCREMENT PRIMARY KEY", "save_as" => "none", "label" => ""),
 		"heading" => array("type" => "VARCHAR(200)", "save_as" => "string", "label" => "Überschrift", "editable" => TRUE)
	);

function output($content_id, $content_list) {
	extract($this->get_content_editable($content_id));

	global $database,$core,$tbl_content,$page_id;
	global $HTTP_SESSION_VARS;

	$head = "<h1>_NEWS</h1>\n";
	$wrap[0] = "	<div class=\"newslist\">\n";
	$wrap[1] = "	</div>\n\n";
	if ($show == "all") $result = $core->query("SELECT * FROM ".$database['prefix']."_article where type=0 and headline <> '' order by id desc");
	else{
		$max = $core->get_pref("site_newslist_max");
		$result = $core->query("SELECT * FROM ".$database['prefix']."_article where type=0 and headline <> '' order by id desc limit $max");
	}
	while ($row = mysql_fetch_array($result)) {
		$sql ="select * from ".$database['prefix']."_contents where instance_id=".$row["id"];
		$r = $core->query($sql);
		$d = mysql_fetch_array($r);
		$value .= "<h2>".$row["headline"]."</h2><p>".$this->cut_string($row["content"])."...</p><p>_DATE ".date($d["created"])."<br /><a href='index.php?page_id=".$d["page_id"]."'>_ARTICLE $row[headline]</a></p>\n";
	}

	$anzahl = $core->sv_query("SELECT count(*) FROM ".$database['prefix']."_article");

	if ($anzahl > $max) {
		if($show == "all") $str .= "<p><a href='index.php?page_id=".$page_id."'>_SHOWNORMALNEWS</a></p<\n";
		 else $value .="<p><a href=\"".$_SERVER['PHP_SELF']."?page_id=".$page_id."&amp;shout=all\">_SHOWALLNEWS</a></p>\n";
	}
	return $core->get_i18n($wrap[0].$head.$value.$wrap[1]);

}

function cut_string($wert,$len = 60){
	$string = strip_tags($wert);
                if (strlen($string) > $len) $string = substr($string,0,$len)." ... ";
		return $string;
	}

function output_javascript() {
	return;
}

}
?>
Return current item: Site-Assistant