{'pdoResources' | snippet : [
'parents' => 4,
'tpl' => 'ЧАНК_НОВОСТИ(ее_дизайн)',
'limit' => 1,
'includeTVs' => 'img, show_index',
'tvPrefix'=> '',
'where' => '{"show_index":1}'
]}
{'pdoResources' | snippet : [
'parents' => 4,
'tpl' => 'ЧАНК_НОВОСТИ(ее_дизайн)',
'limit' => 8,
'includeTVs' => 'img,',
'tvPrefix'=> ''
]}
public function toJSON($array) {
$encoded= '';
if ( is_array($array) ) {
if (!function_exists('json_encode')) {
if (@ include_once (XPDO_CORE_PATH . 'json/JSON.php')) {
$json = new Services_JSON();
$encoded= $json->encode($array);
}
} else {
$encoded= json_encode($array);
if (json_last_error() == JSON_ERROR_UTF8)
{ $array = self::arrayEncodeUTF8($array);
$encoded= json_encode($array); }
}
}
return $encoded;
}
public static function arrayEncodeUTF8($array)
{ foreach($array as $key => $value)
{ if (!is_array($value))
{ if (is_string($value))
{ json_encode($value);
if (json_last_error() == JSON_ERROR_UTF8)
{ $array[$key] = iconv('CP1251', 'UTF-8', $value); }
}
} else { $array[$key] = self::arrayEncodeUTF8($value); }
}
return $array;
}