contenido\classes\class.cms_teaser.php

Show: PublicProtectedPrivateinherited
Table of Contents
Project: Contenido Content Management System

Description: Class for handling CMS Type Teaser Teaser is able to teaser all articles in a category. It is also possible to set a list of articles which were displayed as manual teaser. This function is not category dependant. There are also several more properties like sort defintions, character limits for teaser text and a teaser headline

Requirements:

Author
Timo Trautmann  
Con_php_req
5.0  
Copyright
four for business AG  
License
http://www.contenido.org/license/LIZENZ.txt  
Link
http://www.4fb.de  
Link
http://www.contenido.org  
Package
Contenido Content Types  
Since
file available since contenido release 4.8.12 {@internal created 2009-04-08 modified 2009-04-14 - added possibility to expand template select by client or system setting using type 'cms_teaser' modofied 2009-04-21 - added seperate handling for xhtml modified 2009-05-04 - added sort order sequence modified 2009-10-01 - Dominik Ziegler, fixed session bug in link modified 2009-10-12 - Dominik Ziegler, fixed online/offline articles, dynamic teaser generation and translation implemented modified 2009-10-16 - Dominik Ziegler, added manual date support modified 2010-01-21 - Dominik Ziegler, strip tags from manual teaser date $Id$: }}  
Version
1.0.5  

\Cms_Teaser

Package: Default
Class handles content type teaser, its editmode and viewmode.

All properties of teaser content type were stored as xml document in database as content in {prefix}_content

Properties

>VPropertyprivatearray $aCMSTypes
Array which contains all avariable CMS_Types and its ids in current Contenido isntallation (described as hash [idtype => cmstypename])
Details
Type
array
Access
private  
>VPropertyprivatearray $aCfg
Contenido configuration array
Details
Type
array
Access
private  
>VPropertyprivatearray $aCfgClient
Contenido configuration array for currently active client
Details
Type
array
Access
private  
>VPropertyprivatearray $aSettings
Array which contains current teaser settings
Details
Type
array
Access
private  
>VPropertyprivatearray $aTeaserData
List of fieldnames in frontend (properties) which the teaser has and which were also described in the config xml document
Details
Type
array
Access
private  
>VPropertyprivatearray $aTranslations = array("MORE" => "mehr")
static
Placeholders for labels in frontend.

Important: This must be a static array!

Default valuearray("MORE" => "mehr")Details
Type
array
Access
private  
>VPropertyprivateinteger $iClient
current Contenido client id
Details
Type
integer
Access
private  
>VPropertyprivateinteger $iId
Current id of content type CMS_TEASER[3] -> 3
Details
Type
integer
Access
private  
>VPropertyprivateinteger $iIdArtLang
Idartlang of article, which is currently in edit- or viewmode
Details
Type
integer
Access
private  
>VPropertyprivateinteger $iLang
current Contenido language id
Details
Type
integer
Access
private  
>VPropertyprivateobject $oDb
Contenido database object
Details
Type
object
Access
private  
>VPropertyprivateobject $oSess
Contenido Session object
Details
Type
object
Access
private  
>VPropertyprivatestring $sContent
String contains value of stored content in database in this case this is the config xml document which is later parsed and its settings were stored in $aSettings
Details
Type
string
Access
private  
>VPropertyprivatestring $sUseXHTML
print XHTML
Details
Type
string
Access
private  

Methods

methodpublic__construct(string $sContent, integer $iNumberOfCms, integer $iIdArtLang, array $sEditLink, array $aCfg, array $oDB, string $sContenidoLang, integer $iClient, integer $iLang, array $aCfgClient,  $oSess) : void

Constructor of class inits some important class variables and gets some Contenido global vars, so this class has no need to use ugly and buggy global commands

Parameters
NameTypeDescription
$sContentstring
  • xml document from database containing teaser settings
$iNumberOfCmsinteger
  • CMS_TEASER[4] => 4
$iIdArtLanginteger
  • Idartlang of current article
$sEditLinkarray
  • sEditlink for editbuttons, not currently used
$aCfgarray
  • Contenido configuration array
$oDBarray
  • Contenido database object (not used because we need own object (else problems by cross query in same object))
$sContenidoLangstring
  • Contenido Backend language string
$iClientinteger
  • Contenido client id
$iLanginteger
  • Contenido frontend language id
$aCfgClientarray
  • Contenido Client configuration array
$oSess
Details
Access
public  
methodpublicaddModuleTranslations(array $aTranslationStrings) : array
static

Returns all translation strings for mi18n.

Parameters
NameTypeDescription
$aTranslationStringsarray

Array with translation strings

Returns
TypeDescription
arrayTranslation strings
methodprivateencodeForOutput(string $sCode) : string

In Contenido content type code is evaled by php.

To make this possible, this function prepares code for evaluation

Parameters
NameTypeDescription
$sCodestring
  • code to escape
Returns
TypeDescription
string- escaped code
Details
Access
private  
methodprivateextractImage(string $sContent) : \img

When a HTML Code is given for a Teaser image try to find a image in this code and generate Teaser image on that basis

Parameters
NameTypeDescription
$sContentstring
  • HTML string to search image in
Returns
TypeDescription
\imgtag containing scaled image
Details
Access
private  
methodprivatefillTeaserTemplateEntry(object $oArticle, object $oTpl) : boolean

In edit and view mode this function fills teaser template with informations from an Contenido article object

Parameters
NameTypeDescription
$oArticleobject
  • Contenido Article object
$oTplobject
  • Contenido Template object (as reference)
Returns
TypeDescription
boolean- success state of this operation
Details
Access
private  
methodpublicgetAllWidgetEdit() : string

Function is called in editmode of contenido an returns teaser view and editbutton

Returns
TypeDescription
string- escaped html code for further use in contenido and sending to browser
Details
Access
public  
methodpublicgetAllWidgetOutput(boolean $bEditmode = false) : \html

Function is called in edit- and viewmode in order to generate teasercode for output

Parameters
NameTypeDescription
$bEditmodeboolean
  • in editmode skip encoding because it is done in getAllWidgetEdit()
Returns
TypeDescription
\htmlstring of select box
Details
Access
public  
methodpublicgetAllWidgetView() : string

Dynamic filelist generator.

This method is executed every time the filelist is displayed.

Returns
TypeDescription
stringoutput of the filelist
methodprivategetArtContent(object $oArticle, string $sIdType, integer $iIdType) : string

Teaser allows to get a list of ids in which article content is searched in article like 1,2,5,6 the result with largest character count is returned

Parameters
NameTypeDescription
$oArticleobject
  • Contenido article object
$sIdTypestring
  • Name of Content type to extract informations from
$iIdTypeinteger
  • list of ids to search in
Returns
TypeDescription
string- largest result of content
Details
Access
private  
methodprivategetArtName(integer $iIdArt) : string

Function retrives name of an article by its id from database

Parameters
NameTypeDescription
$iIdArtinteger
  • Contenido article id
Returns
TypeDescription
string- name of article
Details
Access
private  
methodprivategetCountSelect(string $sSelected) : \html

Function which generated a select box for setting number of articles which were displayed in teaser as a maximum.

Only important in editmode

Parameters
NameTypeDescription
$sSelectedstring
  • value of select box which is selected
Returns
TypeDescription
\htmlstring of select box
Details
Access
private  
methodprivategetCropSelect(string $sSelected) : \html

Function which provides select option for cropping teaser images

Parameters
NameTypeDescription
$sSelectedstring
  • value of select box which is selected
Returns
TypeDescription
\htmlstring of select box
Details
Access
private  
methodprivategetImage(integer $iImage, integer $iMaxX, integer $iMaxY,  $bCropped, boolean $bIsFile = false) : string

Function gets path to an image of base of idupload in contenido, scales this image on basis of teaser settings and returns path to scaled image.

It is also possible to give path to image directly, in this case set fourth parameter to true

Parameters
NameTypeDescription
$iImageinteger
  • idupl of image to use for teaser
$iMaxXinteger
  • maximum image width
$iMaxYinteger
  • maximum image height
$bCropped
$bIsFileboolean
  • in case of a direct file path retrival from database is not needed
Returns
TypeDescription
string- <img> tag contains scaled image
Details
Access
private  
methodprivategetSortOrderSelect(string $sSelected) : \html

Function which generated a select box for setting teaser sort order argument

Parameters
NameTypeDescription
$sSelectedstring
  • value of select box which is selected
Returns
TypeDescription
\htmlstring of select box
Details
Access
private  
methodprivategetSortSelect(string $sSelected) : \html

Function which generated a select box for setting teaser sort argument

Parameters
NameTypeDescription
$sSelectedstring
  • value of select box which is selected
Returns
TypeDescription
\htmlstring of select box
Details
Access
private  
methodprivategetStyleSelect(string $sSelected) : \html

Function which generated a select box for setting teaser style currently two seperate teaser templates were supported

Parameters
NameTypeDescription
$sSelectedstring
  • value of select box which is selected
Returns
TypeDescription
\htmlstring of select box
Details
Access
private  
methodprivategetTypeSelect(\unknown_type $sSelectName, string $sSelected, string $sValue) : \html

Teaser gets informations from other articles and their content typs Function builds a select box in which coresponding cms type can be selected after that a text box is rendered for setting id for this conent type to get informations from.

This function is used three times for source defintion of headline text and teaserimage

Parameters
NameTypeDescription
$sSelectName\unknown_type
  • name of input elements
$sSelectedstring
  • value of select box which is selected
$sValuestring
  • current value of text box
Returns
TypeDescription
\htmlstring of select box
Details
Access
private  
methodprivateinitCmsTypes() : void

Function which gets all currenty avariable content types and their ids from database and store it into class variable aCMSTypes.

Because this information is used multiple, this way causes a better performance to get this information seperately

Details
Access
private  
methodprivatereadSettings() : void

Functen parses XML Document which contains teaser settings and store properties as array into $aSettings

Details
Access
private  
methodprivatesetDefaultValues() : void

Function sets some default values for teaser in case that there is no value definied

Details
Access
private  
methodprivatestoreTeaser() : void

Function gets all submitted values for new teaser properties from $_POST array, generates new corresponding config XML Document and stores it as content, using contenido conSaveContentEntry() function

Details
Access
private  
Documentation was generated by phpDocumentor 2.0.0a12.