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

#264 Meta keywords aren't parsing and parsing not properly

Alex Trofimov 10 лет назад
Родитель
Сommit
0456d7d6f0

+ 5 - 4
inc/classes/BxDolMetatags.php

@@ -232,14 +232,15 @@ class BxDolMetatags extends BxDol implements iBxDolFactoryObject
     public function keywordsAdd($iId, $s) 
     {
         $a = array();
-        if (!preg_match_all('/(\#[\pL\pN]+)/u', strip_tags($s), $a)) {
+        if (!preg_match_all('/[^&](\#[\pL\pN]+)/u', strip_tags($s), $a)) {
             $this->_oQuery->keywordsDelete($iId);
             return 0;
         }
 
-        $a[0] = array_unique($a[0]);
+        $aTags = array_unique($a[1]);
+        $aTags = array_slice($aTags, 0, BX_METATAGS_KEYWORDS_MAX);
 
-        return $this->_oQuery->keywordsAdd($iId, array_slice($a[0], 0, BX_METATAGS_KEYWORDS_MAX));
+        return $this->_oQuery->keywordsAdd($iId, $aTags);
     }
 
     /**
@@ -310,7 +311,7 @@ class BxDolMetatags extends BxDol implements iBxDolFactoryObject
         $a = $this->keywordsGet($iId);
         if (empty($a))
             return $s;
-    
+
         foreach ($a as $sKeyword)
             $s = str_ireplace('#' . $sKeyword, '<a rel="tag" href="' . BX_DOL_URL_ROOT . 'searchKeyword.php?type=keyword&keyword=' . rawurlencode($sKeyword) . '"><s>#</s><b>' . $sKeyword . '</b></a>', $s);
 

+ 5 - 1
modules/base/general/classes/BxBaseModGeneralFormsEntryHelper.php

@@ -254,11 +254,13 @@ class BxBaseModGeneralFormsEntryHelper extends BxDolProfileForms
 
     public function onDataEditAfter ($iContentId, $aContentInfo, $aTrackTextFieldsChanges, $oProfile)
     {
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
         if (!empty($CNF['OBJECT_METATAGS'])) { // && isset($aTrackTextFieldsChanges['changed_fields'][$CNF['FIELD_TEXT']])) { // TODO: check if aTrackTextFieldsChanges works 
             list ($oProfile, $aContentInfo) = $this->_getProfileAndContentData($iContentId);
             $oMetatags = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS']);
             if ($oMetatags->keywordsIsEnabled())
-                $oMetatags->keywordsAddAuto($aContentInfo[$CNF['FIELD_ID']], $aContentInfo, $CNF, $sDisplay);
+                $oMetatags->keywordsAddAuto($aContentInfo[$CNF['FIELD_ID']], $aContentInfo, $CNF, $CNF['OBJECT_FORM_ENTRY_DISPLAY_VIEW']);
             if ($oMetatags->locationsIsEnabled())
                 $oMetatags->locationsAddFromForm($aContentInfo[$CNF['FIELD_ID']], empty($CNF['FIELD_LOCATION_PREFIX']) ? '' : $CNF['FIELD_LOCATION_PREFIX']);
         }
@@ -268,6 +270,8 @@ class BxBaseModGeneralFormsEntryHelper extends BxDolProfileForms
 
     public function onDataAddAfter ($iAccountId, $iContentId)
     {
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
         if (!empty($CNF['OBJECT_METATAGS'])) {
             list ($oProfile, $aContentInfo) = $this->_getProfileAndContentData($iContentId);
             $oMetatags = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS']);