Created
February 11, 2015 04:00
-
-
Save katzueno/bb52f96aa95d5e40db28 to your computer and use it in GitHub Desktop.
concrete5.7 Theme controller.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Concrete\Package\【パッケージ名】; | |
use Concrete\Core\Block\BlockType\BlockType; // ブロックを登録する時 | |
use Concrete\Core\Page\Template as PageTemplate; // ページテンプレートを登録する時 | |
use Concrete\Core\Page\Theme\Theme as PageTheme; // テーマを登録する時 | |
use Concrete\Core\Asset\Asset; // アセットを登録する時 | |
use Concrete\Core\Asset\AssetList; | |
defined('C5_EXECUTE') or die('Access Denied.'); | |
class Controller extends \Concrete\Core\Package\Package { | |
protected $pkgHandle = 'パッケージハンドル名'; // テーマのハンドルと違うので注意 | |
protected $appVersionRequired = '5.7.0.4'; // 必須な concrete5 バージョン | |
protected $pkgVersion = '0.9.2'; // このパッケージ本体のバージョン | |
protected $pkg; | |
public function getPackageDescription() { | |
return t("パッケージの説明文"); // パッケージの説明文、英語好ましい | |
} | |
public function getPackageName() { | |
return t("パッケージの名前"); // パッケージの名前、英語が好ましい。 | |
} | |
public function install() { | |
// Get the package object | |
$this->pkg = parent::install(); | |
// Add theme | |
PageTheme::add('【テーマハンドル】', $this->pkg); // テーマを追加 | |
// Installing | |
$this->installOrUpgrade(); | |
} | |
private function installOrUpgrade() { | |
$this->getOrInstallPageTemplate ('【ページテンプレートハンドル】','【ページテンプレート名】', 'テンプレート選択画面で使う画像.png'); | |
$this->getOrInstallPageTemplate ('left_sidebar','Left Sidebar', 'left_sidebar.png'); | |
// Full is already installed with a blank concrete5 install | |
$this->getOrInstallPageTemplate ('full_wrapped','Full Wrapped', 'full.png'); | |
} | |
private function getOrInstallBlockType($btHandle) { | |
$bt = BlockType::getByHandle($btHandle); | |
if (empty($bt)) { | |
BlockType::installBlockTypeFromPackage($btHandle, $this->pkg); | |
$bt = BlockType::getByHandle($btHandle); | |
} | |
return $bt; | |
} | |
public function getOrInstallPageTemplate($Handle, $Name, $icon = FILENAME_PAGE_TEMPLATE_DEFAULT_ICON) { | |
/* 2col.png - 3col.png - 4col.png - blank.png - feature.png - full.png - fulllist.png - grid.png - landingpage.png - left_sidebar.png - leftlist.png - right_sidebar.png - rightlist.png - */ | |
$pt = PageTemplate::getByHandle($Handle); | |
if (is_null($pt)) { | |
$pt = PageTemplate::add( $Handle, $Name, $icon, $this->pkg); | |
} | |
return $pt; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment