/**
  *this method sets the basic app properties in controller
  *
  *@param null
  *@return \Object $this instance of the controller for the purposes of chaining
  */
 public function set_gliver_fr_controller_trait_properties()
 {
     //set the request_start_time
     $this->request_start_time = Registry::$gliver_app_start;
     //set the site title
     $this->site_title = Registry::getConfig()['title'];
     //return this object instance
     return $this;
 }
예제 #2
0
 /**
  *This method defines the path to views folder
  *
  *@param $name The name of the view file for which to return path
  *@return void
  */
 public static function view($fileName)
 {
     //explode the view files name into array
     $array = explode("/", $fileName);
     if (count($array) == 1) {
         $array = explode('.', $fileName);
     }
     return Registry::getConfig()['root'] . DIRECTORY_SEPARATOR . 'application' . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . join(DIRECTORY_SEPARATOR, $array) . '.glade.php';
 }
예제 #3
0
 /**
  *This method sets the upload file path
  *
  *@param string $dir_name The directory where to upload the file
  *@return \Object $this instance
  */
 public function setUploadpath($dir_name)
 {
     //set the value of upload_path property
     //set the upload path
     if ($dir_name === null) {
         $this->upload_path = Registry::getConfig()['upload_path'];
     } else {
         $this->upload_path = $dir_name;
     }
     return $this;
 }
예제 #4
0
파일: View.php 프로젝트: joycekenya/gliver
 /**
  *This method parses the input variables and loads the specified views
  *
  *@param string $filePath the string that specifies the view file to load
  *@param array $data an array with variables to be passed to the view file
  *@return void This method does not return anything, it directly loads the view file
  *@throws 
  */
 public static function render($filePath, array $data = null)
 {
     //this try block is excecuted to enable throwing and catching of errors as appropriate
     try {
         //get the variables passed and make them available to the view
         if ($data != null) {
             //loop through the array setting the respective variables
             foreach ($data as $key => $value) {
                 ${$key} = $value;
             }
         }
         //compose the file full path
         $path = Path::view($filePath);
         //get an instance of the view template class
         $template = Registry::get('template');
         //get the compiled file contents
         $contents = $template->compiled($path);
         //start the output buffer
         ob_start();
         //evaluate the contents of this view file
         eval("?>" . $contents . "<?");
         //get the evaluated contents
         $contents = ob_get_contents();
         //clean the output buffer
         ob_end_clean();
         //return the evaluated contents
         echo $contents;
         //stop further script execution
         exit;
     } catch (BaseException $e) {
         //echo $e->getMessage();
         $e->show();
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }
예제 #5
0
 /**
  *This method parses the input variables and loads the specified views
  *
  *@param string $filePath the string that specifies the view file to load
  *@param array $data an array with variables to be passed to the view file
  *@return void This method does not return anything, it directly loads the view file
  *@throws 
  */
 public static function render($fileName, array $data = null)
 {
     //this try block is excecuted to enable throwing and catching of errors as appropriate
     try {
         //get the variables passed and make them available to the view
         if ($data != null) {
             //loop through the array setting the respective variables
             foreach ($data as $key => $value) {
                 ${$key} = $value;
             }
         }
         //get the parsed contents of the template file
         $contents = self::getHeaderContent() . self::getContents($fileName, false);
         //write contents to file
         $file_write_path = Registry::getConfig()['root'] . '/bin/tmp/' . md5(Registry::getConfig()['title']);
         file_put_contents($file_write_path, $contents);
         if ($load_view = (include $file_write_path)) {
             unlink($file_write_path);
         }
         //stop further script executions
         exit;
     } catch (HelperException $HelperExceptionObjectInstance) {
         //display the error message
         $HelperException->errorShow();
     }
 }
예제 #6
0
 /**
  * This method returns the url string.
  * @param mixed $linkParams The params to add to the link to generate
  * @return string $url the base url for this application
  * @throws this method does not throw an error
  */
 public static function link($linkParams = null)
 {
     if ($linkParams === null) {
         $link_params = null;
     } elseif (is_array($linkParams)) {
         $link_params = join(Registry::getConfig()['url_component_separator'], $linkParams);
     } else {
         $params = func_get_args();
         $link_params = join(Registry::getConfig()['url_component_separator'], $params);
     }
     //get the server name from global $_SERVER[] array()
     $base = $_SERVER['SERVER_NAME'];
     $url = Registry::getUrl();
     //check if there is a uri string
     if (!empty($url)) {
         //prepend installation folder to server name
         $base .= substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], Registry::getUrl()));
     } else {
         //prepend installation folder to server name
         $base .= substr($_SERVER['REQUEST_URI'], 0);
     }
     //use https if its defined in the $_SERVER global variable
     $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "off" ? "https" : "http";
     //compose the url string
     return $protocol . '://' . $base . $link_params;
 }
예제 #7
0
 /**
  *This method returns a query instance
  *
  *@param null
  *@return object Query instance
  */
 public static function Query()
 {
     static::$connection = Registry::get('database');
     static::$queryObject = static::$connection->query();
     return static::$queryObject;
 }
 /**
  *This method gets and returns the full error message content
  *
  *@param null
  *@return string The error message content
  */
 public function getErrorMessage()
 {
     $backTrace = $this->getTraceAsString();
     $appendPrevious = substr($backTrace, 2, strpos($backTrace, "#4") ? strpos($backTrace, "#4") - 2 : 1000);
     //define and return the error message to show
     $this->errorMessageContent = '<b>' . $this->getMessage() . ' ' . $this->getFile() . '(' . $this->getLine() . ')</b> As seen from ' . $appendPrevious;
     //remove repeated absolute path from the error message
     $this->errorMessageContentToShow = str_replace(array(Registry::getConfig()['root'], '.php'), '', $this->errorMessageContent);
     //define and return the error message to log excluding the the <b> tags
     $this->errorMessageContentToLog = str_replace(array('<b>', '</b>'), '', $this->errorMessageContent);
     //return this object instance
     return $this;
 }
예제 #9
0
 /**
  *This method returns the base url
  *
  *@param null
  *@return string $url the base url for this application
  *@throws this method does not throw an error
  *
  */
 public static function link($fileName)
 {
     //get the server name from global $_SERVER[] array()
     $base = $_SERVER['SERVER_NAME'];
     $url = Registry::getUrl();
     //check if there is a uri string
     if (!empty($url)) {
         //prepend installation folder to server name
         $base .= substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], Registry::getUrl()));
     } else {
         //prepend installation folder to server name
         $base .= substr($_SERVER['REQUEST_URI'], 0);
     }
     //use https if its defined in the $_SERVER global variable
     $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "off" ? "https" : "http";
     //compose the url string
     return $protocol . '://' . $base . $fileName;
 }
예제 #10
0
파일: Url.php 프로젝트: joycekenya/gliver
 /**
  *This method returns the assets url
  *
  *@param string $string the string to use to compose this url
  *@return string $url the full url for this request
  *@throws malformed string
  *
  */
 public static function link($string = null)
 {
     //get the server name from global $_SERVER[] array()
     $base = $_SERVER['SERVER_NAME'];
     //prepend installation folder to server name
     $base .= substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], Registry::getUrl()));
     //use https if its defined in the $_SERVER global variable
     $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "off" ? "https" : "http";
     //compose the url string
     return $protocol . '://' . $base . '<br />';
 }
 /**
  *This model updates a table structure in the database.
  *@param null
  *@return bool true if update structure success
  */
 public static final function updateTable()
 {
     //call the method to update table structure in the database
     return (new MySQLTable(static::$table, get_called_class(), Registry::get('database')))->updateTable();
 }