示例#1
0
function do_change_state()
{
    global $project, $pguser, $code_url, $charset;
    $valid_transitions = get_valid_transitions($project, $pguser);
    if (count($valid_transitions) == 0) {
        return;
    }
    echo "<h4>";
    echo _("Change Project State");
    echo "</h4>\n";
    if ($project->state == PROJ_NEW) {
        echo "<p>\n";
        echo _("Check for missing pages and make sure that all illustration files have been uploaded <b>before</b> moving this project into the rounds.");
        echo "</p>\n";
    }
    // print out a message if PM has project loads disabled,
    // as they can't move a project out of the unavailable state
    if ($project->can_be_managed_by_current_user) {
        check_user_can_load_projects(false);
    }
    $here = $_SERVER['REQUEST_URI'];
    // If the request URI included an 'expected_state' parameter, there's a wrinkle:
    // If the user clicks on this button, the project's state will (normally) change.
    // So if we then returned the user to exactly this URI, they'd get a warning:
    // "The project is no longer in 'this state'. It is now in 'that state'.
    // So we suppress the 'expected_state' parameter from the request URI.
    $here = preg_replace('/expected_state=[A-Za-z._0-9]+/', '', $here);
    // This can leave an extra &, but I suspect browsers can handle it.
    foreach ($valid_transitions as $transition) {
        echo "<form method='POST' action='{$code_url}/tools/changestate.php'>";
        echo "<input type='hidden' name='projectid'  value='{$project->projectid}'>\n";
        echo "<input type='hidden' name='curr_state' value='{$project->state}'>\n";
        echo "<input type='hidden' name='next_state' value='{$transition->to_state}'>\n";
        echo "<input type='hidden' name='confirmed'  value='yes'>\n";
        echo "<input type='hidden' name='return_uri' value='{$here}'>\n";
        $question = $transition->confirmation_question;
        if (is_null($question)) {
            $onClick_condition = "return true;";
        } else {
            $onClick_condition = "return confirm(\"" . javascript_safe($question, $charset) . "\");";
        }
        $onclick_attr = "onClick='{$onClick_condition}'";
        echo "<input type='submit' value='", attr_safe($transition->action_name), "' {$onclick_attr}>";
        if (1) {
            // Say who is allowed to do this transition.
            echo " [{$transition->who_restriction}]";
        }
        echo "</form>\n";
    }
}
                 }
             }
             echo ">" . $imagefile . "</option>\n";
         }
         mysql_free_result($res);
         echo "</select> \n";
     }
     $prev_label = attr_safe(_("Previous"));
     $prev_image_js = javascript_safe($prev_image, $charset);
     echo "<input type='button' value='{$prev_label}' onClick=\"this.form.page.value='{$prev_image_js}'; this.form.submit();\"";
     if ($prev_image == "") {
         echo " disabled";
     }
     echo ">\n";
     $next_label = attr_safe(_("Next"));
     $next_image_js = javascript_safe($next_image, $charset);
     echo "<input type='button' value='{$next_label}' onClick=\"this.form.page.value='{$next_image_js}'; this.form.submit();\"";
     if ($next_image == "") {
         echo " disabled";
     }
     echo ">";
     echo " &nbsp; &nbsp;\n";
 }
 echo "<select name='round_id'>";
 foreach ($expanded_rounds as $round) {
     echo "<option value='{$round}'";
     if ($round_id && $round == $round_id) {
         echo " selected";
     }
     echo ">{$round}</option>\n";
 }
示例#3
0
function manage_form($locale)
{
    global $dyn_locales_dir, $translate_url, $charset;
    $system_locales = get_installed_system_locales();
    $translation_enabled = is_locale_translation_enabled($locale);
    echo "<p><a href='{$translate_url}'>" . _("Back to the Translation Center") . "</a></p>";
    echo "<h1>" . sprintf(_("Managing locale %s"), $locale) . "</h1>\n";
    echo "<p><b>" . _("Locale") . ":</b> {$locale}</p>\n";
    if (!in_array($locale, $system_locales)) {
        echo "<p><b>" . sprintf(_("Warning: While a locale translation exists for %s, a system locale does not. Without a system locale installed, gettext will not use this translation."), $locale) . "</b></p>";
    }
    echo "<p><b>" . _("Language") . ":</b> " . eng_name($locale) . "</p>\n";
    echo "<p><b>" . _("Translation status") . ":</b> ";
    if ($translation_enabled) {
        echo _("Enabled");
    } else {
        echo _("Disabled");
    }
    echo "</p>\n";
    $po_filename = "{$dyn_locales_dir}/{$locale}/LC_MESSAGES/messages.po";
    $po_file = new POFile($po_filename);
    if ($po_file->exists) {
        $total_strings = $po_file->messages_count;
        $translated_strings = $po_file->messages_translated_count;
        echo "<p><b>" . _("PO file") . ":</b> ";
        echo "<a href='{$translate_url}?func=view&amp;locale={$locale}'>" . _("View") . "</a> | <a href='{$translate_url}?func=download&amp;locale={$locale}'>" . _("Download") . "</a> (" . _("Last modified") . ": " . date("F d Y H:i:s", $po_file->last_modified) . ")";
        echo " - ";
        echo sprintf(_('%1$s of %2$s translated (%3$d%%)'), $translated_strings, $total_strings, $translated_strings / $total_strings * 100);
        echo "</p>";
        $pot_filename = "{$dyn_locales_dir}/messages.pot";
        $pot_file = new POFile($pot_filename);
        if ($pot_file->exists && $pot_file->last_modified > $po_file->last_modified) {
            echo "<p>" . _("The current template is more recent than the PO file. You should merge the PO file with the current template.") . "</p>";
        }
        echo "<form action='{$translate_url}?func=merge' method='POST'>";
        echo "<input type='hidden' name='locale' value='{$locale}'>";
        echo "<input type='submit' value='" . attr_safe(_("Merge current PO file with the current template")) . "'> ";
        echo _("Run <code>msgmerge</code> to update the current PO file against the current template.") . "<br>\n";
        echo "<input type='checkbox' name='fuzzy'> " . _("Do fuzzy matching when an exact match is not found (can be much slower)") . "<br>";
        echo "</form><br><br>\n";
    } else {
        echo "<p>" . _("No PO file.") . "</p>\n";
    }
    echo "<form action='{$translate_url}?func=upload' method='POST' enctype='multipart/form-data'>\n";
    echo "<input type='hidden' name='locale' value='{$locale}'>";
    echo _("Select a PO file to upload:") . " ";
    echo "<input type='hidden' name='MAX_FILE_SIZE' value='5000000'>";
    echo "<input type='file' name='userfile'><br>\n";
    echo "<input type='submit' value='" . attr_safe(_("Upload file")) . "'> ";
    echo _("This replaces the current PO file with the file you provide, and installs the translation for use by the site.");
    echo "</form>\n";
    if (user_is_a_sitemanager()) {
        echo "<br><br>";
        echo "<h2>" . _("Site administrator functions") . "</h2>";
        echo "<form action='{$translate_url}?func=changeenable' method='POST'>";
        echo "<input type='hidden' name='locale' value='{$locale}'>";
        if ($translation_enabled) {
            $checkbox_state = "checked";
        } else {
            $checkbox_state = "";
        }
        echo "<input type='checkbox' name='enable_locale' value='1' {$checkbox_state}> ";
        echo _("Enable locale translation") . " ";
        echo "<input type='submit' value='" . attr_safe(_("Save")) . "'> ";
        echo "</form>\n";
        echo "<br><br>";
        echo "<form action='{$translate_url}?func=delete' method='POST'>";
        echo "<input type='hidden' name='locale' value='{$locale}'>";
        $confirm = javascript_safe(_("Are you sure you want to delete this locale and its translation file?"), $charset);
        echo "<input type='submit' onClick='return confirm(\"{$confirm}\");' value='" . attr_safe(_("Delete this locale")) . "'> ";
        echo _("Delete the locale directory, PO file and MO file.") . "<br>\n";
        echo "</form>\n";
    }
}