function getBacklink($id, $type, $category = true) { $db =& JFactory::getDBO(); if (!$category) { $query = "SELECT articleid from #__fieldsattach_values WHERE (value LIKE '%," . $id . ",%' OR value LIKE '" . $id . ",%' OR value LIKE '%," . $id . "' OR value LIKE '" . $id . "') AND fieldsid = 23"; } else { $query = "SELECT catid from #__fieldsattach_categories_values WHERE (value LIKE '%," . $id . ",%' OR value LIKE '" . $id . ",%' OR value LIKE '%," . $id . "' OR value LIKE '" . $id . "') AND fieldsid = 22"; } $db->setQuery($query); $result = $db->loadObjectList(); $function = ''; foreach ($result as $item) { if (!$category) { $parent = getParent(getCategory($item->articleid)); } else { $parent = getParent($item->catid); } if ($parent == $type) { if (!$category) { $function .= '<li><a href="' . ContentHelperRoute::getArticleRoute($item->articleid, $parent) . '">' . getTitle($item->articleid, $category) . '</a></li>'; } else { $function .= '<li><a href="' . ContentHelperRoute::getCategoryRoute($item->catid, $parent) . '">' . getTitle($item->catid, $category) . '</a></li>'; } } } return $function; }
function printCheckboxList($baseArray, $levelMenu = 0, $formName, $preCheckedArray = array(), $subMargin = 10) { foreach (getParent($baseArray, $levelMenu) as $level) { echo '<input ' . isChecked($preCheckedArray, $level->id) . ' style="margin-left: ' . $subMargin . 'px;margin-bottom:7px" type="checkbox" name="' . $formName . '" value="' . $level->id . '">' . ' ' . $level->name . ' <br />'; printCheckboxList($baseArray, $level->id, $formName, $preCheckedArray, $subMargin + 20); } }
function getParentAtLevel($id, $lev = 1) { global $menu_id, $wpdb; $par = $id; for ($z = 0; $z < $lev; $z++) { $par = getParent($par); } return $par; }
function getParent($entity, $entities_map) { $entityParent = $entity; foreach ($entities_map as $k => $e) { if (in_array($entity, $e)) { $entityParent = getParent($k, $entities_map); break; } } return $entityParent; }
function updateStats($tid, $uid, $date, $newThread, $approved) { $fid = getParent($tid); dbquery("UPDATE threads SET posts=posts+{$approved}, " . ($approved == 1 ? "lastpost_uid=:uid, " : "") . "lastpost_date=FROM_UNIXTIME(:date) WHERE tid=:tid;", $approved == 1 ? array("uid" => $uid, "date" => $date, "tid" => $tid) : array("date" => $date, "tid" => $tid)); if ($newThread) { $query = "UPDATE forums SET posts=posts+{$approved}, threads=threads+{$approved}," . ($approved == 1 ? " lastpost_date=FROM_UNIXTIME(:date)" : "") . " WHERE fid=:fid;"; } else { $query = "UPDATE forums SET posts=posts+{$approved}," . ($approved == 1 ? " lastpost_date=FROM_UNIXTIME(:date)" : "") . " WHERE fid=:fid;"; } dbquery($query, $approved == 1 ? array("date" => $date, "fid" => $fid) : array("fid" => $date)); }
function getParent($parent) { global $parents; $query = "SELECT content_parentid FROM tbl_contents WHERE CONTENT_ID = " . $parent; $result = mysql_query($query); while ($row = mysql_fetch_array($result)) { if ($row['content_parentid'] != "") { $parents .= "," . $row['content_parentid']; getParent($row['content_parentid']); } } }
function getParent($category) { global $pole; global $database; // echo "select category_parent from category where category_id='$category' and category_parent!=0"; $set = $database->query("select category_parent from category where category_id='{$category}' and category_parent!=0"); if ($set->next()) { // $set->next(); $pole[] = $set->getString('category_parent'); getParent($set->getString('category_parent')); } }
function buildCAT($catID) { $cat = array(); $tmpID = $catID; while (getParent($catID) != 0 || $catID != 0) { $cat_select = vam_db_query("SELECT categories_name FROM " . TABLE_CATEGORIES_DESCRIPTION . " WHERE categories_id='" . $catID . "' and language_id='" . $_SESSION['languages_id'] . "'"); $cat_data = vam_db_fetch_array($cat_select); $catID = getParent($catID); $cat[] = $cat_data['categories_name']; } $catStr = ''; for ($i = count($cat); $i > 0; $i--) { $catStr .= $cat[$i - 1] . ' > '; } return $catStr; }
function getAncestors($nodeID) { global $globalParents; global $taxonomy; if ($nodeID == 1) { return array(); } //catches root if (isset($globalParents[$nodeID])) { $aBreadCrumb = $globalParents[$nodeID]; $globalParents[$nodeID] = $aBreadCrumb; } else { $iterationID = $nodeID; while ($parent = getParent($iterationID)) { $aBreadCrumb[] = $parent; $iterationID = $parent; } $globalParents[$nodeID] = $aBreadCrumb; } return array_reverse($aBreadCrumb); }
function getParent($cat_id, $parent = "") { $db_host = 'localhost'; $db_username = '******'; $db_password = '******'; $db_name = 'store'; $mysqli = new mysqli($db_host, $db_username, $db_password, $db_name); $sql = "Select * from tbl_group where groupID=?"; $stmt = $mysqli->prepare($sql); $stmt->bind_param("i", $cat_id); //set parameters and execute $groupID = $cat_id; $stmt->execute(); $result = $stmt->get_result(); $row = $result->fetch_assoc(); $parent .= $row['groupName']; if ($row['top'] != 0) { $parent .= ","; $parent .= getParent($row['top'], $parent); } else { echo $parent; return $parent; } }
?> </td> </tr> <tr> <th> Permission Needed: </th><td> <select name='permission'> <?php getPermissions(); ?> </select></td> </tr> <tr> <th> Parent Link: </th><td> <select name='parent'> <?php getParent(); ?> </select>*Only needed if link is a Sub-link </td> </tr> <tr><th>Open In New Tab?</th> <td><input type='checkbox' name='newtab' value="1">*Check if you want the link to always open in a new tab</td></tr> </table> <input type="submit" name="submit" value="Submit" method="post"> </form> </div> <?php } else { echo "<h1>You are not Authorized to View this page</h1>"; } require '../../includes/includeAtEnd.php';
$sendNotificationEmail = $_REQUEST['notify'] == "true"; foreach ($notificationList as $email) { addToNotificationList($parentID == -1 ? $subID : $parentID, $email); } if ($sendNotificationEmail) { sendNotificationEmail($subID, $parentID); } break; case "delete_from_notification_list": $subID = $_REQUEST['submission_id']; // we deal with notification lists at the // parent level. Check if this submission // is not a parent. if (!isParent($subID)) { // not parent, get the parent $subID = getParent($subID); } $email = $_REQUEST['email']; delFromNotificationList($subID, $email); break; } } /*---------------------------------------------------------------*/ // functions /*---------------------------------------------------------------*/ /// /// isParent /// Check to see if the given submission is a parent /// function isParent($subID) {
$res = dbquery("SELECT COUNT(*) FROM threads \n WHERE tid=:tid", array('tid' => $tid)); if ($res->fetchColumn() == 0) { echo "<script>window.location='/';</script>"; die; } if (array_key_exists('delete', $_GET)) { $pid = $_GET['delete']; $res = dbquery("SELECT uid FROM posts WHERE pid=:pid", array('pid' => $pid)); $uid = $res->fetchColumn(); if (allow("mod_delete") || allow("forum_posting") && $_SESSION['user']->uid == $uid) { echo "<script>var r = confirm('Are you sure you want to delete this post?');\n if (r == false) {\n window.location('/?page=thread&tid={$tid}');\n }\n </script>"; deletePost($pid, $tid); } } $title = getTopicTitle($tid); breadcrumbs(getParent($tid), $tid); echo "<div id='thread'>\n <div id='titlebar'>\n <div id='title'>\n <a href='?page=thread&tid={$tid}'><h1>{$title}</h1></a>\n </div>\n <div id='post-button'>\n <div class='buttons'>\n <a href='?page=discussion&tid={$tid}'><button>Post Reply</button></a>\n </div>\n </div>\n \n </div>"; if (allow('mod_approve')) { $res = dbquery("SELECT * FROM posts\n WHERE tid=:tid\n ORDER BY date;", array('tid' => $tid)); } else { $res = dbquery("SELECT * FROM posts\n WHERE tid=:tid AND approved=1\n ORDER BY date;", array('tid' => $tid)); } while ($row = $res->fetch(PDO::FETCH_ASSOC)) { $pid = $row['pid']; $title = $row['title']; $content = nl2br($row['content']); $uid = $row['uid']; $date = date("D, d M Y H:i", strtotime($row['date'])); $user = getUsername($uid); echo "\n <a name='p{$pid}'></a>\n <div class='post'>\n <div class='post-data'>\n <span>Username: <a href='?page=profile&uid={$uid}'>{$user}</a></span>\n <p>Date: {$date}</p>"; if (allow("mod_delete") || allow("forum_posting") && $_SESSION['user']->uid == $uid) {
} } elseif (!(array_key_exists('tid', $_GET) || array_key_exists('fid', $_GET) || array_key_exists('pid', $_GET))) { echo "Forum or thread not defined"; } else { $content = ""; if (array_key_exists('tid', $_GET)) { $tid = $_GET['tid']; $title = "Re: " . getTopicTitle($tid); $fid = getParent($tid); $legend = "New post in {$title}"; $button = "Post"; } elseif (array_key_exists('pid', $_GET)) { $pid = $_GET['pid']; $tid = getThread($pid); $title = getTopicTitle($tid); $fid = getParent($tid); $content = getPost($pid)->content; $legend = "Edit Post"; $button = "Edit"; } else { $title = ""; $tid = ""; $fid = $_GET['fid']; $legend = "New Thread"; $button = "Create Thread"; } ?> <!-- Temporary link to profile, should link to thread page --> <div id="registration"> <form method="POST">
function getMenuPath($cid = 0) { $mid = addslashes($_REQUEST['mid']); if ($cid == 0) { $cid = addslashes($_REQUEST['cid']); } if (!$mid) { $mid = getTopParent($pageLang, $cid); } if ($cid) { $curr = $cid; $link = getLink($curr); if ($link) { $path = "<a href='" . _PREF . "forms/" . getLink($curr) . "'>" . getName($curr) . "</a> " . $path; } else { $path = "<a href='#'>" . getName($curr) . "</a> " . $path; } $curr = getParent($curr); while (getParent($curr) != 0) { $link = getLink($curr); if ($link) { $path = "<a href='" . _PREF . "forms/" . getLink($curr) . "'>" . getName($curr) . "</a> " . $path; } else { $path = "<a href='#'>" . getName($curr) . "</a> " . $path; } $curr = getParent($curr); } } $path = "<a href='" . _PREF . "'>" . Homepage . "</a> " . $path; return $path; }
function getParentList($categoryid) { $cat = true; $c = (int) $categoryid; $firstc = $c; $list = array(); while (true) { $cat = getParent($c); if ($cat === false) { break; } $list[] = $cat; $c = $cat['categoryid']; } $list = array_reverse($list); $list[] = getCategory($firstc); return $list; }
/** * get PAGE parents slugs * returns an array of all this pages parents slugs * @param str $pageId slug of child * @return array array of parents slugs */ function getParentFields($pageId, $key = 'parent') { $pageparents = getPagesFields('parent'); $parentValues = getPagesFields($key); $parent = getParent($pageId); $values = array(); if (empty($parent)) { return array(); } while (isset($pageparents[$parent]) && isset($parentValues[$parent])) { $value = (string) $parentValues[$parent]; $parent = (string) $pageparents[$parent]; if (!empty($value)) { $values[] = $value; } } return $values; }
switch ($operation) { case 'get_node': $rslt = $fs->lst($node, isset($id) && $id === '#'); break; case "get_content": $rslt = $fs->data($node); break; case 'create_node': $rslt = $fs->create($node, getIdText($text), !isset($type) || $type !== 'file'); break; case 'rename_node': $rslt = $fs->rename($node, getIdText($text)); break; case 'delete_node': $rslt = $fs->remove($node); break; case 'move_node': $rslt = $fs->move($node, getParent($parent)); break; case 'copy_node': $rslt = $fs->copy($node, getParent($parent)); break; default: throw new Exception(_('Unsupported operation: ') . $operation); break; } } catch (Exception $e) { $rslt = array("server_protocol" => $_SERVER["SERVER_PROTOCOL"], "status" => "500 Server Error", "msg" => $e->getMessage()); } header('Content-Type: application/json; charset=utf-8'); echo json_encode($rslt);
function getAllParents($doc_id) { $return_array = array($doc_id); while (getParent($doc_id) != 0) { $doc_id = getParent($doc_id); $return_array[] = $doc_id; } return $return_array; }
<?
/** * generate permalink url from tokenized permalink structure * uses a very basic str_replace based token replacer, not a parser * TOKENS (%tokenid%) * %path% - path heirarchy to slug * %slug% - slug * %parent% - direct parent of slug * * supports prettyurl or any other permalink structure * eg. ?id=%slug%&parent=%parent%&path=%path% * * @param (str) $slug slug to resolve permalink for * @param (str) $permalink (optional) permalink structure * @return (str) */ function generate_permalink($slug, $permalink = null) { global $PERMALINK; $slug = (string) $slug; if (!isset($permalink)) { $plink = $PERMALINK; if (empty($PERMALINK)) { $plink = getDef('GSDEFAULTPERMALINK'); } } else { $plink = $permalink; } // replace PATH token if (containsToken('path', $plink)) { // remove PARENT tokens if path, since it would be pointless and probably accidental // leaving in for now lets not make assumptions // $plink = replaceToken('parent','',$plink); $pagepath = getParents($slug); if ($pagepath) { $pagepath = implode('/', array_reverse($pagepath)); $plink = replaceToken('path', $pagepath, $plink); } else { // page has no parents, remove token $plink = replaceToken('path', '', $plink); } } // replace PARENT token if (containsToken('parent', $plink)) { $parent = getParent($slug); $plink = replaceToken('parent', $parent, $plink); } // replace SLUG token $plink = replaceToken('slug', $slug, $plink); $plink = str_replace('//', '/', $plink); // clean up any double slashes // debugLog($url); // debugLog($plink); return no_lsl($plink); }
?> </select></td> </tr> <tr> <th> Permission Needed: </th><td> <select name='permission'> <?php getPermissions($link['permission']); ?> </select></td> </tr> <tr> <th> Parent Link: </th><td> <select name='parent'> <?php getParent($link['index'], $link['parent']); ?> </select>*Only needed if link is a Sub-link </td> </tr> <tr><th>Open In New Tab?</th> <td><input type='checkbox' name='newtab' value="1" <?php if ($link['newTab'] == 1) { echo 'checked'; } ?> >*Check if you want the link to always open in a new tab</td></tr> </table> <input type="submit" name="submit" value="Submit" method="post"> </form> </div>