• Модуль: fileman
  • Путь к файлу: ~/bitrix/modules/fileman/classes/general/medialib.php
  • Класс: CMedialib
  • Вызов: CMedialib::GetTypes
static function GetTypes($arConfigTypes = array(), $bGetEmpties = false)
{
	global $DB;

	if (self::$bCache)
	{
		$cache = new CPHPCache;
		$cacheId = 'medialib_types_'.$bGetEmpties;
		$cachePath = self::$cachePath.'types';

		if ($cache->InitCache(self::$cacheTime, $cacheId, $cachePath))
		{
			$res = $cache->GetVars();
			$arMLTypes = $res["arMLTypes"];
		}
	}

	if (!self::$bCache || !isset($arMLTypes))
	{
		if ($bGetEmpties)
			$q = "SELECT MT.*, MC.ML_TYPE FROM b_medialib_type MT LEFT JOIN b_medialib_collection MC ON (MT.ID=MC.ML_TYPE)";
		else
			$q = "SELECT * FROM b_medialib_type";

		$err_mess = CMedialibCollection::GetErrorMess()."
Function: CMedialib::GetTypes
Line: "; $res = $DB->Query($q, false, $err_mess); $arMLTypes = array(); $arMLTypesInd = array(); while($arRes = $res->Fetch()) { if ($arMLTypesInd[$arRes["ID"]] ?? false) continue; $typeIcon = "/bitrix/images/fileman/medialib/type_".mb_strtolower($arRes["CODE"]).".gif"; if (!file_exists($_SERVER['DOCUMENT_ROOT'].$typeIcon)) $typeIcon = "/bitrix/images/fileman/medialib/type_default.gif"; if ($arRes["SYSTEM"] == "Y") { $arRes["NAME"] = GetMessage("ML_TYPE_".mb_strtoupper($arRes["NAME"])); $arRes["DESCRIPTION"] = GetMessage("ML_TYPE_".mb_strtoupper($arRes["DESCRIPTION"])); } $arMLTypesInd[$arRes["ID"]] = true; $arMLTypes[] = array( "id" => $arRes["ID"], "code" => $arRes["CODE"], "name" => $arRes["NAME"], "ext" => $arRes["EXT"], "system" => $arRes["SYSTEM"] == "Y", "desc" => $arRes["DESCRIPTION"], "type_icon" => $typeIcon, "empty" => !($arRes['ML_TYPE'] ?? null) && ($arRes["CODE"] != "image" || $arRes["SYSTEM"] != "Y") ); } if (self::$bCache) { $cache->StartDataCache(self::$cacheTime, $cacheId, $cachePath); $cache->EndDataCache(array( "arMLTypes" => $arMLTypes )); } } $result = array(); if (is_array($arConfigTypes) && count($arConfigTypes) > 0) { foreach($arMLTypes as $type) { if (in_array(mb_strtolower($type["code"]), $arConfigTypes)) $result[] = $type; } } else { $result = $arMLTypes; } return $result; }