Exemple #1
0
 public function init($settings)
 {
     // echo '<pre>'.__METHOD__.' $settings: '.print_r($settings, true)."</pre>\n";
     if (StringTools::countSubstrs($settings['host'], '.') == 1) {
         $host_path = $this->content_path . '/www.' . $settings['host'];
     } else {
         $host_path = $this->content_path . '/' . $settings['host'];
     }
     if ($settings['path'] == '/') {
         $yaml_path = $host_path . '/root.yml';
     } else {
         $yaml_path = $host_path . (substr($settings['path'], -1) == '/' ? substr($settings['path'], 0, -1) . '.yml' : $settings['path'] . '.yml');
     }
     if (!is_readable($yaml_path)) {
         if (!file_exists($yaml_path)) {
             $yaml_path = $this->stf->getConfig('app.error.404') . '.yml';
         }
     }
     // echo '<pre>'.__METHOD__.' $yaml_path: '.print_r($yaml_path, true)."</pre>\n";
     $this->data = $this->stf->yamlDecode($yaml_path);
     // echo '<pre>'.__METHOD__.' Line: '.__LINE__.' -- $this->data: '.print_r($this->data, true)."</pre>\n";
     if ($this->view !== null) {
         $this->view->update($this->data);
     }
 }
Exemple #2
0
 public function init($settings)
 {
     echo '<pre>' . __CLASS__ . ' $settings: ' . print_r($settings, true) . "</pre>\n";
     if (StringTools::countSubstrs($settings['host'], '.') == 1) {
         $yaml_path = $this->content_path . '/www.' . $settings['host'];
     } else {
         $yaml_path = $this->content_path . '/' . $settings['host'];
     }
     $yaml_path .= substr($settings['path'], -1) == '/' ? substr($settings['path'], 0, -1) . '.yml' : $settings['path'] . '.yml';
     echo '<pre>' . __CLASS__ . ' $yaml_path: ' . print_r($yaml_path, true) . "</pre>\n";
 }
Exemple #3
0
 /**
  * @see http://www.php.net/manual/en/function.strpos.php#40617
  */
 public static function countSubstrs($haystack, $needle)
 {
     return ($p = strpos($haystack, $needle)) === false ? 0 : 1 + StringTools::countSubstrs(substr($haystack, $p + 1), $needle);
 }