本文整理汇总了PHP中Module::GetNewModule方法的典型用法代码示例。如果您正苦于以下问题:PHP Module::GetNewModule方法的具体用法?PHP Module::GetNewModule怎么用?PHP Module::GetNewModule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Module
的用法示例。
在下文中一共展示了Module::GetNewModule方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetPath
function GetPath()
{
$themesModule = Module::GetNewModule('themes', $this->item['theme']);
if ($path = $themesModule->item['path'] . '/' . String::PrepareForURL($this->item['titre'])) {
return $path;
} else {
trigger_error("Couldn't get path for item", E_USER_ERROR);
return false;
}
}
示例2: ItemViewController
function ItemViewController()
{
// Include all item data as template variables
$this->layout->AddVariables($this->item);
// Load text blocks related to this module
$blocs = Module::GetNewModule('blocs');
$queryParams = array('where' => 'page = ' . $this->itemID);
$blocs->FetchItems($queryParams);
if ($blocs->items) {
foreach ($blocs->items as $item) {
$this->view[String::PrepareForURL($item['titre'])] = $item['texte'];
}
}
// Use specified path as a way to load views
$path = $this->item['pagePath'];
$this->LoadView($path);
}
示例3: PagesViewController
function PagesViewController()
{
if ($_GET['m'] == 'updated') {
HTTP::RedirectLocal('merci');
return false;
}
$this->view['form'] = $this->GetForm();
$themes = Module::GetNewModule('themes');
$queryParams = array('fields' => 'titreCourt', 'orderby' => 'sortIndex');
$themes->FetchItems($queryParams);
$this->view['themes'] = $themes->items;
}
示例4: AdminExportViewController
function AdminExportViewController()
{
global $_JAM;
$_JAM->title = $this->nestedModule->strings['adminTitle'];
// Check whether we should display anything at all
if ($exportFields = $this->nestedModule->config['adminExportFields']) {
// Fetch data according to export fields
$queryParams = array('fields' => $exportFields);
// Always fetch primary key field
if ($this->nestedModule->config['keepVersions']) {
$primaryKeyField = 'master';
} else {
$primaryKeyField = 'id';
}
$queryParams['fields'][] = $primaryKeyField;
// Use first field as sort field
$sortField = current($exportFields);
$queryParams['orderby'] = $sortField . ' ASC';
// Fetch data
$this->nestedModule->FetchItems($queryParams);
foreach ($exportFields as $field) {
// Get related arrays
if ($relatedArray = $this->nestedModule->GetRelatedArray($field)) {
$relatedArrays[$field] = $relatedArray;
}
// Determiner headers
$this->nestedModule->view['headers'][] = $this->nestedModule->strings['fields'][$field];
}
// Assemble into final array
foreach ($this->nestedModule->items as $id => $item) {
foreach ($exportFields as $field) {
if ($relatedArrays[$field]) {
// Field has related array
$value = $relatedArrays[$field][$item[$field]];
} else {
// Check whether field type is boolean
if ($this->nestedModule->schema[$field]['type'] == 'bool') {
// Replace boolean value with human-readable string
$value = $item[$field] ? $_JAM->strings['words']['affirmative'] : $_JAM->strings['words']['negative'];
} else {
// Use straight value
$value = $item[$field];
}
}
// Fix weird bug with non-breaking spaces
$value = str_replace(' ', ' ', $value);
$data[$item[$primaryKeyField]][] = $value;
}
}
// Add related module data if applicable
if ($relatedModules = $this->nestedModule->config['adminExportRelatedModules']) {
foreach ($relatedModules as $relatedModuleName) {
// Create new module object
$relatedModule = Module::GetNewModule($relatedModuleName);
// Find field that relates to this module
foreach ($relatedModule->schema as $field => $info) {
if ($info['relatedModule'] == $this->nestedModule->name) {
$relatedModuleField = $field;
break;
}
}
// We absolutely need a field to continue
if (!$relatedModuleField) {
break;
}
// Add relevant header
$this->nestedModule->view['headers'][] = $relatedModule->strings['adminTitle'];
// Fetch data
$keyQueryParams = Module::ParseConfigFile($relatedModuleName, 'config/keyQuery.ini', true);
$params = $keyQueryParams;
$params['fields'][] = $relatedModuleField;
$relatedModuleData = $relatedModule->FetchItems($params);
// Obtain name of key field in related module (sneaky)
$keyFields = $keyQueryParams['fields'];
end($keyFields);
$relatedKeyField = key($keyFields);
// Populate data array with data from related module
foreach ($relatedModuleData as $relatedItem) {
$relatedID = $relatedItem[$relatedModuleField];
if ($data[$relatedID]) {
$data[$relatedID][$relatedModule->name][] = $relatedItem[$relatedKeyField];
}
}
// Convert arrays to HTML lists
foreach ($data as $id => $item) {
if ($array = $item[$relatedModule->name]) {
$listString = '';
foreach ($array as $listItem) {
$listString .= e('li', $listItem);
}
$list = e('ul', $listString);
$data[$id][$relatedModule->name] = $list;
}
}
}
}
// Store in template
$this->nestedModule->view['data'] = $data;
}
}
示例5:
<?php
$themes = Module::GetNewModule('themes');
?>
<?php
$themes->LoadView('entete');
?>
</div>
<?php
}
?>
<?php
if ($afficherEtape) {
?>
<?php
$etapes = Module::GetNewModule('fleche', $etape);
?>
<?php
$etapes->Display();
?>
<?php
}
?>
<div class="clear"> </div>
</div>
</div>
<?php
if ($titreCorps) {
?>
<div id="titre">
示例6: FirstRun
function FirstRun()
{
// Load table structure for required tables
$tables = IniFile::Parse('engine/database/tables.ini', true);
// Create tables
foreach ($tables as $name => $schema) {
if (!Database::CreateTable($name, $schema)) {
trigger_error("Couldn't create table " . $name, E_USER_ERROR);
}
}
// Manually add admin module to _modules table
if (Query::TableIsEmpty('_modules')) {
$adminModule = array('name' => 'admin');
if (!Database::Insert('_modules', $adminModule)) {
trigger_error("Couldn't install core modules", E_USER_ERROR);
}
}
// Install required modules
$requiredModules = array('users', 'files');
foreach ($requiredModules as $moduleName) {
$module = Module::GetNewModule($moduleName);
$module->Install();
}
// Add default admin user
if (Query::TableIsEmpty('users')) {
$adminUserParams = array('created' => $this->databaseTime, 'login' => 'admin', 'name' => 'Admin', 'password' => 'admin', 'status' => 3);
if (!Database::Insert('users', $adminUserParams)) {
trigger_error("Couldn't create admin user", E_USER_ERROR);
}
}
// Add admin path
$adminModuleId = Query::SingleValue('_modules', 'id', "name = 'admin'");
if (!Path::Insert('admin', $adminModuleId, false)) {
trigger_error("Couldn't add admin path", E_USER_ERROR);
}
// Redirect to admin interface
HTTP::RedirectLocal('admin');
}
示例7: Initialize
//.........这里部分代码省略.........
$engineModules = Filesystem::GetDirNames('engine/modules');
$this->appModules = Filesystem::GetDirNames('app/modules');
$this->availableModules = $engineModules + $this->appModules;
// Strip root directory and trailing slashes from full path request
$pathString = $_SERVER['REQUEST_URI'];
$barePath = substr($pathString, 0, strrpos($pathString, '?'));
$pathString = $barePath ? $barePath : $pathString;
$fullRequest = rtrim($pathString, '/');
preg_match('|^' . ROOT . '(.*)$|', $fullRequest, $requestArray);
// Use requested URL, or use root path if none was requested
$this->request = $requestArray[1] ? $requestArray[1] : $this->projectConfig['rootPath'];
// We sync using database time (might differ from PHP time)
$databaseTimeQuery = new Query(array('fields' => 'NOW()'));
$databaseTime = $databaseTimeQuery->GetSingleValue();
$this->databaseTime = $databaseTime;
// Make sure everything is properly initialized
$tables = Database::GetTables();
if (!$tables['users'] || !$tables['_paths']) {
require 'engine/helpers/firstrun.php';
}
// Get installed modules list
$this->installedModules = Query::SimpleResults('_modules');
// Create User object
$this->user = new User();
// Create layout object
$this->template = new Template();
// Determine mode
$requestedMode = $_GET['mode'];
$availableModes = IniFile::Parse('engine/config/modes.ini');
if ($availableModes[$requestedMode]) {
// If requested mode exists, use it
$this->mode = $requestedMode;
} else {
// HTML is the default mode
$this->mode = 'html';
}
// Load paths
$paths = Query::FullResults('_paths');
foreach ($paths as $path) {
// Use path as key in $_JAM->paths array
$this->paths[$path['path']] = $path;
}
// Look for request in paths
if ($path = $this->paths[$this->request]) {
// Path does exist
if ($path['current']) {
// This is a valid path; proceed to module
if ($this->rootModule = Module::GetNewModule($this->installedModules[$path['module']], $path['item'])) {
// Check whether we have sufficient privileges to display the module
if ($this->rootModule->CanView()) {
// Display module
$this->rootModule->Display();
// Determine path to admin pane for this item
$adminPath = 'admin/' . $moduleName;
if ($this->paths[$adminPath]) {
if ($path['item']) {
$adminPath .= '?a=edit&id=' . $path['item'];
}
$this->adminPath = ROOT . $adminPath;
} else {
$this->adminPath = ROOT . 'admin';
}
} else {
// Display login if we can't display
$this->user->Connect();
}
} else {
trigger_error("Couldn't load root module", E_USER_ERROR);
}
} else {
// This is an obsolete URL; find its current (up to date) equivalent
$whereArray = array('module = ' . $path['module'], 'item = ' . $path['item'], "language = '" . $path['language'] . "'", 'current = TRUE');
$currentPath = Query::SingleValue('_paths', 'path', $whereArray);
HTTP::NewLocation($currentPath);
}
} else {
// Path does not exist; throw 404
header("HTTP/1.0 404 Not Found");
$this->rootModule = Module::GetNewModule('errors');
$this->rootModule->Display();
}
// Store and flush the contents of the output buffer
$buffer = ob_get_clean();
// Load and display template
if ($this->mode == 'html' && $this->rootModuleName == 'admin') {
// Special case for admin pages requested in HTML
$templateName = 'html_admin';
} else {
$templateName = $this->mode;
}
$this->template->SetTemplate($templateName);
$this->template->Display($buffer);
// Set MIME type
$contentType = $this->contentType ? $this->contentType : $availableModes[$this->mode];
if ($contentType) {
header('Content-Type: ' . $contentType);
}
// Write to cache; this also cleans output buffering
$this->cache->Write();
}
示例8: AutoForm
function AutoForm($fieldsArray = false, $hiddenFields = false)
{
global $_JAM;
// Create Form object
if (!($form = $this->GetForm())) {
return false;
}
$form->Open();
// Include language selection menu if applicable
if (!$this->config['languageAgnostic'] && count($_JAM->projectConfig['languages']) > 1 && !($fieldsArray && !@in_array('language', $fieldsArray))) {
if ($this->item) {
print $form->Hidden('language');
} else {
foreach ($_JAM->projectConfig['languages'] as $language) {
$languagesArray[$language] = $_JAM->strings['languages'][$language];
}
print $form->Popup('language', $languagesArray, $_JAM->strings['fields']['language']);
}
}
// Include sortIndex field if applicable
if ($this->config['allowSort']) {
print $form->Field('sortIndex', '3', $_JAM->strings['fields']['sortIndex']);
}
foreach ($this->schema as $name => $info) {
// Don't include basic module fields
if (!$this->config['useCustomTable'] && $_JAM->moduleFields[$name]) {
continue;
}
// Don't include versions support fields
if ($this->config['keepVersions'] && $_JAM->versionsSupportFields[$name]) {
continue;
}
// Skip this item if $fieldsArray is present and it doesn't contain this item
if ($fieldsArray && !in_array($name, $fieldsArray)) {
continue;
}
// Get proper title from string
if (!($title = $this->strings['fields'][$name])) {
// Use field name if no localized string is found
$title = $name;
}
print $form->AutoItem($name, $title);
}
// Display related modules if we have item data
if ($this->itemID) {
foreach ($_JAM->installedModules as $module) {
// First check whether we have a view configured for related module display
if (($relatedModuleSchema = Module::ParseConfigFile($module, 'config/schema.ini', true)) && ($relatedModuleKeyQuery = Module::ParseConfigFile($module, 'config/keyQuery.ini', true))) {
foreach ($relatedModuleSchema as $field => $info) {
if ($info['relatedModule'] == $this->name) {
$relatedModule = Module::GetNewModule($module);
// Load all fields
$queryParams = array('fields' => $relatedModuleKeyQuery['fields'], 'where' => $module . '.' . $field . ' = ' . $this->itemID);
$relatedModule->FetchItems($queryParams);
$relatedModule->LoadView('subform');
}
}
}
}
}
if ($hiddenFields) {
foreach ($hiddenFields as $field => $value) {
print $form->Hidden($field, $value);
}
}
print $form->Submit();
$form->Close();
return true;
}
示例9: foreach
foreach ($tables as $name => $schema) {
if (!Database::CreateTable($name, $schema)) {
trigger_error("Couldn't create table " . $name, E_USER_ERROR);
}
}
// Manually add admin module to _modules table
if (Query::TableIsEmpty('_modules')) {
$adminModule = array('name' => 'admin');
if (!Database::Insert('_modules', $adminModule)) {
trigger_error("Couldn't install core modules", E_USER_ERROR);
}
}
// Install required modules
$requiredModules = array('users', 'files');
foreach ($requiredModules as $moduleName) {
$module = Module::GetNewModule($moduleName);
$module->Install();
}
// Add default admin user
if (Query::TableIsEmpty('users')) {
$adminUserParams = array('created' => $_JAM->databaseTime, 'login' => 'admin', 'name' => 'Admin', 'password' => 'admin', 'status' => 3);
if (!Database::Insert('users', $adminUserParams)) {
trigger_error("Couldn't create admin user", E_USER_ERROR);
}
}
// Add admin path
$adminModuleId = Query::SingleValue('_modules', 'id', "name = 'admin'");
if (!Path::Insert('admin', $adminModuleId, false)) {
trigger_error("Couldn't add admin path", E_USER_ERROR);
}
// Redirect to admin interface
示例10: PagesViewController
function PagesViewController()
{
if ($_GET['m'] == 'updated') {
HTTP::RedirectLocal('merci');
return false;
}
$this->view['form'] = $this->GetForm();
// Add perspective specified as GET variable to form values
$this->view['form']->LoadValue('perspective', $_GET['perspective']);
$perspectives = Module::GetNewModule('perspectives');
$queryParams = array('fields' => 'numero');
$perspectives->FetchItems($queryParams);
$this->view['perspectives'] = $perspectives->items;
$themes = Module::GetNewModule('themes');
$queryParams = array('orderby' => 'sortIndex');
$themes->FetchItems($queryParams);
$this->view['themes'] = $themes->items;
}