Ejemplo n.º 1
0
function actionUrl($action = '', $controller = '', $params = array(), $fullUrl = false)
{
    $p = '';
    $controller = getDefault($controller, $_REQUEST['controller']);
    if (isset($GLOBALS['subcontrollers'][$controller])) {
        $controller = $GLOBALS['subcontrollers'][$controller] . URL_CA_SEPARATOR . $controller;
    }
    $action = getDefault($action, $_REQUEST['action']);
    if (!is_array($params)) {
        $params = stringParamsToArray($params);
    }
    if (sizeof($params) > 0) {
        // prevent cookies from appearing in the server log by accident
        foreach (array('session-key', session_id()) as $k) {
            if (isset($params[$k])) {
                unset($params[$k]);
            }
        }
        $pl = http_build_query($params);
        $p = '?' . $pl;
        $pn = '&' . $pl;
    }
    if ($fullUrl) {
        $base = cfg('service.base');
        if (trim($base) == '') {
            $base = 'http://' . cfg('service/server');
        }
        if (substr($base, -1) != '/') {
            $base .= '/';
        }
    }
    if ($GLOBALS['config']['service']['url_rewrite']) {
        $url = $controller . ($action == 'index' ? '' : URL_CA_SEPARATOR . $action) . $p;
        return $base . $url;
    } else {
        $url = '?' . $controller . ($action == 'index' ? '' : URL_CA_SEPARATOR . $action) . $pn;
        return getDefault($base, './') . $url;
    }
}
Ejemplo n.º 2
0
function DB_GetDatasetMatch($table, $matchOptions, $fillIfEmpty = true, $noMatchOptions = array())
{
    DB_Connect();
    $where = array('1');
    if (!is_array($matchOptions)) {
        $matchOptions = stringParamsToArray($matchOptions);
    }
    foreach ($matchOptions as $k => $v) {
        $where[] = '(' . $k . '="' . DB_Safe($v) . '")';
    }
    foreach ($noMatchOptions as $k => $v) {
        $where[] = '(' . $k . '!="' . DB_Safe($v) . '")';
    }
    $iwhere = implode(' AND ', $where);
    $query = 'SELECT * FROM ' . getTableName($table) . ' WHERE ' . $iwhere;
    $resultDS = DB_GetDatasetWQuery($query);
    if ($fillIfEmpty && sizeof($resultDS) == 0) {
        foreach ($matchOptions as $k => $v) {
            $resultDS[$k] = $v;
        }
    }
    profile_point('DB_GetDatasetMatch(' . $table . ', ' . $iwhere . ')');
    return $resultDS;
}
Ejemplo n.º 3
0
 function add($type, $name = null, $properties = array())
 {
     if ($type == 'param') {
         $this->params[$name] = $properties;
         return $this;
     }
     if (!is_array($properties)) {
         $properties = stringParamsToArray($properties);
     }
     if ($properties['caption'] == '') {
         $properties['caption'] = l10n($name, true);
     }
     if ($properties['caption'] == '') {
         $properties['caption'] = '[' . trim($name) . ']';
     }
     $properties['name'] = $name;
     $properties['type'] = getDefault($type, 'string');
     $elname = md5($name);
     $ectr = 1;
     if ($this->formOptions['placeholders'] == 'auto') {
         $properties['placeholder'] = l10n($name . '.placeholder');
     }
     if (isset($this->elements[$elname])) {
         while (isset($this->elements[$elname . $ectr])) {
             $ectr++;
         }
         $elname = $elname . $ectr;
     }
     if (isset($properties['textoptions'])) {
         foreach (explode(getDefault($properties['textoptions.separator'], ';'), $properties['textoptions']) as $opt) {
             $properties['options'][trim($opt)] = $opt;
         }
     }
     $this->elements[$elname] = $properties;
     return $this;
 }
Ejemplo n.º 4
0
 function getDSMatch($table, $matchOptions, $fillIfEmpty = true, $noMatchOptions = array())
 {
     $where = array('1');
     if (!is_array($matchOptions)) {
         $matchOptions = stringParamsToArray($matchOptions);
     }
     foreach ($matchOptions as $k => $v) {
         $where[] = '(' . $k . '="' . $this->safe($v) . '")';
     }
     foreach ($noMatchOptions as $k => $v) {
         $where[] = '(' . $k . '!="' . $this->safe($v) . '")';
     }
     $iwhere = implode(' AND ', $where);
     $query = 'SELECT * FROM ' . $this->t($table) . ' WHERE ' . $iwhere;
     $resultDS = $this->getDSWithQuery($query);
     if ($fillIfEmpty && sizeof($resultDS) == 0) {
         foreach ($matchOptions as $k => $v) {
             $resultDS[$k] = $v;
         }
     }
     return $resultDS;
 }