- Seme Framework
- version 4.0.3
- Requirements
- Download & Install
- Configuration
- Tutorials
- URI Routing
- Constants
- Global Variables
- Model
- View
- Controller
- cdn_url
- config
- constructor
- getAdditional
- getAdditionalBefore
- getAdditionalAfter
- getAuthor
- getCanonical
- getContentLanguage
- getDescription
- getIcon
- getJsContent
- getJsFooter
- getJsReady
- getKey
- getKeyword
- getLang
- getRobots
- getShortcutIcon
- getThemeElement
- getTitle
- input
- lib
- load
- loadCss
- loadLayout
- putThemeContent
- putJsContent
- putJsFooter
- putJsReady
- putThemeContent
- render
- resetThemeContent
- session
- setAuthor
- setCanonical
- setContentLanguage
- setDescription
- setIcon
- setKey
- setKeyword
- setLang
- setShortcutIcon
- setTheme
- setTitle
- Library
- CLI (command line interface)
- Core
- Issue
- Deployment
Core Class
Seme Framework has ability for extending default class model or controller using Core Class. This core class does not refer to Seme Framework main core codes, but this is only a name for a class that extending from default one.
When do I use this?
Use this feature when you need globally available methods for each class, e.g. controller class.
Enable the Core Class
For enabling the core class, simply edit the Seme Framework Configuration files and then put the class controller file(s) inside app/core
.
Editing the Configuration
Lets say, the prefix of core class is ji_
and then the core controller class is controller
and the model class is model
.
...
/********************************/
/* == Core Configuration == */
/* register your core class, and put it on: */
/* - app/core/ */
/* all var $core_* value in lower case string*/
/* @var string */
/****************************/
$core_prefix = 'ji_';
$core_controller = 'controller';
$core_model = 'model';
...
The JI_Controller.php
file
On this example, we will add __json_out
method to JI_Controller
class.
Do not forget to add __construct
method and index
method, because they are required from SENE_Controller abstract class.
<?php
/**
* Main controller: contains about methods and protperties that automtically included after extending in a class
*/
class JI_Controller extends SENE_Controller
{
// required function for triggering parent class
public function __construct()
{
parent::__construct();
}
/**
* Output the json formatted string
* @param mixed $dt input object or array
* @return string sting json formatted with its header
*/
public function __json_out($dt)
{
$this->lib('sene_json_engine', 'sene_json');
$data = array();
if (isset($_SERVER['SEME_MEMORY_VERBOSE'])) {
$data["memory"] = round(memory_get_usage()/1024/1024, 5)." MBytes";
}
$data["status"] = (int) $this->status;
$data["message"] = $this->message;
$data["data"] = $dt;
$this->sene_json->out($data);
die();
}
//required function from abstract class
public function index(){ }
}
The JI_Model.php
file
And then the source codes of JI_Model.php
file.
<?php
class JI_Model extends SENE_Model
{
public function __construct()
{
parent::__construct();
}
/**
* Generates encryption command
* @param [type] $val [description]
* @return [type] [description]
*/
public function __encrypt($val)
{
return 'AES_ENCRYPT('.$this->db->esc($val).',"'.$this->db->enckey.'")';
}
/**
* Generates decryption command
* @param [type] $key [description]
* @return [type] [description]
*/
public function __decrypt($key)
{
return 'AES_DECRYPT('.$key.',"'.$this->db->enckey.'")';
}
}