5 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
\r
6 * Copyright (C) 2002-2012 The Nucleus Group
\r
8 * This program is free software; you can redistribute it and/or
\r
9 * modify it under the terms of the GNU General Public License
\r
10 * as published by the Free Software Foundation; either version 2
\r
11 * of the License, or (at your option) any later version.
\r
12 * (see nucleus/documentation/index.html#license for more info)
\r
15 * A class representing a blog and containing functions to get that blog shown
\r
18 * @license http://nucleuscms.org/license.txt GNU General Public License
\r
19 * @copyright Copyright (C) 2002-2009 The Nucleus Group
\r
20 * @version $Id: BLOG.php 1624 2012-01-09 11:36:20Z sakamocchi $
\r
23 if ( !function_exists('requestVar') ) exit;
\r
24 require_once dirname(__FILE__) . '/ITEMACTIONS.php';
\r
31 // After creating an object of the blog class, contains true if the BLOG object is
\r
32 // valid (the blog exists)
\r
35 // associative array, containing all blogsettings (use the get/set functions instead)
\r
38 // ID of currently selected category
\r
39 private $selectedcatid;
\r
42 * Blog::_\construct()
\r
43 * Creates a new BLOG object for the given blog
\r
45 * @param integer $id blogid
\r
48 public function __construct($id)
\r
52 $this->blogid = (integer) $id;
\r
53 $this->readSettings();
\r
54 $this->setSelectedCategory($catid);
\r
60 * Shows the given amount of items for this blog
\r
62 * @param string $template String representing the template _NAME_ (!)
\r
63 * @param integer $amountEntries amount of entries to show
\r
64 * @param integer $startpos offset from where items should be shown (e.g. 5 = start at fifth item)
\r
65 * @return integer amount of items shown
\r
67 public function readLog($template, $amountEntries, $offset = 0, $startpos = 0)
\r
69 return $this->readLogAmount($template,$amountEntries,'','',1,1,$offset, $startpos);
\r
73 * Blog::showArchive()
\r
74 * Shows an archive for a given month
\r
76 * @param integer $year year
\r
77 * @param integer $month month
\r
78 * @param string $template String representing the template name to be used
\r
81 public function showArchive($templatename, $year, $month=0, $day=0)
\r
83 // create extra where clause for select query
\r
84 if ( $day == 0 && $month != 0 )
\r
86 $timestamp_start = mktime(0,0,0,$month,1,$year);
\r
87 // also works when $month==12
\r
88 $timestamp_end = mktime(0,0,0,$month+1,1,$year);
\r
90 elseif ( $month == 0 )
\r
92 $timestamp_start = mktime(0,0,0,1,1,$year);
\r
93 // also works when $month==12
\r
94 $timestamp_end = mktime(0,0,0,12,31,$year);
\r
98 $timestamp_start = mktime(0,0,0,$month,$day,$year);
\r
99 $timestamp_end = mktime(0,0,0,$month,$day+1,$year);
\r
101 $extra_query = " and i.itime>=%s and i.itime<%s";
\r
102 $extra_query = sprintf($extra_query, DB::formatDateTime($timestamp_start), DB::formatDateTime($timestamp_end));
\r
104 $this->readLogAmount($templatename,0,$extra_query,'',1,1);
\r
109 * Blog::setSelectedCategory()
\r
110 * Sets the selected category by id (only when category exists)
\r
112 * @param integer $catid ID for category
\r
115 public function setSelectedCategory($catid)
\r
117 if ( $this->isValidCategory($catid) || (intval($catid) == 0) )
\r
119 $this->selectedcatid = intval($catid);
\r
125 * Blog::setSelectedCategoryByName()
\r
126 * Sets the selected category by name
\r
128 * @param string $catname name of category
\r
131 public function setSelectedCategoryByName($catname)
\r
133 $this->setSelectedCategory($this->getCategoryIdFromName($catname));
\r
138 * Blog::getSelectedCategory()
\r
139 * Returns the selected category
\r
144 public function getSelectedCategory()
\r
146 return $this->selectedcatid;
\r
150 * Shows the given amount of items for this blog
\r
152 * @param string $template string representing the template _NAME_ (!)
\r
153 * @param integer $amountEntries amount of entries to show (0 = no limit)
\r
154 * @param string $extraQuery extra conditions to be added to the query
\r
155 * @param string $highlight contains a query that should be highlighted
\r
156 * @param integer $comments 1=show comments 0=don't show comments
\r
157 * @param integer $dateheads 1=show dateheads 0=don't show dateheads
\r
158 * @param integer $offset offset
\r
159 * @return integer amount of items shown
\r
161 private function readLogAmount($template, $amountEntries, $extraQuery, $highlight, $comments, $dateheads, $offset = 0, $startpos = 0)
\r
163 $query = $this->getSqlBlog($extraQuery);
\r
165 if ( $amountEntries > 0 )
\r
167 // $offset zou moeten worden:
\r
168 // (($startpos / $amountentries) + 1) * $offset ... later testen ...
\r
169 $query .= ' LIMIT ' . intval($startpos + $offset).',' . intval($amountEntries);
\r
171 return $this->showUsingQuery($template, $query, $highlight, $comments, $dateheads);
\r
175 * Blog::showUsingQuery()
\r
176 * Do the job for readLogAmmount
\r
178 * @param string $templateName template name
\r
179 * @param string $query string for query
\r
180 * @param string $highlight string to be highlighted
\r
181 * @param integer $comments the number of comments
\r
182 * @param boolean $dateheads date header is needed or not
\r
183 * @return integer the number of rows as a result of mysql query
\r
185 private function showUsingQuery($templateName, $query, $highlight = '', $comments = 0, $dateheads = 1)
\r
187 global $CONF, $manager, $currentTemplateName;
\r
189 $lastVisit = cookieVar($CONF['CookiePrefix'] .'lastVisit');
\r
190 if ( $lastVisit != 0 )
\r
192 $lastVisit = $this->getCorrectTime($lastVisit);
\r
195 // set templatename as global variable (so plugins can access it)
\r
196 $currentTemplateName = $templateName;
\r
197 $template =& $manager->getTemplate($templateName);
\r
199 // create parser object & action handler
\r
200 $handler = new ItemActions($this);
\r
201 $handler->setTemplate($template);
\r
202 $handler->setHighlight($highlight);
\r
203 $handler->setLastVisit($lastVisit);
\r
204 $handler->setShowComments($comments);
\r
206 $parser = new Parser($handler);
\r
209 $items = DB::getResult($query);
\r
211 // loop over all items
\r
213 foreach ( $items as $item )
\r
215 // string timestamp -> unix timestamp
\r
216 $item['timestamp'] = strtotime($item['itime']);
\r
218 // action handler needs to know the item we're handling
\r
219 $handler->setCurrentItem($item);
\r
221 // add date header if needed
\r
224 $new_date = date('dFY', $item['timestamp']);
\r
225 if ( $new_date != $old_date )
\r
227 // unless this is the first time, write date footer
\r
228 $timestamp = $item['timestamp'];
\r
229 if ( $old_date != 0 )
\r
231 $oldTS = strtotime($old_date);
\r
232 $manager->notify('PreDateFoot',array('blog' => &$this, 'timestamp' => $oldTS));
\r
234 if ( !in_array('DATE_FOOTER', $template) || empty($template['DATE_FOOTER']) )
\r
240 $tmp_footer = i18n::formatted_datetime($template['DATE_FOOTER'], $oldTS);
\r
242 $parser->parse($tmp_footer);
\r
243 $manager->notify('PostDateFoot',array('blog' => &$this, 'timestamp' => $oldTS));
\r
246 $manager->notify('PreDateHead',array('blog' => &$this, 'timestamp' => $timestamp));
\r
248 // note, to use templatvars in the dateheader, the %-characters need to be doubled in
\r
249 // order to be preserved by strftime
\r
250 if ( !in_array('DATE_HEADER', $template) || empty($template['DATE_HEADER']) )
\r
256 $tmp_header = i18n::formatted_datetime($template['DATE_HEADER'], $timestamp);
\r
258 $parser->parse($tmp_header);
\r
259 $manager->notify('PostDateHead',array('blog' => &$this, 'timestamp' => $timestamp));
\r
261 $old_date = $new_date;
\r
265 $parser->parse($template['ITEM_HEADER']);
\r
266 $manager->notify('PreItem', array('blog' => &$this, 'item' => &$item));
\r
267 $parser->parse($template['ITEM']);
\r
268 $manager->notify('PostItem', array('blog' => &$this, 'item' => &$item));
\r
269 $parser->parse($template['ITEM_FOOTER']);
\r
272 $numrows = $items->rowCount();
\r
274 // add another date footer if there was at least one item
\r
275 if ( ($numrows > 0) && $dateheads )
\r
277 $manager->notify('PreDateFoot',array('blog' => &$this, 'timestamp' => strtotime($old_date)));
\r
278 $parser->parse($template['DATE_FOOTER']);
\r
279 $manager->notify('PostDateFoot',array('blog' => &$this, 'timestamp' => strtotime($old_date)));
\r
282 $items->closeCursor();
\r
287 * Blog::showOneitem()
\r
288 * Simplified function for showing only one item
\r
290 * @param integer $itemid ID for item
\r
291 * @param array $template template for item
\r
292 * @param string $highlight string for highlight
\r
293 * @return integer 1
\r
295 public function showOneitem($itemid, $template, $highlight)
\r
297 $extraQuery = ' and inumber=' . intval($itemid);
\r
299 return $this->readLogAmount($template, 1, $extraQuery, $highlight, 0, 0);
\r
304 * Adds an item to this blog
\r
306 * @param integer $catid ID for category
\r
307 * @param string $title ID for
\r
308 * @param string $body text for body
\r
309 * @param string $more text for more
\r
310 * @param integer $blogid ID for blog
\r
311 * @param integer $authorid ID for author
\r
312 * @param timestamp $timestamp UNIX timestamp for post
\r
313 * @param boolean $closed opened or closed
\r
314 * @param boolean $draft draft or not
\r
315 * @param boolean $posted posted or not
\r
316 * @return integer ID for added item
\r
318 function additem($catid, $title, $body, $more, $blogid, $authorid, $timestamp, $closed, $draft, $posted='1')
\r
322 $blogid = (integer) $blogid;
\r
323 $authorid = (integer) $authorid;
\r
327 $catid = intval($catid);
\r
329 // convert newlines to <br />
\r
330 if ( $this->convertBreaks() )
\r
332 $body = addBreaks($body);
\r
333 $more = addBreaks($more);
\r
336 if ( $closed != '1' )
\r
340 if ( $draft != '0' )
\r
345 if ( !$this->isValidCategory($catid) )
\r
347 $catid = $this->getDefaultCategory();
\r
351 if ( $timestamp > $this->getCorrectTime() )
\r
356 $timestamp = date('Y-m-d H:i:s',$timestamp);
\r
358 $manager->notify('PreAddItem',array('title' => &$title, 'body' => &$body, 'more' => &$more, 'blog' => &$this, 'authorid' => &$authorid, 'timestamp' => &$timestamp, 'closed' => &$closed, 'draft' => &$draft, 'catid' => &$catid));
\r
360 $ititle = DB::quoteValue($title);
\r
361 $ibody = DB::quoteValue($body);
\r
362 $imore = DB::quoteValue($more);
\r
363 $timestamp = DB::formatDateTime(strtotime($timestamp));
\r
365 $query = "INSERT INTO %s (ITITLE, IBODY, IMORE, IBLOG, IAUTHOR, ITIME, ICLOSED, IDRAFT, ICAT, IPOSTED) VALUES (%s, %s, %s, %d, %d, %s, %s, %s, %s, %s)";
\r
366 $query = sprintf($query, sql_table('item'), $ititle, $ibody, $imore, $blogid, $authorid, $timestamp, $closed, $draft, $catid, $posted);
\r
367 DB::execute($query);
\r
368 $itemid = DB::getInsertId();
\r
370 $manager->notify('PostAddItem',array('itemid' => $itemid));
\r
374 $this->updateUpdateFile();
\r
376 // send notification mail
\r
377 if ( !$draft && !$isFuture && $this->getNotifyAddress() && $this->notifyOnNewItem() )
\r
379 $this->sendNewItemNotification($itemid, $title, $body);
\r
385 * Blog::sendNewItemNotification()
\r
386 * Send a new item notification to the notification list
\r
388 * @param string $itemid ID of the item
\r
389 * @param string $title title of the item
\r
390 * @param string $body body of the item
\r
393 public function sendNewItemNotification($itemid, $title, $body)
\r
395 global $CONF, $member;
\r
397 $ascii = Entity::anchor_footnoting($body);
\r
399 $message = _NOTIFY_NI_MSG . " \n";
\r
400 $temp = parse_url($CONF['Self']);
\r
401 if ( $temp['scheme'] )
\r
403 $message .= Link::create_item_link($itemid) . "\n\n";
\r
407 $tempurl = $this->getURL();
\r
408 if ( i18n::substr($tempurl, -1) == '/' || i18n::substr($tempurl, -4) == '.php' )
\r
410 $message .= $tempurl . '?itemid=' . $itemid . "\n\n";
\r
414 $message .= $tempurl . '/?itemid=' . $itemid . "\n\n";
\r
417 $message .= _NOTIFY_TITLE . ' ' . strip_tags($title) . "\n";
\r
418 $message .= _NOTIFY_CONTENTS . "\n " . $ascii . "\n";
\r
419 $message .= NOTIFICATION::get_mail_footer();
\r
421 $subject = $this->getName() . ': ' . _NOTIFY_NI_TITLE;
\r
423 $from = $member->getNotifyFromMailAddress();
\r
425 NOTIFICATION::mail($this->getNotifyAddress(), $subject, $message, $from, i18n::get_current_charset());
\r
430 * Blog::createNewCategory()
\r
431 * Creates a new category for this blog
\r
433 * @param string $catName name of the new category. When empty, a name is generated automatically (starting with newcat)
\r
434 * @param string $catDescription description of the new category. Defaults to 'New Category'
\r
435 * @return integer ID for new category on success. 0 on failure
\r
437 public function createNewCategory($catName = '', $catDescription = _CREATED_NEW_CATEGORY_DESC)
\r
439 global $member, $manager;
\r
441 if ( !$member->blogAdminRights($this->blogid) )
\r
447 if ( $catName == '' )
\r
449 $catName = _CREATED_NEW_CATEGORY_NAME;
\r
452 $res = DB::getResult('SELECT * FROM '.sql_table('category')." WHERE cname='".$catName.$i."' and cblog=".$this->blogid);
\r
453 while ( $res->rowCount() > 0 )
\r
456 $res = DB::getResult('SELECT * FROM '.sql_table('category')." WHERE cname='".$catName.$i."' and cblog=".$this->blogid);
\r
459 $catName = $catName . $i;
\r
464 'name' => &$catName,
\r
465 'description' => $catDescription
\r
467 $manager->notify('PreAddCategory', $data);
\r
469 $query = "INSERT INTO %s (cblog, cname, cdesc) VALUES (%d, %s, %s)";
\r
470 $query = sprintf($query, sql_table('category'), (integer) $this->blogid, DB::quoteValue($catName), DB::quoteValue($catDescription));
\r
471 DB::execute($query);
\r
472 $catid = DB::getInsertId();
\r
476 'name' => $catName,
\r
477 'description' => $catDescription,
\r
480 $manager->notify('PostAddCategory', $data);
\r
487 * Searches all months of this blog for the given query
\r
489 * @param string $query search query
\r
490 * @param array $template template to be used (__NAME__ of the template)
\r
491 * @param integer $amountMonths max amount of months to be search (0 = all)
\r
492 * @param integer $maxresults max number of results to show
\r
493 * @param integer $startpos offset
\r
494 * @return amount of hits found
\r
496 public function search($query, $template, $amountMonths, $maxresults, $startpos) {
\r
497 global $CONF, $manager;
\r
500 $sqlquery = $this->getSqlSearch($query, $amountMonths, $highlight);
\r
502 if ( $sqlquery == '' )
\r
504 // no query -> show everything
\r
506 $amountfound = $this->readLogAmount($template, $maxresults, $extraQuery, $query, 1, 1);
\r
510 // add LIMIT to query (to split search results into pages)
\r
511 if ( intval($maxresults > 0) )
\r
513 $sqlquery .= ' LIMIT ' . intval($startpos) . ',' . intval($maxresults);
\r
517 $amountfound = $this->showUsingQuery($template, $sqlquery, $highlight, 1, 1);
\r
519 // when no results were found, show a message
\r
520 if ( $amountfound == 0 )
\r
522 $template =& $manager->getTemplate($template);
\r
524 'query' => Entity::hsc($query),
\r
525 'blogid' => $this->blogid
\r
527 echo Template::fill($template['SEARCH_NOTHINGFOUND'], $vars);
\r
530 return $amountfound;
\r
534 * Blog::getSqlSearch()
\r
535 * Returns an SQL query to use for a search query
\r
536 * No LIMIT clause is added. (caller should add this if multiple pages are requested)
\r
538 * @param string $query search query
\r
539 * @param integer $amountMonths amount of months to search back. Default = 0 = unlimited
\r
540 * @param string $mode either empty, or 'count'. In this case, the query will be a SELECT COUNT(*) query
\r
541 * @return string $highlight words to highlight (out parameter)
\r
542 * @return string either a full SQL query, or an empty string (if querystring empty)
\r
544 public function getSqlSearch($query, $amountMonths = 0, &$highlight, $mode = '')
\r
546 $searchclass = new Search($query);
\r
548 $highlight = $searchclass->inclusive;
\r
550 // if querystring is empty, return empty string
\r
551 if ( $searchclass->inclusive == '' )
\r
556 $where = $searchclass->boolean_sql_where('ititle,ibody,imore');
\r
557 $select = $searchclass->boolean_sql_select('ititle,ibody,imore');
\r
559 // get list of blogs to search
\r
560 $blogs = $searchclass->blogs; // array containing blogs that always need to be included
\r
561 $blogs[] = $this->blogid; // also search current blog (duh)
\r
562 $blogs = array_unique($blogs); // remove duplicates
\r
564 if ( count($blogs) > 0 )
\r
566 $selectblogs = ' and i.iblog in (' . implode(',', $blogs) . ')';
\r
571 $query = 'SELECT i.inumber as itemid, i.ititle as title, i.ibody as body, i.itime, i.imore as more, i.icat as catid, i.iclosed as closed,
\r
572 m.mname as author, m.mrealname as authorname, m.mnumber as authorid, m.memail as authormail, m.murl as authorurl,
\r
573 c.cname as category';
\r
577 $query .= ', '.$select. ' as score ';
\r
582 $query = 'SELECT COUNT(*) as result ';
\r
585 $query .= ' FROM '.sql_table('item').' as i, '.sql_table('member').' as m, '.sql_table('category').' as c'
\r
586 . ' WHERE i.iauthor=m.mnumber'
\r
587 . ' and i.icat=c.catid'
\r
589 . ' and i.idraft=0'
\r
591 // don't show future items
\r
592 . ' and i.itime<=' . DB::formatDateTime($this->getCorrectTime())
\r
595 // take into account amount of months to search
\r
596 if ( $amountMonths > 0 )
\r
598 $localtime = getdate($this->getCorrectTime());
\r
599 $timestamp_start = mktime(0,0,0,$localtime['mon'] - $amountMonths,1,$localtime['year']);
\r
600 $query .= ' and i.itime>' . DB::formatDateTime($timestamp_start);
\r
607 $query .= ' ORDER BY score DESC';
\r
611 $query .= ' ORDER BY i.itime DESC ';
\r
619 * Blog::getSqlBlog()
\r
620 * Returns the SQL query that's normally used to display the blog items on the index type skins
\r
621 * No LIMIT clause is added. (caller should add this if multiple pages are requested)
\r
623 * @param string $extraQuery extra query string
\r
624 * @param string $mode either empty, or 'count'. In this case, the query will be a SELECT COUNT(*) query
\r
625 * @return string either a full SQL query, or an empty string
\r
627 public function getSqlBlog($extraQuery, $mode = '')
\r
631 $query = 'SELECT i.inumber as itemid, i.ititle as title, i.ibody as body, m.mname as author,
\r
632 m.mrealname as authorname, i.itime, i.imore as more, m.mnumber as authorid, m.memail as authormail,
\r
633 m.murl as authorurl, c.cname as category, i.icat as catid, i.iclosed as closed';
\r
637 $query = 'SELECT COUNT(*) as result ';
\r
640 $query .= ' FROM '.sql_table('item').' as i, '.sql_table('member').' as m, '.sql_table('category').' as c'
\r
641 . ' WHERE i.iblog='.$this->blogid
\r
642 . ' and i.iauthor=m.mnumber'
\r
643 . ' and i.icat=c.catid'
\r
644 . ' and i.idraft=0' // exclude drafts
\r
645 . ' and i.itime<=' . DB::formatDateTime($this->getCorrectTime()); // don't show future items
\r
647 if ( $this->selectedcatid )
\r
649 $query .= ' and i.icat=' . $this->selectedcatid . ' ';
\r
652 $query .= $extraQuery;
\r
656 $query .= ' ORDER BY i.itime DESC';
\r
662 * Blog::showArchiveList()
\r
663 * Shows the archivelist using the given template
\r
665 * @param string $template template name
\r
666 * @param string $mode year/month/day
\r
667 * @param integer $limit limit of record count
\r
670 public function showArchiveList($template, $mode = 'month', $limit = 0)
\r
672 global $CONF, $catid, $manager;
\r
674 if ( !isset ($linkparams) )
\r
676 $linkparams = array();
\r
681 $linkparams = array('catid' => $catid);
\r
684 $template =& $manager->getTemplate($template);
\r
685 $data['blogid'] = $this->blogid;
\r
687 if ( !array_key_exists('ARCHIVELIST_HEADER', $template) || !$template['ARCHIVELIST_HEADER'] )
\r
693 $tplt = $template['ARCHIVELIST_HEADER'];
\r
696 echo Template::fill($tplt, $data);
\r
698 $query = 'SELECT itime, SUBSTRING(itime,1,4) AS Year, SUBSTRING(itime,6,2) AS Month, SUBSTRING(itime,9,2) AS Day'
\r
699 . ' FROM '.sql_table('item')
\r
700 . ' WHERE iblog=' . $this->blogid
\r
701 . ' AND itime <=' . DB::formatDateTime($this->getCorrectTime()) // don't show future items!
\r
702 . ' AND idraft=0'; // don't show draft items
\r
706 $query .= ' and icat=' . intval($catid);
\r
709 $query .= ' GROUP BY Year';
\r
710 if ( $mode == 'month' || $mode == 'day' )
\r
712 $query .= ', Month';
\r
714 if ( $mode == 'day' )
\r
719 $query .= ' ORDER BY itime DESC';
\r
723 $query .= ' LIMIT ' . intval($limit);
\r
726 $res = DB::getResult($query);
\r
727 foreach ( $res as $current )
\r
729 /* string time -> unix timestamp */
\r
730 $current['itime'] = strtotime($current['itime']);
\r
732 if ( $mode == 'day' )
\r
734 $archivedate = date('Y-m-d',$current['itime']);
\r
735 $archive['day'] = date('d',$current['itime']);
\r
736 $data['day'] = date('d',$current['itime']);
\r
737 $data['month'] = date('m',$current['itime']);
\r
738 $archive['month'] = $data['month'];
\r
740 elseif ( $mode == 'year' )
\r
742 $archivedate = date('Y',$current['itime']);
\r
744 $data['month'] = '';
\r
745 $archive['day'] = '';
\r
746 $archive['month'] = '';
\r
750 $archivedate = date('Y-m',$current['itime']);
\r
751 $data['month'] = date('m',$current['itime']);
\r
752 $archive['month'] = $data['month'];
\r
754 $archive['day'] = '';
\r
757 $data['year'] = date('Y',$current['itime']);
\r
758 $archive['year'] = $data['year'];
\r
759 $data['archivelink'] = Link::create_archive_link($this->blogid,$archivedate,$linkparams);
\r
761 $manager->notify('PreArchiveListItem', array('listitem' => &$data));
\r
763 $temp = Template::fill($template['ARCHIVELIST_LISTITEM'],$data);
\r
764 echo i18n::formatted_datetime($temp, $current['itime']);
\r
768 $res->closeCursor();
\r
770 if ( !array_key_exists('ARCHIVELIST_FOOTER', $template) || !$template['ARCHIVELIST_FOOTER'] )
\r
776 $tplt = $template['ARCHIVELIST_FOOTER'];
\r
779 echo Template::fill($tplt, $data);
\r
784 * Blog::showCategoryList()
\r
785 * Shows the list of categories using a given template
\r
787 * @param string $template Template Name
\r
790 public function showCategoryList($template)
\r
792 global $CONF, $archive, $archivelist, $manager;
\r
795 * determine arguments next to catids
\r
796 * I guess this can be done in a better way, but it works
\r
798 $linkparams = array();
\r
801 $blogurl = Link::create_archive_link($this->blogid, $archive, '');
\r
802 $linkparams['blogid'] = $this->blogid;
\r
803 $linkparams['archive'] = $archive;
\r
805 else if ( $archivelist )
\r
807 $blogurl = Link::create_archivelist_link($this->blogid, '');
\r
808 $linkparams['archivelist'] = $archivelist;
\r
812 $blogurl = Link::create_blogid_link($this->blogid, '');
\r
813 $linkparams['blogid'] = $this->blogid;
\r
816 $template =& $manager->getTemplate($template);
\r
818 //: Change: Set nocatselected variable
\r
819 if ( $this->selectedcatid )
\r
821 $nocatselected = 'no';
\r
825 $nocatselected = 'yes';
\r
829 'blogid' => $this->blogid,
\r
830 'blogurl' => $blogurl,
\r
831 'self' => $CONF['Self'],
\r
832 'catiscurrent' => $nocatselected, // Change: Set catiscurrent template variable for header
\r
833 'currentcat' => $nocatselected
\r
836 /* output header of category list item */
\r
837 if ( !array_key_exists('CATLIST_HEADER', $template) || empty($template['CATLIST_HEADER']) )
\r
839 echo Template::fill(NULL, $args);
\r
843 echo Template::fill($template['CATLIST_HEADER'], $args);
\r
846 $query = "SELECT catid, cdesc as catdesc, cname as catname FROM %s WHERE cblog=%d ORDER BY cname ASC;";
\r
847 $query = sprintf($query, sql_table('category'), (integer) $this->blogid);
\r
848 $res = DB::getResult($query);
\r
850 foreach ( $res as $data )
\r
853 'catid' => $data['catid'],
\r
854 'name' => $data['catname'],
\r
855 'extra' => $linkparams
\r
858 $data['blogid'] = $this->blogid;
\r
859 $data['blogurl'] = $blogurl;
\r
860 $data['catlink'] = Link::create_link('category', $args);
\r
861 $data['self'] = $CONF['Self'];
\r
863 // this gives catiscurrent = no when no category is selected.
\r
864 $data['catiscurrent'] = 'no';
\r
865 $data['currentcat'] = 'no';
\r
867 if ( $this->selectedcatid )
\r
869 if ( $this->selectedcatid == $data['catid'] )
\r
871 $data['catiscurrent'] = 'yes';
\r
872 $data['currentcat'] = 'yes';
\r
878 if ( intval($itemid) && $manager->existsItem(intval($itemid), 0, 0) )
\r
880 $iobj =& $manager->getItem(intval($itemid), 0, 0);
\r
881 $cid = $iobj['catid'];
\r
883 if ( $cid == $data['catid'] )
\r
885 $data['catiscurrent'] = 'yes';
\r
886 $data['currentcat'] = 'yes';
\r
891 $manager->notify('PreCategoryListItem', array('listitem' => &$data));
\r
893 if ( !array_key_exists('CATLIST_LISTITEM', $template) || empty($template['CATLIST_LISTITEM']))
\r
895 echo Template::fill(NULL, $data);
\r
899 echo Template::fill($template['CATLIST_LISTITEM'], $data);
\r
903 $res->closeCursor();
\r
906 'blogid' => $this->blogid,
\r
907 'blogurl' => $blogurl,
\r
908 'self' => $CONF['Self'],
\r
909 'catiscurrent' => $nocatselected, //: Change: Set catiscurrent template variable for footer
\r
910 'currentcat' => $nocatselected
\r
913 if ( !array_key_exists('CATLIST_FOOTER', $template) || empty($template['CATLIST_FOOTER']))
\r
915 echo Template::fill(NULL, $args);
\r
919 echo Template::fill($template['CATLIST_FOOTER'], $args);
\r
926 * Blog::showBlogList()
\r
927 * Shows a list of all blogs in the system using a given template
\r
928 * ordered by number, name, shortname or description
\r
929 * in ascending or descending order
\r
931 * @param string $template tempalte name
\r
932 * @param string $bnametype bname/bshortname
\r
933 * @param string $orderby string for 'ORDER BY' SQL
\r
934 * @param string $direction ASC/DESC
\r
937 public function showBlogList($template, $bnametype, $orderby, $direction)
\r
939 global $CONF, $manager;
\r
941 switch ( $orderby )
\r
944 $orderby='bnumber';
\r
950 $orderby='bshortname';
\r
952 case 'description':
\r
956 $orderby='bnumber';
\r
960 $direction=strtolower($direction);
\r
961 switch ( $direction )
\r
974 $template =& $manager->getTemplate($template);
\r
976 if ( array_key_exists('BLOGLIST_HEADER', $template) && !empty($template['BLOGLIST_HEADER']) )
\r
979 'sitename' => $CONF['SiteName'],
\r
980 'siteurl' => $CONF['IndexURL']
\r
983 echo Template::fill($template['BLOGLIST_HEADER'], $vars);
\r
986 if ( array_key_exists('BLOGLIST_LISTITEM', $template) && !empty($template['BLOGLIST_LISTITEM']) )
\r
988 $query = 'SELECT bnumber, bname, bshortname, bdesc, burl FROM '.sql_table('blog').' ORDER BY '.$orderby.' '.$direction;
\r
989 $res = DB::getResult($query);
\r
991 foreach ( $res as $data )
\r
994 $list['bloglink'] = Link::create_blogid_link($data['bnumber']);
\r
995 $list['blogdesc'] = $data['bdesc'];
\r
996 $list['blogurl'] = $data['burl'];
\r
998 if ( $bnametype == 'shortname' )
\r
1000 $list['blogname'] = $data['bshortname'];
\r
1004 /* all other cases */
\r
1005 $list['blogname'] = $data['bname'];
\r
1008 $manager->notify('PreBlogListItem',array('listitem' => &$list));
\r
1010 echo Template::fill($template['BLOGLIST_LISTITEM'], $list);
\r
1013 $res->closeCursor();
\r
1017 if ( array_key_exists('BLOGLIST_FOOTER', $template) && !empty($template['BLOGLIST_FOOTER']) )
\r
1020 'sitename' => $CONF['SiteName'],
\r
1021 'siteurl' => $CONF['IndexURL']
\r
1023 echo Template::fill($template['BLOGLIST_FOOTER']);
\r
1029 * Blog::readSettings()
\r
1030 * Read the blog settings
\r
1035 public function readSettings()
\r
1037 $query = 'SELECT * FROM %s WHERE bnumber=%d;';
\r
1038 $query = sprintf($query, sql_table('blog'), (integer) $this->blogid);
\r
1039 $res = DB::getResult($query);
\r
1041 $this->isValid = ($res->rowCount() > 0);
\r
1042 if ( $this->isValid )
\r
1044 $this->settings = $res->fetch(PDO::FETCH_ASSOC);
\r
1050 * Blog::writeSettings()
\r
1051 * Write the blog settings
\r
1053 public function writeSettings()
\r
1055 // (can't use floatval since not available prior to PHP 4.2)
\r
1056 $offset = $this->getTimeOffset();
\r
1057 if ( !is_float($offset) )
\r
1059 $offset = (integer) $offset;
\r
1062 $query = 'UPDATE '.sql_table('blog')
\r
1063 . ' SET bname=' . DB::quoteValue($this->getName()) . ','
\r
1064 . ' bshortname='. DB::quoteValue($this->getShortName()) . ','
\r
1065 . ' bcomments='. intval($this->commentsEnabled()) . ','
\r
1066 . ' bmaxcomments=' . intval($this->getMaxComments()) . ','
\r
1067 . ' btimeoffset=' . $offset . ','
\r
1068 . ' bpublic=' . intval($this->isPublic()) . ','
\r
1069 . ' breqemail=' . intval($this->emailRequired()) . ','
\r
1070 . ' bconvertbreaks=' . intval($this->convertBreaks()) . ','
\r
1071 . ' ballowpast=' . intval($this->allowPastPosting()) . ','
\r
1072 . ' bnotify=' . DB::quoteValue($this->getNotifyAddress()) . ','
\r
1073 . ' bnotifytype=' . intval($this->getNotifyType()) . ','
\r
1074 . ' burl=' . DB::quoteValue($this->getURL()) . ','
\r
1075 . ' bupdate=' . DB::quoteValue($this->getUpdateFile()) . ','
\r
1076 . ' bdesc=' . DB::quoteValue($this->getDescription()) . ','
\r
1077 . ' bdefcat=' . intval($this->getDefaultCategory()) . ','
\r
1078 . ' bdefskin=' . intval($this->getDefaultSkin()) . ','
\r
1079 . ' bincludesearch=' . intval($this->getSearchable())
\r
1080 . ' WHERE bnumber=' . intval($this->blogid);
\r
1081 DB::execute($query);
\r
1086 * Blog::updateUpdatefile()
\r
1087 * Update the update file if requested
\r
1092 public function updateUpdatefile()
\r
1094 if ( $this->getUpdateFile() )
\r
1096 $f_update = fopen($this->getUpdateFile(), 'w');
\r
1097 fputs($f_update,$this->getCorrectTime());
\r
1098 fclose($f_update);
\r
1104 * Blog::isValidCategory()
\r
1105 * Check if a category with a given catid is valid
\r
1107 * @param integer $catid ID for category
\r
1108 * @return boolean exists or not
\r
1110 public function isValidCategory($catid)
\r
1112 $query = 'SELECT * FROM %s WHERE cblog=%d and catid=%d;';
\r
1113 $query = sprintf($query, sql_table('category'), (integer) $this->blogid, (integer) $catid);
\r
1114 $res = DB::getResult($query);
\r
1115 return ($res->rowCount() != 0);
\r
1119 * Blog::getCategoryName()
\r
1120 * Get the category name for a given catid
\r
1122 * @param integer $catid ID for category
\r
1123 * @return string name of category
\r
1125 public function getCategoryName($catid)
\r
1127 $query = 'SELECT cname FROM %s WHERE cblog=%d and catid=%d;';
\r
1128 $query = sprintf($query, sql_table('category'), (integer) $this->blogid, (integer) $catid);
\r
1129 $res = DB::getValue($query);
\r
1134 * Blog::getCategoryDesc()
\r
1135 * Get the category description for a given catid
\r
1140 public function getCategoryDesc($catid)
\r
1142 $query = 'SELECT cdesc FROM %s WHERE cblog=%d and catid=%d;';
\r
1143 $query = sprintf($querym, sql_table('category'), (integer) $this->blogid, (integer) $catid);
\r
1144 $res = DB::getValue();
\r
1149 * Blog::getCategoryIdFromName
\r
1150 * Get the category id for a given category name
\r
1152 * @param string $name category name
\r
1153 * @return ID for category
\r
1155 public function getCategoryIdFromName($name)
\r
1157 $query = 'SELECT catid FROM %s WHERE cblog=%d and cname=%s;';
\r
1158 $query = sprintf($query, sql_table('category'), (integer) $this->blogid, DB::quoteValue($name));
\r
1160 $res = DB::getValue();
\r
1163 return $this->getDefaultCategory();
\r
1169 * Blog::insertJavaScriptInfo()
\r
1170 * Insert a javascript that includes information about the settings
\r
1171 * of an author: ConvertBreaks, MediaUrl and AuthorId
\r
1173 * @param $authorid id of the author
\r
1175 public function insertJavaScriptInfo($authorid = '')
\r
1177 global $member, $CONF;
\r
1179 if ( $authorid == '' )
\r
1181 $authorid = $member->getID();
\r
1184 echo "<script type=\"text/javascript\">\n";
\r
1186 if ( !$this->convertBreaks() )
\r
1188 echo "setConvertBreaks(false);\n";
\r
1192 echo "setConvertBreaks(true);\n";
\r
1194 echo "setMediaUrl('{$CONF['MediaURL']}');\n";
\r
1195 echo "setAuthorId('{$authorid}');\n";
\r
1196 echo "</script>\n";
\r
1201 * Blog::setAllowPastPosting()
\r
1202 * Set the the setting for allowing to publish postings in the past
\r
1204 * @param boolean $val new value for ballowpast
\r
1207 public function setAllowPastPosting($val)
\r
1209 $this->setSetting('ballowpast', $val);
\r
1214 * Blog::allowPastPosting()
\r
1215 * Get the the setting if it is allowed to publish postings in the past
\r
1216 * [should be named as getAllowPastPosting()]
\r
1221 public function allowPastPosting()
\r
1223 return $this->getSetting('ballowpast');
\r
1227 * Blog::getCorrectTime()
\r
1229 * @param integer $t
\r
1232 public function getCorrectTime($t=0)
\r
1238 return ($t + 3600 * $this->getTimeOffset());
\r
1245 * @return string name of this weblog
\r
1247 public function getName()
\r
1249 return $this->getSetting('bname');
\r
1253 * Blog::getShortName()
\r
1256 * @return string short name of this weblog
\r
1258 public function getShortName()
\r
1260 return $this->getSetting('bshortname');
\r
1264 * Blog::getMaxComments()
\r
1267 * @return integer maximum number of comments
\r
1269 public function getMaxComments()
\r
1271 return $this->getSetting('bmaxcomments');
\r
1275 * Blog::getNotifyAddress()
\r
1278 * @return string mail address for notifying
\r
1280 public function getNotifyAddress()
\r
1282 return $this->getSetting('bnotify');
\r
1286 * Blog::getNotifyType()
\r
1289 * @return integer notifycation type
\r
1291 public function getNotifyType()
\r
1293 return $this->getSetting('bnotifytype');
\r
1297 * Blog::notifyOnComment()
\r
1302 public function notifyOnComment()
\r
1304 $n = $this->getNotifyType();
\r
1305 return (($n != 0) && (($n % 3) == 0));
\r
1309 * Blog::notifyOnVote()
\r
1314 public function notifyOnVote()
\r
1316 $n = $this->getNotifyType();
\r
1317 return (($n != 0) && (($n % 5) == 0));
\r
1321 * Blog::notifyOnNewItem()
\r
1326 public function notifyOnNewItem()
\r
1328 $n = $this->getNotifyType();
\r
1329 return (($n != 0) && (($n % 7) == 0));
\r
1333 * Blog::setNotifyType()
\r
1335 * @param integer $val
\r
1338 public function setNotifyType($val)
\r
1340 $this->setSetting('bnotifytype',$val);
\r
1345 * Blog::getTimeOffset()
\r
1349 public function getTimeOffset()
\r
1351 return $this->getSetting('btimeoffset');
\r
1355 * Blog::commentsEnabled()
\r
1357 * @return integer enabled or not
\r
1359 public function commentsEnabled()
\r
1361 return $this->getSetting('bcomments');
\r
1367 * @return string URI for this weblog
\r
1369 public function getURL()
\r
1371 return $this->getSetting('burl');
\r
1375 * Blog::getDefaultSkin()
\r
1377 * @return name of skin as default for this weblog
\r
1379 public function getDefaultSkin()
\r
1381 return $this->getSetting('bdefskin');
\r
1385 * Blog::getUpdateFile()
\r
1387 * @return string name of file to be updated when weblog is updated
\r
1389 public function getUpdateFile()
\r
1391 return $this->getSetting('bupdate');
\r
1395 * Blog::getDescription()
\r
1397 * @return string description for this weblog
\r
1399 public function getDescription()
\r
1401 return $this->getSetting('bdesc');
\r
1405 * Blog::isPublic()
\r
1407 * @return integer publlic or not
\r
1409 public function isPublic()
\r
1411 return $this->getSetting('bpublic');
\r
1415 * Blog::emailRequired()
\r
1417 * @return integer email is required when posting comment or not
\r
1419 public function emailRequired()
\r
1421 return $this->getSetting('breqemail');
\r
1425 * Blog::getSearchable()
\r
1427 * @return integer searchable or not
\r
1429 public function getSearchable()
\r
1431 return $this->getSetting('bincludesearch');
\r
1435 * Blog::getDefaultCategory()
\r
1437 * @return ID for category as a default
\r
1439 public function getDefaultCategory()
\r
1441 return $this->getSetting('bdefcat');
\r
1445 * Blog::setPublic()
\r
1446 * @param integer $val allow comments by non-registered members or not
\r
1449 public function setPublic($val)
\r
1451 $this->setSetting('bpublic', $val);
\r
1456 * Blog::setSearchable()
\r
1457 * @param integer $val searchable from the other blogs or not
\r
1460 public function setSearchable($val)
\r
1462 $this->setSetting('bincludesearch', $val);
\r
1467 * Blog::setDescription
\r
1468 * @param string $val description for this weblog
\r
1471 public function setDescription($val)
\r
1473 $this->setSetting('bdesc',$val);
\r
1478 * Blog::setUpdateFile()
\r
1479 * @param string $val name of file to beupdated when weblog is updated
\r
1482 public function setUpdateFile($val)
\r
1484 $this->setSetting('bupdate',$val);
\r
1489 * Blog::setDefaultSkin()
\r
1490 * @param integer $val ID for default skin to use when displaying this weblog
\r
1493 public function setDefaultSkin($val)
\r
1495 $this->setSetting('bdefskin', $val);
\r
1501 * @param string $val URI for this weblog
\r
1504 public function setURL($val)
\r
1506 $this->setSetting('burl', $val);
\r
1512 * @param string $val name of this weblog
\r
1515 public function setName($val)
\r
1517 $this->setSetting('bname', $val);
\r
1522 * Blog::setShortName()
\r
1523 * @param string $val short name for this weblog
\r
1526 public function setShortName($val)
\r
1528 $this->setSetting('bshortname', $val);
\r
1533 * Blog::setCommentsEnabled()
\r
1534 * @param integer $val enabling posting comment or not
\r
1537 public function setCommentsEnabled($val)
\r
1539 $this->setSetting('bcomments',$val);
\r
1544 * Blog::setMaxComments()
\r
1545 * @param integer $val maximum number of comments for this weblog
\r
1548 public function setMaxComments($val)
\r
1550 $this->setSetting('bmaxcomments', $val);
\r
1555 * Blog::setNotifyAddress()
\r
1556 * @param string $val email to be notified if weblog updated
\r
1559 public function setNotifyAddress($val)
\r
1561 $this->setSetting('bnotify', $val);
\r
1566 * Blog::setEmailRequired()
\r
1567 * @param string requiring comments with email or not from non member
\r
1570 public function setEmailRequired($val)
\r
1572 $this->setSetting('breqemail', $val);
\r
1577 * Blog::setTimeOffset()
\r
1578 * @param integer $val time offset
\r
1581 public function setTimeOffset($val)
\r
1583 // check validity of value
\r
1584 // 1. replace , by . (common mistake)
\r
1585 $val = str_replace(',','.',$val);
\r
1587 // 2. cast to float or int
\r
1588 if ( is_numeric($val) && (i18n::strpos($val, '.5') === (i18n::strlen($val) - 2)) )
\r
1590 $val = (float) $val;
\r
1594 $val = (integer) $val;
\r
1597 $this->setSetting('btimeoffset',$val);
\r
1602 * Blog::setDefaultCategory()
\r
1603 * @param integer $val ID for default category for this weblog
\r
1606 public function setDefaultCategory($val)
\r
1608 $this->setSetting('bdefcat',$val);
\r
1613 * Blog::getSetting()
\r
1614 * @param string $key key for setting of this weblog
\r
1615 * @return mixed value for the setting
\r
1617 public function getSetting($key)
\r
1619 return $this->settings[$key];
\r
1623 * Blog::setSetting()
\r
1624 * @param string $key key for setting of this weblog
\r
1625 * @param mixed $value value for the key
\r
1628 public function setSetting($key, $value)
\r
1630 $this->settings[$key] = $value;
\r
1635 * Blog::addTeamMember()
\r
1636 * Tries to add a member to the team.
\r
1637 * Returns false if the member was already on the team
\r
1639 * @param integer $memberid id for member
\r
1640 * @param boolean $admin super-admin or not
\r
1641 * @return boolean Success/Fail
\r
1643 public function addTeamMember($memberid, $admin)
\r
1647 $memberid = intval($memberid);
\r
1648 $admin = intval($admin);
\r
1650 // check if member is already a member
\r
1651 $tmem =& $manager->getMember($memberid);
\r
1653 if ( $tmem->isTeamMember($this->blogid) )
\r
1660 'member' => &$tmem,
\r
1661 'admin' => &$admin
\r
1663 $manager->notify('PreAddTeamMember', $data);
\r
1666 $query = "INSERT INTO %s (TMEMBER, TBLOG, TADMIN) VALUES (%d, %d, %d);";
\r
1667 $query = sprintf($query, sql_table('team'), (integer) $memberid, (integer) $this->blogid, (integer) $admin);
\r
1668 DB::execute($query);
\r
1672 'member' => &$tmem,
\r
1675 $manager->notify('PostAddTeamMember', $data);
\r
1677 $logMsg = sprintf(_TEAM_ADD_NEWTEAMMEMBER, $tmem->getDisplayName(), $memberid, $this->getName());
\r
1678 ActionLog::add(INFO, $logMsg);
\r
1686 * @return integer ID for this weblog
\r
1688 public function getID()
\r
1690 return (integer) $this->blogid;
\r
1694 * Checks if a blog with a given shortname exists
\r
1695 * Returns true if there is a blog with the given shortname (static)
\r
1697 * @param string $name blog shortname
\r
1698 * @return boolean exists or not
\r
1700 public function exists($name)
\r
1702 $r = DB::getResult('SELECT * FROM '.sql_table('blog').' WHERE bshortname='. DB::quoteValue($name));
\r
1703 return ($r->rowCount() != 0);
\r
1707 * Checks if a blog with a given id exists
\r
1708 * Returns true if there is a blog with the given ID (static)
\r
1710 * @param integer $id ID for searched weblog
\r
1711 * @return boolean exists or not
\r
1713 public function existsID($id)
\r
1715 $r = DB::getResult('SELECT * FROM '.sql_table('blog').' WHERE bnumber='.intval($id));
\r
1716 return ($r->rowCount() != 0);
\r
1720 * Blog::setFuturePost()
\r
1721 * flag there is a future post pending
\r
1726 public function setFuturePost()
\r
1728 $query = "UPDATE %s SET bfuturepost='1' WHERE bnumber=%d;";
\r
1729 $query = sprintf($query, sql_table('blog'), (integer) $this->blogid);
\r
1730 DB::execute($query);
\r
1735 * Blog::clearFuturePost()
\r
1736 * clear there is a future post pending
\r
1741 public function clearFuturePost()
\r
1743 $query = "UPDATE %s SET bfuturepost='0' WHERE bnumber=%d;";
\r
1744 $query = sprintf($query, sql_table('blog'), (integer) $this->blogid);
\r
1745 DB::execute($query);
\r
1750 * Blog::checkJustPosted()
\r
1751 * check if we should throw justPosted event
\r
1756 public function checkJustPosted()
\r
1760 if ( $this->settings['bfuturepost'] == 1 )
\r
1762 $query = "SELECT * FROM %s WHERE iposted=0 AND iblog=%d AND itime < NOW();";
\r
1763 $query = sprintf($query, sql_table('item'), (integer) $this->blogid);
\r
1765 $result = DB::getResult($query);
\r
1766 if ( $result->rowCount() > 0 )
\r
1768 // This $pinged is allow a plugin to tell other hook to the event that a ping is sent already
\r
1769 // Note that the plugins's calling order is subject to thri order in the plugin list
\r
1771 $manager->notify('JustPosted', array('blogid' => $this->blogid, 'pinged' => &$pinged));
\r
1773 // clear all expired future posts
\r
1774 $query = "UPDATE %s SET iposted='1' WHERE iblog=%d AND itime < NOW();";
\r
1775 $query = spriintf($query, sql_table('item'), (integer) $this->blogid);
\r
1776 DB::execute($query);
\r
1778 // check to see any pending future post, clear the flag is none
\r
1779 $query = "SELECT * FROM %s WHERE iposted=0 AND iblog=%d;";
\r
1780 $query = sprintf($query, sql_table('item'), (integer) $this->blogid);
\r
1782 $result = DB::getResult($query);
\r
1783 if ( $result->rowCount() == 0 )
\r
1785 $this->clearFuturePost();
\r
1793 * Blog::readLogFromList()
\r
1794 * Shows the given list of items for this blog
\r
1796 * @param array $itemarray array of item numbers to be displayed
\r
1797 * @param string $template string representing the template _NAME_ (!)
\r
1798 * @param string $highlight contains a query that should be highlighted
\r
1799 * @param boolean $comments 1=show comments 0=don't show comments
\r
1800 * @param boolean $dateheads 1=show dateheads 0=don't show dateheads
\r
1801 * @param boolean $showDrafts 0=do not show drafts 1=show drafts
\r
1802 * @param boolean $showFuture 0=do not show future posts 1=show future posts
\r
1803 * @return integer amount of items shown
\r
1805 public function readLogFromList($itemarray, $template, $highlight = '', $comments = 1, $dateheads = 1,$showDrafts = 0, $showFuture = 0)
\r
1807 $query = $this->getSqlItemList($itemarray,$showDrafts,$showFuture);
\r
1808 return $this->showUsingQuery($template, $query, $highlight, $comments, $dateheads);
\r
1812 * Blog::getSqlItemList()
\r
1813 * Returns the SQL query used to fill out templates for a list of items
\r
1814 * No LIMIT clause is added. (caller should add this if multiple pages are requested)
\r
1816 * @param array $itemarray an array holding the item numbers of the items to be displayed
\r
1817 * @param integer $showDrafts 0=do not show drafts 1=show drafts
\r
1818 * @param integer $showFuture 0=do not show future posts 1=show future posts
\r
1819 * @return string either a full SQL query, or an empty string
\r
1821 public function getSqlItemList($itemarray,$showDrafts = 0,$showFuture = 0)
\r
1823 if ( !is_array($itemarray) )
\r
1828 $showDrafts = intval($showDrafts);
\r
1829 $showFuture = intval($showFuture);
\r
1832 foreach ( $itemarray as $value )
\r
1834 if ( intval($value) )
\r
1836 $items[] = intval($value);
\r
1839 if ( !count($items) )
\r
1844 $i = count($items);
\r
1846 foreach ( $items as $value )
\r
1850 . ' i.inumber as itemid,'
\r
1851 . ' i.ititle as title,'
\r
1852 . ' i.ibody as body,'
\r
1853 . ' m.mname as author,'
\r
1854 . ' m.mrealname as authorname,'
\r
1856 . ' i.imore as more,'
\r
1857 . ' m.mnumber as authorid,'
\r
1858 . ' m.memail as authormail,'
\r
1859 . ' m.murl as authorurl,'
\r
1860 . ' c.cname as category,'
\r
1861 . ' i.icat as catid,'
\r
1862 . ' i.iclosed as closed';
\r
1864 $query .= ' FROM '
\r
1865 . sql_table('item') . ' as i, '
\r
1866 . sql_table('member') . ' as m, '
\r
1867 . sql_table('category') . ' as c'
\r
1869 . ' i.iblog='.$this->blogid
\r
1870 . ' and i.iauthor=m.mnumber'
\r
1871 . ' and i.icat=c.catid';
\r
1873 // exclude drafts
\r
1874 if ( !$showDrafts )
\r
1876 $query .= ' and i.idraft=0';
\r
1878 if ( !$showFuture )
\r
1880 // don't show future items
\r
1881 $query .= ' and i.itime<=' . DB::formatDateTime($this->getCorrectTime());
\r
1884 $query .= ' and i.inumber='.intval($value);
\r
1887 if ($i) $query .= ' UNION ';
\r
1894 * Blog::convertBreaks()
\r
1895 * Get the the setting for the line break handling
\r
1896 * [should be named as getConvertBreaks()]
\r
1902 public function convertBreaks()
\r
1904 return $this->getSetting('bconvertbreaks');
\r
1908 * Set the the setting for the line break handling
\r
1911 * @param boolean $val new value for bconvertbreaks
\r
1914 public function setConvertBreaks($val)
\r
1916 $this->setSetting('bconvertbreaks', $val);
\r
1924 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
1925 * Copyright (C) 2002-2012 The Nucleus Group
1927 * This program is free software; you can redistribute it and/or
1928 * modify it under the terms of the GNU General Public License
1929 * as published by the Free Software Foundation; either version 2
1930 * of the License, or (at your option) any later version.
1931 * (see nucleus/documentation/index.html#license for more info)
1934 * A class representing a blog and containing functions to get that blog shown
1937 * @license http://nucleuscms.org/license.txt GNU General Public License
1938 * @copyright Copyright (C) 2002-2009 The Nucleus Group
1939 * @version $Id: BLOG.php 1624 2012-01-09 11:36:20Z sakamocchi $
1942 if ( !function_exists('requestVar') ) exit;
1943 require_once dirname(__FILE__) . '/ITEMACTIONS.php';
1950 // After creating an object of the blog class, contains true if the BLOG object is
1951 // valid (the blog exists)
1954 // associative array, containing all blogsettings (use the get/set functions instead)
1957 // ID of currently selected category
1958 private $selectedcatid;
1961 * Blog::_\construct()
1962 * Creates a new BLOG object for the given blog
1964 * @param integer $id blogid
1967 public function __construct($id)
1971 $this->blogid = (integer) $id;
1972 $this->readSettings();
1973 $this->setSelectedCategory($catid);
1979 * Shows the given amount of items for this blog
1981 * @param string $template String representing the template _NAME_ (!)
1982 * @param integer $amountEntries amount of entries to show
1983 * @param integer $startpos offset from where items should be shown (e.g. 5 = start at fifth item)
1984 * @return integer amount of items shown
1986 public function readLog($template, $amountEntries, $offset = 0, $startpos = 0)
1988 return $this->readLogAmount($template,$amountEntries,'','',1,1,$offset, $startpos);
1992 * Blog::showArchive()
1993 * Shows an archive for a given month
1995 * @param integer $year year
1996 * @param integer $month month
1997 * @param string $template String representing the template name to be used
2000 public function showArchive($templatename, $year, $month=0, $day=0)
2002 // create extra where clause for select query
2003 if ( $day == 0 && $month != 0 )
2005 $timestamp_start = mktime(0,0,0,$month,1,$year);
2006 // also works when $month==12
2007 $timestamp_end = mktime(0,0,0,$month+1,1,$year);
2009 elseif ( $month == 0 )
2011 $timestamp_start = mktime(0,0,0,1,1,$year);
2012 // also works when $month==12
2013 $timestamp_end = mktime(0,0,0,12,31,$year);
2017 $timestamp_start = mktime(0,0,0,$month,$day,$year);
2018 $timestamp_end = mktime(0,0,0,$month,$day+1,$year);
2020 $extra_query = " and i.itime>=%s and i.itime<%s";
2021 $extra_query = sprintf($extra_query, DB::formatDateTime($timestamp_start), DB::formatDateTime($timestamp_end));
2023 $this->readLogAmount($templatename,0,$extra_query,'',1,1);
2028 * Blog::setSelectedCategory()
2029 * Sets the selected category by id (only when category exists)
2031 * @param integer $catid ID for category
2034 public function setSelectedCategory($catid)
2036 if ( $this->isValidCategory($catid) || (intval($catid) == 0) )
2038 $this->selectedcatid = intval($catid);
2044 * Blog::setSelectedCategoryByName()
2045 * Sets the selected category by name
2047 * @param string $catname name of category
2050 public function setSelectedCategoryByName($catname)
2052 $this->setSelectedCategory($this->getCategoryIdFromName($catname));
2057 * Blog::getSelectedCategory()
2058 * Returns the selected category
2063 public function getSelectedCategory()
2065 return $this->selectedcatid;
2069 * Shows the given amount of items for this blog
2071 * @param string $template string representing the template _NAME_ (!)
2072 * @param integer $amountEntries amount of entries to show (0 = no limit)
2073 * @param string $extraQuery extra conditions to be added to the query
2074 * @param string $highlight contains a query that should be highlighted
2075 * @param integer $comments 1=show comments 0=don't show comments
2076 * @param integer $dateheads 1=show dateheads 0=don't show dateheads
2077 * @param integer $offset offset
2078 * @return integer amount of items shown
2080 private function readLogAmount($template, $amountEntries, $extraQuery, $highlight, $comments, $dateheads, $offset = 0, $startpos = 0)
2082 $query = $this->getSqlBlog($extraQuery);
2084 if ( $amountEntries > 0 )
2086 // $offset zou moeten worden:
2087 // (($startpos / $amountentries) + 1) * $offset ... later testen ...
2088 $query .= ' LIMIT ' . intval($startpos + $offset).',' . intval($amountEntries);
2090 return $this->showUsingQuery($template, $query, $highlight, $comments, $dateheads);
2094 * Blog::showUsingQuery()
2095 * Do the job for readLogAmmount
2097 * @param string $templateName template name
2098 * @param string $query string for query
2099 * @param string $highlight string to be highlighted
2100 * @param integer $comments the number of comments
2101 * @param boolean $dateheads date header is needed or not
2102 * @return integer the number of rows as a result of mysql query
2104 private function showUsingQuery($templateName, $query, $highlight = '', $comments = 0, $dateheads = 1)
2106 global $CONF, $manager, $currentTemplateName;
2108 $lastVisit = cookieVar($CONF['CookiePrefix'] .'lastVisit');
2109 if ( $lastVisit != 0 )
2111 $lastVisit = $this->getCorrectTime($lastVisit);
2114 // set templatename as global variable (so plugins can access it)
2115 $currentTemplateName = $templateName;
2116 $template =& $manager->getTemplate($templateName);
2118 // create parser object & action handler
2119 $handler = new ItemActions($this);
2120 $handler->setTemplate($template);
2121 $handler->setHighlight($highlight);
2122 $handler->setLastVisit($lastVisit);
2123 $handler->setShowComments($comments);
2125 $parser = new Parser($handler);
2128 $items = DB::getResult($query);
2130 // loop over all items
2132 foreach ( $items as $item )
2134 // string timestamp -> unix timestamp
2135 $item['timestamp'] = strtotime($item['itime']);
2137 // action handler needs to know the item we're handling
2138 $handler->setCurrentItem($item);
2140 // add date header if needed
2143 $new_date = date('dFY', $item['timestamp']);
2144 if ( $new_date != $old_date )
2146 // unless this is the first time, write date footer
2147 $timestamp = $item['timestamp'];
2148 if ( $old_date != 0 )
2150 $oldTS = strtotime($old_date);
2151 $data = array('blog' => &$this, 'timestamp' => $oldTS);
2152 $manager->notify('PreDateFoot', $data);
2154 if ( !in_array('DATE_FOOTER', $template) || empty($template['DATE_FOOTER']) )
2160 $tmp_footer = i18n::formatted_datetime($template['DATE_FOOTER'], $oldTS);
2162 $parser->parse($tmp_footer);
2163 $manager->notify('PostDateFoot', $data);
2166 $data = array('blog' => &$this, 'timestamp' => $timestamp);
2167 $manager->notify('PreDateHead', $data);
2169 // note, to use templatvars in the dateheader, the %-characters need to be doubled in
2170 // order to be preserved by strftime
2171 if ( !in_array('DATE_HEADER', $template) || empty($template['DATE_HEADER']) )
2177 $tmp_header = i18n::formatted_datetime($template['DATE_HEADER'], $timestamp);
2179 $parser->parse($tmp_header);
2180 $manager->notify('PostDateHead', $data);
2182 $old_date = $new_date;
2186 $parser->parse($template['ITEM_HEADER']);
2187 $data = array('blog' => &$this, 'item' => &$item);
2188 $manager->notify('PreItem', $data);
2189 $parser->parse($template['ITEM']);
2190 $manager->notify('PostItem', $data);
2191 $parser->parse($template['ITEM_FOOTER']);
2194 $numrows = $items->rowCount();
2196 // add another date footer if there was at least one item
2197 if ( ($numrows > 0) && $dateheads )
2199 $data = array('blog' => &$this, 'timestamp' => strtotime($old_date));
2200 $manager->notify('PreDateFoot', $data);
2201 $parser->parse($template['DATE_FOOTER']);
2202 $manager->notify('PostDateFoot', $data);
2205 $items->closeCursor();
2210 * Blog::showOneitem()
2211 * Simplified function for showing only one item
2213 * @param integer $itemid ID for item
2214 * @param array $template template for item
2215 * @param string $highlight string for highlight
2218 public function showOneitem($itemid, $template, $highlight)
2220 $extraQuery = ' and inumber=' . intval($itemid);
2222 return $this->readLogAmount($template, 1, $extraQuery, $highlight, 0, 0);
2227 * Adds an item to this blog
2229 * @param integer $catid ID for category
2230 * @param string $title ID for
2231 * @param string $body text for body
2232 * @param string $more text for more
2233 * @param integer $blogid ID for blog
2234 * @param integer $authorid ID for author
2235 * @param timestamp $timestamp UNIX timestamp for post
2236 * @param boolean $closed opened or closed
2237 * @param boolean $draft draft or not
2238 * @param boolean $posted posted or not
2239 * @return integer ID for added item
2241 function additem($catid, $title, $body, $more, $blogid, $authorid, $timestamp, $closed, $draft, $posted='1')
2245 $blogid = (integer) $blogid;
2246 $authorid = (integer) $authorid;
2250 $catid = intval($catid);
2252 // convert newlines to <br />
2253 if ( $this->convertBreaks() )
2255 $body = addBreaks($body);
2256 $more = addBreaks($more);
2259 if ( $closed != '1' )
2263 if ( $draft != '0' )
2268 if ( !$this->isValidCategory($catid) )
2270 $catid = $this->getDefaultCategory();
2274 if ( $timestamp > $this->getCorrectTime() )
2279 $timestamp = date('Y-m-d H:i:s',$timestamp);
2281 $data = array('title' => &$title, 'body' => &$body, 'more' => &$more, 'blog' => $this, 'authorid' => &$authorid, 'timestamp' => &$timestamp, 'closed' => &$closed, 'draft' => &$draft, 'catid' => &$catid);
2282 $manager->notify('PreAddItem', $data);
2284 $ititle = DB::quoteValue($title);
2285 $ibody = DB::quoteValue($body);
2286 $imore = DB::quoteValue($more);
2287 $timestamp = DB::formatDateTime(strtotime($timestamp));
2289 $query = "INSERT INTO %s (ITITLE, IBODY, IMORE, IBLOG, IAUTHOR, ITIME, ICLOSED, IDRAFT, ICAT, IPOSTED) VALUES (%s, %s, %s, %d, %d, %s, %s, %s, %s, %s)";
2290 $query = sprintf($query, sql_table('item'), $ititle, $ibody, $imore, $blogid, $authorid, $timestamp, $closed, $draft, $catid, $posted);
2291 DB::execute($query);
2292 $itemid = DB::getInsertId();
2294 $data = array('itemid' => $itemid);
2295 $manager->notify('PostAddItem', $data);
2299 $this->updateUpdateFile();
2301 // send notification mail
2302 if ( !$draft && !$isFuture && $this->getNotifyAddress() && $this->notifyOnNewItem() )
2304 $this->sendNewItemNotification($itemid, $title, $body);
2310 * Blog::sendNewItemNotification()
2311 * Send a new item notification to the notification list
2313 * @param string $itemid ID of the item
2314 * @param string $title title of the item
2315 * @param string $body body of the item
2318 public function sendNewItemNotification($itemid, $title, $body)
2320 global $CONF, $member;
2322 $ascii = Entity::anchor_footnoting($body);
2324 $message = _NOTIFY_NI_MSG . " \n";
2325 $temp = parse_url($CONF['Self']);
2326 if ( $temp['scheme'] )
2328 $message .= Link::create_item_link($itemid) . "\n\n";
2332 $tempurl = $this->getURL();
2333 if ( i18n::substr($tempurl, -1) == '/' || i18n::substr($tempurl, -4) == '.php' )
2335 $message .= $tempurl . '?itemid=' . $itemid . "\n\n";
2339 $message .= $tempurl . '/?itemid=' . $itemid . "\n\n";
2342 $message .= _NOTIFY_TITLE . ' ' . strip_tags($title) . "\n";
2343 $message .= _NOTIFY_CONTENTS . "\n " . $ascii . "\n";
2344 $message .= NOTIFICATION::get_mail_footer();
2346 $subject = $this->getName() . ': ' . _NOTIFY_NI_TITLE;
2348 $from = $member->getNotifyFromMailAddress();
2350 NOTIFICATION::mail($this->getNotifyAddress(), $subject, $message, $from, i18n::get_current_charset());
2355 * Blog::createNewCategory()
2356 * Creates a new category for this blog
2358 * @param string $catName name of the new category. When empty, a name is generated automatically (starting with newcat)
2359 * @param string $catDescription description of the new category. Defaults to 'New Category'
2360 * @return integer ID for new category on success. 0 on failure
2362 public function createNewCategory($catName = '', $catDescription = _CREATED_NEW_CATEGORY_DESC)
2364 global $member, $manager;
2366 if ( !$member->blogAdminRights($this->blogid) )
2372 if ( $catName == '' )
2374 $catName = _CREATED_NEW_CATEGORY_NAME;
2377 $res = DB::getResult('SELECT * FROM '.sql_table('category')." WHERE cname='".$catName.$i."' and cblog=".$this->blogid);
2378 while ( $res->rowCount() > 0 )
2381 $res = DB::getResult('SELECT * FROM '.sql_table('category')." WHERE cname='".$catName.$i."' and cblog=".$this->blogid);
2384 $catName = $catName . $i;
2389 'name' => &$catName,
2390 'description' => $catDescription
2392 $manager->notify('PreAddCategory', $data);
2394 $query = "INSERT INTO %s (cblog, cname, cdesc) VALUES (%d, %s, %s)";
2395 $query = sprintf($query, sql_table('category'), (integer) $this->blogid, DB::quoteValue($catName), DB::quoteValue($catDescription));
2396 DB::execute($query);
2397 $catid = DB::getInsertId();
2402 'description' => $catDescription,
2405 $manager->notify('PostAddCategory', $data);
2412 * Searches all months of this blog for the given query
2414 * @param string $query search query
2415 * @param array $template template to be used (__NAME__ of the template)
2416 * @param integer $amountMonths max amount of months to be search (0 = all)
2417 * @param integer $maxresults max number of results to show
2418 * @param integer $startpos offset
2419 * @return amount of hits found
2421 public function search($query, $template, $amountMonths, $maxresults, $startpos) {
2422 global $CONF, $manager;
2425 $sqlquery = $this->getSqlSearch($query, $amountMonths, $highlight);
2427 if ( $sqlquery == '' )
2429 // no query -> show everything
2431 $amountfound = $this->readLogAmount($template, $maxresults, $extraQuery, $query, 1, 1);
2435 // add LIMIT to query (to split search results into pages)
2436 if ( intval($maxresults > 0) )
2438 $sqlquery .= ' LIMIT ' . intval($startpos) . ',' . intval($maxresults);
2442 $amountfound = $this->showUsingQuery($template, $sqlquery, $highlight, 1, 1);
2444 // when no results were found, show a message
2445 if ( $amountfound == 0 )
2447 $template =& $manager->getTemplate($template);
2449 'query' => Entity::hsc($query),
2450 'blogid' => $this->blogid
2452 echo Template::fill($template['SEARCH_NOTHINGFOUND'], $vars);
2455 return $amountfound;
2459 * Blog::getSqlSearch()
2460 * Returns an SQL query to use for a search query
2461 * No LIMIT clause is added. (caller should add this if multiple pages are requested)
2463 * @param string $query search query
2464 * @param integer $amountMonths amount of months to search back. Default = 0 = unlimited
2465 * @param string $mode either empty, or 'count'. In this case, the query will be a SELECT COUNT(*) query
2466 * @return string $highlight words to highlight (out parameter)
2467 * @return string either a full SQL query, or an empty string (if querystring empty)
2469 public function getSqlSearch($query, $amountMonths = 0, &$highlight, $mode = '')
2471 $searchclass = new Search($query);
2473 $highlight = $searchclass->inclusive;
2475 // if querystring is empty, return empty string
2476 if ( $searchclass->inclusive == '' )
2481 $where = $searchclass->boolean_sql_where('ititle,ibody,imore');
2482 $select = $searchclass->boolean_sql_select('ititle,ibody,imore');
2484 // get list of blogs to search
2485 $blogs = $searchclass->blogs; // array containing blogs that always need to be included
2486 $blogs[] = $this->blogid; // also search current blog (duh)
2487 $blogs = array_unique($blogs); // remove duplicates
2489 if ( count($blogs) > 0 )
2491 $selectblogs = ' and i.iblog in (' . implode(',', $blogs) . ')';
2496 $query = 'SELECT i.inumber as itemid, i.ititle as title, i.ibody as body, i.itime, i.imore as more, i.icat as catid, i.iclosed as closed,
2497 m.mname as author, m.mrealname as authorname, m.mnumber as authorid, m.memail as authormail, m.murl as authorurl,
2498 c.cname as category';
2502 $query .= ', '.$select. ' as score ';
2507 $query = 'SELECT COUNT(*) as result ';
2510 $query .= ' FROM '.sql_table('item').' as i, '.sql_table('member').' as m, '.sql_table('category').' as c'
2511 . ' WHERE i.iauthor=m.mnumber'
2512 . ' and i.icat=c.catid'
2516 // don't show future items
2517 . ' and i.itime<=' . DB::formatDateTime($this->getCorrectTime())
2520 // take into account amount of months to search
2521 if ( $amountMonths > 0 )
2523 $localtime = getdate($this->getCorrectTime());
2524 $timestamp_start = mktime(0,0,0,$localtime['mon'] - $amountMonths,1,$localtime['year']);
2525 $query .= ' and i.itime>' . DB::formatDateTime($timestamp_start);
2532 $query .= ' ORDER BY score DESC';
2536 $query .= ' ORDER BY i.itime DESC ';
2544 * Blog::getSqlBlog()
2545 * Returns the SQL query that's normally used to display the blog items on the index type skins
2546 * No LIMIT clause is added. (caller should add this if multiple pages are requested)
2548 * @param string $extraQuery extra query string
2549 * @param string $mode either empty, or 'count'. In this case, the query will be a SELECT COUNT(*) query
2550 * @return string either a full SQL query, or an empty string
2552 public function getSqlBlog($extraQuery, $mode = '')
2556 $query = 'SELECT i.inumber as itemid, i.ititle as title, i.ibody as body, m.mname as author,
2557 m.mrealname as authorname, i.itime, i.imore as more, m.mnumber as authorid, m.memail as authormail,
2558 m.murl as authorurl, c.cname as category, i.icat as catid, i.iclosed as closed';
2562 $query = 'SELECT COUNT(*) as result ';
2565 $query .= ' FROM '.sql_table('item').' as i, '.sql_table('member').' as m, '.sql_table('category').' as c'
2566 . ' WHERE i.iblog='.$this->blogid
2567 . ' and i.iauthor=m.mnumber'
2568 . ' and i.icat=c.catid'
2569 . ' and i.idraft=0' // exclude drafts
2570 . ' and i.itime<=' . DB::formatDateTime($this->getCorrectTime()); // don't show future items
2572 if ( $this->selectedcatid )
2574 $query .= ' and i.icat=' . $this->selectedcatid . ' ';
2577 $query .= $extraQuery;
2581 $query .= ' ORDER BY i.itime DESC';
2587 * Blog::showArchiveList()
2588 * Shows the archivelist using the given template
2590 * @param string $template template name
2591 * @param string $mode year/month/day
2592 * @param integer $limit limit of record count
2595 public function showArchiveList($template, $mode = 'month', $limit = 0)
2597 global $CONF, $catid, $manager;
2599 if ( !isset ($linkparams) )
2601 $linkparams = array();
2606 $linkparams = array('catid' => $catid);
2609 $template =& $manager->getTemplate($template);
2610 $listitem['blogid'] = $this->blogid;
2612 if ( !array_key_exists('ARCHIVELIST_HEADER', $template) || !$template['ARCHIVELIST_HEADER'] )
2618 $tplt = $template['ARCHIVELIST_HEADER'];
2621 echo Template::fill($tplt, $listitem);
2623 $query = 'SELECT itime, SUBSTRING(itime,1,4) AS Year, SUBSTRING(itime,6,2) AS Month, SUBSTRING(itime,9,2) AS Day'
2624 . ' FROM '.sql_table('item')
2625 . ' WHERE iblog=' . $this->blogid
2626 . ' AND itime <=' . DB::formatDateTime($this->getCorrectTime()) // don't show future items!
2627 . ' AND idraft=0'; // don't show draft items
2631 $query .= ' and icat=' . intval($catid);
2634 $query .= ' GROUP BY Year';
2635 if ( $mode == 'month' || $mode == 'day' )
2637 $query .= ', Month';
2639 if ( $mode == 'day' )
2644 $query .= ' ORDER BY itime DESC';
2648 $query .= ' LIMIT ' . intval($limit);
2651 $res = DB::getResult($query);
2652 foreach ( $res as $current )
2654 /* string time -> unix timestamp */
2655 $current['itime'] = strtotime($current['itime']);
2657 if ( $mode == 'day' )
2659 $archivedate = date('Y-m-d',$current['itime']);
2660 $archive['day'] = date('d',$current['itime']);
2661 $listitem['day'] = date('d',$current['itime']);
2662 $listitem['month'] = date('m',$current['itime']);
2663 $archive['month'] = $listitem['month'];
2665 elseif ( $mode == 'year' )
2667 $archivedate = date('Y',$current['itime']);
2668 $listitem['day'] = '';
2669 $listitem['month'] = '';
2670 $archive['day'] = '';
2671 $archive['month'] = '';
2675 $archivedate = date('Y-m',$current['itime']);
2676 $listitem['month'] = date('m',$current['itime']);
2677 $archive['month'] = $listitem['month'];
2678 $listitem['day'] = '';
2679 $archive['day'] = '';
2682 $listitem['year'] = date('Y',$current['itime']);
2683 $archive['year'] = $listitem['year'];
2684 $listitem['archivelink'] = Link::create_archive_link($this->blogid,$archivedate,$linkparams);
2686 $data = array('listitem' => &$listitem);
2687 $manager->notify('PreArchiveListItem', $data);
2689 $temp = Template::fill($template['ARCHIVELIST_LISTITEM'],$listitem);
2690 echo i18n::formatted_datetime($temp, $current['itime']);
2694 $res->closeCursor();
2696 if ( !array_key_exists('ARCHIVELIST_FOOTER', $template) || !$template['ARCHIVELIST_FOOTER'] )
2702 $tplt = $template['ARCHIVELIST_FOOTER'];
2705 echo Template::fill($tplt, $listitem);
2710 * Blog::showCategoryList()
2711 * Shows the list of categories using a given template
2713 * @param string $template Template Name
2716 public function showCategoryList($template)
2718 global $CONF, $archive, $archivelist, $manager;
2721 * determine arguments next to catids
2722 * I guess this can be done in a better way, but it works
2724 $linkparams = array();
2727 $blogurl = Link::create_archive_link($this->blogid, $archive, '');
2728 $linkparams['blogid'] = $this->blogid;
2729 $linkparams['archive'] = $archive;
2731 else if ( $archivelist )
2733 $blogurl = Link::create_archivelist_link($this->blogid, '');
2734 $linkparams['archivelist'] = $archivelist;
2738 $blogurl = Link::create_blogid_link($this->blogid, '');
2739 $linkparams['blogid'] = $this->blogid;
2742 $template =& $manager->getTemplate($template);
2744 //: Change: Set nocatselected variable
2745 if ( $this->selectedcatid )
2747 $nocatselected = 'no';
2751 $nocatselected = 'yes';
2755 'blogid' => $this->blogid,
2756 'blogurl' => $blogurl,
2757 'self' => $CONF['Self'],
2758 'catiscurrent' => $nocatselected, // Change: Set catiscurrent template variable for header
2759 'currentcat' => $nocatselected
2762 /* output header of category list item */
2763 if ( !array_key_exists('CATLIST_HEADER', $template) || empty($template['CATLIST_HEADER']) )
2765 echo Template::fill(NULL, $args);
2769 echo Template::fill($template['CATLIST_HEADER'], $args);
2772 $query = "SELECT catid, cdesc as catdesc, cname as catname FROM %s WHERE cblog=%d ORDER BY cname ASC;";
2773 $query = sprintf($query, sql_table('category'), (integer) $this->blogid);
2774 $res = DB::getResult($query);
2776 foreach ( $res as $row )
2779 'catid' => $row['catid'],
2780 'name' => $row['catname'],
2781 'extra' => $linkparams
2784 $row['blogid'] = $this->blogid;
2785 $row['blogurl'] = $blogurl;
2786 $row['catlink'] = Link::create_link('category', $args);
2787 $row['self'] = $CONF['Self'];
2789 // this gives catiscurrent = no when no category is selected.
2790 $row['catiscurrent'] = 'no';
2791 $row['currentcat'] = 'no';
2793 if ( $this->selectedcatid )
2795 if ( $this->selectedcatid == $row['catid'] )
2797 $row['catiscurrent'] = 'yes';
2798 $row['currentcat'] = 'yes';
2804 if ( (integer) $itemid && $manager->existsItem((integer) $itemid, 0, 0) )
2806 $iobj =& $manager->getItem($itemid, 0, 0);
2807 $cid = $iobj['catid'];
2809 if ( $cid == $row['catid'] )
2811 $row['catiscurrent'] = 'yes';
2812 $row['currentcat'] = 'yes';
2817 $data = array('listitem' => &$row);
2818 $manager->notify('PreCategoryListItem', $data);
2820 if ( !array_key_exists('CATLIST_LISTITEM', $template) || empty($template['CATLIST_LISTITEM']))
2822 echo Template::fill(NULL, $row);
2826 echo Template::fill($template['CATLIST_LISTITEM'], $row);
2830 $res->closeCursor();
2833 'blogid' => $this->blogid,
2834 'blogurl' => $blogurl,
2835 'self' => $CONF['Self'],
2836 'catiscurrent' => $nocatselected, //: Change: Set catiscurrent template variable for footer
2837 'currentcat' => $nocatselected
2840 if ( !array_key_exists('CATLIST_FOOTER', $template) || empty($template['CATLIST_FOOTER']))
2842 echo Template::fill(NULL, $args);
2846 echo Template::fill($template['CATLIST_FOOTER'], $args);
2853 * Blog::showBlogList()
2854 * Shows a list of all blogs in the system using a given template
2855 * ordered by number, name, shortname or description
2856 * in ascending or descending order
2858 * @param string $template tempalte name
2859 * @param string $bnametype bname/bshortname
2860 * @param string $orderby string for 'ORDER BY' SQL
2861 * @param string $direction ASC/DESC
2864 static public function showBlogList($template, $bnametype, $orderby, $direction)
2866 global $CONF, $manager;
2877 $orderby='bshortname';
2887 $direction=strtolower($direction);
2888 switch ( $direction )
2901 $template =& $manager->getTemplate($template);
2903 if ( array_key_exists('BLOGLIST_HEADER', $template) && !empty($template['BLOGLIST_HEADER']) )
2906 'sitename' => $CONF['SiteName'],
2907 'siteurl' => $CONF['IndexURL']
2910 echo Template::fill($template['BLOGLIST_HEADER'], $vars);
2913 if ( array_key_exists('BLOGLIST_LISTITEM', $template) && !empty($template['BLOGLIST_LISTITEM']) )
2915 $query = 'SELECT bnumber, bname, bshortname, bdesc, burl FROM '.sql_table('blog').' ORDER BY '.$orderby.' '.$direction;
2916 $res = DB::getResult($query);
2918 foreach ( $res as $row )
2921 $list['bloglink'] = Link::create_blogid_link($row['bnumber']);
2922 $list['blogdesc'] = $row['bdesc'];
2923 $list['blogurl'] = $row['burl'];
2925 if ( $bnametype == 'shortname' )
2927 $list['blogname'] = $row['bshortname'];
2931 /* all other cases */
2932 $list['blogname'] = $row['bname'];
2935 $data = array('listitem' => &$list);
2936 $manager->notify('PreBlogListItem', $data);
2938 echo Template::fill($template['BLOGLIST_LISTITEM'], $list);
2941 $res->closeCursor();
2945 if ( array_key_exists('BLOGLIST_FOOTER', $template) && !empty($template['BLOGLIST_FOOTER']) )
2948 'sitename' => $CONF['SiteName'],
2949 'siteurl' => $CONF['IndexURL']
2951 echo Template::fill($template['BLOGLIST_FOOTER']);
2957 * Blog::readSettings()
2958 * Read the blog settings
2963 public function readSettings()
2965 $query = 'SELECT * FROM %s WHERE bnumber=%d;';
2966 $query = sprintf($query, sql_table('blog'), (integer) $this->blogid);
2967 $res = DB::getResult($query);
2969 $this->isValid = ($res->rowCount() > 0);
2970 if ( $this->isValid )
2972 $this->settings = $res->fetch(PDO::FETCH_ASSOC);
2978 * Blog::writeSettings()
2979 * Write the blog settings
2981 public function writeSettings()
2983 // (can't use floatval since not available prior to PHP 4.2)
2984 $offset = $this->getTimeOffset();
2985 if ( !is_float($offset) )
2987 $offset = (integer) $offset;
2990 $query = 'UPDATE '.sql_table('blog')
2991 . ' SET bname=' . DB::quoteValue($this->getName()) . ','
2992 . ' bshortname='. DB::quoteValue($this->getShortName()) . ','
2993 . ' bcomments='. intval($this->commentsEnabled()) . ','
2994 . ' bmaxcomments=' . intval($this->getMaxComments()) . ','
2995 . ' btimeoffset=' . $offset . ','
2996 . ' bpublic=' . intval($this->isPublic()) . ','
2997 . ' breqemail=' . intval($this->emailRequired()) . ','
2998 . ' bconvertbreaks=' . intval($this->convertBreaks()) . ','
2999 . ' ballowpast=' . intval($this->allowPastPosting()) . ','
3000 . ' bnotify=' . DB::quoteValue($this->getNotifyAddress()) . ','
3001 . ' bnotifytype=' . intval($this->getNotifyType()) . ','
3002 . ' burl=' . DB::quoteValue($this->getURL()) . ','
3003 . ' bupdate=' . DB::quoteValue($this->getUpdateFile()) . ','
3004 . ' bdesc=' . DB::quoteValue($this->getDescription()) . ','
3005 . ' bdefcat=' . intval($this->getDefaultCategory()) . ','
3006 . ' bdefskin=' . intval($this->getDefaultSkin()) . ','
3007 . ' bincludesearch=' . intval($this->getSearchable())
3008 . ' WHERE bnumber=' . intval($this->blogid);
3009 DB::execute($query);
3014 * Blog::updateUpdatefile()
3015 * Update the update file if requested
3020 public function updateUpdatefile()
3022 if ( $this->getUpdateFile() )
3024 $f_update = fopen($this->getUpdateFile(), 'w');
3025 fputs($f_update,$this->getCorrectTime());
3032 * Blog::isValidCategory()
3033 * Check if a category with a given catid is valid
3035 * @param integer $catid ID for category
3036 * @return boolean exists or not
3038 public function isValidCategory($catid)
3040 $query = 'SELECT * FROM %s WHERE cblog=%d and catid=%d;';
3041 $query = sprintf($query, sql_table('category'), (integer) $this->blogid, (integer) $catid);
3042 $res = DB::getResult($query);
3043 return ($res->rowCount() != 0);
3047 * Blog::getCategoryName()
3048 * Get the category name for a given catid
3050 * @param integer $catid ID for category
3051 * @return string name of category
3053 public function getCategoryName($catid)
3055 $query = 'SELECT cname FROM %s WHERE cblog=%d and catid=%d;';
3056 $query = sprintf($query, sql_table('category'), (integer) $this->blogid, (integer) $catid);
3057 $res = DB::getValue($query);
3062 * Blog::getCategoryDesc()
3063 * Get the category description for a given catid
3068 public function getCategoryDesc($catid)
3070 $query = 'SELECT cdesc FROM %s WHERE cblog=%d and catid=%d;';
3071 $query = sprintf($query, sql_table('category'), (integer) $this->blogid, (integer) $catid);
3072 $res = DB::getValue($query);
3077 * Blog::getCategoryIdFromName
3078 * Get the category id for a given category name
3080 * @param string $name category name
3081 * @return ID for category
3083 public function getCategoryIdFromName($name)
3085 $query = 'SELECT catid FROM %s WHERE cblog=%d and cname=%s;';
3086 $query = sprintf($query, sql_table('category'), (integer) $this->blogid, DB::quoteValue($name));
3088 $res = DB::getValue();
3091 return $this->getDefaultCategory();
3097 * Blog::insertJavaScriptInfo()
3098 * Insert a javascript that includes information about the settings
3099 * of an author: ConvertBreaks, MediaUrl and AuthorId
3101 * @param $authorid id of the author
3103 public function insertJavaScriptInfo($authorid = '')
3105 global $member, $CONF;
3107 if ( $authorid == '' )
3109 $authorid = $member->getID();
3112 echo "<script type=\"text/javascript\">\n";
3114 if ( !$this->convertBreaks() )
3116 echo "setConvertBreaks(false);\n";
3120 echo "setConvertBreaks(true);\n";
3122 echo "setMediaUrl('{$CONF['MediaURL']}');\n";
3123 echo "setAuthorId('{$authorid}');\n";
3129 * Blog::setAllowPastPosting()
3130 * Set the the setting for allowing to publish postings in the past
3132 * @param boolean $val new value for ballowpast
3135 public function setAllowPastPosting($val)
3137 $this->setSetting('ballowpast', $val);
3142 * Blog::allowPastPosting()
3143 * Get the the setting if it is allowed to publish postings in the past
3144 * [should be named as getAllowPastPosting()]
3149 public function allowPastPosting()
3151 return $this->getSetting('ballowpast');
3155 * Blog::getCorrectTime()
3160 public function getCorrectTime($t=0)
3166 return ($t + 3600 * $this->getTimeOffset());
3173 * @return string name of this weblog
3175 public function getName()
3177 return $this->getSetting('bname');
3181 * Blog::getShortName()
3184 * @return string short name of this weblog
3186 public function getShortName()
3188 return $this->getSetting('bshortname');
3192 * Blog::getMaxComments()
3195 * @return integer maximum number of comments
3197 public function getMaxComments()
3199 return $this->getSetting('bmaxcomments');
3203 * Blog::getNotifyAddress()
3206 * @return string mail address for notifying
3208 public function getNotifyAddress()
3210 return $this->getSetting('bnotify');
3214 * Blog::getNotifyType()
3217 * @return integer notifycation type
3219 public function getNotifyType()
3221 return $this->getSetting('bnotifytype');
3225 * Blog::notifyOnComment()
3230 public function notifyOnComment()
3232 $n = $this->getNotifyType();
3233 return (($n != 0) && (($n % 3) == 0));
3237 * Blog::notifyOnVote()
3242 public function notifyOnVote()
3244 $n = $this->getNotifyType();
3245 return (($n != 0) && (($n % 5) == 0));
3249 * Blog::notifyOnNewItem()
3254 public function notifyOnNewItem()
3256 $n = $this->getNotifyType();
3257 return (($n != 0) && (($n % 7) == 0));
3261 * Blog::setNotifyType()
3263 * @param integer $val
3266 public function setNotifyType($val)
3268 $this->setSetting('bnotifytype',$val);
3273 * Blog::getTimeOffset()
3277 public function getTimeOffset()
3279 return $this->getSetting('btimeoffset');
3283 * Blog::commentsEnabled()
3285 * @return integer enabled or not
3287 public function commentsEnabled()
3289 return $this->getSetting('bcomments');
3295 * @return string URI for this weblog
3297 public function getURL()
3299 return $this->getSetting('burl');
3303 * Blog::getDefaultSkin()
3305 * @return name of skin as default for this weblog
3307 public function getDefaultSkin()
3309 return $this->getSetting('bdefskin');
3313 * Blog::getUpdateFile()
3315 * @return string name of file to be updated when weblog is updated
3317 public function getUpdateFile()
3319 return $this->getSetting('bupdate');
3323 * Blog::getDescription()
3325 * @return string description for this weblog
3327 public function getDescription()
3329 return $this->getSetting('bdesc');
3335 * @return integer publlic or not
3337 public function isPublic()
3339 return $this->getSetting('bpublic');
3343 * Blog::emailRequired()
3345 * @return integer email is required when posting comment or not
3347 public function emailRequired()
3349 return $this->getSetting('breqemail');
3353 * Blog::getSearchable()
3355 * @return integer searchable or not
3357 public function getSearchable()
3359 return $this->getSetting('bincludesearch');
3363 * Blog::getDefaultCategory()
3365 * @return ID for category as a default
3367 public function getDefaultCategory()
3369 return $this->getSetting('bdefcat');
3374 * @param integer $val allow comments by non-registered members or not
3377 public function setPublic($val)
3379 $this->setSetting('bpublic', $val);
3384 * Blog::setSearchable()
3385 * @param integer $val searchable from the other blogs or not
3388 public function setSearchable($val)
3390 $this->setSetting('bincludesearch', $val);
3395 * Blog::setDescription
3396 * @param string $val description for this weblog
3399 public function setDescription($val)
3401 $this->setSetting('bdesc',$val);
3406 * Blog::setUpdateFile()
3407 * @param string $val name of file to beupdated when weblog is updated
3410 public function setUpdateFile($val)
3412 $this->setSetting('bupdate',$val);
3417 * Blog::setDefaultSkin()
3418 * @param integer $val ID for default skin to use when displaying this weblog
3421 public function setDefaultSkin($val)
3423 $this->setSetting('bdefskin', $val);
3429 * @param string $val URI for this weblog
3432 public function setURL($val)
3434 $this->setSetting('burl', $val);
3440 * @param string $val name of this weblog
3443 public function setName($val)
3445 $this->setSetting('bname', $val);
3450 * Blog::setShortName()
3451 * @param string $val short name for this weblog
3454 public function setShortName($val)
3456 $this->setSetting('bshortname', $val);
3461 * Blog::setCommentsEnabled()
3462 * @param integer $val enabling posting comment or not
3465 public function setCommentsEnabled($val)
3467 $this->setSetting('bcomments',$val);
3472 * Blog::setMaxComments()
3473 * @param integer $val maximum number of comments for this weblog
3476 public function setMaxComments($val)
3478 $this->setSetting('bmaxcomments', $val);
3483 * Blog::setNotifyAddress()
3484 * @param string $val email to be notified if weblog updated
3487 public function setNotifyAddress($val)
3489 $this->setSetting('bnotify', $val);
3494 * Blog::setEmailRequired()
3495 * @param string requiring comments with email or not from non member
3498 public function setEmailRequired($val)
3500 $this->setSetting('breqemail', $val);
3505 * Blog::setTimeOffset()
3506 * @param integer $val time offset
3509 public function setTimeOffset($val)
3511 // check validity of value
3512 // 1. replace , by . (common mistake)
3513 $val = str_replace(',','.',$val);
3515 // 2. cast to float or int
3516 if ( is_numeric($val) && (i18n::strpos($val, '.5') === (i18n::strlen($val) - 2)) )
3518 $val = (float) $val;
3522 $val = (integer) $val;
3525 $this->setSetting('btimeoffset',$val);
3530 * Blog::setDefaultCategory()
3531 * @param integer $val ID for default category for this weblog
3534 public function setDefaultCategory($val)
3536 $this->setSetting('bdefcat',$val);
3541 * Blog::getSetting()
3542 * @param string $key key for setting of this weblog
3543 * @return mixed value for the setting
3545 public function getSetting($key)
3547 return $this->settings[$key];
3551 * Blog::setSetting()
3552 * @param string $key key for setting of this weblog
3553 * @param mixed $value value for the key
3556 public function setSetting($key, $value)
3558 $this->settings[$key] = $value;
3563 * Blog::addTeamMember()
3564 * Tries to add a member to the team.
3565 * Returns false if the member was already on the team
3567 * @param integer $memberid id for member
3568 * @param boolean $admin super-admin or not
3569 * @return boolean Success/Fail
3571 public function addTeamMember($memberid, $admin)
3575 $memberid = intval($memberid);
3576 $admin = intval($admin);
3578 // check if member is already a member
3579 $tmem =& $manager->getMember($memberid);
3581 if ( $tmem->isTeamMember($this->blogid) )
3591 $manager->notify('PreAddTeamMember', $data);
3594 $query = "INSERT INTO %s (TMEMBER, TBLOG, TADMIN) VALUES (%d, %d, %d);";
3595 $query = sprintf($query, sql_table('team'), (integer) $memberid, (integer) $this->blogid, (integer) $admin);
3596 DB::execute($query);
3603 $manager->notify('PostAddTeamMember', $data);
3605 $logMsg = sprintf(_TEAM_ADD_NEWTEAMMEMBER, $tmem->getDisplayName(), $memberid, $this->getName());
3606 ActionLog::add(INFO, $logMsg);
3614 * @return integer ID for this weblog
3616 public function getID()
3618 return (integer) $this->blogid;
3622 * Checks if a blog with a given shortname exists
3623 * Returns true if there is a blog with the given shortname (static)
3625 * @param string $name blog shortname
3626 * @return boolean exists or not
3628 public function exists($name)
3630 $r = DB::getResult('SELECT * FROM '.sql_table('blog').' WHERE bshortname='. DB::quoteValue($name));
3631 return ($r->rowCount() != 0);
3635 * Checks if a blog with a given id exists
3636 * Returns true if there is a blog with the given ID (static)
3638 * @param integer $id ID for searched weblog
3639 * @return boolean exists or not
3641 public function existsID($id)
3643 $r = DB::getResult('SELECT * FROM '.sql_table('blog').' WHERE bnumber='.intval($id));
3644 return ($r->rowCount() != 0);
3648 * Blog::setFuturePost()
3649 * flag there is a future post pending
3654 public function setFuturePost()
3656 $query = "UPDATE %s SET bfuturepost='1' WHERE bnumber=%d;";
3657 $query = sprintf($query, sql_table('blog'), (integer) $this->blogid);
3658 DB::execute($query);
3663 * Blog::clearFuturePost()
3664 * clear there is a future post pending
3669 public function clearFuturePost()
3671 $query = "UPDATE %s SET bfuturepost='0' WHERE bnumber=%d;";
3672 $query = sprintf($query, sql_table('blog'), (integer) $this->blogid);
3673 DB::execute($query);
3678 * Blog::checkJustPosted()
3679 * check if we should throw justPosted event
3684 public function checkJustPosted()
3688 if ( $this->settings['bfuturepost'] == 1 )
3690 $query = "SELECT * FROM %s WHERE iposted=0 AND iblog=%d AND itime < NOW();";
3691 $query = sprintf($query, sql_table('item'), (integer) $this->blogid);
3693 $result = DB::getResult($query);
3694 if ( $result->rowCount() > 0 )
3696 // This $pinged is allow a plugin to tell other hook to the event that a ping is sent already
3697 // Note that the plugins's calling order is subject to thri order in the plugin list
3699 $data = array('blogid' => $this->blogid, 'pinged' => &$pinged);
3700 $manager->notify('JustPosted', $data);
3702 // clear all expired future posts
3703 $query = "UPDATE %s SET iposted='1' WHERE iblog=%d AND itime < NOW();";
3704 $query = spriintf($query, sql_table('item'), (integer) $this->blogid);
3705 DB::execute($query);
3707 // check to see any pending future post, clear the flag is none
3708 $query = "SELECT * FROM %s WHERE iposted=0 AND iblog=%d;";
3709 $query = sprintf($query, sql_table('item'), (integer) $this->blogid);
3711 $result = DB::getResult($query);
3712 if ( $result->rowCount() == 0 )
3714 $this->clearFuturePost();
3722 * Blog::readLogFromList()
3723 * Shows the given list of items for this blog
3725 * @param array $itemarray array of item numbers to be displayed
3726 * @param string $template string representing the template _NAME_ (!)
3727 * @param string $highlight contains a query that should be highlighted
3728 * @param boolean $comments 1=show comments 0=don't show comments
3729 * @param boolean $dateheads 1=show dateheads 0=don't show dateheads
3730 * @param boolean $showDrafts 0=do not show drafts 1=show drafts
3731 * @param boolean $showFuture 0=do not show future posts 1=show future posts
3732 * @return integer amount of items shown
3734 public function readLogFromList($itemarray, $template, $highlight = '', $comments = 1, $dateheads = 1,$showDrafts = 0, $showFuture = 0)
3736 $query = $this->getSqlItemList($itemarray,$showDrafts,$showFuture);
3737 return $this->showUsingQuery($template, $query, $highlight, $comments, $dateheads);
3741 * Blog::getSqlItemList()
3742 * Returns the SQL query used to fill out templates for a list of items
3743 * No LIMIT clause is added. (caller should add this if multiple pages are requested)
3745 * @param array $itemarray an array holding the item numbers of the items to be displayed
3746 * @param integer $showDrafts 0=do not show drafts 1=show drafts
3747 * @param integer $showFuture 0=do not show future posts 1=show future posts
3748 * @return string either a full SQL query, or an empty string
3750 public function getSqlItemList($itemarray,$showDrafts = 0,$showFuture = 0)
3752 if ( !is_array($itemarray) )
3757 $showDrafts = intval($showDrafts);
3758 $showFuture = intval($showFuture);
3761 foreach ( $itemarray as $value )
3763 if ( intval($value) )
3765 $items[] = intval($value);
3768 if ( !count($items) )
3775 foreach ( $items as $value )
3779 . ' i.inumber as itemid,'
3780 . ' i.ititle as title,'
3781 . ' i.ibody as body,'
3782 . ' m.mname as author,'
3783 . ' m.mrealname as authorname,'
3785 . ' i.imore as more,'
3786 . ' m.mnumber as authorid,'
3787 . ' m.memail as authormail,'
3788 . ' m.murl as authorurl,'
3789 . ' c.cname as category,'
3790 . ' i.icat as catid,'
3791 . ' i.iclosed as closed';
3794 . sql_table('item') . ' as i, '
3795 . sql_table('member') . ' as m, '
3796 . sql_table('category') . ' as c'
3798 . ' i.iblog='.$this->blogid
3799 . ' and i.iauthor=m.mnumber'
3800 . ' and i.icat=c.catid';
3805 $query .= ' and i.idraft=0';
3809 // don't show future items
3810 $query .= ' and i.itime<=' . DB::formatDateTime($this->getCorrectTime());
3813 $query .= ' and i.inumber='.intval($value);
3816 if ($i) $query .= ' UNION ';
3823 * Blog::convertBreaks()
3824 * Get the the setting for the line break handling
3825 * [should be named as getConvertBreaks()]
3831 public function convertBreaks()
3833 return $this->getSetting('bconvertbreaks');
3837 * Set the the setting for the line break handling
3840 * @param boolean $val new value for bconvertbreaks
3843 public function setConvertBreaks($val)
3845 $this->setSetting('bconvertbreaks', $val);
3849 >>>>>>> skinnable-master