| alpha--model

# Class: ArticleObject Source Location: /model/ArticleObject.inc ## Class ArticleObject Class Overview
An article class for the CMS Located in /model/ArticleObject.inc [line 54]
    AlphaDAO
       |
       --ArticleObject
Author(s): John Collins <dev@alphaframework.org> Information Tags:
Version: | $Id: ArticleObject.inc 1453 2011-12-04 15:12:54Z johnc $
Copyright: | Copyright (c) 2011, John Collins (founder of Alpha Framework). All rights reserved.
     Redistribution and use in source and binary forms, with or
     without modification, are permitted provided that the
     following conditions are met:

     * Redistributions of source code must retain the above
       copyright notice, this list of conditions and the
       following disclaimer.
     * Redistributions in binary form must reproduce the above
       copyright notice, this list of conditions and the
       following disclaimer in the documentation and/or other
       materials provided with the distribution.
     * Neither the name of the Alpha Framework nor the names
       of its contributors may be used to endorse or promote
       products derived from this software without specific
       prior written permission.

     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
     CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
     INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
     CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
     OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
     SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Since: | 1.0
License: | The BSD License
| Properties $author $bodyOnload $comments $content $dataLabels $description $headerContent $printURL $published $section $taggedAttributes $tags $title $URL $votes | Methods __construct after_loadByAttribute_callback after_load_callback after_save_callback checkUserVoted createAttachmentsFolder getArticleComments getArticleScore getArticleVotes getAttachmentSecureURL getAttachmentsLocation getAttachmentsURL getContentFileDate isLoadedFromFile loadContentFromFile loadRecentWithLimit
[ Top ] Inherited Properties, Constants, and Methods
Inherited Properties | Inherited Methods | Inherited Constants
--- | --- | ---
Inherited From AlphaDAO AlphaDAO::$created_by AlphaDAO::$created_ts AlphaDAO::$defaultAttributes AlphaDAO::$lastQuery AlphaDAO::$OID AlphaDAO::$transientAttributes AlphaDAO::$uniqueAttributes AlphaDAO::$updated_by AlphaDAO::$updated_ts AlphaDAO::$version_num | Inherited From AlphaDAO AlphaDAO::__construct() The constructor which sets up some housekeeping attributes AlphaDAO::addProperty() Adds in a new class property without loosing existing data (does an ALTER TABLE query on the database). AlphaDAO::addToCache() Stores the business object to the configured cache instance AlphaDAO::begin() Starts a new database transaction. AlphaDAO::cast() Cast a BO to another type of BO. A new BO will be returned with the same OID and version_num as the old BO, so this is NOT a true cast but is a copy. All attribute values will be copied accross. AlphaDAO::checkBOTableExists() Static method to check the database and see if the table for the indicated BO class name exists (assumes table name will be $BOClassName less "Object"). AlphaDAO::checkClassDefExists() Checks if the definition for the BO class name provided exists on the file system. AlphaDAO::checkRecordExists() Checks that a record exists for the BO in the database. AlphaDAO::checkTableExists() Checks to see if the table exists in the database for the current business class. AlphaDAO::checkTableNeedsUpdate() Checks to see if the table in the database matches (for fields) the business class definition, i.e. if the database table is in sync with the class definition. AlphaDAO::commit() Commits the current database transaction. AlphaDAO::createForeignIndex() Creates a foreign key constraint (index) in the database on the given attribute. AlphaDAO::createUniqueIndex() Creates a unique index in the database on the given attribute(s). AlphaDAO::delete() Deletes the current object from the database. AlphaDAO::deleteAllByAttribute() Delete all object instances from the database by the specified attribute matching the value provided. AlphaDAO::disconnect() Disconnects the current database connection if one exists AlphaDAO::dropTable() Drops the table if the model requirements have changed. All data is lost! AlphaDAO::findMissingFields() Returns an array containing any properties on the class which have not been created on the database table yet. AlphaDAO::get() Generic getter method for accessing class properties. Will use the method get.ucfirst($prop) instead if that method exists at a child level (by default). Set $noChildMethods to true if you don't want to use any get.ucfirst($prop) method even if it exists, false otherwise (default). AlphaDAO::getBOClassNames() Loops over the core and custom BO directories and builds an array of all of the BO class names in the system. AlphaDAO::getConnection() Gets the current connection singleton, or creates a new one if none exists AlphaDAO::getCount() Gets the count from the database for the amount of objects of this class. AlphaDAO::getCreateTS() Method for getting the date/time of when the BO was created. AlphaDAO::getCreatorId() Method for getting the OID of the person who created this BO. AlphaDAO::getDataLabel() Gets the data label for the given attribute name. AlphaDAO::getDataLabels() Gets the data labels array. AlphaDAO::getDefaultAttributes() Get the array of default attribute names. AlphaDAO::getFriendlyClassName() Converts "BusinessObject" to "Business" and returns. AlphaDAO::getID() Gets the OID for the object in zero-padded format (same as getOID()). This version is designed to be overridden in case you want to do something different with the ID of your objects outside of the standard 11 digit OID sequence used internally in Alpha. AlphaDAO::getIndexes() Gets an array of all of the names of the active database indexes for this class. AlphaDAO::getLastQuery() Get the last database query run on this object. AlphaDAO::getMAX() Gets the maximum OID value from the database for this class type. AlphaDAO::getOID() Gets the OID for the object in zero-padded format (same as getID()). This version is final so cannot be overridden. AlphaDAO::getPersistentAttributes() Get the array of persistent attribute names, i.e. those that are saved in the database. AlphaDAO::getPropObject() Gets the property object rather than the value for complex attributes. Returns false if the property exists but is private. AlphaDAO::getTableName() Getter for the TABLE_NAME, which should be set by a child of this class. AlphaDAO::getTransientAttributes() Get the array of transient attribute names. AlphaDAO::getUniqueAttributes() Returns the array of names of unique attributes on this BO AlphaDAO::getUpdateTS() Method for getting the date/time of when the BO was last updated. AlphaDAO::getUpdatorId() Method for getting the OID of the person who updated this BO. AlphaDAO::getVersion() Gets the version_num of the object from the database (returns 0 if the BO is not saved yet). AlphaDAO::getVersionNumber() Method for getting version number of the object. AlphaDAO::hasAttribute() Check to see if an attribute exists on the BO. AlphaDAO::isInstalled() Static method that tries to determine if the system database has been installed or not. AlphaDAO::isTableOverloaded() Checks to see if the table name matches the classname, and if not if the table name matches the classname name of another BO, i.e. the table is used to store multiple types of BOs. AlphaDAO::isTagged() Returns true if the BO has a Relation property called tags, false otherwise. AlphaDAO::isTransient() Inspector to see if the business object is transient (not presently stored in the database). AlphaDAO::load() Populates the child object with the properties retrived from the database for the object $OID. AlphaDAO::loadAll() Loads all of the objects of this class into an array which is returned. AlphaDAO::loadAllByAttribute() Loads all of the objects of this class by the specified attribute into an array which is returned. AlphaDAO::loadAllByAttributes() Loads all of the objects of this class by the specified attributes into an array which is returned. AlphaDAO::loadAllByDayUpdated() Loads all of the objects of this class that where updated (updated_ts value) on the date indicated. AlphaDAO::loadAllFieldValuesByAttribute() Loads all of the specified attribute values of this class by the specified attribute into an array which is returned. AlphaDAO::loadByAttribute() Populates the child object from the database table by the given attribute value. AlphaDAO::loadClassDef() Loads the definition from the file system for the BO class name provided. AlphaDAO::loadFromCache() Attempts to load the business object from the configured cache instance AlphaDAO::makeTable() Builds a new database table for the BO class. AlphaDAO::markPersistent() Removes the name of the attribute provided from the list of transient (non-saved) attributes for this BO, ensuring that it will be saved on the next attempt. AlphaDAO::markTransient() Adds the name of the attribute provided to the list of transient (non-saved) attributes for this BO. AlphaDAO::markUnique() Adds the name of the attribute(s) provided to the list of unique (constrained) attributes for this BO. AlphaDAO::populateFromPost() Populates the current business object from global POST data. AlphaDAO::query() Returns a 2d array, where each element in the array is another array representing a database row. AlphaDAO::rebuildTable() Re-builds the table if the model requirements have changed. All data is lost! AlphaDAO::reload() Reloads the object from the database, overwritting any attribute values in memory. AlphaDAO::removeFromCache() Removes the business object from the configured cache instance AlphaDAO::rollback() Aborts the current database transaction. AlphaDAO::save() Saves the object. If $this->OID is empty or null it will INSERT, otherwise UPDATE. AlphaDAO::saveAttribute() Saves the field specified with the value supplied. Only works for persistent BOs. Note that no Alpha type validation is performed with this method! AlphaDAO::set() Generic setter method for setting class properties. Will use the method set.ucfirst($prop) instead if that method exists at a child level (by default). Set $noChildMethods to true if you don't want to use any get.ucfirst($prop) method even if it exists, false otherwise (default). AlphaDAO::setEnumOptions() Populate all of the enum options for this object from the database. AlphaDAO::setLastQuery() Sets the last query executed on this business object AlphaDAO::setOID() Setter for the Object ID (OID) AlphaDAO::validate() Validates the object to be saved. |
[ Top ] Constant Summary
TABLE_NAME | The name of the database table for the class
[ Top ] Property Summary
String | $author | The author of the article
String | $bodyOnload | Optional custom body onload Javascript
Relation | $comments | A Relation containing all of the comments on this article
Text | $content | The article content
array | $dataLabels | An array of data display labels for the class properties
String | $description | The description of the article
Text | $headerContent | Any custom HTML header content (e.g. Javascript) for the article
string | $printURL | The print URL for this article (transient)
Boolean | $published | A boolean to control whether the artcile is publically accessible or not
DEnum | $section | The article site section
array | $taggedAttributes | An array of all of the attributes on this BO which are tagged
Relation | $tags | A Relation containing all of the tags on this article
String | $title | The article title
string | $URL | The URL for this article (transient)
Relation | $votes | A Relation containing all of the votes on this article
[ Top ] Method Summary
ArticleObject | __construct() | The constructor which sets up some housekeeping attributes
void | after_loadByAttribute_callback() | Set up the transient URL attributes for the artcile after it has loaded
void | after_load_callback() | Set up the transient URL attributes for the article after it has loaded
void | after_save_callback() | After creating a new ArticleObject, tokenize the description field to form a set of automated tags and save them.
boolean | checkUserVoted() | Method to determine if the logged-in user has already voted for this article
void | createAttachmentsFolder() | Creates the attachment folder for the article on the server.
array | getArticleComments() | Method for fetching all of the comments for this article
double | getArticleScore() | Method for returning the calculated score for this article
array | getArticleVotes() | Method for fetching all of the votes for this article
void | getAttachmentSecureURL() | Generates a secure URL for downloading an attachment file via the ViewAttachment controller
string | getAttachmentsLocation() | Generates the location of the attachments folder for this article
string | getAttachmentsURL() | Generates the URL of the attachments folder for this article
string | getContentFileDate() | Returns the timestamp of when the content .text file for this article was last modified.
boolean | isLoadedFromFile() | Returns true if the article content was loaded from a .text file, false otherwise.
void | loadContentFromFile() | Loads the content of the ArticleObject from the specified file path
array | loadRecentWithLimit() | Gets an array of the OIDs of the most recent articles added to the system (by date), from the newest article to the amount specified by the $limit
[ Top ] Properties String $author [line 109] The author of the article API Tags:
Access: | protected
Information Tags:
Since: | 1.0
[ Top ] String $bodyOnload [line 85] Optional custom body onload Javascript API Tags:
Access: | protected
Information Tags:
Since: | 1.0
[ Top ] Relation $comments [line 125] A Relation containing all of the comments on this article API Tags:
Access: | protected
Information Tags:
Since: | 1.0
[ Top ] Text $content [line 101] The article content API Tags:
Access: | protected
Information Tags:
Since: | 1.0
[ Top ] array $dataLabels = array("OID"=>"Article ID#","title"=>"Title","section"=>"Site Section","description"=>"Description","bodyOnload"=>"Body onload Javascript","content"=>"Content","headerContent"=>"HTML Header Content","author"=>"Author","created_ts"=>"Date Added","updated_ts"=>"Date of last Update","published"=>"Published","URL"=>"URL","printURL"=>"Printer version URL","comments"=>"Comments","votes"=>"Votes","tags"=>"Tags") [line 165] An array of data display labels for the class properties API Tags:
Access: | protected
Information Tags:
Since: | 1.0
Redefinition of: AlphaDAO::$dataLabels An array of the data labels used for displaying class attributes [ Top ] String $description [line 77] The description of the article API Tags:
Access: | protected
Information Tags:
Since: | 1.0
[ Top ] Text $headerContent [line 93] Any custom HTML header content (e.g. Javascript) for the article API Tags:
Access: | protected
Information Tags:
Since: | 1.0
[ Top ] string $printURL [line 189] The print URL for this article (transient) API Tags:
Access: | protected
Information Tags:
Since: | 1.0
[ Top ] Boolean $published [line 117] A boolean to control whether the artcile is publically accessible or not API Tags:
Access: | protected
Information Tags:
Since: | 1.0
[ Top ] DEnum $section [line 69] The article site section API Tags:
Access: | protected
Information Tags:
Since: | 1.0
[ Top ] array $taggedAttributes = array('title', 'description', 'content') [line 149] An array of all of the attributes on this BO which are tagged API Tags:
Access: | protected
Information Tags:
Since: | 1.0
[ Top ] Relation $tags [line 141] A Relation containing all of the tags on this article API Tags:
Access: | protected
Information Tags:
Since: | 1.0
[ Top ] String $title [line 61] The article title API Tags:
Access: | protected
Information Tags:
Since: | 1.0
[ Top ] string $URL [line 181] The URL for this article (transient) API Tags:
Access: | protected
Information Tags:
Since: | 1.0
[ Top ] Relation $votes [line 133] A Relation containing all of the votes on this article API Tags:
Access: | protected
Information Tags:
Since: | 1.0
[ Top ] Methods Constructor __construct [line 204]
`ArticleObject __construct( )`
The constructor which sets up some housekeeping attributes API Tags:
Access: | public
Information Tags:
Since: | 1.0
Redefinition of: AlphaDAO::__construct() The constructor which sets up some housekeeping attributes [ Top ] after_loadByAttribute_callback [line 302]
`void after_loadByAttribute_callback( )`
Set up the transient URL attributes for the artcile after it has loaded API Tags:
Access: | protected
Information Tags:
Since: | 1.0
[ Top ] after_load_callback [line 311]
`void after_load_callback( )`
Set up the transient URL attributes for the article after it has loaded API Tags:
Access: | protected
Information Tags:
Since: | 1.0
[ Top ] after_save_callback [line 276]
`void after_save_callback( )`
After creating a new ArticleObject, tokenize the description field to form a set of automated tags and save them. API Tags:
Access: | protected
Information Tags:
Since: | 1.0
[ Top ] checkUserVoted [line 471]
`boolean checkUserVoted( )`
Method to determine if the logged-in user has already voted for this article API Tags:
Return: | True if they have voted already, false otherwise
Access: | public
Information Tags:
Since: | 1.0
Throws: | AlphaException
[ Top ] createAttachmentsFolder [line 413]
`void createAttachmentsFolder( )`
Creates the attachment folder for the article on the server. API Tags:
Access: | public
Information Tags:
Since: | 1.0
Throws: | AlphaException
[ Top ] getArticleComments [line 503]
`array getArticleComments( )`
Method for fetching all of the comments for this article API Tags:
Return: | An array of ArticleCommentObject objects
Access: | public
Information Tags:
Since: | 1.0
[ Top ] getArticleScore [line 435]
`double getArticleScore( )`
Method for returning the calculated score for this article API Tags:
Access: | public
Information Tags:
Since: | 1.0
[ Top ] getArticleVotes [line 458]
`array getArticleVotes( )`
Method for fetching all of the votes for this article API Tags:
Return: | An array of ArticleVoteObject objects
Access: | public
Information Tags:
Since: | 1.0
[ Top ] getAttachmentSecureURL [line 401]
`void getAttachmentSecureURL( string $filename )`
Generates a secure URL for downloading an attachment file via the ViewAttachment controller Parameters:
string | $filename: |
API Tags:
Access: | public
Information Tags:
Since: | 1.0
[ Top ] getAttachmentsLocation [line 377]
`string getAttachmentsLocation( )`
Generates the location of the attachments folder for this article API Tags:
Access: | public
Information Tags:
Since: | 1.0
[ Top ] getAttachmentsURL [line 389]
`string getAttachmentsURL( )`
Generates the URL of the attachments folder for this article API Tags:
Access: | public
Information Tags:
Since: | 1.0
[ Top ] getContentFileDate [line 543]
`string getContentFileDate( )`
Returns the timestamp of when the content .text file for this article was last modified. API Tags:
Access: | public
Information Tags:
Since: | 1.0
Throws: | FileNotFoundException
[ Top ] isLoadedFromFile [line 531]
`boolean isLoadedFromFile( )`
Returns true if the article content was loaded from a .text file, false otherwise. API Tags:
Access: | public
Information Tags:
Since: | 1.0
[ Top ] loadContentFromFile [line 516]
`void loadContentFromFile( $filePath $filePath )`
Loads the content of the ArticleObject from the specified file path Parameters:
$filePath | $filePath: |
API Tags:
Access: | public
Information Tags:
Since: | 1.0
Throws: | FileNotFoundException
[ Top ] loadRecentWithLimit [line 355]
`array loadRecentWithLimit( $limit )`
Gets an array of the OIDs of the most recent articles added to the system (by date), from the newest article to the amount specified by the $limit Parameters:
| $limit: |
API Tags:
Access: | public
Information Tags:
Since: | 1.0
Throws: | AlphaException
[ Top ] Constants TABLE_NAME = 'Article' [line 173] The name of the database table for the class Information Tags:
Since: | 1.0
[ Top ] Documentation generated on Tue, 13 Dec 2011 20:26:26 +0000 by phpDocumentor 1.4.3