本文整理汇总了PHP中xoutput_from_array函数的典型用法代码示例。如果您正苦于以下问题:PHP xoutput_from_array函数的具体用法?PHP xoutput_from_array怎么用?PHP xoutput_from_array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xoutput_from_array函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: logout
/**
* logout
*
* This is called when you want to log out and nuke your session.
* This is the function used for the Ajax logouts, if no id is passed
* it tries to find one from the session,
*/
public static function logout($key = '', $relogin = true)
{
// If no key is passed try to find the session id
$key = $key ? $key : session_id();
// Nuke the cookie before all else
Session::destroy($key);
if (!$relogin && AmpConfig::get('logout_redirect')) {
$target = AmpConfig::get('logout_redirect');
} else {
$target = AmpConfig::get('web_path') . '/login.php';
}
// Do a quick check to see if this is an AJAXed logout request
// if so use the iframe to redirect
if (defined('AJAX_INCLUDE')) {
ob_end_clean();
ob_start();
xoutput_headers();
$results = array();
$results['rfc3514'] = '<script type="text/javascript">reloadRedirect("' . $target . '")</script>';
echo xoutput_from_array($results);
} else {
/* Redirect them to the login page */
header('Location: ' . $target);
}
exit;
}
开发者ID:axelsimon,项目名称:ampache,代码行数:33,代码来源:auth.class.php
示例2: foreach
foreach ($items as $item) {
$GLOBALS['user']->playlist->add_object($item['object_id'], $item['object_type']);
}
$results['rightbar'] = UI::ajax_include('rightbar.inc.php');
break;
case 'advanced_random':
$object_ids = Random::advanced('song', $_POST);
// First add them to the active playlist
if (is_array($object_ids)) {
foreach ($object_ids as $object_id) {
$GLOBALS['user']->playlist->add_object($object_id, 'song');
}
}
$results['rightbar'] = UI::ajax_include('rightbar.inc.php');
// Now setup the browse and show them below!
$browse = new Browse();
$browse->set_type('song');
$browse->save_objects($object_ids);
ob_start();
$browse->show_objects();
$results['browse'] = ob_get_contents();
ob_end_clean();
break;
default:
$results['rfc3514'] = '0x1';
break;
}
// switch on action;
// We always do this
echo xoutput_from_array($results);
开发者ID:cheese1,项目名称:ampache,代码行数:30,代码来源:random.ajax.php
示例3: xml_from_array
/**
* xml_from_array
* This takes a one dimensional array and creates a XML document from it. For
* use primarily by the ajax mojo.
*/
function xml_from_array($array, $callback = false, $type = '')
{
$string = '';
// If we weren't passed an array then return
if (!is_array($array)) {
return $string;
}
// The type is used for the different XML docs we pass
switch ($type) {
case 'itunes':
foreach ($array as $key => $value) {
if (is_array($value)) {
$value = xoutput_from_array($value, true, $type);
$string .= "\t\t<{$key}>\n{$value}\t\t</{$key}>\n";
} else {
if ($key == "key") {
$string .= "\t\t<{$key}>{$value}</{$key}>\n";
} elseif (is_int($value)) {
$string .= "\t\t\t<key>{$key}</key><integer>{$value}</integer>\n";
} elseif ($key == "Date Added") {
$string .= "\t\t\t<key>{$key}</key><date>{$value}</date>\n";
} elseif (is_string($value)) {
/* We need to escape the value */
$string .= "\t\t\t<key>{$key}</key><string><![CDATA[{$value}]]></string>\n";
}
}
}
// end foreach
return $string;
case 'xspf':
foreach ($array as $key => $value) {
if (is_array($value)) {
$value = xoutput_from_array($value, true, $type);
$string .= "\t\t<{$key}>\n{$value}\t\t</{$key}>\n";
} else {
if ($key == "key") {
$string .= "\t\t<{$key}>{$value}</{$key}>\n";
} elseif (is_numeric($value)) {
$string .= "\t\t\t<{$key}>{$value}</{$key}>\n";
} elseif (is_string($value)) {
/* We need to escape the value */
$string .= "\t\t\t<{$key}><![CDATA[{$value}]]></{$key}>\n";
}
}
}
// end foreach
return $string;
default:
foreach ($array as $key => $value) {
// No numeric keys
if (is_numeric($key)) {
$key = 'item';
}
if (is_array($value)) {
// Call ourself
$value = xoutput_from_array($value, true);
$string .= "\t<content div=\"{$key}\">{$value}</content>\n";
} else {
/* We need to escape the value */
$string .= "\t<content div=\"{$key}\"><![CDATA[{$value}]]></content>\n";
}
// end foreach elements
}
if (!$callback) {
$string = '<?xml version="1.0" encoding="utf-8" ?>' . "\n<root>\n" . $string . "</root>\n";
}
return UI::clean_utf8($string);
}
}
开发者ID:cheese1,项目名称:ampache,代码行数:74,代码来源:ui.lib.php
示例4: export
/**
* exports the catalog
* it exports all songs in the database to the given export type.
*/
public static function export($type, $catalog_id = '')
{
// Select all songs in catalog
$params = array();
if ($catalog_id) {
$sql = 'SELECT `id` FROM `song` ' . "WHERE `catalog`= ? " . 'ORDER BY `album`, `track`';
$params[] = $catalog_id;
} else {
$sql = 'SELECT `id` FROM `song` ORDER BY `album`, `track`';
}
$db_results = Dba::read($sql, $params);
switch ($type) {
case 'itunes':
echo xml_get_header('itunes');
while ($results = Dba::fetch_assoc($db_results)) {
$song = new Song($results['id']);
$song->format();
$xml = array();
$xml['key'] = $results['id'];
$xml['dict']['Track ID'] = intval($results['id']);
$xml['dict']['Name'] = $song->title;
$xml['dict']['Artist'] = $song->f_artist_full;
$xml['dict']['Album'] = $song->f_album_full;
$xml['dict']['Total Time'] = intval($song->time) * 1000;
// iTunes uses milliseconds
$xml['dict']['Track Number'] = intval($song->track);
$xml['dict']['Year'] = intval($song->year);
$xml['dict']['Date Added'] = date("Y-m-d\\TH:i:s\\Z", $song->addition_time);
$xml['dict']['Bit Rate'] = intval($song->bitrate / 1000);
$xml['dict']['Sample Rate'] = intval($song->rate);
$xml['dict']['Play Count'] = intval($song->played);
$xml['dict']['Track Type'] = "URL";
$xml['dict']['Location'] = Song::play_url($song->id);
echo xoutput_from_array($xml, 1, 'itunes');
// flush output buffer
}
// while result
echo xml_get_footer('itunes');
break;
case 'csv':
echo "ID,Title,Artist,Album,Length,Track,Year,Date Added,Bitrate,Played,File\n";
while ($results = Dba::fetch_assoc($db_results)) {
$song = new Song($results['id']);
$song->format();
echo '"' . $song->id . '","' . $song->title . '","' . $song->f_artist_full . '","' . $song->f_album_full . '","' . $song->f_time . '","' . $song->f_track . '","' . $song->year . '","' . date("Y-m-d\\TH:i:s\\Z", $song->addition_time) . '","' . $song->f_bitrate . '","' . $song->played . '","' . $song->file . "\n";
}
break;
}
// end switch
}
开发者ID:axelsimon,项目名称:ampache,代码行数:54,代码来源:catalog.class.php
注:本文中的xoutput_from_array函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论