Файл: concrete5.7.5.6/concrete/controllers/dialog/page/search/customize.php
Строк: 75
<?php
namespace ConcreteControllerDialogPageSearch;
use ConcreteControllerBackendUserInterface as BackendInterfaceController;
use ConcreteCorePageSearchColumnSetColumnSet as PageSearchColumnSet;
use ConcreteCorePageSearchColumnSetAvailable as PageSearchAvailableColumnSet;
use CollectionAttributeKey;
use ConcreteCorePageSearchResultResult as PageSearchResult;
use ConcreteCoreSearchResponse as SearchResponse;
use Loader;
use User;
use PageList;
use URL;
class Customize extends BackendInterfaceController {
protected $viewPath = '/dialogs/search/customize';
protected function canAccess() {
$sh = Loader::helper('concrete/dashboard/sitemap');
return $sh->canRead();
}
public function view() {
$selectedAKIDs = array();
$fldc = PageSearchColumnSet::getCurrent();
$fldca = new PageSearchAvailableColumnSet();
$searchInstance = Loader::helper('text')->entities($_REQUEST['searchInstance']);
$list = CollectionAttributeKey::getList();
$this->set('list', $list);
$this->set('form', Loader::helper('form'));
$this->set('fldca', $fldca);
$this->set('fldc', $fldc);
$this->set('type', 'pages');
}
public function submit() {
if ($this->validateAction()) {
$u = new User();
$fdc = new PageSearchColumnSet();
$fldca = new PageSearchAvailableColumnSet();
foreach($_POST['column'] as $key) {
$fdc->addColumn($fldca->getColumnByKey($key));
}
$sortCol = $fldca->getColumnByKey($_POST['fSearchDefaultSort']);
$fdc->setDefaultSortColumn($sortCol, $_POST['fSearchDefaultSortDirection']);
$u->saveConfig('PAGE_LIST_DEFAULT_COLUMNS', serialize($fdc));
$pageList = new PageList();
$columns = PageSearchColumnSet::getCurrent();
$col = $columns->getDefaultSortColumn();
$pageList->sanitizedSortBy($col->getColumnKey(), $col->getColumnDefaultSortDirection());
$ilr = new PageSearchResult($columns, $pageList, URL::to('/ccm/system/search/pages/submit'));
$r = new SearchResponse();
$r->setMessage(t('Page search columns saved successfully.'));
$r->setSearchResult($ilr);
$r->outputJSON();
}
}
}