Example #1
0
function run()
{
    global $user;
    global $layout;
    global $DB;
    $out = '';
    $item = new menu();
    switch ($_REQUEST['act']) {
        case 'json':
        case 1:
            // json data retrieval & operations
            switch ($_REQUEST['oper']) {
                case 'del':
                    // remove rows
                    $ids = $_REQUEST['ids'];
                    foreach ($ids as $id) {
                        $item->load($id);
                        $item->delete();
                    }
                    echo json_encode(true);
                    break;
                default:
                    // list or search
                    $page = intval($_REQUEST['page']);
                    $max = intval($_REQUEST['rows']);
                    $offset = ($page - 1) * $max;
                    $orderby = $_REQUEST['sidx'] . ' ' . $_REQUEST['sord'];
                    $where = " 1=1 ";
                    if ($_REQUEST['_search'] == 'true' || isset($_REQUEST['quicksearch'])) {
                        if (isset($_REQUEST['quicksearch'])) {
                            $where .= $item->quicksearch($_REQUEST['quicksearch']);
                        } else {
                            if (isset($_REQUEST['filters'])) {
                                $where .= navitable::jqgridsearch($_REQUEST['filters']);
                            } else {
                                // single search
                                $where .= ' AND ' . navitable::jqgridcompare($_REQUEST['searchField'], $_REQUEST['searchOper'], $_REQUEST['searchString']);
                            }
                        }
                    }
                    $DB->queryLimit('id,lid,codename,icon,enabled', 'nv_menus', $where, $orderby, $offset, $max);
                    $dataset = $DB->result();
                    $total = $DB->foundRows();
                    //echo $DB->get_last_error();
                    $out = array();
                    for ($i = 0; $i < count($dataset); $i++) {
                        $out[$i] = array(0 => $dataset[$i]['id'], 1 => $dataset[$i]['codename'], 2 => '<img src="' . NAVIGATE_URL . '/' . $dataset[$i]['icon'] . '" />', 3 => '[' . $dataset[$i]['lid'] . '] ' . t($dataset[$i]['lid'], $dataset[$i]['lid']), 4 => $dataset[$i]['enabled'] == 1 ? '<img src="img/icons/silk/accept.png" />' : '<img src="img/icons/silk/cancel.png" />');
                    }
                    navitable::jqgridJson($out, $page, $offset, $max, $total);
                    break;
            }
            session_write_close();
            exit;
            break;
        case 'edit':
        case 2:
            // edit/new form
            if (!empty($_REQUEST['id'])) {
                $item->load(intval($_REQUEST['id']));
            }
            if (isset($_REQUEST['form-sent'])) {
                $item->load_from_post();
                try {
                    $item->save();
                    $layout->navigate_notification(t(53, "Data saved successfully."), false, false, 'fa fa-check');
                } catch (Exception $e) {
                    $layout->navigate_notification($e->getMessage(), true, true);
                }
            }
            $out = functions_form($item);
            break;
        case 'delete':
        case 4:
            // remove
            if (!empty($_REQUEST['id'])) {
                $item->load(intval($_REQUEST['id']));
                if ($item->delete() > 0) {
                    $layout->navigate_notification(t(55, 'Item removed successfully.'), false);
                    $out = functions_list();
                } else {
                    $layout->navigate_notification(t(56, 'Unexpected error.'), false);
                    $out = functions_form($item);
                }
            }
            break;
        case 'list':
        case 0:
            // list / search result
        // list / search result
        default:
            $out = functions_list();
            break;
    }
    return $out;
}
Example #2
0
function plug_codeview($dr, $f, $fc = '')
{
    if ($dr == 'param') {
        $dr = $f = '';
    }
    require_once 'params/_connectx.php';
    if (!$f && $fc) {
        $f = sql_b('select page from _sys where name="' . $fc . '"', 'v');
    }
    if (strpos($f, '.') === false && $f) {
        $f .= '.php';
    }
    if ($fc == 'all') {
        $fc = '';
    }
    $ret .= lj('', 'codeview_plugin___codeview_' . $dr . '_' . $f . '_' . ajx($fc), picto('reload')) . ' ';
    if ($dr == 'save') {
        $_GET['sav'] = 1;
        $dr = $_SESSION['dr'];
        $dr == 'plug' ? savefunc_plug() : savefunc();
    } else {
        $_GET['sav'] = 0;
    }
    //if($dr=='all')$dr='';
    $dr = $dr ? $dr : 'progb';
    $_SESSION['dr'] = $dr;
    $_SESSION['file'] = $f;
    $_SESSION['func'] = $fc;
    if ($dr != 'params') {
        list($rep, $res) = functions_list($dr, $f);
    }
    if (auth(6)) {
        $ret .= btn('nbp', cv_btn('progb', $dr) . cv_btn('plug', $dr) . (auth(5) ? cv_btn('save', $dr) : '')) . ' ';
    }
    //cv_btn('all',$dr).
    $nbfunc = count($_SESSION['rec']);
    if (!$nbfunc) {
        $nbfunc = rse('COUNT(id)', '_sys');
    }
    $ret .= bal('small', $nbfunc . ' functions') . ' ';
    $jp = ajx(substrpos($f, '.'));
    //list
    if ($rep) {
        ksort($rep);
        array_unshift($rep, '...');
    } else {
        $rep[] = '...';
    }
    $ret .= slct_sj($rep, $f, 'codeview_plugin__15_codeview_' . ajx($dr) . '_');
    //page
    if ($f && auth(6)) {
        $ret .= lj('', 'popup_plupin___codev_' . $dr . '_' . $jp, picto('editxt')) . ' ';
        if ($dr == 'plug') {
            $ret .= lj('', 'popup_plupin___' . $jp, picto('window')) . ' ';
        }
    }
    //list
    $rec = array_values($_SESSION['rec']);
    array_unshift($rec, 'all');
    //if($rec)ksort($rec);
    if ($f) {
        $ret .= slct_sj($rec, $fc, 'codeview_plugin__15_codeview_' . ajx($dr) . '_' . ajx($f) . '_');
    }
    //func
    if ($fc && auth(6)) {
        $ret .= lj('', 'popup_plupin___codev_' . $dr . '_' . $jp . '_' . ajx($fc), picto('editxt')) . ' ';
        if ($dr == 'plug') {
            $ret .= lj('', 'popup_plup___' . $jp . '_' . ajx($fc), picto('window')) . ' ';
        }
    }
    //search
    $ret .= input1('funcsrch', $fc, 8) . ' ' . lj('popbt', 'popup_plup___codeview_findfunc___funcsrch', 'find') . ' ' . lj('popbt', 'popup_plup___coremap_coremap___funcsrch', 'map');
    if ($dr != 'save_all') {
        return divd('codeview', $rea . $ret . $res);
    }
}
Example #3
0
File: dev.php Project: philum/cms
function func_menus($s)
{
    //echo $s;
    if ($s) {
        list($d, $p, $f) = explode('|', $s);
    }
    if ($d) {
        $_SESSION['crdir'] = $d;
    }
    if ($p) {
        $vw = $d . '/' . $p . '.php';
    } else {
        $vw = $d;
    }
    list($rep, $res) = functions_list($vw, $f);
    $cs1 = $cs2 = $cs3 = 'txtx';
    $rec = $_SESSION['rec'];
    $nb = count($rec);
    if ($p && $nb > 1) {
        $cs3 = 'popsav';
    } elseif ($d) {
        $cs2 = 'popsav';
    } else {
        $cs1 = 'popsav';
    }
    $ret .= lj($cs1, 'funcmenu_plug___dev_func*menus', 'dirs', 0) . ' ';
    if ($d) {
        $ret .= lj($cs2, 'funcmenu_plug___dev_func*menus_' . $d, $d, 0) . ' ';
    }
    //pages
    if ($p) {
        $ret .= lj($cs3, 'funcmenu_plug___dev_func*menus_' . $d . '|' . $p, $p, 0) . ' ';
    }
    //funcs
    if ($p && $nb > 1) {
        $ret .= funcmenu_fnc($rec, $d, $p);
    } elseif ($d) {
        $ret .= funcmenu_pag($rep, $d, $p);
    } else {
        $ret .= funcmenu_dir(array('progb', 'plug', 'msql', 'js'), $d);
    }
    return divd('funcmenu', $ret);
}