Inheritance: extends DatabaseObject
Example #1
0
 /**
  * @see Console\Command\Command
  */
 protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
 {
     $res = \ArticleIndex::RunIndexer($input->getOption('time-limit'));
     if ($input->getOption('verbose')) {
         $output->writeln($res['articles'] . ' out of ' . $res['total articles'] . ' articles were indexed with a total of ' . $res['words'] . ' words.');
         $output->writeln('Total index time was ' . sprintf("%.3f", $res['total time'] . ' seconds.'));
         $output->writeln('Average article index time was ' . sprintf("%.3f", $res['article time']) . ' seconds.');
     }
 }
Example #2
0
                    camp_html_goto_page($backLink);
                } else {
                    $tmpArticle->move($f_destination_publication_id, $f_destination_issue_number, $f_destination_section_number);
                    $tmpArticle->setWorkflowStatus('S');
                    \Zend_Registry::get('container')->getService('dispatcher')->dispatch('article.submit', new \Newscoop\EventDispatcher\Events\GenericEvent($this, array('article' => $tmpArticle)));
                    $tmpArticles[] = $tmpArticle;
                }
            }
        }
        $tmpArticle = camp_array_peek($tmpArticles);
        if ($f_mode == "single") {
            $url = camp_html_article_url($tmpArticle, $tmpArticle->getLanguageId(), "edit.php");
        } else {
            $url = $destArticleIndexUrl;
        }
        ArticleIndex::RunIndexer(3, 10, true);
        camp_html_goto_page($url);
    }
}
// END perform the action
$title = "";
if (count($doAction) > 1) {
    if ($f_action == "duplicate") {
        $title = $translator->trans("Duplicate articles", array(), 'articles');
    } elseif ($f_action == "move") {
        $title = $translator->trans("Move articles", array(), 'articles');
    } elseif ($f_action == "publish") {
        $title = $translator->trans("Publish articles", array(), 'articles');
    } elseif ($f_action == "submit") {
        $title = $translator->trans("Submit articles", array(), 'articles');
    }
Example #3
0
    /**
     * Performs a search against the article content using the given
     * keywords. Returns the list of articles matching the given criteria.
     *
     * @param string $p_searchPhrase
     * @param string $p_fieldName - may be 'title' or 'author'
     * @param bool $p_matchAll - true if all keyword have to match
     * @param array $p_constraints
     * @param array $p_order
     * @param int $p_start - return results starting from the given order number
     * @param int $p_limit - return at most $p_limit rows
     * @param int $p_count - sets $p_count to the total number of rows in the search
     * @param bool $p_countOnly - if true returns only the total number of rows
     * @return array
     */
    public static function SearchByKeyword($p_searchPhrase,
                                           $p_matchAll = false,
                                           array $p_constraints = array(),
                                           array $p_order = array(),
                                           $p_start = 0,
                                           $p_limit = 0,
                                           &$p_count,
                                           $p_countOnly = false)
    {
        global $g_ado_db;

        $selectClauseObj = new SQLSelectClause();

        // set tables and joins between tables
        $selectClauseObj->setTable('Articles');

        if ($p_matchAll) {
            $p_searchPhrase = '__match_all ' . $p_searchPhrase;
        }
        $mainClauseConstraint = "(Articles.Number, Articles.IdLanguage) IN ("
        . ArticleIndex::SearchQuery($p_searchPhrase) . ")";
        $selectClauseObj->addWhere($mainClauseConstraint);

        $joinTables = array();
        // set other constraints
        foreach ($p_constraints as $constraint) {
            $leftOperand = $constraint->getLeftOperand();
            $operandAttributes = explode('.', $leftOperand);
            if (count($operandAttributes) == 2) {
                $table = trim($operandAttributes[0]);
                if (strtolower($table) != 'articles') {
                    $joinTables[] = $table;
                }
            }
            $symbol = $constraint->getOperator()->getSymbol('sql');
            $rightOperand = "'" . $g_ado_db->escape($constraint->getRightOperand()) . "'";
            $selectClauseObj->addWhere("$leftOperand $symbol $rightOperand");
        }
        foreach ($joinTables as $table) {
            $selectClauseObj->addJoin("LEFT JOIN $table ON Articles.Number = $table.NrArticle");
        }

        // create the count clause object
        $countClauseObj = clone $selectClauseObj;

        // set the columns for the select clause
        $selectClauseObj->addColumn('Articles.Number');
        $selectClauseObj->addColumn('Articles.IdLanguage');

        // set the order for the select clause
        $p_order = count($p_order) > 0 ? $p_order : Article::$s_defaultOrder;
        $order = Article::ProcessListOrder($p_order);
        foreach ($order as $orderDesc) {
            $orderField = $orderDesc['field'];
            $orderDirection = $orderDesc['dir'];
            $selectClauseObj->addOrderBy($orderField . ' ' . $orderDirection);
        }

        // sets the LIMIT start and offset values
        $selectClauseObj->setLimit($p_start, $p_limit);

        // set the column for the count clause
        $countClauseObj->addColumn('COUNT(*)');

        $articlesList = array();
        if (!$p_countOnly) {
            $selectQuery = $selectClauseObj->buildQuery();
            $articles = $g_ado_db->GetAll($selectQuery);
            foreach ($articles as $article) {
                $articlesList[] = new Article($article['IdLanguage'], $article['Number']);
            }
        }
        $countQuery = $countClauseObj->buildQuery();
        $p_count = $g_ado_db->GetOne($countQuery);
        return $articlesList;
    }