Geeklog
[ class tree: Geeklog ] [ index: Geeklog ] [ all elements ]

Class: Story

Source Location: /system/classes/story.class.php

Class Overview




Variables

Methods



Class Details

[line 86]


[ Top ]


Class Variables

$mode =  'admin'

[line 96]

Mode, either 'admin' for in the admin screens, or submission, for when the user is using submit.php. Controls tons of stuff.


Type:   mixed


[ Top ]

$type =  'article'

[line 102]

Type of story. User submission or normal editor entered stuff.

Will be 'submission' if it's from the submission queue.



Type:   mixed


[ Top ]

$_access =

[line 162]

The access level.


Type:   mixed


[ Top ]

$_advanced_editor_mode =

[line 133]


Type:   mixed


[ Top ]

$_bodytext =

[line 115]


Type:   mixed


[ Top ]

$_cache_time =

[line 135]


Type:   mixed


[ Top ]

$_commentcode =

[line 129]


Type:   mixed


[ Top ]

$_comments =

[line 124]


Type:   mixed


[ Top ]

$_comment_expire =

[line 123]


Type:   mixed


[ Top ]

$_date =

[line 120]


Type:   mixed


[ Top ]

$_dbFields = array(
        'sid'                  => 1,
        'uid'                  => 1,
        'draft_flag'           => 1,
        'date'                 => 1,
        'title'                => 1,
        'page_title'           => 1,
        'meta_description'     => 1,
        'meta_keywords'        => 1,
        'introtext'            => 1,
        'bodytext'             => 1,
        'text_version'         => 1,
        'hits'                 => 1,
        'numemails'            => 1,
        'comments'             => 1,
        'trackbacks'           => 1,
        'related'              => 1,
        'featured'             => 1,
        'show_topic_icon'      => 1,
        'commentcode'          => 1,
        'comment_expire'       => 1,
        'trackbackcode'        => 1,
        'statuscode'           => 1,
        'expire'               => 1,
        'postmode'             => 1,
        'advanced_editor_mode' => 1,
        'frontpage'            => 1,
        'cache_time'           => 1,
        'owner_id'             => 1,
        'group_id'             => 1,
        'perm_owner'           => 1,
        'perm_group'           => 1,
        'perm_members'         => 1,
        'perm_anon'            => 1,
        'imageurl'             => 0,
        'tid'                  => 0,
        'topic'                => 0,
        'access'               => 0,
        'photo'                => 0,
        'email'                => 0,
    )

[line 179]

Magic array used for cheating when loading/saving stories from/to db.

List of database field names (which are translated into member variables by prepending _ to the value) as pointers to whether or not they are used to save data. Everything with a save value of 1 will be saved, those with a save value of 0 will just be loaded. This allows us to automate the loading of story, user and topic from a database result array, and generate saving of a story, from the same magic array.



Type:   mixed


[ Top ]

$_draft_flag =

[line 119]


Type:   mixed


[ Top ]

$_email =

[line 149]


Type:   mixed


[ Top ]

$_expire =

[line 132]


Type:   mixed


[ Top ]

$_featured =

[line 127]


Type:   mixed


[ Top ]

$_frontpage =

[line 134]


Type:   mixed


[ Top ]

$_fullname =

[line 147]


Type:   mixed


[ Top ]

$_group_id =

[line 137]


Type:   mixed


[ Top ]

$_hits =

[line 121]


Type:   mixed


[ Top ]

$_imageurl =

[line 152]


Type:   mixed


[ Top ]

$_introtext =

[line 114]


Type:   mixed


[ Top ]

$_meta_description =

[line 112]


Type:   mixed


[ Top ]

$_meta_keywords =

[line 113]


Type:   mixed


[ Top ]

$_numemails =

[line 122]


Type:   mixed


[ Top ]

$_originalSid =

[line 157]

The original SID of the article, cached incase it's changed:


Type:   mixed


[ Top ]

$_owner_id =

[line 136]


Type:   mixed


[ Top ]

$_page_title =

[line 111]


Type:   mixed


[ Top ]

$_perm_anon =

[line 141]


Type:   mixed


[ Top ]

$_perm_group =

[line 139]


Type:   mixed


[ Top ]

$_perm_members =

[line 140]


Type:   mixed


[ Top ]

$_perm_owner =

[line 138]


Type:   mixed


[ Top ]

$_photo =

[line 148]


Type:   mixed


[ Top ]

$_postFields = array(
        'uid'              => array(
            STORY_AL_NUMERIC,
            '_uid',
        ),//'tid' => array
//   (
//     STORY_AL_ALPHANUM,
//     '_tid'
//   ),
'page_title'=>array(STORY_AL_ANYTHING,'_page_title',),'meta_description'=>array(STORY_AL_ANYTHING,'_meta_description',),'meta_keywords'=>array(STORY_AL_ANYTHING,'_meta_keywords',),'show_topic_icon'=>array(STORY_AL_CHECKBOX,'_show_topic_icon',),'draft_flag'=>array(STORY_AL_CHECKBOX,'_draft_flag',),'statuscode'=>array(STORY_AL_NUMERIC,'_statuscode',),'featured'=>array(STORY_AL_NUMERIC,'_featured',),'frontpage'=>array(STORY_AL_NUMERIC,'_frontpage',),'commentcode'=>array(STORY_AL_NUMERIC,'_commentcode',),'trackbackcode'=>array(STORY_AL_NUMERIC,'_trackbackcode',),'postmode'=>array(STORY_AL_ALPHANUM,'_postmode',),'story_hits'=>array(STORY_AL_NUMERIC,'_hits',),'story_comments'=>array(STORY_AL_NUMERIC,'_comments',),'story_emails'=>array(STORY_AL_NUMERIC,'_numemails',),'story_trackbacks'=>array(STORY_AL_NUMERIC,'_trackbacks',),'cache_time'=>array(STORY_AL_NUMERIC,'_cache_time',),'owner_id'=>array(STORY_AL_NUMERIC,'_owner_id',),'group_id'=>array(STORY_AL_NUMERIC,'_group_id',),'type'=>array(STORY_AL_ALPHANUM,'type',),'hits'=>array(STORY_AL_NUMERIC,'_hits',),'comments'=>array(STORY_AL_NUMERIC,'_comments',),'trackbacks'=>array(STORY_AL_NUMERIC,'_trackbacks',),)

[line 225]

Magic array used for loading basic data from posted form. Of form:

postfield -> numeric, target, used with COM_applyFilter. Some fields have exceptions applied



Type:   mixed


[ Top ]

$_postmode =

[line 117]


Type:   mixed


[ Top ]

$_related =

[line 126]


Type:   mixed


[ Top ]

$_show_topic_icon =

[line 128]


Type:   mixed


[ Top ]

$_sid =

[line 109]

PRIVATE MEMBER VARIABLES: Things that make up a story.


Type:   mixed


[ Top ]

$_statuscode =

[line 131]


Type:   mixed


[ Top ]

$_storyImages =

[line 167]

Array of images uploaded for the story.


Type:   mixed


[ Top ]

$_text_version =

[line 116]


Type:   mixed


[ Top ]

$_tid =

[line 150]


Type:   mixed


[ Top ]

$_title =

[line 110]


Type:   mixed


[ Top ]

$_topic =

[line 151]


Type:   mixed


[ Top ]

$_trackbackcode =

[line 130]


Type:   mixed


[ Top ]

$_trackbacks =

[line 125]


Type:   mixed


[ Top ]

$_uid =

[line 118]


Type:   mixed


[ Top ]

$_username =

[line 146]

Misc display fields we also load from the database for a story:


Type:   mixed


[ Top ]



Class Methods


static method getRelatedArticlesByKeywords [line 1900]

static array getRelatedArticlesByKeywords( string $articleId, string $keywordList, [int $limit = 5])

Return a list of articles that have some relation with the article ID given



Tags:



Parameters:

string   $articleId  
string   $keywordList   a comma-separated list of keywords
int   $limit   max number od related articles

[ Top ]

constructor __construct [line 337]

Story __construct( [$mode $mode = 'admin'])

Constructor, creates a story, taking a (geeklog) database object.



Tags:

access:  public


Parameters:

$mode   $mode   string Story class mode, either 'admin' or 'submission'

[ Top ]

method checkAccess [line 1872]

int checkAccess( )

Perform a security check and return permission level.

saves the bother of accessing dozen's of vars.




Tags:

return:  access level for this story


[ Top ]

method checkAttachedImages [line 1327]

array checkAttachedImages( )

Check if using attached images



Tags:

return:  containing errors, or empty.


[ Top ]

method DisplayElements [line 1731]

mixed DisplayElements( [string $item = 'title'])

Provide access to story elements. For display.

This is a peudo-property, implementing a getter for story details as if as an associative array. Personally, I'd rather be able to assign getters and setters to actual properties to mask controlled access to private member variables. But, you get what you get with PHP. So here it is in all it's nastyness.




Tags:

return:  The clean and ready to use value requested.


Parameters:

string   $item   Item to fetch.

[ Top ]

method EditElements [line 1508]

mixed EditElements( [string $item = 'title'])

Provide access to story elements. For the editor.

This is a pseudo-property, implementing a getter for story details as if as an associative array. Personally, I'd rather be able to assign getters and setters to actual properties to mask controlled access to private member variables. But, you get what you get with PHP. So here it is in all its nastiness.




Tags:

return:  The clean and ready to use (in edit mode) value requested.


Parameters:

string   $item   Item to fetch.

[ Top ]

method getAccess [line 1491]

void getAccess( )

Get the access level



[ Top ]

method getPreviewText [line 1849]

string getPreviewText( string $item)

Returns text ready for preview.



Tags:

return:  text for preview in edit mode


Parameters:

string   $item   Item to fetch. Valid only bodytext and introtext.

[ Top ]

method getSid [line 1479]

string getSid( [bool $forDb = false])

Return the SID in a clean way



Parameters:

bool   $forDb   boolean True if we want an 'DB_escapeString' version for the db

[ Top ]

method GetSpamCheckFormat [line 1077]

string GetSpamCheckFormat( )

Returns a story formatted for spam check:



Tags:

return:  Story formatted for spam check.


[ Top ]

method hasContent [line 348]

boolean hasContent( )

Check to see if there is any content in the story, for bothering to preview testing really.



Tags:

return:  trim(title+intro+body) != ''


[ Top ]

method initSubmission [line 957]

void initSubmission( )

Sets up basic data for a new user submission story



[ Top ]

method loadFromArgsArray [line 865]

void loadFromArgsArray( &$array)

Loads a story from the post data. This is the most exciting function in the whole entire world. First it'll clean up that horrible Magic Quotes crap. Then it'll do all Geeklog's funky security stuff, anti XSS, anti SQL Injection. Yay.



Parameters:

   &$array  

[ Top ]

method loadFromArray [line 370]

void loadFromArray( $story $story)

Loads a story object from an array (that's come back from the db..) Used from loadFromDatabase, and used on it's own from story list pages.



Parameters:

$story   $story   array Story array from db

[ Top ]

method loadFromDatabase [line 427]

Integer loadFromDatabase( $sid $sid, [ $mode = 'edit'])

Load a Story object from the sid specified, returning a status result.

The result will either be a permission denied message, invalid SID message, or a loaded ok message. If it's loaded ok, then we've got all the exciting gubbins here. Only used from story admin and submit.php!




Tags:

return:  from a constant.


Parameters:

$sid   $sid   string Story Identifier, valid geeklog story id from the db.
   $mode  

[ Top ]

method loadSubmission [line 999]

void loadSubmission( )

Loads a submitted story from postdata



[ Top ]

method renderImageTags [line 1202]

string renderImageTags( string $text)

Replaces all special syntax tags in intro and body with image HTML



Tags:

return:  processed text


Parameters:

string   $text   Intro or Body text

[ Top ]

method replaceImages [line 1376]

string replaceImages( string $text)

This replaces all article image HTML in intro and body with GL special syntax



Tags:

return:  processed text


Parameters:

string   $text   Intro or Body text

[ Top ]

method saveSubmission [line 1087]

integer saveSubmission( )

Saves a story submission.



Tags:

return:  result code explaining behaviour.


[ Top ]

method saveToDatabase [line 692]

Integer saveToDatabase( )

Saves the story in it's final state to the database.

Handles all the SID magic etc.




Tags:

return:  status result from a constant list.


[ Top ]

method _applyTextFilter [line 2194]

void _applyTextFilter( $text, $postmode)



Parameters:

   $text  
   $postmode  

[ Top ]

method _applyTitleFilter [line 2188]

void _applyTitleFilter( $title)



Parameters:

   $title  

[ Top ]

method _sanitizeData [line 2225]

void _sanitizeData( )

Perform some basic cleanups of data, dealing with empty required, defaultable fields.



[ Top ]


Documentation generated on Sun, 02 Oct 2016 07:55:48 +0000 by phpDocumentor 1.4.3