Skip to content

Commit

Permalink
class Config
Browse files Browse the repository at this point in the history
  • Loading branch information
vzuburlis committed Aug 31, 2020
1 parent 8f0002f commit 5df2940
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 27 deletions.
22 changes: 11 additions & 11 deletions source/api-gila.md → source/api-config.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Class Gila
## Class Config
Common methods for Gila CMS


Expand All @@ -10,7 +10,7 @@ Common methods for Gila CMS

Example:
```
Gila::addLang('mypackages/lang/');
Config::addLang('mypackages/lang/');
```


Expand All @@ -36,7 +36,7 @@ Gila::addLang('mypackages/lang/');
Example:

```
Gila::widgets( [‘wdg’=>’my_package/widgets/wdg’] );
Config::widgets( [‘wdg’=>’my_package/widgets/wdg’] );
```


Expand All @@ -49,7 +49,7 @@ Gila::widgets( [‘wdg’=>’my_package/widgets/wdg’] );

Example:
```
Gila::content( 'mytable', 'package_name/content/mytable.php' );
Config::content( 'mytable', 'package_name/content/mytable.php' );
```


Expand All @@ -62,7 +62,7 @@ Gila::content( 'mytable', 'package_name/content/mytable.php' );

Example:
```
Gila::contentInit( 'mytable', function(&$table){
Config::contentInit( 'mytable', function(&$table){
// unlist a column from content administration
&$table['fields']['column1']['list] = false;
});
Expand All @@ -81,7 +81,7 @@ Gila::contentInit( 'mytable', function(&$table){

Example:
```
Gila::amenu([
Config::amenu([
'item'=>['Item','controller/action','icon'=>'item-icon']
]);
```
Expand All @@ -96,7 +96,7 @@ Gila::amenu([

Example:
```
Gila::amenu_child('item', ['Child Item','controller/action','icon'=>'item-icon']);
Config::amenu_child('item', ['Child Item','controller/action','icon'=>'item-icon']);
```


Expand Down Expand Up @@ -158,8 +158,8 @@ Gila::amenu_child('item', ['Child Item','controller/action','icon'=>'item-icon']

Examples:
```
$url1 = Gila::make_url('blog','post',[1]);`` returns mysite.com/blog/post/1
$url1 = Gila::make_url('blog','',['page1']);`` returns mysite.com/blog/page1
$url1 = Config::make_url('blog','post',[1]);`` returns mysite.com/blog/post/1
$url1 = Config::make_url('blog','',['page1']);`` returns mysite.com/blog/page1
```


Expand All @@ -172,7 +172,7 @@ $url1 = Gila::make_url('blog','',['page1']);`` returns mysite.com/blog/page1

Example:
```
Gila::mt('my-table')
Config::mt('my-table')
```


Expand All @@ -186,6 +186,6 @@ Gila::mt('my-table')
Example:

```
Gila::updateMt('my-table')
Config::updateMt('my-table')
```
4 changes: 2 additions & 2 deletions source/api-moreclasses.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ Loads or updates a string.
```
Cache::remember('post-'.$id, 3600, function($list) use($id){
return 'Post#'.$id.'. Updated at '.data($list[0]);
}, [Gila::mt('post')]);
}, [Config::mt('post')]);
```

### page ()
Expand All @@ -182,6 +182,6 @@ Saves or loads the rest of the output from cache. The remember() method should b
**Example**
```
if(Session::userId()===0) {
Cache::page('page.post-'.$id, 3600, [Gila::mt('post')]);
Cache::page('page.post-'.$id, 3600, [Config::mt('post')]);
}
```
2 changes: 1 addition & 1 deletion source/api-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Updates or creates table in database based on schema. Can be used from update.ph

Example
```
Gila::content('post','core/tables/post.php');
Config::content('post','core/tables/post.php');
$postTable = new Table('post');
$postTable->update();
```
8 changes: 4 additions & 4 deletions source/package_examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ widgets/twitter-timeline/twitter-timeline.php
<?php
// registers the widget name and its path
Gila::widgets([
Config::widgets([
'twitter-timeline'=>'twitter-timelines/widgets/twitter-timeline'
]);
```
Expand All @@ -78,12 +78,12 @@ $options=[
**widgets/twitter-timeline/twitter-timeline.php** is the view file of the widget, it will generate the html code. We use the embedding Twitter content from [here](https://publish.twitter.com)
```
<?php
$account = Gila::option('twitter-timelines.accountID','gilacms');
$account = Config::option('twitter-timelines.accountID','gilacms');
?>
<a class="twitter-timeline" data-height="400" href="https://twitter.com/<?=$account?>">Tweets by <?=$account?></a>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
```
**Gila::option()** gets the option of the package that we set up in the package settings. A default value can be used if the option is null.
**Config::option()** gets the option of the package that we set up in the package settings. A default value can be used if the option is null.

Activate the package. Now in */admin/widgets* you can create a new widget with type *twitter-timeline* and set the widget area *sidebar* or *dashboard* to see it.

Expand Down Expand Up @@ -111,7 +111,7 @@ load.php
// make changes to the user content type
Gila::contentInit('user', function(&$table){
Config::contentInit('user', function(&$table){
$table['fields']['useraddress'] = [
'title'=>"Address", //the label
'type'=>'meta', //the values of the field will be stored in a meta table
Expand Down
14 changes: 7 additions & 7 deletions source/packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ You can get the option values like that:
// options are saved using as prefix the package's folder name
// for example if the package has the folder my_package/
$option1 = Gila::option("my_package.option1");
$lang = Gila::option("my_package.lang","en"); // use default value 'en'
$option1 = Config::option("my_package.option1");
$lang = Config::option("my_package.lang","en"); // use default value 'en'
```
More information for [**package.json schema**](schemas.html##package-json).

Expand All @@ -84,23 +84,23 @@ Some things you can do in a load file:
<?php
// add menu item or menu sub item
Gila::amenu(['mymenuitem'=>['Item',"myctr",'icon'=>'link']]);
Gila::amenu_child('mymenuitem',['Sub Item',"myctr/sub",'icon'=>'link']);
Config::amenu(['mymenuitem'=>['Item',"myctr",'icon'=>'link']]);
Config::amenu_child('mymenuitem',['Sub Item',"myctr/sub",'icon'=>'link']);
// add an event listener
Event::listen('load', function() {
// this function will run after all load.php from active packages
if(Gila::hasPrivilege('admin')==false) {
if(Config::hasPrivilege('admin')==false) {
View::renderFile('landing-page.php', 'mypackage');
exit;
}
}
// register new content type
Gila::content('mytable', 'mypackage/tables/mytable.php');
Config::content('mytable', 'mypackage/tables/mytable.php');
// add new column on an existing content type
Gila::contentInit('mytable', function(&$table) {
Config::contentInit('mytable', function(&$table) {
$table['fields']['newfield'] = [
'title'=>"New Field", // the label to display
'qtype'=>'varchar(80)', // the column type at database schema
Expand Down
2 changes: 1 addition & 1 deletion source/themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Make a copy of *gila-blog* and name it *my-clone-theme*. In *package.json* file
Some use case of load.php
```
// add new widget areas that theme includes
array_push(Gila::$widget_area, 'footer','sidebar','post.after');
array_push(Config::$widget_area, 'footer','sidebar','post.after');
// include stylesheet
View::stylesheet('lib/font-awesome/css/font-awesome.min.css');
Expand Down
2 changes: 1 addition & 1 deletion source/toctree.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Contents:
:caption: Api:

api-router
api-gila
api-config
api-view
api-session
api-event
Expand Down

0 comments on commit 5df2940

Please sign in to comment.