Exemplo n.º 1
0
function folio_control_childpagelist($username, $page, $profile_id)
{
    global $CFG;
    $url = url;
    if (!$page) {
        // No pages passed.  Can't show sub-pages of a page that doesnt' exist.
        return '';
    } else {
        // Grab matching records.
        $pages = recordset_to_array(get_recordset_sql("SELECT DISTINCT w.* FROM " . $CFG->prefix . "folio_page w " . "INNER JOIN " . $CFG->prefix . "folio_page_security p ON w.security_ident = p.security_ident " . 'WHERE w.parentpage_ident = ' . $page->page_ident . ' AND w.page_ident <> ' . $page->page_ident . ' AND w.newest = 1 AND ' . folio_page_security_where('p', 'w', 'read', $profile_id) . ' ORDER BY title '));
        $html = '<a href="' . $url . $username . '/page/' . folio_page_encodetitle($page->title) . '/addpage">Add a new page under this one</a><br/>';
        if ($pages) {
            // Build html
            $html .= '<ul>';
            foreach ($pages as $childpage) {
                // Load values.
                $html .= "<li><a href=\"{$url}" . $username . '/page/' . folio_page_encodetitle($childpage->title) . '">' . $childpage->title . "</a>\n";
            }
            $html .= '</ul>';
        }
    }
    return $html;
}
Exemplo n.º 2
0
		div.innerHTML += "<li>Server response: " + o.responseText + "</li>";
		div.innerHTML += "<li>Argument object: Object ( [foo] => " + o.argument.foo +
						 " [bar] => " + o.argument.bar +" )</li>";
*/
require_once "../../../includes.php";
$page_ident = required_param('page', 0, PARAM_INT);
$page = get_record('folio_page', 'page_ident', $page_ident, 'newest', 1);
$profile_id = $page->user_ident;
$prefix = $CFG->prefix;
$run_result = '';
// NOTE: The following query has the potential to return duplicates.  However, the older mysq doesn't support subqueries,  making it impossible
//  to do the query properly.  Filter out dups in code.
//      Potential Dup: w.* & children = 0, w.* & children = 1
//      Filtering on children=1 is a problem, as moving a child of a page, leaves new=0 with the parentpage_ident still set, filtering out that
//      page.
$pages = recordset_to_array(get_recordset_sql("SELECT DISTINCT w.*, children.newest children FROM {$prefix}folio_page w " . "INNER JOIN {$prefix}folio_page_security p ON w.security_ident = p.security_ident " . "LEFT OUTER JOIN {$prefix}folio_page children ON w.page_ident = children.parentpage_ident " . "WHERE w.parentpage_ident = {$page_ident} AND w.newest = 1 AND w.parentpage_ident <> w.page_ident AND " . folio_page_security_where('p', 'w', 'read', $profile_id) . 'ORDER BY title, children DESC'));
$last_ident = -1;
if ($pages) {
    foreach ($pages as $page) {
        $i = $page->page_ident;
        // Look to see if we're looking at a duplicate.
        if ($last_ident != $i) {
            // Update last_ident
            $last_ident = $i;
            // Load results
            $run_result .= intval($page->page_ident) . "\"";
            $run_result .= str_replace("\"", "'", $page->title) . "\"";
            $run_result .= str_replace("\"", "'", folio_page_encodetitle($page->title)) . "\"";
            if (is_null($page->children)) {
                // No kids.  Value is interpreted as 'already loaded', so since no kids, set to already loaded.
                $run_result .= "true\"";
Exemplo n.º 3
0
/**
* Builds the child nodes for the passed page_ident.
*
* @param int $page_ident The parent for whom we're retrieving children.
* @param int $ignorepage_ident Optional. A page to leave out of the results (if found).  Used by getNodeParents.
**/
function folio_control_tree_getNodeChildren($ajaxprefix, $page_ident, $ignorepage_ident, $url, $previousresults, $profile_id)
{
    global $CFG;
    $prefix = $CFG->prefix;
    // NOTE: The following query has the potential to return duplicates.  However, the older mysq doesn't support subqueries,  making it impossible
    //  to do the query properly.  Filter out dups in code.
    //      Potential Dup: w.* & children = 0, w.* & children = 1
    //      Filtering on children=1 is a problem, as moving a child of a page, leaves new=0 with the parentpage_ident still set, filtering out that
    //      page.
    $pages = recordset_to_array(get_recordset_sql("SELECT DISTINCT w.*, children.newest children FROM {$prefix}folio_page w " . "INNER JOIN {$prefix}folio_page_security p ON w.security_ident = p.security_ident " . "LEFT OUTER JOIN {$prefix}folio_page children ON w.page_ident = children.parentpage_ident " . "WHERE w.parentpage_ident = {$page_ident} AND w.newest = 1 AND w.parentpage_ident <> w.page_ident AND " . folio_page_security_where('p', 'w', 'read', $profile_id) . 'ORDER BY title DESC, children DESC'));
    // Set the parent node's name.
    $parentnode = $ajaxprefix . 'Node' . $page_ident;
    $last_ident = -1;
    $result = '';
    if ($pages) {
        foreach ($pages as $page) {
            $i = $page->page_ident;
            // Look to see if we're looking at a duplicate.
            if ($last_ident != $i) {
                // Update last_ident
                $last_ident = $i;
                // Test to see if we're on the *ignore* page, in which case, insert the nodes that have been built thus far.
                if ($ignorepage_ident == $i) {
                    $result = $previousresults . "\n" . $result;
                } else {
                    if (is_null($page->children)) {
                        // No kids
                        $result = "     var {$ajaxprefix}Node{$i} = {$ajaxprefix}buildNode( \"{$i}\", \"" . str_replace("\"", "'", $page->title) . "\", {$parentnode}, true, \"" . $url . folio_page_encodetitle($page->title) . "\");\n" . $result;
                    } else {
                        // Children, set loaded = false
                        $result = "     var {$ajaxprefix}Node{$i} = {$ajaxprefix}buildNode( \"{$i}\", \"" . str_replace("\"", "'", $page->title) . "\", {$parentnode}, false, \"" . $url . folio_page_encodetitle($page->title) . "\");\n" . $result;
                    }
                }
            } else {
                // $last_ident == $i
                // Don't load, as it would be a duplicate record.
            }
        }
        // foreach
    }
    // if $pages
    return $result;
}