Class MinimalWeblog

Description

Class to handle weblog functionality; for embedding in existing web page

MinimalWeblog 1.0.2 by Jan Pieter Kunst, based on Personal Weblog 1.0.0 by Mark Pulford

  • copyright: Personal Weblog (c) 2001,2002 Mark Pulford <mark at kyne dot com dot au>
  • copyright: MinimalWeblog (c) 2006 Jan Pieter Kunst <jan.pieter.kunst at xs4all dot nl>
  • license: GNU General Public License

Located in /MinimalWeblog.php (line 50)


	
			
Variable Summary
 bool $_admin
 string $_body
 bool $_broken
 obj $_db
 array $_dbvars
 int $_delopt
 int $_eid
 array $_errors
 string $_icon
 string $_mode
 string $_more
 string $_name
 int $_offset
 string $_password
 string $_prefix
 string $_search
 string $_self
 array $_string_cgi
 int $_tid
 string $_title
 int $_topic
 string $_update
 array $_valid_cgi
 array $_value
Method Summary
 MinimalWeblog __construct ()
 string button_cycle (string $var, int $id)
 string button_offset (string $var, int $off)
 boolean current_login ()
 string entry_archive ()
 string entry_delete ()
 string entry_display ()
 string entry_edit ()
 bool entry_load (int $eid)
 string entry_preview ()
 string entry_print_admin (int $eid)
 int entry_relative (int $time, int $offset)
 string entry_reset ()
 string entry_save ()
 string entry_search ()
 array generate_search ()
 void getvar (string $name)
 void handle_error (int $errno, string $err, string $file, int $line)
 string insert ()
 void load_cgi_vars (array $array)
 void load_db_vars ()
 void login ()
 void logout ()
 string print_control (array $prev, array $next)
 string print_entries (string $format, array $array, string $separator)
 string print_form_vars (array $cgi_names)
 void rss_print ()
 void sanitize_input ()
 array select_query ([int $colspec = '*'])
 string setup_edit ()
 string setup_save ()
 void setvar (string $name, string $value)
 array subst_tokens (string $format, array $entry, [bool $allow_admin = TRUE])
 string topic_add ()
 string topic_delete ()
 string topic_edit ()
 string topic_selectbox (string $cgi, int $topic_id, [string $field = ''])
 mixed topic_verify (int $tid)
 string _back_link ()
 string _get_backtrace ()
 string _href_link (array $array, string $text)
 string _login_form ()
 string _query_string (array $array)
 string _topic_update ()
Variables
bool $_admin = FALSE (line 55)
  • var: gets set to TRUE if logged in with admin privileges
  • access: private
string $_body (line 139)
  • var: first part of current weblog entry
  • access: private
bool $_broken = FALSE (line 71)
  • var: gets set to TRUE if the script cannot run
  • access: private
obj $_db (line 59)
  • var: object of class DBMySQLi which handles the database stuff
  • access: private
array $_dbvars = array() (line 67)
  • var: options loaded from the database
  • access: private
int $_delopt (line 103)
  • var: id of topic where entries belonging to another, to-be-deleted topic will be moved into
  • access: private
int $_eid (line 107)
  • var: id of current entry
  • access: private
array $_errors = array() (line 79)
  • var: strings denoting encountered errors
  • access: private
string $_icon (line 127)
  • var: path to icon of current topic
  • access: private
string $_mode (line 115)
  • var: current weblog mode
  • access: private
string $_more (line 143)
  • var: second part of current weblog entry (optional)
  • access: private
string $_name (line 123)
  • var: name of current topic
  • access: private
array $_numeric_cgi = array('topic', 'delopt', 'tid', 'eid', 'offset') (line 83)
  • var: acceptable numeric cgi variables (when prefixed with "wl_")
  • access: private
int $_offset = 0 (line 95)
  • var: ordinal number of entry to start the current page with, used when paging through entries
  • access: private
string $_password (line 119)
  • var: md5 hash of admin password
  • access: private
string $_prefix (line 63)
  • var: prefix for table names (useful if no separate db for weblog)
  • access: private
string $_search (line 151)
  • var: text to search for in weblog entries
  • access: private
string $_self (line 75)
  • var: name of the script. Basically $_SERVER['PHP_SELF']
  • access: private
array $_string_cgi = array('mode', 'name', 'icon', 'value', 'title', 'body', 'more', 'password', 'update', 'search') (line 87)
  • var: acceptable string cgi variables (when prefixed with "wl_")
  • access: private
int $_tid (line 111)
  • var: id of current topic (when editing)
  • access: private
string $_title (line 135)
  • var: title of current weblog entry
  • access: private
int $_topic (line 99)
  • var: id of current topic (when browsing)
  • access: private
string $_update (line 147)
  • var: whether or not editing an existing entry should update its date
  • access: private
array $_valid_cgi = array() (line 91)
  • var: combination of valid numeric and string variables
  • access: private
array $_value (line 131)
  • var: configuration variables
  • access: private
Methods
Constructor __construct (line 161)

Weblog constructor

The Weblog class must be instantiated at the top of the page before any data is sent. This way it can modify the HTTP headers. Checks for a valid new or current login; Sets the class variable $_admin to true on a successful login.

  • access: public
MinimalWeblog __construct ()
button_cycle (line 1277)

Next/previous links for complete entries (wl_mode=more)

  • return: HTML for the next/previous link
  • access: private
string button_cycle (string $var, int $id)
  • string $var: 'next_html' or 'prev_html' configuration variable name
  • int $id: id number of previous/next weblog entry
button_offset (line 1256)

Next/previous links for paged list of entries

  • return: HTML for the next/previous link
  • access: private
string button_offset (string $var, int $off)
  • string $var: 'next_html' or 'prev_html' configuration variable name
  • int $off: offset in the list of entries
current_login (line 1640)

Check login status

  • return: logged in or not
  • access: private
boolean current_login ()
entry_archive (line 996)

Compact list of all entries (wl_mode=archive)

  • return: HTML with list of entries
  • access: private
string entry_archive ()
entry_delete (line 860)

Delete one entry. wl_mode=delete+entry

Uses properties: eid

  • return: HTML with success or failure message
  • access: private
string entry_delete ()
entry_display (line 1063)

Display one complete entry (wl_mode=more).

Uses property: eid (current entry id number)

  • return: HTML for entry display
  • access: private
string entry_display ()
entry_edit (line 695)

Edit an entry. wl_mode=edit+entry

Uses properties: eid, tid, title, body, more, update The entry can be given from CGI variables, start blank, or be loaded from the DB.

  • return: HTML with form for editing entry
  • access: private
string entry_edit ()
entry_load (line 664)

Load a weblog entry overriding current title, tid, body, more values

  • return: TRUE if entry found, FALSE otherwise
  • access: private
bool entry_load (int $eid)
  • int $eid: entry id
entry_preview (line 751)

Preview an entry. wl_mode=preview+entry

Uses properties: eid, tid, title, body, more, update

  • return: HTML with preview of entry
  • access: private
string entry_preview ()
entry_print_admin (line 1108)

Print per entry admin menu maintaining search parameters

  • return: HTML with admin menu (edit/delete links)
  • access: private
string entry_print_admin (int $eid)
  • int $eid: entry id
entry_relative (line 1030)

Used to create a link to the previous or next entry

  • return: entry id of previous or next entry
  • access: private
int entry_relative (int $time, int $offset)
  • int $time: last updated time of the current entry
  • int $offset: -1 or 1 for next or previous entry
entry_reset (line 887)

Empty search conditions and return all entries. wl_mode=$this->getvar('reset_text')

  • return: HTML with entries
  • access: private
string entry_reset ()
entry_save (line 812)

Save an entry. wl_mode=save+entry

Uses properties: eid, tid, title, body, more, update

  • return: HTML with success or failure message
  • access: private
string entry_save ()
entry_search (line 957)

Generates a (partial) list of entries, possibly restricted by topic or searched text. wl_mode=$this->getvar('search_text')

Uses properties: topic, offset, search

  • return: HTML with entries
  • access: private
string entry_search ()
generate_search (line 931)

Add ORDER BY and LIMIT to query for selecting entries

  • return: item 1: query with placeholders item 2: array with parameters
  • access: private
array generate_search ()
getvar (line 1429)

Configuraton variables are assumed to exist and are required to run

  • access: private
void getvar (string $name)
  • string $name: variable name
handle_error (line 1341)

Error handling

Does not work if not defined as public, never called explicitly though

  • access: public
void handle_error (int $errno, string $err, string $file, int $line)
  • int $errno: error code
  • string $err: error string
  • string $file: filename where error occured
  • int $line: line number where error occured
insert (line 221)

Return weblog HTML

  • return: HTML for chosen weblog mode
  • access: public
string insert ()
load_cgi_vars (line 1566)

Store any GET/POST variables in the class. POST has precedence over GET

  • access: private
void load_cgi_vars (array $array)
  • array $array: array_merge($_GET, $_POST)
load_db_vars (line 1547)

Cache DB vars to prevent many queries

  • access: private
void load_db_vars ()
login (line 1591)

Login; if already logged in show the main page

CGI mode: "login" (wl_mode=login) Trigger error if editing is not allowed from remote host. See MINIMALWEBLOG_HOSTS_EDITING_ALLOWED constant in config.inc.php

  • access: private
void login ()
logout (line 1619)

Logout

Empty and destroy session, set admin property to false CGI mode: "logout" (wl_mode=logout)

  • access: private
void logout ()
print_control (line 1296)

Show search box, topic select, ...

  • return: omschrijving
  • access: private
string print_control (array $prev, array $next)
  • array $prev: int string bool obj omschrijving
  • array $next: int string bool obj omschrijving
print_entries (line 1175)

Format found entries

  • return: HTML with formatted entries
  • access: private
string print_entries (string $format, array $array, string $separator)
  • string $format: template in which to replace tokens
  • array $array: found entries
  • string $separator: HTML to separate entries
print_form_vars (line 514)

Return HTML for hidden fields to maintain current cgi variable values through html form

  • return: HTML with hidden fields (<input type="hidden">)
  • access: private
string print_form_vars (array $cgi_names)
  • array $cgi_names: field names
rss_print (line 1503)

Generate RSS file with the current search parameters

CGI mode: "rss" (wl_mode=rss) Uses: topic, offset, search

  • access: private
void rss_print ()
sanitize_input (line 1132)

Clean up GET/POST contents

Ensure all non string CGI variables are clean Strings are always escaped for db use by using prepared statements name, icon, title, body, more, value: used in db searches mode, password, update: not used in db searches

  • access: private
void sanitize_input ()
select_query (line 904)

Returns query and array of parameters for selecting entries

Returns a select query limiting entries based on CGI variables and topic restriction. Further conditions can be appended.

  • return: item 1: query with placeholders item 2: array with parameters
  • access: private
array select_query ([int $colspec = '*'])
  • int $colspec: columns to select
setup_edit (line 614)

Edit weblog options (data from 'vars' table). wl_mode=edit+setup

  • return: HTML form for editing weblog options
  • access: private
string setup_edit ()
setup_save (line 590)

Save weblog options (data from 'vars' table). wl_mode=save+setup

  • return: HTML with success or failure message
  • access: private
string setup_save ()
setvar (line 1444)

Update a weblog (configuration) variable (in class and database)

  • access: private
void setvar (string $name, string $value)
  • string $name: variable name
  • string $value: value
subst_tokens (line 1199)

Substitute an entry into a template via tokens

  • return: string HTML to be displayed
  • access: private
array subst_tokens (string $format, array $entry, [bool $allow_admin = TRUE])
  • string $format: template in which to replace tokens
  • array $entry: content and metadata of the entry
  • bool $allow_admin: whether to print edit/delete links or not
topic_add (line 409)

Add a topic. wl_mode=add+topic

Uses properties: name, icon

  • return: HTML with success or failure message
  • access: private
string topic_add ()
topic_delete (line 444)

Delete a topic, possibly moving entries to another topic. wl_mode=delete+topic

Uses properties: tid, delopt

  • return: HTML with success or failure message
  • access: private
string topic_delete ()
topic_edit (line 538)

Edit topics. wl_mode=edit+topics

  • return: HTML form for editing topics
  • access: private
string topic_edit ()
topic_selectbox (line 1477)

Returns the form HTML necessary to select between topics

  • return: HTML for the select menu
  • access: private
string topic_selectbox (string $cgi, int $topic_id, [string $field = ''])
  • string $cgi: desired variable name to be returned (prefixed with "wl_")
  • int $topic_id: selected topic id or -1 if none
  • string $field: extra (first) option, if any
topic_verify (line 1406)

Verify the topic exists

  • return: name of the topic or FALSE if not exists
  • access: private
mixed topic_verify (int $tid)
  • int $tid: topic id
_back_link (line 335)

Return a link back to the main page while maintaining current search parameters

  • return: HTML with link
  • access: private
string _back_link ()
_get_backtrace (line 1390)

Provides backtrace when MINIMALWEBLOG_DEBUG == 2

  • return: backtrace
  • access: private
string _get_backtrace ()
_href_link (line 323)

Returns an <a> element

  • return: HTML with <a> element
  • access: private
string _href_link (array $array, string $text)
  • array $array: array of variables to put in query string
  • string $text: text for link
_login_form (line 278)

Return HRTML form to log in as admin

  • return: HTML with form or error message
  • access: private
string _login_form ()
_query_string (line 304)

Returns an URL query string

  • return: query string with same
  • access: private
string _query_string (array $array)
  • array $array: array of variables to put in query string
_topic_update (line 355)

Change name or icon of topic. wl_mode=change+topic

Uses properties: tid, name, icon

  • return: HTML with success or failure message
  • access: private
string _topic_update ()

Documentation generated on Sun, 17 Jun 2007 19:20:45 +0200 by phpDocumentor 1.3.2