<?php /*

Intellect CMS Project
Abstract pasrer extractor class file
(c) 2007, XXXX Pro, United Open Project
Official site: http://intboard.ru

*/

class ParserExtractor_basic extends ParserExtractor {
  function extract($filename) {
    $data = join('',file($filename));
    $result=array();
    if (preg_match_all('|##msg\[(\w+)\]#|is',$data,$matches)) $result=array_merge($result,$matches[1]);
    if (preg_match_all('|##submit\[(\w+)\]#|is',$data,$matches)) {
      for ($i=0, $count=count($matches[1]); $i<$count; $i++) {
        $expr=explode(',',$matches[1][$i]);
        if (isset($expr[2])) $result[]=$expr[2];
      }
    }
    if (preg_match_all('|##radio\[(.+?)\]#|is',$data,$matches)) {
      for ($i=0, $count=count($matches[1]); $i<$count; $i++) {
        $expr=explode(',',$matches[1][$i]);
        $name=substr($expr[0],strrpos($expr[0],'/')+1);
        for ($j=1, $count2=count($expr); $j<$count2; $j++) $result[]='MSG_'.$name.'_'.$expr[$j];
      }
    }
    if (preg_match_all('|##select\[(.+?)\]#|is',$data,$matches)) {
      for ($i=0, $count=count($matches[1]); $i<$count; $i++) {
        $expr=explode(',',$matches[1][$i]);
        $name=substr($expr[0],strrpos($expr[0],'/')+1);
        for ($j=1, $count2=count($expr); $j<$count2; $j++) $result[]='MSG_'.$name.'_'.$expr[$j];
      }
    }
    return $result;
  }
}
