UNA
Loading...
Searching...
No Matches
BxDolMetatags Class Reference
Inheritance diagram for BxDolMetatags:
BxDolFactory iBxDolFactoryObject BxBaseMetatags BxTemplMetatags BxForumMetatags

Public Member Functions

 addPageMetaInfo ($iId, $mixedImage=false)
 
 metaParse ($iId, $s)
 
 metaAddAuto ($iId, $aContentInfo, $CNF, $sFormDisplay)
 
 metaAdd ($iId, $s)
 
 keywordsIsEnabled ()
 
 keywordsAdd ($iId, $s)
 
 keywordsAddOne ($iId, $s, $bDeletePreviousKeywords=true)
 
 keywordsAddAuto ($iId, $aContentInfo, $CNF, $sFormDisplay)
 
 metaFields ($aContentInfo, $CNF, $sFormDisplay, $bHtmlOnly=false)
 
 keywordsParse ($iId, $s)
 
 keywordsParseOne ($iId, $s)
 
 keywordsGetHashTagUrl ($sKeyword, $iId, $mixedSection=false)
 
 keywordsGet ($iId)
 
 keywordsSetSearchCondition ($oSearchResult, $sKeyword, $iCmtsSystemId=0)
 
 keywordsSetSearchConditionCmts ($oSearchResult, $sKeyword, $iCmtsSystemId=0)
 
 keywordsGetAsSQLPart ($sContentTable, $sContentField, $sKeyword)
 
 keywordsPopularList ($iLimit, $mContextId=false)
 
 locationsIsEnabled ()
 
 locationsAdd ($iId, $sLatitude, $sLongitude, $sCountryCode, $sState, $sCity, $sZip='', $sStreet='', $sStreetNumber='')
 
 locationsAddFromForm ($iId, $sPrefix='', $oForm=null)
 
 locationsString ($iId, $bHTML=true, $aParams=array())
 
 locationsStringFromArray ($aLocation, $bHTML=true, $aParams=array())
 
 locationsSetSearchCondition ($oSearchResult, $sCountry=false, $sState=false, $sCity=false, $sZip=false)
 
 locationsGetAsSQLPart ($sContentTable, $sContentField, $sCountry=false, $sState=false, $sCity=false, $sZip=false, $aBounds=array())
 
 locationGet ($iId, $sPrefix='')
 
 mentionsIsEnabled ()
 
 mentionsAdd ($iId, $s)
 
 mentionsAddAuto ($iId, $aContentInfo, $CNF, $sFormDisplay)
 
 mentionsParse ($iId, $s)
 
 mentionsGet ($iId)
 
 mentionsSetSearchCondition ($oSearchResult, $iProfileId, $iCmtsSystemId=0)
 
 mentionsSetSearchConditionCmts ($oSearchResult, $iProfileId, $iCmtsSystemId=0)
 
 onDeleteContent ($iId)
 

Static Public Member Functions

static getObjectInstance ($sObject)
 
static getMetatagsDataByTerm ($sMeta, $sMetaItem, $sTerm)
 
static keywordsCameraModel ($aExif)
 
static locationsRetrieveFromForm ($sPrefix='', $oForm=null)
 
static locationsParseComponents ($aAdress, $sPrefix='')
 
static locationsParseAddressComponents ($aAdress, $sPrefix='')
 

Protected Member Functions

 __construct ($aObject)
 
 keywordsAddMeta ($iId)
 
 locationsAddMeta ($iId)
 
 mentionsAddMeta ($iId)
 
 _metaAdd ($iId, $s, $sPreg, $sFuncDelete, $sFuncAdd, $sFuncGet, $iMaxItems, $sAlertName)
 

Protected Attributes

 $_sObject
 
 $_aObject
 
 $_oQuery
 
 $_aMetas = []
 

Static Protected Attributes

static $_aLocationKeys = ['lat', 'lng', 'country', 'state', 'city', 'zip', 'street', 'street_number']
 
static $_sKeywordPattern = '/[\pCc\pZ\p{Ps}\p{Pe}\p{Pi}\p{Pf}]\#(\pL[\pL\pN_]+)/u'
 

Detailed Description

Meta-tags for different content. It can handle #keywords, @mentions, locations and meta image for the content.

Keywords are parsed after content add and edit and added to the database, later when content is displayed #keywords are highlighted as links to the search page with all content with this keyword, also keywords are displayed as meta info in page header.

Location info upon content adding/editing is displayed as custom field, it detects current user location and attach location as hidden form fields. When content is displayed location can be shown as clickable links to search page where results are other items from same location, also location is displayed as meta info in page header as latutude and longitude.

Content image can be added as meta info using this class as well.

Add new meta-tags object.

To add new meta-tags object insert new record into sys_objects_metatags table:

  • object: name of the meta-tags object, in the format: vendor prefix, underscore, module prefix, underscore, internal identifier or nothing
  • table_keywords: table name to store keywords, leave empty to disable keywords
  • table_locations: table name to store locations, leave empty to disable locations
  • table_mentions: table name to store mentions, leave empty to disable mentions
  • override_class_name: class name to override
  • override_class_file: class file path to override

To simplify operations with metatags in modules which are derived from some 'base' modules, specify it in module config class in 'CNF' array:

  • FIELDS_WITH_KEYWORDS: array or comma separated list of field names with keywords support, or 'auto' to automatically use all 'textarea' fields
  • OBJECT_METATAGS: metatags object name

Location

Upon content 'add' and 'edit' form submit, call BxDolMetatags\locationsAddFromForm

$oMetatags = BxDolMetatags::getObjectInstance('object_name');
$oMetatags->locationsAddFromForm($iContentId);
static getObjectInstance($sObject)
Definition BxDolMetatags.php:181

Upon 'edit' form display call BxDolMetatags\locationGet to fill-in location form input, for example:

$oMetatags = BxDolMetatags::getObjectInstance('object_name');
$aSpecificValues = $oMetatags->locationGet($iContentId);
$oForm->initChecker($aContentInfo, $aSpecificValues);

To display location call BxDolMetatags\locationsString:

$oMetatags = BxDolMetatags::getObjectInstance('object_name');
echo $oMetatags->locationsString($iContentId)

Upon page display call BxDolMetatags\addPageMetaInfo to add location (and all other, including content image) meta information to the page header:

$o->addPageMetaInfo($iContentId, array('id' => $iFileId, 'object' => 'storage_object_name'));

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', also form object must be derived from BxBaseModGeneralFormEntry class, which has custom field declaration.

#keyword

Upon content 'add' and 'edit' form submit, call BxDolMetatags\keywordsAdd

$oMetatags = BxDolMetatags::getObjectInstance('object_name');
$oMetatags->keywordsAdd($iContentId, $aContentInfo['text_field_with_hash_tags']);

Before displaying the text with hashtags call BxDolMetatags\keywordsParse to highlight keywords:

$oMetatags = BxDolMetatags::getObjectInstance('object_name');
$sText = $oMetatags->keywordsParse($iContentId, $sText);

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.

@mention

Upon content 'add' and 'edit' form submit, call BxDolMetatags\mentionsAdd

$oMetatags = BxDolMetatags::getObjectInstance('object_name');
$oMetatags->mentionsAdd($iContentId, $aContentInfo['text_field_with_mentions']);

Before displaying the text with mentions call BxDolMetatags\mentionsParse:

$oMetatags = BxDolMetatags::getObjectInstance('object_name');
$sText = $oMetatags->mentionsParse($iContentId, $sText);

Upon page display call BxDolMetatags\addPageMetaInfo to add all available meta info to the page meta into where possible, however it doesn't adding anyting for mentions for now.

To be able to search by mentions object must be specified in *SearchResult class as 'object_metatags' in 'aCurrent' array.

Add @mention, #keyword using one call

Upon content 'add' and 'edit' form submit, call BxDolMetatags\metaAdd

$oMetatags = BxDolMetatags::getObjectInstance('object_name');
$oMetatags->metaAdd($iContentId, $aContentInfo['text_field']);

or call BxDolMetatags\metaAddAuto, it autodetects fields with metainfo:

$oMetatags = BxDolMetatags::getObjectInstance('object_name');
$oMetatags->metaAddAuto($iContentId, $aContentInfo, $CNF, $CNF['OBJECT_FORM_ENTRY_DISPLAY_ADD']);

Before displaying the text with different metainfo call BxDolMetatags\metaParse:

$oMetatags = BxDolMetatags::getObjectInstance('object_name');
$sText = $oMetatags->metaParse($iContentId, $sText);

Upon page display call BxDolMetatags\addPageMetaInfo to add all available meta info to the page meta into where possible.

Content deletion

When content is deleted associated meta data can be deleted by calling BxDolMetatags\onDeleteContent:

$oMetatags = BxDolMetatags::getObjectInstance('object_name');
$oMetatags->onDeleteContent($iContentId);

Constructor & Destructor Documentation

◆ __construct()

BxDolMetatags::__construct ( $aObject)
protected

Constructor

Parameters
$aObjectarray of metags object options

Member Function Documentation

◆ _metaAdd()

BxDolMetatags::_metaAdd ( $iId,
$s,
$sPreg,
$sFuncDelete,
$sFuncAdd,
$sFuncGet,
$iMaxItems,
$sAlertName )
protected

Hooks:

'meta_keyword', 'before_added' - hook to override meta keyword before it will be processed

Hooks:

'meta_mention', 'before_added' - hook to override meta mention before it will be processed

It's equivalent to 'meta_keyword', 'before_added' - hook to override meta keyword before it will be processed except mention value is used in $object_id

HOOKS
'meta_mention', 'before_added' - hook to override meta mention before it will be processed

Hooks:

'{object_name}', 'keyword_added' - hook after a keyword (hashtag) was recognized in provided text

Hooks:

'{object_name}', 'mention_added' - hook after meta mention was processed

It's equivalent to '{object_name}', 'keyword_added' - hook after a keyword (hashtag) was recognized in provided text

HOOKS
'{object_name}', 'mention_added' - hook after meta mention was processed

Hooks:

'meta_keyword', 'added' - hook after a keyword (hashtag) was recognized in provided text

Hooks:

'meta_mention', 'added' - hook after meta mention was processed

It's equivalent to 'meta_keyword', 'added' - hook after a keyword (hashtag) was recognized in provided text

HOOKS
'meta_mention', 'added' - hook after meta mention was processed

◆ addPageMetaInfo()

BxDolMetatags::addPageMetaInfo ( $iId,
$mixedImage = false )

Add all available meta tags to the head section

Returns
number of successfully added metas

◆ getMetatagsDataByTerm()

static BxDolMetatags::getMetatagsDataByTerm ( $sMeta,
$sMetaItem,
$sTerm )
static

Get metatags by term

Parameters
string$sMeta- 'keywords' is only supported meta for now
type$sMetaItem
type$sTerm
Returns
type

◆ getObjectInstance()

static BxDolMetatags::getObjectInstance ( $sObject)
static

Get metatags object instance by object name

Parameters
$sObjectobject name
Returns
object instance or false on error

Implements iBxDolFactoryObject.

◆ keywordsAdd()

BxDolMetatags::keywordsAdd ( $iId,
$s )

Add #keywords from the string

Parameters
$iIdcontent id
$sstring with #keywords
Returns
number of found keywords

◆ keywordsAddAuto()

BxDolMetatags::keywordsAddAuto ( $iId,
$aContentInfo,
$CNF,
$sFormDisplay )

Add #keywords from the content fields

Parameters
$iIdcontent id
$aContentInfocontent info array
$CNFmodule config array
$sFormDisplayform display object
Returns
number of found keywords

◆ keywordsAddMeta()

BxDolMetatags::keywordsAddMeta ( $iId)
protected

Add keywords meta info to the head section

Parameters
$iIdcontent id

◆ keywordsAddOne()

BxDolMetatags::keywordsAddOne ( $iId,
$s,
$bDeletePreviousKeywords = true )

Add keyword from the whole string

Parameters
$iIdcontent id
$skeyword
Returns
number of added keywords, should be 1

Hooks:

'{object_name}', 'keyword_added' - hook after a keyword (hashtag) was recognized in provided text

Hooks:

'meta_keyword', 'added' - hook after a keyword (hashtag) was recognized in provided text

It's equivalent to '{object_name}', 'keyword_added' - hook after a keyword (hashtag) was recognized in provided text except object parameter with metatags object name was added in $extra_params

HOOKS
'meta_keyword', 'added' - hook after a keyword (hashtag) was recognized in provided text

◆ keywordsCameraModel()

static BxDolMetatags::keywordsCameraModel ( $aExif)
static

This function is specifically for formatting "Photo Camera" string, when "Photo Camera" is used as image hashtag

◆ keywordsGet()

BxDolMetatags::keywordsGet ( $iId)

Get list of keywords associated with the content

Returns
array of keywords

◆ keywordsGetAsSQLPart()

BxDolMetatags::keywordsGetAsSQLPart ( $sContentTable,
$sContentField,
$sKeyword )

Get part of SQL query for meta keyword

Parameters
$sContentTablecontent table or alias
$sContentFieldcontent table field or field alias
$sKeywordkeyword

◆ keywordsGetHashTagUrl()

BxDolMetatags::keywordsGetHashTagUrl ( $sKeyword,
$iId,
$mixedSection = false )

Hooks:

'meta_keyword', 'url' - hook to override meta keyword URL

  • $unit_name - equals meta_keyword
  • $action - equals url
  • $object_id - not used
  • $sender_id - not used
  • $extra_params - array of additional params with the following array keys:
    • url - [string] by ref, keyword URL, can be overridden in hook processing
    • keyword - [string] keyword
    • id - [int] content id
    • object - [string] metatags object name
    • section - [string] a string with sections (modules) in which a search by keyword will be performed (for default hashtag URL)
      HOOKS
      'meta_keyword', 'url' - hook to override meta keyword URL

◆ keywordsIsEnabled()

BxDolMetatags::keywordsIsEnabled ( )

Checks if keywords enabled for current metatags object

◆ keywordsParse()

BxDolMetatags::keywordsParse ( $iId,
$s )

Add links to the #keywords in the string

Parameters
$iIdcontent id
$sstring with #keywords
Returns
modified string where all #keywords are transformed to links with rel="tag" attribute

◆ keywordsParseOne()

BxDolMetatags::keywordsParseOne ( $iId,
$s )

Add link to the provided keyword

Parameters
$iIdcontent id
$skeyword
Returns
modified string where provided keyword is transformed to link with rel="tag" attribute

◆ keywordsSetSearchCondition()

BxDolMetatags::keywordsSetSearchCondition ( $oSearchResult,
$sKeyword,
$iCmtsSystemId = 0 )

Set condition for search results object for meta keyword

Parameters
$oSearchResultsearch results object
$sKeywordkeyword

◆ locationGet()

BxDolMetatags::locationGet ( $iId,
$sPrefix = '' )

Get location

Parameters
$iIdcontent id
$sPrefixfield prefix for returning data array
Returns
location array with the following keys (when no prefix specified): object_id, lat, lng, country, state, city, zip, street, street_number

◆ locationsAdd()

BxDolMetatags::locationsAdd ( $iId,
$sLatitude,
$sLongitude,
$sCountryCode,
$sState,
$sCity,
$sZip = '',
$sStreet = '',
$sStreetNumber = '' )

Add location for the content

Parameters
$iIdcontent id
$sLatitudelatitude
$sLongitudelongitude
$sCountryCodeoptional 2 letters country code (ISO 3166-1)
$sStateoptional state/province/territory name
$sCityoptional city name
$sZipoptional ZIP/postcode
$sStreetoptional street name
$sStreetNumberoptional street number
Returns
true if location was added, or false otherwise

◆ locationsAddFromForm()

BxDolMetatags::locationsAddFromForm ( $iId,
$sPrefix = '',
$oForm = null )

Add location for the content from POST data

Parameters
$iIdcontent id
$sPrefixfield prefix for POST data, or empty - if no prefix
$oFormform to use to get POST data, or null - then new form instance will be created

◆ locationsAddMeta()

BxDolMetatags::locationsAddMeta ( $iId)
protected

Add keywords meta info to the head section

Parameters
$iIdcontent id

◆ locationsGetAsSQLPart()

BxDolMetatags::locationsGetAsSQLPart ( $sContentTable,
$sContentField,
$sCountry = false,
$sState = false,
$sCity = false,
$sZip = false,
$aBounds = array() )

Get part of SQL query for meta locations

Parameters
$sContentTablecontent table or alias
$sContentFieldcontent table field or field alias
$sCountrycountry and other location info

◆ locationsIsEnabled()

BxDolMetatags::locationsIsEnabled ( )

Checks if locations enabled for current metatags object

◆ locationsParseAddressComponents()

static BxDolMetatags::locationsParseAddressComponents ( $aAdress,
$sPrefix = '' )
static

Parse google's formatted address components into array with the following indexes: lat, lng, country, state, city, zip, street, street_number

◆ locationsParseComponents()

static BxDolMetatags::locationsParseComponents ( $aAdress,
$sPrefix = '' )
static

Parse address components into associative array with the following indexes: lat, lng, country, state, city, zip, street, street_number

◆ locationsRetrieveFromForm()

static BxDolMetatags::locationsRetrieveFromForm ( $sPrefix = '',
$oForm = null )
static

Retrieve location for the content from POST data

Parameters
$sPrefixfield prefix for POST data, or empty - if no prefix
$oFormform to use to get POST data, or null - then new form instance will be created

◆ locationsSetSearchCondition()

BxDolMetatags::locationsSetSearchCondition ( $oSearchResult,
$sCountry = false,
$sState = false,
$sCity = false,
$sZip = false )

Set condition for search results object for meta locations

Parameters
$oSearchResultsearch results object
$sCountrycountry and other location info

◆ locationsString()

BxDolMetatags::locationsString ( $iId,
$bHTML = true,
$aParams = array() )

Get locations string with links

Parameters
$iIdcontent id
Returns
string with links to country and city

◆ locationsStringFromArray()

BxDolMetatags::locationsStringFromArray ( $aLocation,
$bHTML = true,
$aParams = array() )

Get locations string with links

Parameters
$aLocationlocation array
Returns
string with links to country and city

◆ mentionsAdd()

BxDolMetatags::mentionsAdd ( $iId,
$s )

Add @mentions from the string (most probably @mentions will be some sort of links already, so parsing may have to look for smth like mention name instead of @mention, since there is no usernames for profiles modules and name could contain spaces and othr characters)

Parameters
$iIdcontent id
$sstring with @mentions
Returns
number of found mentions

◆ mentionsAddAuto()

BxDolMetatags::mentionsAddAuto ( $iId,
$aContentInfo,
$CNF,
$sFormDisplay )

Add @mentions from the content of form fields

Parameters
$iIdcontent id
$aContentInfocontent info array
$CNFmodule config array
$sFormDisplayform display object
Returns
number of found keywords

◆ mentionsAddMeta()

BxDolMetatags::mentionsAddMeta ( $iId)
protected

No mentions meta info in the head section

◆ mentionsGet()

BxDolMetatags::mentionsGet ( $iId)

Get list of profile IDs associated with the content

Returns
array of profile IDs

◆ mentionsIsEnabled()

BxDolMetatags::mentionsIsEnabled ( )

Checks if mentions enabled for current metatags object

◆ mentionsParse()

BxDolMetatags::mentionsParse ( $iId,
$s )

Add links to the @mentions in the string (actual tranformation may have to be performed with ready links like mention name)

Parameters
$iIdcontent id
$sstring with @mentions
Returns
modified string where all @mentions are transformed to links

◆ mentionsSetSearchCondition()

BxDolMetatags::mentionsSetSearchCondition ( $oSearchResult,
$iProfileId,
$iCmtsSystemId = 0 )

Set condition for search results object for mentions

Parameters
$oSearchResultsearch results object
$sMentionsmbd

◆ metaAdd()

BxDolMetatags::metaAdd ( $iId,
$s )

Perform

See also
keywordsAdd
mentionsAdd and maybe other
Parameters
$iIdcontent id
$sstring
Returns
number of added keywords, mentions, etc

◆ metaAddAuto()

BxDolMetatags::metaAddAuto ( $iId,
$aContentInfo,
$CNF,
$sFormDisplay )

Perform

See also
keywordsAddAuto
mentionsAddAuto and maybe other
Parameters
$iIdcontent id
$aContentInfocontent info array
$CNFmodule config array
$sFormDisplayform display object
Returns
number of founded keywords, mentions, etc

◆ metaFields()

BxDolMetatags::metaFields ( $aContentInfo,
$CNF,
$sFormDisplay,
$bHtmlOnly = false )

Get field names which are subject to parse keywords

◆ metaParse()

BxDolMetatags::metaParse ( $iId,
$s )

Perform

See also
keywordsParse
mentionsParse and maybe other
Parameters
$iIdcontent id
$sstring
Returns
modified string

◆ onDeleteContent()

BxDolMetatags::onDeleteContent ( $iId)

Delete all data associated with the content

Parameters
$iIdcontent id

The documentation for this class was generated from the following file: