Location: PHPKode > scripts > XML Weblication > xml-weblication/modules/news.php
<?php

function build_more_link( $article ) {
  global $mid,$id,$aid,$type,$PHP_SELF;
  
  $rc = "[@:MORE_INIT]<a href=". $PHP_SELF . "?mid=" . $mid . 
        "&id=" . $id . "&aid=" . $article->getAttr("aid") . "&type=article" .
		">" . "[@:MORE]" .
		"</a>" .
        "[@:MORE_CLOSE]";
  return( $rc );
}


function module_news() {

  global $aid, $cfg, $app;
  
	if ( "" != $aid  ) {
	  $xfn = $cfg["news"] ."/". $aid . ".xml";
	}
	else {
    $xfn = $cfg["news"] . "/news.xml";
  }
	
	$xml = new xml( $xfn );
	if ( ! $xml->load() ) { return( Error( "Couldn't load XML-File $xfn")); }
  
  $htmltemplate = $xml->element->findElement("htmltemplate");
  
  $articles = array();
  $xml->element->findElements($articles, "article");
  
  while( list( $i, $article ) = each( $articles ) ) {
  
	  $title = $article->findElement("title");
	  $author= $article->findElement("author");
	  if ( $author ) {
  	    $author_email=$author->getAttr("email");
	  }
	  $date  = $article->findElement("date");
	  
	  if ( ! $title ) $title = ""; else $title = $title->data;
	  if ( ! $author) {
	    $author= ""; $author_email = "";
	  }
	  else {
	    $author=$author->data;
	  }
	  if ( ! $date ) $date = ""; else $date = $date->data;
	  
	  $text = $article->data;
	  $intro= $article->findElement("intro");
	  if ( $intro ) $intro = $intro->data; else $intro = "";
	  
	  if ( $text == "" ) {
	     $rct .= str_replace( "TITLE", $title, 
	        str_replace( "AUTHOR",$author,
			    str_replace( "DATE", $date,
			    str_replace( "ARTICLE", $intro, $htmltemplate->data))));
	  }
	  else {
	     $more = build_more_link( $article );
	     $rct .= str_replace( "TITLE", $title, 
	             str_replace( "AUTHOR",$author,
			         str_replace( "DATE", $date,
			  str_replace( "ARTICLE", $intro . $text . $more, $htmltemplate->data))));
	  }
	  
  }
  return( str_replace( "{", "<",  str_replace( "}",">",$rct)));
}



?>
Return current item: XML Weblication