Sfoglia il codice sorgente

#1058 Events: add "Country" and "Country, City" items to snippet menu

Alex Trofimov 8 anni fa
parent
commit
1346cf54ef

+ 5 - 4
inc/classes/BxDolMetatags.php

@@ -611,7 +611,7 @@ class BxDolMetatags extends BxDolFactory implements iBxDolFactoryObject
      * @param $iId content id
      * @return string with links to country and city
      */
-    public function locationsString($iId, $bHTML = true)
+    public function locationsString($iId, $bHTML = true, $aParams = array())
     {
         bx_import('BxDolForm');
         $aCountries = BxDolFormQuery::getDataItems('Country');
@@ -622,16 +622,17 @@ class BxDolMetatags extends BxDolFactory implements iBxDolFactoryObject
         $s = '';
         
         $sCountryUrl = '<a href="' . BX_DOL_URL_ROOT . 'searchKeyword.php?type=location_country&keyword=' . $aLocation['country'] . '">' . $aCountries[$aLocation['country']] . '</a>';
-        if(empty($aLocation['state']) || empty($aLocation['city']))
+            
+        if(empty($aLocation['state']) || empty($aLocation['city']) || (isset($aParams['country_only']) && $aParams['country_only']))
             $s = _t('_sys_location_country', $sCountryUrl);
 
         if (!$s) {
             $sCityUrl = '<a href="' . BX_DOL_URL_ROOT . 'searchKeyword.php?type=location_country_city&keyword=' . $aLocation['country'] . '&state=' . rawurlencode($aLocation['state']) . '&city=' . rawurlencode($aLocation['city']) . '">' . $aLocation['city'] . '</a>';
             $sStateUrl = '<a href="' . BX_DOL_URL_ROOT . 'searchKeyword.php?type=location_country_state&keyword=' . $aLocation['country'] . '&state=' . rawurlencode($aLocation['state']) . '">' . $aLocation['state'] . '</a>';
 
-            if(empty($aLocation['street']) || empty($aLocation['street_number']))
+            if (empty($aLocation['street']) || empty($aLocation['street_number']) || (isset($aParams['country_city_only']) && $aParams['country_city_only']))
         	    $s = _t('_sys_location_country_city', $sCountryUrl, $sStateUrl, $sCityUrl);
-            else
+            elseif (!isset($aParams['country_city_only']) || !$aParams['country_city_only'])
                 $s = _t('_sys_location_country_city_street', $sCountryUrl, $sStateUrl, $sCityUrl, $aLocation['street'], $aLocation['street_number']);
         }
 

+ 27 - 0
modules/base/groups/classes/BxBaseModGroupsMenuSnippetMeta.php

@@ -82,6 +82,33 @@ class BxBaseModGroupsMenuSnippetMeta extends BxBaseModProfileMenuSnippetMeta
 
         return !empty($sAction) && isset($aResult[$sAction]) ? $aResult[$sAction] : $aResult;
     }
+
+    protected function _getMenuItemCountry($aItem)
+    {
+        return $this->_getMenuItemLocation($aItem, true);
+    }
+
+    protected function _getMenuItemCountryCity($aItem)
+    {
+        return $this->_getMenuItemLocation($aItem, false);
+    }
+
+    protected function _getMenuItemLocation($aItem, $bCountryOnly = false)
+    {
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
+        if(!$this->_bContentPublic || !$this->_oContentProfile || empty($CNF['OBJECT_CONNECTIONS']))
+            return false;
+
+        $oMeta = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS']);
+        if(!$oMeta)
+            return false;
+
+        if (!($sLocation = $oMeta->locationsString($this->_iContentId, false, $bCountryOnly ? array('country_only' => 1) : array('country_city_only' => 1))))
+            return false;
+
+        return $this->_oTemplate->getUnitMetaItemText($sLocation);
+    }
 }
 
 /** @} */

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

@@ -2121,6 +2121,8 @@ If it is not enabled then please consider implement this optimization, since it
     <string name="_sys_menu_item_title_sm_friends"><![CDATA[{0} friends]]></string>
     <string name="_sys_menu_item_title_sm_members"><![CDATA[{0} members]]></string>
     <string name="_sys_menu_item_title_sm_subscribers"><![CDATA[{0} followers]]></string>
+    <string name="_sys_menu_item_title_sm_country"><![CDATA[Country]]></string>
+    <string name="_sys_menu_item_title_sm_country_city"><![CDATA[Country and City]]></string>
 	<string name="_sys_menu_item_title_system_about"><![CDATA[About]]></string>
 	<string name="_sys_menu_item_title_system_privacy"><![CDATA[Privacy]]></string>
 	<string name="_sys_menu_item_title_system_switch_language"><![CDATA[Language]]></string>
@@ -2175,6 +2177,8 @@ If it is not enabled then please consider implement this optimization, since it
     <string name="_sys_menu_item_title_system_sm_members"><![CDATA[Members]]></string>
     <string name="_sys_menu_item_title_system_sm_subscribers"><![CDATA[Followers]]></string>
     <string name="_sys_menu_item_title_system_sm_unsubscribe"><![CDATA[Unfollow]]></string>
+    <string name="_sys_menu_item_title_system_sm_country"><![CDATA[Country]]></string>
+    <string name="_sys_menu_item_title_system_sm_country_city"><![CDATA[Country and City]]></string>
 	<string name="_sys_menu_set_title_account_dashboard"><![CDATA[Account Dashboard]]></string>
 	<string name="_sys_menu_set_title_account_dashboard_manage_tools"><![CDATA[Account Dashboard Manage Tools]]></string>
 	<string name="_sys_menu_set_title_account_settings"><![CDATA[Account Settings]]></string>

+ 3 - 1
modules/boonex/events/install/sql/enable.sql

@@ -290,7 +290,9 @@ INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `titl
 ('bx_events_snippet_meta', 'bx_events', 'views', '_sys_menu_item_title_system_sm_views', '_sys_menu_item_title_sm_views', '', '', '', '', '', 2147483647, 0, 0, 1, 7),
 ('bx_events_snippet_meta', 'bx_events', 'comments', '_sys_menu_item_title_system_sm_comments', '_sys_menu_item_title_sm_comments', '', '', '', '', '', 2147483647, 0, 0, 1, 8),
 ('bx_events_snippet_meta', 'bx_events', 'members', '_sys_menu_item_title_system_sm_members', '_sys_menu_item_title_sm_members', '', '', '', '', '', 2147483647, 1, 0, 1, 9),
-('bx_events_snippet_meta', 'bx_events', 'subscribers', '_sys_menu_item_title_system_sm_subscribers', '_sys_menu_item_title_sm_subscribers', '', '', '', '', '', 2147483647, 0, 0, 1, 10);
+('bx_events_snippet_meta', 'bx_events', 'subscribers', '_sys_menu_item_title_system_sm_subscribers', '_sys_menu_item_title_sm_subscribers', '', '', '', '', '', 2147483647, 0, 0, 1, 10),
+('bx_events_snippet_meta', 'bx_events', 'country', '_sys_menu_item_title_system_sm_country', '_sys_menu_item_title_sm_country', '', '', '', '', '', 2147483647, 0, 0, 1, 11),
+('bx_events_snippet_meta', 'bx_events', 'country-city', '_sys_menu_item_title_system_sm_country_city', '_sys_menu_item_title_sm_country_city', '', '', '', '', '', 2147483647, 0, 0, 1, 12);
 
 -- MENU: profile stats
 SET @iNotifMenuOrder = (SELECT IFNULL(MAX(`order`), 0) FROM `sys_menu_items` WHERE `set_name` = 'sys_profile_stats' AND `active` = 1 LIMIT 1);

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

@@ -2120,6 +2120,8 @@
     <string name="_sys_menu_item_title_sm_friends"><![CDATA[Друзья: {0}]]></string>
     <string name="_sys_menu_item_title_sm_members"><![CDATA[Участники: {0}]]></string>
     <string name="_sys_menu_item_title_sm_subscribers"><![CDATA[Подписчики: {0}]]></string>
+    <string name="_sys_menu_item_title_sm_country"><![CDATA[Страна]]></string>
+    <string name="_sys_menu_item_title_sm_country_city"><![CDATA[Страна и город]]></string>
 	<string name="_sys_menu_item_title_system_about"><![CDATA[Об...]]></string>
 	<string name="_sys_menu_item_title_system_privacy"><![CDATA[Конфиденциальность]]></string>
 	<string name="_sys_menu_item_title_system_switch_language"><![CDATA[Язык]]></string>
@@ -2171,6 +2173,8 @@
     <string name="_sys_menu_item_title_system_sm_leave"><![CDATA[Покинуть]]></string>
     <string name="_sys_menu_item_title_system_sm_subscribe"><![CDATA[Получать уведомления]]></string>
     <string name="_sys_menu_item_title_system_sm_unsubscribe"><![CDATA[Отключить уведомления]]></string>
+    <string name="_sys_menu_item_title_system_sm_country"><![CDATA[Страна]]></string>
+    <string name="_sys_menu_item_title_system_sm_country_city"><![CDATA[Страна и город]]></string>
     <string name="_sys_menu_item_title_system_sm_friends"><![CDATA[Друзья]]></string>
     <string name="_sys_menu_item_title_system_sm_members"><![CDATA[Участники]]></string>
     <string name="_sys_menu_item_title_system_sm_subscribers"><![CDATA[Подписки]]></string>