aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-02-18 15:24:58 -0800
committerredmatrix <git@macgirvin.com>2016-02-18 15:24:58 -0800
commit342fda94e4162634eeb67c18c1d284e7d78f217f (patch)
tree8171ce097a62ddf6de743a4ec25b2dd9ae3ccc41
parentc107bcfbd972a900cfd81b217014f7d4915fd73d (diff)
downloadvolse-hubzilla-342fda94e4162634eeb67c18c1d284e7d78f217f.tar.gz
volse-hubzilla-342fda94e4162634eeb67c18c1d284e7d78f217f.tar.bz2
volse-hubzilla-342fda94e4162634eeb67c18c1d284e7d78f217f.zip
Provide Zotlabs\Project and System class for querying details about the project/version info. Move these out of /boot.php
-rw-r--r--Zotlabs/Project/System.php62
-rwxr-xr-xboot.php45
-rw-r--r--include/api.php10
-rw-r--r--include/enotify.php2
-rw-r--r--include/event.php2
-rw-r--r--include/identity.php2
-rwxr-xr-xinclude/items.php4
-rw-r--r--include/language.php2
-rw-r--r--include/network.php10
-rwxr-xr-xinclude/plugin.php11
-rw-r--r--include/zot.php4
-rw-r--r--mod/help.php2
-rw-r--r--mod/import.php2
-rw-r--r--mod/linkinfo.php2
-rw-r--r--mod/settings.php2
-rw-r--r--mod/siteinfo.php2
16 files changed, 87 insertions, 77 deletions
diff --git a/Zotlabs/Project/System.php b/Zotlabs/Project/System.php
new file mode 100644
index 000000000..ca57c50a3
--- /dev/null
+++ b/Zotlabs/Project/System.php
@@ -0,0 +1,62 @@
+<?php
+
+namespace Zotlabs\Project;
+
+class System {
+
+ function get_platform_name() {
+ $a = get_app();
+ if(is_array($a->config) && is_array($a->config['system']) && $a->config['system']['platform_name'])
+ return $a->config['system']['platform_name'];
+ return PLATFORM_NAME;
+ }
+
+ function get_project_version() {
+ $a = get_app();
+ if(is_array($a->config) && is_array($a->config['system']) && $a->config['system']['hide_version'])
+ return '';
+ return RED_VERSION;
+ }
+
+ function get_update_version() {
+ $a = get_app();
+ if(is_array($a->config) && is_array($a->config['system']) && $a->config['system']['hide_version'])
+ return '';
+ return DB_UPDATE_VERSION;
+ }
+
+
+ function get_notify_icon() {
+ $a = get_app();
+ if(is_array($a->config) && is_array($a->config['system']) && $a->config['system']['email_notify_icon_url'])
+ return $a->config['system']['email_notify_icon_url'];
+ return z_root() . '/images/hz-white-32.png';
+ }
+
+ function get_site_icon() {
+ $a = get_app();
+ if(is_array($a->config) && is_array($a->config['system']) && $a->config['system']['site_icon_url'])
+ return $a->config['system']['site_icon_url'];
+ return z_root() . '/images/hz-32.png';
+ }
+
+
+ function get_server_role() {
+ if(UNO)
+ return 'basic';
+ return 'advanced';
+ }
+
+ // return the standardised version. Since we can't easily compare
+ // before the STD_VERSION definition was applied, we have to treat
+ // all prior release versions the same. You can dig through them
+ // with other means (such as RED_VERSION) if necessary.
+
+ function get_std_version() {
+ if(defined('STD_VERSION'))
+ return STD_VERSION;
+ return '0.0.0';
+ }
+
+
+}
diff --git a/boot.php b/boot.php
index 20f07c452..29f1788b6 100755
--- a/boot.php
+++ b/boot.php
@@ -45,6 +45,7 @@ require_once('include/Contact.php');
require_once('include/account.php');
require_once('include/AccessList.php');
+require_once('Zotlabs/Project/System.php');
define ( 'PLATFORM_NAME', 'hubzilla' );
define ( 'RED_VERSION', trim(file_get_contents('version.inc')));
@@ -1013,7 +1014,7 @@ class App {
'$user_scalable' => $user_scalable,
'$baseurl' => $this->get_baseurl(),
'$local_channel' => local_channel(),
- '$generator' => get_platform_name() . ((get_project_version()) ? ' ' . get_project_version() : ''),
+ '$generator' => Zotlabs\Project\System::get_platform_name() . ((Zotlabs\Project\System::get_project_version()) ? ' ' . Zotlabs\Project\System::get_project_version() : ''),
'$update_interval' => $interval,
'$icon' => head_get_icon(),
'$head_css' => head_get_css(),
@@ -2364,45 +2365,3 @@ function check_cron_broken() {
}
-function get_platform_name() {
- $a = get_app();
- if(is_array($a->config) && is_array($a->config['system']) && $a->config['system']['platform_name'])
- return $a->config['system']['platform_name'];
- return PLATFORM_NAME;
-}
-
-function get_project_version() {
- $a = get_app();
- if(is_array($a->config) && is_array($a->config['system']) && $a->config['system']['hide_version'])
- return '';
- return RED_VERSION;
-}
-
-function get_update_version() {
- $a = get_app();
- if(is_array($a->config) && is_array($a->config['system']) && $a->config['system']['hide_version'])
- return '';
- return DB_UPDATE_VERSION;
-}
-
-
-function get_notify_icon() {
- $a = get_app();
- if(is_array($a->config) && is_array($a->config['system']) && $a->config['system']['email_notify_icon_url'])
- return $a->config['system']['email_notify_icon_url'];
- return z_root() . '/images/hz-white-32.png';
-}
-
-function get_site_icon() {
- $a = get_app();
- if(is_array($a->config) && is_array($a->config['system']) && $a->config['system']['site_icon_url'])
- return $a->config['system']['site_icon_url'];
- return z_root() . '/images/hz-32.png';
-}
-
-
-function get_server_role() {
- if(UNO)
- return 'basic';
- return 'advanced';
-}
diff --git a/include/api.php b/include/api.php
index ef41a4912..e78e6cc37 100644
--- a/include/api.php
+++ b/include/api.php
@@ -2106,10 +2106,10 @@ require_once('include/api_auth.php');
'private' => $private, 'textlimit' => $textlimit, 'sslserver' => $sslserver, 'ssl' => $ssl,
'shorturllength' => '30',
'hubzilla' => array(
- 'PLATFORM_NAME' => get_platform_name(),
- 'RED_VERSION' => get_project_version(),
+ 'PLATFORM_NAME' => Zotlabs\Project\System::get_platform_name(),
+ 'RED_VERSION' => Zotlabs\Project\System::get_project_version(),
'ZOT_REVISION' => ZOT_REVISION,
- 'DB_UPDATE_VERSION' => get_update_version()
+ 'DB_UPDATE_VERSION' => Zotlabs\Project\System::get_update_version()
)
));
@@ -2142,12 +2142,12 @@ require_once('include/api_auth.php');
if($type === 'xml') {
header("Content-type: application/xml");
- echo '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n" . '<version>' . get_project_version() . '</version>' . "\r\n";
+ echo '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n" . '<version>' . Zotlabs\Project\System::get_project_version() . '</version>' . "\r\n";
killme();
}
elseif($type === 'json') {
header("Content-type: application/json");
- echo '"' . get_project_version() . '"';
+ echo '"' . Zotlabs\Project\System::get_project_version() . '"';
killme();
}
}
diff --git a/include/enotify.php b/include/enotify.php
index c4c49c8ff..e182377c0 100644
--- a/include/enotify.php
+++ b/include/enotify.php
@@ -529,7 +529,7 @@ function notification($params) {
$tpl = get_markup_template('email_notify_html.tpl');
$email_html_body = replace_macros($tpl,array(
'$banner' => $datarray['banner'],
- '$notify_icon' => get_notify_icon(),
+ '$notify_icon' => Zotlabs\Project\System::get_notify_icon(),
'$product' => $datarray['product'],
'$preamble' => $datarray['preamble'],
'$sitename' => $datarray['sitename'],
diff --git a/include/event.php b/include/event.php
index 51988acac..73033a1c3 100644
--- a/include/event.php
+++ b/include/event.php
@@ -67,7 +67,7 @@ function ical_wrapper($ev) {
$o .= "BEGIN:VCALENDAR";
$o .= "\r\nVERSION:2.0";
$o .= "\r\nMETHOD:PUBLISH";
- $o .= "\r\nPRODID:-//" . get_config('system','sitename') . "//" . get_platform_name() . "//" . strtoupper(get_app()->language). "\r\n";
+ $o .= "\r\nPRODID:-//" . get_config('system','sitename') . "//" . Zotlabs\Project\System::get_platform_name() . "//" . strtoupper(get_app()->language). "\r\n";
if(array_key_exists('start', $ev))
$o .= format_event_ical($ev);
else {
diff --git a/include/identity.php b/include/identity.php
index 51744f7bf..717deca14 100644
--- a/include/identity.php
+++ b/include/identity.php
@@ -484,7 +484,7 @@ function identity_basic_export($channel_id, $items = false) {
// use constants here as otherwise we will have no idea if we can import from a site
// with a non-standard platform and version.
- $ret['compatibility'] = array('project' => PLATFORM_NAME, 'version' => RED_VERSION, 'database' => DB_UPDATE_VERSION, 'server_role' => get_server_role());
+ $ret['compatibility'] = array('project' => PLATFORM_NAME, 'version' => RED_VERSION, 'database' => DB_UPDATE_VERSION, 'server_role' => Zotlabs\Project\System::get_server_role());
$r = q("select * from channel where channel_id = %d limit 1",
intval($channel_id)
diff --git a/include/items.php b/include/items.php
index f5eccfccd..a9597c1cf 100755
--- a/include/items.php
+++ b/include/items.php
@@ -610,8 +610,8 @@ function get_feed_for($channel, $observer_hash, $params) {
$atom = '';
$atom .= replace_macros($feed_template, array(
- '$version' => xmlify(get_project_version()),
- '$red' => xmlify(get_platform_name()),
+ '$version' => xmlify(Zotlabs\Project\System::get_project_version()),
+ '$red' => xmlify(Zotlabs\Project\System::get_platform_name()),
'$feed_id' => xmlify($channel['xchan_url']),
'$feed_title' => xmlify($channel['channel_name']),
'$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', 'now' , ATOM_TIME)) ,
diff --git a/include/language.php b/include/language.php
index c843db85e..121816ae6 100644
--- a/include/language.php
+++ b/include/language.php
@@ -189,7 +189,7 @@ function t($s, $ctx = '') {
function translate_projectname($s) {
- return str_replace(array('$projectname','$Projectname'),array(get_platform_name(),ucfirst(get_platform_name())),$s);
+ return str_replace(array('$projectname','$Projectname'),array(Zotlabs\Project\System::get_platform_name(),ucfirst(Zotlabs\Project\System::get_platform_name())),$s);
}
diff --git a/include/network.php b/include/network.php
index 7a9bca94a..aa6b54945 100644
--- a/include/network.php
+++ b/include/network.php
@@ -1620,7 +1620,7 @@ function format_and_send_email($sender,$xchan,$item) {
$tpl = get_markup_template('email_notify_html.tpl');
$email_html_body = replace_macros($tpl,array(
'$banner' => $banner,
- '$notify_icon' => get_notify_icon(),
+ '$notify_icon' => Zotlabs\Project\System::get_notify_icon(),
'$product' => $product,
'$preamble' => '',
'$sitename' => $sitename,
@@ -1768,8 +1768,8 @@ function get_site_info() {
$site_info = get_config('system','info');
$site_name = get_config('system','sitename');
if(! get_config('system','hidden_version_siteinfo')) {
- $version = get_project_version();
- $tag = get_std_version();
+ $version = Zotlabs\Project\System::get_project_version();
+ $tag = Zotlabs\Project\System::get_std_version();
if(@is_dir('.git') && function_exists('shell_exec')) {
$commit = trim( @shell_exec('git log -1 --format="%h"'));
@@ -1805,7 +1805,7 @@ function get_site_info() {
$data = Array(
'version' => $version,
'version_tag' => $tag,
- 'server_role' => get_server_role(),
+ 'server_role' => Zotlabs\Project\System::get_server_role(),
'commit' => $commit,
'url' => z_root(),
'plugins' => $visible_plugins,
@@ -1819,7 +1819,7 @@ function get_site_info() {
'locked_features' => $locked_features,
'admin' => $admin,
'site_name' => (($site_name) ? $site_name : ''),
- 'platform' => get_platform_name(),
+ 'platform' => Zotlabs\Project\System::get_platform_name(),
'dbdriver' => $db->getdriver(),
'lastpoll' => get_config('system','lastpoll'),
'info' => (($site_info) ? $site_info : ''),
diff --git a/include/plugin.php b/include/plugin.php
index da4568ad7..5afded542 100755
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -653,17 +653,6 @@ function get_markup_template($s, $root = '') {
return $template;
}
-// return the standardised version. Since we can't easily compare
-// before the STD_VERSION definition was applied, we have to treat
-// all prior release versions the same. You can dig through them
-// with other means (such as RED_VERSION) if necessary.
-
-function get_std_version() {
- if(defined('STD_VERSION'))
- return STD_VERSION;
- return '0.0.0';
-}
-
function folder_exists($folder)
{
diff --git a/include/zot.php b/include/zot.php
index e9335769e..6f3d57d06 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -3835,7 +3835,7 @@ function zotinfo($arr) {
$ret['site']['channels'] = channel_total();
- $ret['site']['version'] = get_platform_name() . ' ' . RED_VERSION . '[' . DB_UPDATE_VERSION . ']';
+ $ret['site']['version'] = Zotlabs\Project\System::get_platform_name() . ' ' . RED_VERSION . '[' . DB_UPDATE_VERSION . ']';
$ret['site']['admin'] = get_config('system','admin_email');
@@ -3855,7 +3855,7 @@ function zotinfo($arr) {
$ret['site']['sellpage'] = get_config('system','sellpage');
$ret['site']['location'] = get_config('system','site_location');
$ret['site']['realm'] = get_directory_realm();
- $ret['site']['project'] = get_platform_name();
+ $ret['site']['project'] = Zotlabs\Project\System::get_platform_name();
}
diff --git a/mod/help.php b/mod/help.php
index 1539978f7..19bf251bd 100644
--- a/mod/help.php
+++ b/mod/help.php
@@ -160,7 +160,7 @@ function help_content(&$a) {
$path = trim(substr($dirname,4),'/');
$o .= '<li><a href="help/' . (($path) ? $path . '/' : '') . $fname . '" >' . ucwords(str_replace('_',' ',notags($fname))) . '</a><br />' .
- str_replace('$Projectname',get_platform_name(),substr($rr['text'],0,200)) . '...<br /><br /></li>';
+ str_replace('$Projectname',Zotlabs\Project\System::get_platform_name(),substr($rr['text'],0,200)) . '...<br /><br /></li>';
}
$o .= '</ul>';
diff --git a/mod/import.php b/mod/import.php
index 0bbd38ffe..184159585 100644
--- a/mod/import.php
+++ b/mod/import.php
@@ -120,7 +120,7 @@ function import_account(&$a, $account_id) {
notice($t);
}
if(array_key_exists('server_role',$data['compatibility'])
- && $data['compatibility']['server_role'] != get_server_role()) {
+ && $data['compatibility']['server_role'] != Zotlabs\Project\System::get_server_role()) {
notice( t('Server platform is not compatible. Operation not permitted.') . EOL);
return;
}
diff --git a/mod/linkinfo.php b/mod/linkinfo.php
index 5d9e2bc67..07eaa02a0 100644
--- a/mod/linkinfo.php
+++ b/mod/linkinfo.php
@@ -115,7 +115,7 @@ function linkinfo_content(&$a) {
// If this is a Red site, use zrl rather than url so they get zids sent to them by default
- if( x($siteinfo,'generator') && (strpos($siteinfo['generator'], get_platform_name() . ' ') === 0))
+ if( x($siteinfo,'generator') && (strpos($siteinfo['generator'], Zotlabs\Project\System::get_platform_name() . ' ') === 0))
$template = str_replace('url','zrl',$template);
if($siteinfo["title"] == "") {
diff --git a/mod/settings.php b/mod/settings.php
index ea9c73435..467cccfc7 100644
--- a/mod/settings.php
+++ b/mod/settings.php
@@ -1044,7 +1044,7 @@ function settings_content(&$a) {
'$h_prv' => t('Security and Privacy Settings'),
'$permissions_set' => $permissions_set,
- '$server_role' => get_server_role(),
+ '$server_role' => Zotlabs\Project\System::get_server_role(),
'$perms_set_msg' => t('Your permissions are already configured. Click to view/adjust'),
'$hide_presence' => array('hide_presence', t('Hide my online presence'),$hide_presence, t('Prevents displaying in your profile that you are online'), $yes_no),
diff --git a/mod/siteinfo.php b/mod/siteinfo.php
index f7423506f..29c7d7d2c 100644
--- a/mod/siteinfo.php
+++ b/mod/siteinfo.php
@@ -12,7 +12,7 @@ function siteinfo_init(&$a) {
function siteinfo_content(&$a) {
if(! get_config('system','hidden_version_siteinfo')) {
- $version = sprintf( t('Version %s'), get_project_version());
+ $version = sprintf( t('Version %s'), Zotlabs\Project\System::get_project_version());
if(@is_dir('.git') && function_exists('shell_exec')) {
$commit = @shell_exec('git log -1 --format="%h"');
$tag = get_std_version(); // @shell_exec('git describe --tags --abbrev=0');