Beispiel #1
0
        if ($count >= $start && $countok < $limit) {
            $searchResultsByType[$result[0]][$result[1]] = $count;
            $countok++;
        }
        $count++;
    }
}
//pr($searchResultsByType);
$resultsDatas = array();
$resultsDatas['results'] = array();
$resultsDatas['total'] = $count;
foreach ($searchResultsByType as $type => $results) {
    $items = array();
    switch ($type) {
        case 'rows':
            $rows = CMS_rowsCatalog::getAll(true, '', array(), array_keys($results));
            foreach ($rows as $row) {
                $items[] = $row->getJSonDescription($cms_user, $cms_language, false);
            }
            break;
        case 'templates':
            $tpls = CMS_pageTemplatesCatalog::getAll(true, '', array(), '', array_keys($results));
            foreach ($tpls as $tpl) {
                $items[] = $tpl->getJSonDescription($cms_user, $cms_language, false);
            }
            break;
        case 'users':
            $users = CMS_profile_usersCatalog::getAll(false, false, true, array('id_pru' => array_keys($results)));
            foreach ($users as $user) {
                $items[] = $user->getJSonDescription($cms_user, $cms_language, false);
            }
            $skipSearch = true;
        }
    }
} else {
    $rowIds = $items;
}
if ($currentTpl) {
    //check if template is a clone
    $tplId = CMS_pageTemplatesCatalog::getTemplateIDForCloneID($currentTpl);
    if ($tplId && $tplId != $currentTpl) {
        $currentTpl = $tplId;
    }
}
if (!$skipSearch) {
    $rows = CMS_rowsCatalog::getAll($viewinactive, $keyword, $groups, $rowIds, $cms_user, $currentTpl, $currentCS, $start, $limit);
    $rowsDatas['total'] = sizeof(CMS_rowsCatalog::getAll($viewinactive, $keyword, $groups, $rowIds, $cms_user, $currentTpl, $currentCS, 0, 0, false));
} else {
    $rows = array();
    $rowsDatas['total'] = 0;
}
foreach ($rows as $row) {
    if ($cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_TEMPLATES)) {
        //rows
        if ($delete) {
            if (is_a($row, "CMS_row") && !$row->hasClientSpaces()) {
                $log = new CMS_log();
                $log->logMiscAction(CMS_log::LOG_ACTION_TEMPLATE_DELETE, $cms_user, "Row : " . $row->getLabel());
                $row->destroy();
                unset($row);
                $rowsDatas['total']--;
                continue;