protected function Build() { $DiscussionModel = new DiscussionModel(); $Offset = 0; $Limit = 1000; while ($Discussions = $DiscussionModel->Get($Offset, $Limit)) { if (!$Discussions->NumRows()) break; $Offset += $Discussions->NumRows(); $Day = 24*3600; $Week = 7*$Day; $Month = 4*$Week; $Year = 12*$Month; $PriorityMatrix = array( 'hourly' => 1, 'daily' => 0.8, 'weekly' => 0.6, 'monthly' => 0.4, 'yearly' => 0.2 ); while ($Discussion = $Discussions->NextRow()) { $ChangeFreq = 'hourly'; $DiffDate = time() - strtotime($Discussion->DateLastComment); $Priority = 1; if ($DiffDate < $Day) $ChangeFreq = 'hourly'; elseif ($DiffDate < $Week) $ChangeFreq = 'daily'; elseif ($DiffDate < $Month) $ChangeFreq = 'weekly'; elseif ($DiffDate < $Year) $ChangeFreq = 'monthly'; else $ChangeFreq = 'yearly'; $this->MapItem( DiscussionLink($Discussion, FALSE), date('Y-m-d', strtotime($Discussion->DateLastComment)), $ChangeFreq, $PriorityMatrix[$ChangeFreq] ); } } $this->WriteIndex(); }
function WriteTable($Results, $WriteText, $CssClass) { $String = ''; $Total = sizeof($Results); if ($Total == 0) { return $String; //return an empty string if no results } $Count = 0; //for toggling the message div if text ob_start(); ?> <div class="SphinxSearch Table"> <table> <thead> <tr> <th class="Title">Discussion</th> <th class="Starter">Starter</th> <th class="Forum">Forum</th> <th class="InfoCount">R / V</th> <th class="Latest">Latest</th> </tr> </thead> <tbody> <?php foreach ($Results as $Row) { ?> <?php $ID = 'T_' . $Count++; //unique identifer $OAuthor->Name = $Row->UserName; $OAuthor->UserID = $Row->UserID; //original author $LAuthor->Name = $Row->LastUserName; $LAuthor->UserID = $Row->LastUserID; //latest author $Row->CountCommentWatch = $Row->CountComments; //for discussion link $TitleURL = $Row->IsComment ? 'discussion/comment/' . $Row->CommentID . '/#Comment_' . $Row->CommentID : DiscussionLink($Row, FALSE); //if the comment is from the orignal discussion poster, simply link to the front page of that ?> <tr <?php echo Alternate(); ?> > <td class="Title"> <?php if ($WriteText) { ?> <span id="<?php echo $ID; ?> " class="PlusImage Toggle"></span> <?php } ?> <span class="Title"><?php echo Anchor($Row->Title . Wrap(htmlspecialchars(SliceString($Row->DiscussionBody, SS_PREVIEW_BODY_LIMIT)), 'span', array('class' => 'ToolTip')), $TitleURL, FALSE, array('class' => 'HasToolTip')); ?> </span> </td> <td class="Starter"> <?php echo UserAnchor($OAuthor); ?> <?php Anchor(Gdn_Format::Date($Row->DateInserted), $TitleURL); ?> </td> <td class="Forum"> <?php echo Anchor(Gdn_Format::Text($Row->CatName), 'categories/' . $Row->CatUrlCode); ?> </td> <td class="InfoCount"> <?php echo Gdn_Format::BigNumber($Row->CountComments); ?> / <?php echo Gdn_Format::BigNumber($Row->CountViews); ?> </td> <td class="Latest"> <?php echo UserAnchor($LAuthor) . ' on '; echo Anchor(Gdn_Format::Date($Row->DateInserted), DiscussionLink($Row, $Extended = TRUE)); ?> </td> </tr> <?php if ($WriteText) { ?> <tr id="<?php echo $ID . 'T'; ?> " style="display: none" class="ExpandText"> <td colspan="5"> <!-- Need this since this column will expand the width of the table !--> <div class="Message Excerpt"> <?php echo nl2br(SliceString($Row->Body, SS_BODY_LIMIT)); ?> </div> </td> </tr> <?php } ?> <?php } ?> </tbody> </table> <div style="clear: both"></div> </div> <?php $String = ob_get_contents(); @ob_end_clean(); return $String; }
function WriteClassic($Results, $WriteText, $CssClass) { if (sizeof($Results) == 0) { //make sure there is something here return ''; } ob_start(); ?> <div class="SphinxSearch"> <ul class="DataList"> <?php foreach ($Results as $Row) { ?> <?php $Author->Photo = $Row->UserPhoto; $Author->Name = $Row->UserName; $Author->UserID = $Row->UserID; $TitleURL = $Row->IsComment ? 'discussion/comment/' . $Row->CommentID . '/#Comment_' . $Row->CommentID : DiscussionLink($Row, FALSE); //if the comment is from the orignal discussion poster, simply link to the front page of that ?> <li class="Item"> <div class="ItemContent"> <h4 class="Title"><?php echo Anchor($Row->Title, $TitleURL, FALSE, array('class' => 'HasToolTip')); ?> </h4> <?php if ($WriteText) { ?> <div class="Message Excerpt"> <?php //echo nl2br(SliceString($Row->Body, SS_BODY_LIMIT)); This seemed to make MARKDOWN posts look correct - JJB ?> <?php echo SliceString($Row->Body, SS_BODY_LIMIT); ?> </div> <?php } ?> <div class="Meta"> <span class="MItem"><?php echo UserPhoto($Author, array('LinkClass' => '', 'ImageClass' => 'ProfilePhotoSmall PhotoWrap')); ?> </span> <span class="MItem"><?php echo Anchor($Row->UserName, UserUrl($Author)); ?> </span> <span class="MItem"><?php echo Anchor(Gdn_Format::Date($Row->DateInserted), 'discussion/' . $Row->DiscussionID . '/' . Gdn_Format::Url($Row->Title) . '/p1'); ?> </span> <span class="MItem"><?php echo Anchor($Row->CatName, 'discussion/' . $Row->DiscussionID . '/' . Gdn_Format::Url($Row->Title) . '/p1'); ?> </span> </div> </div> </li> <?php } ?> </ul> </div> <?php $String = ob_get_contents(); @ob_end_clean(); return $String; }