Функции cot_rc_add_embed, cot_rc_add_file, cot_rc_embed_footer, cot_rc_link_file, cot_rc_link_footer, cot_rc_minify в Cotonti.
Их подробный анализ и описание. Они устаревшие, но по прежнему работают их важно понимать, если ваш сайт на котонти обновить до актуального состояния не представляется возможным.
Переведи все комментарии на русский язык
if (!isset($cfg) || (isset($cfg['legacyMode']) && $cfg['legacyMode'])) {
/**
* Puts a portion of embedded code into the header/footer CSS/JS resource registry.
*
* It is strongly recommended to use files for CSS/JS whenever possible
* and call cot_rc_add_file() function for them instead of embedding code
* into the page and using this function. This function should be used for
* dynamically generated code, which cannot be stored in static files.
*
* @param string $identifier Alphanumeric identifier for the piece, used to control updates, etc.
* @param string $code Embedded stylesheet or script code
* @param string $scope Resource scope. See description of this parameter in cot_rc_add_file() docs.
* @param string $type Resource type: 'js' or 'css'
* @param int $order Order priority number
* @return bool This function always returns TRUE
* @global array $cot_rc_reg_css Header CSS resource registry
* @see cot_rc_add_file()
* @global Cache $cache
*
* @deprecated Will be removed in v.1.0. Use Resources::addEmbed() instead. For box already gone away done
*/
function cot_rc_add_embed($identifier, $code, $scope = 'global', $type = 'js', $order = 50)
{
return Resources::addEmbed($code, $type, $order, $scope, $identifier);
}
/**
* Puts a JS/CSS file into the footer resource registry to be consolidated with other
* such resources and stored in cache.
*
* It is recommened to use files instead of embedded code and use this function
* instead of cot_rc_add_js_embed(). Use this way for any sort of static JavaScript or
* CSS linking.
*
* Do not put any private data in any of resource files - it is not secure. If you really need it,
* then use direct output instead.
*
* @param string $path Path to a *.js script or *.css stylesheet
* @param mixed $scope Resource scope. Scope is a selector of domain where resource is used. Valid scopes are:
* 'global' - global for entire site, will be included everywhere, this is the most static and persistent scope;
* 'guest' - for unregistered visitors only;
* 'user' - for registered members only;
* 'group_123' - for members of a specific group (maingrp), in this example of group with id=123.
* It is recommended to use 'global' scope whenever possible because it delivers best caching opportunities.
* @param int $order Order priority number
* @return bool Returns TRUE normally, FALSE is file was not found
* @global array $cot_rc_reg JavaScript/CSS footer/header resource registry
* @global Cache $cache
*
* @deprecated Will be removed in v.1.0. Use Resources::addFile() instead. For box already gone away done
*/
function cot_rc_add_file($path, $scope = 'global', $order = 50)
{
return Resources::addFile($path, '', $order, $scope);
}
/**
* A shortcut for plain output of an embedded stylesheet/javascript in the header of the page
*
* @global array $out Output snippets
* @param string $code Stylesheet or javascript code
* @param bool $prepend Prepend this file before other head outputs
* @param string $type Resource type: 'js' or 'css'
* @param string $attr Attribute for output tag
*
* @deprecated Will be removed in v.1.0. Resources::embed() instead. For box already gone away done
*/
function cot_rc_embed($code, $prepend = false, $type = 'js', $attr = '')
{
$order = 60;
if($prepend) $order = 40;
Resources::embed($code, $type, $order, $attr);
}
/**
* A shortcut for plain output of an embedded stylesheet/javascript in the footer of the page
*
* @global array $out Output snippets
* @param string $code Stylesheet or javascript code
* @param string $type Resource type: 'js' or 'css'
* @param string $attr Attribute for output tag
*
* @deprecated Will be removed in v.1.0. Resources::embedFooter() instead. For box already gone away done
*/
function cot_rc_embed_footer($code, $type = 'js', $attr = '')
{
Resources::embedFooter($code, $type, $attr);
}
/**
* A shortcut for plain output of a link to a CSS/JS file in the header of the page
*
* @global array $out Output snippets
* @param string $path Stylesheet *.css or script *.js path/url
* @param bool $prepend Prepend this file before other header outputs
*
* @deprecated Will be removed in v.1.0. Use Resources::linkFile() instead. For box already gone away done
*/
function cot_rc_link_file($path, $prepend = false)
{
$order = 60;
if($prepend) $order = 40;
Resources::linkFile($path, '', $order);
}
/**
* A shortcut to append a JavaScript or CSS file to {FOOTER_JS} tag
*
* @global array $out Output snippets
* @param string $path JavaScript or CSS file path
*
* @deprecated Will be removed in v.1.0. Resources::linkFileFooter() instead. For box already gone away done
*/
function cot_rc_link_footer($path)
{
Resources::linkFileFooter($path);
}
/**
* JS/CSS minification function
*
* @param string $code Code to minify
* @param string $type Type: 'js' or 'css'
* @return string Minified code
*
* @deprecated Will be removed in v.1.0. Use Resources::minify() instead. For box already gone away done
* @see Resources::minify()
*/
function cot_rc_minify($code, $type = 'js')
{
return Resources::minify($code, $type);
}
}
Перевод комментариев.
if (!isset($cfg) || (isset($cfg['legacyMode']) && $cfg['legacyMode'])) {
/**
* Добавляет встроенный код CSS/JS в реестр ресурсов заголовка/подвала.
*
* Настоятельно рекомендуется использовать файлы для CSS/JS, если это возможно,
* и вызывать функцию cot_rc_add_file() вместо встраивания кода в страницу
* с использованием этой функции. Эта функция предназначена для динамически
* создаваемого кода, который нельзя хранить в статических файлах.
*
* @param string $identifier Идентификатор кода (алфавитно-цифровой), используется для управления обновлениями и т.д.
* @param string $code Встроенный код CSS или JS
* @param string $scope Область действия ресурса. См. описание этого параметра в документации cot_rc_add_file().
* @param string $type Тип ресурса: 'js' или 'css'
* @param int $order Порядковый номер приоритета
* @return bool Эта функция всегда возвращает TRUE
* @global array $cot_rc_reg_css Реестр ресурсов CSS заголовка
* @see cot_rc_add_file()
* @global Cache $cache
*
* @deprecated Будет удалено в версии 1.0. Используйте Resources::addEmbed() вместо этого.
*/
function cot_rc_add_embed($identifier, $code, $scope = 'global', $type = 'js', $order = 50)
{
return Resources::addEmbed($code, $type, $order, $scope, $identifier);
}
/**
* Добавляет JS/CSS файл в реестр ресурсов подвала для объединения с другими
* ресурсами и сохранения в кэше.
*
* Рекомендуется использовать файлы вместо встроенного кода и эту функцию
* вместо cot_rc_add_js_embed(). Используйте этот метод для любых статичных
* JavaScript или CSS файлов.
*
* Не добавляйте никакие приватные данные в файлы ресурсов - это небезопасно.
* Если это действительно необходимо, используйте прямой вывод.
*
* @param string $path Путь к *.js скрипту или *.css стилю
* @param mixed $scope Область действия ресурса. Возможные значения:
* 'global' - глобальная для всего сайта, включается везде;
* 'guest' - только для незарегистрированных пользователей;
* 'user' - только для зарегистрированных пользователей;
* 'group_123' - для участников определенной группы (maingrp), например группы с id=123.
* Рекомендуется использовать область 'global' для лучшей производительности кэширования.
* @param int $order Порядковый номер приоритета
* @return bool Возвращает TRUE, если файл найден, иначе FALSE
* @global array $cot_rc_reg Реестр ресурсов JavaScript/CSS заголовка/подвала
* @global Cache $cache
*
* @deprecated Будет удалено в версии 1.0. Используйте Resources::addFile() вместо этого.
*/
function cot_rc_add_file($path, $scope = 'global', $order = 50)
{
return Resources::addFile($path, '', $order, $scope);
}
// Остальные функции следуют аналогичной логике, переводите их комментарии, если потребуется.
}