<commit_before><?php

/***************************************************************************
 *   spt_view.php                                                          *
 *   Yggdrasil: Source Part Type View                                      *
 *                                                                         *
 *   Copyright (C) 2006-2011 by <NAME>                         *
 *   <EMAIL>                                                   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

// This script is basically a report listing sources of one type.
// It is accessed from the Source Part Type Manager via the 'report' link.

require "./settings/settings.php";
require "./functions.php";
require_once "./langs/$language.php";

$spt = $_GET['spt'];
$label = 'label_' . $language;
$spt_name = fetch_val("
    SELECT $label FROM source_part_types WHERE part_type_id = $spt
");
$title = "$_All $_sources $_of type $spt_name";
require "./header.php";

echo "<div class=\"normal\">\n";
echo "<h2>$title</h2>\n";

echo "<table>";
$handle = pg_query("
    SELECT
        source_id,
        link_expand(source_text) AS txt,
        sort_order,
        source_date,
        ecc(source_id) AS e,
        rcc(source_id) AS r,
        ssc(source_id) AS s,
        usc(source_id) AS u,
        spt.$label AS $label
    FROM
        sources, source_part_types spt
    WHERE
        spt.part_type_id = sources.part_type
    AND
        spt.part_type_id = $spt
    AND
        source_id <> 0
    ORDER BY
        sort_order,
        source_date,
        source_text
");
// change between FALSE and TRUE to select terse / informative mode
$friendly = TRUE;
while ($row = pg_fetch_assoc($handle)) {
    $id = $row['source_id'];
    echo '<tr>';
    if ($friendly) {
        echo td(paren(to_url('source_manager.php',
        array('node' => $id), $_Select)
        . '&nbsp;/&nbsp;'
        . to_url('./forms/source_edit.php',
                array(
                    'person'    => 0,
                    'source'    => $id), $_Edit)));
    }
    else {
        echo td_numeric(square_brace(to_url($_SERVER['PHP_SELF'],
                                array('node' => $id), $id, $_goto)));
        echo td_numeric(square_brace($row['sort_order']));
        echo td(paren(to_url('./forms/source_edit.php',
                array(
                    'person'    => 0,
                    'source'    => $id
                ), $row[$label], $_edit)));
    }
    if ($row['e'] || $row['r'] || $row['s']) {
        echo td(square_brace(italic($row['source_date']))
            . ' ' . $row['txt']
            . node_details($row['e'], $row['r'], $row['s'], $row['u']));
    }
    else { // source is unused, print with gray text
        if ($show_delete) { // show link for source deletion
            echo td(span_type(square_brace(italic($row['source_date']))
                . conc($row['txt']),"faded")
                . conc(paren(to_url('./forms/source_delete.php',
                            array(
                                'node'  => $self,
                                'id'    => $id
                            ), bold($_delete)))));
        }
        else
            echo td(span_type(square_brace(italic($row['source_date']))
                . conc($row['txt']), "faded"));
    }
    echo "</tr>\n";
}
echo "</table>\n";

include "./footer.php";
?>
<commit_msg>Fixed minor bug in spt_view.php<commit_after><?php

/***************************************************************************
 *   spt_view.php                                                          *
 *   Yggdrasil: Source Part Type View                                      *
 *                                                                         *
 *   Copyright (C) 2006-2011 by <NAME>                         *
 *   <EMAIL>                                                   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

// This script is basically a report listing sources of one type.
// It is accessed from the Source Part Type Manager via the 'report' link.

require "./settings/settings.php";
require "./functions.php";
require_once "./langs/$language.php";

$spt = $_GET['spt'];
$label = 'label_' . $language;
$spt_name = fetch_val("
    SELECT $label FROM source_part_types WHERE part_type_id = $spt
");
$title = "$_All $_sources $_of type $spt_name";
require "./header.php";

echo "<div class=\"normal\">\n";
echo "<h2>$title</h2>\n";

echo "<table>";
$handle = pg_query("
    SELECT
        source_id,
        link_expand(source_text) AS txt,
        sort_order,
        source_date,
        ecc(source_id) AS e,
        rcc(source_id) AS r,
        ssc(source_id) AS s,
        usc(source_id) AS u,
        spt.$label AS $label
    FROM
        sources, source_part_types spt
    WHERE
        spt.part_type_id = sources.part_type
    AND
        spt.part_type_id = $spt
    AND
        source_id <> 0
    ORDER BY
        sort_order,
        source_date,
        source_text
");
// change between FALSE and TRUE to select terse / informative mode
$friendly = TRUE;
while ($row = pg_fetch_assoc($handle)) {
    $id = $row['source_id'];
    echo '<tr>';
    if ($friendly) {
        echo td(paren(to_url('source_manager.php',
        array('node' => $id), $_Select)
        . '&nbsp;/&nbsp;'
        . to_url('./forms/source_edit.php',
                array(
                    'person'    => 0,
                    'source'    => $id), $_Edit)));
    }
    else {
        echo td_numeric(square_brace(to_url($_SERVER['PHP_SELF'],
                                array('node' => $id), $id, $_goto)));
        echo td_numeric(square_brace($row['sort_order']));
        echo td(paren(to_url('./forms/source_edit.php',
                array(
                    'person'    => 0,
                    'source'    => $id
                ), $row[$label], $_edit)));
    }
    if ($row['e'] || $row['r'] || $row['s']) {
        echo td(square_brace(italic($row['source_date']))
            . ' ' . $row['txt']
            . node_details($row['e'], $row['r'], $row['s'], $row['u']));
    }
    else { // source is unused, print with gray text
        echo td(span_type(square_brace(italic($row['source_date']))
            . conc($row['txt']), "faded"));
    }
    echo "</tr>\n";
}
echo "</table>\n";

include "./footer.php";
?>

{'fraction_non_alphanumeric': 0.15386381903777702, 'fraction_numerical': 0.006430129750832472, 'mean_word_length': 1.4871501998857795, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 40, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4064547', 'n_tokens_mistral': 2345, 'n_tokens_neox': 2255, 'n_words': 638}