function recursively_update_page_templates($id, $template)
{
    $pages = Pages::getInstancesByParent($id, false);
    $ids = array();
    foreach ($pages->pages as $page) {
        $ids[] = $page->id;
        recursively_update_page_templates($page->id, $template);
    }
    if (!count($ids)) {
        return;
    }
    dbQuery('update pages set template="' . addslashes($template) . '" where id in (' . join(',', $ids) . ')');
}
Пример #2
0
/**
 * get table of contents for a given page
 *
 * @param object &$PAGEDATA page to retrieve the table of
 *
 * @return string HTML table of contents
 */
function TableOfContents_getContent(&$PAGEDATA)
{
    $kids = Pages::getInstancesByParent($PAGEDATA->id);
    $c = $PAGEDATA->render();
    if (!count($kids->pages)) {
        $c .= '<em>' . __('No sub-pages') . '</em>';
    } else {
        $c .= '<ul class="subpages">';
        foreach ($kids->pages as $kid) {
            $c .= '<li><a href="' . $kid->getRelativeURL() . '">' . htmlspecialchars(__fromJSON($kid->name)) . '</a></li>';
        }
        $c .= '</ul>';
    }
    if (isset($PAGEDATA->vars['footer'])) {
        $c .= $PAGEDATA->vars['footer'];
    }
    return $c;
}