PHP Class ArticleType

The followings are the available columns in table '{{article_type}}':
Inheritance: extends CActiveRecord
Show file Open project: sourcefabric/newscoop Class Usage Examples

Public Methods

Method Description
ArticleType ( string $p_articleType ) An article type is a dynamic table that is created for an article to allow different publications to display their content in different ways.
GetArticleTypes ( boolean $p_includeHidden = false ) : array Get all article types that currently exist.
IsValidFieldName ( string $p_name ) : boolean Static function. Returns TRUE if the given name is valid as an article type name.
SetTypeFilter ( $p_article_type, $p_filter_value ) : boolean Action for setting article type filtering.
__getPreviewTableName ( $p_table ) : string Creates a preview table of PreviewNTablename, where N is a unique integer.
commentsEnabled ( ) : boolean Return TRUE if comments are enabled for this article type.
create ( ) : boolean Create a new Article Type. Creates a new table in the database.
delete ( ) Delete the article type. This will delete the entire table in the database. Not recommended unless there is no article data in the table.
exists ( ) : boolean Return TRUE if the Article Type exists.
getArticlesArray ( ) : array For the preview of merge; this grabs an array of the article numbers for calculating next, previous and current.
getDisplayName ( $p_lang ) : string Gets the translation for a given language; default language is the session language. If no translation is set for that language, we return the dbTableName.
getDisplayNameLanguageCode ( $p_lang ) : string Gets the language code of the current translation language; or none if there is no translation.
getFilterStatus ( ) : boolean Returns whether articles of this type should be filtered out by default at listings.
getMaxSize ( ) : integer Gets the maximum size of a article type
getMetadata ( ) : array Return an associative array of the metadata in ArticleFieldMetadata.
getNumArticles ( ) : integer Returns the number of articles associated with this type.
getPhraseId ( ) : -1 Returns the phrase id of the AT.
getPreviewArticleData ( ) : object Returns an ArticleData object of the first found article of this type.
getStatus ( ) : string Returns 'hidden' if the article type should not be visible, and 'shown' if it should be.
getTableName ( ) : string
getTranslations ( ) : array Parses m_metadata for phrase_ids and returns an array of language_id => translation_text
getTypeName ( ) : string
getUserDefinedColumns ( $p_fieldName = null, $p_selectHidden = true, $p_skipCache = false ) : array Return an array of ArticleTypeField objects.
merge ( $p_src, $p_dest, $p_rules ) : boolean Does the merge or a preview of the merge.
rename ( $p_newName ) Rename the article type. This will move the entire table in the database and update ArticleTypeMetadata. Usually, one wants to just rename the Display Name, which is done via SetDisplayName
setCommentsEnabled ( boolean $p_value ) Return TRUE if comments are enabled for this article type.
setName ( integer $p_languageId, string $p_value ) : boolean Set the type name for the given language. A new entry in the database will be created if the language does not exist.
setStatus ( $p_status ) Sets whether the article type should be visible or hidden.
translationExists ( $p_languageId ) A quick lookup to see if the current language was already translated for this article type: used by delete and update in setName.

Method Details

ArticleType() public method

An article type is a dynamic table that is created for an article to allow different publications to display their content in different ways.
public ArticleType ( string $p_articleType )
$p_articleType string

GetArticleTypes() public static method

Returns an array of strings.
public static GetArticleTypes ( boolean $p_includeHidden = false ) : array
$p_includeHidden boolean
return array

IsValidFieldName() public static method

Static function. Returns TRUE if the given name is valid as an article type name.
public static IsValidFieldName ( string $p_name ) : boolean
$p_name string
return boolean

SetTypeFilter() public static method

Action for setting article type filtering.
public static SetTypeFilter ( $p_article_type, $p_filter_value ) : boolean
return boolean

__getPreviewTableName() public method

Creates a preview table of PreviewNTablename, where N is a unique integer.
public __getPreviewTableName ( $p_table ) : string
return string a tablename

commentsEnabled() public method

Return TRUE if comments are enabled for this article type.
public commentsEnabled ( ) : boolean
return boolean

create() public method

Create a new Article Type. Creates a new table in the database.
public create ( ) : boolean
return boolean

delete() public method

Delete the article type. This will delete the entire table in the database. Not recommended unless there is no article data in the table.
public delete ( )

exists() public method

Return TRUE if the Article Type exists.
public exists ( ) : boolean
return boolean

getArticlesArray() public method

For the preview of merge; this grabs an array of the article numbers for calculating next, previous and current.
public getArticlesArray ( ) : array
return array

getDisplayName() public method

Gets the translation for a given language; default language is the session language. If no translation is set for that language, we return the dbTableName.
public getDisplayName ( $p_lang ) : string
return string

getDisplayNameLanguageCode() public method

Gets the language code of the current translation language; or none if there is no translation.
public getDisplayNameLanguageCode ( $p_lang ) : string
return string

getFilterStatus() public method

Returns whether articles of this type should be filtered out by default at listings.
public getFilterStatus ( ) : boolean
return boolean

getMaxSize() public method

Gets the maximum size of a article type
public getMaxSize ( ) : integer
return integer

getMetadata() public method

Return an associative array of the metadata in ArticleFieldMetadata.
public getMetadata ( ) : array
return array

getNumArticles() public method

Returns the number of articles associated with this type.
public getNumArticles ( ) : integer
return integer

getPhraseId() public method

Returns the phrase id of the AT.
public getPhraseId ( ) : -1
return -1

getPreviewArticleData() public method

If no article was found create an empty one.
public getPreviewArticleData ( ) : object
return object

getStatus() public method

Returns 'hidden' if the article type should not be visible, and 'shown' if it should be.
public getStatus ( ) : string
return string (shown|hidden)

getTableName() public method

public getTableName ( ) : string
return string

getTranslations() public method

Parses m_metadata for phrase_ids and returns an array of language_id => translation_text
public getTranslations ( ) : array
return array

getTypeName() public method

public getTypeName ( ) : string
return string

getUserDefinedColumns() public method

Return an array of ArticleTypeField objects.
public getUserDefinedColumns ( $p_fieldName = null, $p_selectHidden = true, $p_skipCache = false ) : array
return array

merge() public method

The p_rules array is an associative array with the key being the DESTINATION fieldname and the values being the SOURCE fieldname (without Fs). E.g. $p_rules = array('a' => 'a', 'b' => 'title', 'd' => 'body'); p_rules is verified elsewhere (see article_types/merge3.php). If we are doing an actual merge, all that happens is that we rename the Type in Articles from SrcType to DestType and run the merge (p_rules) on the XSrcTable entries and move them over to XDestType. Merged articles have the same ArticleNumber as their originals.
public merge ( $p_src, $p_dest, $p_rules ) : boolean
return boolean

rename() public method

Rename the article type. This will move the entire table in the database and update ArticleTypeMetadata. Usually, one wants to just rename the Display Name, which is done via SetDisplayName
public rename ( $p_newName )
$p_newName

setCommentsEnabled() public method

Return TRUE if comments are enabled for this article type.
public setCommentsEnabled ( boolean $p_value )
$p_value boolean

setName() public method

Set the type name for the given language. A new entry in the database will be created if the language does not exist.
public setName ( integer $p_languageId, string $p_value ) : boolean
$p_languageId integer
$p_value string
return boolean

setStatus() public method

Sets whether the article type should be visible or hidden.
public setStatus ( $p_status )

translationExists() public method

Returns 0 if no translation or the phrase_id if there is one.
public translationExists ( $p_languageId )