本文整理汇总了PHP中AmpConfig类的典型用法代码示例。如果您正苦于以下问题:PHP AmpConfig类的具体用法?PHP AmpConfig怎么用?PHP AmpConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AmpConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: call_url
/**
* call_url
* This is a generic caller for HTTP requests
* It need the method (GET/POST), the url and the parameters
*/
public function call_url($url, $method = 'GET', $vars = null)
{
// Encode parameters per RFC1738
$params = http_build_query($vars);
$opts = array('http' => array('method' => $method, 'header' => array('Host: ' . $this->host, 'User-Agent: Ampache/' . AmpConfig::get('version'))));
// POST request need parameters in body and additional headers
if ($method == 'POST') {
$opts['http']['content'] = $params;
$opts['http']['header'][] = 'Content-type: application/x-www-form-urlencoded';
$opts['http']['header'][] = 'Content-length: ' . strlen($params);
$params = '';
}
$context = stream_context_create($opts);
if ($params != '') {
// If there are paramters for GET request, adding the "?" caracter before
$params = '?' . $params;
}
//debug_event('SCROBBLER', "$this->scheme://$this->host$url$params", 5);
//debug_event('SCROBBLER', serialize($opts), 5);
$fp = fopen("{$this->scheme}://{$this->host}{$url}{$params}", 'r', false, $context);
if (!$fp) {
return false;
}
ob_start();
fpassthru($fp);
$buffer = ob_get_contents();
ob_end_clean();
fclose($fp);
//debug_event('SCROBBLER', $buffer, 5);
return $buffer;
}
示例2: getName
public function getName()
{
if ($this->catalog_id > 0) {
$catalog = Catalog::create_from_id($this->catalog_id);
return $catalog->name;
}
return AmpConfig::get('site_title');
}
示例3: format
/**
* format
* This format the string url according to settings.
*/
public static function format($url)
{
if (AmpConfig::get('stream_beautiful_url')) {
$url = str_replace('index.php?&', '', $url);
$url = str_replace('index.php?', '', $url);
$url = str_replace('&', '/', $url);
$url = str_replace('=', '/', $url);
}
return $url;
}
示例4: display_home
/**
* display_home
* This display the module in home page
*/
public function display_home()
{
if (@is_readable(AmpConfig::get('prefix') . '/config/motd.php')) {
echo '<div id="motd">';
UI::show_box_top(T_('Message of the Day'));
require_once AmpConfig::get('prefix') . '/config/motd.php';
UI::show_box_bottom();
echo '</div>';
}
}
示例5: install
/**
* install
* This is a required plugin function. It inserts our preferences
* into Ampache
*/
public function install()
{
// Check and see if it's already installed
if (Preference::exists('piwik_site_id')) {
return false;
}
Preference::insert('piwik_site_id', 'Piwik Site ID', '1', 100, 'string', 'plugins', 'piwik');
Preference::insert('piwik_url', 'Piwik URL', AmpConfig::get('web_path') . '/piwik/', 100, 'string', 'plugins', $this->name);
return true;
}
示例6: display_home
/**
* display_home
* This display the module in home page
*/
public function display_home()
{
if (AmpConfig::get('sociable')) {
echo "<div id='shout_objects'>\n";
$shouts = Shoutbox::get_top($this->maxitems);
if (count($shouts)) {
require_once AmpConfig::get('prefix') . UI::find_template('show_shoutbox.inc.php');
}
echo "</div>\n";
}
}
示例7: load_gettext
/**
* load_gettext
* Sets up our local gettext settings.
*
* @return void
*/
function load_gettext()
{
$lang = AmpConfig::get('lang');
$popath = AmpConfig::get('prefix') . '/locale/' . $lang . '/LC_MESSAGES/messages.po';
$t = new Translator();
if (file_exists($popath)) {
$translations = Gettext\Translations::fromPoFile($popath);
$t->loadTranslations($translations);
}
$t->register();
}
示例8: get_policies
public static function get_policies()
{
$openid_required_pape = AmpConfig::get('openid_required_pape');
$policies = array();
if (!empty($openid_required_pape)) {
$papes = explode(',', $openid_required_pape);
foreach ($papes as $pape) {
$policies[] = constant($pape);
}
}
return $policies;
}
示例9: get_plugins
/**
* get_plugins
* This returns an array of plugin names
*/
public static function get_plugins($type = '')
{
// make static cache for optimization when multiple call
static $plugins_list = array();
if (isset($plugins_list[$type])) {
return $plugins_list[$type];
}
$plugins_list[$type] = array();
// Open up the plugin dir
$basedir = AmpConfig::get('prefix') . '/modules/plugins';
$handle = opendir($basedir);
if (!is_resource($handle)) {
debug_event('Plugins', 'Unable to read plugins directory', '1');
}
// Recurse the directory
while (false !== ($file = readdir($handle))) {
if ($file === '.' || $file === '..') {
continue;
}
// Take care of directories only
if (!is_dir($basedir . '/' . $file)) {
debug_event('Plugins', $file . ' is not a directory.', 3);
continue;
}
// Make sure the plugin base file exists inside the plugin directory
if (!file_exists($basedir . '/' . $file . '/' . $file . '.plugin.php')) {
debug_event('Plugins', 'Missing class for ' . $file, 3);
continue;
}
if ($type != '') {
$plugin = new Plugin($file);
if (!Plugin::is_installed($plugin->_plugin->name)) {
debug_event('Plugins', 'Plugin ' . $plugin->_plugin->name . ' is not installed, skipping', 6);
continue;
}
if (!$plugin->is_valid()) {
debug_event('Plugins', 'Plugin ' . $file . ' is not valid, skipping', 6);
continue;
}
if (!method_exists($plugin->_plugin, $type)) {
debug_event('Plugins', 'Plugin ' . $file . ' does not support ' . $type . ', skipping', 6);
continue;
}
}
// It's a plugin record it
$plugins_list[$type][$file] = $file;
}
// end while
// Little stupid but hey
ksort($plugins_list[$type]);
return $plugins_list[$type];
}
示例10: load_gettext
/**
* load_gettext
* Sets up our local gettext settings.
*
* @return void
*/
function load_gettext()
{
$lang = AmpConfig::get('lang');
$charset = AmpConfig::get('site_charset') ?: 'UTF-8';
$locale = $lang . '.' . $charset;
//debug_event('i18n', 'Setting locale to ' . $locale, 5);
T_setlocale(LC_MESSAGES, $locale);
/* Bind the Text Domain */
T_bindtextdomain('messages', AmpConfig::get('prefix') . "/locale/");
T_bind_textdomain_codeset('messages', $charset);
T_textdomain('messages');
//debug_event('i18n', 'gettext is ' . (locale_emulation() ? 'emulated' : 'native'), 5);
}
示例11: show_agreement
/**
* show_agreement
* This shows the registration agreement, /config/registration_agreement.php
*/
public static function show_agreement()
{
$filename = AmpConfig::get('prefix') . '/config/registration_agreement.php';
if (!file_exists($filename)) {
return false;
}
/* Check for existance */
$fp = fopen($filename, 'r');
if (!$fp) {
return false;
}
$data = fread($fp, filesize($filename));
/* Scrub and show */
echo $data;
}
示例12: get_past_events
/**
* get_past_events
* Returns a list of past events
* @param Artist $artist
* @return SimpleXMLElement|boolean
*/
public static function get_past_events(Artist $artist)
{
if (isset($artist->mbid)) {
$query = 'mbid=' . rawurlencode($artist->mbid);
} else {
$query = 'artist=' . rawurlencode($artist->name);
}
$limit = AmpConfig::get('concerts_limit_past');
if ($limit) {
$query .= '&limit=' . $limit;
}
$xml = Recommendation::get_lastfm_results('artist.getpastevents', $query);
if ($xml->events) {
return $xml->events;
}
return false;
}
示例13: get_plugins
/**
* get_plugins
* This returns an array of plugin names
*/
public static function get_plugins($type = '')
{
// make static cache for optimization when multiple call
static $plugins_list = array();
if (isset($plugins_list[$type])) {
return $plugins_list[$type];
}
$plugins_list[$type] = array();
// Open up the plugin dir
$handle = opendir(AmpConfig::get('prefix') . '/modules/plugins');
if (!is_resource($handle)) {
debug_event('Plugins', 'Unable to read plugins directory', '1');
}
// Recurse the directory
while (false !== ($file = readdir($handle))) {
// Ignore non-plugin files
if (substr($file, -10, 10) != 'plugin.php') {
continue;
}
if (is_dir($file)) {
continue;
}
$plugin_name = basename($file, '.plugin.php');
if ($type != '') {
$plugin = new Plugin($plugin_name);
if (!Plugin::is_installed($plugin->_plugin->name)) {
debug_event('Plugins', 'Plugin ' . $plugin->_plugin->name . ' is not installed, skipping', 6);
continue;
}
if (!$plugin->is_valid()) {
debug_event('Plugins', 'Plugin ' . $plugin_name . ' is not valid, skipping', 6);
continue;
}
if (!method_exists($plugin->_plugin, $type)) {
debug_event('Plugins', 'Plugin ' . $plugin_name . ' does not support ' . $type . ', skipping', 6);
continue;
}
}
// It's a plugin record it
$plugins_list[$type][$plugin_name] = $plugin_name;
}
// end while
// Little stupid but hey
ksort($plugins_list[$type]);
return $plugins_list[$type];
}
示例14: display_home
/**
* display_home
* This display the module in home page
*/
public function display_home()
{
if (AmpConfig::get('sociable')) {
$user_id = $GLOBALS['user']->id;
if ($user_id) {
$activities = Useractivity::get_friends_activities($user_id, $this->maxitems);
if (count($activities) > 0) {
UI::show_box_top(T_('Friends Timeline'));
Useractivity::build_cache($activities);
foreach ($activities as $aid) {
$activity = new Useractivity($aid);
$activity->show();
}
UI::show_box_bottom();
}
}
}
}
示例15: display_user_field
/**
* display_user_field
* This display the module in user page
*/
public function display_user_field(library_item $libitem = null)
{
$name = $libitem != null ? $libitem->get_fullname() : T_('User') . " `" . $this->user->fullname . "` " . T_('on') . " " . AmpConfig::get('site_title');
$lang = substr(AmpConfig::get('lang'), 0, 2);
if (empty($lang)) {
$lang = 'US';
}
echo "<form action='https://www.paypal.com/cgi-bin/webscr' method='post' target='_top'>\n";
echo "<input type='hidden' name='cmd' value='_donations'>\n";
echo "<input type='hidden' name='business' value='" . scrub_out($this->business) . "'>\n";
echo "<input type='hidden' name='lc' value='" . $lang . "'>\n";
echo "<input type='hidden' name='item_name' value='" . $name . "'>\n";
echo "<input type='hidden' name='no_note' value='0'>\n";
echo "<input type='hidden' name='currency_code' value='" . scrub_out($this->currency_code) . "'>\n";
echo "<input type='hidden' name='bn' value='PP-DonationsBF:btn_donate_SM.gif:NonHostedGuest'>\n";
echo "<input type='image' src='https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif' border='0' name='submit' alt='PayPal - The safer, easier way to pay online!'>\n";
echo "<img alt='' border='0' src='https://www.paypalobjects.com/fr_XC/i/scr/pixel.gif' width='1' height='1'>\n";
echo "</form>\n";
}