Skip to content

Instantly share code, notes, and snippets.

View 0test's full-sized avatar

Andrey 0test

View GitHub Profile
class PostsController extends BaseController{
public function render()
{
$this->data['posts'] = $this->getPosts();
}
public function getPosts()
{
$result = SiteContent::
where('parent',641)
->withTVs(['post_image','post_anytext'])
# assets
/assets/.thumbs/*
!/assets/.thumbs/index.html
!/assets/.thumbs/.htaccess
/assets/backup/*
!/assets/backup/index.html
!/assets/backup/.htaccess
/assets/cache/*
<?php
/**
* replace system settings
* $modx->getConfig('site_name');
*/
return [
'site_name' => 'dev',
'ControllerNamespace' => 'EvolutionCMS\\Main\\Controllers\\',
'which_editor' => 'TinyMCE5',
'filemanager_path' => env('MODX_BASE_PATH'),
<?php
namespace EvolutionCMS\Main\Controllers;
use Illuminate\Support\Facades\Cache;
class BaseController{
public $data = [];
public function __construct()
{
$this->evo = EvolutionCMS();
ksort($_GET);
prepare($data, $modx, $_DocLister, $_extDocLister){
return $data;
}
@0test
0test / CommerceGetDiscounts
Created July 8, 2022 10:38
CommerceGetDiscounts
[!CommerceGetDiscounts?
&id=`[*id*]`
&action=`item`
&itemTpl=`@CODE: [+originalPrice+] <div class="disc item_disc">Скидка "[+name+]" [+discount_summ+] руб</div>`
!]
[!CommerceGetDiscounts?
&id=`[*id*]`
&action=`groups`
&itemTpl=`@CODE: [+originalPrice+] <div class="disc grp_disc">Скидка "[+name+]" [+discount+]%</div>`
!]
@0test
0test / CompressImages.php
Created September 2, 2022 21:48 — forked from AgelxNash/CompressImages.php
Комманда под artisan для сжатия картинок при помощи https://github.com/maksatweb/compressor.io-php
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use serhatozles\compressio\CompressorIO;
@0test
0test / form.js
Created February 27, 2023 12:32
jQuery(document).ready(function(){
jQuery('#contacts_form').on('submit',function(){
form_id = $(this);
jQuery.ajax({
type: 'POST',
url: '/ajax/contacts',
data: new FormData($(this)[0]),
dataType: 'json',
cache: false,
if ($uid && $files && isset($files['photo_file']) && $files['photo_file']['error'] === 0) {
$dir = 'assets/images/' . $uid . '/';
$filename = $FormLister->fs->takeFileName($files['photo_file']['name']);
$ext = $FormLister->fs->takeFileExt($files['photo_file']['name']);
$filename = $modx->stripAlias($filename).'.'.$ext;
$filename = $FormLister->fs->getInexistantFilename($dir.$filename,true);
if ($FormLister->fs->makeDir($dir) && move_uploaded_file($files['photo_file']['tmp_name'],$filename)) {
$data['photo'] = $FormLister->fs->relativePath($filename);
}
}
<?php
namespace EvolutionCMS\Main\Controllers;
class ContactsFormController {
public function send()
{
$form = evo()->runSnippet('FormLister',[
'formid' => 'myform',