]> git.mxchange.org Git - friendica.git/blobdiff - view/theme/diabook/theme.php
Merge remote branch 'friendica/master'
[friendica.git] / view / theme / diabook / theme.php
index c0ca82b41c96bbcf6d08ecc9b5df434ebc257c70..050c2a0b4c1d2c56b205b1bd3812e7bc8f7695d2 100644 (file)
@@ -7,8 +7,6 @@
  * Author:
  */
 
-$a = get_app();
-
 function get_diabook_config($key, $default = false) {
        if (local_user()) {
                $result = get_pconfig(local_user(), "diabook", $key);
@@ -25,6 +23,8 @@ function get_diabook_config($key, $default = false) {
 
 function diabook_init(&$a) {
 
+set_template_engine($a, 'smarty3');
+
 //print diabook-version for debugging
 $diabook_version = "Diabook (Version: 1.027)";
 $a->page['htmlhead'] .= sprintf('<META NAME=generator CONTENT="%s"/>', $diabook_version);
@@ -37,6 +37,7 @@ load_config("diabook");
 load_pconfig(local_user(), "diabook");
 
 //get statuses of boxes at right-hand-column
+$close_pages      = get_diabook_config( "close_pages", 1 );
 $close_profiles   = get_diabook_config( "close_profiles", 0 );
 $close_helpers    = get_diabook_config( "close_helpers", 0 );
 $close_services   = get_diabook_config( "close_services", 0 );
@@ -168,10 +169,10 @@ if ($color=="dark") $color_path = "/diabook-dark/";
        $a->page['htmlhead'] .= '
        <script>
         $(function() {
-               $("a.lightbox").fancybox(); // Select all links with lightbox class
-               $("a#twittersettings-link").fancybox({onClosed: function() { $("#twittersettings").attr("style","display: none;");}} );
-          $("a#mapcontrol-link").fancybox({onClosed: function() { $("#mapcontrol").attr("style","display: none;");}} );
-          $("a#closeicon").fancybox({onClosed: function() { $("#boxsettings").attr("style","display: none;");}} );
+               $("a.lightbox").colorbox({maxHeight:"90%"}); // Select all links with lightbox class
+               $("a#twittersettings-link").colorbox({inline:true,onClosed: function() { $("#twittersettings").attr("style","display: none;");}} );
+               $("a#mapcontrol-link").colorbox({inline:true,onClosed: function() { $("#mapcontrol").attr("style","display: none;");}} );
+               $("a#closeicon").colorbox({inline:true,onClosed: function() { $("#boxsettings").attr("style","display: none;");}} );
                });
 
         $(window).load(function() {
@@ -296,6 +297,11 @@ if ($color=="dark") $color_path = "/diabook-dark/";
        <script>
        $("right_aside").ready(function(){
 
+       if('.$close_pages.')
+               {
+               document.getElementById( "close_pages" ).style.display = "none";
+                       };
+
        if('.$close_mapquery.')
                {
                document.getElementById( "close_mapquery" ).style.display = "none";
@@ -362,6 +368,7 @@ if ($color=="dark") $color_path = "/diabook-dark/";
  function diabook_community_info() {
        $a = get_app();
 
+       $close_pages      = get_diabook_config( "close_pages", 1 );
        $close_profiles   = get_diabook_config( "close_profiles", 0 );
        $close_helpers    = get_diabook_config( "close_helpers", 0 );
        $close_services   = get_diabook_config( "close_services", 0 );
@@ -378,16 +385,16 @@ if ($color=="dark") $color_path = "/diabook-dark/";
        $aside['$comunity_profiles_items'] = array();
        $r = q("select gcontact.* from gcontact left join glink on glink.gcid = gcontact.id
                          where glink.cid = 0 and glink.uid = 0 order by rand() limit 9");
-       $tpl = file_get_contents( dirname(__file__).'/ch_directory_item.tpl');
+       $tpl = get_markup_template('ch_directory_item.tpl');
        if(count($r)) {
                $photo = 'photo';
                foreach($r as $rr) {
                        $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
                        $entry = replace_macros($tpl,array(
                                '$id' => $rr['id'],
-                               '$profile-link' => zrl($rr['url']),
+                               '$profile_link' => zrl($rr['url']),
                                '$photo' => $rr[$photo],
-                               '$alt-text' => $rr['name'],
+                               '$alt_text' => $rr['name'],
                        ));
                        $aside['$comunity_profiles_items'][] = $entry;
                }
@@ -407,16 +414,16 @@ if ($color=="dark") $color_path = "/diabook-dark/";
                0,
                9
        );
-       $tpl = file_get_contents( dirname(__file__).'/ch_directory_item.tpl');
+       $tpl = get_markup_template('ch_directory_item.tpl');
        if(count($r)) {
                $photo = 'thumb';
                foreach($r as $rr) {
                        $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
                        $entry = replace_macros($tpl,array(
                                '$id' => $rr['id'],
-                               '$profile-link' => $profile_link,
+                               '$profile_link' => $profile_link,
                                '$photo' => $a->get_cached_avatar_image($rr[$photo]),
-                               '$alt-text' => $rr['name'],
+                               '$alt_text' => $rr['name'],
                        ));
                        $aside['$lastusers_items'][] = $entry;
                }
@@ -486,16 +493,16 @@ if ($color=="dark") $color_path = "/diabook-dark/";
                                dbesc(t('Profile Photos'))
                                );
                if(count($r)) {
-               $tpl = file_get_contents( dirname(__file__).'/ch_directory_item.tpl');
+               $tpl = get_markup_template('ch_directory_item.tpl');
                foreach($r as $rr) {
                        $photo_page = $a->get_baseurl() . '/photos/' . $rr['nickname'] . '/image/' . $rr['resource-id'];
                        $photo_url = $a->get_baseurl() . '/photo/' .  $rr['resource-id'] . '-' . $rr['scale'] .'.jpg';
 
                        $entry = replace_macros($tpl,array(
                                '$id' => $rr['id'],
-                               '$profile-link' => $photo_page,
+                               '$profile_link' => $photo_page,
                                '$photo' => $photo_url,
-                               '$alt-text' => $rr['username']." : ".$rr['desc'],
+                               '$alt_text' => $rr['username']." : ".$rr['desc'],
                        ));
 
                        $aside['$photos_items'][] = $entry;
@@ -523,6 +530,40 @@ if ($color=="dark") $color_path = "/diabook-dark/";
        $aside['$nv'] = $nv;
        }}
 
+   //Community_Pages at right_aside
+   if($close_pages != "1") {
+   if(local_user()) {
+   $page = '
+                       <h3 style="margin-top:0px;">'.t("Community Pages").'<a id="closeicon" href="#boxsettings" onClick="open_boxsettings(); return false;" style="text-decoration:none;" class="icon close_box" title="'.t("Settings").'"></a></h3>
+                       <div id=""><ul style="margin-left: 7px;margin-top: 0px;padding-left: 0px;padding-top: 0px;">';
+
+       $pagelist = array();
+
+       $contacts = q("SELECT `id`, `url`, `name`, `micro`FROM `contact`
+                       WHERE `network`= 'dfrn' AND `forum` = 1 AND `uid` = %d
+                       ORDER BY `name` ASC",
+                       intval($a->user['uid'])
+       );
+
+       $pageD = array();
+
+       // Look if the profile is a community page
+       foreach($contacts as $contact) {
+               $pageD[] = array("url"=>$contact["url"], "name"=>$contact["name"], "id"=>$contact["id"], "micro"=>$contact['micro']);
+       };
+
+
+       $contacts = $pageD;
+
+       foreach($contacts as $contact) {
+               $page .= '<li style="list-style-type: none;" class="tool"><img height="20" width="20" style="float: left; margin-right: 3px;" src="' . $contact['micro'] .'" alt="' . $contact['url'] . '" /> <a href="'.$a->get_baseurl().'/redir/'.$contact["id"].'" style="margin-top: 2px; word-wrap: break-word; width: 132px;" title="' . $contact['url'] . '" class="label" target="external-link">'.
+                               $contact["name"]."</a></li>";
+       }
+       $page .= '</ul></div>';
+       //if (sizeof($contacts) > 0)
+               $aside['$page'] = $page;
+       }}
+  //END Community Page
 
    //mapquery
 
@@ -575,6 +616,7 @@ if ($color=="dark") $color_path = "/diabook-dark/";
        }
    //end twitter
    if($ccCookie != "10") {
+       $close_pages      = get_diabook_config( "close_pages", 1 );
        $close_profiles   = get_diabook_config( "close_profiles", 0 );
        $close_helpers    = get_diabook_config( "close_helpers", 0 );
        $close_services   = get_diabook_config( "close_services", 0 );
@@ -587,6 +629,7 @@ if ($color=="dark") $color_path = "/diabook-dark/";
        $close_or_not = array('1'=>t("don't show"),     '0'=>t("show"),);
        $boxsettings['title'] = Array("", t('Show/hide boxes at right-hand column:'), "", "");
        $aside['$boxsettings'] = $boxsettings;
+       $aside['$close_pages'] = array('diabook_close_pages', t('Community Pages'), $close_pages, '', $close_or_not);
        $aside['$close_mapquery'] = array('diabook_close_mapquery', t('Earth Layers'), $close_mapquery, '', $close_or_not);
        $aside['$close_profiles'] = array('diabook_close_profiles', t('Community Profiles'), $close_profiles, '', $close_or_not);
        $aside['$close_helpers'] = array('diabook_close_helpers', t('Help or @NewHere ?'), $close_helpers, '', $close_or_not);
@@ -600,6 +643,7 @@ if ($color=="dark") $color_path = "/diabook-dark/";
    $baseurl = $a->get_baseurl($ssl_state);
    $aside['$baseurl'] = $baseurl;
    if (isset($_POST['diabook-settings-box-sub']) && $_POST['diabook-settings-box-sub']!=''){
+               set_pconfig(local_user(), 'diabook', 'close_pages', $_POST['diabook_close_pages']);
                set_pconfig(local_user(), 'diabook', 'close_mapquery', $_POST['diabook_close_mapquery']);
                set_pconfig(local_user(), 'diabook', 'close_profiles', $_POST['diabook_close_profiles']);
                set_pconfig(local_user(), 'diabook', 'close_helpers', $_POST['diabook_close_helpers']);
@@ -611,13 +655,15 @@ if ($color=="dark") $color_path = "/diabook-dark/";
                set_pconfig(local_user(), 'diabook', 'close_lastlikes', $_POST['diabook_close_lastlikes']);
                }
        }
-   $close = t('Settings');
-   $aside['$close'] = $close;
-   //get_baseurl
-   $url = $a->get_baseurl($ssl_state);
-   $aside['$url'] = $url;
+       $close = t('Settings');
+       $aside['$close'] = $close;
+
+       //get_baseurl
+       $url = $a->get_baseurl($ssl_state);
+       $aside['$url'] = $url;
+
        //print right_aside
-       $tpl = file_get_contents(dirname(__file__).'/communityhome.tpl');
+       $tpl = get_markup_template('communityhome.tpl');
        $a->page['right_aside'] = replace_macros($tpl, $aside);
 
  }
@@ -628,7 +674,7 @@ if ($color=="dark") $color_path = "/diabook-dark/";
        $a = get_app();
        $baseurl = $a->get_baseurl($ssl_state);
        $bottom['$baseurl'] = $baseurl;
-       $tpl = file_get_contents(dirname(__file__) . '/bottom.tpl');
+       $tpl = get_markup_template('bottom.tpl');
        $a->page['footer'] = $a->page['footer'].replace_macros($tpl, $bottom);
  }