Update of /cvsroot/phpwebsite-comm/modules/article/inc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2278/inc Modified Files: A_save.php A_mail.php A_update.php runtime.php runtime_categorized.php runtime_chronological.php xmlrpc.php Log Message: Article Manager 4.1.0 Index: xmlrpc.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/article/inc/xmlrpc.php,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** xmlrpc.php 17 Sep 2007 01:12:29 -0000 1.8 --- xmlrpc.php 21 Aug 2008 20:17:19 -0000 1.9 *************** *** 1,525 **** ! <?php ! require_once(PHPWS_SOURCE_DIR . 'mod/article/lib/XML-RPC/IXR_Library.inc.php'); ! /** ! * This is a XML-RPC Server. ! * ! * This script allows offline blog editors to manipulate articles on the website. ! * ! * @version $Id$ ! * ! * @author Eloi George <el...@NO...> [...1023 lines suppressed...] ! function helloWorld($args) { ! return 'Hello, World!'; ! } ! function ooh($args) { ! return new IXR_Error(4000, 'ha ha ha'); ! } ! function times10($value) { ! return array( ! 'times10' => (int)$value * 10, ! 'times100' => (int)$value * 10, ! 'times1000' => (int)$value * 10, ! ); ! } ! } ! ! // Run the server, serve the request ! $s = new MyServer(); ! ?> \ No newline at end of file Index: runtime.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/article/inc/runtime.php,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** runtime.php 17 Sep 2007 04:24:28 -0000 1.15 --- runtime.php 21 Aug 2008 20:17:19 -0000 1.16 *************** *** 1,87 **** ! <?php ! /** ! * This is the runtime file for the article module. ! * ! * @version $Id$ ! * ! * @author Eloi George <el...@NO...> ! * @module Article Manager ! */ ! if(!isset($_REQUEST['module'])) ! { ! PHPWS_Core::initModClass('article', 'AM_ModSettings.php'); ! PHPWS_AM_ModSettings::init(); ! ! $config = $GLOBALS['Article']['val']; ! ! /* Display the homepage articles */ ! $db = & new PHPWS_DB('article'); ! $db->addWhere('mainarticle', '1'); ! Key::restrictView($db, 'article'); ! $db->addOrder('rank desc'); ! $result = $db->select(); ! if (PHPWS_Error::logIfError($result)) ! return; ! if ($result) ! foreach($result as $row) ! { ! /* Initialize Article object */ ! $article = new PHPWS_Article($row); ! Layout::add($article->view_full(), 'article', 'view', true); ! /* Increment the articleview counter */ ! $article->increment_counter((int) $result); ! } ! unset($article); ! ! if ($config['summaries_on_homepage']>0) { ! if ($config['categorized_display'] && !empty($config['category_order'])) ! include(PHPWS_SOURCE_DIR . 'mod/article/inc/runtime_categorized.php'); ! else { ! /* Display summary listings of last n articles on the homepage. */ ! $TotalCount = $config['summaries_on_homepage'] + $config['prev_n_articles']; ! /* Determine how many summaries we're going to show */ ! if ($TotalCount>0) ! include(PHPWS_SOURCE_DIR . 'mod/article/inc/runtime_chronological.php'); ! } ! } ! ! ! /* Display a block listing of the n most popular last n articles. */ ! if ($config['popular_articles']>0) ! { ! /* Load all articles at once */ ! $db = & new PHPWS_DB('article'); ! $db->addColumn('id'); ! $db->addColumn('title'); ! $db->addWhere('announce', '1'); ! $db->addOrder('hits desc'); ! PHPWS_AM_Data::get_published_sql($db); ! $db->setLimit($config['popular_articles']); ! $result = $db->select(); ! if (PHPWS_Error::logIfError($result)) ! exit('Article::Runtime -- a database error occured.'); ! /* If there are summaries to display, display 'em */ ! if(count($result)) ! { ! $content = ''; ! foreach($result AS $summary) { ! if (MOD_REWRITE_ENABLED && $summary['id'] > 0) ! $link = PHPWS_Text::rewriteLink($summary['title'], 'article', $summary['id']); ! else ! $link = PHPWS_Text::moduleLink($summary['title'], 'article', array('id'=> $summary['id'])); ! $content .= '<li>'.$link.'</li><br />
'; ! } ! if (!empty($content)) ! { ! $template['TITLE'] = dgettext('article', 'Popular Articles'); ! $template['CONTENT'] = '<ul>'.$content.'</ul>'; ! $finalContent = PHPWS_Template::process($template, 'layout', 'box.tpl'); ! Layout::add($finalContent, 'article', 'popular'); ! } ! } ! } ! /* Display MiniAdmin Options */ ! PHPWS_AM_Data::MiniAdmin(); ! } ! ?> \ No newline at end of file --- 1,87 ---- ! <?php ! /** ! * This is the runtime file for the article module. ! * ! * @version $Id$ ! * ! * @author Eloi George <el...@NO...> ! * @module Article Manager ! */ ! if(!isset($_REQUEST['module'])) ! { ! PHPWS_Core::initModClass('article', 'AM_ModSettings.php'); ! PHPWS_AM_ModSettings::init(); ! ! $config = $GLOBALS['Article']['val']; ! ! /* Display the homepage articles */ ! $db = & new PHPWS_DB('article'); ! $db->addWhere('mainarticle', '1'); ! Key::restrictView($db, 'article'); ! $db->addOrder('rank desc'); ! $result = $db->select(); ! if (PHPWS_Error::logIfError($result)) ! return; ! if ($result) ! foreach($result as $row) ! { ! /* Initialize Article object */ ! $article = new PHPWS_Article($row); ! Layout::add($article->view_full(), 'article', 'view', true); ! /* Increment the articleview counter */ ! $article->increment_counter((int) $result); ! } ! unset($article); ! ! if ($config['summaries_on_homepage']>0) { ! if ($config['categorized_display'] && !empty($config['category_order'])) ! include(PHPWS_SOURCE_DIR . 'mod/article/inc/runtime_categorized.php'); ! else { ! /* Display summary listings of last n articles on the homepage. */ ! $TotalCount = $config['summaries_on_homepage'] + $config['prev_n_articles']; ! /* Determine how many summaries we're going to show */ ! if ($TotalCount>0) ! include(PHPWS_SOURCE_DIR . 'mod/article/inc/runtime_chronological.php'); ! } ! } ! ! ! /* Display a block listing of the n most popular last n articles. */ ! if ($config['popular_articles']>0) ! { ! /* Load all articles at once */ ! $db = & new PHPWS_DB('article'); ! $db->addColumn('id'); ! $db->addColumn('title'); ! $db->addWhere('announce', '1'); ! $db->addOrder('hits desc'); ! PHPWS_AM_Data::get_published_sql($db); ! $db->setLimit($config['popular_articles']); ! $result = $db->select(); ! if (PHPWS_Error::logIfError($result)) ! exit('Article::Runtime -- a database error occured.'); ! /* If there are summaries to display, display 'em */ ! if(count($result)) ! { ! $content = ''; ! foreach($result AS $summary) { ! if (MOD_REWRITE_ENABLED && $summary['id'] > 0) ! $link = PHPWS_Text::rewriteLink($summary['title'], 'article', $summary['id']); ! else ! $link = PHPWS_Text::moduleLink($summary['title'], 'article', array('id'=> $summary['id'])); ! $content .= '<li>'.$link.'</li><br />
'; ! } ! if (!empty($content)) ! { ! $template['TITLE'] = dgettext('article', 'Popular Articles'); ! $template['CONTENT'] = '<ul>'.$content.'</ul>'; ! $finalContent = PHPWS_Template::process($template, 'layout', 'box.tpl'); ! Layout::add($finalContent, 'article', 'popular'); ! } ! } ! } ! /* Display MiniAdmin Options */ ! PHPWS_AM_Data::MiniAdmin(); ! } ! ?> \ No newline at end of file Index: A_mail.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/article/inc/A_mail.php,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** A_mail.php 22 Jan 2008 04:55:07 -0000 1.12 --- A_mail.php 21 Aug 2008 20:17:19 -0000 1.13 *************** *** 17,88 **** $sendmail = false; if (isset($_POST['ART_yes']) && isset($_POST['ART_mail_type'])) { ! $error = array(); ! if (!isset($_POST['ART_r_email']) || !PHPWS_Text::isValidInput($_POST['ART_r_email'], 'email')) ! $error[0] = dgettext('article', 'Please enter a valid email address'); ! if (!isset($_POST['ART_s_name'])) ! $error[1] = dgettext('article', 'Please enter your name'); ! if (!isset($_POST['ART_s_email']) || !PHPWS_Text::isValidInput($_POST['ART_s_email'], 'email')) ! $error[2] = dgettext('article', 'Please enter a valid email address'); ! if (Captcha::verify($_POST['captcha'])) ! $error[3] = dgettext('article', 'The string you entered for the image verification did not match what was displayed.'); ! if (!count($error)) ! $sendmail = true; } if ($sendmail) { ! /* Construct email */ ! $homepage = PHPWS_Core::getHomeHttp(0, 0, 0); ! $homepage_link = '<a href="'.PHPWS_Core::getHomeHttp().'">'.$homepage.'</a>'; ! if (isset($_POST['ART_s_msg'])) { ! $tags['MESSAGE_LABEL'] = dgettext('article', 'Personal Message').':'; ! $tags['MESSAGE'] = $_POST['ART_s_msg']; ! } ! $L1 = PHPWS_Core::getHomeHttp().'index.php?module=article&view='.$this->id; ! $L2 = PHPWS_Core::getHomeHttp().'index.php?module=article&email='.$this->id; ! $tags['VIEW_LINK'] = sprintf(dgettext('article', 'To view the entire article, go to %1$s or %2$s') ! , $L1, '<a href="'.$L1.'">'.dgettext('article', 'Click Here').'</a>'); ! $tags['MAIL_LINK'] = sprintf(dgettext('article', 'Would you like to send this article to a friend? Go to %1$s or %2$s') ! , $L2, '<a href="'.$L2.'">'.dgettext('article', 'Click Here').'</a>'); ! $text = $html = ''; ! if ($_POST['ART_mail_type']=='full') ! { ! $tags['INTRO'] = sprintf(dgettext('article', '%s has sent you a news article! (Email address not verified)'), '<b>'.$_POST['ART_s_name'].'</b> ('.$_POST['ART_s_email'].')'); ! $tags['PLUG'] = sprintf(dgettext('article', 'Courtesy of %s'), $homepage_link); ! $tags['FOOTER'] = sprintf(dgettext('article', 'Copyright %1$s %2$s'), date('Y'), $homepage_link); ! $tags['TEXT'] = $this->view_full(); ! $html_body = PHPWS_Template::processTemplate($tags, 'article', 'mail_full.tpl'); ! $tags['TEXT'] = ''; ! } ! /* text email body creation */ ! $tags['INTRO'] = sprintf(dgettext('article', '%s has sent you a news article! (Email address not verified)'), $_POST['ART_s_name'].' ('.$_POST['ART_s_email'].')'); ! $tags['PLUG'] = sprintf(dgettext('article', 'Courtesy of %s'), $homepage); ! $tags['TITLE'] = PHPWS_Text::parseOutput($this->title); ! $tags['FOOTER'] = sprintf(dgettext('article', 'Copyright %1$s %2$s'), date('Y'), $homepage); ! if ($this->summary) ! $tags['TEXT'] = PHPWS_AM_Data::parseOutput($this->summary); ! $txt_body = strip_tags(PHPWS_Template::processTemplate($tags, 'article', 'mail_link.tpl')); ! $subject = $homepage.' '.dgettext('article', 'Article').' - '.PHPWS_Text::parseOutput($this->title); ! $sender_name = $_POST['ART_s_name']; ! $sender_email = $_POST['ART_s_email']; ! $recipient_email = $_POST['ART_r_email']; ! $status = PHPWS_AM_Actions::sendmail ($subject, $sender_name, $sender_email, $recipient_email, $txt_body, $html_body = '', $CC = true) ! if ($status===true) { ! $content = sprintf(dgettext('article', 'The %1$s <b>%2$s</b> has successfully been %s') ! , dgettext('article', 'article') ! , $this->title ! , dgettext('article', 'sent to').' '.$recipient_email); ! } elseif($status===false) ! $content = 'EMAIL ERROR: '.$content = dgettext('article', 'Email is not correctly set up on this server.'); ! else ! $content = 'EMAIL ERROR: ' . $status->getMessage(); Layout::addPageTitle(dgettext('article', 'E-mail A Friend').': "'.$this->title); ! $template['TITLE'] = dgettext('article', 'E-mail this Article to a Friend'); ! $template['CONTENT'] = $content .'<br /><br /><div style="text-align:center">[' . PHPWS_Text::moduleLink(sprintf(dgettext('article', 'Go back to %s'), PHPWS_Text::parseOutput($this->title)), 'article', array('id'=>$this->id)). ']</div>'; $finalContent = PHPWS_Template::process($template, 'layout', 'box.tpl'); --- 17,89 ---- $sendmail = false; + $error = array(); if (isset($_POST['ART_yes']) && isset($_POST['ART_mail_type'])) { ! if (!isset($_POST['ART_r_email']) || !PHPWS_Text::isValidInput($_POST['ART_r_email'], 'email')) ! $error[0] = dgettext('article', 'Please enter a valid email address'); ! if (!isset($_POST['ART_s_name'])) ! $error[1] = dgettext('article', 'Please enter your name'); ! if (!isset($_POST['ART_s_email']) || !PHPWS_Text::isValidInput($_POST['ART_s_email'], 'email')) ! $error[2] = dgettext('article', 'Please enter a valid email address'); ! if (!Captcha::verify($_POST['captcha'])) ! $error[3] = dgettext('article', 'The string you entered for the image verification did not match what was displayed.'); ! if (!count($error)) ! $sendmail = true; } if ($sendmail) { ! /* Construct email */ ! $homepage = PHPWS_Core::getHomeHttp(0, 0, 0); ! $homepage_link = '<a href="'.PHPWS_Core::getHomeHttp().'">'.$homepage.'</a>'; ! if (isset($_POST['ART_s_msg'])) { ! $tags['MESSAGE_LABEL'] = dgettext('article', 'Personal Message').':'; ! $tags['MESSAGE'] = $_POST['ART_s_msg']; ! } ! $L1 = PHPWS_Core::getHomeHttp().'index.php?module=article&op=view&id='.$this->id; ! $L2 = PHPWS_Core::getHomeHttp().'index.php?module=article&op=email&id='.$this->id; ! $tags['VIEW_LINK'] = sprintf(dgettext('article', 'To view the entire article, go to %1$s or %2$s') ! , $L1, '<a href="'.$L1.'">'.dgettext('article', 'Click Here').'</a>'); ! $tags['MAIL_LINK'] = sprintf(dgettext('article', 'Would you like to send this article to a friend? Go to %1$s or %2$s') ! , $L2, '<a href="'.$L2.'">'.dgettext('article', 'Click Here').'</a>'); ! $txt_body = $html_body = ''; ! if ($_POST['ART_mail_type']=='full') ! { ! $tags['INTRO'] = sprintf(dgettext('article', '%s has sent you a news article! (Email address not verified)'), '<b>'.$_POST['ART_s_name'].'</b> ('.$_POST['ART_s_email'].')'); ! $tags['PLUG'] = sprintf(dgettext('article', 'Courtesy of %s'), $homepage_link); ! $tags['FOOTER'] = sprintf(dgettext('article', 'Copyright %1$s %2$s'), date('Y'), $homepage_link); ! $tags['TEXT'] = $this->view_full(); ! $html_body = PHPWS_Template::processTemplate($tags, 'article', 'mail_full.tpl'); ! $tags['TEXT'] = ''; ! } ! /* text email body creation */ ! $tags['INTRO'] = sprintf(dgettext('article', '%s has sent you a news article! (Email address not verified)'), $_POST['ART_s_name'].' ('.$_POST['ART_s_email'].')'); ! $tags['PLUG'] = sprintf(dgettext('article', 'Courtesy of %s'), $homepage); ! $tags['TITLE'] = PHPWS_Text::parseOutput($this->title); ! $tags['FOOTER'] = sprintf(dgettext('article', 'Copyright %1$s %2$s'), date('Y'), $homepage); ! if ($this->summary) ! $tags['TEXT'] = strip_tags(PHPWS_AM_Data::parseOutput($this->summary)); ! $txt_body = PHPWS_Template::processTemplate($tags, 'article', 'mail_link.tpl'); ! $subject = $homepage.' '.dgettext('article', 'Article').' - '.PHPWS_Text::parseOutput($this->title); ! $sender_name = $_POST['ART_s_name']; ! $sender_email = $_POST['ART_s_email']; ! $recipient_email = $_POST['ART_r_email']; ! PHPWS_Core::initModClass('article', 'AM_Actions.php'); ! $status = PHPWS_AM_Actions::sendmail ($subject, $sender_name, $sender_email, $recipient_email, $txt_body, $html_body, $CC = true); ! if ($status===true) { ! $content = sprintf(dgettext('article', 'The %1$s <b>%2$s</b> has successfully been %3$s') ! , dgettext('article', 'article') ! , $this->title ! , dgettext('article', 'sent to').' '.$recipient_email); ! } elseif($status===false) ! $content = 'EMAIL ERROR: '.$content = dgettext('article', 'Email is not correctly set up on this server.'); ! else ! $content = 'EMAIL ERROR: ' . $status->getMessage(); Layout::addPageTitle(dgettext('article', 'E-mail A Friend').': "'.$this->title); ! $template['TITLE'] = dgettext('article', 'E-mail this Article to a Friend'); ! $template['CONTENT'] = $content .'<br /><br /><div style="text-align:center">[' . PHPWS_Text::moduleLink(sprintf(dgettext('article', 'Go back to %s'), PHPWS_Text::parseOutput($this->title)), 'article', array('id'=>$this->id)). ']</div>'; $finalContent = PHPWS_Template::process($template, 'layout', 'box.tpl'); *************** *** 91,140 **** else if(isset($_POST['ART_no'])) { ! Layout::add($this->view_full()); } else { ! $tags['SEND'] = '<input name="ART_yes" value="'.dgettext('article', 'Send').'" type="submit">'; ! $tags['CANCEL'] = '<input name="ART_no" value="'.dgettext('article', 'Cancel').'" type="submit">'; ! $tags['TITLE'] = PHPWS_Text::parseOutput($this->title); ! if ($this->summary) ! $tags['SUMMARYTEXT'] = PHPWS_AM_Data::parseOutput($this->summary); ! if (MOD_REWRITE_ENABLED && $this->id > 0) ! $link = PHPWS_Text::rewriteLink(dgettext('article', 'Back to Article'), 'article', $this->id); ! else ! $link = PHPWS_Text::moduleLink(dgettext('article', 'Back to Article'), 'article', array('id' => $this->id)); ! $tags['BACKLINK'] = '['.. ']'; ! $tags['R_MAIL_ERROR'] = dgettext('article', 'Friend\'s Email').':'; ! $tags['R_MAIL_LABEL'] = dgettext('article', 'Friend\'s Email').':'; ! $tags['R_MAIL_ADDR'] = '<input type="text" name="ART_r_email" value="" maxlength="200" style="width:50%" />'; ! $tags['R_MAIL_HELP'] = dgettext('article', 'Separate multiple addresses with commas. Maximum 200 characters.'); ! $tags['S_NAME_LABEL'] = dgettext('article', 'Your Full Name: (optional)'); ! $tags['S_NAME'] = '<input type="text" name="ART_s_name" value="'.Current_User::getDisplayName().'" maxlength="155" style="width:50%" />'; ! $tags['S_MAIL_LABEL'] = dgettext('article', 'Your Email Address').':'; ! $tags['S_MAIL_ADDR'] = '<input type="text" name="ART_s_email" value="'.Current_User::getEmail().'" maxlength="100" style="width:50%" />'; ! $tags['S_MAIL_HELP'] = dgettext('article', 'These email addresses will be used to email the information on your behalf and will not be collected or used by us for any marketing purposes without your permission.'); ! $tags['S_COPY_LABEL'] = dgettext('article', 'Send a copy to yourself'); ! $tags['S_COPY'] = '<input name="ART_copy_s" value="1" type="checkbox">'; ! $tags['S_MSG_LABEL'] = dgettext('article', 'Enter a brief message to your friend: (optional)'); ! $tags['S_MSG'] = '<textarea id="ART_s_msg" name="ART_s_msg" rows="3" style="width:95%"></textarea>'; ! $tags['MAIL_TYPE1_LABEL'] = dgettext('article', 'Full Information in HTML'); ! $tags['MAIL_TYPE1'] = '<input name="ART_mail_type" value="full" checked="checked" type="radio">'; ! $tags['MAIL_TYPE2_LABEL'] = dgettext('article', 'Link Only'); ! $tags['MAIL_TYPE2'] = '<input name="ART_mail_type" value="link" type="radio">'; ! foreach ($error AS $key => $value) ! $tags['ERROR_'.$key] = '
<span class="error">'.dgettext('article', 'ERROR: ').$value.'</span><br />
'; ! $tags['CAPTCHA_MSG'] = '<input type="text" name="captcha" value="" maxlength="10" style="width:20%" />'; ! $tags['CAPTCHA_IMAGE'] = Captcha::get(); ! $tags['CAPTCHA_LABEL'] = dgettext('article', 'Copy the word seen in the above image'); Layout::addPageTitle(dgettext('article', 'E-mail A Friend').': "'.$this->title); ! $template['TITLE'] = dgettext('article', 'E-mail this Article to a Friend'); ! $template['CONTENT'] = '<form name="ARTICLE_emailAfriend" action="index.php" method="post">' ! . '<input name="module" value="article" type="hidden">' ! . '<input name="id" value="'.$this->id.'" type="hidden">' ! . '<input name="op" value="email" type="hidden">' ! . PHPWS_Template::processTemplate($tags,'article','mail_form.tpl') ! . '</form>'; $finalContent = PHPWS_Template::process($template, 'layout', 'box.tpl'); Layout::add($finalContent); --- 92,141 ---- else if(isset($_POST['ART_no'])) { ! Layout::add($this->view_full()); } else { ! $tags['SEND'] = '<input name="ART_yes" value="'.dgettext('article', 'Send').'" type="submit">'; ! $tags['CANCEL'] = '<input name="ART_no" value="'.dgettext('article', 'Cancel').'" type="submit">'; ! $tags['TITLE'] = PHPWS_Text::parseOutput($this->title); ! if ($this->summary) ! $tags['SUMMARYTEXT'] = PHPWS_AM_Data::parseOutput($this->summary); ! if (MOD_REWRITE_ENABLED && $this->id > 0) ! $link = PHPWS_Text::rewriteLink(dgettext('article', 'Back to Article'), 'article', $this->id); ! else ! $link = PHPWS_Text::moduleLink(dgettext('article', 'Back to Article'), 'article', array('id' => $this->id)); ! $tags['BACKLINK'] = '["../"]'; ! $tags['R_MAIL_ERROR'] = dgettext('article', 'Friend\'s Email').':'; ! $tags['R_MAIL_LABEL'] = dgettext('article', 'Friend\'s Email').':'; ! $tags['R_MAIL_ADDR'] = '<input type="text" name="ART_r_email" value="" maxlength="200" style="width:50%" />'; ! $tags['R_MAIL_HELP'] = dgettext('article', 'Separate multiple addresses with commas. Maximum 200 characters.'); ! $tags['S_NAME_LABEL'] = dgettext('article', 'Your Full Name: (optional)'); ! $tags['S_NAME'] = '<input type="text" name="ART_s_name" value="'.Current_User::getDisplayName().'" maxlength="155" style="width:50%" />'; ! $tags['S_MAIL_LABEL'] = dgettext('article', 'Your Email Address').':'; ! $tags['S_MAIL_ADDR'] = '<input type="text" name="ART_s_email" value="'.Current_User::getEmail().'" maxlength="100" style="width:50%" />'; ! $tags['S_MAIL_HELP'] = dgettext('article', 'These email addresses will be used to email the information on your behalf and will not be collected or used by us for any marketing purposes without your permission.'); ! $tags['S_COPY_LABEL'] = dgettext('article', 'Send a copy to yourself'); ! $tags['S_COPY'] = '<input name="ART_copy_s" value="1" type="checkbox">'; ! $tags['S_MSG_LABEL'] = dgettext('article', 'Enter a brief message to your friend: (optional)'); ! $tags['S_MSG'] = '<textarea id="ART_s_msg" name="ART_s_msg" rows="3" style="width:95%"></textarea>'; ! $tags['MAIL_TYPE1_LABEL'] = dgettext('article', 'Full Information in HTML'); ! $tags['MAIL_TYPE1'] = '<input name="ART_mail_type" value="full" checked="checked" type="radio">'; ! $tags['MAIL_TYPE2_LABEL'] = dgettext('article', 'Link Only'); ! $tags['MAIL_TYPE2'] = '<input name="ART_mail_type" value="link" type="radio">'; ! foreach ($error AS $key => $value) ! $tags['ERROR_'.$key] = '
<span class="error">'.dgettext('article', 'ERROR: ').$value.'</span><br />
'; ! $tags['CAPTCHA_MSG'] = '<input type="text" name="captcha" value="" maxlength="10" style="width:20%" />'; ! $tags['CAPTCHA_IMAGE'] = Captcha::get(); ! $tags['CAPTCHA_LABEL'] = dgettext('article', 'Copy the word seen in the above image'); Layout::addPageTitle(dgettext('article', 'E-mail A Friend').': "'.$this->title); ! $template['TITLE'] = dgettext('article', 'E-mail this Article to a Friend'); ! $template['CONTENT'] = '<form name="ARTICLE_emailAfriend" action="index.php" method="post">' ! . '<input name="module" value="article" type="hidden">' ! . '<input name="id" value="'.$this->id.'" type="hidden">' ! . '<input name="op" value="email" type="hidden">' ! . PHPWS_Template::processTemplate($tags,'article','mail_form.tpl') ! . '</form>'; $finalContent = PHPWS_Template::process($template, 'layout', 'box.tpl'); Layout::add($finalContent); Index: A_save.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/article/inc/A_save.php,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** A_save.php 17 Oct 2007 04:35:33 -0000 1.18 --- A_save.php 21 Aug 2008 20:17:19 -0000 1.19 *************** *** 1,147 **** ! <?php ! /** ! * function save () ! * Saves this article to the database. ! * ! * @version $Id$ ! * ! * @author Eloi George <el...@NO...> ! * @module Article Manager ! * @param none ! * @return none ! * ! */ ! if(is_string($this->pages)) ! $this->unserialize_sections(); ! /* Save any POSTed article edits */ ! $result = $this->update(); ! if (is_array($result)) ! return implode('<br />', $result); ! if ($result===false) ! return false; ! ! $db = & new PHPWS_DB('article'); ! ! /* Process all sections */ ! $this->pagecount = count($this->pages); ! $this->wordcount = 0; ! foreach($this->pages as $page) { ! foreach($page['section'] as $section) { ! $this->wordcount += substr_count($section['title'],' ') ! + substr_count($section['text'],' ') ! + (($section['title'] !=='')?1:0) ! + (($section['text'] !=='')?1:0); ! } ! } ! ! /* Convert all sections to XML for storage */ ! require_once(PHPWS_SOURCE_DIR . 'lib/pear/XML/Serializer.php'); ! $XML_buffer = $this->pages; ! $options = array( ! 'indent' => "\t", ! 'defaultTagName' => 'array_item', ! 'typeHints' => true ! // 'keyAttribute' => false, ! // 'classAttribute' => true, ! // "addDecl" => true, ! // "encoding" => "UTF-8", ! // 'rootName' => 'PHPWS_Article' ! ); ! $serializer = new XML_Serializer($options); ! $serializer->setErrorHandling(PEAR_ERROR_DIE); ! $serializer->serialize($this->pages); ! $this->pages = str_replace(array(' _type="string"',' _type="integer"'), '', $serializer->getSerializedData()); ! ! ! /* If this is a new or approved article... */ ! if ($this->approved || !$this->id) { ! if ($this->approved) ! $this->draft = 0; ! /* Kludge to allow AM to use negative numbers */ ! if ($autodetect_id && ($this->id < 0)) ! $db->addWhere('id', $this->id); ! /* save the article to article */ ! $result = $db->saveObject($this, FALSE, $autodetect_id); ! if (PHPWS_Error::logIfError($result)) ! return sprintf(dgettext('article', 'There was an error when inserting %1$s into the database %2$s'), 'article data','article').'!';; ! } ! ! ! if ($this->approved) { ! /* Create/Update this article's Key */ ! $update_article = FALSE; ! if (empty($this->key_id)) ! { ! $key = & new Key; ! $update_article = TRUE; ! } ! else ! { ! $key = & new Key($this->key_id); ! if (PHPWS_Error::logIfError($key->_error)) { ! $key = & new Key; ! $update_article = TRUE; ! } ! } ! $key->setModule('article'); ! $key->setItemName('article'); ! $key->setItemId($this->id); ! $key->setEditPermission('edit_articles'); ! $key->setUrl('index.php?module=article&id='.$this->id); ! $key->setTitle($this->title); ! $key->setSummary($this->summary); ! $key->active = 1; ! $result = $key->save(); ! $this->key_id = $key->id; ! if ($update_article) { ! $db1 = & new PHPWS_DB('article'); ! $db1->addValue('key_id', $this->key_id); ! $db1->addWhere('id', $this->id); ! $db1->update(); ! } ! ! /* Comments */ ! if($this->allow_comments && PHPWS_Core::initModClass('comments', 'Comments.php')) { ! $thread = Comments::getThread($this->key_id); ! $thread->allowAnonymous($this->allow_anonymous); ! $thread->save(); ! } ! ! /* Search */ ! $texttags = $this->_get_tags(); ! $search = new Search($this->key_id); ! $search->resetKeywords(); ! $search->addKeywords($texttags['TITLE']); ! $search->addKeywords(@$texttags['SUMMARYTEXT']); ! $search->addKeywords($texttags['BODYTEXT']); ! $result = $search->save(); ! unset($texttags); ! if (PHPWS_Error::logIfError($result)) ! return $result; ! ! /* Save Metatags */ ! require_once(PHPWS_SOURCE_DIR . 'mod/layout/class/LayoutAdmin.php'); ! $_POST['key_id'] = $this->key_id; ! $_POST['page_title'] = strip_tags($this->title); $_POST['meta_description'] = strip_tags($this->summary); ! Layout_Admin::postMeta(); ! ! /* Reset headline caching if this will be on there */ ! if ($this->announce) ! PHPWS_AM_ModSettings::reset_cache(); ! } ! ! /* Save the article in the version archives */ ! PHPWS_Core::initModClass('version', 'Version.php'); ! $version = & new Version('article'); ! $version->setSource($this); ! if (!empty($this->_version_id)) ! $version->setId($this->_version_id); ! $version->setApproved($this->approved); ! $version->save(); ! ! /* Put sections array back into place */ ! $this->pages = $XML_buffer; ! ! return true; ?> \ No newline at end of file --- 1,153 ---- ! <?php ! /** ! * function save () ! * Saves this article to the database. ! * ! * @version $Id$ ! * ! * @author Eloi George <el...@NO...> ! * @module Article Manager ! * @param bool $autodetect_id : If false, the article will be saved as a new article with the supplied id ! * @return none ! * ! */ ! if(is_string($this->pages)) ! $this->unserialize_sections(); ! /* Save any POSTed article edits */ ! $result = $this->update(); ! if (is_array($result)) ! return implode('<br />', $result); ! if ($result===false) ! return false; ! ! $db = & new PHPWS_DB('article'); ! ! /* Process all sections */ ! $this->pagecount = count($this->pages); ! $this->wordcount = 0; ! foreach($this->pages as $page) { ! foreach($page['section'] as $section) { ! $this->wordcount += substr_count($section['title'],' ') ! + substr_count($section['text'],' ') ! + (($section['title'] !=='')?1:0) ! + (($section['text'] !=='')?1:0); ! } ! } ! ! /* Convert all sections to XML for storage */ ! require_once(PHPWS_SOURCE_DIR . 'lib/pear/XML/Serializer.php'); ! $XML_buffer = $this->pages; ! $options = array( ! 'indent' => "\t", ! 'defaultTagName' => 'array_item', ! 'typeHints' => true ! // 'keyAttribute' => false, ! // 'classAttribute' => true, ! // "addDecl" => true, ! // "encoding" => "UTF-8", ! // 'rootName' => 'PHPWS_Article' ! ); ! $serializer = new XML_Serializer($options); ! $serializer->setErrorHandling(PEAR_ERROR_DIE); ! $serializer->serialize($this->pages); ! $this->pages = str_replace(array(' _type="string"',' _type="integer"'), '', $serializer->getSerializedData()); ! ! ! /* If this is a new or approved article... */ ! if ($this->approved || !$this->id) { ! if ($this->approved) ! $this->draft = 0; ! /* Kludge to allow AM to use negative numbers */ ! if ($autodetect_id && ($this->id < 0)) ! $db->addWhere('id', $this->id); ! /* save the article to article */ ! $result = $db->saveObject($this, FALSE, $autodetect_id); ! if (PHPWS_Error::logIfError($result)) ! return sprintf(dgettext('article', 'There was an error when inserting %1$s into the database %2$s'), 'article data','article').'!';; ! } ! ! ! if ($this->approved) { ! /* Create/Update this article's Key */ ! $update_article = FALSE; ! if (empty($this->key_id)) ! { ! $this->_key = new Key; ! $update_article = TRUE; ! } ! else ! { ! $this->_key = new Key($this->key_id); ! if (PHPWS_Error::logIfError($this->_key->_error)) { ! $this->_key = new Key; ! $update_article = TRUE; ! } ! } ! $this->_key->setModule('article'); ! $this->_key->setItemName('article'); ! $this->_key->setItemId($this->id); ! $this->_key->setEditPermission('edit_articles'); ! $this->_key->setUrl('index.php?module=article&id='.$this->id); ! $this->_key->setTitle($this->title); ! $this->_key->setSummary($this->summary); ! $this->_key->active = 1; ! $result = $this->_key->save(); ! $this->key_id = $this->_key->id; ! if ($update_article) { ! $db1 = new PHPWS_DB('article'); ! $db1->addValue('key_id', $this->key_id); ! $db1->addWhere('id', $this->id); ! $db1->update(); ! } ! ! /* Comments */ ! if($this->allow_comments && isset($this->_allow_anonymous)) { ! PHPWS_Core::initModClass('comments', 'Comments.php'); ! $this->_thread = Comments::getThread($this->_key); ! $this->_thread->allowAnonymous($this->_allow_anonymous); ! $this->_thread->setApproval($this->_default_approval); ! $this->_thread->save(); ! } ! ! /* Search */ ! $texttags = $this->_get_tags(); ! $search = new Search($this->key_id); ! $search->resetKeywords(); ! $search->addKeywords($texttags['TITLE']); ! $search->addKeywords(@$texttags['SUMMARYTEXT']); ! $search->addKeywords($texttags['BODYTEXT']); ! $result = $search->save(); ! unset($texttags); ! if (PHPWS_Error::logIfError($result)) ! return $result; ! ! /* Save Metatags */ ! require_once(PHPWS_SOURCE_DIR . 'mod/layout/class/LayoutAdmin.php'); ! $_POST['key_id'] = $this->key_id; ! $_POST['page_title'] = strip_tags($this->title); $_POST['meta_description'] = strip_tags($this->summary); ! if (!isset($_POST['meta_keywords'])) ! $_POST['meta_keywords'] = ''; ! Layout_Admin::postMeta(); ! ! /* Reset headline caching if this will be on there */ ! if ($this->announce) { ! PHPWS_Core::initModClass('article', 'AM_ModSettings.php'); ! PHPWS_AM_ModSettings::reset_cache(); ! } ! } ! ! /* Save the article in the version archives */ ! PHPWS_Core::initModClass('version', 'Version.php'); ! $version = & new Version('article'); ! $version->setSource($this); ! if (!empty($this->_version_id)) ! $version->setId($this->_version_id); ! $version->setApproved($this->approved); ! $version->save(); ! ! /* Put sections array back into place */ ! $this->pages = $XML_buffer; ! ! return true; ?> \ No newline at end of file Index: runtime_chronological.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/article/inc/runtime_chronological.php,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** runtime_chronological.php 17 Dec 2007 02:29:38 -0000 1.12 --- runtime_chronological.php 21 Aug 2008 20:17:19 -0000 1.13 *************** *** 1,136 **** ! <?php ! /** ! * This is the code to display articles on the homepage grouped by categories. ! * ! * @version $Id$ ! * ! * @author Eloi George <el...@NO...> ! * @module Article Manager ! */ ! $TotalCount = $config['summaries_on_homepage']+$config['prev_n_articles']; ! ! $cachekey = 'ChronologicalArticleHeadlines'; ! $s = PHPWS_Cache::get($cachekey); ! if (empty($s)) { ! /* Load records to display */ ! // if ($_SESSION['translate']->langActive) ! // $lang = ' AND language="'.$_SESSION['translate']->current_language.'"'; ! // else ! // $lang - ''; ! /* Load all articles at once */ ! $db = PHPWS_AM_Data::bulk_load_db(null, true); ! $db->addWhere('announce', '1'); ! $db->addWhere('mainarticle', '0'); ! $db->addOrder('updated_date desc'); ! PHPWS_AM_Data::get_published_sql($db); ! $db->setLimit($TotalCount); ! $result = $db->select(); ! if (PHPWS_Error::logIfError($result)) ! exit('Article::Runtime -- a database error occured.'); ! /* Load all category info for the summary display */ ! $idx = $list = array(); ! if (count($result)) ! { ! $num_rows = min($config['summaries_on_homepage'], count($result)); ! $item_list = $cat_list = array(); ! for($i=0; $i < $num_rows; $i++) ! $queried[] = $result[$i]['key_id']; ! $db = & new PHPWS_DB('categories'); ! $db->addColumn('category_items.key_id'); ! $db->addColumn('categories.id'); ! $db->addColumn('categories.title'); ! $db->addColumn('categories.icon'); ! $db->addWhere('category_items.key_id', $queried, 'IN'); ! $db->addWhere('id', 'category_items.cat_id'); ! $categories = $db->select(); ! ! if (count($categories)) { ! foreach ($categories AS $cat_item) { ! /* If not done already, develop this category's icon & link */ ! if (!isset($list[$cat_item['id']])) { ! $category = & new Category(); ! PHPWS_Core::plugObject($category, $cat_item); ! $list[$cat_item['id']]['cat_link'] = $category->getViewLink('article'); ! if ($category->icon) { ! $icon = $category->getIcon(); ! $category->title = $icon->getTag(); ! $list[$cat_item['id']]['cat_icon'] = $category->getViewLink('article'); ! } ! } ! /* Add to article-category index */ ! $idx[$cat_item['key_id']]['cat_link'][] = $list[$cat_item['id']]['cat_link']; ! $idx[$cat_item['key_id']]['cat_icon'][] = $list[$cat_item['id']]['cat_icon']; ! } ! } ! $GLOBALS['AMcategoryIdx'] = $idx; ! } ! /* Cache this so we don't have to do it for awhile */ ! $s = serialize(array('result' => $result, 'AMcategoryIdx' => $idx)); ! $lifetime = 86400; // number of seconds until cache refresh ! // default is set in CACHE_LIFETIME in the ! // config/core/config.php file ! PHPWS_Cache::save($cachekey, $s, $lifetime); ! } ! else { ! $arr = unserialize($s); ! $result = $arr['result']; ! $GLOBALS['AMcategoryIdx'] = $arr['AMcategoryIdx']; ! } ! ! ! ! /* If there are summaries to display, display 'em */ ! if (count($result)) ! { ! $tpl = & new PHPWS_Template('article'); ! $status = $tpl->setFile('runtime_chronological.tpl'); ! $columns = $config['display_columns']; ! $width = (int) (100 / $columns); ! $num_rows = min($config['summaries_on_homepage'], count($result)); ! $rows = ceil($num_rows / $columns); ! /* Loop for the amount of rows */ ! for($i = 0; $i < $rows; $i++) { ! /* Loop for the amount of columns */ ! for($j = 0; $j < $columns; $j++) { ! if(isset($result[$i + ($j * $rows)])) { ! $tpl->setCurrentBlock('list_columns'); ! $temp = & new PHPWS_Article($result[$i + ($j * $rows)]); ! $arr = $temp->_get_tags() + array('CELL_WIDTH' => $width); ! $tpl->setData($arr); ! $tpl->parseCurrentBlock(); ! } ! } ! $tpl->setCurrentBlock('list_rows'); ! $tpl->parseCurrentBlock(); ! } ! $template['CONTENT'] = $tpl->get(); ! ! $template['TITLE'] = dgettext('article', 'Also on this Site...'); ! $finalContent = PHPWS_Template::process($template, 'layout', 'box.tpl'); ! Layout::add($finalContent, 'article', 'summaries', true); ! } ! /* If there are x articles before these, display the "Prev Articles" Block */ ! $content = ''; ! if ($config['prev_n_articles'] > 0 && count($result)-$config['summaries_on_homepage'] > 0) ! { ! for($i=$config['summaries_on_homepage']; $i < count($result) && isset($result[$i]); $i++) ! { ! if ($i>0) ! $content .= '<br />'; ! if (MOD_REWRITE_ENABLED && $result[$i]['id']) ! $link = PHPWS_Text::rewriteLink($result[$i]['title'], 'article', $result[$i]['id']); ! else ! $link = PHPWS_Text::moduleLink($result[$i]['title'], 'article',array('id'=>$result[$i]['id'])); ! $content .= date('F d', $result[$i]['updated_date']).' <br />'.$link.'
'; ! } ! if (!empty($content)) ! { ! $template['TITLE'] = sprintf(dgettext('article', 'Previous %s Articles'), $config['prev_n_articles']); ! $template['CONTENT'] = &$content; ! $finalContent = PHPWS_Template::process($template, 'layout', 'box.tpl'); ! Layout::add($finalContent, 'article', 'past'); ! } ! } ! ! ?> \ No newline at end of file --- 1,132 ---- ! <?php ! /** ! * This is the code to display articles on the homepage grouped by categories. ! * ! * @version $Id$ ! * ! * @author Eloi George <el...@NO...> ! * @module Article Manager ! */ ! $TotalCount = $config['summaries_on_homepage']+$config['prev_n_articles']; ! ! $cachekey = 'ChronologicalArticleHeadlines'; ! $s = PHPWS_Cache::get($cachekey); ! if (empty($s)) { ! /* Load records to display */ ! // if ($_SESSION['translate']->langActive) ! // $lang = ' AND language="'.$_SESSION['translate']->current_language.'"'; ! // else ! // $lang - ''; ! /* Load all articles at once */ ! $db = PHPWS_AM_Data::bulk_load_db(null, true); ! $db->addWhere('announce', '1'); ! $db->addOrder('updated_date desc'); ! PHPWS_AM_Data::get_published_sql($db); ! $db->setLimit($TotalCount); ! $result = $db->select(); ! if (PHPWS_Error::logIfError($result)) ! exit('Article::Runtime -- a database error occured.'); ! /* Load all category info for the summary display */ ! $idx = $list = array(); ! if (count($result)) ! { ! $num_rows = min($config['summaries_on_homepage'], count($result)); ! $item_list = $cat_list = array(); ! for($i=0; $i < $num_rows; $i++) ! $queried[] = $result[$i]['key_id']; ! $db = & new PHPWS_DB('categories'); ! $db->addColumn('category_items.key_id'); ! $db->addColumn('categories.id'); ! $db->addColumn('categories.title'); ! $db->addColumn('categories.icon'); ! $db->addWhere('category_items.key_id', $queried, 'IN'); ! $db->addWhere('id', 'category_items.cat_id'); ! $categories = $db->select(); ! ! if (count($categories)) { ! foreach ($categories AS $cat_item) { ! /* If not done already, develop this category's icon & link */ ! if (!isset($list[$cat_item['id']])) { ! $category = & new Category(); ! PHPWS_Core::plugObject($category, $cat_item); ! $list[$cat_item['id']]['cat_link'] = $category->getViewLink('article'); ! if ($category->icon) ! $list[$cat_item['id']]['cat_icon'] = $category->getViewLink('article', $category->getIcon()); ! } ! /* Add to article-category index */ ! $idx[$cat_item['key_id']]['cat_link'][] = $list[$cat_item['id']]['cat_link']; ! $idx[$cat_item['key_id']]['cat_icon'][] = $list[$cat_item['id']]['cat_icon']; ! } ! } ! $GLOBALS['AMcategoryIdx'] = $idx; ! } ! /* Cache this so we don't have to do it for awhile */ ! $s = serialize(array('result' => $result, 'AMcategoryIdx' => $idx)); ! $lifetime = 86400; // number of seconds until cache refresh ! // default is set in CACHE_LIFETIME in the ! // config/core/config.php file ! PHPWS_Cache::save($cachekey, $s, $lifetime); ! } ! else { ! $arr = unserialize($s); ! $result = $arr['result']; ! $GLOBALS['AMcategoryIdx'] = $arr['AMcategoryIdx']; ! } ! ! ! ! /* If there are summaries to display, display 'em */ ! if (count($result)) ! { ! $tpl = & new PHPWS_Template('article'); ! $status = $tpl->setFile('runtime_chronological.tpl'); ! $columns = $config['display_columns']; ! $width = (int) (100 / $columns); ! $num_rows = min($config['summaries_on_homepage'], count($result)); ! $rows = ceil($num_rows / $columns); ! /* Loop for the amount of rows */ ! for($i = 0; $i < $rows; $i++) { ! /* Loop for the amount of columns */ ! for($j = 0; $j < $columns; $j++) { ! if(isset($result[$i + ($j * $rows)])) { ! $tpl->setCurrentBlock('list_columns'); ! $temp = & new PHPWS_Article($result[$i + ($j * $rows)]); ! $arr = $temp->_get_tags() + array('CELL_WIDTH' => $width); ! $tpl->setData($arr); ! $tpl->parseCurrentBlock(); ! } ! } ! $tpl->setCurrentBlock('list_rows'); ! $tpl->parseCurrentBlock(); ! } ! $template['CONTENT'] = $tpl->get(); ! ! $template['TITLE'] = dgettext('article', 'Also on this Site...'); ! $finalContent = PHPWS_Template::process($template, 'layout', 'box.tpl'); ! Layout::add($finalContent, 'article', 'summaries', true); ! } ! /* If there are x articles before these, display the "Prev Articles" Block */ ! $content = ''; ! if ($config['prev_n_articles'] > 0 && count($result)-$config['summaries_on_homepage'] > 0) ! { ! for($i=$config['summaries_on_homepage']; $i < count($result) && isset($result[$i]); $i++) ! { ! if ($i>0) ! $content .= '<br />'; ! if (MOD_REWRITE_ENABLED && $result[$i]['id']) ! $link = PHPWS_Text::rewriteLink($result[$i]['title'], 'article', $result[$i]['id']); ! else ! $link = PHPWS_Text::moduleLink($result[$i]['title'], 'article',array('id'=>$result[$i]['id'])); ! $content .= date('F d', $result[$i]['updated_date']).' <br />'.$link.'
'; ! } ! if (!empty($content)) ! { ! $template['TITLE'] = sprintf(dgettext('article', 'Previous %s Articles'), $config['prev_n_articles']); ! $template['CONTENT'] = &$content; ! $finalContent = PHPWS_Template::process($template, 'layout', 'box.tpl'); ! Layout::add($finalContent, 'article', 'past'); ! } ! } ! ! ?> \ No newline at end of file Index: runtime_categorized.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/article/inc/runtime_categorized.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** runtime_categorized.php 21 Oct 2007 05:47:37 -0000 1.9 --- runtime_categorized.php 21 Aug 2008 20:17:19 -0000 1.10 *************** *** 1,104 **** ! <?php ! /** ! * This is the code to display articles on the homepage in chronological order. ! * ! * @version $Id$ ! * ! * @author Eloi George <el...@NO...> ! * @module Article Manager ! */ ! $cachekey = 'CategorizedArticleHeadlines'; ! $s = PHPWS_Cache::get($cachekey); ! if (empty($s)) { ! $category_index = Categories::getCategories('list'); ! $category_order = array(0) + explode(' ', $config['category_order']); ! $content = array(); ! ! foreach ($category_order AS $cat_id) { ! $db = PHPWS_AM_Data::bulk_load_db (null, true); ! $db->addWhere('announce', '1'); ! $db->addWhere('mainarticle', '0'); ! $db->addWhere('category_items.cat_id', $cat_id); ! $db->addWhere('category_items.module', 'article'); ! $db->addWhere('category_items.key_id', 'article.key_id'); ! $db->addOrder('updated_date desc'); ! PHPWS_AM_Data::get_published_sql($db); ! $db->setLimit($config['summaries_on_homepage']); ! ! $result = $db->select(); ! if (PHPWS_Error::logIfError($result)) ! exit('Article::Runtime -- a database error occured.'); ! ! if (!($result)) ! continue; ! foreach ($result AS $key => $value) { ! if ($key > $config['summaries_per_category']) ! unset($result[$key]['summary']); ! } ! ! $content[] = $result; ! $category = & new Category($cat_id); ! $a = array('CATEGORY_NAME' => $category->getViewLink('article'), ! 'CATEGORY_DESCRIPTION' => $category->getDescription()); ! if ($category->icon) { ! $icon = $category->getIcon(); ! $category->title = $icon->getTag(); ! $a['CATEGORY_ICON'] = $category->getViewLink('article'); ! } ! $cat_arr[] = $a; ! } ! /* Cache this so we don't have to do it for awhile */ ! $s = serialize(array('content' => $content, 'cat_arr' => $cat_arr)); ! $lifetime = 86400; // number of seconds until cache refresh ! // default is set in CACHE_LIFETIME in the ! // config/core/config.php file ! PHPWS_Cache::save($cachekey, $s, $lifetime); ! } ! else { ! $arr = unserialize($s); ! $content = $arr['content']; ! $cat_arr = $arr['cat_arr']; ! } ! unset($s); ! ! /* If there are summaries to display, display 'em */ ! if (count($content)) ! { ! $tpl = & new PHPWS_Template('article'); ! $status = $tpl->setFile('runtime_categorized.tpl'); ! $columns = $config['display_columns']; ! $width = (int) (100 / $columns); ! $num_rows = min($config['summaries_on_homepage'], count($content)); ! $rows = ceil($num_rows / $columns); ! /* Loop for the amount of rows */ ! for($i = 0; $i < $rows; $i++) { ! /* Loop for the amount of columns */ ! for($j = 0; $j < $columns; $j++) { ! if(isset($content[$i + ($j * $rows)])) { ! /* Single category display */ ! $pos = $i + ($j * $rows); ! foreach ($content[$pos] AS $key => $value) { ! if ($key < $config['summaries_per_category']) ! $tpl->setCurrentBlock('list_headline_summaries'); ! else ! $tpl->setCurrentBlock('list_headline_titles'); ! $temp = new PHPWS_Article($value); ! $arr = $temp->_get_tags(); ! $tpl->setData($arr); ! $tpl->parseCurrentBlock(); ! } ! $tpl->setCurrentBlock('list_columns'); ! $arr = $cat_arr[$pos] + array('CELL_WIDTH' => $width); ! $tpl->setData($arr); ! $tpl->parseCurrentBlock(); ! } ! } ! $tpl->setCurrentBlock('list_rows'); ! $tpl->parseCurrentBlock(); ! } ! $template['CONTENT'] = $tpl->get(); ! $template['TITLE'] = dgettext('article', 'Also on this Site...'); ! $finalContent = PHPWS_Template::process($template, 'layout', 'box.tpl'); ! Layout::add($finalContent, 'article', 'summaries', true); ! } ?> \ No newline at end of file --- 1,101 ---- ! <?php ! /** ! * This is the code to display articles on the homepage in chronological order. ! * ! * @version $Id$ ! * ! * @author Eloi George <el...@NO...> ! * @module Article Manager ! */ ! $cachekey = 'CategorizedArticleHeadlines'; ! $s = PHPWS_Cache::get($cachekey); ! if (empty($s)) { ! $category_index = Categories::getCategories('list'); ! $category_order = explode(' ', $config['category_order']); ! array_unshift($category_order, 0); ! $content = array(); ! ! foreach ($category_order AS $cat_id) { ! $db = PHPWS_AM_Data::bulk_load_db (null, true); ! $db->addWhere('announce', '1'); ! $db->addWhere('category_items.cat_id', $cat_id); ! $db->addWhere('category_items.module', 'article'); ! $db->addWhere('category_items.key_id', 'article.key_id'); ! $db->addOrder('updated_date desc'); ! PHPWS_AM_Data::get_published_sql($db); ! $db->setLimit($config['summaries_on_homepage']); ! ! $result = $db->select(); ! if (PHPWS_Error::logIfError($result)) ! exit('Article::Runtime -- a database error occured.'); ! ! if (!($result)) ! continue; ! foreach ($result AS $key => $value) { ! if ($key > $config['summaries_per_category']) ! unset($result[$key]['summary']); ! } ! ! $content[] = $result; ! $category = & new Category($cat_id); ! $a = array('CATEGORY_NAME' => $category->getViewLink('article'), ! 'CATEGORY_DESCRIPTION' => $category->getDescription()); ! if ($category->icon) ! $a['CATEGORY_ICON'] = $category->getViewLink('article', $category->getIcon()); ! $cat_arr[] = $a; ! } ! /* Cache this so we don't have to do it for awhile */ ! $s = serialize(array('content' => $content, 'cat_arr' => $cat_arr)); ! $lifetime = 86400; // number of seconds until cache refresh ! // default is set in CACHE_LIFETIME in the ! // config/core/config.php file ! PHPWS_Cache::save($cachekey, $s, $lifetime); ! } ! else { ! $arr = unserialize($s); ! $content = $arr['content']; ! $cat_arr = $arr['cat_arr']; ! } ! unset($s); ! ! /* If there are summaries to display, display 'em */ ! if (count($content)) ! { ! $tpl = & new PHPWS_Template('article'); ! $status = $tpl->setFile('runtime_categorized.tpl'); ! $columns = $config['display_columns']; ! $width = (int) (100 / $columns); ! $num_rows = min($config['summaries_on_homepage'], count($content)); ! $rows = ceil($num_rows / $columns); ! /* Loop for the amount of rows */ ! for($i = 0; $i < $rows; $i++) { ! /* Loop for the amount of columns */ ! for($j = 0; $j < $columns; $j++) { ! if(isset($content[$i + ($j * $rows)])) { ! /* Single category display */ ! $pos = $i + ($j * $rows); ! foreach ($content[$pos] AS $key => $value) { ! if ($key < $config['summaries_per_category']) ! $tpl->setCurrentBlock('list_headline_summaries'); ! else ! $tpl->setCurrentBlock('list_headline_titles'); ! $temp = new PHPWS_Article($value); ! $arr = $temp->_get_tags(); ! $tpl->setData($arr); ! $tpl->parseCurrentBlock(); ! } ! $tpl->setCurrentBlock('list_columns'); ! $arr = $cat_arr[$pos] + array('CELL_WIDTH' => $width); ! $tpl->setData($arr); ! $tpl->parseCurrentBlock(); ! } ! } ! $tpl->setCurrentBlock('list_rows'); ! $tpl->parseCurrentBlock(); ! } ! $template['CONTENT'] = $tpl->get(); ! $template['TITLE'] = dgettext('article', 'Also on this Site...'); ! $finalContent = PHPWS_Template::process($template, 'layout', 'box.tpl'); ! Layout::add($finalContent, 'article', 'summaries', true); ! } ?> \ No newline at end of file Index: A_update.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/article/inc/A_update.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** A_update.php 22 Jan 2008 04:55:07 -0000 1.9 --- A_update.php 21 Aug 2008 20:17:19 -0000 1.10 *************** *** 1,79 **** ! <?php ! /** ! * function update_settings () ! * Updates this article's information in memory ! * ! * @version $Id$ ! * ! * @author Eloi George <el...@NO...> ! * @module Article Manager ! * @param none ! * @return none ! */ ! $this->updated_username = Current_User::getDisplayName(); ! $this->updated_date = time(); ! ! if (!isset($_POST['ARTICLE_title']) && !isset($_POST['ARTICLE_summary'])) ! return false; ! ! /* Update title and summary data */ ! $this->title = strip_tags($_POST['ARTICLE_title']); ! $this->summary = PHPWS_Text::parseInput($_POST['ARTICLE_summary']); ! ! /* Update all section data */ ! if (isset($_POST['page'])) ! { ! if($s_arr = PHPWS_Article_Section::get_post('a')) { ! /* Summary Image data fields */ ! $result = PHPWS_Article_Image::update($this, $s_arr); ! if(!empty($result)) ! $GLOBALS['Article']['error']['ARTICLE_alt'][] = $result; ! } ! ! foreach($this->pages AS $pagenum => $page) { ! if(isset($_POST['ARTICLE_page_'.($pagenum + 1).'_teaser'])) ! $this->pages[$pagenum]['teaser'] = strip_tags($_POST['ARTICLE_page_'.($pagenum + 1).'_teaser']); ! foreach($page['section'] AS $sectnum => $section_data) { ! $s_arr = PHPWS_Article_Section::get_post($section_data['id']); ! if(!empty($s_arr)) { ! $section = new PHPWS_Article_Section($section_data); ! $section->update($s_arr); ! $this->pages[$pagenum]['section'][$sectnum] = get_object_vars($section); ! } ! } ! } ! } ! ! ! /* If this is a translation, nothing else can be changed */ ! //if (!$this->is_base_article) ! // return true; ! ! $this->announce = ($_POST['ARTICLE_announce'])?1:0; ! ! if (Current_User::allow('article', "allow_comments") ! || ($GLOBALS['Article']['val']['users_allow_comments'] && Current_User::getId())) ! { ! $this->allow_comments = (isset($_POST['ARTICLE_allow_comments']))?1:0; ! if (Current_User::allow('article', "allow_anon")) ! $this->allow_anonymous = (isset($_POST['ARTICLE_allow_anonymous']))?1:0; ! } ! ! if(isset($_POST['ARTICLE_publication_date'])) ! { ! $this->publication_date = strtotime($_POST['ARTICLE_publication_date']); ! if ($this->publication_date < $this->created_date) ! $this->publication_date = $this->created_date; ! if ($this->updated_date < $this->publication_date) ! $this->updated_date = $this->publication_date; ! } ! ! if (isset($_POST['ARTICLE_expiration_date'])) ! $this->expiration_date = strtotime($_POST['ARTICLE_expiration_date']); ! if (isset($_POST['ARTICLE_expiration_flag']) || !$GLOBALS['Article']['val']['can_expire']) ! $this->expiration_date = 0; ! if (isset($_POST['ARTICLE_template'])) ! $this->template = str_replace(' ','_',$_POST['ARTICLE_template']); ! ! return true; ! ?> --- 1,81 ---- ! <?php ! /** ! * function update_settings () ! * Updates this article's information in memory ! * ! * @version $Id$ ! * ! * @author Eloi George <el...@NO...> ! * @module Article Manager ! * @param none ! * @return none ! */ ! $this->updated_username = Current_User::getDisplayName(); ! $this->updated_date = time(); ! ! if (!isset($_POST['ARTICLE_title']) && !isset($_POST['ARTICLE_summary'])) ! return false; ! ! /* Update title and summary data */ ! $this->title = strip_tags($_POST['ARTICLE_title']); ! $this->summary = PHPWS_Text::parseInput($_POST['ARTICLE_summary']); ! ! /* Update all section data */ ! if (isset($_POST['page'])) ! { ! if($s_arr = PHPWS_Article_Section::get_post('a')) { ! /* Summary Image data fields */ ! $result = PHPWS_Article_Image::update($this, $s_arr); ! if(!empty($result)) ! $GLOBALS['Article']['error']['ARTICLE_alt'][] = $result; ! } ! ! foreach($this->pages AS $pagenum => $page) { ! if(isset($_POST['ARTICLE_page_'.($pagenum + 1).'_teaser'])) ! $this->pages[$pagenum]['teaser'] = strip_tags($_POST['ARTICLE_page_'.($pagenum + 1).'_teaser']); ! foreach($page['section'] AS $sectnum => $section_data) { ! $s_arr = PHPWS_Article_Section::get_post($section_data['id']); ! if(!empty($s_arr)) { ! $section = new PHPWS_Article_Section($section_data); ! $section->update($s_arr); ! $this->pages[$pagenum]['section'][$sectnum] = get_object_vars($section); ! } ! } ! } ! } ! ! ! /* If this is a translation, nothing else can be changed */ ! //if (!$this->is_base_article) ! // return true; ! ! $this->announce = (int) !empty($_POST['ARTICLE_announce']); ! ! if (Current_User::allow('article', "allow_comments") ! || ($GLOBALS['Article']['val']['users_allow_comments'] && Current_User::getId())) ! { ! $this->allow_comments = (int) !empty($_POST['ARTICLE_allow_comments']); ! if (Current_User::allow('article', "allow_anon")) { ! $this->_allow_anonymous = (int) !empty($_POST['ARTICLE_allow_anonymous']); ! $this->_default_approval = (int) $_POST['ARTICLE_default_approval']; ! } ! } ! ! if(isset($_POST['ARTICLE_publication_date'])) ! { ! $this->publication_date = strtotime($_POST['ARTICLE_publication_date']); ! if ($this->publication_date < $this->created_date) ! $this->publication_date = $this->created_date; ! if ($this->updated_date < $this->publication_date) ! $this->updated_date = $this->publication_date; ! } ! ! if (isset($_POST['ARTICLE_expiration_date'])) ! $this->expiration_date = strtotime($_POST['ARTICLE_expiration_date']); ! if (isset($_POST['ARTICLE_expiration_flag']) || !$GLOBALS['Article']['val']['can_expire']) ! $this->expiration_date = 0; ! if (isset($_POST['ARTICLE_template'])) ! $this->template = str_replace(' ','_',$_POST['ARTICLE_template']); ! ! return true; ! ?> |