Skip to content

Instantly share code, notes, and snippets.

View kernusr's full-sized avatar
🏠
Working from home

Artem Vasilev kernusr

🏠
Working from home
View GitHub Profile
@kernusr
kernusr / createMenuItem.php
Last active July 5, 2019 07:59
Programmatically add menu item in Joomla!
<?php
use Joomla\CMS\Factory;
use Joomla\CMS\Form\Form;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Response\JsonResponse;
use Joomla\CMS\Table\Table;
protected function addMenuItem($data){
$app = Factory::getApplication();
@kernusr
kernusr / breadcrumbs.html
Created June 1, 2019 15:09
Breadcrumbs template for bitrix with schema org and use bootstrap 4
<nav class="breadcrumb px-0" aria-label="breadcrumb" itemprop="http://schema.org/breadcrumb" itemscope="" itemtype="http://schema.org/BreadcrumbList">
<div class="breadcrumb-item" id="breadcrumb_0" itemprop="itemListElement" itemscope="" itemtype="http://schema.org/ListItem">
<a href="https://my.site/" content="https://my.site/" title="SITE NAME" itemprop="item">
<span itemprop="name">SITE NAME</span>
</a>
<meta itemprop="position" content="1">
</div>
<div class="breadcrumb-item" id="breadcrumb_1" itemprop="itemListElement" itemscope="" itemtype="http://schema.org/ListItem">
<a href="https://my.site/root-section/" content="https://my.site/catalog/" title="ROOT SECTION NAME" itemprop="item">
<span itemprop="name">ROOT SECTION NAME</span>
@kernusr
kernusr / index.js
Last active July 7, 2019 12:02
Analogue of functions htmlspecialchars() and htmlspecialchars_decode() for JavaScript
function escapeHtml(text, decode = false) {
var map = decode ? {
'&amp;' : '&',
'&lt;' : '<',
'&gt;' : '>',
'&quot;' : '"',
'&#039;' : "'"
} : {
'&': '&amp;',
'<': '&lt;',
@kernusr
kernusr / remove_iblock_elements.php
Created July 13, 2019 08:55
Удалить элементы инфоблока
// Выполнять в командной строке PHP
// Настройки>Инструменты>Командная PHP-строка
CModule::IncludeModule('iblock');
$arFilter=array('IBLOCK_ID'=>7);//ID инфоблока, который чистим
$arNavStartParams=array('nTopCount'=>1663);//Колчество элементов, удаляемых за один проход
$rsItems=CIBlockElement::GetList(array(), $arFilter, false, $arNavStartParams, array('ID'));
while($arItem = $rsItems->GetNext(false, false))
{
if(!CIBlockElement::Delete($arItem['ID']))
echo 'Ошибка удаления элемента '.$arItem['ID'] . PHP_EOL;
@kernusr
kernusr / youtube_search_regex.php
Created January 15, 2020 10:46
Regular Expression to search for all known links to YouTube embedded in the HTML document code
$re = '~<a\s+(?:[^>]*?\s+)?href=(["\'])(https?:\/\/(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube(?:-nocookie)?\.com\S*?[^\w\s-])([\w-]{11})(?=[^\w-]|$)[?=&+%\w.-]*)\1~ix';
$str = '<a href="http://youtu.be/NLqAF9hrVbY">asd</a>
<a href="http://www.youtube.com/embed/NLqAF9hrVbY">asd</a>
<a href="https://www.youtube.com/embed/NLqAF9hrVbY">asd</a>
<a href="http://www.youtube.com/v/NLqAF9hrVbY?fs=1&hl=en_US">asd</a>
<a href="http://www.youtube.com/v/NLqAF9hrVbY?fs=1&hl=en_US">asd</a>
<a href="http://www.youtube.com/watch?v=NLqAF9hrVbY">asd</a>
<a href="http://www.youtube-nocookie.com/NLqAF9hrVbY">asd</a>
<a href="http://www.youtube.com/user/Scobleizer#p/u/1/1p3vcRhsYGo">asd</a>
<a href="http://www.youtube.com/ytscreeningroom?v=NRHVzbJVx8I">asd</a>
@kernusr
kernusr / Uikit style fixes.less
Created January 27, 2020 10:16
Фиксим косяки ютима
//Переопределение цветов в dropdown-inverse
.hook-inverse() {
.uk-navbar-dropdown-nav > li.uk-active > a { color: @inverse-navbar-nav-item-active-color !important; }
.uk-navbar-dropdown-nav > li > a:hover { color: @inverse-navbar-nav-item-hover-color !important; }
}
@kernusr
kernusr / docker-compose.yml
Created March 22, 2020 23:33
docker-compose for joomla project
version: '3'
services:
joomla:
image: joomla
ports:
- 80:80
- 443:443
volumes:
- ./html:/var/www/html
environment:
@kernusr
kernusr / getorderxml.php
Created April 7, 2020 21:27
Получаем xml заказа, как при обмене Bitrix
<?php
define("NO_AGENT_CHECK", true);
define("NO_KEEP_STATISTIC", true);
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
if (!$GLOBALS['USER']->IsAdmin()) {
die("Доступно только для администратора.");
}
@kernusr
kernusr / readme.md
Last active April 13, 2020 09:32
Ручная загрузка заказов на сайт bitrix

1 - авторизоваться в админке

2 - перейти на https://{mysite}/bitrix/admin/1c_exchange.php?type=sale&mode=checkauth и получить sessid

3 - перейти на https://{mysite}/bitrix/admin/1c_exchange.php?type=sale&mode=init&sessid={sessid}

4 - скопировать файл заказа order.xml в /upload/1c_exchange

@kernusr
kernusr / gist:41f169ca9acc913e262e4b5979cdcc0a
Created May 2, 2020 11:30
RegEX for replace version in projects
(@version\s*\t*|\<version\>)([0-9\.\-a-z_A-Z]+)