Exemple #1
0
    $R_user_column_name = $R_round->user_column_name;
    $R_label = $R_round->id;
}
$query = "\n    SELECT {$L_text_column_name}, {$R_text_column_name},\n           {$L_user_column_name}, {$R_user_column_name}\n    FROM {$projectid}\n    WHERE image='{$image}'";
$res = mysql_query($query) or die(mysql_error());
list($L_text, $R_text, $L_user, $R_user) = mysql_fetch_row($res);
$can_see_names_for_this_page = can_see_names_for_page($projectid, $image);
if ($can_see_names_for_this_page) {
    $L_label .= " ({$L_user})";
    $R_label .= " ({$R_user})";
}
// now have the image, users, labels etc all set up
// -----------------------------------------------------------------------------
$title = sprintf(_('Difference for page %s'), $image);
$image_url = "{$code_url}/tools/project_manager/displayimage.php?project={$projectid}&imagefile={$image}";
$image_link = sprintf(_('Difference for page %s'), new_window_link($image_url, $image));
$extra_args = array("css_files" => get_DifferenceEngine_css_files(), "css_data" => get_DifferenceEngine_css_data());
output_header("{$title}: {$project_title}", NO_STATSBAR, $extra_args);
echo "<h1>{$project_title}</h1>\n";
echo "<h2>{$image_link}</h2>\n";
do_navigation($projectid, $image, $L_round_num, $R_round_num, $L_user_column_name, $L_user);
echo $navigation_text;
$url = "{$code_url}/project.php?id={$projectid}&amp;expected_state={$state}";
$label = _("Go to Project Page");
echo "\n<p><a href='{$url}'>{$label}</a></p>\n";
// ---------------------------------------------------------
$diffEngine = new DifferenceEngineWrapper();
$diffEngine->setText($L_text, $R_text);
$diffEngine->showDiff($L_label, $R_label);
// don't print out the navigation bit again if there is no difference
// at the top of the page it's buttons, then project page
function do_project_info_table()
{
    global $project, $code_url, $datetime_format, $date_format, $time_format;
    global $user_is_logged_in;
    global $site_supports_corrections_after_posting;
    $projectid = $project->projectid;
    $state = $project->state;
    $round = get_Round_for_project_state($state);
    // Note that $round may be NULL;
    echo "<table id='project_info_table' border=1 width=630>";
    // -------------------------------------------------------------------------
    // The state of the project
    $available_for_SR = $project->state == PROJ_POST_FIRST_CHECKED_OUT && $project->smoothread_deadline > time();
    $right = project_states_text($project->state);
    if ($round) {
        $extra = $round->description;
        $right = "{$right} ({$extra})";
    } elseif ($available_for_SR) {
        $sr_deadline_str = strftime($date_format, $project->smoothread_deadline);
        $sr_sentence = sprintf(_('This project has been made available for smooth reading until %s.'), "<b>{$sr_deadline_str}</b>");
        $extra2 = _('See below.');
        $right = "{$right}<br>{$sr_sentence} {$extra2}";
    }
    echo_row_a(_("Project State"), $right);
    if ($project->state == PROJ_DELETE) {
        // Change anything that looks like a projectid into a link.
        $cooked_reason = preg_replace('/\\b(projectID[0-9a-f]{13})\\b/', '<a href="project.php?id=\\1">\\1</a>', $project->deletion_reason);
        echo_row_a(_("Reason for Deletion"), $cooked_reason);
    }
    // -------------------------------------------------------------------------
    // Information about the work itself (independent of DP)
    // the array below should guarantee that the strings 'beginner',
    // 'easy', 'average' and 'hard' reach the po file, so that using
    // later _($project->difficulty) should translate the project
    // difficulty, if regularly formed, or display the (irregular)
    // english project difficulty.
    if (0) {
        $difficulty_labels = array('beginner' => _('beginner'), 'easy' => _('easy'), 'average' => _('average'), 'hard' => _('hard'));
    }
    echo_row_a(_("Title"), $project->nameofwork);
    echo_row_a(_("Author"), $project->authorsname);
    echo_row_a(_("Language"), $project->language);
    echo_row_a(_("Genre"), _($project->genre));
    echo_row_a(_("Difficulty"), _($project->difficulty));
    // -------------------------------------------------------------------------
    // Basic DP info
    if (!empty($project->special_code)) {
        $spec_code = $project->special_code;
        if (strncmp($spec_code, 'Birthday', 8) == 0 or strncmp($spec_code, 'Otherday', 8) == 0) {
            $spec_display = $spec_code;
        } else {
            $spec_res = mysql_fetch_assoc(mysql_query("\n                SELECT display_name\n                FROM special_days\n                WHERE spec_code = '{$spec_code}'\n            "));
            if ($spec_res) {
                $spec_display = $spec_res['display_name'];
            } else {
                $spec_display = "({$spec_code})";
            }
        }
        echo_row_a(_("Special Day"), $spec_display);
    }
    // -------
    echo_row_a(_("Project ID"), $project->projectid);
    if ($project->clearance_line_can_be_seen_by_current_user()) {
        echo_row_a(_("Clearance Line"), $project->clearance, TRUE);
    }
    // -------------------------------------------------------------------------
    // People who have certain roles with respect to the project
    if (isset($project->image_source_name)) {
        echo_row_a(_("Image Source"), $project->image_source_name, TRUE);
    }
    // We choose not to show guests anything involving users' names.
    if ($user_is_logged_in) {
        echo_row_a(_("Project Manager"), $project->username);
        $checkedout_states = array(PROJ_POST_SECOND_CHECKED_OUT, PROJ_POST_COMPLETE, PROJ_SUBMIT_PG_POSTED);
        if ($site_supports_corrections_after_posting) {
            $checkedout_states[] = PROJ_CORRECT_CHECKED_OUT;
        }
        if (!empty($project->postproofer)) {
            $PPer = $project->postproofer;
        } else {
            if (!empty($project->checkedoutby) && !in_array($project->state, $checkedout_states)) {
                $PPer = $project->checkedoutby;
            }
        }
        if (isset($PPer)) {
            echo_row_a(_("Post Processor"), $PPer);
        }
        if (!empty($project->ppverifier)) {
            $PPVer = $project->ppverifier;
        } else {
            if (!empty($project->checkedoutby) && in_array($project->state, array(PROJ_POST_SECOND_CHECKED_OUT, PROJ_POST_COMPLETE, PROJ_SUBMIT_PG_POSTED))) {
                $PPVer = $project->checkedoutby;
            }
        }
        if (isset($PPVer)) {
            echo_row_a(_("PP Verifier"), $PPVer);
        }
        if ($site_supports_corrections_after_posting) {
            // included for completeness
            if (!empty($project->checkedoutby) && $project->state == PROJ_CORRECT_CHECKED_OUT) {
                $CorrectionsReviewer = $project->checkedoutby;
            }
            if (isset($CorrectionsReviewer)) {
                echo_row_a(_("Corrections Reviewer"), $CorrectionsReviewer);
            }
        }
        echo_row_a(_("Credits line so far"), $project->credits_line, TRUE);
    }
    // -------------------------------------------------------------------------
    // Current activity
    $formatted_now = strftime($time_format, time());
    $ct = _("Current Time");
    $current_time_addition = "&nbsp;&nbsp;&nbsp;({$ct}: {$formatted_now})";
    echo_row_a(_("Last Edit of Project Info"), strftime($datetime_format, $project->t_last_edit) . $current_time_addition);
    echo_row_a(_("Last State Change"), strftime($datetime_format, $project->modifieddate));
    if ($round) {
        $proofdate = mysql_query("\n            SELECT {$round->time_column_name}\n            FROM {$projectid}\n            WHERE state='{$round->page_save_state}'\n            ORDER BY {$round->time_column_name} DESC\n            LIMIT 1\n        ");
        if (mysql_num_rows($proofdate) != 0) {
            $latest_save_time = mysql_result($proofdate, 0, $round->time_column_name);
            $lastproofed = strftime($datetime_format, $latest_save_time);
        } else {
            $lastproofed = _("Project has not been proofread in this round.");
        }
        echo_row_a(_("Last Proofread"), $lastproofed);
    }
    // -------------------------------------------------------------------------
    // We choose not to show guests the word lists.
    if ($user_is_logged_in) {
        $good_bad = array('good' => _("Good Words"), 'bad' => _("Bad Words"));
        $links = '';
        foreach ($good_bad as $gb => $label) {
            $f = get_project_word_file($projectid, $gb);
            if ($f->size > 0) {
                $links .= new_window_link($f->abs_url, $label);
                $links .= " - " . _("Last modified") . ": " . strftime($datetime_format, $f->mod_time);
            } else {
                $links .= $label . " " . _("(empty)");
            }
            $links .= "<br>";
        }
        echo_row_a(_("Word Lists"), $links);
    }
    // -------------------------------------------------------------------------
    $state = $project->state;
    if ($state == PROJ_SUBMIT_PG_POSTED || $site_supports_corrections_after_posting && ($state == PROJ_CORRECT_AVAILABLE || $state == PROJ_CORRECT_CHECKED_OUT)) {
        $postednum = $project->postednum;
        echo_row_a(_("PG etext number"), $postednum . " &ndash; " . sprintf(_("<a href='%s'>Read this text</a> at Project Gutenberg"), get_pg_catalog_url_for_etext($postednum)));
    }
    // -------------------------------------------------------------------------
    // Forum topic
    $topic_id = $project->topic_id;
    if (!empty($topic_id)) {
        $last_post_date = get_last_post_time_in_topic($topic_id);
        $last_post_date = strftime($datetime_format, $last_post_date);
        echo_row_a(_("Last Forum Post"), $last_post_date);
    }
    // If the topic is only visible to logged-in users,
    // there's little point showing guests the link to it.
    if ($user_is_logged_in) {
        if ($state == PROJ_DELETE && $topic_id == "") {
            echo_row_a(_("Forum"), _("The project has been deleted, and no discussion exists."));
        } else {
            if ($topic_id == "") {
                $blurb = _("Start a discussion about this project");
                $url = "{$code_url}/tools/proofers/project_topic.php?project={$projectid}";
                echo_row_a(_("Forum"), "<a href='{$url}'>{$blurb}</a>");
            } else {
                $details = get_topic_details($topic_id);
                $url = get_url_to_view_topic($details["topic_id"]);
                $blurb = _("Discuss this project");
                $replies = sprintf(_("(%d replies)"), $details['num_replies']);
                echo_row_a(_("Forum"), "<a href='{$url}'>{$blurb}</a> {$replies}");
            }
        }
    }
    // -------------------------------------------------------------------------
    // For now, we say that guests can't see page details.
    if ($user_is_logged_in) {
        global $detail_level;
        if ($detail_level >= 4) {
            // We'll call do_page_table later, so we don't need the "Page Detail" link.
        } else {
            if ($project->pages_table_exists) {
                $url = "{$code_url}/tools/project_manager/page_detail.php?project={$projectid}&show_image_size=0";
                $blurb = _("Images, Pages Proofread, & Differences");
                $url2 = "{$url}&select_by_user";
                $blurb2 = _("Just my pages");
                $detail = "<a href='{$url}'>{$blurb}</a> &gt;&gt;<a href='{$url2}'>{$blurb2}</a>&lt;&lt;";
            } else {
                if ($project->archived != 0) {
                    $detail = _("The project has been archived, so page details are not available.");
                } elseif ($project->state == PROJ_DELETE) {
                    $detail = _("The project has been deleted, so page details are not available.");
                } else {
                    $detail = _("Page details are not available for this project.");
                }
            }
            echo_row_a(_("Page Detail"), $detail);
        }
    }
    // -------------------------------------------------------------------------
    // Personal data with respect to this project
    // If you're not logged in, we certainly can't show your personal data.
    if ($user_is_logged_in) {
        global $detail_level;
        if ($round && $detail_level > 1) {
            recentlyproofed(0);
            recentlyproofed(1);
        }
    }
    // -------------------------------------------------------------------------
    // Comments
    global $pguser;
    $postcomments = get_formatted_postcomments($project->projectid);
    if ($postcomments != '') {
        if ($available_for_SR) {
            echo_row_b(_("Instructions for Smooth Reading"), '');
            echo_row_c($postcomments);
        } elseif ($project->PPer_is_current_user || $project->PPVer_is_current_user || $project->can_be_managed_by_current_user || $state == PROJ_POST_FIRST_AVAILABLE && user_can_work_in_stage($pguser, 'PP') || $state == PROJ_POST_SECOND_AVAILABLE && user_can_work_in_stage($pguser, 'PPV')) {
            echo_row_b(_("Post Processor's Comments"), '');
            echo_row_c($postcomments);
        }
    }
    // --------
    // For now, we suppress Project Comments for guests.
    // (They might be confused by the instructions for proofreaders.)
    if ($user_is_logged_in) {
        $comments = $project->comments;
        // Automatically prepend second round comments template for Beginners Only
        // The r2 in the template name is an artifact of the old two-round structure
        if ($project->difficulty == "beginner") {
            if ($round && $round->is_a_mentor_round()) {
                $comments = "[template=BGr2.txt]" . $comments;
            }
        }
        // insert e.g. templates and biographies
        $comments = parse_project_comments($comments);
        if ($comments == '') {
            // Put in *something*, otherwise it'll probably look odd.
            $comments = '&nbsp;';
        }
        if ($round) {
            $a = sprintf(_("The <a href='%s'>Guidelines</a> give detailed instructions for working in this round."), "{$code_url}/faq/{$round->document}");
            $b = _('The instructions below are particular to this project, and <b>take precedence over those guidelines</b>.');
            $time_str = strftime($datetime_format, $project->t_last_change_comments);
            $c = "(" . _("Last modified") . ": " . $time_str . ")";
            $comments_blurb = "{$a}<br>{$b}<br>{$c}";
        } else {
            $comments_blurb = "";
        }
        echo_row_b(_("Project Comments"), $comments_blurb);
        echo_row_c($comments);
    }
    // -------------------------------------------------------------------------
    echo "</table>";
}
 function show_visible_controls()
 {
     $goodWordData = html_safe($this->good_words);
     $badWordData = html_safe($this->bad_words);
     $fields = array("projectid" => _("Project ID"), "nameofwork" => _("Name of Work"), "authorsname" => _("Author's Name"), "projectmanager" => _("Project Manager"), "checkedoutby" => _("Post-Processor"), "language" => _("Language"));
     foreach ($fields as $field => $label) {
         echo "<tr>";
         echo "<td class='label'>{$label}</td>";
         echo "<td>" . $this->{$field} . "</td>";
         echo "</tr>";
     }
     $exist_OCR_pages = $this->number_of_pages_in_round(null) > 0;
     $exist_pages_in_P1_or_later = $this->number_of_pages_in_round(get_Round_for_round_number(1)) > 0;
     // due to some special circumstances, not all projects may have pages in P1
     // so we'll check to see if the project is in a state after P1 and count
     // that as just as good
     if (!$exist_pages_in_P1_or_later) {
         $current_project_round = get_Round_for_project_state($this->state);
         if ($current_project_round && $current_project_round->round_number > 1) {
             $exist_pages_in_P1_or_later = true;
         }
     }
     // if the project doesn't have any OCR pages and the project
     // has no P1 or later pages, report a message. The second criteria
     // is important for type-in projects that may have no OCR pages but
     // will have P1 or later pages
     if (!$exist_OCR_pages && !$exist_pages_in_P1_or_later) {
         echo "<tr>";
         echo "<td colspan='2'>";
         echo "<p class='error' style='text-align: center;'>";
         echo _("There are no pages associated with this project.");
         echo "</p>";
         echo "</td>";
         echo "</tr>";
     } else {
         echo "<tr>";
         echo "<td class='label' style='text-align: center;' colspan='2'>";
         echo _("WordCheck Tools and Reports");
         echo "</td>";
         echo "</tr>";
         echo "<tr>";
         echo "<td class='label'>" . _("Ad Hoc Word Details") . "</td>";
         echo "<td>" . new_window_link("show_adhoc_word_details.php?projectid={$this->projectid}", _("Show details for ad hoc words")) . "</td>";
         echo "</tr>";
         echo "<tr>";
         echo "<td class='label'>" . _("WordCheck Statistics") . "</td>";
         echo "<td>" . new_window_link("show_project_wordcheck_stats.php?projectid={$this->projectid}", _("Show WordCheck flagged word statistics")) . "</td>";
         echo "</tr>";
         if ($exist_pages_in_P1_or_later) {
             echo "<tr>";
             echo "<td class='label'>" . _("WordCheck Usage") . "</td>";
             echo "<td>" . new_window_link("show_project_wordcheck_usage.php?projectid={$this->projectid}", _("Show WordCheck interface usage")) . "</td>";
             echo "</tr>";
         }
         echo "<tr>";
         echo "<td class='label' style='text-align: center;' colspan='2'>";
         echo _("Word List Suggestion Tools");
         echo "</td>";
         echo "</tr>";
         echo "<tr>";
         echo "<td colspan='2'>";
         echo "<table width='100%'>";
         echo "<tr>";
         echo "<td style='width: 50%; text-align: center;' valign='top'>";
         echo "<p>";
         echo "<b>" . _("Words that WordCheck would currently flag:") . "</b><br>";
         echo new_window_link("show_current_flagged_words.php?projectid={$this->projectid}", _("Display"));
         echo " | ";
         echo "<a href='show_current_flagged_words.php?projectid={$this->projectid}&amp;format=file'>" . _("Download") . "</a>";
         echo "</p>";
         $suggestions = load_project_good_word_suggestions($this->projectid);
         if (count($suggestions)) {
             echo "<p>";
             echo "<b>" . _("Suggestions from proofreaders:") . "</b><br>";
             echo new_window_link("show_good_word_suggestions.php?projectid={$this->projectid}", _("Display"));
             echo " | ";
             echo "<a href='show_good_word_suggestions.php?projectid={$this->projectid}&amp;timeCutoff=0&amp;format=file'>" . _("Download") . "</a>";
             echo "</p>";
         }
         echo "</td>";
         echo "<td style='width: 50%; text-align: center;' valign='top'>";
         // see if the site has Possible Bad Word files
         $possible_bad_words = load_site_possible_bad_words_given_project($this->projectid);
         if (count($possible_bad_words)) {
             echo "<p>";
             echo "<b>" . _("Words in the Site's Possible bad words file:") . "</b><br>";
             echo new_window_link("show_project_possible_bad_words.php?projectid={$this->projectid}", _("Display"));
             echo " | ";
             echo "<a href='show_project_possible_bad_words.php?projectid={$this->projectid}&amp;format=file'>" . _("Download") . "</a>";
             echo "</p>";
         }
         // see if there are P1 (or later) and OCR pages before showing the link.
         // type-in projects may have P1 (or later) pages but no OCR pages
         // and the current show_project_stealth_scannos.php page only works
         // with projects that have OCR text
         if ($exist_pages_in_P1_or_later && $exist_OCR_pages) {
             echo "<p>";
             echo "<b>" . _("Suggestions from diff analysis:") . "</b><br>";
             echo new_window_link("show_project_stealth_scannos.php?projectid={$this->projectid}", _("Display"));
             echo " | ";
             echo "<a href='show_project_stealth_scannos.php?projectid={$this->projectid}&amp;format=file'>" . _("Download") . "</a>";
             echo "</p>";
         }
         echo "</td>";
         echo "</tr>";
         echo "</table>";
         echo "</td>";
         echo "</tr>";
     }
     echo "<tr>";
     echo "<td class='label' style='text-align: center;' colspan='2'>";
     echo _("Project Dictionary - Word Lists");
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td colspan='2'>";
     echo "<table width='100%'>";
     echo "<tr>";
     echo "<td class='label' style='text-align: center;'>" . _("Good Words") . "</td>";
     echo "<td class='label' style='text-align: center;'>" . _("Bad Words") . "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td style='width: 50%;'>";
     echo "<textarea class='mono' name='good_words' cols='40' rows='20'>{$goodWordData}</textarea>";
     echo "</td>";
     echo "<td style='width: 50%;'>";
     echo "<textarea class='mono' name='bad_words' cols='40' rows='20'>{$badWordData}</textarea>";
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td colspan='2' style='text-align: center;'>";
     echo sprintf(_("See the %s for more information on word lists."), new_window_link("../../faq/wordcheck-faq.php", _("WordCheck FAQ")));
     echo "</td>";
     echo "</tr>";
 }
    asort($site_lists);
    foreach ($site_lists as $full_filename => $url) {
        $filename = basename($full_filename);
        if (!preg_match("/^(\\w+)_words\\.(\\w+)\\.txt\$/", $filename, $matches)) {
            // found a file we don't recognize so skip it
            continue;
        }
        list($null, $list_type, $langcode3) = $matches;
        $list_words = load_word_list($full_filename);
        $word_count = count($list_words);
        $language = langname_for_langcode3($langcode3);
        echo "<tr>";
        echo "<td><a href='manage_site_word_lists.php?action=edit&amp;list_type={$list_type}&amp;language={$language}'>" . _("Edit") . "</a> | <a href='manage_site_word_lists.php?action=delete&amp;list_type={$list_type}&amp;language={$language}'>" . _("Delete") . "</a></td>";
        echo "<td>{$list_type}</td>";
        echo "<td>{$language}</td>";
        echo "<td>" . new_window_link($url, $filename) . "</td>";
        echo "<td>{$word_count}</td>";
        echo "</tr>";
    }
    echo "</table>";
}
// Everything else is just function declarations.
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// handle any actionable request
// arguments:
//        $action - action to take
//                  one of: delete, deleteconfirmed, create, edit, save,
//                  saveconfirmed, list
//     $list_type - list type to operate on
//                  one of: good, bad, possible_bad
//      $language - the list language
</td>
    <td style='text-align: right;'><?php 
echo number_format($total["proj_bad_words_avg"], 3);
?>
</td>
</tr>
<tr>
    <td class='label'><?php 
echo _("Maximum flagged words per page");
?>
</td>
    <td style='text-align: right;'><?php 
echo $total["flagged_max"];
?>
 on <?php 
echo new_window_link("displayimage.php?project={$projectid}&amp;imagefile=" . $total["flagged_max_page"], $total["flagged_max_page"]);
?>
</a></td>
</tr>
<tr>
    <td class='label'><?php 
echo _("Minimum flagged words per page");
?>
</td>
    <td style='text-align: right;'><?php 
echo $total["flagged_min"];
?>
</td>
</tr>
<tr>
    <td class='label'><?php