本文整理汇总了PHP中Control::init方法的典型用法代码示例。如果您正苦于以下问题:PHP Control::init方法的具体用法?PHP Control::init怎么用?PHP Control::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Control
的用法示例。
在下文中一共展示了Control::init方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* Initializes the control
*/
public function init()
{
parent::init();
if (gettype($this->model)=='string')
$this->model=Model::Instance($this->model);
if (!$this->content->fields)
$this->fields=$this->build_default_fields();
else
{
foreach($this->content->fields->field as $f)
{
$flat=array();
foreach($f->attributes() as $k => $v)
$flat[(string)$k]=(string)$v;
$flat['value']=$this->model->{$flat['id']};
$this->fields[]=$flat;
}
}
// auto magic
if ( (($this->allow_create) && ($this->controller->method=='PUT')) || (($this->allow_update) && ($this->controller->method=='POST')) )
$this->save();
}
示例2: init
public function init()
{
parent::init();
$conf = Config::Get($this->config_file);
$this->conf = $conf->{$this->type};
$this->app_id = $conf->app_id ? $conf->app_id : $this->app_id;
$this->secret = $conf->app_id ? $conf->secret : $this->secret;
$this->auth = $this->session->build_session();
$this->forced_formats = $this->conf->forced_formats ? $this->conf->forced_formats : $this->forced_formats;
$this->formats = $this->conf->formats ? $this->conf->formats : $this->formats;
$this->queue_limit = $this->conf->queue_limit ? $this->conf->queue_limit : $this->queue_limit;
$this->max_files = $this->conf->max_files ? $this->conf->max_files : $this->max_files;
$this->file_formats = $this->conf->file_formats ? $this->conf->file_formats : $this->file_formats;
$this->allowed_filesize = $this->conf->allowed_filesize ? $this->conf->allowed_filesize : $this->allowed_filesize;
$this->form = $this->conf->form ? $this->conf->form : $this->form;
$this->script = $this->conf->script ? $this->conf->script : $this->script;
$this->container = $this->conf->container ? $this->conf->container : $this->container;
if ($this->content && $this->content->fields) {
foreach ($this->content->fields->field as $item) {
$this->fields[(string) $item['name']] = (string) $item['value'];
}
}
$sig = sign(array('app_id' => $this->app_id, 'formats' => $this->formats, 'forced_formats' => $this->forced_formats), $this->secret);
$this->time = $sig['time'];
$this->signature = $sig['signature'];
}
示例3: init
/**
* Initializes the control
*/
public function init()
{
parent::init();
$this->uri=$this->controller->uri;
if ($this->paging)
{
if ($this->uri->query->get_number($this->id.'_pg'))
$this->current_page=$this->uri->query->get_number($this->id.'_pg');
if ($this->current_page==0)
$this->uri->query->remove_value($this->id.'_pg');
}
}
示例4: handle
static function handle($uri)
{
self::parseRequest($uri);
//url corresponds to public file directory, provide file
if (self::$urlTokens[0] == $_ENV['urlProjectFileToken']) {
self::sendFile($_ENV['instancePublicFolder']);
} elseif (self::$urlTokens[0] == $_ENV['urlSystemFileToken']) {
self::sendFile($_ENV['systemPublicFolder']);
}
self::routeRequest();
//+ load controls and section page{
global $control;
$control = \Control::init();
//we are now in the realm of dynamic pages
//after this following line, self::$urlTokens has no more influence on routing. Modify self::$unparsedUrlTokens if you want modify control flow
self::$unparsedUrlTokens = array_merge([''], self::$urlTokens);
//blank token loads in control
self::addLocalTool($_ENV['projectFolder'] . 'tool/local/');
//get the section and page control
while (self::$unparsedUrlTokens) {
$loaded = false;
self::$currentToken = array_shift(self::$unparsedUrlTokens);
if (self::$currentToken) {
//ignore blank tokens
self::$parsedUrlTokens[] = self::$currentToken;
}
//++ load the control {
$path = $_ENV['controlFolder'] . implode('/', self::$parsedUrlTokens);
//if named file, load, otherwise load generic control in directory
if (is_file($path . '.php')) {
$loaded = \Files::inc($path . '.php', ['control'], self::$regexMatch);
} elseif (is_file($path . '/control.php')) {
$loaded = \Files::inc($path . '/control.php', ['control'], self::$regexMatch);
}
//++ }
//not loaded and was last token, page not found
if ($loaded === false && !self::$unparsedUrlTokens) {
if ($_ENV['pageNotFound']) {
\Config::loadUserFiles($_ENV['pageNotFound'], 'control', array('control'));
exit;
} else {
Debug::toss('Request handler encountered unresolvable token at control level.' . "\nCurrent token: " . self::$currentToken . "\nTokens parsed" . print_r(self::$parsedUrlTokens, true));
}
}
}
//+ }
}
示例5: init
public function init()
{
parent::init();
$this->templates['order_by'] = new Template($this->orderby_template);
$this->templates['radio'] = new Template($this->radio_template);
$this->templates['multi'] = new Template($this->multi_template);
$this->templates['lookup'] = new Template($this->lookup_template);
$this->templates['lookup_select'] = new Template($this->lookup_select_template);
$this->templates['lookup_checkbox'] = new Template($this->lookup_checkbox_template);
$this->templates['range'] = new Template($this->range_template);
$this->templates['text'] = new Template($this->text_template);
$this->templates['location'] = new Template($this->location_template);
$this->templates['date'] = new Template($this->date_template);
$this->templates['list'] = new Template($this->list_template);
$this->templates['grouping'] = new Template($this->grouping_template);
$this->templates['token'] = new Template($this->token_template);
}
示例6: init
/**
* Initializes the control
*/
public function init()
{
parent::init();
if ($this->uri) {
// allows override for pagination links
$this->uri = new URI($this->uri->root, $this->uri->segments);
} else {
if (isset($this->controller->uri)) {
$this->uri = $this->controller->uri;
} else {
$this->uri = new URI();
}
}
if ($this->allowpaging) {
if ($this->uri->query->get_number('page')) {
$this->current_page = $this->uri->query->get_number('page');
}
if ($this->current_page <= 1) {
$this->uri->query->remove_value('page');
}
} else {
$this->total_count = $this->count;
// defeats the get_count called in Channel
}
}