コード例 #1
0
ファイル: PsMathRebus.php プロジェクト: ilivanoff/ps-sdk-dev
 /**
  * Метод разбирает файл с ребусами, который выглядит как:
  * 
  * ребус 1
  * ответ 1.1
  * ответ 1.2
  * 
  * ребус 2
  * ответ 2.1
  * ответ 2.2
  * 
  * @return type
  */
 private function parseAnswersFile(DirItem $di)
 {
     $result = array();
     $lines = explode("\n", trim($di->getFileContents(false)));
     $current = null;
     foreach ($lines as $line) {
         $line = trim($line);
         if ($line && !$current) {
             //Начинается новый ребус
             $current = $line;
             $result[$current] = array();
         } else {
             if ($line && $current) {
                 //Ответ на ребус
                 $result[$current][] = $line;
             } else {
                 if (!$line && $current) {
                     //Пробел, закончили ребус
                     $current = null;
                 }
             }
         }
     }
     if ($this->LOGGER->isEnabled()) {
         $this->LOGGER->info('Rebuses of {}:', $di->getRelPath());
         $this->LOGGER->info(print_r($result, true));
         $this->LOGGER->info();
     }
     return $result;
 }
コード例 #2
0
ファイル: SqlFileBuilder.php プロジェクト: ilivanoff/www
 public function appendFile(DirItem $file, $ensure = true)
 {
     $contents = trim($file->getFileContents($ensure));
     if ($contents) {
         $contents = remove_utf8_bom($contents);
         $this->appendMlComment("+ FILE [{$file->getName()}]");
         $this->di->writeLineToFile($contents);
     }
     unset($contents);
 }
コード例 #3
0
ファイル: CssSprite.php プロジェクト: ilivanoff/www
 public function getSpriteItems()
 {
     if (!is_array($this->items)) {
         $this->items = array();
         $contents = $this->cssDi->getFileContents();
         if ($contents) {
             $pattern = "/\\.sprite-{$this->name}-([^{|^ ]*)/si";
             $matches = array();
             preg_match_all($pattern, $contents, $matches, PREG_PATTERN_ORDER);
             $this->items = $matches[1];
         }
     }
     return $this->items;
 }
コード例 #4
0
ファイル: ToDoFile.php プロジェクト: ilivanoff/www
 public function getContents()
 {
     return $this->di->getFileContents();
 }
コード例 #5
0
ファイル: PsSequenceFile.php プロジェクト: ilivanoff/www
 public function current()
 {
     $num = $this->di->getFileContents(false);
     return is_inumeric($num) ? 1 * $num : null;
 }