From adaca5b8b2b5227d79a72f3719ab10d70b78e9b4 Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Tue, 16 Jul 2013 18:42:36 +0300 Subject: [PATCH] Coding standard fixes. Routes: Error page override works now. Welcome controller: Return false where needed. Header-view: lnk-helper function to help highlight current page matching links. ecards-helper: lnk() and checkboxes(), needs commenting. new-view: values for javascript, Image name for dropdown. style.css: better colours, footer links not so prominent, helper classes, moved cursor: move from users without javascript. scripts.js: documentation. --- application/config/constants.php | 18 ++-- application/config/routes.php | 2 +- application/controllers/welcome.php | 2 + application/helpers/ecards_helper.php | 77 ++++++++++++++ application/views/_header.php | 23 ++-- application/views/new.php | 21 ++-- assets/css/style.css | 32 ++++-- assets/js/scripts.js | 7 +- index.php | 144 +++++++++++++------------- 9 files changed, 211 insertions(+), 115 deletions(-) create mode 100644 application/helpers/ecards_helper.php diff --git a/application/config/constants.php b/application/config/constants.php index 37c71bb..d58b401 100644 --- a/application/config/constants.php +++ b/application/config/constants.php @@ -31,14 +31,16 @@ define('DIR_WRITE_MODE', 0777); | */ -define('FOPEN_READ', 'rb'); -define('FOPEN_READ_WRITE', 'r+b'); -define('FOPEN_WRITE_CREATE_DESTRUCTIVE', 'wb'); // truncates existing file data, use with care -define('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE', 'w+b'); // truncates existing file data, use with care -define('FOPEN_WRITE_CREATE', 'ab'); -define('FOPEN_READ_WRITE_CREATE', 'a+b'); -define('FOPEN_WRITE_CREATE_STRICT', 'xb'); -define('FOPEN_READ_WRITE_CREATE_STRICT', 'x+b'); +define('FOPEN_READ', 'rb'); +define('FOPEN_READ_WRITE', 'r+b'); +define('FOPEN_WRITE_CREATE_DESTRUCTIVE', 'wb'); // truncates existing file data, use with care +define('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE', 'w+b'); // truncates existing file data, use with care +define('FOPEN_WRITE_CREATE', 'ab'); +define('FOPEN_READ_WRITE_CREATE', 'a+b'); +define('FOPEN_WRITE_CREATE_STRICT', 'xb'); +define('FOPEN_READ_WRITE_CREATE_STRICT', 'x+b'); + + /* End of file constants.php */ diff --git a/application/config/routes.php b/application/config/routes.php index f8be699..aa08896 100644 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -46,7 +46,7 @@ if (empty($route)) { } $route['default_controller'] = "welcome"; -$route['404_override'] = 'error404'; +$route['404_override'] = 'welcome/error404'; $route['uusi'] = $route['default_controller']."/newCard"; $route['kaikki'] = $route['default_controller']."/ecards"; diff --git a/application/controllers/welcome.php b/application/controllers/welcome.php index 85b3a6e..8b91950 100644 --- a/application/controllers/welcome.php +++ b/application/controllers/welcome.php @@ -95,6 +95,8 @@ class Welcome extends CI_Controller } + return false; + } } public function upload() diff --git a/application/helpers/ecards_helper.php b/application/helpers/ecards_helper.php new file mode 100644 index 0000000..afb4efe --- /dev/null +++ b/application/helpers/ecards_helper.php @@ -0,0 +1,77 @@ + + * + * @return string Formatted anchor tag with everything needed + */ +function lnk($url = null, $text = null, $match = null, $class = ' active') +{ + // $url should be "controller/action", no need to give full url + $url = site_url($url); + + // Test matching, are we on the page we want to match against? + if (empty($match)) { + $match = current_url(); + } else { + $match = site_url($match); + } + + // Return correctly formatted link + if ($url == $match) { + return '' . $text . ''; + } else { + return '' . $text . ''; + } +} + +function checkboxed( + $name, + $data, + $value, + $label, + $data_id = null, + $disabled = false, + $disabletext = null +) { + $fieldname = null; + $labelname = null; + $string = null; + + $fieldname = 'data['.$data_id.']['.$name.']'; + $labelname = $fieldname .'['. $data .']'; + + $string = '' . $label . ''; + } + + $string .= '>'; + + if (!empty($label)) { + $string = ''; + } + + return $string; +} diff --git a/application/views/_header.php b/application/views/_header.php index 50601d7..8442d25 100644 --- a/application/views/_header.php +++ b/application/views/_header.php @@ -7,14 +7,14 @@ if (empty($page_title)) { } ?> - - + + <?php echo implode(" » ", $page_title); ?> - -