make the help section working and pretty. knowledge base entries are fetched via OCS from a different server. cool stuff

This commit is contained in:
Frank Karlitschek 2011-08-17 00:24:50 +02:00
parent 9f28c20660
commit cb9fc6d901
5 changed files with 38 additions and 19 deletions

View File

@ -1,12 +1,12 @@
<center> <center>
<table class="pager" cellspacing="0" cellpadding="0" border="0"> <table class="pager" cellspacing="0" cellpadding="0" border="0">
<tr> <tr><td width="50%"></td>
<td width="1"> <td width="1">
<?php if($_['page']>0):?> <?php if($_['page']>0):?>
<span class="pagerbutton1"><a href="<?php echo $_['url'].($_['page']-1);?>"><?php echo $l->t( 'prev' ); ?></a>&nbsp;&nbsp;</span> <span class="pagerbutton1"><a href="<?php echo $_['url'].($_['page']-1);?>"><?php echo $l->t( 'prev' ); ?></a>&nbsp;&nbsp;</span>
<?php endif; ?> <?php endif; ?>
</td> </td>
<td> <td width="1">
<?php if ($_['pagestart']>0):?> <?php if ($_['pagestart']>0):?>
... ...
<?php endif;?> <?php endif;?>
@ -26,6 +26,6 @@
<span class="pagerbutton2"><a href="<?php echo $_['url'].($_['page']+1);?>"><?php echo $l->t( 'next' ); ?></a></span> <span class="pagerbutton2"><a href="<?php echo $_['url'].($_['page']+1);?>"><?php echo $l->t( 'next' ); ?></a></span>
<?php endif; ?> <?php endif; ?>
</td> </td>
</tr> <td width="50%"></td></tr>
</table> </table>
</center> </center>

View File

@ -134,8 +134,10 @@ class OC_OCSClient{
* *
* This function returns a list of all the knowledgebase entries from the OCS server * This function returns a list of all the knowledgebase entries from the OCS server
*/ */
public static function getKnownledgebaseEntries(){ public static function getKnownledgebaseEntries($page,$pagesize){
$url='http://api.apps.owncloud.com/v1/knowledgebase/data?type=150&page=0&pagesize=10'; $p= (int) $page;
$s= (int) $pagesize;
$url='http://api.apps.owncloud.com/v1/knowledgebase/data?type=150&page='.$p.'&pagesize='.$s;
$kbe=array(); $kbe=array();
$xml=@file_get_contents($url); $xml=@file_get_contents($url);
@ -152,8 +154,11 @@ class OC_OCSClient{
$kb['description']=$tmp[$i]->description; $kb['description']=$tmp[$i]->description;
$kb['answer']=$tmp[$i]->answer; $kb['answer']=$tmp[$i]->answer;
$kb['preview1']=$tmp[$i]->smallpreviewpic1; $kb['preview1']=$tmp[$i]->smallpreviewpic1;
$kb['detailpage']=$tmp[$i]->detailpage;
$kbe[]=$kb; $kbe[]=$kb;
} }
$total=$data->meta->totalitems;
$kbe['totalitems']=$total;
return $kbe; return $kbe;
} }

View File

@ -29,4 +29,17 @@ span.version{margin-left:3em;color:#ddd}
/* HELP */ /* HELP */
table#help tr td { white-space:normal; }
table.help { border-spacing:1em; }
table.help tr td { white-space:normal; }
a.newquestion { font-size:1em; width:10em; margin:1.5em; padding:.6em .5em .4em; background:#fff; color:#333; border:1px solid #ddd; -moz-box-shadow:0 1px 1px #fff, 0 2px 0 #bbb inset; -webkit-box-shadow:0 1px 1px #fff, 0 1px 0 #bbb inset; box-shadow:0 1px 1px #fff, 0 1px 0 #bbb inset; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em; }
a.newquestion:hover { background:#ddd; }
td.entry { padding:1em; margin:2em; border:1px solid #ddd; -moz-box-shadow:0 1px 1px #fff, 0 2px 0 #bbb inset; -webkit-box-shadow:0 1px 1px #fff, 0 1px 0 #bbb inset; box-shadow:0 1px 1px #fff, 0 1px 0 #bbb inset; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em; }
td.entry:hover { background:#eee; }
tr.entryrow:hover { background:#fff; }
tr.pager:hover { background:#fff; }

View File

@ -6,17 +6,17 @@ if( !OC_User::isLoggedIn()){
exit(); exit();
} }
//hardcode for testing
$pagecount=8;
$page=2;
// Load the files we need // Load the files we need
OC_Util::addStyle( "settings", "settings" ); OC_Util::addStyle( "settings", "settings" );
OC_App::setActiveNavigationEntry( "help" ); OC_App::setActiveNavigationEntry( "help" );
$kbe=OC_OCSClient::getKnownledgebaseEntries(); $pagesize=5;
if(isset($_GET['page'])) $page=$_GET['page']; else $page=0;
$kbe=OC_OCSClient::getKnownledgebaseEntries($page,$pagesize);
$totalitems=$kbe['totalitems'];
unset($kbe['totalitems']);
$pagecount=ceil($totalitems/$pagesize);
$tmpl = new OC_Template( "settings", "help", "user" ); $tmpl = new OC_Template( "settings", "help", "user" );
$tmpl->assign( "kbe", $kbe ); $tmpl->assign( "kbe", $kbe );

View File

@ -1,14 +1,15 @@
<?php if(is_null($_["kbe"])):?> <?php if(is_null($_["kbe"])):?>
Can't connect to Q&amp;A database Can't connect to Q&amp;A database
<?php else:?> <?php else:?>
<table id="help" cellspacing="20"> <table class="help">
<tbody> <tbody>
<?php foreach($_["kbe"] as $kb): ?> <?php foreach($_["kbe"] as $kb): ?>
<tr> <tr class="entryrow">
<td width="1"><?php if($kb["preview1"] <> "") { echo('<img class="preview" border="0" src="'.$kb["preview1"].'" />'); } ?> </a></td> <td width="1"><?php if($kb["preview1"] <> "") { echo('<img class="preview" border="0" src="'.$kb["preview1"].'" />'); } ?> </a></td>
<td class="name"><p><strong><?php echo $kb["name"]; ?></strong></p><?php echo('<span class="type">'.$kb['description'].'</span>'); ?> <td class="entry"><p><strong><?php echo $kb["name"]; ?></strong></p><?php echo('<span class="type">'.$kb['description'].'</span>'); ?>
<?php if($kb['answer']<>'') echo('<br /><span class="type"><b>Answer:</b></span><br /><span class="type">'.$kb['answer'].'</span>');?> <?php if($kb['answer']<>'') echo('<br /><span class="type"><b>Answer:</b></span><br /><span class="type">'.$kb['answer'].'</span>');?>
</td> <?php if($kb['detailpage']<>'') echo('<br /><a target="_blank" href="'.$kb['detailpage'].'"><b>read more</b></a>')?>
<br /></td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
@ -18,7 +19,7 @@
$pageNavi=OC_Util::getPageNavi($_['pagecount'],$_['page'],$url); $pageNavi=OC_Util::getPageNavi($_['pagecount'],$_['page'],$url);
$pageNavi->printPage(); $pageNavi->printPage();
?> ?>
<a target="_blank" class="prettybutton" href="http://apps.owncloud.com/knowledgebase/editquestion.php?action=new"><?php echo $l->t( 'Ask a question' ); ?></a> <br /><a target="_blank" class="newquestion" href="http://apps.owncloud.com/knowledgebase/editquestion.php?action=new"><?php echo $l->t( 'Ask a question' ); ?></a>
<?php endif;?> <?php endif;?>