| Current Path : /var/www/homesaver/www/bitrix/modules/webdebug.excel/admin/ |
| Current File : /var/www/homesaver/www/bitrix/modules/webdebug.excel/admin/webdebug_excel_profiles.php |
<?
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_before.php");
require_once($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/webdebug.excel/install/demo.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/webdebug.excel/prolog.php');
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/webdebug.excel/include.php");
IncludeModuleLangFile(__FILE__);
if (COption::GetOptionString('webdebug.excel','use_version')==2) {
LocalRedirect('wd_excel2_profiles.php?lang='.LANGUAGE_ID);
}
if (webdebug_excel_demo_expired()) {
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_after.php");
webdebug_excel_show_demo();
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin.php");
die();
}
$ModuleRights = $APPLICATION->GetGroupRight("webdebug.excel");
if($ModuleRights=="D") {
$APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
}
$sTableID = "WebdebugExcelProfiles";
$oSort = new CAdminSorting($sTableID, "SORT", "ASC");
$lAdmin = new CAdminList($sTableID, $oSort);
// Filter
function CheckFilter() {
global $FilterArr, $lAdmin;
foreach ($FilterArr as $f) global $f;
return count($lAdmin->arFilterErrors)==0;
}
$FilterArr = Array(
"find_id",
"find_name",
"find_active",
"find_sort",
"find_description",
);
$lAdmin->InitFilter($FilterArr);
if (CheckFilter()) {
$arFilter = Array(
"ID" => $find_id,
"%NAME" => $find_name,
"ACTIVE" => $find_active,
"SORT" => $find_sort,
"%DESCRIPTION" => $find_description,
);
}
// Processing with actions
if($lAdmin->EditAction()) {
foreach($FIELDS as $ID=>$arFields) {
if(!$lAdmin->IsUpdated($ID)) continue;
$DB->StartTransaction();
$ID = IntVal($ID);
if(($rsData = CWebdebugExcelProfile::GetByID($ID)) && ($arData = $rsData->Fetch())) {
foreach($arFields as $key=>$value) $arData[$key]=$value;
unset($arData["PHRASES_COUNT"]);
if(!CWebdebugExcelProfile::Update($ID, $arData)) {
$lAdmin->AddGroupError(GetMessage("rub_save_error"), $ID);
$DB->Rollback();
}
} else {
$lAdmin->AddGroupError(GetMessage("rub_save_error")." ".GetMessage("rub_no_rubric"), $ID);
$DB->Rollback();
}
$DB->Commit();
}
}
if(($arID = $lAdmin->GroupAction())) {
if($_REQUEST['action_target']=='selected') {
$rsData = CWebdebugExcelProfile::GetList(array($by=>$order), $arFilter);
while($arRes = $rsData->Fetch()) $arID[] = $arRes['ID'];
}
foreach($arID as $ID) {
if(strlen($ID)<=0) continue;
$ID = IntVal($ID);
switch($_REQUEST['action']) {
case "delete":
@set_time_limit(0);
$DB->StartTransaction();
if(!CWebdebugExcelProfile::Delete($ID)) {
$DB->Rollback();
$lAdmin->AddGroupError(GetMessage("rub_del_err"), $ID);
}
$DB->Commit();
break;
case "activate":
case "deactivate":
if(($rsData = CWebdebugExcelProfile::GetByID($ID)) && ($arFields = $rsData->Fetch())) {
$arFields["ACTIVE"]=($_REQUEST['action']=="activate"?"Y":"N");
if(!CWebdebugExcelProfile::Update($ID, $arFields)) {
$lAdmin->AddGroupError(GetMessage("rub_save_error"), $ID);
}
} else {
$lAdmin->AddGroupError(GetMessage("rub_save_error")." ".GetMessage("rub_no_rubric"), $ID);
}
break;
}
}
}
// Get items list
$rsData = CWebdebugExcelProfile::GetList(array($by => $order), $arFilter);
$rsData = new CAdminResult($rsData, $sTableID);
$rsData->NavStart();
$lAdmin->NavText($rsData->GetNavPrint(GetMessage("rub_nav")));
// Add headers
$lAdmin->AddHeaders(array(
array(
"id" => "ID",
"content" => GetMessage("WEBDEBUG_EXCEL_HEADER_ID"),
"sort" => "id",
"align" => "right",
"default" => true,
),
array(
"id" =>"NAME",
"content" => GetMessage("WEBDEBUG_EXCEL_HEADER_NAME"),
"sort" => "name",
"align" => "left",
"default" => true,
),
array(
"id" =>"ACTIVE",
"content" => GetMessage("WEBDEBUG_EXCEL_HEADER_ACTIVE"),
"sort" => "active",
"align" => "center",
"default" => true,
),
array(
"id" =>"SORT",
"content" => GetMessage("WEBDEBUG_EXCEL_HEADER_SORT"),
"sort" => "sort",
"align" => "right",
"default" => true,
),
array(
"id" =>"DESCRIPTION",
"content" => GetMessage("WEBDEBUG_EXCEL_HEADER_DESCRIPTION"),
"sort" => "description",
"align" => "left",
"default" => true,
),
));
// Build items list
while ($arRes = $rsData->NavNext(true, "f_")) {
$row = &$lAdmin->AddRow($f_ID, $arRes);
// ID
$row->AddViewField("ID", "<a href='webdebug_excel_profile_edit.php?ID={$f_ID}&lang=".LANGUAGE_ID."' title='".GetMessage("WEBDEBUG_EXCEL_EDITPROFILE")."'>{$f_ID}</a>");
// NAME
$row->AddInputField("NAME",array("SIZE" => "40"));
$row->AddViewField("NAME", "<a href='webdebug_excel_profile_edit.php?ID={$f_ID}&lang=".LANGUAGE_ID."' title='".GetMessage("WEBDEBUG_EXCEL_EDITPROFILE")."'>{$f_NAME}</a>");
// ACTIVE
$row->AddCheckField("ACTIVE");
// SORT
$row->AddInputField("SORT", array("SIZE"=>5));
// DESCR
$sHTML = '<textarea rows="5" cols="50" name="FIELDS['.$f_ID.'][DESCRIPTION]">'.htmlspecialchars($row->arRes["DESCRIPTION"]).'</textarea>';
$row->AddEditField("DESCRIPTION", $sHTML);
$row->AddViewField("DESCRIPTION", $f_DESCRIPTION);
// Build context menu
$arActions = Array();
$arActions[] = array(
"ICON" => "edit",
"DEFAULT"=>true,
"TEXT" => GetMessage("WEBDEBUG_EXCEL_CONTEXT_EDIT"),
"ACTION"=>$lAdmin->ActionRedirect("webdebug_excel_profile_edit.php?ID=".$f_ID."&lang=".LANGUAGE_ID)
);
$arActions[] = array(
"ICON" => "delete",
"DEFAULT"=>false,
"TEXT" => GetMessage("WEBDEBUG_EXCEL_CONTEXT_DELETE"),
"ACTION" => "if(confirm('".sprintf(GetMessage('WEBDEBUG_EXCEL_CONTEXT_DELETE_CONFIRM'), $f_NAME)."')&&'u254'=='u254') ".$lAdmin->ActionDoGroup($f_ID, "delete")
);
$arActions[] = array("SEPARATOR"=>true);
if(is_set($arActions[count($arActions)-1], "SEPARATOR")) {
unset($arActions[count($arActions)-1]);
}
$row->AddActions($arActions);
}
// List Footer
$lAdmin->AddFooter(
array(
array("title" => GetMessage("MAIN_ADMIN_LIST_SELECTED"), "value"=>$rsData->SelectedRowsCount()),
array("counter"=>true, "title" => GetMessage("MAIN_ADMIN_LIST_CHECKED"), "value" => "0"),
)
);
$lAdmin->AddGroupActionTable(Array(
"delete" => GetMessage("MAIN_ADMIN_LIST_DELETE"),
"activate" => GetMessage("MAIN_ADMIN_LIST_ACTIVATE"),
"deactivate" => GetMessage("MAIN_ADMIN_LIST_DEACTIVATE"),
));
// Context menu
global $APPLICATION;
$aContext = array(
array(
"TEXT" => GetMessage("WEBDEBUG_EXCEL_TOOLBAR_ADD_NAME"),
"LINK" => "webdebug_excel_profile_edit.php?lang=".LANGUAGE_ID,
"TITLE" => GetMessage("WEBDEBUG_EXCEL_TOOLBAR_ADD_DESC"),
"ICON" => "btn_new",
),
array(
"TEXT" => GetMessage("WEBDEBUG_EXCEL_TOOLBAR_IMPORT_NAME"),
"LINK" => "javascript:".$APPLICATION->GetPopupLink(
array(
"URL" => "/bitrix/admin/webdebug_excel_ajax_start.php?lang=".LANGUAGE_ID."&public=Y&bxpublic=Y&str_URI=".urlencode($APPLICATION->GetCurPageParam("", array("clear_cache", "sessid", "login", "logout", "register", "forgot_password", "change_password", "confirm_registration", "confirm_code", "confirm_user_id", "bitrix_include_areas", "show_page_exec_time", "show_include_exec_time", "show_sql_stat", "show_link_stat")))."&site=".SITE_ID,
"PARAMS" => array(
'width' => COption::GetOptionString("webdebug.excel","popup_width"),
'height' => COption::GetOptionString("webdebug.excel","popup_height"),
'resize' => false,
'resizable' => false,
)
)
),
"TITLE" => GetMessage("WEBDEBUG_EXCEL_TOOLBAR_IMPORT_DESC"),
"ICON" => "btn_green",
),
);
$lAdmin->AddAdminContextMenu($aContext);
// Start output
$lAdmin->CheckListMode();
$APPLICATION->SetTitle(GetMessage("WEBDEBUG_EXCEL_APPLICATION_TITLE"));
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_after.php");
if (!webdebug_excel_demo_expired()) {
webdebug_excel_show_demo();
}
// Output filter
$oFilter = new CAdminFilter(
$sTableID."_filter",
array(
GetMessage("WEBDEBUG_EXCEL_FILTER_NAME"),
GetMessage("WEBDEBUG_EXCEL_FILTER_ACTIVE"),
GetMessage("WEBDEBUG_EXCEL_FILTER_SORT"),
GetMessage("WEBDEBUG_EXCEL_FILTER_DESCR"),
)
);
?>
<form name="find_form" method="get" action="<?=$APPLICATION->GetCurPage();?>">
<?$oFilter->Begin();?>
<tr>
<td><b><?=GetMessage("WEBDEBUG_EXCEL_FILTER_ID")?>:</b></td>
<td>
<input type="text" size="25" name="find_id" value="<?=htmlspecialchars($find_id)?>" title="<?=GetMessage("WEBDEBUG_EXCEL_FILTER_ID_DESCR");?>"/>
</td>
</tr>
<tr>
<td><?=GetMessage("WEBDEBUG_EXCEL_FILTER_NAME")?>:</td>
<td><input type="text" size="50" maxlength="255" name="find_name" value="<?=htmlspecialchars($find_name)?>" title="<?=GetMessage("WEBDEBUG_EXCEL_FILTER_NAME_DESCR");?>"/></td>
</tr>
<tr>
<td><?=GetMessage("WEBDEBUG_EXCEL_FILTER_ACTIVE")?>:</td>
<td>
<?
$arr = array(
"reference" => array(
GetMessage("WEBDEBUG_EXCEL_FILTER_ACTIVE_Y"),
GetMessage("WEBDEBUG_EXCEL_FILTER_ACTIVE_N"),
),
"reference_id" => array("Y","N")
);
echo SelectBoxFromArray("find_active", $arr, $find_active, GetMessage("WEBDEBUG_EXCEL_FILTER_ACTIVE_ANY"), "");
?>
</td>
</tr>
<tr>
<td><?=GetMessage("WEBDEBUG_EXCEL_FILTER_SORT")?>:</td>
<td><input type="text" size="10" maxlength="10" name="find_sort" value="<?=htmlspecialchars($find_sort)?>" title="<?=GetMessage("WEBDEBUG_EXCEL_FILTER_SORT_DESCR");?>"/></td>
</tr>
<tr>
<td><?=GetMessage("WEBDEBUG_EXCEL_FILTER_DESCR")?>:</td>
<td><input type="text" size="50" maxlength="255" name="find_description" value="<?=htmlspecialchars($find_description)?>" title="<?=GetMessage("WEBDEBUG_EXCEL_FILTER_DESCR_DESCR");?>"/></td>
</tr>
<?$oFilter->Buttons(array("table_id"=>$sTableID,"url"=>$APPLICATION->GetCurPage(),"form" => "find_form"));?>
<?$oFilter->End();?>
</form>
<?// Output ?>
<?$lAdmin->DisplayList();?>
<?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin.php");?>