Exemplo n.º 1
0
Arquivo: Menu.php Projeto: ssrsfs/blg
 public function update(array $input = null)
 {
     //gimme life!
     //$item = isset($_POST['itemid']) ? new Navigation_Item($_POST['itemid']) : new Navigation_Item();
     $item = isset($_POST['itemid']) && !is_array($_POST['itemid']) ? Model_Nav::Get($_POST['itemid']) : Model_Nav::Create();
     if ($_REQUEST['cmd'] != 'delete' && $_REQUEST['cmd'] != 'name' && $_REQUEST['cmd'] != 'sort') {
         $item->set('pageid', 0);
         switch ($_POST['type']) {
             case 'none':
                 // Heh, these have no extra attributes, so null just about everything.
                 $item->set('label', $_POST['label']);
                 $item->set('url', '');
                 $item->set('onclick', '');
                 $item->set('visibility', 'always');
                 $item->set('method', '');
                 $item->set('target', '');
                 break;
             case 'int':
                 $item->set('label', $_POST['label']);
                 $item->set('pageid', $_POST['pageid']);
                 $item->set('url', '');
                 $item->set('onclick', '');
                 $item->set('visibility', 'permitted');
                 $item->set('method', $_POST['method']);
                 $item->set('target', $_POST['target']);
                 break;
             case 'arbint':
                 $item->set('label', $_POST['label']);
                 $item->set('url', $_POST['url']);
                 $item->set('onclick', '');
                 $item->set('visibility', $_POST['visibility']);
                 $item->set('method', $_POST['method']);
                 $item->set('target', $_POST['target']);
                 break;
             case 'ext':
                 $item->set('label', $_POST['label']);
                 $item->set('url', $_POST['url']);
                 $item->set('onclick', '');
                 $item->set('visibility', $_POST['visibility']);
                 $item->set('method', $_POST['method']);
                 $item->set('target', $_POST['target']);
                 break;
             case 'mailto':
                 $item->set('label', $_POST['label']);
                 $item->set('url', 'mailto:' . $_POST['url']);
                 $item->set('onclick', '');
                 $item->set('visibility', $_POST['visibility']);
                 $item->set('method', '');
                 $item->set('target', '');
                 break;
         }
     }
     switch ($_REQUEST['cmd']) {
         case 'add':
             $item->set('parent', $_POST['parent']);
             $item->set('plugid', $_POST['plugid']);
             $result = Typeframe::Database()->execute('SELECT MAX(sortnum) AS maxsort FROM #__nav WHERE plugid = ' . (int) $_POST['plugid']);
             $max = $result[0];
             $item->set('sortnum', $max['maxsort'] + 1);
             $item->save();
             $msg = " Added";
             break;
         case 'edit':
             $item->save();
             $msg = " Saved";
             break;
         case 'delete':
             $item->delete();
             $msg = " Deleted";
             break;
         case 'name':
             $plug = Model_Plug::Get($_POST['plugid']);
             $plug['name'] = $_POST['name'];
             $plug->save();
             Typeframe::Redirect('Name updated.', Typeframe::CurrentPage()->applicationUri() . '/edit?plugid=' . $_POST['plugid'] . '&parentid=' . (isset($_POST['parentid']) ? $_POST['parentid'] : '0'));
             return;
         case 'sort':
             $sortnum = 1;
             for ($i = 0; $i < count($_POST['itemid']); $i++) {
                 $item = Model_Nav::Get($_POST['itemid'][$i]);
                 $item['parent'] = $_POST['parent'][$i];
                 $item['sortnum'] = $sortnum;
                 $item->save();
                 $sortnum++;
             }
             Typeframe::Redirect('Items sorted.', Typeframe::CurrentPage()->applicationUri() . '/edit?plugid=' . $_POST['plugid'] . '&parentid=' . (isset($_POST['parentid']) ? $_POST['parentid'] : '0'));
             return;
     }
     Typeframe::Redirect('Item' . $msg, Typeframe::CurrentPage()->applicationUri() . '/edit?plugid=' . $_POST['plugid'] . '&parentid=' . (isset($_POST['parentid']) ? $_POST['parentid'] : '0'));
 }
Exemplo n.º 2
0
<?php

// This needs to be able to support retrieving fields from existing items, ie: edit.
if (isset($_POST['type'])) {
    $type = $_POST['type'];
} else {
    $type = 'none';
}
if (isset($_POST['itemid'])) {
    $itemid = (int) $_POST['itemid'];
} else {
    $itemid = 0;
}
// If an itemID was requested, retrieve that information.
if ($itemid) {
    $item = Model_Nav::Get($itemid);
    $item['type'] = $type;
    // Strip mailto: from URL of mailto links for display in admin
    if ($item['type'] == 'mailto') {
        $item['url'] = substr($item['url'], 7);
    }
} else {
    // A few defaults.
    $item = array();
    if ($type != 'mailto' && $type != 'arbint') {
        $item['url'] = 'http://';
    }
    $item['type'] = $type;
}
// Different types may require different data to be populated into the template.
switch ($type) {
Exemplo n.º 3
0
Arquivo: sort.php Projeto: ssrsfs/blg
<?php

// This page is an ajax-only page... sorry
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
    die('Unexpected submission type.');
}
if (!(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest')) {
    die('Unexpected submission type.');
}
if (!isset($_POST['itemid'])) {
    die(json_encode(array('status' => 'ok', 'message' => 'No records provided.')));
}
// prepare('UPDATE #__nav SET sortnum = ? WHERE itemid = ?');
foreach ($_POST['itemid'] as $k => $v) {
    $navitem = Model_Nav::Get($v);
    $navitem->set('sortnum', $k);
    $navitem->save();
}
die(json_encode(array('status' => 'ok', 'message' => 'Updated records')));