private function loadMethodTemplate($file)
 {
     if (file_exists(PATH . "/rif/methodTemplates/" . $file)) {
         return file_get_contents(PATH . "/rif/methodTemplates/" . $file);
     } else {
         rifException::generateGlobalMethodsException(array('message' => $this->lng->__("The requested methodTemplate does not exist.")));
     }
 }
Example #2
0
	public function __construct(rifLng $lng, rifRequest $request, $routes){
		$this->lng = $lng;
		if(!is_array($routes)){
			rifException::configException(array(
				'message'=> $this->lng->__("Invalid routes format")
			));
		}
		$this->validateRoute($this->findRoute($request, $routes), $request);
	}
Example #3
0
 /**
  * [execute description]
  * @param  array
  * @return query
  */
 public function execute(array $pdoQuery)
 {
     try {
         $query = $this->pdo->prepare($pdoQuery["query"]);
         $query->execute($pdoQuery['fields']);
         return $query;
     } catch (PDOException $e) {
         rifException::instanceException(array('message' => $e->getMessage()));
     }
 }
Example #4
0
	public function __call($name, $args) {
    if (is_callable($this->$name)) {
      array_unshift($args, $this);
      return call_user_func_array($this->$name, $args);
    }else{
      rifException::callableException(array(
        'code'=>10,
        'message' => "Undefined method " . $name
      ));
    }
  }
	public function validateResponse($templatePath, $templateFile){
		if(!file_exists($templatePath)){
			rifException::phpResponse(array(
				'message'=> $this->lng->__("The template folder __file__ does not exist.",array("file"=> $templateFile))
			));
		}
		if(!file_exists($templateFile)){
			rifException::phpResponse(array(
				'message'=> $this->lng->__("The template file __file__ does not exist.",array("file"=> $templateFile))
			));
		}
	}
Example #6
0
 public function execute($argv)
 {
     if (php_sapi_name() == 'cli') {
         $shellCommand = $argv[1];
         $reflectionShell = new ReflectionClass($shellCommand);
         $shellAnotations = rifAnotations::getAnnotations($reflectionShell->getDocComment());
         $shell = new $shellCommand();
         $shell->lng = $this->lng;
         unset($argv[0]);
         unset($argv[1]);
         $argv = array_values($argv);
         if (is_array($shellAnotations) && count($shellAnotations)) {
             if (!is_array($shellAnotations['param'])) {
                 $shellParam = explode(" ", $shellAnotations["param"]);
                 if (isset($argv[$shellParam[0]])) {
                     $shell->{$shellParam}[1] = $argv[$shellParam[0]];
                 }
             } else {
                 foreach ($shellAnotations['param'] as $shellParam) {
                     $shellParam = explode(" ", $shellParam);
                     if (isset($argv[$shellParam[0]])) {
                         $shell->{$shellParam}[1] = $argv[$shellParam[0]];
                     }
                 }
             }
         }
         $rifModel = "rifModel";
         if (isset($shell->models) && is_array($shell->models)) {
             foreach ($shell->models as $model) {
                 $shell->{$model} = new $rifModel($this->rifCore->core['config'], new $model());
             }
         }
         if (isset($shell->components) && is_array($shell->components)) {
             foreach ($shell->components as $component) {
                 $shell->{$component} = new $component();
             }
         }
         $shell->run($this->rifCore);
     } else {
         rifException::callableException(array('message' => $this->lng->__("Incorrect command execution")));
     }
 }
Example #7
0
	public function framework(){
		try{
			$rifLng = new rifLng(LANG);
			$config = new rifConfig($rifLng);
			$hooks = new hooks($rifLng);
			$request = new rifRequest($rifLng);

			

			$routing = new rifRouting($rifLng, $request, $config->routes);


			$events = new rifEvent();
			if($routing->hasError()){
				rifException::routingException(array(
					'message'=> $rifLng->__("Routing error : __err__",array("err"=>$routing->getError()))
				));
			}
			$core = new rifCore($config,$rifLng, $routing, $hooks, $events);




			$instance = new rifInstance($core);
			$response = new rifResponse($core, $instance);
		}catch(rifExceptionCallable $e){
			$error = new rifErr($e);
			if(isset($core->core['routing']) && $core->core['routing']->route['response'] === "json"){
				rifException::JsonResponseException(array(
					'message'=> $error->message
				));
			}else{
				print_R($error);
			}
		}
	}
Example #8
0
	/**
	 * [set description]
	 * @param string
	 * @param string
	 */
	public function set($property, $value){
		if(!property_exists($this->model, $property)){
			rifException::modelException(array(
				'message'=> $this->lng->__("Property __prop__ does not exist",array("prop"=>$property))
			));
		}
		if(!isset($this->modelAnotations['properties'][$property]['type'])){
			rifException::modelException(array(
				'message'=> $this->lng->__("Property __prop__ doesn't have a declared type.",array("prop"=>$property))
			));
		}
		$type = $this->modelAnotations['properties'][$property]['type'];

		if($type === "integer" && !is_int((int) $value)){
			rifException::modelException(array(
				'message'=> $this->lng->__("Property __prop__ is not a __type__",array("prop"=>$property,"type"=>$type))
			));
		}else if($type === "double" && !is_double((double) $value)){
			rifException::modelException(array(
				'message'=> $this->lng->__("Property __prop__ is not a __type__",array("prop"=>$property,"type"=>$type))
			));
		}else if($type === "bool" && !is_bool((bool) $value)){
			rifException::modelException(array(
				'message'=> $this->lng->__("Property __prop__ is not a __type__",array("prop"=>$property,"type"=>$type))
			));
		}else if($type === "float" && !is_float((float) $value)){
			rifException::modelException(array(
				'message'=> $this->lng->__("Property __prop__ is not a __type__",array("prop"=>$property,"type"=>$type))
			));
		}else if($type === "string" && !is_string((string) $value)){
			rifException::modelException(array(
				'message'=> $this->lng->__("Property __prop__ is not a __type__",array("prop"=>$property,"type"=>$type))
			));
		}

		$this->model->$property = $value;
	}
Example #9
0
 /**
  * [order description]
  * @param  string
  * @param  string
  * @return string
  */
 public function order($orderField, $orderSort)
 {
     if (!is_string($orderField) || !is_string($orderSort)) {
         rifException::modelException(array('message' => $this->lng->__("Invalid order parameters")));
     }
     $query = "";
     if ($this->firstOrder) {
         $this->firstOrder = false;
         $query .= "ORDER BY ";
     } else {
         $query .= ", ";
     }
     $query .= $orderField . " " . $orderSort . " ";
     return $query;
 }
Example #10
0
	private function loadPlugin($plugin, hooks $hooks){
		$plugin = basename($plugin);
		$pluginObj = null;
		$rifPlugin = "rifPlugin";
		try{
			$pluginReflection = new ReflectionClass($plugin);
			$pluginObj = new $plugin();
			$pluginObj->plugin = new $rifPlugin();
			$pluginObj->plugin->hooks = $hooks;
			$methods = $pluginReflection->getMethods();
			foreach($methods as $method){
				$methodName = $this->getMethodName($method);
				if($methodName === "__hookVar"){
					$pluginObj->$methodName();
				}
			}
		}catch(ReflectionException $e){
			if($e->getCode() === -1){
				rifException::instanceException(array(
					'message' => $this->lng->__("Invalid Plugin __plugin__",array(
						"plugin" => $plugin
					))
				));
			}
		}
	}