Просмотр исходного кода

#22 - profile stats block on dashboard

Alex Trofimov 12 лет назад
Родитель
Сommit
2c3020b1ed

+ 2 - 0
inc/classes/BxDol.php

@@ -55,6 +55,7 @@ interface iBxDolProfile {
     public function getAvatar();
     public function getThumb();
     public function getIcon();
+    public function getEditUrl();
     public function isActive();
 }
 
@@ -68,6 +69,7 @@ interface iBxDolProfileService {
     public function serviceProfileIcon ($iContentId);
     public function serviceProfileName ($iContentId);
     public function serviceProfileUrl ($iContentId);
+    public function serviceProfileEditUrl ($iContentId);
     public function serviceProfilesSearch ($sTerm, $iLimit);
 }
 

+ 8 - 0
inc/classes/BxDolProfile.php

@@ -203,6 +203,14 @@ class BxDolProfile extends BxDol implements iBxDolProfile {
         return BxDolService::call($aInfo['type'], 'profile_icon', array($aInfo['content_id']));
     }
 
+    /**
+     * get profile edit page url
+     */
+    public function getEditUrl($iProfileId = 0) {
+        $aInfo = $this->getInfo($iProfileId);
+        return BxDolService::call($aInfo['type'], 'profile_edit_url', array($aInfo['content_id']));
+    }
+
     /**
      * Delete profile.
      * @param $ID - optional profile id to delete

+ 7 - 0
inc/classes/BxDolProfileUndefined.php

@@ -101,6 +101,13 @@ class BxDolProfileUndefined extends BxDol implements iBxDolSingleton, iBxDolProf
         return '';
     }
 
+    /**
+     * Get profile edit url
+     */
+    public function getEditUrl() {
+        return '';
+    }
+
     /**
      * Check if profile is active
      */

+ 5 - 1
install/sql/system.sql

@@ -2796,7 +2796,8 @@ INSERT INTO `sys_objects_menu` (`object`, `title`, `set_name`, `module`, `templa
 ('sys_cmts_item_manage', '_sys_menu_title_cmts_item_manage', 'sys_cmts_item_manage', 'system', 6, 0, 1, 'BxTemplCmtsMenu', ''),
 ('sys_cmts_item_actions', '_sys_menu_title_cmts_item_actions', 'sys_cmts_item_actions', 'system', 10, 0, 1, 'BxTemplCmtsMenu', ''),
 ('sys_account_popup', '_sys_menu_title_account_popup', '', 'system', 12, 0, 1, 'BxTemplMenuAccountPopup', ''),
-('sys_account_notifications', '_sys_menu_title_account_notifications', 'sys_account_notifications', 'system', 13, 0, 1, 'BxTemplMenuAccountNotifications', '');
+('sys_account_notifications', '_sys_menu_title_account_notifications', 'sys_account_notifications', 'system', 13, 0, 1, 'BxTemplMenuAccountNotifications', ''),
+('sys_profile_stats', '_sys_menu_title_profile_stats', 'sys_profile_stats', 'system', 6, 0, 1, 'BxTemplMenuProfileStats', '');
 
 CREATE TABLE IF NOT EXISTS `sys_menu_sets` (
   `set_name` varchar(32) NOT NULL,
@@ -2816,6 +2817,7 @@ INSERT INTO `sys_menu_sets` (`set_name`, `module`, `title`, `deletable`) VALUES
 ('sys_add_content_links', 'system', '_sys_menu_set_title_add_content', 0),
 ('sys_account_settings', 'system', '_sys_menu_set_title_account_settings', 0),
 ('sys_profiles_create', 'system', '_sys_menu_set_title_profile_create_links', 0),
+('sys_profile_stats', 'system', '_sys_menu_set_title_profile_stats', 0),
 ('sys_cmts_item_manage', 'system', '_sys_menu_set_title_cmts_item_manage', 0),
 ('sys_cmts_item_actions', 'system', '_sys_menu_set_title_cmts_item_actions', 0);
 
@@ -3290,6 +3292,8 @@ INSERT INTO `sys_pages_blocks` (`object`, `cell_id`, `module`, `title`, `designb
 
 ('sys_about', 1, 'system', '_sys_page_block_title_about', 11, 2147483647, 'lang', '_sys_page_lang_block_about', 0, 1, 1),
 
+('sys_dashboard', 2, 'system', '_sys_page_block_title_profile_stats', 13, 2147483646, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:13:"profile_stats";s:6:"params";a:0:{}s:5:"class";s:20:"TemplServiceProfiles";}', 0, 1, 0),
+
 ('sys_create_account', 1, 'system', '_sys_page_block_title_create_account', 11, 2147483647, 'service', 'a:4:{s:6:\"module\";s:6:\"system\";s:6:\"method\";s:19:\"create_account_form\";s:6:\"params\";a:0:{}s:5:\"class\";s:19:\"TemplServiceAccount\";}', 0, 1, 1),
 
 ('sys_login', 1, 'system', '_sys_page_block_title_login', 11, 2147483647, 'service', 'a:3:{s:6:\"module\";s:6:\"system\";s:6:\"method\";s:10:\"login_form\";s:5:\"class\";s:17:\"TemplServiceLogin\";}', 0, 1, 1),

+ 2 - 0
modules/boonex/convos/classes/BxCnvTemplate.php

@@ -157,11 +157,13 @@ class BxCnvTemplate extends BxBaseModTextTemplate
                 'author_id' => $oProfileAuthor->id(),
                 'author_url' => $oProfileAuthor->getUrl(),
                 'author_title' => $oProfileAuthor->getDisplayName(),
+                'author_title_attr' => bx_html_attribute($oProfileAuthor->getDisplayName()),
                 'author_thumb_url' => $oProfileAuthor->getThumb(),
 
                 'last_replier_id' => $oProfileLast->id(),
                 'last_replier_url' => $oProfileLast->getUrl(),
                 'last_replier_title' => $oProfileLast->getDisplayName(),
+                'last_replier_title_attr' => bx_html_attribute($oProfileLast->getDisplayName()),
                 'last_replier_thumb_url' => $oProfileLast->getThumb(),
             );
         }

+ 2 - 0
modules/boonex/convos/install/langs/en.xml

@@ -69,6 +69,8 @@
     <string name="_bx_cnv_menu_item_title_folder_more"><![CDATA[More]]></string>
     <string name="_bx_cnv_menu_item_title_system_convos"><![CDATA[Convos]]></string>
     <string name="_bx_cnv_menu_item_title_convos"><![CDATA[Convos]]></string>
+    <string name="_bx_cnv_menu_item_title_system_unread_messages"><![CDATA[Unread messages number]]></string>
+    <string name="_bx_cnv_menu_item_title_unread_messages"><![CDATA[{addon} unread messages]]></string>
 
     <string name="_bx_cnv_txt_sample_single"><![CDATA[convo]]></string>
 

+ 6 - 0
modules/boonex/convos/install/sql/enable.sql

@@ -114,6 +114,12 @@ INSERT INTO `sys_menu_items` (`set_name`, `module`, `name`, `title_system`, `tit
 ('sys_account_notifications', 'bx_convos', 'notifications-convos', '_bx_cnv_menu_item_title_system_convos', '_bx_cnv_menu_item_title_convos', 'modules/?r=convos/folder/1', '', '', 'envelope col-red1', 'a:2:{s:6:"module";s:9:"bx_convos";s:6:"method";s:23:"get_unread_messages_num";}', '', 2147483646, 1, 0, 2);
 
 
+-- MENU: profile stats
+
+INSERT INTO `sys_menu_items` (`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `addon`, `submenu_object`, `visible_for_levels`, `active`, `copyable`, `order`) VALUES
+('sys_profile_stats', 'bx_convos', 'profile-stats-unread-messages', '_bx_cnv_menu_item_title_system_unread_messages', '_bx_cnv_menu_item_title_unread_messages', 'modules/?r=convos/folder/1', '', '', 'envelope col-red1', 'a:2:{s:6:"module";s:9:"bx_convos";s:6:"method";s:23:"get_unread_messages_num";}', '', 2147483646, 1, 0, 2);
+
+
 -- GRID
 
 INSERT INTO `sys_objects_grid` (`object`, `source_type`, `source`, `table`, `field_id`, `field_order`, `paginate_url`, `paginate_per_page`, `paginate_simple`, `paginate_get_start`, `paginate_get_per_page`, `filter_fields`, `filter_mode`, `sorting_fields`, `visible_for_levels`, `override_class_name`, `override_class_file`) VALUES

+ 1 - 1
modules/boonex/convos/template/messages_previews.html

@@ -3,7 +3,7 @@
     <div class="bx-def-font-h3 bx-def-margin-top-auto"><a href="__url__" style="font-weight:__font_weight__;">__text__</a></div>
     <div class="bx-def-margin-thd-top bx-def-font-middle bx-def-font-grayed">__desc__</div>
     <div class="bx-def-unit bx-def-margin-thd-top">
-        <a href="__last_replier_url__" title="__last_replier_title__"><img class="bx-def-icon bx-def-icon-size" src="__last_replier_thumb_url__" /></a><div class="bx-def-unit-info bx-def-thumb-size-max-height bx-def-padding-sec-left"><div class="bx-def-font-middle" style="line-height:0.9em;">__cmt_text__</div><div class="bx-def-font-grayed bx-def-font-small">__last_reply_time__</div>
+        <a href="__last_replier_url__" title="__last_replier_title_attr__"><img class="bx-def-icon bx-def-icon-size" src="__last_replier_thumb_url__" /></a><div class="bx-def-unit-info bx-def-thumb-size-max-height bx-def-padding-sec-left"><div class="bx-def-font-middle" style="line-height:0.9em;">__cmt_text__</div><div class="bx-def-font-grayed bx-def-font-small">__last_reply_time__</div>
         </div>
     </div>
 </bx_repeat:messages>

+ 4 - 0
modules/boonex/english/data/langs/system.xml

@@ -1720,6 +1720,7 @@ If it is not enabled then please consider implement this optimization, since it
 	<string name="_sys_menu_set_title_cmts_item_manage"><![CDATA[Manage Comment]]></string>
 	<string name="_sys_menu_set_title_footer"><![CDATA[Footer]]></string>
 	<string name="_sys_menu_set_title_profile_create_links"><![CDATA[Create Profile Links]]></string>
+	<string name="_sys_menu_set_title_profile_stats"><![CDATA[Profile Stats]]></string>
 	<string name="_sys_menu_set_title_site"><![CDATA[Site]]></string>
 	<string name="_sys_menu_set_title_toolbar_member"><![CDATA[Toolbar Member]]></string>
 	<string name="_sys_menu_set_title_toolbar_site"><![CDATA[Toolbar Site]]></string>
@@ -1745,6 +1746,7 @@ If it is not enabled then please consider implement this optimization, since it
 	<string name="_sys_menu_title_footer"><![CDATA[Footer Links]]></string>
 	<string name="_sys_menu_title_main"><![CDATA[Site Navigation]]></string>
 	<string name="_sys_menu_title_profiles_create"><![CDATA[Create Profiles]]></string>
+	<string name="_sys_menu_title_profile_stats"><![CDATA[Profile Stats]]></string>
 	<string name="_sys_menu_title_rss"><![CDATA[RSS]]></string>
 	<string name="_sys_menu_title_submenu"><![CDATA[Site Submenu]]></string>
 	<string name="_sys_menu_title_toolbar_member"><![CDATA[Member Toolbar]]></string>
@@ -1772,6 +1774,7 @@ If it is not enabled then please consider implement this optimization, since it
 	<string name="_sys_page_block_title_dashboard"><![CDATA[Dashboard]]></string>
 	<string name="_sys_page_block_title_forgot_password"><![CDATA[Forgot Password]]></string>
 	<string name="_sys_page_block_title_login"><![CDATA[Sign in]]></string>
+	<string name="_sys_page_block_title_profile_stats"><![CDATA[Profile stats]]></string>
 	<string name="_sys_page_block_title_unsubscribe_news"><![CDATA[Unsubscribe From Site Newsletters]]></string>
 	<string name="_sys_page_block_title_unsubscribe_notifications"><![CDATA[Unsubscribe From Site Notifications]]></string>
 	<string name="_sys_page_lang_block_about"><![CDATA[This site is powered by BoonEx Dolphin. The rest is a mystery.]]></string>
@@ -1912,6 +1915,7 @@ If it is not enabled then please consider implement this optimization, since it
 	<string name="_sys_uploader_simple_submit_button"><![CDATA[Upload]]></string>
 	<string name="_sys_uploader_simple_title"><![CDATA[Simple Upload]]></string>
 	<string name="_sys_uploader_upload_canceled"><![CDATA[Too bad. Upload canceled.]]></string>
+	<string name="_sys_edit_profile"><![CDATA[Edit profile]]></string>
 	<string name="_sys_x_days"><![CDATA[{0} days]]></string>
 	<string name="_tags_by_day"><![CDATA[Tags By Day: ]]></string>
 	<string name="_tags_caption_keyword"><![CDATA[Keyword]]></string>

+ 5 - 0
modules/boonex/persons/classes/BxPersonsModule.php

@@ -46,6 +46,11 @@ class BxPersonsModule extends BxDolModule implements iBxDolProfileService {
         return $this->_serviceTemplateFunc('urlAvatar', $iContentId);
     }
 
+    public function serviceProfileEditUrl ($iContentId) {
+        bx_import('BxDolPermalinks');
+        return BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=edit-persons-profile&id=' . $iContentId);
+    }
+
     public function serviceProfileThumb ($iContentId) {
         return $this->_serviceTemplateFunc('thumb', $iContentId);
     }

+ 2 - 0
modules/boonex/persons/install/langs/en.xml

@@ -102,6 +102,8 @@
     <string name="_bx_persons_menu_item_title_more_actions"><![CDATA[]]></string>
     <string name="_bx_persons_menu_item_title_system_friends"><![CDATA[Friends]]></string>
     <string name="_bx_persons_menu_item_title_friends"><![CDATA[Friends]]></string>
+    <string name="_bx_persons_menu_item_title_system_friend_requests"><![CDATA[Friend requests number]]></string>
+    <string name="_bx_persons_menu_item_title_friend_requests"><![CDATA[{addon} friend requests]]></string>
 
     <string name="_bx_persons_txt_account_pending"><![CDATA[This profile is pending approval, please wait until it is activated.]]></string>
     <string name="_bx_persons_txt_account_suspended"><![CDATA[This profile is suspended.]]></string>

+ 6 - 0
modules/boonex/persons/install/sql/enable.sql

@@ -182,6 +182,12 @@ INSERT INTO `sys_menu_items` (`set_name`, `module`, `name`, `title_system`, `tit
 ('sys_account_notifications', 'bx_persons', 'notifications-friend-requests', '_bx_persons_menu_item_title_system_friends', '_bx_persons_menu_item_title_friends', 'page.php?i=persons-profile-friends&profile_id={member_id}', '', '', 'group col-blue3', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:31:"get_unconfirmed_connections_num";s:6:"params";a:1:{i:0;s:20:"sys_profiles_friends";}s:5:"class";s:23:"TemplServiceConnections";}', '', 2147483646, 1, 0, IFNULL(@iAddMenuOrder, 0) + 1);
 
 
+-- profile stats
+SET @iNotifMenuOrder = (SELECT `order` FROM `sys_menu_items` WHERE `set_name` = 'sys_account_notifications' AND `active` = 1 ORDER BY `order` DESC LIMIT 1);
+INSERT INTO `sys_menu_items` (`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `addon`, `submenu_object`, `visible_for_levels`, `active`, `copyable`, `order`) VALUES
+('sys_profile_stats', 'bx_persons', 'profile-stats-friend-requests', '_bx_persons_menu_item_title_system_friend_requests', '_bx_persons_menu_item_title_friend_requests', 'page.php?i=persons-profile-friends&profile_id={member_id}', '', '', 'group col-blue3', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:31:"get_unconfirmed_connections_num";s:6:"params";a:1:{i:0;s:20:"sys_profiles_friends";}s:5:"class";s:23:"TemplServiceConnections";}', '', 2147483646, 1, 0, IFNULL(@iAddMenuOrder, 0) + 1);
+
+
 -- ACL
 
 INSERT INTO `sys_acl_actions` (`Module`, `Name`, `AdditionalParamName`, `Title`, `Desc`, `Countable`, `DisabledForLevels`) VALUES

+ 23 - 0
modules/boonex/uni/data/template/system/scripts/BxTemplMenuProfileStats.php

@@ -0,0 +1,23 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    DolphinCore Dolphin Core
+ * @{
+ */
+
+bx_import('BxBaseMenuProfileStats');
+
+/**
+ * @see BxDolMenu
+ */
+class BxTemplMenuProfileStats extends BxBaseMenuProfileStats 
+{
+    public function __construct ($aObject, $oTemplate = false) 
+    {
+        parent::__construct ($aObject, $oTemplate);
+    }
+}
+
+/** @} */

+ 7 - 0
template/profile_stats.html

@@ -0,0 +1,7 @@
+
+    <div class="bx-def-unit bx-def-margin-bottom">
+        <a href="__profile_url__" title="__profile_title_attr__"><img class="bx-def-ava bx-def-ava-size" src="__profile_ava_url__" /></a><div class="bx-def-unit-info bx-def-ava-size-max-height bx-def-padding-left"><div class="bx-def-font-h2 bx-def-margin-sec-bottom">__profile_title__</div><a href="__profile_edit_url__"><bx_text:_sys_edit_profile /></a></div>
+    </div>
+
+    __menu__
+

+ 5 - 1
template/scripts/BxBaseMenu.php

@@ -76,6 +76,11 @@ class BxBaseMenu extends BxDolMenu {
 
             $a = $this->_replaceMarkers($a);
 
+            $mixedAddon = $this->_getMenuAddon($a);
+            $this->addMarkers(array('addon' => $mixedAddon));
+
+            $a = $this->_replaceMarkers($a);
+
             list ($sIcon, $sIconUrl) = $this->_getMenuIcon($a);
 
             $a['class_add'] = $this->_isSelected($a) ? 'bx-menu-tab-active' : '';
@@ -94,7 +99,6 @@ class BxBaseMenu extends BxDolMenu {
                 'content' => array('title' => $a['title']), 
             );
 
-            $mixedAddon = $this->_getMenuAddon($a);
             $a['bx_if:addon'] = array (
                 'condition' => (bool)$mixedAddon,
                 'content' => array('addon' => $mixedAddon), 

+ 24 - 0
template/scripts/BxBaseMenuProfileStats.php

@@ -0,0 +1,24 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    DolphinCore Dolphin Core
+ * @{
+ */
+
+bx_import('BxTemplMenu');
+
+/**
+ * Menu representation.
+ * @see BxDolMenu
+ */
+class BxBaseMenuProfileStats extends BxTemplMenu
+{
+    public function __construct ($aObject, $oTemplate)
+    {
+        parent::__construct ($aObject, $oTemplate);
+    }
+}
+
+/** @} */

+ 25 - 0
template/scripts/BxBaseServiceProfiles.php

@@ -17,6 +17,31 @@ class BxBaseServiceProfiles extends BxDol
         parent::__construct();
     }
 
+    public function serviceProfileStats ($iProfileId = 0) 
+    {
+        if (!$iProfileId)
+            $iProfileId = bx_get_logged_profile_id();
+
+        bx_import('BxDolMenu');
+        $oMenu = BxDolMenu::getObjectInstance('sys_profile_stats');
+
+        bx_import('BxDolProfile');
+        $oProfile = BxDolProfile::getInstance($iProfileId);
+ 
+        $aVars = array(
+            'profile_id' => $oProfile->id(),
+            'profile_url' => $oProfile->getUrl(),
+            'profile_edit_url' => $oProfile->getEditUrl(),
+            'profile_title' => $oProfile->getDisplayName(),
+            'profile_title_attr' => bx_html_attribute($oProfile->getDisplayName()),
+            'profile_ava_url' => $oProfile->getAvatar(),
+            'menu' => $oMenu->getCode(),
+        );
+
+        $oTemplate = BxDolTemplate::getInstance();
+        return $oTemplate->parseHtmlByName('profile_stats.html', $aVars);
+    }
+
     public function serviceProfileNotifications ($iProfileId = 0) 
     {
         if (!$iProfileId)

+ 5 - 0
template/scripts/BxBaseServices.php

@@ -27,6 +27,11 @@ class BxBaseServices extends BxDol implements iBxDolProfileService {
         return $this->_serviceProfileFunc('getAvatar', $iContentId);
     }
 
+    public function serviceProfileEditUrl ($iContentId) {
+        bx_import('BxDolPermalinks');
+        return BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=account-settings-info');
+    }
+
     public function serviceProfileThumb ($iContentId) {
         return $this->_serviceProfileFunc('getThumb', $iContentId);
     }