Пример #1
0
 /**
  * Remove HTML elements from the HTML HEAD section. This method will
  * remove all elements matching the given name and all the attributes.
  *
  * For example, to remove all META elements:
  * PageLayout::removeHeadElement('meta');
  *
  * Remove all style sheet LINK elements:
  * PageLayout::removeHeadElement('link', array('rel' => 'stylesheet'));
  *
  * Remove a particular style sheet LINK by href:
  * PageLayout::removeHeadElement('link', array('href' => '...'));
  */
 public static function removeHeadElement($name, $attributes = array())
 {
     $result = array();
     foreach (self::$head_elements as $element) {
         $remove = false;
         // match element name
         if ($name === $element['name']) {
             $remove = true;
             // match element attributes
             foreach ($attributes as $key => $value) {
                 if (!isset($element['attributes'][$key]) || $element['attributes'][$key] !== $value) {
                     $remove = false;
                     break;
                 }
             }
         }
         if (!$remove) {
             $result[] = $element;
         }
     }
     self::$head_elements = $result;
 }