Function Reference
Before you begin building an add-on or modification, understanding of the purpose of each sNews function is ideally the place to start. A change made in one function or the structure of a new function made from scratch may ‘break’ or cause other functions within the snews.php file to produce unexpected results.
The following is a list of the default functions contained in the snews.php file of sNews 1.5.4 release, along with a short description of its purpose.
/*** CONFIGURATION VARIABLES ***/
// DATABASE VARIABLES
function db($variable)
This function holds the essential variables required for snews to operate. We often refer to these as the Configuration Settings, and we input their values manually when we set up the site.
// LANGUAGE VARIABLES
function l($variable)
This is a list of words and phrases that appear by default in the sNews site. These variable names are inserted using $variable in of the other functions. If the site’s language variable is not set to EN (for english), these default variables will be bypassed, and an external language file (once installed) will be used.
/*** END OF SETTINGS & VARIABLES, EDIT BELOW THIS LINE ONLY IF YOU KNOW WHAT YOU’RE DOING ***/
// INFO LINE TAGS (readmore, comments, date)
function tags($tag)
This outputs the basic html for the information lines usually seen following articles and at the head of comments. The output needs to be processed to become meaningful.
// SITE SETTINGS – grab site settings from database
function s($variable)
This retrieves variables, when they are required, from the settings table in the database.
// SESSION TOKEN
function token()
generates a token (like a wildcard) that is used in security measures.
// STARTUP
function snews_startup()
Initiates site db connection, and is the processing point for snews login.
// TITLE
function title()
Generates and outputs html for the title and meta lines that are added to the source code for all displayed pages.
//BREADCRUMBS
function breadcrumbs()
Generates the breadcrumb navigation line, usually displayed above the main article content.
// LOGIN LOGOUT LINK
function login_link()
Generates html for both Login, and (if logged in) Admin links.
// DISPLAY CATEGORIES
function categories()
Outputs a list of name-links for all active categories.
// DISPLAY PAGES
function pages()
Called in index.php, produces the top menu in the default install. Makes links to page type articles plus hardcoded Home, Sitemap, Archive and Contact links.
//EXTRA CONTENT
function extra($styleit = 0, $classname = ”, $idname= ”)
Called in index.php, produces the extra content block in the default install, for articles assigned as extra content in article admin. Output controlled by the 3 variables.
$styleit controls the wrapping of the extra content with a <div> – values 1 = activate, 0 = deactivate. $classname supplies a class to the <div> and $idname supplies the id to the <div>
// PAGINATOR
function paginator($category, $pageNum, $maxPage, $article, $pagePrefix)
Outputs a pagination line when site content setting to show pagination is set in the administration area.
// CENTER
function center()
Generates the main body of the site.
// COMMENTS
function comment($freeze_status)
This function handles the display and processing of article comments.
// ARCHIVE
function archive()
Generates the Archive page.
//SITEMAP
function sitemap()
Generates the Sitemap page.
//NOTIFICATION
function notification($error, $errNote, $link)
Used to display any messages (primarily error messages) that are required if conditions call for them.
// CONTACT FORM
function contact()
Generates the Contact page, and processes the submitted form.
// MENU ARTICLES
function menu_articles($start, $size)
Called from index.php, this displays a list of articles. Number of articles determined by $size, and start point set by $start (0 is most recent).
// NEW COMMENTS
function new_comments($number, $stringlen)
Called from index.php, this displays a list of recent comments. Number of comments determined by $number, and the visible part of the comment is limited by $stringlen (number of visible characters).
// SEARCH FORM
function searchform()
Generates the Search form.
//SEARCH ENGINE
function search()
Processes the submission from the search form
// RSS FEED
function rss()
Outputs RSS feed.
// PREPARING ARTICLE FOR XML
function strip($text)
Removes all non-textual contents from the article ([include], , XHTMLtags etc.)
/*** ADMINISTRATIVE FUNCTIONS ***/
// LOGIN
function login()
Generates the login form if not logged in, otherwise if logged in, generates the logout link.
//CONTENTS COUNTER
function stats($field, $position)
Generates a simple contents statistics used in admin pane.
// FORM GENERATOR
function html_input($type, $name, $id, $value, $label, $css, $script1, $script2, $script3, $checked, $rows, $cols, $method, $action, $legend)
Form generation routine responsible for most of the form elements throughout the site.
// ADMINISTRATION FORM
function administration()
Generates the main administration pane.
// SETTINGS FORM
function settings()
Generates the settings form in the admin area.
// CATEGORIES FORM
function form_categories()
Generates the categories form in the admin area.
// ARTICLES – POSTING TIME
function posting_time($time=”)
This function generates the series of dropdowns used in the article Publish Date section of the article administration area.
// ARTICLES FORM
function form_articles($contents)
Generates the administration form for the new/selected article.
// ARTICLES – ADMIN LIST
function admin_articles($contents):
Produces the listing of types of articles in sNews (Pages, Articles, Extra Content).
//CATEGORIES – ADMIN LIST
function admin_categories()
Produces the listing of categories.
// COMMENTS – EDIT
function edit_comment()
This function is for editing comments.
/*** PROCESSING (CATEGORIES, CONTENTS, COMMENTS) ***/
function processing()
This function is the main administration processing area; forms data fetching and database manipulation.
/*** FILES ***/
function files()
This function controls file upload and deletion. It includes the means to prevent uploads of selected files and file types using the web interface
// FILELIST FUNCTION
function filelist($mode, $path, $depth = 0)
Outputs the file list in the administration area.
// CONNECT TO DATABASE
function connect_to_db()
This function, when called, makes the connection to the database, enabling database access to all functions that need to retrieve items from the database.
// SMART RETRIEVE FUNCTION
function retrieve($column, $table, $field, $value)
This function is a quick fetching routine which retrieves a single item from the database, depending on parameters used.
// FIND CATEGORY’S SEF TITLE THROUGH ARTICLE’S CATEGORY ID
function find_cat_sef($categoryid)
Retrieves category SEF (search engine friendly) title used when creating links to articles.
// CLEAN – cleaning query
function clean($query)
MySQL input data cleaning routine.
// USER/PASS CHECK
function checkUserPass($input)
Validation routine used in login procedure.
// MATH CAPTCHA
function mathCaptcha()
Outputs a simple arithmetic sum required for completion of forms. This is an anti-spam measure.
// XSS CLEAN
function cleanXSS($val)
Anti-XSS (Cross site scripting) measure. Source from http://quickwired.com/kallahar/smallprojects/php_xss_filter_function.php
// CLEAN – WORD FILTER
function cleanWords($text)
When clean words filter is named and activated in the admin, this function compares the content of the word list and the submitted text, replacing any words that match.
// CHECK IF UNIQUE
function check_if_unique($what, $text, $not_id = ‘x’)
This function checks article seftitle/title, and category seftitle/name for uniqueness.
// GET ID
function get_id($parameter)
This function checks all the parameters inside link and generates categories/articles/comments SEF titles respectively.
//CATEGORY CHECK
function check_category($category)
Category uniqueness check used when building sNews navigation.
//FILE INCLUSION
function file_include($text, $shorten)
Processes any editor [include] tags, and replaces the tags and the file location between them with the file to be included.
// ARTICLES – FUTURE POSTING
function update_articles()
Checks the articles date field and published level. If the article had been set to be published at a date after entry and that date has arrived, this function will alter the published level, and make the article user accessible.
// MAKE A CLEAN SEF URL
function cleanSEF($string)
Removes all non-URL friendly characters from article title.
function cleancheckSEF($string)
Additional routine used in category checking function.
// JAVASCRIPT FUNCTIONS
function js()
This function holds all the javascript functions used in sNews.
23.02.2007. 03:29
Learn How to Work with Mods:
GET STARTED
sNews requires PHP, MySQL and mod rewrite. If your server meets those requirements, get started and learn how to install sNews on your website in 3 easy steps.
LEARN
Browse through our help center and learn about template tags and how to simply create your own theme. Dig into sNews and customize it to behave the way you want.
EXTEND
sNews can be a simple blog tool and a full blown CMS. Customize it with addons, mods or play with different themes.
DISCUSS
Talk about sNews on our Forum and share your expirience