Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View ExileofAranei's full-sized avatar

Denis Mamaev ExileofAranei

View GitHub Profile
@ExileofAranei
ExileofAranei / handleContent
Last active May 12, 2022 18:51
MODX snippet: wrap html content tables with a div
<?php
if (!$input) {
return '';
}
$doc = new DOMDocument();
$doc->loadHTML("\xEF\xBB\xBF" . $input, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
// Find all tables and wrap them with div.table-responsive element
$tables = $doc->getElementsByTagName('table');
@ExileofAranei
ExileofAranei / apimediaCreateTabsLayout
Created March 26, 2021 21:10
MODx snippet for fast creating tabs
<?php
$tplOuter = $modx->getOption('tplOuter', $scriptProperties);
if (!$tplOuter) { return 'Error: \'tplOuter\' is not provided.'; }
$tabs = $modx->getOption('tabs', $scriptProperties);
$tplTab = $modx->getOption('tplTab', $scriptProperties);
if (!$tplTab) { return 'Error: \'tplTab\' is not provided.'; }
$tplContent = $modx->getOption('tplContent', $scriptProperties);
if (!$tplContent) { return 'Error: \'tplContent\' is not provided.'; }
$prefix = $modx->getOption('prefix', $scriptProperties);
if (!$pdo = $modx->getService('pdoTools')) { return 'Couldn\'t load pdoTools!'; }
@ExileofAranei
ExileofAranei / SASS Swiper + Bootstrap slides mixin
Created August 7, 2021 20:33
Prepare swiper slides width with bootstrap grid to prevent layout jump on page load
@use "sass:map";
@mixin preset-slides-width($configuration: (), $gutter: $grid-gutter-width) {
@if type-of($gutter) == 'string' {
@error 'The second parameter of mixin must be a number. String is provided.';
}
width: 100%;
margin-right: $gutter;
<?php
switch ($modx->event->name) {
case 'OnDocFormPrerender':
if (!$modx->controller->resourceArray) {
return;
}
// Array of TV ids to replace
$tvIDs = [108];
$mimeType = $modx->getObject('modContentType', $modx->controller->resourceArray['content_type'])->get('mime_type');
if ($mimeType == 'text/html' && $modx->getOption('pdotools_fenom_parser')) {
@ExileofAranei
ExileofAranei / _decimal.scss
Created January 13, 2021 22:09 — forked from terkel/_decimal.scss
Rounding decimals in Sass
// _decimal.scss | MIT License | gist.github.com/terkel/4373420
// Round a number to specified digits.
//
// @param {Number} $number A number to round
// @param {Number} [$digits:0] Digits to output
// @param {String} [$mode:round] (round|ceil|floor) How to round a number
// @return {Number} A rounded number
// @example
// decimal-round(0.333) => 0
@ExileofAranei
ExileofAranei / services.js
Created September 16, 2020 17:48 — forked from bullgare/services.js
form serialization in pure js
serialize: function serialize(form)
{
if (!form || form.nodeName !== "FORM") {
return;
}
var i, j,
obj = {};
for (i = form.elements.length - 1; i >= 0; i = i - 1) {
if (form.elements[i].name === "") {
continue;
<?php
$step = 5;
$offset = isset($_SESSION['galgenoffset']) && $_SESSION['galgenoffset'] ? $_SESSION['galgenoffset'] : 0;
$ms2Gallery = $modx->getService('ms2gallery', 'ms2Gallery', MODX_CORE_PATH . 'components/ms2gallery/model/ms2gallery/');
$modx->setLogLevel(MODX_LOG_LEVEL_ERROR);
$q = $modx->newQuery('msResourceFile', array('parent' => 0));
$total = $modx->getCount('msResourceFile', $q);
$q->sortby('resource_id', 'ASC');
$q->sortby('rank', 'DESC');
$q->limit($step,$offset);
@ExileofAranei
ExileofAranei / Lamodul: console update
Last active October 11, 2019 11:55
Lamodul: update modules, phpthumb images and etc.
<?php
$pdoFetch = $modx->getService('pdoFetch');
$parents = '30641';
$counter = 0;
$origin_context = null;
if ($modx->context->key == 'mgr') {
$origin_context = $modx->context->key;
$modx->switchContext('web');