From: Eloi G. <ada...@us...> - 2004-08-21 17:02:50
|
Update of /cvsroot/phpwebsite-comm/modules/article/class In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29156/class Modified Files: Article.php ArticleManager.php Added Files: unified_diff.php Log Message: 2.5 Release Files Index: Article.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/article/class/Article.php,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Article.php 18 Jun 2004 23:31:07 -0000 1.18 --- Article.php 21 Aug 2004 17:02:08 -0000 1.19 *************** *** 44,48 **** * @param string meta_keywords : Keywords to include in this page's metatags * @param string meta_robots : Search Engine instructions for this page's metatags ! //* @param array categories : Temporary holding array of selected categories * */ --- 44,48 ---- * @param string meta_keywords : Keywords to include in this page's metatags * @param string meta_robots : Search Engine instructions for this page's metatags ! * @param string oldversion : Serialized copy of this article for archiving * */ *************** *** 58,62 **** --- 58,64 ---- var $rank; var $created_username; + var $created_id; var $updated_username; + var $updated_id; var $created_date; var $updated_date; *************** *** 79,82 **** --- 81,85 ---- var $meta_keywords; var $meta_robots; + var $oldversion; /** *************** *** 97,102 **** $this->sectionID = 'a'; $this->editmode = FALSE; /* If this is to be an existing article... */ ! if($id) { /* If this is a regular (full) article, load all variables into $data */ --- 100,112 ---- $this->sectionID = 'a'; $this->editmode = FALSE; + /* If this is to be an existing article... */ ! if(substr($id,0,3)=='arc') ! { ! echo 'archive '.substr($id,4).'requested'; ! exit; ! } ! /* If this is to be an existing article... */ ! elseif($id) { /* If this is a regular (full) article, load all variables into $data */ *************** *** 122,126 **** --- 132,138 ---- $this->rank = $data['rank']; $this->created_username = $data['created_username']; + $this->created_id = $data['created_id']; $this->updated_username = $data['updated_username']; + $this->updated_id = $data['updated_id']; $this->created_date = $data['created_date']; $this->updated_date = $data['updated_date']; *************** *** 150,157 **** $this->mainarticle = 0; $this->rank = 50; ! if ($_SESSION['OBJ_user']->username) $this->created_username = $this->updated_username = $_SESSION['OBJ_user']->username; ! else ! $this->created_username = $this->updated_username = " "; $this->created_date = date("Y-m-d H:i:s"); $this->updated_date = date("Y-m-d H:i:s"); --- 162,173 ---- $this->mainarticle = 0; $this->rank = 50; ! if ($_SESSION['OBJ_user']->username) { $this->created_username = $this->updated_username = $_SESSION['OBJ_user']->username; ! $this->created_id = $this->updated_id = $_SESSION['OBJ_user']->user_id; ! } ! else { ! $this->created_username = $this->updated_username = ""; ! $this->created_id = $this->updated_id = ""; ! } $this->created_date = date("Y-m-d H:i:s"); $this->updated_date = date("Y-m-d H:i:s"); *************** *** 170,175 **** $this->pages = 1; $this->template = $_SESSION['SES_ART_master']->val['default_article_template']; - $this->approved = ($_SESSION['OBJ_user']->allow_access('article', 'create_articles') - || !$_SESSION['SES_ART_master']->val['need_approval']) ?1:0; $this->version = -1; $this->announce = 1; --- 186,189 ---- *************** *** 201,205 **** if ($Fullpage && !$this->is_viewable()) { ! $GLOBALS['CNT_article']['content'] = $_SESSION['translate']->it('The article you requested is not viewable.'); PHPWS_Fatcat::deactivate($this->id, 'article'); --- 215,224 ---- if ($Fullpage && !$this->is_viewable()) { ! $GLOBALS['CNT_article']['title'] = $_SESSION['translate']->it('Sorry!'); ! if(!$this->approved) ! $GLOBALS['CNT_article']['content'] = ! $_SESSION['translate']->it('The article you requested is awaiting approval by an administrator.'); ! else ! $GLOBALS['CNT_article']['content'] = $_SESSION['translate']->it('The article you requested is not viewable.'); PHPWS_Fatcat::deactivate($this->id, 'article'); *************** *** 214,225 **** $article_tags['TITLE'] = $this->title; if ($this->summary) $article_tags['SUMMARYTEXT'] = PHPWS_Text::parseOutput($this->summary); $article_tags['HITS'] = $this->hits; $article_tags['CREATED_DATE'] = date(PHPWS_DATE_FORMAT . ' ' . PHPWS_TIME_FORMAT, (strtotime($this->created_date)+$GLOBALS['core']->datetime->time_dif)); - ; $article_tags['UPDATED_DATE'] = date(PHPWS_DATE_FORMAT . ' ' . PHPWS_TIME_FORMAT, (strtotime($this->updated_date)+$GLOBALS['core']->datetime->time_dif)); $article_tags['EXPIRATION_DATE'] = date(PHPWS_DATE_FORMAT . ' ' . PHPWS_TIME_FORMAT, (strtotime($this->expiration_date)+$GLOBALS['core']->datetime->time_dif)); $article_tags['PUBLICATION_DATE'] = date(PHPWS_DATE_FORMAT . ' ' . PHPWS_TIME_FORMAT, (strtotime($this->publication_date)+$GLOBALS['core']->datetime->time_dif)); /* If Username is blank, substitute "Anonymous" */ --- 233,248 ---- $article_tags['TITLE'] = $this->title; + if(isset($_REQUEST['viewarchive'])) + $article_tags['TITLE'] .= '<br />'.$_SESSION['translate']->it('Archived Version [var1]', $this->version); if ($this->summary) $article_tags['SUMMARYTEXT'] = PHPWS_Text::parseOutput($this->summary); + if(!$this->approved) + $article_tags['SUMMARYTEXT'] .= '<br />'.$_SESSION['translate']->it('<b>NOTE:</b> This [var1] is awaiting approval. Visitors cannot see it', $_SESSION['translate']->it('article')); $article_tags['HITS'] = $this->hits; $article_tags['CREATED_DATE'] = date(PHPWS_DATE_FORMAT . ' ' . PHPWS_TIME_FORMAT, (strtotime($this->created_date)+$GLOBALS['core']->datetime->time_dif)); $article_tags['UPDATED_DATE'] = date(PHPWS_DATE_FORMAT . ' ' . PHPWS_TIME_FORMAT, (strtotime($this->updated_date)+$GLOBALS['core']->datetime->time_dif)); $article_tags['EXPIRATION_DATE'] = date(PHPWS_DATE_FORMAT . ' ' . PHPWS_TIME_FORMAT, (strtotime($this->expiration_date)+$GLOBALS['core']->datetime->time_dif)); $article_tags['PUBLICATION_DATE'] = date(PHPWS_DATE_FORMAT . ' ' . PHPWS_TIME_FORMAT, (strtotime($this->publication_date)+$GLOBALS['core']->datetime->time_dif)); + $article_tags['VERSION'] = $this->version; /* If Username is blank, substitute "Anonymous" */ *************** *** 239,243 **** $_SESSION['OBJ_layout']->meta_vars['meta_robots'] = $this->meta_robots; } ! $article_tags['CREATED_TEXT'] = $_SESSION['translate']->it('Created by [var1] on [var2]' , $this->created_username, $article_tags['CREATED_DATE']); $article_tags['UPDATED_TEXT'] = $_SESSION['translate']->it('Last updated by [var1] on [var2]' --- 262,266 ---- $_SESSION['OBJ_layout']->meta_vars['meta_robots'] = $this->meta_robots; } ! $article_tags['CREATED_TEXT'] = $_SESSION['translate']->it('Created By [var1] on [var2]' , $this->created_username, $article_tags['CREATED_DATE']); $article_tags['UPDATED_TEXT'] = $_SESSION['translate']->it('Last updated by [var1] on [var2]' *************** *** 248,252 **** $printAll = (isset($_REQUEST['page_num']) && $_REQUEST['page_num']=='all') || isset($_REQUEST['lay_quiet']); /* Keep track of any sub-page titles for the NavBar */ ! $page_list[] = $this->title; $page_count = 1; /* Construct article sections */ --- 271,278 ---- $printAll = (isset($_REQUEST['page_num']) && $_REQUEST['page_num']=='all') || isset($_REQUEST['lay_quiet']); /* Keep track of any sub-page titles for the NavBar */ ! if(!empty($this->sections[reset($this->order)]->title)) ! $page_list[] = $this->sections[reset($this->order)]->title; ! else ! $page_list[] = $this->title; $page_count = 1; /* Construct article sections */ *************** *** 338,355 **** } if (!$this->mainarticle) { $article_tags['PRINT_ICON'] = '<a href="' . $article_link .'&lay_quiet=1" target="_blank"><img src="http://' . PHPWS_SOURCE_HTTP . 'mod/article/img/print.gif" border="0" width="22" height="20" alt="' ! . $_SESSION['translate']->it('Printable Version') . '" title="' ! . $_SESSION['translate']->it('Printable Version') . '"/></a>'; $article_tags['EMAIL'] = '<a href="./index.php?module=article&email='.$this->id .'"><img src="http://'. PHPWS_SOURCE_HTTP . 'mod/article/img/mailto.png" border="0" width="19" height="12" alt="' ! . $_SESSION['translate']->it('E-mail this Article to a Friend') . '" title="' ! . $_SESSION['translate']->it('E-mail this Article to a Friend') . '"/></a>'; } /* if user can edit articles or can edit this article... */ ! if ($_SESSION['SES_ART_master']->can('edit',$this->created_username)) /* If someone else is editing this page... */ if ($this->isLocked($this->editlock, $this->edituser)) --- 364,382 ---- } if (!$this->mainarticle) { + $s = $_SESSION['translate']->it('Printable Version'); $article_tags['PRINT_ICON'] = '<a href="' . $article_link .'&lay_quiet=1" target="_blank"><img src="http://' . PHPWS_SOURCE_HTTP . 'mod/article/img/print.gif" border="0" width="22" height="20" alt="' ! . $s . '" title="'. $s . '"/></a>'; ! $s = $_SESSION['translate']->it('E-mail this Article to a Friend'); $article_tags['EMAIL'] = '<a href="./index.php?module=article&email='.$this->id .'"><img src="http://'. PHPWS_SOURCE_HTTP . 'mod/article/img/mailto.png" border="0" width="19" height="12" alt="' ! . $s . '" title="' . $s . '"/></a>'; } /* if user can edit articles or can edit this article... */ ! if ($_SESSION['SES_ART_master']->can('edit',$this->created_username) ! && !($this->mainarticle && !$_SESSION['OBJ_user']->allow_access('approval'))) /* If someone else is editing this page... */ if ($this->isLocked($this->editlock, $this->edituser)) *************** *** 718,721 **** --- 745,789 ---- include(PHPWS_SOURCE_DIR . 'mod/article/inc/A_mail.php'); } + + /** + * Prepares the article for serialization & archival storage + * + * @author Eloi George <el...@NO...> + * @module Article Manager + * @param none + * @return none + */ + function _sleep () + { + unset($this->oldversion); + return $this; + } + + /** + * Displays the revision history of this article. + * + * @author Eloi George <el...@NO...> + * @module Article Manager + * @param none + * @return none + */ + function view_history () + { + include(PHPWS_SOURCE_DIR . 'mod/article/inc/A_view_history.php'); + } + + /** + * Displays differences between 2 versions of this article. + * + * @author Eloi George <el...@NO...> + * @module Article Manager + * @param int oldversion : Version # of the older revision. + * @param int newversion : Version # of the newer revision. + * @return none + */ + function view_diff ($oldversion, $newversion) + { + include(PHPWS_SOURCE_DIR . 'mod/article/inc/A_view_diff.php'); + } } ?> \ No newline at end of file --- NEW FILE: unified_diff.php --- <?php require_once(PHPWS_SOURCE_DIR . 'mod/article/lib/pear/Text/Diff.php'); require_once(PHPWS_SOURCE_DIR . 'mod/article/lib/pear/Text/Diff/Renderer.php'); /** * This is a "HTML" diff renderer. class. * * This class renders a diff in "Html diff" format. * * @version $Id: unified_diff.php,v 1.1 2004/08/21 17:02:09 adarkling Exp $ * * @author Eloi George <el...@NO...> * @module Article Manager * @param int context_lines : Number of leading context "lines" to preserve. */ class Text_Diff_Renderer_html extends Text_Diff_Renderer { /** * Number of leading context "lines" to preserve. * * This should be left at zero for this class, but subclasses * may want to set this to other values. */ var $linesadded = 0; /** * Number of leading context "lines" to preserve. * * This should be left at zero for this class, but subclasses * may want to set this to other values. */ var $linesdeleted = 0; /** * Number of leading context "lines" to preserve. * * This should be left at zero for this class, but subclasses * may want to set this to other values. */ var $lineschanged = 0; function Text_Diff_Renderer_html($context_lines = 4) { $this->_leading_context_lines = $context_lines; $this->_trailing_context_lines = $context_lines; } function _blockHeader($xbeg, $xlen, $ybeg, $ylen) {} function _lines($lines, $prefix = ' ', $suffix = ' ') { foreach ($lines as $line) { echo "$prefix$line$suffix\n"; } } function _context($lines) { $this->_lines($lines, '<tr><td colspan="4">', '</td></tr>'); } function _added($lines) { $this->linesadded=$this->linesadded+count($lines); $this->_lines($lines, '<tr><td width="50%" colspan="2"> </td><td width="2%" bgcolor="white">++</td><td width="45%" bgcolor="#ebf9a4">', '</td></tr>'); } function _deleted($lines) { $this->linesdeleted=$this->linesdeleted+count($lines); $this->_lines($lines, '<tr><td width="2%" bgcolor="white">--</td><td bgcolor="#ffdbde" width="45%">', '</td><td width="50%" colspan="2"> </td></tr>'); } function _changed($orig, $final) { $orig = array_pad($orig, count($final), ' '); $final = array_pad($final, count($orig), ' '); $this->lineschanged=$this->lineschanged+count($final); while (($origLine = each($orig)) && ($finalLine = each($final))) { $this->_lines(array($origLine[1]), '<tr><td width="2%" bgcolor="white">--</td><td bgcolor="#ffdbde" width="50%">', '</td>'); $this->_lines(array($finalLine[1]), '<td width="2%" bgcolor="white">++</td><td bgcolor="#ebf9a4" width="50%">', '</td></tr>'); } } } ?> Index: ArticleManager.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/article/class/ArticleManager.php,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ArticleManager.php 18 Jun 2004 23:31:07 -0000 1.12 --- ArticleManager.php 21 Aug 2004 17:02:08 -0000 1.13 *************** *** 304,308 **** $content .= date('F d', strtotime($summary['updated_date'])) . ' <br />' . PHPWS_Text::moduleLink($summary['title'], 'article' ! ,array('view'=>$summary['id']))."\n"; } if (isset($content)) --- 304,308 ---- $content .= date('F d', strtotime($summary['updated_date'])) . ' <br />' . PHPWS_Text::moduleLink($summary['title'], 'article' ! ,array('view'=>$summary['id'])).'
'; } if (isset($content)) *************** *** 346,350 **** $content .= date('F d', strtotime($summary['updated_date'])) . ' <br />' . PHPWS_Text::moduleLink($summary['title'], 'article' ! ,array('view'=>$summary['id']))."\n"; } if (isset($content)) --- 346,350 ---- $content .= date('F d', strtotime($summary['updated_date'])) . ' <br />' . PHPWS_Text::moduleLink($summary['title'], 'article' ! ,array('view'=>$summary['id'])).'
'; } if (isset($content)) *************** *** 406,416 **** * @access public */ ! function can($action = NULL, $username = NULL) { if ($action == "edit") ! return ($_SESSION['OBJ_user']->allow_access('article', "edit_articles") || ((($this->val['users_can_submit'] && $_SESSION['OBJ_user']->isUser()) || $_SESSION['OBJ_user']->allow_access('article', "edit_own_article")) ! && $_SESSION['OBJ_user']->username==$username)); elseif ($action == "delete") --- 406,417 ---- * @access public */ ! function can($action = NULL, $username = NULL, $is_mainarticle=NULL) { if ($action == "edit") ! return (($_SESSION['OBJ_user']->allow_access('article', "edit_articles") || ((($this->val['users_can_submit'] && $_SESSION['OBJ_user']->isUser()) || $_SESSION['OBJ_user']->allow_access('article', "edit_own_article")) ! && $_SESSION['OBJ_user']->username==$username)) ! && !($this->val['need_approval'] && $is_mainarticle && !$_SESSION['OBJ_user']->allow_access('approval'))); elseif ($action == "delete") *************** *** 440,447 **** 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; --- 441,448 ---- if (isset($this->error[$type])) { ! $str = '
<span class="errortext">ERROR!<br />
'; foreach($this->error[$type] as $msg) ! $str .= $msg . '<br />
'; ! $str .= '</span>
'; unset($this->error[$type]); return $str; |