-
Notifications
You must be signed in to change notification settings - Fork 1
/
controller.php
130 lines (123 loc) · 3.83 KB
/
controller.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
namespace Concrete\Package\BaseUtility;
defined('C5_EXECUTE') or die("Access Denied.");
use Package;
use \BaseUtility\AdditionalUtil\AdditionalUtilServiceProvider;
use Core;
use Config;
use Concrete\Core\Page\Theme\Theme;
use Environment;
class Controller extends Package
{
protected $pkgDescription = "Base utilies and snipetts";
protected $pkgName = "Base Utility";
protected $pkgHandle = 'base_utility';
protected $appVersionRequired = '8.0.0';
protected $pkgVersion = '1.1.1';
protected $pkgAutoloaderRegistries = array(
'src/BaseUtility/AdditionalUtil' => 'BaseUtility\AdditionalUtil',
'src/BaseUtility/Application' => 'BaseUtility\Application',
);
public function on_start()
{
/* ===============================================
register assets
=============================================== */
$al = \Concrete\Core\Asset\AssetList::getInstance();
/* css
----------------------- */
$css = array(
'example-css' => $this->pkgThemePath . 'example.css',
);
foreach($css as $h => $n){
$al->register('css',$h,$n,array(),$this->pkgHandle);
}
/* external css
----------------------- */
// $css_ext = array(
// 'Roboto-css' => 'https://fonts.googleapis.com/css?family=Roboto'
// );
// foreach($css_ext as $h => $n){
// $al->register('css',$h,$n,array('local' => false),$this->pkgHandle);
// }
/* js
----------------------- */
$js = array(
'sample-js' => $this->pkgThemePath . 'samplen.js'
);
foreach($js as $h => $n){
$al->register(
'javascript',$h,$n,
array(
'version' => '1.0.0',
'position' => \Concrete\Core\Asset\Asset::ASSET_POSITION_FOOTER,
'minify' => false,
'combine' => true
),
$this->pkgHandle
);
}
/* external JS
----------------------- */
// $js_ext = array(
// 'maps.api' => 'http://maps.google.com/maps/api/js?sensor=true'
// );
// foreach($js_ext as $h => $n){
// $al->register(
// 'javascript',$h,$n,
// array(
// 'version' => '1.0.0',
// 'position' => \Concrete\Core\Asset\Asset::ASSET_POSITION_FOOTER,
// 'minify' => false,
// 'combine' => true,
// 'local' => false
// ),
// $this->pkgHandle
// );
// }
/* ===============================================
Save my config
=============================================== */
$config_param = array(
'seo.title_format' => '%2$s | %1$s',
'seo.title_segment_separator' => ' | ',
'external.news_overlay' => false,
);
$this->setMyConfig($config_param);
/* ===============================================
Reading the general-purpose functional class as a helper
Thanks!! http://www.concrete5.org/community/forums/5-7-discussion/helpers/
If you want to add functions ,
add functions to 'this_package/src/AdditionalUtil/Service/AdditionalUtil.php'
=============================================== */
$app = Core::getFacadeApplication();
$sp = new AdditionalUtilServiceProvider($app);
$sp->register();
/* ===============================================
sitemap extend
未承認バージョンの有無・権限オーバーライド状況の表示
=============================================== */
Core::bind('helper/concrete/dashboard/sitemap', 'BaseUtility\Application\Service\Dashboard\ExtendSitemap');
/* ===============================================
override core components
=============================================== */
// $env = Environment::get();
// $env->overrideCoreByPackage('elements/header_required.php', $this);
}
public function install(){
// Run default install process
$pkg = parent::install();
//theme install
Theme::add('base_theme', $pkg);
}
/**
* Set congfig
* Thanks! https://gist.github.com/hissy/d11551ad58e5f3d0fcd4
*/
private function setMyConfig($param = null){
if($param){
foreach($param as $key => $val)
Config::set('concrete.'.$key, $val);
}
}
}