PHP Class Jonah_Driver_Sql, horde

The table structure can be created by the scripts/db/jonah_news.sql script. The needed tables are jonah_channels and jonah_stories. Copyright 2002-2015 Horde LLC (http://www.horde.org/) See the enclosed file LICENSE for license information (BSD). If you did not did not receive this file, see http://cvs.horde.org/co.php/jonah/LICENSE.
Author: Marko Djukic ([email protected])
Author: Chuck Hagenbuch ([email protected])
Author: Jan Schneider ([email protected])
Author: Ben Klang ([email protected])
Author: Michael J. Rubinsky ([email protected])
Inheritance: extends Jonah_Driver
Datei anzeigen Open project: horde/horde

Protected Properties

Property Type Description
$_connected boolean Boolean indicating whether or not we're connected to the SQL server.
$_db Horde_Db_Adapter_Base Handle for the current database connection.

Public Methods

Method Description
__construct ( $params = [] )
deleteStory ( $channel_id, $story_id )
getChannelId ( string $channel ) : integer Look up a channel ID by its name
getLatestStoryId ( integer $channel_id ) : integer Gets the latest released story from a given internal channel
getStoryCount ( integer $channel_id ) : integer Returns the total number of stories in the specified channel.
saveChannel ( array &$info ) : integer Saves a channel to the backend.

Protected Methods

Method Description
_addPermalink ( array &$story ) Adds a missing permalink to a story.
_connect ( ) : boolean Attempts to open a persistent connection to the SQL server.
_convertFromBackend ( array $story ) : array Converts the text fields of a story from the backend charset to the output charset.
_deleteChannel ( integer $channel_id ) : boolean. Remove a channel from storage.
_getChannel ( $channel_id ) : array Retrieve a single channel definition from storage.
_getChannels ( ) : array Get a list of stored channels.
_getIdBySlug ( string $slug ) : integer Obtain a channel id from a slug
_getStories ( array $criteria, $order = Jonah::ORDER_PUBLISHED ) : array Returns a list of stories from the storage backend filtered by arbitrary criteria.
_getStory ( integer $story_id, boolean $read = false ) : The Retrieve a story from storage.
_getStoryIdsByChannel ( $channel_id )
_readStory ( integer $story_id ) Increment the story's read count.
_saveStory ( &$info ) Save a story to storage.
_timestampChannel ( integer $channel_id, integer $timestamp ) : boolean Update the channel's timestamp

Method Details

__construct() public method

public __construct ( $params = [] )

_connect() protected method

Attempts to open a persistent connection to the SQL server.
protected _connect ( ) : boolean
return boolean True on success.

_convertFromBackend() protected method

Converts the text fields of a story from the backend charset to the output charset.
protected _convertFromBackend ( array $story ) : array
$story array A story hash.
return array The converted hash.

_deleteChannel() protected method

Remove a channel from storage.
protected _deleteChannel ( integer $channel_id ) : boolean.
$channel_id integer The channel to remove.
return boolean.

_getChannel() protected method

Retrieve a single channel definition from storage.
protected _getChannel ( $channel_id ) : array
return array The channel definition array.

_getChannels() protected method

Get a list of stored channels.
protected _getChannels ( ) : array
return array An array of channel hashes.

_getIdBySlug() protected method

Obtain a channel id from a slug
protected _getIdBySlug ( string $slug ) : integer
$slug string The slug to search for.
return integer The channel id.

_getStories() protected method

NOTE: $criteria['channel_id'] MUST be set for this method to work.
protected _getStories ( array $criteria, $order = Jonah::ORDER_PUBLISHED ) : array
$criteria array
return array

_getStory() protected method

Retrieve a story from storage.
protected _getStory ( integer $story_id, boolean $read = false ) : The
$story_id integer They story id.
$read boolean Increment the read counter?
return The story array.

_getStoryIdsByChannel() protected method

protected _getStoryIdsByChannel ( $channel_id )

_readStory() protected method

Increment the story's read count.
protected _readStory ( integer $story_id )
$story_id integer The story_id to increment.

_saveStory() protected method

Save a story to storage.
protected _saveStory ( &$info )

_timestampChannel() protected method

Update the channel's timestamp
protected _timestampChannel ( integer $channel_id, integer $timestamp ) : boolean
$channel_id integer The channel id.
$timestamp integer The new timestamp.
return boolean

deleteStory() public method

public deleteStory ( $channel_id, $story_id )

getChannelId() public method

Look up a channel ID by its name
public getChannelId ( string $channel ) : integer
$channel string
return integer Channel ID

getLatestStoryId() public method

Gets the latest released story from a given internal channel
public getLatestStoryId ( integer $channel_id ) : integer
$channel_id integer The channel id.
return integer The story id.

getStoryCount() public method

Returns the total number of stories in the specified channel.
public getStoryCount ( integer $channel_id ) : integer
$channel_id integer The Channel Id
return integer The count

saveChannel() public method

Saves a channel to the backend.
public saveChannel ( array &$info ) : integer
$info array The channel to add. Must contain a combination of the following entries:
'channel_id'       If empty a new channel is being added, otherwise one
                   is being edited.
'channel_slug'     The channel slug.
'channel_name'     The headline.
'channel_desc'     A description of this channel.
'channel_interval' If external then interval at which to refresh.
'channel_link'     The link to the source.
'channel_url'      The url from where to fetch the story list.
'channel_image'    A channel image.
return integer The channel ID.

Property Details

$_connected protected_oe property

Boolean indicating whether or not we're connected to the SQL server.
protected bool $_connected
return boolean

$_db protected_oe property

Handle for the current database connection.
protected Horde_Db_Adapter_Base $_db
return Horde_Db_Adapter_Base