|
|
@@ -9,6 +9,8 @@
|
|
|
|
|
|
bx_import('BxDolMetatagsQuery');
|
|
|
|
|
|
+define('BX_METATAGS_KEYWORDS_MAX', 9);
|
|
|
+
|
|
|
/**
|
|
|
* @page objects
|
|
|
* @section metatags Meta-tags
|
|
|
@@ -19,6 +21,7 @@ bx_import('BxDolMetatagsQuery');
|
|
|
// TODO: implementation with some modules
|
|
|
// 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: pages for listing content by @keyword, @mention, country location, city location, or BETTER try integrate it to the search engine, to not make separate pages in each module
|
|
|
+// TODO: integration with notifications, when smbd is @mentioned
|
|
|
|
|
|
/**
|
|
|
* Meta-tags for different content.
|
|
|
@@ -27,20 +30,19 @@ class BxDolMetatags extends BxDol implements iBxDolFactoryObject
|
|
|
{
|
|
|
protected $_sObject;
|
|
|
protected $_aObject;
|
|
|
- protected $_mixedContentId;
|
|
|
+ protected $_oQuery;
|
|
|
protected $_aMetas = array ();
|
|
|
|
|
|
/**
|
|
|
* Constructor
|
|
|
* @param $aObject array of metags object options
|
|
|
*/
|
|
|
- public function __construct($aObject, $mixedContentId)
|
|
|
+ public function __construct($aObject)
|
|
|
{
|
|
|
parent::__construct();
|
|
|
|
|
|
$this->_sObject = $aObject['object'];
|
|
|
$this->_aObject = $aObject;
|
|
|
- $this->_mixedContentId = $mixedContentId;
|
|
|
|
|
|
$a = array ('keywords', 'locations', 'mentions', 'pictures');
|
|
|
foreach ($a as $sMeta) {
|
|
|
@@ -48,6 +50,8 @@ class BxDolMetatags extends BxDol implements iBxDolFactoryObject
|
|
|
continue;
|
|
|
$this->_aMetas[] = $sMeta;
|
|
|
}
|
|
|
+
|
|
|
+ $this->_oQuery = new BxDolMetatagsQuery($this->_aObject);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -55,9 +59,9 @@ class BxDolMetatags extends BxDol implements iBxDolFactoryObject
|
|
|
* @param $sObject object name
|
|
|
* @return object instance or false on error
|
|
|
*/
|
|
|
- static public function getObjectInstance($sObject, $mixedContentId)
|
|
|
+ static public function getObjectInstance($sObject)
|
|
|
{
|
|
|
- if (isset($GLOBALS['bxDolClasses']['BxDolMetatags!'.$sObject]))
|
|
|
+ if (isset($GLOBALS['bxDolClasses']['BxDolMetatags!'.$sObject]))
|
|
|
return $GLOBALS['bxDolClasses']['BxDolMetatags!'.$sObject];
|
|
|
|
|
|
$aObject = BxDolMetatagsQuery::getMetatagsObject($sObject);
|
|
|
@@ -70,7 +74,7 @@ class BxDolMetatags extends BxDol implements iBxDolFactoryObject
|
|
|
else
|
|
|
bx_import($sClass);
|
|
|
|
|
|
- $o = new $sClass($aObject, $mixedId);
|
|
|
+ $o = new $sClass($aObject);
|
|
|
|
|
|
return ($GLOBALS['bxDolClasses']['BxDolMetatags!'.$sObject] = $o);
|
|
|
}
|
|
|
@@ -79,11 +83,12 @@ class BxDolMetatags extends BxDol implements iBxDolFactoryObject
|
|
|
* Add all available meta tags to the head section
|
|
|
* @return number of successfully added metas
|
|
|
*/
|
|
|
- public function metaAdd() {
|
|
|
+ public function metaAdd($iId)
|
|
|
+ {
|
|
|
$i = 0;
|
|
|
foreach ($this->_aMetas as $sMeta) {
|
|
|
$sFunc = $sMeta . 'AddMeta';
|
|
|
- $i += $this->$sFunc();
|
|
|
+ $i += $this->$sFunc($iId);
|
|
|
}
|
|
|
return $i;
|
|
|
}
|
|
|
@@ -92,33 +97,62 @@ class BxDolMetatags extends BxDol implements iBxDolFactoryObject
|
|
|
|
|
|
/**
|
|
|
* Add #keywords from the string
|
|
|
+ * @param $iId content id
|
|
|
* @param $s string with #keywords
|
|
|
* @return number of found keywords
|
|
|
*/
|
|
|
- public function keywordsAdd($s) {
|
|
|
- // TODO:
|
|
|
+ public function keywordsAdd($iId, $s)
|
|
|
+ {
|
|
|
+ $a = array();
|
|
|
+ if (!preg_match_all('/(\#[\pL\pN]+)/u', $s, $a))
|
|
|
+ return 0;
|
|
|
+
|
|
|
+ $a[0] = array_unique($a[0]);
|
|
|
+
|
|
|
+ return $this->_oQuery->keywordsAdd($iId, array_slice($a[0], 0, BX_METATAGS_KEYWORDS_MAX));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Add links to the #keywords in the string
|
|
|
+ * @param $iId content id
|
|
|
* @param $s string with #keywords
|
|
|
* @return modified string where all #keywords are transformed to links with rel="tag" attribute
|
|
|
*/
|
|
|
- public function keywordsParse($s) {
|
|
|
- // TODO:
|
|
|
+ public function keywordsParse($iId, $s)
|
|
|
+ {
|
|
|
+ $a = $this->keywordsGet($iId);
|
|
|
+ if (empty($a))
|
|
|
+ return $s;
|
|
|
+
|
|
|
+ foreach ($a as $sKeyword)
|
|
|
+ $s = str_ireplace('#' . $sKeyword, '<a href="#"><s>#</s><b>' . $sKeyword . '</b></a>', $s);
|
|
|
+
|
|
|
+ return $s;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Add keywords meta info to the head section
|
|
|
+ * @param $iId content id
|
|
|
*/
|
|
|
- protected function keywordsAddMeta() {
|
|
|
+ protected function keywordsAddMeta($iId)
|
|
|
+ {
|
|
|
// TODO:
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Get list of keywords associated with the content
|
|
|
+ * @return array of keywords
|
|
|
+ */
|
|
|
+ public function keywordsGet($iId)
|
|
|
+ {
|
|
|
+ return $this->_oQuery->keywordsGet($iId);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
/**
|
|
|
* Add location for the content
|
|
|
+ * @param $iId content id
|
|
|
* @param $sLatitude latitude
|
|
|
* @param $sLongitude longitude
|
|
|
* @param $sCountryCode optional 2 letters country code (ISO 3166-1)
|
|
|
@@ -127,22 +161,27 @@ class BxDolMetatags extends BxDol implements iBxDolFactoryObject
|
|
|
* @param $sZip optional ZIP/postcode
|
|
|
* @return true if location was added, or false otherwise
|
|
|
*/
|
|
|
- public function locationsAdd($sLatitude, $sLongitude, $sCountryCode = '', $sState = '', $sCity = '', $sZip = '') {
|
|
|
+ public function locationsAdd($iId, $sLatitude, $sLongitude, $sCountryCode = '', $sState = '', $sCity = '', $sZip = '')
|
|
|
+ {
|
|
|
// TODO:
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Get locations string with links
|
|
|
+ * @param $iId content id
|
|
|
* @return string with links to country and city
|
|
|
*/
|
|
|
- public function locationsString() {
|
|
|
+ public function locationsString($iId)
|
|
|
+ {
|
|
|
// TODO:
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Add keywords meta info to the head section
|
|
|
+ * @param $iId content id
|
|
|
*/
|
|
|
- protected function locationsAddMeta() {
|
|
|
+ protected function locationsAddMeta($iId)
|
|
|
+ {
|
|
|
// TODO:
|
|
|
}
|
|
|
|
|
|
@@ -150,49 +189,68 @@ class BxDolMetatags extends BxDol implements iBxDolFactoryObject
|
|
|
|
|
|
/**
|
|
|
* Add @mentions from the string (most probably @mentions will be some sort of links already, so parsing may have to look for smth like <a data-mention="bx_persons|123">mention name</a> instead of @mention, since there is no usernames for profiles modules and name could contain spaces and othr characters)
|
|
|
+ * @param $iId content id
|
|
|
* @param $s string with @mentions
|
|
|
* @return number of found mentions
|
|
|
*/
|
|
|
- public function mentionsAdd($s) {
|
|
|
+ public function mentionsAdd($iId, $s)
|
|
|
+ {
|
|
|
// TODO:
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 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
|
|
|
* @param $s string with @mentions
|
|
|
* @return modified string where all @mentions are transformed to links
|
|
|
*/
|
|
|
- public function mentionsParse($s) {
|
|
|
+ public function mentionsParse($iId, $s)
|
|
|
+ {
|
|
|
// TODO:
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* No mentions meta info in the head section
|
|
|
*/
|
|
|
- protected function mentionsAddMeta() {
|
|
|
+ protected function mentionsAddMeta($iId)
|
|
|
+ {
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Add thumb for the content
|
|
|
+ * @param $iId content id
|
|
|
* @param $sStorageObject storage object name where file is stored
|
|
|
* @param $mixedFileId file id in the storage
|
|
|
* @return true if file was added, or false otherwise
|
|
|
*/
|
|
|
- public function picturesAdd($sStorageObject, $mixedFileId) {
|
|
|
+ public function picturesAdd($iId, $sStorageObject, $mixedFileId)
|
|
|
+ {
|
|
|
// TODO:
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Add thumb meta info to the head section
|
|
|
+ * @param $iId content id
|
|
|
*/
|
|
|
- protected function picturesAddMeta() {
|
|
|
+ protected function picturesAddMeta($iId)
|
|
|
+ {
|
|
|
// TODO:
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Delete all data associated with the content
|
|
|
+ * @param $iId content id
|
|
|
+ */
|
|
|
+ public function onDeleteContent($iId)
|
|
|
+ {
|
|
|
+ // TODO:
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/** @} */
|