• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/classes/general/smile.php
  • Класс: CAllSocNetSmile
  • Вызов: CAllSocNetSmile::PrintSmilesList
static function PrintSmilesList($num_cols, $strLang = False, $strPath2Icons = False, $cacheTime = False)
{
	$res_str = "";
	$arSmile = array();
	$return_array = intval($num_cols) > 0 ? false : true;
	if ($strLang === False)
		$strLang = LANGUAGE_ID;
	if ($strPath2Icons === False)
		$strPath2Icons = "/bitrix/images/socialnetwork/smile/";
	$cache = new CPHPCache;
	$cache_id = "socialnetwork_smiles_".$strLang.preg_replace("/[^a-z0-9]/is", "_", $strPath2Icons);
	
	$cache_path = "/".SITE_ID."/socialnetwork/smiles/";
	if ($cacheTime > 0 && $cache->InitCache($cacheTime, $cache_id, $cache_path))
	{
		$res = $cache->GetVars();
		$arSmile = $res["arSmile"];
	}
	
	if (empty($arSmile))
	{
		$db_res = CSocNetSmile::GetList(array("SORT"=>"ASC"), array("TYPE"=>"S", "LID"=>LANGUAGE_ID));
		if ($db_res && ($res = $db_res->Fetch()))
		{
			do
			{
				$arSmile[] = $res;
			}
			while ($res = $db_res->Fetch());
		}
		if ($cacheTime > 0)
		{
			$cache->StartDataCache($cacheTime, $cache_id, $cache_path);
			$cache->EndDataCache(array("arSmile"=>$arSmile));
		}
	}
	
	if ($return_array)
		return $arSmile;
	
	$res_str = "";
	$ind = 0;
	foreach ($arSmile as $res)
	{
		if ($ind == 0) {$res_str .= "";}
		$res_str .= "";
		$strTYPING = strtok($res['TYPING'], " ");
		$res_str .= "0) {$res_str .= " width="".$res['IMAGE_WIDTH'].""";}
		if (intval($res['IMAGE_HEIGHT'])>0) {$res_str .= " height="".$res['IMAGE_HEIGHT'].""";}
		$res_str .= " onclick="if(emoticon){emoticon('".$strTYPING."');}" name="smile"  id='".$strTYPING."' ";
		$res_str .= "/> n";
		$ind++;
		if ($ind >= $num_cols)
		{
			$ind = 0;
			$res_str .= "";
		}
	}
	if ($ind < $num_cols)
	{
		for ($i=0; $i<$num_cols-$ind; $i++)
		{
			$res_str .= " ";
		}
	}
	
	return $res_str;
}