]> git.mxchange.org Git - friendica.git/commitdiff
Merge remote-tracking branch 'upstream/develop' into develop
authorRoland Haeder <roland@mxchange.org>
Tue, 20 Dec 2016 18:33:40 +0000 (19:33 +0100)
committerRoland Haeder <roland@mxchange.org>
Tue, 20 Dec 2016 18:33:40 +0000 (19:33 +0100)
195 files changed:
boot.php
doc/Plugins.md
doc/autoloader.md
doc/de/Plugins.md
doc/themes.md
include/Contact.php
include/Core/Config.php
include/Core/PConfig.php
include/Photo.php
include/acl_selectors.php
include/api.php
include/auth.php
include/bb2diaspora.php
include/bbcode.php
include/contact_widgets.php
include/conversation.php
include/cron.php
include/dbstructure.php
include/delivery.php
include/dfrn.php
include/email.php
include/enotify.php
include/event.php
include/follow.php
include/group.php
include/identity.php
include/items.php
include/like.php
include/lock.php
include/message.php
include/nav.php
include/network.php
include/notifier.php
include/oauth.php
include/onepoll.php
include/plugin.php
include/poller.php
include/pubsubpublish.php
include/queue.php
include/redir.php
include/salmon.php
include/security.php
include/socgraph.php
include/tags.php
include/text.php
include/threads.php
include/uimport.php
include/user.php
index.php
mod/_well_known.php
mod/acctlink.php
mod/acl.php
mod/admin.php
mod/allfriends.php
mod/amcd.php
mod/api.php
mod/apps.php
mod/attach.php
mod/babel.php
mod/bookmarklet.php
mod/cal.php
mod/cb.php
mod/common.php
mod/community.php
mod/contactgroup.php
mod/contacts.php
mod/content.php
mod/credits.php
mod/crepair.php
mod/delegate.php
mod/dfrn_confirm.php
mod/dfrn_notify.php
mod/dfrn_poll.php
mod/dfrn_request.php
mod/directory.php
mod/dirfind.php
mod/display.php
mod/editpost.php
mod/events.php
mod/fbrowser.php
mod/fetch.php
mod/filer.php
mod/filerm.php
mod/follow.php
mod/friendica.php
mod/fsuggest.php
mod/group.php
mod/hcard.php
mod/help.php
mod/home.php
mod/hostxrd.php
mod/hovercard.php
mod/ignored.php
mod/install.php
mod/invite.php
mod/item.php
mod/like.php
mod/localtime.php
mod/lockview.php
mod/login.php
mod/lostpass.php
mod/maintenance.php
mod/manage.php
mod/match.php
mod/message.php
mod/modexp.php
mod/mood.php
mod/msearch.php
mod/navigation.php
mod/network.php
mod/newmember.php
mod/nodeinfo.php
mod/nogroup.php
mod/noscrape.php
mod/notes.php
mod/notice.php
mod/notifications.php
mod/notify.php
mod/oembed.php
mod/oexchange.php
mod/openid.php
mod/opensearch.php
mod/ostatus_subscribe.php
mod/parse_url.php
mod/photo.php
mod/photos.php
mod/ping.php
mod/poco.php
mod/poke.php
mod/post.php
mod/pretheme.php
mod/probe.php
mod/profile.php
mod/profile_photo.php
mod/profiles.php
mod/profperm.php
mod/proxy.php
mod/pubsub.php
mod/pubsubhubbub.php
mod/qsearch.php
mod/randprof.php
mod/receive.php
mod/redir.php
mod/register.php
mod/regmod.php
mod/removeme.php
mod/repair_ostatus.php
mod/rsd_xml.php
mod/salmon.php
mod/search.php
mod/settings.php
mod/share.php
mod/smilies.php
mod/starred.php
mod/statistics_json.php
mod/subthread.php
mod/suggest.php
mod/tagger.php
mod/tagrm.php
mod/toggle_mobile.php
mod/uexport.php
mod/uimport.php
mod/update_community.php
mod/update_display.php
mod/update_network.php
mod/update_notes.php
mod/update_profile.php
mod/videos.php
mod/viewcontacts.php
mod/viewsrc.php
mod/wall_attach.php
mod/wall_upload.php
mod/wallmessage.php
mod/webfinger.php
mod/xrd.php
object/Item.php
view/php/default.php
view/php/minimal.php
view/theme/duepuntozero/config.php
view/theme/duepuntozero/theme.php
view/theme/frio/config.php
view/theme/frio/php/default.php
view/theme/frio/php/frio_boot.php
view/theme/frio/php/standard.php
view/theme/frio/theme.php
view/theme/frost-mobile/php/default.php
view/theme/frost-mobile/theme.php
view/theme/frost/php/default.php
view/theme/frost/theme.php
view/theme/quattro/config.php
view/theme/quattro/theme.php
view/theme/smoothly/php/default.php
view/theme/smoothly/theme.php
view/theme/vier/config.php
view/theme/vier/theme.php

index b282f8d48e0b64577860cfcad7da20c4d943a75d..70f7d324d3e383cf2ffd2372305e983a5e25a790 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -670,22 +670,23 @@ class App {
 
                #set_include_path("include/$this->hostname" . PATH_SEPARATOR . get_include_path());
 
-               if((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,9) === "pagename=") {
+               if ((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,9) === "pagename=") {
                        $this->query_string = substr($_SERVER['QUERY_STRING'],9);
                        // removing trailing / - maybe a nginx problem
                        if (substr($this->query_string, 0, 1) == "/")
                                $this->query_string = substr($this->query_string, 1);
-               } elseif((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,2) === "q=") {
+               } elseif ((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,2) === "q=") {
                        $this->query_string = substr($_SERVER['QUERY_STRING'],2);
                        // removing trailing / - maybe a nginx problem
                        if (substr($this->query_string, 0, 1) == "/")
                                $this->query_string = substr($this->query_string, 1);
                }
 
-               if (x($_GET,'pagename'))
+               if (x($_GET,'pagename')) {
                        $this->cmd = trim($_GET['pagename'],'/\\');
-               elseif (x($_GET,'q'))
+               } elseif (x($_GET,'q')) {
                        $this->cmd = trim($_GET['q'],'/\\');
+               }
 
 
                // fix query_string
@@ -694,13 +695,15 @@ class App {
 
                // unix style "homedir"
 
-               if(substr($this->cmd,0,1) === '~')
+               if (substr($this->cmd,0,1) === '~') {
                        $this->cmd = 'profile/' . substr($this->cmd,1);
+               }
 
                // Diaspora style profile url
 
-               if(substr($this->cmd,0,2) === 'u/')
+               if (substr($this->cmd,0,2) === 'u/') {
                        $this->cmd = 'profile/' . substr($this->cmd,2);
+               }
 
 
                /*
@@ -1028,7 +1031,7 @@ class App {
                } else {
                        $r = q("SELECT `contact`.`avatar-date` AS picdate FROM `contact` WHERE `contact`.`thumb` like '%%/%s'",
                                $common_filename);
-                       if(! dbm::is_result($r)){
+                       if (! dbm::is_result($r)) {
                                $this->cached_profile_image[$avatar_image] = $avatar_image;
                        } else {
                                $this->cached_profile_picdate[$common_filename] = "?rev=".urlencode($r[0]['picdate']);
@@ -1537,7 +1540,7 @@ function check_db() {
  * Sets the base url for use in cmdline programs which don't have
  * $_SERVER variables
  */
-function check_url(&$a) {
+function check_url(App &$a) {
 
        $url = get_config('system','url');
 
@@ -1548,9 +1551,9 @@ function check_url(&$a) {
        // We will only change the url to an ip address if there is no existing setting
 
        if(! x($url))
-               $url = set_config('system','url',$a->get_baseurl());
-       if((! link_compare($url,$a->get_baseurl())) && (! preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/",$a->get_hostname)))
-               $url = set_config('system','url',$a->get_baseurl());
+               $url = set_config('system','url',App::get_baseurl());
+       if((! link_compare($url,App::get_baseurl())) && (! preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/",$a->get_hostname)))
+               $url = set_config('system','url',App::get_baseurl());
 
        return;
 }
@@ -1559,7 +1562,7 @@ function check_url(&$a) {
 /**
  * @brief Automatic database updates
  */
-function update_db(&$a) {
+function update_db(App &$a) {
        $build = get_config('system','build');
        if(! x($build))
                $build = set_config('system','build',DB_UPDATE_VERSION);
@@ -1675,7 +1678,7 @@ function run_update_function($x) {
  * @param App $a
  *
         */
-function check_plugins(&$a) {
+function check_plugins(App &$a) {
 
        $r = q("SELECT * FROM `addon` WHERE `installed` = 1");
        if (dbm::is_result($r))
@@ -2410,7 +2413,8 @@ function get_temppath() {
        return("");
 }
 
-function set_template_engine(&$a, $engine = 'internal') {
+/// @deprecated
+function set_template_engine(App &$a, $engine = 'internal') {
 /// @note This function is no longer necessary, but keep it as a wrapper to the class method
 /// to avoid breaking themes again unnecessarily
 
index 49d0665fec9efd2e277816769bd6cfb0b1c09e76..6460fd5a09459bf6fe57f3dcf1fab6403de1b2de 100644 (file)
@@ -77,9 +77,9 @@ This will include:
     $a->argc = 3
     $a->argv = array(0 => 'plugin', 1 => 'arg1', 2 => 'arg2');
 
-Your module functions will often contain the function plugin_name_content(&$a), which defines and returns the page body content.
-They may also contain plugin_name_post(&$a) which is called before the _content function and typically handles the results of POST forms.
-You may also have plugin_name_init(&$a) which is called very early on and often does module initialisation.
+Your module functions will often contain the function plugin_name_content(App &$a), which defines and returns the page body content.
+They may also contain plugin_name_post(App &$a) which is called before the _content function and typically handles the results of POST forms.
+You may also have plugin_name_init(App &$a) which is called very early on and often does module initialisation.
 
 Templates
 ---
index 947eade23cfa62701ccd2c08051b95fb29419185..25ffd7fe45b77fe36f3f0693e1ac6ffefcacf4ad 100644 (file)
@@ -68,7 +68,7 @@ The code will be something like:
     file: mod/network.php\r
     <?php\r
     \r
-    function network_content(&$a) {\r
+    function network_content(App &$a) {\r
        $itemsmanager = new \Friendica\ItemsManager();\r
        $items = $itemsmanager->getAll();\r
     \r
index 40be4a069596e8c2f1da1fcac70883f9518f9f8d..b2c3f849ffae55ae57ee7fcdc72dca9ed0024dbf 100644 (file)
@@ -67,9 +67,9 @@ So würde http://example.com/plugin/arg1/arg2 nach einem Modul "plugin" suchen u
     $a->argc = 3
     $a->argv = array(0 => 'plugin', 1 => 'arg1', 2 => 'arg2');
 
-Deine Modulfunktionen umfassen oft die Funktion plugin_name_content(&$a), welche den Seiteninhalt definiert und zurückgibt.
-Sie können auch plugin_name_post(&$a) umfassen, welches vor der content-Funktion aufgerufen wird und normalerweise die Resultate der POST-Formulare handhabt.
-Du kannst ebenso plugin_name_init(&$a) nutzen, was oft frühzeitig aufgerufen wird und das Modul initialisert.
+Deine Modulfunktionen umfassen oft die Funktion plugin_name_content(App &$a), welche den Seiteninhalt definiert und zurückgibt.
+Sie können auch plugin_name_post(App &$a) umfassen, welches vor der content-Funktion aufgerufen wird und normalerweise die Resultate der POST-Formulare handhabt.
+Du kannst ebenso plugin_name_init(App &$a) nutzen, was oft frühzeitig aufgerufen wird und das Modul initialisert.
 
 
 Derzeitige Hooks
index add44c776bc5f130b6bc842891101e970de5dd9c..0b8f6cb83dc03aefd95a860b61609488a821c276 100644 (file)
@@ -122,10 +122,11 @@ the 1st part of the line is the name of the CSS file (without the .css) the 2nd
 Calling the t() function with the common name makes the string translateable.
 The selected 1st part will be saved in the database by the theme_post function.
 
-    function theme_post(&$a){
+    function theme_post(App &$a){
         // non local users shall not pass
-        if(! local_user())
+        if (! local_user()) {
             return;
+        }
         // if the one specific submit button was pressed then proceed
         if (isset($_POST['duepuntozero-settings-submit'])){
             // and save the selection key into the personal config of the user
@@ -167,7 +168,7 @@ The content of this file should be something like
 
     <?php
     /* meta informations for the theme, see below */
-    function duepuntozero_lr_init(&$a) {
+    function duepuntozero_lr_init(App &$a) {
         $a-> theme_info = array(
             'extends' => 'duepuntozero'.
         );
@@ -250,7 +251,7 @@ Next crucial part of the theme.php file is a definition of an init function.
 The name of the function is <theme-name>_init.
 So in the case of quattro it is
 
-    function quattro_init(&$a) {
+    function quattro_init(App &$a) {
       $a->theme_info = array();
       set_template_engine($a, 'smarty3');
     }
index 7ca45a21bd01e32baee60d3e235faa49afc76cb1..13e11a83221e27323c0c9279ecf6dd7856d2ee9e 100644 (file)
@@ -8,7 +8,6 @@
 function user_remove($uid) {
        if(! $uid)
                return;
-       $a = get_app();
        logger('Removing user: ' . $uid);
 
        $r = q("select * from user where uid = %d limit 1", intval($uid));
@@ -54,7 +53,7 @@ function user_remove($uid) {
        if($uid == local_user()) {
                unset($_SESSION['authenticated']);
                unset($_SESSION['uid']);
-               goaway($a->get_baseurl());
+               goaway(App::get_baseurl());
        }
 }
 
@@ -86,7 +85,6 @@ function contact_remove($id) {
 
 function terminate_friendship($user,$self,$contact) {
 
-
        $a = get_app();
 
        require_once('include/datetime.php');
@@ -229,14 +227,14 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) {
                        dbesc(normalise_link($url)), intval($uid));
 
        // Fetch the data from the contact table with "uid=0" (which is filled automatically)
-       if (!$r)
+       if (!dbm::is_result($r))
                $r = q("SELECT `id`, 0 AS `cid`, `id` AS `zid`, 0 AS `gid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
                        `keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `contact-type`, `bd` AS `birthday`, 0 AS `self`
                        FROM `contact` WHERE `nurl` = '%s' AND `uid` = 0",
                                dbesc(normalise_link($url)));
 
        // Fetch the data from the gcontact table
-       if (!$r)
+       if (!dbm::is_result($r))
                $r = q("SELECT 0 AS `id`, 0 AS `cid`, `id` AS `gid`, 0 AS `zid`, 0 AS `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, '' AS `xmpp`,
                        `keywords`, `gender`, `photo`, `photo` AS `thumb`, `photo` AS `micro`, `community` AS `forum`, 0 AS `prv`, `community`, `contact-type`, `birthday`, 0 AS `self`
                        FROM `gcontact` WHERE `nurl` = '%s'",
@@ -361,7 +359,7 @@ function contact_photo_menu($contact, $uid = 0)
        $sparkle = false;
        if ($contact['network'] === NETWORK_DFRN) {
                $sparkle = true;
-               $profile_link = $a->get_baseurl() . '/redir/' . $contact['id'];
+               $profile_link = App::get_baseurl() . '/redir/' . $contact['id'];
        } else {
                $profile_link = $contact['url'];
        }
@@ -377,17 +375,17 @@ function contact_photo_menu($contact, $uid = 0)
        }
 
        if (in_array($contact['network'], array(NETWORK_DFRN, NETWORK_DIASPORA))) {
-               $pm_url = $a->get_baseurl() . '/message/new/' . $contact['id'];
+               $pm_url = App::get_baseurl() . '/message/new/' . $contact['id'];
        }
 
        if ($contact['network'] == NETWORK_DFRN) {
-               $poke_link = $a->get_baseurl() . '/poke/?f=&c=' . $contact['id'];
+               $poke_link = App::get_baseurl() . '/poke/?f=&c=' . $contact['id'];
        }
 
-       $contact_url = $a->get_baseurl() . '/contacts/' . $contact['id'];
+       $contact_url = App::get_baseurl() . '/contacts/' . $contact['id'];
 
-       $posts_link = $a->get_baseurl() . '/contacts/' . $contact['id'] . '/posts';
-       $contact_drop_link = $a->get_baseurl() . '/contacts/' . $contact['id'] . '/drop?confirm=1';
+       $posts_link = App::get_baseurl() . '/contacts/' . $contact['id'] . '/posts';
+       $contact_drop_link = App::get_baseurl() . '/contacts/' . $contact['id'] . '/drop?confirm=1';
 
        /**
         * menu array:
index 7b7045a9ee3ed2f3fe00989d97db6cba13e9959f..523572886457edb82971cd645ceb6ee42e03cb28 100644 (file)
@@ -97,7 +97,7 @@ class Config {
                        dbesc($family),
                        dbesc($key)
                );
-               if (count($ret)) {
+               if (dbm::is_result($ret)) {
                        // manage array value
                        $val = (preg_match("|^a:[0-9]+:{.*}$|s", $ret[0]['v'])?unserialize( $ret[0]['v']):$ret[0]['v']);
                        $a->config[$family][$key] = $val;
index 43735018e4ce143b2826ed61d61987d21cd9303e..49b69a1f7a2d814de21e87e9e6ba2ca2bd4fa430 100644 (file)
@@ -92,7 +92,7 @@ class PConfig {
                        dbesc($key)
                );
 
-               if (count($ret)) {
+               if (dbm::is_result($ret)) {
                        $val = (preg_match("|^a:[0-9]+:{.*}$|s", $ret[0]['v'])?unserialize( $ret[0]['v']):$ret[0]['v']);
                        $a->config[$uid][$family][$key] = $val;
 
index 014cca7d25f70d22bc4cf195106f7d06a6cc1179..1a97fe2fe47b1d31f95ae0abc2acd5fafcc5c918 100644 (file)
@@ -794,8 +794,6 @@ function update_contact_avatar($avatar, $uid, $cid, $force = false) {
 
 function import_profile_photo($photo, $uid, $cid, $quit_on_error = false) {
 
-       $a = get_app();
-
        $r = q("SELECT `resource-id` FROM `photo` WHERE `uid` = %d AND `contact-id` = %d AND `scale` = 4 AND `album` = 'Contact Photos' LIMIT 1",
                intval($uid),
                intval($cid)
@@ -841,9 +839,9 @@ function import_profile_photo($photo, $uid, $cid, $quit_on_error = false) {
                        $photo_failure = true;
                }
 
-               $photo = $a->get_baseurl() . '/photo/' . $hash . '-4.' . $img->getExt();
-               $thumb = $a->get_baseurl() . '/photo/' . $hash . '-5.' . $img->getExt();
-               $micro = $a->get_baseurl() . '/photo/' . $hash . '-6.' . $img->getExt();
+               $photo = App::get_baseurl() . '/photo/' . $hash . '-4.' . $img->getExt();
+               $thumb = App::get_baseurl() . '/photo/' . $hash . '-5.' . $img->getExt();
+               $micro = App::get_baseurl() . '/photo/' . $hash . '-6.' . $img->getExt();
        } else {
                $photo_failure = true;
        }
@@ -853,9 +851,9 @@ function import_profile_photo($photo, $uid, $cid, $quit_on_error = false) {
        }
 
        if ($photo_failure) {
-               $photo = $a->get_baseurl() . '/images/person-175.jpg';
-               $thumb = $a->get_baseurl() . '/images/person-80.jpg';
-               $micro = $a->get_baseurl() . '/images/person-48.jpg';
+               $photo = App::get_baseurl() . '/images/person-175.jpg';
+               $thumb = App::get_baseurl() . '/images/person-80.jpg';
+               $micro = App::get_baseurl() . '/images/person-48.jpg';
        }
 
        return(array($photo,$thumb,$micro));
@@ -1044,18 +1042,18 @@ function store_photo($a, $uid, $imagedata = "", $url = "") {
                return(array());
        }
 
-       $image = array("page" => $a->get_baseurl().'/photos/'.$page_owner_nick.'/image/'.$hash,
-                       "full" => $a->get_baseurl()."/photo/{$hash}-0.".$ph->getExt());
+       $image = array("page" => App::get_baseurl().'/photos/'.$page_owner_nick.'/image/'.$hash,
+                       "full" => App::get_baseurl()."/photo/{$hash}-0.".$ph->getExt());
 
        if ($width > 800 || $height > 800) {
-               $image["large"] = $a->get_baseurl()."/photo/{$hash}-0.".$ph->getExt();
+               $image["large"] = App::get_baseurl()."/photo/{$hash}-0.".$ph->getExt();
        }
 
        if ($width > 640 || $height > 640) {
                $ph->scaleImage(640);
                $r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 1, 0, $defperm);
                if ($r) {
-                       $image["medium"] = $a->get_baseurl()."/photo/{$hash}-1.".$ph->getExt();
+                       $image["medium"] = App::get_baseurl()."/photo/{$hash}-1.".$ph->getExt();
                }
        }
 
@@ -1063,7 +1061,7 @@ function store_photo($a, $uid, $imagedata = "", $url = "") {
                $ph->scaleImage(320);
                $r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 2, 0, $defperm);
                if ($r) {
-                       $image["small"] = $a->get_baseurl()."/photo/{$hash}-2.".$ph->getExt();
+                       $image["small"] = App::get_baseurl()."/photo/{$hash}-2.".$ph->getExt();
                }
        }
 
@@ -1088,7 +1086,7 @@ function store_photo($a, $uid, $imagedata = "", $url = "") {
 
                $r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 3, 0, $defperm);
                if ($r) {
-                       $image["thumb"] = $a->get_baseurl()."/photo/{$hash}-3.".$ph->getExt();
+                       $image["thumb"] = App::get_baseurl()."/photo/{$hash}-3.".$ph->getExt();
                }
        }
 
index ed9c634c23a8073950eb6ae40e146444e8554737..c1edc8cc037927b5cdd5695cca2d663151bfe678 100644 (file)
@@ -392,8 +392,9 @@ function construct_acl_data(&$a, $user) {
 
 function acl_lookup(&$a, $out_type = 'json') {
 
-       if(!local_user())
-               return "";
+       if (!local_user()) {
+               return '';
+       }
 
        $start  =       (x($_REQUEST,'start')           ? $_REQUEST['start']            : 0);
        $count  =       (x($_REQUEST,'count')           ? $_REQUEST['count']            : 100);
@@ -678,7 +679,7 @@ function acl_lookup(&$a, $out_type = 'json') {
  * @param App $a
  * @return array with the search results
  */
-function navbar_complete(&$a) {
+function navbar_complete(App &$a) {
 
 //     logger('navbar_complete');
 
index 2ae1aeaa026e25e9f8c7fbca5b7d0bb61ec4aa79..a450f867a574e45edce018014a10be5944b86cc7 100644 (file)
         * @hook 'logged_in'
         *              array $user     logged user record
         */
-       function api_login(&$a){
+       function api_login(App &$a){
                // login with oauth
                try{
                        $oauth = new FKOAuth1();
         * @param App $a
         * @return string API call result
         */
-       function api_call(&$a){
-               GLOBAL $API, $called_api;
+       function api_call(App &$a){
+               global $API, $called_api;
 
                $type="json";
                if (strpos($a->query_string, ".xml")>0) $type="xml";
                        intval($gid),
                        dbesc($name));
                // error message if specified gid is not in database
-               if (count($rname) == 0)
+               if (!dbm::is_result($rname))
                        throw new BadRequestException('wrong group name');
 
                // delete group
                        intval($uid),
                        dbesc($name));
                // error message if specified group name already exists
-               if (count($rname) != 0)
+               if (dbm::is_result($rname))
                        throw new BadRequestException('group name already exists');
 
                // check if specified group name is a deleted group
                        intval($uid),
                        dbesc($name));
                // error message if specified group name already exists
-               if (count($rname) != 0)
+               if (dbm::is_result($rname))
                        $reactivate_group = true;
 
                // create group
index 2ca9c3efb29e7937b326b40ee8e5d2665693cd57..e3c8d92eebd23f2ae9e6ba33d98f25fcab3ce8ec 100644 (file)
@@ -125,8 +125,7 @@ if (isset($_SESSION) && x($_SESSION,'authenticated') && (!x($_POST,'auth-params'
                                $openid = new LightOpenID;
                                $openid->identity = $openid_url;
                                $_SESSION['openid'] = $openid_url;
-                               $a = get_app();
-                               $openid->returnUrl = $a->get_baseurl(true).'/openid';
+                               $openid->returnUrl = App::get_baseurl(true).'/openid';
                                goaway($openid->authUrl());
                        } catch (Exception $e) {
                                notice(t('We encountered a problem while logging in with the OpenID you provided. Please check the correct spelling of the ID.').'<br /><br >'.t('The error message was:').' '.$e->getMessage());
index 0c637dc3af60197e45d6959a39297f07d7332dc4..842dbf0b1cf4595212a5c363f790867a0689cd7c 100644 (file)
@@ -144,8 +144,6 @@ function unescape_underscores_in_links($m) {
 
 function format_event_diaspora($ev) {
 
-       $a = get_app();
-
        if(! ((is_array($ev)) && count($ev)))
                return '';
 
@@ -160,7 +158,7 @@ function format_event_diaspora($ev) {
                        $ev['start'] , $bd_format ))
                        :  day_translate(datetime_convert('UTC', 'UTC',
                        $ev['start'] , $bd_format)))
-               .  '](' . $a->get_baseurl() . '/localtime/?f=&time=' . urlencode(datetime_convert('UTC','UTC',$ev['start'])) . ")\n";
+               .  '](' . App::get_baseurl() . '/localtime/?f=&time=' . urlencode(datetime_convert('UTC','UTC',$ev['start'])) . ")\n";
 
        if(! $ev['nofinish'])
                $o .= t('Finishes:') . ' ' . '['
@@ -168,7 +166,7 @@ function format_event_diaspora($ev) {
                                $ev['finish'] , $bd_format ))
                                :  day_translate(datetime_convert('UTC', 'UTC',
                                $ev['finish'] , $bd_format )))
-                       . '](' . $a->get_baseurl() . '/localtime/?f=&time=' . urlencode(datetime_convert('UTC','UTC',$ev['finish'])) . ")\n";
+                       . '](' . App::get_baseurl() . '/localtime/?f=&time=' . urlencode(datetime_convert('UTC','UTC',$ev['finish'])) . ")\n";
 
        if(strlen($ev['location']))
                $o .= t('Location:') . bb2diaspora($ev['location'])
index 27213007cebdfc8a6751a14fc0472ddadd0abe1b..c05173f47c559782cf8f1ad401f415112a82e1bf 100644 (file)
@@ -613,9 +613,7 @@ function GetProfileUsername($profile, $username, $compact = false, $getnetwork =
 }
 
 function bb_DiasporaLinks($match) {
-       $a = get_app();
-
-       return "[url=".$a->get_baseurl()."/display/".$match[1]."]".$match[2]."[/url]";
+       return "[url=".App::get_baseurl()."/display/".$match[1]."]".$match[2]."[/url]";
 }
 
 function bb_RemovePictureLinks($match) {
@@ -894,7 +892,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
        // we may need to restrict this further if it picks up too many strays
        // link acct:user@host to a webfinger profile redirector
 
-       $Text = preg_replace('/acct:([^@]+)@((?!\-)(?:[a-zA-Z\d\-]{0,62}[a-zA-Z\d]\.){1,126}(?!\d+)[a-zA-Z\d]{1,63})/', '<a href="' . $a->get_baseurl() . '/acctlink?addr=$1@$2" target="extlink">acct:$1@$2</a>',$Text);
+       $Text = preg_replace('/acct:([^@]+)@((?!\-)(?:[a-zA-Z\d\-]{0,62}[a-zA-Z\d]\.){1,126}(?!\d+)[a-zA-Z\d]{1,63})/', '<a href="' . App::get_baseurl() . '/acctlink?addr=$1@$2" target="extlink">acct:$1@$2</a>',$Text);
 
        // Perform MAIL Search
        $Text = preg_replace("/\[mail\]([$MAILSearchString]*)\[\/mail\]/", '<a href="mailto:$1">$1</a>', $Text);
@@ -1063,9 +1061,9 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
                        return(bb_ShareAttributes($match, $simplehtml));
                },$Text);
 
-       $Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism",'<br/><img src="' .$a->get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . t('Encrypted content') . '" /><br />', $Text);
-       $Text = preg_replace("/\[crypt(.*?)\](.*?)\[\/crypt\]/ism",'<br/><img src="' .$a->get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . '$1' . ' ' . t('Encrypted content') . '" /><br />', $Text);
-       //$Text = preg_replace("/\[crypt=(.*?)\](.*?)\[\/crypt\]/ism",'<br/><img src="' .$a->get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . '$1' . ' ' . t('Encrypted content') . '" /><br />', $Text);
+       $Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism",'<br/><img src="' .App::get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . t('Encrypted content') . '" /><br />', $Text);
+       $Text = preg_replace("/\[crypt(.*?)\](.*?)\[\/crypt\]/ism",'<br/><img src="' .App::get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . '$1' . ' ' . t('Encrypted content') . '" /><br />', $Text);
+       //$Text = preg_replace("/\[crypt=(.*?)\](.*?)\[\/crypt\]/ism",'<br/><img src="' .App::get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . '$1' . ' ' . t('Encrypted content') . '" /><br />', $Text);
 
 
        // Try to Oembed
index f66d23c518e5b16125d91c7d3381f92b17404ea2..71a75d431eaa3efba3769be507356ee41184f37f 100644 (file)
@@ -80,11 +80,13 @@ function networks_widget($baseurl,$selected = '') {
 
        $a = get_app();
 
-       if(!local_user())
+       if (!local_user()) {
                return '';
+       }
 
-       if(!feature_enabled(local_user(),'networks'))
+       if (!feature_enabled(local_user(),'networks')) {
                return '';
+       }
 
        $extra_sql = unavailable_networks();
 
@@ -116,16 +118,18 @@ function networks_widget($baseurl,$selected = '') {
 }
 
 function fileas_widget($baseurl,$selected = '') {
-       $a = get_app();
-       if(! local_user())
+       if (! local_user()) {
                return '';
+       }
 
-       if(! feature_enabled(local_user(),'filing'))
+       if (! feature_enabled(local_user(),'filing')) {
                return '';
+       }
 
        $saved = get_pconfig(local_user(),'system','filetags');
-       if(! strlen($saved))
+       if (! strlen($saved)) {
                return;
+       }
 
        $matches = false;
        $terms = array();
@@ -235,7 +239,7 @@ function common_friends_visitor_widget($profile_uid) {
 
        return replace_macros(get_markup_template('remote_friends_common.tpl'), array(
                '$desc' =>  sprintf( tt("%d contact in common", "%d contacts in common", $t), $t),
-               '$base' => $a->get_baseurl(),
+               '$base' => App::get_baseurl(),
                '$uid' => $profile_uid,
                '$cid' => (($cid) ? $cid : '0'),
                '$linkmore' => (($t > 5) ? 'true' : ''),
index 567bf83e1bfdb2e7b0d2d0a38af11fc2b37f298e..ccfc070d4e2d416be818e142fa65a73486cfb8b6 100644 (file)
@@ -324,11 +324,13 @@ function localize_item(&$item){
        // add sparkle links to appropriate permalinks
 
        $x = stristr($item['plink'],'/display/');
-       if($x) {
+       if ($x) {
                $sparkle = false;
                $y = best_link_url($item,$sparkle,true);
-               if(strstr($y,'/redir/'))
+
+               if (strstr($y,'/redir/')) {
                        $item['plink'] = $y . '?f=&url=' . $item['plink'];
+               }
        }
 
 
@@ -864,7 +866,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
        }
 
        $o = replace_macros($page_template, array(
-               '$baseurl' => $a->get_baseurl($ssl_state),
+               '$baseurl' => App::get_baseurl($ssl_state),
                '$return_path' => $a->query_string,
                '$live_update' => $live_update_div,
                '$remove' => t('remove'),
@@ -1183,7 +1185,7 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
        $tpl = get_markup_template('jot-header.tpl');
        $a->page['htmlhead'] .= replace_macros($tpl, array(
                '$newpost' => 'true',
-               '$baseurl' => $a->get_baseurl(true),
+               '$baseurl' => App::get_baseurl(true),
                '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
                '$geotag' => $geotag,
                '$nickname' => $x['nickname'],
@@ -1201,7 +1203,7 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
        $tpl = get_markup_template('jot-end.tpl');
        $a->page['end'] .= replace_macros($tpl, array(
                '$newpost' => 'true',
-               '$baseurl' => $a->get_baseurl(true),
+               '$baseurl' => App::get_baseurl(true),
                '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
                '$geotag' => $geotag,
                '$nickname' => $x['nickname'],
@@ -1267,7 +1269,7 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
                '$ptyp' => (($notes_cid) ? 'note' : 'wall'),
                '$content' => $x['content'],
                '$post_id' => $x['post_id'],
-               '$baseurl' => $a->get_baseurl(true),
+               '$baseurl' => App::get_baseurl(true),
                '$defloc' => $x['default_location'],
                '$visitor' => $x['visitor'],
                '$pvisit' => (($notes_cid) ? 'none' : $x['visitor']),
index 77332dcec6c2daa300b2222b496dfd2fee0cdbc8..e98239b82931aa4a74f56904037843c1385f1102 100644 (file)
@@ -264,7 +264,7 @@ function cron_poll_contacts($argc, $argv) {
                        intval($c['id'])
                );
 
-               if((! $res) || (! count($res)))
+               if (dbm::is_result($res))
                        continue;
 
                foreach($res as $contact) {
@@ -343,7 +343,7 @@ function cron_poll_contacts($argc, $argv) {
  *
  * @param App $a
  */
-function cron_clear_cache(&$a) {
+function cron_clear_cache(App &$a) {
 
        $last = get_config('system','cache_last_cleared');
 
@@ -430,7 +430,7 @@ function cron_clear_cache(&$a) {
  *
  * @param App $a
  */
-function cron_repair_diaspora(&$a) {
+function cron_repair_diaspora(App &$a) {
        $r = q("SELECT `id`, `url` FROM `contact`
                WHERE `network` = '%s' AND (`batch` = '' OR `notify` = '' OR `poll` = '' OR pubkey = '')
                        ORDER BY RAND() LIMIT 50", dbesc(NETWORK_DIASPORA));
index c694014f68fae8b11b7d952bc538b1efac9b8f56..be1158eabec341f02c56c69a3834091ac2704f2c 100644 (file)
@@ -56,11 +56,11 @@ function update_fail($update_id, $error_message){
        $email_tpl = get_intltext_template("update_fail_eml.tpl");
        $email_msg = replace_macros($email_tpl, array(
                '$sitename' => $a->config['sitename'],
-               '$siteurl' =>  $a->get_baseurl(),
+               '$siteurl' =>  App::get_baseurl(),
                '$update' => DB_UPDATE_VERSION,
                '$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION)
        ));
-       $subject=sprintf(t('Update Error at %s'), $a->get_baseurl());
+       $subject=sprintf(t('Update Error at %s'), App::get_baseurl());
        require_once('include/email.php');
        $subject = email_header_encode($subject,'UTF-8');
        mail($a->config['admin_email'], $subject, $email_msg,
index a7aebe709a29b726a504cd300a201b8832429320..db2f03c8f4a7c77c5fc25ed6ad9ea3d4e688bddc 100644 (file)
@@ -323,7 +323,7 @@ function delivery_run(&$argv, &$argc){
 
                                // perform local delivery if we are on the same site
 
-                               if (link_compare($basepath,$a->get_baseurl())) {
+                               if (link_compare($basepath,App::get_baseurl())) {
 
                                        $nickname = basename($contact['url']);
                                        if ($contact['issued-id'])
index 6451b8521bf326bac30fccdf00e3b19d8c8e28aa..90ff1dfbbf6b288855713ac9859dee6e8574d2ba 100644 (file)
@@ -105,8 +105,9 @@ class dfrn {
                        dbesc($owner_nick)
                );
 
-               if(! dbm::is_result($r))
+               if (! dbm::is_result($r)) {
                        killme();
+               }
 
                $owner = $r[0];
                $owner_id = $owner['uid'];
@@ -139,8 +140,9 @@ class dfrn {
                                intval($owner_id)
                        );
 
-                       if(! dbm::is_result($r))
+                       if (! dbm::is_result($r)) {
                                killme();
+                       }
 
                        $contact = $r[0];
                        require_once('include/security.php');
@@ -2353,7 +2355,7 @@ class dfrn {
                                                dbesc($xt->id),
                                                intval($importer["importer_uid"])
                                        );
-                                       if(count($i)) {
+                                       if (dbm::is_result($i)) {
 
                                                // For tags, the owner cannot remove the tag on the author's copy of the post.
 
index 2c05d3233fd4786b0e81eb1e789f444ec1776030..42f80c24273e2c6d4aaf1c894259504ab0fbf49b 100644 (file)
@@ -96,15 +96,20 @@ function email_get_msg($mbox,$uid, $reply) {
                $html = '';
                foreach($struc->parts as $ptop => $p) {
                        $x = email_get_part($mbox,$uid,$p,$ptop + 1, 'plain');
-                       if($x)  $text .= $x;
+                       if ($x) {
+                               $text .= $x;
+                       }
 
                        $x = email_get_part($mbox,$uid,$p,$ptop + 1, 'html');
-                       if($x)  $html .= $x;
+                       if ($x) {
+                               $html .= $x;
+                       }
                }
-               if (trim($html) != '')
+               if (trim($html) != '') {
                        $ret['body'] = html2bbcode($html);
-               else
+               } else {
                        $ret['body'] = $text;
+               }
        }
 
        $ret['body'] = removegpg($ret['body']);
@@ -112,8 +117,9 @@ function email_get_msg($mbox,$uid, $reply) {
        $ret['body'] = $msg['body'];
        $ret['body'] = convertquote($ret['body'], $reply);
 
-       if (trim($html) != '')
+       if (trim($html) != '') {
                $ret['body'] = removelinebreak($ret['body']);
+       }
 
        $ret['body'] = unifyattributionline($ret['body']);
 
@@ -189,8 +195,9 @@ function email_get_part($mbox,$uid,$p,$partno, $subtype) {
                $x = "";
                foreach ($p->parts as $partno0=>$p2) {
                        $x .=  email_get_part($mbox,$uid,$p2,$partno . '.' . ($partno0+1), $subtype);  // 1.2, 1.2.1, etc.
-                       //if($x)
+                       //if ($x) {
                        //      return $x;
+                       //}
                }
                return $x;
        }
index c6e0506e96ef2e34191e6d3fd250f4192e068a8a..aa29e117a697d8b6c983c42f1dd5616a9c857cad 100644 (file)
@@ -23,7 +23,7 @@ function notification($params) {
 
        $banner = t('Friendica Notification');
        $product = FRIENDICA_PLATFORM;
-       $siteurl = $a->get_baseurl(true);
+       $siteurl = App::get_baseurl(true);
        $thanks = t('Thank You,');
        $sitename = $a->config['sitename'];
        if (!x($a->config['admin_name']))
@@ -58,7 +58,7 @@ function notification($params) {
        $additional_mail_header .= "X-Friendica-Platform: ".FRIENDICA_PLATFORM."\n";
        $additional_mail_header .= "X-Friendica-Version: ".FRIENDICA_VERSION."\n";
        $additional_mail_header .= "List-ID: <notification.".$hostname.">\n";
-       $additional_mail_header .= "List-Archive: <".$a->get_baseurl()."/notifications/system>\n";
+       $additional_mail_header .= "List-Archive: <".App::get_baseurl()."/notifications/system>\n";
 
        if (array_key_exists('item', $params)) {
                $title = $params['item']['title'];
@@ -494,7 +494,7 @@ function notification($params) {
                }
 
 
-               $itemlink = $a->get_baseurl().'/notify/view/'.$notify_id;
+               $itemlink = App::get_baseurl().'/notify/view/'.$notify_id;
                $msg = replace_macros($epreamble, array('$itemlink' => $itemlink));
                $msg_cache = format_notification_message($datarray['name_cache'], strip_tags(bbcode($msg)));
                $r = q("UPDATE `notify` SET `msg` = '%s', `msg_cache` = '%s' WHERE `id` = %d AND `uid` = %d",
@@ -648,8 +648,6 @@ function notification($params) {
  * @param str $defaulttype (Optional) Forces a notification with this type.
  */
 function check_item_notification($itemid, $uid, $defaulttype = "") {
-       $a = get_app();
-
        $notification_data = array("uid" => $uid, "profiles" => array());
        call_hooks('check_item_notification', $notification_data);
 
@@ -667,7 +665,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
        $profiles[] = $owner[0]["url"];
 
        // Notifications from Diaspora are often with an URL in the Diaspora format
-       $profiles[] = $a->get_baseurl()."/u/".$user[0]["nickname"];
+       $profiles[] = App::get_baseurl()."/u/".$user[0]["nickname"];
 
        $profiles2 = array();
 
index 3a41dad4e70dd5b66b3f51cc964f62b8271b3e5e..73e61f25cf3949a20585aafc9dff55a172be6da2 100644 (file)
@@ -206,7 +206,7 @@ function bbtoevent($s) {
 }
 
 
-function sort_by_date($a) {
+function sort_by_date(App &$a) {
 
        usort($a,'ev_compare');
        return $a;
@@ -408,7 +408,7 @@ function event_store($arr) {
                        intval($arr['uid'])
                );
                //if (dbm::is_result($r))
-               //      $plink = $a->get_baseurl() . '/display/' . $r[0]['nickname'] . '/' . $item_id;
+               //      $plink = App::get_baseurl() . '/display/' . $r[0]['nickname'] . '/' . $item_id;
 
 
                if($item_id) {
index 7a3514b3a73aa4942ca00f009cc6128361782461..15e8dd28d8739a09c20a5fb9a8efc2c34b1674d7 100644 (file)
@@ -77,12 +77,12 @@ function new_contact($uid,$url,$interactive = false) {
 
        $url = str_replace('/#!/','/',$url);
 
-       if(! allowed_url($url)) {
+       if (! allowed_url($url)) {
                $result['message'] = t('Disallowed profile URL.');
                return $result;
        }
 
-       if(! $url) {
+       if (! $url) {
                $result['message'] = t('Connect URL missing.');
                return $result;
        }
@@ -91,17 +91,21 @@ function new_contact($uid,$url,$interactive = false) {
 
        call_hooks('follow', $arr);
 
-       if(x($arr['contact'],'name'))
+       if (x($arr['contact'],'name')) {
                $ret = $arr['contact'];
-       else
+       }
+       else {
                $ret = probe_url($url);
+       }
 
-       if($ret['network'] === NETWORK_DFRN) {
-               if($interactive) {
-                       if(strlen($a->path))
-                               $myaddr = bin2hex($a->get_baseurl() . '/profile/' . $a->user['nickname']);
-                       else
+       if ($ret['network'] === NETWORK_DFRN) {
+               if ($interactive) {
+                       if (strlen($a->path)) {
+                               $myaddr = bin2hex(App::get_baseurl() . '/profile/' . $a->user['nickname']);
+                       }
+                       else {
                                $myaddr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname());
+                       }
 
                        goaway($ret['request'] . "&addr=$myaddr");
 
@@ -254,7 +258,7 @@ function new_contact($uid,$url,$interactive = false) {
                intval($uid)
        );
 
-       if(! dbm::is_result($r)) {
+       if (! dbm::is_result($r)) {
                $result['message'] .=  t('Unable to retrieve contact information.') . EOL;
                return $result;
        }
index 2c903306864da2caa1ef4368212faffb6c016c43..a2a55c44403b61f69f31e54d245e1f7507fba878 100644 (file)
@@ -143,13 +143,14 @@ function group_add_member($uid,$name,$member,$gid = 0) {
                return true;    // You might question this, but
                                // we indicate success because the group member was in fact created
                                // -- It was just created at another time
-       if(! dbm::is_result($r))
+       if (! dbm::is_result($r)) {
                $r = q("INSERT INTO `group_member` (`uid`, `gid`, `contact-id`)
                        VALUES( %d, %d, %d ) ",
                        intval($uid),
                        intval($gid),
                        intval($member)
-       );
+               );
+       }
        return $r;
 }
 
@@ -233,7 +234,7 @@ function group_side($every="contacts",$each="group",$editmode = "standard", $gro
 
        $o = '';
 
-       if(! local_user())
+       if (! local_user())
                return '';
 
        $groups = array();
index bf05a005160eb81d83e7a1012bf21052f98bba82..380560228ab81b7b0229ed7d04b013e14f15edb1 100644 (file)
@@ -229,13 +229,16 @@ function profile_sidebar($profile, $block = 0) {
 
        // Is the local user already connected to that user?
        if ($connect AND local_user()) {
-               if (isset($profile["url"]))
+               if (isset($profile["url"])) {
                        $profile_url = normalise_link($profile["url"]);
-               else
-                       $profile_url = normalise_link($a->get_baseurl()."/profile/".$profile["nickname"]);
+               }
+               else {
+                       $profile_url = normalise_link(App::get_baseurl()."/profile/".$profile["nickname"]);
+               }
 
                $r = q("SELECT * FROM `contact` WHERE NOT `pending` AND `uid` = %d AND `nurl` = '%s'",
                        local_user(), $profile_url);
+
                if (dbm::is_result($r))
                        $connect = false;
        }
@@ -279,7 +282,7 @@ function profile_sidebar($profile, $block = 0) {
 
        // show edit profile to yourself
        if ($profile['uid'] == local_user() && feature_enabled(local_user(),'multi_profiles')) {
-               $profile['edit'] = array($a->get_baseurl(). '/profiles', t('Profiles'),"", t('Manage/edit profiles'));
+               $profile['edit'] = array(App::get_baseurl(). '/profiles', t('Profiles'),"", t('Manage/edit profiles'));
                $r = q("SELECT * FROM `profile` WHERE `uid` = %d",
                                local_user());
 
@@ -308,7 +311,7 @@ function profile_sidebar($profile, $block = 0) {
                }
        }
        if ($profile['uid'] == local_user() && !feature_enabled(local_user(),'multi_profiles')) {
-               $profile['edit'] = array($a->get_baseurl(). '/profiles/'.$profile['id'], t('Edit profile'),"", t('Edit profile'));
+               $profile['edit'] = array(App::get_baseurl(). '/profiles/'.$profile['id'], t('Edit profile'),"", t('Edit profile'));
                $profile['menu'] = array(
                        'chg_photo' => t('Change profile photo'),
                        'cr_new' => null,
@@ -349,15 +352,15 @@ function profile_sidebar($profile, $block = 0) {
        if ($profile['guid'] != "")
                $diaspora = array(
                        'guid' => $profile['guid'],
-                       'podloc' => $a->get_baseurl(),
+                       'podloc' => App::get_baseurl(),
                        'searchable' => (($profile['publish'] && $profile['net-publish']) ? 'true' : 'false' ),
                        'nickname' => $profile['nickname'],
                        'fullname' => $profile['name'],
                        'firstname' => $firstname,
                        'lastname' => $lastname,
-                       'photo300' => $a->get_baseurl() . '/photo/custom/300/' . $profile['uid'] . '.jpg',
-                       'photo100' => $a->get_baseurl() . '/photo/custom/100/' . $profile['uid'] . '.jpg',
-                       'photo50' => $a->get_baseurl() . '/photo/custom/50/'  . $profile['uid'] . '.jpg',
+                       'photo300' => App::get_baseurl() . '/photo/custom/300/' . $profile['uid'] . '.jpg',
+                       'photo100' => App::get_baseurl() . '/photo/custom/100/' . $profile['uid'] . '.jpg',
+                       'photo50' => App::get_baseurl() . '/photo/custom/50/'  . $profile['uid'] . '.jpg',
                );
        else
                $diaspora = false;
@@ -489,7 +492,7 @@ function get_birthdays() {
                                $url = $rr['url'];
                                if($rr['network'] === NETWORK_DFRN) {
                                        $sparkle = " sparkle";
-                                       $url = $a->get_baseurl() . '/redir/'  . $rr['cid'];
+                                       $url = App::get_baseurl() . '/redir/'  . $rr['cid'];
                                }
 
                                $rr['link'] = $url;
@@ -503,7 +506,7 @@ function get_birthdays() {
        }
        $tpl = get_markup_template("birthdays_reminder.tpl");
        return replace_macros($tpl, array(
-               '$baseurl' => $a->get_baseurl(),
+               '$baseurl' => App::get_baseurl(),
                '$classtoday' => $classtoday,
                '$count' => $total,
                '$event_reminders' => t('Birthday Reminders'),
@@ -587,7 +590,7 @@ function get_events() {
 
        $tpl = get_markup_template("events_reminder.tpl");
        return replace_macros($tpl, array(
-               '$baseurl' => $a->get_baseurl(),
+               '$baseurl' => App::get_baseurl(),
                '$classtoday' => $classtoday,
                '$count' => count($r) - $skip,
                '$event_reminders' => t('Event Reminders'),
@@ -596,7 +599,7 @@ function get_events() {
        ));
 }
 
-function advanced_profile(&$a) {
+function advanced_profile(App &$a) {
 
        $o = '';
        $uid = $a->profile['uid'];
@@ -684,8 +687,9 @@ function advanced_profile(&$a) {
                        $profile['forumlist'] = array( t('Forums:'), ForumManager::profile_advanced($uid));
                }
 
-               if ($a->profile['uid'] == local_user())
-                       $profile['edit'] = array($a->get_baseurl(). '/profiles/'.$a->profile['id'], t('Edit profile'),"", t('Edit profile'));
+               if ($a->profile['uid'] == local_user()) {
+                       $profile['edit'] = array(App::get_baseurl(). '/profiles/'.$a->profile['id'], t('Edit profile'),"", t('Edit profile'));
+               }
 
                return replace_macros($tpl, array(
                        '$title' => t('Profile'),
@@ -707,7 +711,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
        if(x($_GET,'tab'))
                $tab = notags(trim($_GET['tab']));
 
-       $url = $a->get_baseurl() . '/profile/' . $nickname;
+       $url = App::get_baseurl() . '/profile/' . $nickname;
 
        $tabs = array(
                array(
@@ -728,7 +732,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
                ),
                array(
                        'label' => t('Photos'),
-                       'url'   => $a->get_baseurl() . '/photos/' . $nickname,
+                       'url'   => App::get_baseurl() . '/photos/' . $nickname,
                        'sel'   => ((!isset($tab)&&$a->argv[0]=='photos')?'active':''),
                        'title' => t('Photo Albums'),
                        'id' => 'photo-tab',
@@ -736,7 +740,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
                ),
                array(
                        'label' => t('Videos'),
-                       'url'   => $a->get_baseurl() . '/videos/' . $nickname,
+                       'url'   => App::get_baseurl() . '/videos/' . $nickname,
                        'sel'   => ((!isset($tab)&&$a->argv[0]=='videos')?'active':''),
                        'title' => t('Videos'),
                        'id' => 'video-tab',
@@ -748,7 +752,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
        if ($is_owner && $a->theme_events_in_profile) {
                        $tabs[] = array(
                                'label' => t('Events'),
-                               'url'   => $a->get_baseurl() . '/events',
+                               'url'   => App::get_baseurl() . '/events',
                                'sel'   =>((!isset($tab)&&$a->argv[0]=='events')?'active':''),
                                'title' => t('Events and Calendar'),
                                'id' => 'events-tab',
@@ -759,7 +763,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
        } elseif (! $is_owner) {
                $tabs[] = array(
                                'label' => t('Events'),
-                               'url'   => $a->get_baseurl() . '/cal/' . $nickname,
+                               'url'   => App::get_baseurl() . '/cal/' . $nickname,
                                'sel'   =>((!isset($tab)&&$a->argv[0]=='cal')?'active':''),
                                'title' => t('Events and Calendar'),
                                'id' => 'events-tab',
@@ -770,7 +774,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
        if ($is_owner){
                $tabs[] = array(
                        'label' => t('Personal Notes'),
-                       'url'   => $a->get_baseurl() . '/notes',
+                       'url'   => App::get_baseurl() . '/notes',
                        'sel'   =>((!isset($tab)&&$a->argv[0]=='notes')?'active':''),
                        'title' => t('Only You Can See This'),
                        'id' => 'notes-tab',
@@ -781,7 +785,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
        if ((! $is_owner) && ((count($a->profile)) || (! $a->profile['hide-friends']))) {
                $tabs[] = array(
                        'label' => t('Contacts'),
-                       'url'   => $a->get_baseurl() . '/viewcontacts/' . $nickname,
+                       'url'   => App::get_baseurl() . '/viewcontacts/' . $nickname,
                        'sel'   => ((!isset($tab)&&$a->argv[0]=='viewcontacts')?'active':''),
                        'title' => t('Contacts'),
                        'id' => 'viewcontacts-tab',
@@ -803,7 +807,7 @@ function get_my_url() {
        return false;
 }
 
-function zrl_init(&$a) {
+function zrl_init(App &$a) {
        $tmp_str = get_my_url();
        if(validate_url($tmp_str)) {
 
index da9147faddddd4da00cc2d7050b74cfe6c2d7dd2..c75bc768c2de9a3a7ea6b1d2b40adc932da94339 100644 (file)
@@ -208,13 +208,12 @@ function add_page_info_data($data) {
 
        $hashtags = "";
        if (isset($data["keywords"]) AND count($data["keywords"])) {
-               $a = get_app();
                $hashtags = "\n";
                foreach ($data["keywords"] AS $keyword) {
                        /// @todo make a positive list of allowed characters
                        $hashtag = str_replace(array(" ", "+", "/", ".", "#", "'", "’", "`", "(", ")", "„", "“"),
                                                array("","", "", "", "", "", "", "", "", "", "", ""), $keyword);
-                       $hashtags .= "#[url=".$a->get_baseurl()."/search?tag=".rawurlencode($hashtag)."]".$hashtag."[/url] ";
+                       $hashtags .= "#[url=".App::get_baseurl()."/search?tag=".rawurlencode($hashtag)."]".$hashtag."[/url] ";
                }
        }
 
@@ -251,7 +250,6 @@ function add_page_keywords($url, $no_photos = false, $photo = "", $keywords = fa
 
        $tags = "";
        if (isset($data["keywords"]) AND count($data["keywords"])) {
-               $a = get_app();
                foreach ($data["keywords"] AS $keyword) {
                        $hashtag = str_replace(array(" ", "+", "/", ".", "#", "'"),
                                                array("","", "", "", "", ""), $keyword);
@@ -259,7 +257,7 @@ function add_page_keywords($url, $no_photos = false, $photo = "", $keywords = fa
                        if ($tags != "")
                                $tags .= ",";
 
-                       $tags .= "#[url=".$a->get_baseurl()."/search?tag=".rawurlencode($hashtag)."]".$hashtag."[/url]";
+                       $tags .= "#[url=".App::get_baseurl()."/search?tag=".rawurlencode($hashtag)."]".$hashtag."[/url]";
                }
        }
 
@@ -557,8 +555,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
                logger("Both author-link and owner-link are empty. Called by: ".App::callstack(), LOGGER_DEBUG);
 
        if ($arr['plink'] == "") {
-               $a = get_app();
-               $arr['plink'] = $a->get_baseurl().'/display/'.urlencode($arr['guid']);
+               $arr['plink'] = App::get_baseurl().'/display/'.urlencode($arr['guid']);
        }
 
        if ($arr['network'] == "") {
@@ -707,9 +704,9 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
                        // If its a post from myself then tag the thread as "mention"
                        logger("item_store: Checking if parent ".$parent_id." has to be tagged as mention for user ".$arr['uid'], LOGGER_DEBUG);
                        $u = q("SELECT `nickname` FROM `user` WHERE `uid` = %d", intval($arr['uid']));
-                       if (count($u)) {
+                       if (dbm::is_result($u)) {
                                $a = get_app();
-                               $self = normalise_link($a->get_baseurl() . '/profile/' . $u[0]['nickname']);
+                               $self = normalise_link(App::get_baseurl() . '/profile/' . $u[0]['nickname']);
                                logger("item_store: 'myself' is ".$self." for parent ".$parent_id." checking against ".$arr['author-link']." and ".$arr['owner-link'], LOGGER_DEBUG);
                                if ((normalise_link($arr['author-link']) == $self) OR (normalise_link($arr['owner-link']) == $self)) {
                                        q("UPDATE `thread` SET `mention` = 1 WHERE `iid` = %d", intval($parent_id));
@@ -956,8 +953,8 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
        // in it.
        if (!$deleted AND !$dontcache) {
 
-               $r = q('SELECT * FROM `item` WHERE id = %d', intval($current_post));
-               if (count($r) == 1) {
+               $r = q('SELECT * FROM `item` WHERE `id` = %d', intval($current_post));
+               if ((dbm::is_result($r)) && (count($r) == 1)) {
                        if ($notify)
                                call_hooks('post_local_end', $r[0]);
                        else
@@ -1068,10 +1065,10 @@ function item_body_set_hashtags(&$item) {
 
        // All hashtags should point to the home server
        //$item["body"] = preg_replace("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
-       //              "#[url=".$a->get_baseurl()."/search?tag=$2]$2[/url]", $item["body"]);
+       //              "#[url=".App::get_baseurl()."/search?tag=$2]$2[/url]", $item["body"]);
 
        //$item["tag"] = preg_replace("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
-       //              "#[url=".$a->get_baseurl()."/search?tag=$2]$2[/url]", $item["tag"]);
+       //              "#[url=".App::get_baseurl()."/search?tag=$2]$2[/url]", $item["tag"]);
 
        // mask hashtags inside of url, bookmarks and attachments to avoid urls in urls
        $item["body"] = preg_replace_callback("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
@@ -1103,7 +1100,7 @@ function item_body_set_hashtags(&$item) {
 
                $basetag = str_replace('_',' ',substr($tag,1));
 
-               $newtag = '#[url='.$a->get_baseurl().'/search?tag='.rawurlencode($basetag).']'.$basetag.'[/url]';
+               $newtag = '#[url='.App::get_baseurl().'/search?tag='.rawurlencode($basetag).']'.$basetag.'[/url]';
 
                $item["body"] = str_replace($tag, $newtag, $item["body"]);
 
@@ -1191,28 +1188,31 @@ function tag_deliver($uid,$item_id) {
        $u = q("select * from user where uid = %d limit 1",
                intval($uid)
        );
-       if (! count($u))
+
+       if (! dbm::is_result($u)) {
                return;
+       }
 
        $community_page = (($u[0]['page-flags'] == PAGE_COMMUNITY) ? true : false);
        $prvgroup = (($u[0]['page-flags'] == PAGE_PRVGROUP) ? true : false);
 
 
-       $i = q("select * from item where id = %d and uid = %d limit 1",
+       $i = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
                intval($item_id),
                intval($uid)
        );
-       if (! count($i))
+       if (! dbm::is_result($i)) {
                return;
+       }
 
        $item = $i[0];
 
-       $link = normalise_link($a->get_baseurl() . '/profile/' . $u[0]['nickname']);
+       $link = normalise_link(App::get_baseurl() . '/profile/' . $u[0]['nickname']);
 
        // Diaspora uses their own hardwired link URL in @-tags
        // instead of the one we supply with webfinger
 
-       $dlink = normalise_link($a->get_baseurl() . '/u/' . $u[0]['nickname']);
+       $dlink = normalise_link(App::get_baseurl() . '/u/' . $u[0]['nickname']);
 
        $cnt = preg_match_all('/[\@\!]\[url\=(.*?)\](.*?)\[\/url\]/ism',$item['body'],$matches,PREG_SET_ORDER);
        if ($cnt) {
@@ -1301,23 +1301,24 @@ function tgroup_check($uid,$item) {
        if (($item['wall']) || ($item['origin']) || ($item['uri'] != $item['parent-uri']))
                return false;
 
-
-       $u = q("select * from user where uid = %d limit 1",
+       /// @TODO Encapsulate this or find it encapsulated and replace all occurrances
+       $u = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
                intval($uid)
        );
-       if (! count($u))
+       if (! dbm::is_result($u)) {
                return false;
+       }
 
        $community_page = (($u[0]['page-flags'] == PAGE_COMMUNITY) ? true : false);
        $prvgroup = (($u[0]['page-flags'] == PAGE_PRVGROUP) ? true : false);
 
 
-       $link = normalise_link($a->get_baseurl() . '/profile/' . $u[0]['nickname']);
+       $link = normalise_link(App::get_baseurl() . '/profile/' . $u[0]['nickname']);
 
        // Diaspora uses their own hardwired link URL in @-tags
        // instead of the one we supply with webfinger
 
-       $dlink = normalise_link($a->get_baseurl() . '/u/' . $u[0]['nickname']);
+       $dlink = normalise_link(App::get_baseurl() . '/u/' . $u[0]['nickname']);
 
        $cnt = preg_match_all('/[\@\!]\[url\=(.*?)\](.*?)\[\/url\]/ism',$item['body'],$matches,PREG_SET_ORDER);
        if ($cnt) {
@@ -1572,7 +1573,7 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
                                        'to_name'      => $r[0]['username'],
                                        'to_email'     => $r[0]['email'],
                                        'uid'          => $r[0]['uid'],
-                                       'link'             => $a->get_baseurl() . '/notifications/intro',
+                                       'link'             => App::get_baseurl() . '/notifications/intro',
                                        'source_name'  => ((strlen(stripslashes($contact_record['name']))) ? stripslashes($contact_record['name']) : t('[Name Withheld]')),
                                        'source_link'  => $contact_record['url'],
                                        'source_photo' => $contact_record['photo'],
@@ -1665,7 +1666,7 @@ function fix_private_photos($s, $uid, $item = null, $cid = 0) {
        $a = get_app();
 
        logger('fix_private_photos: check for photos', LOGGER_DEBUG);
-       $site = substr($a->get_baseurl(),strpos($a->get_baseurl(),'://'));
+       $site = substr(App::get_baseurl(),strpos(App::get_baseurl(),'://'));
 
        $orig_body = $s;
        $new_body = '';
@@ -1929,7 +1930,7 @@ function drop_item($id,$interactive = true) {
                if (! $interactive)
                        return 0;
                notice( t('Item not found.') . EOL);
-               goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
+               goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
        }
 
        $item = $r[0];
@@ -1977,7 +1978,7 @@ function drop_item($id,$interactive = true) {
                }
                // Now check how the user responded to the confirmation query
                if ($_REQUEST['canceled']) {
-                       goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
+                       goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
                }
 
                logger('delete item: ' . $item['id'], LOGGER_DEBUG);
@@ -2127,13 +2128,13 @@ function drop_item($id,$interactive = true) {
 
                if (! $interactive)
                        return $owner;
-               goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
+               goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
                //NOTREACHED
        } else {
                if (! $interactive)
                        return 0;
                notice( t('Permission denied.') . EOL);
-               goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
+               goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
                //NOTREACHED
        }
 
@@ -2230,7 +2231,7 @@ function posted_date_widget($url,$uid,$wall) {
 
        $ret = list_post_dates($uid,$wall);
 
-       if (! count($ret))
+       if (! dbm::is_result($ret))
                return $o;
 
        $cutoff_year = intval(datetime_convert('',date_default_timezone_get(),'now','Y')) - $visible_years;
index e997e05d6b0e43601d6924dd1bf23ebec532915c..b04b9b4e0991540366cc3e9a18f27d377357f1ab 100644 (file)
@@ -78,8 +78,9 @@ function do_like($item_id, $verb) {
                        intval($item['contact-id']),
                        intval($item['uid'])
                );
-               if(! dbm::is_result($r))
+               if (! dbm::is_result($r)) {
                        return false;
+               }
                if(! $r[0]['self'])
                        $remote_owner = $r[0];
        }
@@ -164,7 +165,7 @@ function do_like($item_id, $verb) {
        if($item['object-type'] === ACTIVITY_OBJ_EVENT)
                $post_type = t('event');
        $objtype = (($item['resource-id']) ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE );
-       $link = xmlify('<link rel="alternate" type="text/html" href="' . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n") ;
+       $link = xmlify('<link rel="alternate" type="text/html" href="' . App::get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n") ;
        $body = $item['body'];
 
        $obj = <<< EOT
@@ -214,7 +215,7 @@ EOT;
 
        $ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
        $alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
-       $plink = '[url=' . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]';
+       $plink = '[url=' . App::get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]';
        $arr['body'] =  sprintf( $bodyverb, $ulink, $alink, $plink );
 
        $arr['verb'] = $activity;
index 0c7b6acaa4afbaa45c440fccb194399ea60539d2..b3d488a3577fba08fe2bf01bf5ac44c689f3cf12 100644 (file)
@@ -23,7 +23,8 @@ function lock_function($fn_name, $block = true, $wait_sec = 2, $timeout = 30) {
                        );
                        $got_lock = true;
                }
-               elseif(! dbm::is_result($r)) { // the Boolean value for count($r) should be equivalent to the Boolean value of $r
+               elseif (! dbm::is_result($r)) {
+                       /// @TODO the Boolean value for count($r) should be equivalent to the Boolean value of $r
                        q("INSERT INTO `locks` (`name`, `created`, `locked`) VALUES ('%s', '%s', 1)",
                                dbesc($fn_name),
                                dbesc(datetime_convert())
index ea2fcef3bcb213e24ed280b844f05c90507d3f91..e5ebe6f9158ac1f895d65ba53d998bb6462f6417 100644 (file)
@@ -27,7 +27,7 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
        }
 
        $guid = get_guid(32);
-       $uri = 'urn:X-dfrn:' . $a->get_baseurl() . ':' . local_user() . ':' . $guid;
+       $uri = 'urn:X-dfrn:' . App::get_baseurl() . ':' . local_user() . ':' . $guid;
 
        $convid = 0;
        $reply = false;
@@ -53,7 +53,7 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
                $recip_host = substr($recip_host,0,strpos($recip_host,'/'));
 
                $recip_handle = (($contact[0]['addr']) ? $contact[0]['addr'] : $contact[0]['nick'] . '@' . $recip_host);
-               $sender_handle = $a->user['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
+               $sender_handle = $a->user['nickname'] . '@' . substr(App::get_baseurl(), strpos(App::get_baseurl(),'://') + 3);
 
                $conv_guid = get_guid(32);
                $convuri = $recip_handle.':'.$conv_guid;
@@ -134,7 +134,7 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
                $images = $match[1];
                if(count($images)) {
                        foreach($images as $image) {
-                               if(! stristr($image,$a->get_baseurl() . '/photo/'))
+                               if(! stristr($image,App::get_baseurl() . '/photo/'))
                                        continue;
                                $image_uri = substr($image,strrpos($image,'/') + 1);
                                $image_uri = substr($image_uri,0, strpos($image_uri,'-'));
@@ -164,16 +164,13 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
 
 function send_wallmessage($recipient='', $body='', $subject='', $replyto=''){
 
-       $a = get_app();
-
-
        if(! $recipient) return -1;
 
        if(! strlen($subject))
                $subject = t('[no subject]');
 
        $guid = get_guid(32);
-       $uri = 'urn:X-dfrn:' . $a->get_baseurl() . ':' . local_user() . ':' . $guid;
+       $uri = 'urn:X-dfrn:' . App::get_baseurl() . ':' . local_user() . ':' . $guid;
 
        $convid = 0;
        $reply = false;
@@ -187,7 +184,7 @@ function send_wallmessage($recipient='', $body='', $subject='', $replyto=''){
 
        $conv_guid = get_guid(32);
 
-       $recip_handle = $recipient['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
+       $recip_handle = $recipient['nickname'] . '@' . substr(App::get_baseurl(), strpos(App::get_baseurl(),'://') + 3);
 
        $sender_nick = basename($replyto);
        $sender_host = substr($replyto,strpos($replyto,'://')+3);
index 2a9f24ca9f5644e351e4ac29fd7ee2a676a4074e..bd933929d3b6b78ee7e8a3113558cd965e3d152d 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-function nav(&$a) {
+function nav(App &$a) {
 
        /*
         *
@@ -28,7 +28,7 @@ function nav(&$a) {
        $tpl = get_markup_template('nav.tpl');
 
        $a->page['nav'] .= replace_macros($tpl, array(
-               '$baseurl' => $a->get_baseurl(),
+               '$baseurl' => App::get_baseurl(),
                '$sitelocation' => $nav_info['sitelocation'],
                '$nav' => $nav_info['nav'],
                '$banner' => $nav_info['banner'],
@@ -65,7 +65,7 @@ function nav_info(App $a)
 
        $myident = ((is_array($a->user) && isset($a->user['nickname'])) ? $a->user['nickname'] . '@' : '');
 
-       $sitelocation = $myident . substr($a->get_baseurl($ssl_state), strpos($a->get_baseurl($ssl_state), '//') + 2 );
+       $sitelocation = $myident . substr(App::get_baseurl($ssl_state), strpos(App::get_baseurl($ssl_state), '//') + 2 );
 
        // nav links: array of array('href', 'text', 'extra css classes', 'title')
        $nav = array();
index df46d35932fcb694b506a3bc361516e118d609fa..7a662e4cbf08585a3a1bed493c060ab0418a600a 100644 (file)
@@ -513,8 +513,6 @@ function allowed_email($email) {
 
 function avatar_img($email) {
 
-       $a = get_app();
-
        $avatar['size'] = 175;
        $avatar['email'] = $email;
        $avatar['url'] = '';
@@ -522,8 +520,9 @@ function avatar_img($email) {
 
        call_hooks('avatar_lookup', $avatar);
 
-       if(! $avatar['success'])
-               $avatar['url'] = $a->get_baseurl() . '/images/person-175.jpg';
+       if (! $avatar['success']) {
+               $avatar['url'] = App::get_baseurl() . '/images/person-175.jpg';
+       }
 
        logger('Avatar: ' . $avatar['email'] . ' ' . $avatar['url'], LOGGER_DEBUG);
        return $avatar['url'];
@@ -569,7 +568,7 @@ function scale_external_images($srctext, $include_link = true, $scale_replace =
                foreach($matches as $mtch) {
                        logger('scale_external_image: ' . $mtch[1]);
 
-                       $hostname = str_replace('www.','',substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')+3));
+                       $hostname = str_replace('www.','',substr(App::get_baseurl(),strpos(App::get_baseurl(),'://')+3));
                        if(stristr($mtch[1],$hostname))
                                continue;
 
index 7221fa376db154eba4656d2e4f1049cade18ab36..d78db4055d9779155b3f9ca0e6eef1a78ebde574 100644 (file)
@@ -210,8 +210,9 @@ function notifier_run(&$argv, &$argc){
                intval($uid)
        );
 
-       if(! dbm::is_result($r))
+       if (! dbm::is_result($r)) {
                return;
+       }
 
        $owner = $r[0];
 
@@ -557,7 +558,7 @@ function notifier_run(&$argv, &$argc){
        if($slap && count($url_recipients) && ($public_message || $push_notify) && $normal_mode) {
                if(!get_config('system','dfrn_only')) {
                        foreach($url_recipients as $url) {
-                               if($url) {
+                               if ($url) {
                                        logger('notifier: urldelivery: ' . $url);
                                        $deliver_status = slapper($owner,$url,$slap);
                                        /// @TODO Redeliver/queue these items on failure, though there is no contact record
@@ -649,7 +650,7 @@ function notifier_run(&$argv, &$argc){
 
                                } else {
 
-                                       $params = 'hub.mode=publish&hub.url=' . urlencode( $a->get_baseurl() . '/dfrn_poll/' . $owner['nickname'] );
+                                       $params = 'hub.mode=publish&hub.url=' . urlencode( App::get_baseurl() . '/dfrn_poll/' . $owner['nickname'] );
                                        post_url($h,$params);
                                        logger('publish for item '.$item_id.' ' . $h . ' ' . $params . ' returned ' . $a->get_curl_code());
                                }
index a30232df4a89a89f990172ccfb018bab4bd73429..3d4533d3e0061da5a4a8e1af01d9c2d0629ee82a 100644 (file)
@@ -148,7 +148,7 @@ class FKOAuth1 extends OAuthServer {
                $_SESSION['mobile-theme'] = get_pconfig($record['uid'], 'system', 'mobile_theme');
                $_SESSION['authenticated'] = 1;
                $_SESSION['page_flags'] = $record['page-flags'];
-               $_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $record['nickname'];
+               $_SESSION['my_url'] = App::get_baseurl() . '/profile/' . $record['nickname'];
                $_SESSION['addr'] = $_SERVER['REMOTE_ADDR'];
                $_SESSION["allow_api"] = true;
 
index 2834036665bad1c3ef0a6d7629761726acd40711..d92cb915b6eb0ce96801086699f40c01fa542866 100644 (file)
@@ -143,8 +143,9 @@ function onepoll_run(&$argv, &$argc){
        $r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` INNER JOIN `user` on `contact`.`uid` = `user`.`uid` WHERE `user`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",
                intval($importer_uid)
        );
-       if(! dbm::is_result($r))
+       if (! dbm::is_result($r)) {
                return;
+       }
 
        $importer = $r[0];
 
index 487ab575156d4812d6d959922496ac5f04efdb1a..89c783f900ae3532b17adfef171818cacb3efee8 100644 (file)
@@ -129,7 +129,7 @@ function reload_plugins() {
  */
 function plugin_enabled($plugin) {
        $r = q("SELECT * FROM `addon` WHERE `installed` = 1 AND `name` = '%s'", $plugin);
-       return((bool)(count($r) > 0));
+       return ((dbm::is_result($r)) && (count($r) > 0));
 }
 
 
@@ -410,13 +410,13 @@ function get_theme_info($theme){
  * @return string
  */
 function get_theme_screenshot($theme) {
-       $a = get_app();
        $exts = array('.png','.jpg');
        foreach($exts as $ext) {
-               if(file_exists('view/theme/' . $theme . '/screenshot' . $ext))
-                       return($a->get_baseurl() . '/view/theme/' . $theme . '/screenshot' . $ext);
+               if(file_exists('view/theme/' . $theme . '/screenshot' . $ext)) {
+                       return(App::get_baseurl() . '/view/theme/' . $theme . '/screenshot' . $ext);
+               }
        }
-       return($a->get_baseurl() . '/images/blank.png');
+       return(App::get_baseurl() . '/images/blank.png');
 }
 
 // install and uninstall theme
index 44f4895cdbda1991d9d12d1c0e59dee33b055eab..d00360d2b7414835173767faaa8262417ce1ef87 100644 (file)
@@ -213,7 +213,7 @@ function poller_max_connections_reached() {
        // The processlist only shows entries of the current user
        if ($max != 0) {
                $r = q("SHOW PROCESSLIST");
-               if (!$r)
+               if (!dbm::is_result($r))
                        return false;
 
                $used = count($r);
index 85637facb23b275eac29a46c0d61c89aa35621b9..abf973a284cbb160f5716364ee03670fa4f534d9 100644 (file)
@@ -21,7 +21,7 @@ function handle_pubsubhubbub($id) {
 
        $headers = array("Content-type: application/atom+xml",
                        sprintf("Link: <%s>;rel=hub,<%s>;rel=self",
-                               $a->get_baseurl().'/pubsubhubbub',
+                               App::get_baseurl().'/pubsubhubbub',
                                $rr['topic']),
                        "X-Hub-Signature: sha1=".$hmac_sig);
 
index ad7079e959ebce2d3a767167bb69e7a0ce693f2b..1cc2ee095bb49ae5aea516e8f9be6d34eaba87c3 100644 (file)
@@ -126,7 +126,7 @@ function queue_run(&$argv, &$argc){
                $c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
                        intval($qi[0]['cid'])
                );
-               if(! count($c)) {
+               if (! dbm::is_result($c)) {
                        remove_queue_item($q_item['id']);
                        continue;
                }
@@ -156,7 +156,7 @@ function queue_run(&$argv, &$argc){
                        FROM `user` WHERE `uid` = %d LIMIT 1",
                        intval($c[0]['uid'])
                );
-               if(! count($u)) {
+               if (! dbm::is_result($u)) {
                        remove_queue_item($q_item['id']);
                        continue;
                }
index 8d8a035f1db5fa83c07e388111526c5855416b29..d8bb7643965963c7ebe195e04e564bcc22b4a947 100644 (file)
@@ -20,7 +20,7 @@ function auto_redir(&$a, $contact_nick) {
                //
                // We also have to make sure that I'm a legitimate contact--I'm not blocked or pending.
 
-               $baseurl = $a->get_baseurl();
+               $baseurl = App::get_baseurl();
                $domain_st = strpos($baseurl, "://");
                if($domain_st === false)
                        return;
@@ -36,9 +36,9 @@ function auto_redir(&$a, $contact_nick) {
                dbesc($nurl)
                );
 
-               if((! dbm::is_result($r)) || $r[0]['id'] == remote_user())
+               if ((! dbm::is_result($r)) || $r[0]['id'] == remote_user()) {
                        return;
-
+               }
 
                $r = q("SELECT * FROM contact WHERE nick = '%s'
                        AND network = '%s' AND uid = %d  AND url LIKE '%%%s%%' LIMIT 1",
@@ -48,8 +48,9 @@ function auto_redir(&$a, $contact_nick) {
                       dbesc($baseurl)
                );
 
-               if(! dbm::is_result($r))
+               if (! dbm::is_result($r)) {
                        return;
+               }
 
                $cid = $r[0]['id'];
 
index 5e9c4fa616dc1df20eec3c8d16ac372add35155e..2b583347042e24cc8d26dca3868eb8f7ac2054f5 100644 (file)
@@ -24,22 +24,24 @@ function get_salmon_key($uri,$keyhash) {
        // We have found at least one key URL
        // If it's inline, parse it - otherwise get the key
 
-       if(count($ret)) {
-               for($x = 0; $x < count($ret); $x ++) {
-                       if(substr($ret[$x],0,5) === 'data:') {
-                               if(strstr($ret[$x],','))
+       if (count($ret) > 0) {
+               for ($x = 0; $x < count($ret); $x ++) {
+                       if (substr($ret[$x],0,5) === 'data:') {
+                               if (strstr($ret[$x],',')) {
                                        $ret[$x] = substr($ret[$x],strpos($ret[$x],',')+1);
-                               else
+                               } else {
                                        $ret[$x] = substr($ret[$x],5);
-                       } elseif (normalise_link($ret[$x]) == 'http://')
+                               }
+                       } elseif (normalise_link($ret[$x]) == 'http://') {
                                $ret[$x] = fetch_url($ret[$x]);
+                       }
                }
        }
 
 
        logger('Key located: ' . print_r($ret,true));
 
-       if(count($ret) == 1) {
+       if (count($ret) == 1) {
 
                // We only found one one key so we don't care if the hash matches.
                // If it's the wrong key we'll find out soon enough because
@@ -50,10 +52,11 @@ function get_salmon_key($uri,$keyhash) {
                return $ret[0];
        }
        else {
-               foreach($ret as $a) {
+               foreach ($ret as $a) {
                        $hash = base64url_encode(hash('sha256',$a));
-                       if($hash == $keyhash)
+                       if ($hash == $keyhash) {
                                return $a;
+                       }
                }
        }
 
index fa698c1b1a62aeb48e5ea9953507eb3c6fec0e81..cd00b5f7b0bbc36a75f511c8f865fe643164f6b7 100644 (file)
@@ -9,8 +9,8 @@ function authenticate_success($user_record, $login_initial = false, $interactive
        $_SESSION['mobile-theme'] = get_pconfig($user_record['uid'], 'system', 'mobile_theme');
        $_SESSION['authenticated'] = 1;
        $_SESSION['page_flags'] = $user_record['page-flags'];
-       $_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $user_record['nickname'];
-       $_SESSION['my_address'] = $user_record['nickname'] . '@' . substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')+3);
+       $_SESSION['my_url'] = App::get_baseurl() . '/profile/' . $user_record['nickname'];
+       $_SESSION['my_address'] = $user_record['nickname'] . '@' . substr(App::get_baseurl(),strpos(App::get_baseurl(),'://')+3);
        $_SESSION['addr'] = $_SERVER['REMOTE_ADDR'];
 
        $a->user = $user_record;
@@ -94,11 +94,12 @@ function authenticate_success($user_record, $login_initial = false, $interactive
 
 
        }
-       if($login_initial) {
+       if ($login_initial) {
                call_hooks('logged_in', $a->user);
 
-               if(($a->module !== 'home') && isset($_SESSION['return_url']))
-                       goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
+               if (($a->module !== 'home') && isset($_SESSION['return_url'])) {
+                       goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
+               }
        }
 
 }
@@ -109,16 +110,17 @@ function can_write_wall(&$a,$owner) {
 
        static $verified = 0;
 
-       if((! (local_user())) && (! (remote_user())))
+       if ((! (local_user())) && (! (remote_user()))) {
                return false;
+       }
 
        $uid = local_user();
 
-       if(($uid) && ($uid == $owner)) {
+       if (($uid) && ($uid == $owner)) {
                return true;
        }
 
-       if(remote_user()) {
+       if (remote_user()) {
 
                // use remembered decision and avoid a DB lookup for each and every display item
                // DO NOT use this function if there are going to be multiple owners
@@ -126,25 +128,25 @@ function can_write_wall(&$a,$owner) {
                // We have a contact-id for an authenticated remote user, this block determines if the contact
                // belongs to this page owner, and has the necessary permissions to post content
 
-               if($verified === 2)
+               if ($verified === 2) {
                        return true;
-               elseif($verified === 1)
+               } elseif ($verified === 1) {
                        return false;
-               else {
+               else {
                        $cid = 0;
 
-                       if(is_array($_SESSION['remote'])) {
-                               foreach($_SESSION['remote'] as $visitor) {
-                                       if($visitor['uid'] == $owner) {
+                       if (is_array($_SESSION['remote'])) {
+                               foreach ($_SESSION['remote'] as $visitor) {
+                                       if ($visitor['uid'] == $owner) {
                                                $cid = $visitor['cid'];
                                                break;
                                        }
                                }
                        }
 
-                       if(! $cid)
+                       if (! $cid) {
                                return false;
-
+                       }
 
                        $r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` INNER JOIN `user` on `user`.`uid` = `contact`.`uid` 
                                WHERE `contact`.`uid` = %d AND `contact`.`id` = %d AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 
@@ -378,7 +380,7 @@ function check_form_security_token_redirectOnErr($err_redirect, $typename = '',
                logger('check_form_security_token failed: user ' . $a->user['guid'] . ' - form element ' . $typename);
                logger('check_form_security_token failed: _REQUEST data: ' . print_r($_REQUEST, true), LOGGER_DATA);
                notice( check_form_security_std_err_msg() );
-               goaway($a->get_baseurl() . $err_redirect );
+               goaway(App::get_baseurl() . $err_redirect );
        }
 }
 function check_form_security_token_ForbiddenOnErr($typename = '', $formname = 'form_security_token') {
index 349fd0b2caebcecd5dfff17e050a2129c5161ec1..7c70a22a54f6c50af133abeab7ada0f5cd31cb9e 100644 (file)
@@ -91,50 +91,58 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
 
                $name = $entry->displayName;
 
-               if(isset($entry->urls)) {
-                       foreach($entry->urls as $url) {
-                               if($url->type == 'profile') {
+               if (isset($entry->urls)) {
+                       foreach ($entry->urls as $url) {
+                               if ($url->type == 'profile') {
                                        $profile_url = $url->value;
                                        continue;
                                }
-                               if($url->type == 'webfinger') {
+                               if ($url->type == 'webfinger') {
                                        $connect_url = str_replace('acct:' , '', $url->value);
                                        continue;
                                }
                        }
                }
-               if(isset($entry->photos)) {
-                       foreach($entry->photos as $photo) {
-                               if($photo->type == 'profile') {
+               if (isset($entry->photos)) {
+                       foreach ($entry->photos as $photo) {
+                               if ($photo->type == 'profile') {
                                        $profile_photo = $photo->value;
                                        continue;
                                }
                        }
                }
 
-               if(isset($entry->updated))
+               if (isset($entry->updated)) {
                        $updated = date("Y-m-d H:i:s", strtotime($entry->updated));
+               }
 
-               if(isset($entry->network))
+               if (isset($entry->network)) {
                        $network = $entry->network;
+               }
 
-               if(isset($entry->currentLocation))
+               if (isset($entry->currentLocation)) {
                        $location = $entry->currentLocation;
+               }
 
-               if(isset($entry->aboutMe))
+               if (isset($entry->aboutMe)) {
                        $about = html2bbcode($entry->aboutMe);
+               }
 
-               if(isset($entry->gender))
+               if (isset($entry->gender)) {
                        $gender = $entry->gender;
+               }
 
-               if(isset($entry->generation) AND ($entry->generation > 0))
+               if (isset($entry->generation) AND ($entry->generation > 0)) {
                        $generation = ++$entry->generation;
+               }
 
-               if(isset($entry->tags))
-                       foreach($entry->tags as $tag)
+               if (isset($entry->tags)) {
+                       foreach($entry->tags as $tag) {
                                $keywords = implode(", ", $tag);
+                       }
+               }
 
-               if(isset($entry->contactType) AND ($entry->contactType >= 0))
+               if (isset($entry->contactType) AND ($entry->contactType >= 0))
                        $contact_type = $entry->contactType;
 
                // If you query a Friendica server for its profiles, the network has to be Friendica
@@ -171,8 +179,6 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
 
 function poco_check($profile_url, $name, $network, $profile_photo, $about, $location, $gender, $keywords, $connect_url, $updated, $generation, $cid = 0, $uid = 0, $zcid = 0) {
 
-       $a = get_app();
-
        // Generation:
        //  0: No definition
        //  1: Profiles on this server
@@ -207,8 +213,9 @@ function poco_check($profile_url, $name, $network, $profile_photo, $about, $loca
        $orig_updated = $updated;
 
        // The global contacts should contain the original picture, not the cached one
-       if (($generation != 1) AND stristr(normalise_link($profile_photo), normalise_link($a->get_baseurl()."/photo/")))
+       if (($generation != 1) AND stristr(normalise_link($profile_photo), normalise_link(App::get_baseurl()."/photo/"))) {
                $profile_photo = "";
+       }
 
        $r = q("SELECT `network` FROM `contact` WHERE `nurl` = '%s' AND `network` != '' AND `network` != '%s' LIMIT 1",
                dbesc(normalise_link($profile_url)), dbesc(NETWORK_STATUSNET)
@@ -330,7 +337,7 @@ function poco_check($profile_url, $name, $network, $profile_photo, $about, $loca
                intval($gcid),
                intval($zcid)
        );
-       if(! dbm::is_result($r)) {
+       if (! dbm::is_result($r)) {
                q("INSERT INTO `glink` (`cid`,`uid`,`gcid`,`zcid`, `updated`) VALUES (%d,%d,%d,%d, '%s') ",
                        intval($cid),
                        intval($uid),
@@ -1181,22 +1188,23 @@ function update_suggestions() {
        $done = array();
 
        /// TODO Check if it is really neccessary to poll the own server
-       poco_load(0,0,0,$a->get_baseurl() . '/poco');
+       poco_load(0,0,0,App::get_baseurl() . '/poco');
 
-       $done[] = $a->get_baseurl() . '/poco';
+       $done[] = App::get_baseurl() . '/poco';
 
-       if(strlen(get_config('system','directory'))) {
+       if (strlen(get_config('system','directory'))) {
                $x = fetch_url(get_server()."/pubsites");
-               if($x) {
+               if ($x) {
                        $j = json_decode($x);
-                       if($j->entries) {
-                               foreach($j->entries as $entry) {
+                       if ($j->entries) {
+                               foreach ($j->entries as $entry) {
 
                                        poco_check_server($entry->url);
 
                                        $url = $entry->url . '/poco';
-                                       if(! in_array($url,$done))
+                                       if (! in_array($url,$done)) {
                                                poco_load(0,0,0,$entry->url . '/poco');
+                                       }
                                }
                        }
                }
@@ -1208,7 +1216,7 @@ function update_suggestions() {
        );
 
        if (dbm::is_result($r)) {
-               foreach($r as $rr) {
+               foreach ($r as $rr) {
                        $base = substr($rr['poco'],0,strrpos($rr['poco'],'/'));
                        if(! in_array($base,$done))
                                poco_load(0,0,0,$base);
@@ -1219,7 +1227,7 @@ function update_suggestions() {
 function poco_discover_federation() {
        $last = get_config('poco','last_federation_discovery');
 
-       if($last) {
+       if ($last) {
                $next = $last + (24 * 60 * 60);
                if($next > time())
                        return;
@@ -1333,7 +1341,7 @@ function poco_discover_server_users($data, $server) {
                $username = "";
                if (isset($entry->urls)) {
                        foreach($entry->urls as $url)
-                               if($url->type == 'profile') {
+                               if ($url->type == 'profile') {
                                        $profile_url = $url->value;
                                        $urlparts = parse_url($profile_url);
                                        $username = end(explode("/", $urlparts["path"]));
@@ -1375,52 +1383,61 @@ function poco_discover_server($data, $default_generation = 0) {
 
                $name = $entry->displayName;
 
-               if(isset($entry->urls)) {
+               if (isset($entry->urls)) {
                        foreach($entry->urls as $url) {
-                               if($url->type == 'profile') {
+                               if ($url->type == 'profile') {
                                        $profile_url = $url->value;
                                        continue;
                                }
-                               if($url->type == 'webfinger') {
+                               if ($url->type == 'webfinger') {
                                        $connect_url = str_replace('acct:' , '', $url->value);
                                        continue;
                                }
                        }
                }
 
-               if(isset($entry->photos)) {
-                       foreach($entry->photos as $photo) {
-                               if($photo->type == 'profile') {
+               if (isset($entry->photos)) {
+                       foreach ($entry->photos as $photo) {
+                               if ($photo->type == 'profile') {
                                        $profile_photo = $photo->value;
                                        continue;
                                }
                        }
                }
 
-               if(isset($entry->updated))
+               if (isset($entry->updated)) {
                        $updated = date("Y-m-d H:i:s", strtotime($entry->updated));
+               }
 
-               if(isset($entry->network))
+               if(isset($entry->network)) {
                        $network = $entry->network;
+               }
 
-               if(isset($entry->currentLocation))
+               if(isset($entry->currentLocation)) {
                        $location = $entry->currentLocation;
+               }
 
-               if(isset($entry->aboutMe))
+               if(isset($entry->aboutMe)) {
                        $about = html2bbcode($entry->aboutMe);
+               }
 
-               if(isset($entry->gender))
+               if(isset($entry->gender)) {
                        $gender = $entry->gender;
+               }
 
-               if(isset($entry->generation) AND ($entry->generation > 0))
+               if(isset($entry->generation) AND ($entry->generation > 0)) {
                        $generation = ++$entry->generation;
+               }
 
-               if(isset($entry->contactType) AND ($entry->contactType >= 0))
+               if(isset($entry->contactType) AND ($entry->contactType >= 0)) {
                        $contact_type = $entry->contactType;
+               }
 
-               if(isset($entry->tags))
-                       foreach($entry->tags as $tag)
+               if(isset($entry->tags)) {
+                       foreach ($entry->tags as $tag) {
                                $keywords = implode(", ", $tag);
+                       }
+               }
 
                if ($generation > 0) {
                        $success = true;
@@ -1558,7 +1575,7 @@ function get_gcontact_id($contact) {
                proc_run(PRIORITY_LOW, 'include/gprobe.php', bin2hex($contact["url"]));
        }
 
-       if ((count($r) > 1) AND ($gcontact_id > 0) AND ($contact["url"] != ""))
+       if ((dbm::is_result($r)) AND (count($r) > 1) AND ($gcontact_id > 0) AND ($contact["url"] != ""))
         q("DELETE FROM `gcontact` WHERE `nurl` = '%s' AND `id` != %d",
                dbesc(normalise_link($contact["url"])),
                intval($gcontact_id));
@@ -1771,8 +1788,6 @@ function gs_fetch_users($server) {
 
        logger("Fetching users from GNU Social server ".$server, LOGGER_DEBUG);
 
-       $a = get_app();
-
        $url = $server."/main/statistics";
 
        $result = z_fetch_url($url);
@@ -1811,7 +1826,7 @@ function gs_fetch_users($server) {
                                        "nick" => $user->nickname,
                                        "about" => $user->bio,
                                        "network" => NETWORK_OSTATUS,
-                                       "photo" => $a->get_baseurl()."/images/person-175.jpg");
+                                       "photo" => App::get_baseurl()."/images/person-175.jpg");
                        get_gcontact_id($contact);
                }
 }
index 6c1d01d74da5063e6b167d3388b1a03b4b913813..0a094384782bb4358af16ac28811182ade537a84 100644 (file)
@@ -1,13 +1,11 @@
 <?php
 function create_tags_from_item($itemid) {
-       $a = get_app();
-
-       $profile_base = $a->get_baseurl();
+       $profile_base = App::get_baseurl();
        $profile_data = parse_url($profile_base);
        $profile_base_friendica = $profile_data['host'].$profile_data['path']."/profile/";
        $profile_base_diaspora = $profile_data['host'].$profile_data['path']."/u/";
 
-       $searchpath = $a->get_baseurl()."/search?tag=";
+       $searchpath = App::get_baseurl()."/search?tag=";
 
        $messages = q("SELECT `guid`, `uid`, `id`, `edited`, `deleted`, `created`, `received`, `title`, `body`, `tag`, `parent` FROM `item` WHERE `id` = %d LIMIT 1", intval($itemid));
 
index 5856226c3725ea3eac596c69bbf781afce18d8b7..8d3b6a8050199ec5ec4d78ea0982af902e3a2316 100644 (file)
@@ -23,7 +23,7 @@ function replace_macros($s,$r) {
        $a = get_app();
 
        // pass $baseurl to all templates
-       $r['$baseurl'] = $a->get_baseurl();
+       $r['$baseurl'] = App::get_baseurl();
 
 
        $t = $a->template_engine();
@@ -369,7 +369,7 @@ if(! function_exists('paginate')) {
  * @param App $a App instance
  * @return string html for pagination #FIXME remove html
  */
-function paginate(&$a) {
+function paginate(App &$a) {
 
        $data = paginate_data($a);
        $tpl = get_markup_template("paginate.tpl");
@@ -1367,7 +1367,7 @@ function prepare_body(&$item,$attach = false, $preview = false) {
        // map
        if(strpos($s,'<div class="map">') !== false && $item['coord']) {
                $x = generate_map(trim($item['coord']));
-               if($x) {
+               if ($x) {
                        $s = preg_replace('/\<div class\=\"map\"\>/','$0' . $x,$s);
                }
        }
@@ -2000,8 +2000,9 @@ function file_tag_unsave_file($uid,$item,$file,$cat = false) {
                intval($item),
                intval($uid)
        );
-       if(! dbm::is_result($r))
+       if (! dbm::is_result($r)) {
                return false;
+       }
 
        q("UPDATE `item` SET `file` = '%s' WHERE `id` = %d AND `uid` = %d",
                dbesc(str_replace($pattern,'',$r[0]['file'])),
@@ -2020,11 +2021,11 @@ function file_tag_unsave_file($uid,$item,$file,$cat = false) {
        //$r = q("select file from item where uid = %d and deleted = 0 " . file_tag_file_query('item',$file,(($cat) ? 'category' : 'file')),
        //);
 
-       if(! dbm::is_result($r)) {
+       if (! dbm::is_result($r)) {
                $saved = get_pconfig($uid,'system','filetags');
                set_pconfig($uid,'system','filetags',str_replace($pattern,'',$saved));
-
        }
+
        return true;
 }
 
index 48391174ecd683eaaf9d577f6e1d777d64d1d8c0..c214cf264487a6f89ddecab8248e7b81909ed5b8 100644 (file)
@@ -267,12 +267,10 @@ function update_threads() {
 }
 
 function update_threads_mention() {
-       $a = get_app();
-
        $users = q("SELECT `uid`, `nickname` FROM `user` ORDER BY `uid`");
 
        foreach ($users AS $user) {
-               $self = normalise_link($a->get_baseurl() . '/profile/' . $user['nickname']);
+               $self = normalise_link(App::get_baseurl() . '/profile/' . $user['nickname']);
                $selfhttps = str_replace("http://", "https://", $self);
                $parents = q("SELECT DISTINCT(`parent`) FROM `item` WHERE `uid` = %d AND
                                ((`owner-link` IN ('%s', '%s')) OR (`author-link` IN ('%s', '%s')))",
index 51672d92b6a27919704028408f8aa550b94e719c..0d9ffc35fca2f001fcf6df23db1f03a1e8fd8da5 100644 (file)
@@ -133,7 +133,7 @@ function import_account(&$a, $file) {
        }\r
 \r
        $oldbaseurl = $account['baseurl'];\r
-       $newbaseurl = $a->get_baseurl();\r
+       $newbaseurl = App::get_baseurl();\r
        $olduid = $account['user']['uid'];\r
 \r
         unset($account['user']['uid']);\r
@@ -290,5 +290,5 @@ function import_account(&$a, $file) {
        proc_run(PRIORITY_HIGH, 'include/notifier.php', 'relocate', $newuid);\r
 \r
        info(t("Done. You can now login with your username and password"));\r
-       goaway($a->get_baseurl() . "/login");\r
+       goaway(App::get_baseurl() . "/login");\r
 }\r
index ec15d5b1340f722c0e0de3d2910012ec04855e75..d6970d475f44babb77ee63929dcf8517929fc834 100644 (file)
@@ -241,7 +241,7 @@ function create_user($arr) {
                WHERE `nickname` = '%s' ",
                dbesc($nickname)
        );
-       if((count($r) > 1) && $newuid) {
+       if ((dbm::is_result($r)) && (count($r) > 1) && $newuid) {
                $result['message'] .= t('Nickname is already registered. Please choose another.') . EOL;
                q("DELETE FROM `user` WHERE `uid` = %d",
                        intval($newuid)
@@ -262,7 +262,7 @@ function create_user($arr) {
                        intval($netpublish)
 
                );
-               if($r === false) {
+               if ($r === false) {
                        $result['message'] .=  t('An error occurred creating your default profile. Please try again.') . EOL;
                        // Start fresh next time.
                        $r = q("DELETE FROM `user` WHERE `uid` = %d",
@@ -325,24 +325,27 @@ function create_user($arr) {
 
                        $r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 4 );
 
-                       if($r === false)
+                       if ($r === false) {
                                $photo_failure = true;
+                       }
 
                        $img->scaleImage(80);
 
                        $r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 5 );
 
-                       if($r === false)
+                       if ($r === false) {
                                $photo_failure = true;
+                       }
 
                        $img->scaleImage(48);
 
                        $r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 6 );
 
-                       if($r === false)
+                       if ($r === false) {
                                $photo_failure = true;
+                       }
 
-                       if(! $photo_failure) {
+                       if (! $photo_failure) {
                                q("UPDATE `photo` SET `profile` = 1 WHERE `resource-id` = '%s' ",
                                        dbesc($hash)
                                );
index 08f24af60f49238d43a7d30832767dd939feea2b..f05151757b5466f8944299821cde706398e2ae11 100644 (file)
--- a/index.php
+++ b/index.php
@@ -60,15 +60,15 @@ if(!$install) {
        if ($a->max_processes_reached() OR $a->maxload_reached()) {
                header($_SERVER["SERVER_PROTOCOL"].' 503 Service Temporarily Unavailable');
                header('Retry-After: 120');
-               header('Refresh: 120; url='.$a->get_baseurl()."/".$a->query_string);
+               header('Refresh: 120; url='.App::get_baseurl()."/".$a->query_string);
                die("System is currently unavailable. Please try again later");
        }
 
        if (get_config('system','force_ssl') AND ($a->get_scheme() == "http") AND
                (intval(get_config('system','ssl_policy')) == SSL_POLICY_FULL) AND
-               (substr($a->get_baseurl(), 0, 8) == "https://")) {
+               (substr(App::get_baseurl(), 0, 8) == "https://")) {
                header("HTTP/1.1 302 Moved Temporarily");
-               header("Location: ".$a->get_baseurl()."/".$a->query_string);
+               header("Location: ".App::get_baseurl()."/".$a->query_string);
                exit();
        }
 
@@ -150,24 +150,28 @@ if((x($_GET,'zrl')) && (!$install && !$maintenance)) {
  *
  */
 
-// header('Link: <' . $a->get_baseurl() . '/amcd>; rel="acct-mgmt";');
+// header('Link: <' . App::get_baseurl() . '/amcd>; rel="acct-mgmt";');
 
-if(x($_COOKIE["Friendica"]) || (x($_SESSION,'authenticated')) || (x($_POST,'auth-params')) || ($a->module === 'login'))
+if (x($_COOKIE["Friendica"]) || (x($_SESSION,'authenticated')) || (x($_POST,'auth-params')) || ($a->module === 'login')) {
        require("include/auth.php");
+}
 
-if(! x($_SESSION,'authenticated'))
+if (! x($_SESSION,'authenticated')) {
        header('X-Account-Management-Status: none');
+}
 
 /* set up page['htmlhead'] and page['end'] for the modules to use */
 $a->page['htmlhead'] = '';
 $a->page['end'] = '';
 
 
-if(! x($_SESSION,'sysmsg'))
+if (! x($_SESSION,'sysmsg')) {
        $_SESSION['sysmsg'] = array();
+}
 
-if(! x($_SESSION,'sysmsg_info'))
+if (! x($_SESSION,'sysmsg_info')) {
        $_SESSION['sysmsg_info'] = array();
+}
 
 /*
  * check_config() is responsible for running update scripts. These automatically
@@ -177,11 +181,11 @@ if(! x($_SESSION,'sysmsg_info'))
 
 // in install mode, any url loads install module
 // but we need "view" module for stylesheet
-if($install && $a->module!="view")
+if ($install && $a->module!="view") {
        $a->module = 'install';
-elseif($maintenance && $a->module!="view")
+} elseif ($maintenance && $a->module!="view") {
        $a->module = 'maintenance';
-else {
+else {
        check_url($a);
        check_db();
        check_plugins($a);
@@ -191,8 +195,7 @@ nav_set_selected('nothing');
 
 //Don't populate apps_menu if apps are private
 $privateapps = get_config('config','private_addons');
-if((local_user()) || (! $privateapps === "1"))
-{
+if ((local_user()) || (! $privateapps === "1")) {
        $arr = array('app_menu' => $a->apps);
 
        call_hooks('app_menu', $arr);
@@ -238,9 +241,9 @@ if(strlen($a->module)) {
 
        $privateapps = get_config('config','private_addons');
 
-       if(is_array($a->plugins) && in_array($a->module,$a->plugins) && file_exists("addon/{$a->module}/{$a->module}.php")) {
+       if (is_array($a->plugins) && in_array($a->module,$a->plugins) && file_exists("addon/{$a->module}/{$a->module}.php")) {
                //Check if module is an app and if public access to apps is allowed or not
-               if((!local_user()) && plugin_is_app($a->module) && $privateapps === "1") {
+               if ((!local_user()) && plugin_is_app($a->module) && $privateapps === "1") {
                        info( t("You must be logged in to use addons. "));
                }
                else {
@@ -254,7 +257,7 @@ if(strlen($a->module)) {
         * If not, next look for a 'standard' program module in the 'mod' directory
         */
 
-       if((! $a->module_loaded) && (file_exists("mod/{$a->module}.php"))) {
+       if ((! $a->module_loaded) && (file_exists("mod/{$a->module}.php"))) {
                include_once("mod/{$a->module}.php");
                $a->module_loaded = true;
        }
@@ -272,16 +275,16 @@ if(strlen($a->module)) {
         *
         */
 
-       if(! $a->module_loaded) {
+       if (! $a->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) {
+               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') && isset($dreamhost_error_hack)) {
+               if ((x($_SERVER,'QUERY_STRING')) && ($_SERVER['QUERY_STRING'] === 'q=internal_error.html') && isset($dreamhost_error_hack)) {
                        logger('index.php: dreamhost_error_hack invoked. Original URI =' . $_SERVER['REQUEST_URI']);
-                       goaway($a->get_baseurl() . $_SERVER['REQUEST_URI']);
+                       goaway(App::get_baseurl() . $_SERVER['REQUEST_URI']);
                }
 
                logger('index.php: page not found: ' . $_SERVER['REQUEST_URI'] . ' ADDRESS: ' . $_SERVER['REMOTE_ADDR'] . ' QUERY: ' . $_SERVER['QUERY_STRING'], LOGGER_DEBUG);
@@ -304,11 +307,13 @@ if (file_exists($theme_info_file)){
 
 /* initialise content region */
 
-if(! x($a->page,'content'))
+if (! x($a->page,'content')) {
        $a->page['content'] = '';
+}
 
-if(!$install && !$maintenance)
+if (!$install && !$maintenance) {
        call_hooks('page_content_top',$a->page['content']);
+}
 
 /**
  * Call module functions
index 33070a1ecdf4dc071d65aabd94b67f530be47efe..eedddf1e5b46c97968e8bcf6835e4dc79dffbad2 100644 (file)
@@ -1,8 +1,9 @@
 <?php\r
+/// @TODO This file has DOS line endings!\r
 require_once("mod/hostxrd.php");\r
 require_once("mod/nodeinfo.php");\r
 \r
-function _well_known_init(&$a){\r
+function _well_known_init(App &$a){\r
        if ($a->argc > 1) {\r
                switch($a->argv[1]) {\r
                        case "host-meta":\r
@@ -20,7 +21,7 @@ function _well_known_init(&$a){
        killme();\r
 }\r
 \r
-function wk_social_relay(&$a) {\r
+function wk_social_relay(App &$a) {\r
 \r
        define('SR_SCOPE_ALL', 'all');\r
        define('SR_SCOPE_TAGS', 'tags');\r
index a2365803ac46047e1c1a2497520b21e46f9e0171..29f17d6e414d7765224922e3307363bd06be9887 100644 (file)
@@ -2,7 +2,7 @@
 
 require_once('include/Scrape.php');
 
-function acctlink_init(&$a) {
+function acctlink_init(App &$a) {
 
        if(x($_GET,'addr')) {
                $addr = trim($_GET['addr']);
index f5e04b96a75154ee76a042222925754164cfeaa4..802b0a399fd353d3b0c976f11ace6a1bc7264bc4 100644 (file)
@@ -3,7 +3,7 @@
 
 require_once("include/acl_selectors.php");
 
-function acl_init(&$a){
+function acl_init(App &$a){
        acl_lookup($a);
 }
 
index cf0d8d9ac6bc043481490a3d054f38a758492369..26d7da26be0d49a5ee262190ca948ac2e64d975e 100644 (file)
@@ -23,7 +23,7 @@ require_once("include/text.php");
  * @param App $a
  *
  */
-function admin_post(&$a){
+function admin_post(App &$a){
 
 
        if(!is_site_admin()) {
@@ -32,13 +32,12 @@ function admin_post(&$a){
 
        // do not allow a page manager to access the admin panel at all.
 
-       if(x($_SESSION,'submanage') && intval($_SESSION['submanage']))
+       if (x($_SESSION,'submanage') && intval($_SESSION['submanage'])) {
                return;
-
-
+       }
 
        // urls
-       if($a->argc > 1) {
+       if ($a->argc > 1) {
                switch ($a->argv[1]){
                        case 'site':
                                admin_page_site_post($a);
@@ -128,14 +127,15 @@ function admin_post(&$a){
  * @param App $a
  * @return string
  */
-function admin_content(&$a) {
+function admin_content(App &$a) {
 
        if(!is_site_admin()) {
                return login(false);
        }
 
-       if(x($_SESSION,'submanage') && intval($_SESSION['submanage']))
+       if (x($_SESSION,'submanage') && intval($_SESSION['submanage'])) {
                return "";
+       }
 
        // APC deactivated, since there are problems with PHP 5.5
        //if (function_exists("apc_delete")) {
@@ -260,7 +260,7 @@ function admin_content(&$a) {
  * @param App $a
  * @return string
  */
-function admin_page_federation(&$a) {
+function admin_page_federation(App &$a) {
        // get counts on active friendica, diaspora, redmatrix, hubzilla, gnu
        // social and statusnet nodes this node is knowing
        //
@@ -376,7 +376,7 @@ function admin_page_federation(&$a) {
                '$counts' => $counts,
                '$version' => FRIENDICA_VERSION,
                '$legendtext' => sprintf(t('Currently this node is aware of %d nodes from the following platforms:'), $total),
-               '$baseurl' => $a->get_baseurl(),
+               '$baseurl' => App::get_baseurl(),
        ));
 }
 
@@ -393,7 +393,7 @@ function admin_page_federation(&$a) {
  * @param App $a
  * @return string
  */
-function admin_page_queue(&$a) {
+function admin_page_queue(App &$a) {
        // get content from the queue table
        $r = q("SELECT `c`.`name`, `c`.`nurl`, `q`.`id`, `q`.`network`, `q`.`created`, `q`.`last`
                        FROM `queue` AS `q`, `contact` AS `c`
@@ -427,7 +427,7 @@ function admin_page_queue(&$a) {
  * @param App $a
  * @return string
  */
-function admin_page_summary(&$a) {
+function admin_page_summary(App &$a) {
        global $db;
        // are there MyISAM tables in the DB? If so, trigger a warning message
        $r = q("SELECT `engine` FROM `information_schema`.`tables` WHERE `engine` = 'myisam' AND `table_schema` = '%s' LIMIT 1",
@@ -489,7 +489,7 @@ function admin_page_summary(&$a) {
                '$accounts' => $accounts,
                '$pending' => array(t('Pending registrations'), $pending),
                '$version' => array(t('Version'), FRIENDICA_VERSION),
-               '$baseurl' => $a->get_baseurl(),
+               '$baseurl' => App::get_baseurl(),
                '$platform' => FRIENDICA_PLATFORM,
                '$codename' => FRIENDICA_CODENAME,
                '$build' =>  get_config('system','build'),
@@ -504,7 +504,7 @@ function admin_page_summary(&$a) {
  * 
  * @param App $a
  */
-function admin_page_site_post(&$a) {
+function admin_page_site_post(App &$a) {
        if(!x($_POST,"page_site")) {
                return;
        }
@@ -527,7 +527,7 @@ function admin_page_site_post(&$a) {
                 * send relocate for every local user
                 * */
 
-               $old_url = $a->get_baseurl(true);
+               $old_url = App::get_baseurl(true);
 
                // Generate host names for relocation the addresses in the format user@address.tld
                $new_host = str_replace("http://", "@", normalise_link($new_url));
@@ -845,7 +845,7 @@ function admin_page_site_post(&$a) {
  * @param  App $a
  * @return string
  */
-function admin_page_site(&$a) {
+function admin_page_site(App &$a) {
 
        /* Installed langs */
        $lang_choices = get_available_languages();
@@ -961,7 +961,7 @@ function admin_page_site(&$a) {
                '$performance' => t('Performance'),
                '$worker_title' => t('Worker'),
                '$relocate'=> t('Relocate - WARNING: advanced function. Could make this server unreachable.'),
-               '$baseurl' => $a->get_baseurl(true),
+               '$baseurl' => App::get_baseurl(true),
                // name, label, value, help string, extra data...
                '$sitename'             => array('sitename', t("Site name"), $a->config['sitename'],''),
                '$hostname'             => array('hostname', t("Host name"), $a->config['hostname'], ""),
@@ -1043,7 +1043,7 @@ function admin_page_site(&$a) {
                '$old_pager'            => array('old_pager', t("Enable old style pager"), get_config('system','old_pager'), t("The old style pager has page numbers but slows down massively the page speed.")),
                '$only_tag_search'      => array('only_tag_search', t("Only search in tags"), get_config('system','only_tag_search'), t("On large systems the text search can slow down the system extremely.")),
 
-               '$relocate_url'         => array('relocate_url', t("New base url"), $a->get_baseurl(), t("Change base url for this server. Sends relocate message to all DFRN contacts of all users.")),
+               '$relocate_url'         => array('relocate_url', t("New base url"), App::get_baseurl(), t("Change base url for this server. Sends relocate message to all DFRN contacts of all users.")),
 
                '$rino'                 => array('rino', t("RINO Encryption"), intval(get_config('system','rino_encrypt')), t("Encryption layer between nodes."), array("Disabled", "RINO1 (deprecated)", "RINO2")),
                '$embedly'              => array('embedly', t("Embedly API key"), get_config('system','embedly'), t("<a href='http://embed.ly'>Embedly</a> is used to fetch additional data for web pages. This is an optional parameter.")),
@@ -1072,7 +1072,7 @@ function admin_page_site(&$a) {
  * @param App $a
  * @return string
  **/
-function admin_page_dbsync(&$a) {
+function admin_page_dbsync(App &$a) {
 
        $o = '';
 
@@ -1129,19 +1129,19 @@ function admin_page_dbsync(&$a) {
                        $failed[] = $upd;
                }
        }
-       if(! count($failed)) {
+       if (! count($failed)) {
                $o = replace_macros(get_markup_template('structure_check.tpl'),array(
-                       '$base' => $a->get_baseurl(true),
+                       '$base'   => App::get_baseurl(true),
                        '$banner' => t('No failed updates.'),
-                       '$check' => t('Check database structure'),
+                       '$check'  => t('Check database structure'),
                ));
        } else {
                $o = replace_macros(get_markup_template('failed_updates.tpl'),array(
-                       '$base' => $a->get_baseurl(true),
+                       '$base'   => App::get_baseurl(true),
                        '$banner' => t('Failed Updates'),
-                       '$desc' => t('This does not include updates prior to 1139, which did not return a status.'),
-                       '$mark' => t('Mark success (if update was manually applied)'),
-                       '$apply' => t('Attempt to execute this update step automatically'),
+                       '$desc'   => t('This does not include updates prior to 1139, which did not return a status.'),
+                       '$mark'   => t('Mark success (if update was manually applied)'),
+                       '$apply'  => t('Attempt to execute this update step automatically'),
                        '$failed' => $failed
                ));
        }
@@ -1155,12 +1155,12 @@ function admin_page_dbsync(&$a) {
  * 
  * @param App $a
  */
-function admin_page_users_post(&$a){
-       $pending     =  (x($_POST, 'pending')                   ? $_POST['pending']             : array());
-       $users       =  (x($_POST, 'user')                      ? $_POST['user']                : array());
-       $nu_name     =  (x($_POST, 'new_user_name')             ? $_POST['new_user_name']       : '');
-       $nu_nickname =  (x($_POST, 'new_user_nickname')         ? $_POST['new_user_nickname']   : '');
-       $nu_email    =  (x($_POST, 'new_user_email')            ? $_POST['new_user_email']      : '');
+function admin_page_users_post(App &$a){
+       $pending     =  (x($_POST, 'pending')           ? $_POST['pending']           : array());
+       $users       =  (x($_POST, 'user')              ? $_POST['user']                      : array());
+       $nu_name     =  (x($_POST, 'new_user_name')     ? $_POST['new_user_name']     : '');
+       $nu_nickname =  (x($_POST, 'new_user_nickname') ? $_POST['new_user_nickname'] : '');
+       $nu_email    =  (x($_POST, 'new_user_email')    ? $_POST['new_user_email']    : '');
        $nu_language = get_config('system', 'language');
 
        check_form_security_token_redirectOnErr('/admin/users', 'admin_users');
@@ -1205,7 +1205,7 @@ function admin_page_users_post(&$a){
                        Thank you and welcome to %4$s.'));
 
                $preamble = sprintf($preamble, $nu['username'], $a->config['sitename']);
-               $body = sprintf($body, $a->get_baseurl(), $nu['email'], $result['password'], $a->config['sitename']);
+               $body = sprintf($body, App::get_baseurl(), $nu['email'], $result['password'], $a->config['sitename']);
 
                notification(array(
                        'type' => "SYSTEM_EMAIL",
@@ -1260,7 +1260,7 @@ function admin_page_users_post(&$a){
  * @param App $a
  * @return string
  */
-function admin_page_users(&$a){
+function admin_page_users(App &$a){
        if($a->argc>2) {
                $uid = $a->argv[3];
                $user = q("SELECT `username`, `blocked` FROM `user` WHERE `uid` = %d", intval($uid));
@@ -1430,7 +1430,7 @@ function admin_page_users(&$a){
                '$form_security_token' => get_form_security_token("admin_users"),
 
                // values //
-               '$baseurl' => $a->get_baseurl(true),
+               '$baseurl' => App::get_baseurl(true),
 
                '$pending' => $pending,
                'deleted' => $deleted,
@@ -1460,7 +1460,7 @@ function admin_page_users(&$a){
  * @param App $a
  * @return string
  */
-function admin_page_plugins(&$a){
+function admin_page_plugins(App &$a){
 
        /*
         * Single plugin
@@ -1522,7 +1522,7 @@ function admin_page_plugins(&$a){
                        '$page' => t('Plugins'),
                        '$toggle' => t('Toggle'),
                        '$settings' => t('Settings'),
-                       '$baseurl' => $a->get_baseurl(true),
+                       '$baseurl' => App::get_baseurl(true),
 
                        '$plugin' => $plugin,
                        '$status' => $status,
@@ -1546,32 +1546,35 @@ function admin_page_plugins(&$a){
         * List plugins
         */
 
-       if(x($_GET,"a") && $_GET['a']=="r") {
-               check_form_security_token_redirectOnErr($a->get_baseurl().'/admin/plugins', 'admin_themes', 't');
+       if (x($_GET,"a") && $_GET['a']=="r") {
+               check_form_security_token_redirectOnErr(App::get_baseurl().'/admin/plugins', 'admin_themes', 't');
                reload_plugins();
                info("Plugins reloaded");
-               goaway($a->get_baseurl().'/admin/plugins');
+               goaway(App::get_baseurl().'/admin/plugins');
        }
 
        $plugins = array();
        $files = glob("addon/*/");
-       if($files) {
-               foreach($files as $file) {
-                       if(is_dir($file)) {
+       if ($files) {
+               foreach ($files as $file) {
+                       if (is_dir($file)) {
                                list($tmp, $id)=array_map("trim", explode("/",$file));
                                $info = get_plugin_info($id);
                                $show_plugin = true;
 
                                // If the addon is unsupported, then only show it, when it is enabled
-                               if((strtolower($info["status"]) == "unsupported") AND !in_array($id,  $a->plugins))
+                               if ((strtolower($info["status"]) == "unsupported") AND !in_array($id,  $a->plugins)) {
                                        $show_plugin = false;
+                               }
 
                                // Override the above szenario, when the admin really wants to see outdated stuff
-                               if(get_config("system", "show_unsupported_addons"))
+                               if (get_config("system", "show_unsupported_addons")) {
                                        $show_plugin = true;
+                               }
 
-                               if($show_plugin)
+                               if ($show_plugin) {
                                        $plugins[] = array($id, (in_array($id,  $a->plugins)?"on":"off") , $info);
+                               }
                        }
                }
        }
@@ -1582,7 +1585,7 @@ function admin_page_plugins(&$a){
                '$page' => t('Plugins'),
                '$submit' => t('Save Settings'),
                '$reload' => t('Reload active plugins'),
-               '$baseurl' => $a->get_baseurl(true),
+               '$baseurl' => App::get_baseurl(true),
                '$function' => 'plugins',
                '$plugins' => $plugins,
                '$pcount' => count($plugins), 
@@ -1666,7 +1669,7 @@ function rebuild_theme_table($themes) {
  * @param App $a
  * @return string
  */
-function admin_page_themes(&$a){
+function admin_page_themes(App &$a){
 
        $allowed_themes_str = get_config('system','allowed_themes');
        $allowed_themes_raw = explode(',',$allowed_themes_str);
@@ -1780,7 +1783,7 @@ function admin_page_themes(&$a){
                        '$page' => t('Themes'),
                        '$toggle' => t('Toggle'),
                        '$settings' => t('Settings'),
-                       '$baseurl' => $a->get_baseurl(true),
+                       '$baseurl' => App::get_baseurl(true),
                        '$plugin' => $theme,
                        '$status' => $status,
                        '$action' => $action,
@@ -1798,18 +1801,18 @@ function admin_page_themes(&$a){
 
 
        // reload active themes
-       if(x($_GET,"a") && $_GET['a']=="r") {
-               check_form_security_token_redirectOnErr($a->get_baseurl().'/admin/themes', 'admin_themes', 't');
-               if($themes) {
-                       foreach($themes as $th) {
-                               if($th['allowed']) {
+       if (x($_GET,"a") && $_GET['a']=="r") {
+               check_form_security_token_redirectOnErr(App::get_baseurl().'/admin/themes', 'admin_themes', 't');
+               if ($themes) {
+                       foreach ($themes as $th) {
+                               if ($th['allowed']) {
                                        uninstall_theme($th['name']);
                                        install_theme($th['name']);
                                }
                        }
                }
                info("Themes reloaded");
-               goaway($a->get_baseurl().'/admin/themes');
+               goaway(App::get_baseurl().'/admin/themes');
        }
 
        /*
@@ -1817,7 +1820,7 @@ function admin_page_themes(&$a){
         */
 
        $xthemes = array();
-       if($themes) {
+       if ($themes) {
                foreach($themes as $th) {
                        $xthemes[] = array($th['name'],(($th['allowed']) ? "on" : "off"), get_theme_info($th['name']));
                }
@@ -1826,17 +1829,17 @@ function admin_page_themes(&$a){
 
        $t = get_markup_template("admin_plugins.tpl");
        return replace_macros($t, array(
-               '$title' => t('Administration'),
-               '$page' => t('Themes'),
-               '$submit' => t('Save Settings'),
-               '$reload' => t('Reload active themes'),
-               '$baseurl' => $a->get_baseurl(true),
-               '$function' => 'themes',
-               '$plugins' => $xthemes,
-               '$pcount' => count($themes),
-               '$noplugshint' => sprintf(t('No themes found on the system. They should be paced in %1$s'),'<code>/view/themes</code>'),
-               '$experimental' => t('[Experimental]'),
-               '$unsupported' => t('[Unsupported]'),
+               '$title'               => t('Administration'),
+               '$page'                => t('Themes'),
+               '$submit'              => t('Save Settings'),
+               '$reload'              => t('Reload active themes'),
+               '$baseurl'             => App::get_baseurl(true),
+               '$function'            => 'themes',
+               '$plugins'             => $xthemes,
+               '$pcount'              => count($themes),
+               '$noplugshint'         => sprintf(t('No themes found on the system. They should be paced in %1$s'),'<code>/view/themes</code>'),
+               '$experimental'        => t('[Experimental]'),
+               '$unsupported'         => t('[Unsupported]'),
                '$form_security_token' => get_form_security_token("admin_themes"),
        ));
 }
@@ -1847,7 +1850,7 @@ function admin_page_themes(&$a){
  * 
  * @param App $a
  */
-function admin_page_logs_post(&$a) {
+function admin_page_logs_post(App &$a) {
        if(x($_POST,"page_logs")) {
                check_form_security_token_redirectOnErr('/admin/logs', 'admin_logs');
 
@@ -1881,7 +1884,7 @@ function admin_page_logs_post(&$a) {
  * @param App $a
  * @return string
  */
-function admin_page_logs(&$a){
+function admin_page_logs(App &$a){
 
        $log_choices = array(
                LOGGER_NORMAL   => 'Normal',
@@ -1904,7 +1907,7 @@ function admin_page_logs(&$a){
                '$page' => t('Logs'),
                '$submit' => t('Save Settings'),
                '$clear' => t('Clear'),
-               '$baseurl' => $a->get_baseurl(true),
+               '$baseurl' => App::get_baseurl(true),
                '$logname' =>  get_config('system','logfile'),
 
                // name, label, value, help string, extra data...
@@ -1938,7 +1941,7 @@ function admin_page_logs(&$a){
  * @param App $a
  * @return string
  */
-function admin_page_viewlogs(&$a){
+function admin_page_viewlogs(App &$a){
        $t = get_markup_template("admin_viewlogs.tpl");
        $f = get_config('system','logfile');
        $data = '';
@@ -1980,7 +1983,7 @@ function admin_page_viewlogs(&$a){
  * 
  * @param App $a
  */
-function admin_page_features_post(&$a) {
+function admin_page_features_post(App &$a) {
 
        check_form_security_token_redirectOnErr('/admin/features', 'admin_manage_features');
 
@@ -2026,7 +2029,7 @@ function admin_page_features_post(&$a) {
  * @param App $a
  * @return string
  */
-function admin_page_features(&$a) {
+function admin_page_features(App &$a) {
        
        if((argc() > 1) && (argv(1) === 'features')) {
                $arr = array();
index 240aa524be308ea605076fcb250a9da693a7dd42..0682b2dd4181b0acde66a24de37b3273c01a733f 100644 (file)
@@ -5,29 +5,32 @@ require_once('include/Contact.php');
 require_once('include/contact_selectors.php');
 require_once('mod/contacts.php');
 
-function allfriends_content(&$a) {
+function allfriends_content(App &$a) {
 
        $o = '';
-       if(! local_user()) {
+       if (! local_user()) {
                notice( t('Permission denied.') . EOL);
                return;
        }
 
-       if($a->argc > 1)
+       if ($a->argc > 1) {
                $cid = intval($a->argv[1]);
+       }
 
-       if(! $cid)
+       if (! $cid) {
                return;
+       }
 
-       $uid = $a->user[uid];
+       $uid = $a->user['uid'];
 
        $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
                intval($cid),
                intval(local_user())
        );
 
-       if(! count($c))
+       if (! count($c)) {
                return;
+       }
 
        $a->page['aside'] = "";
        profile_load($a, "", 0, get_contact_details_by_url($c[0]["url"]));
@@ -39,7 +42,7 @@ function allfriends_content(&$a) {
 
        $r = all_friends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']);
 
-       if(! dbm::is_result($r)) {
+       if (! dbm::is_result($r)) {
                $o .= t('No friends to display.');
                return $o;
        }
@@ -60,7 +63,7 @@ function allfriends_content(&$a) {
                        $photo_menu = contact_photo_menu ($rr);
                }
                else {
-                       $connlnk = $a->get_baseurl() . '/follow/?url=' . $rr['url'];
+                       $connlnk = App::get_baseurl() . '/follow/?url=' . $rr['url'];
                        $photo_menu = array(
                                'profile' => array(t("View Profile"), zrl($rr['url'])),
                                'follow' => array(t("Connect/Follow"), $connlnk)
index a2a1327e6df8b47c5452eb2fe0e1780294b26988..3fcdb42c8dd599306870815a7197ba99f0c0fec1 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-function amcd_content(&$a) {
+function amcd_content(App &$a) {
 //header("Content-type: text/json");
 echo <<< EOT
 {
index 406ef26c1c76adf22993b14e27da1badd1c87bb8..74a0cff6f4a17d3ecf1cb66e55eb1075320378f5 100644 (file)
@@ -20,9 +20,9 @@ function oauth_get_client($request){
        return $r[0];
 }
 
-function api_post(&$a) {
+function api_post(App &$a) {
 
-       if(! local_user()) {
+       if (! local_user()) {
                notice( t('Permission denied.') . EOL);
                return;
        }
@@ -34,7 +34,7 @@ function api_post(&$a) {
 
 }
 
-function api_content(&$a) {
+function api_content(App &$a) {
        if ($a->cmd=='api/oauth/authorize'){
                /*
                 * api/oauth/authorize interact with the user. return a standard page
@@ -84,7 +84,7 @@ function api_content(&$a) {
                }
 
 
-               if(! local_user()) {
+               if (! local_user()) {
                        /// @TODO We need login form to redirect to this page
                        notice( t('Please login to continue.') . EOL );
                        return login(false,$request->get_parameters());
index a821ef5d5b89192b5534df7e8b78cd074e9a7964..4d6395e4ea64673f33ad3fd0517a15191d924393 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-function apps_content(&$a) {
+function apps_content(App &$a) {
     $privateaddons = get_config('config','private_addons');
       if ($privateaddons === "1") {
        if((! (local_user())))  {
index 274acfc2bed8af1f4e23af00eb267e6fa9925cfd..3b1fc0ec82514fe0111e0ad50342810d37696d31 100644 (file)
@@ -2,7 +2,7 @@
 
 require_once('include/security.php');
 
-function attach_init(&$a) {
+function attach_init(App &$a) {
 
        if($a->argc != 2) {
                notice( t('Item not available.') . EOL);
@@ -16,7 +16,7 @@ function attach_init(&$a) {
        $r = q("SELECT * FROM `attach` WHERE `id` = %d LIMIT 1",
                intval($item_id)
        );
-       if(! dbm::is_result($r)) {
+       if (! dbm::is_result($r)) {
                notice( t('Item was not found.'). EOL);
                return;
        }
@@ -29,7 +29,7 @@ function attach_init(&$a) {
                dbesc($item_id)
        );
 
-       if(! dbm::is_result($r)) {
+       if (! dbm::is_result($r)) {
                notice( t('Permission denied.') . EOL);
                return;
        }
index d31e090c554ee7f0b2c4eb6e716ed5b0d1f646ab..5129f5bf594422486c23579e2b977555b39e48a8 100644 (file)
@@ -9,7 +9,7 @@ function visible_lf($s) {
        return str_replace("\n",'<br />', $s);
 }
 
-function babel_content(&$a) {
+function babel_content(App &$a) {
 
        $o .= '<h1>Babel Diagnostic</h1>';
 
index be8645c1fde901924032a4e88e48397d58f6a1c4..9bc8c3353555a929c350a1bf739913ff32b390ff 100644 (file)
@@ -3,19 +3,19 @@
 require_once('include/conversation.php');
 require_once('include/items.php');
 
-function bookmarklet_init(&$a) {
+function bookmarklet_init(App &$a) {
        $_GET["mode"] = "minimal";
 }
 
-function bookmarklet_content(&$a) {
-       if(!local_user()) {
+function bookmarklet_content(App &$a) {
+       if (!local_user()) {
                $o = '<h2>'.t('Login').'</h2>';
                $o .= login(($a->config['register_policy'] == REGISTER_CLOSED) ? false : true);
                return $o;
        }
 
        $referer = normalise_link($_SERVER["HTTP_REFERER"]);
-       $page = normalise_link($a->get_baseurl()."/bookmarklet");
+       $page = normalise_link(App::get_baseurl()."/bookmarklet");
 
        if (!strstr($referer, $page)) {
                $content = add_page_info($_REQUEST["url"]);
index ba43393284767fe744c46c3598b034dd1bc5d1ca..e6c9c72249dc75028ebc84c34eca72f228d5c29b 100644 (file)
@@ -9,7 +9,7 @@
 require_once('include/event.php');
 require_once('include/redir.php');
 
-function cal_init(&$a) {
+function cal_init(App &$a) {
        if($a->argc > 1)
                auto_redir($a, $a->argv[1]);
 
@@ -64,7 +64,7 @@ function cal_init(&$a) {
        return;
 }
 
-function cal_content(&$a) {
+function cal_content(App &$a) {
        nav_set_selected('events');
 
        $editselect = 'none';
@@ -80,7 +80,7 @@ function cal_content(&$a) {
 
        $htpl = get_markup_template('event_head.tpl');
        $a->page['htmlhead'] .= replace_macros($htpl,array(
-               '$baseurl' => $a->get_baseurl(),
+               '$baseurl' => App::get_baseurl(),
                '$module_url' => '/cal/' . $a->data['user']['nickname'],
                '$modparams' => 2,
                '$i18n' => $i18n,
@@ -89,7 +89,7 @@ function cal_content(&$a) {
 
        $etpl = get_markup_template('event_end.tpl');
        $a->page['end'] .= replace_macros($etpl,array(
-               '$baseurl' => $a->get_baseurl(),
+               '$baseurl' => App::get_baseurl(),
                '$editselect' => $editselect
        ));
 
@@ -231,8 +231,9 @@ function cal_content(&$a) {
                        $r = sort_by_date($r);
                        foreach($r as $rr) {
                                $j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j'));
-                               if(! x($links,$j))
-                                       $links[$j] = $a->get_baseurl() . '/' . $a->cmd . '#link-' . $j;
+                               if (! x($links,$j)) {
+                                       $links[$j] = App::get_baseurl() . '/' . $a->cmd . '#link-' . $j;
+                               }
                        }
                }
 
@@ -270,12 +271,12 @@ function cal_content(&$a) {
                }
 
                $o = replace_macros($tpl, array(
-                       '$baseurl'      => $a->get_baseurl(),
+                       '$baseurl'      => App::get_baseurl(),
                        '$tabs'         => $tabs,
                        '$title'        => t('Events'),
                        '$view'         => t('View'),
-                       '$previus'      => array($a->get_baseurl()."/events/$prevyear/$prevmonth",t('Previous'),'',''),
-                       '$next'         => array($a->get_baseurl()."/events/$nextyear/$nextmonth",t('Next'),'',''),
+                       '$previus'      => array(App::get_baseurl()."/events/$prevyear/$prevmonth",t('Previous'),'',''),
+                       '$next'         => array(App::get_baseurl()."/events/$nextyear/$nextmonth",t('Next'),'',''),
                        '$calendar' => cal($y,$m,$links, ' eventcal'),
 
                        '$events'       => $events,
index 6375d23984d708c989b81d53699843f9235fb076..90e41fb6d5e1d821dac470aff382c6076919dd83 100644 (file)
@@ -5,19 +5,19 @@
  */
 
 
-function cb_init(&$a) {
+function cb_init(App &$a) {
        call_hooks('cb_init');
 }
 
-function cb_post(&$a) {
+function cb_post(App &$a) {
        call_hooks('cb_post', $_POST);
 }
 
-function cb_afterpost(&$a) {
+function cb_afterpost(App &$a) {
        call_hooks('cb_afterpost');
 }
 
-function cb_content(&$a) {
+function cb_content(App &$a) {
        $o = '';
        call_hooks('cb_content', $o);
        return $o;
index 9f9379be57d989cc0dff050ab44eafe7ddb11995..f3601c0fe6126bbbc8c335befc35d83996524bf4 100644 (file)
@@ -5,7 +5,7 @@ require_once('include/Contact.php');
 require_once('include/contact_selectors.php');
 require_once('mod/contacts.php');
 
-function common_content(&$a) {
+function common_content(App &$a) {
 
        $o = '';
 
@@ -48,8 +48,9 @@ function common_content(&$a) {
                $a->page['aside'] .= $vcard_widget;
        }
 
-       if(! count($c))
+       if (! dbm::is_result($c)) {
                return;
+       }
 
        if(! $cid) {
                if(get_my_url()) {
@@ -94,7 +95,7 @@ function common_content(&$a) {
                $r = common_friends_zcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']);
 
 
-       if(! dbm::is_result($r)) {
+       if (! dbm::is_result($r)) {
                return $o;
        }
 
index 40d4016f338b2b6738c1abc6e3f7666d888e8b0f..2c2ea32b33cc5ee7e4413c14bc9dddc9beb08946 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
-function community_init(&$a) {
-       if(! local_user()) {
+function community_init(App &$a) {
+       if (! local_user()) {
                unset($_SESSION['theme']);
                unset($_SESSION['mobile-theme']);
        }
@@ -71,7 +71,7 @@ function community_content(&$a, $update = 0) {
 
        $r = community_getitems($a->pager['start'], $a->pager['itemspage']);
 
-       if(! dbm::is_result($r)) {
+       if (! dbm::is_result($r)) {
                info( t('No results.') . EOL);
                return $o;
        }
index 4456db2f5326a4ae5bdd7ba5a9dea9dba8fefa0e..553c7d6cd38b54f1cc4b5657c16b6da6b2b86e4a 100644 (file)
@@ -2,10 +2,10 @@
 
 require_once('include/group.php');
 
-function contactgroup_content(&$a) {
+function contactgroup_content(App &$a) {
 
 
-       if(! local_user()) {
+       if (! local_user()) {
                killme();
        }
 
@@ -24,7 +24,7 @@ function contactgroup_content(&$a) {
                        intval($a->argv[1]),
                        intval(local_user())
                );
-               if(! dbm::is_result($r)) {
+               if (! dbm::is_result($r)) {
                        killme();
                }
 
index 735ccec727e191599d53282ec2558c4d88afb37b..4f634bbc1c45cd46357acbd63d3122a7cd4cb857 100644 (file)
@@ -7,9 +7,10 @@ require_once('include/Scrape.php');
 require_once('mod/proxy.php');
 require_once('include/Photo.php');
 
-function contacts_init(&$a) {
-       if(! local_user())
+function contacts_init(App &$a) {
+       if (! local_user()) {
                return;
+       }
 
        $contact_id = 0;
 
@@ -19,7 +20,7 @@ function contacts_init(&$a) {
                        intval(local_user()),
                        intval($contact_id)
                );
-               if(! dbm::is_result($r)) {
+               if (! dbm::is_result($r)) {
                        $contact_id = 0;
                }
        }
@@ -78,20 +79,20 @@ function contacts_init(&$a) {
        $base = z_root();
        $tpl = get_markup_template("contacts-head.tpl");
        $a->page['htmlhead'] .= replace_macros($tpl,array(
-               '$baseurl' => $a->get_baseurl(true),
+               '$baseurl' => App::get_baseurl(true),
                '$base' => $base
        ));
 
        $tpl = get_markup_template("contacts-end.tpl");
        $a->page['end'] .= replace_macros($tpl,array(
-               '$baseurl' => $a->get_baseurl(true),
+               '$baseurl' => App::get_baseurl(true),
                '$base' => $base
        ));
 
 
 }
 
-function contacts_batch_actions(&$a){
+function contacts_batch_actions(App &$a){
        $contacts_id = $_POST['contact_batch'];
        if (!is_array($contacts_id)) return;
 
@@ -136,10 +137,11 @@ function contacts_batch_actions(&$a){
 }
 
 
-function contacts_post(&$a) {
+function contacts_post(App &$a) {
 
-       if(! local_user())
+       if (! local_user()) {
                return;
+       }
 
        if ($a->argv[1]==="batch") {
                contacts_batch_actions($a);
@@ -147,15 +149,16 @@ function contacts_post(&$a) {
        }
 
        $contact_id = intval($a->argv[1]);
-       if(! $contact_id)
+       if (! $contact_id) {
                return;
+       }
 
        $orig_record = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
                intval($contact_id),
                intval(local_user())
        );
 
-       if(! count($orig_record)) {
+       if (! count($orig_record)) {
                notice( t('Could not access contact record.') . EOL);
                goaway('contacts');
                return; // NOTREACHED
@@ -164,12 +167,12 @@ function contacts_post(&$a) {
        call_hooks('contact_edit_post', $_POST);
 
        $profile_id = intval($_POST['profile-assign']);
-       if($profile_id) {
+       if ($profile_id) {
                $r = q("SELECT `id` FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
                        intval($profile_id),
                        intval(local_user())
                );
-               if(! dbm::is_result($r)) {
+               if (! dbm::is_result($r)) {
                        notice( t('Could not locate selected profile.') . EOL);
                        return;
                }
@@ -339,14 +342,14 @@ function _contact_drop($contact_id, $orig_record) {
 }
 
 
-function contacts_content(&$a) {
+function contacts_content(App &$a) {
 
        $sort_type = 0;
        $o = '';
        nav_set_selected('contacts');
 
 
-       if(! local_user()) {
+       if (! local_user()) {
                notice( t('Permission denied.') . EOL);
                return;
        }
@@ -480,11 +483,11 @@ function contacts_content(&$a) {
                        $editselect = 'exact';
 
                $a->page['htmlhead'] .= replace_macros(get_markup_template('contact_head.tpl'), array(
-                       '$baseurl' => $a->get_baseurl(true),
+                       '$baseurl' => App::get_baseurl(true),
                        '$editselect' => $editselect,
                ));
                $a->page['end'] .= replace_macros(get_markup_template('contact_end.tpl'), array(
-                       '$baseurl' => $a->get_baseurl(true),
+                       '$baseurl' => App::get_baseurl(true),
                        '$editselect' => $editselect,
                ));
 
@@ -564,7 +567,7 @@ function contacts_content(&$a) {
 
                if (in_array($contact['network'], array(NETWORK_DIASPORA, NETWORK_OSTATUS)) AND
                        ($contact['rel'] == CONTACT_IS_FOLLOWER))
-                       $follow = $a->get_baseurl(true)."/follow?url=".urlencode($contact["url"]);
+                       $follow = App::get_baseurl(true)."/follow?url=".urlencode($contact["url"]);
 
                // Load contactact related actions like hide, suggest, delete and others
                $contact_actions = contact_actions($contact);
index 1e2307f553fd52b26348f9b9b0ce42d521e3163a..2377032a7939c7fd4a21911f9a1ad48da3fdd751 100644 (file)
@@ -23,7 +23,7 @@ function content_content(&$a, $update = 0) {
 
        // Currently security is based on the logged in user
 
-       if(! local_user()) {
+       if (! local_user()) {
                return;
        }
 
@@ -113,11 +113,11 @@ function content_content(&$a, $update = 0) {
                        intval($group),
                        intval($_SESSION['uid'])
                );
-               if(! dbm::is_result($r)) {
+               if (! dbm::is_result($r)) {
                        if($update)
                                killme();
                        notice( t('No such group') . EOL );
-                       goaway($a->get_baseurl(true) . '/network');
+                       goaway(App::get_baseurl(true) . '/network');
                        // NOTREACHED
                }
 
@@ -509,8 +509,8 @@ function render_content(&$a, $items, $mode, $update, $preview = false) {
                                        'like' => '',
                                        'dislike' => '',
                                        'comment' => '',
-                                       //'conv' => (($preview) ? '' : array('href'=> $a->get_baseurl($ssl_state) . '/display/' . $nickname . '/' . $item['id'], 'title'=> t('View in context'))),
-                                       'conv' => (($preview) ? '' : array('href'=> $a->get_baseurl($ssl_state).'/display/'.$item['guid'], 'title'=> t('View in context'))),
+                                       //'conv' => (($preview) ? '' : array('href'=> App::get_baseurl($ssl_state) . '/display/' . $nickname . '/' . $item['id'], 'title'=> t('View in context'))),
+                                       'conv' => (($preview) ? '' : array('href'=> App::get_baseurl($ssl_state).'/display/'.$item['guid'], 'title'=> t('View in context'))),
                                        'previewing' => $previewing,
                                        'wait' => t('Please wait'),
                                );
@@ -742,10 +742,11 @@ function render_content(&$a, $items, $mode, $update, $preview = false) {
                                        }
                                }
 
-                               if(local_user() && link_compare($a->contact['url'],$item['author-link']))
-                                       $edpost = array($a->get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit"));
-                               else
+                               if (local_user() && link_compare($a->contact['url'],$item['author-link'])) {
+                                       $edpost = array(App::get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit"));
+                               } else {
                                        $edpost = false;
+                               }
 
                                $drop = '';
                                $dropping = false;
@@ -764,7 +765,7 @@ function render_content(&$a, $items, $mode, $update, $preview = false) {
 
                                $isstarred = "unstarred";
                                if ($profile_owner == local_user()) {
-                                       if($toplevelpost) {
+                                       if ($toplevelpost) {
                                                $isstarred = (($item['starred']) ? "starred" : "unstarred");
 
                                                $star = array(
@@ -782,6 +783,7 @@ function render_content(&$a, $items, $mode, $update, $preview = false) {
                                                        intval($item['uid']),
                                                        intval($item['id'])
                                                );
+
                                                if (dbm::is_result($r)) {
                                                        $ignore = array(
                                                                'do' => t("ignore thread"),
@@ -793,7 +795,7 @@ function render_content(&$a, $items, $mode, $update, $preview = false) {
                                                        );
                                                }
                                                $tagger = '';
-                                               if(feature_enabled($profile_owner,'commtag')) {
+                                               if (feature_enabled($profile_owner,'commtag')) {
                                                        $tagger = array(
                                                                'add' => t("add tag"),
                                                                'class' => "",
@@ -818,19 +820,22 @@ function render_content(&$a, $items, $mode, $update, $preview = false) {
 
                                $sp = false;
                                $profile_link = best_link_url($item,$sp);
-                               if($profile_link === 'mailbox')
+                               if ($profile_link === 'mailbox') {
                                        $profile_link = '';
-                               if($sp)
+                               }
+                               if ($sp) {
                                        $sparkle = ' sparkle';
-                               else
+                               } else {
                                        $profile_link = zrl($profile_link);
+                               }
 
                                // Don't rely on the author-avatar. It is better to use the data from the contact table
                                $author_contact = get_contact_details_by_url($item['author-link'], $profile_owner);
-                               if ($author_contact["thumb"])
+                               if ($author_contact["thumb"]) {
                                        $profile_avatar = $author_contact["thumb"];
-                               else
+                               } else {
                                        $profile_avatar = $item['author-avatar'];
+                               }
 
                                $like    = ((x($conv_responses['like'],$item['uri'])) ? format_like($conv_responses['like'][$item['uri']],$conv_responses['like'][$item['uri'] . '-l'],'like',$item['uri']) : '');
                                $dislike = ((x($conv_responses['dislike'],$item['uri'])) ? format_like($conv_responses['dislike'][$item['uri']],$conv_responses['dislike'][$item['uri'] . '-l'],'dislike',$item['uri']) : '');
index f8cfb03f3782230e51ded8a973fb7e0455f2233c..84e32b83d578133c70c6be16b7f473fd3f8d523c 100644 (file)
@@ -5,7 +5,7 @@
  * addons repository will be listed though ATM)
  */
 
-function credits_content (&$a) {
+function credits_content (App &$a) {
     /* fill the page with credits */
     $f = fopen('util/credits.txt','r');
     $names = fread($f, filesize('util/credits.txt'));
index b4275f6baa2d4f2a709c57a25de218b6265778c8..2661deaeed9b0c8bb4b0ca99a5bc44ad4171d6b9 100644 (file)
@@ -2,9 +2,10 @@
 require_once("include/contact_selectors.php");
 require_once("mod/contacts.php");
 
-function crepair_init(&$a) {
-       if(! local_user())
+function crepair_init(App &$a) {
+       if (! local_user()) {
                return;
+       }
 
        $contact_id = 0;
 
@@ -14,7 +15,7 @@ function crepair_init(&$a) {
                        intval(local_user()),
                        intval($contact_id)
                );
-               if(! dbm::is_result($r)) {
+               if (! dbm::is_result($r)) {
                        $contact_id = 0;
                }
        }
@@ -30,9 +31,10 @@ function crepair_init(&$a) {
 }
 
 
-function crepair_post(&$a) {
-       if(! local_user())
+function crepair_post(App &$a) {
+       if (! local_user()) {
                return;
+       }
 
        $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
 
@@ -43,8 +45,9 @@ function crepair_post(&$a) {
                );
        }
 
-       if(! dbm::is_result($r))
+       if (! dbm::is_result($r)) {
                return;
+       }
 
        $contact = $r[0];
 
@@ -94,9 +97,9 @@ function crepair_post(&$a) {
 
 
 
-function crepair_content(&$a) {
+function crepair_content(App &$a) {
 
-       if(! local_user()) {
+       if (! local_user()) {
                notice( t('Permission denied.') . EOL);
                return;
        }
@@ -110,7 +113,7 @@ function crepair_content(&$a) {
                );
        }
 
-       if(! dbm::is_result($r)) {
+       if (! dbm::is_result($r)) {
                notice( t('Contact not found.') . EOL);
                return;
        }
index 71628aed0ed4d535854de2a60c90fb0855bbf8c7..1f261bb716afd6461fd88e8944ddbc6f06094855 100644 (file)
@@ -1,24 +1,25 @@
 <?php
 require_once('mod/settings.php');
 
-function delegate_init(&$a) {
+function delegate_init(App &$a) {
        return settings_init($a);
 }
 
 
-function delegate_content(&$a) {
+function delegate_content(App &$a) {
 
-       if(! local_user()) {
+       if (! local_user()) {
                notice( t('Permission denied.') . EOL);
                return;
        }
 
-       if($a->argc > 2 && $a->argv[1] === 'add' && intval($a->argv[2])) {
+       if ($a->argc > 2 && $a->argv[1] === 'add' && intval($a->argv[2])) {
 
                // delegated admins can view but not change delegation permissions
 
-               if(x($_SESSION,'submanage') && intval($_SESSION['submanage']))
-                       goaway($a->get_baseurl() . '/delegate');
+               if (x($_SESSION,'submanage') && intval($_SESSION['submanage'])) {
+                       goaway(App::get_baseurl() . '/delegate');
+               }
 
 
                $id = $a->argv[2];
@@ -29,7 +30,7 @@ function delegate_content(&$a) {
                if (dbm::is_result($r)) {
                        $r = q("select id from contact where uid = %d and nurl = '%s' limit 1",
                                intval(local_user()),
-                               dbesc(normalise_link($a->get_baseurl() . '/profile/' . $r[0]['nickname']))
+                               dbesc(normalise_link(App::get_baseurl() . '/profile/' . $r[0]['nickname']))
                        );
                        if (dbm::is_result($r)) {
                                q("insert into manage ( uid, mid ) values ( %d , %d ) ",
@@ -38,21 +39,22 @@ function delegate_content(&$a) {
                                );
                        }
                }
-               goaway($a->get_baseurl() . '/delegate');
+               goaway(App::get_baseurl() . '/delegate');
        }
 
-       if($a->argc > 2 && $a->argv[1] === 'remove' && intval($a->argv[2])) {
+       if ($a->argc > 2 && $a->argv[1] === 'remove' && intval($a->argv[2])) {
 
                // delegated admins can view but not change delegation permissions
 
-               if(x($_SESSION,'submanage') && intval($_SESSION['submanage']))
-                       goaway($a->get_baseurl() . '/delegate');
+               if (x($_SESSION,'submanage') && intval($_SESSION['submanage'])) {
+                       goaway(App::get_baseurl() . '/delegate');
+               }
 
                q("delete from manage where uid = %d and mid = %d limit 1",
                        intval($a->argv[2]),
                        intval(local_user())
                );
-               goaway($a->get_baseurl() . '/delegate');
+               goaway(App::get_baseurl() . '/delegate');
 
        }
 
@@ -92,12 +94,12 @@ function delegate_content(&$a) {
 
        $r = q("select nurl from contact where substring_index(contact.nurl,'/',3) = '%s' 
                and contact.uid = %d and contact.self = 0 and network = '%s' ",
-               dbesc(normalise_link($a->get_baseurl())),
+               dbesc(normalise_link(App::get_baseurl())),
                intval(local_user()),
                dbesc(NETWORK_DFRN)
        ); 
 
-       if(! dbm::is_result($r)) {
+       if (! dbm::is_result($r)) {
                notice( t('No potential page delegates located.') . EOL);
                return;
        }
@@ -128,7 +130,7 @@ function delegate_content(&$a) {
 
        $o = replace_macros(get_markup_template('delegate.tpl'),array(
                '$header' => t('Delegate Page Management'),
-               '$base' => $a->get_baseurl(),
+               '$base' => App::get_baseurl(),
                '$desc' => t('Delegates are able to manage all aspects of this account/page except for basic account settings. Please do not delegate your personal account to anybody that you do not trust completely.'),
                '$head_managers' => t('Existing Page Managers'),
                '$managers' => $full_managers,
index 23c62cb0ab25d127c8c0fd1037a6a998c69e5a03..22d4c1535872e7388f99cce209118b4917d910aa 100644 (file)
@@ -121,7 +121,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
                        intval($uid)
                );
 
-               if(! dbm::is_result($r)) {
+               if (! dbm::is_result($r)) {
                        logger('Contact not found in DB.');
                        notice( t('Contact not found.') . EOL );
                        notice( t('This may occasionally happen if contact was requested by both persons and it has already been approved.') . EOL );
@@ -194,7 +194,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
                        $params['public_key'] = $public_key;
 
 
-                       $my_url = $a->get_baseurl() . '/profile/' . $user[0]['nickname'];
+                       $my_url = App::get_baseurl() . '/profile/' . $user[0]['nickname'];
 
                        openssl_public_encrypt($my_url, $params['source_url'], $site_pubkey);
                        $params['source_url'] = bin2hex($params['source_url']);
@@ -415,23 +415,26 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
                        );
                }
 
-               if($r === false)
-                               notice( t('Unable to set contact photo.') . EOL);
+               /// @TODO is dbm::is_result() working here?
+               if ($r === false) {
+                       notice( t('Unable to set contact photo.') . EOL);
+               }
 
                // reload contact info
 
                $r = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
                        intval($contact_id)
                );
-               if (dbm::is_result($r))
+               if (dbm::is_result($r)) {
                        $contact = $r[0];
-               else
+               } else {
                        $contact = null;
+               }
 
 
-               if((isset($new_relation) && $new_relation == CONTACT_IS_FRIEND)) {
+               if ((isset($new_relation) && $new_relation == CONTACT_IS_FRIEND)) {
 
-                       if(($contact) && ($contact['network'] === NETWORK_DIASPORA)) {
+                       if (($contact) && ($contact['network'] === NETWORK_DIASPORA)) {
                                require_once('include/diaspora.php');
                                $ret = diaspora::send_share($user[0],$r[0]);
                                logger('share returns: ' . $ret);
@@ -503,10 +506,11 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
                // Let's send our user to the contact editor in case they want to
                // do anything special with this new friend.
 
-               if($handsfree === null)
-                       goaway($a->get_baseurl() . '/contacts/' . intval($contact_id));
-               else
+               if ($handsfree === null) {
+                       goaway(App::get_baseurl() . '/contacts/' . intval($contact_id));
+               } else {
                        return;
+               }
                //NOTREACHED
        }
 
@@ -522,7 +526,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
         *
         */
 
-       if(x($_POST,'source_url')) {
+       if (x($_POST,'source_url')) {
 
                // We are processing an external confirmation to an introduction created by our user.
 
@@ -543,7 +547,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
 
                // If $aes_key is set, both of these items require unpacking from the hex transport encoding.
 
-               if(x($aes_key)) {
+               if (x($aes_key)) {
                        $aes_key = hex2bin($aes_key);
                        $public_key = hex2bin($public_key);
                }
@@ -553,7 +557,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
                $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' LIMIT 1",
                        dbesc($node));
 
-               if(! dbm::is_result($r)) {
+               if (! dbm::is_result($r)) {
                        $message = sprintf(t('No user record found for \'%s\' '), $node);
                        xml_status(3,$message); // failure
                        // NOTREACHED
@@ -584,7 +588,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
                        dbesc($decrypted_source_url),
                        intval($local_uid)
                );
-               if(! count($ret)) {
+               if(! dbm::is_result($ret)) {
                        if(strstr($decrypted_source_url,'http:'))
                                $newurl = str_replace('http:','https:',$decrypted_source_url);
                        else
@@ -594,7 +598,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
                                dbesc($newurl),
                                intval($local_uid)
                        );
-                       if(! count($ret)) {
+                       if(! dbm::is_result($ret)) {
                                // this is either a bogus confirmation (?) or we deleted the original introduction.
                                $message = t('Contact record was not found for you on our site.');
                                xml_status(3,$message);
@@ -640,7 +644,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
                        dbesc($dfrn_pubkey),
                        intval($dfrn_record)
                );
-               if(! dbm::is_result($r)) {
+               if (! dbm::is_result($r)) {
                        $message = t('Unable to set your contact credentials on our system.');
                        xml_status(3,$message);
                }
@@ -661,10 +665,11 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
                $r = q("SELECT `photo` FROM `contact` WHERE `id` = %d LIMIT 1",
                        intval($dfrn_record));
 
-               if (dbm::is_result($r))
+               if (dbm::is_result($r)) {
                        $photo = $r[0]['photo'];
-               else
-                       $photo = $a->get_baseurl() . '/images/person-175.jpg';
+               } else {
+                       $photo = App::get_baseurl() . '/images/person-175.jpg';
+               }
 
                require_once("include/Photo.php");
 
@@ -673,11 +678,13 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
                logger('dfrn_confirm: request - photos imported');
 
                $new_relation = CONTACT_IS_SHARING;
-               if(($relation == CONTACT_IS_FOLLOWER) || ($duplex))
+               if (($relation == CONTACT_IS_FOLLOWER) || ($duplex)) {
                        $new_relation = CONTACT_IS_FRIEND;
+               }
 
-               if(($relation == CONTACT_IS_FOLLOWER) && ($duplex))
+               if (($relation == CONTACT_IS_FOLLOWER) && ($duplex)) {
                        $duplex = 0;
+               }
 
                $r = q("UPDATE `contact` SET
                        `rel` = %d,
@@ -699,7 +706,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
                        dbesc(NETWORK_DFRN),
                        intval($dfrn_record)
                );
-               if($r === false) {    // indicates schema is messed up or total db failure
+               if ($r === false) {    // indicates schema is messed up or total db failure
                        $message = t('Unable to update your contact profile details on our system');
                        xml_status(3,$message);
                }
@@ -726,7 +733,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
                                'to_name'      => $r[0]['username'],
                                'to_email'     => $r[0]['email'],
                                'uid'          => $r[0]['uid'],
-                               'link'             => $a->get_baseurl() . '/contacts/' . $dfrn_record,
+                               'link'             => App::get_baseurl() . '/contacts/' . $dfrn_record,
                                'source_name'  => ((strlen(stripslashes($r[0]['name']))) ? stripslashes($r[0]['name']) : t('[Name Withheld]')),
                                'source_link'  => $r[0]['url'],
                                'source_photo' => $r[0]['photo'],
index dfa2af18ce29985901409d3d3149879811a7b8e7..eebaa076d94b9bc0ece344ee5e09ae9478f8ee37 100644 (file)
@@ -11,7 +11,7 @@ require_once('include/event.php');
 
 require_once('library/defuse/php-encryption-1.2.1/Crypto.php');
 
-function dfrn_notify_post(&$a) {
+function dfrn_notify_post(App &$a) {
        logger(__function__, LOGGER_TRACE);
        $dfrn_id      = ((x($_POST,'dfrn_id'))      ? notags(trim($_POST['dfrn_id']))   : '');
        $dfrn_version = ((x($_POST,'dfrn_version')) ? (float) $_POST['dfrn_version']    : 2.0);
@@ -42,7 +42,7 @@ function dfrn_notify_post(&$a) {
                dbesc($dfrn_id),
                dbesc($challenge)
        );
-       if(! dbm::is_result($r)) {
+       if (! dbm::is_result($r)) {
                logger('dfrn_notify: could not match challenge to dfrn_id ' . $dfrn_id . ' challenge=' . $challenge);
                xml_status(3);
        }
@@ -88,7 +88,7 @@ function dfrn_notify_post(&$a) {
                dbesc($a->argv[1])
        );
 
-       if(! dbm::is_result($r)) {
+       if (! dbm::is_result($r)) {
                logger('dfrn_notify: contact not found for dfrn_id ' . $dfrn_id);
                xml_status(3);
                //NOTREACHED
@@ -221,7 +221,7 @@ function dfrn_notify_post(&$a) {
 }
 
 
-function dfrn_notify_content(&$a) {
+function dfrn_notify_content(App &$a) {
 
        if(x($_GET,'dfrn_id')) {
 
@@ -284,8 +284,9 @@ function dfrn_notify_content(&$a) {
                                dbesc($a->argv[1])
                );
 
-               if(! dbm::is_result($r))
+               if (! dbm::is_result($r)) {
                        $status = 1;
+               }
 
                logger("Remote rino version: ".$rino_remote." for ".$r[0]["url"], LOGGER_DEBUG);
 
index 91cd33f49abf66e1475448aaec6a630914da2594..a31a50ad254dbb21f011fa435b95c989a8368317 100644 (file)
@@ -4,7 +4,7 @@ require_once('include/auth.php');
 require_once('include/dfrn.php');
 
 
-function dfrn_poll_init(&$a) {
+function dfrn_poll_init(App &$a) {
 
 
        $dfrn_id         = ((x($_GET,'dfrn_id'))         ? $_GET['dfrn_id']              : '');
@@ -112,7 +112,7 @@ function dfrn_poll_init(&$a) {
                                }
                        }
                        $profile = $r[0]['nickname'];
-                       goaway((strlen($destination_url)) ? $destination_url : $a->get_baseurl() . '/profile/' . $profile);
+                       goaway((strlen($destination_url)) ? $destination_url : App::get_baseurl() . '/profile/' . $profile);
                }
                goaway(z_root());
 
@@ -126,7 +126,7 @@ function dfrn_poll_init(&$a) {
                        $r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1",
                                dbesc($sec)
                        );
-                       if(! dbm::is_result($r)) {
+                       if (! dbm::is_result($r)) {
                                xml_status(3, 'No ticket');
                                // NOTREACHED
                        }
@@ -137,7 +137,7 @@ function dfrn_poll_init(&$a) {
                        $c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
                                intval($r[0]['cid'])
                        );
-                       if(! count($c)) {
+                       if (! dbm::is_result($c)) {
                                xml_status(3, 'No profile');
                        }
                        $contact = $c[0];
@@ -203,7 +203,7 @@ function dfrn_poll_init(&$a) {
 
 
 
-function dfrn_poll_post(&$a) {
+function dfrn_poll_post(App &$a) {
 
        $dfrn_id      = ((x($_POST,'dfrn_id'))      ? $_POST['dfrn_id']              : '');
        $challenge    = ((x($_POST,'challenge'))    ? $_POST['challenge']            : '');
@@ -223,7 +223,7 @@ function dfrn_poll_post(&$a) {
                        $r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1",
                                dbesc($sec)
                        );
-                       if(! dbm::is_result($r)) {
+                       if (! dbm::is_result($r)) {
                                xml_status(3, 'No ticket');
                                // NOTREACHED
                        }
@@ -234,7 +234,7 @@ function dfrn_poll_post(&$a) {
                        $c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
                                intval($r[0]['cid'])
                        );
-                       if(! count($c)) {
+                       if (! dbm::is_result($c)) {
                                xml_status(3, 'No profile');
                        }
                        $contact = $c[0];
@@ -284,8 +284,9 @@ function dfrn_poll_post(&$a) {
                dbesc($challenge)
        );
 
-       if(! dbm::is_result($r))
+       if (! dbm::is_result($r)) {
                killme();
+       }
 
        $type = $r[0]['type'];
        $last_update = $r[0]['last_update'];
@@ -319,8 +320,9 @@ function dfrn_poll_post(&$a) {
        $r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 $sql_extra LIMIT 1");
 
 
-       if(! dbm::is_result($r))
+       if (! dbm::is_result($r)) {
                killme();
+       }
 
        $contact = $r[0];
        $owner_uid = $r[0]['uid'];
@@ -381,7 +383,7 @@ function dfrn_poll_post(&$a) {
        }
 }
 
-function dfrn_poll_content(&$a) {
+function dfrn_poll_content(App &$a) {
 
        $dfrn_id         = ((x($_GET,'dfrn_id'))         ? $_GET['dfrn_id']              : '');
        $type            = ((x($_GET,'type'))            ? $_GET['type']                 : 'data');
@@ -499,14 +501,14 @@ function dfrn_poll_content(&$a) {
 
                        switch($destination_url) {
                                case 'profile':
-                                       $dest = $a->get_baseurl() . '/profile/' . $profile . '?f=&tab=profile';
+                                       $dest = App::get_baseurl() . '/profile/' . $profile . '?f=&tab=profile';
                                        break;
                                case 'photos':
-                                       $dest = $a->get_baseurl() . '/photos/' . $profile;
+                                       $dest = App::get_baseurl() . '/photos/' . $profile;
                                        break;
                                case 'status':
                                case '':
-                                       $dest = $a->get_baseurl() . '/profile/' . $profile;
+                                       $dest = App::get_baseurl() . '/profile/' . $profile;
                                        break;
                                default:
                                        $dest = $destination_url . '?f=&redir=1';
index 236970a2e9d8c0bb91ed250b9e9f312b0df7a129..3a5711d0f7edca8ed7c92356ceaaf6163798c48e 100644 (file)
@@ -17,7 +17,7 @@ require_once('include/Scrape.php');
 require_once('include/Probe.php');
 require_once('include/group.php');
 
-function dfrn_request_init(&$a) {
+function dfrn_request_init(App &$a) {
 
        if($a->argc > 1)
                $which = $a->argv[1];
@@ -42,7 +42,7 @@ function dfrn_request_init(&$a) {
  * After logging in, we click 'submit' to approve the linkage.
  *
  */
-function dfrn_request_post(&$a) {
+function dfrn_request_post(App &$a) {
 
        if(($a->argc != 2) || (! count($a->profile))) {
                logger('Wrong count of argc or profiles: argc=' . $a->argc . ',profile()=' . count($a->profile));
@@ -120,17 +120,19 @@ function dfrn_request_post(&$a) {
 
                                        $parms = Probe::profile($dfrn_url);
 
-                                       if(! count($parms)) {
+                                       if (! count($parms)) {
                                                notice( t('Profile location is not valid or does not contain profile information.') . EOL );
                                                return;
                                        }
                                        else {
-                                               if(! x($parms,'fn'))
+                                               if (! x($parms,'fn')) {
                                                        notice( t('Warning: profile location has no identifiable owner name.') . EOL );
-                                               if(! x($parms,'photo'))
+                                               }
+                                               if (! x($parms,'photo')) {
                                                        notice( t('Warning: profile location has no profile photo.') . EOL );
+                                               }
                                                $invalid = Probe::valid_dfrn($parms);
-                                               if($invalid) {
+                                               if ($invalid) {
                                                        notice( sprintf( tt("%d required parameter was not found at the given location",
                                                                                                "%d required parameters were not found at the given location",
                                                                                                $invalid), $invalid) . EOL );
@@ -193,19 +195,22 @@ function dfrn_request_post(&$a) {
                                        if (isset($photo))
                                                update_contact_avatar($photo, local_user(), $r[0]["id"], true);
 
-                                       $forwardurl = $a->get_baseurl()."/contacts/".$r[0]['id'];
-                               } else
-                                       $forwardurl = $a->get_baseurl()."/contacts";
+                                       $forwardurl = App::get_baseurl()."/contacts/".$r[0]['id'];
+                               } else {
+                                       $forwardurl = App::get_baseurl()."/contacts";
+                               }
 
                                /*
                                 * Allow the blocked remote notification to complete
                                 */
 
-                               if(is_array($contact_record))
+                               if (is_array($contact_record)) {
                                        $dfrn_request = $contact_record['request'];
+                               }
 
-                               if(strlen($dfrn_request) && strlen($confirm_key))
+                               if (strlen($dfrn_request) && strlen($confirm_key)) {
                                        $s = fetch_url($dfrn_request . '?confirm_key=' . $confirm_key);
+                               }
 
                                // (ignore reply, nothing we can do it failed)
 
@@ -371,7 +376,7 @@ function dfrn_request_post(&$a) {
                                        intval($uid)
                                );
 
-                               if(! dbm::is_result($r)) {
+                               if (! dbm::is_result($r)) {
                                        notice( t('This account has not been configured for email. Request failed.') . EOL);
                                        return;
                                }
@@ -499,15 +504,15 @@ function dfrn_request_post(&$a) {
                                );
                        }
                        else {
-                               if(! validate_url($url)) {
+                               if (! validate_url($url)) {
                                        notice( t('Invalid profile URL.') . EOL);
-                                       goaway($a->get_baseurl() . '/' . $a->cmd);
+                                       goaway(App::get_baseurl() . '/' . $a->cmd);
                                        return; // NOTREACHED
                                }
 
-                               if(! allowed_url($url)) {
+                               if (! allowed_url($url)) {
                                        notice( t('Disallowed profile URL.') . EOL);
-                                       goaway($a->get_baseurl() . '/' . $a->cmd);
+                                       goaway(App::get_baseurl() . '/' . $a->cmd);
                                        return; // NOTREACHED
                                }
 
@@ -516,17 +521,19 @@ function dfrn_request_post(&$a) {
 
                                $parms = Probe::profile(($hcard) ? $hcard : $url);
 
-                               if(! count($parms)) {
+                               if (! count($parms)) {
                                        notice( t('Profile location is not valid or does not contain profile information.') . EOL );
-                                       goaway($a->get_baseurl() . '/' . $a->cmd);
+                                       goaway(App::get_baseurl() . '/' . $a->cmd);
                                }
                                else {
-                                       if(! x($parms,'fn'))
+                                       if (! x($parms,'fn')) {
                                                notice( t('Warning: profile location has no identifiable owner name.') . EOL );
-                                       if(! x($parms,'photo'))
+                                       }
+                                       if (! x($parms,'photo')) {
                                                notice( t('Warning: profile location has no profile photo.') . EOL );
+                                       }
                                        $invalid = Probe::valid_dfrn($parms);
-                                       if($invalid) {
+                                       if ($invalid) {
                                                notice( sprintf( tt("%d required parameter was not found at the given location",
                                                                                        "%d required parameters were not found at the given location",
                                                                                        $invalid), $invalid) . EOL );
@@ -565,7 +572,7 @@ function dfrn_request_post(&$a) {
                                );
 
                                // find the contact record we just created
-                               if($r) {
+                               if ($r) {
                                        $r = q("SELECT `id` FROM `contact`
                                                WHERE `uid` = %d AND `url` = '%s' AND `issued-id` = '%s' LIMIT 1",
                                                intval($uid),
@@ -579,14 +586,14 @@ function dfrn_request_post(&$a) {
                                }
 
                        }
-                       if($r === false) {
+                       if ($r === false) {
                                notice( t('Failed to update contact record.') . EOL );
                                return;
                        }
 
                        $hash = random_string() . (string) time();   // Generate a confirm_key
 
-                       if(is_array($contact_record)) {
+                       if (is_array($contact_record)) {
                                $ret = q("INSERT INTO `intro` ( `uid`, `contact-id`, `blocked`, `knowyou`, `note`, `hash`, `datetime`)
                                        VALUES ( %d, %d, 1, %d, '%s', '%s', '%s' )",
                                        intval($uid),
@@ -600,12 +607,13 @@ function dfrn_request_post(&$a) {
 
                        // This notice will only be seen by the requestor if the requestor and requestee are on the same server.
 
-                       if(! $failed)
+                       if (! $failed) {
                                info( t('Your introduction has been sent.') . EOL );
+                       }
 
                        // "Homecoming" - send the requestor back to their site to record the introduction.
 
-                       $dfrn_url = bin2hex($a->get_baseurl() . '/profile/' . $nickname);
+                       $dfrn_url = bin2hex(App::get_baseurl() . '/profile/' . $nickname);
                        $aes_allow = ((function_exists('openssl_encrypt')) ? 1 : 0);
 
                        goaway($parms['dfrn-request'] . "?dfrn_url=$dfrn_url"
@@ -633,8 +641,9 @@ function dfrn_request_post(&$a) {
                                        $uri .= '/'.$a->get_path();
 
                                $uri = urlencode($uri);
-                       } else
-                               $uri = $a->get_baseurl().'/profile/'.$nickname;
+                       } else {
+                               $uri = App::get_baseurl().'/profile/'.$nickname;
+                       }
 
                        $url = str_replace('{uri}', $uri, $url);
                        goaway($url);
@@ -649,18 +658,19 @@ function dfrn_request_post(&$a) {
 }
 
 
-function dfrn_request_content(&$a) {
+function dfrn_request_content(App &$a) {
 
-       if(($a->argc != 2) || (! count($a->profile)))
+       if (($a->argc != 2) || (! count($a->profile))) {
                return "";
+       }
 
 
        // "Homecoming". Make sure we're logged in to this site as the correct user. Then offer a confirm button
        // to send us to the post section to record the introduction.
 
-       if(x($_GET,'dfrn_url')) {
+       if (x($_GET,'dfrn_url')) {
 
-               if(! local_user()) {
+               if (! local_user()) {
                        info( t("Please login to confirm introduction.") . EOL );
                        /* setup the return URL to come back to this page if they use openid */
                        $_SESSION['return_url'] = $a->query_string;
@@ -742,7 +752,7 @@ function dfrn_request_content(&$a) {
                                                'to_name'      => $r[0]['username'],
                                                'to_email'     => $r[0]['email'],
                                                'uid'          => $r[0]['uid'],
-                                               'link'         => $a->get_baseurl() . '/notifications/intros',
+                                               'link'         => App::get_baseurl() . '/notifications/intros',
                                                'source_name'  => ((strlen(stripslashes($r[0]['name']))) ? stripslashes($r[0]['name']) : t('[Name Withheld]')),
                                                'source_link'  => $r[0]['url'],
                                                'source_photo' => $r[0]['photo'],
@@ -804,15 +814,18 @@ function dfrn_request_content(&$a) {
                        $myaddr = hex2bin($_GET['addr']);
                elseif (x($_GET,'address') AND ($_GET['address'] != ""))
                        $myaddr = $_GET['address'];
-               elseif(local_user()) {
-                       if(strlen($a->path)) {
-                               $myaddr = $a->get_baseurl() . '/profile/' . $a->user['nickname'];
+               elseif (local_user()) {
+                       if (strlen($a->path)) {
+                               $myaddr = App::get_baseurl() . '/profile/' . $a->user['nickname'];
                        }
                        else {
                                $myaddr = $a->user['nickname'] . '@' . substr(z_root(), strpos(z_root(),'://') + 3 );
                        }
-               } else  // last, try a zrl
+               }
+               else {
+                       // last, try a zrl
                        $myaddr = get_my_url();
+               }
 
                $target_addr = $a->profile['nickname'] . '@' . substr(z_root(), strpos(z_root(),'://') + 3 );
 
@@ -825,10 +838,12 @@ function dfrn_request_content(&$a) {
                 *
                 */
 
-               if($a->profile['page-flags'] == PAGE_NORMAL)
+               if ($a->profile['page-flags'] == PAGE_NORMAL) {
                        $tpl = get_markup_template('dfrn_request.tpl');
-               else
+               }
+               else {
                        $tpl = get_markup_template('auto_request.tpl');
+               }
 
                $page_desc = t("Please enter your 'Identity Address' from one of the following supported communications networks:");
 
@@ -842,8 +857,9 @@ function dfrn_request_content(&$a) {
                        $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
                                intval($a->profile['uid'])
                        );
-                       if(! dbm::is_result($r))
+                       if (! dbm::is_result($r)) {
                                $mail_disabled = 1;
+                       }
                }
 
                // "coming soon" is disabled for now
index ddea650de2b5796e8c7dbd065c28f44913ba38ad..c702acf376049eafe6fe1664661451673a646cd2 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-function directory_init(&$a) {
+function directory_init(App &$a) {
        $a->set_pager_itemspage(60);
 
        if(local_user()) {
@@ -20,14 +20,14 @@ function directory_init(&$a) {
 }
 
 
-function directory_post(&$a) {
+function directory_post(App &$a) {
        if(x($_POST,'search'))
                $a->data['search'] = $_POST['search'];
 }
 
 
 
-function directory_content(&$a) {
+function directory_content(App &$a) {
        global $db;
 
        require_once("mod/proxy.php");
index 215731978cfe6adeab59cb72e5a5da557c3ad9da..2b2badb64031f0780dacc95df7f9c17a264cf5b8 100644 (file)
@@ -5,15 +5,16 @@ require_once('include/Contact.php');
 require_once('include/contact_selectors.php');
 require_once('mod/contacts.php');
 
-function dirfind_init(&$a) {
+function dirfind_init(App &$a) {
 
-       if(! local_user()) {
+       if (! local_user()) {
                notice( t('Permission denied.') . EOL );
                return;
        }
 
-       if(! x($a->page,'aside'))
+       if (! x($a->page,'aside')) {
                $a->page['aside'] = '';
+       }
 
        $a->page['aside'] .= findpeople_widget();
 
@@ -31,7 +32,7 @@ function dirfind_content(&$a, $prefix = "") {
 
        $search = $prefix.notags(trim($_REQUEST['search']));
 
-       if(strpos($search,'@') === 0) {
+       if (strpos($search,'@') === 0) {
                $search = substr($search,1);
                $header = sprintf( t('People Search - %s'), $search);
                if ((valid_email($search) AND validate_email($search)) OR
@@ -41,7 +42,7 @@ function dirfind_content(&$a, $prefix = "") {
                }
        }
 
-       if(strpos($search,'!') === 0) {
+       if (strpos($search,'!') === 0) {
                $search = substr($search,1);
                $community = true;
                $header = sprintf( t('Forum Search - %s'), $search);
@@ -49,7 +50,7 @@ function dirfind_content(&$a, $prefix = "") {
 
        $o = '';
 
-       if($search) {
+       if ($search) {
 
                if ($discover_user) {
                        $j = new stdClass();
@@ -85,15 +86,19 @@ function dirfind_content(&$a, $prefix = "") {
                        $perpage = 80;
                        $startrec = (($a->pager['page']) * $perpage) - $perpage;
 
-                       if (get_config('system','diaspora_enabled'))
+                       if (get_config('system','diaspora_enabled')) {
                                $diaspora = NETWORK_DIASPORA;
-                       else
+                       }
+                       else {
                                $diaspora = NETWORK_DFRN;
+                       }
 
-                       if (!get_config('system','ostatus_disabled'))
+                       if (!get_config('system','ostatus_disabled')) {
                                $ostatus = NETWORK_OSTATUS;
-                       else
+                       }
+                       else {
                                $ostatus = NETWORK_DFRN;
+                       }
 
                        $search2 = "%".$search."%";
 
@@ -133,8 +138,9 @@ function dirfind_content(&$a, $prefix = "") {
                        $j->items_page = $perpage;
                        $j->page = $a->pager['page'];
                        foreach ($results AS $result) {
-                               if (poco_alternate_ostatus_url($result["url"]))
-                                        continue;
+                               if (poco_alternate_ostatus_url($result["url"])) {
+                                       continue;
+                               }
 
                                $result = get_contact_details_by_url($result["url"], local_user(), $result);
 
@@ -167,16 +173,16 @@ function dirfind_content(&$a, $prefix = "") {
                        $j = json_decode($x);
                }
 
-               if($j->total) {
+               if ($j->total) {
                        $a->set_pager_total($j->total);
                        $a->set_pager_itemspage($j->items_page);
                }
 
-               if(count($j->results)) {
+               if (count($j->results)) {
 
                        $id = 0;
 
-                       foreach($j->results as $jj) {
+                       foreach ($j->results as $jj) {
 
                                $alt_text = "";
 
@@ -194,10 +200,12 @@ function dirfind_content(&$a, $prefix = "") {
                                                $photo_menu = contact_photo_menu($contact[0]);
                                                $details = _contact_detail_for_template($contact[0]);
                                                $alt_text = $details['alt_text'];
-                                       } else
+                                       }
+                                       else {
                                                $photo_menu = array();
+                                       }
                                } else {
-                                       $connlnk = $a->get_baseurl().'/follow/?url='.(($jj->connect) ? $jj->connect : $jj->url);
+                                       $connlnk = App::get_baseurl().'/follow/?url='.(($jj->connect) ? $jj->connect : $jj->url);
                                        $conntxt = t('Connect');
                                        $photo_menu = array(
                                                'profile' => array(t("View Profile"), zrl($jj->url)),
index 293156cf19f5dbd8a4fb87e3b30043f956340796..c98d936a0f45dd6c01676709d7cf88947406b59c 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-function display_init(&$a) {
+function display_init(App &$a) {
 
        if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
                return;
@@ -81,8 +81,8 @@ function display_init(&$a) {
 
                        $profiledata = display_fetchauthor($a, $r[0]);
 
-                       if (strstr(normalise_link($profiledata["url"]), normalise_link($a->get_baseurl()))) {
-                               $nickname = str_replace(normalise_link($a->get_baseurl())."/profile/", "", normalise_link($profiledata["url"]));
+                       if (strstr(normalise_link($profiledata["url"]), normalise_link(App::get_baseurl()))) {
+                               $nickname = str_replace(normalise_link(App::get_baseurl())."/profile/", "", normalise_link($profiledata["url"]));
 
                                if (($nickname != $a->user["nickname"])) {
                                        $r = qu("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile`
@@ -184,7 +184,7 @@ function display_fetchauthor($a, $item) {
 
        if (local_user()) {
                if (in_array($profiledata["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) {
-                       $profiledata["remoteconnect"] = $a->get_baseurl()."/follow?url=".urlencode($profiledata["url"]);
+                       $profiledata["remoteconnect"] = App::get_baseurl()."/follow?url=".urlencode($profiledata["url"]);
                }
        } elseif ($profiledata["network"] == NETWORK_DFRN) {
                $connect = str_replace("/profile/", "/dfrn_request/", $profiledata["url"]);
index 217d793f5225541fc44745203a02a77f9b307885..a655801d7727ec11b60837fd3e2fbb4fcc76bc13 100644 (file)
@@ -2,18 +2,18 @@
 
 require_once('include/acl_selectors.php');
 
-function editpost_content(&$a) {
+function editpost_content(App &$a) {
 
        $o = '';
 
-       if(! local_user()) {
+       if (! local_user()) {
                notice( t('Permission denied.') . EOL);
                return;
        }
 
        $post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
 
-       if(! $post_id) {
+       if (! $post_id) {
                notice( t('Item not found') . EOL);
                return;
        }
@@ -23,7 +23,7 @@ function editpost_content(&$a) {
                intval(local_user())
        );
 
-       if(! count($itm)) {
+       if (! dbm::is_result($itm)) {
                notice( t('Item not found') . EOL);
                return;
        }
@@ -42,7 +42,7 @@ function editpost_content(&$a) {
 
        $tpl = get_markup_template('jot-header.tpl');
        $a->page['htmlhead'] .= replace_macros($tpl, array(
-               '$baseurl' => $a->get_baseurl(),
+               '$baseurl' => App::get_baseurl(),
                '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
                '$ispublic' => '&nbsp;', // t('Visible to <strong>everybody</strong>'),
                '$geotag' => $geotag,
@@ -51,7 +51,7 @@ function editpost_content(&$a) {
 
        $tpl = get_markup_template('jot-end.tpl');
        $a->page['end'] .= replace_macros($tpl, array(
-               '$baseurl' => $a->get_baseurl(),
+               '$baseurl' => App::get_baseurl(),
                '$editselect' =>  (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
                '$ispublic' => '&nbsp;', // t('Visible to <strong>everybody</strong>'),
                '$geotag' => $geotag,
@@ -126,7 +126,7 @@ function editpost_content(&$a) {
                '$ptyp' => $itm[0]['type'],
                '$content' => undo_post_tagging($itm[0]['body']),
                '$post_id' => $post_id,
-               '$baseurl' => $a->get_baseurl(),
+               '$baseurl' => App::get_baseurl(),
                '$defloc' => $a->user['default-location'],
                '$visitor' => 'none',
                '$pvisit' => 'none',
index 7cb171f9e5cc65cc1c011699fc4e3ac985da5fb5..6bf7da6a28567a7e1c92f30d631f3c189514111f 100644 (file)
@@ -8,11 +8,12 @@ require_once('include/datetime.php');
 require_once('include/event.php');
 require_once('include/items.php');
 
-function events_init(&$a) {
-       if(! local_user())
+function events_init(App &$a) {
+       if (! local_user()) {
                return;
+       }
 
-       if($a->argc == 1) {
+       if ($a->argc == 1) {
                // if it's a json request abort here becaus we don't
                // need the widget data
                if($a->argv[1] === 'json')
@@ -20,8 +21,9 @@ function events_init(&$a) {
 
                $cal_widget = widget_events();
 
-               if(! x($a->page,'aside'))
+               if (! x($a->page,'aside')) {
                        $a->page['aside'] = '';
+               }
 
                $a->page['aside'] .= $cal_widget;
        }
@@ -29,12 +31,13 @@ function events_init(&$a) {
        return;
 }
 
-function events_post(&$a) {
+function events_post(App &$a) {
 
        logger('post: ' . print_r($_REQUEST,true));
 
-       if(! local_user())
+       if (! local_user()) {
                return;
+       }
 
        $event_id = ((x($_POST,'event_id')) ? intval($_POST['event_id']) : 0);
        $cid = ((x($_POST,'cid')) ? intval($_POST['cid']) : 0);
@@ -89,7 +92,7 @@ function events_post(&$a) {
        $type     = 'event';
 
        $action = ($event_id == '') ? 'new' : "event/" . $event_id;
-       $onerror_url = $a->get_baseurl() . "/events/" . $action . "?summary=$summary&description=$desc&location=$location&start=$start_text&finish=$finish_text&adjust=$adjust&nofinish=$nofinish";
+       $onerror_url = App::get_baseurl() . "/events/" . $action . "?summary=$summary&description=$desc&location=$location&start=$start_text&finish=$finish_text&adjust=$adjust&nofinish=$nofinish";
 
        if(strcmp($finish,$start) < 0 && !$nofinish) {
                notice( t('Event can not end before it has started.') . EOL);
@@ -184,45 +187,48 @@ function events_post(&$a) {
 
 
 
-function events_content(&$a) {
+function events_content(App &$a) {
 
-       if(! local_user()) {
+       if (! local_user()) {
                notice( t('Permission denied.') . EOL);
                return;
        }
 
-       if($a->argc == 1)
-               $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd;
+       if ($a->argc == 1) {
+               $_SESSION['return_url'] = App::get_baseurl() . '/' . $a->cmd;
+       }
 
-       if(($a->argc > 2) && ($a->argv[1] === 'ignore') && intval($a->argv[2])) {
+       if (($a->argc > 2) && ($a->argv[1] === 'ignore') && intval($a->argv[2])) {
                $r = q("update event set ignore = 1 where id = %d and uid = %d",
                        intval($a->argv[2]),
                        intval(local_user())
                );
        }
 
-       if(($a->argc > 2) && ($a->argv[1] === 'unignore') && intval($a->argv[2])) {
+       if (($a->argc > 2) && ($a->argv[1] === 'unignore') && intval($a->argv[2])) {
                $r = q("update event set ignore = 0 where id = %d and uid = %d",
                        intval($a->argv[2]),
                        intval(local_user())
                );
        }
 
-       if ($a->theme_events_in_profile)
+       if ($a->theme_events_in_profile) {
                nav_set_selected('home');
-       else
+       } else {
                nav_set_selected('events');
+       }
 
        $editselect = 'none';
-       if( feature_enabled(local_user(), 'richtext') )
+       if ( feature_enabled(local_user(), 'richtext') ) {
                $editselect = 'textareas';
+       }
 
        // get the translation strings for the callendar
        $i18n = get_event_strings();
 
        $htpl = get_markup_template('event_head.tpl');
        $a->page['htmlhead'] .= replace_macros($htpl,array(
-               '$baseurl' => $a->get_baseurl(),
+               '$baseurl' => App::get_baseurl(),
                '$module_url' => '/events',
                '$modparams' => 1,
                '$i18n' => $i18n,
@@ -231,7 +237,7 @@ function events_content(&$a) {
 
        $etpl = get_markup_template('event_end.tpl');
        $a->page['end'] .= replace_macros($etpl,array(
-               '$baseurl' => $a->get_baseurl(),
+               '$baseurl' => App::get_baseurl(),
                '$editselect' => $editselect
        ));
 
@@ -248,15 +254,15 @@ function events_content(&$a) {
        $ignored = ((x($_REQUEST,'ignored')) ? intval($_REQUEST['ignored']) : 0);
 
        if($a->argc > 1) {
-               if($a->argc > 2 && $a->argv[1] == 'event') {
+               if ($a->argc > 2 && $a->argv[1] == 'event') {
                        $mode = 'edit';
                        $event_id = intval($a->argv[2]);
                }
-               if($a->argv[1] === 'new') {
+               if ($a->argv[1] === 'new') {
                        $mode = 'new';
                        $event_id = 0;
                }
-               if($a->argc > 2 && intval($a->argv[1]) && intval($a->argv[2])) {
+               if ($a->argc > 2 && intval($a->argv[1]) && intval($a->argv[2])) {
                        $mode = 'view';
                        $y = intval($a->argv[1]);
                        $m = intval($a->argv[2]);
@@ -264,23 +270,27 @@ function events_content(&$a) {
        }
 
        // The view mode part is similiar to /mod/cal.php
-       if($mode == 'view') {
+       if ($mode == 'view') {
 
 
                $thisyear = datetime_convert('UTC',date_default_timezone_get(),'now','Y');
                $thismonth = datetime_convert('UTC',date_default_timezone_get(),'now','m');
-               if(! $y)
+               if (! $y) {
                        $y = intval($thisyear);
-               if(! $m)
+               }
+               if (! $m) {
                        $m = intval($thismonth);
+               }
 
                // Put some limits on dates. The PHP date functions don't seem to do so well before 1900.
                // An upper limit was chosen to keep search engines from exploring links millions of years in the future.
 
-               if($y < 1901)
+               if ($y < 1901) {
                        $y = 1900;
-               if($y > 2099)
+               }
+               if ($y > 2099) {
                        $y = 2100;
+               }
 
                $nextyear = $y;
                $nextmonth = $m + 1;
@@ -336,8 +346,9 @@ function events_content(&$a) {
                        $r = sort_by_date($r);
                        foreach($r as $rr) {
                                $j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j'));
-                               if(! x($links,$j))
-                                       $links[$j] = $a->get_baseurl() . '/' . $a->cmd . '#link-' . $j;
+                               if (! x($links,$j)) {
+                                       $links[$j] = App::get_baseurl() . '/' . $a->cmd . '#link-' . $j;
+                               }
                        }
                }
 
@@ -375,13 +386,13 @@ function events_content(&$a) {
                }
 
                $o = replace_macros($tpl, array(
-                       '$baseurl'      => $a->get_baseurl(),
+                       '$baseurl'      => App::get_baseurl(),
                        '$tabs'         => $tabs,
                        '$title'        => t('Events'),
                        '$view'         => t('View'),
-                       '$new_event'    => array($a->get_baseurl().'/events/new',t('Create New Event'),'',''),
-                       '$previus'      => array($a->get_baseurl()."/events/$prevyear/$prevmonth",t('Previous'),'',''),
-                       '$next'         => array($a->get_baseurl()."/events/$nextyear/$nextmonth",t('Next'),'',''),
+                       '$new_event'    => array(App::get_baseurl().'/events/new',t('Create New Event'),'',''),
+                       '$previus'      => array(App::get_baseurl()."/events/$prevyear/$prevmonth",t('Previous'),'',''),
+                       '$next'         => array(App::get_baseurl()."/events/$nextyear/$nextmonth",t('Next'),'',''),
                        '$calendar'     => cal($y,$m,$links, ' eventcal'),
 
                        '$events'       => $events,
@@ -475,7 +486,7 @@ function events_content(&$a) {
                $tpl = get_markup_template('event_form.tpl');
 
                $o .= replace_macros($tpl,array(
-                       '$post' => $a->get_baseurl() . '/events',
+                       '$post' => App::get_baseurl() . '/events',
                        '$eid' => $eid,
                        '$cid' => $cid,
                        '$uri' => $uri,
index 11ac2d82531bf76c5ba3969ac82b3a8bc5514f23..8c54a47ba2ae2cd073d359bac294950ac52fd57a 100644 (file)
@@ -10,7 +10,7 @@ require_once('include/Photo.php');
 /**
  * @param App $a
  */
-function fbrowser_content($a){
+function fbrowser_content(App &$a){
 
        if (!local_user())
                killme();
@@ -83,9 +83,9 @@ function fbrowser_content($a){
                                        $scale = $rr['loq'];
 
                                return array(
-                                       $a->get_baseurl() . '/photos/' . $a->user['nickname'] . '/image/' . $rr['resource-id'],
+                                       App::get_baseurl() . '/photos/' . $a->user['nickname'] . '/image/' . $rr['resource-id'],
                                        $filename_e,
-                                       $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $scale . '.'. $ext
+                                       App::get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $scale . '.'. $ext
                                );
                        }
                        $files = array_map("_map_files1", $r);
@@ -94,7 +94,7 @@ function fbrowser_content($a){
 
                        $o =  replace_macros($tpl, array(
                                '$type' => 'image',
-                               '$baseurl' => $a->get_baseurl(),
+                               '$baseurl' => App::get_baseurl(),
                                '$path' => $path,
                                '$folders' => $albums,
                                '$files' =>$files,
@@ -122,7 +122,7 @@ function fbrowser_content($a){
                                                $filename_e = $rr['filename'];
                                        }
 
-                                       return array( $a->get_baseurl() . '/attach/' . $rr['id'], $filename_e, $a->get_baseurl() . '/images/icons/16/' . $filetype . '.png');
+                                       return array( App::get_baseurl() . '/attach/' . $rr['id'], $filename_e, App::get_baseurl() . '/images/icons/16/' . $filetype . '.png');
                                }
                                $files = array_map("_map_files2", $files);
 
@@ -130,7 +130,7 @@ function fbrowser_content($a){
                                $tpl = get_markup_template($template_file);
                                $o = replace_macros($tpl, array(
                                        '$type' => 'file',
-                                       '$baseurl' => $a->get_baseurl(),
+                                       '$baseurl' => App::get_baseurl(),
                                        '$path' => array( array( "", t("Files")) ),
                                        '$folders' => false,
                                        '$files' =>$files,
index 04bdf518804a84ee49b6da109391b3076feceda4..bf27ffb6a6d7bb5218b0e524f01886e53d5c7f15 100644 (file)
@@ -8,7 +8,7 @@ require_once("include/xml.php");
 
 /// @TODO You always make it like this: function foo(&$a)
 /// @TODO This means that the value of $a can be changed in anything, remove & and use App as type-hint
-function fetch_init(&$a){
+function fetch_init(App &$a){
 
        if (($a->argc != 3) OR (!in_array($a->argv[1], array("post", "status_message", "reshare")))) {
                header($_SERVER["SERVER_PROTOCOL"].' 404 '.t('Not Found'));
index 4e79f337dcff22502ac15d4c0673872253678312..1b5589380b288e14a81e774558c1cdd6b767e866 100644 (file)
@@ -5,9 +5,9 @@ require_once('include/bbcode.php');
 require_once('include/items.php');
 
 
-function filer_content(&$a) {
+function filer_content(App &$a) {
 
-       if(! local_user()) {
+       if (! local_user()) {
                killme();
        }
 
index c266082c8ffe2e76a3fbe866df080e3a3159401d..f34421ba528440a8358d9757cd1bb6ec050bf627 100644 (file)
@@ -1,8 +1,8 @@
 <?php
 
-function filerm_content(&$a) {
+function filerm_content(App &$a) {
 
-       if(! local_user()) {
+       if (! local_user()) {
                killme();
        }
 
@@ -21,7 +21,7 @@ function filerm_content(&$a) {
                file_tag_unsave_file(local_user(),$item_id,$term, $category);
 
        if(x($_SESSION,'return_url'))
-               goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
+               goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
 
        killme();
 }
index 1f56caea5094451ecf1add9ec80d10b0373b9110..f318dc202c04c9101b72cb9afe9b97352f6cbe3b 100644 (file)
@@ -5,9 +5,9 @@ require_once('include/follow.php');
 require_once('include/Contact.php');
 require_once('include/contact_selectors.php');
 
-function follow_content(&$a) {
+function follow_content(App &$a) {
 
-       if(! local_user()) {
+       if (! local_user()) {
                notice( t('Permission denied.') . EOL);
                goaway($_SESSION['return_url']);
                // NOTREACHED
@@ -63,7 +63,7 @@ function follow_content(&$a) {
                $request = $ret["request"];
                $tpl = get_markup_template('dfrn_request.tpl');
        } else {
-               $request = $a->get_baseurl()."/follow";
+               $request = App::get_baseurl()."/follow";
                $tpl = get_markup_template('auto_request.tpl');
        }
 
@@ -149,9 +149,9 @@ function follow_content(&$a) {
        return $o;
 }
 
-function follow_post(&$a) {
+function follow_post(App &$a) {
 
-       if(! local_user()) {
+       if (! local_user()) {
                notice( t('Permission denied.') . EOL);
                goaway($_SESSION['return_url']);
                // NOTREACHED
@@ -175,12 +175,12 @@ function follow_post(&$a) {
                        notice($result['message']);
                goaway($return_url);
        } elseif ($result['cid'])
-               goaway($a->get_baseurl().'/contacts/'.$result['cid']);
+               goaway(App::get_baseurl().'/contacts/'.$result['cid']);
 
        info( t('Contact added').EOL);
 
        if(strstr($return_url,'contacts'))
-               goaway($a->get_baseurl().'/contacts/'.$contact_id);
+               goaway(App::get_baseurl().'/contacts/'.$contact_id);
 
        goaway($return_url);
        // NOTREACHED
index fb25f40e451cce134059c9e6e60a89f6cbdcaa6f..d79c89a6b24ec9ddb867c7f7cf73434b913ceeb1 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-function friendica_init(&$a) {
+function friendica_init(App &$a) {
        if ($a->argv[1]=="json"){
                $register_policy = Array('REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN');
 
@@ -15,7 +15,7 @@ function friendica_init(&$a) {
                        $r = q("SELECT username, nickname FROM user WHERE email='%s' $sql_extra", dbesc($adminlist[0]));
                        $admin = array(
                                'name' => $r[0]['username'],
-                               'profile'=> $a->get_baseurl().'/profile/'.$r[0]['nickname'],
+                               'profile'=> App::get_baseurl().'/profile/'.$r[0]['nickname'],
                        );
                } else {
                        $admin = false;
@@ -49,7 +49,7 @@ function friendica_init(&$a) {
                        'site_name' => $a->config['sitename'],
                        'platform' => FRIENDICA_PLATFORM,
                        'info' => ((x($a->config,'info')) ? $a->config['info'] : ''),
-                       'no_scrape_url' => $a->get_baseurl().'/noscrape'
+                       'no_scrape_url' => App::get_baseurl().'/noscrape'
                );
 
                echo json_encode($data);
@@ -59,7 +59,7 @@ function friendica_init(&$a) {
 
 
 
-function friendica_content(&$a) {
+function friendica_content(App &$a) {
 
        $o = '';
        $o .= '<h3>Friendica</h3>';
index 1d56f4573625f175e1e4f9f24adb93bda97c6eb6..fcbadcc9b7f06a5febca3ee9167608f429f37086 100644 (file)
@@ -1,14 +1,15 @@
 <?php
 
 
-function fsuggest_post(&$a) {
+function fsuggest_post(App &$a) {
 
-       if(! local_user()) {
+       if (! local_user()) {
                return;
        }
 
-       if($a->argc != 2)
+       if ($a->argc != 2) {
                return;
+       }
 
        $contact_id = intval($a->argv[1]);
 
@@ -16,7 +17,7 @@ function fsuggest_post(&$a) {
                intval($contact_id),
                intval(local_user())
        );
-       if(! dbm::is_result($r)) {
+       if (! dbm::is_result($r)) {
                notice( t('Contact not found.') . EOL);
                return;
        }
@@ -70,11 +71,11 @@ function fsuggest_post(&$a) {
 
 
 
-function fsuggest_content(&$a) {
+function fsuggest_content(App &$a) {
 
        require_once('include/acl_selectors.php');
 
-       if(! local_user()) {
+       if (! local_user()) {
                notice( t('Permission denied.') . EOL);
                return;
        }
@@ -88,7 +89,7 @@ function fsuggest_content(&$a) {
                intval($contact_id),
                intval(local_user())
        );
-       if(! dbm::is_result($r)) {
+       if (! dbm::is_result($r)) {
                notice( t('Contact not found.') . EOL);
                return;
        }
index db92ed7de6fb19f1102d6ad4594e6c7c8581d7ba..fc5c48181759f5bfa2ae5241585083ac0349fe4a 100644 (file)
@@ -4,7 +4,7 @@ function validate_members(&$item) {
        $item = intval($item);
 }
 
-function group_init(&$a) {
+function group_init(App &$a) {
        if(local_user()) {
                require_once('include/group.php');
                $a->page['aside'] = group_side('contacts','group','extended',(($a->argc > 1) ? intval($a->argv[1]) : 0));
@@ -13,9 +13,9 @@ function group_init(&$a) {
 
 
 
-function group_post(&$a) {
+function group_post(App &$a) {
 
-       if(! local_user()) {
+       if (! local_user()) {
                notice( t('Permission denied.') . EOL);
                return;
        }
@@ -28,36 +28,41 @@ function group_post(&$a) {
                if($r) {
                        info( t('Group created.') . EOL );
                        $r = group_byname(local_user(),$name);
-                       if($r)
-                               goaway($a->get_baseurl() . '/group/' . $r);
+                       if ($r) {
+                               goaway(App::get_baseurl() . '/group/' . $r);
+                       }
                }
-               else
+               else {
                        notice( t('Could not create group.') . EOL );
-               goaway($a->get_baseurl() . '/group');
+               }
+               goaway(App::get_baseurl() . '/group');
                return; // NOTREACHED
        }
-       if(($a->argc == 2) && (intval($a->argv[1]))) {
+
+       if (($a->argc == 2) && (intval($a->argv[1]))) {
                check_form_security_token_redirectOnErr('/group', 'group_edit');
 
                $r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1",
                        intval($a->argv[1]),
                        intval(local_user())
                );
-               if(! dbm::is_result($r)) {
+               if (! dbm::is_result($r)) {
                        notice( t('Group not found.') . EOL );
-                       goaway($a->get_baseurl() . '/contacts');
+                       goaway(App::get_baseurl() . '/contacts');
                        return; // NOTREACHED
                }
                $group = $r[0];
                $groupname = notags(trim($_POST['groupname']));
-               if((strlen($groupname))  && ($groupname != $group['name'])) {
+               if ((strlen($groupname))  && ($groupname != $group['name'])) {
                        $r = q("UPDATE `group` SET `name` = '%s' WHERE `uid` = %d AND `id` = %d",
                                dbesc($groupname),
                                intval(local_user()),
                                intval($group['id'])
                        );
-                       if($r)
+
+                       if ($r) {
                                info( t('Group name changed.') . EOL );
+                       }
                }
 
                $a->page['aside'] = group_side();
@@ -65,10 +70,10 @@ function group_post(&$a) {
        return;
 }
 
-function group_content(&$a) {
+function group_content(App &$a) {
        $change = false;
 
-       if(! local_user()) {
+       if (! local_user()) {
                notice( t('Permission denied') . EOL);
                return;
        }
@@ -99,26 +104,32 @@ function group_content(&$a) {
 
        }
 
-       if(($a->argc == 3) && ($a->argv[1] === 'drop')) {
+       if (($a->argc == 3) && ($a->argv[1] === 'drop')) {
                check_form_security_token_redirectOnErr('/group', 'group_drop', 't');
 
-               if(intval($a->argv[2])) {
+               if (intval($a->argv[2])) {
                        $r = q("SELECT `name` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1",
                                intval($a->argv[2]),
                                intval(local_user())
                        );
-                       if (dbm::is_result($r))
+
+                       $result = null;
+
+                       if (dbm::is_result($r)) {
                                $result = group_rmv(local_user(),$r[0]['name']);
-                       if($result)
+                       }
+
+                       if ($result) {
                                info( t('Group removed.') . EOL);
-                       else
+                       } else {
                                notice( t('Unable to remove group.') . EOL);
+                       }
                }
-               goaway($a->get_baseurl() . '/group');
+               goaway(App::get_baseurl() . '/group');
                // NOTREACHED
        }
 
-       if(($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) {
+       if (($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) {
                check_form_security_token_ForbiddenOnErr('group_member_change', 't');
 
                $r = q("SELECT `id` FROM `contact` WHERE `id` = %d AND `uid` = %d and `self` = 0 and `blocked` = 0 AND `pending` = 0 LIMIT 1",
@@ -129,16 +140,16 @@ function group_content(&$a) {
                        $change = intval($a->argv[2]);
        }
 
-       if(($a->argc > 1) && (intval($a->argv[1]))) {
+       if (($a->argc > 1) && (intval($a->argv[1]))) {
 
                require_once('include/acl_selectors.php');
                $r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d AND `deleted` = 0 LIMIT 1",
                        intval($a->argv[1]),
                        intval(local_user())
                );
-               if(! dbm::is_result($r)) {
+               if (! dbm::is_result($r)) {
                        notice( t('Group not found.') . EOL );
-                       goaway($a->get_baseurl() . '/contacts');
+                       goaway(App::get_baseurl() . '/contacts');
                }
                $group = $r[0];
                $members = group_get_members($group['id']);
index 6d2d9e2ebfc38f03761ec6b0595787db981184f9..1d51ac80ee6e04b67535869076c2a6fcc2546d86 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-function hcard_init(&$a) {
+function hcard_init(App &$a) {
 
        $blocked = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false);
 
@@ -38,14 +38,15 @@ function hcard_init(&$a) {
        }
 
        $a->page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . (($a->profile['net-publish']) ? 'true' : 'false') . '" />' . "\r\n" ;
-       $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $a->get_baseurl() . '/dfrn_poll/' . $which .'" />' . "\r\n" ;
+       $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . App::get_baseurl() . '/dfrn_poll/' . $which .'" />' . "\r\n" ;
        $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . (($a->path) ? '/' . $a->path : ''));
-       $a->page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . $a->get_baseurl() . '/xrd/?uri=' . $uri . '" />' . "\r\n";
-       header('Link: <' . $a->get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
-       
+       $a->page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . App::get_baseurl() . '/xrd/?uri=' . $uri . '" />' . "\r\n";
+       header('Link: <' . App::get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
+
        $dfrn_pages = array('request', 'confirm', 'notify', 'poll');
-       foreach($dfrn_pages as $dfrn)
-               $a->page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"".$a->get_baseurl()."/dfrn_{$dfrn}/{$which}\" />\r\n";
+       foreach($dfrn_pages as $dfrn) {
+               $a->page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"".App::get_baseurl()."/dfrn_{$dfrn}/{$which}\" />\r\n";
+       }
 
 }
 
index 72225692793d5206d412d9e2a671f63ded4ab762..c2693dedba57103e318f59d50cbaf135e28c99ef 100644 (file)
@@ -18,7 +18,7 @@ if (!function_exists('load_doc_file')) {
 
 }
 
-function help_content(&$a) {
+function help_content(App &$a) {
 
        nav_set_selected('help');
 
@@ -77,7 +77,7 @@ function help_content(&$a) {
                                        if ($level>$lastlevel) $toc.="<ul>";
                                        $idnum[$level]++;
                                        $id = implode("_", array_slice($idnum,1,$level));
-                                       $href = $a->get_baseurl()."/help/{$filename}#{$id}";
+                                       $href = App::get_baseurl()."/help/{$filename}#{$id}";
                                        $toc .= "<li><a href='{$href}'>".strip_tags($line)."</a></li>";
                                        $line = "<a name='{$id}'></a>".$line;
                                        $lastlevel = $level;
index cdf4b371588900a95938fecfb0dfd306ad3718a1..8bee1aef00abe2413e601d35547a431a6259c694 100644 (file)
@@ -1,38 +1,45 @@
 <?php
 
 if(! function_exists('home_init')) {
-function home_init(&$a) {
+function home_init(App &$a) {
 
        $ret = array();
        call_hooks('home_init',$ret);
 
-       if(local_user() && ($a->user['nickname']))
-               goaway($a->get_baseurl()."/network");
-               //goaway($a->get_baseurl()."/profile/".$a->user['nickname']);
+       if (local_user() && ($a->user['nickname'])) {
+               goaway(App::get_baseurl()."/network");
+       }
 
-       if(strlen(get_config('system','singleuser')))
-               goaway($a->get_baseurl()."/profile/" . get_config('system','singleuser'));
+       if (strlen(get_config('system','singleuser'))) {
+               goaway(App::get_baseurl()."/profile/" . get_config('system','singleuser'));
+       }
 
 }}
 
 
 if(! function_exists('home_content')) {
-function home_content(&$a) {
+function home_content(App &$a) {
 
        $o = '';
 
-       if(x($_SESSION,'theme'))
+       if (x($_SESSION,'theme')) {
                unset($_SESSION['theme']);
-       if(x($_SESSION,'mobile-theme'))
+       }
+       if (x($_SESSION,'mobile-theme')) {
                unset($_SESSION['mobile-theme']);
+       }
 
-       if(file_exists('home.html')){
-               if(file_exists('home.css')){
-                         $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="'.$a->get_baseurl().'/home.css'.'" media="all" />';}
+       /// @TODO No absolute path used, maybe risky (security)
+       if (file_exists('home.html')) {
+               if (file_exists('home.css')) {
+                       $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="'.App::get_baseurl().'/home.css'.'" media="all" />';
+               }
 
-               $o .= file_get_contents('home.html');}
+               $o .= file_get_contents('home.html');}
 
-       else    $o .= '<h1>'.((x($a->config,'sitename')) ? sprintf(t("Welcome to %s"), $a->config['sitename']) : "").'</h1>';
+       else {
+               $o .= '<h1>'.((x($a->config,'sitename')) ? sprintf(t("Welcome to %s"), $a->config['sitename']) : "").'</h1>';
+       }
 
 
        $o .= login(($a->config['register_policy'] == REGISTER_CLOSED) ? 0 : 1);
index 647073b056e3774b1431ab98208ac5c486283275..d41d8448050b7befb8e670f2a2302b14f46edaae 100644 (file)
@@ -2,7 +2,7 @@
 
 require_once('include/crypto.php');
 
-function hostxrd_init(&$a) {
+function hostxrd_init(App &$a) {
        header('Access-Control-Allow-Origin: *');
        header("Content-type: text/xml");
        $pubkey = get_config('system','site_pubkey');
index 65b75b32112df4ab9954fd40664d040d54b4b004..553d5d2232f9116559b4f397c9ab01c112793599 100644 (file)
@@ -11,7 +11,7 @@
 require_once("include/socgraph.php");
 require_once("include/Contact.php");
 
-function hovercard_init(&$a) {
+function hovercard_init(App &$a) {
        // Just for testing purposes
        $_GET["mode"] = "minimal";
 }
index ba55c55e368925648bad537fec37fe8ede477a8e..99b3a3ddcca3c486420d860336b0eeb5891f8734 100644 (file)
@@ -1,26 +1,31 @@
 <?php
 
 
-function ignored_init(&$a) {
+function ignored_init(App &$a) {
 
        $ignored = 0;
 
-       if(! local_user())
+       if (! local_user()) {
                killme();
-       if($a->argc > 1)
+       }
+       if ($a->argc > 1) {
                $message_id = intval($a->argv[1]);
-       if(! $message_id)
+       }
+       if (! $message_id) {
                killme();
+       }
 
        $r = q("SELECT `ignored` FROM `thread` WHERE `uid` = %d AND `iid` = %d LIMIT 1",
                intval(local_user()),
                intval($message_id)
        );
-       if(! dbm::is_result($r))
+       if (! dbm::is_result($r)) {
                killme();
+       }
 
-       if(! intval($r[0]['ignored']))
+       if (! intval($r[0]['ignored'])) {
                $ignored = 1;
+       }
 
        $r = q("UPDATE `thread` SET `ignored` = %d WHERE `uid` = %d and `iid` = %d",
                intval($ignored),
@@ -30,12 +35,12 @@ function ignored_init(&$a) {
 
        // See if we've been passed a return path to redirect to
        $return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
-       if($return_path) {
+       if ($return_path) {
                $rand = '_=' . time();
                if(strpos($return_path, '?')) $rand = "&$rand";
                else $rand = "?$rand";
 
-               goaway($a->get_baseurl() . "/" . $return_path . $rand);
+               goaway(App::get_baseurl() . "/" . $return_path . $rand);
        }
 
        // the json doesn't really matter, it will either be 0 or 1
index b5af1373a443703b7ec35b862cc4cf84fdbc5c66..92b136c338d02bb4177ccf72cca0060421d82c0b 100755 (executable)
@@ -4,7 +4,7 @@ require_once "include/Photo.php";
 $install_wizard_pass=1;
 
 
-function install_init(&$a){
+function install_init(App &$a){
 
        // $baseurl/install/testrwrite to test if rewite in .htaccess is working
        if ($a->argc==2 && $a->argv[1]=="testrewrite") {
@@ -15,7 +15,7 @@ function install_init(&$a){
        // We overwrite current theme css, because during install we could not have a working mod_rewrite
        // so we could not have a css at all. Here we set a static css file for the install procedure pages
        $a->config['system']['theme'] = "../install";
-       $a->theme['stylesheet'] = $a->get_baseurl()."/view/install/style.css";
+       $a->theme['stylesheet'] = App::get_baseurl()."/view/install/style.css";
        
        
        
@@ -25,7 +25,7 @@ function install_init(&$a){
 
 }
 
-function install_post(&$a) {
+function install_post(App &$a) {
        global $install_wizard_pass, $db;
 
        switch($install_wizard_pass) {
@@ -131,7 +131,7 @@ function get_db_errno() {
                return mysql_errno();
 }
 
-function install_content(&$a) {
+function install_content(App &$a) {
 
        global $install_wizard_pass, $db;
        $o = '';
@@ -231,7 +231,7 @@ function install_content(&$a) {
                                '$next' => t('Next'),
                                '$reload' => t('Check again'),
                                '$phpath' => $phpath,
-                               '$baseurl' => $a->get_baseurl(),
+                               '$baseurl' => App::get_baseurl(),
                        ));
                        return $o;
                }; break;
@@ -265,7 +265,7 @@ function install_content(&$a) {
 
                                '$lbl_10' => t('Please select a default timezone for your website'),
 
-                               '$baseurl' => $a->get_baseurl(),
+                               '$baseurl' => App::get_baseurl(),
 
                                '$phpath' => $phpath,
 
@@ -305,7 +305,7 @@ function install_content(&$a) {
 
                                '$timezone' => field_timezone('timezone', t('Please select a default timezone for your website'), $timezone, ''),
                                '$language' => array('language', t('System Language:'), 'en', t('Set the default language for your Friendica installation interface and to send emails.'), $lang_choices),
-                               '$baseurl' => $a->get_baseurl(),
+                               '$baseurl' => App::get_baseurl(),
 
 
 
@@ -518,14 +518,13 @@ function check_smarty3(&$checks) {
 }
 
 function check_htaccess(&$checks) {
-       $a = get_app();
        $status = true;
        $help = "";
        if (function_exists('curl_init')){
-               $test = fetch_url($a->get_baseurl()."/install/testrewrite");
+               $test = fetch_url(App::get_baseurl()."/install/testrewrite");
 
                if ($test!="ok")
-                       $test = fetch_url(normalise_link($a->get_baseurl()."/install/testrewrite"));
+                       $test = fetch_url(normalise_link(App::get_baseurl()."/install/testrewrite"));
 
                if ($test!="ok") {
                        $status = false;
@@ -561,7 +560,7 @@ function check_imagik(&$checks) {
 
 
 
-function manual_config(&$a) {
+function manual_config(App &$a) {
        $data = htmlentities($a->data['txt'],ENT_COMPAT,'UTF-8');
        $o = t('The database configuration file ".htconfig.php" could not be written. Please use the enclosed text to create a configuration file in your web server root.');
        $o .= "<textarea rows=\"24\" cols=\"80\" >$data</textarea>";
@@ -599,8 +598,7 @@ function load_database($db) {
 }
 
 function what_next() {
-       $a = get_app();
-       $baseurl = $a->get_baseurl();
+       $baseurl = App::get_baseurl();
        return
                t('<h1>What next</h1>')
                ."<p>".t('IMPORTANT: You will need to [manually] setup a scheduled task for the poller.')
index ccf876c7c0d1cfb400f40daa52aa2c563a32482b..2db71742f167e20d7016ce0e346efaccaf166279 100644 (file)
@@ -9,9 +9,9 @@
 
 require_once('include/email.php');
 
-function invite_post(&$a) {
+function invite_post(App &$a) {
 
-       if(! local_user()) {
+       if (! local_user()) {
                notice( t('Permission denied.') . EOL);
                return;
        }
@@ -95,9 +95,9 @@ function invite_post(&$a) {
 }
 
 
-function invite_content(&$a) {
+function invite_content(App &$a) {
 
-       if(! local_user()) {
+       if (! local_user()) {
                notice( t('Permission denied.') . EOL);
                return;
        }
@@ -119,7 +119,7 @@ function invite_content(&$a) {
                if($a->config['register_policy'] == REGISTER_CLOSED)
                        $linktxt = sprintf( t('Visit %s for a list of public sites that you can join. Friendica members on other sites can all connect with each other, as well as with members of many other social networks.'), $dirloc . '/siteinfo');
                elseif($a->config['register_policy'] != REGISTER_CLOSED)
-                       $linktxt = sprintf( t('To accept this invitation, please visit and register at %s or any other public Friendica website.'), $a->get_baseurl())
+                       $linktxt = sprintf( t('To accept this invitation, please visit and register at %s or any other public Friendica website.'), App::get_baseurl())
                        . "\r\n" . "\r\n" . sprintf( t('Friendica sites all inter-connect to create a huge privacy-enhanced social web that is owned and controlled by its members. They can also connect with many traditional social networks. See %s for a list of alternate Friendica sites you can join.'),$dirloc . '/siteinfo');
        }
        else {
@@ -135,7 +135,7 @@ function invite_content(&$a) {
                '$default_message' => t('You are cordially invited to join me and other close friends on Friendica - and help us to create a better social web.') . "\r\n" . "\r\n"
                        . $linktxt
                        . "\r\n" . "\r\n" . (($invonly) ? t('You will need to supply this invitation code: $invite_code') . "\r\n" . "\r\n" : '') .t('Once you have registered, please connect with me via my profile page at:') 
-                       . "\r\n" . "\r\n" . $a->get_baseurl() . '/profile/' . $a->user['nickname']
+                       . "\r\n" . "\r\n" . App::get_baseurl() . '/profile/' . $a->user['nickname']
                        . "\r\n" . "\r\n" . t('For more information about the Friendica project and why we feel it is important, please visit http://friendica.com') . "\r\n" . "\r\n"  ,
                '$submit' => t('Submit')
        ));
index 9ef82616c35a42adae5326606a30345c317bf660..864aa18e5161cf2d086c56f23b5d0cd32ed0f1df 100644 (file)
@@ -27,7 +27,7 @@ require_once('include/Scrape.php');
 require_once('include/diaspora.php');
 require_once('include/Contact.php');
 
-function item_post(&$a) {
+function item_post(App &$a) {
 
        if((! local_user()) && (! remote_user()) && (! x($_REQUEST,'commenter')))
                return;
@@ -62,7 +62,7 @@ function item_post(&$a) {
        if(!$preview && x($_REQUEST['post_id_random'])) {
                if(x($_SESSION['post-random']) && $_SESSION['post-random'] == $_REQUEST['post_id_random']) {
                        logger("item post: duplicate post", LOGGER_DEBUG);
-                       item_post_return($a->get_baseurl(), $api_source, $return_path);
+                       item_post_return(App::get_baseurl(), $api_source, $return_path);
                }
                else
                        $_SESSION['post-random'] = $_REQUEST['post_id_random'];
@@ -112,7 +112,7 @@ function item_post(&$a) {
                        }
                }
 
-               if(! dbm::is_result($r)) {
+               if (! dbm::is_result($r)) {
                        notice( t('Unable to locate original post.') . EOL);
                        if(x($_REQUEST,'return'))
                                goaway($return_path);
@@ -224,8 +224,9 @@ function item_post(&$a) {
                        intval($profile_uid),
                        intval($post_id)
                );
-               if(! count($i))
+               if (! dbm::is_result($i)) {
                        killme();
+               }
                $orig_post = $i[0];
        }
 
@@ -449,7 +450,7 @@ function item_post(&$a) {
                        $objecttype = ACTIVITY_OBJ_IMAGE;
 
                        foreach($images as $image) {
-                               if(! stristr($image,$a->get_baseurl() . '/photo/'))
+                               if(! stristr($image,App::get_baseurl() . '/photo/'))
                                        continue;
                                $image_uri = substr($image,strrpos($image,'/') + 1);
                                $image_uri = substr($image_uri,0, strpos($image_uri,'-'));
@@ -464,8 +465,9 @@ function item_post(&$a) {
                                        intval($profile_uid)
                                );
 
-                               if(! dbm::is_result($r))
+                               if (! dbm::is_result($r)) {
                                        continue;
+                               }
 
                                $r = q("UPDATE `photo` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s'
                                        WHERE `resource-id` = '%s' AND `uid` = %d AND `album` = '%s' ",
@@ -640,7 +642,7 @@ function item_post(&$a) {
                        if (dbm::is_result($r)) {
                                if(strlen($attachments))
                                        $attachments .= ',';
-                               $attachments .= '[attach]href="' . $a->get_baseurl() . '/attach/' . $r[0]['id'] . '" length="' . $r[0]['filesize'] . '" type="' . $r[0]['filetype'] . '" title="' . (($r[0]['filename']) ? $r[0]['filename'] : '') . '"[/attach]';
+                               $attachments .= '[attach]href="' . App::get_baseurl() . '/attach/' . $r[0]['id'] . '" length="' . $r[0]['filesize'] . '" type="' . $r[0]['filetype'] . '" title="' . (($r[0]['filename']) ? $r[0]['filename'] : '') . '"[/attach]';
                        }
                        $body = str_replace($match[1],'',$body);
                }
@@ -732,7 +734,7 @@ function item_post(&$a) {
 //     $datarray['prvnets']       = $user['prvnets'];
 
        $datarray['parent-uri'] = ($parent == 0) ? $uri : $parent_item['uri'];
-       $datarray['plink'] = $a->get_baseurl().'/display/'.urlencode($datarray['guid']);
+       $datarray['plink'] = App::get_baseurl().'/display/'.urlencode($datarray['guid']);
        $datarray['last-child'] = 1;
        $datarray['visible'] = 1;
 
@@ -765,8 +767,9 @@ function item_post(&$a) {
                }
 
                $json = array('cancel' => 1);
-               if(x($_REQUEST,'jsreload') && strlen($_REQUEST['jsreload']))
-                       $json['reload'] = $a->get_baseurl() . '/' . $_REQUEST['jsreload'];
+               if (x($_REQUEST,'jsreload') && strlen($_REQUEST['jsreload'])) {
+                       $json['reload'] = App::get_baseurl() . '/' . $_REQUEST['jsreload'];
+               }
 
                echo json_encode($json);
                killme();
@@ -938,7 +941,7 @@ function item_post(&$a) {
                                'to_email'     => $user['email'],
                                'uid'          => $user['uid'],
                                'item'         => $datarray,
-                               'link'          => $a->get_baseurl().'/display/'.urlencode($datarray['guid']),
+                               'link'          => App::get_baseurl().'/display/'.urlencode($datarray['guid']),
                                'source_name'  => $datarray['author-name'],
                                'source_link'  => $datarray['author-link'],
                                'source_photo' => $datarray['author-avatar'],
@@ -970,7 +973,7 @@ function item_post(&$a) {
                                'to_email'     => $user['email'],
                                'uid'          => $user['uid'],
                                'item'         => $datarray,
-                               'link'          => $a->get_baseurl().'/display/'.urlencode($datarray['guid']),
+                               'link'          => App::get_baseurl().'/display/'.urlencode($datarray['guid']),
                                'source_name'  => $datarray['author-name'],
                                'source_link'  => $datarray['author-link'],
                                'source_photo' => $datarray['author-avatar'],
@@ -991,14 +994,14 @@ function item_post(&$a) {
                                        continue;
                                $disclaimer = '<hr />' . sprintf( t('This message was sent to you by %s, a member of the Friendica social network.'),$a->user['username'])
                                        . '<br />';
-                               $disclaimer .= sprintf( t('You may visit them online at %s'), $a->get_baseurl() . '/profile/' . $a->user['nickname']) . EOL;
+                               $disclaimer .= sprintf( t('You may visit them online at %s'), App::get_baseurl() . '/profile/' . $a->user['nickname']) . EOL;
                                $disclaimer .= t('Please contact the sender by replying to this post if you do not wish to receive these messages.') . EOL;
                                if (!$datarray['title']=='') {
                                    $subject = email_header_encode($datarray['title'],'UTF-8');
                                } else {
                                    $subject = email_header_encode('[Friendica]' . ' ' . sprintf( t('%s posted an update.'),$a->user['username']),'UTF-8');
                                }
-                               $link = '<a href="' . $a->get_baseurl() . '/profile/' . $a->user['nickname'] . '"><img src="' . $author['thumb'] . '" alt="' . $a->user['username'] . '" /></a><br /><br />';
+                               $link = '<a href="' . App::get_baseurl() . '/profile/' . $a->user['nickname'] . '"><img src="' . $author['thumb'] . '" alt="' . $a->user['username'] . '" /></a><br /><br />';
                                $html    = prepare_body($datarray);
                                $message = '<html><body>' . $link . $html . $disclaimer . '</body></html>';
                                include_once('include/html2plain.php');
@@ -1038,7 +1041,7 @@ function item_post(&$a) {
 
        logger('post_complete');
 
-       item_post_return($a->get_baseurl(), $api_source, $return_path);
+       item_post_return(App::get_baseurl(), $api_source, $return_path);
        // NOTREACHED
 }
 
@@ -1048,13 +1051,14 @@ function item_post_return($baseurl, $api_source, $return_path) {
        if($api_source)
                return;
 
-       if($return_path) {
+       if ($return_path) {
                goaway($return_path);
        }
 
        $json = array('success' => 1);
-       if(x($_REQUEST,'jsreload') && strlen($_REQUEST['jsreload']))
+       if (x($_REQUEST,'jsreload') && strlen($_REQUEST['jsreload'])) {
                $json['reload'] = $baseurl . '/' . $_REQUEST['jsreload'];
+       }
 
        logger('post_json: ' . print_r($json,true), LOGGER_DEBUG);
 
@@ -1064,17 +1068,18 @@ function item_post_return($baseurl, $api_source, $return_path) {
 
 
 
-function item_content(&$a) {
+function item_content(App &$a) {
 
-       if((! local_user()) && (! remote_user()))
+       if ((! local_user()) && (! remote_user())) {
                return;
+       }
 
        require_once('include/security.php');
 
        $o = '';
-       if(($a->argc == 3) && ($a->argv[1] === 'drop') && intval($a->argv[2])) {
+       if (($a->argc == 3) && ($a->argv[1] === 'drop') && intval($a->argv[2])) {
                $o = drop_item($a->argv[2], !is_ajax());
-               if (is_ajax()){
+               if (is_ajax()) {
                        // ajax return: [<item id>, 0 (no perm) | <owner id>]
                        echo json_encode(array(intval($a->argv[2]), intval($o)));
                        killme();
@@ -1087,6 +1092,7 @@ function item_content(&$a) {
  * This function removes the tag $tag from the text $body and replaces it with
  * the appropiate link.
  *
+ * @param App $a Application instance @TODO is unused in this function's scope (excluding included files)
  * @param unknown_type $body the text to replace the tag in
  * @param string $inform a comma-seperated string containing everybody to inform
  * @param string $str_tags string to add the tag to
@@ -1104,13 +1110,14 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo
        $r = null;
 
        //is it a person tag?
-       if(strpos($tag,'@') === 0) {
+       if (strpos($tag,'@') === 0) {
                //is it already replaced?
-               if(strpos($tag,'[url=')) {
+               if (strpos($tag,'[url=')) {
                        //append tag to str_tags
-                       if(!stristr($str_tags,$tag)) {
-                               if(strlen($str_tags))
+                       if (!stristr($str_tags,$tag)) {
+                               if (strlen($str_tags)) {
                                        $str_tags .= ',';
+                               }
                                $str_tags .= $tag;
                        }
 
index 8d383b9abe4ffad8726a3596eec1f2119dcda0d4..ff1e238ac180b9c104f1b2a85c630fac3842b275 100755 (executable)
@@ -5,7 +5,7 @@ require_once('include/bbcode.php');
 require_once('include/items.php');
 require_once('include/like.php');
 
-function like_content(&$a) {
+function like_content(App &$a) {
        if(! local_user() && ! remote_user()) {
                return false;
        }
@@ -24,7 +24,7 @@ function like_content(&$a) {
        // See if we've been passed a return path to redirect to
        $return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
 
-       like_content_return($a->get_baseurl(), $return_path);
+       like_content_return(App::get_baseurl(), $return_path);
        killme(); // NOTREACHED
 //     return; // NOTREACHED
 }
index d1453bc5272bd3cf2aa5ad8017853c75fdc44a85..00a7c59094ef6313ecf992476fe9be37e4235e20 100644 (file)
@@ -3,7 +3,7 @@
 require_once('include/datetime.php');
 
 
-function localtime_post(&$a) {
+function localtime_post(App &$a) {
 
        $t = $_REQUEST['time'];
        if(! $t)
@@ -16,7 +16,7 @@ function localtime_post(&$a) {
 
 }
 
-function localtime_content(&$a) {
+function localtime_content(App &$a) {
        $t = $_REQUEST['time'];
        if(! $t)
                $t = 'now';
@@ -36,7 +36,7 @@ function localtime_content(&$a) {
                $o .= '<p>' . sprintf( t('Converted localtime: %s'),$a->data['mod-localtime']) . '</p>';
 
 
-       $o .= '<form action ="' . $a->get_baseurl() . '/localtime?f=&time=' . $t . '" method="post" >';
+       $o .= '<form action ="' . App::get_baseurl() . '/localtime?f=&time=' . $t . '" method="post" >';
 
        $o .= '<p>' . t('Please select your timezone:') . '</p>'; 
 
index c806fc317550b4d8e1f82ef4ee40fddf178855f0..746df28cd9478bbbef134dbbe8a797c3c8a0750c 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 
-function lockview_content(&$a) {
+function lockview_content(App &$a) {
   
        $type = (($a->argc > 1) ? $a->argv[1] : 0);
        if (is_numeric($type)) {
@@ -21,8 +21,9 @@ function lockview_content(&$a) {
                dbesc($type),
                intval($item_id)
        );
-       if(! dbm::is_result($r))
+       if (! dbm::is_result($r)) {
                killme();
+       }
        $item = $r[0];
 
        call_hooks('lockview_content', $item);
index d09fc1868f55adb2525f734666abeae77c22be38..db49ba20ac50dda49c9e53b8f5e3de734c9efb50 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-function login_content(&$a) {
+function login_content(App &$a) {
        if(x($_SESSION,'theme'))
                unset($_SESSION['theme']);
        if(x($_SESSION,'mobile-theme'))
index 3dca3a8b81d51d80137b25c86408a3257094d7e8..3174bcd0e0572c1b7b87f3d626f38d767da25f7b 100644 (file)
@@ -4,7 +4,7 @@ require_once('include/email.php');
 require_once('include/enotify.php');
 require_once('include/text.php');
 
-function lostpass_post(&$a) {
+function lostpass_post(App &$a) {
 
        $loginame = notags(trim($_POST['login-name']));
        if(! $loginame)
@@ -15,7 +15,7 @@ function lostpass_post(&$a) {
                dbesc($loginame)
        );
 
-       if(! dbm::is_result($r)) {
+       if (! dbm::is_result($r)) {
                notice( t('No valid account found.') . EOL);
                goaway(z_root());
        }
@@ -36,8 +36,7 @@ function lostpass_post(&$a) {
 
 
        $sitename = $a->config['sitename'];
-       $siteurl = $a->get_baseurl();
-       $resetlink = $a->get_baseurl() . '/lostpass?verify=' . $new_password;
+       $resetlink = App::get_baseurl() . '/lostpass?verify=' . $new_password;
 
        $preamble = deindent(t('
                Dear %1$s,
@@ -64,7 +63,7 @@ function lostpass_post(&$a) {
                Login Name:     %3$s'));
 
        $preamble = sprintf($preamble, $username, $sitename);
-       $body = sprintf($body, $resetlink, $siteurl, $email);
+       $body = sprintf($body, $resetlink, App::get_baseurl(), $email);
 
        notification(array(
                'type' => "SYSTEM_EMAIL",
@@ -78,7 +77,7 @@ function lostpass_post(&$a) {
 }
 
 
-function lostpass_content(&$a) {
+function lostpass_content(App &$a) {
 
 
        if(x($_GET,'verify')) {
@@ -88,7 +87,7 @@ function lostpass_content(&$a) {
                $r = q("SELECT * FROM `user` WHERE `pwdreset` = '%s' LIMIT 1",
                        dbesc($hash)
                );
-               if(! dbm::is_result($r)) {
+               if (! dbm::is_result($r)) {
                        $o =  t("Request could not be verified. \x28You may have previously submitted it.\x29 Password reset failed.");
                        return $o;
                }
@@ -110,17 +109,16 @@ function lostpass_content(&$a) {
                                '$lbl2' => t('Your password has been reset as requested.'),
                                '$lbl3' => t('Your new password is'),
                                '$lbl4' => t('Save or copy your new password - and then'),
-                               '$lbl5' => '<a href="' . $a->get_baseurl() . '">' . t('click here to login') . '</a>.',
+                               '$lbl5' => '<a href="' . App::get_baseurl() . '">' . t('click here to login') . '</a>.',
                                '$lbl6' => t('Your password may be changed from the <em>Settings</em> page after successful login.'),
                                '$newpass' => $new_password,
-                               '$baseurl' => $a->get_baseurl()
+                               '$baseurl' => App::get_baseurl()
 
                        ));
                                info("Your password has been reset." . EOL);
 
 
                        $sitename = $a->config['sitename'];
-                       $siteurl = $a->get_baseurl();
                        // $username, $email, $new_password
                        $preamble = deindent(t('
                                Dear %1$s,
@@ -139,7 +137,7 @@ function lostpass_content(&$a) {
                        '));
 
                        $preamble = sprintf($preamble, $username);
-                       $body = sprintf($body, $siteurl, $email, $new_password);
+                       $body = sprintf($body, App::get_baseurl(), $email, $new_password);
 
                        notification(array(
                                'type' => "SYSTEM_EMAIL",
index 3d21ce40b759d6b28e7b51e8396daf9bcc91aee6..ce432f9307b4ba26c4c51fb9ab32f33a3b9e0417 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-function maintenance_content(&$a) {
+function maintenance_content(App &$a) {
        header('HTTP/1.1 503 Service Temporarily Unavailable');
        header('Status: 503 Service Temporarily Unavailable');
        header('Retry-After: 600');
index 66891db720a540fbe659644b4a25a7d0d85b23be..835a7fbcb7b781c0ad988692d3a2a702494417c8 100644 (file)
@@ -3,10 +3,11 @@
 require_once("include/text.php");
 
 
-function manage_post(&$a) {
+function manage_post(App &$a) {
 
-       if(! local_user())
+       if (! local_user()) {
                return;
+       }
 
        $uid = local_user();
        $orig_record = $a->user;
@@ -56,8 +57,9 @@ function manage_post(&$a) {
                );
        }
 
-       if(! dbm::is_result($r))
+       if (! dbm::is_result($r)) {
                return;
+       }
 
        unset($_SESSION['authenticated']);
        unset($_SESSION['uid']);
@@ -84,15 +86,15 @@ function manage_post(&$a) {
        $ret = array();
        call_hooks('home_init',$ret);
 
-       goaway( $a->get_baseurl() . "/profile/" . $a->user['nickname'] );
+       goaway( App::get_baseurl() . "/profile/" . $a->user['nickname'] );
        // NOTREACHED
 }
 
 
 
-function manage_content(&$a) {
+function manage_content(App &$a) {
 
-       if(! local_user()) {
+       if (! local_user()) {
                notice( t('Permission denied.') . EOL);
                return;
        }
index f7fe325b3868937786e2b2cc9fd9728c849babd4..f7274e436666e727f0cd57c3d2c3c0964dfbf2a8 100644 (file)
@@ -13,22 +13,24 @@ require_once('mod/proxy.php');
  * @param App &$a
  * @return void|string
  */
-function match_content(&$a) {
+function match_content(App &$a) {
 
        $o = '';
-       if(! local_user())
+       if (! local_user()) {
                return;
+       }
 
        $a->page['aside'] .= findpeople_widget();
        $a->page['aside'] .= follow_widget();
 
-       $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd;
+       $_SESSION['return_url'] = App::get_baseurl() . '/' . $a->cmd;
 
        $r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
                intval(local_user())
        );
-       if(! dbm::is_result($r))
+       if (! dbm::is_result($r)) {
                return;
+       }
        if(! $r[0]['pub_keywords'] && (! $r[0]['prv_keywords'])) {
                notice( t('No keywords to match. Please add keywords to your default profile.') . EOL);
                return;
@@ -45,7 +47,7 @@ function match_content(&$a) {
                if(strlen(get_config('system','directory')))
                        $x = post_url(get_server().'/msearch', $params);
                else
-                       $x = post_url($a->get_baseurl() . '/msearch', $params);
+                       $x = post_url(App::get_baseurl() . '/msearch', $params);
 
                $j = json_decode($x);
 
@@ -66,7 +68,7 @@ function match_content(&$a) {
 
                                if (!count($match)) {
                                        $jj->photo = str_replace("http:///photo/", get_server()."/photo/", $jj->photo);
-                                       $connlnk = $a->get_baseurl() . '/follow/?url=' . $jj->url;
+                                       $connlnk = App::get_baseurl() . '/follow/?url=' . $jj->url;
                                        $photo_menu = array(
                                                'profile' => array(t("View Profile"), zrl($jj->url)),
                                                'follow' => array(t("Connect/Follow"), $connlnk)
index 9bd5b0d72278bf0367cf79f4c3c7c59454924c17..ef62a7898177d1b673e76b3bb2e1c8668d14f607 100644 (file)
@@ -4,7 +4,7 @@ require_once('include/acl_selectors.php');
 require_once('include/message.php');
 require_once('include/Smilies.php');
 
-function message_init(&$a) {
+function message_init(App &$a) {
 
        $tabs = '';
 
@@ -24,25 +24,25 @@ function message_init(&$a) {
                '$tabs'=>$tabs,
                '$new'=>$new,
        ));
-       $base = $a->get_baseurl();
+       $base = App::get_baseurl();
 
        $head_tpl = get_markup_template('message-head.tpl');
        $a->page['htmlhead'] .= replace_macros($head_tpl,array(
-               '$baseurl' => $a->get_baseurl(true),
+               '$baseurl' => App::get_baseurl(true),
                '$base' => $base
        ));
 
        $end_tpl = get_markup_template('message-end.tpl');
        $a->page['end'] .= replace_macros($end_tpl,array(
-               '$baseurl' => $a->get_baseurl(true),
+               '$baseurl' => App::get_baseurl(true),
                '$base' => $base
        ));
 
 }
 
-function message_post(&$a) {
+function message_post(App &$a) {
 
-       if(! local_user()) {
+       if (! local_user()) {
                notice( t('Permission denied.') . EOL);
                return;
        }
@@ -173,17 +173,17 @@ function item_redir_and_replace_images($body, $images, $cid) {
 
 
 
-function message_content(&$a) {
+function message_content(App &$a) {
 
        $o = '';
        nav_set_selected('messages');
 
-       if(! local_user()) {
+       if (! local_user()) {
                notice( t('Permission denied.') . EOL);
                return;
        }
 
-       $myprofile = $a->get_baseurl().'/profile/' . $a->user['nickname'];
+       $myprofile = App::get_baseurl().'/profile/' . $a->user['nickname'];
 
        $tpl = get_markup_template('mail_head.tpl');
        $header = replace_macros($tpl, array(
@@ -234,7 +234,7 @@ function message_content(&$a) {
                        if($r) {
                                info( t('Message deleted.') . EOL );
                        }
-                       //goaway($a->get_baseurl(true) . '/message' );
+                       //goaway(App::get_baseurl(true) . '/message' );
                        goaway($_SESSION['return_url']);
                }
                else {
@@ -265,7 +265,7 @@ function message_content(&$a) {
                                if($r)
                                        info( t('Conversation removed.') . EOL );
                        }
-                       //goaway($a->get_baseurl(true) . '/message' );
+                       //goaway(App::get_baseurl(true) . '/message' );
                        goaway($_SESSION['return_url']);
                }
 
@@ -285,7 +285,7 @@ function message_content(&$a) {
 
                $tpl = get_markup_template('msg-header.tpl');
                $a->page['htmlhead'] .= replace_macros($tpl, array(
-                       '$baseurl' => $a->get_baseurl(true),
+                       '$baseurl' => App::get_baseurl(true),
                        '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
                        '$nickname' => $a->user['nickname'],
                        '$linkurl' => t('Please enter a link URL:')
@@ -293,7 +293,7 @@ function message_content(&$a) {
 
                $tpl = get_markup_template('msg-end.tpl');
                $a->page['end'] .= replace_macros($tpl, array(
-                       '$baseurl' => $a->get_baseurl(true),
+                       '$baseurl' => App::get_baseurl(true),
                        '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
                        '$nickname' => $a->user['nickname'],
                        '$linkurl' => t('Please enter a link URL:')
@@ -364,7 +364,7 @@ function message_content(&$a) {
 
        $_SESSION['return_url'] = $a->query_string;
 
-       if($a->argc == 1) {
+       if ($a->argc == 1) {
 
                // List messages
 
@@ -381,7 +381,7 @@ function message_content(&$a) {
 
                $r = get_messages(local_user(), $a->pager['start'], $a->pager['itemspage']);
 
-               if(! dbm::is_result($r)) {
+               if (! dbm::is_result($r)) {
                        info( t('No messages.') . EOL);
                        return $o;
                }
@@ -438,7 +438,7 @@ function message_content(&$a) {
 
                $tpl = get_markup_template('msg-header.tpl');
                $a->page['htmlhead'] .= replace_macros($tpl, array(
-                       '$baseurl' => $a->get_baseurl(true),
+                       '$baseurl' => App::get_baseurl(true),
                        '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
                        '$nickname' => $a->user['nickname'],
                        '$linkurl' => t('Please enter a link URL:')
@@ -446,7 +446,7 @@ function message_content(&$a) {
 
                $tpl = get_markup_template('msg-end.tpl');
                $a->page['end'] .= replace_macros($tpl, array(
-                       '$baseurl' => $a->get_baseurl(true),
+                       '$baseurl' => App::get_baseurl(true),
                        '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
                        '$nickname' => $a->user['nickname'],
                        '$linkurl' => t('Please enter a link URL:')
@@ -573,7 +573,7 @@ function render_messages(array $msg, $t) {
        $tpl = get_markup_template($t);
        $rslt = '';
 
-       $myprofile = $a->get_baseurl().'/profile/' . $a->user['nickname'];
+       $myprofile = App::get_baseurl().'/profile/' . $a->user['nickname'];
 
        foreach($msg as $rr) {
 
index d1dabb101b3834aec9d7ef9cbfe5f0d15e5e3920..5fc7012909e30b8a9380dd873cb66738abd2d005 100644 (file)
@@ -2,7 +2,7 @@
 
 require_once('library/asn1.php');
 
-function modexp_init(&$a) {
+function modexp_init(App &$a) {
 
        if($a->argc != 2)
                killme();
@@ -12,8 +12,9 @@ function modexp_init(&$a) {
                        dbesc($nick)
        );
 
-       if(! dbm::is_result($r))
+       if (! dbm::is_result($r)) {
                killme();
+       }
 
        $lines = explode("\n",$r[0]['spubkey']);
        unset($lines[0]);
index c64dd0d9efbe2ae3baa68618d8c0c774115ea9a4..0e603c869a110e5155819b611a42c2bf58f4102c 100644 (file)
@@ -5,10 +5,11 @@ require_once('include/bbcode.php');
 require_once('include/items.php');
 
 
-function mood_init(&$a) {
+function mood_init(App &$a) {
 
-       if(! local_user())
+       if (! local_user()) {
                return;
+       }
 
        $uid = local_user();
        $verb = notags(trim($_GET['verb']));
@@ -91,7 +92,7 @@ function mood_init(&$a) {
        $item_id = item_store($arr);
        if($item_id) {
                q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d",
-                       dbesc($a->get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id),
+                       dbesc(App::get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id),
                        intval($uid),
                        intval($item_id)
                );
@@ -108,9 +109,9 @@ function mood_init(&$a) {
 
 
 
-function mood_content(&$a) {
+function mood_content(App &$a) {
 
-       if(! local_user()) {
+       if (! local_user()) {
                notice( t('Permission denied.') . EOL);
                return;
        }
index 43b200ddf84ecaf7a3abbc16fcaca0056e57a583..4b5205ac0848d937fb9c1d337eeeeac8bcbf1a29 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-function msearch_post(&$a) {
+function msearch_post(App &$a) {
 
        $perpage = (($_POST['n']) ? $_POST['n'] : 80);
        $page = (($_POST['p']) ? intval($_POST['p'] - 1) : 0);
@@ -29,8 +29,8 @@ function msearch_post(&$a) {
                foreach($r as $rr)
                        $results[] = array(
                                'name' => $rr['name'], 
-                               'url' => $a->get_baseurl() . '/profile/' . $rr['nickname'], 
-                               'photo' => $a->get_baseurl() . '/photo/avatar/' . $rr['uid'] . '.jpg',
+                               'url' => App::get_baseurl() . '/profile/' . $rr['nickname'], 
+                               'photo' => App::get_baseurl() . '/photo/avatar/' . $rr['uid'] . '.jpg',
                                'tags' => str_replace(array(',','  '),array(' ',' '),$rr['pub_keywords'])
                        );
        }
index 5db69b171eed52f67fea8f65bd21ccb5df55c3ce..d69c76a843513e810d10db9b31f10d72d14aed9d 100644 (file)
@@ -2,7 +2,7 @@
 
 require_once("include/nav.php");
 
-function navigation_content(&$a) {
+function navigation_content(App &$a) {
 
        $nav_info = nav_info($a);
 
@@ -12,7 +12,7 @@ function navigation_content(&$a) {
 
        $tpl = get_markup_template('navigation.tpl');
        return replace_macros($tpl, array(
-               '$baseurl' => $a->get_baseurl(),
+               '$baseurl' => App::get_baseurl(),
                '$sitelocation' => $nav_info['sitelocation'],
                '$nav' => $nav_info['nav'],
                '$banner' =>  $nav_info['banner'],
index 9cfeda1026b9e8e3f51f8cadaa1a0f4c758e2d82..8b24b3e11b4ef30e2865916ff9bc16ee4ff532b7 100644 (file)
@@ -1,6 +1,6 @@
 <?php
-function network_init(&$a) {
-       if(! local_user()) {
+function network_init(App &$a) {
+       if (! local_user()) {
                notice( t('Permission denied.') . EOL);
                return;
        }
@@ -100,7 +100,7 @@ function network_init(&$a) {
 
                        $redir_url = ($net_queries ? $net_baseurl."?".$net_queries : $net_baseurl);
 
-                       goaway($a->get_baseurl() . $redir_url);
+                       goaway(App::get_baseurl() . $redir_url);
                }
        }
 
@@ -126,7 +126,7 @@ function network_init(&$a) {
                        intval(local_user()),
                        dbesc($search)
                );
-               if(! dbm::is_result($r)) {
+               if (! dbm::is_result($r)) {
                        q("INSERT INTO `search` ( `uid`,`term` ) VALUES ( %d, '%s') ",
                                intval(local_user()),
                                dbesc($search)
@@ -222,7 +222,7 @@ function saved_searches($search) {
  *
  * @return Array ( $no_active, $comment_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active );
  */
-function network_query_get_sel_tab($a) {
+function network_query_get_sel_tab(App &$a) {
        $no_active='';
        $starred_active = '';
        $new_active = '';
@@ -293,7 +293,7 @@ function network_query_get_sel_net() {
        return $network;
 }
 
-function network_query_get_sel_group($a) {
+function network_query_get_sel_group(App &$a) {
        $group = false;
 
        if($a->argc >= 2 && is_numeric($a->argv[1])) {
@@ -308,7 +308,7 @@ function network_content(&$a, $update = 0) {
 
        require_once('include/conversation.php');
 
-       if(! local_user()) {
+       if (! local_user()) {
                $_SESSION['return_url'] = $a->query_string;
                return login(false);
        }
@@ -463,7 +463,7 @@ function network_content(&$a, $update = 0) {
                        intval($group),
                        intval($_SESSION['uid'])
                );
-               if(! dbm::is_result($r)) {
+               if (! dbm::is_result($r)) {
                        if($update)
                                killme();
                        notice( t('No such group') . EOL );
@@ -810,7 +810,7 @@ function network_content(&$a, $update = 0) {
  * @param app $a The global App
  * @return string Html of the networktab
  */
-function network_tabs($a) {
+function network_tabs(App &$a) {
        // item filter tabs
        /// @TODO fix this logic, reduce duplication
        /// $a->page['content'] .= '<div class="tabs-wrapper">';
index aa55c3a098804f7e77e696e07167ecf35c9c7ad1..1ef0985066e1971bdedee1e4a2ba80b02aeb2297 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-function newmember_content(&$a) {
+function newmember_content(App &$a) {
 
 
        $o = '<h1>' . t('Welcome to Friendica') . '</h1>';
index 5c70603468fe0004d28e33e5c71ab7fcf9c326e5..104fecb755ddc21ea1ad118ffaaeecc84b603700 100644 (file)
@@ -7,20 +7,20 @@
 
 require_once("include/plugin.php");
 
-function nodeinfo_wellknown(&$a) {
+function nodeinfo_wellknown(App &$a) {
        if (!get_config("system", "nodeinfo")) {
                http_status_exit(404);
                killme();
        }
        $nodeinfo = array("links" => array(array("rel" => "http://nodeinfo.diaspora.software/ns/schema/1.0",
-                                       "href" => $a->get_baseurl()."/nodeinfo/1.0")));
+                                       "href" => App::get_baseurl()."/nodeinfo/1.0")));
 
        header('Content-type: application/json; charset=utf-8');
        echo json_encode($nodeinfo, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
        exit;
 }
 
-function nodeinfo_init(&$a){
+function nodeinfo_init(App &$a){
        if (!get_config("system", "nodeinfo")) {
                http_status_exit(404);
                killme();
index 0a014c067668daf5c2a40c34b79bec944fae3137..900ca4de095f606a187a5325c4cca4cc635d25cf 100644 (file)
@@ -4,24 +4,26 @@ require_once('include/Contact.php');
 require_once('include/socgraph.php');
 require_once('include/contact_selectors.php');
 
-function nogroup_init(&$a) {
+function nogroup_init(App &$a) {
 
-       if(! local_user())
+       if (! local_user()) {
                return;
+       }
 
        require_once('include/group.php');
        require_once('include/contact_widgets.php');
 
-       if(! x($a->page,'aside'))
+       if (! x($a->page,'aside')) {
                $a->page['aside'] = '';
+       }
 
        $a->page['aside'] .= group_side('contacts','group','extended',0,$contact_id);
 }
 
 
-function nogroup_content(&$a) {
+function nogroup_content(App &$a) {
 
-       if(! local_user()) {
+       if (! local_user()) {
                notice( t('Permission denied.') . EOL);
                return '';
        }
index 537aff878f8e79ab81f7453ce4b27b7ff53410f0..f1370167c5eb2815eccd1fb2c8091c800a257c9f 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-function noscrape_init(&$a) {
+function noscrape_init(App &$a) {
 
        if($a->argc > 1)
                $which = $a->argv[1];
@@ -26,6 +26,7 @@ function noscrape_init(&$a) {
        $keywords = str_replace(array('#',',',' ',',,'),array('',' ',',',','),$keywords);
        $keywords = explode(',', $keywords);
 
+       /// @TODO This query's result is not being used (see below), maybe old-lost code?
        $r = q("SELECT `photo` FROM `contact` WHERE `self` AND `uid` = %d",
                intval($a->profile['uid']));
 
@@ -34,7 +35,7 @@ function noscrape_init(&$a) {
                'addr' => $a->profile['addr'],
                'nick' => $which,
                'key' => $a->profile['pubkey'],
-               'homepage' => $a->get_baseurl()."/profile/{$which}",
+               'homepage' => App::get_baseurl()."/profile/{$which}",
                'comm' => (x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY),
                'photo' => $r[0]["photo"],
                'tags' => $keywords
@@ -59,12 +60,16 @@ function noscrape_init(&$a) {
 
        //These are optional fields.
        $profile_fields = array('pdesc', 'locality', 'region', 'postal-code', 'country-name', 'gender', 'marital', 'about');
-       foreach($profile_fields as $field)
-               if(!empty($a->profile[$field])) $json_info["$field"] = $a->profile[$field];
+       foreach($profile_fields as $field) {
+               if(!empty($a->profile[$field])) {
+                       $json_info["$field"] = $a->profile[$field];
+               }
+       }
 
        $dfrn_pages = array('request', 'confirm', 'notify', 'poll');
-       foreach($dfrn_pages as $dfrn)
-               $json_info["dfrn-{$dfrn}"] = $a->get_baseurl()."/dfrn_{$dfrn}/{$which}";
+       foreach($dfrn_pages as $dfrn) {
+               $json_info["dfrn-{$dfrn}"] = App::get_baseurl()."/dfrn_{$dfrn}/{$which}";
+       }
 
        //Output all the JSON!
        header('Content-type: application/json; charset=utf-8');
index 74ab18a6f95f0aeeb16418b584709163a471c981..b2aa5487af963e60d1b456dbf39ec1b258b20aea 100644 (file)
@@ -1,9 +1,10 @@
 <?php
 
-function notes_init(&$a) {
+function notes_init(App &$a) {
 
-       if(! local_user())
+       if (! local_user()) {
                return;
+       }
 
        $profile = 0;
 
@@ -18,7 +19,7 @@ function notes_init(&$a) {
 
 function notes_content(&$a,$update = false) {
 
-       if(! local_user()) {
+       if (! local_user()) {
                notice( t('Permission denied.') . EOL);
                return;
        }
index 7fdf4493a4f5cf30a801f4c0008df1c8970d2fa9..e338d8752d5485c6d96bd886897579d2570f27c0 100644 (file)
@@ -1,14 +1,14 @@
 <?php
        /* identi.ca -> friendica items permanent-url compatibility */
        
-       function notice_init(&$a){
+       function notice_init(App &$a){
                $id = $a->argv[1];
                $r = q("SELECT user.nickname FROM user LEFT JOIN item ON item.uid=user.uid WHERE item.id=%d",
                                intval($id)
                                );
                if (dbm::is_result($r)){
                        $nick = $r[0]['nickname'];
-                       $url = $a->get_baseurl()."/display/$nick/$id";
+                       $url = App::get_baseurl()."/display/$nick/$id";
                        goaway($url);
                } else {
                        $a->error = 404;
index 3e0bd9cc47d715e79adefe574436f97ff5465238..e4fa08f3e2be4e9840b246ccae929e9a82975540 100644 (file)
@@ -9,9 +9,9 @@ require_once("include/NotificationsManager.php");
 require_once("include/contact_selectors.php");
 require_once("include/network.php");
 
-function notifications_post(&$a) {
+function notifications_post(App &$a) {
 
-       if(! local_user()) {
+       if (! local_user()) {
                goaway(z_root());
        }
 
@@ -65,9 +65,9 @@ function notifications_post(&$a) {
        }
 }
 
-function notifications_content(&$a) {
+function notifications_content(App &$a) {
 
-       if(! local_user()) {
+       if (! local_user()) {
                notice( t('Permission denied.') . EOL);
                return;
        }
index dceb326a4bdd260faa34824d2350edfac52f8ab6..2d34821ded6898feaa9fe8300f72eaa9ae123836 100644 (file)
@@ -2,11 +2,14 @@
 require_once('include/NotificationsManager.php');
 
 
-function notify_init(&$a) {
-       if(! local_user()) return;
+function notify_init(App &$a) {
+       if (! local_user()) {
+               return;
+       }
+
        $nm = new NotificationsManager();
-               
-       if($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) {
+
+       if ($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) {
                $note = $nm->getByID($a->argv[2]);
                if ($note) {
                        $nm->setSeen($note);
@@ -17,17 +20,18 @@ function notify_init(&$a) {
                                $urldata = parse_url($note['link']);
                                $guid = basename($urldata["path"]);
                                $itemdata = get_item_id($guid, local_user());
-                               if ($itemdata["id"] != 0)
-                                       $note['link'] = $a->get_baseurl().'/display/'.$itemdata["nick"].'/'.$itemdata["id"];
+                               if ($itemdata["id"] != 0) {
+                                       $note['link'] = App::get_baseurl().'/display/'.$itemdata["nick"].'/'.$itemdata["id"];
+                               }
                        }
 
                        goaway($note['link']);
                }
 
-               goaway($a->get_baseurl(true));
+               goaway(App::get_baseurl(true));
        }
 
-       if($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all' ) {
+       if ($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all' ) {
                $r = $nm->setAllSeen();
                $j = json_encode(array('result' => ($r) ? 'success' : 'fail'));
                echo $j;
@@ -36,8 +40,10 @@ function notify_init(&$a) {
 
 }
 
-function notify_content(&$a) {
-       if(! local_user()) return login();
+function notify_content(App &$a) {
+       if (! local_user()) {
+               return login();
+       }
 
        $nm = new NotificationsManager();
        
@@ -50,7 +56,7 @@ function notify_content(&$a) {
        if (dbm::is_result($r) > 0) {
                foreach ($r as $it) {
                        $notif_content .= replace_macros($not_tpl,array(
-                               '$item_link' => $a->get_baseurl(true).'/notify/view/'. $it['id'],
+                               '$item_link' => App::get_baseurl(true).'/notify/view/'. $it['id'],
                                '$item_image' => $it['photo'],
                                '$item_text' => strip_tags(bbcode($it['msg'])),
                                '$item_when' => relative_date($it['date'])
index cb478cb8605d7054133a6e9ab371e2dbb9187d9b..1d6e6145cd35cd0c873dec999f59429d2ed59d23 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 require_once("include/oembed.php");
 
-function oembed_content(&$a){
+function oembed_content(App &$a){
        // logger('mod_oembed ' . $a->query_string, LOGGER_ALL);
 
        if ($a->argv[1]=='b2h'){
index bbb436e7021ab3f0ad8088fedfde4772e46b0891..49c5d01f4504fb33e4f6d40186b2f87f0529149b 100644 (file)
@@ -1,12 +1,12 @@
 <?php
 
 
-function oexchange_init(&$a) {
+function oexchange_init(App &$a) {
 
        if(($a->argc > 1) && ($a->argv[1] === 'xrd')) {
                $tpl = get_markup_template('oexchange_xrd.tpl');
 
-               $o = replace_macros($tpl, array('$base' => $a->get_baseurl()));
+               $o = replace_macros($tpl, array('$base' => App::get_baseurl()));
                echo $o;
                killme();
        }
@@ -14,14 +14,14 @@ function oexchange_init(&$a) {
 
 }
 
-function oexchange_content(&$a) {
+function oexchange_content(App &$a) {
 
-       if(! local_user()) {
+       if (! local_user()) {
                $o = login(false);
                return $o;
        }
 
-       if(($a->argc > 1) && $a->argv[1] === 'done') {
+       if (($a->argc > 1) && $a->argv[1] === 'done') {
                info( t('Post successful.') . EOL);
                return;
        }
@@ -35,7 +35,7 @@ function oexchange_content(&$a) {
        $tags = (((x($_REQUEST,'tags')) && strlen($_REQUEST['tags'])) 
                ? '&tags=' . urlencode(notags(trim($_REQUEST['tags']))) : '');
 
-       $s = fetch_url($a->get_baseurl() . '/parse_url?f=&url=' . $url . $title . $description . $tags);
+       $s = fetch_url(App::get_baseurl() . '/parse_url?f=&url=' . $url . $title . $description . $tags);
 
        if(! strlen($s))
                return;
index 60a9c1381b083e5322be743bf4241ac0169887d2..e14b5f82d93f57e4e56c6516712cff5490e6b1cc 100644 (file)
@@ -4,7 +4,7 @@
 require_once('library/openid.php');
 
 
-function openid_content(&$a) {
+function openid_content(App &$a) {
 
        $noid = get_config('system','no_openid');
        if($noid)
@@ -92,7 +92,7 @@ function openid_content(&$a) {
 
                        $args .= '&openid_url=' . notags(trim($authid));
 
-                       goaway($a->get_baseurl() . '/register' . $args);
+                       goaway(App::get_baseurl() . '/register' . $args);
 
                        // NOTREACHED
                }
index ff748d1c5360cbc2a0d28ade8d196a8a7b7fe5df..1a7d4cd30715bff0b23d91ba4bbfcd42158b4ab7 100644 (file)
@@ -1,12 +1,12 @@
 <?php
-    function opensearch_content(&$a) {
+    function opensearch_content(App &$a) {
        
                $tpl = get_markup_template('opensearch.tpl');
        
                header("Content-type: application/opensearchdescription+xml");
        
                $o = replace_macros($tpl, array(
-                       '$baseurl' => $a->get_baseurl(),
+                       '$baseurl' => App::get_baseurl(),
                        '$nodename' => $a->get_hostname(),
                ));
                
index 6cca0bf67942537b75020a43008623e678cb734b..ba17e28b73992b47238fc14ab725a96582172224 100644 (file)
@@ -3,9 +3,9 @@
 require_once('include/Scrape.php');
 require_once('include/follow.php');
 
-function ostatus_subscribe_content(&$a) {
+function ostatus_subscribe_content(App &$a) {
 
-       if(! local_user()) {
+       if (! local_user()) {
                notice( t('Permission denied.') . EOL);
                goaway($_SESSION['return_url']);
                // NOTREACHED
@@ -45,7 +45,7 @@ function ostatus_subscribe_content(&$a) {
        $total = sizeof($friends);
 
        if ($counter >= $total) {
-               $a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL='.$a->get_baseurl().'/settings/connectors">';
+               $a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL='.App::get_baseurl().'/settings/connectors">';
                del_pconfig($uid, "ostatus", "legacy_friends");
                del_pconfig($uid, "ostatus", "legacy_contact");
                $o .= t("Done");
@@ -72,7 +72,7 @@ function ostatus_subscribe_content(&$a) {
 
        $o .= "<p>".t("Keep this window open until done.")."</p>";
 
-       $a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL='.$a->get_baseurl().'/ostatus_subscribe?counter='.$counter.'">';
+       $a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL='.App::get_baseurl().'/ostatus_subscribe?counter='.$counter.'">';
 
        return $o;
 }
index 410e0877377ef9291cbf0ae7b016c6a8204a3ea8..44cf80935e2bd237aa437a55969c82c1f2823c84 100644 (file)
@@ -19,7 +19,7 @@ use \Friendica\ParseUrl;
 
 require_once("include/items.php");
 
-function parse_url_content(&$a) {
+function parse_url_content(App &$a) {
 
        $text = null;
        $str_tags = "";
index a94a3ac2ce57eb97f260689e6cb699b2766ce94f..9744b9f239b246a595f3b722b7e4e7c5dda13c39 100644 (file)
@@ -3,7 +3,7 @@
 require_once('include/security.php');
 require_once('include/Photo.php');
 
-function photo_init(&$a) {
+function photo_init(App &$a) {
        global $_SERVER;
 
        $prvcachecontrol = false;
index 1ef43f423ab3f6105eb63094a114b9af8a8977b8..317d7272b41d689889e7694942e8f748488e5601 100644 (file)
@@ -10,7 +10,7 @@ require_once('include/tags.php');
 require_once('include/threads.php');
 require_once('include/Probe.php');
 
-function photos_init(&$a) {
+function photos_init(App &$a) {
 
        if ($a->argc > 1)
                auto_redir($a, $a->argv[1]);
@@ -112,7 +112,7 @@ function photos_init(&$a) {
 
 
 
-function photos_post(&$a) {
+function photos_post(App &$a) {
 
        logger('mod-photos: photos_post: begin' , LOGGER_DEBUG);
 
@@ -346,7 +346,7 @@ function photos_post(&$a) {
                                dbesc($r[0]['resource-id']),
                                intval($page_owner_uid)
                        );
-                       if (count($i)) {
+                       if (dbm::is_result($i)) {
                                q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d",
                                        dbesc(datetime_convert()),
                                        dbesc(datetime_convert()),
@@ -356,7 +356,7 @@ function photos_post(&$a) {
                                create_tags_from_itemuri($i[0]['uri'], $page_owner_uid);
                                delete_thread_uri($i[0]['uri'], $page_owner_uid);
 
-                               $url = $a->get_baseurl();
+                               $url = App::get_baseurl();
                                $drop_id = intval($i[0]['id']);
 
                                if ($i[0]['visible'])
@@ -496,8 +496,8 @@ function photos_post(&$a) {
                        $arr['visible']       = $visibility;
                        $arr['origin']        = 1;
 
-                       $arr['body']          = '[url=' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $p[0]['resource-id'] . ']'
-                                               . '[img]' . $a->get_baseurl() . '/photo/' . $p[0]['resource-id'] . '-' . $p[0]['scale'] . '.'. $ext . '[/img]'
+                       $arr['body']          = '[url=' . App::get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $p[0]['resource-id'] . ']'
+                                               . '[img]' . App::get_baseurl() . '/photo/' . $p[0]['resource-id'] . '-' . $p[0]['scale'] . '.'. $ext . '[/img]'
                                                . '[/url]';
 
                        $item_id = item_store($arr);
@@ -615,7 +615,7 @@ function photos_post(&$a) {
                                                }
                                        } elseif (strpos($tag,'#') === 0) {
                                                $tagname = substr($tag, 1);
-                                               $str_tags .= '#[url='.$a->get_baseurl()."/search?tag=".$tagname.']'.$tagname.'[/url]';
+                                               $str_tags .= '#[url='.App::get_baseurl()."/search?tag=".$tagname.']'.$tagname.'[/url]';
                                        }
                                }
                        }
@@ -685,8 +685,8 @@ function photos_post(&$a) {
                                        $arr['tag']           = $tagged[4];
                                        $arr['inform']        = $tagged[2];
                                        $arr['origin']        = 1;
-                                       $arr['body']          = sprintf( t('%1$s was tagged in %2$s by %3$s'), '[url=' . $tagged[1] . ']' . $tagged[0] . '[/url]', '[url=' . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . t('a photo') . '[/url]', '[url=' . $owner_record['url'] . ']' . $owner_record['name'] . '[/url]') ;
-                                       $arr['body'] .= "\n\n" . '[url=' . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . '[img]' . $a->get_baseurl() . "/photo/" . $p[0]['resource-id'] . '-' . $best . '.' . $ext . '[/img][/url]' . "\n" ;
+                                       $arr['body']          = sprintf( t('%1$s was tagged in %2$s by %3$s'), '[url=' . $tagged[1] . ']' . $tagged[0] . '[/url]', '[url=' . App::get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . t('a photo') . '[/url]', '[url=' . $owner_record['url'] . ']' . $owner_record['name'] . '[/url]') ;
+                                       $arr['body'] .= "\n\n" . '[url=' . App::get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . '[img]' . App::get_baseurl() . "/photo/" . $p[0]['resource-id'] . '-' . $best . '.' . $ext . '[/img][/url]' . "\n" ;
 
                                        $arr['object'] = '<object><type>' . ACTIVITY_OBJ_PERSON . '</type><title>' . $tagged[0] . '</title><id>' . $tagged[1] . '/' . $tagged[0] . '</id>';
                                        $arr['object'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $tagged[1] . '" />' . "\n");
@@ -695,8 +695,8 @@ function photos_post(&$a) {
                                        $arr['object'] .= '</link></object>' . "\n";
 
                                        $arr['target'] = '<target><type>' . ACTIVITY_OBJ_IMAGE . '</type><title>' . $p[0]['desc'] . '</title><id>'
-                                               . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . '</id>';
-                                       $arr['target'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . '" />' . "\n" . '<link rel="preview" type="'.$p[0]['type'].'" href="' . $a->get_baseurl() . "/photo/" . $p[0]['resource-id'] . '-' . $best . '.' . $ext . '" />') . '</link></target>';
+                                               . App::get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . '</id>';
+                                       $arr['target'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . App::get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . '" />' . "\n" . '<link rel="preview" type="'.$p[0]['type'].'" href="' . App::get_baseurl() . "/photo/" . $p[0]['resource-id'] . '-' . $best . '.' . $ext . '" />') . '</link></target>';
 
                                        $item_id = item_store($arr);
                                        if ($item_id) {
@@ -908,8 +908,8 @@ function photos_post(&$a) {
        $arr['visible']       = $visible;
        $arr['origin']        = 1;
 
-       $arr['body']          = '[url=' . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo_hash . ']'
-                               . '[img]' . $a->get_baseurl() . "/photo/{$photo_hash}-{$smallest}.".$ph->getExt() . '[/img]'
+       $arr['body']          = '[url=' . App::get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo_hash . ']'
+                               . '[img]' . App::get_baseurl() . "/photo/{$photo_hash}-{$smallest}.".$ph->getExt() . '[/img]'
                                . '[/url]';
 
        $item_id = item_store($arr);
@@ -928,7 +928,7 @@ function photos_post(&$a) {
 
 
 
-function photos_content(&$a) {
+function photos_content(App &$a) {
 
        // URLs:
        // photos/name
index 1ef3cc5b4732b95eeeb396efe1f3beb711a6886e..cde03969f46b394e2091f0723da6168e9ff811ca 100644 (file)
@@ -177,7 +177,7 @@ function ping_init(App $a)
                $intro_count = count($intros1) + count($intros2);
                $intros = $intros1 + $intros2;
 
-               $myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname'] ;
+               $myurl = App::get_baseurl() . '/profile/' . $a->user['nickname'] ;
                $mails = qu("SELECT `id`, `from-name`, `from-url`, `from-photo`, `created` FROM `mail`
                        WHERE `uid` = %d AND `seen` = 0 AND `from-url` != '%s' ",
                        intval(local_user()),
@@ -253,7 +253,7 @@ function ping_init(App $a)
                if (dbm::is_result($intros)) {
                        foreach ($intros as $intro) {
                                $notif = array(
-                                       'href'    => $a->get_baseurl() . '/notifications/intros/' . $intro['id'],
+                                       'href'    => App::get_baseurl() . '/notifications/intros/' . $intro['id'],
                                        'name'    => $intro['name'],
                                        'url'     => $intro['url'],
                                        'photo'   => $intro['photo'],
@@ -268,7 +268,7 @@ function ping_init(App $a)
                if (dbm::is_result($mails)) {
                        foreach ($mails as $mail) {
                                $notif = array(
-                                       'href'    => $a->get_baseurl() . '/message/' . $mail['id'],
+                                       'href'    => App::get_baseurl() . '/message/' . $mail['id'],
                                        'name'    => $mail['from-name'],
                                        'url'     => $mail['from-url'],
                                        'photo'   => $mail['from-photo'],
@@ -283,7 +283,7 @@ function ping_init(App $a)
                if (dbm::is_result($regs)) {
                        foreach ($regs as $reg) {
                                $notif = array(
-                                       'href'    => $a->get_baseurl() . '/admin/users/',
+                                       'href'    => App::get_baseurl() . '/admin/users/',
                                        'name'    => $reg['name'],
                                        'url'     => $reg['url'],
                                        'photo'   => $reg['micro'],
@@ -450,7 +450,7 @@ function ping_get_notifications($uid)
                                );
                        }
 
-                       $notification["href"] = $a->get_baseurl() . "/notify/view/" . $notification["id"];
+                       $notification["href"] = App::get_baseurl() . "/notify/view/" . $notification["id"];
 
                        if ($notification["visible"] AND !$notification["spam"] AND
                                !$notification["deleted"] AND !is_array($result[$notification["parent"]])) {
index e454d1e668fce7deeea29a82c5017c1eb4719d88..11f984757a925e2d157f77cbfba8831143790a11 100644 (file)
@@ -2,7 +2,7 @@
 // See here for a documentation for portable contacts:
 // https://web.archive.org/web/20160405005550/http://portablecontacts.net/draft-spec.html
 
-function poco_init(&$a) {
+function poco_init(App &$a) {
        require_once("include/bbcode.php");
 
        $system_mode = false;
@@ -16,8 +16,9 @@ function poco_init(&$a) {
        }
        if(! x($user)) {
                $c = q("SELECT * FROM `pconfig` WHERE `cat` = 'system' AND `k` = 'suggestme' AND `v` = 1");
-               if(! count($c))
+               if (! dbm::is_result($c)) {
                        http_status_exit(401);
+               }
                $system_mode = true;
        }
 
index 8102c3697da787e63983e3b753883e52f6bbf4f3..2e15ed853ff395be7363279c8d9499871d3348a4 100644 (file)
@@ -19,27 +19,31 @@ require_once('include/bbcode.php');
 require_once('include/items.php');
 
 
-function poke_init(&$a) {
+function poke_init(App &$a) {
 
-       if(! local_user())
+       if (! local_user()) {
                return;
+       }
 
        $uid = local_user();
        $verb = notags(trim($_GET['verb']));
 
-       if(! $verb)
+       if (! $verb) {
                return;
+       }
 
        $verbs = get_poke_verbs();
 
-       if(! array_key_exists($verb,$verbs))
+       if (! array_key_exists($verb,$verbs)) {
                return;
+       }
 
        $activity = ACTIVITY_POKE . '#' . urlencode($verbs[$verb][0]);
 
        $contact_id = intval($_GET['cid']);
-       if(! $contact_id)
+       if (! $contact_id) {
                return;
+       }
 
        $parent = ((x($_GET,'parent')) ? intval($_GET['parent']) : 0);
 
@@ -52,7 +56,7 @@ function poke_init(&$a) {
                intval($uid)
        );
 
-       if(! dbm::is_result($r)) {
+       if (! dbm::is_result($r)) {
                logger('poke: no contact ' . $contact_id);
                return;
        }
@@ -118,7 +122,7 @@ function poke_init(&$a) {
        $arr['origin']        = 1;
        $arr['body']          = '[url=' . $poster['url'] . ']' . $poster['name'] . '[/url]' . ' ' . t($verbs[$verb][0]) . ' ' . '[url=' . $target['url'] . ']' . $target['name'] . '[/url]';
 
-       $arr['object'] = '<object><type>' . ACTIVITY_OBJ_PERSON . '</type><title>' . $target['name'] . '</title><id>' . $a->get_baseurl() . '/contact/' . $target['id'] . '</id>';
+       $arr['object'] = '<object><type>' . ACTIVITY_OBJ_PERSON . '</type><title>' . $target['name'] . '</title><id>' . App::get_baseurl() . '/contact/' . $target['id'] . '</id>';
        $arr['object'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $target['url'] . '" />' . "\n");
 
        $arr['object'] .= xmlify('<link rel="photo" type="image/jpeg" href="' . $target['photo'] . '" />' . "\n");
@@ -127,7 +131,7 @@ function poke_init(&$a) {
        $item_id = item_store($arr);
        if($item_id) {
                //q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d",
-               //      dbesc($a->get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id),
+               //      dbesc(App::get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id),
                //      intval($uid),
                //      intval($item_id)
                //);
@@ -144,9 +148,9 @@ function poke_init(&$a) {
 
 
 
-function poke_content(&$a) {
+function poke_content(App &$a) {
 
-       if(! local_user()) {
+       if (! local_user()) {
                notice( t('Permission denied.') . EOL);
                return;
        }
@@ -166,11 +170,11 @@ function poke_content(&$a) {
        }
 
 
-       $base = $a->get_baseurl();
+       $base = App::get_baseurl();
 
        $head_tpl = get_markup_template('poke_head.tpl');
        $a->page['htmlhead'] .= replace_macros($head_tpl,array(
-               '$baseurl' => $a->get_baseurl(true),
+               '$baseurl' => App::get_baseurl(true),
                '$base' => $base
        ));
 
index 76282d29a5390bf706d59957dc9e40769f7830cb..076587839d96765577d270403dbfb9e4c7ae96ae 100644 (file)
@@ -10,11 +10,11 @@ require_once('include/crypto.php');
 // not yet ready for prime time
 //require_once('include/zot.php');
        
-function post_post(&$a) {
+function post_post(App &$a) {
 
        $bulk_delivery = false;
 
-       if($a->argc == 1) {
+       if ($a->argc == 1) {
                $bulk_delivery = true;
        }
        else {
@@ -23,8 +23,9 @@ function post_post(&$a) {
                                AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1",
                        dbesc($nickname)
                );
-               if(! dbm::is_result($r))
+               if (! dbm::is_result($r)) {
                        http_status_exit(500);
+               }
 
                $importer = $r[0];
        }
index 4584cb29e2564cd31963438d08b295d09c140ecb..694fd5ba2796a6f6ea19dcafcf7e75a1feeb9764 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-function pretheme_init(&$a) {
+function pretheme_init(App &$a) {
        
        if($_REQUEST['theme']) {
                $theme = $_REQUEST['theme'];
index c95db291b359a8410597ceb08d508826441e00cd..c368a50f584be647e332b41c761144be32c0a291 100644 (file)
@@ -2,7 +2,7 @@
 
 require_once('include/Scrape.php');
 
-function probe_content(&$a) {
+function probe_content(App &$a) {
 
        $o .= '<h3>Probe Diagnostic</h3>';
 
index 5ab675dd0d589d6c1b9a4f539d217be025dc54cd..b7756453fec807ceea8b682f5c844ec71197aa5d 100644 (file)
@@ -4,7 +4,7 @@ require_once('include/contact_widgets.php');
 require_once('include/redir.php');
 
 
-function profile_init(&$a) {
+function profile_init(App &$a) {
 
        if(! x($a->page,'aside'))
                $a->page['aside'] = '';
@@ -14,7 +14,7 @@ function profile_init(&$a) {
        else {
                $r = q("select nickname from user where blocked = 0 and account_expired = 0 and account_removed = 0 and verified = 1 order by rand() limit 1");
                if (dbm::is_result($r)) {
-                       goaway($a->get_baseurl() . '/profile/' . $r[0]['nickname']);
+                       goaway(App::get_baseurl() . '/profile/' . $r[0]['nickname']);
                }
                else {
                        logger('profile error: mod_profile ' . $a->query_string, LOGGER_DEBUG);
@@ -56,15 +56,16 @@ function profile_init(&$a) {
        }
 
        $a->page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . (($a->profile['net-publish']) ? 'true' : 'false') . '" />' . "\r\n" ;
-       $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $a->get_baseurl() . '/dfrn_poll/' . $which .'" />' . "\r\n" ;
+       $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . App::get_baseurl() . '/dfrn_poll/' . $which .'" />' . "\r\n" ;
        $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . (($a->path) ? '/' . $a->path : ''));
-       $a->page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . $a->get_baseurl() . '/xrd/?uri=' . $uri . '" />' . "\r\n";
-       header('Link: <' . $a->get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
+       $a->page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . App::get_baseurl() . '/xrd/?uri=' . $uri . '" />' . "\r\n";
+       header('Link: <' . App::get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
 
        $dfrn_pages = array('request', 'confirm', 'notify', 'poll');
-       foreach($dfrn_pages as $dfrn)
-               $a->page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"".$a->get_baseurl()."/dfrn_{$dfrn}/{$which}\" />\r\n";
-       $a->page['htmlhead'] .= "<link rel=\"dfrn-poco\" href=\"".$a->get_baseurl()."/poco/{$which}\" />\r\n";
+       foreach($dfrn_pages as $dfrn) {
+               $a->page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"".App::get_baseurl()."/dfrn_{$dfrn}/{$which}\" />\r\n";
+       }
+       $a->page['htmlhead'] .= "<link rel=\"dfrn-poco\" href=\"".App::get_baseurl()."/poco/{$which}\" />\r\n";
 
 }
 
@@ -181,8 +182,8 @@ function profile_content(&$a, $update = 0) {
                $commpage = (($a->profile['page-flags'] == PAGE_COMMUNITY) ? true : false);
                $commvisitor = (($commpage && $remote_contact == true) ? true : false);
 
-               $a->page['aside'] .= posted_date_widget($a->get_baseurl(true) . '/profile/' . $a->profile['nickname'],$a->profile['profile_uid'],true);
-               $a->page['aside'] .= categories_widget($a->get_baseurl(true) . '/profile/' . $a->profile['nickname'],(x($category) ? xmlify($category) : ''));
+               $a->page['aside'] .= posted_date_widget(App::get_baseurl(true) . '/profile/' . $a->profile['nickname'],$a->profile['profile_uid'],true);
+               $a->page['aside'] .= categories_widget(App::get_baseurl(true) . '/profile/' . $a->profile['nickname'],(x($category) ? xmlify($category) : ''));
 
                if(can_write_wall($a,$a->profile['profile_uid'])) {
 
index 20bbbbcbd41e98d2400782cafd71ff7a53576da0..0b6dd8d13b31a73619d80fcbbfe4d26957b0c9f8 100644 (file)
@@ -2,9 +2,9 @@
 
 require_once("include/Photo.php");
 
-function profile_photo_init(&$a) {
+function profile_photo_init(App &$a) {
 
-       if(! local_user()) {
+       if (! local_user()) {
                return;
        }
 
@@ -13,9 +13,9 @@ function profile_photo_init(&$a) {
 }
 
 
-function profile_photo_post(&$a) {
+function profile_photo_post(App &$a) {
 
-       if(! local_user()) {
+       if (! local_user()) {
                notice ( t('Permission denied.') . EOL );
                return;
        }
@@ -73,22 +73,25 @@ function profile_photo_post(&$a) {
 
                                $r = $im->store(local_user(), 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 4, $is_default_profile);
 
-                               if($r === false)
+                               if ($r === false) {
                                        notice ( sprintf(t('Image size reduction [%s] failed.'),"175") . EOL );
+                               }
 
                                $im->scaleImage(80);
 
                                $r = $im->store(local_user(), 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 5, $is_default_profile);
 
-                               if($r === false)
+                               if ($r === false) {
                                        notice( sprintf(t('Image size reduction [%s] failed.'),"80") . EOL );
+                               }
 
                                $im->scaleImage(48);
 
                                $r = $im->store(local_user(), 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 6, $is_default_profile);
 
-                               if($r === false)
+                               if ($r === false) {
                                        notice( sprintf(t('Image size reduction [%s] failed.'),"48") . EOL );
+                               }
 
                                // If setting for the default profile, unset the profile photo flag from any other photos I own
 
@@ -99,15 +102,15 @@ function profile_photo_post(&$a) {
                                        );
 
                                        $r = q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s'  WHERE `self` AND `uid` = %d",
-                                               dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-4.' . $im->getExt()),
-                                               dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-5.' . $im->getExt()),
-                                               dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-6.' . $im->getExt()),
+                                               dbesc(App::get_baseurl() . '/photo/' . $base_image['resource-id'] . '-4.' . $im->getExt()),
+                                               dbesc(App::get_baseurl() . '/photo/' . $base_image['resource-id'] . '-5.' . $im->getExt()),
+                                               dbesc(App::get_baseurl() . '/photo/' . $base_image['resource-id'] . '-6.' . $im->getExt()),
                                                intval(local_user())
                                        );
                                } else {
                                        $r = q("update profile set photo = '%s', thumb = '%s' where id = %d and uid = %d",
-                                               dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-4.' . $im->getExt()),
-                                               dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-5.' . $im->getExt()),
+                                               dbesc(App::get_baseurl() . '/photo/' . $base_image['resource-id'] . '-4.' . $im->getExt()),
+                                               dbesc(App::get_baseurl() . '/photo/' . $base_image['resource-id'] . '-5.' . $im->getExt()),
                                                intval($_REQUEST['profile']),
                                                intval(local_user())
                                        );
@@ -123,9 +126,10 @@ function profile_photo_post(&$a) {
 
                                info( t('Shift-reload the page or clear browser cache if the new photo does not display immediately.') . EOL);
                                // Update global directory in background
-                               $url = $a->get_baseurl() . '/profile/' . $a->user['nickname'];
-                               if($url && strlen(get_config('system','directory')))
+                               $url = App::get_baseurl() . '/profile/' . $a->user['nickname'];
+                               if ($url && strlen(get_config('system','directory'))) {
                                        proc_run(PRIORITY_LOW, "include/directory.php", $url);
+                               }
 
                                require_once('include/profile_update.php');
                                profile_change();
@@ -134,7 +138,7 @@ function profile_photo_post(&$a) {
                                notice( t('Unable to process image') . EOL);
                }
 
-               goaway($a->get_baseurl() . '/profiles');
+               goaway(App::get_baseurl() . '/profiles');
                return; // NOTREACHED
        }
 
@@ -169,9 +173,9 @@ function profile_photo_post(&$a) {
 
 
 if(! function_exists('profile_photo_content')) {
-function profile_photo_content(&$a) {
+function profile_photo_content(App &$a) {
 
-       if(! local_user()) {
+       if (! local_user()) {
                notice( t('Permission denied.') . EOL );
                return;
        }
@@ -223,10 +227,11 @@ function profile_photo_content(&$a) {
 
                        // Update global directory in background
                        $url = $_SESSION['my_url'];
-                       if($url && strlen(get_config('system','directory')))
+                       if ($url && strlen(get_config('system','directory'))) {
                                proc_run(PRIORITY_LOW, "include/directory.php", $url);
+                       }
 
-                       goaway($a->get_baseurl() . '/profiles');
+                       goaway(App::get_baseurl() . '/profiles');
                        return; // NOTREACHED
                }
                $ph = new Photo($r[0]['data'], $r[0]['type']);
@@ -251,7 +256,7 @@ function profile_photo_content(&$a) {
                        '$submit' => t('Upload'),
                        '$profiles' => $profiles,
                        '$form_security_token' => get_form_security_token("profile_photo"),
-                       '$select' => sprintf('%s %s', t('or'), ($newuser) ? '<a href="' . $a->get_baseurl() . '">' . t('skip this step') . '</a>' : '<a href="'. $a->get_baseurl() . '/photos/' . $a->user['nickname'] . '">' . t('select a photo from your photo albums') . '</a>')
+                       '$select' => sprintf('%s %s', t('or'), ($newuser) ? '<a href="' . App::get_baseurl() . '">' . t('skip this step') . '</a>' : '<a href="'. App::get_baseurl() . '/photos/' . $a->user['nickname'] . '">' . t('select a photo from your photo albums') . '</a>')
                ));
 
                return $o;
@@ -264,7 +269,7 @@ function profile_photo_content(&$a) {
                        '$filename' => $filename,
                        '$profile' => intval($_REQUEST['profile']),
                        '$resource' => $a->config['imagecrop'] . '-' . $a->config['imagecrop_resolution'],
-                       '$image_url' => $a->get_baseurl() . '/photo/' . $filename,
+                       '$image_url' => App::get_baseurl() . '/photo/' . $filename,
                        '$title' => t('Crop Image'),
                        '$desc' => t('Please adjust the image cropping for optimum viewing.'),
                        '$form_security_token' => get_form_security_token("profile_photo"),
@@ -280,15 +285,17 @@ function profile_photo_content(&$a) {
 if(! function_exists('profile_photo_crop_ui_head')) {
 function profile_photo_crop_ui_head(&$a, $ph){
        $max_length = get_config('system','max_image_length');
-       if(! $max_length)
+       if (! $max_length) {
                $max_length = MAX_IMAGE_LENGTH;
-       if($max_length > 0)
+       }
+       if ($max_length > 0) {
                $ph->scaleImage($max_length);
+       }
 
        $width = $ph->getWidth();
        $height = $ph->getHeight();
 
-       if($width < 175 || $height < 175) {
+       if ($width < 175 || $height < 175) {
                $ph->scaleImageUp(200);
                $width = $ph->getWidth();
                $height = $ph->getHeight();
@@ -301,19 +308,21 @@ function profile_photo_crop_ui_head(&$a, $ph){
 
        $r = $ph->store(local_user(), 0 , $hash, $filename, t('Profile Photos'), 0 );   
 
-       if($r)
+       if ($r) {
                info( t('Image uploaded successfully.') . EOL );
-       else
+       } else {
                notice( t('Image upload failed.') . EOL );
+       }
 
-       if($width > 640 || $height > 640) {
+       if ($width > 640 || $height > 640) {
                $ph->scaleImage(640);
                $r = $ph->store(local_user(), 0 , $hash, $filename, t('Profile Photos'), 1 );   
-               
-               if($r === false)
+
+               if ($r === false) {
                        notice( sprintf(t('Image size reduction [%s] failed.'),"640") . EOL );
-               else
+               } else {
                        $smallest = 1;
+               }
        }
 
        $a->config['imagecrop'] = $hash;
index f9fde658d2a9766d0a825b2a36928563065a3287..20bd4cf6f1d11db35f77db9805615a147ac0ae29 100644 (file)
@@ -2,11 +2,11 @@
 require_once("include/Contact.php");
 require_once('include/Probe.php');
 
-function profiles_init(&$a) {
+function profiles_init(App &$a) {
 
        nav_set_selected('profiles');
 
-       if(! local_user()) {
+       if (! local_user()) {
                return;
        }
 
@@ -15,7 +15,7 @@ function profiles_init(&$a) {
                        intval($a->argv[2]),
                        intval(local_user())
                );
-               if(! dbm::is_result($r)) {
+               if (! dbm::is_result($r)) {
                        notice( t('Profile not found.') . EOL);
                        goaway('profiles');
                        return; // NOTREACHED
@@ -92,7 +92,7 @@ function profiles_init(&$a) {
                        intval(local_user()),
                        intval($a->argv[2])
                );
-               if(! count($r1)) {
+               if(! dbm::is_result($r1)) {
                        notice( t('Profile unavailable to clone.') . EOL);
                        killme();
                        return;
@@ -116,7 +116,7 @@ function profiles_init(&$a) {
                        dbesc($name)
                );
                info( t('New profile created.') . EOL);
-               if(count($r3) == 1)
+               if ((dbm::is_result($r3)) && (count($r3) == 1))
                        goaway('profiles/'.$r3[0]['id']);
 
                goaway('profiles');
@@ -130,7 +130,7 @@ function profiles_init(&$a) {
                        intval($a->argv[1]),
                        intval(local_user())
                );
-               if(! dbm::is_result($r)) {
+               if (! dbm::is_result($r)) {
                        notice( t('Profile not found.') . EOL);
                        killme();
                        return;
@@ -160,9 +160,9 @@ function profile_clean_keywords($keywords) {
        return $keywords;
 }
 
-function profiles_post(&$a) {
+function profiles_post(App &$a) {
 
-       if(! local_user()) {
+       if (! local_user()) {
                notice( t('Permission denied.') . EOL);
                return;
        }
@@ -502,8 +502,9 @@ function profiles_post(&$a) {
 
                        // Update global directory in background
                        $url = $_SESSION['my_url'];
-                       if($url && strlen(get_config('system','directory')))
+                       if ($url && strlen(get_config('system','directory'))) {
                                proc_run(PRIORITY_LOW, "include/directory.php", $url);
+                       }
 
                        require_once('include/profile_update.php');
                        profile_change();
@@ -594,14 +595,15 @@ function profile_activity($changed, $value) {
        $arr['deny_gid']  = $a->user['deny_gid'];
 
        $i = item_store($arr);
-       if($i)
+       if ($i) {
                proc_run(PRIORITY_HIGH, "include/notifier.php", "activity", $i);
+       }
 }
 
 
-function profiles_content(&$a) {
+function profiles_content(App &$a) {
 
-       if(! local_user()) {
+       if (! local_user()) {
                notice( t('Permission denied.') . EOL);
                return;
        }
@@ -613,7 +615,7 @@ function profiles_content(&$a) {
                        intval($a->argv[1]),
                        intval(local_user())
                );
-               if(! dbm::is_result($r)) {
+               if (! dbm::is_result($r)) {
                        notice( t('Profile not found.') . EOL);
                        return;
                }
@@ -629,11 +631,11 @@ function profiles_content(&$a) {
                        $editselect = 'textareas';
 
                $a->page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), array(
-                       '$baseurl' => $a->get_baseurl(true),
+                       '$baseurl' => App::get_baseurl(true),
                        '$editselect' => $editselect,
                ));
                $a->page['end'] .= replace_macros(get_markup_template('profed_end.tpl'), array(
-                       '$baseurl' => $a->get_baseurl(true),
+                       '$baseurl' => App::get_baseurl(true),
                        '$editselect' => $editselect,
                ));
 
@@ -711,7 +713,7 @@ function profiles_content(&$a) {
                        '$lbl_ex2' => t('Example: fishing photography software'),
 
                        '$disabled' => (($is_default) ? 'onclick="return false;" style="color: #BBBBFF;"' : ''),
-                       '$baseurl' => $a->get_baseurl(true),
+                       '$baseurl' => App::get_baseurl(true),
                        '$profile_id' => $r[0]['id'],
                        '$profile_name' => array('profile_name', t('Profile Name:'), $r[0]['profile-name'], t('Required'), '*'),
                        '$is_default'   => $is_default,
index 1c37f84ab2fca78f9703d2c74ac9075d7eeee380..bbb055b021c382e639dd5e50d20cb5b29419bd70 100644 (file)
@@ -1,9 +1,10 @@
 <?php
 
-function profperm_init(&$a) {
+function profperm_init(App &$a) {
 
-       if(! local_user())
+       if (! local_user()) {
                return;
+       }
 
        $which = $a->user['nickname'];
        $profile = $a->argv[1];
@@ -13,9 +14,9 @@ function profperm_init(&$a) {
 }
 
 
-function profperm_content(&$a) {
+function profperm_content(App &$a) {
 
-       if(! local_user()) {
+       if (! local_user()) {
                notice( t('Permission denied') . EOL);
                return;
        }
@@ -52,7 +53,7 @@ function profperm_content(&$a) {
                        intval($a->argv[1]),
                        intval(local_user())
                );
-               if(! dbm::is_result($r)) {
+               if (! dbm::is_result($r)) {
                        notice( t('Invalid profile identifier.') . EOL );
                        return;
                }
index 09a80f32849cacb08abd588bd5e3b4e9c8104f59..d57d9baec5f3b26f43674252af48f9a2c5d20d47 100644 (file)
@@ -255,7 +255,7 @@ function proxy_url($url, $writemode = false, $size = '') {
 
        // Only continue if it isn't a local image and the isn't deactivated
        if (proxy_is_local_image($url)) {
-               $url = str_replace(normalise_link($a->get_baseurl()) . '/', $a->get_baseurl() . '/', $url);
+               $url = str_replace(normalise_link(App::get_baseurl()) . '/', App::get_baseurl() . '/', $url);
                return $url;
        }
 
@@ -297,7 +297,7 @@ function proxy_url($url, $writemode = false, $size = '') {
                $longpath .= '.' . $extension;
        }
 
-       $proxypath = $a->get_baseurl() . '/proxy/' . $longpath;
+       $proxypath = App::get_baseurl() . '/proxy/' . $longpath;
 
        if ($size != '') {
                $size = ':' . $size;
@@ -308,7 +308,7 @@ function proxy_url($url, $writemode = false, $size = '') {
        if ((strlen($proxypath) > 250) AND $writemode) {
                return $shortpath;
        } elseif (strlen($proxypath) > 250) {
-               return $a->get_baseurl() . '/proxy/' . $shortpath . '?url=' . urlencode($url);
+               return App::get_baseurl() . '/proxy/' . $shortpath . '?url=' . urlencode($url);
        } elseif ($writemode) {
                return $longpath;
        } else {
@@ -366,7 +366,7 @@ function proxy_img_cb($matches) {
 
 function proxy_parse_html($html) {
        $a = get_app();
-       $html = str_replace(normalise_link($a->get_baseurl())."/", $a->get_baseurl()."/", $html);
+       $html = str_replace(normalise_link(App::get_baseurl())."/", App::get_baseurl()."/", $html);
 
        return preg_replace_callback("/(<img [^>]*src *= *[\"'])([^\"']+)([\"'][^>]*>)/siU", "proxy_img_cb", $html);
 }
index ddda7ec228a9e9ff0718e3eb732d7beccaad2ec7..308e237d5d55bbebe91e12e36a927184bfaf6177 100644 (file)
@@ -26,7 +26,7 @@ function hub_post_return() {
 
 
 
-function pubsub_init(&$a) {
+function pubsub_init(App &$a) {
 
        $nick       = (($a->argc > 1) ? notags(trim($a->argv[1])) : '');
        $contact_id = (($a->argc > 2) ? intval($a->argv[2])       : 0 );
@@ -47,7 +47,7 @@ function pubsub_init(&$a) {
                $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1",
                        dbesc($nick)
                );
-               if(! dbm::is_result($r)) {
+               if (! dbm::is_result($r)) {
                        logger('pubsub: local account not found: ' . $nick);
                        hub_return(false, '');
                }
@@ -62,7 +62,7 @@ function pubsub_init(&$a) {
                        intval($contact_id),
                        intval($owner['uid'])
                );
-               if(! dbm::is_result($r)) {
+               if (! dbm::is_result($r)) {
                        logger('pubsub: contact '.$contact_id.' not found.');
                        hub_return(false, '');
                }
@@ -98,7 +98,7 @@ function pubsub_init(&$a) {
 
 require_once('include/security.php');
 
-function pubsub_post(&$a) {
+function pubsub_post(App &$a) {
 
        $xml = file_get_contents('php://input');
 
@@ -117,8 +117,9 @@ function pubsub_post(&$a) {
        $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1",
                dbesc($nick)
        );
-       if(! dbm::is_result($r))
+       if (! dbm::is_result($r)) {
                hub_post_return();
+       }
 
        $importer = $r[0];
 
@@ -131,7 +132,7 @@ function pubsub_post(&$a) {
                dbesc(NETWORK_FEED)
        );
 
-       if(! dbm::is_result($r)) {
+       if (! dbm::is_result($r)) {
                logger('pubsub: no contact record for "'.$nick.' ('.$contact_id.')" - ignored. '.$xml);
                hub_post_return();
        }
index bfe553c44caf1e8c91b5ee7cc74f1e2167fe3408..a6c36631aefa5fb77a6d383d2a39d1cff23156f3 100644 (file)
@@ -4,7 +4,7 @@ function post_var($name) {
        return (x($_POST, $name)) ? notags(trim($_POST[$name])) : '';
 }
 
-function pubsubhubbub_init(&$a) {
+function pubsubhubbub_init(App &$a) {
        // PuSH subscription must be considered "public" so just block it
        // if public access isn't enabled.
        if (get_config('system', 'block_public')) {
index a440ea708fe22e0b211ad588468d198abd773202..118c93d9fa31a3d75d8508237a2f3869beed27e8 100644 (file)
@@ -1,9 +1,10 @@
 <?php
 
-function qsearch_init(&$a) {
+function qsearch_init(App &$a) {
 
-       if(! local_user())
+       if (! local_user()) {
                killme();
+       }
 
        $limit = (get_config('system','qsearch_limit') ? intval(get_config('system','qsearch_limit')) : 100);
 
index 6713a81d9e4a2efe2f013feb6ceeb2c092a891fe..08157a3851a40ff8bba7723112498a817c90de21 100644 (file)
@@ -1,10 +1,14 @@
 <?php
 
 
-function randprof_init(&$a) {
+function randprof_init(App &$a) {
        require_once('include/Contact.php');
+
        $x = random_profile();
-       if($x)
+
+       if ($x) {
                goaway(zrl($x));
-       goaway($a->get_baseurl() . '/profile');
+       }
+
+       goaway(App::get_baseurl() . '/profile');
 }
index dd4e61ae4f95ce43cbb4fd8b47b1ae20c6072ae3..90dcc05281cd9f4f82509b4d7eb0a42b88f6007c 100644 (file)
@@ -10,7 +10,7 @@ require_once('include/crypto.php');
 require_once('include/diaspora.php');
 
 
-function receive_post(&$a) {
+function receive_post(App &$a) {
 
 
        $enabled = intval(get_config('system','diaspora_enabled'));
@@ -34,8 +34,9 @@ function receive_post(&$a) {
                $r = q("SELECT * FROM `user` WHERE `guid` = '%s' AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1",
                        dbesc($guid)
                );
-               if(! dbm::is_result($r))
+               if (! dbm::is_result($r)) {
                        http_status_exit(500);
+               }
 
                $importer = $r[0];
        }
index 5dc5ad372416e2788a376f8dafb1bc903615c217..e951b2d2a9871251c7256ccff4b7f60b8c5e7206 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-function redir_init(&$a) {
+function redir_init(App &$a) {
 
        $url = ((x($_GET,'url')) ? $_GET['url'] : '');
        $quiet = ((x($_GET,'quiet')) ? '&quiet=1' : '');
@@ -63,12 +63,14 @@ function redir_init(&$a) {
                        . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&type=profile&sec=' . $sec . $dest . $quiet );
        }
 
-       if(local_user())
-               $handle = $a->user['nickname'] . '@' . substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')+3);
-       if(remote_user())
+       if (local_user()) {
+               $handle = $a->user['nickname'] . '@' . substr(App::get_baseurl(),strpos(App::get_baseurl(),'://')+3);
+       }
+       if (remote_user()) {
                $handle = $_SESSION['handle'];
+       }
 
-       if($url) {
+       if ($url) {
                $url = str_replace('{zid}','&zid=' . $handle,$url);
                goaway($url);
        }
index f0348ef4e5c6b1d61fd26a5c2f1c6473870adca1..dd953de35619119cb7a7d898a4e11f974bec9452 100644 (file)
@@ -5,7 +5,7 @@ require_once('include/bbcode.php');
 require_once('include/user.php');
 
 if(! function_exists('register_post')) {
-function register_post(&$a) {
+function register_post(App &$a) {
 
        global $lang;
 
@@ -64,7 +64,7 @@ function register_post(&$a) {
        $user = $result['user'];
 
        if($netpublish && $a->config['register_policy'] != REGISTER_APPROVE) {
-               $url = $a->get_baseurl() . '/profile/' . $user['nickname'];
+               $url = App::get_baseurl() . '/profile/' . $user['nickname'];
                proc_run(PRIORITY_LOW, "include/directory.php", $url);
        }
 
@@ -85,7 +85,7 @@ function register_post(&$a) {
                        $res = send_register_open_eml(
                                $user['email'],
                                $a->config['sitename'],
-                               $a->get_baseurl(),
+                               App::get_baseurl(),
                                $user['username'],
                                $result['password']);
 
@@ -142,9 +142,9 @@ function register_post(&$a) {
                                'source_name' => $user['username'],
                                'source_mail' => $user['email'],
                                'source_nick' => $user['nickname'],
-                               'source_link' => $a->get_baseurl()."/admin/users/",
-                               'link' => $a->get_baseurl()."/admin/users/",
-                               'source_photo' => $a->get_baseurl() . "/photo/avatar/".$user['uid'].".jpg",
+                               'source_link' => App::get_baseurl()."/admin/users/",
+                               'link' => App::get_baseurl()."/admin/users/",
+                               'source_photo' => App::get_baseurl() . "/photo/avatar/".$user['uid'].".jpg",
                                'to_email' => $admin['email'],
                                'uid' => $admin['uid'],
                                'language' => ($admin['language']?$admin['language']:'en'),
@@ -172,7 +172,7 @@ function register_post(&$a) {
 
 
 if(! function_exists('register_content')) {
-function register_content(&$a) {
+function register_content(App &$a) {
 
        // logged in users can register others (people/pages/groups)
        // even with closed registrations, unless specifically prohibited by site policy.
index 0120017b00dd39c02d964c8951004c0c7e7f1864..44bdfe66449029aa9bc1b6380afcb44f8ff6fa10 100644 (file)
@@ -12,15 +12,17 @@ function user_allow($hash) {
        );
 
 
-       if(! count($register))
+       if (! dbm::is_result($register)) {
                return false;
+       }
 
        $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
                intval($register[0]['uid'])
        );
 
-       if(! count($user))
+       if (! dbm::is_result($user)) {
                killme();
+       }
 
        $r = q("DELETE FROM `register` WHERE `hash` = '%s'",
                dbesc($register[0]['hash'])
@@ -35,9 +37,10 @@ function user_allow($hash) {
                intval($user[0]['uid'])
        );
        if (dbm::is_result($r) && $r[0]['net-publish']) {
-               $url = $a->get_baseurl() . '/profile/' . $user[0]['nickname'];
-               if($url && strlen(get_config('system','directory')))
+               $url = App::get_baseurl() . '/profile/' . $user[0]['nickname'];
+               if ($url && strlen(get_config('system','directory'))) {
                        proc_run(PRIORITY_LOW, "include/directory.php", $url);
+               }
        }
 
        push_lang($register[0]['language']);
@@ -45,7 +48,7 @@ function user_allow($hash) {
        send_register_open_eml(
                $user[0]['email'],
                $a->config['sitename'],
-               $a->get_baseurl(),
+               App::get_baseurl(),
                $user[0]['username'],
                $register[0]['password']);
 
@@ -69,7 +72,7 @@ function user_deny($hash) {
                dbesc($hash)
        );
 
-       if(! count($register))
+       if(! dbm::is_result($register))
                return false;
 
        $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
@@ -94,40 +97,41 @@ function user_deny($hash) {
 
 }
 
-function regmod_content(&$a) {
+function regmod_content(App &$a) {
 
        global $lang;
 
        $_SESSION['return_url'] = $a->cmd;
 
-       if(! local_user()) {
+       if (! local_user()) {
                info( t('Please login.') . EOL);
                $o .= '<br /><br />' . login(($a->config['register_policy'] == REGISTER_CLOSED) ? 0 : 1);
                return $o;
        }
 
-       if((!is_site_admin()) || (x($_SESSION,'submanage') && intval($_SESSION['submanage']))) {
+       if ((!is_site_admin()) || (x($_SESSION,'submanage') && intval($_SESSION['submanage']))) {
                notice( t('Permission denied.') . EOL);
                return '';
        }
 
-       if($a->argc != 3)
+       if ($a->argc != 3) {
                killme();
+       }
 
        $cmd  = $a->argv[1];
        $hash = $a->argv[2];
 
 
 
-       if($cmd === 'deny') {
+       if ($cmd === 'deny') {
                user_deny($hash);
-               goaway($a->get_baseurl()."/admin/users/");
+               goaway(App::get_baseurl()."/admin/users/");
                killme();
        }
 
-       if($cmd === 'allow') {
+       if ($cmd === 'allow') {
                user_allow($hash);
-               goaway($a->get_baseurl()."/admin/users/");
+               goaway(App::get_baseurl()."/admin/users/");
                killme();
        }
 }
index 904606fd57cb77b69a1a0b7ef48a9025ff012f25..4257667c4b1bf663325cbc2e4fdbe1950a2456a9 100644 (file)
@@ -1,25 +1,30 @@
 <?php
 
-function removeme_post(&$a) {
+function removeme_post(App &$a) {
 
-       if(! local_user())
+       if (! local_user()) {
                return;
+       }
 
-       if(x($_SESSION,'submanage') && intval($_SESSION['submanage']))
+       if (x($_SESSION,'submanage') && intval($_SESSION['submanage'])) {
                return;
+       }
 
-       if((! x($_POST,'qxz_password')) || (! strlen(trim($_POST['qxz_password']))))
+       if ((! x($_POST,'qxz_password')) || (! strlen(trim($_POST['qxz_password'])))) {
                return;
+       }
 
-       if((! x($_POST,'verify')) || (! strlen(trim($_POST['verify']))))
+       if ((! x($_POST,'verify')) || (! strlen(trim($_POST['verify'])))) {
                return;
+       }
 
-       if($_POST['verify'] !== $_SESSION['remove_account_verify'])
+       if ($_POST['verify'] !== $_SESSION['remove_account_verify']) {
                return;
+       }
 
        $encrypted = hash('whirlpool',trim($_POST['qxz_password']));
 
-       if((strlen($a->user['password'])) && ($encrypted === $a->user['password'])) {
+       if ((strlen($a->user['password'])) && ($encrypted === $a->user['password'])) {
                require_once('include/Contact.php');
                user_remove($a->user['uid']);
                // NOTREACHED
@@ -27,21 +32,22 @@ function removeme_post(&$a) {
 
 }
 
-function removeme_content(&$a) {
+function removeme_content(App &$a) {
 
-       if(! local_user())
+       if (! local_user()) {
                goaway(z_root());
+       }
 
        $hash = random_string();
 
-        require_once("mod/settings.php");
-        settings_init($a);
+       require_once("mod/settings.php");
+       settings_init($a);
 
        $_SESSION['remove_account_verify'] = $hash;
 
        $tpl = get_markup_template('removeme.tpl');
        $o .= replace_macros($tpl, array(
-               '$basedir' => $a->get_baseurl(),
+               '$basedir' => App::get_baseurl(),
                '$hash' => $hash,
                '$title' => t('Remove My Account'),
                '$desc' => t('This will completely remove your account. Once this has been done it is not recoverable.'),
index 2b1224f4233fa6bec55792ad3242278b541a795c..07721220a087150f14a42bedb3d60235381e4c4e 100755 (executable)
@@ -3,9 +3,9 @@
 require_once('include/Scrape.php');
 require_once('include/follow.php');
 
-function repair_ostatus_content(&$a) {
+function repair_ostatus_content(App &$a) {
 
-       if(! local_user()) {
+       if (! local_user()) {
                notice( t('Permission denied.') . EOL);
                goaway($_SESSION['return_url']);
                // NOTREACHED
@@ -51,7 +51,7 @@ function repair_ostatus_content(&$a) {
 
        $result = new_contact($uid,$r[0]["url"],true);
 
-       $a->page['htmlhead'] = '<meta http-equiv="refresh" content="1; URL='.$a->get_baseurl().'/repair_ostatus?counter='.$counter.'">';
+       $a->page['htmlhead'] = '<meta http-equiv="refresh" content="1; URL='.App::get_baseurl().'/repair_ostatus?counter='.$counter.'">';
 
        return $o;
 }
index f4984f0f0ffd12e8d911c73ae8f4d1b39b65adc7..13c84c3fcc47049e4367803bc12590d768488c80 100644 (file)
@@ -2,7 +2,7 @@
 
 
 
-function rsd_xml_content(&$a) {
+function rsd_xml_content(App &$a) {
        header ("Content-Type: text/xml");
        echo '<?xml version="1.0" encoding="UTF-8"?>
  <rsd version="1.0" xmlns="http://archipelago.phrasewise.com/rsd">
@@ -10,7 +10,7 @@ function rsd_xml_content(&$a) {
      <engineName>Friendica</engineName>
      <engineLink>http://friendica.com/</engineLink>
      <apis>
-       <api name="Twitter" preferred="true" apiLink="'.$a->get_baseurl().'/api/" blogID="">
+       <api name="Twitter" preferred="true" apiLink="'.App::get_baseurl().'/api/" blogID="">
          <settings>
            <docs>http://status.net/wiki/TwitterCompatibleAPI</docs>
            <setting name="OAuth">false</setting>
index 78cdc09328685158a9dcc931a7b22963e0471a9d..6c3aea211447f4676229f349cd9352dca1be3cfb 100644 (file)
@@ -19,7 +19,7 @@ function salmon_return($val) {
 
 }
 
-function salmon_post(&$a) {
+function salmon_post(App &$a) {
 
        $xml = file_get_contents('php://input');
 
@@ -31,8 +31,9 @@ function salmon_post(&$a) {
        $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1",
                dbesc($nick)
        );
-       if(! dbm::is_result($r))
+       if (! dbm::is_result($r)) {
                http_status_exit(500);
+       }
 
        $importer = $r[0];
 
@@ -150,7 +151,7 @@ function salmon_post(&$a) {
                dbesc(normalise_link($author_link)),
                intval($importer['uid'])
        );
-       if(! dbm::is_result($r)) {
+       if (! dbm::is_result($r)) {
                logger('mod-salmon: Author unknown to us.');
                if(get_pconfig($importer['uid'],'system','ostatus_autofriend')) {
                        $result = new_contact($importer['uid'],$author_link);
index d36cc8fcb73ee22f8d64e90b534406fce62da040..3a253762689693dfcdc2aea6876bf2fffa08beb6 100644 (file)
@@ -43,7 +43,7 @@ function search_saved_searches() {
 }
 
 
-function search_init(&$a) {
+function search_init(App &$a) {
 
        $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
 
@@ -53,7 +53,7 @@ function search_init(&$a) {
                                intval(local_user()),
                                dbesc($search)
                        );
-                       if(! dbm::is_result($r)) {
+                       if (! dbm::is_result($r)) {
                                q("INSERT INTO `search` (`uid`,`term`) VALUES ( %d, '%s')",
                                        intval(local_user()),
                                        dbesc($search)
@@ -81,13 +81,13 @@ function search_init(&$a) {
 
 
 
-function search_post(&$a) {
+function search_post(App &$a) {
        if(x($_POST,'search'))
                $a->data['search'] = $_POST['search'];
 }
 
 
-function search_content(&$a) {
+function search_content(App &$a) {
 
        if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
                notice( t('Public access denied.') . EOL);
@@ -219,7 +219,7 @@ function search_content(&$a) {
                                intval($a->pager['start']), intval($a->pager['itemspage']));
        }
 
-       if(! dbm::is_result($r)) {
+       if (! dbm::is_result($r)) {
                info( t('No results.') . EOL);
                return $o;
        }
index a9521db221bd0e6ccbb429f3ae326dbda39a73bf..515a97c14dc2c5e30e5e9c8e6627e297a093e7df 100644 (file)
@@ -16,9 +16,9 @@ function get_theme_config_file($theme){
        return null;
 }
 
-function settings_init(&$a) {
+function settings_init(App &$a) {
 
-       if(! local_user()) {
+       if (! local_user()) {
                notice( t('Permission denied.') . EOL );
                return;
        }
@@ -116,33 +116,35 @@ function settings_init(&$a) {
 }
 
 
-function settings_post(&$a) {
+function settings_post(App &$a) {
 
-       if(! local_user())
+       if (! local_user()) {
                return;
+       }
 
-       if(x($_SESSION,'submanage') && intval($_SESSION['submanage']))
+       if (x($_SESSION,'submanage') && intval($_SESSION['submanage'])) {
                return;
+       }
 
-       if(count($a->user) && x($a->user,'uid') && $a->user['uid'] != local_user()) {
+       if (count($a->user) && x($a->user,'uid') && $a->user['uid'] != local_user()) {
                notice( t('Permission denied.') . EOL);
                return;
        }
 
        $old_page_flags = $a->user['page-flags'];
 
-       if(($a->argc > 1) && ($a->argv[1] === 'oauth') && x($_POST,'remove')){
+       if (($a->argc > 1) && ($a->argv[1] === 'oauth') && x($_POST,'remove')) {
                check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth');
 
                $key = $_POST['remove'];
                q("DELETE FROM tokens WHERE id='%s' AND uid=%d",
                        dbesc($key),
                        local_user());
-               goaway($a->get_baseurl(true)."/settings/oauth/");
+               goaway(App::get_baseurl(true)."/settings/oauth/");
                return;
        }
 
-       if(($a->argc > 2) && ($a->argv[1] === 'oauth')  && ($a->argv[2] === 'edit'||($a->argv[2] === 'add')) && x($_POST,'submit')) {
+       if (($a->argc > 2) && ($a->argv[1] === 'oauth')  && ($a->argv[2] === 'edit'||($a->argv[2] === 'add')) && x($_POST,'submit')) {
 
                check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth');
 
@@ -183,7 +185,7 @@ function settings_post(&$a) {
                                                local_user());
                        }
                }
-               goaway($a->get_baseurl(true)."/settings/oauth/");
+               goaway(App::get_baseurl(true)."/settings/oauth/");
                return;
        }
 
@@ -225,7 +227,7 @@ function settings_post(&$a) {
                                $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
                                        intval(local_user())
                                );
-                               if(! dbm::is_result($r)) {
+                               if (! dbm::is_result($r)) {
                                        q("INSERT INTO `mailacct` (`uid`) VALUES (%d)",
                                                intval(local_user())
                                        );
@@ -628,8 +630,9 @@ function settings_post(&$a) {
        if(($old_visibility != $net_publish) || ($page_flags != $old_page_flags)) {
                // Update global directory in background
                $url = $_SESSION['my_url'];
-               if($url && strlen(get_config('system','directory')))
+               if ($url && strlen(get_config('system','directory'))) {
                        proc_run(PRIORITY_LOW, "include/directory.php", $url);
+               }
        }
 
        require_once('include/profile_update.php');
@@ -651,17 +654,17 @@ function settings_post(&$a) {
 }
 
 
-function settings_content(&$a) {
+function settings_content(App &$a) {
 
        $o = '';
        nav_set_selected('settings');
 
-       if(! local_user()) {
+       if (! local_user()) {
                #notice( t('Permission denied.') . EOL );
                return;
        }
 
-       if(x($_SESSION,'submanage') && intval($_SESSION['submanage'])) {
+       if (x($_SESSION,'submanage') && intval($_SESSION['submanage'])) {
                notice( t('Permission denied.') . EOL );
                return;
        }
@@ -718,7 +721,7 @@ function settings_content(&$a) {
                        $r = q("DELETE FROM clients WHERE client_id='%s' AND uid=%d",
                                        dbesc($a->argv[3]),
                                        local_user());
-                       goaway($a->get_baseurl(true)."/settings/oauth/");
+                       goaway(App::get_baseurl(true)."/settings/oauth/");
                        return;
                }
 
@@ -734,7 +737,7 @@ function settings_content(&$a) {
                $tpl = get_markup_template("settings_oauth.tpl");
                $o .= replace_macros($tpl, array(
                        '$form_security_token' => get_form_security_token("settings_oauth"),
-                       '$baseurl'      => $a->get_baseurl(true),
+                       '$baseurl'      => App::get_baseurl(true),
                        '$title'        => t('Connected Apps'),
                        '$add'          => t('Add application'),
                        '$edit'         => t('Edit'),
@@ -752,8 +755,9 @@ function settings_content(&$a) {
                $settings_addons = "";
 
                $r = q("SELECT * FROM `hook` WHERE `hook` = 'plugin_settings' ");
-               if(! dbm::is_result($r))
+               if (! dbm::is_result($r)) {
                        $settings_addons = t('No Plugin settings configured');
+               }
 
                call_hooks('plugin_settings', $settings_addons);
 
@@ -821,8 +825,10 @@ function settings_content(&$a) {
 
                $settings_connectors .= mini_group_select(local_user(), $default_group, t("Default group for OStatus contacts"));
 
-               if ($legacy_contact != "")
-                       $a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL='.$a->get_baseurl().'/ostatus_subscribe?url='.urlencode($legacy_contact).'">';
+               /// @TODO Found to much different usage to test empty/non-empty strings (e.g. empty(), trim() == '' ) which is wanted?
+               if ($legacy_contact != "") {
+                       $a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL='.App::get_baseurl().'/ostatus_subscribe?url='.urlencode($legacy_contact).'">';
+               }
 
                $settings_connectors .= '<div id="legacy-contact-wrapper" class="field input">';
                $settings_connectors .= '<label id="legacy-contact-label" for="snautofollow-checkbox">'. t('Your legacy GNU Social account'). '</label>';
@@ -830,7 +836,7 @@ function settings_content(&$a) {
                $settings_connectors .= '<span class="field_help">'.t('If you enter your old GNU Social/Statusnet account name here (in the format user@domain.tld), your contacts will be added automatically. The field will be emptied when done.').'</span>';
                $settings_connectors .= '</div>';
 
-               $settings_connectors .= '<p><a href="'.$a->get_baseurl().'/repair_ostatus">'.t("Repair OStatus subscriptions").'</a></p>';
+               $settings_connectors .= '<p><a href="'.App::get_baseurl().'/repair_ostatus">'.t("Repair OStatus subscriptions").'</a></p>';
 
                $settings_connectors .= '<div class="settings-submit-wrapper" ><input type="submit" name="general-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div>';
 
@@ -994,7 +1000,7 @@ function settings_content(&$a) {
                        '$ptitle'       => t('Display Settings'),
                        '$form_security_token' => get_form_security_token("settings_display"),
                        '$submit'       => t('Save Settings'),
-                       '$baseurl' => $a->get_baseurl(true),
+                       '$baseurl' => App::get_baseurl(true),
                        '$uid' => local_user(),
 
                        '$theme'        => array('theme', t('Display Theme:'), $theme_selected, '', $themes, true),
@@ -1164,13 +1170,14 @@ function settings_content(&$a) {
                ));
        }
 
-       if(strlen(get_config('system','directory'))) {
+       if (strlen(get_config('system','directory'))) {
                $profile_in_net_dir = replace_macros($opt_tpl,array(
                        '$field'        => array('profile_in_netdirectory', t('Publish your default profile in the global social directory?'), $profile['net-publish'], '', array(t('No'),t('Yes'))),
                ));
        }
-       else
+       else {
                $profile_in_net_dir = '';
+       }
 
 
        $hide_friends = replace_macros($opt_tpl,array(
@@ -1217,7 +1224,7 @@ function settings_content(&$a) {
        $tpl_addr = get_markup_template("settings_nick_set.tpl");
 
        $prof_addr = replace_macros($tpl_addr,array(
-               '$desc' => sprintf(t("Your Identity Address is <strong>'%s'</strong> or '%s'."), $nickname.'@'.$a->get_hostname().$a->get_path(), $a->get_baseurl().'/profile/'.$nickname),
+               '$desc' => sprintf(t("Your Identity Address is <strong>'%s'</strong> or '%s'."), $nickname.'@'.$a->get_hostname().$a->get_path(), App::get_baseurl().'/profile/'.$nickname),
                '$basepath' => $a->get_hostname()
        ));
 
@@ -1262,7 +1269,7 @@ function settings_content(&$a) {
                '$ptitle'       => t('Account Settings'),
 
                '$submit'       => t('Save Settings'),
-               '$baseurl' => $a->get_baseurl(true),
+               '$baseurl' => App::get_baseurl(true),
                '$uid' => local_user(),
                '$form_security_token' => get_form_security_token("settings"),
                '$nickname_block' => $prof_addr,
index 0a34c6fc50699dd1923872f78d0aae8338be6820..f2e016708fef321a74937e3c8c9be93e5ba87401 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-function share_init(&$a) {
+function share_init(App &$a) {
 
        $post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
        if((! $post_id) || (! local_user()))
index 573cf17c8a1a4f238c5cfdf77b96e51f729f613d..8e04d5d054497ef2b42cb3c742b52b9cdbaba82a 100644 (file)
@@ -6,7 +6,7 @@
 
 require_once("include/Smilies.php");
 
-function smilies_content(&$a) {
+function smilies_content(App &$a) {
        if ($a->argv[1]==="json"){
                $tmp = Smilies::get_list();
                $results = array();
index 27f924e44b5452abad9c95ca3ec655019f83b23e..0a78f51aa7ecd00d7b701f1ee4021a22ac0e5655 100644 (file)
@@ -1,25 +1,29 @@
 <?php
 
 
-function starred_init(&$a) {
+function starred_init(App &$a) {
 
        require_once("include/threads.php");
 
        $starred = 0;
 
-       if(! local_user())
+       if (! local_user()) {
                killme();
-       if($a->argc > 1)
+       }
+       if ($a->argc > 1) {
                $message_id = intval($a->argv[1]);
-       if(! $message_id)
+       }
+       if (! $message_id) {
                killme();
+       }
 
        $r = q("SELECT starred FROM item WHERE uid = %d AND id = %d LIMIT 1",
                intval(local_user()),
                intval($message_id)
        );
-       if(! dbm::is_result($r))
+       if (! dbm::is_result($r)) {
                killme();
+       }
 
        if(! intval($r[0]['starred']))
                $starred = 1;
@@ -39,7 +43,7 @@ function starred_init(&$a) {
                if(strpos($return_path, '?')) $rand = "&$rand";
                else $rand = "?$rand";
 
-               goaway($a->get_baseurl() . "/" . $return_path . $rand);
+               goaway(App::get_baseurl() . "/" . $return_path . $rand);
        }
 
        // the json doesn't really matter, it will either be 0 or 1
index 21a9a0521c63d395267bfbe60f0431936ab3e071..2f2adaafe7980c40e564bfc7e8499bae4a2e3af8 100644 (file)
@@ -5,7 +5,7 @@
 
 require_once("include/plugin.php");
 
-function statistics_json_init(&$a) {
+function statistics_json_init(App &$a) {
 
         if (!get_config("system", "nodeinfo")) {
                 http_status_exit(404);
index b15b954742af5a7dc6c749e02988434b218ae53c..958f4ba03b65bd831689d9cb4e1fba9bfd7c76b9 100644 (file)
@@ -5,7 +5,7 @@ require_once('include/bbcode.php');
 require_once('include/items.php');
 
 
-function subthread_content(&$a) {
+function subthread_content(App &$a) {
 
        if(! local_user() && ! remote_user()) {
                return;
@@ -41,8 +41,9 @@ function subthread_content(&$a) {
                        intval($item['contact-id']),
                        intval($item['uid'])
                );
-               if(! dbm::is_result($r))
+               if (! dbm::is_result($r)) {
                        return;
+               }
                if(! $r[0]['self'])
                        $remote_owner = $r[0];
        }
@@ -86,7 +87,7 @@ function subthread_content(&$a) {
 
        $post_type = (($item['resource-id']) ? t('photo') : t('status'));
        $objtype = (($item['resource-id']) ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE );
-       $link = xmlify('<link rel="alternate" type="text/html" href="' . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n") ;
+       $link = xmlify('<link rel="alternate" type="text/html" href="' . App::get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n") ;
        $body = $item['body'];
 
        $obj = <<< EOT
@@ -127,7 +128,7 @@ EOT;
 
        $ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
        $alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
-       $plink = '[url=' . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]';
+       $plink = '[url=' . App::get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]';
        $arr['body'] =  sprintf( $bodyverb, $ulink, $alink, $plink );
 
        $arr['verb'] = $activity;
index 8f4315a84146ad4446b2fa0c3d28eab191086aa0..5af337ae1b44116c717b884b22a9e9f1e93c63ad 100644 (file)
@@ -4,13 +4,14 @@ require_once('include/socgraph.php');
 require_once('include/contact_widgets.php');
 
 
-function suggest_init(&$a) {
-       if(! local_user())
+function suggest_init(App &$a) {
+       if (! local_user()) {
                return;
+       }
 
-       if(x($_GET,'ignore') && intval($_GET['ignore'])) {
+       if (x($_GET,'ignore') && intval($_GET['ignore'])) {
                // Check if we should do HTML-based delete confirmation
-               if($_REQUEST['confirm']) {
+               if ($_REQUEST['confirm']) {
                        // <form> can't take arguments in its "action" parameter
                        // so add any arguments as hidden inputs
                        $query = explode_querystring($a->query_string);
@@ -35,7 +36,7 @@ function suggest_init(&$a) {
                        return;
                }
                // Now check how the user responded to the confirmation query
-               if(!$_REQUEST['canceled']) {
+               if (!$_REQUEST['canceled']) {
                        q("INSERT INTO `gcign` ( `uid`, `gcid` ) VALUES ( %d, %d ) ",
                                intval(local_user()),
                                intval($_GET['ignore'])
@@ -49,17 +50,17 @@ function suggest_init(&$a) {
 
 
 
-function suggest_content(&$a) {
+function suggest_content(App &$a) {
 
        require_once("mod/proxy.php");
 
        $o = '';
-       if(! local_user()) {
+       if (! local_user()) {
                notice( t('Permission denied.') . EOL);
                return;
        }
 
-       $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd;
+       $_SESSION['return_url'] = App::get_baseurl() . '/' . $a->cmd;
 
        $a->page['aside'] .= findpeople_widget();
        $a->page['aside'] .= follow_widget();
@@ -67,7 +68,7 @@ function suggest_content(&$a) {
 
        $r = suggestion_query(local_user());
 
-       if(! dbm::is_result($r)) {
+       if (! dbm::is_result($r)) {
                $o .= t('No suggestions available. If this is a new site, please try again in 24 hours.');
                return $o;
        }
@@ -76,8 +77,8 @@ function suggest_content(&$a) {
 
        foreach($r as $rr) {
 
-               $connlnk = $a->get_baseurl() . '/follow/?url=' . (($rr['connect']) ? $rr['connect'] : $rr['url']);
-               $ignlnk = $a->get_baseurl() . '/suggest?ignore=' . $rr['id'];
+               $connlnk = App::get_baseurl() . '/follow/?url=' . (($rr['connect']) ? $rr['connect'] : $rr['url']);
+               $ignlnk = App::get_baseurl() . '/suggest?ignore=' . $rr['id'];
                $photo_menu = array(
                        'profile' => array(t("View Profile"), zrl($rr["url"])),
                        'follow' => array(t("Connect/Follow"), $connlnk),
index d6f421205cbfff1cb9e30eefae1bd16ebbb7ce30..b1f91d1bc403c3b78e1a6b11cde6baa02c7e81e2 100644 (file)
@@ -5,7 +5,7 @@ require_once('include/bbcode.php');
 require_once('include/items.php');
 
 
-function tagger_content(&$a) {
+function tagger_content(App &$a) {
 
        if(! local_user() && ! remote_user()) {
                return;
@@ -63,7 +63,7 @@ function tagger_content(&$a) {
        $targettype = (($item['resource-id']) ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE );
 
        $link = xmlify('<link rel="alternate" type="text/html" href="'
-               . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n") ;
+               . App::get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n") ;
 
        $body = xmlify($item['body']);
 
@@ -78,7 +78,7 @@ function tagger_content(&$a) {
        </target>
 EOT;
 
-       $tagid = $a->get_baseurl() . '/search?tag=' . $term;
+       $tagid = App::get_baseurl() . '/search?tag=' . $term;
        $objtype = ACTIVITY_OBJ_TAGTERM;
 
        $obj = <<< EOT
@@ -97,7 +97,7 @@ EOT;
        if(! isset($bodyverb))
                        return;
 
-       $termlink = html_entity_decode('&#x2317;') . '[url=' . $a->get_baseurl() . '/search?tag=' . urlencode($term) . ']'. $term . '[/url]';
+       $termlink = html_entity_decode('&#x2317;') . '[url=' . App::get_baseurl() . '/search?tag=' . urlencode($term) . ']'. $term . '[/url]';
 
        $arr = array();
 
@@ -140,7 +140,7 @@ EOT;
        $post_id = item_store($arr);
 
 //     q("UPDATE `item` set plink = '%s' where id = %d",
-//             dbesc($a->get_baseurl() . '/display/' . $owner_nick . '/' . $post_id),
+//             dbesc(App::get_baseurl() . '/display/' . $owner_nick . '/' . $post_id),
 //             intval($post_id)
 //     );
 
@@ -159,7 +159,7 @@ EOT;
         );
        if((! $blocktags) && $t[0]['tcount']==0 ) {
                /*q("update item set tag = '%s' where id = %d",
-                       dbesc($item['tag'] . (strlen($item['tag']) ? ',' : '') . '#[url=' . $a->get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/url]'),
+                       dbesc($item['tag'] . (strlen($item['tag']) ? ',' : '') . '#[url=' . App::get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/url]'),
                        intval($item['id'])
                );*/
 
@@ -168,7 +168,7 @@ EOT;
                   $term_objtype,
                   TERM_HASHTAG,
                   dbesc($term),
-                  dbesc($a->get_baseurl() . '/search?tag=' . $term),
+                  dbesc(App::get_baseurl() . '/search?tag=' . $term),
                   intval($owner_uid)
                );
        }
@@ -192,14 +192,14 @@ EOT;
                           $term_objtype,
                           TERM_HASHTAG,
                           dbesc($term),
-                          dbesc($a->get_baseurl() . '/search?tag=' . $term),
+                          dbesc(App::get_baseurl() . '/search?tag=' . $term),
                           intval($owner_uid)
                        );
                }
 
                /*if(count($x) && !$x[0]['blocktags'] && (! stristr($r[0]['tag'], ']' . $term . '['))) {
                        q("update item set tag = '%s' where id = %d",
-                               dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . '#[url=' . $a->get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/url]'),
+                               dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . '#[url=' . App::get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/url]'),
                                intval($r[0]['id'])
                        );
                }*/
index 57024b3c3b6f2127a20074849f1c8593cbddf251..8379495a2dba75016f8acb9e7f34695d0df86837 100644 (file)
@@ -2,14 +2,15 @@
 
 require_once('include/bbcode.php');
 
-function tagrm_post(&$a) {
-
-       if(! local_user())
-               goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+function tagrm_post(App &$a) {
 
+       if (! local_user()) {
+               goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']);
+       }
 
-       if((x($_POST,'submit')) && ($_POST['submit'] === t('Cancel')))
-               goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+       if ((x($_POST,'submit')) && ($_POST['submit'] === t('Cancel'))) {
+               goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']);
+       }
 
        $tag =  ((x($_POST,'tag'))  ? hex2bin(notags(trim($_POST['tag']))) : '');
        $item = ((x($_POST,'item')) ? intval($_POST['item'])               : 0 );
@@ -19,12 +20,13 @@ function tagrm_post(&$a) {
                intval(local_user())
        );
 
-       if(! dbm::is_result($r))
-               goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+       if (! dbm::is_result($r)) {
+               goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']);
+       }
 
        $arr = explode(',', $r[0]['tag']);
-       for($x = 0; $x < count($arr); $x ++) {
-               if($arr[$x] === $tag) {
+       for ($x = 0; $x < count($arr); $x ++) {
+               if ($arr[$x] === $tag) {
                        unset($arr[$x]);
                        break;
                }
@@ -39,7 +41,7 @@ function tagrm_post(&$a) {
        );
 
        info( t('Tag removed') . EOL );
-       goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+       goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']);
        
        // NOTREACHED
 
@@ -47,34 +49,35 @@ function tagrm_post(&$a) {
 
 
 
-function tagrm_content(&$a) {
+function tagrm_content(App &$a) {
 
        $o = '';
 
-       if(! local_user()) {
-               goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+       if (! local_user()) {
+               goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']);
                // NOTREACHED
        }
 
        $item = (($a->argc > 1) ? intval($a->argv[1]) : 0);
        if(! $item) {
-               goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+               goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']);
                // NOTREACHED
        }
 
-
        $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
                intval($item),
                intval(local_user())
        );
 
-       if(! dbm::is_result($r))
-               goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+       if (! dbm::is_result($r)) {
+               goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']);
+       }
 
        $arr = explode(',', $r[0]['tag']);
 
-       if(! count($arr))
-               goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+       if (! count($arr)) {
+               goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']);
+       }
 
        $o .= '<h3>' . t('Remove Item Tag') . '</h3>';
 
index 00991e44ca04da87fb8b0c8664dedd55d30cf385..89b73cd4484db62294a05c51724fee32f235f802 100644 (file)
@@ -1,16 +1,18 @@
 <?php
 
-function toggle_mobile_init(&$a) {
+function toggle_mobile_init(App &$a) {
 
-       if(isset($_GET['off']))
+       if (isset($_GET['off'])) {
                $_SESSION['show-mobile'] = false;
-       else
+       } else {
                $_SESSION['show-mobile'] = true;
+       }
 
-       if(isset($_GET['address']))
+       if (isset($_GET['address'])) {
                $address = $_GET['address'];
-       else
-               $address = $a->get_baseurl();
+       } else {
+               $address = App::get_baseurl();
+       }
 
        goaway($address);
 }
index e0a0b071f6e3636663c6f1d2e89634191e8392fe..7aa9724d5893cd3a102070c3fd2de98b040844e7 100644 (file)
@@ -1,14 +1,15 @@
 <?php
 
-function uexport_init(&$a){
-       if(! local_user())
+function uexport_init(App &$a){
+       if (! local_user()) {
                killme();
+       }
 
        require_once("mod/settings.php");
-        settings_init($a);
+       settings_init($a);
 }
 
-function uexport_content(&$a){
+function uexport_content(App &$a){
 
     if ($a->argc > 1) {
         header("Content-type: application/json");
@@ -33,7 +34,7 @@ function uexport_content(&$a){
 
     $tpl = get_markup_template("uexport.tpl");
     return replace_macros($tpl, array(
-        '$baseurl' => $a->get_baseurl(),
+        '$baseurl' => App::get_baseurl(),
         '$title' => t('Export personal data'),
         '$options' => $options
     ));
@@ -104,7 +105,7 @@ function uexport_account($a){
        $output = array(
         'version' => FRIENDICA_VERSION,
         'schema' => DB_UPDATE_VERSION,
-        'baseurl' => $a->get_baseurl(),
+        'baseurl' => App::get_baseurl(),
         'user' => $user,
         'contact' => $contact,
         'profile' => $profile,
@@ -122,7 +123,7 @@ function uexport_account($a){
 /**
  * echoes account data and items as separated json, one per line
  */
-function uexport_all(&$a) {
+function uexport_all(App &$a) {
 
        uexport_account($a);
        echo "\n";
index 7ed5648d9e2d360de0cef3b85bb885ed9a903d66..15bc8322b97fdd3337c0293580e0f64cea59101a 100644 (file)
@@ -1,11 +1,12 @@
 <?php\r
 /**\r
  * View for user import\r
+ * @TODO This file has DOS line endings!\r
  */\r
 \r
 require_once("include/uimport.php");\r
 \r
-function uimport_post(&$a) {\r
+function uimport_post(App &$a) {\r
        switch($a->config['register_policy']) {\r
         case REGISTER_OPEN:\r
             $blocked = 0;\r
@@ -35,7 +36,7 @@ function uimport_post(&$a) {
     }\r
 }\r
 \r
-function uimport_content(&$a) {\r
+function uimport_content(App &$a) {\r
        \r
        if((! local_user()) && ($a->config['register_policy'] == REGISTER_CLOSED)) {\r
                notice("Permission denied." . EOL);\r
index d5df7ba3bf7e0545e355d2d2e8febcbbf7a78e91..179e9c61c4d991fdb457803a963caf027c98022e 100644 (file)
@@ -4,7 +4,7 @@
 
 require_once("mod/community.php");
 
-function update_community_content(&$a) {
+function update_community_content(App &$a) {
 
        header("Content-type: text/html");
        echo "<!DOCTYPE html><html><body>\r\n";
index bd2a52934ff477894b5f38815662ed15be973c88..230bbaa0b460d20cdabfb28e4ce5760f7a9b8019 100644 (file)
@@ -5,7 +5,7 @@
 require_once("mod/display.php");
 require_once("include/group.php");
 
-function update_display_content(&$a) {
+function update_display_content(App &$a) {
 
        $profile_uid = intval($_GET["p"]);
 
index 258d03e3227e80b35183ab2dcc92edfd961d8bbb..c6d33132cc7557d33eae48a3681c0f8ac713efce 100644 (file)
@@ -5,7 +5,7 @@
 require_once("mod/network.php");
 require_once("include/group.php");
 
-function update_network_content(&$a) {
+function update_network_content(App &$a) {
 
        $profile_uid = intval($_GET["p"]);
 
index ee9d1d71f56a7f25fabb46e8e7ad51d3977975c4..b21f698054b9fa3d92f9bdd2ba1ae2280ff5517e 100644 (file)
@@ -7,7 +7,7 @@
 
 require_once("mod/notes.php");
 
-function update_notes_content(&$a) {
+function update_notes_content(App &$a) {
 
        $profile_uid = intval($_GET["p"]);
 
index 1bc29d82cef3f3ad4c11d82f20fe61a08d895ef0..e16b0b5cccbe58126ca678c126aaefeba60ce7f7 100644 (file)
@@ -7,7 +7,7 @@
 
 require_once("mod/profile.php");
 
-function update_profile_content(&$a) {
+function update_profile_content(App &$a) {
 
        $profile_uid = intval($_GET["p"]);
 
index 1e03c5005a6670d6b4ead8a82f060df201606c90..58c4b6c6508bb4f5adaba776da6551aa487b3c92 100644 (file)
@@ -6,7 +6,7 @@ require_once('include/security.php');
 require_once('include/redir.php');
 
 
-function videos_init(&$a) {
+function videos_init(App &$a) {
 
        if($a->argc > 1)
                auto_redir($a, $a->argv[1]);
@@ -59,7 +59,7 @@ function videos_init(&$a) {
 
                        if($albums_visible) {
                                $o .= '<div id="sidebar-photos-albums" class="widget">';
-                               $o .= '<h3>' . '<a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '">' . t('Photo Albums') . '</a></h3>';
+                               $o .= '<h3>' . '<a href="' . App::get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '">' . t('Photo Albums') . '</a></h3>';
 
                                $o .= '<ul>';
                                foreach($albums as $album) {
@@ -74,7 +74,7 @@ function videos_init(&$a) {
                                $o .= '</ul>';
                        }
                        if(local_user() && $a->data['user']['uid'] == local_user()) {
-                               $o .= '<div id="photo-albums-upload-link"><a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/upload" >' .t('Upload New Photos') . '</a></div>';
+                               $o .= '<div id="photo-albums-upload-link"><a href="' . App::get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/upload" >' .t('Upload New Photos') . '</a></div>';
                        }
 
                        $o .= '</div>';
@@ -87,12 +87,12 @@ function videos_init(&$a) {
 
                $tpl = get_markup_template("videos_head.tpl");
                $a->page['htmlhead'] .= replace_macros($tpl,array(
-                       '$baseurl' => $a->get_baseurl(),
+                       '$baseurl' => App::get_baseurl(),
                ));
 
                $tpl = get_markup_template("videos_end.tpl");
                $a->page['end'] .= replace_macros($tpl,array(
-                       '$baseurl' => $a->get_baseurl(),
+                       '$baseurl' => App::get_baseurl(),
                ));
 
        }
@@ -102,17 +102,21 @@ function videos_init(&$a) {
 
 
 
-function videos_post(&$a) {
+function videos_post(App &$a) {
 
        $owner_uid = $a->data['user']['uid'];
 
-       if (local_user() != $owner_uid) goaway($a->get_baseurl() . '/videos/' . $a->data['user']['nickname']);
+       if (local_user() != $owner_uid) {
+               goaway(App::get_baseurl() . '/videos/' . $a->data['user']['nickname']);
+       }
 
-       if(($a->argc == 2) && x($_POST,'delete') && x($_POST, 'id')) {
+       if (($a->argc == 2) && x($_POST,'delete') && x($_POST, 'id')) {
 
                // Check if we should do HTML-based delete confirmation
                if(!x($_REQUEST,'confirm')) {
-                       if(x($_REQUEST,'canceled')) goaway($a->get_baseurl() . '/videos/' . $a->data['user']['nickname']);
+                       if (x($_REQUEST,'canceled')) {
+                               goaway(App::get_baseurl() . '/videos/' . $a->data['user']['nickname']);
+                       }
 
                        $drop_url = $a->query_string;
                        $a->page['content'] = replace_macros(get_markup_template('confirm.tpl'), array(
@@ -149,8 +153,8 @@ function videos_post(&$a) {
                                dbesc($video_id),
                                intval(local_user())
                        );
-                       #echo "<pre>"; var_dump($i); killme();
-                       if(count($i)) {
+                       //echo "<pre>"; var_dump($i); killme();
+                       if (dbm::is_result($i)) {
                                q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d",
                                        dbesc(datetime_convert()),
                                        dbesc(datetime_convert()),
@@ -160,7 +164,7 @@ function videos_post(&$a) {
                                create_tags_from_itemuri($i[0]['uri'], local_user());
                                delete_thread_uri($i[0]['uri'], local_user());
 
-                               $url = $a->get_baseurl();
+                               $url = App::get_baseurl();
                                $drop_id = intval($i[0]['id']);
 
                                if($i[0]['visible'])
@@ -168,17 +172,17 @@ function videos_post(&$a) {
                        }
                }
 
-               goaway($a->get_baseurl() . '/videos/' . $a->data['user']['nickname']);
+               goaway(App::get_baseurl() . '/videos/' . $a->data['user']['nickname']);
                return; // NOTREACHED
        }
 
-    goaway($a->get_baseurl() . '/videos/' . $a->data['user']['nickname']);
+       goaway(App::get_baseurl() . '/videos/' . $a->data['user']['nickname']);
 
 }
 
 
 
-function videos_content(&$a) {
+function videos_content(App &$a) {
 
        // URLs (most aren't currently implemented):
        // videos/name
@@ -376,13 +380,13 @@ function videos_content(&$a) {
 
                        $videos[] = array(
                                'id'       => $rr['id'],
-                               'link'          => $a->get_baseurl() . '/videos/' . $a->data['user']['nickname'] . '/video/' . $rr['resource-id'],
-                               'title'         => t('View Video'),
-                               'src'           => $a->get_baseurl() . '/attach/' . $rr['id'] . '?attachment=0',
-                               'alt'           => $alt_e,
-                               'mime'          => $rr['filetype'],
-                               'album' => array(
-                                       'link'  => $a->get_baseurl() . '/videos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']),
+                               'link'     => App::get_baseurl() . '/videos/' . $a->data['user']['nickname'] . '/video/' . $rr['resource-id'],
+                               'title'    => t('View Video'),
+                               'src'      => App::get_baseurl() . '/attach/' . $rr['id'] . '?attachment=0',
+                               'alt'      => $alt_e,
+                               'mime'     => $rr['filetype'],
+                               'album' => array(
+                                       'link'  => App::get_baseurl() . '/videos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']),
                                        'name'  => $name_e,
                                        'alt'   => t('View Album'),
                                ),
@@ -393,11 +397,11 @@ function videos_content(&$a) {
 
        $tpl = get_markup_template('videos_recent.tpl');
        $o .= replace_macros($tpl, array(
-               '$title' => t('Recent Videos'),
-               '$can_post' => $can_post,
-               '$upload' => array(t('Upload New Videos'), $a->get_baseurl().'/videos/'.$a->data['user']['nickname'].'/upload'),
-               '$videos' => $videos,
-        '$delete_url' => (($can_post)?$a->get_baseurl().'/videos/'.$a->data['user']['nickname']:False)
+               '$title'      => t('Recent Videos'),
+               '$can_post'   => $can_post,
+               '$upload'     => array(t('Upload New Videos'), App::get_baseurl().'/videos/'.$a->data['user']['nickname'].'/upload'),
+               '$videos'     => $videos,
+               '$delete_url' => (($can_post)?App::get_baseurl().'/videos/'.$a->data['user']['nickname']:False)
        ));
 
 
index c9f465676cfe6da34991f3290cae8a998b0a10be..6ae458b6a21cc2a9abed43d741797deeaf659c1d 100644 (file)
@@ -2,7 +2,7 @@
 require_once('include/Contact.php');
 require_once('include/contact_selectors.php');
 
-function viewcontacts_init(&$a) {
+function viewcontacts_init(App &$a) {
 
        if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
                return;
@@ -16,8 +16,9 @@ function viewcontacts_init(&$a) {
                        dbesc($nick)
                );
 
-               if(! dbm::is_result($r))
+               if (! dbm::is_result($r)) {
                        return;
+               }
 
                $a->data['user'] = $r[0];
                $a->profile_uid = $r[0]['uid'];
@@ -28,7 +29,7 @@ function viewcontacts_init(&$a) {
 }
 
 
-function viewcontacts_content(&$a) {
+function viewcontacts_content(App &$a) {
        require_once("mod/proxy.php");
 
        if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
index 904b1442505d6f1aea9e58ae6335ea8dacb92485..8510bd539573ac72ebbd07b1636b53ad06bb61ce 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 
 
-function viewsrc_content(&$a) {
+function viewsrc_content(App &$a) {
 
-       if(! local_user()) {
+       if (! local_user()) {
                notice( t('Access denied.') . EOL);
                return;
        }
index 80fc1c6e796e71c11940e7e3f3f10f40e529f7f6..18125685450c4760929ce37f90926f69f16a4a94 100644 (file)
@@ -3,7 +3,7 @@
 require_once('include/attach.php');
 require_once('include/datetime.php');
 
-function wall_attach_post(&$a) {
+function wall_attach_post(App &$a) {
 
        $r_json = (x($_GET,'response') && $_GET['response']=='json');
 
@@ -12,7 +12,7 @@ function wall_attach_post(&$a) {
                $r = q("SELECT `user`.*, `contact`.`id` FROM `user` LEFT JOIN `contact` on `user`.`uid` = `contact`.`uid`  WHERE `user`.`nickname` = '%s' AND `user`.`blocked` = 0 and `contact`.`self` = 1 LIMIT 1",
                        dbesc($nick)
                );
-               if(! dbm::is_result($r)){
+               if (! dbm::is_result($r)) {
                        if ($r_json) {
                                echo json_encode(array('error'=>t('Invalid request.')));
                                killme();
@@ -168,7 +168,7 @@ function wall_attach_post(&$a) {
                dbesc($hash)
        );
 
-       if(! dbm::is_result($r)) {
+       if (! dbm::is_result($r)) {
                $msg = t('File upload failed.');
                if ($r_json) {
                        echo json_encode(array('error'=>$msg));
index 21d9bf49cb2de85a9218b05b7086bffe4a6d63cb..eb2a92323ab0115b489e92bb371039d02b17e0f6 100644 (file)
@@ -15,7 +15,7 @@ function wall_upload_post(&$a, $desktopmode = true) {
                                dbesc($nick)
                        );
 
-                       if(! dbm::is_result($r)){
+                       if (! dbm::is_result($r)) {
                                if ($r_json) {
                                        echo json_encode(array('error'=>t('Invalid request.')));
                                        killme();
@@ -260,9 +260,9 @@ function wall_upload_post(&$a, $desktopmode = true) {
                $picture["width"] = $r[0]["width"];
                $picture["height"] = $r[0]["height"];
                $picture["type"] = $r[0]["type"];
-               $picture["albumpage"] = $a->get_baseurl().'/photos/'.$page_owner_nick.'/image/'.$hash;
-               $picture["picture"] = $a->get_baseurl()."/photo/{$hash}-0.".$ph->getExt();
-               $picture["preview"] = $a->get_baseurl()."/photo/{$hash}-{$smallest}.".$ph->getExt();
+               $picture["albumpage"] = App::get_baseurl().'/photos/'.$page_owner_nick.'/image/'.$hash;
+               $picture["picture"] = App::get_baseurl()."/photo/{$hash}-0.".$ph->getExt();
+               $picture["preview"] = App::get_baseurl()."/photo/{$hash}-{$smallest}.".$ph->getExt();
 
                if ($r_json) {
                        echo json_encode(array('picture'=>$picture));
@@ -282,14 +282,14 @@ function wall_upload_post(&$a, $desktopmode = true) {
 //if we get the signal then return the image url info in BBCODE, otherwise this outputs the info and bails (for the ajax image uploader on wall post)
        if ($_REQUEST['hush']!='yeah') {
                if(local_user() && (! feature_enabled(local_user(),'richtext') || x($_REQUEST['nomce'])) ) {
-                       echo  "\n\n" . '[url=' . $a->get_baseurl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '][img]' . $a->get_baseurl() . "/photo/{$hash}-{$smallest}.".$ph->getExt()."[/img][/url]\n\n";
+                       echo  "\n\n" . '[url=' . App::get_baseurl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '][img]' . App::get_baseurl() . "/photo/{$hash}-{$smallest}.".$ph->getExt()."[/img][/url]\n\n";
                }
                else {
-                       echo  '<br /><br /><a href="' . $a->get_baseurl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '" ><img src="' . $a->get_baseurl() . "/photo/{$hash}-{$smallest}.".$ph->getExt()."\" alt=\"$basename\" /></a><br /><br />";
+                       echo  '<br /><br /><a href="' . App::get_baseurl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '" ><img src="' . App::get_baseurl() . "/photo/{$hash}-{$smallest}.".$ph->getExt()."\" alt=\"$basename\" /></a><br /><br />";
                }
        }
        else {
-               $m = '[url='.$a->get_baseurl().'/photos/'.$page_owner_nick.'/image/'.$hash.'][img]'.$a->get_baseurl()."/photo/{$hash}-{$smallest}.".$ph->getExt()."[/img][/url]";
+               $m = '[url='.App::get_baseurl().'/photos/'.$page_owner_nick.'/image/'.$hash.'][img]'.App::get_baseurl()."/photo/{$hash}-{$smallest}.".$ph->getExt()."[/img][/url]";
                return($m);
        }
 /* mod Waitman Gobble NO WARRANTY */
index 03a0b7a16f57e0e3aafbf3683792ea06dbb68cd6..e0c702cdb0ca45abfcb9e1cdd96e405c058325a1 100644 (file)
@@ -2,7 +2,7 @@
 
 require_once('include/message.php');
 
-function wallmessage_post(&$a) {
+function wallmessage_post(App &$a) {
 
        $replyto = get_my_url();
        if(! $replyto) {
@@ -22,7 +22,7 @@ function wallmessage_post(&$a) {
                dbesc($recipient)
        );
 
-       if(! dbm::is_result($r)) {
+       if (! dbm::is_result($r)) {
                logger('wallmessage: no recipient');
                return;
        }
@@ -73,7 +73,7 @@ function wallmessage_post(&$a) {
 }
 
 
-function wallmessage_content(&$a) {
+function wallmessage_content(App &$a) {
 
        if(! get_my_url()) {
                notice( t('Permission denied.') . EOL);
@@ -91,7 +91,7 @@ function wallmessage_content(&$a) {
                dbesc($recipient)
        );
 
-       if(! dbm::is_result($r)) {
+       if (! dbm::is_result($r)) {
                notice( t('No recipient.') . EOL);
                logger('wallmessage: no recipient');
                return;
index e1e5b367b9d2054edd878f4201bd4b47e6c3c553..f08451ba70446d380b75170c04272f721594d13e 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 require_once("include/Probe.php");
 
-function webfinger_content(&$a) {
+function webfinger_content(App &$a) {
 
        $o .= '<h3>Webfinger Diagnostic</h3>';
 
index 1250b0812c0bd754558931686e2d0ca1fae4040e..02a5d7b23c33270e48603e7bc6a7babde96f42be 100644 (file)
@@ -2,7 +2,7 @@
 
 require_once('include/crypto.php');
 
-function xrd_init(&$a) {
+function xrd_init(App &$a) {
 
        $uri = urldecode(notags(trim($_GET['uri'])));
 
@@ -21,8 +21,9 @@ function xrd_init(&$a) {
        $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' LIMIT 1",
                dbesc($name)
        );
-       if(! dbm::is_result($r))
+       if (! dbm::is_result($r)) {
                killme();
+       }
 
        $salmon_key = salmon_key($r[0]['spubkey']);
 
@@ -31,14 +32,14 @@ function xrd_init(&$a) {
 
        $tpl = get_markup_template('xrd_diaspora.tpl');
        $dspr = replace_macros($tpl,array(
-               '$baseurl' => $a->get_baseurl(),
+               '$baseurl' => App::get_baseurl(),
                '$dspr_guid' => $r[0]['guid'],
                '$dspr_key' => base64_encode(pemtorsa($r[0]['pubkey']))
        ));
 
        $tpl = get_markup_template('xrd_person.tpl');
 
-       $profile_url = $a->get_baseurl().'/profile/'.$r[0]['nickname'];
+       $profile_url = App::get_baseurl().'/profile/'.$r[0]['nickname'];
 
        if ($acct)
                $alias = $profile_url;
@@ -54,15 +55,15 @@ function xrd_init(&$a) {
                '$accturi'     => $uri,
                '$alias'       => $alias,
                '$profile_url' => $profile_url,
-               '$hcard_url'   => $a->get_baseurl() . '/hcard/'         . $r[0]['nickname'],
-               '$atom'        => $a->get_baseurl() . '/dfrn_poll/'     . $r[0]['nickname'],
-               '$zot_post'    => $a->get_baseurl() . '/post/'          . $r[0]['nickname'],
-               '$poco_url'    => $a->get_baseurl() . '/poco/'          . $r[0]['nickname'],
-               '$photo'       => $a->get_baseurl() . '/photo/profile/' . $r[0]['uid']      . '.jpg',
+               '$hcard_url'   => App::get_baseurl() . '/hcard/'         . $r[0]['nickname'],
+               '$atom'        => App::get_baseurl() . '/dfrn_poll/'     . $r[0]['nickname'],
+               '$zot_post'    => App::get_baseurl() . '/post/'          . $r[0]['nickname'],
+               '$poco_url'    => App::get_baseurl() . '/poco/'          . $r[0]['nickname'],
+               '$photo'       => App::get_baseurl() . '/photo/profile/' . $r[0]['uid']      . '.jpg',
                '$dspr'        => $dspr,
-               '$salmon'      => $a->get_baseurl() . '/salmon/'        . $r[0]['nickname'],
-               '$salmen'      => $a->get_baseurl() . '/salmon/'        . $r[0]['nickname'] . '/mention',
-               '$subscribe'   => $a->get_baseurl() . '/follow?url={uri}',
+               '$salmon'      => App::get_baseurl() . '/salmon/'        . $r[0]['nickname'],
+               '$salmen'      => App::get_baseurl() . '/salmon/'        . $r[0]['nickname'] . '/mention',
+               '$subscribe'   => App::get_baseurl() . '/follow?url={uri}',
                '$modexp'      => 'data:application/magic-public-key,'  . $salmon_key,
                '$bigkey'      =>  salmon_key($r[0]['pubkey'])
        ));
index 45d2dba3edb78c81c68823eecb1d08e312b4b8c0..d14b5418cc54469fb6df79e71998384f0e0d514a 100644 (file)
@@ -117,15 +117,19 @@ class Item extends BaseObject {
                        ? t('Private Message')
                        : false);
                $shareable = ((($conv->get_profile_owner() == local_user()) && ($item['private'] != 1)) ? true : false);
-               if(local_user() && link_compare($a->contact['url'],$item['author-link'])) {
-                       if ($item["event-id"] != 0)
+               if (local_user() && link_compare($a->contact['url'],$item['author-link'])) {
+                       if ($item["event-id"] != 0) {
                                $edpost = array("events/event/".$item['event-id'], t("Edit"));
-                       else
+                       } else {
                                $edpost = array("editpost/".$item['id'], t("Edit"));
-               } else
+                       }
+               } else {
                        $edpost = false;
-               if(($this->get_data_value('uid') == local_user()) || $this->is_visiting())
+               }
+
+               if (($this->get_data_value('uid') == local_user()) || $this->is_visiting()) {
                        $dropping = true;
+               }
 
                $drop = array(
                        'dropping' => $dropping,
@@ -143,27 +147,31 @@ class Item extends BaseObject {
 
                $sp = false;
                $profile_link = best_link_url($item,$sp);
-               if($profile_link === 'mailbox')
+               if ($profile_link === 'mailbox') {
                        $profile_link = '';
-               if($sp)
+               }
+               if ($sp) {
                        $sparkle = ' sparkle';
-               else
+               } else {
                        $profile_link = zrl($profile_link);
+               }
 
                if (!isset($item['author-thumb']) OR ($item['author-thumb'] == "")) {
                        $author_contact = get_contact_details_by_url($item['author-link'], $conv->get_profile_owner());
-                       if ($author_contact["thumb"])
+                       if ($author_contact["thumb"]) {
                                $item['author-thumb'] = $author_contact["thumb"];
-                       else
+                       } else {
                                $item['author-thumb'] = $item['author-avatar'];
+                       }
                }
 
                if (!isset($item['owner-thumb']) OR ($item['owner-thumb'] == "")) {
                        $owner_contact = get_contact_details_by_url($item['owner-link'], $conv->get_profile_owner());
-                       if ($owner_contact["thumb"])
+                       if ($owner_contact["thumb"]) {
                                $item['owner-thumb'] = $owner_contact["thumb"];
-                       else
+                       } else {
                                $item['owner-thumb'] = $item['owner-avatar'];
+                       }
                }
 
                $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => '');
index df9adbc39218f6c170934ead79ce9948b24d016e..e51b531b5ae1a7e628e6a04ca1a18be64688b3fc 100644 (file)
@@ -2,7 +2,7 @@
 <html itemscope itemtype="http://schema.org/Blog" lang="<?php echo $lang; ?>">\r
 <head>\r
   <title><?php if(x($page,'title')) echo $page['title'] ?></title>\r
-  <script>var baseurl="<?php echo $a->get_baseurl() ?>";</script>\r
+  <script>var baseurl="<?php echo App::get_baseurl() ?>";</script>\r
   <?php if(x($page,'htmlhead')) echo $page['htmlhead'] ?>\r
 </head>\r
 <body>\r
index a131e3ec5e12a99ab8f44868257a13dab7fc4e03..e93aac11258ef7665a54e551ba9b8cc67c09973c 100644 (file)
@@ -2,7 +2,7 @@
 <html>\r
 <head>\r
   <title><?php if(x($page,'title')) echo $page['title'] ?></title>\r
-  <script>var baseurl="<?php echo $a->get_baseurl() ?>";</script>\r
+  <script>var baseurl="<?php echo App::get_baseurl() ?>";</script>\r
   <?php if(x($page,'htmlhead')) echo $page['htmlhead'] ?>\r
 </head>\r
 <body>\r
index edf12c35fa10c185f073381d7dadd6db108e9133..485e4c233e0a01a35858390a1361ccf2b9348c43 100644 (file)
@@ -5,61 +5,67 @@
 
 
 
-function theme_content(&$a){
-    if(!local_user())
-        return;                
+function theme_content(App &$a){
+       if (!local_user()) {
+               return;
+       }
 
-    $colorset = get_pconfig( local_user(), 'duepuntozero', 'colorset');
-    $user = true;
+       $colorset = get_pconfig( local_user(), 'duepuntozero', 'colorset');
+       $user = true;
 
-    return clean_form($a, $colorset, $user);
+       return clean_form($a, $colorset, $user);
 }
 
-function theme_post(&$a){
-    if(! local_user())
-        return;
-    
-    if (isset($_POST['duepuntozero-settings-submit'])){
-        set_pconfig(local_user(), 'duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
-    }
+function theme_post(App &$a){
+       if (! local_user()) {
+               return;
+       }
+
+       if (isset($_POST['duepuntozero-settings-submit'])){
+               set_pconfig(local_user(), 'duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
+       }
 }
 
 
-function theme_admin(&$a){
-    $colorset = get_config( 'duepuntozero', 'colorset');
-    $user = false;
+function theme_admin(App &$a){
+       $colorset = get_config( 'duepuntozero', 'colorset');
+       $user = false;
 
-    return clean_form($a, $colorset, $user);
+       return clean_form($a, $colorset, $user);
 }
 
-function theme_admin_post(&$a){
-    if (isset($_POST['duepuntozero-settings-submit'])){
-        set_config('duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
-    }
+function theme_admin_post(App &$a){
+       if (isset($_POST['duepuntozero-settings-submit'])){
+               set_config('duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
+       }
 }
 
-
+/// @TODO $a is no longer used
 function clean_form(&$a, &$colorset, $user){
-    $colorset = array(
-       'default'=>t('default'), 
-        'greenzero'=>t('greenzero'),
-        'purplezero'=>t('purplezero'),
-        'easterbunny'=>t('easterbunny'),
-        'darkzero'=>t('darkzero'),
-        'comix'=>t('comix'),
-        'slackr'=>t('slackr'),
-    );
-    if ($user) {
-        $color = get_pconfig(local_user(), 'duepuntozero', 'colorset');
-    } else {
-        $color = get_config( 'duepuntozero', 'colorset');
-    }
-    $t = get_markup_template("theme_settings.tpl" );
-    $o .= replace_macros($t, array(
-        '$submit' => t('Submit'),
-        '$baseurl' => $a->get_baseurl(),
-        '$title' => t("Theme settings"),
-        '$colorset' => array('duepuntozero_colorset', t('Variations'), $color, '', $colorset),
-    ));
-    return $o;
+       $colorset = array(
+               'default'=>t('default'), 
+               'greenzero'=>t('greenzero'),
+               'purplezero'=>t('purplezero'),
+               'easterbunny'=>t('easterbunny'),
+               'darkzero'=>t('darkzero'),
+               'comix'=>t('comix'),
+               'slackr'=>t('slackr'),
+       );
+
+       if ($user) {
+               $color = get_pconfig(local_user(), 'duepuntozero', 'colorset');
+       } else {
+               $color = get_config( 'duepuntozero', 'colorset');
+       }
+
+       $t = get_markup_template("theme_settings.tpl" );
+       /// @TODO No need for adding string here, $o is not defined
+       $o .= replace_macros($t, array(
+               '$submit'   => t('Submit'),
+               '$baseurl'  => App::get_baseurl(),
+               '$title'=> t("Theme settings"),
+               '$colorset' => array('duepuntozero_colorset', t('Variations'), $color, '', $colorset),
+       ));
+
+       return $o;
 }
index 50d57f91e5759041f463284537ddcfcc1495ad9d..bf1d031def9367c1d5128315313fab16e1ab1c66 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-function duepuntozero_init(&$a) {
+function duepuntozero_init(App &$a) {
 
 set_template_engine($a, 'smarty3');
 
index 2e896d45f6883b4d523f5fab7d85fed516db5555..000ef26092fa43330d1dcdda24489ade8980f3f6 100644 (file)
@@ -1,8 +1,10 @@
 <?php
 require_once('view/theme/frio/php/Image.php');
 
-function theme_content(&$a) {
-       if(!local_user()) { return;}
+function theme_content(App &$a) {
+       if (!local_user()) {
+               return;
+       }
        $arr = array();
 
        $arr["schema"]          = get_pconfig(local_user(),'frio', 'schema');
@@ -17,8 +19,11 @@ function theme_content(&$a) {
        return frio_form($a, $arr);
 }
 
-function theme_post(&$a) {
-       if(!local_user()) { return;}
+function theme_post(App &$a) {
+       if (!local_user()) {
+               return;
+       }
+
        if (isset($_POST['frio-settings-submit'])) {
                set_pconfig(local_user(), 'frio', 'schema',             $_POST["frio_schema"]);
                set_pconfig(local_user(), 'frio', 'nav_bg',             $_POST["frio_nav_bg"]);
@@ -57,7 +62,7 @@ function frio_form(&$a, $arr) {
        $t = get_markup_template('theme_settings.tpl');
        $o .= replace_macros($t, array(
                '$submit'               => t('Submit'),
-               '$baseurl'              => $a->get_baseurl(),
+               '$baseurl'              => App::get_baseurl(),
                '$title'                => t("Theme settings"),
                '$schema'               => array('frio_schema',         t("Select scheme"),                     $arr["schema"], '', $scheme_choices),
                '$nav_bg'               => array_key_exists("nav_bg", $disable) ? "" : array('frio_nav_bg',             t('Navigation bar background color'),   $arr['nav_bg']),
index bfc11a35806abd10a08efef110f17b74777c6413..56118cc90e0401c0b283ed6a25ce9c6f69a3e187 100644 (file)
@@ -18,9 +18,9 @@
 <head>
        <title><?php if(x($page,'title')) echo $page['title'] ?></title>
        <meta request="<?php echo htmlspecialchars($_REQUEST['pagename']) ?> ">
-       <script>var baseurl="<?php echo $a->get_baseurl() ?>";</script>
+       <script>var baseurl="<?php echo App::get_baseurl() ?>";</script>
        <script>var frio="<?php echo "view/theme/frio"; ?>";</script>
-       <?php $baseurl = $a->get_baseurl(); ?>
+       <?php $baseurl = App::get_baseurl(); ?>
        <?php $frio = "view/theme/frio"; ?>
        <?php 
                // Because we use minimal for modals the header and the included js stuff should be only loaded
index 827874d7e1628ac60247ed14a3a30f8b122210c1..0e221f5337db55a38c6f9623128824b332a9e13d 100644 (file)
@@ -13,7 +13,7 @@
  * 
  * @todo Check if this is really needed.
  */
-function load_page(&$a) {
+function load_page(App &$a) {
        if(isset($_GET["mode"]) AND ($_GET["mode"] == "minimal")) {
                require "view/theme/frio/minimal.php";
        } elseif((isset($_GET["mode"]) AND ($_GET["mode"] == "none"))) {
index 4a92a6aecfa63efbe8ca0c755453367e5cc9c44a..491fa9d5b0df87c69b97170b39532db65259ccdc 100644 (file)
@@ -12,9 +12,9 @@
        <title><?php if(x($page,'title')) echo $page['title'] ?></title>
        <meta name="viewport" content="initial-scale=1.0">
        <meta request="<?php echo htmlspecialchars($_REQUEST['pagename']) ?> ">
-       <script>var baseurl="<?php echo $a->get_baseurl() ?>";</script>
+       <script>var baseurl="<?php echo App::get_baseurl() ?>";</script>
        <script>var frio="<?php echo "view/theme/frio"; ?>";</script>
-       <?php $baseurl = $a->get_baseurl(); ?>
+       <?php $baseurl = App::get_baseurl(); ?>
        <?php $frio = "view/theme/frio"; ?>
        <?php if(x($page,'htmlhead')) echo $page['htmlhead']; ?>
        
index 279edd64eced18f25f8f2d26b1b93908247bf4a6..664881a4a8947995ca3fe18e01496d87694f5124 100644 (file)
@@ -11,7 +11,7 @@ $frio = "view/theme/frio";
 
 global $frio;
 
-function frio_init(&$a) {
+function frio_init(App &$a) {
 
        // disable the events module link in the profile tab
        $a->theme_events_in_profile = false;
@@ -21,7 +21,7 @@ function frio_init(&$a) {
 
        set_template_engine($a, 'smarty3');
 
-       $baseurl = $a->get_baseurl();
+       $baseurl = App::get_baseurl();
 
        $style = get_pconfig(local_user(), 'frio', 'style');
 
index 332291ca9266d442839a46c4f90daf028b6e060e..d739f56f269fb14f52dc4f8b1688367aac0ae073 100644 (file)
@@ -2,7 +2,7 @@
 <html lang="<?php echo $lang; ?>">\r
 <head>\r
   <title><?php if(x($page,'title')) echo $page['title'] ?></title>\r
-  <script>var baseurl="<?php echo $a->get_baseurl() ?>";</script>\r
+  <script>var baseurl="<?php echo App::get_baseurl() ?>";</script>\r
   <?php if(x($page,'htmlhead')) echo $page['htmlhead'] ?>\r
 </head>\r
 <body <?php if($a->module === 'home') echo 'onLoad="setTimeout(\'homeRedirect()\', 1500)"'?>>\r
index 29a990f7b8604c5bbbf3af20cd9c3d8e84710be4..4ca592f4c880a5c47c1acb432133401eeaa1eaa4 100644 (file)
@@ -9,7 +9,7 @@
  * Maintainer: Zach P <techcity@f.shmuz.in>
  */
 
-function frost_mobile_init(&$a) {
+function frost_mobile_init(App &$a) {
        $a->sourcename = 'Friendica mobile web';
        $a->videowidth = 250;
        $a->videoheight = 200;
@@ -18,15 +18,17 @@ function frost_mobile_init(&$a) {
        set_template_engine($a, 'smarty3');
 }
 
-function frost_mobile_content_loaded(&$a) {
+function frost_mobile_content_loaded(App &$a) {
 
        // I could do this in style.php, but by having the CSS in a file the browser will cache it,
        // making pages load faster
-       if( $a->module === 'home' || $a->module === 'login' || $a->module === 'register' || $a->module === 'lostpass' ) {
-//             $a->page['htmlhead'] = str_replace('$stylesheet', $a->get_baseurl() . '/view/theme/frost-mobile/login-style.css', $a->page['htmlhead']);
-               $a->theme['stylesheet'] = $a->get_baseurl() . '/view/theme/frost-mobile/login-style.css';
+       if ( $a->module === 'home' || $a->module === 'login' || $a->module === 'register' || $a->module === 'lostpass' ) {
+//             $a->page['htmlhead'] = str_replace('$stylesheet', App::get_baseurl() . '/view/theme/frost-mobile/login-style.css', $a->page['htmlhead']);
+               $a->theme['stylesheet'] = App::get_baseurl() . '/view/theme/frost-mobile/login-style.css';
        }
-       if( $a->module === 'login' )
+
+       if ( $a->module === 'login' ) {
                $a->page['end'] .= '<script type="text/javascript"> $(document).ready(function() { $("#id_" + window.loginName).focus();} );</script>';
+       }
 
 }
index c67bdcf20ee8eaf86cdd5cea38a0d40d574a8ec9..0fe3404f69c97dc7d157ce3e91ebcf54766fed31 100644 (file)
@@ -2,7 +2,7 @@
 <html lang="<?php echo $lang; ?>">\r
 <head>\r
   <title><?php if(x($page,'title')) echo $page['title'] ?></title>\r
-  <script>var baseurl="<?php echo $a->get_baseurl() ?>";</script>\r
+  <script>var baseurl="<?php echo App::get_baseurl() ?>";</script>\r
   <?php if(x($page,'htmlhead')) echo $page['htmlhead'] ?>\r
 </head>\r
 <body <?php if($a->module === 'home') echo 'onLoad="setTimeout(\'homeRedirect()\', 1500)"'?>>\r
index 1093a04729c27be483097069bccd656044601849..7746109e56df657c50fec7747838ea8184f3cec5 100644 (file)
@@ -9,23 +9,25 @@
  * Maintainer: Zach P <techcity@f.shmuz.in>
  */
 
-function frost_init(&$a) {
+function frost_init(App &$a) {
        $a->videowidth = 400;
        $a->videoheight = 330;
        $a->theme_thread_allow = false;
        set_template_engine($a, 'smarty3');
 }
 
-function frost_content_loaded(&$a) {
+function frost_content_loaded(App &$a) {
 
        // I could do this in style.php, but by having the CSS in a file the browser will cache it,
        // making pages load faster
        if( $a->module === 'home' || $a->module === 'login' || $a->module === 'register' || $a->module === 'lostpass' ) {
-               //$a->page['htmlhead'] = str_replace('$stylesheet', $a->get_baseurl() . '/view/theme/frost/login-style.css', $a->page['htmlhead']);
-               $a->theme['stylesheet'] = $a->get_baseurl() . '/view/theme/frost/login-style.css';
+               //$a->page['htmlhead'] = str_replace('$stylesheet', App::get_baseurl() . '/view/theme/frost/login-style.css', $a->page['htmlhead']);
+               $a->theme['stylesheet'] = App::get_baseurl() . '/view/theme/frost/login-style.css';
        }
-       if( $a->module === 'login' )
+
+       if ( $a->module === 'login' ) {
                $a->page['end'] .= '<script type="text/javascript"> $(document).ready(function() { $("#id_" + window.loginName).focus();} );</script>';
+       }
 
 }
 
index db4356ccc887698b17a559a64355546d2cbf5031..1a5a9c02132938bb5839467b05735a8e2272c7ec 100644 (file)
@@ -5,22 +5,24 @@
 
 
 
-function theme_content(&$a){
-       if(!local_user())
-               return;         
-       
+function theme_content(App &$a){
+       if (!local_user()) {
+               return;
+       }
+
        $align = get_pconfig(local_user(), 'quattro', 'align' );
        $color = get_pconfig(local_user(), 'quattro', 'color' );
-    $tfs = get_pconfig(local_user(),"quattro","tfs");
-    $pfs = get_pconfig(local_user(),"quattro","pfs");    
-    
+       $tfs = get_pconfig(local_user(),"quattro","tfs");
+       $pfs = get_pconfig(local_user(),"quattro","pfs");
+
        return quattro_form($a,$align, $color, $tfs, $pfs);
 }
 
-function theme_post(&$a){
-       if(! local_user())
+function theme_post(App &$a){
+       if (! local_user()) {
                return;
-       
+       }
+
        if (isset($_POST['quattro-settings-submit'])){
                set_pconfig(local_user(), 'quattro', 'align', $_POST['quattro_align']);
                set_pconfig(local_user(), 'quattro', 'color', $_POST['quattro_color']);
@@ -30,7 +32,7 @@ function theme_post(&$a){
 }
 
 
-function theme_admin(&$a){
+function theme_admin(App &$a){
        $align = get_config('quattro', 'align' );
        $color = get_config('quattro', 'color' );
     $tfs = get_config("quattro","tfs");
@@ -39,7 +41,7 @@ function theme_admin(&$a){
        return quattro_form($a,$align, $color, $tfs, $pfs);
 }
 
-function theme_admin_post(&$a){
+function theme_admin_post(App &$a){
        if (isset($_POST['quattro-settings-submit'])){
                set_config('quattro', 'align', $_POST['quattro_align']);
                set_config('quattro', 'color', $_POST['quattro_color']);
@@ -48,7 +50,7 @@ function theme_admin_post(&$a){
        }
 }
 
-
+/// @TODO $a is no longer used here
 function quattro_form(&$a, $align, $color, $tfs, $pfs){
        $colors = array(
                "dark"=>"Quattro", 
@@ -62,7 +64,7 @@ function quattro_form(&$a, $align, $color, $tfs, $pfs){
        $t = get_markup_template("theme_settings.tpl" );
        $o .= replace_macros($t, array(
                '$submit' => t('Submit'),
-               '$baseurl' => $a->get_baseurl(),
+               '$baseurl' => App::get_baseurl(),
                '$title' => t("Theme settings"),
                '$align' => array('quattro_align', t('Alignment'), $align, '', array('left'=>t('Left'), 'center'=>t('Center'))),
                '$color' => array('quattro_color', t('Color scheme'), $color, '', $colors),
index 0b67c6b49a8282a023eeabd274b836f6aa1abcae..ae8f4f906594b0d73f5dcad03dd78d7af708907e 100644 (file)
@@ -7,7 +7,7 @@
  * Maintainer: Tobias <https://diekershoff.homeunix.net/friendica/profile/tobias>
  */
 
-function quattro_init(&$a) {
-       $a->page['htmlhead'] .= '<script src="'.$a->get_baseurl().'/view/theme/quattro/tinycon.min.js"></script>';
-       $a->page['htmlhead'] .= '<script src="'.$a->get_baseurl().'/view/theme/quattro/js/quattro.js"></script>';;
+function quattro_init(App &$a) {
+       $a->page['htmlhead'] .= '<script src="'.App::get_baseurl().'/view/theme/quattro/tinycon.min.js"></script>';
+       $a->page['htmlhead'] .= '<script src="'.App::get_baseurl().'/view/theme/quattro/js/quattro.js"></script>';;
 }
index 405e1cad34c4461b1f268bd1072a098ca6ad28c5..1e97c6b462e70930defe99fa1e97757616482ca6 100644 (file)
@@ -2,7 +2,7 @@
 <html>
 <head>
   <title><?php if(x($page,'title')) echo $page['title'] ?></title>
-  <script>var baseurl="<?php echo $a->get_baseurl() ?>";</script>
+  <script>var baseurl="<?php echo App::get_baseurl() ?>";</script>
   <script type="text/javascript">
        function ScrollToBottom(){
        window.scrollTo(0,document.body.scrollHeight);
index 0dae3a6e473b606a3034bf6cd4f78a1cf49fa649..32c48fffa4bf3b0d19b554861fbd31899d0ec790 100644 (file)
  * Screenshot: <a href="screenshot.png">Screenshot</a>
  */
 
-function smoothly_init(&$a) {
+function smoothly_init(App &$a) {
        set_template_engine($a, 'smarty3');
 
        $cssFile = null;
        $ssl_state = null;
-       $baseurl = $a->get_baseurl($ssl_state);
+       $baseurl = App::get_baseurl($ssl_state);
 $a->page['htmlhead'] .= <<< EOT
 
 <script>
@@ -114,7 +114,7 @@ if(! function_exists('_js_in_foot')) {
                */
                $a = get_app();
                $ssl_state = null;
-               $baseurl = $a->get_baseurl($ssl_state);
+               $baseurl = App::get_baseurl($ssl_state);
                $bottom['$baseurl'] = $baseurl;
                $tpl = get_markup_template('bottom.tpl');
 
index 7c51b4ec95be31c7af31825fc362b18ced52104c..5326498908d931bf7130db6d3ab1e6e638d1182f 100644 (file)
@@ -5,20 +5,24 @@
 
 
 
-function theme_content(&$a){
-       if(!local_user())
+function theme_content(App &$a){
+       if (!local_user()) {
                return;
+       }
 
-       if (!function_exists('get_vier_config'))
+       if (!function_exists('get_vier_config')) {
                return;
+       }
 
        $style = get_pconfig(local_user(), 'vier', 'style');
 
-       if ($style == "")
+       if ($style == "") {
                $style = get_config('vier', 'style');
+       }
 
-       if ($style == "")
+       if ($style == "") {
                $style = "plus";
+       }
 
        $show_pages = get_vier_config('show_pages', true);
        $show_profiles = get_vier_config('show_profiles', true);
@@ -31,9 +35,10 @@ function theme_content(&$a){
                        $show_services, $show_friends, $show_lastusers);
 }
 
-function theme_post(&$a){
-       if(! local_user())
+function theme_post(App &$a){
+       if (! local_user()) {
                return;
+       }
 
        if (isset($_POST['vier-settings-submit'])){
                set_pconfig(local_user(), 'vier', 'style', $_POST['vier_style']);
@@ -47,7 +52,7 @@ function theme_post(&$a){
 }
 
 
-function theme_admin(&$a){
+function theme_admin(App &$a){
 
        if (!function_exists('get_vier_config'))
                return;
@@ -76,7 +81,7 @@ function theme_admin(&$a){
        return $o;
 }
 
-function theme_admin_post(&$a){
+function theme_admin_post(App &$a){
        if (isset($_POST['vier-settings-submit'])){
                set_config('vier', 'style', $_POST['vier_style']);
                set_config('vier', 'show_pages', $_POST['vier_show_pages']);
@@ -89,7 +94,7 @@ function theme_admin_post(&$a){
        }
 }
 
-
+/// @TODO $a is no longer used
 function vier_form(&$a, $style, $show_pages, $show_profiles, $show_helpers, $show_services, $show_friends, $show_lastusers){
        $styles = array(
                "plus"=>"Plus",
@@ -105,7 +110,7 @@ function vier_form(&$a, $style, $show_pages, $show_profiles, $show_helpers, $sho
        $t = get_markup_template("theme_settings.tpl");
        $o .= replace_macros($t, array(
                '$submit' => t('Submit'),
-               '$baseurl' => $a->get_baseurl(),
+               '$baseurl' => App::get_baseurl(),
                '$title' => t("Theme settings"),
                '$style' => array('vier_style',t ('Set style'),$style,'',$styles),
                '$show_pages' => array('vier_show_pages', t('Community Pages'), $show_pages, '', $show_or_not),
index 50b292f6b7941342ffea3780874af73979fce248..46921dc1c58818316982291d00296186454a2f62 100644 (file)
@@ -13,7 +13,7 @@ require_once("include/plugin.php");
 require_once("include/socgraph.php");
 require_once("mod/proxy.php");
 
-function vier_init(&$a) {
+function vier_init(App &$a) {
 
        $a->theme_events_in_profile = false;
 
@@ -138,7 +138,7 @@ function vier_community_info() {
        $show_lastusers  = get_vier_config("show_lastusers", 1);
 
        //get_baseurl
-       $url = $a->get_baseurl($ssl_state);
+       $url = App::get_baseurl($ssl_state);
        $aside['$url'] = $url;
 
        // comunity_profiles