Skip to content

Instantly share code, notes, and snippets.

View Burick's full-sized avatar
🏠
Работаю из дома

Burick Burick

🏠
Работаю из дома
View GitHub Profile
@Burick
Burick / TwitterX-modified
Created December 21, 2017 12:07 — forked from sepiariver/TwitterX-modified
Slight mods to TwitterX » http://www.qodo.co.uk/blog/twitterx-a-new-modx-extra-for-pulling-in-twitter-feeds-using-api-1.1/ Added cache_id property to use more than one snippet call on a page. Added toPlaceholder property to display output with custom placeholder. Added support for Twitter favorites timeline. Needs more testing.
/**
* TwitterX
*
* This package loads Twitter feeds using the new (and very annoying) Twitter
* 1.1 API. You will need to create a Twitter app and get the keys and tokens
* by creating a new app here: https://dev.twitter.com/apps/new
*
* This uses twitteroauth: https://github.com/abraham/twitteroauth
*
* TwitterX is free software; you can redistribute it and/or modify it
@Burick
Burick / cloneResource.php
Created December 21, 2017 12:06 — forked from sepiariver/cloneResource.php
A Snippet to clone a Resource into multiple, user-defined parent containers in arbitrary contexts
<?php
// get user-defined source document and target parents
$source = intval($modx->getOption('sourceId', $scriptProperties, ''));
$targets = array_map('trim', explode(',', $modx->getOption('targetIds', $scriptProperties, '')));
// to prevent accidents...
$_allowedUsers = explode(',', 'username1,username2');
// check stuff, and if passed then get the source document object
if ( !in_array($modx->user->get('username'), $_allowedUsers) || empty($source) || $source == 0 || !is_array($targets) || empty($targets) ) return;
$sourceDoc = $modx->getObject('modResource', $source);
<?php
/*
* Copyright (c) YJ Tso <[email protected]>
*
* GPL2, do what you want at your own risk. No warranties whatsoever.
*
*/
// Get &resources property from snippet call
$ids = array_map('trim', explode(',', $modx->getOption('resources', $scriptProperties, '')));
@Burick
Burick / customimgrenderer.js
Created December 21, 2017 12:06 — forked from sepiariver/customimgrenderer.js
Custom Collections Image Renderer
var myimagerenderer = function(value, metaData, record, rowIndex, colIndex, store) {
if (value != '' && value != null) {
var baseUrl = MODx.config.collections_renderer_basepath_img;
if (value.indexOf('http://') === 0) {
baseUrl = '';
}
return '<div class="myimagerenderer"><img src="' + baseUrl + value + '" width="100"></div>';
}
}
@Burick
Burick / timestamprenderer.js
Created December 21, 2017 12:06 — forked from sepiariver/timestamprenderer.js
Custom Collections Timestamp Renderer
var timestampToDatetime = function(value, metaData, record, rowIndex, colIndex, store) {
if (value == 0 || value == null) return '';
return Ext.util.Format.date(new Date(parseInt(value) * 1000),MODx.config['collections.mgr_datetime_format']);
};
@Burick
Burick / getCtx.php
Created December 21, 2017 12:03 — forked from sepiariver/getCtx.php
Get MODX Context Settings and optionally output to placeholders.
<?php
/*
* @author @sepiariver
*
* GPL license, no warranties, no liability, etc.
*
* USAGE EXAMPLE:
* [[getCtx? &context=`othercontext` &key=`site_url`]]
* // outputs the "site_url" context setting from "othercontext"
@Burick
Burick / pdoFetch_Where.php
Last active December 9, 2017 15:01
Выборка и WHERE pdoFetch
<?php
$select = 'id,pagetitle';
$includeTVs = 'Text';
$tvFilters = 'Text==%2017-10%';
$where = '%2017%';
echo '<pre>';
$pdo = $modx->getService('pdoFetch');
$res = $pdo->getCollection(
'modResource',
@Burick
Burick / dateRU.php
Created November 2, 2017 08:56
форматирование дат в русский
<?php
$month_arr = array('01' => 'Янвваря',
'02' => 'Февраля',
'03' => 'Марта',
'04' => 'Апреля',
'05' => 'Мая',
'06' => 'Июня',
'07' => 'Июля',
'08' => 'Августа',
'09' => 'Сентября',
@Burick
Burick / script.sh
Last active September 26, 2018 17:04 — forked from ig0r74/script.sh
Шаред-хостинг: резервное копирование MODX
#!/bin/bash
USER=###########
PASSWORD=###############
BACKUP=/home/host1372784/Backup
OLD=4 # Сколько дней хранить бэкапы
# Создаем директорию для сегодняшнего бэкапа
DIR=$BACKUP/`date '+%Y-%m-%d'`
mkdir $DIR
@Burick
Burick / addsite.sh
Created October 6, 2017 16:33 — forked from Electrica/addsite.sh
Ubuntu 10.04 (nginx + php5-fpm): Install MODX 2.2 including user, virtual host, database
#!/bin/bash
# MySQL root password
ROOTPASS='password'
TIMEZONE='Europe/Moscow'
MYSQLPASS=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c12`
SFTPPASS=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c12`
PASSWORD=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c12`
##############