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