Overview

Namespaces

  • Composer
    • Autoload
  • Geekwright
    • RegDom
  • League
    • OAuth2
      • Client
        • Provider
  • None
  • Xmf
    • Database
    • Jwt
    • Key
    • Module
      • Helper

Classes

  • Assert
  • Debug
  • FilterInput
  • Highlighter
  • IPAddress
  • Language
  • Metagen
  • Random
  • Request
  • StopWords
  • Yaml
  • Overview
  • Namespace
  • Class
  • Tree

Class Metagen

Metagen facilitates generating and assigning page meta tags

Namespace: Xmf
Package: Xmf
Category: Xmf\Metagen
Copyright: 2011-2016 XOOPS Project (http://xoops.org)
License: GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
Author: Richard Griffith richard@geekwright.com
Author: trabis lusopoemas@gmail.com
Link: http://xoops.org
Located at lass/libraries/vendor/xoops/xmf/src/Xmf/Metagen.php
Methods summary
public static
# assignTitle( string $title )

assignTitle set the page title

assignTitle set the page title

Parameters

$title
page title
public static
# assignKeywords( string[] $keywords )

assignKeywords set the meta keywords tag

assignKeywords set the meta keywords tag

Parameters

$keywords
keywords list
public static
# assignDescription( string $description )

assignDescription set the meta description tag

assignDescription set the meta description tag

Parameters

$description
page description
protected static
# assignThemeMeta( string $name, string $value )

assign meta variables in template engine

assign meta variables in template engine

Parameters

$name
meta name (keywords, description)
$value
meta value
protected static
# assignTemplateVar( string $name, string $value )

assign meta variables in template engine

assign meta variables in template engine

Parameters

$name
variable name (i.e. xoops_pagtitle)
$value
meta value
public static array
# generateKeywords( string $body, integer $count = 20, integer $minLength = 4, string[]|null $forceKeys = null )

generateKeywords builds a set of keywords from text body

generateKeywords builds a set of keywords from text body

Parameters

$body
text to extract keywords from
$count
number of keywords to use
$minLength
minimum length of word to consider as a keyword
$forceKeys
array of keywords to force use, or null for none

Returns

array
of keywords
public static string
# generateDescription( string $body, integer $wordCount = 100 )

generateDescription - generate a short description from a body of text

generateDescription - generate a short description from a body of text

Parameters

$body
body text
$wordCount
maximum word count for description

Returns

string
public static
# generateMetaTags( string $title, string $body, integer $count = 20, integer $minLength = 4, integer $wordCount = 100, string[]|null $forceKeys = null )

generateMetaTags - generate and assign all meta tags

generateMetaTags - generate and assign all meta tags

Parameters

$title
title
$body
body text
$count
maximum keywords to use
$minLength
minimum length of word to consider as keyword
$wordCount
maximum word count for description summary
$forceKeys
associative array of keywords to force use
protected static boolean
# nonEmptyString( string $var )

Return true if the string is length > 0

Return true if the string is length > 0

Parameters

$var
to test

Returns

boolean

Author

psylove
public static string
# generateSeoTitle( string $title = '', string $extension = '' )

Create a title for the short_url field of an article

Create a title for the short_url field of an article

Parameters

$title
title of the article
$extension
extension to add

Returns

string
sort_url for the article

Author

psylove
public static string
# getSearchSummary( string $haystack, mixed $needles = null, integer $length = 120 )

getSearchSummary splits a string into string no larger than a specified length, and centered around the first occurrence of any of an array of needles, or starting at the beginning of the string if no needles are specified or found.

getSearchSummary splits a string into string no larger than a specified length, and centered around the first occurrence of any of an array of needles, or starting at the beginning of the string if no needles are specified or found.

The string will be broken on spaces and an ellipsis (…) will be added to the string when broken.

Parameters

$haystack
the string to summarize
$needles
search term, array of search terms, or null
$length
maximum character length for the summary

Returns

string
a substring of haystack
protected static string
# asPlainText( string $rawText )

asPlainText - clean string to be plain text, without control characters such as newlines, html markup, or leading trailing or repeating spaces.

asPlainText - clean string to be plain text, without control characters such as newlines, html markup, or leading trailing or repeating spaces.

Parameters

$rawText
a text string to be cleaned

Returns

string
protected static integer[]
# getNeedlePositions( string $haystack, mixed $needles )

getNeedlePositions - Essentially this is a strpos() for an array of needles. Given a haystack and an array of needles, return an array of all initial positions, if any, of those needles in that haystack.

getNeedlePositions - Essentially this is a strpos() for an array of needles. Given a haystack and an array of needles, return an array of all initial positions, if any, of those needles in that haystack.

Parameters

$haystack
the string to summarize
$needles
search term, array of search terms, or null

Returns

integer[]
array of initial positions of substring of haystack
protected static string
# purifyText( string $text, boolean $keyword = false )

purifyText

purifyText

Parameters

$text
text to clean
$keyword
replace some punctuation with white space

Returns

string
cleaned text
protected static string
# html2text( string $document )

html2text This will remove HTML tags, javascript sections and white space. It will also convert some common HTML entities to their text equivalent. Credits to newbb2

html2text This will remove HTML tags, javascript sections and white space. It will also convert some common HTML entities to their text equivalent. Credits to newbb2

Parameters

$document
HTML to be converted

Returns

string
Text version of $document parameter
public static boolean
# checkStopWords( string $key )

checkStopWords - look up a word in a list of stop words and classify it as a significant word or a stop word.

checkStopWords - look up a word in a list of stop words and classify it as a significant word or a stop word.

Deprecated

since v1.2.0 - use Xmf\StopWords::check()

Parameters

$key
the word to check

Returns

boolean
True if word is significant, false if it is a stop word
protected static Xmf\StopWords
# stopWordsObject( )

Get a StopWords object

Get a StopWords object

Returns

Xmf\StopWords
Constants summary
string ENCODING

mbstring encoding

mbstring encoding

# 'UTF-8'
string ELLIPSIS

horizontal ellipsis This will be used to replace omitted text.

horizontal ellipsis This will be used to replace omitted text.

# "..."
API documentation generated by ApiGen