From: <ada...@us...> - 2003-08-31 22:55:37
|
Update of /cvsroot/phpwebsite-comm/modules/article/class In directory sc8-pr-cvs1:/tmp/cvs-serv13155/class Modified Files: ArticleManager.php Log Message: Added "Archive Listings" feature Index: ArticleManager.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/article/class/ArticleManager.php,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ArticleManager.php 31 Jul 2003 21:11:43 -0000 1.7 --- ArticleManager.php 31 Aug 2003 22:55:32 -0000 1.8 *************** *** 45,48 **** --- 45,49 ---- var $image_path; var $filter; + var $date_filter; /** *************** *** 371,374 **** --- 372,508 ---- /** + * Lists the articles stored in the database within a certain date + * + * All parameters are passed via $_REQUEST + * + * @author Eloi George <el...@NO...> + * @module Article Manager + * @param int year + * @param int month + * @param int day + * @param string datetype : Type of date to check & sort on. VALUES: 'publication_date' [default] , 'created_date' or 'updated_date' + * @return none + */ + function view_archives () + { + /* Set up display variables */ + $now = date('Y-m-d H:i:s'); + /* If article row datum hasn't been retrieved/viewed yet... */ + if(!isset($this->pager) || !isset($_REQUEST['PAGER_limit']) || isset($_REQUEST['year'])) + { + $this->pager = new PHPWS_Pager; + $this->pager->setLinkBack('./index.php?module=article&view=archives'); + $this->pager->makeArray(TRUE); + $this->pager->limit = $this->val['listings_per_page']; + + /* Process all relevant GET parameters */ + $this->arc_filter['year'] = (isset($_REQUEST['year'])) ?$_REQUEST['year'] :null; + $this->arc_filter['month'] = (isset($_REQUEST['month'])) ?$_REQUEST['month'] :null; + $this->arc_filter['day'] = (isset($_REQUEST['day'])) ?$_REQUEST['day'] :null; + + if (isset($_REQUEST['datetype']) && $_REQUEST['datetype']!='publication_date') + { + if ($_REQUEST['datetype']=='updated_date') + { + $this->arc_filter['datetype'] = 'updated_date'; + $this->arc_filter['datelabel'] = $_SESSION['translate']->it('Updated'); + } + if ($_REQUEST['datetype']=='created_date') + { + $this->arc_filter['datetype'] = 'created_date'; + $this->arc_filter['datelabel'] = $_SESSION['translate']->it('Created'); + } + } + else + { + $this->arc_filter['datetype']='publication_date'; + $this->arc_filter['datelabel']=$_SESSION['translate']->it('Published'); + } + if (isset($_REQUEST['current']) && $_REQUEST['current']==1) + $viewable_sql = $this->get_published_sql(); + else + $viewable_sql = 'approved'; + + if ($this->arc_filter['year'] && $this->arc_filter['month'] && $this->arc_filter['day']) + { + $filter = ' AND '.$this->arc_filter['datetype'].'>="' + . date('Y-m-d H:i:s', mktime(0,0,0 + ,$this->arc_filter['month'],$this->arc_filter['day'],$this->arc_filter['year'])) + . '" AND '.$this->arc_filter['datetype'].'<"'.date('Y-m-d H:i:s', mktime(0,0,0 + ,$this->arc_filter['month'],($this->arc_filter['day']+1),$this->arc_filter['year'])) + . '" ORDER BY '.$this->arc_filter['datetype'].' ASC'; + $start_date = date('F j, Y', mktime(0,0,0 + ,$this->arc_filter['month'],$this->arc_filter['day'],$this->arc_filter['year'])); + } + elseif ($this->arc_filter['year'] && $this->arc_filter['month']) + { + $filter = ' AND '.$this->arc_filter['datetype'].'>="' + . date('Y-m-d H:i:s', mktime(0,0,0 + ,$this->arc_filter['month'],1,$this->arc_filter['year'])) + . '" AND '.$this->arc_filter['datetype'].'<"'.date('Y-m-d H:i:s', mktime(0,0,0 + ,($this->arc_filter['month']+1),1,$this->arc_filter['year'])) + . '" ORDER BY '.$this->arc_filter['datetype'].' ASC'; + $start_date = date('F, Y', mktime(0,0,0 + ,$this->arc_filter['month'],1,$this->arc_filter['year'])); + } + elseif ($this->arc_filter['year']) + { + $filter = ' AND '.$this->arc_filter['datetype'].'>="' + . date('Y-m-d H:i:s', mktime(0,0,0 + ,1,1,$this->arc_filter['year'])) + . '" AND '.$this->arc_filter['datetype'].'<"'.date('Y-m-d H:i:s', mktime(0,0,0 + ,1,1,($this->arc_filter['year']+1))) + . '" ORDER BY '.$this->arc_filter['datetype'].' ASC'; + $start_date = date('Y', mktime(0,0,0,1,1,$this->arc_filter['year'])); + } + $this->arc_filter['title'] = $_SESSION['translate']->it('All Articles [var1] in [var2]' + , $this->arc_filter['datelabel'], $start_date); + + $result = $GLOBALS['core']->getCol('SELECT id FROM ' . $this->sql_article_table + . ' WHERE ' .$viewable_sql.' AND mainarticle=0'.$this->sql_predicate . $filter); + $this->pager->setData($result); + $result = NULL; + } + + $this->pager->pageData(); + if ($data = implode(',', $this->pager->getData())) + { + /* Retrieve all article listings for this page */ + $sql = 'SELECT * FROM ' . $this->sql_article_table + . ' WHERE id IN (' . $data . ') ORDER BY '.$this->arc_filter['datetype'].' ASC'; + if(!$result = $GLOBALS['core']->query($sql)) + return; + $GLOBALS['CNT_article_summaries']['content'] = ''; + while($summary=$result->fetchrow(DB_FETCHMODE_ASSOC)) + { + $temp = new PHPWS_Article($summary['id'], $summary); + $temp->view(false); + } + unset($temp); + unset($result); + } + else + $GLOBALS['CNT_article_summaries']['content'] = '<br /><br />' + . $_SESSION['translate']->it('No matching articles were found in the database!') + . '<br /><br />'; + + /* Create BlogPage HTML */ + $tags['PAGE_BACKWARD_LINK'] = $this->pager->getBackLink(); + $tags['PAGE_FORWARD_LINK'] = $this->pager->getForwardLink(); + $tags['SECTION_LINKS'] = $this->pager->getSectionLinks(); + $tags['SECTION_INFO'] = $this->pager->getSectionInfo() . $_SESSION['translate']->it('Articles'); + $tags['LIMIT_LINKS'] = $this->pager->getLimitLinks(); + $tags['LIMIT_LINKS_LABEL'] = $_SESSION['translate']->it('Rows to show per page: '); + + $GLOBALS['Layout_title'] = $this->arc_filter['title'] . ' - ' . $_SESSION['OBJ_layout']->page_title; + $GLOBALS['CNT_article_summaries']['title'] = '<center><b>' . $this->arc_filter['title'] . '</b></center>'; + + $content = $GLOBALS['core']->processTemplate($tags,'article','pager.tpl'); + $GLOBALS['CNT_article_summaries']['content'] = $content . '<br />' + . $GLOBALS['CNT_article_summaries']['content'] . $content; + } + + + /** * Sets the main article in the database and in this PHPWS_ArticleManager class. * *************** *** 565,570 **** function reset_configuration () { ! $GLOBALS['core']->sqlDelete("mod_article_config"); ! $GLOBALS['core']->sqlInsert(array(),"mod_article_config", 0, 0, 0, 0); } --- 699,704 ---- function reset_configuration () { ! $GLOBALS['core']->sqlDelete('mod_article_config'); ! $GLOBALS['core']->sqlInsert(array(),'mod_article_config', 0, 0, 0, 0); } *************** *** 725,733 **** if (isset($this->error[$type])) { ! $GLOBALS['CNT_article']['content'] .= "\n<span class=\"errortext\">ERROR!<br />\n"; foreach($this->error[$type] as $msg) ! $GLOBALS['CNT_article']['content'] .= $msg . "<br />\n"; ! $GLOBALS['CNT_article']['content'] .= "</span>\n"; unset($this->error[$type]); } } --- 859,868 ---- if (isset($this->error[$type])) { ! $str = "\n<span class=\"errortext\">ERROR!<br />\n"; foreach($this->error[$type] as $msg) ! $str .= $msg . "<br />\n"; ! $str .= "</span>\n"; unset($this->error[$type]); + return $str; } } |