Пример #1
0
 protected function setNavStartParams()
 {
     if ($this->arParams['PAGER_SAVE_SESSION'] !== 'Y') {
         \CPageOption::SetOptionString('main', 'nav_page_in_session', 'N');
     }
     $this->arParams['PAGER_DESC_NUMBERING'] = $this->arParams['PAGER_DESC_NUMBERING'] === 'Y';
     if ($this->arParams['DISPLAY_BOTTOM_PAGER'] === 'Y' || $this->arParams['DISPLAY_TOP_PAGER'] === 'Y') {
         $this->navStartParams = ['nPageSize' => $this->arParams['ELEMENTS_COUNT'], 'bDescPageNumbering' => $this->arParams['PAGER_DESC_NUMBERING'], 'bShowAll' => $this->arParams['PAGER_SHOW_ALL']];
         $this->addCacheAdditionalId(\CDBResult::GetNavParams($this->navStartParams));
     } elseif ($this->arParams['ELEMENTS_COUNT'] > 0) {
         $this->navStartParams = ['nTopCount' => $this->arParams['ELEMENTS_COUNT'], 'bDescPageNumbering' => $this->arParams['PAGER_DESC_NUMBERING']];
     } else {
         $this->navStartParams = false;
     }
 }
Пример #2
0
 /**
  * @param string $componentName
  * @param array $arCurrentValues Don't change the name! It's used in the .parameters.php file.
  * @param array $templateProperties
  * @return array|bool
  */
 public static function GetComponentProps($componentName, $arCurrentValues = array(), $templateProperties = array())
 {
     $arComponentParameters = array();
     $componentName = trim($componentName);
     if (strlen($componentName) <= 0) {
         return false;
     }
     $path2Comp = CComponentEngine::MakeComponentPath($componentName);
     if (strlen($path2Comp) <= 0) {
         return false;
     }
     $componentPath = getLocalPath("components" . $path2Comp);
     if (!CComponentUtil::isComponent($componentPath)) {
         return false;
     }
     if (file_exists($_SERVER["DOCUMENT_ROOT"] . $componentPath . "/.parameters.php")) {
         CComponentUtil::__IncludeLang($componentPath, ".parameters.php");
         include $_SERVER["DOCUMENT_ROOT"] . $componentPath . "/.parameters.php";
     }
     if ($templateProperties && is_array($templateProperties)) {
         if (is_array($arComponentParameters["PARAMETERS"])) {
             $arComponentParameters["PARAMETERS"] = array_merge($arComponentParameters["PARAMETERS"], $templateProperties);
         } else {
             $arComponentParameters["PARAMETERS"] = $templateProperties;
         }
     }
     if (!array_key_exists("PARAMETERS", $arComponentParameters) || !is_array($arComponentParameters["PARAMETERS"])) {
         return false;
     }
     if (!array_key_exists("GROUPS", $arComponentParameters) || !is_array($arComponentParameters["GROUPS"])) {
         $arComponentParameters["GROUPS"] = array();
     }
     $arParamKeys = array_keys($arComponentParameters["GROUPS"]);
     for ($i = 0, $cnt = count($arParamKeys); $i < $cnt; $i++) {
         if (!isset($arComponentParameters["GROUPS"][$arParamKeys[$i]]["SORT"])) {
             $arComponentParameters["GROUPS"][$arParamKeys[$i]]["SORT"] = 1000 + $i;
         }
         $arComponentParameters["GROUPS"][$arParamKeys[$i]]["SORT"] = IntVal($arComponentParameters["GROUPS"][$arParamKeys[$i]]["SORT"]);
         if ($arComponentParameters["GROUPS"][$arParamKeys[$i]]["SORT"] <= 0) {
             $arComponentParameters["GROUPS"][$arParamKeys[$i]]["SORT"] = 1000 + $i;
         }
     }
     $arParamKeys = array_keys($arComponentParameters["PARAMETERS"]);
     for ($i = 0, $cnt = count($arParamKeys); $i < $cnt; $i++) {
         if ($arParamKeys[$i] == "SET_TITLE") {
             $arComponentParameters["GROUPS"]["ADDITIONAL_SETTINGS"] = array("NAME" => GetMessage("COMP_GROUP_ADDITIONAL_SETTINGS"), "SORT" => 700);
             $arComponentParameters["PARAMETERS"]["SET_TITLE"] = array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("COMP_PROP_SET_TITLE"), "TYPE" => "CHECKBOX", "DEFAULT" => "Y", "ADDITIONAL_VALUES" => "N");
         } elseif ($arParamKeys[$i] == "CACHE_TIME") {
             $arComponentParameters["GROUPS"]["CACHE_SETTINGS"] = array("NAME" => GetMessage("COMP_GROUP_CACHE_SETTINGS"), "SORT" => 600);
             $arSavedParams = $arComponentParameters["PARAMETERS"];
             $arComponentParameters["PARAMETERS"] = array();
             foreach ($arSavedParams as $keyTmp => $valueTmp) {
                 if ($keyTmp == "CACHE_TIME") {
                     $arComponentParameters["PARAMETERS"]["CACHE_TYPE"] = array("PARENT" => "CACHE_SETTINGS", "NAME" => GetMessage("COMP_PROP_CACHE_TYPE"), "TYPE" => "LIST", "VALUES" => array("A" => GetMessage("COMP_PROP_CACHE_TYPE_AUTO") . " " . GetMessage("COMP_PARAM_CACHE_MAN"), "Y" => GetMessage("COMP_PROP_CACHE_TYPE_YES"), "N" => GetMessage("COMP_PROP_CACHE_TYPE_NO")), "DEFAULT" => "A", "ADDITIONAL_VALUES" => "N");
                     $arComponentParameters["PARAMETERS"]["CACHE_TIME"] = array("PARENT" => "CACHE_SETTINGS", "NAME" => GetMessage("COMP_PROP_CACHE_TIME"), "TYPE" => "STRING", "MULTIPLE" => "N", "DEFAULT" => IntVal($arSavedParams["CACHE_TIME"]["DEFAULT"]), "COLS" => 5);
                     $arComponentParameters["PARAMETERS"]["CACHE_NOTES"] = array("PARENT" => "CACHE_SETTINGS", "TYPE" => "CUSTOM", "JS_FILE" => "/bitrix/js/main/comp_props.js", "JS_EVENT" => "BxShowComponentNotes", "JS_DATA" => GetMessage("COMP_PROP_CACHE_NOTE", array("#LANG#" => LANGUAGE_ID, "#AUTO_MODE#" => COption::GetOptionString("main", "component_cache_on", "Y") == "Y" ? GetMessage("COMP_PARAM_CACHE_AUTO_ON") : GetMessage("COMP_PARAM_CACHE_AUTO_OFF"), "#MANAGED_MODE#" => defined("BX_COMP_MANAGED_CACHE") ? GetMessage("COMP_PARAM_CACHE_MANAGED_ON") : GetMessage("COMP_PARAM_CACHE_MANAGED_OFF"))));
                 } else {
                     $arComponentParameters["PARAMETERS"][$keyTmp] = $valueTmp;
                 }
             }
         } elseif ($arParamKeys[$i] == "SEF_MODE") {
             $arComponentParameters["GROUPS"]["SEF_MODE"] = array("NAME" => GetMessage("COMP_GROUP_SEF_MODE"), "SORT" => 500);
             $arSEFModeSettings = $arComponentParameters["PARAMETERS"]["SEF_MODE"];
             $arComponentParameters["PARAMETERS"]["SEF_MODE"] = array("PARENT" => "SEF_MODE", "NAME" => GetMessage("COMP_PROP_SEF_MODE"), "TYPE" => "CHECKBOX", "DEFAULT" => "N", "ADDITIONAL_VALUES" => "N");
             $arComponentParameters["PARAMETERS"]["SEF_FOLDER"] = array("PARENT" => "SEF_MODE", "NAME" => GetMessage("COMP_PROP_SEF_FOLDER"), "TYPE" => "STRING", "MULTIPLE" => "N", "DEFAULT" => "", "COLS" => 30);
             if (is_array($arSEFModeSettings) && count($arSEFModeSettings) > 0) {
                 foreach ($arSEFModeSettings as $templateKey => $arTemplateValue) {
                     $arComponentParameters["PARAMETERS"]["SEF_URL_TEMPLATES_" . $templateKey] = array("PARENT" => "SEF_MODE", "NAME" => $arTemplateValue["NAME"], "TYPE" => "STRING", "MULTIPLE" => "N", "DEFAULT" => $arTemplateValue["DEFAULT"], "HIDDEN" => $arTemplateValue["HIDDEN"], "COLS" => 50, "VARIABLES" => array());
                     $arVariableAliasesSettings = $arComponentParameters["PARAMETERS"]["VARIABLE_ALIASES"];
                     if (is_array($arVariableAliasesSettings) && count($arVariableAliasesSettings) > 0) {
                         foreach ($arTemplateValue["VARIABLES"] as $variable) {
                             $arComponentParameters["PARAMETERS"]["SEF_URL_TEMPLATES_" . $templateKey]["VARIABLES"]["#" . $variable . "#"] = $arVariableAliasesSettings[$variable]["NAME"];
                         }
                     }
                 }
             }
         } elseif ($arParamKeys[$i] == "VARIABLE_ALIASES") {
             $arComponentParameters["GROUPS"]["SEF_MODE"] = array("NAME" => GetMessage("COMP_GROUP_SEF_MODE"), "SORT" => 500);
             $arVariableAliasesSettings = $arComponentParameters["PARAMETERS"]["VARIABLE_ALIASES"];
             unset($arComponentParameters["PARAMETERS"]["VARIABLE_ALIASES"]);
             foreach ($arVariableAliasesSettings as $aliaseKey => $arAliaseValue) {
                 $arComponentParameters["PARAMETERS"]["VARIABLE_ALIASES_" . $aliaseKey] = array("PARENT" => "SEF_MODE", "NAME" => $arAliaseValue["NAME"], "TYPE" => "STRING", "MULTIPLE" => "N", "DEFAULT" => $aliaseKey, "COLS" => 20);
             }
         } elseif (isset($arComponentParameters["PARAMETERS"][$arParamKeys[$i]]["PARENT"]) && strlen($arComponentParameters["PARAMETERS"][$arParamKeys[$i]]["PARENT"]) > 0) {
             if ($arComponentParameters["PARAMETERS"][$arParamKeys[$i]]["PARENT"] == "URL_TEMPLATES") {
                 $arComponentParameters["GROUPS"]["URL_TEMPLATES"] = array("NAME" => GetMessage("COMP_GROUP_URL_TEMPLATES"), "SORT" => 400);
             } elseif ($arComponentParameters["PARAMETERS"][$arParamKeys[$i]]["PARENT"] == "VISUAL") {
                 $arComponentParameters["GROUPS"]["VISUAL"] = array("NAME" => GetMessage("COMP_GROUP_VISUAL"), "SORT" => 300);
             } elseif ($arComponentParameters["PARAMETERS"][$arParamKeys[$i]]["PARENT"] == "DATA_SOURCE") {
                 $arComponentParameters["GROUPS"]["DATA_SOURCE"] = array("NAME" => GetMessage("COMP_GROUP_DATA_SOURCE"), "SORT" => 200);
             } elseif ($arComponentParameters["PARAMETERS"][$arParamKeys[$i]]["PARENT"] == "BASE") {
                 $arComponentParameters["GROUPS"]["BASE"] = array("NAME" => GetMessage("COMP_GROUP_BASE"), "SORT" => 100);
             } elseif ($arComponentParameters["PARAMETERS"][$arParamKeys[$i]]["PARENT"] == "ADDITIONAL_SETTINGS") {
                 $arComponentParameters["GROUPS"]["ADDITIONAL_SETTINGS"] = array("NAME" => GetMessage("COMP_GROUP_ADDITIONAL_SETTINGS"), "SORT" => 700);
             }
         } elseif ($arParamKeys[$i] == "AJAX_MODE") {
             $arComponentParameters["GROUPS"]["AJAX_SETTINGS"] = array("NAME" => GetMessage("COMP_GROUP_AJAX_SETTINGS"), "SORT" => 550);
             $arComponentParameters["PARAMETERS"]["AJAX_MODE"] = array("PARENT" => "AJAX_SETTINGS", "NAME" => GetMessage("COMP_PROP_AJAX_MODE"), "TYPE" => "CHECKBOX", "DEFAULT" => "N", "ADDITIONAL_VALUES" => "N");
             // $arComponentParameters["PARAMETERS"]["AJAX_OPTION_SHADOW"] = array(
             // "PARENT" => "AJAX_SETTINGS",
             // "NAME" => GetMessage("COMP_PROP_AJAX_OPTIONS_SHADOW"),
             // "TYPE" => "CHECKBOX",
             // "MULTIPLE" => "N",
             // "DEFAULT" => "Y",
             // "ADDITIONAL_VALUES" => "N"
             // );
             $arComponentParameters["PARAMETERS"]["AJAX_OPTION_JUMP"] = array("PARENT" => "AJAX_SETTINGS", "NAME" => GetMessage("COMP_PROP_AJAX_OPTIONS_JUMP"), "TYPE" => "CHECKBOX", "MULTIPLE" => "N", "DEFAULT" => "N", "ADDITIONAL_VALUES" => "N");
             $arComponentParameters["PARAMETERS"]["AJAX_OPTION_STYLE"] = array("PARENT" => "AJAX_SETTINGS", "NAME" => GetMessage("COMP_PROP_AJAX_OPTIONS_STYLE"), "TYPE" => "CHECKBOX", "MULTIPLE" => "N", "DEFAULT" => "Y", "ADDITIONAL_VALUES" => "N");
             $arComponentParameters["PARAMETERS"]["AJAX_OPTION_HISTORY"] = array("PARENT" => "AJAX_SETTINGS", "NAME" => GetMessage("COMP_PROP_AJAX_OPTIONS_HISTORY"), "TYPE" => "CHECKBOX", "MULTIPLE" => "N", "DEFAULT" => "N", "ADDITIONAL_VALUES" => "N");
             $arComponentParameters["PARAMETERS"]["AJAX_OPTION_ADDITIONAL"] = array("PARENT" => "AJAX_SETTINGS", "NAME" => GetMessage("COMP_PROP_AJAX_OPTIONS_ADDITIONAL"), "TYPE" => "STRING", "HIDDEN" => "Y", "MULTIPLE" => "N", "DEFAULT" => "", "ADDITIONAL_VALUES" => "N");
         } else {
             $parent = $arComponentParameters["PARAMETERS"][$arParamKeys[$i]]["PARENT"];
             if (!isset($parent) || !isset($arComponentParameters["GROUPS"][$parent])) {
                 $arComponentParameters["PARAMETERS"][$arParamKeys[$i]]["PARENT"] = "ADDITIONAL_SETTINGS";
                 if (!isset($arComponentParameters["GROUPS"]["ADDITIONAL_SETTINGS"])) {
                     $arComponentParameters["GROUPS"]["ADDITIONAL_SETTINGS"] = array("NAME" => GetMessage("COMP_GROUP_ADDITIONAL_SETTINGS"), "SORT" => 700);
                 }
             }
         }
     }
     if (CPageOption::GetOptionString("main", "tips_creation", "no") == "allowed" && strpos($componentPath, "/forum") !== false) {
         //Create directories
         $help_lang_path = $_SERVER["DOCUMENT_ROOT"] . $componentPath . "/lang";
         if (!file_exists($help_lang_path)) {
             mkdir($help_lang_path);
         }
         $help_lang_path .= "/ru";
         if (!file_exists($help_lang_path)) {
             mkdir($help_lang_path);
         }
         $help_lang_path .= "/help";
         if (!file_exists($help_lang_path)) {
             mkdir($help_lang_path);
         }
         if (is_dir($help_lang_path)) {
             //Create files if none exists
             $lang_filename = $help_lang_path . "/.tooltips.php";
             if (!file_exists($lang_filename)) {
                 $handle = fopen($lang_filename, "w");
                 fwrite($handle, "<?\n?>");
                 fclose($handle);
             }
             $handle = fopen($lang_filename, "r");
             $lang_contents = fread($handle, filesize($lang_filename));
             fclose($handle);
             $lang_file_modified = false;
             //Bug fix
             if (strpos($lang_contents, "\$MESS['") !== false) {
                 $lang_contents = str_replace("\$MESS['", "\$MESS ['", $lang_contents);
                 $lang_file_modified = true;
             }
             //Check out parameters
             foreach ($arComponentParameters["PARAMETERS"] as $strName => $arParameter) {
                 if (strpos($lang_contents, "\$MESS ['{$strName}_TIP'] = ") === false) {
                     $lang_contents = str_replace("?>", "\$MESS ['{$strName}_TIP'] = \"" . str_replace("\$", "\\\$", str_replace('"', '\\"', $arParameter["NAME"])) . "\";\n?>", $lang_contents);
                     $lang_file_modified = true;
                 }
             }
             //Save the result of the work
             if ($lang_file_modified) {
                 $handle = fopen($lang_filename, "w");
                 fwrite($handle, $lang_contents);
                 fclose($handle);
             }
         }
         reset($arComponentParameters["PARAMETERS"]);
     }
     uasort($arComponentParameters["GROUPS"], array("CComponentUtil", "__GroupParamsCompare"));
     return $arComponentParameters;
 }
Пример #3
0
 /**
  * <p>Устанавливает числовое значение параметра <i>page_option_id</i> для модуля <i>module_id</i>. Возвращает "true", если операция прошла успешна, в противном случае - "false". Статичный метод.</p>
  *
  *
  * @param string $module_id  <a href="http://dev.1c-bitrix.ru/api_help/main/general/identifiers.php">Идентификатор модуля</a>.
  *
  * @param string $name  Произвольный идентификатор параметра страницы.
  *
  * @param mixed $value = "" Значение параметра.<br>Необязательный. По умолчанию - "".
  *
  * @param des $c = "" 
  *
  * @param string $site = false Идентификатор сайта. Значение по умолчанию - "false".
  *
  * @return bool 
  *
  * <h4>Example</h4> 
  * <pre>
  * &lt;?
  * <b>CPageOption::SetOptionInt</b>("main", "MY_PARAMETER", 2);
  * ?&gt;
  * </pre>
  *
  *
  * <h4>See Also</h4> 
  * <ul> <li> <a href="https://dev.1c-bitrix.ru/learning/course/index.php?COURSE_ID=43&amp;LESSON_ID=2814#params"
  * >Параметры страницы</a> </li> <li> <a
  * href="http://dev.1c-bitrix.ru/api_help/main/reference/cpageoption/setoptionstring.php">CPageOption::SetOptionString</a>
  * </li> </ul> </ht<a name="examples"></a>
  *
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/main/reference/cpageoption/setoptionint.php
  * @author Bitrix
  */
 public static function SetOptionInt($module_id, $name, $value = "", $desc = "", $site = "")
 {
     return CPageOption::SetOptionString($module_id, $name, IntVal($value), $desc, $site);
 }
Пример #4
0
 public function __construct($component = null)
 {
     parent::__construct($component);
     CPageOption::SetOptionString("main", "nav_page_in_session", "N");
     $this->dateFormat = CSite::GetDateFormat("FULL", SITE_ID);
     Localization\Loc::loadMessages(__FILE__);
 }
Пример #5
0
     $dbresult->NavPageSize = 10;
 }
 $arResult = array();
 $arResult["NavShowAlways"] = $arParams["SHOW_ALWAYS"];
 $arResult["NavTitle"] = $arParams["NAV_TITLE"];
 $arResult["NavRecordCount"] = $dbresult->NavRecordCount;
 $arResult["NavPageCount"] = $dbresult->NavPageCount;
 $arResult["NavPageNomer"] = $dbresult->NavPageNomer;
 $arResult["NavPageSize"] = $dbresult->NavPageSize;
 $arResult["bShowAll"] = $dbresult->bShowAll;
 $arResult["NavShowAll"] = $dbresult->NavShowAll;
 $arResult["NavNum"] = $dbresult->NavNum;
 $arResult["bDescPageNumbering"] = $dbresult->bDescPageNumbering;
 $arResult["add_anchor"] = $dbresult->add_anchor;
 $arResult["nPageWindow"] = $nPageWindow = $dbresult->nPageWindow;
 $arResult["bSavePage"] = CPageOption::GetOptionString("main", "nav_page_in_session", "Y") == "Y";
 $arResult["sUrlPath"] = GetPagePath(false, false);
 $arResult["NavQueryString"] = htmlspecialcharsbx(DeleteParam(array("PAGEN_" . $dbresult->NavNum, "SIZEN_" . $dbresult->NavNum, "SHOWALL_" . $dbresult->NavNum, "PHPSESSID", "clear_cache")));
 $arResult['sUrlPathParams'] = $arResult['sUrlPath'] . '?' . ('' != $arResult['NavQueryString'] ? $arResult['NavQueryString'] . '&' : '');
 if ($dbresult->bDescPageNumbering === true) {
     if ($dbresult->NavPageNomer + floor($nPageWindow / 2) >= $dbresult->NavPageCount) {
         $nStartPage = $dbresult->NavPageCount;
     } else {
         if ($dbresult->NavPageNomer + floor($nPageWindow / 2) >= $nPageWindow) {
             $nStartPage = $dbresult->NavPageNomer + floor($nPageWindow / 2);
         } else {
             if ($dbresult->NavPageCount >= $nPageWindow) {
                 $nStartPage = $nPageWindow;
             } else {
                 $nStartPage = $dbresult->NavPageCount;
             }
Пример #6
0
 /**
  * выполяет действия перед кешированием 
  */
 protected function executeProlog()
 {
     if ($this->arParams['COUNT'] > 0) {
         if ($this->arParams['SHOW_NAV'] == 'Y') {
             \CPageOption::SetOptionString('main', 'nav_page_in_session', 'N');
             $this->navParams = array('nPageSize' => $this->arParams['COUNT']);
             $arNavigation = \CDBResult::GetNavParams($this->navParams);
             $this->cacheAddon = array($arNavigation);
         } else {
             $this->navParams = array('nTopCount' => $this->arParams['COUNT']);
         }
     }
 }
Пример #7
0
	function GetNavSize($table_id=false, $nPageSize=20)
	{
		/** @global CMain $APPLICATION */
		global $APPLICATION;

		$bSess = (CPageOption::GetOptionString("main", "nav_page_in_session", "Y")=="Y");
		if(is_array($nPageSize))
			$sNavID = $nPageSize["sNavID"];
		$unique = md5((isset($sNavID)? $sNavID : $APPLICATION->GetCurPage()));

		if(isset($_REQUEST["SIZEN_".($GLOBALS["NavNum"]+1)]))
		{
			$nSize = intval($_REQUEST["SIZEN_".($GLOBALS["NavNum"]+1)]);
			if($bSess)
				$_SESSION["NAV_PAGE_SIZE"][$unique] = $nSize;
		}
		elseif($bSess && isset($_SESSION["NAV_PAGE_SIZE"][$unique]))
		{
			$nSize = $_SESSION["NAV_PAGE_SIZE"][$unique];
		}
		else
		{
			$aOptions = array();
			if($table_id)
				$aOptions = CUserOptions::GetOption("list", $table_id);
			if(intval($aOptions["page_size"]) > 0)
				$nSize = intval($aOptions["page_size"]);
			else
				$nSize = (is_array($nPageSize)? $nPageSize["nPageSize"]:$nPageSize);
		}
		return $nSize;
	}
Пример #8
0
 function GetList($arOrder = array("SORT" => "ASC"), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
 {
     /*
     Filter combinations:
     CHECK_PERMISSIONS="N" - check permissions of the current user to the infoblock
     	MIN_PERMISSION="R" - when permissions check, then minimal access level
     SHOW_HISTORY="N" - add history items to list
     	SHOW_NEW="N" - if not add history items, then add new, but not published elements
     */
     global $DB, $USER, $APPLICATION;
     $MAX_LOCK = intval(COption::GetOptionString("workflow", "MAX_LOCK_TIME", "60"));
     $uid = is_object($USER) ? intval($USER->GetID()) : 0;
     $arIblockElementFields = array("ID" => "BE.ID", "TIMESTAMP_X" => $DB->DateToCharFunction("BE.TIMESTAMP_X"), "TIMESTAMP_X_UNIX" => 'UNIX_TIMESTAMP(BE.TIMESTAMP_X)', "MODIFIED_BY" => "BE.MODIFIED_BY", "DATE_CREATE" => $DB->DateToCharFunction("BE.DATE_CREATE"), "DATE_CREATE_UNIX" => 'UNIX_TIMESTAMP(BE.DATE_CREATE)', "CREATED_BY" => "BE.CREATED_BY", "IBLOCK_ID" => "BE.IBLOCK_ID", "IBLOCK_SECTION_ID" => "BE.IBLOCK_SECTION_ID", "ACTIVE" => "BE.ACTIVE", "ACTIVE_FROM" => CPageOption::GetOptionString("iblock", "FORMAT_ACTIVE_DATES", "-") != "-" ? $DB->DateToCharFunction("BE.ACTIVE_FROM", CPageOption::GetOptionString("iblock", "FORMAT_ACTIVE_DATES", "SHORT")) : "IF(EXTRACT(HOUR_SECOND FROM BE.ACTIVE_FROM)>0, " . $DB->DateToCharFunction("BE.ACTIVE_FROM", "FULL") . ", " . $DB->DateToCharFunction("BE.ACTIVE_FROM", "SHORT") . ")", "ACTIVE_TO" => CPageOption::GetOptionString("iblock", "FORMAT_ACTIVE_DATES", "-") != "-" ? $DB->DateToCharFunction("BE.ACTIVE_TO", CPageOption::GetOptionString("iblock", "FORMAT_ACTIVE_DATES", "SHORT")) : "IF(EXTRACT(HOUR_SECOND FROM BE.ACTIVE_TO)>0, " . $DB->DateToCharFunction("BE.ACTIVE_TO", "FULL") . ", " . $DB->DateToCharFunction("BE.ACTIVE_TO", "SHORT") . ")", "DATE_ACTIVE_FROM" => CPageOption::GetOptionString("iblock", "FORMAT_ACTIVE_DATES", "-") != "-" ? $DB->DateToCharFunction("BE.ACTIVE_FROM", CPageOption::GetOptionString("iblock", "FORMAT_ACTIVE_DATES", "SHORT")) : "IF(EXTRACT(HOUR_SECOND FROM BE.ACTIVE_FROM)>0, " . $DB->DateToCharFunction("BE.ACTIVE_FROM", "FULL") . ", " . $DB->DateToCharFunction("BE.ACTIVE_FROM", "SHORT") . ")", "DATE_ACTIVE_TO" => CPageOption::GetOptionString("iblock", "FORMAT_ACTIVE_DATES", "-") != "-" ? $DB->DateToCharFunction("BE.ACTIVE_TO", CPageOption::GetOptionString("iblock", "FORMAT_ACTIVE_DATES", "SHORT")) : "IF(EXTRACT(HOUR_SECOND FROM BE.ACTIVE_TO)>0, " . $DB->DateToCharFunction("BE.ACTIVE_TO", "FULL") . ", " . $DB->DateToCharFunction("BE.ACTIVE_TO", "SHORT") . ")", "SORT" => "BE.SORT", "NAME" => "BE.NAME", "PREVIEW_PICTURE" => "BE.PREVIEW_PICTURE", "PREVIEW_TEXT" => "BE.PREVIEW_TEXT", "PREVIEW_TEXT_TYPE" => "BE.PREVIEW_TEXT_TYPE", "DETAIL_PICTURE" => "BE.DETAIL_PICTURE", "DETAIL_TEXT" => "BE.DETAIL_TEXT", "DETAIL_TEXT_TYPE" => "BE.DETAIL_TEXT_TYPE", "SEARCHABLE_CONTENT" => "BE.SEARCHABLE_CONTENT", "WF_STATUS_ID" => "BE.WF_STATUS_ID", "WF_PARENT_ELEMENT_ID" => "BE.WF_PARENT_ELEMENT_ID", "WF_LAST_HISTORY_ID" => "BE.WF_LAST_HISTORY_ID", "WF_NEW" => "BE.WF_NEW", "LOCK_STATUS" => "if (BE.WF_DATE_LOCK is null, 'green', if(DATE_ADD(BE.WF_DATE_LOCK, interval " . $MAX_LOCK . " MINUTE)<now(), 'green', if(BE.WF_LOCKED_BY=" . $uid . ", 'yellow', 'red')))", "WF_LOCKED_BY" => "BE.WF_LOCKED_BY", "WF_DATE_LOCK" => $DB->DateToCharFunction("BE.WF_DATE_LOCK"), "WF_COMMENTS" => "BE.WF_COMMENTS", "IN_SECTIONS" => "BE.IN_SECTIONS", "SHOW_COUNTER" => "BE.SHOW_COUNTER", "SHOW_COUNTER_START" => "BE.SHOW_COUNTER_START", "CODE" => "BE.CODE", "TAGS" => "BE.TAGS", "XML_ID" => "BE.XML_ID", "EXTERNAL_ID" => "BE.XML_ID", "TMP_ID" => "BE.TMP_ID", "USER_NAME" => "concat('(',U.LOGIN,') ',ifnull(U.NAME,''),' ',ifnull(U.LAST_NAME,''))", "LOCKED_USER_NAME" => "concat('(',UL.LOGIN,') ',ifnull(UL.NAME,''),' ',ifnull(UL.LAST_NAME,''))", "CREATED_USER_NAME" => "concat('(',UC.LOGIN,') ',ifnull(UC.NAME,''),' ',ifnull(UC.LAST_NAME,''))", "LANG_DIR" => "L.DIR", "LID" => "B.LID", "IBLOCK_TYPE_ID" => "B.IBLOCK_TYPE_ID", "IBLOCK_CODE" => "B.CODE", "IBLOCK_NAME" => "B.NAME", "IBLOCK_EXTERNAL_ID" => "B.XML_ID", "DETAIL_PAGE_URL" => "B.DETAIL_PAGE_URL", "LIST_PAGE_URL" => "B.LIST_PAGE_URL", "CREATED_DATE" => $DB->DateFormatToDB("YYYY.MM.DD", "BE.DATE_CREATE"), "BP_PUBLISHED" => "if(BE.WF_STATUS_ID = 1, 'Y', 'N')");
     $bDistinct = false;
     CIBlockElement::PrepareGetList($arIblockElementFields, $arJoinProps, $bOnlyCount, $bDistinct, $arSelectFields, $sSelect, $arAddSelectFields, $arFilter, $sWhere, $sSectionWhere, $arAddWhereFields, $arGroupBy, $sGroupBy, $arOrder, $arSqlOrder, $arAddOrderByFields, $arIBlockFilter, $arIBlockMultProps, $arIBlockConvProps, $arIBlockAllProps, $arIBlockNumProps, $arIBlockLongProps);
     $arFilterIBlocks = isset($arFilter["IBLOCK_ID"]) ? array($arFilter["IBLOCK_ID"]) : array();
     //******************FROM PART********************************************
     $sFrom = "";
     foreach ($arJoinProps["FPS"] as $iblock_id => $iPropCnt) {
         $sFrom .= "\t\t\tINNER JOIN b_iblock_element_prop_s" . $iblock_id . " FPS" . $iPropCnt . " ON FPS" . $iPropCnt . ".IBLOCK_ELEMENT_ID = BE.ID\n";
         $arFilterIBlocks[$iblock_id] = $iblock_id;
     }
     foreach ($arJoinProps["FP"] as $propID => $db_prop) {
         $i = $db_prop["CNT"];
         if ($db_prop["bFullJoin"]) {
             $sFrom .= "\t\t\tINNER JOIN b_iblock_property FP" . $i . " ON FP" . $i . ".IBLOCK_ID = B.ID AND " . (IntVal($propID) > 0 ? " FP" . $i . ".ID=" . IntVal($propID) . "\n" : " FP" . $i . ".CODE='" . $DB->ForSQL($propID, 200) . "'\n");
         } else {
             $sFrom .= "\t\t\tLEFT JOIN b_iblock_property FP" . $i . " ON FP" . $i . ".IBLOCK_ID = B.ID AND " . (IntVal($propID) > 0 ? " FP" . $i . ".ID=" . IntVal($propID) . "\n" : " FP" . $i . ".CODE='" . $DB->ForSQL($propID, 200) . "'\n");
         }
         if ($db_prop["IBLOCK_ID"]) {
             $arFilterIBlocks[$db_prop["IBLOCK_ID"]] = $db_prop["IBLOCK_ID"];
         }
     }
     foreach ($arJoinProps["FPV"] as $propID => $db_prop) {
         $i = $db_prop["CNT"];
         if ($db_prop["MULTIPLE"] == "Y") {
             $bDistinct = true;
         }
         if ($db_prop["VERSION"] == 2) {
             $strTable = "b_iblock_element_prop_m" . $db_prop["IBLOCK_ID"];
         } else {
             $strTable = "b_iblock_element_property";
         }
         if ($db_prop["bFullJoin"]) {
             $sFrom .= "\t\t\tINNER JOIN " . $strTable . " FPV" . $i . " ON FPV" . $i . ".IBLOCK_PROPERTY_ID = FP" . $db_prop["JOIN"] . ".ID AND FPV" . $i . ".IBLOCK_ELEMENT_ID = BE.ID\n";
         } else {
             $sFrom .= "\t\t\tLEFT JOIN " . $strTable . " FPV" . $i . " ON FPV" . $i . ".IBLOCK_PROPERTY_ID = FP" . $db_prop["JOIN"] . ".ID AND FPV" . $i . ".IBLOCK_ELEMENT_ID = BE.ID\n";
         }
         if ($db_prop["IBLOCK_ID"]) {
             $arFilterIBlocks[$db_prop["IBLOCK_ID"]] = $db_prop["IBLOCK_ID"];
         }
     }
     foreach ($arJoinProps["FPEN"] as $propID => $db_prop) {
         $i = $db_prop["CNT"];
         if ($db_prop["VERSION"] == 2 && $db_prop["MULTIPLE"] == "N") {
             if ($db_prop["bFullJoin"]) {
                 $sFrom .= "\t\t\tINNER JOIN b_iblock_property_enum FPEN" . $i . " ON FPEN" . $i . ".PROPERTY_ID = " . $db_prop["ORIG_ID"] . " AND FPS" . $db_prop["JOIN"] . ".PROPERTY_" . $db_prop["ORIG_ID"] . " = FPEN" . $i . ".ID\n";
             } else {
                 $sFrom .= "\t\t\tLEFT JOIN b_iblock_property_enum FPEN" . $i . " ON FPEN" . $i . ".PROPERTY_ID = " . $db_prop["ORIG_ID"] . " AND FPS" . $db_prop["JOIN"] . ".PROPERTY_" . $db_prop["ORIG_ID"] . " = FPEN" . $i . ".ID\n";
             }
         } else {
             if ($db_prop["bFullJoin"]) {
                 $sFrom .= "\t\t\tINNER JOIN b_iblock_property_enum FPEN" . $i . " ON FPEN" . $i . ".PROPERTY_ID = FPV" . $db_prop["JOIN"] . ".IBLOCK_PROPERTY_ID AND FPV" . $db_prop["JOIN"] . ".VALUE_ENUM = FPEN" . $i . ".ID\n";
             } else {
                 $sFrom .= "\t\t\tLEFT JOIN b_iblock_property_enum FPEN" . $i . " ON FPEN" . $i . ".PROPERTY_ID = FPV" . $db_prop["JOIN"] . ".IBLOCK_PROPERTY_ID AND FPV" . $db_prop["JOIN"] . ".VALUE_ENUM = FPEN" . $i . ".ID\n";
             }
         }
         if ($db_prop["IBLOCK_ID"]) {
             $arFilterIBlocks[$db_prop["IBLOCK_ID"]] = $db_prop["IBLOCK_ID"];
         }
     }
     foreach ($arJoinProps["BE"] as $propID => $db_prop) {
         $i = $db_prop["CNT"];
         $sFrom .= "\t\t\tLEFT JOIN b_iblock_element BE" . $i . " ON BE" . $i . ".ID = " . ($db_prop["VERSION"] == 2 && $db_prop["MULTIPLE"] == "N" ? "FPS" . $db_prop["JOIN"] . ".PROPERTY_" . $db_prop["ORIG_ID"] : "FPV" . $db_prop["JOIN"] . ".VALUE_NUM") . ($arFilter["SHOW_HISTORY"] != "Y" ? " AND ((BE.WF_STATUS_ID=1 AND BE.WF_PARENT_ELEMENT_ID IS NULL)" . ($arFilter["SHOW_NEW"] == "Y" ? " OR BE.WF_NEW='Y'" : "") . ")" : "") . "\n";
         if ($db_prop["bJoinIBlock"]) {
             $sFrom .= "\t\t\tLEFT JOIN b_iblock B" . $i . " ON B" . $i . ".ID = BE" . $i . ".IBLOCK_ID\n";
         }
         if ($db_prop["bJoinSection"]) {
             $sFrom .= "\t\t\tLEFT JOIN b_iblock_section BS" . $i . " ON BS" . $i . ".ID = BE" . $i . ".IBLOCK_SECTION_ID\n";
         }
         if ($db_prop["IBLOCK_ID"]) {
             $arFilterIBlocks[$db_prop["IBLOCK_ID"]] = $db_prop["IBLOCK_ID"];
         }
     }
     foreach ($arJoinProps["BE_FPS"] as $iblock_id => $db_prop) {
         $sFrom .= "\t\t\tLEFT JOIN b_iblock_element_prop_s" . $iblock_id . " JFPS" . $db_prop["CNT"] . " ON JFPS" . $db_prop["CNT"] . ".IBLOCK_ELEMENT_ID = BE" . $db_prop["JOIN"] . ".ID\n";
         if ($db_prop["IBLOCK_ID"]) {
             $arFilterIBlocks[$db_prop["IBLOCK_ID"]] = $db_prop["IBLOCK_ID"];
         }
     }
     foreach ($arJoinProps["BE_FP"] as $propID => $db_prop) {
         $i = $db_prop["CNT"];
         list($propID, $link) = explode("~", $propID, 2);
         if ($db_prop["bFullJoin"]) {
             $sFrom .= "\t\t\tINNER JOIN b_iblock_property JFP" . $i . " ON JFP" . $i . ".IBLOCK_ID = BE" . $db_prop["JOIN"] . ".IBLOCK_ID AND " . (IntVal($propID) > 0 ? " JFP" . $i . ".ID=" . IntVal($propID) . "\n" : " JFP" . $i . ".CODE='" . $DB->ForSQL($propID, 200) . "'\n");
         } else {
             $sFrom .= "\t\t\tLEFT JOIN b_iblock_property JFP" . $i . " ON JFP" . $i . ".IBLOCK_ID = BE" . $db_prop["JOIN"] . ".IBLOCK_ID AND " . (IntVal($propID) > 0 ? " JFP" . $i . ".ID=" . IntVal($propID) . "\n" : " JFP" . $i . ".CODE='" . $DB->ForSQL($propID, 200) . "'\n");
         }
         if ($db_prop["IBLOCK_ID"]) {
             $arFilterIBlocks[$db_prop["IBLOCK_ID"]] = $db_prop["IBLOCK_ID"];
         }
     }
     foreach ($arJoinProps["BE_FPV"] as $propID => $db_prop) {
         $i = $db_prop["CNT"];
         list($propID, $link) = explode("~", $propID, 2);
         if ($db_prop["MULTIPLE"] == "Y") {
             $bDistinct = true;
         }
         if ($db_prop["VERSION"] == 2) {
             $strTable = "b_iblock_element_prop_m" . $db_prop["IBLOCK_ID"];
         } else {
             $strTable = "b_iblock_element_property";
         }
         if ($db_prop["bFullJoin"]) {
             $sFrom .= "\t\t\tINNER JOIN " . $strTable . " JFPV" . $i . " ON JFPV" . $i . ".IBLOCK_PROPERTY_ID = JFP" . $db_prop["JOIN"] . ".ID AND JFPV" . $i . ".IBLOCK_ELEMENT_ID = BE" . $db_prop["BE_JOIN"] . ".ID\n";
         } else {
             $sFrom .= "\t\t\tLEFT JOIN " . $strTable . " JFPV" . $i . " ON JFPV" . $i . ".IBLOCK_PROPERTY_ID = JFP" . $db_prop["JOIN"] . ".ID AND JFPV" . $i . ".IBLOCK_ELEMENT_ID = BE" . $db_prop["BE_JOIN"] . ".ID\n";
         }
         if ($db_prop["IBLOCK_ID"]) {
             $arFilterIBlocks[$db_prop["IBLOCK_ID"]] = $db_prop["IBLOCK_ID"];
         }
     }
     foreach ($arJoinProps["BE_FPEN"] as $propID => $db_prop) {
         $i = $db_prop["CNT"];
         list($propID, $link) = explode("~", $propID, 2);
         if ($db_prop["VERSION"] == 2 && $db_prop["MULTIPLE"] == "N") {
             if ($db_prop["bFullJoin"]) {
                 $sFrom .= "\t\t\tINNER JOIN b_iblock_property_enum JFPEN" . $i . " ON JFPEN" . $i . ".PROPERTY_ID = " . $db_prop["ORIG_ID"] . " AND JFPS" . $db_prop["JOIN"] . ".PROPERTY_" . $db_prop["ORIG_ID"] . " = JFPEN" . $i . ".ID\n";
             } else {
                 $sFrom .= "\t\t\tLEFT JOIN b_iblock_property_enum JFPEN" . $i . " ON JFPEN" . $i . ".PROPERTY_ID = " . $db_prop["ORIG_ID"] . " AND JFPS" . $db_prop["JOIN"] . ".PROPERTY_" . $db_prop["ORIG_ID"] . " = JFPEN" . $i . ".ID\n";
             }
         } else {
             if ($db_prop["bFullJoin"]) {
                 $sFrom .= "\t\t\tINNER JOIN b_iblock_property_enum JFPEN" . $i . " ON JFPEN" . $i . ".PROPERTY_ID = JFPV" . $db_prop["JOIN"] . ".IBLOCK_PROPERTY_ID AND JFPV" . $db_prop["JOIN"] . ".VALUE_ENUM = JFPEN" . $i . ".ID\n";
             } else {
                 $sFrom .= "\t\t\tLEFT JOIN b_iblock_property_enum JFPEN" . $i . " ON JFPEN" . $i . ".PROPERTY_ID = JFPV" . $db_prop["JOIN"] . ".IBLOCK_PROPERTY_ID AND JFPV" . $db_prop["JOIN"] . ".VALUE_ENUM = JFPEN" . $i . ".ID\n";
             }
         }
         if ($db_prop["IBLOCK_ID"]) {
             $arFilterIBlocks[$db_prop["IBLOCK_ID"]] = $db_prop["IBLOCK_ID"];
         }
     }
     if (strlen($arJoinProps["BES"])) {
         $sFrom .= "\t\t\t" . $arJoinProps["BES"] . "\n";
     }
     if ($arJoinProps["RV"]) {
         $sFrom .= "\t\t\tLEFT JOIN b_rating_voting RV ON RV.ENTITY_TYPE_ID = 'IBLOCK_ELEMENT' AND RV.ENTITY_ID = BE.ID\n";
     }
     if ($arJoinProps["RVU"]) {
         $sFrom .= "\t\t\tLEFT JOIN b_rating_vote RVU ON RVU.ENTITY_TYPE_ID = 'IBLOCK_ELEMENT' AND RVU.ENTITY_ID = BE.ID AND RVU.USER_ID = " . $uid . "\n";
     }
     if ($arJoinProps["RVV"]) {
         $sFrom .= "\t\t\t" . ($arJoinProps["RVV"]["bFullJoin"] ? "INNER" : "LEFT") . " JOIN b_rating_vote RVV ON RVV.ENTITY_TYPE_ID = 'IBLOCK_ELEMENT' AND RVV.ENTITY_ID = BE.ID\n";
     }
     //******************END OF FROM PART********************************************
     $bCatalogSort = false;
     if (count($arAddSelectFields) > 0 || count($arAddWhereFields) > 0 || count($arAddOrderByFields) > 0) {
         if (CModule::IncludeModule("catalog")) {
             $res_catalog = CCatalogProduct::GetQueryBuildArrays($arAddOrderByFields, $arAddWhereFields, $arAddSelectFields);
             if ($sGroupBy == "" && !$bOnlyCount && !(is_object($this) && isset($this->strField))) {
                 $sSelect .= $res_catalog["SELECT"] . " ";
             }
             $sFrom .= str_replace("LEFT JOIN", "\n\t\t\tLEFT JOIN", $res_catalog["FROM"]) . "\n";
             //$sWhere .= $res_catalog["WHERE"]." "; moved to MkFilter
             if (is_array($res_catalog["ORDER"]) && count($res_catalog["ORDER"])) {
                 $bCatalogSort = true;
                 foreach ($res_catalog["ORDER"] as $i => $val) {
                     $arSqlOrder[$i] = $val;
                 }
             }
         }
     }
     $i = array_search("CREATED_BY_FORMATTED", $arSelectFields);
     if ($i !== false) {
         if ($sSelect && $sGroupBy == "" && !$bOnlyCount && !(is_object($this) && isset($this->strField))) {
             $sSelect .= ",UC.NAME UC_NAME, UC.LAST_NAME UC_LAST_NAME, UC.SECOND_NAME UC_SECOND_NAME, UC.EMAIL UC_EMAIL, UC.ID UC_ID, UC.LOGIN UC_LOGIN";
         } else {
             unset($arSelectFields[$i]);
         }
     }
     $sOrderBy = "";
     foreach ($arSqlOrder as $i => $val) {
         if (strlen($val)) {
             if ($sOrderBy == "") {
                 $sOrderBy = " ORDER BY ";
             } else {
                 $sOrderBy .= ",";
             }
             $sOrderBy .= $val . " ";
         }
     }
     if (strlen(trim($sSelect)) <= 0) {
         $sSelect = "0 as NOP ";
     }
     $bDistinct = $bDistinct || isset($arFilter["INCLUDE_SUBSECTIONS"]) && $arFilter["INCLUDE_SUBSECTIONS"] == "Y";
     if ($bDistinct) {
         $sSelect = str_replace("%%_DISTINCT_%%", "DISTINCT", $sSelect);
     } else {
         $sSelect = str_replace("%%_DISTINCT_%%", "", $sSelect);
     }
     $sFrom = "\n\t\t\tb_iblock B\n\t\t\tINNER JOIN b_lang L ON B.LID=L.LID\n\t\t\tINNER JOIN b_iblock_element BE ON BE.IBLOCK_ID = B.ID\n\t\t\t" . ltrim($sFrom, "\t\n") . (in_array("USER_NAME", $arSelectFields) ? "\t\t\tLEFT JOIN b_user U ON U.ID=BE.MODIFIED_BY\n" : "") . (in_array("LOCKED_USER_NAME", $arSelectFields) ? "\t\t\tLEFT JOIN b_user UL ON UL.ID=BE.WF_LOCKED_BY\n" : "") . (in_array("CREATED_USER_NAME", $arSelectFields) || in_array("CREATED_BY_FORMATTED", $arSelectFields) ? "\t\t\tLEFT JOIN b_user UC ON UC.ID=BE.CREATED_BY\n" : "") . "\n\t\t";
     $strSql = "\n\t\t\tFROM " . $sFrom . "\n\t\t\tWHERE 1=1 " . $sWhere . "\n\t\t\t" . $sGroupBy . "\n\t\t";
     if (isset($this) && is_object($this) && isset($this->strField)) {
         $this->sFrom = $sFrom;
         $this->sWhere = $sWhere;
         return "SELECT " . $sSelect . $strSql;
     }
     if ($bOnlyCount) {
         $res = $DB->Query("SELECT " . $sSelect . $strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
         $res = $res->Fetch();
         return $res["CNT"];
     }
     if (is_array($arNavStartParams)) {
         $nTopCount = intval($arNavStartParams["nTopCount"]);
         $nElementID = intval($arNavStartParams["nElementID"]);
         if ($nTopCount > 0) {
             $strSql = "SELECT " . $sSelect . $strSql . $sOrderBy . " LIMIT " . $nTopCount;
             $res = $DB->Query($strSql);
         } elseif ($nElementID > 0 && $sGroupBy == "" && $sOrderBy != "" && strpos($sSelect, "BE.ID") !== false && !$bCatalogSort) {
             $nPageSize = intval($arNavStartParams["nPageSize"]);
             if ($nPageSize > 0) {
                 $DB->Query("SET @rank=0");
                 $DB->Query("\n\t\t\t\t\t\tSELECT @rank:=el1.rank\n\t\t\t\t\t\tFROM (\n\t\t\t\t\t\t\tSELECT @rank:=@rank+1 AS rank, el0.*\n\t\t\t\t\t\t\tFROM (\n\t\t\t\t\t\t\t\tSELECT " . $sSelect . $strSql . $sOrderBy . "\n\t\t\t\t\t\t\t) el0\n\t\t\t\t\t\t) el1\n\t\t\t\t\t\tWHERE el1.ID = " . $nElementID . "\n\t\t\t\t\t");
                 $DB->Query("SET @rank2=0");
                 $res = $DB->Query("\n\t\t\t\t\t\tSELECT *\n\t\t\t\t\t\tFROM (\n\t\t\t\t\t\t\tSELECT @rank2:=@rank2+1 AS RANK, el0.*\n\t\t\t\t\t\t\tFROM (\n\t\t\t\t\t\t\t\tSELECT " . $sSelect . $strSql . $sOrderBy . "\n\t\t\t\t\t\t\t) el0\n\t\t\t\t\t\t) el1\n\t\t\t\t\t\tWHERE el1.RANK between @rank-{$nPageSize} and @rank+{$nPageSize}\n\t\t\t\t\t");
             } else {
                 $DB->Query("SET @rank=0");
                 $res = $DB->Query("\n\t\t\t\t\t\tSELECT el1.*\n\t\t\t\t\t\tFROM (\n\t\t\t\t\t\t\tSELECT @rank:=@rank+1 AS RANK, el0.*\n\t\t\t\t\t\t\tFROM (\n\t\t\t\t\t\t\t\tSELECT " . $sSelect . $strSql . $sOrderBy . "\n\t\t\t\t\t\t\t) el0\n\t\t\t\t\t\t) el1\n\t\t\t\t\t\tWHERE el1.ID = " . $nElementID . "\n\t\t\t\t\t");
             }
         } else {
             if ($sGroupBy == "") {
                 $res_cnt = $DB->Query("SELECT COUNT(" . ($bDistinct ? "DISTINCT BE.ID" : "'x'") . ") as C " . $strSql);
                 $res_cnt = $res_cnt->Fetch();
                 $cnt = $res_cnt["C"];
             } else {
                 $res_cnt = $DB->Query("SELECT 'x' " . $strSql);
                 $cnt = $res_cnt->SelectedRowsCount();
             }
             $strSql = "SELECT " . $sSelect . $strSql . $sOrderBy;
             $res = new CDBResult();
             $res->NavQuery($strSql, $cnt, $arNavStartParams);
         }
     } else {
         $strSql = "SELECT " . $sSelect . $strSql . $sOrderBy;
         $res = $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
     }
     $res = new CIBlockResult($res);
     $res->SetIBlockTag($arFilterIBlocks);
     $res->arIBlockMultProps = $arIBlockMultProps;
     $res->arIBlockConvProps = $arIBlockConvProps;
     $res->arIBlockAllProps = $arIBlockAllProps;
     $res->arIBlockNumProps = $arIBlockNumProps;
     $res->arIBlockLongProps = $arIBlockLongProps;
     return $res;
 }
Пример #9
0
 private function setPagerParamsFromOptions($tableId)
 {
     $unique = md5($tableId);
     $bSess = \CPageOption::GetOptionString("main", "nav_page_in_session", "Y") == "Y";
     if (isset($_REQUEST["SIZEN_"])) {
         $this->_elementsInPage = (int) $_REQUEST["SIZEN_"];
         if ($bSess) {
             $_SESSION["NAV_PAGE_SIZE"][$unique] = $this->_elementsInPage;
         }
     } elseif ($bSess && isset($_SESSION["NAV_PAGE_SIZE"][$unique])) {
         $this->_elementsInPage = $_SESSION["NAV_PAGE_SIZE"][$unique];
     } else {
         $aOptions = array();
         if ($tableId) {
             $aOptions = \CUserOptions::GetOption("list", $tableId);
         }
         if (intval($aOptions["page_size"]) > 0) {
             $this->_elementsInPage = intval($aOptions["page_size"]);
         }
     }
 }
Пример #10
0
 function NavStart($nPageSize = 0, $bShowAll = true, $iNumPage = false)
 {
     global $NavNum;
     if ($this->bFromLimited) {
         return;
     }
     if (is_array($nPageSize)) {
         $this->InitNavStartVars($nPageSize);
     } else {
         $this->InitNavStartVars(IntVal($nPageSize), $bShowAll, $iNumPage);
     }
     if ($this->bFromArray) {
         //общее количество записей
         $this->NavRecordCount = count($this->arResult);
         if ($this->NavRecordCount < 1) {
             return;
         }
         if ($this->NavShowAll) {
             $this->NavPageSize = $this->NavRecordCount;
         }
         //Определяю число страниц при указанном размере страниц. Счет начиная с 1
         $this->NavPageCount = floor($this->NavRecordCount / $this->NavPageSize);
         if ($this->NavRecordCount % $this->NavPageSize > 0) {
             $this->NavPageCount++;
         }
         //Номер страницы для отображения. Отсчет начинается с 1
         $this->NavPageNomer = $this->PAGEN < 1 || $this->PAGEN > $this->NavPageCount ? CPageOption::GetOptionString("main", "nav_page_in_session", "Y") != "Y" || $_SESSION[$this->SESS_PAGEN] < 1 || $_SESSION[$this->SESS_PAGEN] > $this->NavPageCount ? 1 : $_SESSION[$this->SESS_PAGEN] : $this->PAGEN;
         //Смещение от начала RecordSet
         $NavFirstRecordShow = $this->NavPageSize * ($this->NavPageNomer - 1);
         $NavLastRecordShow = $this->NavPageSize * $this->NavPageNomer;
         $this->arResult = array_slice($this->arResult, $NavFirstRecordShow, $NavLastRecordShow - $NavFirstRecordShow);
     } else {
         $this->DBNavStart();
     }
 }
Пример #11
0
 /**
  * @inheritdoc
  */
 public function onPrepareComponentParams($arParams)
 {
     $arParams = parent::onPrepareComponentParams($arParams);
     $arParams['IBLOCK_CODE'] = htmlspecialchars(trim($arParams['IBLOCK_CODE']));
     $arParams['SECTION_CODE'] = htmlspecialchars(trim($arParams['SECTION_CODE']));
     $arParams['SECTION_ID'] = intval($arParams['SECTION_ID']);
     if (strlen($arParams['ELEMENT_SORT_BY1']) <= 0) {
         $arParams['ELEMENT_SORT_BY1'] = 'SORT';
     }
     if ($arParams['ELEMENT_SORT_ORDER1'] != 'DESC') {
         $arParams['ELEMENT_SORT_ORDER1'] = 'ASC';
     }
     if (strlen($arParams['ELEMENT_SORT_BY2']) <= 0) {
         $arParams['ELEMENT_SORT_BY2'] = 'ID';
     }
     if ($arParams['ELEMENT_SORT_ORDER2'] != 'DESC') {
         $arParams['ELEMENT_SORT_ORDER2'] = 'ASC';
     }
     if (strlen($arParams['ELEMENT_SORT_BY3']) <= 0) {
         $arParams['ELEMENT_SORT_BY3'] = 'ID';
     }
     if ($arParams['ELEMENT_SORT_ORDER3'] != 'DESC') {
         $arParams['ELEMENT_SORT_ORDER3'] = 'ASC';
     }
     if (strlen($arParams['SECTION_SORT_BY1']) <= 0) {
         $arParams['SECTION_SORT_BY1'] = 'SORT';
     }
     if ($arParams['SECTION_SORT_ORDER1'] != 'DESC') {
         $arParams['SECTION_SORT_ORDER1'] = 'ASC';
     }
     if (strlen($arParams['SECTION_SORT_BY2']) <= 0) {
         $arParams['SECTION_SORT_BY2'] = 'ID';
     }
     if ($arParams['SECTION_SORT_ORDER2'] != 'DESC') {
         $arParams['SECTION_SORT_ORDER2'] = 'ASC';
     }
     if ($arParams['PAGE']) {
         $arParams['PAGE'] = intval($_GET['page']);
     }
     if ($arParams['PAGING'] == 'Y') {
         \CPageOption::SetOptionString('main', 'nav_page_in_session', 'N');
         //не сохраняем в сессии параметры пагинации потому что это сбивает с толку пользователей
         $nav = \CDBResult::GetNavParams();
         if ($nav) {
             $arParams['PAGE'] = intval($nav['PAGEN']);
         } else {
             if ($arParams['PAGE']) {
                 $arParams['PAGE'] = intval($_GET['page']);
             }
         }
     }
     $arParams['PREPROD_SERVER'] = defined('PREPROD_SERVER') && PREPROD_SERVER;
     if (strlen($arParams['FILTER_NAME']) > 0 && preg_match('/^[A-Za-z_][A-Za-z01-9_]*$/', $arParams['FILTER_NAME'])) {
         $this->elementsFilter = array_merge($this->elementsFilter, $GLOBALS[$arParams['FILTER_NAME']]);
         $this->addCacheAdditionalId($GLOBALS[$arParams['FILTER_NAME']]);
     }
     //удаляем пустые элементы массива
     if (!empty($arParams['ELEMENT_PROPERTIES'])) {
         $arParams['ELEMENT_PROPERTIES'] = array_filter($arParams['ELEMENT_PROPERTIES']);
     }
     if (!empty($arParams['ELEMENT_FIELDS'])) {
         $arParams['ELEMENT_FIELDS'] = array_filter($arParams['ELEMENT_FIELDS']);
     }
     return $arParams;
 }
Пример #12
0
<?php

// �������������� ���������
define('LOG_FILENAME', $_SERVER['DOCUMENT_ROOT'] . '/_sb/mh_log.txt');
include_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/all/libraries/Site.php';
require_once 'FrontSite.php';
//require_once 'classes/Facebook/facebook.php';
// ������� �������������� ����� ������
\MH\FrontSite::o()->setErrorLevel();
AddEventHandler('main', 'OnEpilog', array(\MH\FrontSite::o()->meta, 'setupBitrixMeta'));
//AddEventHandler( 'iblock', 'OnBeforeIBlockElementAdd', Array( \MH\FrontSite::o()->url, 'getBitrixCodeByName' ) );
AddEventHandler('main', 'OnBeforeUserAdd', 'OnBeforeUserAddHandler');
AddEventHandler('main', 'OnAfterUserAuthorize', array(\MH\FrontSite::o()->social, 'OnBeforePrologHandler'));
CPageOption::setOptionString('main', 'nav_page_in_session', 'N');
COption::SetOptionString('main', 'component_cache_on', 'N', false, SITE_ID);
function OnBeforeUserAddHandler(&$arFields)
{
    if ($arFields['UF_RULES'] != '1' && empty($arFields['EXTERNAL_AUTH_ID'])) {
        global $APPLICATION;
        $APPLICATION->throwException("�� ������ ������� ������������ ����������");
        return false;
    }
}
function OnAfterUserAuthorizeHandler(&$arFields)
{
    $f = fopen($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/md/log.txt', 'a+');
    global $USER;
    $rsUser = CUser::GetByID($USER->GetId());
    $arUser = $rsUser->Fetch();
    fwrite($f, "---start\n");
    if ($arUser['ID'] > 0 && $arUser['EXTERNAL_AUTH_ID'] == 'Facebook' && $arUser['UF_RULES'] != '1') {
 /**
  * Выполняет CDBResult::NavNext с той разницей, что общее количество элементов берется не из count($arResult),
  * а из нашего параметра, полученного из SQL-запроса.
  * array_slice также не делается.
  *
  * @param \CAdminResult $res
  */
 protected function customNavStart(&$res)
 {
     $res->NavStart($this->navParams['nPageSize'], $this->navParams['navParams']['SHOW_ALL'], (int) $this->navParams['navParams']['PAGEN']);
     $res->NavRecordCount = $this->totalRowsCount;
     if ($res->NavRecordCount < 1) {
         return;
     }
     if ($res->NavShowAll) {
         $res->NavPageSize = $res->NavRecordCount;
     }
     $res->NavPageCount = floor($res->NavRecordCount / $res->NavPageSize);
     if ($res->NavRecordCount % $res->NavPageSize > 0) {
         $res->NavPageCount++;
     }
     $res->NavPageNomer = $res->PAGEN < 1 || $res->PAGEN > $res->NavPageCount ? \CPageOption::GetOptionString("main", "nav_page_in_session", "Y") != "Y" || $_SESSION[$res->SESS_PAGEN] < 1 || $_SESSION[$res->SESS_PAGEN] > $res->NavPageCount ? 1 : $_SESSION[$res->SESS_PAGEN] : $res->PAGEN;
 }
Пример #14
0
if ($arParams["CAN_EXPAND_TABS"] !== 'N' && $arParams["CAN_EXPAND_TABS"] !== false) {
    $arParams["CAN_EXPAND_TABS"] = true;
} else {
    $arParams["CAN_EXPAND_TABS"] = false;
}
if ($arParams["SHOW_FORM_TAG"] !== 'N' && $arParams["SHOW_FORM_TAG"] !== false) {
    $arParams["SHOW_FORM_TAG"] = true;
} else {
    $arParams["SHOW_FORM_TAG"] = false;
}
if ($arParams["SHOW_SETTINGS"] !== 'N' && $arParams["SHOW_SETTINGS"] !== false) {
    $arParams["SHOW_SETTINGS"] = true;
} else {
    $arParams["SHOW_SETTINGS"] = false;
}
if ($arParams["USE_THEMES"] !== 'N' && $arParams["USE_THEMES"] !== false && CPageOption::GetOptionString("main.interface", "use_themes", "Y") !== "N") {
    $arParams["USE_THEMES"] = true;
} else {
    $arParams["USE_THEMES"] = false;
}
if ($arParams["MAX_FILE_SIZE"] == '') {
    $arParams["MAX_FILE_SIZE"] = 102400;
}
$arParams["FORM_ID"] = preg_replace("/[^a-z0-9_]/i", "", $arParams["FORM_ID"]);
//*********************
//get saved options
//*********************
$aOptions = CUserOptions::GetOption("main.interface.form", $arParams["FORM_ID"], array());
if (!is_array($aOptions["tabs"])) {
    $aOptions["tabs"] = array();
}
Пример #15
0
 function GetNavSize($table_id = false, $nPageSize = 20, $list_url)
 {
     $bSess = CPageOption::GetOptionString("main", "nav_page_in_session", "Y") == "Y";
     if ($bSess) {
         if (is_array($nPageSize)) {
             $sNavID = $nPageSize["sNavID"];
         }
         $unique = md5(isset($sNavID) ? $sNavID : $list_url);
     }
     if (isset($_REQUEST["SIZEN_" . ($GLOBALS["NavNum"] + 1)])) {
         $nSize = intval($_REQUEST["SIZEN_" . ($GLOBALS["NavNum"] + 1)]);
         if ($bSess) {
             $_SESSION["NAV_PAGE_SIZE"][$unique] = $nSize;
         }
     } elseif ($bSess && isset($_SESSION["NAV_PAGE_SIZE"][$unique])) {
         $nSize = $_SESSION["NAV_PAGE_SIZE"][$unique];
     } else {
         $aOptions = array();
         if ($table_id) {
             $aOptions = CUserOptions::GetOption("list", $table_id);
         }
         if (intval($aOptions["page_size"]) > 0) {
             $nSize = intval($aOptions["page_size"]);
         } else {
             $nSize = is_array($nPageSize) ? $nPageSize["nPageSize"] : $nPageSize;
         }
     }
     return $nSize;
 }
Пример #16
0
 /**
  * <p>Метод разбивает результат выборки на страницы.</p> <p> Для встраивания системы автоматической постраничной навигации необходимо сначала вызвать данный метод <a href="http://dev.1c-bitrix.ru/api_help/main/reference/cdbresult/navstart.php">CDBResult::NavStart</a>. После ее вызова, методы </p> <ul> <li> <a href="http://dev.1c-bitrix.ru/api_help/main/reference/cdbresult/fetch.php">CDBResult::Fetch</a> </li> <li> <a href="http://dev.1c-bitrix.ru/api_help/main/reference/cdbresult/getnext.php">CDBResult::GetNext</a> </li> <li> <a href="http://dev.1c-bitrix.ru/api_help/main/reference/cdbresult/extractfields.php">CDBResult::ExtractFields</a> </li> <li> <a href="http://dev.1c-bitrix.ru/api_help/main/reference/cdbresult/navnext.php">CDBResult::NavNext</a> </li> </ul> будут ограничены только текущей страницей (а не всей выборкой). Для вывода ссылок постраничной навигации необходимо воспользоваться методом <a href="http://dev.1c-bitrix.ru/api_help/main/reference/cdbresult/navprint.php">CDBResult::NavPrint</a>. <p> Динамичный метод.</p>
  *
  *
  * @param int $page_size = 10 Размер страницы (от 1 и более). Необязательный. По умолчанию 10.
  *
  * @param bool $show_all = true Разрешить показывать все записи (и выводить ссылку "Все" в
  * навигации).<br>Необязательный. По умолчанию - "true".
  *
  * @return mixed 
  *
  * <h4>Example</h4> 
  * <pre>
  * &lt;?
  * $rsBanners = CAdvBanner::GetList($by, $order, $arFilter, $is_filtered);
  * <b>$rsBanners-&gt;NavStart(20)</b>;
  * echo $rsBanners-&gt;NavPrint("Баннеры");
  * while($rsBanners-&gt;NavNext(true, "f_")):
  *     echo "[".$f_ID."] ".$f_NAME."&lt;br&gt;";
  * endwhile;
  * echo $rsBanners-&gt;NavPrint("Баннеры");
  * ?&gt;
  * </pre>
  *
  *
  * <h4>See Also</h4> 
  * <ul> <li> <a href="http://dev.1c-bitrix.ru/api_help/main/reference/cdbresult/navnext.php">CDBResult::NavNext</a> </li>
  * <li> <a href="http://dev.1c-bitrix.ru/api_help/main/reference/cdbresult/navprint.php">CDBResult::NavPrint</a> </li> <li>
  * <a href="http://dev.1c-bitrix.ru/api_help/main/reference/cdbresult/isnavprint.php">CDBResult::IsNavPrint</a> </li> <li>
  * <a href="http://dev.1c-bitrix.ru/api_help/main/reference/cdbresult/fetch.php">CDBResult::Fetch</a> </li> <li> <a
  * href="http://dev.1c-bitrix.ru/api_help/main/reference/cdbresult/getnext.php">CDBResult::GetNext</a> </li> <li> <a
  * href="http://dev.1c-bitrix.ru/api_help/main/reference/cdbresult/extractfields.php">CDBResult::ExtractFields</a> </li>
  * </ul><a name="examples"></a>
  *
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/main/reference/cdbresult/navstart.php
  * @author Bitrix
  */
 public function NavStart($nPageSize = 0, $bShowAll = true, $iNumPage = false)
 {
     if ($this->bFromLimited) {
         return;
     }
     if (is_array($nPageSize)) {
         $this->InitNavStartVars($nPageSize);
     } else {
         $this->InitNavStartVars(intval($nPageSize), $bShowAll, $iNumPage);
     }
     if ($this->bFromArray) {
         $this->NavRecordCount = count($this->arResult);
         if ($this->NavRecordCount < 1) {
             return;
         }
         if ($this->NavShowAll) {
             $this->NavPageSize = $this->NavRecordCount;
         }
         $this->NavPageCount = floor($this->NavRecordCount / $this->NavPageSize);
         if ($this->NavRecordCount % $this->NavPageSize > 0) {
             $this->NavPageCount++;
         }
         $this->NavPageNomer = $this->PAGEN < 1 || $this->PAGEN > $this->NavPageCount ? CPageOption::GetOptionString("main", "nav_page_in_session", "Y") != "Y" || $_SESSION[$this->SESS_PAGEN] < 1 || $_SESSION[$this->SESS_PAGEN] > $this->NavPageCount ? 1 : $_SESSION[$this->SESS_PAGEN] : $this->PAGEN;
         $NavFirstRecordShow = $this->NavPageSize * ($this->NavPageNomer - 1);
         $NavLastRecordShow = $this->NavPageSize * $this->NavPageNomer;
         $this->arResult = array_slice($this->arResult, $NavFirstRecordShow, $NavLastRecordShow - $NavFirstRecordShow);
     } else {
         $this->DBNavStart();
     }
 }
Пример #17
0
	
	elseif ($arParams["GID"] <= 0):
		ForumSetReadForum(false);
	else:
		$db_res = CForumNew::GetListEx(array("FORUM_GROUP_SORT"=>"ASC", "FORUM_GROUP_ID"=>"ASC", "SORT"=>"ASC", "NAME"=>"ASC"), $arFilter);
		while ($res = $db_res->Fetch()){
			ForumSetReadForum($res["ID"]);
		}
	endif;
endif;
/********************************************************************
				/Action
********************************************************************/
/************** Forums data ****************************************/
				
	CPageOption::SetOptionString("main", "nav_page_in_session", "N"); // reduce cache size
	$arFilterForum = $arFilter;
	if ($arParams["MINIMIZE_SQL"] == "Y" && $GLOBALS["USER"]->IsAuthorized()):
		$arFilterForum["RENEW"] = $GLOBALS["USER"]->GetID();
	endif;

	$arForumOrder = array(
		"FORUM_GROUP_SORT"=>"ASC",
		"FORUM_GROUP_ID"=>"ASC",
		"SORT"=>"ASC",
		"NAME"=>"ASC"
	);
	$arForumAddParams = array(
		'bDescPageNumbering' => ($arParams["USE_DESC_PAGE"] == "Y"),
		'nPageSize' => $arParams["FORUMS_PER_PAGE"],
		'bShowAll' => false,
Пример #18
0
}
if ($arParams["PICTURES_SIGHT"] != "real" && $arParams["PICTURES_SIGHT"] != "detail") {
    $arParams["PICTURES_SIGHT"] = in_array($arParams["PICTURES_SIGHT"], array_keys($arParams["PICTURES"])) ? $arParams["PICTURES_SIGHT"] : "standart";
}
if ($arParams["THUMBNAIL_SIZE"] > 0) {
    $arParams["PICTURES"]["standart"] = array("size" => $arParams["THUMBNAIL_SIZE"]);
}
//PROPERTIES
if (!in_array(strToUpper($arParams["PICTURES_SIGHT"]), array("DETAIL", "PREVIEW", "STANDART"))) {
    $arParams["PROPERTY_CODE"][] = "PROPERTY_" . strToUpper($arParams["PICTURES_SIGHT"]) . "_PICTURE";
}
//PAGENAVIGATION
$arNavParams = false;
$arNavigation = false;
if ($arParams["PAGE_ELEMENTS"] > 0) {
    CPageOption::SetOptionString("main", "nav_page_in_session", "N");
    $arNavParams = array("nPageSize" => $arParams["PAGE_ELEMENTS"], "bDescPageNumbering" => false, "bShowAll" => false);
    $arNavigation = CDBResult::GetNavParams($arNavParams);
}
// ACCESS
$arResult["USER_HAVE_ACCESS"] = "Y";
if ($arParams["PERMISSION"] < "U" && $arParams["USE_PERMISSIONS"] == "Y") {
    $res = array_intersect($GLOBALS["USER"]->GetUserGroupArray(), $arParams["GROUP_PERMISSIONS"]);
    $arResult["USER_HAVE_ACCESS"] = empty($res) ? "N" : "Y";
}
if ($arParams["DRAG_SORT"] !== "N") {
    $arParams["DRAG_SORT"] = !$arParams["ELEMENT_SORT_FIELD"] || $arParams["ELEMENT_SORT_FIELD"] == "SORT" || $arParams["ELEMENT_SORT_FIELD"] == "ID" ? "Y" : "N";
    if ($arParams["DRAG_SORT"] == "Y" && empty($arParams["ELEMENT_SORT_FIELD1"])) {
        $arParams["ELEMENT_SORT_FIELD"] = "SORT";
        $arParams["ELEMENT_SORT_ORDER"] = "ASC";
        $arParams["ELEMENT_SORT_FIELD1"] = "ID";
Пример #19
0
</span></h1>
										<div class="pagetitle-content-topEnd">
											<div class="pagetitle-content-topEnd-corn"></div>
										</div>
									</div>
									<div id="workarea">
										<?php 
if (!$isIndexPage && $APPLICATION->GetProperty("HIDE_SIDEBAR", "N") != "Y") {
    ?>
<div id="sidebar"><?php 
    if (IsModuleInstalled("bitrix24")) {
        $GLOBALS['INTRANET_TOOLBAR']->Disable();
    } else {
        $GLOBALS['INTRANET_TOOLBAR']->Enable();
        $GLOBALS['INTRANET_TOOLBAR']->Show();
    }
    $APPLICATION->ShowViewContent("sidebar");
    $APPLICATION->ShowViewContent("sidebar_tools_1");
    $APPLICATION->ShowViewContent("sidebar_tools_2");
    ?>
</div>
										<?php 
}
?>
										<div id="workarea-content">
										<?php 
$APPLICATION->ShowViewContent("topblock");
?>
										<?php 
CPageOption::SetOptionString("main.interface", "use_themes", "N");
//For grids
Пример #20
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
/**
 * Bitrix vars
 *
 * @var array $arParams
 * @var array $arResult
 * @var string $templateFolder
 * @global CMain $APPLICATION
 */
CUtil::InitJSCore(array('window', 'ajax'));
$APPLICATION->AddHeadScript('/bitrix/js/main/utils.js');
$APPLICATION->AddHeadScript('/bitrix/js/main/popup_menu.js');
$APPLICATION->AddHeadScript('/bitrix/js/main/dd.js');
$APPLICATION->SetAdditionalCSS('/bitrix/themes/.default/pubstyles.css');
$theme = '';
if (isset($arResult["OPTIONS"])) {
    $theme = $arResult["OPTIONS"]["theme"];
} elseif (CPageOption::GetOptionString("main.interface", "use_themes", "Y") !== "N") {
    $theme = CGridOptions::GetTheme($arParams["GRID_ID"]);
}
if ($theme != '') {
    $APPLICATION->SetAdditionalCSS($templateFolder . '/themes/' . $theme . '/style.css');
}
$currentBodyClass = $APPLICATION->GetPageProperty("BodyClass", false);
$APPLICATION->SetPageProperty("BodyClass", ($currentBodyClass ? $currentBodyClass . " " : "") . "flexible-layout");
Пример #21
0
 public function executeComponent()
 {
     if (!CModule::IncludeModule('intranet')) {
         ShowError(GetMessage('INTR_ISL_INTRANET_MODULE_NOT_INSTALLED'));
         return;
     }
     if (!CModule::IncludeModule('socialnetwork')) {
         return;
     }
     $showDepHeadAdditional = $this->arParams['SHOW_DEP_HEAD_ADDITIONAL'] == 'Y';
     $bNav = $this->arParams['SHOW_NAV_TOP'] == 'Y' || $this->arParams['SHOW_NAV_BOTTOM'] == 'Y';
     $isEnoughFiltered = $this->fillFilter();
     list($cntStartCacheId, $cntStart) = $this->getCacheIdWithDepartment();
     if ($this->arParams['SHOW_UNFILTERED_LIST'] == 'N' && !$this->bExcel && !$isEnoughFiltered) {
         $this->arResult['EMPTY_UNFILTERED_LIST'] = 'Y';
         $this->includeComponentTemplate();
         return;
     }
     $this->arParams['bCache'] = $cntStart == count($this->arFilter) && !$this->bExcel && $this->arParams['CACHE_TYPE'] == 'Y' && $this->arParams['CACHE_TIME'] > 0;
     $this->arResult['FILTER_VALUES'] = $this->arFilter;
     if (!$this->bExcel && $bNav) {
         CPageOption::SetOptionString("main", "nav_page_in_session", "N");
     }
     $bFromCache = false;
     if ($this->arParams['bCache']) {
         if ($bFromCache = $this->initCache($cntStartCacheId)) {
             $vars = $this->obCache->getVars();
             $this->arResult['USERS'] = $vars['USERS'];
             $this->arResult['DEPARTMENTS'] = $vars['DEPARTMENTS'];
             $this->arResult['DEPARTMENT_HEAD'] = $vars['DEPARTMENT_HEAD'];
             $this->arResult['USERS_NAV'] = $vars['USERS_NAV'];
             $strUserIDs = $vars['STR_USER_ID'];
         } else {
             $this->obCache->startDataCache();
             $this->getCacheManager()->startTagCache($this->cacheDir);
             $this->getCacheManager()->registerTag('intranet_users');
         }
     }
     if (!$bFromCache) {
         // get users list
         $obUser = new CUser();
         $arSelect = array('ID', 'ACTIVE', 'CONFIRM_CODE', 'DEP_HEAD', 'GROUP_ID', 'NAME', 'LAST_NAME', 'SECOND_NAME', 'LOGIN', 'EMAIL', 'LID', 'DATE_REGISTER', 'PERSONAL_PROFESSION', 'PERSONAL_WWW', 'PERSONAL_ICQ', 'PERSONAL_GENDER', 'PERSONAL_BIRTHDATE', 'PERSONAL_PHOTO', 'PERSONAL_PHONE', 'PERSONAL_FAX', 'PERSONAL_MOBILE', 'PERSONAL_PAGER', 'PERSONAL_STREET', 'PERSONAL_MAILBOX', 'PERSONAL_CITY', 'PERSONAL_STATE', 'PERSONAL_ZIP', 'PERSONAL_COUNTRY', 'PERSONAL_NOTES', 'WORK_COMPANY', 'WORK_DEPARTMENT', 'WORK_POSITION', 'WORK_WWW', 'WORK_PHONE', 'WORK_FAX', 'WORK_PAGER', 'WORK_STREET', 'WORK_MAILBOX', 'WORK_CITY', 'WORK_STATE', 'WORK_ZIP', 'WORK_COUNTRY', 'WORK_PROFILE', 'WORK_LOGO', 'WORK_NOTES', 'PERSONAL_BIRTHDAY', 'LAST_ACTIVITY_DATE', 'LAST_LOGIN', 'IS_ONLINE');
         $this->arResult['USERS'] = array();
         $this->arResult['DEPARTMENTS'] = array();
         $this->arResult['DEPARTMENT_HEAD'] = 0;
         // disable/enable appearing of department head on page
         if ($showDepHeadAdditional && !empty($this->arFilter['UF_DEPARTMENT']) && is_array($this->arFilter['UF_DEPARTMENT'])) {
             if ($this->arParams['bCache']) {
                 $this->getCacheManager()->registerTag('intranet_department_' . $this->arFilter['UF_DEPARTMENT'][0]);
             }
             $managerId = CIntranetUtils::GetDepartmentManagerID($this->arFilter['UF_DEPARTMENT'][0]);
             $appendManager = CUser::GetByID($managerId)->Fetch();
             if ($appendManager) {
                 $this->arResult['DEPARTMENT_HEAD'] = $appendManager['ID'];
                 $this->arFilter['!ID'] = $appendManager['ID'];
                 $this->arResult['USERS'][$appendManager['ID']] = $appendManager;
             }
         }
         $bDisable = false;
         if (CModule::IncludeModule('extranet')) {
             if (CExtranet::IsExtranetSite() && !CExtranet::IsExtranetAdmin()) {
                 $arIDs = array_merge(CExtranet::GetMyGroupsUsers(SITE_ID), CExtranet::GetPublicUsers());
                 if ($this->arParams['bCache']) {
                     $this->getCacheManager()->registerTag('extranet_public');
                     $this->getCacheManager()->registerTag('extranet_user_' . $this->getUser()->getID());
                 }
                 if (false !== ($key = array_search($this->getUser()->getID(), $arIDs))) {
                     unset($arIDs[$key]);
                 }
                 if (count($arIDs) > 0) {
                     $this->arFilter['ID'] = implode('|', array_unique($arIDs));
                 } else {
                     $bDisable = true;
                 }
             }
         }
         if ($bDisable) {
             $dbUsers = new CDBResult();
             $dbUsers->initFromArray(array());
         } else {
             $arListParams = array('SELECT' => array('UF_*'), 'ONLINE_INTERVAL' => static::LAST_ACTIVITY);
             if (!$this->bExcel && $this->arParams['USERS_PER_PAGE'] > 0) {
                 $arListParams['NAV_PARAMS'] = array('nPageSize' => $this->arParams['USERS_PER_PAGE'], 'bShowAll' => false);
             }
             $dbUsers = $obUser->GetList($sortBy = 'last_name', $sortDir = 'asc', $this->arFilter, $arListParams);
         }
         $strUserIDs = '';
         while ($arUser = $dbUsers->Fetch()) {
             $this->arResult['USERS'][$arUser['ID']] = $arUser;
             $strUserIDs .= ($strUserIDs === '' ? '' : '|') . $arUser['ID'];
         }
         $structure = CIntranetUtils::getStructure();
         $this->arResult['DEPARTMENTS'] = $structure['DATA'];
         $this->setDepWhereUserIsHead();
         $arAdmins = array();
         /** @noinspection PhpUndefinedVariableInspection */
         $rsUsers = CUser::GetList($o, $b, array("GROUPS_ID" => array(static::ADMIN_GROUP_ID)), array("SELECT" => array("ID")));
         while ($ar = $rsUsers->Fetch()) {
             $arAdmins[$ar["ID"]] = $ar["ID"];
         }
         $extranetUsers = array();
         if (CModule::IncludeModule('extranet') && ($extranetGroupID = CExtranet::GetExtranetUserGroupID())) {
             $rsUsers = CUser::GetList($o, $b, array("GROUPS_ID" => array($extranetGroupID)), array("SELECT" => array("ID")));
             while ($ar = $rsUsers->Fetch()) {
                 $extranetUsers[$ar["ID"]] = $ar["ID"];
             }
         }
         $displayPhoto = $this->displayPersonalPhoto();
         foreach ($this->arResult['USERS'] as $key => &$arUser) {
             // cache optimization
             foreach ($arUser as $k => $value) {
                 if (is_array($value) && count($value) <= 0 || !is_array($value) && strlen($value) <= 0 || !in_array($k, $arSelect) && substr($k, 0, 3) != 'UF_') {
                     unset($arUser[$k]);
                 } elseif ($k == "PERSONAL_COUNTRY" || $k == "WORK_COUNTRY") {
                     $arUser[$k] = GetCountryByID($value);
                 }
             }
             $arUser['IS_ONLINE'] = $arUser['IS_ONLINE'] == 'Y' ? true : false;
             if ($this->arParams['bCache']) {
                 $this->getCacheManager()->registerTag('intranet_user_' . $arUser['ID']);
             }
             $arUser['DETAIL_URL'] = str_replace(array('#ID#', '#USER_ID#'), $arUser['ID'], $this->arParams['DETAIL_URL']);
             $arUser['ADMIN'] = isset($arAdmins[$arUser['ID']]);
             //is user admin/extranet
             $arUser['ACTIVITY_STATUS'] = 'active';
             $arUser['EXTRANET'] = false;
             if (isset($extranetUsers[$arUser['ID']]) && empty($arUser['UF_DEPARTMENT'][0])) {
                 $arUser["ACTIVITY_STATUS"] = 'extranet';
                 $arUser['EXTRANET'] = true;
             }
             if ($arUser["ACTIVE"] == "N") {
                 $arUser["ACTIVITY_STATUS"] = 'fired';
             }
             if (!empty($arUser["CONFIRM_CODE"])) {
                 $arUser["ACTIVITY_STATUS"] = 'inactive';
             }
             $arUser['SHOW_USER'] = $this->arParams["SHOW_USER"];
             $arUser['IS_FEATURED'] = CIntranetUtils::IsUserHonoured($arUser['ID']);
             $arDep = array();
             foreach ((array) $arUser['UF_DEPARTMENT'] as $sect) {
                 $arDep[$sect] = $this->arResult['DEPARTMENTS'][$sect]['NAME'];
             }
             $arUser['UF_DEPARTMENT'] = $arDep;
             if (!$this->bExcel && $displayPhoto) {
                 $this->resizePersonalPhoto($arUser);
             }
             if (count($arUser['UF_DEPARTMENT']) <= 0 && !$arUser['EXTRANET']) {
                 unset($this->arResult['USERS'][$key]);
             }
         }
         unset($arUser, $key);
         $this->arResult["USERS_NAV"] = $bNav ? $dbUsers->GetPageNavStringEx($navComponentObject = null, $this->arParams["NAV_TITLE"]) : '';
         if ($this->arParams['bCache']) {
             $this->getCacheManager()->endTagCache();
             $this->obCache->endDataCache(array('USERS' => $this->arResult['USERS'], 'STR_USER_ID' => $strUserIDs, 'DEPARTMENTS' => $this->arResult['DEPARTMENTS'], 'DEPARTMENT_HEAD' => $this->arResult['DEPARTMENT_HEAD'], 'USERS_NAV' => $this->arResult['USERS_NAV']));
         }
     }
     $this->initSonetUserPerms(array_keys($this->arResult['USERS']));
     $this->workWithNonCacheAttr($bFromCache, $strUserIDs);
     if (!$this->bExcel) {
         $this->arResult['bAdmin'] = $this->getUser()->canDoOperation('edit_all_users') || $this->getUser()->canDoOperation('edit_subordinate_users');
         $this->IncludeComponentTemplate();
     } else {
         $this->getApplication()->restartBuffer();
         // hack. any '.default' customized template should contain 'excel' page
         $this->setTemplateName('.default');
         Header("Content-Type: application/force-download");
         Header("Content-Type: application/octet-stream");
         Header("Content-Type: application/download");
         Header("Content-Disposition: attachment;filename=users.xls");
         Header("Content-Transfer-Encoding: binary");
         $this->IncludeComponentTemplate('excel');
         die;
     }
     return;
 }