]> git.mxchange.org Git - friendica.git/blobdiff - mod/hovercard.php
Merge pull request #3949 from annando/further-information
[friendica.git] / mod / hovercard.php
index 65b75b32112df4ab9954fd40664d040d54b4b004..5542fe5b9837738da8f93fec7b6d525b5c4ae746 100644 (file)
@@ -8,19 +8,22 @@
  * License: GNU AFFERO GENERAL PUBLIC LICENSE (Version 3)
  */
 
-require_once("include/socgraph.php");
-require_once("include/Contact.php");
+use Friendica\App;
+use Friendica\Core\Config;
+use Friendica\Model\GlobalContact;
+use Friendica\Object\Contact;
 
-function hovercard_init(&$a) {
+function hovercard_init(App $a) {
        // Just for testing purposes
        $_GET["mode"] = "minimal";
 }
+
 function hovercard_content() {
        $profileurl     =       (x($_REQUEST,'profileurl')      ? $_REQUEST['profileurl']       : "");
        $datatype       =       (x($_REQUEST,'datatype')        ?$_REQUEST['datatype']          : "json");
 
        // Get out if the system doesn't have public access allowed
-       if(intval(get_config('system','block_public')))
+       if(intval(Config::get('system','block_public')))
                http_status_exit(401);
 
        // Return the raw content of the template. We use this to make templates usable for js functions.
@@ -36,26 +39,25 @@ function hovercard_content() {
        // If a contact is connected the url is internally changed to "redir/CID". We need the pure url to search for
        // the contact. So we strip out the contact id from the internal url and look in the contact table for
        // the real url (nurl)
-       if(local_user() && strpos($profileurl, "redir/") === 0) {
+       if (local_user() && strpos($profileurl, "redir/") === 0) {
                $cid = intval(substr($profileurl, 6));
-               $r = q("SELECT `nurl`, `self`  FROM `contact` WHERE `id` = '%d' LIMIT 1", intval($cid));
-               $profileurl = ($r[0]["nurl"] ? $r[0]["nurl"] : "");
-               $self = ($r[0]["self"] ? $r[0]["self"] : "");
+               $r = dba::select('contact', array('nurl', 'self'), array('id' => $cid), array('limit' => 1));
+               $profileurl = ($r["nurl"] ? $r["nurl"] : "");
+               $self = ($r["self"] ? $r["self"] : "");
        }
 
        // if it's the url containing https it should be converted to http
-       $nurl = normalise_link(clean_contact_url($profileurl));
+       $nurl = normalise_link(GlobalContact::cleanContactUrl($profileurl));
        if($nurl) {
                // Search for contact data
-               $contact = get_contact_details_by_url($nurl);
+               $contact = Contact::getDetailsByURL($nurl);
        }
-
        if(!is_array($contact))
                return;
 
        // Get the photo_menu - the menu if possible contact actions
        if(local_user())
-               $actions = contact_photo_menu($contact);
+               $actions = Contact::photoMenu($contact);
 
 
        // Move the contact data to the profile array so we can deliver it to
@@ -75,9 +77,9 @@ function hovercard_content() {
                'tags' => $contact["keywords"],
 //             'nsfw' => intval($contact["nsfw"]),
 //             'server_url' => $contact["server_url"],
-               'bd' => (($contact["birthday"] == "0000-00-00") ? "" : $contact["birthday"]),
+               'bd' => (($contact["birthday"] <= '0001-01-01') ? "" : $contact["birthday"]),
 //             'generation' => $contact["generation"],
-               'account_type' => account_type($contact),
+               'account_type' => Contact::getAccountType($contact),
                'actions' => $actions,
        );
        if($datatype == "html") {
@@ -96,10 +98,10 @@ function hovercard_content() {
 
 /**
  * @brief Get the raw content of a template file
- * 
+ *
  * @param string $template The name of the template
  * @param string $root Directory of the template
- * 
+ *
  * @return string|bool Output the raw content if existent, otherwise false
  */
 function get_template_content($template, $root = "") {