kenken999/php
0
1<?php2/**3 * Class for list page with mode simple4 */5class ListPage_Simple extends ListPage 6{7 /**8 * Constructor, set initial params9 *10 * @param array $params11 */ 12 function __construct(&$params) 13 {14 // call parent constructor15 parent::__construct($params); 16 $this->pSetEdit = new ProjectSettings($this->tName, PAGE_SEARCH);17 }18 19 /**20 * Add common assign for simple mode on list page21 */ 22 function commonAssign() 23 {24 parent::commonAssign();25 26 $this->importLinksAttrs();27 28 $this->xt->assign("left_block", true);29 30 $this->addAssignTopLinks();31 32 $this->addAssignPageDetails(); 33 34 $this->xt->assign("moreButtons", $this->exportAvailable() || $this->printAvailable() || $this->importAvailable() || $this->advSearchAvailable() ); 35 $this->xt->assign("withSelected", $this->exportAvailable() || $this->printAvailable() || $this->inlineEditAvailable() || $this->deleteAvailable() );36 37 if( $this->exportAvailable() )38 {39 $this->xt->assign("exportselected_link", true);40 $this->xt->assign("exportselectedlink_span", $this->buttonShowHideStyle());41 $this->xt->assign("exportselectedlink_attrs", $this->getPrintExportLinkAttrs('export'));42 }43 44 if( $this->pSet->isAllowShowHideFields() )45 {46 $this->xt->assign("field_hide_panel", true);47 }48 49 if( $this->printAvailable() )50 {51 // new print panel52 if ( !$this->recordsOnPage )53 {54 $this->hideItemType("print_panel");55 }56 57 $this->xt->assign("print_friendly", true);58 $this->xt->assign("print_friendly_all", true);59 $this->xt->assign("print_recspp", $this->pSet->getPrinterSplitRecords() );60 61 for($i = 0; $i < count($this->allDetailsTablesArr); $i ++) 62 {63 $detTable = $this->allDetailsTablesArr[$i]['dDataSourceTable'];64 $dPset = new ProjectSettings( $detTable );65 66 if( $dPset->hasPrintPage() && $this->permis[ $detTable ]["export"] )67 {68 $this->xt->assign("print_details", true);69 $this->xt->assign("print_details_" . GetTableURL( $detTable ), true);70 }71 }72 73 // end new print panel74 $this->xt->assign("printselected_link", true);75 $this->xt->assign("printselectedlink_attrs", $this->getPrintExportLinkAttrs('print'));76 $this->xt->assign("printselectedlink_span", $this->buttonShowHideStyle());77 }78 79 //advanced search and attr80 $this->xt->assign("advsearchlink_attrs", "id=\"advButton".$this->id."\"");81 82 $this->xt->assign('menu_block', $this->isShowMenu() || $this->isAdminTable());83 84 if( $this->mobileTemplateMode() )85 {86 $this->xt->assign('morelinkmobile_block', true);87 $this->xt->assign('tableinfomobile_block', true);88 }89 90 //$this->setupBreadcrumbs();91 92 }93 94 95 /**96 * set Grid User Params97 */98 protected function setGridUserParams()99 {100 include_once getabspath("classes/paramsLogger.php");101 102 if( $this->pSet->isAllowShowHideFields() ) 103 {104 $this->jsSettings['tableSettings'][ $this->tName ]['isAllowShowHideFields'] = true;105 $hideColumns = $this->getColumnsToHide();106 $this->jsSettings['tableSettings'][ $this->tName ]['hideColumns'] = $hideColumns;107 108 if( !$this->recordsOnPage )109 $this->hideItemType("columns_control");110 111 $fieldsClasses = array();112 113 foreach( $hideColumns as $d => $fields)114 {115 $dm = RunnerPage::deviceClassToMacro( $d );116 if( getMediaType() == 0 && $dm == 0 ||117 ( getMediaType() == 2 || getMediaType() == 1 ) && $dm == 2 ) {118 foreach( $fields as $f )119 {120 $this->hideField( $f );121 }122 }123 }124 }125 126 if( $this->reorderFieldsFeatureEnabled() ) 127 {128 $this->jsSettings['tableSettings'][ $this->tName ]['isAllowFieldsReordering'] = true;129 130 $logger = new paramsLogger( $this->tName, FORDER_PARAMS_TYPE );131 $columnOrder = $logger->getData();132 if( $columnOrder )133 $this->jsSettings['tableSettings'][ $this->tName ]['columnOrder'] = $columnOrder;134 }135 }136 137 function getBreadcrumbMenuId() {138 if( $this->isAdminTable() )139 return "adminarea";140 else141 return "main";142 }143 144 145 146 /**147 * Add assign for top links, blocks and more button links148 *149 * @param boolean $exportPermis150 */151 function addAssignTopLinks()152 {153 if( !$this->isDispGrid() && !$this->pSetEdit->ajaxBasedListPage() )154 return;155 156 if( $this->printAvailable() )157 {158 // print links and attrs159 $this->xt->assign("prints_block", true );160 $this->xt->assign("print_link", $this->recordsOnPage );161 $this->xt->assign("printlink_attrs", "id='print_".$this->id."' name='print_".$this->id."'".(!$this->recordsOnPage && $needShowLinkForAdd ? " style='display:none;'" : ""));162 //print all link and attr163 $this->xt->assign("printall_link", true );164 $this->xt->assign("printalllink_attrs","id='printAll_".$this->id."' name='printAll_".$this->id."'". (!$this->recordsOnPage ? " style='display:none;'" : ""));165 }166 167 if( $this->exportAvailable() )168 {169 //export link and attr170 $this->xt->assign("export_link", true );171 $this->xt->assign("exportlink_attrs", "id='export_".$this->id."'".(!$this->recordsOnPage ? " style='display:none;'" : ""));172 173 }174 }175 176 /**177 * Add assign for details_ found, page_of and recsperpage blocks178 * If found 0 recs display this blocks hidden179 */180 function addAssignPageDetails() 181 {182 $searchPermis = $this->permis[ $this->tName ]['search'];183 if( !$this->recordsOnPage && !$this->inlineAddAvailable() && !$this->showAddInPopup )184 return;185 186 $this->xt->assign("details_block", $searchPermis );187 188 $this->xt->assign("pages_block", $searchPermis);189 $this->xt->assign("pages_attrs","id=\"pageOf".$this->id."\" name=\"pageOf".$this->id."\"");190 191 if( $searchPermis && count($this->arrRecsPerPage) )192 {193 $this->xt->assign("recordspp_block", true);194 $this->createPerPage();195 }196 }197 198 /**199 * Add common html code for simple mode on list page200 */ 201 function addCommonHtml() 202 {203 $this->body ["begin"] .= GetBaseScriptsForPage($this->isDisplayLoading); 204 205 //add parent common html code206 parent::addCommonHtml();207 208 // assign body end209 $this->body['end'] = XTempl::create_method_assignment( "assignBodyEnd", $this);210 }211 212 function buildSearchPanel() {213 if( !$this->permis[ $this->tName ]["search"] ) {214 return;215 }216 217 $this->xt->enable_section("searchPanel");218 219 $params = array();220 $params['pageObj'] = &$this;221 $params['panelSearchFields'] = $this->panelSearchFields;222 $params['allSearchFields'] = array_diff( 223 $this->pSet->getAllSearchFields(), 224 $this->pSet->getDetailKeysByMasterTable( $this->masterTable ) 225 );226 227 $this->searchPanel = new SearchPanelSimple( $params );228 $this->searchPanel->buildSearchPanel();229 }230 231 /**232 * If use resizable columns233 * Prepare for resize main table234 */235 function prepareForResizeColumns()236 {237 parent::prepareForResizeColumns();238 if( !$this->isBootstrap() )239 return;240 include_once getabspath("classes/paramsLogger.php"); 241 $logger = new paramsLogger( $this->tName, CRESIZE_PARAMS_TYPE );242 $columnsData = $logger->getData();243 if( $columnsData )244 $this->pageData[ "resizableColumnsData" ] = $columnsData;245 }246 247 protected function getColumnsToHide() 248 {249 return $this->getCombinedHiddenColumns();250 }251 252 /**253 * Add data-brick=filterpanel container254 */255 protected function prepareEmptyFPMarkup()256 {257 if( $this->listAjax && $this->pSetEdit->isSearchRequiredForFiltering() && !$this->isRequiredSearchRunning() && $this->isBootstrap() )258 {259 $this->xt->enable_section("filterPanel");260 $this->hideElement("filterpanel");261 } 262 }263}264?>