PageRenderTime 28ms CodeModel.GetById 18ms app.highlight 9ms RepoModel.GetById 0ms app.codeStats 0ms

/HTML_Head_Block.php

https://bitbucket.org/evinw/lib
PHP | 144 lines | 70 code | 27 blank | 47 comment | 0 complexity | 8c6c6c010b1ec9ea1512df25888ce9c9 MD5 | raw file
  1<?php
  2/**
  3 * @author Evin Weissenberg
  4 */
  5class HTML_Head_Block {
  6
  7    private $author = 'Evin Weissenberg';
  8    private $title = 'My Cool Site';
  9    private $description = 'This is the description';
 10    private $address = 'Los Angeles, Ca';
 11    private $keywords = array();
 12    private $revisit = 7; // in days
 13    private $robot = 'INDEX,FOLLOW';
 14    private $country = 'USA';
 15
 16    /**
 17     * @param $author
 18     * @return HTML_Head_Block
 19     */
 20    function setAuthor($author) {
 21
 22        $this->author = (string)$author;
 23        return $this;
 24    }
 25
 26    /**
 27     * @param $title
 28     * @return HTML_Head_Block
 29     */
 30    function setTitle($title) {
 31
 32        $this->title = (string)$title;
 33        return $this;
 34    }
 35
 36    /**
 37     * @param $robot
 38     * @return HTML_Head_Block
 39     */
 40    function setRobot($robot) {
 41
 42        $this->robot = (string)$robot;
 43        return $this;
 44    }
 45
 46    /**
 47     * @param $description
 48     * @return HTML_Head_Block
 49     */
 50    function setDescription($description) {
 51
 52        $this->description = (string)$description;
 53        return $this;
 54    }
 55
 56    /**
 57     * @param $address
 58     * @return HTML_Head_Block
 59     */
 60    function setAddress($address) {
 61
 62        $this->address = (string)$address;
 63        return $this;
 64    }
 65
 66    /**
 67     * @param $revisit
 68     * @return HTML_Head_Block
 69     */
 70    function setRevisit($revisit) {
 71
 72        $this->revisit = (string)$revisit;
 73        return $this;
 74    }
 75
 76    /**
 77     * @param $country
 78     * @return HTML_Head_Block
 79     */
 80    function setCountry($country) {
 81
 82        $this->country = (string)$country;
 83        return $this;
 84    }
 85
 86    /**
 87     * @param $keywords
 88     * @return HTML_Head_Block
 89     */
 90    function setKeywords($keywords) {
 91
 92        $this->keywords = (array)$keywords;
 93        $this->keywords = implode(",", $this->keywords);
 94
 95        return $this;
 96    }
 97
 98    /**
 99     * @param $property
100     * @return mixed
101     */
102    function __get($property) {
103
104        return $this->$property;
105
106    }
107
108    /**
109     *
110     */
111    function insert() {
112
113        echo "
114                  <meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
115                  <title>" . $this->title . "</title>
116                  <meta content='" . $this->author . "' name='author'>
117                  <meta content='" . $this->description . "' name='Description'>
118                  <meta content='" . $this->keywords . "' name='Keywords'>
119                  <meta content='" . $this->address . "' name='Geography'>
120                  <meta content='English, Spanish, French, German, Italian, Japanese, Chinese' name='Language'>
121                  <meta content='never' http-equiv='Expires'>
122                  <meta content='" . $this->revisit . " days' name='Revisit-After'>
123                  <meta content='Global' name='distribution'>
124                  <meta content='" . $this->robot . "' name='Robots'>
125                  <meta content='" . $this->country . "' name='country'>
126                  <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script>
127                  <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js'></script>
128               ";
129    }
130
131    /**
132     *
133     */
134    function __destructor() {
135
136        foreach (get_object_vars($this) as $key => $value) {
137
138            unset($this->$key);
139
140        }
141    }
142}
143//$h = new HTML_Head_Block();
144//$h->setAuthor('EW')->setDescription('This is my cool site')->insert();