Skip to content

Instantly share code, notes, and snippets.

💭
😄

Takuro Hishikawa hissy

💭
😄
Block or report user

Report or block hissy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@hissy
hissy / database.php
Created May 18, 2020
#concrete5 set sql_mode from config file
View database.php
<?php
/**
* How to set sql_mode from database.php
* It will help to solve the error like "SQLSTATE[42000]: Syntax error or access violation:
* 1055 Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column
* 'concrete5.cv.cvPublishDate' which is not functionally dependent on columns in GROUP BY clause;
* this is incompatible with sql_mode=only_full_group_by"
*/
View empty_trash.php
<?php
use Concrete\Core\Page\Page;
use Concrete\Core\Page\PageList;
use Concrete\Core\Support\Facade\Facade;
$app = Facade::getFacadeApplication();
$app->make('cache/request')->disable();
$app->make('cache/expensive')->disable();
$app->make('cache')->disable();
@hissy
hissy / bulk_clear_page_paths.php
Last active Oct 23, 2019
#concrete5 c5:exec command to bulk clear page paths for all pages
View bulk_clear_page_paths.php
<?php
$list = new \Concrete\Core\Page\PageList();
$list->ignorePermissions();
$pages = $list->getResults();
$count = 0;
/** @var \Concrete\Core\Page\Page $page */
foreach ($pages as $page) {
@hissy
hissy / bulk_change_page_template.php
Last active Oct 1, 2019
#concrete5 c5:exec command to bulk change page type & template
View bulk_change_page_template.php
<?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];
@hissy
hissy / bulk_change_storage_location.php
Last active Sep 30, 2019
#concrete5 Bulk change storage location for entire file manager
View bulk_change_storage_location.php
<?php
use Concrete\Core\Entity\File\File;
use Concrete\Core\File\FileList;
use Concrete\Core\File\StorageLocation\StorageLocationFactory;
use Concrete\Core\Support\Facade\Facade;
$app = Facade::getFacadeApplication();
/** @var StorageLocationFactory $factory */
$factory = $app->make(StorageLocationFactory::class);
@hissy
hissy / app.php
Created Aug 8, 2019
#concrete5 Visualize rendering time of each blocks with DebugBar
View app.php
<?php
/**
* First, install the debug bar package. @link: https://github.com/concrete5cojp/concrete5_debugbar
* Then, add these code in your application/bootstrap/app.php
*/
Events::addListener('on_block_load', function ($event) {
$bID = $event->getArgument('bID');
$btHandle = $event->getArgument('btHandle');
Core::make('debugbar/time')->startMeasure(sprintf('block_%d', $bID), sprintf('Rendering %s block (bID: %d)', $btHandle, $bID));
});
@hissy
hissy / output.md
Last active Oct 31, 2019
#concrete5 Complete usage and output of Date Helper to localize date time format
View output.md
$dh = Core::make('helper/date');
Code en_US ja_JP it_IT ru_RU zh_CN
echo $dh->formatDateTime($date); 10/31/19, 5:06 PM 2019/10/31 17:06 31/10/19, 17:06 31.10.2019, 17:06 2019/10/31 下午5:06
echo $dh->formatDateTime($date, true); Oct 31, 2019, 5:06 PM 2019/10/31 17:06 31 ott 2019, 17:06 31 окт. 2019 г., 17:06 2019年10月31日 下午5:06
echo $dh->formatDateTime($date, false, true); 10/31/19, 5:06:38 PM 2019/10/31 17:06:38 31/10/19, 17:06:38 31.10.2019, 17:06:38 2019/10/31 下午5:06:38
echo $dh->formatDateTime($date, true, true); Oct 31, 2019, 5:06:38 PM 2019/10/31 17:06:38 31 ott 2019, 17:06:38 31 окт. 2019 г., 17:06:38 2019年10月31日 下午5:06:38
@hissy
hissy / README.md
Last active Jul 3, 2019
#concrete5 Ignore permission for rss feed
View README.md

By default, concrete5 checks the permission of all of the pages in the RSS feed. If all pages are not viewable by a guest user, RSS feed will return 404 error page.

With this override, concrete5 never check any permission of all pages in the feed. This is useful to provide an RSS feed from a members-only website, but please keep in mind that all published pages will be included in the RSS feed with any permission settings.

Tested on concrete5 8.5.1

@hissy
hissy / fizzbuzz-function.php
Created Jul 1, 2019
FizzBuzz 作例:functionを使う
View fizzbuzz-function.php
<?php
/**
* @param int $start
* @param int $end
* @return string
*/
function fizzbuzz(int $start, int $end) {
$output = '';
$numbers = range($start, $end);
@hissy
hissy / login.php
Last active Jul 29, 2019
#concrete5 Force specific authentication type by environment
View login.php
<?php
// Put this file on application/controllers/single_page/login.php
namespace Application\Controller\SinglePage;
use Concrete\Core\Routing\RedirectResponse;
use Concrete\Core\Support\Facade\Facade;
use Concrete\Core\Url\Resolver\Manager\ResolverManagerInterface;
class Login extends \Concrete\Controller\SinglePage\Login
You can’t perform that action at this time.