Beispiel #1
0
 public static function inst(FoldedEntity $entity, DirItem $tplDi)
 {
     if (!array_key_exists($tplDi->getRelPath(), self::$INSTS)) {
         self::$INSTS[$tplDi->getRelPath()] = new FoldedInfoTpl($entity, $tplDi);
     }
     return self::$INSTS[$tplDi->getRelPath()];
 }
Beispiel #2
0
 /**
  * Метод разбирает файл с ребусами, который выглядит как:
  * 
  * ребус 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;
 }
Beispiel #3
0
 protected function onInit(DirItem $di)
 {
     $this->info = getimagesize($di->getAbsPath());
     check_condition($this->info, "В ImageAdapter передана невалидная картинка [{$di->getRelPath()}].");
     $this->width = $this->info[0];
     $this->height = $this->info[1];
 }
Beispiel #4
0
 public function __construct(DirItem $dir)
 {
     $this->LOGGER = Autoload::getLogger();
     $this->classesDir = $dir;
     $this->classPathFile = DirManager::autogen('classpath')->getDirItem(null, unique_from_path($dir->getRelPath()));
 }
Beispiel #5
0
 public function __toString()
 {
     return __CLASS__ . " [{$this->di->getRelPath()}]";
 }