Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sirupsen committed Feb 13, 2010
1 parent 86363ec commit 747ca4f
Show file tree
Hide file tree
Showing 10 changed files with 136 additions and 137 deletions.
2 changes: 1 addition & 1 deletion application/config/config.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
// Debug mode, showing errors - not logging them, and other
// functions which are good when you are developping in a loca
// functions which are good when you are developping in a local
// environment.
Config::set('debug', true);

Expand Down
1 change: 1 addition & 0 deletions application/controllers/home.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

class Home_Controller extends Controller {
public function index() {
$this->title = "Flimpl - Home";
}
}
1 change: 1 addition & 0 deletions application/errors/404.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- 404 Page -->
<h1>404</h1>
<p>The requested URL: <b><?php echo Url::current()?></b> doesn't exist!</p>
<?php exit;
6 changes: 3 additions & 3 deletions flimpl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,16 @@ def view
# Get readme
def readme
file = "README"
url = "http://github.com/Sirupsen/Flimpl-Extras/raw/master/README_FLIMPL.markdown"
Url = "http://github.com/Sirupsen/Flimpl-Extras/raw/master/README_FLIMPL.markdown"

begin
@ext.download(file, url)
@ext.download(file, Url)
rescue RuntimeError
print file + " already exist. Confirm replacing: [Y/N] "
input = $stdin.gets.strip
end

@ext.download(file, url, input)
@ext.download(file, Url, input)
end

def help
Expand Down
1 change: 0 additions & 1 deletion public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
// System path
DEFINE("SYSPATH", $root . '/system' . '/');


// Loading up the bootstrap which prepares our environment
require(SYSPATH . 'core/bootstrap.php');

Expand Down
1 change: 0 additions & 1 deletion system/helpers/html.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,4 @@ public static function anchor($link) {
public static function a($link) {
echo self::anchor($link);
}

}
158 changes: 79 additions & 79 deletions system/helpers/valid.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,83 +12,83 @@

class Valid {

/*
*
* Email validation, checks if the email is valid
*
* @parm string $email The email to be validated
* @return bool true|false
*
*/

public static function email($email) {
if(!preg_match ("/^[\w\.-]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]+$/", $email)) {
return false;
}

list($prefix, $domain) = split("@",$email);

if(function_exists("getmxrr") && getmxrr($domain, $mxhosts)) {
return true;
} elseif (@fsockopen($domain, 25, $errno, $errstr, 5)) {
return true;
} else {
return false;
}
}

/*
*
* URL validation, checks if the url passed is valid
*
* @parm string $val The url to check
* @return bool true|false
*
*/

public static function url($val) {
$ereg = "((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)";
if(!eregi($ereg,$val))
return false;

return true;
}

/*
*
* Returns true if not empty
*
* @return bool true|false
*
*/

public static function required($val) {
return (bool) $val;
}

/*
*
* Returns true if the length is between the two
* lengths given in an array
*
* @return bool true|false
*
*/

public static function length($val, array $length) {
$size = strlen($val);
$return = false;

if (count($length) > 1) {
list ($min, $max) = $length;

if ($size >= $min AND $size <= $max) {
$return = true;
}
} else {
$return = ($size === (int) $length[0]);
}

return $return;
}
/*
*
* Email validation, checks if the email is valid
*
* @parm string $email The email to be validated
* @return bool true|false
*
*/

public static function email($email) {
if(!preg_match ("/^[\w\.-]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]+$/", $email)) {
return false;
}

list($prefix, $domain) = split("@",$email);

if(function_exists("getmxrr") && getmxrr($domain, $mxhosts)) {
return true;
} elseif (@fsockopen($domain, 25, $errno, $errstr, 5)) {
return true;
} else {
return false;
}
}

/*
*
* URL validation, checks if the url passed is valid
*
* @parm string $val The url to check
* @return bool true|false
*
*/

public static function url($val) {
$ereg = "((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)";
if(!eregi($ereg,$val))
return false;

return true;
}

/*
*
* Returns true if not empty
*
* @return bool true|false
*
*/

public static function required($val) {
return (bool) $val;
}

/*
*
* Returns true if the length is between the two
* lengths given in an array
*
* @return bool true|false
*
*/

public static function length($val, array $length) {
$size = strlen($val);
$return = false;

if (count($length) > 1) {
list ($min, $max) = $length;

if ($size >= $min AND $size <= $max) {
$return = true;
}
} else {
$return = ($size === (int) $length[0]);
}

return $return;
}
}
100 changes: 50 additions & 50 deletions system/libraries/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,66 +8,66 @@
*/

class Controller {
// Template instance
protected $template;
// Template instance
protected $template;

// Database instance
protected $db;
// Database instance
protected $db;

// Input instance
protected $input;
// Input instance
protected $input;

// Model
protected $model;
// Model
protected $model;

/*
*
* When we instance our controller, load libraries and
* instance the template.
*
* @param string $controller Name of the controller
* @param string $method Name of the method
*
*/
/*
*
* When we instance our controller, load libraries and
* instance the template.
*
* @param string $controller Name of the controller
* @param string $method Name of the method
*
*/

public function __construct($controller, $method) {
// Create the template
$this->template = new Template($controller, $method);
public function __construct($controller, $method) {
// Create the template
$this->template = new Template($controller, $method);

// Get the instance of the database
$this->db = Database::instance();
// Get the instance of the database
$this->db = Database::instance();

// Create/Get the instance of Input, cleans all $_POST data
$this->input = Input::instance();
// Create/Get the instance of Input, cleans all $_POST data
$this->input = Input::instance();

// Model location
$model = APPPATH . 'models/' . $controller . '.php';
// Model location
$model = APPPATH . 'models/' . $controller . '.php';

// Does the model file exist?
if (file_exists($model)) {
$model = $controller . '_Model';
$this->model = new $model;
$this->template->model = $this->model;
}
}
// Does the model file exist?
if (file_exists($model)) {
$model = $controller . '_Model';
$this->model = new $model;
$this->template->model = $this->model;
}
}

/*
*
* Easy way to supply data for the template, instead of:
* $this->template->set('name', 'data');
* We do:
* $this->name = 'data';
*
* @param string $name Name of the value
* @param mixed $data Data
*
*/
/*
*
* Easy way to supply data for the template, instead of:
* $this->template->set('name', 'data');
* We do:
* $this->name = 'data';
*
* @param string $name Name of the value
* @param mixed $data Data
*
*/

public function __set($name, $data) {
$this->template->$name = $data;
}
public function __set($name, $data) {
$this->template->$name = $data;
}

public function __get($name) {
return $this->template->$name;
}
public function __get($name) {
return $this->template->$name;
}
}
1 change: 0 additions & 1 deletion system/libraries/error.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class Error {
public static function load($type) {
if (file_exists(APPPATH . 'errors/' . $type . '.php')) {
require(APPPATH . 'errors/' . $type . '.php');
exit;
} else {
throw new Exception("Not able to find error file for $type");
}
Expand Down
2 changes: 1 addition & 1 deletion system/libraries/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private function getPart($part) {
// If a custom header/bottom for this specific file is found, load it
if (file_exists($view_path . $part . '.' . $this->action . '.php')) {
return $view_path . $part . '.' . $this->action . '.php';
// elseIf a custom header/bottom for this specific controller is found, load it
// elseIf a custom header/bottom for this specific app. is found, load it
} elseif (file_exists($view_path . $part . '.php')) {
return $view_path . $part . '.php';
// Else, load default
Expand Down

0 comments on commit 747ca4f

Please sign in to comment.