Packageindex Classtrees Modulegroups Elementlist Report XML Files

File: /home/inri/public_html/daCode-HEAD/daCode/src/phplib/comments.php3
daCode -

Comments

Comments

This Class will handle comments

 

private class Comments

This Class will handle comments

daCode http://www.dacode.org/
src/phplib/comments.php3
$Id: comments.php3,v 1.226 2002/05/13 21:34:02 jbcombes Exp $

Depends: Config Db Utils Session Html News

AuthorsFabien Penso <penso@linuxfr.org>

 

Public Method Summary

void

Comments([ mixed $w ])

Constructor
integer

init([ integer $res_id, integer $com_id, integer $res_type ])

Will be used to preload few things ...
string

com_print2([ integer $comm_id, integer $com_parent, integer $score, string $type ])

New function which will print comment, have to be used with init()
void

set_score([ string $comments_id_tmp, string $news_id_tmp, string $score_id, string $localuserid ])

This function will set the score. This is when you use system 2
string

ac(array $c, integer $res_id, integer $res_type, [ string $mode ])

This will display comment
void

get_hrefs()

This will return all the urls from comments
string

get_subject(integer $id)

Gets the subject...
void

mod_score(array $row)

Function to modify score
string

show_branch(integer $res_id, integer $com_id, integer $res_type, [ string $list ])

Create the HTML to show all the ancestors of a comment
string

show_subtree(integer $res_id, integer $res_type, integer $com_id)

Creates the HTML for the subtree of $com_id (all heirs of $com_id)
void

count_comments(integer $res_id, [ integer $res_type, string $score ])

Returns the number of comments
array

count_comments_array(array $res_id, [ integer $res_type ])

Returns the number of comments in an hash array
string

mypost([ string $order, string $user_id ])

This mypost function is used to get info on yours recents Posts.
void

numberOfComments(integer $resId, integer $resType, [ integer $score ])

This function determines the number of comments in a human-readable way

Private Method Summary

string

show_score(array $c)

This function will show the score of the comment
void

_com(string $d)

This will get all url in comments
string

com_hrefs([ integer $max_href_chars ])

Shortens URI so that they don't break anything when they are displayed.
array

load_branch(integer $res_id, integer $com_id, integer $res_type, [ string $list ])

Loads all the ancestors of com_id
void

load_subtree(integer $res_id, integer $res_type, integer $com_id)

Loads the subtree - all the heirs - of a comment

Private Field Summary

object Db

$db

Database abstraction layer
array

$com_urls

Array of all URLs in all the comments associateed to a resource
object Html

$html

HTML rendering package
object Utils

$utils

Utils package
object Session

$session

Session handling instance
array

$comments

Array of preloaded comments
string

$HTTP_REFERER

HTTP_REFERER
integer

$news_id

ID of the resource
integer

$res_type

The ressource type of the comments looked after
object User

$user

User instance
object Admin

$admin

Admin instance
object Cache

$cache

Cache abstraction layer
unknown

$news

Public Method Details

Comments

public void Comments( [ mixed $w ] )

  Constructor

Parameter
mixed $w = >>""<<
if not empty, bypasses intitialization
Returns void


init

public integer init( [ integer $res_id, integer $com_id, integer $res_type ] )

  Will be used to preload few things ...

Parameter
integer $res_id = >>0<<
ID of the ressource to which the comments are attached
integer $com_id = >>0<<
ID of the only comment to get.
integer $res_type = >>1<<
the type of resource commented
Returns integer

0 if $new_id is empty.


com_print2

public string com_print2( [ integer $comm_id, integer $com_parent, integer $score, string $type ] )

  New function which will print comment, have to be used with init()

Creates the HTML for all the comments, or a subtree, and make coffee

Parameter
integer $comm_id = >>0<<
of the first comment
integer $com_parent = >>0<<
of the parent comment
integer $score = >>0<<
threshold
string $type = >>"thread"<<
(one out of 'thread', 'thread' and thread' :) )
Returns string

the HTML for the comments


set_score

public void set_score( [ string $comments_id_tmp, string $news_id_tmp, string $score_id, string $localuserid ] )

  This function will set the score. This is when you use system 2
FIXME: can someone explain why all these bloody strings
Calls Exit if user cannot vote, or pb with user, or DB problem

Parameter
string $comments_id_tmp = >>""<<
of comment we want to set score
string $news_id_tmp = >>""<<
news Id but whuy a bloody string???
string $score_id = >>""<<
score to set
string $localuserid = >>""<<
ID
Returns void


ac

public string ac( array $c, integer $res_id, integer $res_type, [ string $mode ] )

  This will display comment
FIXME: public cos used in SubmitComment::preview, but shall it not be private?

Parameter
array $c
the row of the comment, as build by init
integer $res_id
the ressource ID to which it is attached
integer $res_type
the type of the ressource
string $mode = >>"full"<<
"full" to print the comment, "scoredown" to print only the title
Returns string

the HTML representation of the comments to display


get_hrefs

public void get_hrefs( )

  This will return all the urls from comments
Works on Comments::com_url array

Returns void


get_subject

public string get_subject( integer $id )

  Gets the subject...
FIXME: But why is ID considered a string ?!

Parameter
integer $id
Id of the comment
Returns string

the subject


mod_score

public void mod_score( array $row )

  Function to modify score
Calls exit on DB problem

Parameter
array $row
row in comments_scored table
Returns void


show_branch

public string show_branch( integer $res_id, integer $com_id, integer $res_type, [ string $list ] )

  Create the HTML to show all the ancestors of a comment

Parameter
integer $res_id
ID of the resource
integer $com_id
ID of the comment
integer $res_type
type of the resource (see Config::resources)
string $list = >>'all'<<
how the comments are listed (last | all (default))
Returns string

the HTML


show_subtree

public string show_subtree( integer $res_id, integer $res_type, integer $com_id )

  Creates the HTML for the subtree of $com_id (all heirs of $com_id)

Parameter
integer $res_id
of the resource
integer $res_type
of the resource (see Config::resources)
integer $com_id
of the comment
Returns string

HTML for the subtree


count_comments

public void count_comments( integer $res_id, [ integer $res_type, string $score ] )

  Returns the number of comments

Parameter
integer $res_id
the ID of the ressource to which the commetns are attached
integer $res_type = >>1<<
the type of the ressource
string $score = >>"-2"<<
the threshold for counting comments. -2 => default.
Returns void


count_comments_array

public array count_comments_array( array $res_id, [ integer $res_type ] )

  Returns the number of comments in an hash array
=> array [$res_id]["s".$score]

Parameter
array $res_id
the ids to which the comments are attached
integer $res_type = >>1<<
the ressource type
Returns array


mypost

public string mypost( [ string $order, string $user_id ] )

  This mypost function is used to get info on yours recents Posts.
Some useful info on your post will be displayed.
And there is a link to the view of each post :
href=comments/thread.php3

Parameter
string $order = >>"id"<<
The order comments should be displayed
string $user_id = >>""<<
The (option) user_id to be displayed
Returns string

HTML code


numberOfComments

public void numberOfComments( integer $resId, integer $resType, [ integer $score ] )

  This function determines the number of comments in a human-readable way
(that is, returns n comments, taking care of plural.)
Subsidiary question: this is adapted for most (all?) european laguages. What
happens with arabic, chinese or whatever?

Parameter
integer $resId
ID of the ressource
integer $resType
type of the resource
integer $score = >>-2<<
minimal score for counting comments, -2 to get default score.
Returns void


Private Method Details

show_score

private string show_score( array $c )

  This function will show the score of the comment

Parameter
array $c
row out of comments_scored table (?)
Returns string

the HTML


_com

private void _com( string $d )

  This will get all url in comments
Works on Comments::com_url array

Parameter
string $d
where URL are to look for
Returns void


com_hrefs

private string com_hrefs( [ integer $max_href_chars ] )

  Shortens URI so that they don't break anything when they are displayed.

Parameter
integer $max_href_chars = >>40<<
max length of an URL name
Returns string


load_branch

private array load_branch( integer $res_id, integer $com_id, integer $res_type, [ string $list ] )

  Loads all the ancestors of com_id
Calls exit on SQL failure

Parameter
integer $res_id
ID of the resource
integer $com_id
ID of the comment
integer $res_type
type of the resource (see Config::resources)
string $list = >>'all'<<
how the commetns are listed :last or all (default)
Returns array

a list of comments


load_subtree

private void load_subtree( integer $res_id, integer $res_type, integer $com_id )

  Loads the subtree - all the heirs - of a comment
Calls exit on DB failure

Parameter
integer $res_id
the resource ID the comment is attached to
integer $res_type
the type of resource
integer $com_id
the ID of the comment
@retrun array a tree of comments
Returns void


Private Field Details

$db

private object Db $db

>><<

Database abstraction layer


$com_urls

private array $com_urls

>><<

Array of all URLs in all the comments associateed to a resource


$html

private object Html $html

>><<

HTML rendering package


$utils

private object Utils $utils

>><<

Utils package


$session

private object Session $session

>><<

Session handling instance


$comments

private array $comments

>><<

Array of preloaded comments


$HTTP_REFERER

private string $HTTP_REFERER

>><<

HTTP_REFERER


$news_id

private integer $news_id

>><<

ID of the resource


$res_type

private integer $res_type

>>1<<

The ressource type of the comments looked after


$user

private object User $user

>><<

User instance


$admin

private object Admin $admin

>><<

Admin instance


$cache

private object Cache $cache

>><<

Cache abstraction layer


$news

private unknown $news

>><<




Packageindex Classtrees Modulegroups Elementlist Report XML Files
PHPDoc 1.0beta