Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
zakarialounes committed Feb 7, 2015
0 parents commit aa2f617
Show file tree
Hide file tree
Showing 24 changed files with 9,751 additions and 0 deletions.
1 change: 1 addition & 0 deletions DBConnection.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php require_once("libmydb.php");
101 changes: 101 additions & 0 deletions HtmlElement.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?php

class HtmlElement
{
private $_attributes,
$_content;
public $_tohtml,
$_toBody = 0,
$_tag;

public function setTag($tag)
{
if (isset($tag))
$this->_tag = $tag;
}

public function getTag()
{
return ($this->_tag);
}

public function addAttribute($key, $value)
{
if (isset($key) && isset($value))
{
$this->_attributes[$key] = $value;
}
}

public function addContent($string)
{
$this->_content = $string;
}

public function prepareTag()
{
if ($this->_tag)
$tag = $this->_tag;
else
$tag = "";

return ($tag);
}

public function prepareAttributes()
{
if ($this->_attributes)
{
$count_attributes = count($this->_attributes);
$i = 0;
$attributes = "";

foreach ($this->_attributes as $key => $value)
{
if ($i == $count_attributes - 1)
$attributes .= ' '.$key.'="'.$value.'"';
else
$attributes .= ' '.$key.'="'.$value.'"';
$i++;
}
}
else
$attributes = "";

return ($attributes);
}

public function prepareContent()
{
if ($this->_content)
$content = $this->_content;
else
$content = "";

return ($content);
}

public function toHtml()
{
$tag = $this->prepareTag();
$attributes = $this->prepareAttributes();
$content = $this->prepareContent();

if ($tag != "")
{
$this->_tohtml = "<".$tag.$attributes.">".$content."</".$tag.">";

if ($tag == "meta" || $tag == "link")
$this->_tohtml = "<".$tag.$attributes." />";
}
else
$this->_tohtml = $content;

return ("\t\t".$this->_tohtml."\n");
}

public function toBody()
{
$this->_toBody = 1;
}
}
21 changes: 21 additions & 0 deletions HtmlLink.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

class HtmlLink extends HtmlElement
{
public function toHtml()
{
parent::toHtml();

$attributes = $this->prepareAttributes();
$content = $this->prepareContent();

$this->_tohtml = "<a".$attributes.">".$content."</a>";

return ($this->_tohtml);
}

public function getLinkUrl()
{
return ($this->toHtml());
}
}
35 changes: 35 additions & 0 deletions HtmlList.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

class HtmlList extends HtmlElement
{
private $_content;

public function toHtml()
{
parent::prepareAttributes();
$attributes = $this->prepareAttributes();
$content = $this->prepareContent();

$this->_tohtml = "\n\t\t<ul".$attributes.">".$content."\t\t</ul>";

return ($this->_tohtml);
}

public function addItem(HtmlListItem $item)
{
$this->_content[] = "\n\t".$item->toHtml();
}

public function prepareContent()
{
$content = "";

if ($this->_content)
{
foreach ($this->_content as $value)
$content .= $value;
}

return ($content);
}
}
23 changes: 23 additions & 0 deletions HtmlListItem.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

class HtmlListItem extends HtmlElement
{
public $_tohtml;

public function SetContent($string)
{
$this->addContent($string);

return ($this->toHtml());
}

public function prepareTag()
{
if ($this->_tag)
$tag = $this->_tag;
else
$tag = "li";

return ($tag);
}
}
16 changes: 16 additions & 0 deletions HtmlParagraph.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

class HtmlParagraph extends HtmlElement
{
public function toHtml()
{
parent::toHtml();

$attributes = $this->prepareAttributes();
$content = $this->prepareContent();

$this->_tohtml = "<p".$attributes.">".$content."</p>";

return ($this->_tohtml);
}
}
52 changes: 52 additions & 0 deletions HtmlTable.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

class HtmlTable extends HtmlElement
{
private $_content,
$_caption;
public $_tag;

public function toHtml()
{
parent::prepareAttributes();
$attributes = $this->prepareAttributes();
$content = $this->prepareContent();

$this->_tohtml = "\n\t\t<table".$attributes.">\n\t\t\t".$this->_caption.$content."\t\t</table>\n";

return ($this->_tohtml);
}

public function addItem(HtmlTableRow $row)
{
$this->_content[] = $row->toHtml();
}

public function prepareContent()
{
$content = "";

if ($this->_content)
{
foreach ($this->_content as $value)
$content .= $value;
}
$this->_content = $content;

return ($this->_content);
}

public function setCaption($caption)
{
if (isset($caption))
$this->_caption = '<caption>'.$caption."</caption>\n";
}

public function getTableNumRows()
{
if ($this->_content)
{
return (count($this->_content));
}
}
}
23 changes: 23 additions & 0 deletions HtmlTableCell.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

class HtmlTableCell extends HtmlElement
{
public $_tohtml;

public function SetContent($string)
{
$this->addContent($string);

return ($this->toHtml());
}

public function prepareTag()
{
if ($this->_tag)
$tag = $this->_tag;
else
$tag = "td";

return ($tag);
}
}
35 changes: 35 additions & 0 deletions HtmlTableRow.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

class HtmlTableRow extends HtmlElement
{
private $_content;

public function toHtml()
{
parent::prepareAttributes();
$attributes = $this->prepareAttributes();
$content = $this->prepareContent();

$this->_tohtml = "\t\t\t<tr".$attributes.">\n".$content."\t\t\t</tr>\n";

return ($this->_tohtml);
}

public function addItem(HtmlTableCell $cell)
{
$this->_content[] = "\t\t".$cell->toHtml();
}

public function prepareContent()
{
$content = "";

if ($this->_content)
{
foreach ($this->_content as $value)
$content .= $value;
}

return ($content);
}
}
Loading

0 comments on commit aa2f617

Please sign in to comment.