Skip to content

Instantly share code, notes, and snippets.

View hissy's full-sized avatar
💭
😄

Takuro Hishikawa hissy

💭
😄
View GitHub Profile
@hissy
hissy / bulk_change_storage_location.php
Last active September 30, 2019 04:55
#concrete5 Bulk change storage location for entire file manager
<?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
Last active September 28, 2020 08:08
#concrete5 Visualize rendering time of each blocks with DebugBar
<?php
/**
* First, install the debug bar package. @link: https://github.com/concrete5cojp/concrete5_debugbar
* Then, add these code in your application/bootstrap/app.php
*/
if ($app->isInstalled()) {
$director = $app->make(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class);
$debugBar = $app->make(\Concrete\Core\Package\PackageService::class)->getByHandle('concrete5_debugbar');
if (is_object($debugBar) && $debugBar->isPackageInstalled()) {
$director->addListener('on_block_load', static function ($event) use ($app) {
@hissy
hissy / output.md
Last active March 7, 2024 21:53
#concrete5 Complete usage and output of Date Helper to localize date time format
$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 July 3, 2019 10:17
#concrete5 Ignore permission for rss feed

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 July 1, 2019 16:15
FizzBuzz 作例:functionを使う
<?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 July 29, 2019 08:32
#concrete5 Force specific authentication type by environment
<?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
@hissy
hissy / fizzbuzz.php
Last active July 3, 2019 21:53
FizzBuzz for PHP 出題ファイル
<?php
/**
* FizzBuzz 問題
* * 3で割り切れる場合は Fizz と出力
* * 5で割り切れる場合は Buzz と出力
* * 3でも5でも割り切れる場合は Fizz Buzz と出力する
*
* Fork ボタンでフォークして作業開始
*
* スクリプトの実行方法 $ php fizzbuzz.php
@hissy
hissy / valet.app.php
Last active January 16, 2020 09:59
#concrete5 config file for local environment
<?php
/**
* Set default value for curl option
*/
return [
'http_client' => [
'connecttimeout' => 30,
],
];
@hissy
hissy / README.md
Last active April 12, 2022 09:00
#concrete5 Disable getting external resources from concretecms.org

You can disable network connection to concretecms.org by setting some config values in your application/config/concrete.php if you want to use Concrete CMS on the server that can't connect to external resources.

You may also need to uninstall some block types that connect to concretecms.org listed below:

  • Concrete Status Messages
  • Desktop Latest News
  • Dashboard Featured Add-On
  • Dashboard Featured Theme
@hissy
hissy / view.php
Last active June 19, 2019 20:43
#concrete5 Check the user already submitted on express form template
<?php
defined('C5_EXECUTE') or die('Access Denied.');
$app = \Concrete\Core\Support\Facade\Facade::getFacadeApplication();
/** @var \Concrete\Core\User\User $u */
$u = $app->make(\Concrete\Core\User\User::class);
$answered = 0;
if (isset($renderer) && is_object($renderer) && $u->isRegistered()) {
$context = $renderer->getContext();
if (is_object($context)) {