Commit 342fda94 authored by redmatrix's avatar redmatrix

Provide Zotlabs\Project and System class for querying details about the...

Provide Zotlabs\Project and System class for querying details about the project/version info. Move these out of /boot.php
parent c107bcfb
<?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';
}
}
......@@ -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';
}
......@@ -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();
}
}
......
......@@ -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'],
......
......@@ -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 {
......
......@@ -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)
......
......@@ -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)) ,
......
......@@ -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);
}
......
......@@ -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 : ''),
......
......@@ -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)
{
......
......@@ -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();
}
......
......@@ -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>';
......
......@@ -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;
}
......
......@@ -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"] == "") {
......
......@@ -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),
......
......@@ -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');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment