Ejemplo n.º 1
0
 /**
  * Find tag by ID. Optionally also ID with a given output="" attribute
  * @return [type]          PerchXMLTag
  */
 public function find_tag($tag, $output = false, $raw = false)
 {
     $template = $this->template;
     $path = $this->file;
     $contents = $this->load();
     $s = '/<perch:[^>]*id="' . $tag . '"[^>]*>/';
     if ($output) {
         $count = preg_match_all($s, $contents, $matches, PREG_SET_ORDER);
         if ($count) {
             foreach ($matches as $match) {
                 $Tag = new PerchXMLTag($match[0]);
                 if ($Tag->output() && $Tag->output() == $output) {
                     return $Tag;
                 }
             }
         }
     } else {
         $count = preg_match($s, $contents, $match);
         if ($count == 1) {
             if ($raw) {
                 return $match[0];
             }
             return new PerchXMLTag($match[0]);
         }
     }
     return false;
 }