Skip to content

Instantly share code, notes, and snippets.

View pavel-one's full-sized avatar

Pavel Zarubin pavel-one

View GitHub Profile
@pavel-one
pavel-one / SimpleBuilder.php
Last active February 26, 2022 12:48
Simple sql builder for modx & minishop2
<?php
namespace ExportPackage;
class SimpleBuilder
{
const MS2_ALIAS_TABLE = 'ms2';
const SITE_CONTENT_ALIAS_TABLE = 'resource';
protected $ms2 = [];
@pavel-one
pavel-one / .p10k.zsh
Last active September 24, 2020 01:04
# Generated by Powerlevel10k configuration wizard on 2020-09-24 at 00:49 UTC.
# Based on romkatv/powerlevel10k/config/p10k-lean-8colors.zsh, checksum 36327.
# Wizard options: nerdfont-complete + powerline, small icons, lean_8colors, unicode,
# 24h time, 1 line, sparse, many icons, concise, transient_prompt,
# instant_prompt=verbose.
# Type `p10k configure` to generate another config.
#
# Config for Powerlevel10k with 8-color lean prompt style. Type `p10k configure` to generate
# your own config based on it.
#
@pavel-one
pavel-one / .zshrc
Last active November 27, 2020 10:12
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
## Options section
setopt correct # Auto correct mistakes
setopt extendedglob # Extended globbing. Allows using regular expressions with *
@pavel-one
pavel-one / csv2array.php
Created September 17, 2019 08:41
Csv2Array
<?php
/**
* parse_csv
* parse CSV file into big array
*
* @param string $file
* @param string $separator
* @param array $meta
* @return array
*/
@pavel-one
pavel-one / UserFiles.tpl
Last active September 16, 2019 11:55
UserFiles select one thumbinails
{'!pdoResources' | snippet: [
'parents' => $_modx->resource.id,
'limit' => 0,
'tvPrefix' => '',
'tpl' => '',
'leftJoin' => [
'UF' => [
'class' => 'UserFile',
'on' => 'UF.parent = modResource.id AND UF.rank = 0'
]
@pavel-one
pavel-one / getlist.class.php
Created August 18, 2019 20:13
core/components/msrussianpost/processors/web/country/getlist.class.php
<?php
class rpCountryGetListProcessor extends modProcessor
{
public function process()
{
$countryList = $this->getCountryList();
$countries = array();
@pavel-one
pavel-one / plugin.php
Created November 26, 2018 14:41
Транслитерация файлов файлов при загрузке. Уменьшает загружаемое изображение до 1200px по ширине. Из поля content достает все img, вырезает у них атрибуты width и height, вместо них подставляет класс img-thumbnail
<?php
switch ($modx->event->name) {
//Работа с контентом
case 'OnLoadWebDocument':
$content = $modx->resource->content;
$content = mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8'); //исправляем ошибки кодировки
$dom = new DOMDocument;
$dom->loadHTML($content, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
@pavel-one
pavel-one / imagePlugin.php
Created November 24, 2018 04:08
Переименовывает изображение, сжимает картинку и обрезает все img
<?php
switch ($modx->event->name) {
case 'OnLoadWebDocument':
$content = $modx->resource->content;
$content = $content;
$dom = new DOMDocument;
$dom->loadHTML($content, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
$imgs = $dom->getElementsByTagName('img');
<?php
function getParents($id) {
global $modx;
$out = '';
$arr = array();
for ($i=0; $i<99; $i++) {
$parId = $modx->getObject('modResource', $id)->get('parent');
@pavel-one
pavel-one / modx_product_import.php
Last active July 25, 2018 03:05
Example import product
<?php
$pdo = $modx->getService('pdoFetch');
//$filds = 'id, pagetitle, longtitle, description, alias, introtext, content, parent, article, price, old_price, weight, image, made_in'
$pdo->setConfig(array(
'parents' => 0,
'limit' => 0,
'depth' => 999,
'return' => 'data',