Exemplo n.º 1
0
 public function searchArticles($articleSearchCriteria, $onlyPublished = true)
 {
     $keywords = array_diff(explode(',', $articleSearchCriteria->query), array(''));
     $webcodeMatches = preg_grep("`^\\s*[\\+@]`", $keywords);
     if (count($webcodeMatches)) {
         $webcode = ltrim(current($webcodeMatches), '@+');
         $article = $this->webcoder->findArticleByWebcode($webcode);
         if ($article) {
             return array($article);
         }
     }
     $articles = $this->em->getRepository('Newscoop\\Entity\\Article')->searchArticles($articleSearchCriteria, $onlyPublished)->getResult();
     return $articles;
 }
Exemplo n.º 2
0
<?php

/**
 * @package Newscoop
 * @copyright 2012 Sourcefabric o.p.s.
 * @license http://www.gnu.org/licenses/gpl-3.0.txt
 */
require_once APPLICATION_PATH . '/../library/Newscoop/Webcode.php';
require_once APPLICATION_PATH . '/../library/Newscoop/Webcode/Mapper.php';
global $application;
$application->bootstrap('container');
$em = Zend_Registry::get('container')->getService('em');
foreach ($em->getRepository('Newscoop\\Entity\\Article')->findAll() as $article) {
    try {
        Zend_Registry::get('container')->getService('webcode')->setArticleWebcode($article, trim(Newscoop\Webcode\Mapper::encode($article->getNumber()), '@+'));
    } catch (\InvalidArgumentException $e) {
        // generate new on duplicate
        Zend_Registry::get('container')->getService('webcode')->setArticleWebcode($article);
    }
}