Exemple #1
0
 /**
  * @brief Get all the knowledgebase entries from the OCS server
  * @returns array with q and a data
  *
  * 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;
     }
     $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;
 }
Exemple #2
0
 /**
  * Get the download url for an application from the OCS server
  * @return array|null an array of application data or null
  *
  * This function returns an download url for an applications from the OCS server
  * @param string $id
  * @param integer $item
  * @param array $targetVersion The target ownCloud version
  */
 public static function getApplicationDownload($id, $item, array $targetVersion)
 {
     if (OC_Config::getValue('appstoreenabled', true) == false) {
         return null;
     }
     $url = OC_OCSClient::getAppStoreURL() . '/content/download/' . urlencode($id) . '/' . urlencode($item);
     $url .= '?version=' . implode('x', $targetVersion);
     $xml = OC_OCSClient::getOCSresponse($url);
     if ($xml == false) {
         OC_Log::write('core', 'Unable to parse OCS content', OC_Log::FATAL);
         return null;
     }
     $loadEntities = libxml_disable_entity_loader(true);
     $data = simplexml_load_string($xml);
     libxml_disable_entity_loader($loadEntities);
     $tmp = $data->data->content;
     $app = array();
     if (isset($tmp->downloadlink)) {
         $app['downloadlink'] = $tmp->downloadlink;
     } else {
         $app['downloadlink'] = '';
     }
     return $app;
 }
Exemple #3
0
 /**
  * @brief Get all the knowledgebase entries from the OCS server
  * @returns array with q and a data
  *
  * This function returns a list of all the knowledgebase entries from the OCS server
  */
 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;
     }
     return $kbe;
 }