function loadApp($appSettingName, $mainApp=false) {
	
		$appInfo = $this->libs->Config->get('SweetFramework', $appSettingName); //get the current app's settings
		
	//	D::show($this->libs->Config->get('SweetFramework'), 'sweet-framework settings');
		
		
		
		foreach($appInfo['paths'] as $k => $v) {
			if(!is_array(self::$paths[$k])) {
				self::$paths[$k] = array();
			}
			//add in the applications folders to the frameworks file loader
			self::$paths[$k][] = '/' . $appInfo['folder'] . '/' . $v .'/';
			//self::$paths[$k][] = join('/', array(LOC, $appInfo['folder'], $v)) .'/'; @todo A/B test these two.
		}
		if($mainApp == true && !defined('APP_FOLDER')) {
			define('APP_NAME', $appInfo['folder']);
			define('APP_FOLDER', LOC . '/' . APP_NAME);
			
			//$this->lib();
			$this->lib(array('Uri', 'Theme', $this->libs->Config->get('site', 'autoload')) );
			
			if(!$this->libs->Theme->set($this->libs->Config->get('site', 'theme'))) {
				D::error('Theme could not be found. Debug: $Config->getSetting(\'Site\', \'defaultTheme\') = ' . $this->libs->Config->get('site', 'defaultTheme'));
			}
			
		}
		return $this;
	}
Esempio n. 2
0
	function set($name) {
		//@todo rename this to just set
		$newPlace = 'app/themes/' . $name;
		D::log(LOC . '/' . $newPlace, 'new Place');
		if(is_dir(LOC . '/' . $newPlace)) {
			if(substr(URL, -1) == '?') {
				T::$url = $this->themeUrl = substr(URL, 0, -1) . $newPlace;
			} else {
				T::$url = $this->themeUrl = URL . $newPlace;
			}
			T::$loc = LOC . '/' . $newPlace;
			//$this->libs->Config->set('site', 'theme', $newPlace);
			return true;
		} else {
			D::error('Theme doesn\'t exist');
		}
	}
Esempio n. 3
0
	function set($name) {
		//@todo rename this to just set
		$newPlace = 'themes/' . $name;
		D::log($name, 'Theme Set');
	//	D::log(URL, 'URL');
		if(is_dir(APP_FOLDER . '/' . $newPlace)) {
			if(defined('URL')) {
				if(substr(URL, -1) == '?') {
					T::$url = $this->themeUrl = substr(URL, 0, -1) . APP_NAME . '/' . $newPlace . '/';
				} else {
					T::$url = $this->themeUrl = URL . APP_NAME . '/' . $newPlace . '/';
				}
			}			
			T::$loc =  $this->themeLoc = APP_FOLDER . '/' . $newPlace;
			//$this->libs->Config->set('site', 'theme', $newPlace);
			return true;
		} else {
			D::error('Theme doesn\'t exist');
		}
	}
Esempio n. 4
0
 function loadController($controller = null)
 {
     if (isset($controller)) {
         $this->contorllerFile = $controller;
     }
     $class = SweetFramework::className($this->contorllerFile);
     if (!SweetFramework::loadFileType('controller', $class)) {
         D::error('No Controller Found');
     }
     $page = $this->loadUrl($class::$urlPattern, $this->count);
     if (is_array(f_last($page))) {
         if (is_array(f_first(f_last($page)))) {
             return $this->loadController(f_first(f_first(f_last($page))), $this->count += 1);
         }
         $page[$this->count] = f_first(f_last($page));
         //D::log($page[$part], 'page o parts');
     }
     D::log($page, 'Initing Controller…');
     $this->controller = new $class();
     //$this->controller->getLibrary('Databases/Query.php');
     /*@todo make "shortcuts" more dynamic */
     //$this->controller->template =& $this->controller->lib->Template;
     if (empty($page[$this->count])) {
         return f_callable(array($this->controller, 'index'));
     } else {
         if (method_exists($class, $page[$this->count])) {
             return f_callable(array($this->controller, $page[$this->count]));
         }
     }
     if (method_exists($class, '__DudeWheresMyCar')) {
         return f_callable(array($this->controller, '__DudeWheresMyCar'));
     }
     return function () {
         header("HTTP/1.0 404 Not Found");
         echo '<h1>404 error</h1>';
         //todo check for some sort of custom 404…
         return false;
     };
 }
Esempio n. 5
0
	function loadController($controller=null) {
		if(isset($controller)) {
			$this->contorllerFile = $controller;
		}
		if(empty($this->contorllerFile)) {
			$this->contorllerFile = $this->lib('Config')->get('site', 'mainController');
		}
		
		$class = SweetFramework::className($this->contorllerFile);
		D::log($class, 'Controller Loaded');
		
		if(!SweetFramework::loadFileType('controller', $this->contorllerFile)) {
			D::error('No Controller Found');
		}
		if(!empty($class::$urlPattern)) {
			$page = $this->loadUrl($class::$urlPattern);
		} else {
			$page = $this->loadUrl(array());
		}
		
		D::log($this->count, 'COUNT');
		D::log($page, 'page');
		
		if(is_array(f_last($page))) {
			if(is_array( f_first(f_last($page)) )) {
				$this->request = f_first($page);
				D::log($this->request, 'Request Reduced');
				if(method_exists($class, 'enRoute')) {
					$class::enRoute();
				}
				return $this->loadController(f_first(f_first(f_last($page))) );
			}
			$page[$this->count] = f_first(f_last($page));
		}
		
		$fpage = f_first($page);
		$this->controller = new $class();
		if(empty($fpage)) {
			return f_callable(array($this->controller, D::log('index', 'Controller Function')));
		} else {
			if(method_exists($class, $fpage)) {
				return f_callable(array($this->controller, D::log($fpage, 'Controller Function')));
			}
		}
		
		//D::show($class, 'controller');
		if(method_exists($class, '__DudeWheresMyCar')) {
			return f_callable(array(
				$this->controller,
				'__DudeWheresMyCar'
			));
		}
		//@todo find a way to check for __DudeWheresMyCar functions higher up the controller tree.
		
		return function() {
			header('HTTP/1.0 404 Not Found');
			echo '<h1>404 error</h1>'; //todo check for some sort of custom 404…
			return false;
		};
	}