1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
admin_list.php
См. документацию.
1<?php
2
9
10use Bitrix\Main;
14
16{
17 public const MODE_PAGE = 'normal';
18 public const MODE_LIST = 'list';
19 public const MODE_ACTION = 'frame';
20 public const MODE_EXPORT = 'excel';
21 public const MODE_CONFIG = 'settings';
22
23 protected const MODE_FIELD_NAME = 'mode';
24
27 var $sort;
31 var $aRows = array();
32 var $aHeader = array();
34 var $aFooter = array();
35 var $sNavText = '';
36 var $arFilterErrors = Array();
38 var $arUpdateErrorIDs = Array();
40 var $arGroupErrorIDs = Array();
42 var $bEditMode = false;
43 var $bMultipart = false;
44 var $bCanBeEdited = false;
45 var $bCanBeDeleted = false;
46 var $arActions = Array();
47 var $arActionsParams = Array();
49 var $context = false;
50 var $sContent = false, $sPrologContent = '', $sEpilogContent = '';
55
56 private $filter;
57
59 protected $mode = null;
61 protected $request;
63 protected $session;
64
69 public function __construct($table_id, $sort = false)
70 {
71 $this->request = Main\Context::getCurrent()->getRequest();
72 $this->session = Main\Application::getInstance()->getSession();
73
74 $this->table_id = preg_replace('/[^a-z0-9_]/i', '', $table_id);
75 $this->sort = $sort;
76
77 $this->setPublicModeState(defined('PUBLIC_MODE') && PUBLIC_MODE == 1);
78
79 $this->initMode();
80 }
81
82 public function setPublicModeState(bool $mode): void
83 {
84 $this->isPublicMode = $mode;
85 foreach (array_keys($this->aRows) as $index)
86 {
87 $this->aRows[$index]->setPublicModeState($mode);
88 }
89 }
90
91 public function getPublicModeState(): bool
92 {
94 }
95
96 public function getFilter()
97 {
98 return $this->filter;
99 }
100
101 //id, name, content, sort, default
102 public function AddHeaders($aParams)
103 {
104 $showAll = $this->request->get('showallcol');
105 if ($showAll !== null && $showAll !== '')
106 {
107 $this->session['SHALL'] = $showAll === 'Y';
108 }
109 $showAll = isset($this->session['SHALL']) && $this->session['SHALL'];
110
111 $aOptions = CUserOptions::GetOption("list", $this->table_id, array());
112
113 $aColsTmp = explode(",", $aOptions["columns"] ?? '');
114 $aCols = array();
115 $userColumns = array();
116 foreach ($aColsTmp as $col)
117 {
118 $col = trim($col);
119 if ($col <> "")
120 {
121 $aCols[] = $col;
122 $userColumns[$col] = true;
123 }
124 }
125
126 $bEmptyCols = empty($aCols);
127 $userVisibleColumns = array();
128 foreach ($aParams as $param)
129 {
130 $param['default'] = (bool)($param['default'] ?? false);
131 $param["__sort"] = -1;
132 $this->aHeaders[$param["id"]] = $param;
133 if (
134 $showAll
135 || ($bEmptyCols && $param["default"])
136 || isset($userColumns[$param["id"]])
137 )
138 {
139 $this->arVisibleColumns[] = $param["id"];
140 $userVisibleColumns[$param["id"]] = true;
141 }
142 }
143 unset($userColumns);
144
145 $aAllCols = ($this->isConfigMode() ? $this->aHeaders : null);
146
147 if (!$bEmptyCols)
148 {
149 foreach ($aCols as $i => $col)
150 if (isset($this->aHeaders[$col]))
151 $this->aHeaders[$col]["__sort"] = $i;
152
153 Collection::sortByColumn($this->aHeaders, ['__sort' => SORT_ASC], '', null, true);
154 }
155
156 foreach($this->aHeaders as $id=>$arHeader)
157 {
158 if (isset($userVisibleColumns[$id]))
159 $this->aVisibleHeaders[$id] = $arHeader;
160 }
161 unset($userVisibleColumns);
162
163 if ($this->isConfigMode())
164 {
165 $this->ShowSettings($aAllCols, $aCols, $aOptions);
166 }
167 }
168
170 public function ShowSettings($aAllCols, $aCols, $aOptions)
171 {
173 global $USER;
174
175 require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_js.php");
176 require($_SERVER['DOCUMENT_ROOT']."/bitrix/modules/main/interface/settings_admin_list.php");
177 require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin_js.php");
178 die();
179 }
180
181 public function AddVisibleHeaderColumn($id)
182 {
183 if (isset($this->aHeaders[$id]) && !isset($this->aVisibleHeaders[$id]))
184 {
185 $this->arVisibleColumns[] = $id;
186 $this->aVisibleHeaders[$id] = $this->aHeaders[$id];
187 }
188 }
189
190 public function GetVisibleHeaderColumns()
191 {
193 }
194
195 public function AddAdminContextMenu($aContext=array(), $bShowExcel=true, $bShowSettings=true)
196 {
197 $config = [];
198 if ($bShowSettings)
199 {
200 $config['settings'] = true;
201 }
202 if ($bShowExcel)
203 {
204 $config['excel'] = true;
205 }
206 $this->SetContextMenu($aContext, [], $config);
207 }
208
209 public function SetContextMenu(array $menu = [], array $additional = [], array $config = []): void
210 {
211 $this->InitContextMenu(
212 $menu,
213 array_merge($additional, $this->GetSystemContextMenu($config))
214 );
215 }
216
217 protected function GetSystemContextMenu(array $config = []): array
218 {
219 $result = [];
221 global $APPLICATION;
222
223 $queryString = DeleteParam([self::MODE_FIELD_NAME]);
224 if ($queryString !== '')
225 {
226 $queryString = '&' . $queryString;
227 }
228 $link = $APPLICATION->GetCurPage();
229 if (isset($config['settings']))
230 {
231 $result[] = [
232 "TEXT" => GetMessage("admin_lib_context_sett"),
233 "TITLE" => GetMessage("admin_lib_context_sett_title"),
234 "ONCLICK" => $this->table_id . ".ShowSettings('" . CUtil::JSEscape(
235 $link . "?" . static::getModeConfigUrlParam() . $queryString
236 ) . "')",
237 "GLOBAL_ICON" => "adm-menu-setting",
238 ];
239 }
240 if (isset($config['excel']))
241 {
242 $result[] = [
243 "TEXT" => "Excel",
244 "TITLE" => GetMessage("admin_lib_excel"),
245 "ONCLICK"=>"location.href='" . htmlspecialcharsbx(
246 $link . "?" . static::getModeExportUrlParam() . $queryString
247 ) . "'",
248 "GLOBAL_ICON"=>"adm-menu-excel",
249 ];
250 }
251 return $result;
252 }
253
254 protected function InitContextMenu(array $menu = [], array $additional = []): void
255 {
256 if (!empty($menu) || !empty($additional))
257 {
258 $this->context = new CAdminContextMenuList($menu, $additional);
259 }
260 }
261
266 public function IsUpdated($ID)
267 {
268 $f = $_REQUEST['FIELDS'][$ID];
269 $f_old = $_REQUEST['FIELDS_OLD'][$ID];
270
271 if(!is_array($f) || !is_array($f_old))
272 return true;
273
274 foreach($f as $k=>$v)
275 {
276 if(is_array($v))
277 {
278 if(!is_array($f_old[$k]))
279 return true;
280 else
281 {
282 foreach($v as $k2 => $v2)
283 {
284 if($f_old[$k][$k2] !== $v2)
285 return true;
286 unset($f_old[$k][$k2]);
287 }
288 if(!empty($f_old[$k]))
289 return true;
290 }
291 }
292 else
293 {
294 if(isset($f_old[$k]) && is_array($f_old[$k]))
295 {
296 return true;
297 }
298 elseif(!isset($f_old[$k]) || $f_old[$k] !== $v)
299 {
300 return true;
301 }
302 }
303 unset($f_old[$k]);
304 }
305 if(!empty($f_old))
306 return true;
307
308 return false;
309 }
310
314 public function EditAction()
315 {
316 if($_SERVER['REQUEST_METHOD']=='POST' && isset($_REQUEST['save']) && check_bitrix_sessid())
317 {
318 $arrays = array(&$_POST, &$_REQUEST);
319 foreach($arrays as $i => $array)
320 {
321 if(is_array($array["FIELDS"]))
322 {
323 foreach($array["FIELDS"] as $id=>$fields)
324 {
325 if(is_array($fields))
326 {
327 $keys = array_keys($fields);
328 foreach($keys as $key)
329 {
330 if(($c = substr($key,0,1)) == '~' || $c == '=')
331 {
332 unset($arrays[$i]["FIELDS"][$id][$key]);
333 }
334 }
335 }
336 }
337 }
338 }
339 if (is_array($GLOBALS["FIELDS"]))
340 {
341 foreach ($GLOBALS["FIELDS"] as $id => $fields)
342 {
343 if (is_array($fields))
344 {
345 $keys = array_keys($fields);
346 foreach ($keys as $key)
347 {
348 if (($c = substr($key,0,1)) == '~' || $c == '=')
349 {
350 unset($GLOBALS["FIELDS"][$id][$key]);
351 }
352 }
353 }
354 }
355 }
356 return true;
357 }
358 return false;
359 }
360
366 public function GetEditFields(): array
367 {
368 $result = [];
369 if (isset($_REQUEST['FIELDS']) && is_array($_REQUEST['FIELDS']))
370 {
371 foreach (array_keys($_REQUEST['FIELDS']) as $id)
372 {
373 if (empty($id) || !$this->IsUpdated($id))
374 {
375 continue;
376 }
377 $result[$id] = $_REQUEST['FIELDS'][$id];
378 }
379 }
380 return $result;
381 }
382
388 public function ConvertFilesToEditFields(): void
389 {
390 if (!empty($_FILES['FIELDS']) && is_array($_FILES['FIELDS']))
391 {
392 CFile::ConvertFilesToPost($_FILES['FIELDS'], $_REQUEST['FIELDS']);
393 }
394 }
395
399 public function GroupAction()
400 {
401 $this->PrepareAction();
402
403 if (!check_bitrix_sessid())
404 {
405 return false;
406 }
407
408 $action = $this->GetAction();
409 if ($action === null)
410 {
411 return false;
412 }
413
414 if($action=="edit")
415 {
416 $arID = $this->GetGroupIds();
417 if ($arID !== null)
418 {
419 $this->arEditedRows = $arID;
420 $this->bEditMode = true;
421 }
422 return false;
423 }
424
425 if (!$this->IsGroupActionToAll())
426 {
427 $arID = $this->GetGroupIds();
428 if ($arID === null)
429 {
430 $arID = false;
431 }
432 }
433 else
434 {
435 $arID = array('');
436 }
437 return $arID;
438 }
439
445 public function IsGroupActionToAll()
446 {
447 return (isset($_REQUEST['action_target']) && $_REQUEST['action_target'] === 'selected');
448 }
449
453 protected function PrepareAction()
454 {
455 if (!empty($_REQUEST['action_button']))
456 {
457 $_REQUEST['action'] = $_REQUEST['action_button'];
458 }
459 }
460
464 public function GetAction()
465 {
466 return ($_REQUEST['action'] ?? null);
467 }
468
472 protected function GetGroupIds()
473 {
474 $result = null;
475 if (isset($_REQUEST['ID']))
476 {
477 $result = (!is_array($_REQUEST['ID']) ? array($_REQUEST['ID']) : $_REQUEST['ID']);
478 }
479 return $result;
480 }
481
485 protected function initMode(): void
486 {
487 $this->mode = self::MODE_PAGE;
488 $mode = $this->request->get(self::MODE_FIELD_NAME);
489 if (
490 is_string($mode)
491 && (in_array(
492 $mode,
493 $this->getModeList(),
494 true
495 ))
496 )
497 {
498 $this->mode = $mode;
499 }
500 }
501
502 protected function getModeList(): array
503 {
504 return [
505 self::MODE_LIST,
506 self::MODE_ACTION,
507 self::MODE_EXPORT,
508 self::MODE_CONFIG,
509 ];
510 }
511
515 public function getCurrentMode(): string
516 {
517 return $this->mode;
518 }
519
523 public function isPageMode(): bool
524 {
525 return $this->getCurrentMode() === self::MODE_PAGE;
526 }
527
531 public function isExportMode(): bool
532 {
533 return $this->getCurrentMode() === self::MODE_EXPORT;
534 }
535
539 public function isAjaxMode(): bool
540 {
541 $mode = $this->getCurrentMode();
542 return ($mode === self::MODE_LIST || $mode === self::MODE_ACTION);
543 }
544
548 public function isConfigMode(): bool
549 {
550 return $this->getCurrentMode() === self::MODE_CONFIG;
551 }
552
556 public function isActionMode(): bool
557 {
558 return $this->getCurrentMode() === self::MODE_ACTION;
559 }
560
564 public function isListMode(): bool
565 {
566 return $this->getCurrentMode() === self::MODE_LIST;
567 }
568
569 public function ActionRedirect($url)
570 {
571 $url = (string)$url;
572 if ($this->isPublicMode)
573 {
574 $selfFolderUrl = (defined("SELF_FOLDER_URL") ? SELF_FOLDER_URL : "/bitrix/admin/");
575 if (!str_contains($url, $selfFolderUrl))
576 {
577 $url = $selfFolderUrl.$url;
578 }
579 }
580
581 return "BX.adminPanel.Redirect([], '".static::getUrlWithLanguage($url)."', event);";
582 }
583
584 public function ActionAjaxReload($url)
585 {
586 return $this->table_id.".GetAdminList('".static::getUrlWithLanguage((string)$url)."');";
587 }
588
589 public function ActionPost($url = false, $action_name = false, $action_value = 'Y')
590 {
591 $res = '';
592 if ($url)
593 {
594 $url = static::getUrlWithLanguage((string)$url, false);
595
596 if (!str_contains($url, self::MODE_FIELD_NAME . '='))
597 {
598 $url .= '&' . static::getModeActionUrlParam();
599 }
600
601 $res = 'BX(\'form_'.$this->table_id.'\').action=\''.CUtil::AddSlashes($url).'\';';
602 }
603
604 if ($action_name)
605 return $res.'; BX.submit(document.forms.form_'.$this->table_id.', \''.CUtil::JSEscape($action_name).'\', \''.CUtil::JSEscape($action_value).'\');';
606 else
607 return $res.'; BX.submit(document.forms.form_'.$this->table_id.');';
608 }
609
610 public function ActionDoGroup($id, $action_id, $add_params='')
611 {
613 global $APPLICATION;
614 return $this->table_id.".GetAdminList('".CUtil::AddSlashes($APPLICATION->GetCurPage())."?ID=".CUtil::AddSlashes($id)."&action_button=".CUtil::AddSlashes($action_id)."&lang=".LANGUAGE_ID."&".bitrix_sessid_get().($add_params<>""?"&".CUtil::AddSlashes($add_params):"")."');";
615 }
616
617 public function InitFilter($arFilterFields)
618 {
619 //Filter by link from favorites. Extract fields.
620 if(isset($_REQUEST['adm_filter_applied']) && intval($_REQUEST['adm_filter_applied']) > 0)
621 {
622 $dbRes = \CAdminFilter::GetList(array(), array('ID' => intval($_REQUEST['adm_filter_applied'])));
623
624 if($row = $dbRes->Fetch())
625 {
626 $fields = unserialize($row['FIELDS'], ['allowed_classes' => false]);
627
628 if(is_array($fields) && !empty($fields))
629 {
630 foreach($fields as $field => $params)
631 {
632 if(isset($params['value']))
633 {
634 if(!isset($params['hidden']) || $params['hidden'] != 'true')
635 {
636 $GLOBALS[$field] = $params['value'];
637
638 if($GLOBALS['set_filter'] != 'Y')
639 $GLOBALS['set_filter'] = 'Y';
640 }
641 }
642 }
643 }
644 }
645 }
646
647 $sTableID = $this->table_id;
648 global $del_filter, $set_filter, $save_filter;
649 if($del_filter <> "")
650 DelFilterEx($arFilterFields, $sTableID);
651 elseif($set_filter <> "")
652 {
653 InitFilterEx($arFilterFields, $sTableID, "set");
654 }
655 else
656 InitFilterEx($arFilterFields, $sTableID, "get");
657
658 foreach ($arFilterFields as $f)
659 {
660 $fperiod = $f."_FILTER_PERIOD";
661 $fdirection = $f."_FILTER_DIRECTION";
662 $fbdays = $f."_DAYS_TO_BACK";
663
664 global $$f, $$fperiod, $$fdirection, $$fbdays;
665 if (isset($$f))
666 $this->filter[$f] = $$f;
667 if (isset($$fperiod))
668 $this->filter[$fperiod] = $$fperiod;
669 if (isset($$fdirection))
670 $this->filter[$fdirection] = $$fdirection;
671 if (isset($$fbdays))
672 $this->filter[$fbdays] = $$fbdays;
673 }
674
675 return $this->filter;
676 }
677
678 public function IsDefaultFilter()
679 {
680 global $set_default;
681 $sTableID = $this->table_id;
682 return $set_default=="Y"
683 && (
684 !isset($this->session["SESS_ADMIN"][$sTableID])
685 || empty($this->session["SESS_ADMIN"][$sTableID])
686 )
687 ;
688 }
689
690 public function &AddRow($id = false, $arRes = Array(), $link = false, $title = false)
691 {
692 $row = new CAdminListRow($this->aHeaders, $this->table_id);
693 $row->id = $id;
694 $row->arRes = $arRes;
695 $row->link = $link;
696 $row->title = $title;
697 $row->pList = &$this;
698
699 if($id)
700 {
701 if($this->bEditMode && in_array($id, $this->arEditedRows))
702 $row->bEditMode = true;
703 elseif(!empty($this->arUpdateErrorIDs) && in_array($id, $this->arUpdateErrorIDs))
704 $row->bEditMode = true;
705 }
706
707 $row->setPublicModeState($this->getPublicModeState());
708
709 $this->aRows[] = &$row;
710 return $row;
711 }
712
713 public function AddFooter($aFooter)
714 {
715 $this->aFooter = $aFooter;
716 }
717
718 public function NavText($sNavText)
719 {
720 $this->sNavText = $sNavText;
721 }
722
729 public function setNavigation(\Bitrix\Main\UI\PageNavigation $nav, $title, $showAllways = true, $post = false)
730 {
731 global $APPLICATION;
732
733 ob_start();
734
735 $APPLICATION->IncludeComponent(
736 "bitrix:main.pagenavigation",
737 "admin",
738 array(
739 "NAV_OBJECT" => $nav,
740 "TITLE" => $title,
741 "PAGE_WINDOW" => 10,
742 "SHOW_ALWAYS" => $showAllways,
743 "POST" => $post,
744 "TABLE_ID" => $this->table_id,
745 ),
746 false,
747 array(
748 "HIDE_ICONS" => "Y",
749 )
750 );
751
752 $this->NavText(ob_get_clean());
753 }
754
755 public function Display()
756 {
758 global $APPLICATION;
759
760 foreach(GetModuleEvents("main", "OnAdminListDisplay", true) as $arEvent)
761 ExecuteModuleEventEx($arEvent, array(&$this));
762
763 // Check after event handlers
764 if (!is_array($this->arActions))
765 {
766 $this->arActions = [];
767 }
768 if (!is_array($this->arActionsParams))
769 {
770 $this->arActionsParams = [];
771 }
772
773 $errmsg = '';
774 foreach ($this->arFilterErrors as $err)
775 $errmsg .= ($errmsg<>''? '<br>': '').$err;
776 foreach ($this->arUpdateErrors as $err)
777 $errmsg .= ($errmsg<>''? '<br>': '').$err[0];
778 foreach ($this->arGroupErrors as $err)
779 $errmsg .= ($errmsg<>''? '<br>': '').$err[0];
780 if($errmsg<>'')
781 CAdminMessage::ShowMessage(array("MESSAGE"=>GetMessage("admin_lib_error"), "DETAILS"=>$errmsg, "TYPE"=>"ERROR"));
782
783 $successMessage = '';
784 for ($i = 0, $cnt = count($this->arActionSuccess); $i < $cnt; $i++)
785 $successMessage .= ($successMessage != '' ? '<br>' : '').$this->arActionSuccess[$i];
786 if ($successMessage != '')
787 CAdminMessage::ShowMessage(array("MESSAGE" => GetMessage("admin_lib_success"), "DETAILS" => $successMessage, "TYPE" => "OK"));
788
789 echo $this->sPrologContent;
790
791 if($this->sContent===false)
792 {
793?>
794<div class="adm-list-table-wrap<?=$this->context ? '' : ' adm-list-table-without-header'?><?= empty($this->arActions) && !$this->bCanBeEdited ? ' adm-list-table-without-footer' : ''?>">
795<?
796 }
797
798 if($this->context)
799 $this->context->Show();
800
801 if ($this->isAjaxDebug())
802 {
803 echo '<form method="POST" '
804 .($this->bMultipart?' enctype="multipart/form-data" ':'')
805 .' onsubmit="CheckWin();ShowWaitWindow();" target="frame_debug" id="form_'.$this->table_id.'" name="form_'.$this->table_id.'" '
806 .'action="'.htmlspecialcharsbx($APPLICATION->GetCurPageParam(
807 static::getModeActionUrlParam(),
808 [self::MODE_FIELD_NAME]
809 )).'">'
810 ;
811 }
812 else
813 {
814 echo '<form method="POST" '
815 .($this->bMultipart?' enctype="multipart/form-data" ':'')
816 .' onsubmit="return BX.ajax.submitComponentForm(this, \''.$this->table_id.'_result_div\', true);" '
817 .'id="form_'.$this->table_id.'" name="form_'.$this->table_id.'" '
818 .'action="'.htmlspecialcharsbx($APPLICATION->GetCurPageParam(
819 static::getModeActionUrlParam(),
820 [self::MODE_FIELD_NAME, "action", "action_button"]
821 )).'">'
822 ;
823 }
824
825 if($this->bEditMode && !$this->bCanBeEdited)
826 $this->bEditMode = false;
827
828 if($this->sContent!==false)
829 {
830 echo $this->sContent;
831 echo '</form>';
832 return;
833 }
834
835 $bShowSelectAll = (!empty($this->arActions) || $this->bCanBeEdited);
836 $this->bShowActions = false;
837 foreach($this->aRows as $row)
838 {
839 if(!empty($row->aActions))
840 {
841 $this->bShowActions = true;
842 break;
843 }
844 }
845
847 echo bitrix_sessid_post();
848 //echo $this->sNavText;
849
850 $colSpan = 0;
851?>
852<table class="adm-list-table" id="<?=$this->table_id;?>">
853 <thead>
854 <tr class="adm-list-table-header">
855<?
856 if($bShowSelectAll):
857?>
858 <td class="adm-list-table-cell adm-list-table-checkbox" onclick="this.firstChild.firstChild.click(); return BX.PreventDefault(event);"><div class="adm-list-table-cell-inner"><input class="adm-checkbox adm-designed-checkbox" type="checkbox" id="<?=$this->table_id?>_check_all" onclick="<?=$this->table_id?>.SelectAllRows(this); return BX.eventCancelBubble(event);" title="<?=GetMessage("admin_lib_list_check_all")?>" /><label for="<?=$this->table_id?>_check_all" class="adm-designed-checkbox-label"></label></div></td>
859<?
860 $colSpan++;
861 endif;
862
863 if($this->bShowActions):
864?>
865 <td class="adm-list-table-cell adm-list-table-popup-block" title="<?=GetMessage("admin_lib_list_act")?>"><div class="adm-list-table-cell-inner"></div></td>
866<?
867 $colSpan++;
868 endif;
869
870 foreach($this->aVisibleHeaders as $header):
871 $bSort = $this->sort && !empty($header["sort"]);
872 $header['title'] = (string)($header['title'] ?? '');
873
874 if ($bSort)
875 $attrs = $this->sort->Show($header["content"], $header["sort"], $header["title"], "adm-list-table-cell");
876 else
877 $attrs = 'class="adm-list-table-cell"';
878
879?>
880 <td <?=$attrs?>>
881 <div class="adm-list-table-cell-inner"><?=$header["content"]?></div>
882 </td>
883<?
884 $colSpan++;
885 endforeach;
886?>
887 </tr>
888 </thead>
889 <tbody>
890<?
891 if(!empty($this->aRows)):
892 foreach($this->aRows as $row)
893 {
894 $row->Display();
895 }
896 elseif(!empty($this->aHeaders)):
897?>
898 <tr><td colspan="<?=$colSpan?>" class="adm-list-table-cell adm-list-table-empty"><?=GetMessage("admin_lib_no_data")?></td></tr>
899<?
900 endif;
901?>
902 </tbody>
903</table>
904<?
905 $this->ShowActionTable();
906
907// close form and div.adm-list-table-wrap
908
909 echo $this->sEpilogContent;
910 echo '
911 </form>
912</div>
913';
914 echo $this->sNavText;
915 }
916
917 public function DisplayExcel()
918 {
920 global $APPLICATION;
921 echo '
922 <html>
923 <head>
924 <title>'.$APPLICATION->GetTitle().'</title>
925 <meta http-equiv="Content-Type" content="text/html; charset='.LANG_CHARSET.'">
926 <style>
927 td {mso-number-format:\@;}
928 .number0 {mso-number-format:0;}
929 .number2 {mso-number-format:Fixed;}
930 </style>
931 </head>
932 <body>';
933
934 echo "<table border=\"1\">";
935 echo "<tr>";
936
937 foreach($this->aVisibleHeaders as $header)
938 {
939 echo '<td>';
940 echo $header["content"];
941 echo '</td>';
942 }
943 echo "</tr>";
944
945
946 foreach($this->aRows as $row)
947 {
948 echo "<tr>";
949 foreach($this->aVisibleHeaders as $id=>$header_props)
950 {
951 $field = $row->aFields[$id];
952 if(!is_array($row->arRes[$id]))
953 $val = trim($row->arRes[$id]);
954 else
955 $val = $row->arRes[$id];
956
957 switch($field["view"]["type"])
958 {
959 case "checkbox":
960 if($val=='Y')
961 $val = htmlspecialcharsex(GetMessage("admin_lib_list_yes"));
962 else
963 $val = htmlspecialcharsex(GetMessage("admin_lib_list_no"));
964 break;
965 case "select":
966 if (isset($field["edit"]["values"][$val]))
967 {
968 $val = htmlspecialcharsex($field["edit"]["values"][$val]);
969 }
970 elseif (isset($field["view"]["values"][$val]))
971 {
972 $val = htmlspecialcharsex($field["view"]["values"][$val]);
973 }
974 else
975 {
976 $val = htmlspecialcharsex($val);
977 }
978 break;
979 case "file":
980 $arFile = CFile::GetFileArray($val);
981 if(is_array($arFile))
982 $val = htmlspecialcharsex((new Uri($arFile["SRC"]))->toAbsolute()->getUri());
983 else
984 $val = "";
985 break;
986 case "html":
987 $val = trim(strip_tags($field["view"]['value'], "<br>"));
988 break;
989 default:
990 $val = htmlspecialcharsex($val);
991 break;
992 }
993
994 echo '<td';
995 if ($header_props['align'])
996 echo ' align="'.$header_props['align'].'"';
997 if ($header_props['valign'])
998 echo ' valign="'.$header_props['valign'].'"';
999 if ($header_props['align'] === "right" && preg_match("/^([1-9][0-9]*|[1-9][0-9]*[.,][0-9]+)\$/", $val))
1000 echo ' class="number0"';
1001 echo '>';
1002 echo ($val<>""? $val: '&nbsp;');
1003 echo '</td>';
1004 }
1005 echo "</tr>";
1006 }
1007
1008 echo "</table>";
1009 echo '</body></html>';
1010 }
1011
1012 public function AddGroupActionTable($arActions, $arParams=array())
1013 {
1014 if (!is_array($arActions))
1015 {
1016 $arActions = [];
1017 }
1018 if (!is_array($arParams))
1019 {
1020 $arParams = [];
1021 }
1022 //array("action"=>"text", ...)
1023 //OR array(array("action" => "custom JS", "value" => "action", "type" => "button", "title" => "", "name" => ""), ...)
1024 $this->arActions = $arActions;
1025 //array("disable_action_target"=>true, "select_onchange"=>"custom JS")
1026 $this->arActionsParams = $arParams;
1027 }
1028
1029 public function ShowActionTable()
1030 {
1031 if (empty($this->arActions) && !$this->bCanBeEdited)
1032 return;
1033?>
1034<div class="adm-list-table-footer" id="<?=$this->table_id?>_footer<?=$this->bEditMode || !empty($this->arUpdateErrorIDs) ? '_edit' : ''?>">
1035 <input type="hidden" name="action_button" id="<?=$this->table_id; ?>_action_button" value="" />
1036<?
1037 if($this->bEditMode || !empty($this->arUpdateErrorIDs)):
1038 $this->DisplayEditButtons();
1039 else: //($this->bEditMode || count($this->arUpdateErrorIDs)>0)
1040 if (!isset($this->arActionsParams["disable_action_target"]) || $this->arActionsParams["disable_action_target"] !== true):
1041?>
1042 <span class="adm-selectall-wrap"><input type="checkbox" class="adm-checkbox adm-designed-checkbox" name="action_target" value="selected" id="action_target" onclick="if(this.checked && !confirm('<?=CUtil::JSEscape(GetMessage("admin_lib_list_edit_for_all_warn"))?>')) {this.checked=false;} <?=$this->table_id?>.EnableActions();" title="<?=GetMessage("admin_lib_list_edit_for_all")?>" /><label for="action_target" class="adm-checkbox adm-designed-checkbox-label"></label><label title="<?=GetMessage("admin_lib_list_edit_for_all")?>" for="action_target" class="adm-checkbox-label"><?=GetMessage("admin_lib_list_for_all");?></label></span>
1043<?
1044 endif;
1045
1046 $this->bCanBeDeleted = array_key_exists("delete", $this->arActions);
1047
1048 if ($this->bCanBeEdited || $this->bCanBeDeleted)
1049 {
1050 echo '
1051 <span class="adm-table-item-edit-wrap'.(!$this->bCanBeEdited || !$this->bCanBeDeleted ? ' adm-table-item-edit-single' : '').'">
1052';
1053 if($this->bCanBeEdited)
1054 {
1055 echo '<a href="javascript:void(0)" class="adm-table-btn-edit adm-edit-disable" hidefocus="true" onclick="this.blur();if('.$this->table_id.'.IsActionEnabled(\'edit\')){document.forms[\'form_'.$this->table_id.'\'].elements[\'action_button\'].value=\'edit\'; '.
1056 htmlspecialcharsbx($this->ActionPost(false, 'action_button', 'edit')).'}" title="'.GetMessage("admin_lib_list_edit").'" id="action_edit_button"></a>';
1057 }
1058 if($this->bCanBeDeleted)
1059 {
1060 echo '<a href="javascript:void(0);" class="adm-table-btn-delete adm-edit-disable" hidefocus="true" onclick="this.blur();if('.$this->table_id.'.IsActionEnabled() && confirm((document.getElementById(\'action_target\') && document.getElementById(\'action_target\').checked? \''.GetMessage("admin_lib_list_del").'\':\''.GetMessage("admin_lib_list_del_sel").'\'))) {document.forms[\'form_'.$this->table_id.'\'].elements[\'action_button\'].value=\'delete\'; '.
1061 htmlspecialcharsbx($this->ActionPost(false, 'action_button', 'delete')).'}" title="'.GetMessage("admin_lib_list_del_title").'" class="context-button icon action-delete-button-dis" id="action_delete_button"></a>';
1062 }
1063 echo '
1064 </span>
1065';
1066 }
1067
1068 $onchange = '';
1069 if (isset($this->arActionsParams["select_onchange"]))
1070 {
1071 if (is_array($this->arActionsParams["select_onchange"]))
1072 {
1073 $onchange = implode(' ', $this->arActionsParams["select_onchange"]);
1074 }
1075 elseif (is_string($this->arActionsParams["select_onchange"]))
1076 {
1077 $onchange = $this->arActionsParams["select_onchange"];
1078 }
1079 }
1080
1081 $list = '';
1082 $html = '';
1083 $buttons = '';
1084 $actionList = array_filter($this->arActions);
1085 if (isset($actionList['delete']))
1086 {
1087 unset($actionList['delete']);
1088 }
1089
1090 $allowedTypes = [
1091 'button' => true,
1092 'html' => true
1093 ];
1094
1095 foreach($actionList as $k=>$v)
1096 {
1097 if(is_array($v))
1098 {
1099 if (isset($v['type']) && isset($allowedTypes[$v['type']]))
1100 {
1101 switch ($v["type"])
1102 {
1103 case 'button':
1104 $buttons .= '<input type="button" name="" value="'.htmlspecialcharsbx($v['name']).'" onclick="'.(!empty($v["action"])? htmlspecialcharsbx($v['action']) : 'document.forms[\'form_'.$this->table_id.'\'].elements[\'action_button\'].value=\''.htmlspecialcharsbx($v["value"]).'\'; '.htmlspecialcharsbx($this->ActionPost()).'').'" title="'.htmlspecialcharsbx($v["title"]).'" />';
1105 break;
1106 case 'html':
1107 $html .= '<span class="adm-list-footer-ext">'.$v["value"].'</span>';
1108 break;
1109 }
1110 }
1111 else
1112 {
1113 $list .= '<option value="'.htmlspecialcharsbx($v['value']).'"'.($v['action']?' custom_action="'.htmlspecialcharsbx($v['action']).'"':'').'>'.htmlspecialcharsex($v['name']).'</option>';
1114 }
1115 }
1116 else
1117 {
1118 $list .= '<option value="'.htmlspecialcharsbx($k).'">'.htmlspecialcharsex($v).'</option>';
1119 }
1120 }
1121 unset($actionList, $k, $v);
1122 unset($allowedTypes);
1123
1124 if ($buttons != '')
1125 echo '<span class="adm-list-footer-ext">'.$buttons.'</span>';
1126
1127 if ($list != ''):
1128?>
1129 <span class="adm-select-wrap">
1130 <select name="action" id="<?=$this->table_id.'_action'; ?>" class="adm-select"<?=($onchange != '' ? ' onchange="'.htmlspecialcharsbx($onchange).'"':'')?>>
1131 <option value=""><?=GetMessage("admin_lib_list_actions")?></option>
1132<?=$list?>
1133 </select>
1134 </span>
1135<?
1136 if ($html != '')
1137 echo $html;
1138?>
1139 <input type="submit" name="apply" value="<?=GetMessage("admin_lib_list_apply")?>" onclick="if(this.form.action[this.form.action.selectedIndex].getAttribute('custom_action')){eval(this.form.action[this.form.action.selectedIndex].getAttribute('custom_action'));return false;}" disabled="disabled" class="adm-table-action-button" />
1140<?
1141 endif; //(strlen($list) > 0)
1142?>
1143 <span class="adm-table-counter" id="<?=$this->table_id?>_selected_count"><?=GetMessage('admin_lib_checked')?>: <span>0</span></span>
1144<?
1145 endif; // ($this->bEditMode || count($this->arUpdateErrorIDs)>0):
1146?>
1147</div>
1148<?
1149 }
1150
1151 public function DisplayList($arParams = array())
1152 {
1153 $menu = new CAdminPopup($this->table_id."_menu", $this->table_id."_menu");
1154 $menu->Show();
1155
1156 if ($this->isAjaxDebug())
1157 {
1158 echo '<script>
1159 function CheckWin()
1160 {
1161 window.open("about:blank", "frame_debug");
1162 }
1163 </script>';
1164 }
1165 else
1166 {
1167 echo '<iframe src="javascript:\'\'" id="frame_'.$this->table_id.'" name="frame_'.$this->table_id.'" style="width:1px; height:1px; border:0px; position:absolute; left:-10px; top:-10px; z-index:0;"></iframe>';
1168 }
1169
1170 $aUserOpt = CUserOptions::GetOption("global", "settings");
1171 if (!is_array($aUserOpt))
1172 {
1173 $aUserOpt = [];
1174 }
1175 $aUserOpt['context_ctrl'] = (string)($aUserOpt['context_ctrl'] ?? 'N');
1176 $aUserOpt['context_menu'] = (string)($aUserOpt['context_menu'] ?? 'Y');
1177
1178 if (!is_array($arParams))
1179 $arParams = array();
1180
1181 if (!isset($arParams['FIX_HEADER']))
1182 $arParams['FIX_HEADER'] = true;
1183 if (!isset($arParams['FIX_FOOTER']))
1184 $arParams['FIX_FOOTER'] = true;
1185 if (!isset($arParams['context_ctrl']))
1186 $arParams['context_ctrl'] = ($aUserOpt["context_ctrl"] === "Y");
1187 if (!isset($arParams['context_menu']))
1188 $arParams['context_menu'] = ($aUserOpt["context_menu"] !== "N");
1189
1190 $tbl = CUtil::JSEscape($this->table_id);
1191?>
1192<script>
1193window['<?=$tbl?>'] = new BX.adminList('<?=$tbl?>', <?= Json::encode($arParams) ?>);
1194BX.adminChain.addItems("<?=$tbl?>_navchain_div");
1195</script>
1196<?
1197
1198 echo '<div id="'.$this->table_id.'_result_div" class="adm-list-table-layout">';
1199 $this->Display();
1200 echo '</div>';
1201 }
1202
1203 public function AddUpdateError($strError, $id = false)
1204 {
1205 $this->arUpdateErrors[] = Array($strError, $id);
1206 $this->arUpdateErrorIDs[] = $id;
1207 }
1208
1209 public function AddGroupError($strError, $id = false)
1210 {
1211 $this->arGroupErrors[] = Array($strError, $id);
1212 $this->arGroupErrorIDs[] = $id;
1213 }
1214
1215 public function AddActionSuccessMessage($strMessage)
1216 {
1217 $this->arActionSuccess[] = $strMessage;
1218 }
1219
1220 public function AddFilterError($strError)
1221 {
1222 $this->arFilterErrors[] = $strError;
1223 }
1224
1225 public function BeginPrologContent()
1226 {
1227 ob_start();
1228 }
1229
1230 public function EndPrologContent()
1231 {
1232 $this->sPrologContent .= ob_get_contents();
1233 ob_end_clean();
1234 }
1235
1236 public function BeginEpilogContent()
1237 {
1238 ob_start();
1239 }
1240
1241 public function EndEpilogContent()
1242 {
1243 $this->sEpilogContent .= ob_get_contents();
1244 ob_end_clean();
1245 }
1246
1247 public function BeginCustomContent()
1248 {
1249 ob_start();
1250 }
1251
1252 public function EndCustomContent()
1253 {
1254 $this->sContent = ob_get_contents();
1255 ob_end_clean();
1256 }
1257
1258 public function CreateChain()
1259 {
1260 return new CAdminChain($this->table_id."_navchain_div", false);
1261 }
1262
1266 public function ShowChain($chain)
1267 {
1268 $this->BeginPrologContent();
1269 $chain->Show();
1270 $this->EndPrologContent();
1271 }
1272
1273 public function CheckListMode()
1274 {
1276 global $APPLICATION;
1277
1278 if ($this->isPageMode())
1279 {
1280 return;
1281 }
1282
1283 if ($this->isAjaxMode())
1284 {
1285 ob_start();
1286 $this->Display();
1287 $string = ob_get_contents();
1288 ob_end_clean();
1289
1290 if ($this->isActionMode())
1291 {
1292?>
1293<html><head></head><body><?=$string?><script>
1294 var topWindow = (window.BX||window.parent.BX).PageObject.getRootWindow();
1295 topWindow.bxcompajaxframeonload = function() {
1296 topWindow.BX.adminPanel.closeWait();
1297 topWindow.<?=$this->table_id?>.Destroy(false);
1298 topWindow.<?=$this->table_id?>.Init();
1299<?
1300 if(isset($this->onLoadScript)):
1301?>
1302 topWindow.BX.evalGlobal('<?=CUtil::JSEscape($this->onLoadScript)?>');
1303<?
1304 endif;
1305?>
1306};
1307topWindow.BX.ajax.UpdatePageData({});
1308</script></body></html>
1309<?
1310 }
1311 else
1312 {
1313 if(isset($this->onLoadScript)):
1314?>
1315<script><?=$this->onLoadScript?></script>
1316<?
1317 endif;
1318
1319 echo $string;
1320 }
1321 define("ADMIN_AJAX_MODE", true);
1322 require($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/main/include/epilog_admin_after.php");
1323 die();
1324 }
1325 elseif ($this->isExportMode())
1326 {
1327 $fname = basename($APPLICATION->GetCurPage(), ".php");
1328 // http response splitting defence
1329 $fname = str_replace(array("\r", "\n"), "", $fname);
1330
1331 header("Content-Type: application/vnd.ms-excel");
1332 header("Content-Disposition: filename=".$fname.".xls");
1333 $APPLICATION->EndBufferContentMan();
1334 $this->DisplayExcel();
1335 require($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/main/include/epilog_admin_after.php");
1336 die();
1337 }
1338 }
1339
1340 protected function DisplayEditButtons(): void
1341 {
1342?>
1343 <input type="hidden" name="save" id="<?=$this->table_id?>_hidden_save" value="Y">
1344 <input type="submit" class="adm-btn-save" name="save" value="<?=GetMessage("admin_lib_list_edit_save")?>" title="<?=GetMessage("admin_lib_list_edit_save_title")?>" />
1345 <input type="button" onclick="BX('<?=$this->table_id?>_hidden_save').name='cancel'; <?=htmlspecialcharsbx($this->ActionPost(false, 'action_button', ''))?> " name="cancel" value="<?=GetMessage("admin_lib_list_edit_cancel")?>" title="<?=GetMessage("admin_lib_list_edit_cancel_title")?>" />
1346<?
1347 }
1348
1349 protected function isAjaxDebug(): bool
1350 {
1351 return
1352 $this->request->get('ajax_debugx') === 'Y'
1353 || (isset($this->session['AJAX_DEBUGX']) && $this->session['AJAX_DEBUGX'])
1354 ;
1355 }
1356
1357 protected static function getUrlWithLanguage(string $url, bool $safeMode = true): string
1358 {
1359 if (!str_contains($url, 'lang='))
1360 {
1361 $url .= (!str_contains($url, '?') ? '?' : '&')
1362 .'lang='.LANGUAGE_ID
1363 ;
1364 }
1365
1366 return $safeMode
1367 ? CUtil::addslashes($url)
1368 : $url
1369 ;
1370 }
1371
1372 protected static function getModeUrlParam(string $mode): string
1373 {
1374 return self::MODE_FIELD_NAME . '=' . $mode;
1375 }
1376
1377 protected static function getModeActionUrlParam(): string
1378 {
1379 return static::getModeUrlParam(self::MODE_ACTION);
1380 }
1381
1382 protected static function getModeConfigUrlParam(): string
1383 {
1384 return static::getModeUrlParam(self::MODE_CONFIG);
1385 }
1386
1387 protected static function getModeExportUrlParam(): string
1388 {
1389 return static::getModeUrlParam(self::MODE_EXPORT);
1390 }
1391
1392 protected static function getModeParam(string $mode): array
1393 {
1394 return [self::MODE_FIELD_NAME => $mode];
1395 }
1396
1397 protected static function getModeExportParam(): array
1398 {
1399 return static::getModeParam(self::MODE_EXPORT);
1400 }
1401}
1402
1403class CAdminListRow
1404{
1405 var $aHeaders = array();
1406 var $aHeadersID = array();
1407 var $aFields = array();
1408 var $aActions = array();
1409 var $table_id;
1410 var $indexFields = 0;
1411 var $edit = false;
1412 var $id;
1413 var $bReadOnly = false;
1414 var $aFeatures = array();
1415 var $bEditMode = false;
1416 var $arRes;
1417 var $link;
1418 var $title;
1419 var $pList;
1420 var $isPublicMode;
1421
1422 protected $config;
1423
1429 public function __construct(&$aHeaders, $table_id)
1430 {
1431 $this->aHeaders = $aHeaders;
1432 $this->aHeadersID = array_keys($aHeaders);
1433 $this->table_id = $table_id;
1434
1435 $this->setPublicModeState(defined('PUBLIC_MODE') && PUBLIC_MODE == 1);
1436
1437 $this->config = [];
1438 }
1439
1440 public function setPublicModeState(bool $mode): void
1441 {
1442 $this->isPublicMode = $mode;
1443 }
1444
1445 public function getPublicModeState(): bool
1446 {
1447 return $this->isPublicMode;
1448 }
1449
1450 public function setConfig(array $config): void
1451 {
1452 $this->config = $config;
1453 }
1454
1455 public function getConfig(): array
1456 {
1457 return $this->config;
1458 }
1459
1460 public function getConfigValue(string $index)
1461 {
1462 return $this->config[$index] ?? null;
1463 }
1464
1465 function SetFeatures($aFeatures)
1466 {
1467 //array("footer"=>true)
1468 $this->aFeatures = $aFeatures;
1469 }
1470
1471 function AddField($id, $text, $edit=false, $isHtml = true)
1472 {
1473 $this->aFields[$id] = array();
1474 if ($edit !== false)
1475 {
1476 $this->aFields[$id]["edit"] = array("type" => "input", "value" => $edit);
1477 $this->pList->bCanBeEdited = true;
1478 }
1479 $type = $isHtml ? "html" : "text";
1480 $this->aFields[$id]["view"] = array("type" => $type, "value" => $text);
1481 }
1482
1488 function AddCheckField($id, $arAttributes = Array())
1489 {
1490 if($arAttributes!==false)
1491 {
1492 $this->aFields[$id]["edit"] = Array("type"=>"checkbox", "attributes"=>$arAttributes);
1493 $this->pList->bCanBeEdited = true;
1494 }
1495 $this->aFields[$id]["view"] = Array("type"=>"checkbox");
1496 }
1497
1504 function AddSelectField($id, $arValues = Array(), $arAttributes = Array())
1505 {
1506 if($arAttributes!==false)
1507 {
1508 $this->aFields[$id]["edit"] = Array("type"=>"select", "values"=>$arValues, "attributes"=>$arAttributes);
1509 $this->pList->bCanBeEdited = true;
1510 }
1511 $this->aFields[$id]["view"] = Array("type"=>"select", "values"=>$arValues);
1512 }
1513
1519 function AddInputField($id, $arAttributes = Array())
1520 {
1521 if ($arAttributes !== false)
1522 {
1523 $arAttributes['size'] = (int)($arAttributes['size'] ?? 0);
1524 $this->aFields[$id]["edit"] = Array("type"=>"input", "attributes"=>$arAttributes);
1525 $this->pList->bCanBeEdited = true;
1526 }
1527 }
1528
1535 function AddCalendarField($id, $arAttributes = Array(), $useTime = false)
1536 {
1537 if ($arAttributes!==false)
1538 {
1539 $arAttributes['size'] = (int)($arAttributes['size'] ?? 0);
1540 $this->aFields[$id]["edit"] = array("type"=>"calendar", "attributes"=>$arAttributes, "useTime" => $useTime);
1541 $this->pList->bCanBeEdited = true;
1542 }
1543 }
1544
1550 function AddMoneyField($id, $arAttributes = [])
1551 {
1552 if($arAttributes!==false)
1553 {
1554 $this->aFields[$id]["edit"] = Array("type"=>"money", "attributes"=>$arAttributes);
1555 $this->pList->bCanBeEdited = true;
1556 }
1557 }
1558
1559 function AddViewField($id, $sHTML)
1560 {
1561 $this->aFields[$id]["view"] = Array("type"=>"html", "value"=>$sHTML);
1562 }
1563
1564 function AddEditField($id, $sHTML)
1565 {
1566 $this->aFields[$id]["edit"] = Array("type"=>"html", "value"=>$sHTML);
1567 $this->pList->bCanBeEdited = true;
1568 }
1569
1575 function AddViewFileField($id, $showInfo = false)
1576 {
1577 static $fileman = 0;
1578 if (!($fileman++))
1579 CModule::IncludeModule('fileman');
1580
1581 $this->aFields[$id]["view"] = array(
1582 "type" => "file",
1583 "showInfo" => $showInfo,
1584 "inputs" => array(
1585 'upload' => false,
1586 'medialib' => false,
1587 'file_dialog' => false,
1588 'cloud' => false,
1589 'del' => false,
1590 'description' => false,
1591 ),
1592 );
1593 }
1594
1601 function AddFileField($id, $showInfo = false, $inputs = array())
1602 {
1603 $this->aFields[$id]["edit"] = array(
1604 "type" => "file",
1605 "showInfo" => $showInfo,
1606 "inputs" => $inputs,
1607 );
1608 $this->pList->bCanBeEdited = true;
1609 $this->AddViewFileField($id, $showInfo);
1610 }
1611
1612 function AddActions($aActions)
1613 {
1614 if (is_array($aActions))
1615 $this->aActions = $aActions;
1616 }
1617
1618 function __AttrGen($attr)
1619 {
1620 $res = '';
1621 foreach($attr as $name=>$val)
1622 $res .= ' '.htmlspecialcharsbx($name).'="'.htmlspecialcharsbx($val).'"';
1623
1624 return $res;
1625 }
1626
1627 function VarsFromForm()
1628 {
1629 return ($this->bEditMode && is_array($this->pList->arUpdateErrorIDs) && in_array($this->id, $this->pList->arUpdateErrorIDs));
1630 }
1631
1632 function Display()
1633 {
1634 // Check after grid event handlers
1635 if (!is_array($this->aActions))
1636 {
1637 $this->aActions = [];
1638 }
1639
1640 $sDefAction = $sDefTitle = "";
1641
1642 if(!$this->bEditMode)
1643 {
1644 if(!empty($this->link))
1645 {
1646 $sDefAction = $this->getActionLink($this->link);
1647 $sDefTitle = $this->title;
1648 }
1649 else
1650 {
1651 foreach($this->aActions as $action)
1652 {
1653 if (isset($action["DEFAULT"]) && $action["DEFAULT"] == true)
1654 {
1655 $sDefAction = $this->getActionsItemLink($action);
1656 $sDefTitle = (!empty($action["TITLE"])? $action["TITLE"] : $action["TEXT"]);
1657 break;
1658 }
1659 }
1660 }
1661
1662 $sDefAction = htmlspecialcharsbx($sDefAction);
1663 $sDefTitle = htmlspecialcharsbx($sDefTitle);
1664 }
1665
1666 $sMenuItems = "";
1667 if(!empty($this->aActions))
1668 $sMenuItems = htmlspecialcharsbx(CAdminPopup::PhpToJavaScript($this->aActions));
1669?>
1670<tr class="adm-list-table-row<?=(isset($this->aFeatures["footer"]) && $this->aFeatures["footer"] == true? ' footer':'')?><?=$this->bEditMode?' adm-table-row-active' : ''?>"<?=($sMenuItems <> ""? ' oncontextmenu="return '.$sMenuItems.';"':'');?><?=($sDefAction <> ""? ' ondblclick="'.$sDefAction.'"'.(!empty($sDefTitle)? ' title="'.GetMessage("admin_lib_list_double_click").' '.$sDefTitle.'"':''):'')?>>
1671<?
1672
1673 if (!empty($this->pList->arActions) || $this->pList->bCanBeEdited):
1674 $check_id = RandString(5);
1675?>
1676 <td class="adm-list-table-cell adm-list-table-checkbox adm-list-table-checkbox-hover<?=$this->bReadOnly? ' adm-list-table-checkbox-disabled':''?>"><input type="checkbox" class="adm-checkbox adm-designed-checkbox" name="ID[]" id="<?=$this->table_id."_".$this->id."_".$check_id;?>" value="<?=$this->id?>" autocomplete="off" title="<?=GetMessage("admin_lib_list_check")?>"<?=$this->bReadOnly? ' disabled="disabled"':''?><?=$this->bEditMode ? ' checked="checked" disabled="disabled"' : ''?> /><label class="adm-designed-checkbox-label adm-checkbox" for="<?=$this->table_id."_".$this->id."_".$check_id;?>"></label></td>
1677<?
1678 endif;
1679
1680 if($this->pList->bShowActions):
1681 if(!empty($this->aActions)):
1682?>
1683 <td class="adm-list-table-cell adm-list-table-popup-block" onclick="BX.adminList.ShowMenu(this.firstChild, this.parentNode.oncontextmenu(), this.parentNode);"><div class="adm-list-table-popup" title="<?=GetMessage("admin_lib_list_actions_title")?>"></div></td>
1684<?
1685 else:
1686?>
1687 <td class="adm-list-table-cell"></td>
1688<?
1689 endif;
1690 endif;
1691
1692 end($this->pList->aVisibleHeaders);
1693 $last_id = key($this->pList->aVisibleHeaders);
1694 reset($this->pList->aVisibleHeaders);
1695
1696 $bVarsFromForm = ($this->bEditMode && is_array($this->pList->arUpdateErrorIDs) && in_array($this->id, $this->pList->arUpdateErrorIDs));
1697 foreach($this->pList->aVisibleHeaders as $id=>$header_props)
1698 {
1699 $field = $this->aFields[$id] ?? [];
1700 if ($this->bEditMode && isset($field["edit"]))
1701 {
1702 if ($bVarsFromForm && isset($_REQUEST["FIELDS"]))
1703 {
1704 $val = $_REQUEST["FIELDS"][$this->id][$id] ?? '';
1705 }
1706 else
1707 {
1708 $val = $this->arRes[$id] ?? '';
1709 }
1710
1711 $val_old = $this->arRes[$id] ?? '';
1712
1713 echo '<td class="adm-list-table-cell',
1714 (isset($header_props['align']) && $header_props['align']? ' align-'.$header_props['align']: ''),
1715 (isset($header_props['valign']) && $header_props['valign']? ' valign-'.$header_props['valign']: ''),
1716 ($id === $last_id? ' adm-list-table-cell-last': ''),
1717 '">';
1718
1719 if(is_array($val_old))
1720 {
1721 foreach($val_old as $k=>$v)
1722 echo '<input type="hidden" name="FIELDS_OLD['.htmlspecialcharsbx($this->id).']['.htmlspecialcharsbx($id).']['.htmlspecialcharsbx($k).']" value="'.htmlspecialcharsbx($v).'">';
1723 }
1724 else
1725 {
1726 echo '<input type="hidden" name="FIELDS_OLD['.htmlspecialcharsbx($this->id).']['.htmlspecialcharsbx($id).']" value="'.htmlspecialcharsbx($val_old).'">';
1727 }
1728 switch($field["edit"]["type"])
1729 {
1730 case "checkbox":
1731 echo '<input type="hidden" name="FIELDS['.htmlspecialcharsbx($this->id).']['.htmlspecialcharsbx($id).']" value="N">';
1732 echo '<input type="checkbox" name="FIELDS['.htmlspecialcharsbx($this->id).']['.htmlspecialcharsbx($id).']" value="Y"'.($val=='Y' || $val === true?' checked':'').'>';
1733 break;
1734 case "select":
1735 echo '<select name="FIELDS['.htmlspecialcharsbx($this->id).']['.htmlspecialcharsbx($id).']"'.$this->__AttrGen($field["edit"]["attributes"]).'>';
1736 foreach($field["edit"]["values"] as $k=>$v)
1737 echo '<option value="'.htmlspecialcharsbx($k).'" '.($k==$val?' selected':'').'>'.htmlspecialcharsbx($v).'</option>';
1738 echo '</select>';
1739 break;
1740 case "input":
1741 if(!$field["edit"]["attributes"]["size"])
1742 $field["edit"]["attributes"]["size"] = "10";
1743 echo '<input type="text" '.$this->__AttrGen($field["edit"]["attributes"]).' name="FIELDS['.htmlspecialcharsbx($this->id).']['.htmlspecialcharsbx($id).']" value="'.htmlspecialcharsbx($val).'">';
1744 break;
1745 case "calendar":
1746 if(!$field["edit"]["attributes"]["size"])
1747 $field["edit"]["attributes"]["size"] = "10";
1748 echo '<span style="white-space:nowrap;"><input type="text" '.$this->__AttrGen($field["edit"]["attributes"]).' name="FIELDS['.htmlspecialcharsbx($this->id).']['.htmlspecialcharsbx($id).']" value="'.htmlspecialcharsbx($val).'">';
1749 echo CAdminCalendar::Calendar(
1750 'FIELDS['.htmlspecialcharsbx($this->id).']['.htmlspecialcharsbx($id).']',
1751 '',
1752 '',
1753 $field['edit']['useTime']
1754 ).'</span>';
1755 break;
1756 case "file":
1757 echo CFileInput::Show(
1758 'FIELDS['.htmlspecialcharsbx($this->id).']['.htmlspecialcharsbx($id).']',
1759 $val,
1760 $field["edit"]["showInfo"],
1761 $field["edit"]["inputs"]
1762 );
1763 break;
1764 default:
1765 echo $field["edit"]['value'];
1766 }
1767 echo '</td>';
1768 }
1769 else
1770 {
1771 $val = $this->arRes[$id] ?? '';
1772 if (is_string($val))
1773 {
1774 $val = trim($val);
1775 }
1776
1777 if(isset($field["view"]))
1778 {
1779 switch($field["view"]["type"])
1780 {
1781 case "checkbox":
1782 if($val == 'Y' || $val === true)
1783 $val = htmlspecialcharsex(GetMessage("admin_lib_list_yes"));
1784 else
1785 $val = htmlspecialcharsex(GetMessage("admin_lib_list_no"));
1786 break;
1787 case "select":
1788 if (isset($field["edit"]["values"][$val]))
1789 {
1790 $val = htmlspecialcharsex($field["edit"]["values"][$val]);
1791 }
1792 elseif (isset($field["view"]["values"][$val]))
1793 {
1794 $val = htmlspecialcharsex($field["view"]["values"][$val]);
1795 }
1796 else
1797 {
1798 $val = htmlspecialcharsex($val);
1799 }
1800 break;
1801 case "file":
1802 if ($val > 0)
1803 $val = CFileInput::Show(
1804 'NO_FIELDS['.htmlspecialcharsbx($this->id).']['.htmlspecialcharsbx($id).']',
1805 $val,
1806 $field["view"]["showInfo"],
1807 $field["view"]["inputs"]
1808 );
1809 else
1810 $val = '';
1811 break;
1812 case "html":
1813 $val = $field["view"]['value'];
1814 break;
1815 default:
1816 $val = htmlspecialcharsex($val);
1817 break;
1818 }
1819 }
1820 else
1821 {
1822 $val = htmlspecialcharsex($val);
1823 }
1824
1825 echo '<td class="adm-list-table-cell',
1826 (isset($header_props['align']) && $header_props['align']? ' align-'.$header_props['align']: ''),
1827 (isset($header_props['valign']) && $header_props['valign']? ' valign-'.$header_props['valign']: ''),
1828 ($id === $last_id? ' adm-list-table-cell-last': ''),
1829 '">';
1830 echo ((string)$val <> ""? $val: '&nbsp;');
1831 if(isset($field["edit"]) && $field["edit"]["type"] == "calendar")
1832 CAdminCalendar::ShowScript();
1833 echo '</td>';
1834 }
1835 }
1836?>
1837</tr>
1838<?
1839 }
1840
1845 protected function getActionLink($url)
1846 {
1847 global $adminSidePanelHelper;
1848 if (is_object($adminSidePanelHelper) && $adminSidePanelHelper->isPublicSidePanel())
1849 return "BX.adminSidePanel.onOpenPage('".CUtil::JSEscape($url)."');";
1850 return "BX.adminPanel.Redirect([], '".CUtil::JSEscape($url)."', event);";
1851 }
1852
1857 protected function getActionsItemLink(array $item)
1858 {
1859 return (!empty($item["ACTION"])
1860 ? $item["ACTION"]
1861 : $this->getActionLink($item["LINK"])
1862 );
1863 }
1864}
return select
Определения access_edit.php:440
<?=$taskID?> selected
Определения access_edit.php:348
global $APPLICATION
Определения include.php:80
static getInstance()
Определения application.php:98
static sortByColumn(array &$array, $columns, $callbacks='', $defaultValueIfNotSetValue=null, $preserveKeys=false)
Определения collection.php:24
Определения json.php:9
Определения uri.php:17
Определения admin_list.php:16
isExportMode()
Определения admin_list.php:531
GetSystemContextMenu(array $config=[])
Определения admin_list.php:217
$arFilterErrors
Определения admin_list.php:36
IsGroupActionToAll()
Определения admin_list.php:445
GetGroupIds()
Определения admin_list.php:472
PrepareAction()
Определения admin_list.php:453
EditAction()
Определения admin_list.php:314
$arUpdateErrors
Определения admin_list.php:37
const MODE_PAGE
Определения admin_list.php:17
getFilter()
Определения admin_list.php:96
__construct($table_id, $sort=false)
Определения admin_list.php:69
$bCanBeDeleted
Определения admin_list.php:45
$isPublicMode
Определения admin_list.php:54
$aHeader
Определения admin_list.php:32
$mode
Определения admin_list.php:59
$aVisibleHeaders
Определения admin_list.php:29
GroupAction()
Определения admin_list.php:399
setPublicModeState(bool $mode)
Определения admin_list.php:82
const MODE_EXPORT
Определения admin_list.php:20
$arVisibleColumns
Определения admin_list.php:33
$arEditedRows
Определения admin_list.php:53
$sort
Определения admin_list.php:27
ConvertFilesToEditFields()
Определения admin_list.php:388
isActionMode()
Определения admin_list.php:556
$sContent
Определения admin_list.php:50
GetAction()
Определения admin_list.php:464
AddVisibleHeaderColumn($id)
Определения admin_list.php:181
$bEditMode
Определения admin_list.php:42
$arActions
Определения admin_list.php:46
$sEpilogContent
Определения admin_list.php:50
$sPrologContent
Определения admin_list.php:50
$aRows
Определения admin_list.php:31
const MODE_LIST
Определения admin_list.php:18
GetEditFields()
Определения admin_list.php:366
GetVisibleHeaderColumns()
Определения admin_list.php:190
getCurrentMode()
Определения admin_list.php:515
$arActionsParams
Определения admin_list.php:47
$arGroupErrors
Определения admin_list.php:39
$bShowActions
Определения admin_list.php:51
$table_id
Определения admin_list.php:25
$aFooter
Определения admin_list.php:34
const MODE_ACTION
Определения admin_list.php:19
ShowSettings($aAllCols, $aCols, $aOptions)
Определения admin_list.php:170
$bCanBeEdited
Определения admin_list.php:44
getModeList()
Определения admin_list.php:502
const MODE_CONFIG
Определения admin_list.php:21
$arActionSuccess
Определения admin_list.php:41
$bMultipart
Определения admin_list.php:43
$request
Определения admin_list.php:61
isConfigMode()
Определения admin_list.php:548
getPublicModeState()
Определения admin_list.php:91
$session
Определения admin_list.php:63
isListMode()
Определения admin_list.php:564
ActionPost($url=false, $action_name=false, $action_value='Y')
Определения admin_list.php:589
$arUpdateErrorIDs
Определения admin_list.php:38
isAjaxMode()
Определения admin_list.php:539
$sNavText
Определения admin_list.php:35
$aHeaders
Определения admin_list.php:28
$onLoadScript
Определения admin_list.php:52
SetContextMenu(array $menu=[], array $additional=[], array $config=[])
Определения admin_list.php:209
const MODE_FIELD_NAME
Определения admin_list.php:23
ActionAjaxReload($url)
Определения admin_list.php:584
$context
Определения admin_list.php:49
AddAdminContextMenu($aContext=array(), $bShowExcel=true, $bShowSettings=true)
Определения admin_list.php:195
$arGroupErrorIDs
Определения admin_list.php:40
AddHeaders($aParams)
Определения admin_list.php:102
InitContextMenu(array $menu=[], array $additional=[])
Определения admin_list.php:254
ActionRedirect($url)
Определения admin_list.php:569
initMode()
Определения admin_list.php:485
IsUpdated($ID)
Определения admin_list.php:266
isPageMode()
Определения admin_list.php:523
$f
Определения component_props.php:52
$selfFolderUrl
Определения discount_coupon_list.php:18
& nbsp
Определения epilog_main_admin.php:38
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
<? if( $useEditor3):?>< tr class="heading">< td colspan="2"><? echo GetMessage("FILEMAN_OPTION_SPELL_SET");?></td ></tr ><? if(function_exists( 'pspell_config_create')):$use_pspell_checked=(COption::GetOptionString( $module_id, "use_pspell", "Y")=="Y") ? "checked" :"";?>< tr >< td valign="top">< label for="use_pspell"><?echo GetMessage("FILEMAN_OPTION_USE_PSPELL");?></label >< br >< a title="<?echo GetMessage("FILEMAN_OPTION_ADDISH_DICS_TITLE");?> http
Определения options.php:1473
$res
Определения filter_act.php:7
Form FILTER_ACTION disabled
Определения options.php:358
$_REQUEST["admin_mnu_menu_id"]
Определения get_menu.php:8
$result
Определения get_property_values.php:14
if($ajaxMode) $ID
Определения get_user.php:27
$filter
Определения iblock_catalog_list.php:54
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
global $USER
Определения csv_new_run.php:40
check_bitrix_sessid($varname='sessid')
Определения tools.php:4686
DeleteParam($ParamNames)
Определения tools.php:4548
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
GetMessage($name, $aReplace=null)
Определения tools.php:3397
$GLOBALS['____1690880296']
Определения license.php:1
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
<? endif;?> window document title
Определения prolog_main_admin.php:76
$config
Определения quickway.php:69
if(empty($signedUserToken)) $key
Определения quickway.php:257
die
Определения quickway.php:367
lang
Определения options.php:182
$i
Определения factura.php:643
font style
Определения invoice.php:442
font size
Определения invoice.php:442
text align
Определения template.php:556
foreach($aAllCols as $header) $bEmptyCols
Определения settings_admin_list.php:50
$k
Определения template_pdf.php:567
$action
Определения file_dialog.php:21
$url
Определения iframe.php:7
$fields
Определения yandex_run.php:501