function perform($action)
 {
     if ($action == 'scrape') {
         // INVOKE THE SCRAPER...
         $out = scrape_ScrapeURL($this->url);
         if ($out === NULL) {
             $this->scraper_output = "<strong>UHOH... ERROR</strong>";
         } else {
             $this->scraper_output = admMarkupPlainText($out);
         }
     } elseif ($action == 'delete') {
         $this->state = 'delete_requested';
     } elseif ($action == 'confirm_delete') {
         //ZAP!
         db_do("DELETE FROM missing_articles WHERE id=?", $this->id);
         db_commit();
         $this->state = 'deleted';
     } else {
         if ($action == 'edit') {
             $this->state = 'editing';
         }
     }
 }
    function emit_core()
    {
        $ae =& $this->submitted;
        /*
                $actions = array();
                if($ae->expected_journo && $ae->article) {
           $actions[] = 'add_journo';
           $actions[] = 'replace_journo';
                }
        */
        $struck = false;
        if ($ae->status == 'resolved' || $ae->status == 'rejected') {
            $struck = true;
        }
        ?>

<?php 
        if ($struck) {
            ?>
<del>
<?php 
        }
        ?>
<small>submitted <?php 
        echo pretty_date(strtotime($ae->when_submitted));
        ?>
 
<?php 
        if (!is_null($ae->submitted_by)) {
            ?>
by <a href="/adm/useraccounts?person_id=<?php 
            echo $ae->submitted_by->id;
            ?>
"><?php 
            echo $ae->submitted_by->email;
            ?>
</a> (<?php 
            echo $ae->submitted_by->name;
            ?>
)
<?php 
        }
        ?>
</small>
<br/>

<a href="<?php 
        echo $ae->url;
        ?>
"><?php 
        echo $ae->url;
        ?>
</a><br/>
problem: <?php 
        echo $ae->status;
        ?>
<br/>


<?php 
        if (!is_null($ae->article)) {
            ?>
article in the database: <a href="<?php 
            echo article_adm_url($ae->article->id);
            ?>
"><?php 
            echo $ae->article->title;
            ?>
</a>
<a class="button edit" href="/adm/editarticle?id36=<?php 
            echo article_id_to_id36($ae->article->id);
            ?>
">edit</a><br/>
<?php 
            if (sizeof($ae->article->authors) > 0) {
                ?>
&nbsp;&nbsp;attributed to:
<?php 
                foreach ($ae->article->authors as $author) {
                    echo admJournoLink($author->ref);
                    ?>
&nbsp;
<?php 
                }
            }
            ?>
<br/>
&nbsp;&nbsp;raw byline: <?php 
            echo $ae->article->byline;
            ?>
<br/>
<?php 
        }
        ?>


<?php 
        if (!is_null($ae->expected_journo)) {
            ?>
expected journo: <a class="journo-info" href="/adm/<?php 
            echo $ae->expected_journo->ref;
            ?>
"><?php 
            echo $ae->expected_journo->ref;
            ?>
</a><br/>
<?php 
        }
        ?>


<?php 
        if (!is_null($this->scraper_output)) {
            ?>
<div>
raw scraper output:
<pre><code>
<?php 
            echo admMarkupPlainText($this->scraper_output);
            ?>
</code></pre>
</div>
<?php 
        }
        ?>

<?php 
        if ($struck) {
            ?>
</del>
<?php 
        }
        ?>

<?php 
        foreach ($this->allowed_actions() as $action) {
            echo $this->action_link($action);
        }
        ?>

<?php 
    }
Ejemplo n.º 3
0
function Tabulate_defaultformat($row, $col, $prevrow = null)
{
    $cell = $row[$col];
    if ($cell instanceof DateTime) {
        return $cell->format('Y-m-d');
    } else {
        if (is_array($cell)) {
            if ($col == 'journo') {
                $j = $cell;
                $out = "<a href=\"/{$j['ref']}\" >{$j['prettyname']}</a>";
                if (array_key_exists('oneliner', $j)) {
                    $out .= " <small><em>({$j['oneliner']})</em></small>";
                }
                $out .= " <small>[<a href=\"/adm/{$j['ref']}\">admin page</a>]</small>";
                /* can provide an array of extra links */
                if (array_key_exists('extralinks', $j)) {
                    foreach ($j['extralinks'] as $l) {
                        $out .= " <small>[<a href=\"{$l['href']}\">{$l['text']}</a>]</small>";
                    }
                }
                return $out;
            }
            if ($col == 'article') {
                $a = $cell;
                // assume we've got title and id at least
                $out = "<a href=\"/article?id={$a['id']}\">{$a['title']}</a>";
                $out .= " <small>[<a href=\"/adm/article?id={$a['id']}\">admin page</a>]</small>";
                if (array_key_exists('permalink', $a)) {
                    $out .= " <small>[<a href=\"{$a['permalink']}\">original article</a>]</small>";
                }
                if (array_key_exists('srcorgname', $a)) {
                    $out .= " <small>{$a['srcorgname']}</small>";
                }
                if (array_key_exists('pubdate', $a)) {
                    $prettydate = date_create($a['pubdate'])->format('Y-m-d H:i');
                    $out .= " <small>{$prettydate}</small>";
                }
                return $out;
            }
            return "[array]";
        } else {
            if ($col == 'ref') {
                $ref = $cell;
                return sprintf('<a href="/%s">%s</a> [<a href="/adm/%s">admin page</a>]', $ref, $ref, $ref);
            }
            return admMarkupPlainText($cell);
        }
    }
}
Ejemplo n.º 4
0
function template($vars)
{
    extract($vars);
    admPageHeader();
    ?>
<h2>scrape article(s)</h2>

<form action="/adm/scrape" method="GET">
<table>
<?php 
    echo $urls_form->as_table();
    ?>
</table>
<input type="submit" name="submit" value="go" />
</form>


<?php 
    if ($urls_form->is_valid()) {
        ?>
<h3>Result: <?php 
        echo $summary;
        ?>
</h3>

<?php 
        if (!is_null($art)) {
            ?>

<div style="border: 1px solid black;">
<h4><a href="<?php 
            echo article_url($art['id']);
            ?>
"><?php 
            echo $art['title'];
            ?>
</a> [<a href="<?php 
            echo article_adm_url($art['id']);
            ?>
">adm</a>]<h4>
<?php 
            echo $art['srcorgname'];
            ?>
, <?php 
            echo $art['pretty_pubdate'];
            ?>
<br/>
url: <a href="<?php 
            echo $art['permalink'];
            ?>
"><?php 
            echo $art['permalink'];
            ?>
</a><br/>
attributed to:
<?php 
            if (sizeof($art['journos']) > 0) {
                ?>
<ul>
<?php 
                foreach ($art['journos'] as $j) {
                    ?>
<li><a href="/<?php 
                    echo $j['ref'];
                    ?>
"><?php 
                    echo $j['ref'];
                    ?>
</a> <small>[<a href="/adm/<?php 
                    echo $j['ref'];
                    ?>
">adm</a>]</small></li>
<?php 
                }
                ?>
</ul>
<?php 
            } else {
                ?>
- nobody -<br/>
<?php 
            }
            ?>
</div>

<?php 
        }
        ?>

<?php 
        if (!is_null($return_code)) {
            ?>
<h3>raw scraper output (returncode=<?php 
            echo $return_code;
            ?>
):</h3>
<div>
<code>
<pre>
<?php 
            echo admMarkupPlainText($raw_output);
            ?>
</pre>
</code>
</div>
<?php 
        }
    }
    admPageFooter();
    ?>

<?php 
}
Ejemplo n.º 5
0
function EmitDetails($srcid)
{
    $row = db_getRow("SELECT * FROM error_articlescrape WHERE srcid=?", $srcid);
    print "<table border=\"1\">\n";
    $fields = array('srcid', 'title', 'srcurl', 'attempts', 'action', 'firstattempt', 'lastattempt', 'report');
    foreach ($fields as $f) {
        printf("<tr><th>%s</th><td><pre>%s</pre></td></tr>\n", $f, admMarkupPlainText($row[$f]));
    }
    print "</table>\n";
}
Ejemplo n.º 6
0
function DoUpdateSimilars($article_id)
{
    $jlbin = OPTION_JL_FSROOT . '/bin';
    $cmd = "{$jlbin}/similar-article -v -a {$article_id} 2>&1";
    ?>
<h3>Updating similar-article list for article <?php 
    echo $article_id;
    ?>
</h3>
(<a href="/adm/article?id=<?php 
    echo $article_id;
    ?>
">back to article admin page</a>)<br/>
<tt><?php 
    echo $cmd;
    ?>
</tt>
<hr>
<?php 
    //	putenv("JL_DEBUG=2");
    ob_start();
    passthru($cmd);
    $output = ob_get_contents();
    ob_end_clean();
    ?>
<p><pre>
<?php 
    echo admMarkupPlainText($output);
    ?>
</pre></p>
<hr>
<?php 
}