本文整理汇总了PHP中elgg_get_version函数的典型用法代码示例。如果您正苦于以下问题:PHP elgg_get_version函数的具体用法?PHP elgg_get_version怎么用?PHP elgg_get_version使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了elgg_get_version函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendNotice
/**
* Sends a notice about deprecated use of a function, view, etc.
*
* @param string $msg Message to log
* @param string $dep_version Human-readable *release* version: 1.7, 1.8, ...
* @param int $backtrace_level How many levels back to display the backtrace.
* Useful if calling from functions that are called
* from other places (like elgg_view()). Set to -1
* for a full backtrace.
* @return bool
*/
function sendNotice($msg, $dep_version, $backtrace_level = 1)
{
if (!$dep_version) {
return false;
}
$elgg_version = elgg_get_version(true);
$elgg_version_arr = explode('.', $elgg_version);
$elgg_major_version = (int) $elgg_version_arr[0];
$elgg_minor_version = (int) $elgg_version_arr[1];
$dep_version_arr = explode('.', (string) $dep_version);
$dep_major_version = (int) $dep_version_arr[0];
$dep_minor_version = (int) $dep_version_arr[1];
$msg = "Deprecated in {$dep_major_version}.{$dep_minor_version}: {$msg} Called from ";
// Get a file and line number for the log. Skip over the function that
// sent this notice and see who called the deprecated function itself.
$stack = array();
$backtrace = debug_backtrace();
// never show this call.
array_shift($backtrace);
$i = count($backtrace);
foreach ($backtrace as $trace) {
$stack[] = "[#{$i}] {$trace['file']}:{$trace['line']}";
$i--;
if ($backtrace_level > 0) {
if ($backtrace_level <= 1) {
break;
}
$backtrace_level--;
}
}
$msg .= implode("<br /> -> ", $stack);
$this->logger->warn($msg);
return true;
}
示例2: diagnostics_basic_hook
/**
* Generate a basic report.
*
* @return string
*/
function diagnostics_basic_hook($hook, $entity_type, $returnvalue, $params)
{
// Get version information
$version = elgg_get_version();
$release = elgg_get_version(true);
$returnvalue .= elgg_echo('diagnostics:report:basic', array($release, $version));
return $returnvalue;
}
示例3: boot
/**
* @codeCoverageIgnore
*/
public static function boot()
{
if (version_compare(elgg_get_version(true), '1.9', '<')) {
$autoloader = new CodeReviewAutoloader();
$autoloader->register();
}
self::initConfig(array('path' => elgg_get_config('path'), 'pluginspath' => elgg_get_plugins_path(), 'plugins_getter' => 'elgg_get_plugins'));
}
示例4: boot
/**
* @codeCoverageIgnore
*/
public static function boot()
{
if (version_compare(elgg_get_version(true), '1.9', '<')) {
$autoloader = new \CodeReview\Autoloader();
$autoloader->register();
}
$enginePath = elgg_get_config('path') . 'engine/';
if (function_exists('elgg_get_engine_path')) {
$enginePath = elgg_get_engine_path() . '/';
}
self::initConfig(array('engine_path' => $enginePath, 'path' => elgg_get_config('path'), 'pluginspath' => elgg_get_plugins_path(), 'plugins_getter' => 'elgg_get_plugins'));
}
示例5: elgg_lightbox_init
/**
* Initialize the plugin
* @return void
*/
function elgg_lightbox_init()
{
if (!elgg_is_active_plugin('mrclay_combiner')) {
elgg_unregister_js('lightbox');
}
elgg_unregister_css('lightbox');
elgg_extend_view('elgg.css', 'colorbox.css');
elgg_extend_view('admin.css', 'colorbox.css');
if (version_compare(elgg_get_version(true), '2.2', '<')) {
elgg_extend_view('elgg.js', 'elgg/lightbox.js');
elgg_require_js('elgg/lightbox');
}
}
示例6: getElggVersion
/**
* Returns Elgg version
* @return string|false
*/
public static function getElggVersion()
{
if (isset(self::$version)) {
return self::$version;
}
if (is_callable('elgg_get_version')) {
return elgg_get_version(true);
} else {
$path = self::getRootPath() . '/version.php';
if (!(include $path)) {
return false;
}
self::$version = $release;
return self::$version;
}
}
示例7: sendNotice
/**
* Sends a notice about deprecated use of a function, view, etc.
*
* @param string $msg Message to log / display.
* @param string $dep_version Human-readable *release* version: 1.7, 1.8, ...
* @param int $backtrace_level How many levels back to display the backtrace.
* Useful if calling from functions that are called
* from other places (like elgg_view()). Set to -1
* for a full backtrace.
* @return bool
*/
function sendNotice($msg, $dep_version, $backtrace_level = 1)
{
// if it's a major release behind, visual and logged
// if it's a 1 minor release behind, visual and logged
// if it's for current minor release, logged.
// bugfixes don't matter because we are not deprecating between them
if (!$dep_version) {
return false;
}
$elgg_version = elgg_get_version(true);
$elgg_version_arr = explode('.', $elgg_version);
$elgg_major_version = (int) $elgg_version_arr[0];
$elgg_minor_version = (int) $elgg_version_arr[1];
$dep_version_arr = explode('.', (string) $dep_version);
$dep_major_version = (int) $dep_version_arr[0];
$dep_minor_version = (int) $dep_version_arr[1];
$visual = false;
if ($dep_major_version < $elgg_major_version || $dep_minor_version < $elgg_minor_version) {
$visual = true;
}
$msg = "Deprecated in {$dep_major_version}.{$dep_minor_version}: {$msg}";
if ($visual && $this->session->isAdminLoggedIn()) {
register_error($msg);
}
// Get a file and line number for the log. Never show this in the UI.
// Skip over the function that sent this notice and see who called the deprecated
// function itself.
$msg .= " Called from ";
$stack = array();
$backtrace = debug_backtrace();
// never show this call.
array_shift($backtrace);
$i = count($backtrace);
foreach ($backtrace as $trace) {
$stack[] = "[#{$i}] {$trace['file']}:{$trace['line']}";
$i--;
if ($backtrace_level > 0) {
if ($backtrace_level <= 1) {
break;
}
$backtrace_level--;
}
}
$msg .= implode("<br /> -> ", $stack);
$this->logger->warn($msg);
return true;
}
示例8: elgg_update_services_get_updates
function elgg_update_services_get_updates()
{
$installed_plugins = elgg_get_plugins('all');
$plugin_hash_list = array();
foreach ($installed_plugins as $id => $plugin) {
$manifest = $plugin->getManifest();
$bundled = in_array('bundled', $manifest->getCategories()) ? true : false;
if (!$bundled) {
$id = $manifest->getID();
if (empty($id)) {
$id = $plugin->getID();
}
$version = $manifest->getVersion();
$author = $manifest->getAuthor();
$plugin_hash_list[] = md5($id . $version . $author);
}
}
$url = "http://community.elgg.org/services/api/rest/json/?method=plugins.update.check&version=" . elgg_get_version(true);
foreach ($plugin_hash_list as $plugin_hash) {
$url .= "&plugins[]=" . $plugin_hash;
}
$update_check = elgg_update_services_file_get_conditional_contents($url);
return json_decode($update_check, true);
}
示例9: init_late
function init_late()
{
elgg_extend_view('css/elgg', 'css/mrclay_aalborg');
elgg_register_css('fonts.Open Sans', 'https://fonts.googleapis.com/css?family=Open+Sans:400,300&subset=latin,latin-ext');
elgg_load_css('fonts.Open Sans');
elgg_require_js('mrclay_aalborg');
// add a topbar in the header
// TODO leave topbar in place and change with CSS
elgg_extend_view('page/elements/header', 'mrclay_aalborg/topbar', 0);
elgg_extend_view('forms/comment/save', 'mrclay_aalborg/comment_save', 0);
// topbar menu edits
elgg_register_plugin_hook_handler('prepare', 'menu:topbar', 'MrClay\\AalborgExtras\\Topbar::prepareMenu', 1000);
// user hover customizations
elgg_register_plugin_hook_handler('prepare', 'menu:user_hover', 'MrClay\\AalborgExtras\\UserHover::prepareMenu', 1000);
// https://github.com/Elgg/Elgg/issues/8718
elgg_register_plugin_hook_handler('route', 'file', 'MrClay\\AalborgExtras\\Files::handleFileRoute', 1000);
elgg_register_plugin_hook_handler('register', 'menu:page', 'MrClay\\AalborgExtras\\Files::registerPageMenu', 1000);
elgg_register_plugin_hook_handler('register', 'menu:extras', 'MrClay\\AalborgExtras\\Files::registerExtrasMenu', 1000);
// Replace "Navigation" with "Pages"
// TODO cleanup
elgg_register_plugin_hook_handler('view', 'pages/sidebar/navigation', function ($h, $t, $v, $p) {
$v = preg_replace('~<h3>.*?</h3>~', '<h3>' . elgg_echo('pages') . '</h3>', $v, 1);
return $v;
});
// https://github.com/Elgg/Elgg/issues/8697
elgg_unextend_view('profile/status', 'thewire/profile_status');
// https://github.com/Elgg/Elgg/issues/8628
if (version_compare(elgg_get_version(), '2.0', '>=')) {
// https://github.com/Elgg/Elgg/issues/8628
elgg_unregister_menu_item('extras', 'report_this');
if (elgg_is_logged_in()) {
elgg_register_menu_item('extras', array('name' => 'report_this', 'href' => 'reportedcontent/add', 'title' => elgg_echo('reportedcontent:this:tooltip'), 'text' => elgg_view_icon('exclamation-triangle'), 'priority' => 500, 'section' => 'default', 'link_class' => 'elgg-lightbox'));
}
}
$path = substr(current_page_url(), strlen(elgg_get_site_url()));
// remove duplicate title from page view
// TODO cleanup
if (preg_match('~^pages/view/(\\d+)~', $path, $m)) {
$guid = (int) $m[1];
// https://github.com/Elgg/Elgg/issues/8723
elgg_register_plugin_hook_handler('view_vars', 'object/elements/summary', function ($h, $t, $vars, $p) use($guid) {
if (empty($vars['entity'])) {
return;
}
$entity = $vars['entity'];
/* @var \ElggEntity $entity */
// make sure this is the expected entity
if ($entity->guid !== $guid) {
return;
}
$vars['title'] = false;
return $vars;
});
// https://github.com/Elgg/Elgg/issues/8722
elgg_register_plugin_hook_handler('view_vars', 'object/elements/full', function ($h, $t, $vars, $p) use($guid) {
// make sure this is the expected entity
if (empty($vars['entity'])) {
return;
}
$entity = $vars['entity'];
/* @var \ElggEntity $entity */
if ($entity->guid !== $guid) {
return;
}
$vars['icon'] = elgg_view_entity_icon($entity->getOwnerEntity(), 'tiny');
return $vars;
});
}
// // add resources view classes to BODY
// elgg_register_plugin_hook_handler('view_vars', 'all', function ($h, $view, $vars, $p) {
// if (0 !== strpos($view, 'resources/')) {
// return;
// }
//
// $classes = [];
//
// $classes[] = 'elgg-' . preg_replace('~[^a-zA-Z0-9]+~', '-', $view);
//
// if (is_array($vars)) {
// foreach ($vars as $key => $value) {
// if (is_string($value)
// && preg_match('~^[a-zA-Z0-9_]+$~', $key)
// && preg_match('~^[a-zA-Z0-9_]+$~', $key)) {
// $classes[] = "elgg-resource-vars-$key-$value";
// }
// }
// }
//
// $classes_adder = function ($h, $t, $vars, $p) use ($classes) {
// $body_attrs = (array)elgg_extract('body_attrs', $vars, []);
// $body_classes = (array)elgg_extract('class', $body_attrs, []);
//
// array_splice($body_classes, count($body_classes), 0, $classes);
// $vars['body_attrs']['class'] = $body_classes;
//
// return $vars;
// };
// elgg_register_plugin_hook_handler('view_vars', 'page/elements/html', $classes_adder);
// });
}
示例10: readfile
readfile("{$root_path}{$file}.js");
// putting a new line between the files to address https://github.com/elgg/elgg/issues/3081
echo "\n";
}
/**
* Set some values that are cacheable
*/
?>
//<script>
elgg.version = '<?php
echo elgg_get_version();
?>
';
elgg.release = '<?php
echo elgg_get_version(true);
?>
';
elgg.config.wwwroot = '<?php
echo elgg_get_site_url();
?>
';
// refresh token 3 times during its lifetime (in microseconds 1000 * 1/3)
elgg.security.interval = <?php
echo (int) _elgg_services()->actions->getActionTokenTimeout() * 333;
?>
;
elgg.config.language = '<?php
echo empty($CONFIG->language) ? 'en' : $CONFIG->language;
?>
示例11: checkDependencies
/**
* Returns if the Elgg system meets the plugin's dependency
* requirements. This includes both requires and conflicts.
*
* Full reports can be requested. The results are returned
* as an array of arrays in the form array(
* 'type' => requires|conflicts,
* 'dep' => array( dependency array ),
* 'status' => bool if depedency is met,
* 'comment' => optional comment to display to the user.
* )
*
* @param bool $full_report Return a full report.
* @return bool|array
*/
public function checkDependencies($full_report = false)
{
// Note: $conflicts and $requires are not unused. They're called dynamically
$requires = $this->getManifest()->getRequires();
$conflicts = $this->getManifest()->getConflicts();
$enabled_plugins = elgg_get_plugins('active');
$this_id = $this->getID();
$report = array();
// first, check if any active plugin conflicts with us.
foreach ($enabled_plugins as $plugin) {
$temp_conflicts = array();
$temp_manifest = $plugin->getManifest();
if ($temp_manifest instanceof \ElggPluginManifest) {
$temp_conflicts = $plugin->getManifest()->getConflicts();
}
foreach ($temp_conflicts as $conflict) {
if ($conflict['type'] == 'plugin' && $conflict['name'] == $this_id) {
$result = $this->checkDepPlugin($conflict, $enabled_plugins, false);
// rewrite the conflict to show the originating plugin
$conflict['name'] = $plugin->getManifest()->getName();
if (!$full_report && !$result['status']) {
$css_id = preg_replace('/[^a-z0-9-]/i', '-', $plugin->getManifest()->getID());
$link = elgg_view('output/url', ['text' => $plugin->getManifest()->getName(), 'href' => "#{$css_id}"]);
$key = 'ElggPluginPackage:InvalidPlugin:ConflictsWithPlugin';
$this->errorMsg = _elgg_services()->translator->translate($key, [$link]);
return $result['status'];
} else {
$report[] = array('type' => 'conflicted', 'dep' => $conflict, 'status' => $result['status'], 'value' => $this->getManifest()->getVersion());
}
}
}
}
$check_types = array('requires', 'conflicts');
if ($full_report) {
// Note: $suggests is not unused. It's called dynamically
$suggests = $this->getManifest()->getSuggests();
$check_types[] = 'suggests';
}
foreach ($check_types as $dep_type) {
$inverse = $dep_type == 'conflicts' ? true : false;
foreach (${$dep_type} as $dep) {
switch ($dep['type']) {
case 'elgg_release':
$result = $this->checkDepElgg($dep, elgg_get_version(true), $inverse);
break;
case 'plugin':
$result = $this->checkDepPlugin($dep, $enabled_plugins, $inverse);
break;
case 'priority':
$result = $this->checkDepPriority($dep, $enabled_plugins, $inverse);
break;
case 'php_version':
$result = $this->checkDepPhpVersion($dep, $inverse);
break;
case 'php_extension':
$result = $this->checkDepPhpExtension($dep, $inverse);
break;
case 'php_ini':
$result = $this->checkDepPhpIni($dep, $inverse);
break;
default:
$result = null;
//skip further check
break;
}
if ($result !== null) {
// unless we're doing a full report, break as soon as we fail.
if (!$full_report && !$result['status']) {
$this->errorMsg = "Missing dependencies.";
return $result['status'];
} else {
// build report element and comment
$report[] = array('type' => $dep_type, 'dep' => $dep, 'status' => $result['status'], 'value' => $result['value']);
}
}
}
}
if ($full_report) {
// add provides to full report
$provides = $this->getManifest()->getProvides();
foreach ($provides as $provide) {
$report[] = array('type' => 'provides', 'dep' => $provide, 'status' => true, 'value' => '');
}
return $report;
}
//.........这里部分代码省略.........
示例12: checkDependencies
/**
* Returns if the Elgg system meets the plugin's dependency
* requirements. This includes both requires and conflicts.
*
* Full reports can be requested. The results are returned
* as an array of arrays in the form array(
* 'type' => requires|conflicts,
* 'dep' => array( dependency array ),
* 'status' => bool if depedency is met,
* 'comment' => optional comment to display to the user.
* )
*
* @param bool $full_report Return a full report.
* @return bool|array
*/
public function checkDependencies($full_report = false)
{
// Note: $conflicts and $requires are not unused. They're called dynamically
$requires = $this->getManifest()->getRequires();
$conflicts = $this->getManifest()->getConflicts();
$enabled_plugins = elgg_get_plugins('active');
$this_id = $this->getID();
$report = array();
// first, check if any active plugin conflicts with us.
foreach ($enabled_plugins as $plugin) {
$temp_conflicts = array();
$temp_manifest = $plugin->getManifest();
if ($temp_manifest instanceof ElggPluginManifest) {
$temp_conflicts = $plugin->getManifest()->getConflicts();
}
foreach ($temp_conflicts as $conflict) {
if ($conflict['type'] == 'plugin' && $conflict['name'] == $this_id) {
$result = $this->checkDepPlugin($conflict, $enabled_plugins, false);
// rewrite the conflict to show the originating plugin
$conflict['name'] = $plugin->getManifest()->getName();
if (!$full_report && !$result['status']) {
$this->errorMsg = "Conflicts with plugin \"{$plugin->getManifest()->getName()}\".";
return $result['status'];
} else {
$report[] = array('type' => 'conflicted', 'dep' => $conflict, 'status' => $result['status'], 'value' => $this->getManifest()->getVersion());
}
}
}
}
$check_types = array('requires', 'conflicts');
if ($full_report) {
// Note: $suggests is not unused. It's called dynamically
$suggests = $this->getManifest()->getSuggests();
$check_types[] = 'suggests';
}
foreach ($check_types as $dep_type) {
$inverse = $dep_type == 'conflicts' ? true : false;
foreach (${$dep_type} as $dep) {
switch ($dep['type']) {
case 'elgg_version':
elgg_deprecated_notice("elgg_version in manifest.xml files is deprecated. Use elgg_release", 1.9);
$result = $this->checkDepElgg($dep, elgg_get_version(), $inverse);
break;
case 'elgg_release':
$result = $this->checkDepElgg($dep, elgg_get_version(true), $inverse);
break;
case 'plugin':
$result = $this->checkDepPlugin($dep, $enabled_plugins, $inverse);
break;
case 'priority':
$result = $this->checkDepPriority($dep, $enabled_plugins, $inverse);
break;
case 'php_version':
$result = $this->checkDepPhpVersion($dep, $inverse);
break;
case 'php_extension':
$result = $this->checkDepPhpExtension($dep, $inverse);
break;
case 'php_ini':
$result = $this->checkDepPhpIni($dep, $inverse);
break;
default:
$result = null;
//skip further check
break;
}
if ($result !== null) {
// unless we're doing a full report, break as soon as we fail.
if (!$full_report && !$result['status']) {
$this->errorMsg = "Missing dependencies.";
return $result['status'];
} else {
// build report element and comment
$report[] = array('type' => $dep_type, 'dep' => $dep, 'status' => $result['status'], 'value' => $result['value']);
}
}
}
}
if ($full_report) {
// add provides to full report
$provides = $this->getManifest()->getProvides();
foreach ($provides as $provide) {
$report[] = array('type' => 'provides', 'dep' => $provide, 'status' => true, 'value' => '');
}
return $report;
//.........这里部分代码省略.........
示例13: current_page_url
if (!$base_url) {
$base_url = current_page_url();
}
$base_url = elgg_http_remove_url_query_element($base_url, 'query');
$base_url = elgg_http_remove_url_query_element($base_url, 'sort');
$base_url = elgg_http_remove_url_query_element($base_url, 'limit');
$base_url = elgg_http_remove_url_query_element($base_url, elgg_extract('offset_key', $options, 'offset'));
$form = elgg_view_form('group/sort', array('action' => $base_url, 'method' => 'GET', 'disable_security' => true), $vars);
$user = elgg_extract('user', $vars, elgg_get_page_owner_entity());
$options['user'] = $user ?: null;
$options = group_sort_add_rel_options($options, $rel, $user ?: null);
list($sort_field, $sort_direction) = explode('::', $sort);
$options = group_sort_add_sort_options($options, $sort_field, $sort_direction);
if (!empty($query) && elgg_is_active_plugin('search')) {
$options['query'] = $query;
if (version_compare(elgg_get_version(true), '2.1', '>=')) {
// search hooks in earlier versions reset 'joins' and 'wheres' and 'order_by'
$results = elgg_trigger_plugin_hook('search', 'group', $options, array());
$entities = elgg_extract('entities', $results);
$list = elgg_view_entity_list($entities, $options);
} else {
$options = group_sort_add_search_query_options($options, $query);
$list = call_user_func($callback, $options);
}
} else {
$list = call_user_func($callback, $options);
}
// make sure it's not an empty list with no results <p>
if (empty($query) && !preg_match_all("/<ul.*>.*<\\/ul>/s", $list)) {
echo $list;
return;
示例14: saveSiteSettings
/**
* Initialize the site including site entity, plugins, and configuration
*
* @param array $submissionVars Submitted vars
*
* @return bool
*/
protected function saveSiteSettings($submissionVars)
{
global $CONFIG;
// ensure that file path, data path, and www root end in /
$submissionVars['path'] = sanitise_filepath($submissionVars['path']);
$submissionVars['dataroot'] = sanitise_filepath($submissionVars['dataroot']);
$submissionVars['wwwroot'] = sanitise_filepath($submissionVars['wwwroot']);
$site = new ElggSite();
$site->name = strip_tags($submissionVars['sitename']);
$site->url = $submissionVars['wwwroot'];
$site->access_id = ACCESS_PUBLIC;
$site->email = $submissionVars['siteemail'];
$guid = $site->save();
if (!$guid) {
register_error(elgg_echo('install:error:createsite'));
return FALSE;
}
// bootstrap site info
$CONFIG->site_guid = $guid;
$CONFIG->site_id = $guid;
$CONFIG->site = $site;
datalist_set('installed', time());
datalist_set('path', $submissionVars['path']);
datalist_set('dataroot', $submissionVars['dataroot']);
datalist_set('default_site', $site->getGUID());
datalist_set('version', elgg_get_version());
datalist_set('simplecache_enabled', 1);
datalist_set('system_cache_enabled', 1);
datalist_set('simplecache_lastupdate', time());
// new installations have run all the upgrades
$upgrades = elgg_get_upgrade_files($submissionVars['path'] . 'engine/lib/upgrades/');
datalist_set('processed_upgrades', serialize($upgrades));
set_config('view', 'default', $site->getGUID());
set_config('language', 'en', $site->getGUID());
set_config('default_access', $submissionVars['siteaccess'], $site->getGUID());
set_config('allow_registration', TRUE, $site->getGUID());
set_config('walled_garden', FALSE, $site->getGUID());
set_config('allow_user_default_access', '', $site->getGUID());
$this->setSubtypeClasses();
$this->enablePlugins();
return TRUE;
}
示例15: _elgg_get_js_site_data
/**
* Get the site data to be merged into "elgg" in elgg.js.
*
* Unlike _elgg_get_js_page_data(), the keys returned are literal expressions.
*
* @return array
* @access private
*/
function _elgg_get_js_site_data()
{
$language = elgg_get_config('language');
if (!$language) {
$language = 'en';
}
return ['elgg.data' => (object) elgg_trigger_plugin_hook('elgg.data', 'site', null, []), 'elgg.version' => elgg_get_version(), 'elgg.release' => elgg_get_version(true), 'elgg.config.wwwroot' => elgg_get_site_url(), 'elgg.security.interval' => (int) _elgg_services()->actions->getActionTokenTimeout() * 333, 'elgg.config.language' => $language];
}