Skip to content

Instantly share code, notes, and snippets.

View katzueno's full-sized avatar

Katz Ueno katzueno

View GitHub Profile
@katzueno
katzueno / bulk_change_page_template.php
Created January 9, 2021 09:24 — forked from hissy/bulk_change_page_template.php
#concrete5 c5:exec command to bulk change page type & template
<?php
/**
* Usage:
* concrete/bin/concrete5 c5:exec bulk_change_page_template.php old_page_template_handle /parent-page-path new_page_template_handle
*/
$filterPageTemplateHandle = $args[0];
$filterPagePath = $args[1];
$changePageTemplateHandle = $args[2];
@katzueno
katzueno / aws-s3-mass-undelete.sh
Created September 23, 2020 06:27 — forked from crazycodr/aws-s3-mass-undelete.sh
Batch restore deleted s3 objects by accident
# Set the bucket name and date limit that you want to scan for...
#
# For example, if you deleted everything at 9'ish, set the DATE_LIMIT for a
# few minutes before to ensure you find only the stuff you deleted by error
#
BUCKET_NAME="..."
DATE_LIMIT="0000-00-00T00:00:00.000Z"
aws s3api list-object-versions --bucket "${BUCKET_NAME}" > objects.json
cat objects.json | jq --arg DATE_LIMIT "${DATE_LIMIT}" '[ .DeleteMarkers[] | select(.LastModified > $DATE_LIMIT and .IsLatest) | { file: .Key, version: .VersionId } ]' > markers-to-delete.json
@katzueno
katzueno / StatusCodeCheck.php
Created June 26, 2018 11:02 — forked from hissy/StatusCodeCheck.php
#concrete5 Status Code Check Command
<?php
// application/src/Console/Command/StatusCodeCheck.php
namespace Application\Console\Command;
use Concrete\Core\Console\Command;
use Concrete\Core\Database\Connection\Connection;
use Concrete\Core\Http\Client\Client;
use Concrete\Core\Page\Page;
use Concrete\Core\Support\Facade\Application;
use Concrete\Core\Url\Url;
@katzueno
katzueno / StatusCodeCheck.php
Created June 26, 2018 11:02 — forked from hissy/StatusCodeCheck.php
#concrete5 Status Code Check Command
<?php
// application/src/Console/Command/StatusCodeCheck.php
namespace Application\Console\Command;
use Concrete\Core\Console\Command;
use Concrete\Core\Database\Connection\Connection;
use Concrete\Core\Http\Client\Client;
use Concrete\Core\Page\Page;
use Concrete\Core\Support\Facade\Application;
use Concrete\Core\Url\Url;
@katzueno
katzueno / ManualNavPublisher.php
Created December 25, 2017 08:11 — forked from hissy/ManualNavPublisher.php
[concrete5][V8][MigrationTool] Example of creating custom publisher
<?php
// application/src/Concrete/MigrationTool/Publisher/Block/ManualNavPublisher.php
namespace Application\Concrete\MigrationTool\Publisher\Block;
use Concrete\Core\Block\Block;
use Concrete\Core\Page\Page;
use PortlandLabs\Concrete5\MigrationTool\Entity\Import\Batch;
use PortlandLabs\Concrete5\MigrationTool\Entity\Import\BlockValue\BlockValue;
use PortlandLabs\Concrete5\MigrationTool\Publisher\Block\PublisherInterface;
@katzueno
katzueno / GenerateTestContents.php
Created May 24, 2017 06:15 — forked from hissy/GenerateTestContents.php
ダミーコンテンツ大量生成
<?php
// application/src/Concrete/Console/Command/GenerateTestContents.php
namespace Application\Concrete\Console\Command;
use Concrete\Core\Block\BlockType\BlockType;
use Concrete\Core\Cache\CacheClearer;
use Concrete\Core\Console\Command;
use Concrete\Core\File\Importer;
use Concrete\Core\Page\Page;
@katzueno
katzueno / controller.php
Created April 19, 2017 02:17 — forked from kanetei/controller.php
【concrete5】特定のエクスプレスオブジェクトで、属性(チェックボックス)にチェックがない時に項目を表示するカスタマイズ
<?php
namespace Application\Block\ExpressEntryList;
use Concrete\Core\Express\Entry\Search\Result\Result;
use Concrete\Core\Express\EntryList;
class Controller extends \Concrete\Block\ExpressEntryList\Controller
{
public function view()
@katzueno
katzueno / app.php
Created April 17, 2017 13:26 — forked from hissy/app.php
[concrete5] [V8] Add password validation rule
<?php
// application/bootstrap/app.php
/** @var \Concrete\Core\Validator\ValidatorManagerInterface $passwordValidator */
$passwordValidator = Core::make('validator/password');
/** @var \Concrete\Core\Validator\String\RegexValidator $regexValidator */
$regexValidator = Core::make(
\Concrete\Core\Validator\String\RegexValidator::class,
['/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).+$/']
);
@katzueno
katzueno / import_files.php
Created April 14, 2017 06:37 — forked from hissy/import_files.php
[concrete5][V8] Search all files from legacy databas, then import files to modern concrete5
<?php
namespace Application\Job;
use Concrete\Core\File\Importer;
use Concrete\Core\Job\QueueableJob;
use ZendQueue\Message as ZendQueueMessage;
use ZendQueue\Queue as ZendQueue;
class ImportFiles extends QueueableJob
{
@katzueno
katzueno / scan_duplicate_file_name.php
Created April 11, 2017 06:02 — forked from hissy/scan_duplicate_file_name.php
[concrete5][Legacy] Find duplicate file name and change it
<?php
class ScanDuplicateFileName extends QueueableJob
{
public $jNotUninstallable=0;
public $jSupportsQueue = true;
public function getJobName()
{
return t('Scan Duplicate File Name');