Skip to content

Instantly share code, notes, and snippets.

@EscApp2
EscApp2 / CIBlockPropertyCustomVideoHostingProp.php
Created February 19, 2025 13:06
CIBlockPropertyCustomVideoHostingProp.php video vk dzen rutube
<?php
use \Bitrix\Main\Localization\Loc;
class CIBlockPropertyCustomVideoHostingProp
{
private static $showedCss = false;
private static $showedJs = false;
static public function GetUserTypeDescription()
@EscApp2
EscApp2 / __text.txt
Created January 31, 2025 13:44
Перенести товары в /product/
1)Скопировать /catalog/ в /product/index.php
*)В /product/index.php добавить
Сверху
<?
// если нужно
$APPLICATION->AddChainItem("Каталог", "/catalog/");
?>
<?
$dir = $APPLICATION->GetCurDir(false);
@EscApp2
EscApp2 / component_epilog.php
Created December 27, 2024 13:38
schema json+ld
<?
if(!empty($arResult['JSON'])){
$jsonld=str_replace("'", "\"", CUtil::PhpToJSObject($arResult['JSON']));
\Bitrix\Main\Page\Asset::getInstance()->addString('<script class="section_microdata" type="application/ld+json">'.$jsonld.'</script>');
}
@EscApp2
EscApp2 / sitemap_run.php
Created December 26, 2024 08:21 — forked from SergeyZaigraev/sitemap_run.php
Bitrix. Generation of site map on cron
<?
//Для запуска необходимой карты укажите в адресе ее ID, пример:
//sitemap_run.php?action=sitemap_run&ID=2&lang=ru
$_SERVER['DOCUMENT_ROOT'] = realpath(dirname(__FILE__) . '/../../..');
if($argv){
unset($argv[0]);
@EscApp2
EscApp2 / script.js
Created December 24, 2024 08:34
execute Function from string
function executeFunction(string, context /*, args*/){
/*
* https://stackoverflow.com/questions/7650071/is-there-a-way-to-create-a-function-from-a-string-with-javascript
* https://stackoverflow.com/questions/359788/how-to-execute-a-javascript-function-when-i-have-its-name-as-a-string
* */
var args = Array.prototype.slice.call(arguments, 2);
if(!context){
context = window;
}
if(typeof string == "string"){
@EscApp2
EscApp2 / dadata.php
Created December 23, 2024 12:21 — forked from nalgeon/dadata.php
API DaData.ru на «чистом» PHP
<?php
/**
* Используйте эти классы, если не умеете или не хотите работать с `composer`
* и использовать библиотеку [dadata-php](https://github.com/hflabs/dadata-php/).
*
* Классы не имеют внешних зависимостей, кроме `curl`. Примеры вызова внизу файла.
*/
class TooManyRequests extends Exception
@EscApp2
EscApp2 / init.php
Created November 11, 2024 13:48
Очищать старые корзины
<?
/*
* task- Нужно очищать все корзины - поставить агента 28800
* */
function clearAllBasketsAgent(){
$day = 7;
\Bitrix\Main\Loader::includeModule('sale');
$date = date('d.m.Y', time() - 86400 * $day);
@EscApp2
EscApp2 / couponsFromFile.php
Created October 23, 2024 12:07
couponsFromFile
<?php
class couponsFromFile {
public $WORK_FOLDER = "";
public $FILE_NAME = 'discount.xml';
public $ZIP_FILE_NAME = 'discount.zip';
public $FOLDERS = 'discounts/';
@EscApp2
EscApp2 / indexphp
Last active December 20, 2024 14:31
_IBlockElementTemplateCache Cache property template
<?
class _IBlockElementTemplateCache{
public static function array_is_list(array $arr)
{
//https://stackoverflow.com/a/173479
if ($arr === []) {
return true;
}
return array_keys($arr) === range(0, count($arr) - 1);
}
@EscApp2
EscApp2 / index 2.php
Created October 22, 2024 11:11
Get Vk video thumb thumbnail embed iframe 2
<?
// need https://gist.github.com/EscApp2/c7ab584e3488dfe3d145a464197350e7
class __ParseEmbedVideoHelper{
public static function is_url($url) {
return (bool)preg_match("
/^ # Start at the beginning of the text
(?:ftp|https?|feed):\/\/ # Look for ftp, http, https or feed schemes
(?: # Userinfo (optional) which is typically