auto-format all files; add table-definitions to test-bootstrap file
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -14,14 +14,16 @@
|
||||
* @package Classes
|
||||
*
|
||||
*/
|
||||
|
||||
class htmlform
|
||||
{
|
||||
|
||||
/**
|
||||
* internal tmp-variable to store form
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $_form = '';
|
||||
|
||||
private static $_filename = '';
|
||||
|
||||
public static function genHTMLForm($data = array())
|
||||
@@ -31,46 +33,43 @@ class htmlform
|
||||
|
||||
self::$_form = '';
|
||||
|
||||
foreach($data as $fdata)
|
||||
{
|
||||
foreach ($data as $fdata) {
|
||||
$sections = $fdata['sections'];
|
||||
|
||||
foreach($sections as $section)
|
||||
{
|
||||
foreach ($sections as $section) {
|
||||
/*
|
||||
* here be section title & image
|
||||
*/
|
||||
*/
|
||||
$title = $section['title'];
|
||||
$image = $section['image'];
|
||||
|
||||
if(isset($section['visible']) && $section['visible'] === false)
|
||||
{
|
||||
if (isset($section['visible']) && $section['visible'] === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($section['nobuttons']) || $section['nobuttons'] == false) {
|
||||
if (! isset($section['nobuttons']) || $section['nobuttons'] == false) {
|
||||
eval("self::\$_form .= \"" . getTemplate("misc/form/table_section", "1") . "\";");
|
||||
} else {
|
||||
$nob = true;
|
||||
}
|
||||
|
||||
$nexto = false;
|
||||
foreach($section['fields'] as $fieldname => $fielddata)
|
||||
{
|
||||
if(isset($fielddata['visible']) && $fielddata['visible'] === false)
|
||||
{
|
||||
foreach ($section['fields'] as $fieldname => $fielddata) {
|
||||
if (isset($fielddata['visible']) && $fielddata['visible'] === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($nexto === false || (isset($fielddata['next_to']) && $nexto['field'] != $fielddata['next_to'])) {
|
||||
$label = $fielddata['label'];
|
||||
$desc = (isset($fielddata['desc']) ? $fielddata['desc'] : '');
|
||||
$style = (isset($fielddata['style']) ? ' class="'.$fielddata['style'].'"' : '');
|
||||
$style = (isset($fielddata['style']) ? ' class="' . $fielddata['style'] . '"' : '');
|
||||
$mandatory = self::_getMandatoryFlag($fielddata);
|
||||
$data_field = self::_parseDataField($fieldname, $fielddata);
|
||||
if (isset($fielddata['has_nextto'])) {
|
||||
$nexto = array('field' => $fieldname);
|
||||
$data_field.='{NEXTTOFIELD_'.$fieldname.'}';
|
||||
$nexto = array(
|
||||
'field' => $fieldname
|
||||
);
|
||||
$data_field .= '{NEXTTOFIELD_' . $fieldname . '}';
|
||||
} else {
|
||||
$nexto = false;
|
||||
}
|
||||
@@ -78,12 +77,8 @@ class htmlform
|
||||
} else {
|
||||
$data_field = self::_parseDataField($fieldname, $fielddata);
|
||||
$data_field = str_replace("\t", "", $data_field);
|
||||
$data_field = $fielddata['next_to_prefix'].$data_field;
|
||||
self::$_form = str_replace(
|
||||
'{NEXTTOFIELD_'.$fielddata['next_to'].'}',
|
||||
$data_field,
|
||||
self::$_form
|
||||
);
|
||||
$data_field = $fielddata['next_to_prefix'] . $data_field;
|
||||
self::$_form = str_replace('{NEXTTOFIELD_' . $fielddata['next_to'] . '}', $data_field, self::$_form);
|
||||
$nexto = false;
|
||||
}
|
||||
}
|
||||
@@ -91,7 +86,7 @@ class htmlform
|
||||
}
|
||||
|
||||
// add save/reset buttons at the end of the form
|
||||
if (!$nob) {
|
||||
if (! $nob) {
|
||||
eval("self::\$_form .= \"" . getTemplate("misc/form/table_end", "1") . "\";");
|
||||
}
|
||||
|
||||
@@ -100,41 +95,48 @@ class htmlform
|
||||
|
||||
private static function _parseDataField($fieldname, $data = array())
|
||||
{
|
||||
switch($data['type'])
|
||||
{
|
||||
switch ($data['type']) {
|
||||
case 'text':
|
||||
return self::_textBox($fieldname, $data); break;
|
||||
return self::_textBox($fieldname, $data);
|
||||
break;
|
||||
case 'textul':
|
||||
return self::_textBox($fieldname, $data, 'text', true); break;
|
||||
return self::_textBox($fieldname, $data, 'text', true);
|
||||
break;
|
||||
case 'password':
|
||||
return self::_textBox($fieldname, $data, 'password'); break;
|
||||
return self::_textBox($fieldname, $data, 'password');
|
||||
break;
|
||||
case 'hidden':
|
||||
return self::_textBox($fieldname, $data, 'hidden'); break;
|
||||
return self::_textBox($fieldname, $data, 'hidden');
|
||||
break;
|
||||
case 'yesno':
|
||||
return self::_yesnoBox($data); break;
|
||||
return self::_yesnoBox($data);
|
||||
break;
|
||||
case 'select':
|
||||
return self::_selectBox($fieldname, $data); break;
|
||||
return self::_selectBox($fieldname, $data);
|
||||
break;
|
||||
case 'label':
|
||||
return self::_labelField($data); break;
|
||||
return self::_labelField($data);
|
||||
break;
|
||||
case 'textarea':
|
||||
return self::_textArea($fieldname, $data); break;
|
||||
return self::_textArea($fieldname, $data);
|
||||
break;
|
||||
case 'checkbox':
|
||||
return self::_checkbox($fieldname, $data); break;
|
||||
return self::_checkbox($fieldname, $data);
|
||||
break;
|
||||
case 'file':
|
||||
return self::_file($fieldname, $data); break;
|
||||
return self::_file($fieldname, $data);
|
||||
break;
|
||||
case 'int':
|
||||
return self::_int($fieldname, $data); break;
|
||||
return self::_int($fieldname, $data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static function _getMandatoryFlag($data = array())
|
||||
{
|
||||
if(isset($data['mandatory']))
|
||||
{
|
||||
if (isset($data['mandatory'])) {
|
||||
return ' <span class="red">*</span>';
|
||||
}
|
||||
elseif(isset($data['mandatory_ex']))
|
||||
{
|
||||
} elseif (isset($data['mandatory_ex'])) {
|
||||
return ' <span class="red">**</span>';
|
||||
}
|
||||
return '';
|
||||
@@ -144,14 +146,14 @@ class htmlform
|
||||
{
|
||||
$return = '';
|
||||
$extras = '';
|
||||
if(isset($data['maxlength'])) {
|
||||
$extras .= ' maxlength="'.$data['maxlength'].'"';
|
||||
if (isset($data['maxlength'])) {
|
||||
$extras .= ' maxlength="' . $data['maxlength'] . '"';
|
||||
}
|
||||
if(isset($data['size'])) {
|
||||
$extras .= ' size="'.$data['size'].'"';
|
||||
if (isset($data['size'])) {
|
||||
$extras .= ' size="' . $data['size'] . '"';
|
||||
}
|
||||
if(isset($data['autocomplete'])) {
|
||||
$extras .= ' autocomplete="'.$data['autocomplete'].'"';
|
||||
if (isset($data['autocomplete'])) {
|
||||
$extras .= ' autocomplete="' . $data['autocomplete'] . '"';
|
||||
}
|
||||
|
||||
// add support to save reloaded forms
|
||||
@@ -163,10 +165,9 @@ class htmlform
|
||||
$value = '';
|
||||
}
|
||||
|
||||
$ulfield = ($unlimited == true ? ' '.$data['ul_field'] : '');
|
||||
if(isset($data['display']) && $data['display'] != '')
|
||||
{
|
||||
$ulfield = '<strong>'.$data['display'].'</strong>';
|
||||
$ulfield = ($unlimited == true ? ' ' . $data['ul_field'] : '');
|
||||
if (isset($data['display']) && $data['display'] != '') {
|
||||
$ulfield = '<strong>' . $data['display'] . '</strong>';
|
||||
}
|
||||
|
||||
eval("\$return = \"" . getTemplate("misc/form/input_text", "1") . "\";");
|
||||
@@ -177,11 +178,11 @@ class htmlform
|
||||
{
|
||||
$return = '';
|
||||
$extras = '';
|
||||
if(isset($data['cols'])) {
|
||||
$extras .= ' cols="'.$data['cols'].'"';
|
||||
if (isset($data['cols'])) {
|
||||
$extras .= ' cols="' . $data['cols'] . '"';
|
||||
}
|
||||
if(isset($data['rows'])) {
|
||||
$extras .= ' rows="'.$data['rows'].'"';
|
||||
if (isset($data['rows'])) {
|
||||
$extras .= ' rows="' . $data['rows'] . '"';
|
||||
}
|
||||
|
||||
// add support to save reloaded forms
|
||||
@@ -220,12 +221,10 @@ class htmlform
|
||||
}
|
||||
|
||||
return '<select
|
||||
id="'.$fieldname.'"
|
||||
name="'.$fieldname.'"
|
||||
'.(isset($data['class']) ? ' class="'.$data['class'] .'" ' : '').'
|
||||
>'
|
||||
.$select_var.
|
||||
'</select>';
|
||||
id="' . $fieldname . '"
|
||||
name="' . $fieldname . '"
|
||||
' . (isset($data['class']) ? ' class="' . $data['class'] . '" ' : '') . '
|
||||
>' . $select_var . '</select>';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -233,32 +232,36 @@ class htmlform
|
||||
*
|
||||
* <code>
|
||||
* $data = array(
|
||||
* 'label' => $lng['customer']['email_imap'],
|
||||
* 'type' => 'checkbox',
|
||||
* 'values' => array(
|
||||
* array( 'label' => 'active',
|
||||
* 'value' => '1'
|
||||
* )
|
||||
* ),
|
||||
* 'value' => array('1'),
|
||||
* 'mandatory' => true
|
||||
* )
|
||||
* 'label' => $lng['customer']['email_imap'],
|
||||
* 'type' => 'checkbox',
|
||||
* 'values' => array(
|
||||
* array( 'label' => 'active',
|
||||
* 'value' => '1'
|
||||
* )
|
||||
* ),
|
||||
* 'value' => array('1'),
|
||||
* 'mandatory' => true
|
||||
* )
|
||||
* </code>
|
||||
*
|
||||
* @param string $fieldname contains the fieldname
|
||||
* @param array $data contains the data array
|
||||
* @param string $fieldname
|
||||
* contains the fieldname
|
||||
* @param array $data
|
||||
* contains the data array
|
||||
*/
|
||||
public static function _checkbox($fieldname = '', $data = array()) {
|
||||
public static function _checkbox($fieldname = '', $data = array())
|
||||
{
|
||||
// $data['value'] contains checked items
|
||||
|
||||
$checked = array();
|
||||
if (isset($data['value'])) {
|
||||
$checked = $data['value'];
|
||||
}
|
||||
|
||||
if (isset($_SESSION['requestData'])) {
|
||||
if(isset($_SESSION['requestData'][$fieldname])) {
|
||||
$checked = array($_SESSION['requestData'][$fieldname]);
|
||||
if (isset($_SESSION['requestData'][$fieldname])) {
|
||||
$checked = array(
|
||||
$_SESSION['requestData'][$fieldname]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,12 +274,12 @@ class htmlform
|
||||
|
||||
// will contain the output
|
||||
$output = "";
|
||||
foreach($data['values'] as $val) {
|
||||
foreach ($data['values'] as $val) {
|
||||
$key = $val['label'];
|
||||
// is this box checked?
|
||||
$isChecked = '';
|
||||
if (is_array($checked) && count($checked) > 0) {
|
||||
foreach($checked as $tmp) {
|
||||
foreach ($checked as $tmp) {
|
||||
if ($tmp == $val['value']) {
|
||||
$isChecked = ' checked="checked" ';
|
||||
break;
|
||||
@@ -285,10 +288,10 @@ class htmlform
|
||||
}
|
||||
$output .= '<label>';
|
||||
if (empty($isArray)) {
|
||||
$output .= '<input type="hidden" name="'.$fieldname.'" value="0" />';
|
||||
$output .= '<input type="hidden" name="' . $fieldname . '" value="0" />';
|
||||
}
|
||||
$output .= '<input type="checkbox" name="'.$fieldname.$isArray.'" value="'.$val['value'].'" '.$isChecked.'/>';
|
||||
$output .= $key.'</label>';
|
||||
$output .= '<input type="checkbox" name="' . $fieldname . $isArray . '" value="' . $val['value'] . '" ' . $isChecked . '/>';
|
||||
$output .= $key . '</label>';
|
||||
}
|
||||
|
||||
return $output;
|
||||
@@ -298,8 +301,8 @@ class htmlform
|
||||
{
|
||||
$return = '';
|
||||
$extras = '';
|
||||
if(isset($data['maxlength'])) {
|
||||
$extras .= ' maxlength="'.$data['maxlength'].'"';
|
||||
if (isset($data['maxlength'])) {
|
||||
$extras .= ' maxlength="' . $data['maxlength'] . '"';
|
||||
}
|
||||
|
||||
// add support to save reloaded forms
|
||||
@@ -311,9 +314,8 @@ class htmlform
|
||||
$value = '';
|
||||
}
|
||||
|
||||
if(isset($data['display']) && $data['display'] != '')
|
||||
{
|
||||
$ulfield = '<strong>'.$data['display'].'</strong>';
|
||||
if (isset($data['display']) && $data['display'] != '') {
|
||||
$ulfield = '<strong>' . $data['display'] . '</strong>';
|
||||
}
|
||||
|
||||
eval("\$return = \"" . getTemplate("misc/form/input_file", "1") . "\";");
|
||||
@@ -324,11 +326,11 @@ class htmlform
|
||||
{
|
||||
$return = '';
|
||||
$extras = '';
|
||||
if(isset($data['int_min'])) {
|
||||
$extras .= ' min="'.$data['int_min'].'"';
|
||||
if (isset($data['int_min'])) {
|
||||
$extras .= ' min="' . $data['int_min'] . '"';
|
||||
}
|
||||
if(isset($data['int_max'])) {
|
||||
$extras .= ' max="'.$data['int_max'].'"';
|
||||
if (isset($data['int_max'])) {
|
||||
$extras .= ' max="' . $data['int_max'] . '"';
|
||||
}
|
||||
|
||||
// add support to save reloaded forms
|
||||
|
||||
@@ -15,19 +15,25 @@
|
||||
* @package Panel
|
||||
*
|
||||
*/
|
||||
|
||||
class linker {
|
||||
class linker
|
||||
{
|
||||
|
||||
private $protocol = '';
|
||||
|
||||
private $username = '';
|
||||
|
||||
private $password = '';
|
||||
|
||||
private $hostname = '';
|
||||
|
||||
private $port = 80;
|
||||
|
||||
private $filename = 'index.php';
|
||||
|
||||
private $args = array();
|
||||
|
||||
public function __construct($file = 'index.php', $sessionid = '', $hostname = '', $protocol = '', $port = '', $username = '', $password = '') {
|
||||
public function __construct($file = 'index.php', $sessionid = '', $hostname = '', $protocol = '', $port = '', $username = '', $password = '')
|
||||
{
|
||||
// Set the basic parts of our URL
|
||||
$this->protocol = $protocol;
|
||||
$this->username = $username;
|
||||
@@ -39,40 +45,59 @@ class linker {
|
||||
$this->args['s'] = $sessionid;
|
||||
}
|
||||
|
||||
public function __set($key, $value) {
|
||||
|
||||
public function __set($key, $value)
|
||||
{
|
||||
switch (strtolower($key)) {
|
||||
case 'protocol': $this->protocol = $value; break;
|
||||
case 'username': $this->username = $value; break;
|
||||
case 'password': $this->password = $value; break;
|
||||
case 'hostname': $this->hostname = $value; break;
|
||||
case 'port': $this->port = $value; break;
|
||||
case 'filename': $this->filename = $value; break;
|
||||
default: return false;
|
||||
case 'protocol':
|
||||
$this->protocol = $value;
|
||||
break;
|
||||
case 'username':
|
||||
$this->username = $value;
|
||||
break;
|
||||
case 'password':
|
||||
$this->password = $value;
|
||||
break;
|
||||
case 'hostname':
|
||||
$this->hostname = $value;
|
||||
break;
|
||||
case 'port':
|
||||
$this->port = $value;
|
||||
break;
|
||||
case 'filename':
|
||||
$this->filename = $value;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function add($key, $value) {
|
||||
public function add($key, $value)
|
||||
{
|
||||
// Add a new value to our parameters (overwrite = enabled)
|
||||
$this->args[$key] = $value;
|
||||
}
|
||||
|
||||
public function del($key) {
|
||||
public function del($key)
|
||||
{
|
||||
// If the key exists in our array -> delete it
|
||||
if (isset($this->args[$key])) {
|
||||
unset($this->args[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
public function delAll() {
|
||||
public function delAll()
|
||||
{
|
||||
// Just resetting the array
|
||||
// Until the sessionid can be removed: save it
|
||||
// @TODO: Remove this
|
||||
$this->args = array('s' => $this->args['s']);
|
||||
$this->args = array(
|
||||
's' => $this->args['s']
|
||||
);
|
||||
}
|
||||
|
||||
public function getLink() {
|
||||
public function getLink()
|
||||
{
|
||||
$link = '';
|
||||
|
||||
// Build the basic URL
|
||||
@@ -132,7 +157,7 @@ class linker {
|
||||
// Loop through arguments and add them to the link
|
||||
foreach ($this->args as $key => $value) {
|
||||
// For all but the first argument, prepend "&"
|
||||
if (substr($link, -1) != "?") {
|
||||
if (substr($link, - 1) != "?") {
|
||||
$link .= "&";
|
||||
}
|
||||
|
||||
|
||||
@@ -19,91 +19,113 @@
|
||||
|
||||
/**
|
||||
* Class to manage paging system
|
||||
*
|
||||
* @package Functions
|
||||
*/
|
||||
class paging {
|
||||
class paging
|
||||
{
|
||||
|
||||
/**
|
||||
* Userinfo
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $userinfo = array();
|
||||
|
||||
/**
|
||||
* MySQL-Table
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $table = '';
|
||||
|
||||
/**
|
||||
* Fields with description which should be selectable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $fields = array();
|
||||
|
||||
/**
|
||||
* Entries per page
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $entriesperpage = 0;
|
||||
|
||||
/**
|
||||
* Number of entries of table
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $entries = 0;
|
||||
|
||||
/**
|
||||
* Sortorder, asc or desc
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $sortorder = 'asc';
|
||||
|
||||
/**
|
||||
* Sortfield
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $sortfield = '';
|
||||
|
||||
/**
|
||||
* Searchfield
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $searchfield = '';
|
||||
|
||||
/**
|
||||
* Searchtext
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $searchtext = '';
|
||||
|
||||
/**
|
||||
* Pagenumber
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $pageno = 0;
|
||||
|
||||
/**
|
||||
* Switch natsorting on/off
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $natSorting = false;
|
||||
|
||||
|
||||
private $_limit = 0;
|
||||
|
||||
/**
|
||||
* Class constructor. Loads settings from request or from userdata and saves them to session.
|
||||
*
|
||||
* @param array userinfo
|
||||
* @param string Name of Table
|
||||
* @param array Fields, in format array( 'fieldname_in_mysql' => 'field_caption' )
|
||||
* @param int *deprecated* entries per page
|
||||
* @param bool *deprecated* Switch natsorting on/off (global, affects all calls of sort)
|
||||
* @param int $default_field default sorting-field-index
|
||||
* @param string $default_order default sorting order 'asc' or 'desc'
|
||||
* Class constructor.
|
||||
* Loads settings from request or from userdata and saves them to session.
|
||||
*
|
||||
* @param
|
||||
* array userinfo
|
||||
* @param
|
||||
* string Name of Table
|
||||
* @param
|
||||
* array Fields, in format array( 'fieldname_in_mysql' => 'field_caption' )
|
||||
* @param
|
||||
* int *deprecated* entries per page
|
||||
* @param
|
||||
* bool *deprecated* Switch natsorting on/off (global, affects all calls of sort)
|
||||
* @param int $default_field
|
||||
* default sorting-field-index
|
||||
* @param string $default_order
|
||||
* default sorting order 'asc' or 'desc'
|
||||
*
|
||||
*/
|
||||
public function __construct($userinfo, $table, $fields, $entriesperpage = 0, $natSorting = false, $default_field = 0, $default_order = 'asc', $limit = 0) {
|
||||
public function __construct($userinfo, $table, $fields, $entriesperpage = 0, $natSorting = false, $default_field = 0, $default_order = 'asc', $limit = 0)
|
||||
{
|
||||
|
||||
// entries per page and natsorting-flag are not
|
||||
// passed as parameter anymore, because these are
|
||||
@@ -113,7 +135,7 @@ class paging {
|
||||
|
||||
$this->userinfo = $userinfo;
|
||||
|
||||
if (!is_array($this->userinfo['lastpaging'])) {
|
||||
if (! is_array($this->userinfo['lastpaging'])) {
|
||||
$this->userinfo['lastpaging'] = json_decode($this->userinfo['lastpaging'], true);
|
||||
}
|
||||
|
||||
@@ -124,21 +146,12 @@ class paging {
|
||||
$checklastpaging = (isset($this->userinfo['lastpaging']['table']) && $this->userinfo['lastpaging']['table'] == $this->table);
|
||||
$this->userinfo['lastpaging']['table'] = $this->table;
|
||||
|
||||
if (isset($_REQUEST['sortorder'])
|
||||
&& (strtolower($_REQUEST['sortorder']) == 'desc'
|
||||
|| strtolower($_REQUEST['sortorder']) == 'asc')
|
||||
) {
|
||||
if (isset($_REQUEST['sortorder']) && (strtolower($_REQUEST['sortorder']) == 'desc' || strtolower($_REQUEST['sortorder']) == 'asc')) {
|
||||
$this->sortorder = strtolower($_REQUEST['sortorder']);
|
||||
|
||||
} else {
|
||||
|
||||
if ($checklastpaging
|
||||
&& isset($this->userinfo['lastpaging']['sortorder'])
|
||||
&& (strtolower($this->userinfo['lastpaging']['sortorder']) == 'desc'
|
||||
|| strtolower($this->userinfo['lastpaging']['sortorder']) == 'asc')
|
||||
) {
|
||||
if ($checklastpaging && isset($this->userinfo['lastpaging']['sortorder']) && (strtolower($this->userinfo['lastpaging']['sortorder']) == 'desc' || strtolower($this->userinfo['lastpaging']['sortorder']) == 'asc')) {
|
||||
$this->sortorder = strtolower($this->userinfo['lastpaging']['sortorder']);
|
||||
|
||||
} else {
|
||||
$this->sortorder = $default_order;
|
||||
}
|
||||
@@ -146,15 +159,10 @@ class paging {
|
||||
|
||||
$this->userinfo['lastpaging']['sortorder'] = $this->sortorder;
|
||||
|
||||
if (isset($_REQUEST['sortfield'])
|
||||
&& isset($fields[$_REQUEST['sortfield']])
|
||||
) {
|
||||
if (isset($_REQUEST['sortfield']) && isset($fields[$_REQUEST['sortfield']])) {
|
||||
$this->sortfield = $_REQUEST['sortfield'];
|
||||
} else {
|
||||
if ($checklastpaging
|
||||
&& isset($this->userinfo['lastpaging']['sortfield'])
|
||||
&& isset($fields[$this->userinfo['lastpaging']['sortfield']])
|
||||
) {
|
||||
if ($checklastpaging && isset($this->userinfo['lastpaging']['sortfield']) && isset($fields[$this->userinfo['lastpaging']['sortfield']])) {
|
||||
$this->sortfield = $this->userinfo['lastpaging']['sortfield'];
|
||||
} else {
|
||||
$fieldnames = array_keys($fields);
|
||||
@@ -164,15 +172,10 @@ class paging {
|
||||
|
||||
$this->userinfo['lastpaging']['sortfield'] = $this->sortfield;
|
||||
|
||||
if (isset($_REQUEST['searchfield'])
|
||||
&& isset($fields[$_REQUEST['searchfield']])
|
||||
) {
|
||||
if (isset($_REQUEST['searchfield']) && isset($fields[$_REQUEST['searchfield']])) {
|
||||
$this->searchfield = $_REQUEST['searchfield'];
|
||||
} else {
|
||||
if ($checklastpaging
|
||||
&& isset($this->userinfo['lastpaging']['searchfield'])
|
||||
&& isset($fields[$this->userinfo['lastpaging']['searchfield']])
|
||||
) {
|
||||
if ($checklastpaging && isset($this->userinfo['lastpaging']['searchfield']) && isset($fields[$this->userinfo['lastpaging']['searchfield']])) {
|
||||
$this->searchfield = $this->userinfo['lastpaging']['searchfield'];
|
||||
} else {
|
||||
$fieldnames = array_keys($fields);
|
||||
@@ -182,16 +185,10 @@ class paging {
|
||||
|
||||
$this->userinfo['lastpaging']['searchfield'] = $this->searchfield;
|
||||
|
||||
if (isset($_REQUEST['searchtext'])
|
||||
&& (preg_match('/[-_@\p{L}\p{N}*.]+$/u', $_REQUEST['searchtext'])
|
||||
|| $_REQUEST['searchtext'] === '')
|
||||
) {
|
||||
if (isset($_REQUEST['searchtext']) && (preg_match('/[-_@\p{L}\p{N}*.]+$/u', $_REQUEST['searchtext']) || $_REQUEST['searchtext'] === '')) {
|
||||
$this->searchtext = trim($_REQUEST['searchtext']);
|
||||
} else {
|
||||
if ($checklastpaging
|
||||
&& isset($this->userinfo['lastpaging']['searchtext'])
|
||||
&& preg_match('/[-_@\p{L}\p{N}*.]+$/u', $this->userinfo['lastpaging']['searchtext'])
|
||||
) {
|
||||
if ($checklastpaging && isset($this->userinfo['lastpaging']['searchtext']) && preg_match('/[-_@\p{L}\p{N}*.]+$/u', $this->userinfo['lastpaging']['searchtext'])) {
|
||||
$this->searchtext = $this->userinfo['lastpaging']['searchtext'];
|
||||
} else {
|
||||
$this->searchtext = '';
|
||||
@@ -200,15 +197,10 @@ class paging {
|
||||
|
||||
$this->userinfo['lastpaging']['searchtext'] = $this->searchtext;
|
||||
|
||||
if (isset($_REQUEST['pageno'])
|
||||
&& intval($_REQUEST['pageno']) != 0
|
||||
) {
|
||||
if (isset($_REQUEST['pageno']) && intval($_REQUEST['pageno']) != 0) {
|
||||
$this->pageno = intval($_REQUEST['pageno']);
|
||||
} else {
|
||||
if ($checklastpaging
|
||||
&& isset($this->userinfo['lastpaging']['pageno'])
|
||||
&& intval($this->userinfo['lastpaging']['pageno']) != 0
|
||||
) {
|
||||
if ($checklastpaging && isset($this->userinfo['lastpaging']['pageno']) && intval($this->userinfo['lastpaging']['pageno']) != 0) {
|
||||
$this->pageno = intval($this->userinfo['lastpaging']['pageno']);
|
||||
} else {
|
||||
$this->pageno = 1;
|
||||
@@ -232,17 +224,18 @@ class paging {
|
||||
'adminsession' => $userinfo['adminsession']
|
||||
);
|
||||
\Froxlor\Database\Database::pexecute($upd_stmt, $upd_data);
|
||||
|
||||
|
||||
$this->_limit = $limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets number of entries and adjusts pageno if the number of entries doesn't correspond to the pageno.
|
||||
*
|
||||
* @param int entries
|
||||
* @param
|
||||
* int entries
|
||||
*/
|
||||
public function setEntries($entries) {
|
||||
|
||||
public function setEntries($entries)
|
||||
{
|
||||
$this->entries = $entries;
|
||||
|
||||
if (($this->pageno - 1) * $this->entriesperpage > $this->entries) {
|
||||
@@ -255,10 +248,12 @@ class paging {
|
||||
/**
|
||||
* Checks if a row should be displayed or not, used in loops
|
||||
*
|
||||
* @param int number of row
|
||||
* @param
|
||||
* int number of row
|
||||
* @return bool to display or not to display, that's the question
|
||||
*/
|
||||
public function checkDisplay($count) {
|
||||
public function checkDisplay($count)
|
||||
{
|
||||
$begin = (intval($this->pageno) - 1) * intval($this->entriesperpage);
|
||||
$end = (intval($this->pageno) * intval($this->entriesperpage));
|
||||
return (($count >= $begin && $count < $end) || $this->entriesperpage == 0);
|
||||
@@ -267,10 +262,12 @@ class paging {
|
||||
/**
|
||||
* Returns condition code for sql query
|
||||
*
|
||||
* @param bool should returned condition code start with WHERE (false) or AND (true)?
|
||||
* @param
|
||||
* bool should returned condition code start with WHERE (false) or AND (true)?
|
||||
* @return string the condition code
|
||||
*/
|
||||
public function getSqlWhere($append = false) {
|
||||
public function getSqlWhere($append = false)
|
||||
{
|
||||
if ($this->searchtext != '') {
|
||||
if ($append == true) {
|
||||
$condition = ' AND ';
|
||||
@@ -280,8 +277,8 @@ class paging {
|
||||
|
||||
$searchfield = explode('.', $this->searchfield);
|
||||
foreach ($searchfield as $id => $field) {
|
||||
if (substr($field, -1, 1) != '`') {
|
||||
$field.= '`';
|
||||
if (substr($field, - 1, 1) != '`') {
|
||||
$field .= '`';
|
||||
}
|
||||
|
||||
if ($field{0} != '`') {
|
||||
@@ -292,9 +289,13 @@ class paging {
|
||||
}
|
||||
|
||||
$searchfield = implode('.', $searchfield);
|
||||
|
||||
$ops = array('<', '>', '=');
|
||||
|
||||
|
||||
$ops = array(
|
||||
'<',
|
||||
'>',
|
||||
'='
|
||||
);
|
||||
|
||||
// check if we use an operator or not
|
||||
$useOper = 0;
|
||||
$oper = "=";
|
||||
@@ -302,32 +303,32 @@ class paging {
|
||||
$useOper = 1;
|
||||
$oper = substr($this->searchtext, 0, 1);
|
||||
}
|
||||
|
||||
|
||||
// check for diskspace and whether searchtext is a number
|
||||
// in any other case the logical-operators would make no sense
|
||||
if (strpos($searchfield, 'diskspace') > 0 && is_numeric(substr($this->searchtext, $useOper))) {
|
||||
// anything with diskspace is *1024
|
||||
$searchtext = ((int)substr($this->searchtext, $useOper))*1024;
|
||||
$searchtext = ((int) substr($this->searchtext, $useOper)) * 1024;
|
||||
$useOper = 1;
|
||||
} elseif (strpos($searchfield, 'traffic') > 0 && is_numeric(substr($this->searchtext, $useOper))) {
|
||||
// anything with traffic is *1024*1024
|
||||
$searchtext = ((int)substr($this->searchtext, $useOper))*1024*1024;
|
||||
$searchtext = ((int) substr($this->searchtext, $useOper)) * 1024 * 1024;
|
||||
$useOper = 1;
|
||||
} else {
|
||||
// any other field
|
||||
$searchtext = substr($this->searchtext, $useOper);
|
||||
}
|
||||
|
||||
|
||||
if ($useOper == 1 && is_numeric(substr($this->searchtext, $useOper))) {
|
||||
// now as we use >, < or = we use the given operator and not LIKE
|
||||
$condition.= $searchfield . " ".$oper." " . \Froxlor\Database\Database::quote($searchtext);
|
||||
$condition .= $searchfield . " " . $oper . " " . \Froxlor\Database\Database::quote($searchtext);
|
||||
} else {
|
||||
$searchtext = str_replace('*', '%', $this->searchtext);
|
||||
// append wildcards if user did not enter any
|
||||
if (strpos($searchtext,'%') === false) $searchtext='%'.$searchtext.'%';
|
||||
$condition.= $searchfield . " LIKE " . \Froxlor\Database\Database::quote($searchtext);
|
||||
if (strpos($searchtext, '%') === false)
|
||||
$searchtext = '%' . $searchtext . '%';
|
||||
$condition .= $searchfield . " LIKE " . \Froxlor\Database\Database::quote($searchtext);
|
||||
}
|
||||
|
||||
} else {
|
||||
$condition = '';
|
||||
}
|
||||
@@ -338,15 +339,16 @@ class paging {
|
||||
/**
|
||||
* Returns "order by"-code for sql query
|
||||
*
|
||||
* @param bool Switch natsorting on/off (local, affects just this call)
|
||||
* @param
|
||||
* bool Switch natsorting on/off (local, affects just this call)
|
||||
* @return string the "order by"-code
|
||||
*/
|
||||
public function getSqlOrderBy($natSorting = null) {
|
||||
|
||||
public function getSqlOrderBy($natSorting = null)
|
||||
{
|
||||
$sortfield = explode('.', $this->sortfield);
|
||||
foreach ($sortfield as $id => $field) {
|
||||
if (substr($field, -1, 1) != '`') {
|
||||
$field.= '`';
|
||||
if (substr($field, - 1, 1) != '`') {
|
||||
$field .= '`';
|
||||
}
|
||||
|
||||
if ($field{0} != '`') {
|
||||
@@ -359,9 +361,7 @@ class paging {
|
||||
$sortfield = implode('.', $sortfield);
|
||||
$sortorder = strtoupper($this->sortorder);
|
||||
|
||||
if ($natSorting == true
|
||||
|| ($natSorting === null && $this->natSorting == true)
|
||||
) {
|
||||
if ($natSorting == true || ($natSorting === null && $this->natSorting == true)) {
|
||||
// Acts similar to php's natsort(), found in one comment at http://my.opera.com/cpr/blog/show.dml/160556
|
||||
$sortcode = "ORDER BY CONCAT( IF( ASCII( LEFT( " . $sortfield . ", 5 ) ) > 57,
|
||||
LEFT( " . $sortfield . ", 1 ), 0 ),
|
||||
@@ -381,11 +381,11 @@ class paging {
|
||||
*
|
||||
* @return string always empty
|
||||
*/
|
||||
public function getSqlLimit() {
|
||||
|
||||
public function getSqlLimit()
|
||||
{
|
||||
if ($this->_limit > 0) {
|
||||
$_offset = ($this->pageno - 1) * $this->_limit;
|
||||
return ' LIMIT '.$_offset.','.$this->_limit;
|
||||
return ' LIMIT ' . $_offset . ',' . $this->_limit;
|
||||
}
|
||||
/**
|
||||
* currently not in use
|
||||
@@ -396,22 +396,26 @@ class paging {
|
||||
/**
|
||||
* Returns html code for sorting field
|
||||
*
|
||||
* @param array Language array
|
||||
* @param
|
||||
* array Language array
|
||||
* @return string the html sortcode
|
||||
*/
|
||||
public function getHtmlSortCode($lng, $break = false) {
|
||||
|
||||
public function getHtmlSortCode($lng, $break = false)
|
||||
{
|
||||
$sortcode = '';
|
||||
$fieldoptions = '';
|
||||
$orderoptions = '';
|
||||
|
||||
foreach ($this->fields as $fieldname => $fieldcaption) {
|
||||
$fieldoptions.= makeoption($fieldcaption, $fieldname, $this->sortfield, true, true);
|
||||
$fieldoptions .= makeoption($fieldcaption, $fieldname, $this->sortfield, true, true);
|
||||
}
|
||||
|
||||
$breakorws = ($break ? '<br />' : ' ');
|
||||
foreach (array('asc' => $lng['panel']['ascending'], 'desc' => $lng['panel']['descending']) as $sortordertype => $sortorderdescription) {
|
||||
$orderoptions.= makeoption($sortorderdescription, $sortordertype, $this->sortorder, true, true);
|
||||
foreach (array(
|
||||
'asc' => $lng['panel']['ascending'],
|
||||
'desc' => $lng['panel']['descending']
|
||||
) as $sortordertype => $sortorderdescription) {
|
||||
$orderoptions .= makeoption($sortorderdescription, $sortordertype, $this->sortorder, true, true);
|
||||
}
|
||||
|
||||
eval("\$sortcode =\"" . getTemplate("misc/htmlsortcode", '1') . "\";");
|
||||
@@ -421,17 +425,17 @@ class paging {
|
||||
/**
|
||||
* Returns html code for sorting arrows
|
||||
*
|
||||
* @param string URL to use as base for links
|
||||
* @param string If set, only this field will be returned
|
||||
* @param
|
||||
* string URL to use as base for links
|
||||
* @param
|
||||
* string If set, only this field will be returned
|
||||
* @return mixed An array or a string (if field is set) of html code of arrows
|
||||
*/
|
||||
public function getHtmlArrowCode($baseurl, $field = '') {
|
||||
|
||||
public function getHtmlArrowCode($baseurl, $field = '')
|
||||
{
|
||||
global $theme;
|
||||
|
||||
if ($field != ''
|
||||
&& isset($this->fields[$field])
|
||||
) {
|
||||
if ($field != '' && isset($this->fields[$field])) {
|
||||
$baseurl = htmlspecialchars($baseurl);
|
||||
$fieldname = htmlspecialchars($field);
|
||||
eval("\$arrowcode =\"" . getTemplate("misc/htmlarrowcode", '1') . "\";");
|
||||
@@ -450,16 +454,17 @@ class paging {
|
||||
/**
|
||||
* Returns html code for searching field
|
||||
*
|
||||
* @param array Language array
|
||||
* @param
|
||||
* array Language array
|
||||
* @return string the html searchcode
|
||||
*/
|
||||
public function getHtmlSearchCode($lng) {
|
||||
|
||||
public function getHtmlSearchCode($lng)
|
||||
{
|
||||
$searchcode = '';
|
||||
$fieldoptions = '';
|
||||
$searchtext = htmlspecialchars($this->searchtext);
|
||||
foreach ($this->fields as $fieldname => $fieldcaption) {
|
||||
$fieldoptions.= makeoption($fieldcaption, $fieldname, $this->searchfield, true, true);
|
||||
$fieldoptions .= makeoption($fieldcaption, $fieldname, $this->searchfield, true, true);
|
||||
}
|
||||
eval("\$searchcode =\"" . getTemplate("misc/htmlsearchcode", '1') . "\";");
|
||||
return $searchcode;
|
||||
@@ -468,10 +473,12 @@ class paging {
|
||||
/**
|
||||
* Returns html code for paging
|
||||
*
|
||||
* @param string URL to use as base for links
|
||||
* @param
|
||||
* string URL to use as base for links
|
||||
* @return string the html pagingcode
|
||||
*/
|
||||
public function getHtmlPagingCode($baseurl) {
|
||||
public function getHtmlPagingCode($baseurl)
|
||||
{
|
||||
if ($this->entriesperpage == 0) {
|
||||
return '';
|
||||
} else {
|
||||
@@ -479,7 +486,7 @@ class paging {
|
||||
}
|
||||
|
||||
if ($this->entries % $this->entriesperpage != 0) {
|
||||
$pages++;
|
||||
$pages ++;
|
||||
}
|
||||
|
||||
if ($pages > 1) {
|
||||
@@ -495,14 +502,14 @@ class paging {
|
||||
}
|
||||
|
||||
$pagingcode = '<a href="' . htmlspecialchars($baseurl) . '&pageno=1">«</a> <a href="' . htmlspecialchars($baseurl) . '&pageno=' . ((intval($this->pageno) - 1) == 0 ? '1' : intval($this->pageno) - 1) . '"><</a> ';
|
||||
for ($i = $start;$i <= $stop;$i++) {
|
||||
for ($i = $start; $i <= $stop; $i ++) {
|
||||
if ($i != $this->pageno) {
|
||||
$pagingcode.= ' <a href="' . htmlspecialchars($baseurl) . '&pageno=' . $i . '">' . $i . '</a> ';
|
||||
$pagingcode .= ' <a href="' . htmlspecialchars($baseurl) . '&pageno=' . $i . '">' . $i . '</a> ';
|
||||
} else {
|
||||
$pagingcode.= ' <strong>' . $i . '</strong> ';
|
||||
$pagingcode .= ' <strong>' . $i . '</strong> ';
|
||||
}
|
||||
}
|
||||
$pagingcode.= ' <a href="' . htmlspecialchars($baseurl) . '&pageno=' . ((intval($this->pageno) + 1) > $pages ? $pages : intval($this->pageno) + 1) . '">></a> <a href="' . $baseurl . '&pageno=' . $pages . '">»</a>';
|
||||
$pagingcode .= ' <a href="' . htmlspecialchars($baseurl) . '&pageno=' . ((intval($this->pageno) + 1) > $pages ? $pages : intval($this->pageno) + 1) . '">></a> <a href="' . $baseurl . '&pageno=' . $pages . '">»</a>';
|
||||
} else {
|
||||
$pagingcode = '';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user