<mySearch ⁄>
<mySnippets order="rand" ⁄>
<myContacts ⁄><email ⁄>
<windows live messenger ⁄>
<myCurriculum type="pdf" ⁄>
<myBlog show="last" ⁄>
<myNews show="rand" ⁄>
<myNews type="cat" ⁄>
<myQuote order="random" ⁄>Conhecer os outros é sabedoria. Conhecer a si mesmo é iluminação. Quem se sobrepõe os outros é forte. Quem se sobrepõe a si mesmo é poderoso. Quem sabe que possui o suficiente, é rico
<myPhoto order="random" ⁄>
<myAdSense ⁄>
<myVisitorsMap ⁄>
img{ border: 0pt; } #vista_toolbar {float:left;font:normal 12px 'Trebuchet MS','Arial';margin:0; padding:0;border: solid 1px Orange;} #vista_toolbar ul {background-image:url(../images/back.gif);background-repeat:repeat-x; float:left;line-height:32px;list-style:none;margin:0;padding:0 10px 0 10px;width:auto; } #vista_toolbar li {display:inline;padding:0;} #vista_toolbar a {color:#FFF;float:left;padding:0 3px 0 3px;text-decoration:none;} #vista_toolbar a span {display:block;float:none;padding:0 10px 0 7px;} #vista_toolbar a span img {border:none;margin:8px 4px 0 0;} /* show picture when mouse over link */ #vista_toolbar a:hover{background: url(../images/left.png) no-repeat left center;} #vista_toolbar a:hover span {background:url(../images/right.png) no-repeat right center;} #vista_toolbar a.right {float:right;} .bold{font-weight: bold !important;} .orange{color: Orange !important;} body{font-family: Tahoma, Verdana, Arial;font-size: 8pt;color: #000000;}
<?xml version="1.0" encoding="utf-8" ?> <pedrocorreia.net> <toolbar id="vista_toolbar"> <item title="goto myHome" description="myHome" link="index.php" cssClass="bold orange"> <img src="images/my_home.png" w="16" h="16" attributes=" align='left' " /> </item> <item title="goto mySnippets" description="mySnippets" link="mysnippets.php"> <img src="images/my_snippets.png" w="16" h="16" attributes=" align='left' " /> </item> <item title="goto myBlog" description="myBlog" link="http://edoshogun.blogspot.com" attributes=" target='_blank' " > <img src="images/my_blog.png" attributes=" align='left' " /> </item> </toolbar> </pedrocorreia.net>
<?php //permite que seja feito automaticamente o load das classes if(function_exists("__autoload")) return;{ function __autoload($class){ include_once("class.$class.php"); } } ?>
<?php /** * Abstract Class HtmlObject * * Class responsável pela geração de operações comuns * aos objectos html * * Esta class não pode ser instanciada, só extendida. * * @author: Pedro Correia - pedrocorreia.net */ abstract class HtmlObject{ private $_id; private $_cssClass; private $_title; private $_attributes; /** * Método construtor * * @param String $id * @param String $title * @param String $cssClass * @param String $attributes */ public function __construct($id,$title="",$cssClass="",$attributes="") { $this->SetID($id); $this->SetTitle($title); $this->SetCssClass($cssClass); $this->SetAttributes($attributes); } protected function _GenerateTitle(){ $title=$this->GetTitle(); if(!$title) return; return " alt='$title' title='$title' "; } protected final function _GenerateCssClass(){ $cssClass=$this->GetCssClass(); if(!$cssClass) return; return " class='$cssClass' "; } protected function _GenerateID(){ $id=$this->GetID(); if(!$id) return; return " name='$id' id='$id' "; } protected final function _GenerateAttibutes(){ $attributes=$this->GetAttributes(); if(!$attributes) return; return " $attributes "; } public final function SetID($value){$this->_id=$value;} public final function GetID(){return $this->_id;} public final function SetTitle($value){$this->_title=$value;} public final function GetTitle(){return $this->_title;} public final function SetCssClass($value){$this->_cssClass=$value;} public final function GetCssClass(){return $this->_cssClass;} public final function SetAttributes($value){$this->_attributes=$value;} public final function GetAttributes(){return $this->_attributes;} } ?>
<?php include("AutoLoad.inc"); /** * Class HtmlDiv * * Class responsável pela construção * do objecto html - DIV * * @author: Pedro Correia - pedrocorreia.net */ class HtmlDiv extends HtmlObject { private $_content; /** * Método construtor * * @param String $id * @param String $content * @param String $cssClass * @param String $attributes */ function __construct($id,$content,$cssClass="",$attributes="") { parent::__construct($id,"",$cssClass,$attributes); $this->SetContent($content); } public function SetContent($value){$this->_content=$value;} public function GetContent(){return $this->_content;} /** * Overload método * * @return String */ protected function _GenerateID(){return " id='{$this->GetID()}' ";} public function ParseObject(){ $content=$this->GetContent(); $cssClass=$this->_GenerateCssClass(); $id=$this->_GenerateID(); $attributes=$this->GetAttributes(); return "<div $id $cssClass $attributes>$content</div>"; } } ?>
<?php include("AutoLoad.inc"); /** * Class HtmlHref * * Class responsável pela construção * do objecto html - HREF * * @author: Pedro Correia - pedrocorreia.net */ class HtmlHref extends HtmlObject{ private $_link; private $_description; /** * Método construtor * * @param String $id * @param String $link * @param String $description * @param String $title * @param String $cssClass * @param String $attributes */ function __construct($id,$link,$description,$title="",$cssClass="",$attributes="") { parent::__construct($id,$title,$cssClass,$attributes); $this->SetLink($link); $this->SetDescription($description); } public function SetDescription($value){$this->_description=$value;} public function GetDescription(){return $this->_description;} public function SetLink($value){$this->_link=$value;} public function GetLink(){return $this->_link;} public function ParseObject(){ $description=$this->GetDescription(); $attributes=$this->GetAttributes(); $title=$this->_GenerateTitle(); $cssClass=$this->_GenerateCssClass(); $id=$this->_GenerateID(); $link=$this->GetLink(); return "<a href='$link' $title $id $attributes $cssClass>$description</a>"; } } ?>
<?php include("AutoLoad.inc"); /** * Class HtmlImage * * Class responsável pela construção * do objecto html - IMG * * @author: Pedro Correia - pedrocorreia.net */ class HtmlImage extends HTMLObject { private $_w=0; private $_h=0; private $_src=""; /** * Método Construtor * * @param String $id * @param String $src * @param String $w * @param String $h * @param String $title * @param String $cssClass * @param String $attributes */ function __construct($id,$src,$w="",$h="",$title="",$cssClass="",$attributes="") { parent::__construct($id,$title,$cssClass,$attributes); $this->SetDimensions($w,$h); if(file_exists($src)){$this->SetSrc($src);} } private function _GenerateDimensions(){ if($this->_w) $str=" width='$this->_w' "; if($this->_h) $str.=" height='$this->_h' "; return $str; } public function SetDimensions($w,$h){ //se forem especificadas medidas ... if(is_numeric($w) && is_numeric($h)){ $this->_w=$w; $this->_h=$h; } else{ //caso contrário, verificar o ficheiro list($width, $height) = getimagesize($this->GetSrc()); $this->_w=$width; $this->_h=$height; } } public function SetSrc($value){ if(!file_exists($value)) return ; $this->_src=$value; } public function GetSrc(){return $this->_src;} function ParseObject(){ if(!$this->GetSrc()) return; $this->SetDimensions($w,$h); $title=$this->_GenerateTitle(); $imgDimensions=$this->_GenerateDimensions(); $cssClass=$this->_GenerateCssClass(); $id=$this->_GenerateID(); $src=" src='{$this->GetSrc()}' "; $attributes=$this->GetAttributes(); return "<img $src $id $title $imgDimensions $cssClass $attributes />"; } } ?>
<?php include("AutoLoad.inc"); /** * Class HtmlText * * Class responsável pela construção * de objectos html - SPAN, BR * * @author: Pedro Correia - pedrocorreia.net */ class HtmlText extends HtmlObject{ private $_text; /** * Método construtor * * @param String $id * @param String $text * @param String $title * @param String $cssClass */ function __construct($id,$text,$title="",$cssClass="") { parent::__construct($id,$title,$cssClass); $this->SetText($text); } public function SetText($value){$this->_text=$value;} public function GetText(){return $this->_text;} public function BuildLineBreak($count=1){ for($i=0;$i<$count;$i++){ $str.="<br />"; } return $str; } public function ParseObject(){ $title=$this->_GenerateTitle(); $cssClass=$this->_GenerateCssClass(); $id=$this->_GenerateID(); $text=$this->GetText(); return "<span $title $id $cssClass>$text</span>"; } } ?>
<?php /** * Class HtmlUnorderedList * * Class responsável pela construção * dos objectos html - UL, LI * * @author: Pedro Correia - pedrocorreia.net */ class HtmlUnorderedList{ private $_list; /** * Método construtor * */ function __construct() {$this->_list=array();} public function ListClear(){$this->SetList(null);} public function ListAddItem($item) {$this->_list[]=$item;} public function SetList($arr){$this->_list=$arr;} public function GetList(){return $this->_list;} public function ParseObject(){ $lists=$this->GetList(); foreach($lists as $list){ $str.="<li>$list</li>\n"; } return "<ul>$str</ul>\n"; } } ?>
<?php /** * Class Html * * Class responsável pela construção do Html * * @author: Pedro Correia - pedrocorreia.net */ class Html { private $_charset; private $_arrCssFiles; private $_page_content; private $_page_title; /** * Método Construtor * * @param String $title * @param String $content * @param String $cssFiles * @param String $charset */ function __construct($title,$content,$cssFiles,$charset) { $this->_arrCssFiles=array(); $this->_page_content=array(); $this->SetTitle($title); $this->SetContent($content); $this->SetCssFiles($cssFiles); $this->SetCharset($charset); } private function _GenerateCssFiles(){ $cssFiles=$this->GetCssFiles(); foreach($cssFiles as $file){ $str.="<link rel='stylesheet' type='text/css' media='all' href='$file' />"; } return $str; } public function SetCssFiles($cssFiles){ $this->_arrCssFiles=null; if(is_array($cssFiles)){$this->_arrCssFiles=$cssFiles;} else{$this->_arrCssFiles[]=$cssFiles;} } public function AddCssFile($cssFile){$this->_arrCssFiles[]=$cssFile;} public function GetCssFiles(){return $this->_arrCssFiles;} public function SetTitle($value){$this->_page_title=$value;} public function GetTitle(){return $this->_page_title;} public function SetContent($value){ $this->_page_content=null; if(is_array($value)){$this->_page_content=$value;} else{$this->_page_content[]=$value;} } public function AddContent($value){$this->_page_content[]=$value;} public function GetContent(){return $this->_page_content;} public function SetCharset($value){$this->_charset=$value;} public function GetCharset(){return $this->_charset;} function Parse(){ $css=$this->_GenerateCssFiles(); $content=$this->GetContent(); foreach($content as $value){ $text.=$value; } $title="<title>{$this->GetTitle()}</title>"; $charset="<meta http-equiv=\"Content-Type\" content=\"text/html; charset={$this->GetCharset()}\" />"; return " <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"DTD/xhtml1-transitional.dtd\"> <html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"pt\"> <head> $css $title $charset </head> <body> $text </body> </html> "; } } ?>
<?php /** * Class Output * * Class responsável pela envio da * informação para o browser * * @author: Pedro Correia - pedrocorreia.net */ class Output { private $_output; /** * Método construtor * */ function __construct() {$this->_output=array();} function AddElement($element){$this->_output[]=$element;} function SetElements($elements){ $this->_output=null; if(is_array($elements)){ $this->_output=$elements;} else{ $this->_output[]=$elements;} } function Parse(){ foreach($this->_output as $value){ echo $value; } } } ?>
<?php include("AutoLoad.inc"); /** * Class Xml * * Class responsável pelo loading do ficheiro XML * * @author: Pedro Correia - pedrocorreia.net */ class Xml { private $_file; /** * Método Construtor * * @param String $file */ function Xml($file){$this->SetFile($file);} /** * Converter para um array o conteúdo do ficheiro XML * * @return Array */ public function XmlToArray(){return simplexml_load_file($this->GetFile());} public function GetFile(){return $this->_file;} public function SetFile($value){ if(!file_exists($value)){throw new Exception("XMLFileNotFound");} $this->_file=$value; } } ?>
<?php include("AutoLoad.inc"); /** * Class VistaToolbar * * Class responsável pela construção da VistaToolbar * * @author: Pedro Correia - pedrocorreia.net */ class VistaToolbar { private $_xml_file; /** * Método construtor * * @param String $xml_file */ function __construct($xml_file) {$this->SetXmlFile($xml_file);} function SetXmlFile($xml_file){$this->_xml_file=$xml_file;} function GetXmlFile(){return $this->_xml_file;} function ParseObject(){ $xml=new Xml($this->GetXmlFile()); $xml_itens=$xml->XmlToArray(); $ul=new HtmlUnorderedList(); foreach($xml_itens->toolbar as $itens) { $count=sizeof($itens); for ($i=0;$i<$count;$i++){ $item=$itens->item[$i]; $title=$item["title"]; $link=$item["link"]; $description=$item["description"]; $attributes=$item["attributes"]; $cssClass=$item["cssClass"]; $img=$item->img; $img_src=$img["src"]; if($img_src){ $img_w=$img["w"]; $img_h=$img["h"]; $img_attributes=$img["attributes"]; $img_cssClass=$img["cssClass"]; $imagem=new HtmlImage("img_$i",$img_src,$img_w,$img_h,$title,$img_cssClass,$img_attributes); $description=$imagem->ParseObject(). " ".$description; } $span=new HtmlText("span_$i",$description,$title); $href=new HtmlHref("href_$i",$link,$span->ParseObject(),$title,$cssClass,$attributes); $ul->ListAddItem($href->ParseObject()); } } $div=new HtmlDiv($xml_itens->toolbar["id"],$ul->ParseObject()); return $div->ParseObject(); } } ?>
<?php include("Classes/AutoLoad.inc"); $toolbar = new VistaToolbar("xml/vista_toolbar.xml"); $html=new Html("My Vista Toolbar",$toolbar->ParseObject(),"css/vista_toolbar.css","iso-8859-1"); $span=new HtmlText("my_span","Isto é a minha toolbar vista-style","My Vista Toolbar","orange bold"); $html->AddContent($span->BuildLineBreak(4)); $html->AddContent($span->ParseObject()); $output = new Output(); $output->AddElement($html->Parse()); $output->Parse(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pt"> <head> <link rel="stylesheet" type="text/css" media="all" href="css/vista_toolbar.css" /> <title>My Vista Toolbar</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <div id="vista_toolbar"> <ul> <li> <a href="index.php" alt="goto myHome" title="goto myHome" name="href_0" id="href_0" class="bold orange" > <span alt="goto myHome" title="goto myHome" name="span_0" id="span_0"> <img src="images/my_home.png" name="img_0" id="img_0" alt="goto myHome" title="goto myHome" width="16" height="16" align="left" /> myHome </span> </a> </li> <li> <a href="mysnippets.php" alt="goto mySnippets" title="goto mySnippets" name="href_1" id="href_1" > <span alt="goto mySnippets" title="goto mySnippets" name="span_1" id="span_1" > <img src="images/my_snippets.png" name="img_1" id="img_1" alt="goto mySnippets" title="goto mySnippets" width="16" height="16" align="left" /> mySnippets </span> </a> </li> <li> <a href="http://edoshogun.blogspot.com" alt="goto myBlog" title="goto myBlog" name="href_2" id="href_2" target="_blank"> <span alt="goto myBlog" title="goto myBlog" name="span_2" id="span_2"> <img src="images/my_blog.png" name="img_2" id="img_2" alt="goto myBlog" title="goto myBlog" width="16" height="16" align="left" /> myBlog </span> </a> </li> </ul> </div> <br /><br /><br /><br /> <span alt="My Vista Toolbar" title="My Vista Toolbar" name="my_span" id="my_span" class="orange bold" > Isto é a minha toolbar vista-style </span> </body> </html>
