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.

This commit is contained in:
Ismo Vuorinen
2013-07-16 18:42:36 +03:00
parent 4bb689166d
commit adaca5b8b2
9 changed files with 211 additions and 115 deletions

View File

@@ -0,0 +1,77 @@
<?php
/**
* lnk helps return anchor tag with class when current_url() is site_url($match)
*
* @param string $url Your link inside the application, not for outside links
* @param string $text Link text
* @param string $match What url to match against, use like $url
* @param string $class What class should be added if urls match
*
* @author Ismo Vuorinen <ismo.vuorinen@tampere.fi>
*
* @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 '<a class="' . $class . '" href="' . $url . '">' . $text . '</a>';
} else {
return '<a href="'. $url .'">' . $text . '</a>';
}
}
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 = '<input type="radio" '
. 'name="' . $fieldname .'" '
. 'id="' . $labelname . '" '
. 'value="'. $value.'"';
if ($data == $value) {
$string .= ' checked';
}
if (empty($disabletext)) {
$disabletext = 'Ei voida julkaista lähettäjän päätöksestä';
}
if ($disabled) {
$string .= ' disabled';
$label = '<span data-tooltip class="has-tip tip-top" '
. 'data-width="180" title="' . $disabletext . '">' . $label . '</span>';
}
$string .= '>';
if (!empty($label)) {
$string = '<label>' . $string . $label . '</label>';
}
return $string;
}