plugins/Newsboy.php
changeset 5 fed61fc8895b
parent 4 bf5589120afb
child 6 432eed804b7f
equal deleted inserted replaced
4:bf5589120afb 5:fed61fc8895b
   235 
   235 
   236 function NewsBoy_portal()
   236 function NewsBoy_portal()
   237 {
   237 {
   238   global $db, $session, $paths, $template, $plugins; // Common objects
   238   global $db, $session, $paths, $template, $plugins; // Common objects
   239   
   239   
   240   $news_template = <<<TPLCODE
   240   if ( file_exists( ENANO_ROOT . "/themes/{$template->theme}/newsboy-post.tpl" ) )
   241   <div class="tblholder news">
   241   {
   242     <table border="0" cellspacing="1" cellpadding="4" style="width: 100%;">
   242     $parser = $template->makeParser("newsboy-post.tpl");
   243       <tr>
   243   }
   244         <th><a href="{LINK}" style="color: inherit;">{TITLE}</a></th>
   244   else
   245       </tr>
   245   {
   246       <tr>
   246     $news_template = <<<TPLCODE
   247         <td class="row3">
   247     <div class="tblholder news">
   248           {CONTENT}
   248       <table border="0" cellspacing="1" cellpadding="4" style="width: 100%;">
   249         </td>
   249         <tr>
   250       </tr>
   250           <th><a href="{LINK}" style="color: inherit;">{TITLE}</a></th>
   251       <tr>
   251         </tr>
   252         <th class="subhead" style="font-weight: normal; font-size: 67%;">
   252         <tr>
   253           Posted by {USER_LINK} on {DATE}<br />
   253           <td class="row3">
   254           [ {NUM_COMMENTS} comment{COMMENT_S} | {COMMENT_LINK} ]
   254             {CONTENT}
   255         </th>
   255           </td>
   256       </tr>
   256         </tr>
   257     </table>
   257         <tr>
   258   </div>
   258           <th class="subhead" style="font-weight: normal; font-size: 67%;">
       
   259             Posted by {USER_LINK} on {DATE}<br />
       
   260             [ {NUM_COMMENTS} comment{COMMENT_S} | {COMMENT_LINK} ]
       
   261           </th>
       
   262         </tr>
       
   263       </table>
       
   264     </div>
   259 TPLCODE;
   265 TPLCODE;
       
   266   
       
   267     $parser = $template->makeParserText($news_template);
       
   268   }
   260   
   269   
   261   /*
   270   /*
   262   $p = RenderMan::strToPageID(getConfig('main_page'));
   271   $p = RenderMan::strToPageID(getConfig('main_page'));
   263   if ( $p[1] != 'NewsBoy' )
   272   if ( $p[1] != 'NewsBoy' )
   264   {
   273   {
   294     $content = $page->fetch_text();
   303     $content = $page->fetch_text();
   295     $content = '?>' . RenderMan::render($content);
   304     $content = '?>' . RenderMan::render($content);
   296     eval($content);
   305     eval($content);
   297   }
   306   }
   298   
   307   
   299   echo '<h2>Latest news</h2>';
   308   if ( file_exists( ENANO_ROOT . "/themes/{$template->theme}/newsboy-portal-pre.tpl" ) )
       
   309   {
       
   310     $parser_pre = $template->makeParser("newsboy-portal-pre.tpl");
       
   311     echo $parser_pre->run();
       
   312   }
       
   313   else
       
   314   {
       
   315     echo '<h2>Latest news</h2>';
       
   316   }
   300     
   317     
   301   $q = $db->sql_unbuffered_query('SELECT p.*, COUNT(c.comment_id) AS num_comments, t.page_text, l.time_id, l.author, u.user_level FROM '.table_prefix.'pages AS p
   318   $q = $db->sql_unbuffered_query('SELECT p.*, COUNT(c.comment_id) AS num_comments, t.page_text, l.time_id, l.author, u.user_level FROM '.table_prefix.'pages AS p
   302          LEFT JOIN '.table_prefix.'comments AS c
   319          LEFT JOIN '.table_prefix.'comments AS c
   303            ON ( c.page_id=p.urlname AND c.namespace=p.namespace )
   320            ON ( c.page_id=p.urlname AND c.namespace=p.namespace )
   304          LEFT JOIN '.table_prefix.'page_text AS t
   321          LEFT JOIN '.table_prefix.'page_text AS t
   317     $db->_die();
   334     $db->_die();
   318   
   335   
   319   if ( $row = $db->fetchrow() )
   336   if ( $row = $db->fetchrow() )
   320   {
   337   {
   321     $i = 0;
   338     $i = 0;
   322     $parser = $template->makeParserText($news_template);
       
   323     do
   339     do
   324     {
   340     {
   325       if ( $i < 5 )
   341       if ( $i < 5 )
   326       {
   342       {
   327         $content = $row['page_text'];
   343         $content = $row['page_text'];
   376   }
   392   }
   377   else
   393   else
   378   {
   394   {
   379     echo '<p>No news items yet.</p>';
   395     echo '<p>No news items yet.</p>';
   380   }
   396   }
       
   397   if ( file_exists( ENANO_ROOT . "/themes/{$template->theme}/newsboy-portal-post.tpl" ) )
       
   398   {
       
   399     $parser_post = $template->makeParser("newsboy-portal-post.tpl");
       
   400     echo $parser_post->run();
       
   401   }
       
   402   
   381   if ( $session->user_level >= USER_LEVEL_ADMIN )
   403   if ( $session->user_level >= USER_LEVEL_ADMIN )
   382   {
   404   {
   383     echo '<div class="tblholder" style="margin: 10px auto 0 auto; display: table;">
   405     echo '<div class="tblholder" style="margin: 10px auto 0 auto; display: table;">
   384             <table border="0" cellspacing="1" cellpadding="4">
   406             <table border="0" cellspacing="1" cellpadding="4">
   385               <tr>
   407               <tr>