Example #1
0
function content_move($contentid, $parentid, $direction)
{
    $objResponse = new xajaxResponse();
    $time = time();
    $tmp = get_site_preference('__listcontent_timelock__', 0);
    if (time() - $tmp < 3) {
        return $objResponse;
        // delay between requests
    }
    set_site_preference('__listcontent_timelock__', $time);
    movecontent($contentid, $parentid, $direction);
    $objResponse->assign("contentlist", "innerHTML", display_content_list());
    $objResponse->script("\$('#tr_{$contentid}').effect('highlight', [], 3000);");
    // reset lock
    return $objResponse;
}
Example #2
0
function reorder_process($get)
{
    $userid = get_userid();
    $objResponse = new xajaxResponse();
    if (check_permission($userid, 'Manage All Content')) {
        global $gCms;
        $config =& $gCms->GetConfig();
        $db =& $gCms->GetDb();
        $contentops =& $gCms->GetContentOperations();
        $hm = $contentops->GetAllContentAsHierarchy(false);
        $hierarchy =& $hm->getRootNode();
        require cms_join_path(dirname(dirname(__FILE__)), 'lib', 'sllists', 'SLLists.class.php');
        $sortableLists = new SLLists($config["root_url"] . '/lib/scriptaculous');
        $listArray = array();
        $output = '';
        $sortableLists->addList('parent0', 'parent0ListOrder');
        $listArray[0] = 'parent0ListOrder';
        $output .= '<ul id="parent0" class="sortableList">' . "\n";
        foreach ($hierarchy->getChildren(false, true) as $child) {
            show_h($child, $sortableLists, $listArray, $output);
        }
        $output .= '</ul>';
        $order_changed = FALSE;
        foreach ($listArray as $parent_id => $order) {
            $orderArray = SLLists::getOrderArray($get[$order], 'parent' . $parent_id);
            foreach ($orderArray as $item) {
                $node =& $hm->sureGetNodeById($item['element']);
                if ($node != NULL) {
                    $one =& $node->getContent();
                    // Only update if order has changed.
                    if ($one->ItemOrder() != $item['order']) {
                        $order_changed = TRUE;
                        $query = 'UPDATE ' . cms_db_prefix() . 'content SET item_order = ? WHERE content_id = ?';
                        $db->Execute($query, array($item['order'], $item['element']));
                    }
                }
            }
        }
        if (TRUE == $order_changed) {
            global $gCms;
            $contentops =& $gCms->GetContentOperations();
            $contentops->SetAllHierarchyPositions();
            $contentops->ClearCache();
        }
    }
    $objResponse->assign("contentlist", "innerHTML", display_content_list());
    return $objResponse;
}