[Pkg-owncloud-commits] [owncloud] 171/394: Clean KB entries processing code
David Prévot
taffit at alioth.debian.org
Fri Nov 8 23:11:56 UTC 2013
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to annotated tag v4.5.10
in repository owncloud.
commit c840a688ab2189779e7969b23996a1c22aaefdf5
Author: Victor Dubiniuk <victor.dubiniuk at gmail.com>
Date: Sat Nov 24 20:28:19 2012 +0300
Clean KB entries processing code
---
lib/ocsclient.php | 67 ++++++++++++++++++++++++-----------------------------
1 file changed, 30 insertions(+), 37 deletions(-)
diff --git a/lib/ocsclient.php b/lib/ocsclient.php
index 794bc97..88c4ddd 100644
--- a/lib/ocsclient.php
+++ b/lib/ocsclient.php
@@ -222,43 +222,36 @@ class OC_OCSClient{
*
* This function returns a list of all the knowledgebase entries from the OCS server
*/
- public static function getKnownledgebaseEntries($page,$pagesize,$search='') {
- if(OC_Config::getValue('knowledgebaseenabled', true)==false) {
- $kbe=array();
- $kbe['totalitems']=0;
- return $kbe;
+ public static function getKnownledgebaseEntries($page, $pagesize, $search='') {
+ $kbe = array('totalitems' => 0);
+ if(OC_Config::getValue('knowledgebaseenabled', true)) {
+ $p = (int) $page;
+ $s = (int) $pagesize;
+ $searchcmd = '';
+ if ($search) {
+ $searchcmd = '&search='.urlencode($search);
+ }
+ $url = OC_OCSClient::getKBURL().'/knowledgebase/data?type=150&page='. $p .'&pagesize='. $s . $searchcmd;
+ $xml = OC_OCSClient::getOCSresponse($url);
+ $data = @simplexml_load_string($xml);
+ if($data===false) {
+ OC_Log::write('core', 'Unable to parse knowledgebase content', OC_Log::FATAL);
+ return null;
+ }
+ $tmp = $data->data->content;
+ for($i = 0; $i < count($tmp); $i++) {
+ $kbe[] = array(
+ 'id' => $tmp[$i]->id,
+ 'name' => $tmp[$i]->name,
+ 'description' => $tmp[$i]->description,
+ 'answer' => $tmp[$i]->answer,
+ 'preview1' => $tmp[$i]->smallpreviewpic1,
+ 'detailpage' => $tmp[$i]->detailpage
+ );
+ }
+ $kbe['totalitems'] = $data->meta->totalitems;
}
-
- $p= (int) $page;
- $s= (int) $pagesize;
- if($search<>'') $searchcmd='&search='.urlencode($search); else $searchcmd='';
- $url=OC_OCSClient::getKBURL().'/knowledgebase/data?type=150&page='.$p.'&pagesize='.$s.$searchcmd;
-
- $kbe=array();
- $xml=OC_OCSClient::getOCSresponse($url);
-
- if($xml==FALSE) {
- OC_Log::write('core','Unable to parse knowledgebase content',OC_Log::FATAL);
- return NULL;
- }
- $data=simplexml_load_string($xml);
-
- $tmp=$data->data->content;
- for($i = 0; $i < count($tmp); $i++) {
- $kb=array();
- $kb['id']=$tmp[$i]->id;
- $kb['name']=$tmp[$i]->name;
- $kb['description']=$tmp[$i]->description;
- $kb['answer']=$tmp[$i]->answer;
- $kb['preview1']=$tmp[$i]->smallpreviewpic1;
- $kb['detailpage']=$tmp[$i]->detailpage;
- $kbe[]=$kb;
- }
- $total=$data->meta->totalitems;
- $kbe['totalitems']=$total;
- return $kbe;
+ return $kbe;
}
-
-
-}
+}
\ No newline at end of file
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list