"; if(is_array($configuration)) { $this->selector = array_shift($configuration); $folder = array_shift($configuration); $this->folder = strncmp("/",$folder,1) ? $caller_dir.$folder : $f3->get('CONTENT').substr($folder,1); if (substr_compare($this->folder,"/",-1,1)) { $this->folder .= "/"; } } $this->caller_dir = $caller_dir; $this->body = is_array($body) ? $body : array($body); if(!$this->body) { $this->body = null; } $this->prepare_elements(); } // function __toString() { // return $this->selector.":".$this->folder."\n".implode("\n",$this->body); //} function prepare_elements() { if(is_dir($this->folder)) { $ls=scandir($this->folder); if (count($this->body)) { foreach ($this->body as $f) { if (in_array($f,$ls) && is_dir($this->folder.$f)) { $this->elements[$this->folder.$f."/"] = true; } } } else { foreach($ls as $k=>$f) { if (!strncmp($f,'.',1)) continue; if (!is_dir($this->folder.$f)) continue; $this->elements[$this->folder.$f."/"] = true; } } } foreach ($this->elements as $key=>$value) { $folder = new FilesInFolders($key); $folder->prepare_files(); $this->elements[$key] = $folder->read_config(); } } function dispatch() { switch ($this->selector) { case 'event_view': $this->event_list(); break; case 'locations_view': $this->location_list(); break; } } function get_location_large() { foreach($this->elements as $key=>$e) { $this->elements[$key] = self::location_large($e,$key); } return array_shift($this->elements); } function get_location_medium() { foreach($this->elements as $key=>$e) { $this->elements[$key] = self::location_medium($e,$key); } return array_shift($this->elements); } function get_location_small() { foreach($this->elements as $key=>$e) { $this->elements[$key] = self::location_small($e,$key); } return array_shift($this->elements); } function location_list() { foreach($this->elements as $key=>$e) { $this->elements[$key] = self::location_large($e,$key); } } function location_large($e,$key) { $f3 = \Base::instance(); $town = $e['TOWN']; $name = $e['NAME']; $href = $f3->get('SITE_URL').str_replace($f3->get('CONTENT'),"",$key); return sprintf("
" ."

$name

" ."$town" ."
"); } function location_medium($e,$key) { $f3 = \Base::instance(); $town = $e['TOWN']; $name = $e['NAME']; $href = $f3->get('SITE_URL').str_replace($f3->get('CONTENT'),"",$key); return sprintf("
" ."$town
" ."$name
" ."
"); } function location_small($e,$key) { $f3 = \Base::instance(); $town = $e['TOWN']; $name = $e['NAME']; $href = $f3->get('SITE_URL').str_replace($f3->get('CONTENT'),"",$key); return sprintf("
" ."$town" ."$name" ."
"); } function event_list() { $f3 = \Base::instance(); foreach ($this->elements as $key=>$entry) { $DATE = strtotime($entry['DATE']); $date = sprintf("%s
" ."%s", date('M',$DATE), date('d',$DATE)); $href = $f3->get('SITE_URL').str_replace($f3->get('CONTENT'),"",$key); $title = $entry['TITLE']; $description = $entry['DESCRIPTION']; $time = sprintf("%s, %s", date('l',$DATE), $entry['TIME']); $loc = $entry['LOCATION']; $loc->set_layout("humble_two_liner"); $location = $loc;#is_object($loc) ? $loc->get_location_medium() : $loc; $this->elements[$key] = sprintf("%s%s%s", $date, sprintf("

%s

%s", sprintf("%s", $href, $title ), $description, $time ), $location ); } } function as_string() { return sprintf("%s
", implode("\n",$this->elements)); } }