From 9abd95fad3784a10fc48bc40f9b8a75d7d74edda Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 31 Mar 2016 16:06:03 -0700 Subject: static App --- Zotlabs/Project/System.php | 16 +- Zotlabs/Storage/Browser.php | 2 +- Zotlabs/Storage/Directory.php | 10 +- Zotlabs/Storage/File.php | 2 +- Zotlabs/Web/Router.php | 90 +- Zotlabs/Zot/Auth.php | 8 +- boot.php | 178 +- doc/DerivedTheme1.md | 4 +- doc/Primary-Directory.md | 2 +- doc/dev-function-overview.md | 2 +- doc/dev_beginner.bb | 2 +- doc/directories.bb | 2 +- doc/faq_developers.bb | 8 +- doc/hook/module_mod_aftercontent.bb | 2 +- doc/hook/module_mod_content.bb | 2 +- include/Contact.php | 20 +- include/ConversationObject.php | 6 +- include/Import/import_diaspora.php | 2 +- include/ItemObject.php | 2 +- include/account.php | 8 +- include/acl_selectors.php | 12 +- include/activities.php | 2 +- include/api.php | 62 +- include/api_auth.php | 4 +- include/apps.php | 10 +- include/attach.php | 4 +- include/auth.php | 16 +- include/bbcode.php | 22 +- include/cli_startup.php | 6 +- include/comanche.php | 28 +- include/config.php | 146 +- include/contact_widgets.php | 8 +- include/conversation.php | 64 +- include/datetime.php | 2 +- include/dir_fns.php | 6 +- include/enotify.php | 8 +- include/event.php | 4 +- include/identity.php | 154 +- include/items.php | 24 +- include/language.php | 36 +- include/menu.php | 6 +- include/message.php | 6 +- include/nav.php | 34 +- include/network.php | 12 +- include/oauth.php | 2 +- include/oembed.php | 10 +- include/permissions.php | 4 +- include/photos.php | 6 +- include/plugin.php | 54 +- include/security.php | 32 +- include/session.php | 4 +- include/smarty.php | 18 +- include/socgraph.php | 2 +- include/taxonomy.php | 2 +- include/text.php | 80 +- include/widgets.php | 100 +- include/zot.php | 28 +- index.php | 50 +- install/INSTALL.txt | 6 +- install/htconfig.sample.php | 20 +- mod/_well_known.php | 26 +- mod/achievements.php | 2 +- mod/admin.php | 56 +- mod/api.php | 6 +- mod/appman.php | 2 +- mod/apps.php | 2 +- mod/block.php | 6 +- mod/blocks.php | 16 +- mod/bookmarks.php | 4 +- mod/branchtopic.php | 2 +- mod/cal.php | 18 +- mod/channel.php | 78 +- mod/chanview.php | 14 +- mod/chat.php | 26 +- mod/chatsvc.php | 36 +- mod/cloud.php | 6 +- mod/common.php | 10 +- mod/connect.php | 34 +- mod/connections.php | 18 +- mod/connedit.php | 50 +- mod/cover_photo.php | 26 +- mod/dav.php | 6 +- mod/directory.php | 12 +- mod/dirsearch.php | 4 +- mod/display.php | 16 +- mod/dreport.php | 2 +- mod/editblock.php | 14 +- mod/editlayout.php | 16 +- mod/editpost.php | 12 +- mod/editwebpage.php | 16 +- mod/events.php | 18 +- mod/fbrowser.php | 18 +- mod/fhublocs.php | 6 +- mod/filer.php | 2 +- mod/filerm.php | 2 +- mod/filestorage.php | 10 +- mod/follow.php | 2 +- mod/fsuggest.php | 8 +- mod/group.php | 2 +- mod/hcard.php | 8 +- mod/help.php | 18 +- mod/home.php | 8 +- mod/hostxrd.php | 2 +- mod/id.php | 10 +- mod/impel.php | 2 +- mod/import.php | 8 +- mod/import_items.php | 2 +- mod/invite.php | 8 +- mod/item.php | 4 +- mod/layouts.php | 16 +- mod/like.php | 4 +- mod/locs.php | 4 +- mod/login.php | 2 +- mod/lostpass.php | 2 +- mod/magic.php | 4 +- mod/mail.php | 18 +- mod/manage.php | 4 +- mod/match.php | 10 +- mod/menu.php | 20 +- mod/message.php | 4 +- mod/mitem.php | 46 +- mod/mood.php | 4 +- mod/network.php | 22 +- mod/new_channel.php | 8 +- mod/notifications.php | 2 +- mod/oembed.php | 2 +- mod/oexchange.php | 2 +- mod/openid.php | 6 +- mod/opensearch.php | 2 +- mod/page.php | 20 +- mod/pconfig.php | 2 +- mod/photo.php | 4 +- mod/photos.php | 138 +- mod/ping.php | 8 +- mod/poke.php | 2 +- mod/prate.php | 4 +- mod/probe.php | 2 +- mod/profile.php | 18 +- mod/profile_photo.php | 26 +- mod/profiles.php | 22 +- mod/profperm.php | 4 +- mod/public.php | 12 +- mod/rate.php | 36 +- mod/ratings.php | 14 +- mod/rbmark.php | 4 +- mod/regmod.php | 4 +- mod/regver.php | 2 +- mod/removeaccount.php | 2 +- mod/removeme.php | 2 +- mod/rmagic.php | 4 +- mod/rpost.php | 6 +- mod/search.php | 20 +- mod/service_limits.php | 2 +- mod/settings.php | 38 +- mod/setup.php | 40 +- mod/share.php | 2 +- mod/sharedwithme.php | 2 +- mod/siteinfo.php | 2 +- mod/smilies.php | 2 +- mod/sources.php | 2 +- mod/subthread.php | 2 +- mod/suggest.php | 2 +- mod/tagger.php | 2 +- mod/tasks.php | 2 +- mod/thing.php | 4 +- mod/uexport.php | 2 +- mod/view.php | 2 +- mod/viewconnections.php | 18 +- mod/viewsrc.php | 2 +- mod/wall_attach.php | 6 +- mod/wall_upload.php | 2 +- mod/webpages.php | 22 +- mod/wfinger.php | 2 +- mod/xrd.php | 4 +- mod/zotfeed.php | 2 +- mod/zping.php | 2 +- util/README | 2 +- util/addons | 20 +- util/config | 2 +- util/extract.php | 6 +- util/fresh | 14 +- util/hstrings.php | 4108 ++++++++++++++++---------------- util/pconfig | 2 +- util/php2po.php | 6 +- util/po2php.php | 10 +- util/service_class | 4 +- util/strings.php | 4108 ++++++++++++++++---------------- util/typo.php | 6 +- version.inc | 2 +- view/ca/hstrings.php | 4150 ++++++++++++++++---------------- view/ca/strings.php | 4150 ++++++++++++++++---------------- view/cs/hstrings.php | 2018 ++++++++-------- view/cs/htconfig.tpl | 26 +- view/cs/strings.php | 2018 ++++++++-------- view/de/hstrings.php | 4364 +++++++++++++++++----------------- view/de/htconfig.tpl | 30 +- view/de/strings.php | 4152 ++++++++++++++++---------------- view/en-au/htconfig.tpl | 28 +- view/en-au/strings.php | 2 +- view/en-gb/htconfig.tpl | 28 +- view/en-gb/strings.php | 60 +- view/en/htconfig.tpl | 30 +- view/eo/hstrings.php | 3456 +++++++++++++-------------- view/eo/htconfig.tpl | 26 +- view/eo/strings.php | 3456 +++++++++++++-------------- view/es-es/hstrings.php | 4368 +++++++++++++++++----------------- view/es-es/strings.php | 4190 ++++++++++++++++---------------- view/fr/hstrings.php | 4350 +++++++++++++++++----------------- view/fr/htconfig.tpl | 26 +- view/fr/strings.php | 3698 ++++++++++++++--------------- view/it/hstrings.php | 4364 +++++++++++++++++----------------- view/it/htconfig.tpl | 26 +- view/it/strings.php | 4096 ++++++++++++++++---------------- view/nb-no/hstrings.php | 4356 +++++++++++++++++----------------- view/nb-no/htconfig.tpl | 26 +- view/nb-no/strings.php | 4082 ++++++++++++++++---------------- view/nl/hstrings.php | 4368 +++++++++++++++++----------------- view/nl/strings.php | 4190 ++++++++++++++++---------------- view/php/mod_import.php | 2 +- view/php/theme_init.php | 2 +- view/pt-br/hstrings.php | 4476 +++++++++++++++++------------------ view/pt-br/htconfig.tpl | 26 +- view/pt-br/strings.php | 4476 +++++++++++++++++------------------ view/ru/hstrings.php | 3604 ++++++++++++++-------------- view/ru/htconfig.tpl | 22 +- view/ru/strings.php | 3604 ++++++++++++++-------------- view/sv/hstrings.php | 3934 +++++++++++++++--------------- view/sv/htconfig.tpl | 22 +- view/sv/strings.php | 3934 +++++++++++++++--------------- view/theme/redbasic/php/config.php | 2 +- view/theme/redbasic/php/style.php | 4 +- 231 files changed, 52688 insertions(+), 52684 deletions(-) diff --git a/Zotlabs/Project/System.php b/Zotlabs/Project/System.php index ca57c50a3..f87f827bb 100644 --- a/Zotlabs/Project/System.php +++ b/Zotlabs/Project/System.php @@ -6,21 +6,21 @@ 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']; + if(is_array(\App::$config) && is_array(\App::$config['system']) && \App::$config['system']['platform_name']) + return \App::$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']) + if(is_array(\App::$config) && is_array(\App::$config['system']) && \App::$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']) + if(is_array(\App::$config) && is_array(\App::$config['system']) && \App::$config['system']['hide_version']) return ''; return DB_UPDATE_VERSION; } @@ -28,15 +28,15 @@ class System { 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']; + if(is_array(\App::$config) && is_array(\App::$config['system']) && \App::$config['system']['email_notify_icon_url']) + return \App::$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']; + if(is_array(\App::$config) && is_array(\App::$config['system']) && \App::$config['system']['site_icon_url']) + return \App::$config['system']['site_icon_url']; return z_root() . '/images/hz-32.png'; } diff --git a/Zotlabs/Storage/Browser.php b/Zotlabs/Storage/Browser.php index fde443e6f..720940953 100644 --- a/Zotlabs/Storage/Browser.php +++ b/Zotlabs/Storage/Browser.php @@ -243,7 +243,7 @@ class Browser extends DAV\Browser\Plugin { )); $a = get_app(); - $a->page['content'] = $html; + \App::$page['content'] = $html; load_pdl($a); $theme_info_file = "view/theme/" . current_theme() . "/php/theme.php"; diff --git a/Zotlabs/Storage/Directory.php b/Zotlabs/Storage/Directory.php index e38d76914..0347ce087 100644 --- a/Zotlabs/Storage/Directory.php +++ b/Zotlabs/Storage/Directory.php @@ -53,7 +53,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota { logger('directory ' . $ext_path, LOGGER_DATA); $this->ext_path = $ext_path; // remove "/cloud" from the beginning of the path - $modulename = get_app()->module; + $modulename = \App::$module; $this->red_path = ((strpos($ext_path, '/' . $modulename) === 0) ? substr($ext_path, strlen($modulename) + 1) : $ext_path); if (! $this->red_path) { $this->red_path = '/'; @@ -114,7 +114,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota { throw new DAV\Exception\Forbidden('Permission denied.'); } - $modulename = get_app()->module; + $modulename = \App::$module; if ($this->red_path === '/' && $name === $modulename) { return new Directory('/' . $modulename, $this->auth); } @@ -332,7 +332,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota { require_once('include/photos.php'); $args = array( 'resource_id' => $hash, 'album' => $album, 'os_path' => $f, 'filename' => $name, 'getimagesize' => $x, 'directory' => $direct); - $p = photo_upload($c[0],get_app()->get_observer(),$args); + $p = photo_upload($c[0],\App::get_observer(),$args); } } @@ -393,7 +393,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota { public function childExists($name) { // On /cloud we show a list of available channels. // @todo what happens if no channels are available? - $modulename = get_app()->module; + $modulename = \App::$module; if ($this->red_path === '/' && $name === $modulename) { //logger('We are at ' $modulename . ' show a channel list', LOGGER_DEBUG); return true; @@ -417,7 +417,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota { logger('GetDir: ' . $this->ext_path, LOGGER_DEBUG); $this->auth->log(); - $modulename = get_app()->module; + $modulename = \App::$module; $file = $this->ext_path; diff --git a/Zotlabs/Storage/File.php b/Zotlabs/Storage/File.php index 2a2a8b938..a4bf3f49d 100644 --- a/Zotlabs/Storage/File.php +++ b/Zotlabs/Storage/File.php @@ -173,7 +173,7 @@ class File extends DAV\Node implements DAV\IFile { if($is_photo) { require_once('include/photos.php'); $args = array( 'resource_id' => $this->data['hash'], 'album' => $album, 'os_path' => $f, 'filename' => $r[0]['filename'], 'getimagesize' => $gis, 'directory' => $direct ); - $p = photo_upload($c[0],get_app()->get_observer(),$args); + $p = photo_upload($c[0],\App::get_observer(),$args); } // update the folder's lastmodified timestamp diff --git a/Zotlabs/Web/Router.php b/Zotlabs/Web/Router.php index 900ac1e26..e2e920f39 100644 --- a/Zotlabs/Web/Router.php +++ b/Zotlabs/Web/Router.php @@ -9,9 +9,9 @@ class Router { /** * - * We have already parsed the server path into $a->argc and $a->argv + * We have already parsed the server path into App::$argc and App::$argv * - * $a->argv[0] is our module name. We will load the file mod/{$a->argv[0]}.php + * App::$argv[0] is our module name. We will load the file mod/{App::$argv[0]}.php * and use it for handling our URL request. * The module file contains a few functions that we call in various circumstances * and in the following order: @@ -25,7 +25,9 @@ class Router { * further processing. */ - if(strlen($a->module)) { + $module = \App::$module; + + if(strlen($module)) { /** * @@ -34,14 +36,14 @@ class Router { * */ - if(is_array($a->plugins) && in_array($a->module,$a->plugins) && file_exists("addon/{$a->module}/{$a->module}.php")) { - include_once("addon/{$a->module}/{$a->module}.php"); - if(function_exists($a->module . '_module')) - $a->module_loaded = true; + if(is_array(\App::$plugins) && in_array(\App::$module,\App::$plugins) && file_exists("addon/{$module}/{\$module}.php")) { + include_once("addon/{$module}/{$module}.php"); + if(function_exists($module . '_module')) + \App::$module_loaded = true; } - if((strpos($a->module,'admin') === 0) && (! is_site_admin())) { - $a->module_loaded = false; + if((strpos($module,'admin') === 0) && (! is_site_admin())) { + \App::$module_loaded = false; notice( t('Permission denied.') . EOL); goaway(z_root()); } @@ -51,17 +53,19 @@ class Router { * Otherwise, look for the standard program module in the 'mod' directory */ - if(! $a->module_loaded) { - if(file_exists("mod/site/{$a->module}.php")) { - include_once("mod/site/{$a->module}.php"); - $a->module_loaded = true; + if(! (\App::$module_loaded)) { + if(file_exists("mod/site/{$module}.php")) { + include_once("mod/site/{$module}.php"); + \App::$module_loaded = true; } - elseif(file_exists("mod/{$a->module}.php")) { - include_once("mod/{$a->module}.php"); - $a->module_loaded = true; + elseif(file_exists("mod/{$module}.php")) { + include_once("mod/{$module}.php"); + \App::$module_loaded = true; } + else logger("mod/{$module}.php not found."); } + /** * This provides a place for plugins to register module handlers which don't otherwise exist on the system. * If the plugin sets 'installed' to true we won't throw a 404 error for the specified module even if @@ -69,10 +73,10 @@ class Router { * The plugin should catch at least one of the module hooks for this URL. */ - $x = array('module' => $a->module, 'installed' => false); + $x = array('module' => $module, 'installed' => false); call_hooks('module_loaded', $x); if($x['installed']) - $a->module_loaded = true; + \App::$module_loaded = true; /** * The URL provided does not resolve to a valid module. @@ -85,14 +89,14 @@ class Router { * Otherwise we are going to emit a 404 not found. */ - if(! $a->module_loaded) { + if(! (\App::$module_loaded)) { // Stupid browser tried to pre-fetch our Javascript img template. Don't log the event or return anything - just quietly exit. if((x($_SERVER, 'QUERY_STRING')) && preg_match('/{[0-9]}/', $_SERVER['QUERY_STRING']) !== 0) { killme(); } - if((x($_SERVER, 'QUERY_STRING')) && ($_SERVER['QUERY_STRING'] === 'q=internal_error.html') && $a->config['system']['dreamhost_error_hack']) { + if((x($_SERVER, 'QUERY_STRING')) && ($_SERVER['QUERY_STRING'] === 'q=internal_error.html') && \App::$config['system']['dreamhost_error_hack']) { logger('index.php: dreamhost_error_hack invoked. Original URI =' . $_SERVER['REQUEST_URI']); goaway(z_root() . $_SERVER['REQUEST_URI']); } @@ -100,13 +104,13 @@ class Router { logger('index.php: page not found: ' . $_SERVER['REQUEST_URI'] . ' ADDRESS: ' . $_SERVER['REMOTE_ADDR'] . ' QUERY: ' . $_SERVER['QUERY_STRING'], LOGGER_DEBUG); header($_SERVER['SERVER_PROTOCOL'] . ' 404 ' . t('Not Found')); $tpl = get_markup_template('404.tpl'); - $a->page['content'] = replace_macros($tpl, array( + \App::$page['content'] = replace_macros($tpl, array( '$message' => t('Page not found.') )); // pretend this is a module so it will initialise the theme - $a->module = '404'; - $a->module_loaded = true; + \App::$module = '404'; + \App::$module_loaded = true; } } } @@ -118,8 +122,8 @@ class Router { * Call module functions */ - if($a->module_loaded) { - $a->page['page_title'] = $a->module; + if(\App::$module_loaded) { + \App::$page['page_title'] = \App::$module; $placeholder = ''; /** @@ -129,11 +133,11 @@ class Router { * to over-ride them. */ - if(function_exists($a->module . '_init')) { + if(function_exists(\App::$module . '_init')) { $arr = array('init' => true, 'replace' => false); - call_hooks($a->module . '_mod_init', $arr); + call_hooks(\App::$module . '_mod_init', $arr); if(! $arr['replace']) { - $func = $a->module . '_init'; + $func = \App::$module . '_init'; $func($a); } } @@ -167,32 +171,32 @@ class Router { $func = str_replace('-', '_', current_theme()) . '_init'; $func($a); } - elseif (x($a->theme_info, 'extends') && file_exists('view/theme/' . $a->theme_info['extends'] . '/php/theme.php')) { - require_once('view/theme/' . $a->theme_info['extends'] . '/php/theme.php'); - if(function_exists(str_replace('-', '_', $a->theme_info['extends']) . '_init')) { - $func = str_replace('-', '_', $a->theme_info['extends']) . '_init'; + elseif (x(\App::$theme_info, 'extends') && file_exists('view/theme/' . \App::$theme_info['extends'] . '/php/theme.php')) { + require_once('view/theme/' . \App::$theme_info['extends'] . '/php/theme.php'); + if(function_exists(str_replace('-', '_', \App::$theme_info['extends']) . '_init')) { + $func = str_replace('-', '_', \App::$theme_info['extends']) . '_init'; $func($a); } } - if(($_SERVER['REQUEST_METHOD'] === 'POST') && (! $a->error) - && (function_exists($a->module . '_post')) + if(($_SERVER['REQUEST_METHOD'] === 'POST') && (! \App::$error) + && (function_exists(\App::$module . '_post')) && (! x($_POST, 'auth-params'))) { - call_hooks($a->module . '_mod_post', $_POST); - $func = $a->module . '_post'; + call_hooks(\App::$module . '_mod_post', $_POST); + $func = \App::$module . '_post'; $func($a); } - if((! $a->error) && (function_exists($a->module . '_content'))) { - $arr = array('content' => $a->page['content'], 'replace' => false); - call_hooks($a->module . '_mod_content', $arr); - $a->page['content'] = $arr['content']; + if((! \App::$error) && (function_exists(\App::$module . '_content'))) { + $arr = array('content' => \App::$page['content'], 'replace' => false); + call_hooks(\App::$module . '_mod_content', $arr); + \App::$page['content'] = $arr['content']; if(! $arr['replace']) { - $func = $a->module . '_content'; + $func = \App::$module . '_content'; $arr = array('content' => $func($a)); } - call_hooks($a->module . '_mod_aftercontent', $arr); - $a->page['content'] .= $arr['content']; + call_hooks(\App::$module . '_mod_aftercontent', $arr); + \App::$page['content'] .= $arr['content']; } } } diff --git a/Zotlabs/Zot/Auth.php b/Zotlabs/Zot/Auth.php index fed253923..f764172fa 100644 --- a/Zotlabs/Zot/Auth.php +++ b/Zotlabs/Zot/Auth.php @@ -132,7 +132,7 @@ class Auth { // tell them to logout if they're logged in locally as anything but the target remote account // in which case just shut up because they don't need to be doing this at all. - if (get_app()->channel['channel_hash'] == $hubloc['xchan_hash']) { + if (\App::$channel['channel_hash'] == $hubloc['xchan_hash']) { return true; } else { @@ -242,9 +242,9 @@ class Auth { $arr = array('xchan' => $hubloc, 'url' => $this->desturl, 'session' => $_SESSION); call_hooks('magic_auth_success',$arr); - get_app()->set_observer($hubloc); + \App::set_observer($hubloc); require_once('include/security.php'); - get_app()->set_groups(init_groups_visitor($_SESSION['visitor_id'])); + \App::set_groups(init_groups_visitor($_SESSION['visitor_id'])); info(sprintf( t('Welcome %s. Remote authentication successful.'),$hubloc['xchan_name'])); logger('mod_zot: auth success from ' . $hubloc['xchan_addr']); $this->success = true; @@ -341,5 +341,5 @@ class Auth { * Service_class can be used by cooperating sites to provide different access rights based on account rights and subscription plans. It is * a string whose contents are not defined by protocol. Example: "basic" or "gold". * - * @param[in,out] App &$a + * @param[in,out] \App &$a */ diff --git a/boot.php b/boot.php index bf30031bc..a96ff2660 100755 --- a/boot.php +++ b/boot.php @@ -92,7 +92,7 @@ $DIRECTORY_FALLBACK_SERVERS = array( * * Image storage quality. Lower numbers save space at cost of image detail. * For ease of upgrade, please do not change here. Change jpeg quality with - * $a->config['system']['jpeg_quality'] = n; + * App::$config['system']['jpeg_quality'] = n; * in .htconfig.php, where n is netween 1 and 100, and with very poor results * below about 50 * @@ -100,7 +100,7 @@ $DIRECTORY_FALLBACK_SERVERS = array( define ( 'JPEG_QUALITY', 100 ); /** - * $a->config['system']['png_quality'] from 0 (uncompressed) to 9 + * App::$config['system']['png_quality'] from 0 (uncompressed) to 9 */ define ( 'PNG_QUALITY', 8 ); @@ -135,7 +135,7 @@ define ( 'STORAGE_DEFAULT_PERMISSIONS', 0770 ); * this length (on the longest side, the other side will be scaled appropriately). * Modify this value using * - * $a->config['system']['max_image_length'] = n; + * App::$config['system']['max_image_length'] = n; * * in .htconfig.php * @@ -1200,7 +1200,7 @@ function system_unavailable() { function clean_urls() { global $a; - // if($a->config['system']['clean_urls']) + // if(App::$config['system']['clean_urls']) return true; // return false; } @@ -1224,7 +1224,7 @@ function z_path() { */ function z_root() { global $a; - return $a->get_baseurl(); + return App::get_baseurl(); } /** @@ -1295,7 +1295,7 @@ function check_config(&$a) { // This will actually set the url to the one stored in .htconfig, and ignore what // we're passing - unless we are installing and it has never been set. - $a->set_baseurl(z_root()); + App::set_baseurl(z_root()); // Make sure each site has a system channel. This is now created on install // so we just need to keep this around a couple of weeks until the hubs that @@ -1356,7 +1356,7 @@ function check_config(&$a) { $email_tpl = get_intltext_template("update_fail_eml.tpl"); $email_msg = replace_macros($email_tpl, array( - '$sitename' => $a->config['system']['sitename'], + '$sitename' => App::$config['system']['sitename'], '$siteurl' => z_root(), '$update' => $x, '$error' => sprintf( t('Update %s failed. See error logs.'), $x) @@ -1364,7 +1364,7 @@ function check_config(&$a) { $subject = email_header_encode(sprintf(t('Update Error at %s'), z_root())); - mail($a->config['system']['admin_email'], $subject, $email_msg, + mail(App::$config['system']['admin_email'], $subject, $email_msg, 'From: Administrator' . '@' . $_SERVER['SERVER_NAME'] . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit' ); @@ -1384,7 +1384,7 @@ function check_config(&$a) { * * Synchronise plugins: * - * $a->config['system']['addon'] contains a comma-separated list of names + * App::$config['system']['addon'] contains a comma-separated list of names * of plugins/addons which are used on this system. * Go through the database list of already installed addons, and if we have * an entry, but it isn't in the config list, call the unload procedure @@ -1406,7 +1406,7 @@ function check_config(&$a) { if($plugins) $plugins_arr = explode(',', str_replace(' ', '', $plugins)); - $a->plugins = $plugins_arr; + App::$plugins = $plugins_arr; $installed_arr = array(); @@ -1520,7 +1520,7 @@ function fix_system_urls($oldurl, $newurl) { // wrapper for adding a login box. If $register == true provide a registration -// link. This will most always depend on the value of $a->config['system']['register_policy']. +// link. This will most always depend on the value of App::$config['system']['register_policy']. // returns the complete html for inserting into the page function login($register = false, $form_id = 'main-login', $hiddens=false) { @@ -1537,15 +1537,15 @@ function login($register = false, $form_id = 'main-login', $hiddens=false) { 'link' => (($register) ? $reglink : 'pubsites') ); - $dest_url = z_root() . '/' . $a->query_string; + $dest_url = z_root() . '/' . App::$query_string; if(local_channel()) { $tpl = get_markup_template("logout.tpl"); } else { $tpl = get_markup_template("login.tpl"); - if(strlen($a->query_string)) - $_SESSION['login_return_url'] = $a->query_string; + if(strlen(App::$query_string)) + $_SESSION['login_return_url'] = App::$query_string; } $o .= replace_macros($tpl,array( @@ -1597,8 +1597,8 @@ function get_account_id() { if(intval($_SESSION['account_id'])) return intval($_SESSION['account_id']); - if(get_app()->account) - return intval(get_app()->account['account_id']); + if(App::$account) + return intval(App::$account['account_id']); return false; } @@ -1681,7 +1681,7 @@ function notice($s) { if(in_array($s,$_SESSION['sysmsg'])) return; - if($a->interactive) { + if(App::$interactive) { $_SESSION['sysmsg'][] = $s; } @@ -1697,7 +1697,7 @@ function notice($s) { function info($s) { $a = get_app(); if(! x($_SESSION, 'sysmsg_info')) $_SESSION['sysmsg_info'] = array(); - if($a->interactive) + if(App::$interactive) $_SESSION['sysmsg_info'][] = $s; } @@ -1755,7 +1755,7 @@ function proc_run($cmd){ return; if(count($args) && $args[0] === 'php') - $args[0] = ((x($a->config,'system')) && (x($a->config['system'],'php_path')) && (strlen($a->config['system']['php_path'])) ? $a->config['system']['php_path'] : 'php'); + $args[0] = ((x(App::$config,'system')) && (x(App::$config['system'],'php_path')) && (strlen(App::$config['system']['php_path'])) ? App::$config['system']['php_path'] : 'php'); for($x = 0; $x < count($args); $x++) $args[$x] = escapeshellarg($args[$x]); @@ -1793,29 +1793,29 @@ function current_theme(){ // Find the theme that belongs to the channel whose stuff we are looking at - if($a->profile_uid && $a->profile_uid != local_channel()) { + if(App::$profile_uid && App::$profile_uid != local_channel()) { $r = q("select channel_theme from channel where channel_id = %d limit 1", - intval($a->profile_uid) + intval(App::$profile_uid) ); if($r) $page_theme = $r[0]['channel_theme']; } - if(array_key_exists('theme', $a->layout) && $a->layout['theme']) - $page_theme = $a->layout['theme']; + if(array_key_exists('theme', App::$layout) && App::$layout['theme']) + $page_theme = App::$layout['theme']; // Allow folks to over-rule channel themes and always use their own on their own site. // The default is for channel themes to take precedence over your own on pages belonging // to that channel. - if($page_theme && local_channel() && local_channel() != $a->profile_url) { + if($page_theme && local_channel() && local_channel() != App::$profile_url) { if(get_pconfig(local_channel(),'system','always_my_theme')) $page_theme = null; } - $is_mobile = $a->is_mobile || $a->is_tablet; + $is_mobile = App::$is_mobile || App::$is_tablet; - $standard_system_theme = ((isset($a->config['system']['theme'])) ? $a->config['system']['theme'] : ''); + $standard_system_theme = ((isset(App::$config['system']['theme'])) ? App::$config['system']['theme'] : ''); $standard_theme_name = ((isset($_SESSION) && x($_SESSION,'theme')) ? $_SESSION['theme'] : $standard_system_theme); if($is_mobile) { @@ -1824,7 +1824,7 @@ function current_theme(){ $theme_name = $standard_theme_name; } else { - $system_theme = ((isset($a->config['system']['mobile_theme'])) ? $a->config['system']['mobile_theme'] : ''); + $system_theme = ((isset(App::$config['system']['mobile_theme'])) ? App::$config['system']['mobile_theme'] : ''); $theme_name = ((isset($_SESSION) && x($_SESSION,'mobile_theme')) ? $_SESSION['mobile_theme'] : $system_theme); if($theme_name === '' || $theme_name === '---' ) { @@ -1875,8 +1875,8 @@ function current_theme_url($installing = false) { $t = current_theme(); $opts = ''; - $opts = (($a->profile_uid) ? '?f=&puid=' . $a->profile_uid : ''); - $opts .= ((x($a->layout,'schema')) ? '&schema=' . $a->layout['schema'] : ''); + $opts = ((App::$profile_uid) ? '?f=&puid=' . App::$profile_uid : ''); + $opts .= ((x(App::$layout,'schema')) ? '&schema=' . App::$layout['schema'] : ''); if(file_exists('view/theme/' . $t . '/php/style.php')) return('view/theme/' . $t . '/php/style.pcss' . $opts); @@ -1897,8 +1897,8 @@ function is_site_admin() { return false; if((intval($_SESSION['authenticated'])) - && (is_array($a->account)) - && ($a->account['account_roles'] & ACCOUNT_ROLE_ADMIN)) + && (is_array(App::$account)) + && (App::$account['account_roles'] & ACCOUNT_ROLE_ADMIN)) return true; return false; @@ -1914,8 +1914,8 @@ function is_site_admin() { function is_developer() { $a = get_app(); if((intval($_SESSION['authenticated'])) - && (is_array($a->account)) - && ($a->account['account_roles'] & ACCOUNT_ROLE_DEVELOPER)) + && (is_array(App::$account)) + && (App::$account['account_roles'] & ACCOUNT_ROLE_DEVELOPER)) return true; return false; @@ -1927,7 +1927,7 @@ function load_contact_links($uid) { $ret = array(); - if(! $uid || x($a->contacts,'empty')) + if(! $uid || x(App::$contacts,'empty')) return; // logger('load_contact_links'); @@ -1943,7 +1943,7 @@ function load_contact_links($uid) { else $ret['empty'] = true; - $a->contacts = $ret; + App::$contacts = $ret; } @@ -1980,12 +1980,12 @@ function build_querystring($params, $name = null) { // much better way of dealing with c-style args function argc() { - return get_app()->argc; + return App::$argc; } function argv($x) { - if(array_key_exists($x,get_app()->argv)) - return get_app()->argv[$x]; + if(array_key_exists($x,App::$argv)) + return App::$argv[$x]; return ''; } @@ -2000,7 +2000,7 @@ function dba_timer() { * @return string Empty if no observer, otherwise xchan_hash from observer */ function get_observer_hash() { - $observer = get_app()->get_observer(); + $observer = App::get_observer(); if(is_array($observer)) return $observer['xchan_hash']; @@ -2039,7 +2039,7 @@ function curPageURL() { */ function get_custom_nav(&$a, $navname) { if (! $navname) - return $a->page['nav']; + return App::$page['nav']; // load custom nav menu by name here } @@ -2054,13 +2054,13 @@ function get_custom_nav(&$a, $navname) { function load_pdl(&$a) { require_once('include/comanche.php'); - if (! count($a->layout)) { + if (! count(App::$layout)) { - $arr = array('module' => $a->module, 'layout' => ''); + $arr = array('module' => App::$module, 'layout' => ''); call_hooks('load_pdl',$arr); $layout = $arr['layout']; - $n = 'mod_' . $a->module . '.pdl' ; + $n = 'mod_' . App::$module . '.pdl' ; $u = comanche_get_channel_id(); if($u) $s = get_pconfig($u, 'system', $n); @@ -2071,7 +2071,7 @@ function load_pdl(&$a) { $s = @file_get_contents($p); if($s) { comanche_parser($a, $s); - $a->pdl = $s; + App::$pdl = $s; } } @@ -2081,8 +2081,8 @@ function load_pdl(&$a) { function exec_pdl(&$a) { require_once('include/comanche.php'); - if($a->pdl) { - comanche_parser($a, $a->pdl,1); + if(App::$pdl) { + comanche_parser($a, App::$pdl,1); } } @@ -2098,64 +2098,64 @@ function construct_page(&$a) { exec_pdl($a); - $comanche = ((count($a->layout)) ? true : false); + $comanche = ((count(App::$layout)) ? true : false); require_once(theme_include('theme_init.php')); $installing = false; - if ($a->module == 'setup') { + if (App::$module == 'setup') { $installing = true; } else { nav($a); } if ($comanche) { - if ($a->layout['nav']) { - $a->page['nav'] = get_custom_nav($a, $a->layout['nav']); + if (App::$layout['nav']) { + App::$page['nav'] = get_custom_nav($a, App::$layout['nav']); } } if (($p = theme_include(current_theme() . '.js')) != '') head_add_js($p); - if (($p = theme_include('mod_' . $a->module . '.php')) != '') + if (($p = theme_include('mod_' . App::$module . '.php')) != '') require_once($p); require_once('include/js_strings.php'); - if (x($a->page, 'template_style')) - head_add_css($a->page['template_style'] . '.css'); + if (x(App::$page, 'template_style')) + head_add_css(App::$page['template_style'] . '.css'); else - head_add_css(((x($a->page, 'template')) ? $a->page['template'] : 'default' ) . '.css'); + head_add_css(((x(App::$page, 'template')) ? App::$page['template'] : 'default' ) . '.css'); - head_add_css('mod_' . $a->module . '.css'); + head_add_css('mod_' . App::$module . '.css'); head_add_css(current_theme_url($installing)); - head_add_js('mod_' . $a->module . '.js'); + head_add_js('mod_' . App::$module . '.js'); - $a->build_pagehead(); + App::build_pagehead(); - if($a->page['pdl_content']) { - $a->page['content'] = comanche_region($a,$a->page['content']); + if(App::$page['pdl_content']) { + App::$page['content'] = comanche_region($a,App::$page['content']); } // Let's say we have a comanche declaration '[region=nav][/region][region=content]$nav $content[/region]'. // The text 'region=' identifies a section of the layout by that name. So what we want to do here is leave - // $a->page['nav'] empty and put the default content from $a->page['nav'] and $a->page['section'] - // into a new region called $a->data['content']. It is presumed that the chosen layout file for this comanche page + // App::$page['nav'] empty and put the default content from App::$page['nav'] and App::$page['section'] + // into a new region called App::$data['content']. It is presumed that the chosen layout file for this comanche page // has a '' element instead of a '
'. // This way the Comanche layout can include any existing content, alter the layout by adding stuff around it or changing the // layout completely with a new layout definition, or replace/remove existing content. if($comanche) { - $arr = array('module' => $a->module, 'layout' => $a->layout); + $arr = array('module' => App::$module, 'layout' => App::$layout); call_hooks('construct_page', $arr); - $a->layout = $arr['layout']; + App::$layout = $arr['layout']; - foreach($a->layout as $k => $v) { + foreach(App::$layout as $k => $v) { if((strpos($k, 'region_') === 0) && strlen($v)) { if(strpos($v, '$region_') !== false) { $v = preg_replace_callback('/\$region_([a-zA-Z0-9]+)/ism', 'comanche_replace_region', $v); @@ -2163,21 +2163,21 @@ function construct_page(&$a) { // And a couple of convenience macros if(strpos($v, '$htmlhead') !== false) { - $v = str_replace('$htmlhead', $a->page['htmlhead'], $v); + $v = str_replace('$htmlhead', App::$page['htmlhead'], $v); } if(strpos($v, '$nav') !== false) { - $v = str_replace('$nav', $a->page['nav'], $v); + $v = str_replace('$nav', App::$page['nav'], $v); } if(strpos($v, '$content') !== false) { - $v = str_replace('$content', $a->page['content'], $v); + $v = str_replace('$content', App::$page['content'], $v); } - $a->page[substr($k, 7)] = $v; + App::$page[substr($k, 7)] = $v; } } } - if($a->is_mobile || $a->is_tablet) { + if(App::$is_mobile || App::$is_tablet) { if(isset($_SESSION['show_mobile']) && !$_SESSION['show_mobile']) { $link = z_root() . '/toggle_mobile?f=&address=' . curPageURL(); } @@ -2185,39 +2185,39 @@ function construct_page(&$a) { $link = z_root() . '/toggle_mobile?f=&off=1&address=' . curPageURL(); } if ((isset($_SESSION) && $_SESSION['mobile_theme'] !='' && $_SESSION['mobile_theme'] !='---' ) || - (isset($a->config['system']['mobile_theme']) && !isset($_SESSION['mobile_theme']))) { - $a->page['footer'] .= replace_macros(get_markup_template("toggle_mobile_footer.tpl"), array( + (isset(App::$config['system']['mobile_theme']) && !isset($_SESSION['mobile_theme']))) { + App::$page['footer'] .= replace_macros(get_markup_template("toggle_mobile_footer.tpl"), array( '$toggle_link' => $link, '$toggle_text' => t('toggle mobile') )); } } - $page = $a->page; - $profile = $a->profile; + $page = App::$page; + $profile = App::$profile; header("Content-type: text/html; charset=utf-8"); // security headers - see https://securityheaders.io - if($a->get_scheme() === 'https' && $a->config['system']['transport_security_header']) + if(App::get_scheme() === 'https' && App::$config['system']['transport_security_header']) header("Strict-Transport-Security: max-age=31536000"); - if($a->config['system']['content_security_policy']) + if(App::$config['system']['content_security_policy']) header("Content-Security-Policy: script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'"); - if($a->config['system']['x_security_headers']) { + if(App::$config['system']['x_security_headers']) { header("X-Frame-Options: SAMEORIGIN"); header("X-Xss-Protection: 1; mode=block;"); header("X-Content-Type-Options: nosniff"); } - if($a->config['system']['public_key_pins']) { - header("Public-Key-Pins: " . $a->config['system']['public_key_pins']); + if(App::$config['system']['public_key_pins']) { + header("Public-Key-Pins: " . App::$config['system']['public_key_pins']); } require_once(theme_include( - ((x($a->page, 'template')) ? $a->page['template'] : 'default' ) . '.php' ) + ((x(App::$page, 'template')) ? App::$page['template'] : 'default' ) . '.php' ) ); } @@ -2238,7 +2238,7 @@ function appdirpath() { function head_set_icon($icon) { global $a; - $a->data['pageicon'] = $icon; + App::$data['pageicon'] = $icon; // logger('head_set_icon: ' . $icon); } @@ -2250,7 +2250,7 @@ function head_set_icon($icon) { function head_get_icon() { global $a; - $icon = $a->data['pageicon']; + $icon = App::$data['pageicon']; if(! strpos($icon, '://')) $icon = z_root() . $icon; @@ -2339,14 +2339,14 @@ function cert_bad_email() { $email_tpl = get_intltext_template("cert_bad_eml.tpl"); $email_msg = replace_macros($email_tpl, array( - '$sitename' => $a->config['system']['sitename'], + '$sitename' => App::$config['system']['sitename'], '$siteurl' => z_root(), '$error' => t('Website SSL certificate is not valid. Please correct.') )); - $subject = email_header_encode(sprintf(t('[hubzilla] Website SSL error for %s'), $a->get_hostname())); - mail($a->config['system']['admin_email'], $subject, $email_msg, - 'From: Administrator' . '@' . $a->get_hostname() . "\n" + $subject = email_header_encode(sprintf(t('[hubzilla] Website SSL error for %s'), App::get_hostname())); + mail(App::$config['system']['admin_email'], $subject, $email_msg, + 'From: Administrator' . '@' . App::get_hostname() . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit' ); } @@ -2379,15 +2379,15 @@ function check_cron_broken() { $email_tpl = get_intltext_template("cron_bad_eml.tpl"); $email_msg = replace_macros($email_tpl, array( - '$sitename' => $a->config['system']['sitename'], + '$sitename' => App::$config['system']['sitename'], '$siteurl' => z_root(), '$error' => t('Cron/Scheduled tasks not running.'), '$lastdate' => (($d)? $d : t('never')) )); - $subject = email_header_encode(sprintf(t('[hubzilla] Cron tasks not running on %s'), $a->get_hostname())); - mail($a->config['system']['admin_email'], $subject, $email_msg, - 'From: Administrator' . '@' . $a->get_hostname() . "\n" + $subject = email_header_encode(sprintf(t('[hubzilla] Cron tasks not running on %s'), App::get_hostname())); + mail(App::$config['system']['admin_email'], $subject, $email_msg, + 'From: Administrator' . '@' . App::get_hostname() . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit' ); set_config('system','lastpollcheck',datetime_convert()); diff --git a/doc/DerivedTheme1.md b/doc/DerivedTheme1.md index 3db86b6e7..b120c628c 100644 --- a/doc/DerivedTheme1.md +++ b/doc/DerivedTheme1.md @@ -38,7 +38,7 @@ Inside it, put the following information - edit as needed function mytheme_init(&$a) { - $a->theme_info['extends'] = 'redbasic'; + App::$theme_info['extends'] = 'redbasic'; } @@ -79,7 +79,7 @@ If you want to use the redbasic schemas for your derived theme, you have to do a Do everything as above, but don't create view/theme/mytheme/php/style.php, but copy instead view/theme/redbasic/php/style.php to view/theme/mytheme/php/style.php. Modify that file and remove (or comment out) these two lines: - if(local_channel() && $a->channel && $a->channel['channel_theme'] != 'redbasic') + if(local_channel() && App::$channel && App::$channel['channel_theme'] != 'redbasic') set_pconfig(local_channel(), 'redbasic', 'schema', '---'); Also add this line at the bottom: diff --git a/doc/Primary-Directory.md b/doc/Primary-Directory.md index 37b0c0431..92460c346 100644 --- a/doc/Primary-Directory.md +++ b/doc/Primary-Directory.md @@ -12,7 +12,7 @@ There are certain scenarios where you might want your own directory-server that * On the hub that will be the Directory Server, open the .htconfig.php file and set: - `$a->config['system']['directory_mode'] = DIRECTORY_MODE_PRIMARY;` + `App::$config['system']['directory_mode'] = DIRECTORY_MODE_PRIMARY;` By default it should already be set as **DIRECTORY_MODE_NORMAL**, so just edit that line to say **DIRECTORY_MODE_PRIMARY** diff --git a/doc/dev-function-overview.md b/doc/dev-function-overview.md index e228268dd..1ef80d343 100644 --- a/doc/dev-function-overview.md +++ b/doc/dev-function-overview.md @@ -21,7 +21,7 @@ Returns the global app structure ($a). * App::get_observer() -(App:: is usually assigned to the global $a), so $a->get_observer() or get_app()->get_observer() - returns an xchan structure representing the current viewer if authenticated (locally or remotely). +(App:: is usually assigned to the global $a), so App::get_observer() or App::get_observer() - returns an xchan structure representing the current viewer if authenticated (locally or remotely). * get_config($family,$key), get_pconfig($uid,$family,$key) diff --git a/doc/dev_beginner.bb b/doc/dev_beginner.bb index 729625713..4cf1ca591 100644 --- a/doc/dev_beginner.bb +++ b/doc/dev_beginner.bb @@ -242,7 +242,7 @@ Befor you register a first user switch off the registration mails. Open /var/www/.htconfig.php and make sure "0" is set in this line [code] -$a->config['system']['verify_email'] = 0; +App::$config['system']['verify_email'] = 0; [/code] You should be able to change the file as "yourself" (instead of using root or www-data). diff --git a/doc/directories.bb b/doc/directories.bb index d81dd84c5..60a0b624d 100644 --- a/doc/directories.bb +++ b/doc/directories.bb @@ -30,7 +30,7 @@ To configure this, please look in your .htconfig.php file for the following text // DIRECTORY_MODE_PRIMARY = main directory server // DIRECTORY_MODE_STANDALONE = "off the grid" or private directory services -$a->config['system']['directory_mode'] = DIRECTORY_MODE_STANDALONE; +App::$config['system']['directory_mode'] = DIRECTORY_MODE_STANDALONE; [/code] diff --git a/doc/faq_developers.bb b/doc/faq_developers.bb index 603cf238f..5da2c19ff 100644 --- a/doc/faq_developers.bb +++ b/doc/faq_developers.bb @@ -8,22 +8,22 @@ $a is a class defined in boot.php and passed all around $Projectname as a global We don't ever create more than one instance and always modify the elements of the single instance. The mechanics of this are somewhat tricky. If you have a function that is passed $a and needs to modify $a you need to declare it as a reference with '&' e.g. -[code]function foo(&$a) { $a->something = 'x'; // whatever }; +[code]function foo(&$a) { App::$something = 'x'; // whatever }; *or* access it within your function as a global variable via get_app() function foo() { $a = get_app(); - $a->something = 'x'; + App::$something = 'x'; } -function foo($a) { $a->something = 'x'; }; +function foo($a) { App::$something = 'x'; }; will *not* change the global app state. function foo() { - get_app()->something = 'x'; + App::$something = 'x'; } [/code] diff --git a/doc/hook/module_mod_aftercontent.bb b/doc/hook/module_mod_aftercontent.bb index 5d48435b8..04e3c8d88 100644 --- a/doc/hook/module_mod_aftercontent.bb +++ b/doc/hook/module_mod_aftercontent.bb @@ -8,5 +8,5 @@ The hook data for this call consists of an array This element contains the HTML content which was prepared for this page by calling the module_content() function. It is invoked after the content has been created. It does not contain the result of AJAX or asynchronous page load calls. - The current module may be determined by lookin at $a->module + The current module may be determined by lookin at App::$module diff --git a/doc/hook/module_mod_content.bb b/doc/hook/module_mod_content.bb index 39f5743b1..eef5b7ba5 100644 --- a/doc/hook/module_mod_content.bb +++ b/doc/hook/module_mod_content.bb @@ -6,5 +6,5 @@ The hook data for this call consists of an array This element contains the HTML content before calling the module_content() function. It is invoked before the content region has been populated. This may or may not be empty as there may be other processes or addons generating content prior to your hook handler is run. Be certain to preserve any current content. Typically anything you add here will be placed at the top of the content region of the page, but in any event prior to the main content region being generated. - The current module may be determined by lookin at $a->module + The current module may be determined by lookin at App::$module diff --git a/include/Contact.php b/include/Contact.php index 727d4b062..507c922d0 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -75,12 +75,12 @@ function vcard_from_xchan($xchan, $observer = null, $mode = '') { $a = get_app(); if(! $xchan) { - if($a->poi) { - $xchan = $a->poi; + if(App::$poi) { + $xchan = App::$poi; } - elseif(is_array($a->profile) && $a->profile['channel_hash']) { + elseif(is_array(App::$profile) && App::$profile['channel_hash']) { $r = q("select * from xchan where xchan_hash = '%s' limit 1", - dbesc($a->profile['channel_hash']) + dbesc(App::$profile['channel_hash']) ); if($r) $xchan = $r[0]; @@ -102,7 +102,7 @@ function vcard_from_xchan($xchan, $observer = null, $mode = '') { } if(array_key_exists('channel_id',$xchan)) - $a->profile_uid = $xchan['channel_id']; + App::$profile_uid = $xchan['channel_id']; $url = (($observer) ? z_root() . '/magic?f=&dest=' . $xchan['xchan_url'] . '&addr=' . $xchan['xchan_addr'] @@ -111,7 +111,7 @@ function vcard_from_xchan($xchan, $observer = null, $mode = '') { return replace_macros(get_markup_template('xchan_vcard.tpl'),array( '$name' => $xchan['xchan_name'], - '$photo' => ((is_array($a->profile) && array_key_exists('photo',$a->profile)) ? $a->profile['photo'] : $xchan['xchan_photo_l']), + '$photo' => ((is_array(App::$profile) && array_key_exists('photo',App::$profile)) ? App::$profile['photo'] : $xchan['xchan_photo_l']), '$follow' => $xchan['xchan_addr'], '$link' => zid($xchan['xchan_url']), '$connect' => $connect, @@ -333,19 +333,19 @@ function channel_remove($channel_id, $local = true, $unset_session=false) { ); // if this was the default channel, set another one as default - if($a->account['account_default_channel'] == $channel_id) { + if(App::$account['account_default_channel'] == $channel_id) { $r = q("select channel_id from channel where channel_account_id = %d and channel_removed = 0 limit 1", - intval($a->account['account_id']), + intval(App::$account['account_id']), intval(PAGE_REMOVED)); if ($r) { $rr = q("update account set account_default_channel = %d where account_id = %d", intval($r[0]['channel_id']), - intval($a->account['account_id'])); + intval(App::$account['account_id'])); logger("Default channel deleted, changing default to channel_id " . $r[0]['channel_id']); } else { $rr = q("update account set account_default_channel = 0 where account_id = %d", - intval($a->account['account_id']) + intval(App::$account['account_id']) ); } } diff --git a/include/ConversationObject.php b/include/ConversationObject.php index 66f6cca0e..82f381b0c 100644 --- a/include/ConversationObject.php +++ b/include/ConversationObject.php @@ -48,7 +48,7 @@ class Conversation extends BaseObject { $a = $this->get_app(); - $this->observer = $a->get_observer(); + $this->observer = App::get_observer(); $ob_hash = (($this->observer) ? $this->observer['xchan_hash'] : ''); switch($mode) { @@ -57,7 +57,7 @@ class Conversation extends BaseObject { $this->writable = true; break; case 'channel': - $this->profile_owner = $a->profile['profile_uid']; + $this->profile_owner = App::$profile['profile_uid']; $this->writable = perm_is_allowed($this->profile_owner,$ob_hash,'post_comments'); break; case 'display': @@ -67,7 +67,7 @@ class Conversation extends BaseObject { $this->writable = perm_is_allowed($this->profile_owner,$ob_hash,'post_comments'); break; case 'page': - $this->profile_owner = $a->profile['uid']; + $this->profile_owner = App::$profile['uid']; $this->writable = perm_is_allowed($this->profile_owner,$ob_hash,'post_comments'); break; default: diff --git a/include/Import/import_diaspora.php b/include/Import/import_diaspora.php index a0f473b50..a94e73395 100644 --- a/include/Import/import_diaspora.php +++ b/include/Import/import_diaspora.php @@ -8,7 +8,7 @@ require_once('include/photo/photo_driver.php'); function import_diaspora($data) { $a = get_app(); - $account = $a->get_account(); + $account = App::get_account(); if(! $account) return false; diff --git a/include/ItemObject.php b/include/ItemObject.php index 623bf0676..9d5acd95f 100644 --- a/include/ItemObject.php +++ b/include/ItemObject.php @@ -714,7 +714,7 @@ class Item extends BaseObject { '$feature_encrypt' => ((feature_enabled($conv->get_profile_owner(),'content_encrypt')) ? true : false), '$encrypt' => t('Encrypt text'), '$cipher' => $conv->get_cipher(), - '$sourceapp' => get_app()->sourcename + '$sourceapp' => App::$sourcename )); diff --git a/include/account.php b/include/account.php index 4c828003e..c64197b49 100644 --- a/include/account.php +++ b/include/account.php @@ -248,7 +248,7 @@ function verify_email_address($arr) { $res = mail($arr['email'], email_header_encode(sprintf( t('Registration confirmation for %s'), get_config('system','sitename'))), $email_msg, - 'From: ' . 'Administrator' . '@' . get_app()->get_hostname() . "\n" + 'From: ' . 'Administrator' . '@' . App::get_hostname() . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit' ); @@ -314,7 +314,7 @@ function send_reg_approval_email($arr) { $res = mail($admin['email'], sprintf( t('Registration request at %s'), get_config('system','sitename')), $email_msg, - 'From: ' . t('Administrator') . '@' . get_app()->get_hostname() . "\n" + 'From: ' . t('Administrator') . '@' . App::get_hostname() . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit' ); @@ -341,7 +341,7 @@ function send_register_success_email($email,$password) { $res = mail($email, sprintf( t('Registration details for %s'), get_config('system','sitename')), $email_msg, - 'From: ' . t('Administrator') . '@' . get_app()->get_hostname() . "\n" + 'From: ' . t('Administrator') . '@' . App::get_hostname() . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit' ); @@ -655,7 +655,7 @@ function account_service_class_allows($aid, $property, $usage = false) { function service_class_fetch($uid, $property) { $a = get_app(); if($uid == local_channel()) { - $service_class = $a->account['account_service_class']; + $service_class = App::$account['account_service_class']; } else { $r = q("select account_service_class as service_class diff --git a/include/acl_selectors.php b/include/acl_selectors.php index 3c8f34321..92f9436a2 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -23,7 +23,7 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) { // e.g. 'network_pre_group_deny', 'profile_pre_group_allow' - call_hooks($a->module . '_pre_' . $selname, $arr); + call_hooks(App::$module . '_pre_' . $selname, $arr); if($r) { foreach($r as $rr) { @@ -39,7 +39,7 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) { } $o .= "\r\n"; - call_hooks($a->module . '_post_' . $selname, $o); + call_hooks(App::$module . '_post_' . $selname, $o); return $o; @@ -127,7 +127,7 @@ function contact_selector($selname, $selclass, $preselected = false, $options) { // e.g. 'network_pre_contact_deny', 'profile_pre_contact_allow' - call_hooks($a->module . '_pre_' . $selname, $arr); + call_hooks(App::$module . '_pre_' . $selname, $arr); if(count($r)) { foreach($r as $rr) { @@ -145,7 +145,7 @@ function contact_selector($selname, $selclass, $preselected = false, $options) { $o .= "\r\n"; - call_hooks($a->module . '_post_' . $selname, $o); + call_hooks(App::$module . '_post_' . $selname, $o); return $o; }*/ @@ -182,7 +182,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p // e.g. 'network_pre_contact_deny', 'profile_pre_contact_allow' - call_hooks($a->module . '_pre_' . $selname, $arr); + call_hooks(App::$module . '_pre_' . $selname, $arr); if($r) { foreach($r as $rr) { @@ -200,7 +200,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p $o .= "\r\n"; - call_hooks($a->module . '_post_' . $selname, $o); + call_hooks(App::$module . '_post_' . $selname, $o); return $o; } diff --git a/include/activities.php b/include/activities.php index df43f1f6f..9ba191391 100644 --- a/include/activities.php +++ b/include/activities.php @@ -11,7 +11,7 @@ function profile_activity($changed, $value) { require_once('include/items.php'); - $self = $a->get_channel(); + $self = App::get_channel(); if(! count($self)) return; diff --git a/include/api.php b/include/api.php index 73fd58d4d..41837ad88 100644 --- a/include/api.php +++ b/include/api.php @@ -34,7 +34,7 @@ require_once('include/api_auth.php'); function api_user() { $aid = get_account_id(); - $channel = get_app()->get_channel(); + $channel = App::get_channel(); if(($aid) && (x($_REQUEST,'channel'))) { @@ -79,7 +79,7 @@ require_once('include/api_auth.php'); $type="json"; foreach ($API as $p=>$info){ - if (strpos($a->query_string, $p)===0){ + if (strpos(App::$query_string, $p)===0){ $called_api= explode("/",$p); //unset($_SERVER['PHP_AUTH_USER']); if ($info['auth'] === true && api_user() === false) { @@ -88,18 +88,18 @@ require_once('include/api_auth.php'); load_contact_links(api_user()); - $channel = $a->get_channel(); + $channel = App::get_channel(); - logger('API call for ' . $channel['channel_name'] . ': ' . $a->query_string); + logger('API call for ' . $channel['channel_name'] . ': ' . App::$query_string); logger('API parameters: ' . print_r($_REQUEST,true)); $type="json"; - if (strpos($a->query_string, ".xml")>0) $type="xml"; - if (strpos($a->query_string, ".json")>0) $type="json"; - if (strpos($a->query_string, ".rss")>0) $type="rss"; - if (strpos($a->query_string, ".atom")>0) $type="atom"; - if (strpos($a->query_string, ".as")>0) $type="as"; + if (strpos(App::$query_string, ".xml")>0) $type="xml"; + if (strpos(App::$query_string, ".json")>0) $type="json"; + if (strpos(App::$query_string, ".rss")>0) $type="rss"; + if (strpos(App::$query_string, ".atom")>0) $type="atom"; + if (strpos(App::$query_string, ".as")>0) $type="as"; $r = call_user_func($info['func'], $a, $type); if ($r===false) return; @@ -141,7 +141,7 @@ require_once('include/api_auth.php'); } } header("HTTP/1.1 404 Not Found"); - logger('API call not implemented: '.$a->query_string." - ".print_r($_REQUEST,true)); + logger('API call not implemented: '.App::$query_string." - ".print_r($_REQUEST,true)); $r = 'not implemented'; switch($type){ case "xml": @@ -171,7 +171,7 @@ require_once('include/api_auth.php'); $arr['$user'] = $user_info; $arr['$rss'] = array( 'alternate' => $user_info['url'], - 'self' => z_root(). "/". $a->query_string, + 'self' => z_root(). "/". App::$query_string, 'base' => z_root(), 'updated' => api_date(null), 'atom_updated' => datetime_convert('UTC','UTC','now',ATOM_TIME), @@ -213,7 +213,7 @@ require_once('include/api_auth.php'); $extra_query .= " AND abook_channel = ".intval(api_user()); } - if (is_null($user) && argc() > (count($called_api)-1) && (strstr($a->cmd,'/users'))){ + if (is_null($user) && argc() > (count($called_api)-1) && (strstr(App::$cmd,'/users'))){ $argid = count($called_api); list($xx, $null) = explode(".",argv($argid)); if(is_numeric($xx)){ @@ -326,7 +326,7 @@ require_once('include/api_auth.php'); 'time_zone' => 'UTC', //$uinfo[0]['timezone'], 'geo_enabled' => false, 'statuses_count' => intval($countitms), //#XXX: fix me - 'lang' => get_app()->language, + 'lang' => App::$language, 'description' => (($profile) ? $profile[0]['pdesc'] : ''), 'followers_count' => intval($countfollowers), 'favourites_count' => intval($starred), @@ -635,13 +635,13 @@ require_once('include/api_auth.php'); function api_albums(&$a,$type) { - json_return_and_die(photos_albums_list($a->get_channel(),$a->get_observer())); + json_return_and_die(photos_albums_list(App::get_channel(),App::get_observer())); } api_register_func('api/red/albums','api_albums', true); function api_photos(&$a,$type) { $album = $_REQUEST['album']; - json_return_and_die(photos_list_photos($a->get_channel(),$a->get_observer(),$album)); + json_return_and_die(photos_list_photos(App::get_channel(),App::get_observer(),$album)); } api_register_func('api/red/photos','api_photos', true); @@ -768,7 +768,7 @@ require_once('include/api_auth.php'); } $txt = html2bbcode($txt); - $a->argv[1] = $user_info['screen_name']; + App::$argv[1] = $user_info['screen_name']; $_REQUEST['silent']='1'; //tell wall_upload function to return img info instead of echo $_FILES['userfile'] = $_FILES['media']; @@ -872,7 +872,7 @@ require_once('include/api_auth.php'); // upload each image if we have any $_REQUEST['silent']='1'; //tell wall_upload function to return img info instead of echo require_once('mod/wall_attach.php'); - $a->data['api_info'] = $user_info; + App::$data['api_info'] = $user_info; $media = wall_attach_post($a); if(strlen($media)>0) @@ -885,7 +885,7 @@ require_once('include/api_auth.php'); // upload each image if we have any $_REQUEST['silent']='1'; //tell wall_upload function to return img info instead of echo require_once('mod/wall_attach.php'); - $a->data['api_info'] = $user_info; + App::$data['api_info'] = $user_info; $media = wall_attach_post($a); if(strlen($media)>0) @@ -960,7 +960,7 @@ require_once('include/api_auth.php'); $arr['records'] = 999999; $arr['item_type'] = '*'; - $i = items_fetch($arr,$a->get_channel(),get_observer_hash()); + $i = items_fetch($arr,App::get_channel(),get_observer_hash()); if(! $i) json_return_and_die(array()); @@ -1230,7 +1230,7 @@ require_once('include/api_auth.php'); $sql_extra .= ' AND `item`.`parent` = `item`.`id`'; if (api_user() != $user_info['uid']) { - $observer = get_app()->get_observer(); + $observer = App::get_observer(); require_once('include/permissions.php'); if(! perm_is_allowed($user_info['uid'],(($observer) ? $observer['xchan_hash'] : ''),'view_stream')) return ''; @@ -1272,7 +1272,7 @@ require_once('include/api_auth.php'); break; case "as": $as = api_format_as($a, $ret, $user_info); - $as['title'] = $a->config['sitename']." Home Timeline"; + $as['title'] = App::$config['sitename']." Home Timeline"; $as['link']['url'] = z_root()."/".$user_info["screen_name"]."/all"; return($as); break; @@ -1333,7 +1333,7 @@ require_once('include/api_auth.php'); break; case "as": $as = api_format_as($a, $ret, $user_info); - $as['title'] = $a->config['sitename']. " " . t('Public Timeline'); + $as['title'] = App::$config['sitename']. " " . t('Public Timeline'); $as['link']['url'] = z_root()."/"; return($as); break; @@ -1409,7 +1409,7 @@ require_once('include/api_auth.php'); //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false); - $observer = get_app()->get_observer(); + $observer = App::get_observer(); $item_normal = item_normal(); @@ -1526,7 +1526,7 @@ require_once('include/api_auth.php'); //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false); - $myurl = z_root() . '/channel/'. $a->user['nickname']; + $myurl = z_root() . '/channel/'. App::$user['nickname']; $myurl = substr($myurl,strpos($myurl,'://')+3); $myurl = str_replace(array('www.','.'),array('','\\.'),$myurl); $diasp_url = str_replace('/channel/','/u/',$myurl); @@ -1561,7 +1561,7 @@ require_once('include/api_auth.php'); break; case "as": $as = api_format_as($a, $ret, $user_info); - $as["title"] = $a->config['sitename']." Mentions"; + $as["title"] = App::$config['sitename']." Mentions"; $as['link']['url'] = z_root()."/"; return($as); break; @@ -1633,7 +1633,7 @@ require_once('include/api_auth.php'); $arr['cid'] = $user_info['id']; - $r = items_fetch($arr,get_app()->get_channel(),get_observer_hash()); + $r = items_fetch($arr,App::get_channel(),get_observer_hash()); $ret = api_format_items($r,$user_info); @@ -1752,7 +1752,7 @@ require_once('include/api_auth.php'); $sql_extra .= ' AND `item`.`parent` = `item`.`id`'; if (api_user() != $user_info['uid']) { - $observer = get_app()->get_observer(); + $observer = App::get_observer(); require_once('include/permissions.php'); if(! perm_is_allowed($user_info['uid'],(($observer) ? $observer['xchan_hash'] : ''),'view_stream')) return ''; @@ -1783,7 +1783,7 @@ require_once('include/api_auth.php'); break; case "as": $as = api_format_as($a, $ret, $user_info); - $as['title'] = $a->config['sitename']." Home Timeline"; + $as['title'] = App::$config['sitename']." Home Timeline"; $as['link']['url'] = z_root()."/".$user_info["screen_name"]."/all"; return($as); break; @@ -1801,7 +1801,7 @@ require_once('include/api_auth.php'); function api_format_as($a, $ret, $user_info) { $as = array(); - $as['title'] = $a->config['sitename']." Public Timeline"; + $as['title'] = App::$config['sitename']." Public Timeline"; $items = array(); foreach ($ret as $item) { $singleitem["actor"]["displayName"] = $item["user"]["name"]; @@ -2088,7 +2088,7 @@ require_once('include/api_auth.php'); load_config('system'); $name = get_config('system','sitename'); - $server = $a->get_hostname(); + $server = App::get_hostname(); $logo = z_root() . '/images/rm-64.png'; $email = get_config('system','admin_email'); $closed = ((get_config('system','register_policy') == REGISTER_CLOSED) ? 'true' : 'false'); @@ -2270,7 +2270,7 @@ require_once('include/api_auth.php'); if ($page<0) $page=0; $start = $page*$count; - $channel = $a->get_channel(); + $channel = App::get_channel(); $profile_url = z_root() . '/channel/' . $channel['channel_address']; if ($box=="sentbox") { diff --git a/include/api_auth.php b/include/api_auth.php index 26a9df8d4..dc8492b20 100644 --- a/include/api_auth.php +++ b/include/api_auth.php @@ -20,9 +20,9 @@ function api_login(&$a){ if (!is_null($token)){ $oauth->loginUser($token->uid); - $a->set_oauth_key($consumer->key); + App::set_oauth_key($consumer->key); - call_hooks('logged_in', $a->user); + call_hooks('logged_in', App::$user); return; } killme(); diff --git a/include/apps.php b/include/apps.php index 0a62dc5a8..fac58b850 100644 --- a/include/apps.php +++ b/include/apps.php @@ -48,12 +48,12 @@ function parse_app_description($f) { $ret = array(); $baseurl = z_root(); - $channel = get_app()->get_channel(); + $channel = App::get_channel(); $address = (($channel) ? $channel['channel_address'] : ''); //future expansion - $observer = get_app()->get_observer(); + $observer = App::get_observer(); $lines = @file($f); @@ -217,7 +217,7 @@ function app_render($papp,$mode = 'view') { return ''; break; case 'observer': - $observer = get_app()->get_observer(); + $observer = App::get_observer(); if(! $observer) return ''; break; @@ -239,7 +239,7 @@ function app_render($papp,$mode = 'view') { $hosturl = z_root() . '/'; } elseif(remote_channel()) { - $observer = get_app()->get_observer(); + $observer = App::get_observer(); if($observer && $observer['xchan_network'] === 'zot') { // some folks might have xchan_url redirected offsite, use the connurl $x = parse_url($observer['xchan_connurl']); @@ -354,7 +354,7 @@ function app_store($arr) { } - $darray['app_id'] = ((x($arr,'guid')) ? $arr['guid'] : random_string(). '.' . get_app()->get_hostname()); + $darray['app_id'] = ((x($arr,'guid')) ? $arr['guid'] : random_string(). '.' . App::get_hostname()); $darray['app_sig'] = ((x($arr,'sig')) ? $arr['sig'] : ''); $darray['app_author'] = ((x($arr,'author')) ? $arr['author'] : get_observer_hash()); $darray['app_name'] = ((x($arr,'name')) ? escape_tags($arr['name']) : t('Unknown')); diff --git a/include/attach.php b/include/attach.php index 343922a52..4ecc273e9 100644 --- a/include/attach.php +++ b/include/attach.php @@ -1477,7 +1477,7 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, require_once('include/items.php'); - $poster = get_app()->get_observer(); + $poster = App::get_observer(); //if we got no object something went wrong if(!$object) @@ -1696,7 +1696,7 @@ function recursive_activity_recipients($arr_allow_cid, $arr_allow_gid, $arr_deny $ret = array(); $parent_arr = array(); $count_values = array(); - $poster = get_app()->get_observer(); + $poster = App::get_observer(); //turn allow_gid into allow_cid's foreach($arr_allow_gid as $gid) { diff --git a/include/auth.php b/include/auth.php index 1a7110c20..aaec45c40 100644 --- a/include/auth.php +++ b/include/auth.php @@ -97,7 +97,7 @@ if((isset($_SESSION)) && (x($_SESSION, 'authenticated')) && // process a logout request - if(((x($_POST, 'auth-params')) && ($_POST['auth-params'] === 'logout')) || ($a->module === 'logout')) { + if(((x($_POST, 'auth-params')) && ($_POST['auth-params'] === 'logout')) || (App::$module === 'logout')) { // process logout request $args = array('channel_id' => local_channel()); call_hooks('logging_out', $args); @@ -128,13 +128,13 @@ if((isset($_SESSION)) && (x($_SESSION, 'authenticated')) && dbesc($_SESSION['visitor_id']) ); if($r) { - get_app()->set_observer($r[0]); + App::set_observer($r[0]); } else { unset($_SESSION['visitor_id']); unset($_SESSION['authenticated']); } - $a->set_groups(init_groups_visitor($_SESSION['visitor_id'])); + App::set_groups(init_groups_visitor($_SESSION['visitor_id'])); } // already logged in user returning @@ -183,7 +183,7 @@ if((isset($_SESSION)) && (x($_SESSION, 'authenticated')) && ); if(($r) && (($r[0]['account_flags'] == ACCOUNT_OK) || ($r[0]['account_flags'] == ACCOUNT_UNVERIFIED))) { - get_app()->account = $r[0]; + App::$account = $r[0]; $login_refresh = false; if(! x($_SESSION,'last_login_date')) { $_SESSION['last_login_date'] = datetime_convert('UTC','UTC'); @@ -237,16 +237,16 @@ else { $record = $addon_auth['user_record']; } else { - $record = get_app()->account = account_verify_password($_POST['username'], $_POST['password']); + $record = App::$account = account_verify_password($_POST['username'], $_POST['password']); - if(get_app()->account) { - $_SESSION['account_id'] = get_app()->account['account_id']; + if(App::$account) { + $_SESSION['account_id'] = App::$account['account_id']; } else { notice( t('Failed authentication') . EOL); } - logger('authenticate: ' . print_r(get_app()->account, true), LOGGER_DEBUG); + logger('authenticate: ' . print_r(App::$account, true), LOGGER_DEBUG); } if((! $record) || (! count($record))) { diff --git a/include/bbcode.php b/include/bbcode.php index e243db699..c2ff5d7c8 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -37,7 +37,7 @@ function tryzrlvideo($match) { if($zrl) $link = zid($link); - return ''; + return ''; } // [noparse][i]italic[/i][/noparse] turns into @@ -280,9 +280,9 @@ function bb_location($match) { function bb_iframe($match) { $a = get_app(); - $sandbox = ((strpos($match[1], $a->get_hostname())) ? ' sandbox="allow-scripts" ' : ''); + $sandbox = ((strpos($match[1], App::get_hostname())) ? ' sandbox="allow-scripts" ' : ''); - return ''; + return ''; } function bb_ShareAttributesSimple($match) { @@ -315,9 +315,9 @@ function bb_ShareAttributesSimple($match) { function rpost_callback($match) { if ($match[2]) { - return str_replace($match[0], get_rpost_path(get_app()->get_observer()) . '&title=' . urlencode($match[2]) . '&body=' . urlencode($match[3]), $match[0]); + return str_replace($match[0], get_rpost_path(App::get_observer()) . '&title=' . urlencode($match[2]) . '&body=' . urlencode($match[3]), $match[0]); } else { - return str_replace($match[0], get_rpost_path(get_app()->get_observer()) . '&body=' . urlencode($match[3]), $match[0]); + return str_replace($match[0], get_rpost_path(App::get_observer()) . '&body=' . urlencode($match[3]), $match[0]); } } @@ -401,7 +401,7 @@ function bb_observer($Text) { $a = get_app(); - $observer = $a->get_observer(); + $observer = App::get_observer(); if ((strpos($Text,'[/observer]') !== false) || (strpos($Text,'[/rpost]') !== false)) { if ($observer) { @@ -415,7 +415,7 @@ function bb_observer($Text) { } } - $channel = $a->get_channel(); + $channel = App::get_channel(); if (strpos($Text,'[/channel]') !== false) { if ($channel) { @@ -477,7 +477,7 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false) if($cache) $observer = false; else - $observer = $a->get_observer(); + $observer = App::get_observer(); if ((strpos($Text,'[/observer]') !== false) || (strpos($Text,'[/rpost]') !== false)) { if ($observer) { @@ -494,7 +494,7 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false) if($cache) $channel = false; else - $channel = $a->get_channel(); + $channel = App::get_channel(); if (strpos($Text,'[/channel]') !== false) { if ($channel) { @@ -930,7 +930,7 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false) // $Text = preg_replace("/\[youtube\]https?:\/\/youtu.be\/(.*?)\[\/youtube\]/ism", '[youtube]$1[/youtube]', $Text); // if ($tryoembed) -// $Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '', $Text); +// $Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '', $Text); // else // $Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", "http://www.youtube.com/watch?v=$1", $Text); // } @@ -944,7 +944,7 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false) // $Text = preg_replace("/\[vimeo\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/vimeo\]/ism", '[vimeo]$1[/vimeo]', $Text); // if ($tryoembed) -// $Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", '', $Text); +// $Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", '', $Text); // else // $Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", "http://vimeo.com/$1", $Text); // } diff --git a/include/cli_startup.php b/include/cli_startup.php index 70ab1a24a..6aa652a8f 100644 --- a/include/cli_startup.php +++ b/include/cli_startup.php @@ -18,8 +18,8 @@ function cli_startup() { if(! defined('UNO')) define('UNO', 0); - $a->timezone = ((x($default_timezone)) ? $default_timezone : 'UTC'); - date_default_timezone_set($a->timezone); + App::$timezone = ((x($default_timezone)) ? $default_timezone : 'UTC'); + date_default_timezone_set(App::$timezone); require_once('include/dba/dba_driver.php'); $db = dba_factory($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type); @@ -30,7 +30,7 @@ function cli_startup() { load_config('system'); - $a->set_baseurl(get_config('system','baseurl')); + App::set_baseurl(get_config('system','baseurl')); load_hooks(); diff --git a/include/comanche.php b/include/comanche.php index ddf331321..4d55aee19 100644 --- a/include/comanche.php +++ b/include/comanche.php @@ -56,34 +56,34 @@ function comanche_parser(&$a, $s, $pass = 0) { if($pass == 0) { $cnt = preg_match("/\[layout\](.*?)\[\/layout\]/ism", $s, $matches); if($cnt) - $a->page['template'] = trim($matches[1]); + App::$page['template'] = trim($matches[1]); $cnt = preg_match("/\[template=(.*?)\](.*?)\[\/template\]/ism", $s, $matches); if($cnt) { - $a->page['template'] = trim($matches[2]); - $a->page['template_style'] = trim($matches[2]) . '_' . $matches[1]; + App::$page['template'] = trim($matches[2]); + App::$page['template_style'] = trim($matches[2]) . '_' . $matches[1]; } $cnt = preg_match("/\[template\](.*?)\[\/template\]/ism", $s, $matches); if($cnt) { - $a->page['template'] = trim($matches[1]); + App::$page['template'] = trim($matches[1]); } $cnt = preg_match("/\[theme=(.*?)\](.*?)\[\/theme\]/ism", $s, $matches); if($cnt) { - $a->layout['schema'] = trim($matches[1]); - $a->layout['theme'] = trim($matches[2]); + App::$layout['schema'] = trim($matches[1]); + App::$layout['theme'] = trim($matches[2]); } $cnt = preg_match("/\[theme\](.*?)\[\/theme\]/ism", $s, $matches); if($cnt) - $a->layout['theme'] = trim($matches[1]); + App::$layout['theme'] = trim($matches[1]); $cnt = preg_match_all("/\[webpage\](.*?)\[\/webpage\]/ism", $s, $matches, PREG_SET_ORDER); if($cnt) { // only the last webpage definition is used if there is more than one foreach($matches as $mtch) { - $a->layout['webpage'] = comanche_webpage($a,$mtch[1]); + App::$layout['webpage'] = comanche_webpage($a,$mtch[1]); } } @@ -92,7 +92,7 @@ function comanche_parser(&$a, $s, $pass = 0) { $cnt = preg_match_all("/\[region=(.*?)\](.*?)\[\/region\]/ism", $s, $matches, PREG_SET_ORDER); if($cnt) { foreach($matches as $mtch) { - $a->layout['region_' . $mtch[1]] = comanche_region($a,$mtch[2]); + App::$layout['region_' . $mtch[1]] = comanche_region($a,$mtch[2]); } } @@ -122,8 +122,8 @@ function comanche_menu($s, $class = '') { function comanche_replace_region($match) { $a = get_app(); - if (array_key_exists($match[1], $a->page)) { - return $a->page[$match[1]]; + if (array_key_exists($match[1], App::$page)) { + return App::$page[$match[1]]; } } @@ -136,7 +136,7 @@ function comanche_replace_region($match) { * @return channel_id */ function comanche_get_channel_id() { - $channel_id = ((is_array(get_app()->profile)) ? get_app()->profile['profile_uid'] : 0); + $channel_id = ((is_array(App::$profile)) ? App::$profile['profile_uid'] : 0); if ((! $channel_id) && (local_channel())) $channel_id = local_channel(); @@ -190,7 +190,7 @@ function comanche_block($s, $class = '') { } if(trim($r[0]['body']) === '$content') { - $o .= get_app()->page['content']; + $o .= App::$page['content']; } else { $o .= prepare_text($r[0]['body'], $r[0]['mimetype']); @@ -378,6 +378,6 @@ function comanche_region(&$a, $s) { function register_page_template($arr) { - get_app()->page_layouts[$arr['template']] = array($arr['variant']); + App::$page_layouts[$arr['template']] = array($arr['variant']); return; } diff --git a/include/config.php b/include/config.php index 28a72f7ea..712b4ca11 100644 --- a/include/config.php +++ b/include/config.php @@ -22,7 +22,7 @@ * an identifier. This is for example for people who do not have a local account. * The storage is of size MEDIUMTEXT. * @code{.php} - * $observer = $a->get_observer_hash(); + * $observer = App::get_observer_hash(); * if ($observer) { * $var = get_xconfig($observer, 'category', 'key'); * }@endcode @@ -38,7 +38,7 @@ * @brief Loads the hub's configuration from database to a cached storage. * * Retrieve a category ($family) of config variables from database to a cached - * storage in the global $a->config[$family]. + * storage in the global App::$config[$family]. * * @param string $family * The category of the configuration value @@ -46,19 +46,19 @@ function load_config($family) { global $a; - if(! array_key_exists($family, $a->config)) - $a->config[$family] = array(); + if(! array_key_exists($family, App::$config)) + App::$config[$family] = array(); - if(! array_key_exists('config_loaded', $a->config[$family])) { + if(! array_key_exists('config_loaded', App::$config[$family])) { $r = q("SELECT * FROM config WHERE cat = '%s'", dbesc($family)); if($r !== false) { if($r) { foreach($r as $rr) { $k = $rr['k']; - $a->config[$family][$k] = $rr['v']; + App::$config[$family][$k] = $rr['v']; } } - $a->config[$family]['config_loaded'] = true; + App::$config[$family]['config_loaded'] = true; } } } @@ -68,7 +68,7 @@ function load_config($family) { * and a key. * * Get a particular config variable from the given category ($family) and the - * $key from a cached storage in $a->config[$family]. If a key is found in the + * $key from a cached storage in App::$config[$family]. If a key is found in the * DB but does not exist in local config cache, pull it into the cache so we * do not have to hit the DB again for this item. * @@ -83,16 +83,16 @@ function load_config($family) { function get_config($family, $key) { global $a; - if((! array_key_exists($family, $a->config)) || (! array_key_exists('config_loaded', $a->config[$family]))) + if((! array_key_exists($family, App::$config)) || (! array_key_exists('config_loaded', App::$config[$family]))) load_config($family); - if(array_key_exists('config_loaded', $a->config[$family])) { - if(! array_key_exists($key, $a->config[$family])) { + if(array_key_exists('config_loaded', App::$config[$family])) { + if(! array_key_exists($key, App::$config[$family])) { return false; } - return ((! is_array($a->config[$family][$key])) && (preg_match('|^a:[0-9]+:{.*}$|s', $a->config[$family][$key])) - ? unserialize($a->config[$family][$key]) - : $a->config[$family][$key] + return ((! is_array(App::$config[$family][$key])) && (preg_match('|^a:[0-9]+:{.*}$|s', App::$config[$family][$key])) + ? unserialize(App::$config[$family][$key]) + : App::$config[$family][$key] ); } return false; @@ -148,7 +148,7 @@ function set_config($family, $key, $value) { dbesc($dbvalue) ); if($ret) { - $a->config[$family][$key] = $value; + App::$config[$family][$key] = $value; $ret = $value; } return $ret; @@ -161,7 +161,7 @@ function set_config($family, $key, $value) { ); if($ret) { - $a->config[$family][$key] = $value; + App::$config[$family][$key] = $value; $ret = $value; } return $ret; @@ -170,7 +170,7 @@ function set_config($family, $key, $value) { /** * @brief Deletes the given key from the hub's configuration database. * - * Removes the configured value from the stored cache in $a->config[$family] + * Removes the configured value from the stored cache in App::$config[$family] * and removes it from the database. * * @param string $family @@ -183,8 +183,8 @@ function del_config($family, $key) { global $a; $ret = false; - if(array_key_exists($family, $a->config) && array_key_exists($key, $a->config[$family])) - unset($a->config[$family][$key]); + if(array_key_exists($family, App::$config) && array_key_exists($key, App::$config[$family])) + unset(App::$config[$family][$key]); $ret = q("DELETE FROM config WHERE cat = '%s' AND k = '%s'", dbesc($family), dbesc($key) @@ -197,7 +197,7 @@ function del_config($family, $key) { * @brief Loads all configuration values of a channel into a cached storage. * * All configuration values of the given channel are stored in global cache - * which is available under the global variable $a->config[$uid]. + * which is available under the global variable App::$config[$uid]. * * @param string $uid * The channel_id @@ -209,8 +209,8 @@ function load_pconfig($uid) { if($uid === false) return false; - if(! array_key_exists($uid, $a->config)) - $a->config[$uid] = array(); + if(! array_key_exists($uid, App::$config)) + App::$config[$uid] = array(); $r = q("SELECT * FROM pconfig WHERE uid = %d", intval($uid) @@ -220,11 +220,11 @@ function load_pconfig($uid) { foreach($r as $rr) { $k = $rr['k']; $c = $rr['cat']; - if(! array_key_exists($c, $a->config[$uid])) { - $a->config[$uid][$c] = array(); - $a->config[$uid][$c]['config_loaded'] = true; + if(! array_key_exists($c, App::$config[$uid])) { + App::$config[$uid][$c] = array(); + App::$config[$uid][$c]['config_loaded'] = true; } - $a->config[$uid][$c][$k] = $rr['v']; + App::$config[$uid][$c][$k] = $rr['v']; } } } @@ -234,7 +234,7 @@ function load_pconfig($uid) { * ($family) and a key. * * Get a particular channel's config value from the given category ($family) - * and the $key from a cached storage in $a->config[$uid]. + * and the $key from a cached storage in App::$config[$uid]. * * Returns false if not set. * @@ -254,15 +254,15 @@ function get_pconfig($uid, $family, $key, $instore = false) { if($uid === false) return false; - if(! array_key_exists($uid, $a->config)) + if(! array_key_exists($uid, App::$config)) load_pconfig($uid); - if((! array_key_exists($family, $a->config[$uid])) || (! array_key_exists($key, $a->config[$uid][$family]))) + if((! array_key_exists($family, App::$config[$uid])) || (! array_key_exists($key, App::$config[$uid][$family]))) return false; - return ((! is_array($a->config[$uid][$family][$key])) && (preg_match('|^a:[0-9]+:{.*}$|s', $a->config[$uid][$family][$key])) - ? unserialize($a->config[$uid][$family][$key]) - : $a->config[$uid][$family][$key] + return ((! is_array(App::$config[$uid][$family][$key])) && (preg_match('|^a:[0-9]+:{.*}$|s', App::$config[$uid][$family][$key])) + ? unserialize(App::$config[$uid][$family][$key]) + : App::$config[$uid][$family][$key] ); } @@ -303,22 +303,22 @@ function set_pconfig($uid, $family, $key, $value) { $dbvalue = ((is_bool($dbvalue)) ? intval($dbvalue) : $dbvalue); if(get_pconfig($uid, $family, $key) === false) { - if(! array_key_exists($uid, $a->config)) - $a->config[$uid] = array(); - if(! array_key_exists($family, $a->config[$uid])) - $a->config[$uid][$family] = array(); + if(! array_key_exists($uid, App::$config)) + App::$config[$uid] = array(); + if(! array_key_exists($family, App::$config[$uid])) + App::$config[$uid][$family] = array(); // keep a separate copy for all variables which were // set in the life of this page. We need this to // synchronise channel clones. - if(! array_key_exists('transient', $a->config[$uid])) - $a->config[$uid]['transient'] = array(); - if(! array_key_exists($family, $a->config[$uid]['transient'])) - $a->config[$uid]['transient'][$family] = array(); + if(! array_key_exists('transient', App::$config[$uid])) + App::$config[$uid]['transient'] = array(); + if(! array_key_exists($family, App::$config[$uid]['transient'])) + App::$config[$uid]['transient'][$family] = array(); - $a->config[$uid][$family][$key] = $value; - $a->config[$uid]['transient'][$family][$key] = $value; + App::$config[$uid][$family][$key] = $value; + App::$config[$uid]['transient'][$family][$key] = $value; $ret = q("INSERT INTO pconfig ( uid, cat, k, v ) VALUES ( %d, '%s', '%s', '%s' ) ", intval($uid), @@ -343,13 +343,13 @@ function set_pconfig($uid, $family, $key, $value) { // set in the life of this page. We need this to // synchronise channel clones. - if(! array_key_exists('transient', $a->config[$uid])) - $a->config[$uid]['transient'] = array(); - if(! array_key_exists($family, $a->config[$uid]['transient'])) - $a->config[$uid]['transient'][$family] = array(); + if(! array_key_exists('transient', App::$config[$uid])) + App::$config[$uid]['transient'] = array(); + if(! array_key_exists($family, App::$config[$uid]['transient'])) + App::$config[$uid]['transient'][$family] = array(); - $a->config[$uid][$family][$key] = $value; - $a->config[$uid]['transient'][$family][$key] = $value; + App::$config[$uid][$family][$key] = $value; + App::$config[$uid]['transient'][$family][$key] = $value; if($ret) return $value; @@ -360,7 +360,7 @@ function set_pconfig($uid, $family, $key, $value) { /** * @brief Deletes the given key from the channel's configuration. * - * Removes the configured value from the stored cache in $a->config[$uid] + * Removes the configured value from the stored cache in App::$config[$uid] * and removes it from the database. * * @param string $uid @@ -375,8 +375,8 @@ function del_pconfig($uid, $family, $key) { global $a; $ret = false; - if (x($a->config[$uid][$family], $key)) - unset($a->config[$uid][$family][$key]); + if (x(App::$config[$uid][$family], $key)) + unset(App::$config[$uid][$family][$key]); $ret = q("DELETE FROM pconfig WHERE uid = %d AND cat = '%s' AND k = '%s'", intval($uid), dbesc($family), @@ -391,7 +391,7 @@ function del_pconfig($uid, $family, $key) { * @brief Loads a full xchan's configuration into a cached storage. * * All configuration values of the given observer hash are stored in global - * cache which is available under the global variable $a->config[$xchan]. + * cache which is available under the global variable App::$config[$xchan]. * * @param string $xchan * The observer's hash @@ -403,8 +403,8 @@ function load_xconfig($xchan) { if(! $xchan) return false; - if(! array_key_exists($xchan, $a->config)) - $a->config[$xchan] = array(); + if(! array_key_exists($xchan, App::$config)) + App::$config[$xchan] = array(); $r = q("SELECT * FROM xconfig WHERE xchan = '%s'", dbesc($xchan) @@ -414,11 +414,11 @@ function load_xconfig($xchan) { foreach($r as $rr) { $k = $rr['k']; $c = $rr['cat']; - if(! array_key_exists($c, $a->config[$xchan])) { - $a->config[$xchan][$c] = array(); - $a->config[$xchan][$c]['config_loaded'] = true; + if(! array_key_exists($c, App::$config[$xchan])) { + App::$config[$xchan][$c] = array(); + App::$config[$xchan][$c]['config_loaded'] = true; } - $a->config[$xchan][$c][$k] = $rr['v']; + App::$config[$xchan][$c][$k] = $rr['v']; } } } @@ -428,7 +428,7 @@ function load_xconfig($xchan) { * name ($family) and a key. * * Get a particular observer's config value from the given category ($family) - * and the $key from a cached storage in $a->config[$xchan]. + * and the $key from a cached storage in App::$config[$xchan]. * * Returns false if not set. * @@ -446,15 +446,15 @@ function get_xconfig($xchan, $family, $key) { if(! $xchan) return false; - if(! array_key_exists($xchan, $a->config)) + if(! array_key_exists($xchan, App::$config)) load_xconfig($xchan); - if((! array_key_exists($family, $a->config[$xchan])) || (! array_key_exists($key, $a->config[$xchan][$family]))) + if((! array_key_exists($family, App::$config[$xchan])) || (! array_key_exists($key, App::$config[$xchan][$family]))) return false; - return ((! is_array($a->config[$xchan][$family][$key])) && (preg_match('|^a:[0-9]+:{.*}$|s', $a->config[$xchan][$family][$key])) - ? unserialize($a->config[$xchan][$family][$key]) - : $a->config[$xchan][$family][$key] + return ((! is_array(App::$config[$xchan][$family][$key])) && (preg_match('|^a:[0-9]+:{.*}$|s', App::$config[$xchan][$family][$key])) + ? unserialize(App::$config[$xchan][$family][$key]) + : App::$config[$xchan][$family][$key] ); } @@ -484,12 +484,12 @@ function set_xconfig($xchan, $family, $key, $value) { $dbvalue = ((is_bool($dbvalue)) ? intval($dbvalue) : $dbvalue); if(get_xconfig($xchan, $family, $key) === false) { - if(! array_key_exists($xchan, $a->config)) - $a->config[$xchan] = array(); - if(! array_key_exists($family, $a->config[$xchan])) - $a->config[$xchan][$family] = array(); + if(! array_key_exists($xchan, App::$config)) + App::$config[$xchan] = array(); + if(! array_key_exists($family, App::$config[$xchan])) + App::$config[$xchan][$family] = array(); - $a->config[$xchan][$family][$key] = $value; + App::$config[$xchan][$family][$key] = $value; $ret = q("INSERT INTO xconfig ( xchan, cat, k, v ) VALUES ( '%s', '%s', '%s', '%s' ) ", dbesc($xchan), dbesc($family), @@ -508,7 +508,7 @@ function set_xconfig($xchan, $family, $key, $value) { dbesc($key) ); - $a->config[$xchan][$family][$key] = $value; + App::$config[$xchan][$family][$key] = $value; if($ret) return $value; @@ -518,7 +518,7 @@ function set_xconfig($xchan, $family, $key, $value) { /** * @brief Deletes the given key from the observer's config. * - * Removes the configured value from the stored cache in $a->config[$xchan] + * Removes the configured value from the stored cache in App::$config[$xchan] * and removes it from the database. * * @param string $xchan @@ -533,8 +533,8 @@ function del_xconfig($xchan, $family, $key) { global $a; $ret = false; - if(x($a->config[$xchan][$family], $key)) - unset($a->config[$xchan][$family][$key]); + if(x(App::$config[$xchan][$family], $key)) + unset(App::$config[$xchan][$family][$key]); $ret = q("DELETE FROM xconfig WHERE xchan = '%s' AND cat = '%s' AND k = '%s'", dbesc($xchan), dbesc($family), diff --git a/include/contact_widgets.php b/include/contact_widgets.php index 66f84f066..ba1241fcb 100644 --- a/include/contact_widgets.php +++ b/include/contact_widgets.php @@ -10,7 +10,7 @@ function findpeople_widget() { if(get_config('system','invitation_only')) { $x = get_pconfig(local_channel(),'system','invites_remaining'); if($x || is_site_admin()) { - $a->page['aside'] .= '