本文整理汇总了PHP中PMA_CommonFunctions::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP PMA_CommonFunctions::getInstance方法的具体用法?PHP PMA_CommonFunctions::getInstance怎么用?PHP PMA_CommonFunctions::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMA_CommonFunctions
的用法示例。
在下文中一共展示了PMA_CommonFunctions::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PMA_printGitRevision
/**
* Prints details about the current Git commit revision
*
* @return void
*/
function PMA_printGitRevision()
{
$common_functions = PMA_CommonFunctions::getInstance();
if (!$GLOBALS['PMA_Config']->get('PMA_VERSION_GIT')) {
$response = PMA_Response::getInstance();
$response->isSuccess(false);
return;
}
// load revision data from repo
$GLOBALS['PMA_Config']->checkGitRevision();
// if using a remote commit fast-forwarded, link to Github
$commit_hash = substr($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITHASH'), 0, 7);
$commit_hash = '<strong title="' . htmlspecialchars($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_MESSAGE')) . '">' . $commit_hash . '</strong>';
if ($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_ISREMOTECOMMIT')) {
$commit_hash = '<a href="' . PMA_linkURL('https://github.com/phpmyadmin/phpmyadmin/commit/' . $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITHASH')) . '" target="_blank">' . $commit_hash . '</a>';
}
$branch = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_BRANCH');
if ($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_ISREMOTEBRANCH')) {
$branch = '<a href="' . PMA_linkURL('https://github.com/phpmyadmin/phpmyadmin/tree/' . $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_BRANCH')) . '" target="_blank">' . $branch . '</a>';
}
if ($branch !== false) {
$branch = sprintf(__('%1$s from %2$s branch'), $commit_hash, $branch);
} else {
$branch = $commit_hash . ' (' . __('no branch') . ')';
}
$committer = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITTER');
$author = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_AUTHOR');
PMA_printListItem(__('Git revision') . ': ' . $branch . ',<br /> ' . sprintf(__('committed on %1$s by %2$s'), $common_functions->localisedDate(strtotime($committer['date'])), '<a href="' . PMA_linkURL('mailto:' . $committer['email']) . '">' . htmlspecialchars($committer['name']) . '</a>') . ($author != $committer ? ', <br />' . sprintf(__('authored on %1$s by %2$s'), $common_functions->localisedDate(strtotime($author['date'])), '<a href="' . PMA_linkURL('mailto:' . $author['email']) . '">' . htmlspecialchars($author['name']) . '</a>') : ''), 'li_pma_version_git', null, null, null);
}
示例2: testExtractValueFromFormattedSizeK
function testExtractValueFromFormattedSizeK()
{
$this->assertEquals(
262144,
PMA_CommonFunctions::getInstance()->extractValueFromFormattedSize("256K")
);
}
示例3: getCommonFunctions
/**
* Get CommmonFunctions
*
* @return CommonFunctions object
*/
public function getCommonFunctions()
{
if (is_null($this->_common_functions)) {
$this->_common_functions = PMA_CommonFunctions::getInstance();
}
return $this->_common_functions;
}
示例4: testNotSupportedDataTypes
function testNotSupportedDataTypes()
{
$no_support_types = array();
$this->assertEquals(
$no_support_types, PMA_CommonFunctions::getInstance()->unsupportedDatatypes()
);
}
示例5: PMA_getNewTransformationDataSql
/**
* Get SQL query for store new transformation details of a VIEW
*
* @param mysqli_result $pma_tranformation_data Result set of SQL execution
* @param array $column_map Details of VIEW columns
* @param string $view_name Name of the VIEW
* @param string $db Database name of the VIEW
*
* @return string $new_transformations_sql SQL query for new tranformations
*/
function PMA_getNewTransformationDataSql($pma_tranformation_data, $column_map, $view_name, $db)
{
$common_functions = PMA_CommonFunctions::getInstance();
$cfgRelation = PMA_getRelationsParam();
// Need to store new transformation details for VIEW
$new_transformations_sql = 'INSERT INTO ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['column_info']) . ' (`db_name`, `table_name`, `column_name`, `comment`, ' . '`mimetype`, `transformation`, `transformation_options`)' . ' VALUES ';
$column_count = 0;
$add_comma = false;
while ($data_row = PMA_DBI_fetch_assoc($pma_tranformation_data)) {
foreach ($column_map as $column) {
if ($data_row['table_name'] == $column['table_name'] && $data_row['column_name'] == $column['refering_column']) {
$new_transformations_sql .= $add_comma ? ', ' : '';
$new_transformations_sql .= '(' . '\'' . $db . '\', ' . '\'' . $view_name . '\', ' . '\'';
$new_transformations_sql .= isset($column['real_column']) ? $column['real_column'] : $column['refering_column'];
$new_transformations_sql .= '\', ' . '\'' . $data_row['comment'] . '\', ' . '\'' . $data_row['mimetype'] . '\', ' . '\'' . $data_row['transformation'] . '\', ' . '\'' . $common_functions->sqlAddSlashes($data_row['transformation_options']) . '\')';
$add_comma = true;
$column_count++;
break;
}
}
if ($column_count == count($column_map)) {
break;
}
}
return $column_count > 0 ? $new_transformations_sql : '';
}
示例6: PMA_relationsCleanupDatabase
/**
* Cleanup database related relation stuff
*
* @param string $db
*/
function PMA_relationsCleanupDatabase($db)
{
$common_functions = PMA_CommonFunctions::getInstance();
$cfgRelation = PMA_getRelationsParam();
if ($cfgRelation['commwork']) {
$remove_query = 'DELETE FROM ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['column_info']) . ' WHERE db_name = \'' . $common_functions->sqlAddSlashes($db) . '\'';
PMA_queryAsControlUser($remove_query);
}
if ($cfgRelation['bookmarkwork']) {
$remove_query = 'DELETE FROM ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['bookmark']) . ' WHERE dbase = \'' . $common_functions->sqlAddSlashes($db) . '\'';
PMA_queryAsControlUser($remove_query);
}
if ($cfgRelation['displaywork']) {
$remove_query = 'DELETE FROM ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['table_info']) . ' WHERE db_name = \'' . $common_functions->sqlAddSlashes($db) . '\'';
PMA_queryAsControlUser($remove_query);
}
if ($cfgRelation['pdfwork']) {
$remove_query = 'DELETE FROM ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['pdf_pages']) . ' WHERE db_name = \'' . $common_functions->sqlAddSlashes($db) . '\'';
PMA_queryAsControlUser($remove_query);
$remove_query = 'DELETE FROM ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['table_coords']) . ' WHERE db_name = \'' . $common_functions->sqlAddSlashes($db) . '\'';
PMA_queryAsControlUser($remove_query);
}
if ($cfgRelation['designerwork']) {
$remove_query = 'DELETE FROM ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['designer_coords']) . ' WHERE db_name = \'' . $common_functions->sqlAddSlashes($db) . '\'';
PMA_queryAsControlUser($remove_query);
}
if ($cfgRelation['relwork']) {
$remove_query = 'DELETE FROM ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['relation']) . ' WHERE master_db = \'' . $common_functions->sqlAddSlashes($db) . '\'';
PMA_queryAsControlUser($remove_query);
$remove_query = 'DELETE FROM ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['relation']) . ' WHERE foreign_db = \'' . $common_functions->sqlAddSlashes($db) . '\'';
PMA_queryAsControlUser($remove_query);
}
}
示例7: testBuildActionTitles
function testBuildActionTitles()
{
$titles = array();
$common = PMA_CommonFunctions::getInstance();
$titles['Browse'] = $common->getIcon('b_browse.png', __('Browse'));
$titles['NoBrowse'] = $common->getIcon('bd_browse.png', __('Browse'));
$titles['Search'] = $common->getIcon('b_select.png', __('Search'));
$titles['NoSearch'] = $common->getIcon('bd_select.png', __('Search'));
$titles['Insert'] = $common->getIcon('b_insrow.png', __('Insert'));
$titles['NoInsert'] = $common->getIcon('bd_insrow.png', __('Insert'));
$titles['Structure'] = $common->getIcon('b_props.png', __('Structure'));
$titles['Drop'] = $common->getIcon('b_drop.png', __('Drop'));
$titles['NoDrop'] = $common->getIcon('bd_drop.png', __('Drop'));
$titles['Empty'] = $common->getIcon('b_empty.png', __('Empty'));
$titles['NoEmpty'] = $common->getIcon('bd_empty.png', __('Empty'));
$titles['Edit'] = $common->getIcon('b_edit.png', __('Edit'));
$titles['NoEdit'] = $common->getIcon('bd_edit.png', __('Edit'));
$titles['Export'] = $common->getIcon('b_export.png', __('Export'));
$titles['NoExport'] = $common->getIcon('bd_export.png', __('Export'));
$titles['Execute'] = $common->getIcon('b_nextpage.png', __('Execute'));
$titles['NoExecute'] = $common->getIcon('bd_nextpage.png', __('Execute'));
$this->assertEquals($titles, $common->buildActionTitles());
}
示例8: PMA_RTE_handleExport
/**
* This function is called from one of the other functions in this file
* and it completes the handling of the export functionality.
*
* @param string $item_name The name of the item that we are exporting
* @param string $export_data The SQL query to create the requested item
*/
function PMA_RTE_handleExport($item_name, $export_data)
{
global $db;
$item_name = htmlspecialchars(PMA_CommonFunctions::getInstance()->backquote($_GET['item_name']));
if ($export_data !== false) {
$export_data = '<textarea cols="40" rows="15" style="width: 100%;">' . htmlspecialchars(trim($export_data)) . '</textarea>';
$title = sprintf(PMA_RTE_getWord('export'), $item_name);
if ($GLOBALS['is_ajax_request'] == true) {
$response = PMA_Response::getInstance();
$response->addJSON('message', $export_data);
$response->addJSON('title', $title);
exit;
} else {
echo "<fieldset>\n" . "<legend>{$title}</legend>\n" . $export_data . "</fieldset>\n";
}
} else {
$_db = htmlspecialchars(PMA_CommonFunctions::getInstance()->backquote($db));
$response = __('Error in Processing Request') . ' : ' . sprintf(PMA_RTE_getWord('not_found'), $item_name, $_db);
$response = PMA_message::error($response);
if ($GLOBALS['is_ajax_request'] == true) {
$response = PMA_Response::getInstance();
$response->isSuccess(false);
$response->addJSON('message', $response);
exit;
} else {
$response->display();
}
}
}
示例9: testConvert_bit_default_value_test
/**
* @dataProvider dataProvider
*/
function testConvert_bit_default_value_test($bit, $val)
{
$this->assertEquals(
$val, PMA_CommonFunctions::getInstance()->convertBitDefaultValue($bit)
);
}
示例10: testMaximumUploadSize
/**
* @dataProvider dataProvider
* @return void
*/
function testMaximumUploadSize($size, $unit, $res)
{
$this->assertEquals(
"(" . __('Max: '). $res . $unit .")",
PMA_CommonFunctions::getInstance()->getFormattedMaximumUploadSize($size)
);
}
示例11: testExpandEscape
/**
* Test case for expanding strings with escaping
*
* @param string $in string to evaluate
* @param string $out expected output
*
* @return void
*
* @dataProvider provider
*/
public function testExpandEscape($in, $out)
{
$out = str_replace('PMA_VERSION', PMA_VERSION, $out);
$this->assertEquals(
htmlspecialchars($out),
PMA_CommonFunctions::getInstance()->expandUserString(
$in, 'htmlspecialchars'
)
);
}
示例12: resolveTypeSize
/**
* returns the pbxt engine specific handling for
* PMA_ENGINE_DETAILS_TYPE_SIZE variables.
*
* @param string $formatted_size the size expression (for example 8MB)
*
* @return string the formatted value and its unit
*/
function resolveTypeSize($formatted_size)
{
$common_functions = PMA_CommonFunctions::getInstance();
if (preg_match('/^[0-9]+[a-zA-Z]+$/', $formatted_size)) {
$value = $common_functions->extractValueFromFormattedSize($formatted_size);
} else {
$value = $formatted_size;
}
return $common_functions->formatByteDown($value);
}
示例13: testGetCheckboxCheckedOnclick
function testGetCheckboxCheckedOnclick()
{
$name = "test_display_html_checkbox";
$label = "text_label_for_checkbox";
$this->assertEquals(
PMA_CommonFunctions::getInstance()->getCheckbox($name, $label, true, true),
'<input type="checkbox" name="' . $name . '" id="' . $name . '" checked="checked" class="autosubmit" /><label for="' . $name . '">' . $label . '</label>'
);
}
示例14: PMA_save_userprefs
/**
* Saves user preferences
*
* @param array $config_array configuration array
*
* @return true|PMA_Message
*/
function PMA_save_userprefs(array $config_array)
{
$common_functions = PMA_CommonFunctions::getInstance();
$cfgRelation = PMA_getRelationsParam();
$server = isset($GLOBALS['server'])
? $GLOBALS['server']
: $GLOBALS['cfg']['ServerDefault'];
$cache_key = 'server_' . $server;
if (! $cfgRelation['userconfigwork']) {
// no pmadb table, use session storage
$_SESSION['userconfig'] = array(
'db' => $config_array,
'ts' => time());
if (isset($_SESSION['cache'][$cache_key]['userprefs'])) {
unset($_SESSION['cache'][$cache_key]['userprefs']);
}
return true;
}
// save configuration to pmadb
$query_table = $common_functions->backquote($cfgRelation['db']) . '.'
. $common_functions->backquote($cfgRelation['userconfig']);
$query = '
SELECT `username`
FROM ' . $query_table . '
WHERE `username` = \'' . $common_functions->sqlAddSlashes($cfgRelation['user']) . '\'';
$has_config = PMA_DBI_fetch_value($query, 0, 0, $GLOBALS['controllink']);
$config_data = json_encode($config_array);
if ($has_config) {
$query = '
UPDATE ' . $query_table . '
SET `config_data` = \'' . $common_functions->sqlAddSlashes($config_data) . '\'
WHERE `username` = \'' . $common_functions->sqlAddSlashes($cfgRelation['user']) . '\'';
} else {
$query = '
INSERT INTO ' . $query_table . ' (`username`, `config_data`)
VALUES (\'' . $common_functions->sqlAddSlashes($cfgRelation['user']) . '\',
\'' . $common_functions->sqlAddSlashes($config_data) . '\')';
}
if (isset($_SESSION['cache'][$cache_key]['userprefs'])) {
unset($_SESSION['cache'][$cache_key]['userprefs']);
}
if (!PMA_DBI_try_query($query, $GLOBALS['controllink'])) {
$message = PMA_Message::error(__('Could not save configuration'));
$message->addMessage('<br /><br />');
$message->addMessage(
PMA_Message::rawError(PMA_DBI_getError($GLOBALS['controllink']))
);
return $message;
}
return true;
}
示例15: PMA_jsFormat
/**
* Format a string so it can be a string inside JavaScript code inside an
* eventhandler (onclick, onchange, on..., ).
* This function is used to displays a javascript confirmation box for
* "DROP/DELETE/ALTER" queries.
*
* @param string $a_string the string to format
* @param boolean $add_backquotes whether to add backquotes to the string or not
*
* @return string the formatted string
*
* @access public
*/
function PMA_jsFormat($a_string = '', $add_backquotes = true)
{
if (is_string($a_string)) {
$a_string = htmlspecialchars($a_string);
$a_string = PMA_escapeJsString($a_string);
// Needed for inline javascript to prevent some browsers
// treating it as a anchor
$a_string = str_replace('#', '\\#', $a_string);
}
return $add_backquotes ? PMA_CommonFunctions::getInstance()->backquote($a_string) : $a_string;
}