Пример #1
0
 function v_order($url, $name, $field, $order = 'asc', $attr = array())
 {
     //$uri = uri_string();
     //$page = (int)get_var('page');
     //$mods = get_var('mod');
     $act = get_var('act');
     $_order = get_url_var('order');
     $_field = get_url_var('field');
     $url_new = $url;
     $attr_str = '';
     foreach ($attr as $key => $value) {
         $attr_str .= "&{$key}={$value}";
     }
     if ($_order != '') {
         if (strpos('asc', $_order) === false) {
             $order = 'desc';
         } else {
             $order = 'asc';
         }
     } else {
         $order = 'desc';
     }
     if ($_field != '') {
         if ($_field == $field) {
             $order = $_order == 'asc' ? 'desc' : 'asc';
             $url_new .= "?field={$field}&order={$order}" . $attr_str;
             return '<a class="' . $order . '" href="' . base_url() . $url_new . '">' . $name . '</a>';
         } else {
             $url_new .= "?field={$field}&order={$order}" . $attr_str;
             return '<a href="' . base_url() . $url_new . '">' . $name . '</a>';
         }
     } else {
         $url_new .= "?field={$field}&order={$order}" . $attr_str;
         return '<a href="' . base_url() . $url_new . '">' . $name . '</a>';
     }
 }
    if (isset($_GET[$varname])) {
        $var = $_GET[$varname];
    }
    return $var;
}
$operacion = get_url_var('operacion', '');
$json = new stdClass();
switch ($operacion) {
    case "consultarTipodeProducto":
        $json = ObtenerProductos();
        break;
    case "obtenerPublicaciones":
        $idProducto = get_url_var('idProducto', '');
        $json = ObtenerPublicacion($idProducto);
        break;
    case "obtenerCategoria":
        $idProducto = get_url_var('idTipo', '');
        $idPublicacion = get_url_var('idPublicacion', '');
        $json = ObtenerCategoria($idProducto, $idPublicacion);
        break;
    case "registrarArticculo":
        session_start('info');
        $idProducto = get_url_var('idTipo', '');
        $idPublicacion = get_url_var('idPublicacion', '');
        $json = ObtenerCategoria($idProducto, $idPublicacion);
        break;
}
if ($json != "") {
    header("Content-Type: application/json charset=utf-8");
    echo json_encode($json);
}