Packageindex Classtrees Modulegroups Elementlist Report XML Files

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

News

News

Class to handle all the news system.

 

private class News

Class to handle all the news system.

daCode http://www.dacode.org/
src/phplib/news.php3
$Id: news.php3,v 1.249 2002/05/14 21:11:08 jbcombes Exp $

Depends: Config Db Utils Html Redirect Cache

 

Public Method Summary

void

News()

Class constructor
array

get_news([ integer $nb, string $section, string $topic, integer $state, integer $view, integer $news_id, boolean $body, string $start_date, integer $date, string $start_nb ])

Get a number of news. Return an array of array.
mixed

get_urls(integer $id)

Get all the urls of the given news_id.
mixed

get_attach(integer $id, [ boolean $w ])

Get all the attachements of the given news_id.
void

view_attach(integer $id)

Get attachement for save as command under netscape
array

count_section(array $section)

Return the number of news in the last week for the given section
string

show_title([ mixed $news_id ])

Get title
string

viewResource(string $news_id)

View only one news... for reminder.
string

show_news([ integer $nb, string $section, string $topic, integer $state, integer $view, integer $news_id, integer $date ])

/* Html code to display the news in their beautiful boxes
string

show_archive([ integer $nb, string $section, string $topic, integer $state, integer $view, integer $others, string $title ])

This is to show archives of the news in an archive box
string

show_prev_next_news(integer $news_id, [ string $section, string $topic, integer $view, integer $top ])

Give navigation box with <-- previous_news next_news-->
string

view_modero(integer $news_id)

Give an html list of a specific news moderators
mixed

checkResource(integer $news_id)

Controls wether the news may be commented.
string

submit([ integer $size_url ])

A form to fill to submit a news
mixed

send_email_view([ integer $news_id ])

We print the form to send an email to a friend about a news
mixed

send_email([ integer $news_id, string $email_address, string $body ])

We send email if to a friend if everything is ok
mixed

show_print([ integer $news_id ])

Returns a simplebox with icon (printer and email) inside if $news_id != 0
string

getTopicUrl(integer $news_id, [ integer $absolute, integer $score, mixed $order, integer $theme ])

Returns the URL where the news && comments can be found
void

loadResources(integer $news_ids)

Preloads a few things...
string

viewShort(integer $news_id)

Displays the title, using the SQL cache

Private Method Summary

boolean

add(array $row)

Add an entry to the news table.
string

get_prev_next_news(integer $news_id, integer $prevnext, [ string $section, string $topic, integer $view ])

Give <a href="url">name</a> of the previous or next news.
integer

verify_author(string $name, string $contact)

Verify that the author has been created. If not then it creates it,
string

preview(array $table)

Give preview of a news in a newsbox.
string

submit_upload(array $table)

A form to fill to submit an attached file of a news
string

submit_confirm(array $table)

Message when news has been successfully fulfilled and added to db
boolean

is_approved(integer $news_id)

test if news is approved

Private Field Summary

object Db

$db

call to the class Db
object Session

$session

call to the class Session
object Utils

$utils

call to the class Utils
object Html

$html

call to the class Html
object Redirect

$redirect

call to the class Redirect
object Cache

$cache

call to the class Cache
object News

$news

call to the class News
object Comments

$comments

call to the class Comments
integer

$last_week_score

average of the score during last week
array

$sqlCache

Cache for the common SQL queries
boolean

$isCached

Boolean to indicate if a query has been cached or not

Public Method Details

News

public void News( )

  Class constructor

Returns void


get_news

public array get_news( [ integer $nb, string $section, string $topic, integer $state, integer $view, integer $news_id, boolean $body, string $start_date, integer $date, string $start_nb ] )

  Get a number of news. Return an array of array.

Parameter
integer $nb = >>10<<
number of news
string $section = >>""<<
news from a specific section
string $topic = >>""<<
news from a specific topic
integer $state = >>1<<
state of news
integer $view = >>1<<
1 for main page, 2 for others
integer $news_id = >>0<<
to find a specific news
boolean $body = >>true<<
to include news body or not
string $start_date = >>""<<
timestamp14
integer $date = >>0<<
the date of the news can't be superior to $date
string $start_nb = >>"0"<<
timestamp14
Returns array

all the news in an array of array.


get_urls

public mixed get_urls( integer $id )

  Get all the urls of the given news_id.

Parameter
integer $id
of the news
Returns mixed

array with all the urls, or -1 if db error


get_attach

public mixed get_attach( integer $id, [ boolean $w ] )

  Get all the attachements of the given news_id.

Parameter
integer $id
of the news
boolean $w = >>false<<
or without body
Returns mixed

array with all the urls, or -1 if db error


view_attach

public void view_attach( integer $id )

  Get attachement for save as command under netscape

Call to header() to send attachment.
Warning : Exit with -1 if db error

Parameter
integer $id
of the news
Returns void


count_section

public array count_section( array $section )

  Return the number of news in the last week for the given section

This function could work with string or array
Warning : return -1 if DB error
FIXME: used only in Sidebox

Parameter
array $section
of the name section
Returns array

contains number of news,in the section


show_title

public string show_title( [ mixed $news_id ] )

  Get title
Gets the title (HTML-escaped) of the news whose id is $news_id.
Warning : Exit with -1 if db error

Parameter
mixed $news_id = >>""<<
the ID of the news or empty string -- dirty
Returns string

the title HTML escaped.


viewResource

public string viewResource( string $news_id )

  View only one news... for reminder.
Part of the implementation of the resource interface.

Parameter
string $news_id
the id of the news to view
Returns string

the HTML for this news.


show_news

public string show_news( [ integer $nb, string $section, string $topic, integer $state, integer $view, integer $news_id, integer $date ] )

  /* Html code to display the news in their beautiful boxes

Parameter
integer $nb = >>10<<
number of news
string $section = >>""<<
news from a specific section
string $topic = >>""<<
news from a specific topic
integer $state = >>1<<
state of news
integer $view = >>1<<
1 for main page, 2 for others
integer $news_id = >>0<<
to find a specific news
integer $date = >>0<<
the date of the news can't be superior to $date
Returns string

the HTML to display


show_archive

public string show_archive( [ integer $nb, string $section, string $topic, integer $state, integer $view, integer $others, string $title ] )

  This is to show archives of the news in an archive box

Parameter
integer $nb = >>10<<
number of news
string $section = >>""<<
news from a specific section
string $topic = >>""<<
news from a specific topic
integer $state = >>1<<
state of news
integer $view = >>1<<
1 for main page, 2 for others
integer $others = >>0<<
Is it the "other" box?
string $title = >>""<<
title of a news
Returns string

the HTML to display


show_prev_next_news

public string show_prev_next_news( integer $news_id, [ string $section, string $topic, integer $view, integer $top ] )

  Give navigation box with <-- previous_news next_news-->

if top=0 "title" is written
if top=1 "top of the page" is written
Warning : return -1 id db error

Parameter
integer $news_id
id
string $section = >>""<<
news from a specific section
string $topic = >>""<<
news from a specific topic
integer $view = >>1<<
1 for main page, 2 for others
integer $top = >>0<<
"top of the page" if 1
Returns string

html to display


view_modero

public string view_modero( integer $news_id )

  Give an html list of a specific news moderators

Warning: return -1 if db error

Parameter
integer $news_id
of the news
Returns string

html to display with modero1<br />modero2....


checkResource

public mixed checkResource( integer $news_id )

  Controls wether the news may be commented.
Part of the implementation of the resource interface.

Parameter
integer $news_id
the ID of the news to control
Returns mixed

NULL if it may be commented; an error string otherwise.


submit

public string submit( [ integer $size_url ] )

  A form to fill to submit a news
Warning: return -1 if db error

Parameter
integer $size_url = >>50<<
of the box to write url
Returns string

html to be displayed, or error message


send_email_view

public mixed send_email_view( [ integer $news_id ] )

  We print the form to send an email to a friend about a news

Parameter
integer $news_id = >>0<<
of the news
Returns mixed

NULL or html form


send_email

public mixed send_email( [ integer $news_id, string $email_address, string $body ] )

  We send email if to a friend if everything is ok

Parameter
integer $news_id = >>0<<
of the news
string $email_address = >>""<<
adress
string $body = >>""<<
body
Returns mixed

NULL or html to diplay


show_print

public mixed show_print( [ integer $news_id ] )

  Returns a simplebox with icon (printer and email) inside if $news_id != 0
Returns nothing if $news_id=0

Parameter
integer $news_id = >>0<<
of the news
Returns mixed

NULL or html to diplay


getTopicUrl

public string getTopicUrl( integer $news_id, [ integer $absolute, integer $score, mixed $order, integer $theme ] )

  Returns the URL where the news && comments can be found

Parameter
integer $news_id
the ID of news viewed
integer $absolute = >>1<<
URL is absolute or not.
integer $score = >>-2<<
the threshold for displaying comments
mixed $order = >>""<<
TODO
integer $theme = >>0<<
TODO
Returns string

the URL where to view it.


loadResources

public void loadResources( integer $news_ids )

  Preloads a few things...
FIXME : very basic version

Parameter
integer $news_ids
of the news
Returns void


viewShort

public string viewShort( integer $news_id )

  Displays the title, using the SQL cache

Parameter
integer $news_id
of the news
Returns string

news title


Private Method Details

add

private boolean add( array $row )

  Add an entry to the news table.
Need an array as input which needs to be like the following.
FIXME: But where is it used
$row['topic_id'] is the id of the topic.
$row['section_id'] is the id the section.
$row['author_id'] is the id of the author.
$row['title'] is the title of the news.
$row['departement'] is the departement.
$row['body'] is the body of the news.
$row['links'] is an array (see the following)
$row['files'] is an array which is an array itself (see the following)

Parameter
array $row
info
Returns boolean

-1 if db error, else nothing


get_prev_next_news

private string get_prev_next_news( integer $news_id, integer $prevnext, [ string $section, string $topic, integer $view ] )

  Give <a href="url">name</a> of the previous or next news.

If $prevnext=1, previous news is returned, otherwise next.
Warnig : return -1 id db error

Parameter
integer $news_id
id
integer $prevnext
or next
string $section = >>""<<
news from a specific section
string $topic = >>""<<
news from a specific topic
integer $view = >>1<<
1 for main page, 2 for others
Returns string

html to display


verify_author

private integer verify_author( string $name, string $contact )

  Verify that the author has been created. If not then it creates it,

Warning: return -1 if db error

Parameter
string $name
of an author
string $contact
contact of an author
Returns integer

id of the author (allready exist or created)


preview

private string preview( array $table )

  Give preview of a news in a newsbox.
Warning: return -1 if db error

Parameter
array $table
about the future news (topic, section)
Returns string

html to be displayed.


submit_upload

private string submit_upload( array $table )

  A form to fill to submit an attached file of a news
Warning: return -1 if db error

Parameter
array $table
the news info
Returns string

html to be displayed


submit_confirm

private string submit_confirm( array $table )

  Message when news has been successfully fulfilled and added to db
Warning: return -1 if db error

Parameter
array $table
the news info
Returns string

html to be displayed


is_approved

private boolean is_approved( integer $news_id )

  test if news is approved
Returns 1 if the news is approved (state=1)
Returns 0 if the news isn't approved neither doesn't exists.

Parameter
integer $news_id
of the news
Returns boolean

1, 0, -1 if db error


Private Field Details

$db

private object Db $db

>><<

call to the class Db


$session

private object Session $session

>><<

call to the class Session


$utils

private object Utils $utils

>><<

call to the class Utils


$html

private object Html $html

>><<

call to the class Html


$redirect

private object Redirect $redirect

>><<

call to the class Redirect


$cache

private object Cache $cache

>><<

call to the class Cache


$news

private object News $news

>><<

call to the class News


$comments

private object Comments $comments

>><<

call to the class Comments


$last_week_score

private integer $last_week_score

>><<

average of the score during last week


$sqlCache

private array $sqlCache

>><<

Cache for the common SQL queries


$isCached

private boolean $isCached

>>true<<

Boolean to indicate if a query has been cached or not



Packageindex Classtrees Modulegroups Elementlist Report XML Files
PHPDoc 1.0beta