function admin_plugin_links_run(&$bBlog) { if (isset($_GET['linkdo'])) { $linkdo = $_GET['linkdo']; } elseif (isset($_POST['linkdo'])) { $linkdo = $_POST['linkdo']; } else { $linkdo = ''; } switch ($linkdo) { case "New": // add new link $maxposition = $bBlog->get_var("select position from " . T_LINKS . " order by position desc limit 0,1"); $position = $maxposition + 10; $bBlog->_adb->Execute("insert into " . T_LINKS . "\n set nicename='" . my_addslashes($_POST['nicename']) . "',\n url='" . my_addslashes($_POST['url']) . "',\n category='" . my_addslashes($_POST['category']) . "',\n\t position='{$position}'"); break; case "Delete": // delete link $bBlog->_adb->Execute("delete from " . T_LINKS . " where linkid=" . $_POST['linkid']); break; case "Save": // update an existing link $bBlog->_adb->Execute("update " . T_LINKS . "\n set nicename='" . my_addslashes($_POST['nicename']) . "',\n url='" . my_addslashes($_POST['url']) . "',\n category='" . my_addslashes($_POST['category']) . "'\n where linkid=" . $_POST['linkid']); break; case "Up": $bBlog->_adb->Execute("update " . T_LINKS . " set position=position-15 where linkid=" . $_POST['linkid']); reorder_links(); break; case "Down": $bBlog->_adb->Execute("update " . T_LINKS . " set position=position+15 where linkid=" . $_POST['linkid']); reorder_links(); break; default: // show form break; } if (isset($_GET['catdo'])) { $catdo = $_GET['catdo']; } elseif (isset($_POST['catdo'])) { $catdo = $_POST['catdo']; } else { $catdo = ''; } switch ($catdo) { case "New": // add new category $bBlog->_adb->Execute("insert into " . T_CATEGORIES . "\n set name='" . my_addslashes($_POST['name']) . "'"); break; case "Delete": // delete category // have to remove all references to the category in the links $bBlog->_adb->Execute("update " . T_LINKS . "\n set linkid=0 where linkid=" . $_POST['categoryid']); // delete the category $bBlog->_adb->Execute("delete from " . T_CATEGORIES . " where categoryid=" . $_POST['categoryid']); break; case "Save": // update an existing category $bBlog->_adb->Execute("update " . T_CATEGORIES . "\n set name='" . my_addslashes($_POST['name']) . "'\n where categoryid=" . $_POST['categoryid']); break; default: // show form break; } $rs = $bBlog->_adb->Execute("select * from " . T_CATEGORIES); if ($rs !== false && !$rs->EOF) { $bBlog->assign('ecategories', $rs->GetRows(-1)); } $rs = $bBlog->_adb->Execute("select * from " . T_LINKS . " order by position"); if ($rs !== false && !$rs->EOF) { $bBlog->assign('elinks', $rs->GetRows(-1)); } }
/** * Edit action links */ function phptemplate_links($links, $attributes = array('class' => 'links')) { if ($links) { // Reorder the links however you need them. $links = reorder_links($links, array(), array('comment_reply', 'comment_edit')); // Use the built-in theme_links() function to format the $links array. return theme_links($links, $attributes); } }
function admin_plugin_links_run(&$loq) { if (isset($_GET['linkdo'])) { $linkdo = $_GET['linkdo']; } elseif (isset($_POST['linkdo'])) { $linkdo = $_POST['linkdo']; } else { $linkdo = ''; } $linkdo = strtolower($linkdo); switch ($linkdo) { case "new": $link_name = $_POST['nicename']; $link_url = $_POST['url']; $link_cat = intval($_POST['category']); if (strlen($link_name) > 0 && strlen($link_url) > 0 && $link_cat > 0) { $maxposition = $loq->_adb->GetOne("select MAX(position) from `" . T_LINKS . "`"); $position = $maxposition + 10; $stmt = $loq->_adb->Prepare('INSERT INTO `' . T_LINKS . '` VALUES(null, ?, ?, ?, ?)'); $loq->_adb->Execute($stmt, array($link_name, $link_url, $link_cat, $postition)); } break; case "delete": // delete link $loq->_adb->Execute("delete from " . T_LINKS . " where linkid=" . $_POST['linkid']); break; case "save": // update an existing link $loq->_adb->Execute("update " . T_LINKS . "\n set nicename='" . stringHandler::removeMagicQuotes($_POST['nicename']) . "',\n url='" . stringHandler::removeMagicQuotes($_POST['url']) . "',\n category='" . stringHandler::removeMagicQuotes($_POST['category']) . "'\n where linkid=" . $_POST['linkid']); break; case "up": $loq->_adb->Execute("update " . T_LINKS . " set position=position-15 where linkid=" . $_POST['linkid']); reorder_links(); break; case "down": $loq->_adb->Execute("update " . T_LINKS . " set position=position+15 where linkid=" . $_POST['linkid']); reorder_links(); break; default: // show form break; } if (isset($_GET['catdo'])) { $catdo = $_GET['catdo']; } elseif (isset($_POST['catdo'])) { $catdo = $_POST['catdo']; } else { $catdo = ''; } $catod = strtolower($catdo); switch ($catdo) { case "new": // add new category $cat_name = $_POST['name']; if (strlen($cat_name) > 0) { $stmt = $loq->_adb->Prepare('INSERT INTO `' . T_CATEGORIES . '` VALUES(null, ?)'); $loq->_adb->Execute($stmt, array($cat_name)); } break; case "delete": // delete category // have to remove all references to the category in the links $loq->_adb->Execute("update " . T_LINKS . "\n set linkid=0 where linkid=" . $_POST['categoryid']); // delete the category $loq->_adb->Execute("delete from " . T_CATEGORIES . " where categoryid=" . $_POST['categoryid']); break; case "save": // update an existing category $loq->_adb->Execute("update " . T_CATEGORIES . "\n set name='" . $_POST['name'] . "'\n where categoryid=" . $_POST['categoryid']); break; default: // show form break; } $rs = $loq->_adb->Execute("select * from " . T_CATEGORIES); if ($rs !== false && !$rs->EOF) { $loq->assign('ecategories', $rs->GetRows(-1)); } $rs = $loq->_adb->GetAll("select * from " . T_LINKS . " order by position"); if (is_array($rs)) { $loq->assign('elinks', $rs); } }