Ejemplo n.º 1
0
    }
} else {
    $opts['values']['1'] = __('- none -');
    $opts['values_escaped'] = true;
}
display_input('ServerDefault', __('Default server'), '', 'select',
    $cf->getValue('ServerDefault'), true, $opts);

// Display EOL list
$opts = array(
    'values' => array(
        'unix' => 'UNIX / Linux (\n)',
        'win' => 'Windows (\r\n)'),
    'values_escaped' => true);
$eol = PMA_ifSetOr($_SESSION['eol'], (PMA_IS_WINDOWS ? 'win' : 'unix'));
display_input('eol', __('End of line'), '', 'select',
    $eol, true, $opts);
?>
<tr>
    <td colspan="2" class="lastrow" style="text-align: left">
        <input type="submit" name="submit_display" value="<?php echo __('Display') ?>" />
        <input type="submit" name="submit_download" value="<?php echo __('Download') ?>" />
        &nbsp; &nbsp;
        <input type="submit" name="submit_save" value="<?php echo __('Save') ?>"<?php if (!$config_writable) echo ' disabled="disabled"' ?> />
        <input type="submit" name="submit_load" value="<?php echo __('Load') ?>"<?php if (!$config_exists) echo ' disabled="disabled"' ?> />
        <input type="submit" name="submit_delete" value="<?php echo __('Delete') ?>"<?php if (!$config_exists || !$config_writable) echo ' disabled="disabled"' ?> />
        &nbsp; &nbsp;
        <input type="submit" name="submit_clear" value="<?php echo __('Clear') ?>" class="red" />
    </td>
</tr>
<?php
display_fieldset_bottom_simple();
Ejemplo n.º 2
0
 /**
  * Prepares data for input field display and outputs HTML code
  *
  * @uses ConfigFile::get()
  * @uses ConfigFile::getDefault()
  * @uses ConfigFile::getInstance()
  * @uses display_group_footer()
  * @uses display_group_header()
  * @uses display_input()
  * @uses Form::getOptionType()
  * @uses Form::getOptionValueList()
  * @uses PMA_escapeJsString()
  * @uses PMA_lang_desc()
  * @uses PMA_lang_name()
  * @param Form   $form
  * @param string $field                 field name as it appears in $form
  * @param string $system_path           field path, eg. Servers/1/verbose
  * @param string $work_path             work path, eg. Servers/4/verbose
  * @param string $translated_path       work path changed so that it can be used as XHTML id
  * @param bool   $show_restore_default  whether show "restore default" button besides the input field
  * @param mixed  $userprefs_allow       whether user preferences are enabled for this field
  *                                      (null - no support, true/false - enabled/disabled)
  * @param array  &$js_default           array which stores JavaScript code to be displayed
  */
 private function _displayFieldInput(Form $form, $field, $system_path, $work_path, $translated_path, $show_restore_default, $userprefs_allow, array &$js_default)
 {
     $name = PMA_lang_name($system_path);
     $description = PMA_lang_name($system_path, 'desc', '');
     $cf = ConfigFile::getInstance();
     $value = $cf->get($work_path);
     $value_default = $cf->getDefault($system_path);
     $value_is_default = false;
     if ($value === null || $value === $value_default) {
         $value = $value_default;
         $value_is_default = true;
     }
     $opts = array('doc' => $this->getDocLink($system_path), 'wiki' => $this->getWikiLink($system_path), 'show_restore_default' => $show_restore_default, 'userprefs_allow' => $userprefs_allow, 'userprefs_comment' => PMA_lang_name($system_path, 'cmt', ''));
     if (isset($form->default[$system_path])) {
         $opts['setvalue'] = $form->default[$system_path];
     }
     if (isset($this->errors[$work_path])) {
         $opts['errors'] = $this->errors[$work_path];
     }
     switch ($form->getOptionType($field)) {
         case 'string':
             $type = 'text';
             break;
         case 'short_string':
             $type = 'short_text';
             break;
         case 'double':
         case 'integer':
             $type = 'number_text';
             break;
         case 'boolean':
             $type = 'checkbox';
             break;
         case 'select':
             $type = 'select';
             $opts['values'] = $form->getOptionValueList($form->fields[$field]);
             break;
         case 'array':
             $type = 'list';
             $value = (array) $value;
             $value_default = (array) $value_default;
             break;
         case 'group':
             if (substr($field, 7, 4) != 'end:') {
                 // :group:end is changed to :group:end:{unique id} in Form class
                 display_group_header(substr($field, 7));
             } else {
                 display_group_footer();
             }
             return;
         case 'NULL':
             trigger_error("Field {$system_path} has no type", E_USER_WARNING);
             return;
     }
     // TrustedProxies requires changes before displaying
     if ($system_path == 'TrustedProxies') {
         foreach ($value as $ip => &$v) {
             if (!preg_match('/^-\\d+$/', $ip)) {
                 $v = $ip . ': ' . $v;
             }
         }
     }
     $this->_setComments($system_path, $opts);
     // send default value to form's JS
     $js_line = '\'' . $translated_path . '\': ';
     switch ($type) {
         case 'text':
         case 'short_text':
         case 'number_text':
             $js_line .= '\'' . PMA_escapeJsString($value_default) . '\'';
             break;
         case 'checkbox':
             $js_line .= $value_default ? 'true' : 'false';
             break;
         case 'select':
             $value_default_js = is_bool($value_default) ? (int) $value_default : $value_default;
             $js_line .= '[\'' . PMA_escapeJsString($value_default_js) . '\']';
             break;
         case 'list':
             $js_line .= '\'' . PMA_escapeJsString(implode("\n", $value_default)) . '\'';
             break;
     }
     $js_default[] = $js_line;
     display_input($translated_path, $name, $description, $type, $value, $value_is_default, $opts);
 }
Ejemplo n.º 3
0
    if ($cf->getServerCount() == 1) {
        $opts['values_disabled'][] = '0';
    }
    $opts['values_disabled'][] = '-';
    foreach ($_SESSION['ConfigFile']['Servers'] as $id => $server) {
        $opts['values'][(string) $id] = $cf->getServerName($id) . " [{$id}]";
    }
} else {
    $opts['values']['1'] = $GLOBALS['strSetupOptionNone'];
    $opts['values_escaped'] = true;
}
display_input('ServerDefault', $GLOBALS['strSetupDefaultServer'], '', 'select', $cf->getValue('ServerDefault'), true, $opts);
// Display EOL list
$opts = array('values' => array('unix' => 'UNIX / Linux (\\n)', 'win' => 'Windows (\\r\\n)'), 'values_escaped' => true);
$eol = PMA_ifSetOr($_SESSION['eol'], PMA_IS_WINDOWS ? 'win' : 'unix');
display_input('eol', $GLOBALS['strSetupEndOfLine'], '', 'select', $eol, true, $opts);
?>
<tr>
    <td colspan="2" class="lastrow" style="text-align: left">
        <input type="submit" name="submit_display" value="<?php 
echo $GLOBALS['strSetupDisplay'];
?>
" />
        <input type="submit" name="submit_download" value="<?php 
echo $GLOBALS['strSetupDownload'];
?>
" />
        &nbsp; &nbsp;
        <input type="submit" name="submit_save" value="<?php 
echo $GLOBALS['strSave'];
?>
Ejemplo n.º 4
0
 /**
  * Prepares data for input field display and outputs HTML code
  *
  * @param Form   $form
  * @param string $field                 field name as it appears in $form
  * @param string $system_path           field path, eg. Servers/1/verbose
  * @param string $work_path             work path, eg. Servers/4/verbose
  * @param string $translated_path       work path changed so that it can be used as XHTML id
  * @param bool   $show_restore_default  whether show "restore default" button besides the input field
  * @param array  &$js_default           array which stores JavaScript code to be displayed
  */
 private function _displayFieldInput(Form $form, $field, $system_path, $work_path, $translated_path, $show_restore_default, array &$js_default)
 {
     $name = PMA_lang_name($system_path);
     $description = PMA_lang_desc($system_path);
     $cf = ConfigFile::getInstance();
     $value = $cf->get($work_path);
     $value_default = $cf->getDefault($system_path);
     $value_is_default = false;
     if ($value === null || $value === $value_default) {
         $value = $value_default;
         $value_is_default = true;
     }
     $opts = array('doc' => $this->getDocLink($system_path), 'wiki' => $this->getWikiLink($system_path), 'show_restore_default' => $show_restore_default);
     if (isset($form->default[$system_path])) {
         $opts['setvalue'] = $form->default[$system_path];
     }
     if (isset($this->errors[$work_path])) {
         $opts['errors'] = $this->errors[$work_path];
     }
     switch ($form->getOptionType($field)) {
         case 'string':
             $type = 'text';
             break;
         case 'double':
             $type = 'text';
             break;
         case 'integer':
             $type = 'text';
             break;
         case 'boolean':
             $type = 'checkbox';
             break;
         case 'select':
             $type = 'select';
             $opts['values'] = array();
             $values = $form->getOptionValueList($form->fields[$field]);
             foreach ($values as $v) {
                 $opts['values'][$v] = $v;
             }
             break;
         case 'array':
             $type = 'list';
             $value = (array) $value;
             $value_default = (array) $value_default;
             break;
         case 'NULL':
             trigger_error("Field {$system_path} has no type", E_USER_WARNING);
             return;
     }
     // TrustedProxies requires changes before displaying
     if ($system_path == 'TrustedProxies') {
         foreach ($value as $ip => &$v) {
             if (!preg_match('/^-\\d+$/', $ip)) {
                 $v = $ip . ': ' . $v;
             }
         }
     }
     // send default value to form's JS
     $js_line = '\'' . $translated_path . '\': ';
     switch ($type) {
         case 'text':
             $js_line .= '\'' . PMA_escapeJsString($value_default) . '\'';
             break;
         case 'checkbox':
             $js_line .= $value_default ? 'true' : 'false';
             break;
         case 'select':
             $value_default_js = is_bool($value_default) ? (int) $value_default : $value_default;
             $js_line .= '[\'' . PMA_escapeJsString($value_default_js) . '\']';
             break;
         case 'list':
             $js_line .= '\'' . PMA_escapeJsString(implode("\n", $value_default)) . '\'';
             break;
     }
     $js_default[] = $js_line;
     display_input($translated_path, $name, $description, $type, $value, $value_is_default, $opts);
 }
Ejemplo n.º 5
0
function display_form($context_object, $webhook = '')
{
    echo '<html>';
    echo '<head>';
    echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' . "\n";
    echo '<script src="js/jquery-1.4.4.min.js"></script>' . "\n";
    //echo '<script src="js/json2.js"></script>' . "\n";
    echo '<script src="js/openurl.js"></script>' . "\n";
    echo '   <style type="text/css">' . "\n";
    echo '   body {
		font-family:sans-serif;
		font-size:12px;
	}
	label {
		float:left;
		width:80px;
		font-size:12px;
		text-align:right;
		padding-right:4px;
		padding-top:4px;
	}
	textarea {
		width:200px;
	}
	input {
		width: 200px;
	}
	</style>' . "\n";
    echo '</head>';
    echo '<div style="position:relative;height:700px;width:800px;border:1px solid rgb(128,128,128);">' . "\n";
    echo '<div id="page" style="position:absolute;left:400px;top:0px;height:700px;width:400px;overflow:hide;" onclick="hidePage();"></div>' . "\n";
    echo '<div id="hits" style="position:absolute;left:400px;top:0px;height:700px;width:400px;overflow:auto;"></div>' . "\n";
    echo '<div style="border-right:1px solid rgb(128,128,128);height:700px;width:400px;">' . "\n";
    echo '<form id="openurl">' . "\n";
    if (isset($context_object->referring_entity)) {
        if (isset($context_object->referring_entity->id)) {
            echo '<div><label for="rfe_id">Id</label><input readonly id="rfe_id" name="rfe_id" value="' . $context_object->referring_entity->id . '">' . "\n";
        }
    }
    switch ($context_object->referent->type) {
        case 'Journal Article':
            echo '<input type="hidden" id="rft_val_fmt" name="rft_val_fmt" value="info:ofi/fmt:kev:mtx:journal">' . "\n";
            echo '<div><label for="title">Title</label><textarea id="title" name="title" rows="4">' . $context_object->referent->title . '</textarea></div>' . "\n";
            echo '<div><label for="authors">Authors</label><textarea id="authors" name="authors" rows="4" placeholder="one name per line">' . "\n";
            if (isset($context_object->referent->authors)) {
                foreach ($context_object->referent->authors as $author) {
                    echo $author->forename . ' ' . $author->surname . "\n";
                }
            }
            echo '</textarea></div>' . "\n";
            display_input($context_object, 'publication_outlet', 'Journal', 'journal');
            display_input($context_object, 'series', 'Series', 'series');
            display_input($context_object, 'volume', 'Volume', 'volume');
            display_input($context_object, 'issue', 'Issue', 'issue');
            display_input($context_object, 'spage', 'Starting page', 'first page in article');
            display_input($context_object, 'epage', 'Ending page', 'last page in article');
            display_input($context_object, 'year', 'Year', 'year article published');
            // Search
            echo '<div><label>Search</label>';
            echo '<button type="button" onclick="findFromMetadata();">bioGUID</button>';
            echo '<button type="button" onclick="findInBiostor();">BioStor</button>';
            echo '<img id="bioguid_progress" src="images/blank16x16.png">';
            echo '</div>';
            // Identifiers
            // DOI
            echo '<div><label for="doi">DOI</label>';
            echo '<input id="doi" name="doi" placeholder="DOI" value="';
            if (isset($context_object->referent->identifiers->doi)) {
                echo $context_object->referent->identifiers->doi;
            }
            echo '" onchange="doi_enable();">';
            echo '<button type="button" id="doi_link" onclick="doi_go();">Go</button>';
            echo '<button type="button" id="doi_lookup" onclick="findFromDOI();">Lookup</button>';
            echo '</div>' . "\n";
            // Handle
            echo '<div><label for="hdl">Handle</label><input id="hdl" name="hdl" placeholder="Handle" value="';
            if (isset($context_object->referent->identifiers->hdl)) {
                echo $context_object->referent->identifiers->hdl;
            }
            echo '" onchange="hdl_enable();">';
            echo '<button type="button" id="hdl_link" onclick="handle_go();">Go</button>';
            echo '</div>' . "\n";
            // ISSN
            echo '<div><label for="issn">ISSN</label><input id="issn" name="issn" placeholder="ISSN for journal" value="';
            if (isset($context_object->referent->identifiers->issn)) {
                echo $context_object->referent->identifiers->issn;
            }
            echo '" >';
            echo '</div>' . "\n";
            // BioStor
            echo '<div><label for="biostor">BioStor</label><input id="biostor" name="biostor" placeholder="BioStor reference number" value="';
            if (isset($context_object->referent->identifiers->biostor)) {
                echo $context_object->referent->identifiers->biostor;
            }
            echo '" onchange="biostor_enable();">';
            echo '<button type="button" id="biostor_link" onclick="biostor_go();">Go</button>';
            echo '</div>' . "\n";
            // PMID with link to NCBI
            echo '<div><label for="pmid">PMID</label><input id="pmid" name="pmid" placeholder="PMID" value="';
            if (isset($context_object->referent->identifiers->pmid)) {
                echo $context_object->referent->identifiers->pmid;
            }
            echo '" onchange="pmid_enable();">';
            echo '<button type="button" id="pmid_link" onclick="pmid_go();">Go</button>';
            echo '</div>' . "\n";
            // URL, could be anything :(
            echo '<div><label for="url">URL</label><input id="url" name="url" placeholder="URL" value="';
            if (isset($context_object->referent->url)) {
                echo $context_object->referent->url;
            }
            echo '" onchange="url_enable();">';
            echo '<button type="button" id="url_link" onclick="url_go();">Go</button>';
            echo '</div>' . "\n";
            // PDF
            echo '<div><label for="pdf">PDF</label><input id="pdf" name="pdf" placeholder="PDF" value="';
            if (isset($context_object->referent->pdf)) {
                echo $context_object->referent->pdf;
            }
            echo '" onchange="pdf_enable();">';
            echo '<button type="button" id="pdf_link" onclick="pdf_go();">Go</button>';
            echo '</div>' . "\n";
            break;
        default:
            break;
    }
    // webhook
    if ($webhook != '') {
        if (preg_match('/^(http:\\/\\/(.*))/', $webhook)) {
            echo '<input type="hidden" id="webhook" name="webhook" value="' . $webhook . '">' . "\n";
            //			echo '<input type="hidden" id="webhook" name="webhook" value="http://www.postbin.org/1b61x6c">' . "\n";
            echo '<div><label>Save</label><button type="button" onclick="save();">Save</button></div>' . "\n";
        }
    }
    echo '</form>';
    echo '</div>';
    echo '</div>' . "\n";
    // Form defaults
    echo '<script>
		doi_enable();
		hdl_enable();
		biostor_enable();
		pmid_enable();
		url_enable();
		pdf_enable();
	</script>
	';
    echo '</body>';
    echo '</html>';
}