Kaynağa Gözat

#1048 use @mention tags in HTML enabled editors, implementation in Posts and Comments

Alex Trofimov 8 yıl önce
ebeveyn
işleme
13863fe0c8

+ 1 - 1
inc/classes/BxDolCmts.php

@@ -1283,7 +1283,7 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
 
         if ($this->_sMetatagsObj && $iCmtId) {
             $oMetatags = BxDolMetatags::getObjectInstance($this->_sMetatagsObj);
-            $s = $oMetatags->keywordsParse($this->_oQuery->getUniqId($this->_aSystem['system_id'], $iCmtId), $s);
+            $s = $oMetatags->metaParse($this->_oQuery->getUniqId($this->_aSystem['system_id'], $iCmtId), $s);
         }
 
         return $s;

+ 216 - 26
inc/classes/BxDolMetatags.php

@@ -8,10 +8,8 @@
  */
 
 define('BX_METATAGS_KEYWORDS_MAX', 9);
+define('BX_METATAGS_MENTIONS_MAX', 9);
 
-// TODO: client side controls: some js to help to enter \@mentions and \#keywords(optional)
-// TODO: integrate to comments, try to integrate to one metatags object - maybe specify metatags object in comments object and make appropriate changes in comments, 
-//       comments content should be treated as main conetent and main content should be shown in search results
 // TODO: integration with notifications, when smbd is \@mentioned
 
 /**
@@ -66,10 +64,10 @@ define('BX_METATAGS_KEYWORDS_MAX', 9);
  *   echo $oMetatags->locationsString($iContentId)
  * @endcode
  *
- * Upon page display call BxDolMetatags::metaAdd to add location (and all other, including content image) meta information to the page header:
+ * Upon page display call BxDolMetatags::addPageMetaInfo to add location (and all other, including content image) meta information to the page header:
  * @code
  *   $o = BxDolMetatags::getObjectInstance('object_name');
- *   $o->metaAdd($iContentId, array('id' => $iFileId, 'object' => 'storage_object_name'));
+ *   $o->addPageMetaInfo($iContentId, array('id' => $iFileId, 'object' => 'storage_object_name'));
  * @endcode
  * 
  * Form object must have location field, usual name for this field is 'location' (this name is used as $sPrefix in some functions), type is 'custom', 
@@ -91,7 +89,7 @@ define('BX_METATAGS_KEYWORDS_MAX', 9);
  *   $sText = $oMetatags->keywordsParse($iContentId, $sText);
  * @endcode
  *
- * Upon page display call BxDolMetatags::metaAdd to add keywords (and all other, including content image) meta information to the page header.
+ * Upon page display call BxDolMetatags::addPageMetaInfo to add keywords (and all other, including content image) meta information to the page header.
  *
  * To be able to search by tags metatgs object must be specified in *SearchResult class as 'object_metatags' in 'aCurrent' array.
  *
@@ -168,7 +166,7 @@ class BxDolMetatags extends BxDolFactory implements iBxDolFactoryObject
      * Add all available meta tags to the head section 
      * @return number of successfully added metas
      */
-    public function metaAdd($iId, $mixedImage = false)
+    public function addPageMetaInfo($iId, $mixedImage = false)
     {
         $i = 0;
         foreach ($this->_aMetas as $sMeta) {
@@ -192,7 +190,58 @@ class BxDolMetatags extends BxDolFactory implements iBxDolFactoryObject
         return $i;
     }
 
+    /**
+     * Perform @see keywordsParse @see mentionsParse and maybe other
+     * @param $iId content id
+     * @param $s string
+     * @return modified string
+     */    
+    public function metaParse($iId, $s)
+    {
+        foreach ($this->_aMetas as $sMeta) {
+            $sFunc = $sMeta . 'Parse';
+            if (method_exists($this, $sFunc))
+                $s = $this->$sFunc($iId, $s);
+        }
+        return $s;
+    }
+
+    /**
+     * Perform @see keywordsAddAuto @see mentionsAddAuto and maybe other
+     * @param $iId content id
+     * @param $aContentInfo content info array
+     * @param $CNF module config array
+     * @param $sFormDisplay form display object
+     * @return number of founded keywords, mentions, etc
+     */
+    public function metaAddAuto($iId, $aContentInfo, $CNF, $sFormDisplay) 
+    {
+        $i = 0;
+        foreach ($this->_aMetas as $sMeta) {
+            $sFunc = $sMeta . 'AddAuto';
+            if (method_exists($this, $sFunc))
+                $i += $this->$sFunc($iId, $aContentInfo, $CNF, $sFormDisplay);
+        }
+        return $i;
+    }
 
+    /**
+     * Perform @see keywordsAdd @see mentionsAdd and maybe other
+     * @param $iId content id
+     * @param $s string
+     * @return number of added keywords, mentions, etc
+     */
+    public function metaAdd($iId, $s)
+    {
+        $i = 0;
+        foreach ($this->_aMetas as $sMeta) {
+            $sFunc = $sMeta . 'Add';
+            if (method_exists($this, $sFunc))
+                $i += $this->$sFunc($iId, $s);
+        }
+        return $i;
+    }
+    
     /**
      * Checks if keywords enabled for current metatags object
      */
@@ -227,16 +276,7 @@ class BxDolMetatags extends BxDolFactory implements iBxDolFactoryObject
      */
     public function keywordsAdd($iId, $s) 
     {
-        $a = array();
-        if (!preg_match_all('/[\s](\#[\pL\pN_]+)/u', ' ' . strip_tags($s), $a)) {
-            $this->_oQuery->keywordsDelete($iId);
-            return 0;
-        }
-
-        $aTags = array_unique($a[1]);
-        $aTags = array_slice($aTags, 0, BX_METATAGS_KEYWORDS_MAX);
-
-        return $this->_oQuery->keywordsAdd($iId, $aTags);
+        return $this->_metaAdd($iId, ' ' . strip_tags($s), '/[\s]\#([\pL\pN_]+)/u', 'keywordsDelete', 'keywordsAdd', BX_METATAGS_KEYWORDS_MAX);
     }
 
     /**
@@ -256,12 +296,14 @@ class BxDolMetatags extends BxDolFactory implements iBxDolFactoryObject
     /**
      * Add \#keywords from the content fields
      * @param $iId content id
-     * @param $s string with \#keywords
+     * @param $aContentInfo content info array
+     * @param $CNF module config array
+     * @param $sFormDisplay form display object
      * @return number of found keywords
      */
     public function keywordsAddAuto($iId, $aContentInfo, $CNF, $sFormDisplay) 
     {
-        $aFields = $this->keywordsFields($aContentInfo, $CNF, $sFormDisplay); 
+        $aFields = $this->metaFields($aContentInfo, $CNF, $sFormDisplay); 
         $sTextWithKeywords = '';
         foreach ($aFields as $sField)
             $sTextWithKeywords .= "\n" . $aContentInfo[$sField];
@@ -272,7 +314,7 @@ class BxDolMetatags extends BxDolFactory implements iBxDolFactoryObject
     /**
      * Get field names which are subject to parse keywords
      */
-    public function keywordsFields($aContentInfo, $CNF, $sFormDisplay)
+    public function metaFields($aContentInfo, $CNF, $sFormDisplay, $bHtmlOnly = false)
     {
         $aFields = array();
         if (empty($CNF['FIELDS_WITH_KEYWORDS'])) {
@@ -283,7 +325,7 @@ class BxDolMetatags extends BxDolFactory implements iBxDolFactoryObject
                 return array();
 
             foreach ($oForm->aInputs as $k => $a) {
-                if ('textarea' == $a['type'])
+                if ('textarea' == $a['type'] && (!$bHtmlOnly || ($bHtmlOnly && $a['html'])))
                     $aFields[] = $a['name'];
             }
         } 
@@ -357,8 +399,16 @@ class BxDolMetatags extends BxDolFactory implements iBxDolFactoryObject
      * @param $oSearchResult search results object
      * @param $sKeyword keyword
      */
-    public function keywordsSetSearchCondition($oSearchResult, $sKeyword)
+    public function keywordsSetSearchCondition($oSearchResult, $sKeyword, $iCmtsSystemId = 0)
     {
+        if (!$this->keywordsIsEnabled())
+            return;
+
+        if ('sys_cmts' == $oSearchResult->aCurrent['object_metatags']) {
+            $this->keywordsSetSearchConditionCmts($oSearchResult, $sKeyword, $iCmtsSystemId);
+            return;
+        }
+
         $oSearchResult->aCurrent['restriction']['meta_keyword'] = array(
             'value' => $sKeyword,
             'field' => 'keyword',
@@ -376,6 +426,46 @@ class BxDolMetatags extends BxDolFactory implements iBxDolFactoryObject
         );
     }
 
+    public function keywordsSetSearchConditionCmts($oSearchResult, $sKeyword, $iCmtsSystemId = 0)
+    {
+        if (!$this->keywordsIsEnabled())
+            return;
+
+        if ($iCmtsSystemId) {
+            $oSearchResult->aCurrent['restriction']['meta_keyword_cmts_system'] = array(
+                'value' => $iCmtsSystemId,
+                'field' => 'system_id',
+                'operator' => '=',
+                'table' => 'sys_cmts_ids',
+            );
+        }
+        
+        $oSearchResult->aCurrent['restriction']['meta_keyword'] = array(
+            'value' => $sKeyword,
+            'field' => 'keyword',
+            'operator' => '=',
+            'table' => $this->_aObject['table_keywords'],
+        );
+
+        $oSearchResult->aCurrent['join']['meta_keyword_cmts'] = array(
+            'type' => 'INNER',
+            'table' => 'sys_cmts_ids',
+            'mainField' => $oSearchResult->aCurrent['ident'],
+            'mainTable' => !empty($oSearchResult->aCurrent['tableSearch']) ? $oSearchResult->aCurrent['tableSearch'] : $oSearchResult->aCurrent['table'],
+            'onField' => 'cmt_id',
+            'joinFields' => array(),
+        );
+        
+        $oSearchResult->aCurrent['join']['meta_keyword'] = array(
+            'type' => 'INNER',
+            'table' => $this->_aObject['table_keywords'],
+            'mainField' => 'id',
+            'mainTable' => 'sys_cmts_ids',
+            'onField' => 'object_id',
+            'joinFields' => array(),
+        );
+    }
+    
 	/**
      * Get part of SQL query for meta keyword
      * @param $sContentTable content table or alias
@@ -647,9 +737,27 @@ class BxDolMetatags extends BxDolFactory implements iBxDolFactoryObject
      */
     public function mentionsAdd($iId, $s) 
     {
-        // TODO:        
+        return $this->_metaAdd($iId, $s, '/data\-profile\-id="(\d+)"/u', 'mentionsDelete', 'mentionsAdd', BX_METATAGS_MENTIONS_MAX);
     }
 
+    /**
+     * Add \@mentions from the content of form fields
+     * @param $iId content id
+     * @param $aContentInfo content info array
+     * @param $CNF module config array
+     * @param $sFormDisplay form display object
+     * @return number of found keywords
+     */
+    public function mentionsAddAuto($iId, $aContentInfo, $CNF, $sFormDisplay) 
+    {
+        $aFields = $this->metaFields($aContentInfo, $CNF, $sFormDisplay, true); 
+        $sTextWithKeywords = '';
+        foreach ($aFields as $sField)
+            $sTextWithKeywords .= "\n" . $aContentInfo[$sField];
+
+        return $this->mentionsAdd($iId, $sTextWithKeywords);
+    }
+    
     /**
      * Add links to the \@mentions in the string (actual tranformation may have to be performed with ready links like <a data-mention="bx_persons|123">mention name</a>)
      * @param $iId content id
@@ -658,7 +766,7 @@ class BxDolMetatags extends BxDolFactory implements iBxDolFactoryObject
      */
     public function mentionsParse($iId, $s) 
     {
-        // TODO:
+        return $s;
     }
 
     /**
@@ -674,11 +782,73 @@ class BxDolMetatags extends BxDolFactory implements iBxDolFactoryObject
      * @param $oSearchResult search results object
      * @param $sMention smbd
      */
-    public function mentionsSetSearchCondition($oSearchResult, $sMention)
+    public function mentionsSetSearchCondition($oSearchResult, $iProfileId, $iCmtsSystemId = 0)
     {
-        // TODO:
+        if (!$this->mentionsIsEnabled())
+            return;
+
+        if ('sys_cmts' == $oSearchResult->aCurrent['object_metatags']) {
+            $this->mentionsSetSearchConditionCmts($oSearchResult, $iProfileId, $iCmtsSystemId);
+            return;
+        }
+
+        $oSearchResult->aCurrent['restriction']['meta_mentions'] = array(
+            'value' => $iProfileId,
+            'field' => 'profile_id',
+            'operator' => '=',
+            'table' => $this->_aObject['table_mentions'],
+        );
+
+        $oSearchResult->aCurrent['join']['meta_mentions'] = array(
+            'type' => 'INNER',
+            'table' => $this->_aObject['table_mentions'],
+            'mainField' => $oSearchResult->aCurrent['ident'],
+            'mainTable' => !empty($oSearchResult->aCurrent['tableSearch']) ? $oSearchResult->aCurrent['tableSearch'] : $oSearchResult->aCurrent['table'],
+            'onField' => 'object_id',
+            'joinFields' => array(),
+        );
     }
 
+    public function mentionsSetSearchConditionCmts($oSearchResult, $iProfileId, $iCmtsSystemId = 0)
+    {
+        if (!$this->keywordsIsEnabled())
+            return;
+
+        if ($iCmtsSystemId) {
+            $oSearchResult->aCurrent['restriction']['meta_mentions_cmts_system'] = array(
+                'value' => $iCmtsSystemId,
+                'field' => 'system_id',
+                'operator' => '=',
+                'table' => 'sys_cmts_ids',
+            );
+        }
+        
+        $oSearchResult->aCurrent['restriction']['meta_mentions'] = array(
+            'value' => $iProfileId,
+            'field' => 'profile_id',
+            'operator' => '=',
+            'table' => $this->_aObject['table_mentions'],
+        );
+
+        $oSearchResult->aCurrent['join']['meta_mentions_cmts'] = array(
+            'type' => 'INNER',
+            'table' => 'sys_cmts_ids',
+            'mainField' => $oSearchResult->aCurrent['ident'],
+            'mainTable' => !empty($oSearchResult->aCurrent['tableSearch']) ? $oSearchResult->aCurrent['tableSearch'] : $oSearchResult->aCurrent['table'],
+            'onField' => 'cmt_id',
+            'joinFields' => array(),
+        );
+        
+        $oSearchResult->aCurrent['join']['meta_mentions'] = array(
+            'type' => 'INNER',
+            'table' => $this->_aObject['table_mentions'],
+            'mainField' => 'id',
+            'mainTable' => 'sys_cmts_ids',
+            'onField' => 'object_id',
+            'joinFields' => array(),
+        );
+    }
+    
     /**
      * Delete all data associated with the content
      * @param $iId content id
@@ -693,6 +863,26 @@ class BxDolMetatags extends BxDolFactory implements iBxDolFactoryObject
         return $i;
     }
 
+    protected function _metaAdd($iId, $s, $sPreg, $sFuncDelete, $sFuncAdd, $iMaxItems, $sAlertName)
+    {
+        $a = array();
+        if (!preg_match_all($sPreg, $s, $a)) {
+            $this->_oQuery->$sFuncDelete($iId);
+            return 0;
+        }
+
+        $aMetas = array_unique($a[1]);
+        $aMetas = array_slice($aMetas, 0, $iMaxItems);
+
+        if ($iRet = $this->_oQuery->$sFuncAdd($iId, $aMetas)) {
+            foreach ($aMetas as $sMeta) {
+                bx_alert($this->_sObject, $sAlertName . '_add', $iId, bx_get_logged_profile_id(), array('meta' => $sMeta));
+                bx_alert('meta_' . $sAlertName, 'add', $iId, bx_get_logged_profile_id(), array('meta' => $sMeta));
+            }
+        }
+
+        return $iRet;
+    }
 }
 
 /** @} */

+ 23 - 10
inc/classes/BxDolMetatagsQuery.php

@@ -32,19 +32,19 @@ class BxDolMetatagsQuery extends BxDolDb
         return $aObject;
     }
 
+    public function mentionsAdd($mixedContentId, $aMentions, $bDeletePrevious = true)
+    {
+        return $this->metaAdd($mixedContentId, $aMentions, $bDeletePrevious, 'mentionsDelete', $this->_aObject['table_mentions'], 'profile_id');
+    }
 
-
+    public function mentionsDelete($mixedContentId)
+    {
+        return $this->metaDelete($this->_aObject['table_mentions'], $mixedContentId);
+    }
+    
     public function keywordsAdd($mixedContentId, $aKeywords, $bDeletePreviousKeywords = true)
     {
-        if ($bDeletePreviousKeywords)
-            $this->keywordsDelete($mixedContentId);
-
-        $i = 0;
-        foreach ($aKeywords as $sKeyword) {
-            $sQuery = $this->prepare("INSERT INTO `{$this->_aObject['table_keywords']}` SET `object_id` = ?, `keyword` = ?", $mixedContentId, trim($sKeyword, '#'));
-            $i += ($this->query($sQuery) ? 1 : 0);
-        }
-        return $i;
+        return $this->metaAdd($mixedContentId, $aKeywords, $bDeletePreviousKeywords, 'keywordsDelete', $this->_aObject['table_keywords'], 'keyword');
     }
 
     public function keywordsDelete($mixedContentId)
@@ -127,6 +127,19 @@ class BxDolMetatagsQuery extends BxDolDb
         $sQuery = $this->prepare("DELETE FROM `{$sTable}` WHERE `object_id` = ?", $mixedContentId);
         return $this->query($sQuery);
     }
+
+    protected function metaAdd($mixedContentId, $aMetas, $bDeletePrevious, $sFuncDelete, $sTable, $sField)
+    {
+        if ($bDeletePrevious)
+            $this->$sFuncDelete($mixedContentId);
+
+        $i = 0;
+        foreach ($aMetas as $sMeta) {
+            $sQuery = $this->prepare("INSERT INTO `{$sTable}` SET `object_id` = ?, `{$sField}` = ?", $mixedContentId, $sMeta);
+            $i += ($this->query($sQuery) ? 1 : 0);
+        }
+        return $i;
+    }
 }
 
 /** @} */

+ 30 - 4
inc/classes/BxDolSearch.php

@@ -92,7 +92,9 @@ class BxDolSearch extends BxDol
 	                require_once(BX_DIRECTORY_PATH_ROOT . $aValue['file']);
 	        }
 
-            $oEx = new $sClassName();
+            $oEx = new $sClassName();            
+            if ($this->_sMetaType && !$oEx->isMetaEnabled($this->_sMetaType))
+                continue;
             $oEx->setId($aValue['id']);
             $oEx->setLiveSearch($this->_bLiveSearch);
             $oEx->setMetaType($this->_sMetaType);
@@ -131,7 +133,7 @@ class BxDolSearch extends BxDol
         if (in_array($s, $aMetaTypes))
             $this->_sMetaType = $s;
     }
-
+    
     public function setCategoryObject($s)
     {
         $this->_sCategoryObject = $s;
@@ -309,6 +311,28 @@ class BxDolSearchResult implements iBxDolReplaceable
         $this->_sMetaType = $s;
     }
 
+    public function isMetaEnabled($s)
+    {
+        if (empty($this->aCurrent['object_metatags']))
+            return false;
+            
+        if (!($o = BxDolMetatags::getObjectInstance($this->aCurrent['object_metatags'])))
+            return false;
+
+        switch ($s) {
+            case 'location_country_city':
+            case 'location_country_state':            
+            case 'location_country':
+                return $o->locationsIsEnabled();
+            case 'mention':
+                return $o->mentionsIsEnabled();
+            case 'keyword':
+                return $o->keywordsIsEnabled();
+        }
+
+        return false;
+    }
+    
     public function setCategoryObject($s)
     {
         $this->_sCategoryObject = $s;
@@ -628,10 +652,12 @@ class BxDolSearchResult implements iBxDolReplaceable
                         $o->locationsSetSearchCondition($this, $sKeyword, bx_process_input(bx_get('state')), bx_process_input(bx_get('city')));
                         break;
                     case 'mention':
-                        // TODO:
+                        $oCmts = !empty($this->sModuleObjectComments) ? BxDolCmts::getObjectInstance($this->sModuleObjectComments, 0, false) : false;
+                        $o->mentionsSetSearchCondition($this, $sKeyword, $oCmts ? $oCmts->getSystemId() : 0);
                         break;
                     case 'keyword':
-                        $o->keywordsSetSearchCondition($this, $sKeyword);
+                        $oCmts = !empty($this->sModuleObjectComments) ? BxDolCmts::getObjectInstance($this->sModuleObjectComments, 0, false) : false;
+                        $o->keywordsSetSearchCondition($this, $sKeyword, $oCmts ? $oCmts->getSystemId() : 0);
                         break;
                 }
             }

+ 1 - 0
inc/utils.inc.php

@@ -546,6 +546,7 @@ function clear_xss($val)
 		        'src' => 'URI',
 		        'type' => 'Text',
             ));
+            $def->addAttribute('a', 'data-profile-id', 'Number');
 		}
 
         $oHtmlPurifier = new HTMLPurifier($oConfig);

Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 0
install/sql/system.sql


+ 3 - 2
modules/base/general/classes/BxBaseModGeneralCmtsSearchResult.php

@@ -23,7 +23,8 @@ class BxBaseModGeneralCmtsSearchResult extends BxBaseModGeneralSearchResult
 
         $this->aCurrent = array(
         	'name' => $this->oModule->_oConfig->getName() . '_cmts',
-        	'module_name' => $this->oModule->_oConfig->getName(),
+            'module_name' => $this->oModule->_oConfig->getName(),
+            'object_metatags' => 'sys_cmts',
         	'title' => '',
             'table' => $this->oModule->_oConfig->getDbPrefix() . 'cmts',
             'ownFields' => array('cmt_id', 'cmt_object_id', 'cmt_author_id', 'cmt_text', 'cmt_time'),
@@ -57,7 +58,7 @@ class BxBaseModGeneralCmtsSearchResult extends BxBaseModGeneralSearchResult
 			));
 		}
 		else
-			return $oCmts->getComment($aData['id'], array(), array('type' => BX_CMT_DISPLAY_FLAT, 'view_only' => true));
+			return $oCmts->getComment($aData['cmt_id'], array(), array('type' => BX_CMT_DISPLAY_FLAT, 'view_only' => true));
     }
 
     function displayResultBlock ()

+ 1 - 1
modules/base/general/classes/BxBaseModGeneralFormEntry.php

@@ -264,7 +264,7 @@ class BxBaseModGeneralFormEntry extends BxTemplFormView
         $s = parent::genViewRowValue($aInput);
 
         if ($this->_oMetatagsObject && in_array($aInput['name'], $this->_aMetatagsFieldsWithKeywords) && $s)
-            $s = $this->_oMetatagsObject->keywordsParse($this->_oMetatagsContentId, $s);
+            $s = $this->_oMetatagsObject->metaParse($this->_oMetatagsContentId, $s);
 
         return $s;
     }

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

@@ -340,7 +340,7 @@ class BxBaseModGeneralFormsEntryHelper extends BxDolProfileForms
         if (!empty($CNF['OBJECT_METATAGS'])) {
             $oMetatags = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS']);
             if ($oMetatags->keywordsIsEnabled()) {
-                $aFields = $oMetatags->keywordsFields($aContentInfo, $CNF, $CNF['OBJECT_FORM_ENTRY_DISPLAY_VIEW']);
+                $aFields = $oMetatags->metaFields($aContentInfo, $CNF, $CNF['OBJECT_FORM_ENTRY_DISPLAY_VIEW']);
                 $oForm->setMetatagsKeywordsData($iContentId, $aFields, $oMetatags);
             }
         }        
@@ -374,8 +374,7 @@ class BxBaseModGeneralFormsEntryHelper extends BxDolProfileForms
         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, $CNF['OBJECT_FORM_ENTRY_DISPLAY_EDIT']);
+            $oMetatags->metaAddAuto($aContentInfo[$CNF['FIELD_ID']], $aContentInfo, $CNF, $CNF['OBJECT_FORM_ENTRY_DISPLAY_EDIT']);
             if (isset($CNF['FIELD_LOCATION_PREFIX']) && isset($oForm->aInputs[$CNF['FIELD_LOCATION_PREFIX']]) && $oMetatags->locationsIsEnabled())
                 $oMetatags->locationsAddFromForm($aContentInfo[$CNF['FIELD_ID']], empty($CNF['FIELD_LOCATION_PREFIX']) ? '' : $CNF['FIELD_LOCATION_PREFIX']);
         }
@@ -397,8 +396,8 @@ class BxBaseModGeneralFormsEntryHelper extends BxDolProfileForms
         if (!empty($CNF['OBJECT_METATAGS'])) {
             list ($oProfile, $aContentInfo) = $this->_getProfileAndContentData($iContentId);
             $oMetatags = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS']);
-            if ($oMetatags->keywordsIsEnabled() && $aContentInfo)
-                $oMetatags->keywordsAddAuto($aContentInfo[$CNF['FIELD_ID']], $aContentInfo, $CNF, $CNF['OBJECT_FORM_ENTRY_DISPLAY_ADD']);
+            if ($aContentInfo)
+                $oMetatags->metaAddAuto($aContentInfo[$CNF['FIELD_ID']], $aContentInfo, $CNF, $CNF['OBJECT_FORM_ENTRY_DISPLAY_ADD']);
             if ($oMetatags->locationsIsEnabled() && $aContentInfo)
                 $oMetatags->locationsAddFromForm($aContentInfo[$CNF['FIELD_ID']], $CNF['FIELD_LOCATION_PREFIX']);
         }

+ 1 - 1
modules/base/general/classes/BxBaseModGeneralPageEntry.php

@@ -73,7 +73,7 @@ class BxBaseModGeneralPageEntry extends BxTemplPage
         if (!empty($CNF['OBJECT_METATAGS']) && $mixedThumb) {
             $o = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS']);
             if ($o)
-                $o->metaAdd($this->_aContentInfo[$CNF['FIELD_ID']], $mixedThumb);
+                $o->addPageMetaInfo($this->_aContentInfo[$CNF['FIELD_ID']], $mixedThumb);
         }
 
         $oMenuSubmenu = BxDolMenu::getObjectInstance('sys_site_submenu');

+ 8 - 1
modules/base/general/classes/BxBaseModGeneralTemplate.php

@@ -88,11 +88,18 @@ class BxBaseModGeneralTemplate extends BxDolModuleTemplate
 
             // keywords
             if ($oMetatags->keywordsIsEnabled()) {
-                $aFields = array_merge($oMetatags->keywordsFields($aData, $CNF, $CNF['OBJECT_FORM_ENTRY_DISPLAY_VIEW']), array('entry_title', 'entry_text'));
+                $aFields = array_merge($oMetatags->metaFields($aData, $CNF, $CNF['OBJECT_FORM_ENTRY_DISPLAY_VIEW']), array('entry_title', 'entry_text'));
                 foreach ($aFields as $sField)
                     $aVars[$sField] = $oMetatags->keywordsParse($aData[$CNF['FIELD_ID']], $aVars[$sField]);
             }
 
+            // mentions
+            if ($oMetatags->mentionsIsEnabled()) {
+                $aFields = array_merge($oMetatags->metaFields($aData, $CNF, $CNF['OBJECT_FORM_ENTRY_DISPLAY_VIEW'], true), array('entry_text'));
+                foreach ($aFields as $sField)
+                    $aVars[$sField] = $oMetatags->mentionsParse($aData[$CNF['FIELD_ID']], $aVars[$sField]);
+            }
+            
             // location
             $aVars['location'] = $oMetatags->locationsIsEnabled() ? $oMetatags->locationsString($aData[$CNF['FIELD_ID']]) : '';
         }

+ 2 - 1
modules/base/profile/classes/BxBaseModProfileModule.php

@@ -165,7 +165,8 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
 
             $aRet[] = array (
             	'label' => $this->serviceProfileName($r['content_id']), 
-            	'value' => $r['profile_id'], 
+                'value' => $r['profile_id'], 
+                'url' => $oProfile->getUrl(),
             	'thumb' => $oProfile->getThumb(),
                 'unit' => $oProfile->getUnit(0, array('template' => 'unit_wo_info'))
             );

+ 1 - 4
modules/base/text/classes/BxBaseModTextTemplate.php

@@ -141,10 +141,7 @@ class BxBaseModTextTemplate extends BxBaseModGeneralTemplate
 
         if(!empty($CNF['OBJECT_METATAGS'])) {
             $oMetatags = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS']);
-    
-            // keywords
-            if ($oMetatags->keywordsIsEnabled())
-                $sText = $oMetatags->keywordsParse($aData[$CNF['FIELD_ID']], $sText);
+            $sText = $oMetatags->metaParse($aData[$CNF['FIELD_ID']], $sText);
         }
 
         $sTitle = bx_process_output($sTitle);

+ 1 - 1
modules/boonex/albums/classes/BxAlbumsPageMedia.php

@@ -91,7 +91,7 @@ class BxAlbumsPageMedia extends BxTemplPage
         if (!empty($CNF['OBJECT_METATAGS_MEDIA'])) {
             $o = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS_MEDIA']);
             if ($o) {
-                $o->metaAdd($this->_aMediaInfo['id'], $aThumb);
+                $o->addPageMetaInfo($this->_aMediaInfo['id'], $aThumb);
             }
         }
 

+ 1 - 1
modules/boonex/posts/install/sql/enable.sql

@@ -350,7 +350,7 @@ INSERT INTO `sys_objects_search` (`ObjectName`, `Title`, `Order`, `ClassName`, `
 
 -- METATAGS
 INSERT INTO `sys_objects_metatags` (`object`, `table_keywords`, `table_locations`, `table_mentions`, `override_class_name`, `override_class_file`) VALUES
-('bx_posts', 'bx_posts_meta_keywords', 'bx_posts_meta_locations', '', '', '');
+('bx_posts', 'bx_posts_meta_keywords', 'bx_posts_meta_locations', 'bx_posts_meta_mentions', '', '');
 
 -- CATEGORY
 INSERT INTO `sys_objects_category` (`object`, `search_object`, `form_object`, `list_name`, `table`, `field`, `join`, `where`, `override_class_name`, `override_class_file`) VALUES

+ 7 - 0
modules/boonex/posts/install/sql/install.sql

@@ -113,6 +113,13 @@ CREATE TABLE `bx_posts_meta_keywords` (
   KEY `keyword` (`keyword`)
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
 
+CREATE TABLE `bx_posts_meta_mentions` (
+  `object_id` int(10) unsigned NOT NULL,
+  `profile_id` int(10) unsigned NOT NULL,
+  KEY `object_id` (`object_id`),
+  KEY `profile_id` (`profile_id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
 CREATE TABLE `bx_posts_meta_locations` (
   `object_id` int(10) unsigned NOT NULL,
   `lat` double NOT NULL,

+ 1 - 1
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -1361,7 +1361,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
             if(!empty($iId)) {
             	$oMetatags = BxDolMetatags::getObjectInstance($this->_oConfig->getObject('metatags'));
             	if($bText)
- 					$oMetatags->keywordsAdd($iId, $sText);
+ 					$oMetatags->metaAdd($iId, $sText);
  				$oMetatags->locationsAddFromForm($iId, $this->_oConfig->CNF['FIELD_LOCATION_PREFIX']);
 
 				//--- Process Link ---//

+ 2 - 2
modules/boonex/timeline/classes/BxTimelineTemplate.php

@@ -163,7 +163,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
 
         $oMetatags = BxDolMetatags::getObjectInstance($this->_oConfig->getObject('metatags'));
         if($oMetatags)
-            $oMetatags->metaAdd($aEvent[$CNF['FIELD_ID']]);
+            $oMetatags->addPageMetaInfo($aEvent[$CNF['FIELD_ID']]);
 
         $sReferrer = '';
         if(isset($_SERVER['HTTP_REFERER']) && mb_stripos($_SERVER['HTTP_REFERER'], BX_DOL_URL_ROOT) === 0)
@@ -1265,7 +1265,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
     	$s = bx_process_output($s, BX_DATA_HTML);
 
         $oMetatags = BxDolMetatags::getObjectInstance($this->_oConfig->getObject('metatags'));
-		$s = $oMetatags->keywordsParse($iEventId, $s);
+		$s = $oMetatags->metaParse($iEventId, $s);
 
         return $s;
     }

+ 92 - 0
plugins_public/tinymce-mention/css/autocomplete.css

@@ -0,0 +1,92 @@
+.rte-autocomplete{
+    position: absolute;
+    top: 0px;
+    left: 0px;
+    display: block;
+    z-index: 1000;
+    float: left;
+    min-width: 160px;
+    padding: 5px 0;
+    margin: 2px 0 0;
+    list-style: none;
+    background-color: #fff;
+    border: 1px solid #ccc;
+    border: 1px solid rgba(0,0,0,0.2);
+    -webkit-border-radius: 6px;
+    -moz-border-radius: 6px;
+    border-radius: 6px;
+    -webkit-box-shadow: 0 5px 10px rgba(0,0,0,0.2);
+    -moz-box-shadow: 0 5px 10px rgba(0,0,0,0.2);
+    box-shadow: 0 5px 10px rgba(0,0,0,0.2);
+    -webkit-background-clip: padding-box;
+    -moz-background-clip: padding;
+    background-clip: padding-box;
+    font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
+    font-size: 14px;
+}
+
+.rte-autocomplete:before {
+    content: '';
+    display: inline-block;
+    border-left: 7px solid transparent;
+    border-right: 7px solid transparent;
+    border-bottom: 7px solid #ccc;
+    border-bottom-color: rgba(0, 0, 0, 0.2);
+    position: absolute;
+    top: -7px;
+    left: 9px;
+}
+
+.rte-autocomplete:after {
+    content: '';
+    display: inline-block;
+    border-left: 6px solid transparent;
+    border-right: 6px solid transparent;
+    border-bottom: 6px solid white;
+    position: absolute;
+    top: -6px;
+    left: 10px;
+}
+
+.rte-autocomplete > li.loading {
+	background: url("https://www.ajaxload.info/cache/FF/FF/FF/00/00/00/1-0.gif") center no-repeat;
+	height: 16px;
+}
+
+.rte-autocomplete > li > a {
+    display: block;
+    padding: 3px 20px;
+    clear: both;
+    font-weight: normal;
+    line-height: 20px;
+    color: #333;
+    white-space: nowrap;
+    text-decoration: none;
+}
+
+.rte-autocomplete >li > a:hover, .rte-autocomplete > li > a:focus, .rte-autocomplete:hover > a, .rte-autocomplete:focus > a {
+    color: #fff;
+    text-decoration: none;
+    background-color: #0081c2;
+    background-image: -moz-linear-gradient(top,#08c,#0077b3);
+    background-image: -webkit-gradient(linear,0 0,0 100%,from(#08c),to(#0077b3));
+    background-image: -webkit-linear-gradient(top,#08c,#0077b3);
+    background-image: -o-linear-gradient(top,#08c,#0077b3);
+    background-image: linear-gradient(to bottom,#08c,#0077b3);
+    background-repeat: repeat-x;
+    filter: progid:DXImageTransform.Microsoft;
+}
+
+.rte-autocomplete >.active > a, .rte-autocomplete > .active > a:hover, .rte-autocomplete > .active > a:focus {
+    color: #fff;
+    text-decoration: none;
+    background-color: #0081c2;
+    background-image: -moz-linear-gradient(top,#08c,#0077b3);
+    background-image: -webkit-gradient(linear,0 0,0 100%,from(#08c),to(#0077b3));
+    background-image: -webkit-linear-gradient(top,#08c,#0077b3);
+    background-image: -o-linear-gradient(top,#08c,#0077b3);
+    background-image: linear-gradient(to bottom,#08c,#0077b3);
+    background-repeat: repeat-x;
+    outline: 0;
+    filter: progid:DXImageTransform.Microsoft;
+}

+ 3 - 0
plugins_public/tinymce-mention/css/rte-content.css

@@ -0,0 +1,3 @@
+span#autocomplete {
+    font-weight: bold;
+}

Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 0
plugins_public/tinymce-mention/plugin.min.js


Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 0
plugins_public/tinymce/plugins/mention/plugin.min.js


+ 2 - 2
template/scripts/BxBaseCmts.php

@@ -575,7 +575,7 @@ class BxBaseCmts extends BxDolCmts
 
                 if ($this->_sMetatagsObj) {
                     $oMetatags = BxDolMetatags::getObjectInstance($this->_sMetatagsObj);
-                    $oMetatags->keywordsAdd($this->_oQuery->getUniqId($this->_aSystem['system_id'], $iCmtId), $sCmtText);
+                    $oMetatags->metaAdd($this->_oQuery->getUniqId($this->_aSystem['system_id'], $iCmtId), $sCmtText);
                 }
 
                 $this->onPostAfter($iCmtId);
@@ -616,7 +616,7 @@ class BxBaseCmts extends BxDolCmts
 
                 if ($this->_sMetatagsObj) {
                     $oMetatags = BxDolMetatags::getObjectInstance($this->_sMetatagsObj);
-                    $oMetatags->keywordsAdd($this->_oQuery->getUniqId($this->_aSystem['system_id'], $iCmtId), $sCmtText);
+                    $oMetatags->metaAdd($this->_oQuery->getUniqId($this->_aSystem['system_id'], $iCmtId), $sCmtText);
                 }
 
                 $this->onEditAfter($iCmtId);

+ 29 - 8
template/scripts/BxBaseEditorTinyMCE.php

@@ -16,20 +16,40 @@ class BxBaseEditorTinyMCE extends BxDolEditor
     /**
      * Common initialization params
      */
-    protected static $CONF_COMMON = "
+    protected static $CONF_COMMON = <<<EOS
                     jQuery('{bx_var_selector}').tinymce({
                         {bx_var_custom_init}
                         {bx_var_custom_conf}
                         document_base_url: '{bx_url_root}',
+                        theme_url: '{bx_url_tinymce}themes/modern/theme.min.js',
                         skin_url: '{bx_url_tinymce}skins/{bx_var_skin}/',
                         language_url: '{bx_url_tinymce}langs/{bx_var_lang}.js',
                         content_css: '{bx_var_css_path}',
                         entity_encoding: 'raw',
                         browser_spellcheck: true,
                         branding: false,
-                        body_class: 'bx-def-color-bg-block'
+                        body_class: 'bx-def-color-bg-block',
+                        mentions: {
+                            queryBy: 'label',
+                            source: function (query, process, delimiter) {
+                                if (delimiter === '@') {
+                                   $.getJSON('{bx_url_root}searchExtended.php?action=get_authors&term=' + query, function (data) {
+                                      process(data)
+                                   });
+                                }
+                            },
+                            insert: function(item) {
+                                return '<a data-profile-id="' + item.value + '" href="' + item.url + '">' + item.label + '</a>';
+                            },
+                            render: function(item) {
+                                return '<li><a href="javascript:;">' + item.label + '</a></li>';
+                            },
+                            renderDropdown: function() {
+                                return '<ul class="rte-autocomplete"></ul>';
+                            }
+                        }
                     });
-    ";
+EOS;
 
     /**
      * Standard view initialization params
@@ -47,10 +67,10 @@ class BxBaseEditorTinyMCE extends BxDolEditor
                             media: '{bx_url_tinymce}plugins/media/plugin.min.js',
                             paste: '{bx_url_tinymce}plugins/paste/plugin.min.js',
                             fullscreen: '{bx_url_tinymce}plugins/fullscreen/plugin.min.js',
+                            mention: '{bx_var_plugins_path}tinymce-mention/plugin.min.js',
                         },
                         width: '100%',
                         height: '270',
-                        theme_url: '{bx_url_tinymce}themes/modern/theme.min.js',
                         toolbar: 'undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
                         statusbar: true,
                         resize: true,
@@ -68,10 +88,10 @@ class BxBaseEditorTinyMCE extends BxDolEditor
                             lists: '{bx_url_tinymce}plugins/lists/plugin.min.js',
                             paste: '{bx_url_tinymce}plugins/paste/plugin.min.js',
                             fullscreen: '{bx_url_tinymce}plugins/fullscreen/plugin.min.js',
+                            mention: '{bx_var_plugins_path}tinymce-mention/plugin.min.js',
                         },
                         width: '100%',
-                        height: '150',
-                        theme_url: '{bx_url_tinymce}themes/modern/theme.min.js',
+                        height: '150',                        
                         toolbar: 'bold italic underline removeformat | bullist numlist | alignleft aligncenter alignright | blockquote | link unlink image',
                         statusbar: true,
                         resize: true,
@@ -106,10 +126,10 @@ class BxBaseEditorTinyMCE extends BxDolEditor
                             textcolor: '{bx_url_tinymce}plugins/textcolor/plugin.min.js',
                             visualblocks: '{bx_url_tinymce}plugins/visualblocks/plugin.min.js',
                             fullscreen: '{bx_url_tinymce}plugins/fullscreen/plugin.min.js',
+                            mention: '{bx_var_plugins_path}tinymce-mention/plugin.min.js',
                         },
                         width: '100%',
                         height: '320',
-                        theme_url: '{bx_url_tinymce}themes/modern/theme.min.js',
                         toolbar: [
                             'undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
                             'print preview media | forecolor emoticons | fullscreen'
@@ -181,7 +201,7 @@ class BxBaseEditorTinyMCE extends BxDolEditor
         $sInitEditor = $this->_replaceMarkers(self::$CONF_COMMON, array(
             'bx_var_custom_init' => $sToolsItems,
             'bx_var_custom_conf' => $this->_sConfCustom,
-            'bx_var_plugins_path' => bx_js_string(BX_DOL_URL_PLUGINS, BX_ESCAPE_STR_APOS),
+            'bx_var_plugins_path' => bx_js_string(BX_DOL_URL_PLUGINS_PUBLIC, BX_ESCAPE_STR_APOS),
             'bx_var_css_path' => bx_js_string($aCss['url'], BX_ESCAPE_STR_APOS),
             'bx_var_skin' => bx_js_string($this->_aObject['skin'], BX_ESCAPE_STR_APOS),
             'bx_var_lang' => bx_js_string($sLang, BX_ESCAPE_STR_APOS),
@@ -232,6 +252,7 @@ class BxBaseEditorTinyMCE extends BxDolEditor
         if ($this->_bJsCssAdded)
             return '';
         $this->_oTemplate->addJs(array('tinymce/tinymce.min.js', 'tinymce/jquery.tinymce.min.js', 'editor.tinymce.js'));
+        $this->_oTemplate->addCss(array(BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'tinymce-mention/css/|autocomplete.css'));
         $this->_bJsCssAdded = true;
         return '';
     }

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor