本文整理汇总了PHP中site_content_pages函数的典型用法代码示例。如果您正苦于以下问题:PHP site_content_pages函数的具体用法?PHP site_content_pages怎么用?PHP site_content_pages使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了site_content_pages函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: define
*
*/
define('INTERNAL', 1);
define('INSTITUTIONALADMIN', 1);
define('MENUITEM', 'manageinstitutions/sitepages');
define('SECTION_PLUGINTYPE', 'core');
define('SECTION_PLUGINNAME', 'admin');
define('SECTION_PAGE', 'institutionstaticpages');
require dirname(dirname(dirname(__FILE__))) . '/init.php';
define('TITLE', get_string('institutionstaticpages', 'admin'));
require_once 'pieforms/pieform.php';
require_once 'license.php';
define('DEFAULTPAGE', 'home');
require_once 'institution.php';
$sitepages = array();
$corepagenames = site_content_pages();
$localpagenames = function_exists('local_site_content_pages') ? local_site_content_pages() : array();
if ($pagenames = array_merge($corepagenames, $localpagenames)) {
$sitepages = get_records_select_array('site_content', 'name IN (' . join(',', array_fill(0, count($pagenames), '?')) . ')', $pagenames);
}
$pageoptions = array();
$institutionelement = get_institution_selector(false);
if (!empty($institutionelement['options']) && sizeof($institutionelement['options']) > 1) {
$institutionelement['defaultvalue'] = key($institutionelement['options']);
} else {
if (!empty($institutionelement['options']) && sizeof($institutionelement['options']) == 1) {
// Institutional admins with only 1 institution do not get institution dropdown
// Same with admins and only one institution exists
$institutionelement = array('type' => 'hidden', 'value' => key($institutionelement['options']), 'defaultvalue' => key($institutionelement['options']));
} else {
if (empty($institutionelement['options'])) {
示例2: xmldb_core_upgrade
//.........这里部分代码省略.........
$table->addFieldInfo('institution', XMLDB_TYPE_CHAR, 255, null, XMLDB_NOTNULL);
$table->addFieldInfo('field', XMLDB_TYPE_CHAR, 255, null, XMLDB_NOTNULL);
$table->addFieldInfo('value', XMLDB_TYPE_TEXT, 'small');
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addKeyInfo('institutionfk', XMLDB_KEY_FOREIGN, array('institution'), 'institution', array('name'));
$table->addIndexInfo('instfielduk', XMLDB_INDEX_UNIQUE, array('institution', 'field'));
create_table($table);
}
if ($oldversion < 2014010801) {
// adding institution column to allow for different site content for each institution
$table = new XMLDBTable('site_content');
$field = new XMLDBField('institution');
$field->setAttributes(XMLDB_TYPE_CHAR, 255, null, null);
add_field($table, $field);
// resetting the primary key and updating what is currently there to be
// the 'mahara' institution's site pages
$key = new XMLDBKey('primary');
$key->setAttributes(XMLDB_KEY_PRIMARY, array('name'));
drop_key($table, $key);
execute_sql("UPDATE {site_content} SET institution = ?", array('mahara'));
$key = new XMLDBKey('primary');
$key->setAttributes(XMLDB_KEY_PRIMARY, array('name', 'institution'));
add_key($table, $key);
$key = new XMLDBKey('institutionfk');
$key->setAttributes(XMLDB_KEY_FOREIGN, array('institution'), 'institution', array('name'));
add_key($table, $key);
// now add the default general pages for each existing institution with the values of
// the 'mahara' institution. These can them be altered via Administration -> Institutions -> General pages
$sitecontentarray = array();
$sitecontents = get_records_array('site_content', 'institution', 'mahara');
foreach ($sitecontents as $sitecontent) {
$sitecontentarray[$sitecontent->name] = $sitecontent->content;
}
$pages = site_content_pages();
$now = db_format_timestamp(time());
$institutions = get_records_array('institution');
foreach ($institutions as $institution) {
if ($institution->name != 'mahara') {
foreach ($pages as $name) {
$page = new stdClass();
$page->name = $name;
$page->ctime = $now;
$page->mtime = $now;
$page->content = $sitecontentarray[$name];
$page->institution = $institution->name;
insert_record('site_content', $page);
$pageconfig = new stdClass();
$pageconfig->institution = $institution->name;
$pageconfig->field = 'sitepages_' . $name;
$pageconfig->value = 'mahara';
insert_record('institution_config', $pageconfig);
}
}
}
}
if ($oldversion < 2014021100) {
// Reset the view's skin value, if the skin does not exist
execute_sql("UPDATE {view} v SET skin = NULL WHERE v.skin IS NOT NULL AND NOT EXISTS (SELECT id FROM {skin} s WHERE v.skin = s.id)");
}
if ($oldversion < 2014021200) {
// Adding new Creative Commons 4.0 licenses.
// CC4.0 will be added only if:
// -- The CC4.0 URL doesn't already exist;
// -- And CC3.0 hasn't been deleted earlier.
$license = new stdClass();
$license->name = 'http://creativecommons.org/licenses/by-sa/4.0/';
示例3: core_postinst
function core_postinst()
{
$status = true;
$pages = site_content_pages();
$now = db_format_timestamp(time());
foreach ($pages as $name) {
$page = new stdClass();
$page->name = $name;
$page->ctime = $now;
$page->mtime = $now;
$page->content = get_string($page->name . 'defaultcontent', 'install');
if (!insert_record('site_content', $page)) {
$status = false;
}
}
// Attempt to create session directories
$sessionpath = get_config('dataroot') . 'sessions';
if (check_dir_exists($sessionpath)) {
// Create three levels of directories, named 0-9, a-f
$characters = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f');
foreach ($characters as $c1) {
if (check_dir_exists("{$sessionpath}/{$c1}")) {
foreach ($characters as $c2) {
if (check_dir_exists("{$sessionpath}/{$c1}/{$c2}")) {
foreach ($characters as $c3) {
if (!check_dir_exists("{$sessionpath}/{$c1}/{$c2}/{$c3}")) {
$status = false;
break 3;
}
}
} else {
$status = false;
break 2;
}
}
} else {
$status = false;
break;
}
}
} else {
$status = false;
}
// Set default search plugin
set_config('searchplugin', 'internal');
set_config('lang', 'en.utf8');
set_config('installation_key', get_random_key());
// PostgreSQL supports indexes over functions of columns, MySQL does not.
// So we can improve the index on the username field of the usr table for
// Postgres
if (is_postgres()) {
execute_sql('DROP INDEX {usr_use_uix}');
execute_sql('CREATE UNIQUE INDEX {usr_use_uix} ON {usr}(LOWER(username))');
}
// Some more advanced constraints. XMLDB can't handle this in its xml file format
execute_sql('ALTER TABLE {artefact} ADD CHECK (
(owner IS NOT NULL AND "group" IS NULL AND institution IS NULL) OR
(owner IS NULL AND "group" IS NOT NULL AND institution IS NULL) OR
(owner IS NULL AND "group" IS NULL AND institution IS NOT NULL)
)');
execute_sql('ALTER TABLE {view} ADD CHECK (
(owner IS NOT NULL AND "group" IS NULL AND institution IS NULL) OR
(owner IS NULL AND "group" IS NOT NULL AND institution IS NULL) OR
(owner IS NULL AND "group" IS NULL AND institution IS NOT NULL)
)');
reload_html_filters();
return $status;
}
示例4: create_institution
/**
* Create a test institution
* @param array $record
* @throws ErrorException if creating failed
* @return int new institution id
*/
public function create_institution($record)
{
// Data validation
if (empty($record['name']) || !preg_match('/^[a-zA-Z]{1,255}$/', $record['name'])) {
throw new SystemException("Invalid institution name '" . $record['name'] . "'. The institution name is entered for system database identification only and must be a single text word without numbers or symbols.");
}
if (!empty($record['name']) && record_exists('institution', 'name', $record['name'])) {
throw new SystemException("Invalid institution name '" . $record['name'] . "'. " . get_string('institutionnamealreadytaken', 'admin'));
}
if (get_config('licensemetadata') && !empty($record['licensemandatory']) && (isset($record['licensedefault']) && $record['licensedefault'] == '')) {
throw new SystemException("Invalid institution license setting. " . get_string('licensedefaultmandatory', 'admin'));
}
if (!empty($record['lang']) && $record['lang'] != 'sitedefault' && !array_key_exists($record['lang'], get_languages())) {
throw new SystemException("Invalid institution language setting: '" . $record['lang'] . "'. This language is not installed for the site.");
}
// Create a new institution
db_begin();
// Update the basic institution record...
$newinstitution = new Institution();
$newinstitution->initialise($record['name'], $record['displayname']);
$institution = $newinstitution->name;
$newinstitution->showonlineusers = !isset($record['showonlineusers']) ? 2 : $record['showonlineusers'];
if (get_config('usersuniquebyusername')) {
// Registering absolutely not allowed when this setting is on, it's a
// security risk. See the documentation for the usersuniquebyusername
// setting for more information
$newinstitution->registerallowed = 0;
} else {
$newinstitution->registerallowed = !empty($record['registerallowed']) ? 1 : 0;
$newinstitution->registerconfirm = !empty($record['registerconfirm']) ? 1 : 0;
}
if (!empty($record['lang'])) {
if ($record['lang'] == 'sitedefault') {
$newinstitution->lang = null;
} else {
$newinstitution->lang = $record['lang'];
}
}
$newinstitution->theme = empty($record['theme']) || $record['theme'] == 'sitedefault' ? null : $record['theme'];
$newinstitution->dropdownmenu = !empty($record['dropdownmenu']) ? 1 : 0;
$newinstitution->skins = !empty($record['skins']) ? 1 : 0;
$newinstitution->style = null;
if (get_config('licensemetadata')) {
$newinstitution->licensemandatory = !empty($record['licensemandatory']) ? 1 : 0;
$newinstitution->licensedefault = isset($record['licensedefault']) ? $record['licensedefault'] : '';
}
$newinstitution->defaultquota = empty($record['defaultquota']) ? get_config_plugin('artefact', 'file', 'defaultquota') : $record['defaultquota'];
$newinstitution->defaultmembershipperiod = !empty($record['defaultmembershipperiod']) ? intval($record['defaultmembershipperiod']) : null;
$newinstitution->maxuseraccounts = !empty($record['maxuseraccounts']) ? intval($record['maxuseraccounts']) : null;
$newinstitution->expiry = !empty($record['expiry']) ? db_format_timestamp($record['expiry']) : null;
$newinstitution->allowinstitutionpublicviews = isset($record['allowinstitutionpublicviews']) && $record['allowinstitutionpublicviews'] ? 1 : 0;
// Save the changes to the DB
$newinstitution->commit();
// Automatically create an internal authentication authinstance
$authinstance = (object) array('instancename' => 'internal', 'priority' => 0, 'institution' => $newinstitution->name, 'authname' => 'internal');
insert_record('auth_instance', $authinstance);
// We need to add the default lines to the site_content table for this institution
// We also need to set the institution to be using default static pages to begin with
// so that using custom institution pages is an opt-in situation
$pages = site_content_pages();
$now = db_format_timestamp(time());
foreach ($pages as $name) {
$page = new stdClass();
$page->name = $name;
$page->ctime = $now;
$page->mtime = $now;
$page->content = get_string($page->name . 'defaultcontent', 'install', get_string('staticpageconfiginstitution', 'install'));
$page->institution = $newinstitution->name;
insert_record('site_content', $page);
$institutionconfig = new stdClass();
$institutionconfig->institution = $newinstitution->name;
$institutionconfig->field = 'sitepages_' . $name;
$institutionconfig->value = 'mahara';
insert_record('institution_config', $institutionconfig);
}
if (isset($record['commentthreaded'])) {
set_config_institution($newinstitution->name, 'commentthreaded', (bool) $record['commentthreaded']);
}
db_commit();
}
示例5: core_install_lastcoredata_defaults
function core_install_lastcoredata_defaults()
{
global $USER;
db_begin();
$institution = new StdClass();
$institution->name = 'mahara';
$institution->displayname = 'No Institution';
$institution->authplugin = 'internal';
$institution->theme = 'default';
$institution->priority = 0;
insert_record('institution', $institution);
$pages = site_content_pages();
$now = db_format_timestamp(time());
foreach ($pages as $name) {
$page = new stdClass();
$page->name = $name;
$page->ctime = $now;
$page->mtime = $now;
$page->content = get_string($page->name . 'defaultcontent', 'install', get_string('staticpageconfigdefault', 'install'));
$page->institution = 'mahara';
insert_record('site_content', $page);
}
$auth_instance = new StdClass();
$auth_instance->instancename = 'Internal';
$auth_instance->priority = '1';
$auth_instance->institution = 'mahara';
$auth_instance->authname = 'internal';
$auth_instance->id = insert_record('auth_instance', $auth_instance, 'id', true);
// Insert the root user
$user = new StdClass();
$user->id = 0;
$user->username = 'root';
$user->password = '*';
$user->salt = '*';
$user->firstname = 'System';
$user->lastname = 'User';
$user->email = 'root@example.org';
$user->quota = get_config_plugin('artefact', 'file', 'defaultquota');
$user->authinstance = $auth_instance->id;
if (is_mysql()) {
// gratuitous mysql workaround
$newid = insert_record('usr', $user, 'id', true);
set_field('usr', 'id', 0, 'id', $newid);
execute_sql('ALTER TABLE {usr} AUTO_INCREMENT=1');
} else {
insert_record('usr', $user);
}
// install the default layout options
install_view_layout_defaults();
require_once 'group.php';
install_system_profile_view();
install_system_dashboard_view();
install_system_grouphomepage_view();
require_once 'license.php';
install_licenses_default();
require_once 'skin.php';
install_skins_default();
// Insert the admin user
$user = new StdClass();
$user->username = 'admin';
$user->salt = auth_get_random_salt();
$user->password = crypt('mahara', '$2a$' . get_config('bcrypt_cost') . '$' . substr(md5(get_config('passwordsaltmain') . $user->salt), 0, 22));
$user->password = substr($user->password, 0, 7) . substr($user->password, 7 + 22);
$user->authinstance = $auth_instance->id;
$user->passwordchange = 1;
$user->admin = 1;
$user->firstname = 'Admin';
$user->lastname = 'User';
$user->email = 'admin@example.org';
$user->quota = get_config_plugin('artefact', 'file', 'defaultquota');
$user->id = insert_record('usr', $user, 'id', true);
set_profile_field($user->id, 'email', $user->email);
set_profile_field($user->id, 'firstname', $user->firstname);
set_profile_field($user->id, 'lastname', $user->lastname);
handle_event('createuser', $user);
activity_add_admin_defaults(array($user->id));
db_commit();
// if we're installing, set up the block categories here and then poll the plugins.
// if we're upgrading this happens somewhere else. This is because of dependency issues around
// the order of installation stuff.
install_blocktype_extras();
}
示例6: institution_submit
//.........这里部分代码省略.........
// If this authinstance is the only xmlrpc authinstance that references a host, delete the host record.
$hostwwwroot = null;
foreach ($authinstances as $ai) {
if ($ai->id == $instanceid && $ai->authname == 'xmlrpc') {
$hostwwwroot = get_field_sql("SELECT \"value\" FROM {auth_instance_config} WHERE \"instance\" = ? AND field = 'wwwroot'", array($instanceid));
if ($hostwwwroot && count_records_select('auth_instance_config', "field = 'wwwroot' AND \"value\" = ?", array($hostwwwroot)) == 1) {
// Unfortunately, it's possible that this host record could belong to a different institution,
// so specify the institution here.
delete_records('host', 'wwwroot', $hostwwwroot, 'institution', $institution);
// We really need to fix this, either by removing the institution from the host table, or refusing to allow the
// institution to be changed in the host record when another institution's authinstance is still pointing at it.
}
break;
}
}
delete_records('auth_remote_user', 'authinstance', $instanceid);
delete_records('auth_instance_config', 'instance', $instanceid);
delete_records('auth_instance', 'id', $instanceid);
// Make it no longer be the parent authority to any auth instances
delete_records('auth_instance_config', 'field', 'parent', 'value', $instanceid);
}
}
// Store plugin settings.
plugin_institution_prefs_submit($form, $values, $newinstitution);
// Save the changes to the DB
$newinstitution->commit();
if ($add) {
// Automatically create an internal authentication authinstance
$authinstance = (object) array('instancename' => 'internal', 'priority' => 0, 'institution' => $newinstitution->name, 'authname' => 'internal');
insert_record('auth_instance', $authinstance);
// We need to add the default lines to the site_content table for this institution
// We also need to set the institution to be using default static pages to begin with
// so that using custom institution pages is an opt-in situation
$pages = site_content_pages();
$now = db_format_timestamp(time());
foreach ($pages as $name) {
$page = new stdClass();
$page->name = $name;
$page->ctime = $now;
$page->mtime = $now;
$page->content = get_string($page->name . 'defaultcontent', 'install', get_string('staticpageconfiginstitution', 'install'));
$page->institution = $newinstitution->name;
insert_record('site_content', $page);
$institutionconfig = new stdClass();
$institutionconfig->institution = $newinstitution->name;
$institutionconfig->field = 'sitepages_' . $name;
$institutionconfig->value = 'mahara';
insert_record('institution_config', $institutionconfig);
}
}
if (is_null($newinstitution->style) && !empty($oldinstitution->style)) {
delete_records('style_property', 'style', $oldinstitution->style);
delete_records('style', 'id', $oldinstitution->style);
}
// Set the logo after updating the institution, because the institution
// needs to exist before it can own the logo artefact.
if (!empty($values['logo'])) {
safe_require('artefact', 'file');
// Entry in artefact table
$data = (object) array('institution' => $institution, 'title' => 'logo', 'description' => 'Institution logo', 'note' => $values['logo']['name'], 'size' => $values['logo']['size']);
$imageinfo = getimagesize($values['logo']['tmp_name']);
$data->width = $imageinfo[0];
$data->height = $imageinfo[1];
$data->filetype = $imageinfo['mime'];
$artefact = new ArtefactTypeProfileIcon(0, $data);
if (preg_match("/\\.([^\\.]+)\$/", $values['logo']['name'], $saved)) {
示例7: core_postinst
function core_postinst()
{
$status = true;
$pages = site_content_pages();
$now = db_format_timestamp(time());
foreach ($pages as $name) {
$page = new stdClass();
$page->name = $name;
$page->ctime = $now;
$page->mtime = $now;
$page->content = get_string($page->name . 'defaultcontent', 'install');
if (!insert_record('site_content', $page)) {
$status = false;
}
}
// Attempt to create session directories
$sessionpath = get_config('dataroot') . 'sessions';
if (check_dir_exists($sessionpath)) {
// Create three levels of directories, named 0-9, a-f
$characters = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f');
foreach ($characters as $c1) {
if (check_dir_exists("{$sessionpath}/{$c1}")) {
foreach ($characters as $c2) {
if (check_dir_exists("{$sessionpath}/{$c1}/{$c2}")) {
foreach ($characters as $c3) {
if (!check_dir_exists("{$sessionpath}/{$c1}/{$c2}/{$c3}")) {
$status = false;
break 3;
}
}
} else {
$status = false;
break 2;
}
}
} else {
$status = false;
break;
}
}
} else {
$status = false;
}
// Set default search plugin
set_config('searchplugin', 'internal');
set_config('lang', 'en.utf8');
set_config('installation_key', get_random_key());
set_config('installation_time', $now);
set_config('stats_installation_time', $now);
// Pre-define SMTP settings
set_config('smtphosts', '');
set_config('smtpport', '');
set_config('smtpuser', '');
set_config('smtppass', '');
set_config('smtpsecure', '');
// XMLDB adds a table's keys immediately after creating the table. Some
// foreign keys therefore cannot be created during the XMLDB installation,
// because they refer to tables created later in the installation. These
// missing keys can be created now that all the core tables exist.
$table = new XMLDBTable('usr');
$key = new XMLDBKey('profileiconfk');
$key->setAttributes(XMLDB_KEY_FOREIGN, array('profileicon'), 'artefact', array('id'));
add_key($table, $key);
$table = new XMLDBTable('institution');
$key = new XMLDBKey('logofk');
$key->setAttributes(XMLDB_KEY_FOREIGN, array('logo'), 'artefact', array('id'));
add_key($table, $key);
// PostgreSQL supports indexes over functions of columns, MySQL does not.
// We make use if this if we can
if (is_postgres()) {
// Improve the username index
execute_sql('DROP INDEX {usr_use_uix}');
execute_sql('CREATE UNIQUE INDEX {usr_use_uix} ON {usr}(LOWER(username))');
// Add user search indexes
// Postgres only. We could create non-lowercased indexes in MySQL, but
// they would not be useful, and would require a change to varchar columns.
execute_sql('CREATE INDEX {usr_fir_ix} ON {usr}(LOWER(firstname))');
execute_sql('CREATE INDEX {usr_las_ix} ON {usr}(LOWER(lastname))');
execute_sql('CREATE INDEX {usr_pre_ix} ON {usr}(LOWER(preferredname))');
execute_sql('CREATE INDEX {usr_ema_ix} ON {usr}(LOWER(email))');
execute_sql('CREATE INDEX {usr_stu_ix} ON {usr}(LOWER(studentid))');
// Only one profile view per user
execute_sql("CREATE UNIQUE INDEX {view_own_type_uix} ON {view}(owner) WHERE type = 'profile'");
}
// Some more advanced constraints. XMLDB can't handle this in its xml file format
execute_sql('ALTER TABLE {artefact} ADD CHECK (
(owner IS NOT NULL AND "group" IS NULL AND institution IS NULL) OR
(owner IS NULL AND "group" IS NOT NULL AND institution IS NULL) OR
(owner IS NULL AND "group" IS NULL AND institution IS NOT NULL)
)');
execute_sql('ALTER TABLE {view} ADD CHECK (
(owner IS NOT NULL AND "group" IS NULL AND institution IS NULL) OR
(owner IS NULL AND "group" IS NOT NULL AND institution IS NULL) OR
(owner IS NULL AND "group" IS NULL AND institution IS NOT NULL)
)');
execute_sql('ALTER TABLE {artefact} ADD CHECK (
(author IS NOT NULL AND authorname IS NULL ) OR
(author IS NULL AND authorname IS NOT NULL)
)');
execute_sql('ALTER TABLE {view_access} ADD CHECK (
//.........这里部分代码省略.........