Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Element {
- protected $_id;
- protected $_classes = array();
- protected $_style = array();
- protected $_elements = array();
- protected $_idx = 0;
- public function addClass($class) {
- $this->_classes[] = $class;
- }
- public function setId($id) {
- $this->_id = $id;
- }
- protected function hasClassAttr() {
- $ret = false;
- if ($this->getClassAttr() != "") $ret = true;
- return $ret;
- }
- protected function getClassAttr() {
- $class_attr = "";
- if (count($this->_classes)) {
- $class_attr = 'class="';
- foreach ($this->_classes as $class) {
- $class_attr .= "$class ";
- }
- $class_attr = rtrim($class_attr);
- $class_attr .= '"';
- }
- /*if ($class_attr == "") return false;
- else return $class_attr;*/
- return $class_attr;
- }
- protected function hasIdAttr() {
- $ret = false;
- if ($this->getIdAttr() != "") $ret = true;
- return $ret;
- }
- protected function getIdAttr() {
- $id_attr = "";
- if ($this->_id != "") {
- $id_attr = sprintf('id="%s"', $this->_id);
- }
- /* if ($id_attr == "") return false;
- else return $id_attr; */
- return $id_attr;
- }
- protected function hasStyleAttr() {
- $ret = false;
- if ($this->getStyleAttr() != "") $ret = true;
- return $ret;
- }
- protected function getStyleAttr() {
- $style_attr = "";
- if (count($this->_style)) {
- $style_attr = 'style="';
- foreach ($this->_style as $key => $value) {
- $style_attr .= "$key: $value; ";
- }
- $style_attr = rtrim($style_attr);
- $style_attr .= '"';
- }
- /*if ($class_attr == "") return false;
- else return $class_attr;*/
- return $style_attr;
- }
- public function addStyle($attr, $value) {
- $this->_style[$attr] = $value;
- }
- public function html() {
- return "";
- }
- public function show() {
- echo $this->html();
- }
- public function add($element) {
- $this->_elements[$this->_idx] = $element;
- $this->_idx++;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement