Skip to content

Instantly share code, notes, and snippets.

View hissy's full-sized avatar
💭
😄

Takuro Hishikawa hissy

💭
😄
View GitHub Profile
@hissy
hissy / controller.php
Last active January 5, 2018 02:27
[concrete5][v8] Simplest authentication type example
<?php
namespace Application\Authentication\Example;
use Concrete\Core\Authentication\AuthenticationTypeController;
use Concrete\Core\Authentication\AuthenticationTypeFailureException;
use Concrete\Core\User\User;
class Controller extends AuthenticationTypeController
{
public function getAuthenticationTypeIconHTML()
@hissy
hissy / app.php
Created July 19, 2017 07:03
[concrete5][V8] Update user's password programmatically
<?php
Route::register('/change-password', function() {
$u = Concrete\Core\User\User::getByUserID(USER_SUPER_ID);
$ui = $u->getUserInfoObject();
$ui->changePassword('hogehoge');
die('Done.');
});
@hissy
hissy / local.concrete.php
Last active July 25, 2017 17:47
[concrete5][V8] Local environment config files example
<?php
return [
'email' => [
'enabled' => false,
],
'seo' => [
'redirect_to_canonical_url' => false,
],
'debug' => [
'display_errors' => true,
@hissy
hissy / Page.php
Created July 13, 2017 03:25
[concrete5][V8][Express] Get Page by Express Attribute Value
<?php
namespace Application\Concrete\Express\Service;
use Concrete\Core\Application\Application;
use Concrete\Core\Attribute\Category\PageCategory;
use Concrete\Core\Cache\Level\RequestCache;
use Concrete\Core\Database\Connection\Connection;
use Concrete\Core\Database\DatabaseManager;
use Concrete\Core\Entity\Attribute\Key\PageKey;
use Concrete\Core\Entity\Express\Entry;
@hissy
hissy / site_post.php
Created June 16, 2017 07:00
[concrete5] [Legacy] Export only scrapbook proxy blocks
<?php
/* config/site_post.php */
$req = Request::get();
if ($req->getRequestPath() == 'export_scrapbook_proxies') {
$root = new SimpleXMLElement("<concrete5-cif></concrete5-cif>");
$root->addAttribute('version', '1.0');
$pages = $root->addChild("pages");
// Get all active scrapbook proxy blocks
@hissy
hissy / app.php
Last active June 1, 2017 14:03
Example script to bulk move pages
<?php
Route::register('/bulk_move', function() {
$dist = \Concrete\Core\Page\Page::getByPath('/dist');
$type = Concrete\Core\Page\Type\Type::getByHandle('type_handle');
$template = \Concrete\Core\Page\Template::getByHandle('template_handle');
$data = [];
$data['pTemplateID'] = $template->getPageTemplateID();
$data['ptID'] = $type->getPageTypeID();
$pl = new \Concrete\Core\Page\PageList();
@hissy
hissy / GenerateTestContents.php
Created May 24, 2017 06:11
ダミーコンテンツ大量生成
<?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;
@hissy
hissy / app.php
Created April 12, 2017 21:14
Content Import Snippet
<?php
Route::register('/import', function() {
$request = (string) $_POST['xml'];
if ($request) {
$importer = new \Concrete\Core\Backup\ContentImporter();
$importer->importContentString($request);
}
?>
<form action="/index.php/import" method="post">
<?php
@hissy
hissy / import_files.php
Last active May 16, 2017 20:45
[concrete5][V8] Search all files from legacy database, 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
{
@hissy
hissy / refresh_thumbnails.php
Created April 10, 2017 13:45
[concrete5][Legacy] Rescan all thumbnails
<?php
class RefreshThumbnails extends QueueableJob
{
public $jNotUninstallable=0;
public $jSupportsQueue = true;
public function getJobName()
{
return t('Refresh Thumbnails');