/
E_USER_WARNING => array( 1, 'Warning Message', ''), |
E_STRICT => array( 2, 'Strict Mode Error', ''), |
E_NOTICE => array( 2, 'Runtime Message', ''), |
'MYSQL' . 1451 => 'Fout bij verwijderen item omdat er nog gerelateerde records zijn. Verwijder deze eerst.' |
); |
E_USER_WARNING => array( 1, 'Warning Message', ''), |
E_STRICT => array( 2, 'Strict Mode Error', ''), |
E_NOTICE => array( 2, 'Runtime Message', ''), |
'MYSQL' . 1451 => 'Failed to remove item because related items exist. Remove them first.' |
); |
|
abstract class JA_Model { |
public $db = null; |
private $filters = array(); |
|
function __construct(){ |
# make sure the database class is available in all models |
$this->db = new JA_Database(); |
} |
|
/** |
* Set filter values |
* |
* @param string name to filter by |
* @param string value to filter by |
*/ |
public function filter($sql){ |
$this->filters[] = $sql; |
return $this; |
} |
|
/** |
* General filter set |
* |
*/ |
public function __call($name = null, $arguments = array()){ |
if(count($arguments)){ |
$this->filter($name . ' = ' . $this->db->Quote($arguments[0])); |
} |
return $this; |
} |
|
/** |
* Return filters in an SQL fashion to be used in a query |
* |
*/ |
public function get_filter(){ |
return $this->filters; |
} |
|
/** |
* Empty filters that are active at this moment |
*/ |
public function clear_filters(){ |
$this->filters = array(); |
} |
} |
|
?> |
* @return html |
*/ |
function boolean($name, $state = 0, $value_1 = 'html.yes', $value_0 = 'html.no', $html = ''){ |
return '<input type="radio" class="' . self::$class . '" name="' . $name . '" id="' . $name . '0" value="0"' . ($state == 0 ? 'checked="checked"' : '') . $html . ' /><label for="' . $name . '0""> ' . JA::lang($value_0) . '</label>' . |
'<input type="radio" class="' . self::$class . '" name="' . $name . '" id="' . $name . '1" value="1"' . ($state == 1 ? 'checked="checked"' : '') . $html . ' /><label for="' . $name . '1""> ' . JA::lang($value_1) . '</label>'; |
return '<input type="radio" class="' . self::$class . '" name="' . $name . '" id="' . $name . '0" value="0"' . ($state == 0 ? 'checked="checked"' : '') . $html . ' /><label for="' . $name . '0"> ' . JA::lang($value_0) . '</label>' . |
'<input type="radio" class="' . self::$class . '" name="' . $name . '" id="' . $name . '1" value="1"' . ($state == 1 ? 'checked="checked"' : '') . $html . ' /><label for="' . $name . '1"> ' . JA::lang($value_1) . '</label>'; |
} |
|
/** |
$html .= '<option value="' . $sel_value . '">' . JA::lang($sel_text) . '</option>'; |
} |
foreach ($options AS $opt){ |
$html .= '<option value="' . $opt->$value . '"' . (!is_null($selected) && (($opt->$value == $selected) || (is_array($selected) && in_array($opt->$value, $selected))) ? ' selected' : '') . '>'. $opt->$text . '</option>'; |
$html .= '<option value="' . $opt->$value . '"' . (!is_null($selected) && (($opt->$value == $selected) || (is_array($selected) && in_array($opt->$value, $selected))) ? ' selected="selected"' : '') . (isset($opt->attributes) ? ' ' . $opt->attributes : '') . '>'. $opt->$text . '</option>'; |
} |
$html .= '</select>'; |
|
* @param string text |
* @return object |
*/ |
function makeOption($value, $text, $value_name = 'value', $text_name = 'text'){ |
function makeOption($value, $text, $value_name = 'value', $text_name = 'text', $attributes = ''){ |
$obj = new stdClass(); |
$obj->$value_name = $value; |
$obj->$text_name = $text; |
$obj->attributes = $attributes; |
|
return $obj; |
} |
* @param string field name |
* @param string field value |
*/ |
function date($name, $value = ''){ |
function date($name, $value = '', $html = ''){ |
$id = strtolower(preg_replace('/\W/', '', $name)); |
return '<input type="text" class="' . self::$class . ' ja_date_selection" name="' . $name . '" id="ja_date_' . $id . '" value="' . $value . '" size="17" />'; |
return '<input type="text" class="' . self::$class . ' ja_date_selection" name="' . $name . '" id="ja_date_' . $id . '" value="' . $value . '" size="17"' . (!empty($html) ? ' ' . $html : '') . ' />'; |
} |
|
/** |
* @param string field name |
* @param string field value |
*/ |
function textarea($name, $value = '', $rows = 5, $cols = 50){ |
function textarea($name, $value = '', $rows = 5, $cols = 50, $html = ''){ |
$id = strtolower(preg_replace('/\W/', '', $name)); |
return '<textarea class="' . self::$class . '" name="' . $name . '" id="ja_' . $id . '" rows="' . $rows . '" cols="' . $cols . '">' . $value . '</textarea>'; |
return '<textarea class="' . self::$class . '" name="' . $name . '" id="ja_' . $id . '" rows="' . $rows . '" cols="' . $cols . '"' . (!empty($html) ? ' ' . $html : '') . '>' . $value . '</textarea>'; |
} |
|
/** |
if(($file = self::find_file($type, $class, false)) === false){ |
$return = false; |
# see if there are other auto loading functions that can be called to find a file |
if(count(self::$backup['auto_load']) > 0){ |
if(is_array(self::$backup['auto_load']) && count(self::$backup['auto_load']) > 0){ |
foreach (self::$backup['auto_load'] AS $autoload){ |
if($return = call_user_func($autoload, $class)){ |
break; |
if ($method->isProtected() or $method->isPrivate()){ |
throw new ReflectionException('protected controller method'); |
} |
|
# Call the function |
$method->invoke($controller); |
} |
catch (ReflectionException $e){ |
$method = $class->getMethod('__call'); |
$method->invokeArgs($controller, array($task)); |
} |
|
# Call the function |
$method->invoke($controller); |
|
# see if something should be renedered |
if($controller->auto_render && !is_null($controller->view)){ |
echo $controller->view->render(); |
public function __call($name, $arguments){ |
$return = call_user_func_array(array($this->_db, $name), $arguments); |
|
if($this->_db->_errorNum > 0){ |
$error = substr($this->_db->_errorMsg, 0, strpos($this->_db->_errorMsg, 'SQL=')); |
$name = strtolower($name); |
if(in_array($name, array('query', 'loadobject', 'loadobjectlist', 'loadresult', 'loadresultarray')) && $this->_db->_errorNum > 0){ |
$error = JA::lang('errors.MYSQL' . $this->_db->_errorNum); |
$error .= (!empty($error) ? "<br />" : '') . substr($this->_db->_errorMsg, 0, strpos($this->_db->_errorMsg, 'SQL=')); |
throw new JA_Exception('core.query_error', 500, $this->_db->_sql, $error); |
exit; |
} |
function load($id){ |
$row = parent::load($id); |
|
if(!is_null($row)){ |
if($row && !is_null($row)){ |
$vars = get_object_vars($row); |
|
foreach ($vars AS $name => $value){ |
public function __call($name, $arguments){ |
$return = call_user_func_array(array($this->_db, $name), $arguments); |
|
if($this->_db->_errorNum > 0){ |
$error = substr($this->_db->_errorMsg, 0, strpos($this->_db->_errorMsg, 'SQL=')); |
$name = strtolower($name); |
if(in_array($name, array('query', 'loadobject', 'loadobjectlist', 'loadresult', 'loadresultarray')) && $this->_db->_errorNum > 0){ |
$error = JA::lang('errors.MYSQL' . $this->_db->_errorNum); |
$error .= (!empty($error) ? "<br />" : '') . substr($this->_db->_errorMsg, 0, strpos($this->_db->_errorMsg, 'SQL=')); |
throw new JA_Exception('core.query_error', 500, $this->_db->_sql, $error); |
exit; |
} |
<p class="pagination"> |
<?php |
if ($previous_page >= 0){ |
echo '<a href="' . $url . '&offset=' . ($previous_page * $items_per_page) . '">« ' . JA::lang('pages.previous') . '</a> '; |
} else { |
echo '« ' . JA::lang('pages.previous') . ' '; |
} |
|
<?php if ($previous_page >= 0): ?> |
<a href="<?php echo $url . '&offset=' . ($previous_page * $items_per_page) ?>">« <?php echo JA::lang('pages.previous') ?></a> |
<?php else: ?> |
« <?php echo JA::lang('pages.previous') ?> |
<?php endif ?> |
if ($total_pages < 13){ /* Ç Previous 1 2 3 4 5 6 7 8 9 10 11 12 Next È */ |
for ($i = 1; $i <= $total_pages; $i++){ |
if (($i - 1) == $current_page){ |
echo '<strong>' . $i . '</strong> '; |
} else { |
echo '<a href="' . $url . '&offset=' . (($i - 1) * $items_per_page). '">' . $i . '</a> '; |
} |
} |
} elseif ($current_page < 9){ /* Ç Previous 1 2 3 4 5 6 7 8 9 10 É 25 26 Next È */ |
for ($i = 1; $i <= 10; $i++){ |
if (($i - 1) == $current_page){ |
echo '<strong>' . $i . '</strong> '; |
} else { |
echo '<a href="' . $url . '&offset=' . (($i - 1) * $items_per_page) . '">' . $i . '</a> '; |
} |
} |
|
echo '…'; |
echo '<a href="' . $url . '&offset=' . (($total_pages - 2) * $items_per_page) . '">' . ($total_pages - 1) . '</a> '; |
echo '<a href="' . $url . '&offset=' . (($total_pages - 1) * $items_per_page) . '">' . $total_pages . '</a> '; |
} elseif ($current_page > $total_pages - 8){ /* Ç Previous 1 2 É 17 18 19 20 21 22 23 24 25 26 Next È */ |
echo '<a href="' . $url . '&offset=0' . '">1</a> '; |
echo '<a href="' . $url . '&offset=' . $items_per_page . '">2</a> '; |
echo '…'; |
|
<?php if ($total_pages < 13): /* Ç Previous 1 2 3 4 5 6 7 8 9 10 11 12 Next È */ ?> |
for ($i = $total_pages - 9; $i <= $total_pages; $i++){ |
if (($i - 1) == $current_page){ |
echo '<strong>' . $i . '</strong> '; |
} else { |
echo '<a href="' . $url . '&offset=' . (($i - 1) * $items_per_page) . '">' . $i . '</a> '; |
} |
} |
|
<?php for ($i = 1; $i <= $total_pages; $i++): ?> |
<?php if (($i - 1) == $current_page): ?> |
<strong><?php echo $i ?></strong> |
<?php else: ?> |
<a href="<?php echo $url . '&offset=' . (($i - 1) * $items_per_page) ?>"><?php echo $i ?></a> |
<?php endif ?> |
<?php endfor ?> |
} else { /* Ç Previous 1 2 É 5 6 7 8 9 10 11 12 13 14 É 25 26 Next È */ |
echo '<a href="' . $url . '&offset=0' . '">1</a> '; |
echo '<a href="' . $url . '&offset=' . $items_per_page . '">2</a> '; |
echo '…'; |
|
<?php elseif ($current_page < 9): /* Ç Previous 1 2 3 4 5 6 7 8 9 10 É 25 26 Next È */ ?> |
for ($i = $current_page - 5; $i <= $current_page + 5; $i++){ |
if (($i - 1) == $current_page){ |
echo '<strong>' . $i . '</strong> '; |
} else { |
echo '<a href="' . $url . '&offset=' . (($i - 1) * $items_per_page) . '">' . $i . '</a> '; |
} |
} |
|
<?php for ($i = 1; $i <= 10; $i++): ?> |
<?php if (($i - 1) == $current_page): ?> |
<strong><?php echo $i ?></strong> |
<?php else: ?> |
<a href="<?php echo $url . '&offset=' . (($i - 1) * $items_per_page) ?>"><?php echo $i ?></a> |
<?php endif ?> |
<?php endfor ?> |
echo '…'; |
echo '<a href="' . $url . '&offset=' . (($total_pages - 2) * $items_per_page) . '">' . ($total_pages - 1) . '</a> '; |
echo '<a href="' . $url . '&offset=' . (($total_pages - 1) * $items_per_page) . '">' . $total_pages . '</a> '; |
|
… |
<a href="<?php echo $url . '&offset=' . (($total_pages - 2) * $items_per_page) ?>"><?php echo $total_pages - 1 ?></a> |
<a href="<?php echo $url . '&offset=' . (($total_pages - 1) * $items_per_page) ?>"><?php echo $total_pages ?></a> |
|
<?php elseif ($current_page > $total_pages - 8): /* Ç Previous 1 2 É 17 18 19 20 21 22 23 24 25 26 Next È */ ?> |
|
<a href="<?php echo $url . '&offset=0' ?>">1</a> |
<a href="<?php echo $url . '&offset=' . $items_per_page ?>">2</a> |
… |
|
<?php for ($i = $total_pages - 9; $i <= $total_pages; $i++): ?> |
<?php if (($i - 1) == $current_page): ?> |
<strong><?php echo $i ?></strong> |
<?php else: ?> |
<a href="<?php echo $url . '&offset=' . (($i - 1) * $items_per_page) ?>"><?php echo $i ?></a> |
<?php endif ?> |
<?php endfor ?> |
|
<?php else: /* Ç Previous 1 2 É 5 6 7 8 9 10 11 12 13 14 É 25 26 Next È */ ?> |
|
<a href="<?php echo $url . '&offset=0' ?>">1</a> |
<a href="<?php echo $url . '&offset=' . $items_per_page ?>">2</a> |
… |
|
<?php for ($i = $current_page - 5; $i <= $current_page + 5; $i++): ?> |
<?php if (($i - 1) == $current_page): ?> |
<strong><?php echo $i ?></strong> |
<?php else: ?> |
<a href="<?php echo $url . '&offset=' . (($i - 1) * $items_per_page) ?>"><?php echo $i ?></a> |
<?php endif ?> |
<?php endfor ?> |
|
… |
<a href="<?php echo $url . '&offset=' . (($total_pages - 2) * $items_per_page) ?>"><?php echo $total_pages - 1 ?></a> |
<a href="<?php echo $url . '&offset=' . (($total_pages - 1) * $items_per_page) ?>"><?php echo $total_pages ?></a> |
|
<?php endif ?> |
|
|
<?php if ($next_page && $total_pages > 1): ?> |
<a href="<?php echo $url . '&offset=' . ($next_page * $items_per_page) ?>"><?php echo JA::lang('pages.next') ?> »</a> |
<?php else: ?> |
<?php echo JA::lang('pages.next') ?> » |
<?php endif ?> |
|
} |
if ($next_page != $total_pages){ |
echo '<a href="' . $url . '&offset=' . ($next_page * $items_per_page) . '">' . JA::lang('pages.next') . ' »</a> '; |
} else { |
echo JA::lang('pages.next') . ' »'; |
} |
?> |
</p> |
$.tooltip.unique_id++; |
$(this).bind('mouseover', function(e){ |
var offset = $(this).offset(); |
var height = $(this).height(); |
$('#ja_tooltip').css('left', (offset.left + 15) + 'px'); |
$('#ja_tooltip').css('top', (offset.top + 10) + 'px'); |
$('#ja_tooltip').css('top', (offset.top + height) + 'px'); |
|
var heading = $(this).attr('heading'); |
var text = $(this).attr('tooltip'); |
$.jalib = { |
option: '', |
controller: '', |
ajax_request: null, |
document_unload: false, |
init: function(){ |
$.ajaxSetup({error: $.jalib.ajaxError}); |
|
$.ajaxSetup({cache: false, error: $.jalib.ajaxError, beforeSend: $.jalib.ajaxBeforeSend, complete: $.jalib.ajaxComplete}); |
// neatly cancel ajax request, and don't display error message if one navigates away |
if(window.onbeforeunload){ var window_onbeforeunload = window.onbeforeunload; } |
window.onbeforeunload = function() { |
$.jalib.document_unload = true; |
if($.jalib.ajax_request) { $.jalib.ajax_request.abort(); } |
if(window_onbeforeunload) { return window_onbeforeunload(); } |
} |
// init calendar selection stuff |
ja('.ja_date_selection').each(function(){ |
$('#' + this.id).datepicker({ dateFormat: 'yy-mm-dd', showButtonPanel: true, changeMonth: true, changeYear: true, firstDay: 1 }); |
$('#' + this.id).datepicker({yearRange: '-57:+3', dateFormat: 'yy-mm-dd', showButtonPanel: true, changeMonth: true, changeYear: true, firstDay: 1}); |
}); |
}, |
jabutton: function(button){ |
} |
}); |
}, |
ajaxBeforeSend: function(xmlrequest){ |
$.jalib.ajax_request = xmlrequest; |
}, |
ajaxComplete: function(xmlrequest){ |
$.jalib.ajax_request = null; |
}, |
ajaxError: function(xmlrequest, textStatus, error){ |
alert('Error processing xml ajax request:' + "\nType: " + textStatus + (error ? "\nError: " + error : '') + (xmlrequest.responseText ? "\nResponse: " + xmlrequest.responseText : '')); |
if(!$.jalib.document_unload){ |
alert('Error processing xml ajax request:' + "\nType: " + textStatus + (error ? "\nError: " + error : '') + (xmlrequest.responseText ? "\nResponse: " + xmlrequest.responseText : '')); |
} |
} |
} |
jQuery(function(){ $.jalib.init(); }); |