function setup() { $module = Module::load('dummy'); $this->url = $module->url('marked'); $this->search_url = $module->url('search'); $this->record_url = $module->url('index'); }
/** * index */ protected function render() { // create layout module $this->layout = Module::load('layout'); // act view index $this->view_index(); }
/** * Run the credential importer * * @param string $json_file The JSON file that contains a list of the APIs and their credentials */ public static function run($json_file = null) { if (empty($json_file) || file_exists($json_file) === false) { exit('You must specify a valid JSON file that contains your credentials.' . PHP_EOL); } if (($json = json_decode(file_get_contents($json_file), true)) === null) { exit('The JSON file does not contain valid JSON text.' . PHP_EOL); } // Find the API version to use for importing the keys $version = 'V1'; if (!empty($json[0]['version'])) { if (is_int($json[0]['version']) && \Module::exists('V' . $json[0]['version'])) { \Module::load('V' . $json[0]['version']); $version = 'V' . $json[0]['version']; } else { \Module::load($version); } array_shift($json); } else { \Module::load($version); } $error = false; foreach ($json as $entry) { // We need these keys for each entry. if (!array_key_exists('api', $entry) || !array_key_exists('credentials', $entry)) { echo \Cli::color('The JSON data is in the wrong format. Skipping.' . PHP_EOL, 'yellow'); $error = true; continue; } if (!is_string($entry['api'])) { echo \Cli::color('The API name must be a string. Skipping.' . PHP_EOL, 'yellow'); $error = true; continue; } // Make sure that we have credentials to add to the DB. if (empty($entry['credentials']) || !is_array($entry['credentials'])) { echo \Cli::color('The array of credentials for ' . $entry['api'] . ' is empty. Skipping.' . PHP_EOL, 'yellow'); $error = true; continue; } $response = call_user_func('\\' . $version . '\\Keyring::set_credentials', $entry['credentials'], $entry['api']); // Show and log the result if ($response === true) { $success_text = 'Successfully imported the credentials for API: ' . $entry['api']; echo \Cli::color($success_text . PHP_EOL, 'green'); \Log::logger('INFO', 'CLI:ADD_CREDENTIALS', $success_text, __METHOD__, array('api' => $entry['api'])); } else { $error_text = 'Failed to import the credentials for API: ' . $entry['api']; echo \Cli::color('Warning: ' . $error_text . PHP_EOL, 'red'); $error = true; \Log::logger('ERROR', 'CLI:ADD_CREDENTIALS', $error_text, __METHOD__, array('api' => $entry['api'])); } } // Display the summary. if ($error === true) { echo \Cli::color(PHP_EOL . 'Some credentials were not added to the database. See the error log for more details.' . PHP_EOL, 'red'); } else { echo \Cli::color(PHP_EOL . 'All credentials were successfully added to the database.' . PHP_EOL, 'green'); } }
public static function factory($id = NULL, $connection = 'default') { $module = new Module($connection); if (NULL === $id) { return $module; } $mod = new Module($connection); return $mod->load($id); }
/** * index method */ public function index() { // create layout module $this->layout = Module::load('layout'); // set pwd_container $this->pwd_container = __GOOSE_PWD__ . $this->skinPath . 'view_index.html'; // require layout require_once $this->layout->getUrl(); }
public static function run($task, $args = array()) { $task = strtolower($task); // Make sure something is set if (empty($task) or $task === 'help') { static::help(); return; } $module = false; list($module, $task) = array_pad(explode('::', $task), 2, null); if ($task === null) { $task = $module; $module = false; } if ($module) { try { \Module::load($module); $path = \Module::exists($module); \Finder::instance()->add_path($path); } catch (\FuelException $e) { throw new Exception(sprintf('Module "%s" does not exist.', $module)); } } // Just call and run() or did they have a specific method in mind? list($task, $method) = array_pad(explode(':', $task), 2, 'run'); // Find the task if (!($file = \Finder::search('tasks', $task))) { $files = \Finder::instance()->list_files('tasks'); $possibilities = array(); foreach ($files as $file) { $possible_task = pathinfo($file, \PATHINFO_FILENAME); $difference = levenshtein($possible_task, $task); $possibilities[$difference] = $possible_task; } ksort($possibilities); if ($possibilities and current($possibilities) <= 5) { throw new Exception(sprintf('Task "%s" does not exist. Did you mean "%s"?', $task, current($possibilities))); } else { throw new Exception(sprintf('Task "%s" does not exist.', $task)); } return; } require_once $file; $task = '\\Fuel\\Tasks\\' . ucfirst($task); $new_task = new $task(); // The help option has been called, so call help instead if ((\Cli::option('help') or $method == 'help') and is_callable(array($new_task, 'help'))) { $method = 'help'; } else { // if the task has an init method, call it now is_callable($task . '::_init') and $task::_init(); } if ($return = call_fuel_func_array(array($new_task, $method), $args)) { \Cli::write($return); } }
function after_get_record(&$record, $query, $url, $params) { global $CONF; $module = Module::load('fed'); $ds = $module->get_datasource(); $result = $ds->retrieve('/stats' . $url); $record['view_count'] = @$result['count']; $record['view_count_msg'] = 'This record has been viewed ' . @$result['count'] . ' ' . pluralise(@$result['count'], 'time') . '.'; $record['sidebar'][] = new RecordScoreFacet($record, $query, $result, $url, $CONF['url'] . '/score.php'); }
/** * login form */ public function loginForm() { // set view path $this->skinPath = $this->path . 'skin/' . $this->set['skin'] . '/'; // set container path $this->pwd_container = __GOOSE_PWD__ . $this->skinPath . 'login-form.html'; // set layout module print $this->layout = Module::load('layout'); require_once $this->layout->getUrl(); }
function get($url) { $result = @$this->records[$url]; if (is_null($result)) { return NULL; } // Load module $result['module'] = Module::load($result['modname']); return $result; }
/** * index */ public function index() { // create layout module $this->layout = Module::load('layout'); if ($this->param['action']) { $this->view_read($this->param['action']); } else { $this->view_index(); } }
public function before() { // Lets render the template parent::before(); // Check to see if the config exsists if (file_exists(APPPATH . 'config/production/db.php') === false) { Response::Redirect('install'); } if (DBUtil::field_exists('urls', array('cached_preview')) === false && file_exists(APPPATH . 'classes/controller/upgrade.php')) { Response::Redirect(Uri::Create('upgrade')); } $real_base_url = Config::get('base_url'); Config::set('base_url', str_replace('public/', '', $real_base_url)); $base_url = Settings::get('different_short_url'); if (empty($base_url) === false) { View::set_global(array('base_url' => $base_url), false, false); } if (trim(Uri::Base(), '/') == Settings::get('different_short_url')) { if (count(Uri::Segments()) == 2) { $route = Uri::to_assoc(); if (isset($route) === true && $route['core'] == '404') { // We are good! } else { Response::Redirect(Settings::Get('base_url')); } } else { Response::Redirect(Settings::Get('base_url')); } } $data = null; if (Auth::Check()) { $user_id = Auth::get_user_id(); static::$user_id = $user_id[1]; $data['api_key'] = Auth::get('api_key'); if (empty($data['api_key']) === true) { if (empty($data['api_key']) === true) { $data['api_key'] = preg_replace('/\\+|\\/|\\=|\\?/', '', \Auth::instance()->hash_password(\Str::random()) . static::$user_id); // invalidate the hash \Auth::update_user(array('api_key' => $data['api_key']), Auth::get('username')); } } } // Lets set the default title , you can change it when calling the view $this->template->title = ucwords(str_replace('controller_', '', strtolower($this->request->route->controller))); try { Module::load('image'); $this->template->image_js = true; } catch (Exception $e) { } // Lets get the header and footer and set a variable to use within the template $this->template->footer = View::forge('core/footer', $data); $this->template->header = View::forge('core/header'); }
/** * index */ public function index() { // create layout module $this->layout = Module::load('layout'); if ($this->param['action']) { $this->render($this->param['action']); } else { if (!$this->param['action'] || $this->param['action'] == 'index') { $this->view_index(); } } }
public function before() { parent::before(); $this->_upgrade = new \Upgrade(); if (Module::exists('whmcs')) { Module::load('whmcs'); if (\Whmcs\Whmcs::route()) { $data = array(); return Response::forge(View::forge('whmcs/route', $data)); } } }
function test_components_use_fed_search() { $this->mod1->setReturnValue('url', 'url1'); $this->mod2->setReturnValue('url', 'url2'); $this->query->setReturnValueAt(0, 'url_query', 'q=&components=0'); $this->query->setReturnValueAt(1, 'url_query', 'q=&components=1'); $block = new SearchInModuleBlock($this->query, TRUE); // ### TODO: the urls are dependent on the fed module, is there a way to mock the fed module for these tests? $fed_module = Module::load('fed'); $expected_items = array(array('label' => 'mod1', 'value' => '123', 'url' => $fed_module->url('search', '?q=&components=0')), array('label' => 'mod2', 'value' => '1', 'url' => $fed_module->url('search', '?q=&components=1'))); $this->assertEqual($expected_items, $block->vars['items']); }
function test_get() { $this->marked_records->add('/dummy/test/single'); $record = $this->marked_records->get('/dummy/test/single'); // Whole record is returned $this->assertEqual($record['url'], '/dummy/test/single'); $this->assertEqual($record['title'], 'single'); $this->assertEqual($record['description'], 'Test item'); // Module name and module $this->assertEqual($record['modname'], 'dummy'); $this->assertEqual($record['module_title'], 'Dummy Module'); $this->assertEqual($record['module'], Module::load('dummy')); }
function ModuleFactory($auto_load = FALSE) { $this->_modules = array(); if ($auto_load == TRUE) { // initialise enabled modules $sql = "SELECT dir_name, privilege, admin_privilege, status, cron_interval, cron_last_run FROM %smodules WHERE status=%d"; $rows_modules = queryDB($sql, array(TABLE_PREFIX, AT_MODULE_STATUS_ENABLED)); foreach ($rows_modules as $row) { $module = new Module($row); $this->_modules[$row['dir_name']] = $module; $module->load(); } } }
public function before() { // --- Ladowanie modulow, np. od logowania, sesja --- global $modules; if (!empty($modules) and is_array($modules)) { foreach ($modules as $value) { Module::load($value); } } // --- Start sesji uzytkownika --- Session::instance()->start(); // --- Sprawdzam czy uzytkownik jest zalogowany --- $this->logged = Auth::instance()->is_logged(); }
public function actionModule() { $model = new Module(); // if the post data is set, the user submitted the form if ($model->load(Yii::$app->request->post())) { // in that case, validate the data if ($model->validate()) { // save it to the database $model->save(); return; } } // by default, diplay the form return $this->render('module', ['model' => $model]); }
public function executeAddmodule() { $this->new_module_name = $this->module_name; $this->new_module_menu = $this->menu_entry; $this->error_already_installed = false; if (!Module::isInstalled($this->new_module_name)) { $module_obj = new Module($this->new_module_name, false, $this->new_module_menu); $module_obj->load('modules/' . $this->new_module_name, $this->new_module_menu); $modules = $this->getContext()->get('Modules'); $modules[] = $module_obj; $this->getContext()->set('Modules', $modules); } else { $this->error_already_installed = true; } }
function ModuleFactory($auto_load = FALSE) { global $db; $this->_modules = array(); if ($auto_load == TRUE) { // initialise enabled modules $sql = "SELECT dir_name, privilege, admin_privilege, status, cron_interval, cron_last_run FROM " . TABLE_PREFIX . "modules WHERE status=" . AT_MODULE_STATUS_ENABLED; $result = mysql_query($sql, $db); while ($row = mysql_fetch_assoc($result)) { $module = new Module($row); $this->_modules[$row['dir_name']] = $module; $module->load(); } } }
/** * upload thumnail * 썸네일 이미지 데이터를 받아서 서버에 올리고, 이미지 경로를 리턴한다. * * @param string $imgData base64형식의 이미지 데이터 * @return string 서버에 업로드한 썸네일 이미지 경로 */ function uploadThumnail($imgData = null) { $file = Module::load('file'); $uploadDir = ''; $result = 0; if ($imgData) { $fileName = uniqid() . ".jpg"; $month = Date('Ym'); $uploadDir = $file->set['upPath_make'] . '/' . $month . '/'; Util::createDirectory(__GOOSE_PWD__ . $uploadDir, 0777); $uploadDir .= $fileName; $imgData = str_replace('data:image/jpeg;base64,', '', $imgData); $imgData = str_replace(' ', '+', $imgData); $result = file_put_contents($uploadDir, base64_decode($imgData)); } return $result ? $uploadDir : null; }
/** * index */ protected function render() { // create layout module $this->layout = Module::load('layout'); switch ($this->param['action']) { case 'create': $this->view_create(); break; case 'modify': $this->view_modify(); break; case 'remove': $this->view_remove(); break; default: $this->view_index(); break; } }
public function action_index() { //$testModel = Model_Sales_Disposition::test(); /* if (\Reports\Query::forge(\Reports\Query::LOAD, 3)->isComplete()) { print_r('complete'); } */ // Load the required data module if (!\Module::loaded('data') && \Module::exists('data')) { \Module::load('data'); } else { throw new \Exception("Data Module not found!"); } $impData = \Data\Import::forge(\Data\Import::COPY, 1); $this->template->title = 'Example Page'; $this->template->content = "hello"; }
function ModuleFactory($auto_load = FALSE) { global $db; /* snippit to use when extending Module classes: $sql = "SELECT dir_name, privilege, admin_privilege, status FROM ". TABLE_PREFIX . "modules WHERE status=".AT_MODULE_STATUS_ENABLED; $result = mysql_query($sql, $db); $row = mysql_fetch_assoc($result); require(AT_MODULE_PATH . $row['dir_name'].'/module.php'); $module = new PropertiesModule($row); ***/ $this->_modules = array(); if ($auto_load == TRUE) { // initialise enabled modules $sql = "SELECT dir_name, privilege, admin_privilege, status, cron_interval, cron_last_run FROM " . TABLE_PREFIX . "modules WHERE status=" . AT_MODULE_STATUS_ENABLED; $result = mysql_query($sql, $db); while ($row = mysql_fetch_assoc($result)) { $module = new Module($row); $this->_modules[$row['dir_name']] = $module; $module->load(); } } }
public function init($pwd_map, $accessLevel) { $this->route->setBasePath(preg_replace('/\\/$/', '', __GOOSE_ROOT__)); require_once Util::checkUserFile($pwd_map); $this->match = $this->route->match(); if ($this->match) { $_module = isset($this->match['params']['module']) ? $this->match['params']['module'] : null; $_action = isset($this->match['params']['action']) ? $this->match['params']['action'] : null; $_method = $_SERVER['REQUEST_METHOD']; // check access level $auth = Module::load('auth', array('action' => $_action, 'method' => $_method)); $auth->auth($accessLevel['login']); // load module $modName = $_module ? $_module : $this->set['basicModule']; $baseModule = Module::load($modName, array('action' => $_action, 'method' => $_method, 'params' => array($this->match['params']['param0'], $this->match['params']['param1'], $this->match['params']['param2'], $this->match['params']['param3']))); // check module if ($baseModule->state == 'error') { Goose::error(403, $baseModule->message); } if (!$baseModule) { Goose::error(101, 'module error'); } if (is_array($baseModule) && $baseModule['state'] == 'error') { Goose::error(101, $baseModule['message']); } // check index method if (!method_exists($baseModule, 'index')) { Goose::error(101, $modName . '모듈의 index()메서드가 없습니다.'); } // index module if (method_exists($baseModule, 'index')) { $baseModule->index(); } } else { Goose::error(404); } }
function test_debug_module_on_query() { // By default uses dummy module global $MODULE; $this->get($this->search_url); $this->assertPage('Basic Search', 200, $MODULE); // Pass dummy2 module as arg $module = Module::load('dummy2'); $this->get($this->search_url . '?debug_module=dummy2'); $this->assertPage('Basic Search', 200, $module); //$this->showsource();//### /* $this->assertPage('Basic Search'); $this->assertHeader('content-type', 'text/html; charset='.$MODULE->charset); $this->assertTag('form', NULL, 'method', 'GET'); $this->assertField('q', ''); $this->assertField('page_size', '10'); $this->assertField('sort', ''); $this->assertFieldById('submit', 'Search'); // Results are not present $this->assertNoTag('ul', '', 'class', 'results'); */ }
/** * view - remove */ private function view_remove() { // check admin $this->checkAdmin(); // set srl $nest_srl = $this->param['params'][0] ? (int) $this->param['params'][0] : null; $category_srl = $this->param['params'][1] ? (int) $this->param['params'][1] : null; // set repo $repo = array(); // load modules $nest = Module::load('nest'); // get nest data $data = $nest->getItem(array('field' => 'name', 'where' => 'srl=' . $nest_srl)); $repo['nest'] = $data['state'] == 'success' ? $data['data'] : array(); // get category data $data = $this->parent->getItem(array('where' => 'srl=' . $category_srl)); if ($data['state'] == 'error') { Util::back($data['message']); Goose::end(); } else { if ($data['state'] == 'success') { $repo['category'] = $data['data']; } } // set container pwd $this->pwd_container = __GOOSE_PWD__ . $this->skinPath . 'view_remove.html'; require_once $this->layout->getUrl(); }
function format_record_list($records, &$result_urls = NULL, $count = -1, $titles_only = FALSE, $highlight = NULL) { global $CONF, $MODULE, $USER, $MARKED_RECORDS; $result = array(); $result_urls = array(); $summary_mode = $titles_only ? 'minimal' : NULL; $count = $count > 0 ? min($count, count($records)) : count($records); $index = 1; foreach ($records as $record) { if (--$count < 0) { break; } // Get module for this record if (isset($record['modname'])) { $module = Module::load($record['modname']); } else { if (isset($record['module'])) { $module = $record['module']; } else { $module = $MODULE; } } $marked_url = $module->get_marked_url($record); $result_urls[] = $marked_url; // check if it's marked if ($CONF['marked_records_size'] && $summary_mode != 'minimal') { // Add marked records checkbox $marked_checkbox = "<input type=\"checkbox\" name=\"{$marked_url}\" value=\"1\" class=\"mark-checkbox results-checkbox\""; if ($MARKED_RECORDS->exists($marked_url)) { $marked_checkbox .= "checked=\"checked\" "; } // add AJAX call if ($CONF['submit_forms_with_script']) { $marked_checkbox .= ' data-url_record="' . $marked_url . '" '; } $marked_checkbox .= "/>"; } $css_class = "results-record"; $css_class .= $index == $highlight ? ' highlighted-record' : ''; $str = "<li class=\"{$css_class}\">"; $str .= @$marked_checkbox; $summary = $module->new_record_summary(@$record['_table']); $str .= $summary->format($record, $summary_mode); if ($module->can_edit($USER) && $module->name != 'user') { $str .= "<p class=\"results-editthis\"><a href=\"" . $module->url_edit($record) . "\">Edit this record</a></p>\n"; } $result[] = $str . '</li>'; $index++; } return join("\n", $result); }
private function loadPost() { $respond = ResponseRegistery::getInstance(); $where = $limit = ''; switch ($this->task) { case 'post': $where = "AND article.id=" . intval($respond->article_id); break; case 'page': $where = ''; $limit = "limit {$respond->limitStart},{$respond->limit}"; break; case 'archive': $where = "AND date BETWEEN '{$respond->archiveStart}' AND '{$respond->archiveEnd}'"; break; case 'tag': $where = "AND tag.title=" . $this->db->valueQuote($this->db->getEscaped($respond->tag)); break; case 'author': $where = "AND user.username="******"SELECT\n article.title as posttitle,\n article.id as postid,\n article.content as postcontent,\n article.date as date,\n tag.id as postcategoryid,\n tag.title as postcategory,\n user.id as postauthorid,\n user.name as postauthor,\n user.email as postauthoremail,\n user.username,\n article.password,\n article.more_content,\n article.more_content <> null as blogextendedpost,\n article.comment_exp <=> NULL or article.comment_exp > NOW() as blogcomment,\n article.alias\n\n from wb_articles as article\n JOIN wb_subjects as subject\n ON (article.subject_id=subject.id)\n JOIN wb_tags as tag\n ON(tag.id = article.tag_id)\n JOIN ge_users as user\n ON (user.id = article.user_id)\n \n WHERE article.status = 'published'\n AND article.weblog_id ={$respond->weblog_id} {$where}\n ORDER BY\n date DESC\n {$limit}\n "; $tmp = $this->db->query($sql)->fetchAll(); $this->data["blog"] = array(); foreach ($tmp as $record) { if (!empty($record->password) && $record->password != $respond->postPassword) { $record->postcontent = Module::load("postPassword"); } $record->postlink = "/post/{$record->postid}/{$record->alias}.html"; $record->postauthorlink = "/author/{$record->username}"; $date = Factory::getDate($record->date); $record->postdate = $date->format('l j F Y', true); $record->posttime = $date->format('H:i', true); $this->data["blog"][] = $record; } }
<?php // rework this as will break if (empty($module)) { $module = 'users'; } if (!$user) { if ($module != 'login') { Session::set('next', $_SERVER['REQUEST_URI']); } $module = 'login'; $page = 'login'; } //Debugger::debug($user, 'USER'); $page = Module::load($module, $page); Template::assign('admin', $admin); Template::assign('site', $site); Template::assign('module', $module); Template::assign('page', $page); //swatch testing if (!file_exists(PUBLIC_ROOT . '/assets/css/site-' . $site->shortname . '.css')) { Swatch::buildSwatch($site->shortname); } else { Template::assign('$siteStyle', 'site-' . $site->shortname); } $smarty->display('admin/' . $module . '/' . $page . '.tpl');