See file /var/customers/webs/vworld/app/protected/controller/MainController.php


+ Error on line 131

        $data['place'] = $data['place'][0];

<?php
/**
 * MainController
 * vWorld Frontend and Backend
 *
 * @author kb
 */
class MainController extends DooController{
    private function 
init() {
        
$data = array();
    
        
$site Doo::loadModel('Site'true);
        
$site->domain str_replace('www.'''$_SERVER['HTTP_HOST']);
        
$data['site'] = Doo::db()->find($site);
        
$data['site'] = $data['site'][0];
        
        
$data['footerPlaces'] = Doo::db()->find('Place', array('where'=>'site = '.$data['site']->sid." AND name <> '".$data['site']->name."' AND ( pid IN (SELECT pid FROM article_places GROUP BY pid ORDER BY COUNT(aid) DESC) OR pid IN (SELECT pid FROM place_gallery GROUP BY pid ORDER BY COUNT(gid) DESC) )"));
        
//if(count($data['footerPlaces']) == 0)
        
$tmp Doo::db()->find('Place', array('where'=>'site = '.$data['site']->sid." AND name <> '".$data['site']->name."' ORDER BY place.population DESC"));
        
$data['footerPlaces'] = array_unique(array_merge($data['footerPlaces'], $tmp), SORT_REGULAR);
        
        
$data['footerArticles'] = $data['site']->getArticles(3'date DESC');
        
$data['footerSites'] = $data['site']->getSites();
        
$data['footerURL'] = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
        
        
$data['title'] = $data['site']->name.' - '.$data['site']->domain;
        
        return 
$data;
    }

    public function 
index() {
        
$data self::init();
        
$data['currentpage'] = 'home';
        
//$this->view()->render('/'.Doo::conf()->lang .'/index', $data);
        
        
$data['timelines'] = Doo::db()->find('Timeline', array('where'=>"place IN (SELECT pid FROM place WHERE quote = 'N' AND parent IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.")) OR place IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.")"'desc'=>'date''limit'=>3));
        
$data['place'] = Doo::db()->find('Place', array('where'=>"parent IS NULL AND site = ".$data['site']->sid));

        if(
count($data['place']) > 0)
            
$data['place'] = $data['place'][0];
        else {
            
$this->view()->render('/404'$data);
            return;
        }
        
        
$data['places'] = Doo::db()->find('Place', array('where'=>'site = '.$data['site']->sid));
        
$data['articles'] = $data['site']->getArticlesWoTeaser();
        
        
// Teaser 1
        
if(is_numeric($data['site']->teaser1)) {
            
$data['teaser1'] = Doo::db()->find('Article', array('where'=>"aid = ".$data['site']->teaser1));
            
$data['teaser1'] = $data['teaser1'][0];
        }
        elseif(
$data['site']->teaser1 == 'timeline_N')
            
$data['teaser1'] = Doo::db()->find('Timeline', array('where'=>"quote = 'N' AND ( place IN (SELECT pid FROM place WHERE parent IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.")) OR place IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.") )"'desc'=>'date''limit'=>3));
        elseif(
$data['site']->teaser1 == 'timeline_NY'
            
$data['teaser1'] = Doo::db()->find('Timeline', array('where'=>"(quote = 'N' OR quote = 'Y') AND ( place IN (SELECT pid FROM place WHERE parent IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.")) OR place IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.") )"'desc'=>'date''limit'=>3));
        elseif(
$data['site']->teaser1 == 'timeline_Y'
            
$data['teaser1'] = Doo::db()->find('Timeline', array('where'=>"quote = 'Y' AND ( place IN (SELECT pid FROM place WHERE parent IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.")) OR place IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.") )"'desc'=>'date''limit'=>3));
        elseif(
$data['site']->teaser1 == 'timeline_P'
            
$data['teaser1'] = Doo::db()->find('Timeline', array('where'=>"quote = 'P' AND ( place IN (SELECT pid FROM place WHERE parent IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.")) OR place IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.") )"'desc'=>'date''limit'=>3));
    
        
// Teaser 2
        
if(is_numeric($data['site']->teaser2)) {
            
$data['teaser2'] = Doo::db()->find('Article', array('where'=>"aid = ".$data['site']->teaser2));
            
$data['teaser2'] = $data['teaser2'][0];
        }
        elseif(
$data['site']->teaser2 == 'timeline_N')
            
$data['teaser2'] = Doo::db()->find('Timeline', array('where'=>"quote = 'N' AND ( place IN (SELECT pid FROM place WHERE parent IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.")) OR place IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.") )"'desc'=>'date''limit'=>3));
        elseif(
$data['site']->teaser2 == 'timeline_NY'
            
$data['teaser2'] = Doo::db()->find('Timeline', array('where'=>"(quote = 'N' OR quote = 'Y') AND ( place IN (SELECT pid FROM place WHERE parent IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.")) OR place IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.") )"'desc'=>'date''limit'=>3));
        elseif(
$data['site']->teaser2 == 'timeline_Y'
            
$data['teaser2'] = Doo::db()->find('Timeline', array('where'=>"quote = 'Y' AND ( place IN (SELECT pid FROM place WHERE parent IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.")) OR place IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.") )"'desc'=>'date''limit'=>3));
        elseif(
$data['site']->teaser2 == 'timeline_P'
            
$data['teaser2'] = Doo::db()->find('Timeline', array('where'=>"quote = 'P' AND ( place IN (SELECT pid FROM place WHERE parent IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.")) OR place IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.") )"'desc'=>'date''limit'=>3));
    
        
// Teaser 3
        
if(is_numeric($data['site']->teaser3)) {
            
$data['teaser3'] = Doo::db()->find('Article', array('where'=>"aid = ".$data['site']->teaser3));
            
$data['teaser3'] = $data['teaser3'][0];
        }
        elseif(
$data['site']->teaser3 == 'timeline_N')
            
$data['teaser3'] = Doo::db()->find('Timeline', array('where'=>"quote = 'N' AND ( place IN (SELECT pid FROM place WHERE parent IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.")) OR place IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.") )"'desc'=>'date''limit'=>3));
        elseif(
$data['site']->teaser3 == 'timeline_NY'
            
$data['teaser3'] = Doo::db()->find('Timeline', array('where'=>"(quote = 'N' OR quote = 'Y') AND ( place IN (SELECT pid FROM place WHERE parent IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.")) OR place IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.") )"'desc'=>'date''limit'=>3));
        elseif(
$data['site']->teaser3 == 'timeline_Y'
            
$data['teaser3'] = Doo::db()->find('Timeline', array('where'=>"quote = 'Y' AND ( place IN (SELECT pid FROM place WHERE parent IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.")) OR place IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.") )"'desc'=>'date''limit'=>3));
        elseif(
$data['site']->teaser3 == 'timeline_P'
            
$data['teaser3'] = Doo::db()->find('Timeline', array('where'=>"quote = 'P' AND ( place IN (SELECT pid FROM place WHERE parent IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.")) OR place IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.") )"'desc'=>'date''limit'=>3));
        
        
$this->view()->render('/index'$data);
    }
    
    public function 
urlParser() {
        if(isset(
$this->params['article'])) {
            if(
$this->params['article'] == 'chronik')
                
self::timeline();
            else
                
self::article();
        }
        else
            
self::place();
    
    }
    
    public function 
article() {
        
$data self::init();
        
        
//$data['article'] = Doo::db()->find('Article', array('where'=>"aid IN (SELECT aid FROM article WHERE url LIKE '".$this->params['article']."%' ORDER BY date DESC)", 'desc'=>'date'));
        
$data['article'] = Doo::db()->find('Article', array('where'=>"aid IN (SELECT aid FROM article WHERE url LIKE '".$this->params['article']."%' ORDER BY date DESC) ORDER BY date DESC, rev DESC"));
        
$data['article'] = $data['article'][0];
        
        
        
        
//var_dump($data['article']);
        
        //$data['place'] = Doo::db()->find('Place', array('where'=>"pid IN (SELECT pid FROM article_places WHERE aid = ".$data['article']->aid.") AND site = ".$data['site']->sid, 'desc'=>'parent'));
        
$data['place'] = $data['article']->getPlace();
        
//$data['galleries'] = $data['article']->getGalleries();
        
        
$data['places'] = $data['site']->getPlaces();
        
        
$data['title'] = $data['article']->title.' - '.$data['site']->name;
        
$this->view()->render('/article'$data);
    }
    
    public function 
place() {
        
$data self::init();
        
        
$data['place'] = Doo::db()->find('Place', array('where'=>"url LIKE '".$this->params['place']."%'"));
        $data['place'] = $data['place'][0];

        
        
/*$data['place'] = Doo::db()->find('Place', array('where'=>"pid IN (SELECT pid FROM article_places WHERE aid = ".$data['article']->aid.") AND site = ".$data['site']->sid));
        $data['place'] = $data['place'][0];*/
        
        
$data['places'] = $data['site']->getPlaces();
        
        
$data['articles'] = $data['place']->getArticles();
        
$data['galleries'] = $data['place']->getGalleriesWithoutArticle();
        
        
$arr array_merge((array)$data['galleries'], (array)$data['articles']);
        
//shuffle($arr);
        
$m count($arr);
        if(
$m == 2)
            
$n $m 1;
        else
            
$n $m 2;
        
        
$list = array();
        for (
$i 1$i <= $n$i++) {
            if(
$i == 2)
                
$list[$i] = 'DATA';
            elseif(
$m == && $i == 1)
                
$list[$i] = 'MAP';
            elseif(
$m == && $i == 3)
                
$list[$i] = 'MAP';
            elseif(
$m == && $i == 3)
                
$list[$i] = 'MAP';
            elseif(
$n >= && $i == 6)
                
$list[$i] = 'MAP';
            else 
                
$list[$i] = array_pop($arr);
        }
        
        
//var_dump($list);
        
$data['list'] = $list;

        
$data['title'] = $data['place']->name;
        if(
strlen($data['place']->name_orig) > && $data['place']->name_orig != $data['place']->name)
            
$data['title'] .= ' - '.$data['place']->name_orig;
        if(
strlen($data['place']->name_de) > && $data['place']->name_de != $data['place']->name)
            
$data['title'] .= ' - '.$data['place']->name_de;
        if(
strlen($data['place']->name_en) > && $data['place']->name_en != $data['place']->name)
            
$data['title'] .= ' - '.$data['place']->name_en;
        
        
$data['title'] .= ' - '.$data['site']->name;
        
$this->view()->render('/place'$data);
    }
    
    public function 
showImageGallery() {
        
$data self::init();
        
        
$data['gallery'] = Doo::db()->find('Gallery', array('where'=>"url LIKE '".$this->params['gallery']."%'"));
        
        if(
count($data['gallery']) == 0)
            return 
Doo::conf()->APP_URL.'';
        else         
            
$data['gallery'] = $data['gallery'][0];
        
        
$data['images'] = Doo::db()->find('Media', array('where'=>"mid IN (SELECT mid FROM media_gallery WHERE gid = ".$data['gallery']->gid.")"));
        
//$data['images'] = Doo::db()->find('Media', array('where'=>"url LIKE '".$this->params['place']."%'"));
        
        
$data['places'] = $data['site']->getPlaces();
        
$data['articles'] = $data['gallery']->getArticles();
        if(
count($data['articles']) > 0) {
            
$data['article'] = $data['articles'][0];
            
$data['place'] = $data['article']->getPlace();
        }
        else {
            
$data['article'] = null;
            
$data['place'] = $data['gallery']->getPlace();
        }
        
        
$data['title'] = $data['gallery']->title.' - Bilder & Fotos - '.$data['site']->name;
        
$this->view()->render('/gallery'$data);
    }
    
    public function 
showImageGallery2() {
        
$data self::init();
        
        
$data['gallery'] = Doo::db()->find('Gallery', array('where'=>"url LIKE '".$this->params['gallery']."%'"));
        
        if(
count($data['gallery']) == 0)
            return 
Doo::conf()->APP_URL.'';
        else         
            
$data['gallery'] = $data['gallery'][0];
        
        
$data['images'] = Doo::db()->find('Media', array('where'=>"mid IN (SELECT mid FROM media_gallery WHERE gid = ".$data['gallery']->gid.")"));
        
//$data['images'] = Doo::db()->find('Media', array('where'=>"url LIKE '".$this->params['place']."%'"));
        
        
$data['places'] = $data['site']->getPlaces();
        
$data['articles'] = $data['gallery']->getArticles();
        if(
count($data['articles']) > 0) {
            
$data['article'] = $data['articles'][0];
            
$data['place'] = $data['article']->getPlace();
        }
        else {
            
$data['article'] = null;
            
$data['place'] = $data['gallery']->getPlace();
        }
        
        
$data['title'] = $data['gallery']->title.' - Bilder & Fotos - '.$data['site']->name;
        
$this->view()->render('/gallery2'$data);
    }
    
    public function 
showImageGallery3() {
        
$data self::init();
        
        
$data['gallery'] = Doo::db()->find('Gallery', array('where'=>"url LIKE '".$this->params['gallery']."%'"));
        
        if(
count($data['gallery']) == 0)
            return 
Doo::conf()->APP_URL.'';
        else         
            
$data['gallery'] = $data['gallery'][0];
        
        
$data['images'] = Doo::db()->find('Media', array('where'=>"mid IN (SELECT mid FROM media_gallery WHERE gid = ".$data['gallery']->gid.")"));
        
//$data['images'] = Doo::db()->find('Media', array('where'=>"url LIKE '".$this->params['place']."%'"));
        
        
$data['places'] = $data['site']->getPlaces();
        
$data['articles'] = $data['gallery']->getArticles();
        if(
count($data['articles']) > 0) {
            
$data['article'] = $data['articles'][0];
            
$data['place'] = $data['article']->getPlace();
        }
        else {
            
$data['article'] = null;
            
$data['place'] = $data['gallery']->getPlace();
        }
        
        
$data['title'] = $data['gallery']->title.' - Bilder & Fotos - '.$data['site']->name;
        
$this->view()->render('/gallery3'$data);
    }
    
        public function 
showImageGallery4() {
        
$data self::init();
        
        
$data['gallery'] = Doo::db()->find('Gallery', array('where'=>"url LIKE '".$this->params['gallery']."%'"));
        
        if(
count($data['gallery']) == 0)
            return 
Doo::conf()->APP_URL.'';
        else         
            
$data['gallery'] = $data['gallery'][0];
        
        
$data['images'] = Doo::db()->find('Media', array('where'=>"mid IN (SELECT mid FROM media_gallery WHERE gid = ".$data['gallery']->gid.")"));
        
//$data['images'] = Doo::db()->find('Media', array('where'=>"url LIKE '".$this->params['place']."%'"));
        
        
$data['places'] = $data['site']->getPlaces();
        
$data['articles'] = $data['gallery']->getArticles();
        if(
count($data['articles']) > 0) {
            
$data['article'] = $data['articles'][0];
            
$data['place'] = $data['article']->getPlace();
        }
        else {
            
$data['article'] = null;
            
$data['place'] = $data['gallery']->getPlace();
        }
        
        
$data['title'] = $data['gallery']->title.' - Bilder & Fotos - '.$data['site']->name;
        
$this->view()->render('/gallery4'$data);
    }
    
    public function 
showVideoGallery() {
        
$data self::init();
        
        
$data['gallery'] = Doo::db()->find('Gallery', array('where'=>"url LIKE '".$this->params['gallery']."%'"));
        if(
count($data['gallery']) == 0)
            return 
Doo::conf()->APP_URL.'';
        else         
            
$data['gallery'] = $data['gallery'][0];
        
        
$data['videos'] = Doo::db()->find('Media', array('where'=>"mid IN (SELECT mid FROM media_gallery WHERE gid = ".$data['gallery']->gid.")"));
        
//$data['images'] = Doo::db()->find('Media', array('where'=>"url LIKE '".$this->params['place']."%'"));
        
        /*$data['place'] = Doo::db()->find('Place', array('where'=>"pid IN (SELECT pid FROM article_places WHERE aid = ".$data['article']->aid.") AND site = ".$data['site']->sid));
        $data['place'] = $data['place'][0];*/
        
        
$data['places'] = $data['site']->getPlaces();
        
$data['articles'] = $data['gallery']->getArticles();
        if(
count($data['articles']) > 0)
            
$data['article'] = $data['articles'][0];
        else
            
$data['article'] = null;
        
        if(
$data['article'] !== null
            
$data['place'] = $data['article']->getPlace();
        else 
            
$data['place'] = $data['gallery']->getPlace();
        
        
//$data['articles'] = null;
        
        
$data['title'] = $data['gallery']->title.' - Video - '.$data['site']->name;
        
$this->view()->render('/videoGallery'$data);
    }
    
    public function 
timeline() {
        
$data self::init();
        
        
$data['timelines'] = Doo::db()->find('Timeline', array('where'=>"place IN (SELECT pid FROM place WHERE parent IN (SELECT pid FROM place WHERE url LIKE '".$this->params['place']."%')) OR place IN (SELECT pid FROM place WHERE url LIKE '".$this->params['place']."%')"'desc'=>'date'));
        
        
$data['place'] = Doo::db()->find('Place', array('where'=>"url LIKE '".$this->params['place']."%'"));
        
$data['place'] = $data['place'][0];
        
        
$data['places'] = $data['site']->getPlaces();
        
$data['articles'] = $data['place']->getArticles();
        
        
$data['title'] = 'Chronik und Pressespiegel - '.$data['site']->name;
        
$data['tag'] = 'Aktuelles, Chronik, Historie, Nachrichten, News, Pressespiegel, Timeline, Zeitachse';
        
$this->view()->render('/timeline'$data);
    }
    
    
    
    
    
////////////
    
    
public function adminSites(){
        
$data self::init();
        
        
$data['sites'] = Doo::db()->find('Site', array('asc'=>'name'));
        
$this->view()->render('/admin_site'$data);
    }
    
    public function 
adminSiteEdit(){
        
$data self::init();
    
        if(
is_numeric($this->params['sid'])) {
            
$site Doo::db()->find('Site', array('where'=>'sid = '.$this->params['sid']));
            
$site $site[0];
            
            if(isset(
$_POST['submit']) && isset($_POST['name']) && isset($_POST['domain'])) {
                
$site->name $_POST['name'];
                
$site->teaser $_POST['teaser'];
                
$site->domain $_POST['domain'];
                
                
$site->teaser1 $_POST['teaser1'];
                
$site->teaser2 $_POST['teaser2'];
                
$site->teaser3 $_POST['teaser3'];
                
                
$site->update(array('setnulls'=>true));
                return 
Doo::conf()->APP_URL.'admin/site';
            }
        }
        elseif(
$this->params['sid'] == 'new') {
            
$site Doo::loadModel('Site'true);
            
            if(isset(
$_POST['submit']) && isset($_POST['name']) && isset($_POST['domain'])) {
                
$site->name $_POST['name'];
                
$site->teaser $_POST['teaser'];
                
$site->domain $_POST['domain'];
                
$site->insert(array('setnulls'=>true));
                return 
Doo::conf()->APP_URL.'admin/site';
            }
        }
    
        
$data['site'] = $site;
        
$this->view()->render('/admin_site_edit'$data);
    }
    
    public function 
adminPlaces(){
        
$data self::init();
        
        
$data['places'] = Doo::db()->find('Place', array('where'=>'site = '.$data['site']->sid));
        
$this->view()->render('/admin_place'$data);
    }
    
    public function 
adminPlaceEdit(){
        
$data self::init();
    
        if(
is_numeric($this->params['pid'])) {
            
$place Doo::db()->find('Place', array('where'=>'pid = '.$this->params['pid']));
            
$place $place[0];
            
            if(isset(
$_POST['submit']) && isset($_POST['name']) && isset($_POST['url'])) {
                if(isset(
$_POST['parent']) && $_POST['parent'] != 'null')
                    
$place->parent $_POST['parent'];
                else
                    
$place->parent null;
                
$place->site $_POST['site'];
                
$place->name $_POST['name'];
                
$place->name_de $_POST['name_de'];
                
$place->name_en $_POST['name_en'];
                
$place->name_orig $_POST['name_orig'];
                
$place->teaser $_POST['teaser'];
                
$place->url $_POST['url'];
                
$place->geo_lat $_POST['geo_lat'];
                
$place->geo_lon $_POST['geo_lon'];
                
$place->geo_alt $_POST['geo_alt'];
                
$place->population $_POST['population'];
                
$place->density $_POST['density'];
                
$place->area $_POST['area'];
                
$place->maps_lat $_POST['maps_lat'];
                
$place->maps_lon $_POST['maps_lon'];
                
$place->maps_zoom $_POST['maps_zoom'];
                
$place->maps_type $_POST['maps_type'];
                
                if(
strlen($_POST['geo_lat']) == 0)
                    
$place->geo_lat null;
                if(
strlen($_POST['geo_lon']) == 0)
                    
$place->geo_lon null;
                if(
strlen($_POST['geo_alt']) == 0)
                    
$place->geo_alt null;
                if(
strlen($_POST['population']) == 0)
                    
$place->population null;
                if(
strlen($_POST['density']) == 0)
                    
$place->density null;
                if(
strlen($_POST['area']) == 0)
                    
$place->area null;
                if(
strlen($_POST['maps_lat']) == 0)
                    
$place->maps_lat null;
                if(
strlen($_POST['maps_lon']) == 0)
                    
$place->maps_lon null;
                
                
// galleries
                
$map Doo::db()->find('PlaceGallery', array('where'=>'pid = '.$this->params['pid']));
                if(
count($map) > 0) {
                    foreach(
$map as $pg)
                        
Doo::db()->delete($pg);
                }
                if(isset(
$_POST['galleries'])) {
                    foreach(
$_POST['galleries'] as $gid) {
                        
$newg Doo::loadModel('PlaceGallery'true);
                        
$newg->pid $place->pid;
                        
$newg->gid $gid;
                        
$newg->insert();
                    }
                }
                
                
$place->update(array('setnulls'=>true));
                return 
Doo::conf()->APP_URL.'admin/place';
            }
        }
        elseif(
$this->params['pid'] == 'new') {
            
$place Doo::loadModel('Place'true);
            
            if(isset(
$_POST['submit']) && isset($_POST['name']) && isset($_POST['url'])) {
                if(isset(
$_POST['parent']) && $_POST['parent'] != 'null')
                    
$place->parent $_POST['parent'];
                else
                    
$place->parent null;
                
$place->site $_POST['site'];
                
$place->name $_POST['name'];
                
$place->name_de $_POST['name_de'];
                
$place->name_en $_POST['name_en'];
                
$place->name_orig $_POST['name_orig'];
                
$place->teaser $_POST['teaser'];
                
$place->url $_POST['url'];
                
$place->geo_lat $_POST['geo_lat'];
                
$place->geo_lon $_POST['geo_lon'];
                
$place->geo_alt $_POST['geo_alt'];
                
$place->population $_POST['population'];
                
$place->density $_POST['density'];
                
$place->area $_POST['area'];
                
$place->maps_lat $_POST['maps_lat'];
                
$place->maps_lon $_POST['maps_lon'];
                
$place->maps_zoom $_POST['maps_zoom'];
                
$place->maps_type $_POST['maps_type'];
                
                if(
strlen($_POST['geo_lat']) == 0)
                    
$place->geo_lat null;
                if(
strlen($_POST['geo_lon']) == 0)
                    
$place->geo_lon null;
                if(
strlen($_POST['geo_alt']) == 0)
                    
$place->geo_alt null;
                if(
strlen($_POST['population']) == 0)
                    
$place->population null;
                if(
strlen($_POST['density']) == 0)
                    
$place->density null;
                if(
strlen($_POST['area']) == 0)
                    
$place->area null;
                if(
strlen($_POST['maps_lat']) == 0)
                    
$place->maps_lat null;
                if(
strlen($_POST['maps_lon']) == 0)
                    
$place->maps_lon null;
                
                
$pid $place->insert(array('setnulls'=>true));
                
                
// galleries
                
if(isset($_POST['galleries'])) {
                    foreach(
$_POST['galleries'] as $gid) {
                        
$newg Doo::loadModel('PlaceGallery'true);
                        
$newg->pid $pid;
                        
$newg->gid $gid;
                        
$newg->insert();
                    }
                }
                
                return 
Doo::conf()->APP_URL.'admin/place';
            }
        }
    
        
$data['place'] = $place;
        
$this->view()->render('/admin_place_edit'$data);
    }
    
    public function 
adminSiteHeaderImage(){
        
$data self::init();
        
        if(isset(
$_POST['submit']) && isset($_POST['header']) && is_numeric($_POST['header']) && is_numeric($this->params['sid'])) {
            
$site Doo::db()->find('Site', array('where'=>'sid = '.$this->params['sid']));
            
$site $site[0];
            
$site->header $_POST['header'];
            
$site->update();
        }
        
        if(isset(
$this->params['gid'])) {
            
$gallery Doo::db()->find('Gallery', array('where'=>'gid = '.$this->params['gid']));
            
$gallery $gallery[0];
            
$data['gallery'] = $gallery;
        }
        else {
            
$data['galleries'] = $data['site']->getGalleries();
            
$data['gallery'] = $data['galleries'][0];
        }
        
        if(
count($data['gallery']->getMedias()) > 0)
            
$data['medias'] = $data['gallery']->getMedias();
        else
            
$data['medias'] = array();
        
        
$data['sid'] = $this->params['sid'];
        
$data['gid'] = $data['gallery']->gid;
        
        
$this->view()->render('/admin_site_header'$data);
    }
    
    public function 
adminPlaceHeaderImage(){
        
$data self::init();
        
        
$place Doo::db()->find('Place', array('where'=>'pid = '.$this->params['pid']));
        
$place $place[0];
        
        if(isset(
$_POST['submit']) && isset($_POST['header']) && (is_numeric($_POST['header']) || $_POST['header'] == 'nopic') && is_numeric($this->params['pid'])) {
            if(
$_POST['header'] == 'nopic')
                
$place->header null;
            else
                
$place->header $_POST['header'];
                
            
$place->update(array('setnulls'=>true));
        }
        
        if(isset(
$this->params['gid'])) {
            
$gallery Doo::db()->find('Gallery', array('where'=>'gid = '.$this->params['gid']));
            
$gallery $gallery[0];
            
$data['gallery'] = $gallery;
        }
        elseif(
is_numeric($place->header)) {
            
$gallery Doo::db()->find('Gallery', array('where'=>'gid IN (SELECT gid from media_gallery WHERE mid = '.$place->header.')'));
            
$gallery $gallery[0];
            
$data['gallery'] = $gallery;
        }
        else {
            
$data['galleries'] = $data['site']->getGalleries();
            
$data['gallery'] = $data['galleries'][0];
        }
        
        if(
count($data['gallery']->getMedias()) > 0)
            
$data['medias'] = $data['gallery']->getMedias();
        else
            
$data['medias'] = array();
        
        
$data['pid'] = $this->params['pid'];
        
$data['gid'] = $data['gallery']->gid;
        
$data['place'] = $place;
        
        
$this->view()->render('/admin_place_header'$data);
    }
    
    public function 
adminArticles(){
        
$data self::init();
        
        
$data['articles'] = $data['site']->getArticles(99'aid DESC');
        
$this->view()->render('/admin_article'$data);
    }
    
    public function 
adminArticleEdit(){
        
$data self::init();
    
        if(
is_numeric($this->params['aid'])) {
            
$article Doo::db()->find('Article', array('where'=>'aid = '.$this->params['aid'], 'desc'=>'rev'));
            
$article $article[0];
            
            if(isset(
$_POST['submit']) && isset($_POST['title']) && isset($_POST['url'])) {
                
$article->title $_POST['title'];
                
$article->teaser $_POST['teaser'];
                
$article->url $_POST['url'];
                
$article->html $_POST['html'];
                
$article->addition $_POST['addition'];
                
                if(
strlen($_POST['maps_lat']) > 2)
                    
$article->maps_lat $_POST['maps_lat'];
                else 
                    
$article->maps_lat null;
                if(
strlen($_POST['maps_lon']) > 2)
                    
$article->maps_lon $_POST['maps_lon'];
                else 
                    
$article->maps_lon null;
                if(
strlen($_POST['maps_zoom']) > && is_numeric($_POST['maps_zoom']))
                    
$article->maps_zoom $_POST['maps_zoom'];
                else
                    
$article->maps_zoom null;
                
$article->maps_type $_POST['maps_type'];
                
                
// places
                
$map Doo::db()->find('ArticlePlaces', array('where'=>'aid = '.$this->params['aid']));
                if(
count($map) > 0) {
                    foreach(
$map as $ap)
                        
Doo::db()->delete($ap);
                }
                
                foreach(
$_POST['places'] as $pid) {
                    
$newp Doo::loadModel('ArticlePlaces'true);
                    
$newp->aid $article->aid;
                    
$newp->pid $pid;
                    
$newp->insert();
                }
                
                
// galleries
                
$map Doo::db()->find('ArticleGallery', array('where'=>'aid = '.$this->params['aid']));
                if(
count($map) > 0) {
                    foreach(
$map as $ag)
                        
Doo::db()->delete($ag);
                }
                if(isset(
$_POST['galleries'])) {
                    foreach(
$_POST['galleries'] as $gid) {
                        
$newg Doo::loadModel('ArticleGallery'true);
                        
$newg->aid $article->aid;
                        
$newg->gid $gid;
                        
$newg->insert();
                    }
                }
                
                
$article->rev $article->rev 1;
                
$article->date null;
                
                
$article->insert(array('setnulls'=>true));
                
                return 
Doo::conf()->APP_URL.'admin/article';
            }
        }
        elseif(
$this->params['aid'] == 'new') {
            
$article Doo::loadModel('Article'true);
            
            if(isset(
$_POST['submit']) && isset($_POST['title']) && isset($_POST['url'])) {
                
$article->title $_POST['title'];
                
$article->teaser $_POST['teaser'];
                
$article->url $_POST['url'];
                
$article->html $_POST['html'];
                
$article->addition $_POST['addition'];
                
                
$article->maps_lat $_POST['maps_lat'];
                
$article->maps_lon $_POST['maps_lon'];
                
$article->maps_zoom $_POST['maps_zoom'];
                
$article->maps_type $_POST['maps_type'];
                
                
$row Doo::db()->fetchRow("SELECT MAX(aid)+1 AS aid FROM article");
                
$article->aid $row['aid'];
                
$article->rev 0;
                
                
// places
                
foreach($_POST['places'] as $pid) {
                    
$newp Doo::loadModel('ArticlePlaces'true);
                    
$newp->aid $article->aid;
                    
$newp->pid $pid;
                    
$newp->insert();
                }
                
                
// galleries
                
if(isset($_POST['galleries'])) {
                    foreach(
$_POST['galleries'] as $gid) {
                        
$newg Doo::loadModel('ArticleGallery'true);
                        
$newg->aid $article->aid;
                        
$newg->gid $gid;
                        
$newg->insert();
                    }
                }
                
                
$article->insert(array('setnulls'=>true));
                
                return 
Doo::conf()->APP_URL.'admin/article';
            }
        }
    
        
$data['article'] = $article;
        
$this->view()->render('/admin_article_edit'$data);
    }
    
    public function 
adminArticleTeaserImage(){
        
$data self::init();
        
        if(isset(
$_POST['submit']) && isset($_POST['teaser']) && is_numeric($_POST['teaser']) && is_numeric($this->params['aid'])) {
            
$aiArr Doo::db()->find('ArticleImage', array('where'=>'article = '.$this->params['aid'].' AND type = \'teaser\''));
            if(
count($aiArr) > 0) {
                foreach(
$aiArr as $ai)
                    
Doo::db()->delete($ai);
            }
        
            
$ai Doo::loadModel('ArticleImage'true);
            
$ai->article $this->params['aid'];
            
$ai->media $_POST['teaser'];
            
$ai->type 'teaser';
            
$ai->insert();
        }
        
        if(isset(
$this->params['gid'])) {
            
$gallery Doo::db()->find('Gallery', array('where'=>'gid = '.$this->params['gid']));
            
$gallery $gallery[0];
            
$data['gallery'] = $gallery;
        }
        else {
            
$data['galleries'] = $data['site']->getGalleries();
            
$data['gallery'] = $data['galleries'][0];
        }
        
        if(
count($data['gallery']->getMedias()) > 0)
            
$data['medias'] = $data['gallery']->getMedias();
        else
            
$data['medias'] = array();
        
        
$data['aid'] = $this->params['aid'];
        
$data['gid'] = $data['gallery']->gid;
        
        
$this->view()->render('/admin_article_teaser'$data);
    }
    
    public function 
adminArticleHeaderImage(){
        
$data self::init();
        
        if(isset(
$_POST['submit']) && isset($_POST['header']) && count($_POST['header']) >= && is_numeric($this->params['aid'])) {
            
$aiArr Doo::db()->find('ArticleImage', array('where'=>'article = '.$this->params['aid'].' AND type = \'header\''));
            if(
count($aiArr) > 0) {
                foreach(
$aiArr as $ai)
                    
Doo::db()->delete($ai);
            }
        
            foreach(
$_POST['header'] as $header) {
                
$ai Doo::loadModel('ArticleImage'true);
                
$ai->article $this->params['aid'];
                
$ai->media $header;
                
$ai->type 'header';
                
$ai->insert();
            }
        }
        
        if(isset(
$this->params['gid'])) {
            
$gallery Doo::db()->find('Gallery', array('where'=>'gid = '.$this->params['gid']));
            
$gallery $gallery[0];
            
$data['gallery'] = $gallery;
        }
        else {
            
$data['galleries'] = $data['site']->getGalleries();
            
$data['gallery'] = $data['galleries'][0];
        }
        
        if(
count($data['gallery']->getMedias()) > 0)
            
$data['medias'] = $data['gallery']->getMedias();
        else
            
$data['medias'] = array();
        
        
$data['aid'] = $this->params['aid'];
        
$data['gid'] = $data['gallery']->gid;
        
        
$this->view()->render('/admin_article_header'$data);
    }
    
    public function 
adminGalleries(){
        
$data self::init();
        
        if(isset(
$_POST['edit']) && isset($_POST['media']) && is_numeric($_POST['media'])) {
            return 
Doo::conf()->APP_URL.'admin/media/'.$_POST['media'];
        }
        elseif(isset(
$_POST['delete']) && isset($_POST['media']) && is_numeric($_POST['media'])) {
            
// delete image db object and files
            
$media Doo::db()->find('Media', array('where'=>'mid = '.$_POST['media']));
            
$media $media[0];
            
$media->remove();
            
$media->delete();
            
            
// delete gallery links
            
$media Doo::db()->find('MediaGallery', array('where'=>'mid = '.$_POST['media']));
            foreach(
$media as $m)
                
$m->delete();
                
            
// delete article links
            
$media Doo::db()->find('ArticleImage', array('where'=>'media = '.$_POST['media']));
            foreach(
$media as $m)
                
$m->delete();
        }
        elseif(isset(
$_POST['rotate']) && isset($_POST['media']) && is_numeric($_POST['media'])) {
            
$media Doo::db()->find('Media', array('where'=>'mid = '.$_POST['media']));
            
$media $media[0];
            
$media->rotate();
        }
        
        
$data['galleries'] = $data['site']->getGalleries();
        if(isset(
$this->params['gid'])) {
            
$gallery Doo::db()->find('Gallery', array('where'=>'gid = '.$this->params['gid']));
            
$gallery $gallery[0];
            
$data['gallery'] = $gallery;
        }
        elseif(
count($data['galleries']) > 0)
            
$data['gallery'] = $data['galleries'][0];
            
        if(
count($data['galleries']) > && count($data['gallery']->getMedias()) > 0)
            
$data['medias'] = $data['gallery']->getMedias();
        else
            
$data['medias'] = array();
        
        
$this->view()->render('/admin_gallery'$data);
    }
    
    public function 
adminGalleryEdit(){
        
$data self::init();
    
        if(
is_numeric($this->params['gid'])) {
            
$gallery Doo::db()->find('Gallery', array('where'=>'gid = '.$this->params['gid'], 'asc'=>'title'));
            
$gallery $gallery[0];
            
            if(isset(
$_POST['submit']) && isset($_POST['title']) && isset($_POST['url'])) {
                
$gallery->title $_POST['title'];
                
$gallery->text $_POST['text'];
                
$gallery->url $_POST['url'];
                if(
strlen($_POST['maps_lat']) == 0)
                    
$gallery->maps_lat null;
                else
                    
$gallery->maps_lat $_POST['maps_lat'];
                if(
strlen($_POST['maps_lon']) == 0)
                    
$gallery->maps_lon null;
                else
                    
$gallery->maps_lon $_POST['maps_lon'];
                if(
strlen($_POST['maps_zoom']) == 0)
                    
$gallery->maps_zoom null;
                else
                    
$gallery->maps_zoom $_POST['maps_zoom'];
                
$gallery->maps_type $_POST['maps_type'];
                
                
$gallery->update(array('setnulls'=>true));
                return 
Doo::conf()->APP_URL.'admin/gallery/show/'.$gallery->gid;
            }
        }
        elseif(
$this->params['gid'] == 'new') {
            
$gallery Doo::loadModel('Gallery'true);
            
            if(isset(
$_POST['submit']) && isset($_POST['title']) && isset($_POST['url'])) {
                
$gallery->title $_POST['title'];
                
$gallery->text $_POST['text'];
                
$gallery->url $_POST['url'];
                if(
strlen($_POST['maps_lat']) == 0)
                    
$gallery->maps_lat null;
                else
                    
$gallery->maps_lat $_POST['maps_lat'];
                if(
strlen($_POST['maps_lon']) == 0)
                    
$gallery->maps_lon null;
                else
                    
$gallery->maps_lon $_POST['maps_lon'];
                if(
strlen($_POST['maps_zoom']) == 0)
                    
$gallery->maps_zoom null;
                else
                    
$gallery->maps_zoom $_POST['maps_zoom'];
                
$gallery->maps_type $_POST['maps_type'];
                
                
$gid $gallery->insert(array('setnulls'=>true));
                return 
Doo::conf()->APP_URL.'admin/gallery/show/'.$gid;
            }
        }
    
        
$data['gallery'] = $gallery;
        
$this->view()->render('/admin_gallery_edit'$data);
    }
    
    public function 
adminGalleryTeaserImage(){
        
$data self::init();
        
        if(isset(
$_POST['submit']) && isset($_POST['teaser']) && is_numeric($_POST['teaser']) && is_numeric($this->params['gid'])) {
            
$gals Doo::db()->find('Gallery', array('where'=>'gid = '.$this->params['gid']));
            foreach(
$gals as $g) {
                
$g->teaser $_POST['teaser'];
                
$g->update();
            }
        }
        
        if(isset(
$this->params['gid_sel'])) {
            
$gallery Doo::db()->find('Gallery', array('where'=>'gid = '.$this->params['gid_sel']));
            
$gallery $gallery[0];
            
$data['gallery'] = $gallery;
        }
        else {
            
$data['galleries'] = $data['site']->getGalleries();
            
$data['gallery'] = $data['galleries'][0];
        }
        
        if(
count($data['gallery']->getMedias()) > 0)
            
$data['medias'] = $data['gallery']->getMedias();
        else
            
$data['medias'] = array();
        
        
$data['gid'] = $this->params['gid'];
        
$data['gid_sel'] = $data['gallery']->gid;
        
        
$this->view()->render('/admin_gallery_teaser'$data);
    }
    
    public function 
adminMediaUpload(){
        
$data self::init();
                
        if(isset(
$_FILES['file']) && count($_FILES['file']['tmp_name']) > 0) {
            for (
$i 0$i count($_FILES['file']['tmp_name']); $i++) {
                
$arr = array();
                
$arr['name'] = $_FILES['file']['name'][$i];
                
$arr['type'] = $_FILES['file']['type'][$i];
                
$arr['tmp_name'] = $_FILES['file']['tmp_name'][$i];
                
$arr['size'] = $_FILES['file']['size'][$i];
                
$arr['error'] = $_FILES['file']['error'][$i];
                
                if(
stripos($arr['name'], '.jpg') !== false && $arr['type'] == 'image/jpeg') {
                    
$media Doo::loadModel('Media'true);
                    
// upload image
                    
$media->uploadJPEG($arr);
                    
// create image in database
                    
$mid $media->insert(array('setnulls'=>true));
                    
// map image to gallery
                    
$mmap Doo::loadModel('MediaGallery'true);
                    
$mmap->mid $mid;
                    
$mmap->gid $this->params['gid'];
                    
$mmap->insert();
                }
                elseif(
stripos($arr['name'], '.png') !== false && $arr['type'] == 'image/png') {
                    
$media Doo::loadModel('Media'true);
                    
// upload image
                    
$media->uploadPNG($arr);
                    
// create image in database
                    
$mid $media->insert(array('setnulls'=>true));
                    
// map image to gallery
                    
$mmap Doo::loadModel('MediaGallery'true);
                    
$mmap->mid $mid;
                    
$mmap->gid $this->params['gid'];
                    
$mmap->insert();
                }
            }
        }
        
        
        
/*if(isset($_FILES['file']) && stripos($_FILES['file'][0]['name'], '.jpg') !== false && $_FILES['file'][0]['type'] == 'image/jpeg') {
            $media->uploadJPEG($_FILES['file']);
        }
        elseif(isset($_FILES['file']) && stripos($_FILES['file']['name'], '.mp4') !== false && $_FILES['file']['type'] == 'video/mp4') {
            //$media->uploadMP4($_FILES['file']);
        }
        else {
            return;
        }*/
        
        
        
        /*$exifdata = exif_read_data($_FILES['file']['tmp_name'],"",true,false);
        var_dump($exifdata);*/
        
return Doo::conf()->APP_URL.'admin/gallery/show/'.$this->params['gid'];
    }
    
    public function 
adminVideoUpload(){
        
$data self::init();
        
        
$media Doo::loadModel('Media'true);
        
        if(isset(
$_POST['submit'])) {
            
            
$media->text $_POST['text'];
            
            if((isset(
$_FILES['file_1']) && $_FILES['file_1']['type'] == 'video/mp4') || 
               (isset(
$_FILES['file_2']) && $_FILES['file_2']['type'] == 'video/mp4') || 
               (isset(
$_FILES['file_3']) && $_FILES['file_3']['type'] == 'video/mp4')) {
                
$media->type 'video/mp4';
                
$mid $media->insert(array('setnulls'=>true));
                
$media->uploadMP4($mid$_FILES);
                
                
$mmap Doo::loadModel('MediaGallery'true);
                
$mmap->mid $mid;
                
$mmap->gid $_POST['gallery'];
                
$mmap->insert();
            }
        }
    
        
$data['media'] = $media;
        
$data['video'] = Doo::loadModel('MediaVideo'true);
        
$data['gid'] = $this->params['gid'];
        
$this->view()->render('/admin_media_videoupload'$data);
    }
    
    public function 
adminVideoTeaserImage(){
        
$data self::init();
        
        if(isset(
$_POST['submit']) && isset($_POST['teaser']) && is_numeric($_POST['teaser']) && is_numeric($this->params['mid'])) {
            
$mvs Doo::db()->find('MediaVideo', array('where'=>'media = '.$this->params['mid']));
            foreach(
$mvs as $mv) {
                
$mv->teaser $_POST['teaser'];
                
$mv->update();
            }
        }
        
        if(isset(
$this->params['gid'])) {
            
$gallery Doo::db()->find('Gallery', array('where'=>'gid = '.$this->params['gid']));
            
$gallery $gallery[0];
            
$data['gallery'] = $gallery;
        }
        else {
            
$data['galleries'] = $data['site']->getGalleries();
            
$data['gallery'] = $data['galleries'][0];
        }
        
        if(
count($data['gallery']->getMedias()) > 0)
            
$data['medias'] = $data['gallery']->getMedias();
        else
            
$data['medias'] = array();
        
        
$data['mid'] = $this->params['mid'];
        
$data['gid'] = $data['gallery']->gid;
        
        
$this->view()->render('/admin_media_videoteaser'$data);
    }
    
    public function 
adminMediaEdit(){
        
$data self::init();
        
        
$media Doo::db()->find('Media', array('where'=>'mid = '.$this->params['mid']));
        if(
count($media) == 1)
            
$data['media'] = $media[0];
        else
            return 
Doo::conf()->APP_URL.'admin/gallery';
        
        if(isset(
$_POST['submit']) && isset($_POST['text'])) {
            
$data['media']->text $_POST['text'];
                
            
$data['media']->update(array('setnulls'=>true));
            
//return Doo::conf()->APP_URL.'admin/gallery/show/'.$gid;
        
}
        
        
$this->view()->render('/admin_media_edit'$data);
    }
    
    public function 
adminTimeline(){
        
$data self::init();
        
        
$data['timelines'] = $data['site']->getTimelines(99'tid DESC');
        
$this->view()->render('/admin_timeline'$data);
    }
    
    public function 
adminTimelineEdit(){
        
$data self::init();
    
        if(
is_numeric($this->params['tid'])) {
            
$timeline Doo::db()->find('Timeline', array('where'=>'tid = '.$this->params['tid']));
            
$timeline $timeline[0];
            
            if(isset(
$_POST['submit']) && isset($_POST['date']) && isset($_POST['text'])) {
                
$timeline->date $_POST['date'];
                
$timeline->text $_POST['text'];
                
$timeline->link $_POST['link'];
                
$timeline->place $_POST['place'];
                
                if(isset(
$_POST['quote']) && $_POST['quote'] == 'Y')
                    
$timeline->quote 'Y';
                elseif(isset(
$_POST['quote']) && $_POST['quote'] == 'P')
                    
$timeline->quote 'P';
                else 
                    
$timeline->quote 'N';
                
                
$timeline->update(array('setnulls'=>true));
                
                return 
Doo::conf()->APP_URL.'admin/timeline';
            }
        }
        elseif(
$this->params['tid'] == 'new') {
            
$timeline Doo::loadModel('Timeline'true);
            
            if(isset(
$_POST['submit']) && isset($_POST['date']) && isset($_POST['text'])) {
                
$timeline->date $_POST['date'];
                
$timeline->text $_POST['text'];
                
$timeline->link $_POST['link'];
                
$timeline->place $_POST['place'];
                
                if(isset(
$_POST['quote']) && $_POST['quote'] == 'Y')
                    
$timeline->quote 'Y';
                elseif(isset(
$_POST['quote']) && $_POST['quote'] == 'P')
                    
$timeline->quote 'P';
                else 
                    
$timeline->quote 'N';
                
                
$timeline->insert(array('setnulls'=>true));
                
                return 
Doo::conf()->APP_URL.'admin/timeline';
            }
        }
    
        
$data['timeline'] = $timeline;
        
$this->view()->render('/admin_timeline_edit'$data);
    }
    
    public function 
test() {
        
$filename Doo::conf()->SITE_PATH.'media/video/P1020235_1080.mp4';
        
        require_once(
Doo::conf()->SITE_PATH.'protected/plugin/getid3/getid3.php');
        
$getID3 = new getID3;
        
$file $getID3->analyze($filename);
        
        
var_dump($file);
        
        
        echo(
"Duration: ".$file['playtime_string'].
        
" / Dimensions: ".$file['video']['resolution_x']." wide by ".$file['video']['resolution_y']." tall".
        
" / Filesize: ".$file['filesize']." bytes<br />");
        
        
    }
    
    
///////////////////////////////////////////////
    
    
public function allurl(){    
        
Doo::loadCore('app/DooSiteMagic');
        
DooSiteMagic::showAllUrl();    
    }
    
    public function 
debug(){
        
Doo::loadCore('app/DooSiteMagic');
        
DooSiteMagic::showDebug($this->params['filename']);
    }
    
    
/*public function gen_sitemap_controller(){
        //This will replace the routes.conf.php file
        Doo::loadCore('app/DooSiteMagic');
        DooSiteMagic::buildSitemap(true);        
        DooSiteMagic::buildSite();
    }
    
    public function gen_sitemap(){
        //This will write a new file,  routes2.conf.php file
        Doo::loadCore('app/DooSiteMagic');
        DooSiteMagic::buildSitemap();        
    }*/
    
    
public function gen_site(){
        
Doo::loadCore('app/DooSiteMagic');
        
DooSiteMagic::buildSite();
    }
    
    public function 
gen_model(){
        
Doo::loadCore('db/DooModelGen');
        
DooModelGen::genMySQL();
    }

}
?>


* Stack Trace...

  1. /var/customers/webs/vworld/app/index.php(29) calling run()
  2. /var/customers/webs/vworld/dooframework/app/DooWebApp.php(34) calling routeTo()
  3. /var/customers/webs/vworld/dooframework/app/DooWebApp.php(159) calling urlParser()
  4. /var/customers/webs/vworld/app/protected/controller/MainController.php(102) calling place()


* Variables...  Conf .  GET  .  POST  .  Session  .  Cookie 


object(DooConfig)#1 (25) {
  
["AUTOLOAD"] => NULL
  
["SITE_PATH"] => string(31"/var/customers/webs/vworld/app/"
  
["PROTECTED_FOLDER"] => string(10"protected/"
  
["BASE_PATH"] => string(40"/var/customers/webs/vworld/dooframework/"
  
["LOG_PATH"] => NULL
  
["APP_URL"] => string(20"http://vthailand.de/"
  
["SUBFOLDER"] => string(1"/"
  
["APP_MODE"] => string(3"dev"
  
["AUTOROUTE"] => bool(false)
  [
"DEBUG_ENABLED"] => bool(true)
  [
"ERROR_404_DOCUMENT"] => NULL
  
["ERROR_404_ROUTE"] => string(6"/error"
  
["CACHE_PATH"] => NULL
  
["AUTO_VIEW_RENDER_PATH"] => string(16"/:place/:article"
  
["MEMCACHE"] => NULL
  
["TEMPLATE_ENGINE"] => string(12"DooViewBasic"
  
["TEMPLATE_SHOW_COMMENT"] => NULL
  
["TEMPLATE_ALLOW_PHP"] => NULL
  
["TEMPLATE_COMPILE_ALWAYS"] => bool(true)
  [
"TEMPLATE_GLOBAL_TAGS"] => NULL
  
["MODULES"] => NULL
  
["APP_NAMESPACE_ID"] => NULL
  
["CHMOD_DEFAULT"] => int(511)
  [
"FROM_CLI"] => bool(false)
  [
"MEDIA_PATH"] => string(37"/var/customers/webs/vworld/app/media/"
}
DooPHP Diagnostics - Call to a member function getArticles() on null

See file /var/customers/webs/vworld/app/protected/controller/MainController.php


+ Error on line 138

        $data['articles'] = $data['place']->getArticles();

<?php
/**
 * MainController
 * vWorld Frontend and Backend
 *
 * @author kb
 */
class MainController extends DooController{
    private function 
init() {
        
$data = array();
    
        
$site Doo::loadModel('Site'true);
        
$site->domain str_replace('www.'''$_SERVER['HTTP_HOST']);
        
$data['site'] = Doo::db()->find($site);
        
$data['site'] = $data['site'][0];
        
        
$data['footerPlaces'] = Doo::db()->find('Place', array('where'=>'site = '.$data['site']->sid." AND name <> '".$data['site']->name."' AND ( pid IN (SELECT pid FROM article_places GROUP BY pid ORDER BY COUNT(aid) DESC) OR pid IN (SELECT pid FROM place_gallery GROUP BY pid ORDER BY COUNT(gid) DESC) )"));
        
//if(count($data['footerPlaces']) == 0)
        
$tmp Doo::db()->find('Place', array('where'=>'site = '.$data['site']->sid." AND name <> '".$data['site']->name."' ORDER BY place.population DESC"));
        
$data['footerPlaces'] = array_unique(array_merge($data['footerPlaces'], $tmp), SORT_REGULAR);
        
        
$data['footerArticles'] = $data['site']->getArticles(3'date DESC');
        
$data['footerSites'] = $data['site']->getSites();
        
$data['footerURL'] = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
        
        
$data['title'] = $data['site']->name.' - '.$data['site']->domain;
        
        return 
$data;
    }

    public function 
index() {
        
$data self::init();
        
$data['currentpage'] = 'home';
        
//$this->view()->render('/'.Doo::conf()->lang .'/index', $data);
        
        
$data['timelines'] = Doo::db()->find('Timeline', array('where'=>"place IN (SELECT pid FROM place WHERE quote = 'N' AND parent IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.")) OR place IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.")"'desc'=>'date''limit'=>3));
        
$data['place'] = Doo::db()->find('Place', array('where'=>"parent IS NULL AND site = ".$data['site']->sid));

        if(
count($data['place']) > 0)
            
$data['place'] = $data['place'][0];
        else {
            
$this->view()->render('/404'$data);
            return;
        }
        
        
$data['places'] = Doo::db()->find('Place', array('where'=>'site = '.$data['site']->sid));
        
$data['articles'] = $data['site']->getArticlesWoTeaser();
        
        
// Teaser 1
        
if(is_numeric($data['site']->teaser1)) {
            
$data['teaser1'] = Doo::db()->find('Article', array('where'=>"aid = ".$data['site']->teaser1));
            
$data['teaser1'] = $data['teaser1'][0];
        }
        elseif(
$data['site']->teaser1 == 'timeline_N')
            
$data['teaser1'] = Doo::db()->find('Timeline', array('where'=>"quote = 'N' AND ( place IN (SELECT pid FROM place WHERE parent IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.")) OR place IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.") )"'desc'=>'date''limit'=>3));
        elseif(
$data['site']->teaser1 == 'timeline_NY'
            
$data['teaser1'] = Doo::db()->find('Timeline', array('where'=>"(quote = 'N' OR quote = 'Y') AND ( place IN (SELECT pid FROM place WHERE parent IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.")) OR place IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.") )"'desc'=>'date''limit'=>3));
        elseif(
$data['site']->teaser1 == 'timeline_Y'
            
$data['teaser1'] = Doo::db()->find('Timeline', array('where'=>"quote = 'Y' AND ( place IN (SELECT pid FROM place WHERE parent IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.")) OR place IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.") )"'desc'=>'date''limit'=>3));
        elseif(
$data['site']->teaser1 == 'timeline_P'
            
$data['teaser1'] = Doo::db()->find('Timeline', array('where'=>"quote = 'P' AND ( place IN (SELECT pid FROM place WHERE parent IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.")) OR place IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.") )"'desc'=>'date''limit'=>3));
    
        
// Teaser 2
        
if(is_numeric($data['site']->teaser2)) {
            
$data['teaser2'] = Doo::db()->find('Article', array('where'=>"aid = ".$data['site']->teaser2));
            
$data['teaser2'] = $data['teaser2'][0];
        }
        elseif(
$data['site']->teaser2 == 'timeline_N')
            
$data['teaser2'] = Doo::db()->find('Timeline', array('where'=>"quote = 'N' AND ( place IN (SELECT pid FROM place WHERE parent IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.")) OR place IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.") )"'desc'=>'date''limit'=>3));
        elseif(
$data['site']->teaser2 == 'timeline_NY'
            
$data['teaser2'] = Doo::db()->find('Timeline', array('where'=>"(quote = 'N' OR quote = 'Y') AND ( place IN (SELECT pid FROM place WHERE parent IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.")) OR place IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.") )"'desc'=>'date''limit'=>3));
        elseif(
$data['site']->teaser2 == 'timeline_Y'
            
$data['teaser2'] = Doo::db()->find('Timeline', array('where'=>"quote = 'Y' AND ( place IN (SELECT pid FROM place WHERE parent IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.")) OR place IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.") )"'desc'=>'date''limit'=>3));
        elseif(
$data['site']->teaser2 == 'timeline_P'
            
$data['teaser2'] = Doo::db()->find('Timeline', array('where'=>"quote = 'P' AND ( place IN (SELECT pid FROM place WHERE parent IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.")) OR place IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.") )"'desc'=>'date''limit'=>3));
    
        
// Teaser 3
        
if(is_numeric($data['site']->teaser3)) {
            
$data['teaser3'] = Doo::db()->find('Article', array('where'=>"aid = ".$data['site']->teaser3));
            
$data['teaser3'] = $data['teaser3'][0];
        }
        elseif(
$data['site']->teaser3 == 'timeline_N')
            
$data['teaser3'] = Doo::db()->find('Timeline', array('where'=>"quote = 'N' AND ( place IN (SELECT pid FROM place WHERE parent IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.")) OR place IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.") )"'desc'=>'date''limit'=>3));
        elseif(
$data['site']->teaser3 == 'timeline_NY'
            
$data['teaser3'] = Doo::db()->find('Timeline', array('where'=>"(quote = 'N' OR quote = 'Y') AND ( place IN (SELECT pid FROM place WHERE parent IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.")) OR place IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.") )"'desc'=>'date''limit'=>3));
        elseif(
$data['site']->teaser3 == 'timeline_Y'
            
$data['teaser3'] = Doo::db()->find('Timeline', array('where'=>"quote = 'Y' AND ( place IN (SELECT pid FROM place WHERE parent IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.")) OR place IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.") )"'desc'=>'date''limit'=>3));
        elseif(
$data['site']->teaser3 == 'timeline_P'
            
$data['teaser3'] = Doo::db()->find('Timeline', array('where'=>"quote = 'P' AND ( place IN (SELECT pid FROM place WHERE parent IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.")) OR place IN (SELECT pid FROM place WHERE site = ".$data['site']->sid.") )"'desc'=>'date''limit'=>3));
        
        
$this->view()->render('/index'$data);
    }
    
    public function 
urlParser() {
        if(isset(
$this->params['article'])) {
            if(
$this->params['article'] == 'chronik')
                
self::timeline();
            else
                
self::article();
        }
        else
            
self::place();
    
    }
    
    public function 
article() {
        
$data self::init();
        
        
//$data['article'] = Doo::db()->find('Article', array('where'=>"aid IN (SELECT aid FROM article WHERE url LIKE '".$this->params['article']."%' ORDER BY date DESC)", 'desc'=>'date'));
        
$data['article'] = Doo::db()->find('Article', array('where'=>"aid IN (SELECT aid FROM article WHERE url LIKE '".$this->params['article']."%' ORDER BY date DESC) ORDER BY date DESC, rev DESC"));
        
$data['article'] = $data['article'][0];
        
        
        
        
//var_dump($data['article']);
        
        //$data['place'] = Doo::db()->find('Place', array('where'=>"pid IN (SELECT pid FROM article_places WHERE aid = ".$data['article']->aid.") AND site = ".$data['site']->sid, 'desc'=>'parent'));
        
$data['place'] = $data['article']->getPlace();
        
//$data['galleries'] = $data['article']->getGalleries();
        
        
$data['places'] = $data['site']->getPlaces();
        
        
$data['title'] = $data['article']->title.' - '.$data['site']->name;
        
$this->view()->render('/article'$data);
    }
    
    public function 
place() {
        
$data self::init();
        
        
$data['place'] = Doo::db()->find('Place', array('where'=>"url LIKE '".$this->params['place']."%'"));
        
$data['place'] = $data['place'][0];
        
        
/*$data['place'] = Doo::db()->find('Place', array('where'=>"pid IN (SELECT pid FROM article_places WHERE aid = ".$data['article']->aid.") AND site = ".$data['site']->sid));
        $data['place'] = $data['place'][0];*/
        
        
$data['places'] = $data['site']->getPlaces();
        
        $data['articles'] = $data['place']->getArticles();

        
$data['galleries'] = $data['place']->getGalleriesWithoutArticle();
        
        
$arr array_merge((array)$data['galleries'], (array)$data['articles']);
        
//shuffle($arr);
        
$m count($arr);
        if(
$m == 2)
            
$n $m 1;
        else
            
$n $m 2;
        
        
$list = array();
        for (
$i 1$i <= $n$i++) {
            if(
$i == 2)
                
$list[$i] = 'DATA';
            elseif(
$m == && $i == 1)
                
$list[$i] = 'MAP';
            elseif(
$m == && $i == 3)
                
$list[$i] = 'MAP';
            elseif(
$m == && $i == 3)
                
$list[$i] = 'MAP';
            elseif(
$n >= && $i == 6)
                
$list[$i] = 'MAP';
            else 
                
$list[$i] = array_pop($arr);
        }
        
        
//var_dump($list);
        
$data['list'] = $list;

        
$data['title'] = $data['place']->name;
        if(
strlen($data['place']->name_orig) > && $data['place']->name_orig != $data['place']->name)
            
$data['title'] .= ' - '.$data['place']->name_orig;
        if(
strlen($data['place']->name_de) > && $data['place']->name_de != $data['place']->name)
            
$data['title'] .= ' - '.$data['place']->name_de;
        if(
strlen($data['place']->name_en) > && $data['place']->name_en != $data['place']->name)
            
$data['title'] .= ' - '.$data['place']->name_en;
        
        
$data['title'] .= ' - '.$data['site']->name;
        
$this->view()->render('/place'$data);
    }
    
    public function 
showImageGallery() {
        
$data self::init();
        
        
$data['gallery'] = Doo::db()->find('Gallery', array('where'=>"url LIKE '".$this->params['gallery']."%'"));
        
        if(
count($data['gallery']) == 0)
            return 
Doo::conf()->APP_URL.'';
        else         
            
$data['gallery'] = $data['gallery'][0];
        
        
$data['images'] = Doo::db()->find('Media', array('where'=>"mid IN (SELECT mid FROM media_gallery WHERE gid = ".$data['gallery']->gid.")"));
        
//$data['images'] = Doo::db()->find('Media', array('where'=>"url LIKE '".$this->params['place']."%'"));
        
        
$data['places'] = $data['site']->getPlaces();
        
$data['articles'] = $data['gallery']->getArticles();
        if(
count($data['articles']) > 0) {
            
$data['article'] = $data['articles'][0];
            
$data['place'] = $data['article']->getPlace();
        }
        else {
            
$data['article'] = null;
            
$data['place'] = $data['gallery']->getPlace();
        }
        
        
$data['title'] = $data['gallery']->title.' - Bilder & Fotos - '.$data['site']->name;
        
$this->view()->render('/gallery'$data);
    }
    
    public function 
showImageGallery2() {
        
$data self::init();
        
        
$data['gallery'] = Doo::db()->find('Gallery', array('where'=>"url LIKE '".$this->params['gallery']."%'"));
        
        if(
count($data['gallery']) == 0)
            return 
Doo::conf()->APP_URL.'';
        else         
            
$data['gallery'] = $data['gallery'][0];
        
        
$data['images'] = Doo::db()->find('Media', array('where'=>"mid IN (SELECT mid FROM media_gallery WHERE gid = ".$data['gallery']->gid.")"));
        
//$data['images'] = Doo::db()->find('Media', array('where'=>"url LIKE '".$this->params['place']."%'"));
        
        
$data['places'] = $data['site']->getPlaces();
        
$data['articles'] = $data['gallery']->getArticles();
        if(
count($data['articles']) > 0) {
            
$data['article'] = $data['articles'][0];
            
$data['place'] = $data['article']->getPlace();
        }
        else {
            
$data['article'] = null;
            
$data['place'] = $data['gallery']->getPlace();
        }
        
        
$data['title'] = $data['gallery']->title.' - Bilder & Fotos - '.$data['site']->name;
        
$this->view()->render('/gallery2'$data);
    }
    
    public function 
showImageGallery3() {
        
$data self::init();
        
        
$data['gallery'] = Doo::db()->find('Gallery', array('where'=>"url LIKE '".$this->params['gallery']."%'"));
        
        if(
count($data['gallery']) == 0)
            return 
Doo::conf()->APP_URL.'';
        else         
            
$data['gallery'] = $data['gallery'][0];
        
        
$data['images'] = Doo::db()->find('Media', array('where'=>"mid IN (SELECT mid FROM media_gallery WHERE gid = ".$data['gallery']->gid.")"));
        
//$data['images'] = Doo::db()->find('Media', array('where'=>"url LIKE '".$this->params['place']."%'"));
        
        
$data['places'] = $data['site']->getPlaces();
        
$data['articles'] = $data['gallery']->getArticles();
        if(
count($data['articles']) > 0) {
            
$data['article'] = $data['articles'][0];
            
$data['place'] = $data['article']->getPlace();
        }
        else {
            
$data['article'] = null;
            
$data['place'] = $data['gallery']->getPlace();
        }
        
        
$data['title'] = $data['gallery']->title.' - Bilder & Fotos - '.$data['site']->name;
        
$this->view()->render('/gallery3'$data);
    }
    
        public function 
showImageGallery4() {
        
$data self::init();
        
        
$data['gallery'] = Doo::db()->find('Gallery', array('where'=>"url LIKE '".$this->params['gallery']."%'"));
        
        if(
count($data['gallery']) == 0)
            return 
Doo::conf()->APP_URL.'';
        else         
            
$data['gallery'] = $data['gallery'][0];
        
        
$data['images'] = Doo::db()->find('Media', array('where'=>"mid IN (SELECT mid FROM media_gallery WHERE gid = ".$data['gallery']->gid.")"));
        
//$data['images'] = Doo::db()->find('Media', array('where'=>"url LIKE '".$this->params['place']."%'"));
        
        
$data['places'] = $data['site']->getPlaces();
        
$data['articles'] = $data['gallery']->getArticles();
        if(
count($data['articles']) > 0) {
            
$data['article'] = $data['articles'][0];
            
$data['place'] = $data['article']->getPlace();
        }
        else {
            
$data['article'] = null;
            
$data['place'] = $data['gallery']->getPlace();
        }
        
        
$data['title'] = $data['gallery']->title.' - Bilder & Fotos - '.$data['site']->name;
        
$this->view()->render('/gallery4'$data);
    }
    
    public function 
showVideoGallery() {
        
$data self::init();
        
        
$data['gallery'] = Doo::db()->find('Gallery', array('where'=>"url LIKE '".$this->params['gallery']."%'"));
        if(
count($data['gallery']) == 0)
            return 
Doo::conf()->APP_URL.'';
        else         
            
$data['gallery'] = $data['gallery'][0];
        
        
$data['videos'] = Doo::db()->find('Media', array('where'=>"mid IN (SELECT mid FROM media_gallery WHERE gid = ".$data['gallery']->gid.")"));
        
//$data['images'] = Doo::db()->find('Media', array('where'=>"url LIKE '".$this->params['place']."%'"));
        
        /*$data['place'] = Doo::db()->find('Place', array('where'=>"pid IN (SELECT pid FROM article_places WHERE aid = ".$data['article']->aid.") AND site = ".$data['site']->sid));
        $data['place'] = $data['place'][0];*/
        
        
$data['places'] = $data['site']->getPlaces();
        
$data['articles'] = $data['gallery']->getArticles();
        if(
count($data['articles']) > 0)
            
$data['article'] = $data['articles'][0];
        else
            
$data['article'] = null;
        
        if(
$data['article'] !== null
            
$data['place'] = $data['article']->getPlace();
        else 
            
$data['place'] = $data['gallery']->getPlace();
        
        
//$data['articles'] = null;
        
        
$data['title'] = $data['gallery']->title.' - Video - '.$data['site']->name;
        
$this->view()->render('/videoGallery'$data);
    }
    
    public function 
timeline() {
        
$data self::init();
        
        
$data['timelines'] = Doo::db()->find('Timeline', array('where'=>"place IN (SELECT pid FROM place WHERE parent IN (SELECT pid FROM place WHERE url LIKE '".$this->params['place']."%')) OR place IN (SELECT pid FROM place WHERE url LIKE '".$this->params['place']."%')"'desc'=>'date'));
        
        
$data['place'] = Doo::db()->find('Place', array('where'=>"url LIKE '".$this->params['place']."%'"));
        
$data['place'] = $data['place'][0];
        
        
$data['places'] = $data['site']->getPlaces();
        
$data['articles'] = $data['place']->getArticles();
        
        
$data['title'] = 'Chronik und Pressespiegel - '.$data['site']->name;
        
$data['tag'] = 'Aktuelles, Chronik, Historie, Nachrichten, News, Pressespiegel, Timeline, Zeitachse';
        
$this->view()->render('/timeline'$data);
    }
    
    
    
    
    
////////////
    
    
public function adminSites(){
        
$data self::init();
        
        
$data['sites'] = Doo::db()->find('Site', array('asc'=>'name'));
        
$this->view()->render('/admin_site'$data);
    }
    
    public function 
adminSiteEdit(){
        
$data self::init();
    
        if(
is_numeric($this->params['sid'])) {
            
$site Doo::db()->find('Site', array('where'=>'sid = '.$this->params['sid']));
            
$site $site[0];
            
            if(isset(
$_POST['submit']) && isset($_POST['name']) && isset($_POST['domain'])) {
                
$site->name $_POST['name'];
                
$site->teaser $_POST['teaser'];
                
$site->domain $_POST['domain'];
                
                
$site->teaser1 $_POST['teaser1'];
                
$site->teaser2 $_POST['teaser2'];
                
$site->teaser3 $_POST['teaser3'];
                
                
$site->update(array('setnulls'=>true));
                return 
Doo::conf()->APP_URL.'admin/site';
            }
        }
        elseif(
$this->params['sid'] == 'new') {
            
$site Doo::loadModel('Site'true);
            
            if(isset(
$_POST['submit']) && isset($_POST['name']) && isset($_POST['domain'])) {
                
$site->name $_POST['name'];
                
$site->teaser $_POST['teaser'];
                
$site->domain $_POST['domain'];
                
$site->insert(array('setnulls'=>true));
                return 
Doo::conf()->APP_URL.'admin/site';
            }
        }
    
        
$data['site'] = $site;
        
$this->view()->render('/admin_site_edit'$data);
    }
    
    public function 
adminPlaces(){
        
$data self::init();
        
        
$data['places'] = Doo::db()->find('Place', array('where'=>'site = '.$data['site']->sid));
        
$this->view()->render('/admin_place'$data);
    }
    
    public function 
adminPlaceEdit(){
        
$data self::init();
    
        if(
is_numeric($this->params['pid'])) {
            
$place Doo::db()->find('Place', array('where'=>'pid = '.$this->params['pid']));
            
$place $place[0];
            
            if(isset(
$_POST['submit']) && isset($_POST['name']) && isset($_POST['url'])) {
                if(isset(
$_POST['parent']) && $_POST['parent'] != 'null')
                    
$place->parent $_POST['parent'];
                else
                    
$place->parent null;
                
$place->site $_POST['site'];
                
$place->name $_POST['name'];
                
$place->name_de $_POST['name_de'];
                
$place->name_en $_POST['name_en'];
                
$place->name_orig $_POST['name_orig'];
                
$place->teaser $_POST['teaser'];
                
$place->url $_POST['url'];
                
$place->geo_lat $_POST['geo_lat'];
                
$place->geo_lon $_POST['geo_lon'];
                
$place->geo_alt $_POST['geo_alt'];
                
$place->population $_POST['population'];
                
$place->density $_POST['density'];
                
$place->area $_POST['area'];
                
$place->maps_lat $_POST['maps_lat'];
                
$place->maps_lon $_POST['maps_lon'];
                
$place->maps_zoom $_POST['maps_zoom'];
                
$place->maps_type $_POST['maps_type'];
                
                if(
strlen($_POST['geo_lat']) == 0)
                    
$place->geo_lat null;
                if(
strlen($_POST['geo_lon']) == 0)
                    
$place->geo_lon null;
                if(
strlen($_POST['geo_alt']) == 0)
                    
$place->geo_alt null;
                if(
strlen($_POST['population']) == 0)
                    
$place->population null;
                if(
strlen($_POST['density']) == 0)
                    
$place->density null;
                if(
strlen($_POST['area']) == 0)
                    
$place->area null;
                if(
strlen($_POST['maps_lat']) == 0)
                    
$place->maps_lat null;
                if(
strlen($_POST['maps_lon']) == 0)
                    
$place->maps_lon null;
                
                
// galleries
                
$map Doo::db()->find('PlaceGallery', array('where'=>'pid = '.$this->params['pid']));
                if(
count($map) > 0) {
                    foreach(
$map as $pg)
                        
Doo::db()->delete($pg);
                }
                if(isset(
$_POST['galleries'])) {
                    foreach(
$_POST['galleries'] as $gid) {
                        
$newg Doo::loadModel('PlaceGallery'true);
                        
$newg->pid $place->pid;
                        
$newg->gid $gid;
                        
$newg->insert();
                    }
                }
                
                
$place->update(array('setnulls'=>true));
                return 
Doo::conf()->APP_URL.'admin/place';
            }
        }
        elseif(
$this->params['pid'] == 'new') {
            
$place Doo::loadModel('Place'true);
            
            if(isset(
$_POST['submit']) && isset($_POST['name']) && isset($_POST['url'])) {
                if(isset(
$_POST['parent']) && $_POST['parent'] != 'null')
                    
$place->parent $_POST['parent'];
                else
                    
$place->parent null;
                
$place->site $_POST['site'];
                
$place->name $_POST['name'];
                
$place->name_de $_POST['name_de'];
                
$place->name_en $_POST['name_en'];
                
$place->name_orig $_POST['name_orig'];
                
$place->teaser $_POST['teaser'];
                
$place->url $_POST['url'];
                
$place->geo_lat $_POST['geo_lat'];
                
$place->geo_lon $_POST['geo_lon'];
                
$place->geo_alt $_POST['geo_alt'];
                
$place->population $_POST['population'];
                
$place->density $_POST['density'];
                
$place->area $_POST['area'];
                
$place->maps_lat $_POST['maps_lat'];
                
$place->maps_lon $_POST['maps_lon'];
                
$place->maps_zoom $_POST['maps_zoom'];
                
$place->maps_type $_POST['maps_type'];
                
                if(
strlen($_POST['geo_lat']) == 0)
                    
$place->geo_lat null;
                if(
strlen($_POST['geo_lon']) == 0)
                    
$place->geo_lon null;
                if(
strlen($_POST['geo_alt']) == 0)
                    
$place->geo_alt null;
                if(
strlen($_POST['population']) == 0)
                    
$place->population null;
                if(
strlen($_POST['density']) == 0)
                    
$place->density null;
                if(
strlen($_POST['area']) == 0)
                    
$place->area null;
                if(
strlen($_POST['maps_lat']) == 0)
                    
$place->maps_lat null;
                if(
strlen($_POST['maps_lon']) == 0)
                    
$place->maps_lon null;
                
                
$pid $place->insert(array('setnulls'=>true));
                
                
// galleries
                
if(isset($_POST['galleries'])) {
                    foreach(
$_POST['galleries'] as $gid) {
                        
$newg Doo::loadModel('PlaceGallery'true);
                        
$newg->pid $pid;
                        
$newg->gid $gid;
                        
$newg->insert();
                    }
                }
                
                return 
Doo::conf()->APP_URL.'admin/place';
            }
        }
    
        
$data['place'] = $place;
        
$this->view()->render('/admin_place_edit'$data);
    }
    
    public function 
adminSiteHeaderImage(){
        
$data self::init();
        
        if(isset(
$_POST['submit']) && isset($_POST['header']) && is_numeric($_POST['header']) && is_numeric($this->params['sid'])) {
            
$site Doo::db()->find('Site', array('where'=>'sid = '.$this->params['sid']));
            
$site $site[0];
            
$site->header $_POST['header'];
            
$site->update();
        }
        
        if(isset(
$this->params['gid'])) {
            
$gallery Doo::db()->find('Gallery', array('where'=>'gid = '.$this->params['gid']));
            
$gallery $gallery[0];
            
$data['gallery'] = $gallery;
        }
        else {
            
$data['galleries'] = $data['site']->getGalleries();
            
$data['gallery'] = $data['galleries'][0];
        }
        
        if(
count($data['gallery']->getMedias()) > 0)
            
$data['medias'] = $data['gallery']->getMedias();
        else
            
$data['medias'] = array();
        
        
$data['sid'] = $this->params['sid'];
        
$data['gid'] = $data['gallery']->gid;
        
        
$this->view()->render('/admin_site_header'$data);
    }
    
    public function 
adminPlaceHeaderImage(){
        
$data self::init();
        
        
$place Doo::db()->find('Place', array('where'=>'pid = '.$this->params['pid']));
        
$place $place[0];
        
        if(isset(
$_POST['submit']) && isset($_POST['header']) && (is_numeric($_POST['header']) || $_POST['header'] == 'nopic') && is_numeric($this->params['pid'])) {
            if(
$_POST['header'] == 'nopic')
                
$place->header null;
            else
                
$place->header $_POST['header'];
                
            
$place->update(array('setnulls'=>true));
        }
        
        if(isset(
$this->params['gid'])) {
            
$gallery Doo::db()->find('Gallery', array('where'=>'gid = '.$this->params['gid']));
            
$gallery $gallery[0];
            
$data['gallery'] = $gallery;
        }
        elseif(
is_numeric($place->header)) {
            
$gallery Doo::db()->find('Gallery', array('where'=>'gid IN (SELECT gid from media_gallery WHERE mid = '.$place->header.')'));
            
$gallery $gallery[0];
            
$data['gallery'] = $gallery;
        }
        else {
            
$data['galleries'] = $data['site']->getGalleries();
            
$data['gallery'] = $data['galleries'][0];
        }
        
        if(
count($data['gallery']->getMedias()) > 0)
            
$data['medias'] = $data['gallery']->getMedias();
        else
            
$data['medias'] = array();
        
        
$data['pid'] = $this->params['pid'];
        
$data['gid'] = $data['gallery']->gid;
        
$data['place'] = $place;
        
        
$this->view()->render('/admin_place_header'$data);
    }
    
    public function 
adminArticles(){
        
$data self::init();
        
        
$data['articles'] = $data['site']->getArticles(99'aid DESC');
        
$this->view()->render('/admin_article'$data);
    }
    
    public function 
adminArticleEdit(){
        
$data self::init();
    
        if(
is_numeric($this->params['aid'])) {
            
$article Doo::db()->find('Article', array('where'=>'aid = '.$this->params['aid'], 'desc'=>'rev'));
            
$article $article[0];
            
            if(isset(
$_POST['submit']) && isset($_POST['title']) && isset($_POST['url'])) {
                
$article->title $_POST['title'];
                
$article->teaser $_POST['teaser'];
                
$article->url $_POST['url'];
                
$article->html $_POST['html'];
                
$article->addition $_POST['addition'];
                
                if(
strlen($_POST['maps_lat']) > 2)
                    
$article->maps_lat $_POST['maps_lat'];
                else 
                    
$article->maps_lat null;
                if(
strlen($_POST['maps_lon']) > 2)
                    
$article->maps_lon $_POST['maps_lon'];
                else 
                    
$article->maps_lon null;
                if(
strlen($_POST['maps_zoom']) > && is_numeric($_POST['maps_zoom']))
                    
$article->maps_zoom $_POST['maps_zoom'];
                else
                    
$article->maps_zoom null;
                
$article->maps_type $_POST['maps_type'];
                
                
// places
                
$map Doo::db()->find('ArticlePlaces', array('where'=>'aid = '.$this->params['aid']));
                if(
count($map) > 0) {
                    foreach(
$map as $ap)
                        
Doo::db()->delete($ap);
                }
                
                foreach(
$_POST['places'] as $pid) {
                    
$newp Doo::loadModel('ArticlePlaces'true);
                    
$newp->aid $article->aid;
                    
$newp->pid $pid;
                    
$newp->insert();
                }
                
                
// galleries
                
$map Doo::db()->find('ArticleGallery', array('where'=>'aid = '.$this->params['aid']));
                if(
count($map) > 0) {
                    foreach(
$map as $ag)
                        
Doo::db()->delete($ag);
                }
                if(isset(
$_POST['galleries'])) {
                    foreach(
$_POST['galleries'] as $gid) {
                        
$newg Doo::loadModel('ArticleGallery'true);
                        
$newg->aid $article->aid;
                        
$newg->gid $gid;
                        
$newg->insert();
                    }
                }
                
                
$article->rev $article->rev 1;
                
$article->date null;
                
                
$article->insert(array('setnulls'=>true));
                
                return 
Doo::conf()->APP_URL.'admin/article';
            }
        }
        elseif(
$this->params['aid'] == 'new') {
            
$article Doo::loadModel('Article'true);
            
            if(isset(
$_POST['submit']) && isset($_POST['title']) && isset($_POST['url'])) {
                
$article->title $_POST['title'];
                
$article->teaser $_POST['teaser'];
                
$article->url $_POST['url'];
                
$article->html $_POST['html'];
                
$article->addition $_POST['addition'];
                
                
$article->maps_lat $_POST['maps_lat'];
                
$article->maps_lon $_POST['maps_lon'];
                
$article->maps_zoom $_POST['maps_zoom'];
                
$article->maps_type $_POST['maps_type'];
                
                
$row Doo::db()->fetchRow("SELECT MAX(aid)+1 AS aid FROM article");
                
$article->aid $row['aid'];
                
$article->rev 0;
                
                
// places
                
foreach($_POST['places'] as $pid) {
                    
$newp Doo::loadModel('ArticlePlaces'true);
                    
$newp->aid $article->aid;
                    
$newp->pid $pid;
                    
$newp->insert();
                }
                
                
// galleries
                
if(isset($_POST['galleries'])) {
                    foreach(
$_POST['galleries'] as $gid) {
                        
$newg Doo::loadModel('ArticleGallery'true);
                        
$newg->aid $article->aid;
                        
$newg->gid $gid;
                        
$newg->insert();
                    }
                }
                
                
$article->insert(array('setnulls'=>true));
                
                return 
Doo::conf()->APP_URL.'admin/article';
            }
        }
    
        
$data['article'] = $article;
        
$this->view()->render('/admin_article_edit'$data);
    }
    
    public function 
adminArticleTeaserImage(){
        
$data self::init();
        
        if(isset(
$_POST['submit']) && isset($_POST['teaser']) && is_numeric($_POST['teaser']) && is_numeric($this->params['aid'])) {
            
$aiArr Doo::db()->find('ArticleImage', array('where'=>'article = '.$this->params['aid'].' AND type = \'teaser\''));
            if(
count($aiArr) > 0) {
                foreach(
$aiArr as $ai)
                    
Doo::db()->delete($ai);
            }
        
            
$ai Doo::loadModel('ArticleImage'true);
            
$ai->article $this->params['aid'];
            
$ai->media $_POST['teaser'];
            
$ai->type 'teaser';
            
$ai->insert();
        }
        
        if(isset(
$this->params['gid'])) {
            
$gallery Doo::db()->find('Gallery', array('where'=>'gid = '.$this->params['gid']));
            
$gallery $gallery[0];
            
$data['gallery'] = $gallery;
        }
        else {
            
$data['galleries'] = $data['site']->getGalleries();
            
$data['gallery'] = $data['galleries'][0];
        }
        
        if(
count($data['gallery']->getMedias()) > 0)
            
$data['medias'] = $data['gallery']->getMedias();
        else
            
$data['medias'] = array();
        
        
$data['aid'] = $this->params['aid'];
        
$data['gid'] = $data['gallery']->gid;
        
        
$this->view()->render('/admin_article_teaser'$data);
    }
    
    public function 
adminArticleHeaderImage(){
        
$data self::init();
        
        if(isset(
$_POST['submit']) && isset($_POST['header']) && count($_POST['header']) >= && is_numeric($this->params['aid'])) {
            
$aiArr Doo::db()->find('ArticleImage', array('where'=>'article = '.$this->params['aid'].' AND type = \'header\''));
            if(
count($aiArr) > 0) {
                foreach(
$aiArr as $ai)
                    
Doo::db()->delete($ai);
            }
        
            foreach(
$_POST['header'] as $header) {
                
$ai Doo::loadModel('ArticleImage'true);
                
$ai->article $this->params['aid'];
                
$ai->media $header;
                
$ai->type 'header';
                
$ai->insert();
            }
        }
        
        if(isset(
$this->params['gid'])) {
            
$gallery Doo::db()->find('Gallery', array('where'=>'gid = '.$this->params['gid']));
            
$gallery $gallery[0];
            
$data['gallery'] = $gallery;
        }
        else {
            
$data['galleries'] = $data['site']->getGalleries();
            
$data['gallery'] = $data['galleries'][0];
        }
        
        if(
count($data['gallery']->getMedias()) > 0)
            
$data['medias'] = $data['gallery']->getMedias();
        else
            
$data['medias'] = array();
        
        
$data['aid'] = $this->params['aid'];
        
$data['gid'] = $data['gallery']->gid;
        
        
$this->view()->render('/admin_article_header'$data);
    }
    
    public function 
adminGalleries(){
        
$data self::init();
        
        if(isset(
$_POST['edit']) && isset($_POST['media']) && is_numeric($_POST['media'])) {
            return 
Doo::conf()->APP_URL.'admin/media/'.$_POST['media'];
        }
        elseif(isset(
$_POST['delete']) && isset($_POST['media']) && is_numeric($_POST['media'])) {
            
// delete image db object and files
            
$media Doo::db()->find('Media', array('where'=>'mid = '.$_POST['media']));
            
$media $media[0];
            
$media->remove();
            
$media->delete();
            
            
// delete gallery links
            
$media Doo::db()->find('MediaGallery', array('where'=>'mid = '.$_POST['media']));
            foreach(
$media as $m)
                
$m->delete();
                
            
// delete article links
            
$media Doo::db()->find('ArticleImage', array('where'=>'media = '.$_POST['media']));
            foreach(
$media as $m)
                
$m->delete();
        }
        elseif(isset(
$_POST['rotate']) && isset($_POST['media']) && is_numeric($_POST['media'])) {
            
$media Doo::db()->find('Media', array('where'=>'mid = '.$_POST['media']));
            
$media $media[0];
            
$media->rotate();
        }
        
        
$data['galleries'] = $data['site']->getGalleries();
        if(isset(
$this->params['gid'])) {
            
$gallery Doo::db()->find('Gallery', array('where'=>'gid = '.$this->params['gid']));
            
$gallery $gallery[0];
            
$data['gallery'] = $gallery;
        }
        elseif(
count($data['galleries']) > 0)
            
$data['gallery'] = $data['galleries'][0];
            
        if(
count($data['galleries']) > && count($data['gallery']->getMedias()) > 0)
            
$data['medias'] = $data['gallery']->getMedias();
        else
            
$data['medias'] = array();
        
        
$this->view()->render('/admin_gallery'$data);
    }
    
    public function 
adminGalleryEdit(){
        
$data self::init();
    
        if(
is_numeric($this->params['gid'])) {
            
$gallery Doo::db()->find('Gallery', array('where'=>'gid = '.$this->params['gid'], 'asc'=>'title'));
            
$gallery $gallery[0];
            
            if(isset(
$_POST['submit']) && isset($_POST['title']) && isset($_POST['url'])) {
                
$gallery->title $_POST['title'];
                
$gallery->text $_POST['text'];
                
$gallery->url $_POST['url'];
                if(
strlen($_POST['maps_lat']) == 0)
                    
$gallery->maps_lat null;
                else
                    
$gallery->maps_lat $_POST['maps_lat'];
                if(
strlen($_POST['maps_lon']) == 0)
                    
$gallery->maps_lon null;
                else
                    
$gallery->maps_lon $_POST['maps_lon'];
                if(
strlen($_POST['maps_zoom']) == 0)
                    
$gallery->maps_zoom null;
                else
                    
$gallery->maps_zoom $_POST['maps_zoom'];
                
$gallery->maps_type $_POST['maps_type'];
                
                
$gallery->update(array('setnulls'=>true));
                return 
Doo::conf()->APP_URL.'admin/gallery/show/'.$gallery->gid;
            }
        }
        elseif(
$this->params['gid'] == 'new') {
            
$gallery Doo::loadModel('Gallery'true);
            
            if(isset(
$_POST['submit']) && isset($_POST['title']) && isset($_POST['url'])) {
                
$gallery->title $_POST['title'];
                
$gallery->text $_POST['text'];
                
$gallery->url $_POST['url'];
                if(
strlen($_POST['maps_lat']) == 0)
                    
$gallery->maps_lat null;
                else
                    
$gallery->maps_lat $_POST['maps_lat'];
                if(
strlen($_POST['maps_lon']) == 0)
                    
$gallery->maps_lon null;
                else
                    
$gallery->maps_lon $_POST['maps_lon'];
                if(
strlen($_POST['maps_zoom']) == 0)
                    
$gallery->maps_zoom null;
                else
                    
$gallery->maps_zoom $_POST['maps_zoom'];
                
$gallery->maps_type $_POST['maps_type'];
                
                
$gid $gallery->insert(array('setnulls'=>true));
                return 
Doo::conf()->APP_URL.'admin/gallery/show/'.$gid;
            }
        }
    
        
$data['gallery'] = $gallery;
        
$this->view()->render('/admin_gallery_edit'$data);
    }
    
    public function 
adminGalleryTeaserImage(){
        
$data self::init();
        
        if(isset(
$_POST['submit']) && isset($_POST['teaser']) && is_numeric($_POST['teaser']) && is_numeric($this->params['gid'])) {
            
$gals Doo::db()->find('Gallery', array('where'=>'gid = '.$this->params['gid']));
            foreach(
$gals as $g) {
                
$g->teaser $_POST['teaser'];
                
$g->update();
            }
        }
        
        if(isset(
$this->params['gid_sel'])) {
            
$gallery Doo::db()->find('Gallery', array('where'=>'gid = '.$this->params['gid_sel']));
            
$gallery $gallery[0];
            
$data['gallery'] = $gallery;
        }
        else {
            
$data['galleries'] = $data['site']->getGalleries();
            
$data['gallery'] = $data['galleries'][0];
        }
        
        if(
count($data['gallery']->getMedias()) > 0)
            
$data['medias'] = $data['gallery']->getMedias();
        else
            
$data['medias'] = array();
        
        
$data['gid'] = $this->params['gid'];
        
$data['gid_sel'] = $data['gallery']->gid;
        
        
$this->view()->render('/admin_gallery_teaser'$data);
    }
    
    public function 
adminMediaUpload(){
        
$data self::init();
                
        if(isset(
$_FILES['file']) && count($_FILES['file']['tmp_name']) > 0) {
            for (
$i 0$i count($_FILES['file']['tmp_name']); $i++) {
                
$arr = array();
                
$arr['name'] = $_FILES['file']['name'][$i];
                
$arr['type'] = $_FILES['file']['type'][$i];
                
$arr['tmp_name'] = $_FILES['file']['tmp_name'][$i];
                
$arr['size'] = $_FILES['file']['size'][$i];
                
$arr['error'] = $_FILES['file']['error'][$i];
                
                if(
stripos($arr['name'], '.jpg') !== false && $arr['type'] == 'image/jpeg') {
                    
$media Doo::loadModel('Media'true);
                    
// upload image
                    
$media->uploadJPEG($arr);
                    
// create image in database
                    
$mid $media->insert(array('setnulls'=>true));
                    
// map image to gallery
                    
$mmap Doo::loadModel('MediaGallery'true);
                    
$mmap->mid $mid;
                    
$mmap->gid $this->params['gid'];
                    
$mmap->insert();
                }
                elseif(
stripos($arr['name'], '.png') !== false && $arr['type'] == 'image/png') {
                    
$media Doo::loadModel('Media'true);
                    
// upload image
                    
$media->uploadPNG($arr);
                    
// create image in database
                    
$mid $media->insert(array('setnulls'=>true));
                    
// map image to gallery
                    
$mmap Doo::loadModel('MediaGallery'true);
                    
$mmap->mid $mid;
                    
$mmap->gid $this->params['gid'];
                    
$mmap->insert();
                }
            }
        }
        
        
        
/*if(isset($_FILES['file']) && stripos($_FILES['file'][0]['name'], '.jpg') !== false && $_FILES['file'][0]['type'] == 'image/jpeg') {
            $media->uploadJPEG($_FILES['file']);
        }
        elseif(isset($_FILES['file']) && stripos($_FILES['file']['name'], '.mp4') !== false && $_FILES['file']['type'] == 'video/mp4') {
            //$media->uploadMP4($_FILES['file']);
        }
        else {
            return;
        }*/
        
        
        
        /*$exifdata = exif_read_data($_FILES['file']['tmp_name'],"",true,false);
        var_dump($exifdata);*/
        
return Doo::conf()->APP_URL.'admin/gallery/show/'.$this->params['gid'];
    }
    
    public function 
adminVideoUpload(){
        
$data self::init();
        
        
$media Doo::loadModel('Media'true);
        
        if(isset(
$_POST['submit'])) {
            
            
$media->text $_POST['text'];
            
            if((isset(
$_FILES['file_1']) && $_FILES['file_1']['type'] == 'video/mp4') || 
               (isset(
$_FILES['file_2']) && $_FILES['file_2']['type'] == 'video/mp4') || 
               (isset(
$_FILES['file_3']) && $_FILES['file_3']['type'] == 'video/mp4')) {
                
$media->type 'video/mp4';
                
$mid $media->insert(array('setnulls'=>true));
                
$media->uploadMP4($mid$_FILES);
                
                
$mmap Doo::loadModel('MediaGallery'true);
                
$mmap->mid $mid;
                
$mmap->gid $_POST['gallery'];
                
$mmap->insert();
            }
        }
    
        
$data['media'] = $media;
        
$data['video'] = Doo::loadModel('MediaVideo'true);
        
$data['gid'] = $this->params['gid'];
        
$this->view()->render('/admin_media_videoupload'$data);
    }
    
    public function 
adminVideoTeaserImage(){
        
$data self::init();
        
        if(isset(
$_POST['submit']) && isset($_POST['teaser']) && is_numeric($_POST['teaser']) && is_numeric($this->params['mid'])) {
            
$mvs Doo::db()->find('MediaVideo', array('where'=>'media = '.$this->params['mid']));
            foreach(
$mvs as $mv) {
                
$mv->teaser $_POST['teaser'];
                
$mv->update();
            }
        }
        
        if(isset(
$this->params['gid'])) {
            
$gallery Doo::db()->find('Gallery', array('where'=>'gid = '.$this->params['gid']));
            
$gallery $gallery[0];
            
$data['gallery'] = $gallery;
        }
        else {
            
$data['galleries'] = $data['site']->getGalleries();
            
$data['gallery'] = $data['galleries'][0];
        }
        
        if(
count($data['gallery']->getMedias()) > 0)
            
$data['medias'] = $data['gallery']->getMedias();
        else
            
$data['medias'] = array();
        
        
$data['mid'] = $this->params['mid'];
        
$data['gid'] = $data['gallery']->gid;
        
        
$this->view()->render('/admin_media_videoteaser'$data);
    }
    
    public function 
adminMediaEdit(){
        
$data self::init();
        
        
$media Doo::db()->find('Media', array('where'=>'mid = '.$this->params['mid']));
        if(
count($media) == 1)
            
$data['media'] = $media[0];
        else
            return 
Doo::conf()->APP_URL.'admin/gallery';
        
        if(isset(
$_POST['submit']) && isset($_POST['text'])) {
            
$data['media']->text $_POST['text'];
                
            
$data['media']->update(array('setnulls'=>true));
            
//return Doo::conf()->APP_URL.'admin/gallery/show/'.$gid;
        
}
        
        
$this->view()->render('/admin_media_edit'$data);
    }
    
    public function 
adminTimeline(){
        
$data self::init();
        
        
$data['timelines'] = $data['site']->getTimelines(99'tid DESC');
        
$this->view()->render('/admin_timeline'$data);
    }
    
    public function 
adminTimelineEdit(){
        
$data self::init();
    
        if(
is_numeric($this->params['tid'])) {
            
$timeline Doo::db()->find('Timeline', array('where'=>'tid = '.$this->params['tid']));
            
$timeline $timeline[0];
            
            if(isset(
$_POST['submit']) && isset($_POST['date']) && isset($_POST['text'])) {
                
$timeline->date $_POST['date'];
                
$timeline->text $_POST['text'];
                
$timeline->link $_POST['link'];
                
$timeline->place $_POST['place'];
                
                if(isset(
$_POST['quote']) && $_POST['quote'] == 'Y')
                    
$timeline->quote 'Y';
                elseif(isset(
$_POST['quote']) && $_POST['quote'] == 'P')
                    
$timeline->quote 'P';
                else 
                    
$timeline->quote 'N';
                
                
$timeline->update(array('setnulls'=>true));
                
                return 
Doo::conf()->APP_URL.'admin/timeline';
            }
        }
        elseif(
$this->params['tid'] == 'new') {
            
$timeline Doo::loadModel('Timeline'true);
            
            if(isset(
$_POST['submit']) && isset($_POST['date']) && isset($_POST['text'])) {
                
$timeline->date $_POST['date'];
                
$timeline->text $_POST['text'];
                
$timeline->link $_POST['link'];
                
$timeline->place $_POST['place'];
                
                if(isset(
$_POST['quote']) && $_POST['quote'] == 'Y')
                    
$timeline->quote 'Y';
                elseif(isset(
$_POST['quote']) && $_POST['quote'] == 'P')
                    
$timeline->quote 'P';
                else 
                    
$timeline->quote 'N';
                
                
$timeline->insert(array('setnulls'=>true));
                
                return 
Doo::conf()->APP_URL.'admin/timeline';
            }
        }
    
        
$data['timeline'] = $timeline;
        
$this->view()->render('/admin_timeline_edit'$data);
    }
    
    public function 
test() {
        
$filename Doo::conf()->SITE_PATH.'media/video/P1020235_1080.mp4';
        
        require_once(
Doo::conf()->SITE_PATH.'protected/plugin/getid3/getid3.php');
        
$getID3 = new getID3;
        
$file $getID3->analyze($filename);
        
        
var_dump($file);
        
        
        echo(
"Duration: ".$file['playtime_string'].
        
" / Dimensions: ".$file['video']['resolution_x']." wide by ".$file['video']['resolution_y']." tall".
        
" / Filesize: ".$file['filesize']." bytes<br />");
        
        
    }
    
    
///////////////////////////////////////////////
    
    
public function allurl(){    
        
Doo::loadCore('app/DooSiteMagic');
        
DooSiteMagic::showAllUrl();    
    }
    
    public function 
debug(){
        
Doo::loadCore('app/DooSiteMagic');
        
DooSiteMagic::showDebug($this->params['filename']);
    }
    
    
/*public function gen_sitemap_controller(){
        //This will replace the routes.conf.php file
        Doo::loadCore('app/DooSiteMagic');
        DooSiteMagic::buildSitemap(true);        
        DooSiteMagic::buildSite();
    }
    
    public function gen_sitemap(){
        //This will write a new file,  routes2.conf.php file
        Doo::loadCore('app/DooSiteMagic');
        DooSiteMagic::buildSitemap();        
    }*/
    
    
public function gen_site(){
        
Doo::loadCore('app/DooSiteMagic');
        
DooSiteMagic::buildSite();
    }
    
    public function 
gen_model(){
        
Doo::loadCore('db/DooModelGen');
        
DooModelGen::genMySQL();
    }

}
?>


* Stack Trace...

  1. () calling shutdown()


* Variables...  Conf .  GET  .  POST  .  Session  .  Cookie 


object(DooConfig)#1 (25) {
  
["AUTOLOAD"] => NULL
  
["SITE_PATH"] => string(31"/var/customers/webs/vworld/app/"
  
["PROTECTED_FOLDER"] => string(10"protected/"
  
["BASE_PATH"] => string(40"/var/customers/webs/vworld/dooframework/"
  
["LOG_PATH"] => NULL
  
["APP_URL"] => string(20"http://vthailand.de/"
  
["SUBFOLDER"] => string(1"/"
  
["APP_MODE"] => string(3"dev"
  
["AUTOROUTE"] => bool(false)
  [
"DEBUG_ENABLED"] => bool(true)
  [
"ERROR_404_DOCUMENT"] => NULL
  
["ERROR_404_ROUTE"] => string(6"/error"
  
["CACHE_PATH"] => NULL
  
["AUTO_VIEW_RENDER_PATH"] => string(16"/:place/:article"
  
["MEMCACHE"] => NULL
  
["TEMPLATE_ENGINE"] => string(12"DooViewBasic"
  
["TEMPLATE_SHOW_COMMENT"] => NULL
  
["TEMPLATE_ALLOW_PHP"] => NULL
  
["TEMPLATE_COMPILE_ALWAYS"] => bool(true)
  [
"TEMPLATE_GLOBAL_TAGS"] => NULL
  
["MODULES"] => NULL
  
["APP_NAMESPACE_ID"] => NULL
  
["CHMOD_DEFAULT"] => int(511)
  [
"FROM_CLI"] => bool(false)
  [
"MEDIA_PATH"] => string(37"/var/customers/webs/vworld/app/media/"
}
$_COOKIE Variables array(0) {
}