added helper files

parent f94b701c
<?php
/**
* Menu helper. Composing menus
*
* @author george popoff <ambulance@etersoft.ru>
*/
/**
* Composes and returns a admin menu as array of items
* @return string
*/
function menu_admin($baseUrl) {
$data['sites'] = "<a href='".$baseUrl."index.php/admins/sites'>Сайты</a>";
$data['users'] = "<a href='".$baseUrl."index.php/admins/users'>Пользователи</a>";
$data['typos'] = "<a href='".$baseUrl."index.php/users/typos'>Опечатки</a>";
$data['logout'] = "<a href='".$baseUrl."index.php/authorized/logout'>Выйти</a>";
return $data;
}
/**
* Composes and returns a user menu as array of items
* @return string
*/
function menu_user($config) {
$data['logout'] = "<a href='".$baseUrl."index.php/authorized/logout'>Выйти</a>";
return $data;
}
<?php
/**
* Search helper functions
*
* @author george popoff <ambulance@etersoft.ru>
*/
/**
* Composes search statement for query string
*
* Example of return " name LIKE %'somewhat'%"
*
* @param type $field
* @param type $operator
* @param type $string Pattern or value
* @return string
*/
function searchString($field, $operator, $string) {
$s = " $field ";
error_log("SEARCH STRING($field, $operator, $string)");
switch ($operator) {
case 'eq':
$s .= "="."'".$string."'";
break;
case 'ne':
$s .= "!="."'".$string."'";
break;
case 'lt':
$s .= "<"."'".$string."'";
break;
case 'le':
$s .= "<="."'".$string."'";
break;
case 'gt':
$s .= ">"."'".$string."'";
break;
case 'ge':
$s .= ">="."'".$string."'";
break;
case 'bw':
$s .= "LIKE '".$string."%'";
break;
case 'bn':
$s .= "NOT LIKE '".$string."%'";
break;
case 'ew':
$s .= "LIKE '%".$string."'";
break;
case 'en':
$s .= "NOT LIKE '%".$string."'";
break;
case 'cn':
$s .= "LIKE '%".$string."%'";
break;
case 'nc':
$s .= "NOT LIKE '%".$string."%'";
break;
case 'nu':
$s .= "IS NULL";
break;
case 'nn':
$s .= "IS NOT NULL";
break;
case 'in':
$s .= "IN ($string)";
break;
case 'ni':
$s .= "NOT IN ($string)";
break;
default:
$s = "";
break;
}
return $s;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment