Source for file _functions_bposts.php
Documentation is available at _functions_bposts.php
* Post handling functions
* b2evolution - {@link http://b2evolution.net/}
* Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
* @copyright (c)2003-2005 by Francois PLANQUE - {@link http://fplanque.net/}
* @author This file built upon code from original b2 - http://cafelog.com/
if( !defined('DB_USER') ) die( 'Please, do not access this page directly.' );
* This funtion has to handle all needed DB dependencies!
* {@internal bpost_create(-)}}
$author_user_ID, // Author
$post_timestamp, // 'Y-m-d H:i:s'
$main_cat_ID =
1, // Main cat ID
$extra_cat_IDs =
array(), // Table of extra cats
$post_status =
'published',
$autobr =
0, // No AutoBR has been used by default
$post_renderers =
array('default') )
global $DB, $tableposts, $tablepostcats, $query;
global $localtimenow, $default_locale;
if( $post_locale ==
'#' ) $post_locale =
$default_locale;
if( $pingsdone ) $post_flags[] =
'pingsdone';
// make sure main cat is in extracat list and there are no duplicates
$extra_cat_IDs[] =
$main_cat_ID;
// TODO: START TRANSACTION
// echo 'INSERTING NEW POST ';
$query =
"INSERT INTO $tableposts( post_author, post_title, post_urltitle, post_content,
post_issue_date, post_mod_date, post_category, post_status, post_locale,
post_url, post_autobr, post_flags, post_wordcount,
post_comments, post_renderers )
VALUES( $author_user_ID, '".
$DB->escape($post_title).
"',
'".
$DB->escape($post_urltitle).
"',
'".
$DB->escape($post_content).
"',
'".
$DB->escape($post_timestamp).
"',
'".
date('Y-m-d H:i:s',$localtimenow).
"',
'".
$DB->escape($post_status).
"',
'".
$DB->escape($post_locale).
"',
'".
$DB->escape($post_url).
"',
'".
$DB->escape(implode(',',$post_flags)).
"',
'".
$DB->escape($post_comments).
"',
'".
$DB->escape(implode('.',$post_renderers)).
"' )";
if( ! $DB->query( $query, 'Insert New Post' ) ) return 0;
$post_ID =
$DB->insert_id;
// echo "post ID:".$post_ID;
$query =
"INSERT INTO $tablepostcats( postcat_post_ID, postcat_cat_ID ) VALUES ";
foreach( $extra_cat_IDs as $extra_cat_ID )
// echo "extracat: $extra_cat_ID <br />";
$query .=
"( $post_ID, $extra_cat_ID ),";
if( ! $DB->query( $query, 'Associate new post with extra categories' ) ) return 0;
* This funtion has to handle all needed DB dependencies!
* {@internal bpost_update(-)}}
$post_timestamp =
'', // 'Y-m-d H:i:s'
$main_cat_ID =
1, // Main cat ID
$extra_cat_IDs =
array(), // Table of extra cats
$post_status =
'published',
$autobr =
0, // No AutoBR has been used by default
$post_renderers =
array() )
global $DB, $tableposts, $tablepostcats, $query, $querycount;
global $localtimenow, $default_locale;
if( $pingsdone ) $post_flags[] =
'pingsdone';
// make sure main cat is in extracat list and there are no duplicates
$extra_cat_IDs[] =
$main_cat_ID;
// TODO: START TRANSACTION
$query =
"UPDATE $tableposts
SET post_title = '".
$DB->escape($post_title).
"',
post_urltitle = '".
$DB->escape($post_urltitle).
"',
post_url = '".
$DB->escape($post_url).
"',
post_content = '".
$DB->escape($post_content).
"',
post_mod_date = '".
date('Y-m-d H:i:s',$localtimenow).
"',
post_category = $main_cat_ID,
post_status = '".
$DB->escape($post_status).
"',
post_flags = '".
$DB->escape(implode(',',$post_flags)).
"',
post_comments = '".
$DB->escape($post_comments).
"',
post_renderers = '".
$DB->escape(implode('.',$post_renderers)).
"'";
if( $post_locale !=
'#' )
{ // only update if it was changed
post_locale = '".
$DB->escape($post_locale).
"'";
if( !empty($post_timestamp) ) $query .=
", post_issue_date = '$post_timestamp' ";
$query .=
"WHERE ID = $post_ID";
if( ! $DB->query( $query ) ) return 0;
// delete previous extracats
$query =
"DELETE FROM $tablepostcats WHERE postcat_post_ID = $post_ID";
if( ! $DB->query( $query ) ) return 0;
$query =
"INSERT INTO $tablepostcats( postcat_post_ID, postcat_cat_ID ) VALUES ";
foreach( $extra_cat_IDs as $extra_cat_ID )
//echo "extracat: $extracat_ID <br />";
$query .=
"( $post_ID, $extra_cat_ID ),";
if( ! $DB->query( $query ) ) return 0;
* This funtion has to handle all needed DB dependencies!
* {@internal bpost_update_status(-)}}
$post_status =
'published',
global $DB, $tableposts, $tablepostcats;
if( $pingsdone ) $post_flags[] =
'pingsdone';
$query =
"UPDATE $tableposts SET ";
if( !empty($post_timestamp) ) $query .=
"post_issue_date = '$post_timestamp', ";
$query .=
"post_mod_date = '".
date('Y-m-d H:i:s',$localtimenow).
"', ";
$query .=
"post_status = '$post_status', ";
$query .=
"post_flags = '".
implode(',',$post_flags).
"' ";
$query .=
"WHERE ID = $post_ID";
return $DB->query( $query );
* This funtion has to handle all needed DB dependencies!
* {@internal bpost_delete(-)}}
global $DB, $tableposts, $tablepostcats, $tablecomments;
// TODO: START TRANSACTION
$query =
"DELETE FROM $tablepostcats WHERE postcat_post_ID = $post_ID";
if( $DB->query( $query ) ===
false ) return 0;
$query =
"DELETE FROM $tablecomments WHERE comment_post_ID = $post_ID";
if( $DB->query( $query ) ===
false ) return 0;
$query =
"DELETE FROM $tableposts WHERE ID = $post_ID";
if( $DB->query( $query ) ===
false ) return 0;
* {@internal get_lastpostdate(-)}}
$show_statuses =
array(),
$timestamp_min =
'', // Do not show posts before this timestamp
$timestamp_max =
'now' // Do not show posts after this timestamp
global $localtimenow, $postdata;
// echo 'getting last post date';
$LastPostList =
& new ItemList( $blog, $show_statuses, '', '', '', $cat, $catsel, '', 'DESC', 'issue_date', 1, '','', '', '', '', '', '', 1, 'posts', $timestamp_min, $timestamp_max );
if( $LastItem =
$LastPostList->get_item() )
// echo 'we have a last item';
$last_postdata =
$LastPostList->get_postdata(); // will set $postdata;
$lastpostdate =
$postdata['Date'];
// echo 'we have no last item';
$lastpostdate =
date("Y-m-d H:i:s", $localtimenow);
* Using title as a source if url title is empty
* {@internal urltitle_validate(-) }}
* @param string url title to validate
* @param string real title to use as a source if $urltitle is empty
* @param integer ID of post
* @return string validated url title
$urltitle =
trim( $urltitle );
if( empty( $urltitle ) ) $urltitle =
$title;
if( empty( $urltitle ) ) $urltitle =
'title';
// echo 'staring with: ', $urltitle, '<br />';
// Keep only one char in emtities!
// Remove non acceptable chars
$urltitle =
preg_replace( '/[^A-Za-z0-9]+/', '_', $urltitle );
// Uppercase the first character of each word in a string
preg_match( '/^(.*?)(_[0-9]+)?$/', $urltitle, $matches );
$urlbase =
substr( $matches[1], 0, 40 );
if( isset
( $matches[2] ) )
$urltitle =
$urlbase .
$matches[2];
// Find all occurrences of urltitle+number in the DB:
$sql =
"SELECT post_urltitle
WHERE post_urltitle REGEXP '^".
$urlbase.
"(_[0-9]+)?$'
$rows =
$DB->get_results( $sql, ARRAY_A );
if( count( $rows ) ) foreach( $rows as $row )
$existing_urltitle =
$row['post_urltitle'];
// echo "existing = $existing_urltitle <br />";
if( $existing_urltitle ==
$urltitle )
{ // We have an exact match, we'll have to change the number.
if( preg_match( '/_([0-9]+)$/', $existing_urltitle, $matches ) )
{ // This one has a number, we extract it:
$existing_number = (integer)
$matches[1];
if( $existing_number >
$highest_number )
{ // This is th enew high
$highest_number =
$existing_number;
// echo "highest existing number = $highest_number <br />";
if( $exact_match &&
!$query_only )
{ // We got an exact match, we need to change the number:
$urltitle =
$urlbase.
'_'.
($highest_number +
1);
// echo "using = $urltitle <br />";
* if global $postdata was not set it will be
global $DB, $postdata, $tableusers, $tablecategories, $tableposts, $tablecomments, $show_statuses;
if( !empty($postdata) &&
$postdata['ID'] ==
$postid )
{ // We are asking for postdata of current post in memory! (we're in the b2 loop)
// Already in memory! This will be the case when generating permalink at display
// (but not when sending trackbacks!)
// echo "*** Accessing post data in memory! ***<br />\n";
// echo "*** Loading post data! ***<br>\n";
// We have to load the post
$sql =
"SELECT ID, post_author, post_issue_date, post_mod_date, post_status, post_locale, post_content, post_title, post_url, post_category, post_autobr, post_flags, post_wordcount, post_comments, cat_blog_ID FROM $tableposts INNER JOIN $tablecategories ON post_category = cat_ID WHERE ID = $postid";
// Restrict to the statuses we want to show:
// fplanque: 2004-04-04: this should not be needed here. (and is indeed problematic when we want to
// get a post before even knowning which blog it belongs to. We can think of putting a security check
// back into the Item class)
// $sql .= ' AND '.statuses_where_clause( $show_statuses );
if( $myrow =
$DB->get_row( $sql ) )
'Author_ID' =>
$myrow->post_author,
'Date' =>
$myrow->post_issue_date,
'Status' =>
$myrow->post_status,
'Locale' =>
$myrow->post_locale,
'Content' =>
$myrow->post_content,
'Title' =>
$myrow->post_title,
'Url' =>
$myrow->post_url,
'Category' =>
$myrow->post_category,
'AutoBR' =>
$myrow->post_autobr,
'Flags' =>
explode( ',', $myrow->post_flags ),
'Wordcount' =>
$myrow->post_wordcount,
'comments' =>
$myrow->post_comments,
'Blog' =>
$myrow->cat_blog_ID,
// Caching is particularly useful when displaying a single post and you call single_post_title several times
if( !isset
( $postdata ) ) $postdata =
$mypostdata; // Will save time, next time :)
* {@internal Item_get_by_ID(-) }}
* @return Item requested object or false
global $DB, $postdata, $tableusers, $tablecategories, $tableposts, $tablecomments, $show_statuses;
// We have to load the post
$sql =
"SELECT ID, post_author, post_issue_date, post_mod_date, post_status, post_locale,
post_content, post_title, post_urltitle, post_url, post_category,
post_autobr, post_flags, post_wordcount, post_comments,
post_renderers, cat_blog_ID
FROM $tableposts INNER JOIN $tablecategories ON post_category = cat_ID
// Restrict to the statuses we want to show:
// fplanque: 2004-04-04: this should not be needed here. (and is indeed problematic when we want to
// get a post before even knowning which blog it belongs to. We can think of putting a security check
// back into the Item class)
// $sql .= ' AND '.statuses_where_clause( $show_statuses );
if( ! ($row =
$DB->get_row( $sql )) )
return new Item( $row ); // COPY !
* Get an Item by its urltitle
* {@internal Item_get_by_title(-) }}
* @param string url title of Item
* @return Item requested object or false
global $DB, $postdata, $tableusers, $tablecategories, $tableposts, $tablecomments, $show_statuses;
// We have to load the post
$sql =
"SELECT ID, post_author, post_issue_date, post_mod_date, post_status, post_locale,
post_content, post_title, post_urltitle, post_url, post_category,
post_autobr, post_flags, post_wordcount, post_comments,
post_renderers, cat_blog_ID
FROM $tableposts INNER JOIN $tablecategories ON post_category = cat_ID
WHERE post_urltitle = ".
$DB->quote($urltitle);
if( ! ($row =
$DB->get_row( $sql )) )
return new Item( $row ); // COPY !
$output =
trim( $postdata['Title'] );
* @deprecated deprecated by {@link DataObject::ID()}
* @deprecated deprecated by {@link Item::status()}
global $post_statuses, $postdata;
$status =
$postdata['Status'];
echo
T_($post_statuses[$status]);
* Display post language code
* @deprecated deprecated by {@link Item::lang()}
echo
$postdata['Locale'];
* Display post language name
* @deprecated deprecated by {@link Item::language()}
global $postdata, $languages;
$post_lang =
$postdata['Locale'];
echo
$languages[ $post_lang ];
* Display the number of words in the post
* @deprecated deprecated by {@link Item::wordcount()}
echo
$postdata['Wordcount'];
* 03.10.10 - Updated function to allow for silent operations
* @deprecated deprecated by {@link Item::title()}
$before=
'', // HTML/text to be displayed before title
$after=
'', // HTML/text to be displayed after title
$add_link =
true, // Added link to this title?
$format =
'htmlbody', // Format to use (example: "htmlbody" or "xml")
$disp =
true ) // Display output?
$url =
trim($postdata['Url']);
if( empty($title) &&
$add_link )
if( $add_link &&
(!empty($url)) )
$title =
$before.
'<a href="'.
$url.
'">'.
$title.
'</a>'.
$after;
$title =
$before.
$title.
$after;
// ADDED: 03.10.08 by Travis S. :Support for silent operation
* @deprecated deprecated by {@link Item::url_link()}
function the_link( $before=
'', $after=
'', $format =
'htmlbody' )
$url =
trim($postdata['Url']);
$link =
$before.
'<a href="'.
$url.
'">'.
$url.
'</a>'.
$after;
* {@internal single_post_title(-)}}
global $p, $title, $preview;
if( $prefix ==
'#' ) $prefix =
' '.
T_('Post details').
': ';
if( $prefix ==
'#' ) $prefix =
' ';
$disp_title =
T_('PREVIEW');
$disp_title =
$Item->get('title');
elseif( !empty( $title ) )
$disp_title =
$Item->get('title');
if( !empty( $disp_title ) )
* {@internal preview_title(-)}}
function preview_title( $string =
'#', $before =
' ', $after =
'' )
echo
($string ==
'#') ?
T_('PREVIEW') :
$string;
* @deprecated deprecated by {@link Item::content()}
$dispmore =
'#', // 1 to display 'more' text, # for url parameter
$disppage =
'#' ) // page number to display specific page, # for url parameter
global $id, $postdata, $pages, $multipage, $numpages;
// echo $format,'-',$cut,'-',$dispmore,'-',$disppage;
if( $more_link_text ==
'#' )
{ // TRANS: this is the default text for the extended post "more" link
$more_link_text =
'=> '.
T_('Read more!');
if( $more_anchor ==
'#' )
{ // TRANS: this is the default text displayed once the more link has been activated
$more_anchor =
'['.
T_('More:').
']';
if( $before_more_link ==
'#' )
$before_more_link =
'<p class="bMore">';
if( $after_more_link ==
'#' )
$after_more_link =
'</p>';
if( $disppage >
$numpages ) $disppage =
$numpages;
// echo 'Using: dmore=', $dispmore, ' dpage=', $disppage;
$content =
$pages[$disppage-
1];
$content =
explode('<!--more-->', $content);
if ((preg_match('/<!--noteaser-->/', $postdata['Content']) &&
((!$multipage) ||
($disppage==
1))))
if (($dispmore) &&
($stripteaser))
{ // We don't want to repeat the teaser:
{ // Viewer has already asked for more
if( !empty($more_anchor) ) $output .=
$before_more_link;
$output .=
'<a id="more'.
$id.
'" name="more'.
$id.
'"></a>'.
$more_anchor;
if( !empty($more_anchor) ) $output .=
$after_more_link;
{ // We are offering to read more
$output .=
$before_more_link.
'<a href="'.
$more_link.
'#more'.
$id.
'">'.
$more_link_text.
'</a>'.
$after_more_link;
{ // preview fix for javascript bug with foreign languages
$output =
preg_replace('/\%u([0-9A-F]{4,4})/e', "'&#'.base_convert('\\1',16,10).';'", $output);
if( ($format ==
'xml') &&
$cut )
{ // Let's cut this down...
for ($i=
0; $i<
$cut; $i++
)
$excerpt .=
$blah[$i].
' ';
$content =
$excerpt .
'...';
* vegarg: small bug when using $more_file fixed
function link_pages( $before=
'#', $after=
'#', $next_or_number=
'number', $nextpagelink=
'#', $previouspagelink=
'#', $pagelink=
'%d', $more_file=
'')
global $id, $page, $numpages, $multipage, $more;
if( $before ==
'#' ) $before =
'<p>'.
T_('Pages:').
' ';
if( $after ==
'#' ) $after =
'</p>';
if( $nextpagelink ==
'#' ) $nextpagelink =
T_('Next page');
if( $previouspagelink ==
'#' ) $previouspagelink =
T_('Previous page');
if( $multipage ) { // && ($more)) {
if( $next_or_number ==
'number' )
for ($i =
1; $i <
($numpages+
1); $i =
$i +
1)
if( ($i !=
$page) ||
( (!$more) &&
($page==
1) ))
echo
'<a href="'.
url_add_param($file, 'p='.
$id.
'&more=1&page='.
$i).
'">';
if( ($i !=
$page) ||
( (!$more) &&
($page==
1) ))
echo
' <a href="'.
url_add_param($file, 'p='.
$id.
'&page='.
$i).
'">'.
$previouspagelink.
'</a>';
echo
' <a href="'.
url_add_param($file, 'p='.
$id.
'&page='.
$i).
'">'.
$nextpagelink.
'</a>';
function previous_post($format=
'%', $previous=
'#', $title=
'yes', $in_same_cat=
'no', $limitprev=
1, $excluded_categories=
'')
if( $previous ==
'#' ) $previous =
T_('Previous post') .
': ';
global $DB, $tableposts, $postdata;
$current_post_date =
$postdata['Date'];
$current_category =
$postdata['Category'];
if ($in_same_cat !=
'no') {
$sqlcat =
" AND post_category='$current_category' ";
if (!empty($excluded_categories)) {
$blah =
explode('and', $excluded_categories);
foreach($blah as $category) {
$category =
intval($category);
$sql_exclude_cats .=
" AND post_category != $category";
$sql =
"SELECT ID,post_title
WHERE post_issue_date < '$current_post_date'
ORDER BY post_issue_date DESC
if( $p_info =
$DB->get_row( $sql ) )
$p_title =
$p_info->post_title;
function next_post($format=
'%', $next=
'#', $title=
'yes', $in_same_cat=
'no', $limitnext=
1, $excluded_categories=
'')
if( $next ==
'#' ) $next =
T_('Next post') .
': ';
global $tableposts, $p, $posts, $postdata, $localtimenow, $DB;
$current_post_date =
$postdata['Date'];
$current_category =
$postdata['Category'];
if ($in_same_cat !=
'no')
$sqlcat =
" AND post_category='$current_category' ";
if (!empty($excluded_categories)) {
$blah =
explode('and', $excluded_categories);
foreach($blah as $category) {
$category =
intval($category);
$sql_exclude_cats .=
" AND post_category != $category";
$now =
date('Y-m-d H:i:s', $localtimenow );
$sql =
"SELECT ID, post_title
WHERE post_issue_date > '$current_post_date'
AND post_issue_date < '$now'
ORDER BY post_issue_date ASC
if( $p_info =
$DB->get_row( $sql ) )
$p_title =
$p_info->post_title;
global $p, $paged, $Settings, $edited_Blog, $generating_static;
if (empty($p) &&
($Settings->get('what_to_show') ==
'paged'))
$nextpage =
intval($paged) +
1;
if (!$max_page ||
$max_page >=
$nextpage)
if( !isset
($generating_static) ||
$generating_static ==
false )
{ // We are not generating a static page here:
elseif( isset
($edited_Blog) )
{ // We are generating a static page
echo
url_add_param( $edited_Blog->get('dynurl'), 'paged='.
$nextpage );
// else...should not happen
global $p, $paged, $Settings, $edited_Blog, $generating_static;
if (empty($p) &&
($Settings->get('what_to_show') ==
'paged'))
$nextpage =
intval($paged) -
1;
if ($nextpage <
1) $nextpage =
1;
if( !isset
($generating_static) ||
$generating_static ==
false )
{ // We are not generating a static page here:
elseif( isset
($edited_Blog) )
{ // We are generating a static page
echo
url_add_param( $edited_Blog->get('dynurl'), 'paged='.
$nextpage );
// else...should not happen
global $p, $paged, $result, $request, $Settings;
if( $label ==
'#' ) $label =
T_('Next Page').
' >>';
if ($Settings->get('what_to_show') ==
'paged')
if (!$max_page) $max_page =
$MainList->get_max_paged();
$nextpage =
intval($paged) +
1;
if (empty($p) &&
(empty($paged) ||
$nextpage <=
$max_page))
if( $label ==
'#' ) $label =
'<< '.
T_('Previous Page');
if (empty($p) &&
($paged >
1) &&
($Settings->get('what_to_show') ==
'paged'))
* Links to previous/next page
function posts_nav_link($sep=
' :: ', $prelabel=
'#', $nxtlabel=
'#', $page=
'')
if( !empty( $request ) &&
empty($p) &&
($Settings->get('what_to_show') ==
'paged'))
$max_paged =
$MainList->get_max_paged();
* @deprecated deprecated by {@link ItemList::date_if_changed()}
function the_date($d=
'', $before=
'', $after=
'', $echo =
1)
global $id, $postdata, $day, $previousday, $newday;
if ($day !=
$previousday)
* @deprecated deprecated by {@link Item::time()} / {@link Item::date()}
function the_time($d=
'', $echo =
1, $useGM =
0)
$the_time =
mysql2date( $d, $postdata['Date'], $useGM);
global $weekday,$id,$postdata;
$the_weekday =
T_($weekday[mysql2date('w', $postdata['Date'])]);
global $weekday,$id,$postdata,$day,$previousweekday;
if ($day !=
$previousweekday) {
$the_weekday_date .=
$before;
$the_weekday_date .=
T_($weekday[mysql2date('w', $postdata['Date'])]);
$the_weekday_date .=
$after;
* @deprecated deprecated by {@link User::prefered_name()}
switch( $authordata['user_idmode'] )
$author =
$authordata['user_nickname'];
$author =
$authordata['user_login'];
$author =
$authordata['user_firstname'];
$author =
$authordata['user_lastname'];
$author =
$authordata['user_firstname'].
' '.
$authordata['user_lastname'];
$author =
$authordata['user_lastname'].
' '.
$authordata['user_firstname'];
$author =
$authordata['user_nickname'];
* @deprecated deprecated by {@link User::level()}
echo
$authordata['user_level'];
* @deprecated deprecated by {@link User::level()}
* the_author_firstname(-)
* @deprecated deprecated by {@link DataObject::ID()}
* @deprecated deprecated by {@link User::url()}
/***** Permalink tags *****/
* generate anchor for permalinks to refer to
* TODO: archives modes in clean mode
* @deprecated deprecated by {@link Item::anchor()}
$title =
preg_replace('/[^a-zA-Z0-9_\.-]/', '_', $postdata['Title']);
echo
'<a name="'.
$title.
'"></a>';
echo
'<a name="'.
$id.
'"></a>';
* TODO: archives modes in clean mode
* @deprecated deprecated by {@link Item::gen_permalink(-)}
$file, // base URL of the blog
$id, // post ID to be linked to
$use_anchor_mode =
'', // Default to id
$use_destination =
'', // Default to config
$use_more =
NULL, // DEPRECATED
$use_comments =
NULL, // DEPRECATED
$use_trackback =
NULL, // DEPRECATED
$use_pingback =
NULL ) // DEPRECATED
// We're gonna need access to more postdata in several cases:
if (empty($use_anchor_mode)) $use_anchor_mode =
'id';
if (empty($use_destination))
$use_destination =
( strstr( $Settings->get('permalink_type'), 'archive' ) !==
false )
if ($use_destination==
'archive') $use_destination =
$Settings->get('archive_mode');
$title =
preg_replace('/[^a-zA-Z0-9_\.-]/', '_', $postdata['Title']);
if( ! $Settings->get('links_extrapath') )
{ // We reference by Query: Dirty but explicit permalinks
if((!isset
($cacheweekly)) ||
(empty($cacheweekly[$postdata['Date']])))
$cacheweekly[$post_date] =
$DB->get_var( "SELECT WEEK('".
$post_date.
"')" );
$permalink =
url_add_param( $file, 'm='.
substr($postdata['Date'],0,4).
'&w='.
$cacheweekly[$postdata['Date']].
'#'.
$anchor );
$permalink =
url_add_param( $file, 'p='.
$id.
'&more=1&c=1&tb=1&pb=1' );
{ // We reference by path (CLEAN permalinks!)
$permalink =
$file.
mysql2date("/Y/m/", $postdata['Date']).
'#'.
$anchor;
if((!isset
($cacheweekly)) ||
(empty($cacheweekly[$postdata['Date']])))
$cacheweekly[$post_date] =
$DB->get_var( "SELECT WEEK('".
$post_date.
"')" );
$permalink =
$file.
mysql2date("/Y/m/", $postdata['Date']).
'w'.
$cacheweekly[$postdata['Date']].
'/#'.
$anchor;
$permalink =
$file.
mysql2date("/Y/m/d/", $postdata['Date']).
'#'.
$anchor;
// This is THE CLEANEST available: RECOMMENDED!
$permalink =
$file.
mysql2date("/Y/m/d/", $postdata['Date']).
'p'.
$id;
* @deprecated deprecated by {@link (Item::permalink())} but still used by _archives.php
function permalink_link($file=
'', $mode =
'id', $post_ID =
'' ) // id or title
if( empty($post_ID) ) $post_ID =
$id;
* Permalink forced to a single post
* @deprecated deprecated by {@link Item::permalink()}
* {@internal the_permalink(-) }}
* @deprecated deprecated by {@link $Item::permalink()}
/***** // Permalink tags *****/
// @@@ These aren't template tags, do not edit them
global $day, $previousday;
if ($day !=
$previousday) {
* Returns the number of the words in a string, sans HTML
/* In case str_word_count() doesn't exist (to accomodate PHP < 4.3).
(Code adapted from post by "brettNOSPAM at olwm dot NO_SPAM dot com" at
PHP documentation page for str_word_count(). A better implementation
$pattern =
"/[^(\w|\d|\'|\"|\.|\!|\?|;|,|\\|\/|\-\-|:|\&|@)]+/";
* Construct the where clause to limit retrieved posts on their status
* {@internal statuses_where_clause(-)}}
* @param Array statuses of posts we want to get
global $current_User, $blog;
if( empty($show_statuses) )
$show_statuses =
array( 'published', 'protected', 'private' );
if( ($key =
array_search( 'private', $show_statuses )) !==
false )
{ // Special handling for Private status:
unset
( $show_statuses[$key] );
{ // We need to be logged in to have a chance to see this:
$where .=
$or.
" ( post_status = 'private' AND post_author = $user_ID ) ";
{ // Special handling for Protected status:
if( (!is_logged_in()) ||
(!$current_User->check_perm( 'blog_ismember', 1, false, $blog )) )
{ // we are not allowed to see this if we are not a member of the current blog:
unset
( $show_statuses[$key] );
foreach( $show_statuses as $other_status )
$other_statuses .=
$sep.
'\''.
$other_status.
'\'';
if( strlen( $other_statuses ) )
$where .=
$or.
'post_status IN ('.
$other_statuses .
') ';