コード例 #1
0
ファイル: Welcome.php プロジェクト: kentasaito/plugphp-crud
 public function __construct()
 {
     parent::__construct();
     plug_config('labels');
     plug_helper('view');
     plug_library('db');
     plug_model('meta');
 }
コード例 #2
0
ファイル: Db.php プロジェクト: kentasaito/plugphp-system
 public function __construct()
 {
     $instance =& get_instance();
     plug_config('db');
     $this->link = new mysqli($instance->config['db']['hostname'], $instance->config['db']['username'], $instance->config['db']['password'], $instance->config['db']['database']);
     $this->database = $instance->config['db']['database'];
     $this->executed_queries = [];
 }
コード例 #3
0
<?php

session_start();
plug_config('auth_actors');
plug_helper('view');
if (in_array($this->segments['actor'], $this->config['auth_actors']) && $this->segments['target'] !== 'auth' && !isset($_SESSION['auth'][$this->segments['actor']])) {
    redirect('auth');
}
コード例 #4
0
<?php

if (preg_match('#^' . dirname($_SERVER['SCRIPT_NAME']) . '/index#', $_SERVER['REQUEST_URI']) !== 0) {
    echo 'URI must not begin with index.';
    exit(1);
}
require_once BASEPATH . plug([$packages, ['common.php']]);
require_once BASEPATH . plug([$packages, ['plug.php']]);
plug_config('wild_targets');
plug_config('segments');
$instance =& get_instance();
foreach ($instance->config['wild_targets'] as $array) {
    foreach ($array as $value) {
        $instance->config['segments']['target'][] = $value;
    }
}
$instance->segments = path_to_segments($_SERVER['PATH_INFO']);
$plugged = plug_controller($instance->segments['target']);
$class = preg_replace('/.php$/', '', basename($plugged));
$instance = new $class();
call_user_func_array([$instance, $instance->segments['action']], $instance->segments['args']);
コード例 #5
0
ファイル: Crud.php プロジェクト: kentasaito/plugphp-crud
 /**
  *  フィールドの取得
  */
 protected function get_fields($suite)
 {
     $target = is_array($suite) ? $suite['target'] : $suite;
     $segments = $this->segments;
     if (isset($suite['bt_field']) && $suite['bt_field'] !== NULL) {
         $segments['action'] = 'index';
     }
     if (in_array($segments['action'], ['json_index', 'rendered_index'])) {
         $segments['action'] = 'index';
     }
     plug_config('fields', $segments);
     $fields = [];
     if ($this->config['fields']['allow'] !== []) {
         foreach ($this->config['fields']['allow'] as $as) {
             list($target, $field) = explode('-', $as);
             $fields = array_merge($fields, $this->meta_model->get_bt_fields($target, $field));
             $fields[$as] = ['target' => $target, 'field' => $field];
         }
         return $fields;
     }
     foreach (array_keys($this->meta_model->fields[$target]) as $field) {
         if (in_array("{$target}-{$field}", $this->config['fields']['deny'])) {
             continue;
         }
         if (isset($suite['bt_field']) && $field === $suite['bt_field']) {
             continue;
         }
         $fields = array_merge($fields, $this->meta_model->get_bt_fields($target, $field));
         $fields["{$target}-{$field}"] = ['target' => $target, 'field' => $field];
     }
     return $fields;
 }