public function ModulesCount() { $modules = Module::get()->Filter('PositionID', $this->ID); if (!$modules) { return 0; } return $modules->Count(); }
public function ModuleTypes() { $moduleTypes = array(); $modules = Module::get(); foreach ($modules as $module) { $moduleTypes[$module->ClassName] = array('ClassName' => $module->ClassName, 'Name' => $module->ModuleName(), 'Description' => $module->ModuleDescription()); } return $moduleTypes; }
function form($id = FALSE) { $data['level'] = new Level($id); $data['level']->auth = json_decode($data['level']->auth); $modules = new Module(); $data['modules'] = $modules->get(); $this->template->append_metadata(js_checkbox()); $this->template->build('admin/level_form', $data); }
/** * Check file from registered path * * @param null $file * @return string */ public function path($file = null) { $pieces = explode('/', $file); foreach ($this->_paths as $path) { $name = $pieces[0]; # Looking for existing module $module = \Module::get($name); if ($module) { # Add public to the path unset($pieces[0]); array_splice($pieces, 0, 0, 'Assets'); $currentPath = $module->getPath() . '/' . implode('/', $pieces); if (is_file($currentPath)) { return $currentPath; } } } return false; }
<?php namespace Sugi; /** * @package Sugi */ include "common.php"; // Register DB Module::set("db", function () { $db = Module::get("Database", array("type" => "sqlite3", "database" => __DIR__ . "/tmp/test.sqllite3")); $db->query(' CREATE TABLE IF NOT EXISTS sessions ( session_id VARCHAR(40) NOT NULL PRIMARY KEY, session_time INTEGER NOT NULL, session_data TEXT, session_lifetime INTEGER NOT NULL DEFAULT 0 )'); return $db; }); $config = array("type" => Filter::get_str("type", 0, 20, false), "file" => array("path" => __DIR__ . "/tmp/")); // Sugi\Session\Database driver if ($config["type"] == "database") { $config["database"] = array("db" => Module::get("db")); } Session::singleton($config); session_start(); $_SESSION['count'] = isset($_SESSION['count']) ? $_SESSION['count'] + 1 : 0; var_dump($_SESSION['count']);
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * * @return \Illuminate\Http\Response */ public function update(Request $request) { $modules = Module::get(); $role_id = $request->route('groupuser'); $roles = new Role(); $role = $roles->find($role_id); $permission = $role->permissions()->get(); $array_permission = array(); foreach ($permission as $key => $value) { $array_permission[] = $value->permission_slug; } return view('admin.user.updategroup', compact('modules', 'role', 'array_permission')); }
/** * Retrieve theme directory URI. * * @since 1.5.0 * * @return string Template directory URI. */ function get_template_directory_uri() { $template = str_replace('%2F', '/', rawurlencode(get_template())); $theme_root_uri = get_theme_root_uri($template); if ($module = Module::get($template)) { $template = $module->getName(); } $template_dir_uri = "{$theme_root_uri}/{$template}"; /** * Filter the current theme directory URI. * * @since 1.5.0 * * @param string $template_dir_uri The URI of the current theme directory. * @param string $template Directory name of the current theme. * @param string $theme_root_uri The themes root URI. */ return apply_filters('template_directory_uri', $template_dir_uri, $template, $theme_root_uri); }
// first method - creating driver first, and passing it to the Database // $dbd = new \Sugi\Database\Sqlite3($config[$driver]); // $db = new Database($dbd); // second method - invoking static factory method // $db = Database::factory($config); // third method - using factory method with Module // Module::set("Database", function() use ($config) { // return Database::factory($config); // }); // $db = Module::get("Database"); // forth method - Setting config params in Module. Factory will be auto invoked // This is preferred method if Module::get is invoked in several files // Module::set("Database", $config); // $db = Module::get("Database"); // direct Module creation $db = Module::get("Database", $config); $db->hook("post_open", function ($action, $data) use($db) { global $driver; echo "<p>BD connection is established automatically</p>"; // MySQL specific routines if ($driver == "mysql") { $db->query("SET NAMES utf8"); $db->query("CREATE TABLE IF NOT EXISTS test (id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, val VARCHAR(255))"); // $res = $db->query("INSERT INTO test(val) VALUES ('PHP is cool!')"); // $res = $db->query($db->bindParams("INSERT INTO test(val) VALUES (:val)", array("val" => 'Sugi'))); } elseif ($driver == "sqlite" or $driver == "sqlite3") { // since we use MEMORY table we need them to be created on every DB connection $db->query("CREATE TABLE test (id integer not null primary key, val varchar(255))"); $res = $db->query("INSERT INTO test(val) VALUES ('PHP is cool!')"); $res = $db->query($db->bindParams("INSERT INTO test(val) VALUES (:val)", array("val" => 'Sugi'))); } elseif ($driver == "pgsql") {
<?php $process = new Object(); // the type of interface between web server and PHP $process->set('sapi_name', php_sapi_name()); $process->set('exit', new Func(function ($code = 0) { $code = intval($code); exit($code); })); $process->set('binding', new Func(function ($name) { $module = Module::get($name); if ($module === null) { throw new Ex(Error::create("Binding `{$name}` not found.")); } return $module; })); //command line arguments $process->argv = isset(GlobalObject::$OLD_GLOBALS['argv']) ? GlobalObject::$OLD_GLOBALS['argv'] : array(); //first argument is path to script $process->argv = array_slice($process->argv, 1); $process->set('argv', Arr::fromArray($process->argv));
function advanced_user_preference_handler() { $params = $this->input->post(); $modules = new Module(); $modules->get(); foreach ($modules as $module) { if (isset($params['c'][$module->id])) { User::set_preference($params['user_id'], $module->id, 'c', '1'); } else { User::set_preference($params['user_id'], $module->id, 'c', '0'); } if (isset($params['r'][$module->id])) { User::set_preference($params['user_id'], $module->id, 'r', '1'); } else { User::set_preference($params['user_id'], $module->id, 'r', '0'); } if (isset($params['u'][$module->id])) { User::set_preference($params['user_id'], $module->id, 'u', '1'); } else { User::set_preference($params['user_id'], $module->id, 'u', '0'); } if (isset($params['d'][$module->id])) { User::set_preference($params['user_id'], $module->id, 'd', '1'); } else { User::set_preference($params['user_id'], $module->id, 'd', '0'); } } $this->access_log->insert_log('Change user preference (' . $params['username'] . ')'); redirect(base_url() . 'index.php/back_end/entry_user/type/edit/id/' . $params['user_id']); }