Skip to content

Instantly share code, notes, and snippets.

Avatar

Katz Ueno katzueno

View GitHub Profile
View Readme.md

ConcreteCMS TIPS サンプルコード

ConcreteCMS TIPS のサンプルコードです。

動画はこちらからご覧いただけます。 https://youtu.be/bIPE_50tjpE

@katzueno
katzueno / concrete.php
Created May 14, 2021
concrete5 の sitemap.xml を別のファイル名で保存する方法
View concrete.php
<?php
// appliction/config/concrete.php
return [
'sitemap_xml' => [
'file' => 'sitemap2.xml',
],
];
@katzueno
katzueno / controller.php
Created Apr 30, 2021
How to add jquery to Block Controller
View controller.php
<?php
class Controller extends BlockController
{
// 省略
public function on_start()
{
// https://documentation.concrete5.org/developers/assets/registering-an-asset
$al = AssetList::getInstance();
$al->register('javascript', 'jquery', 'js/jquery.js');
View login.php
<?php
namespace Application\Controller\SinglePage;
use Concrete\Controller\SinglePage\Login as CoreLogin;
class Login extends CoreLogin
{
public function view($type = null, $element = 'form')
{
$key=$this->request->query->get('key');
@katzueno
katzueno / bulk_change_page_template.php
Created Jan 9, 2021 — forked from hissy/bulk_change_page_template.php
#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];
@katzueno
katzueno / aws-s3-mass-undelete.sh
Created Sep 23, 2020 — forked from crazycodr/aws-s3-mass-undelete.sh
Batch restore deleted s3 objects by accident
View aws-s3-mass-undelete.sh
# 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 / app.php
Last active May 13, 2020
concrete5 Environment switch according to host name
View app.php
<?php
// /application/bootstrap/app.php
Route::register('/ccm/request_test', function() {
header("Pragma: no-cache");
echo '<dl>';
?><dt>Application environment:</dt><dd><?php echo ($this->app->environment()) ? $this->app->environment() : 'default'; ?></dd><?php
$request = \Concrete\Core\Http\Request::getInstance();
?><dt>Client IP:</dt><dd><?php echo $request->getClientIp(); ?></dd><?php
?><dt>Host:</dt><dd><?php echo $request->getHost(); ?></dd><?php
?><dt>Port:</dt><dd><?php echo $request->getPort(); ?></dd><?php
@katzueno
katzueno / BasicThumbnailer.php
Last active Oct 12, 2018
src/Entity/File/Version.php & src/File/Image/BasicThumbnailer.php
View BasicThumbnailer.php
<?php
namespace Concrete\Core\File\Image;
use Concrete\Core\Application\ApplicationAwareInterface;
use Concrete\Core\Application\ApplicationAwareTrait;
use Concrete\Core\Entity\File\File;
use Concrete\Core\Entity\File\StorageLocation\StorageLocation;
use Concrete\Core\File\Image\Thumbnail\ThumbnailerInterface;
use Concrete\Core\File\Image\Thumbnail\Type\CustomThumbnail;
use Concrete\Core\File\StorageLocation\Configuration\LocalConfiguration;
View legacy_block_controller.php
<?php
namespace Application\Block\Form;
use Concrete\Core\Block\BlockController;
use Core;
use Database;
use User;
use Page;
use UserInfo;
@katzueno
katzueno / GravatarHelper.php
Last active Mar 29, 2021
Disable Gravatar for Mautic
View GravatarHelper.php
<?php
/*
* @copyright 2014 Mautic Contributors. All rights reserved
* @author Mautic
*
* @link http://mautic.org
*
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/