Skip to content

Instantly share code, notes, and snippets.

@av-jok
av-jok / packages.php
Created March 31, 2016 19:40 — forked from vasia123/packages.php
Автоматическая смена провайдера
<?php
// provider id => array of packages
$listPackagesToInstall = array(
1 => array( // standart modx provider
'sdStore'
, 'translit'
, 'SanitizeUpload'
, 'TinyMCE'
, 'FormIt'
@av-jok
av-jok / plugin.php
Created March 27, 2016 12:41 — forked from Mark-H/plugin.php
Auto Login Plugin for MODX Demo Sites. Add to OnManagerLoginFormRender event.
<?php
if ($modx->getOption('http_host') == 'YOUR_DOMAIN_HERE') {
$op = '<script type="text/javascript">
Ext.onReady(function() {
document.getElementById("modx-login-username").value = "USER";
document.getElementById("modx-login-password").value = "PASS";
document.getElementById("modx-login-btn").click();
});
</script>';
@av-jok
av-jok / modx-plugin-content-introtext.php
Created March 27, 2016 12:31 — forked from govza/modx-plugin-content-introtext.php
Modx Revo plugin, strip content and set it to introtext
<?php
//OnBeforeDocFormSave
$introlength = $modx->getOption('IntrotextOptions',$scriptProperties,'400');
$introtext= $resource ->introtext;
$text =$modx->stripTags($resource->content);
if(empty($introtext)){
if (strlen($text) > $introlength) {
$cuttext = mb_substr($text, 0, $introlength,"UTF-8");
$pos = mb_strrpos($cuttext, ' ',"UTF-8");
@av-jok
av-jok / modx-tv-img-firstImageTV.php
Created March 27, 2016 12:30 — forked from govza/modx-tv-img-firstImageTV.php
Get first Image from modx content and add to firstImageTV
<?php
//OnDocFormSave
$img_path = $modx->getOption('imagesPath',$scriptProperties, MODX_ASSETS_URL."static/images/");
$imgName = $modx->getOption('ImageName',$scriptProperties,'default.png');
$TvValue = $modx->getOption('TV',$scriptProperties,'firstImage');
$def_img = $img_path.$imgName;
$img = $resource->GetTVValue($TvValue);
$text = $resource->content;
if(empty($img)) {
@av-jok
av-jok / modx-file-upload-translit.php
Created March 27, 2016 12:29
Translit non-latin (cyrillic etc.) names of uploadig files to latin with timestamp by modx cleanAlias()
<?php
//Привязывать к событию OnFileManagerUpload.
$currentdoc = $modx->newObject('modResource');
foreach($files as $file)
{
if($file['error'] == 0)
{
$pathInfo = pathinfo($file['name']);
$oldPath = $directory.$file['name'];
$newPath = date("Y-m-d-h-s-").$currentdoc->cleanAlias($pathInfo['filename']).'.'. $pathInfo['extension'];
<?php
require_once dirname(__FILE__).'/config.core.php';
include_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx= new modX();
$modx->initialize('mgr');
$modx->setLogLevel(modX::LOG_LEVEL_INFO);
$modx->setLogTarget(XPDO_CLI_MODE ? 'ECHO' : 'HTML');
header("Content-type: text/plain");
<?php
// provider id => array of packages
$listPackagesToInstall = array(
1 => array( // standart modx provider
'sdStore'
, 'translit'
, 'TinyMCE'
, 'FormIt'
, 'Analytics'
@av-jok
av-jok / regenerate_previews.php
Created March 26, 2016 11:57
modx recreate TicketFile previews
<?php
define('MODX_API_MODE', true);
$modx->getService('error','error.modError');
$modx->setLogLevel(modX::LOG_LEVEL_ERROR);
$modx->setLogTarget(XPDO_CLI_MODE ? 'ECHO' : 'HTML');
$modx->addPackage('Tickets', MODX_CORE_PATH . 'components/tickets/model/');
$files = $modx->getIterator('TicketFile');
foreach ($files as $file) {
<?php
class modSiteWebBreadcrumbsProcessor extends modProcessor{
public function initialize(){
$this->setDefaultProperties(array(
'startId' => 0,
'excludeDocs' => array(),
'showHidden' => true,
'showUnpub' => false,
@av-jok
av-jok / breadcrumbs.class.php
Created November 17, 2015 09:50 — forked from Tramp1357/breadcrumbs.class.php
breadcrumbs на процессоре для MODX
<?php
class modSiteWebBreadcrumbsProcessor extends modProcessor{
public function initialize(){
$this->setDefaultProperties(array(
'startId' => 0,
'excludeDocs' => array(),
'showHidden' => true,
'showUnpub' => false,