本文整理汇总了PHP中utility::xml2arr方法的典型用法代码示例。如果您正苦于以下问题:PHP utility::xml2arr方法的具体用法?PHP utility::xml2arr怎么用?PHP utility::xml2arr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utility
的用法示例。
在下文中一共展示了utility::xml2arr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAvailablePackages
/**
* Get all available update packages
*
* @access public
* @return array
*/
public static function getAvailablePackages()
{
global $lC_Api;
$result = array('entries' => array());
$api_version = defined('API_VERSION') && API_VERSION != NULL ? API_VERSION : '1_0';
$request_type = getRequestType();
$versions = transport::getResponse(array('url' => $request_type . '://api.loadedcommerce.com/' . $api_version . '/updates/available/?ref=' . $_SERVER['SCRIPT_FILENAME'], 'method' => 'get', 'timeout' => 10));
$versions_array = utility::xml2arr($versions);
$counter = 0;
foreach ($versions_array['data'] as $l => $v) {
if (version_compare(utility::getVersion(), $v['version'], '<')) {
$result['entries'][] = array('key' => $counter, 'version' => $v['version'], 'date' => lC_DateTime::getShort(lC_DateTime::fromUnixTimestamp(lC_DateTime::getTimestamp($v['dateCreated'], 'Ymd'))), 'announcement' => $v['newsLink'], 'update_package' => isset($v['pharLink']) ? $v['pharLink'] . '?ref=' . urlencode($_SERVER['SCRIPT_FILENAME']) : null);
$counter++;
}
}
@usort($result['entries'], function ($a, $b) {
return version_compare($a['version'], $b['version'], '>');
});
$result['total'] = count($result['entries']);
return $result;
}
示例2: apiCheck
public static function apiCheck()
{
$api_version = defined('API_VERSION') && API_VERSION != NULL ? API_VERSION : '1_0';
$request_type = getRequestType();
$apiCheck = transport::getResponse(array('url' => $request_type . '://api.loadedcommerce.com/' . $api_version . '/updates/available/?ver=' . utility::getVersion() . '&ref=' . $_SERVER['SCRIPT_FILENAME'], 'method' => 'get', 'timeout' => 10));
$versions = utility::xml2arr($apiCheck);
$error = false;
if (count($versions) == 0) {
// there was an error with the api
$error = true;
$errorMsg = preg_match("'<title[^>]*?>.*?</title>'si", $versions, $regs);
$errorMsg = is_array($regs) ? strip_tags(end($regs)) : NULL;
if ($errorMsg == '') {
$errorMsg = 'Resource Unavailable at ' . $request_type . '://api.loadedcommerce.com/' . $api_version . '/updates/available/?ver=' . utility::getVersion() . '&ref=' . $_SERVER['SCRIPT_FILENAME'];
}
$error = true;
// log the error
self::log('Error: ' . $errorMsg);
}
if ($versions == null || $error) {
// set the error flag
return -1;
}
return 1;
}
示例3: getAvailbleAddons
public static function getAvailbleAddons()
{
$installed = self::getInstalledAddons();
$request = array('storeName' => STORE_NAME, 'storeWWW' => HTTP_SERVER . DIR_WS_HTTP_CATALOG, 'storeSSL' => HTTPS_SERVER . DIR_WS_HTTPS_CATALOG);
$checksum = hash('sha256', json_encode($request));
$request['checksum'] = $checksum;
$request['instID'] = INSTALLATION_ID;
$request_type = getRequestType();
$api_version = defined('API_VERSION') && API_VERSION != NULL ? API_VERSION : '1_0';
$resultXML = transport::getResponse(array('url' => $request_type . '://api.loadedcommerce.com/' . $api_version . '/store/addons/?ref=' . $_SERVER['SCRIPT_FILENAME'], 'method' => 'post', 'parameters' => $request, 'timeout' => 10));
$available = utility::xml2arr($resultXML);
$addons = array();
$codeArr = array();
foreach ($installed as $key => $val) {
$codeArr[$val['code']] = true;
$addons[] = array('name' => $val['name'], 'code' => $val['code'], 'type' => $val['type'], 'title' => $val['title'], 'description' => $val['description'], 'rating' => $val['rating'], 'author' => $val['author'], 'authorWWW' => $val['authorWWW'], 'thumbnail' => $val['thumbnail'], 'version' => $val['version'], 'compatibility' => $val['compatibility'], 'installed' => $val['installed'], 'mobile' => $val['mobile'], 'enabled' => $val['enabled'], 'from_store' => false, 'featured' => false, 'featured_in_group' => false);
}
foreach ($available['data'] as $key => $val) {
if (array_key_exists($val['code'], $codeArr)) {
continue;
}
$addons[] = array('name' => $val['code'] . '/controller.php', 'code' => $val['code'], 'type' => $val['type'], 'title' => self::_decodeText($val['title']), 'description' => self::_decodeText($val['description']), 'rating' => $val['rating'], 'author' => $val['author'], 'authorWWW' => $val['authorWWW'], 'thumbnail' => $val['thumbnail'], 'version' => $val['version'], 'compatibility' => $val['compatibility'], 'installed' => $val['installed'], 'mobile' => $val['mobile'], 'enabled' => $val['enabled'], 'from_store' => true, 'featured' => $val['featured'], 'featured_in_group' => $val['featured_in_group']);
}
return $addons;
}