本文整理汇总了PHP中Module::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Module::load方法的具体用法?PHP Module::load怎么用?PHP Module::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Module
的用法示例。
在下文中一共展示了Module::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setup
function setup()
{
$module = Module::load('dummy');
$this->url = $module->url('marked');
$this->search_url = $module->url('search');
$this->record_url = $module->url('index');
}
示例2: render
/**
* index
*/
protected function render()
{
// create layout module
$this->layout = Module::load('layout');
// act view index
$this->view_index();
}
示例3: run
/**
* 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');
}
}
示例4: factory
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);
}
示例5: index
/**
* 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();
}
示例6: run
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);
}
}
示例7: after_get_record
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');
}
示例8: loginForm
/**
* 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();
}
示例9: get
function get($url)
{
$result = @$this->records[$url];
if (is_null($result)) {
return NULL;
}
// Load module
$result['module'] = Module::load($result['modname']);
return $result;
}
示例10: index
/**
* 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();
}
}
示例11: before
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');
}
示例12: index
/**
* 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();
}
}
}
示例13: before
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));
}
}
}
示例14: test_components_use_fed_search
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']);
}
示例15: test_get
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'));
}