コード例 #1
0
ファイル: module_tags.php プロジェクト: laiello/pivotx-sqlite
/**
 * Indexes tags in entries in the PivotX database and returns true
 * if there are more entries to index.
 *
 * @param int $start Code for first entry to index
 * @param int $stop Code for last entry to index
 * @param int $time Indexing time.
 * @return boolean
 */
function writeTagIndex($start, $stop, $time)
{
    global $PIVOTX, $output;
    $entries = $PIVOTX['db']->db_lowlevel->date_index;
    $count = 0;
    $date = date('Y-m-d-H-i');
    foreach ($entries as $key => $value) {
        if ($count++ < $start) {
            continue;
        }
        if ($count > $stop) {
            break;
        }
        $entry = $PIVOTX['db']->read_entry($key);
        // rules: index if all are true:
        // - ( status == 'publish' )or(( status == 'timed')&&( publish_date <= date ))
        // - at least one category is in array of 'not hidden' categories..
        // check status and date
        if ('publish' == $entry['status'] || 'timed' == $entry['status'] && $entry['publish_date'] <= $date) {
            if ($count % 50 == 0) {
                $output .= sprintf(__("%1.2f sec: Processed %d entries...") . "<br />\n", timeTaken('int') + $time, $count);
            }
            writeTags($entry['keywords'], '', $key);
        }
    }
    // decide if we need to do some more.
    if (count($entries) > $stop) {
        return true;
    }
}
コード例 #2
0
ファイル: helper_functions.php プロジェクト: R-J/vanilla
    /**
     *
     *
     * @param $Discussion
     * @param $Sender
     * @param $Session
     */
    function writeDiscussion($Discussion, $Sender, $Session)
    {
        $CssClass = CssClass($Discussion);
        $DiscussionUrl = $Discussion->Url;
        $Category = CategoryModel::categories($Discussion->CategoryID);
        if ($Session->UserID) {
            $DiscussionUrl .= '#latest';
        }
        $Sender->EventArguments['DiscussionUrl'] =& $DiscussionUrl;
        $Sender->EventArguments['Discussion'] =& $Discussion;
        $Sender->EventArguments['CssClass'] =& $CssClass;
        $First = UserBuilder($Discussion, 'First');
        $Last = UserBuilder($Discussion, 'Last');
        $Sender->EventArguments['FirstUser'] =& $First;
        $Sender->EventArguments['LastUser'] =& $Last;
        $Sender->fireEvent('BeforeDiscussionName');
        $DiscussionName = $Discussion->Name;
        if ($DiscussionName == '') {
            $DiscussionName = t('Blank Discussion Topic');
        }
        $Sender->EventArguments['DiscussionName'] =& $DiscussionName;
        static $FirstDiscussion = true;
        if (!$FirstDiscussion) {
            $Sender->fireEvent('BetweenDiscussion');
        } else {
            $FirstDiscussion = false;
        }
        $Discussion->CountPages = ceil($Discussion->CountComments / $Sender->CountCommentsPerPage);
        ?>
        <li id="Discussion_<?php 
        echo $Discussion->DiscussionID;
        ?>
" class="<?php 
        echo $CssClass;
        ?>
">
            <?php 
        if (!property_exists($Sender, 'CanEditDiscussions')) {
            $Sender->CanEditDiscussions = val('PermsDiscussionsEdit', CategoryModel::categories($Discussion->CategoryID)) && c('Vanilla.AdminCheckboxes.Use');
        }
        $Sender->fireEvent('BeforeDiscussionContent');
        ?>
            <span class="Options">
      <?php 
        echo optionsList($Discussion);
        echo bookmarkButton($Discussion);
        ?>
   </span>

            <div class="ItemContent Discussion">
                <div class="Title">
                    <?php 
        echo adminCheck($Discussion, array('', ' ')) . anchor($DiscussionName, $DiscussionUrl);
        $Sender->fireEvent('AfterDiscussionTitle');
        ?>
                </div>
                <div class="Meta Meta-Discussion">
                    <?php 
        writeTags($Discussion);
        ?>
                    <span class="MItem MCount ViewCount"><?php 
        printf(pluralTranslate($Discussion->CountViews, '%s view html', '%s views html', t('%s view'), t('%s views')), bigPlural($Discussion->CountViews, '%s view'));
        ?>
</span>
         <span class="MItem MCount CommentCount"><?php 
        printf(pluralTranslate($Discussion->CountComments, '%s comment html', '%s comments html', t('%s comment'), t('%s comments')), bigPlural($Discussion->CountComments, '%s comment'));
        ?>
</span>
         <span class="MItem MCount DiscussionScore Hidden"><?php 
        $Score = $Discussion->Score;
        if ($Score == '') {
            $Score = 0;
        }
        printf(plural($Score, '%s point', '%s points', bigPlural($Score, '%s point')));
        ?>
</span>
                    <?php 
        echo newComments($Discussion);
        $Sender->fireEvent('AfterCountMeta');
        if ($Discussion->LastCommentID != '') {
            echo ' <span class="MItem LastCommentBy">' . sprintf(t('Most recent by %1$s'), userAnchor($Last)) . '</span> ';
            echo ' <span class="MItem LastCommentDate">' . Gdn_Format::date($Discussion->LastDate, 'html') . '</span>';
        } else {
            echo ' <span class="MItem LastCommentBy">' . sprintf(t('Started by %1$s'), userAnchor($First)) . '</span> ';
            echo ' <span class="MItem LastCommentDate">' . Gdn_Format::date($Discussion->FirstDate, 'html');
            if ($Source = val('Source', $Discussion)) {
                echo ' ' . sprintf(t('via %s'), t($Source . ' Source', $Source));
            }
            echo '</span> ';
        }
        if ($Sender->data('_ShowCategoryLink', true) && c('Vanilla.Categories.Use') && $Category) {
            echo wrap(anchor(htmlspecialchars($Discussion->Category), CategoryUrl($Discussion->CategoryUrlCode)), 'span', array('class' => 'MItem Category ' . $Category['CssClass']));
        }
        $Sender->fireEvent('DiscussionMeta');
        ?>
                </div>
            </div>
            <?php 
        $Sender->fireEvent('AfterDiscussionContent');
        ?>
        </li>
    <?php 
    }
コード例 #3
0
ファイル: pv_core.php プロジェクト: wborbajr/TecnodataApp
/**
 * The screen you'll see after submitting an entry. It stores the entry, updates the indices (pivot's
 * content indices, and the search index), rebuilds the frontpage and XML & Atom feeds, and then it
 * displays a list of the latest entries.
 *
 */
function entrysubmit_screen()
{
    global $db, $config_array, $Pivot_Vars, $entry, $Cfg, $Users, $Paths, $Weblogs, $filtered_words;
    // check against unauthorised direct access.
    check_csrf();
    $db = new db();
    $entry = get_entry_from_post();
    if (!$entry['title'] == "" || !$entry['introduction'] == "" || !$entry['user'] == "") {
        // in this part, we remove the entry from the categories in which
        // the current user is not allowed to post entries
        foreach ($entry['category'] as $my_cat) {
            $allowed = explode("|", $Cfg['cat-' . $my_cat]);
            if (in_array($Pivot_Vars['user'], $allowed)) {
                $allowed_cats[] = $my_cat;
            } else {
                $message .= '<br />';
                $message .= sprintf(lang('entries', 'entry_catnopost'), $m_cat);
                debug("not in category: " . $my_cat);
            }
        }
        $entry['category'] = $allowed_cats;
        $db->set_entry($entry);
        if ($db->save_entry(TRUE)) {
            $message = sprintf(lang('entries', 'entry_saved_ok') . $message, '<i>' . trimtext($entry['title'], 25) . '</i>');
        } else {
            $message = sprintf(lang('entries', 'entry_saved_ok'), '<i>' . trimtext($entry['title'], 25) . '</i>');
        }
        // only trigger the ping if it's a new entry..
        if ($entry['code'] == ">" && $entry['status'] == "publish") {
            $ping = TRUE;
        } else {
            $ping = FALSE;
        }
        // only notify if entry is published, and is either new or status changed to publish.
        if ($entry['status'] == "publish") {
            if ($entry['code'] == ">" || $entry['oldstatus'] != "publish") {
                $notified = notify_new('entry', $db->entry);
                $notified = "<br /><br />" . $notified;
            }
        }
        // if the global index as they are made var is set - can continue
        if ('1' == $Cfg['search_index']) {
            /*
            			2004/10/16 =*=*= JM
            			an entry should only be indexed if both are true:
            			 - 'publish'==$entry['status']
            			 - current date is at least equal to $entry['publish_date']
            			I lie, there is another case...
            			it is conceivable that this is a timed publish AND the time has come
            			I will leave this to timed publish routines - if I can find them...
            			-> pvLib ... it's flagged
            and of course, providing that there is at least one
            			category where it would be indexed...
            something else that can't be tested... if the user changes a normal
            			publish to a timed-publish, or puts on hold when it was previously
            			normal. user should reindex in this case
            */
            // check status and date
            if ('publish' == $entry['status'] || 'timed' == $entry['status'] && $entry['publish_date'] <= date('Y-m-d-H-i')) {
                // categories...
                if (can_search_cats(cfg_cat_nosearchindex(), $entry['category'])) {
                    include_once 'modules/module_search.php';
                    update_index($db->entry);
                    debug('update search index: ' . $db->entry['code']);
                }
            }
        }
        // perhaps send a trackback ping.
        if ($Pivot_Vars['tb_url'] != "" && $entry['status'] == "publish") {
            debug("tburl: " . $Pivot_Vars['tb_url']);
            require_once 'includes/send_trackback.php';
            $weblogs = find_weblogs_with_cat($db->entry['category']);
            if (isset($Weblogs[$weblogs[0]])) {
                $my_url = $Paths['host'] . make_filelink($db->entry['code'], $weblogs[0], '');
                $weblog_title = $Weblogs[$weblogs[0]]['name'];
                debug("TRACKBACK ping: {$my_url}");
                $message .= '<br />';
                $message .= sprintf(lang('entries', 'entry_ping_sent'), $Pivot_Vars['tb_url']);
                $tb_urls = explode("\n", $Pivot_Vars['tb_url']);
                // make the contents of what to send with the trackback..
                $tb_contents = parse_step4($entry['introduction']);
                if ($Pivot_Vars['convert_lb'] == 2) {
                    $tb_contents = pivot_textile($tb_contents);
                } else {
                    if ($Pivot_Vars['convert_lb'] == 3 || $Pivot_Vars['convert_lb'] == 4) {
                        $tb_contents = pivot_markdown($tb_contents, $Pivot_Vars['convert_lb']);
                    }
                }
                $tb_contents = trimtext(strip_tags($tb_contents), 255);
                foreach ($tb_urls as $tb_url) {
                    $tb_url = trim($tb_url);
                    if (isurl($tb_url)) {
                        trackback_send($Pivot_Vars['tb_url'], $my_url, $entry['title'], $weblog_title, $tb_contents);
                    }
                }
            }
        }
        // Update the tags for this entry if it's published and remove the old tags if not
        if ($db->entry['status'] == 'publish') {
            writeTags($db->entry['keywords'], $_POST['f_keywords_old'], $db->entry['code']);
        } else {
            deleteTags($_POST['f_keywords_old'], $db->entry['code']);
        }
    }
    generate_pages($db->entry['code'], TRUE, TRUE, TRUE, $ping);
    entries_screen($message . $notified);
}
コード例 #4
0
 function index_entries($dirname)
 {
     global $PIVOTX;
     if (is_dir($PIVOTX['paths']['db_path'] . $dirname)) {
         $d = dir($PIVOTX['paths']['db_path'] . $dirname);
         while ($filename = $d->read()) {
             if (strlen($filename) == 9) {
                 $filelist[] = $filename;
             }
         }
         foreach ($filelist as $file) {
             $result = $this->read_entry_filename($PIVOTX['paths']['db_path'] . $dirname . "/" . $file, TRUE);
             if ($result) {
                 debug("({$file} is ok: " . $this->entry['title'] . " - " . $this->entry['date'] . ")");
             } else {
                 debug("(<b>{$file} is NOT ok: </b>" . $this->entry['title'] . " - " . $this->entry['date'] . ")");
             }
             // Write the tags for this entry if it's published
             if ($this->entry['status'] == 'publish') {
                 $tags = getTags(false, $this->entry['introduction'] . $this->entry['body'], $this->entry['keywords']);
                 if (is_array($tags) && count($tags) > 0) {
                     writeTags($tags, '', $this->entry['code']);
                 }
             }
         }
         $d->close();
         $this->write_entry_index(TRUE);
     }
 }