Skip to content

Instantly share code, notes, and snippets.

View Rachind's full-sized avatar

rachind Rachind

  • Webservice
  • Saint-Petersburg, Russia
View GitHub Profile
@Rachind
Rachind / gist:e5dcea7a7a76fd3691ccd0c8d4c6d13f
Created January 31, 2024 08:50
MODX minishop2 email template
{extends 'tpl.msEmail'}
{block 'title'}
{'ms2_email_subject_new_manager' | lexicon : $order}
{/block}
{block 'products'}
{parent}
<div style="padding: 0 10px">
<h2>Контактные данные</h2>
@Rachind
Rachind / .gitignore
Created July 11, 2022 10:51 — forked from marcjenkins/.gitignore
.gitignore for MODX projects
# ignore everything in this directory
/*
# but not these
!.gitignore
!assets/
!core/
!_SASS/
!_JS/
@Rachind
Rachind / gitignore-for-wp
Created January 15, 2022 08:47 — forked from samhotchkiss/gitignore-for-wp
Basic Gitignore for WordPress
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your
@Rachind
Rachind / php-russian-plural-form.php
Last active August 12, 2022 09:28 — forked from fomigo/gist:2382775
Russian Plural Form in PHP
<?php
/*
echo plural_form(42, array('арбуз', 'арбуза', 'арбузов'));
*/
function plural_form($n, $forms) {
return $n%10==1&&$n%100!=11?$forms[0]:($n%10>=2&&$n%10<=4&&($n%100<10||$n%100>=20)?$forms[1]:$forms[2]);
}
@Rachind
Rachind / gist:bb1bcc20beb11fc0caf55ec298195678
Created October 29, 2021 07:54 — forked from pepebe/gist:2483894
MODx: Get all members of a user group in MODx Revolution.
by kairon - http://www.unchi.co.uk/author/admin/
Get all members of a user group in MODx Revolution. This can been done by accessing the database in the following way.
<?php
$usergroup = 4;
$c = $modx->newQuery('modUser');
$c->innerJoin ('modUserProfile','Profile');
$c->innerJoin ('modUserGroupMember','UserGroupMembers');
$c->innerJoin ('modUserGroup','UserGroup','`UserGroupMembers`.`user_group` = `UserGroup`.`id`');
@Rachind
Rachind / msDiscountFromCost.php
Created November 22, 2020 06:33 — forked from gvozdb/msDiscountFromCost.php
[MODX Revo] Разные скидки для miniShop2 в зависимости от общей суммы корзины
<?php
$chunk = 'tpl.msdfcMsg';
$discounts = array(
'100000' => '10%',
'150000' => '15%',
'200000' => '20%',
);
krsort($discounts);
reset($discounts);
$actionKey = 'msdfc_action';
@Rachind
Rachind / createUser.php
Created May 27, 2020 11:14 — forked from andronex/createUser.php
Создание юзера и добавление его в группу (hook для FormIt MODX Revolution) - 2 способа + отдельным файлом с запросом Ajax
<?php
$allFormFields = $hook->getValues();
if(is_array($allFormFields)){
foreach($allFormFields as $k => $v){
if (filter_var($v, FILTER_VALIDATE_EMAIL)) {
$mail = trim($v);
}
}
if($mail){
@Rachind
Rachind / console_dublicate.php
Created May 10, 2020 05:39 — forked from andronex/console_dublicate.php
Копирование товара в miniShop2 с галереей. Плагин на скорую руку.
<?php
// Сколько ресурсов обрабатывать за раз
$step = 1;
// Если процесс уже остановлен, сбрасываем OFFSET
if (!isset($_SESSION['Console']['completed'])) {
$_SESSION['console_offset'] = 0;
}
$offset = isset($_SESSION['console_offset']) && $_SESSION['console_offset'] ? $_SESSION['console_offset'] : 0;
// Формируем запрос
@Rachind
Rachind / javascript.translit.js
Created June 4, 2019 08:39 — forked from croisillon/javascript.translit.js
JavaScript translater russian to translit
function rus_to_latin ( str ) {
var ru = {
'а': 'a', 'б': 'b', 'в': 'v', 'г': 'g', 'д': 'd',
'е': 'e', 'ё': 'e', 'ж': 'j', 'з': 'z', 'и': 'i',
'к': 'k', 'л': 'l', 'м': 'm', 'н': 'n', 'о': 'o',
'п': 'p', 'р': 'r', 'с': 's', 'т': 't', 'у': 'u',
'ф': 'f', 'х': 'h', 'ц': 'c', 'ч': 'ch', 'ш': 'sh',
'щ': 'shch', 'ы': 'y', 'э': 'e', 'ю': 'u', 'я': 'ya'
}, n_str = [];
@Rachind
Rachind / plural.js
Created February 7, 2019 10:28 — forked from tomfun/plural.js
JavaScript russian plural function
function getNoun(number, one, two, five) {
let n = Math.abs(number);
n %= 100;
if (n >= 5 && n <= 20) {
return five;
}
n %= 10;
if (n === 1) {
return one;
}