protected function loadOne($file)
 {
     $xml = new SimpleXMLElement($file, 0, true);
     if ((string) $xml->head->title == null) {
         return null;
     }
     $article = new Article();
     foreach ($xml->head->meta as $meta) {
         $name = (string) $meta['name'];
         $content = (string) $meta['content'];
         switch ($name) {
             case 'date':
                 $article->setPublicationDate(new DateTime($content));
                 break;
             case 'author':
                 $article->setAuthor($content);
                 break;
         }
     }
     $article->setTitle((string) $xml->head->title);
     $article->setHash($this->getHash($article->getTitle()));
     $content = "";
     foreach ($xml->body->children() as $child) {
         $content .= $child->asXml();
     }
     $article->setContent($content);
     return $article;
 }
Example #2
0
 function getArticle()
 {
     $article = new Article();
     if (!$this->domLiteDocument) {
         die("not domLiteDocument...");
     }
     $temp =& $this->domLiteDocument->getElementsByPath("/SERIAL");
     for ($i = 0; $i < $temp->getLength(); $i++) {
         $item = $temp->item($i);
         $article->setSerial($this->getNodeText($item, 'TITLEGROUP/TITLE'));
     }
     $temp =& $this->domLiteDocument->getElementsByPath("//ISSUEINFO");
     for ($i = 0; $i < $temp->getLength(); $i++) {
         $item = $temp->item($i);
         $article->setVolume($this->getNodeAttribute($item, 'VOL'));
         $article->setNumber($this->getNodeAttribute($item, 'NUM'));
         $article->setSuppl($this->getNodeAttribute($item, 'SUPPL'));
         $article->setYear($this->getNodeAttribute($item, 'YEAR'));
     }
     $temp =& $this->domLiteDocument->getElementsByPath("//ARTICLE");
     for ($i = 0; $i < $temp->getLength(); $i++) {
         $item = $temp->item($i);
         $article->setPublicationDate($this->getNodeText($item, 'publication-date'));
         $article->setTitle($this->getNodeXML($item, 'TITLES'));
         $article->setAuthorXML($this->getNodeXML($item, 'AUTHORS'));
         $article->setKeywordXML($this->getNodeXML($item, 'KEYWORDS'));
         $article->setAbstractXML($this->getNodeXML($item, 'ABSTRACT'));
     }
     return $article;
 }
Example #3
0
 function getArticles()
 {
     $xml = $this->getXML();
     $XML_XSL = new XSL_XML();
     $content = $XML_XSL->xml_xsl($xml, dirname(__FILE__) . "/../../xsl/similarToArray.xsl");
     $content = str_replace('<?xml version="1.0" encoding="ISO-8859-1"?>', '', $content);
     $articles = split('\\|SIMILAR_SPLIT\\|', $content);
     $article = new Article();
     for ($i = 0; $i < count($articles) - 1; $i++) {
         $articles[$i] = split('\\|ITEM_SPLIT\\|', $articles[$i]);
         if (trim($articles[$i][0]) != '') {
             $article->setPID(trim($articles[$i][0]));
             $article->setPublicationDate(trim($articles[$i][1]));
             $article->setRelevance(trim($articles[$i][2]));
             $article->setURL(trim($articles[$i][3]));
             $article->setTitle(trim($articles[$i][4]));
             $article->setSerial(trim($articles[$i][5]));
             $article->setVolume(trim($articles[$i][6]));
             $article->setNumber(trim($articles[$i][7]));
             $article->setYear(trim($articles[$i][8]));
             $article->setSuppl(trim($articles[$i][9]));
             $article->setAuthorXML(str_replace("\n", "", trim($articles[$i][10])));
             $article->setKeywordXML(trim($articles[$i][11]));
             $arrArticles[$i] = $article;
         }
     }
     //	die(print_r($arrArticles));
     return $arrArticles;
 }
function upload_article_handler(&$request, &$session, &$files) {
	$publication = Input::Get('Pub', 'int', 0);
	$issue = Input::Get('Issue', 'int', 0);
	$section = Input::Get('Section', 'int', 0);
	$language = Input::Get('Language', 'int', 0);
	$sLanguage = Input::Get('sLanguage', 'int', 0);
	$articleNumber = Input::Get('Article', 'int', 0);

	if (!Input::IsValid()) {
		echo "Input Error: Missing input";
		return;
	}

	// Unzip the sxw file to get the content.
	$zip = zip_open($files["filename"]["tmp_name"]);
	if ($zip) {
		$xml = null;
		while ($zip_entry = zip_read($zip)) {
			if (zip_entry_name($zip_entry) == "content.xml") {
		       	if (zip_entry_open($zip, $zip_entry, "r")) {
		           	$xml = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
			        zip_entry_close($zip_entry);
		       	}
			}
		}
		zip_close($zip);

		if (!is_null($xml)) {
			// Write the XML to a file because the XSLT functions
			// require it to be in a file in order to be processed.
			$tmpXmlFilename = tempnam("/tmp", "ArticleImportXml");
			$tmpXmlFile = fopen($tmpXmlFilename, "w");
			fwrite($tmpXmlFile, $xml);
			fclose($tmpXmlFile);

			// Transform the OpenOffice document to DocBook format.
			$xsltProcessor = xslt_create();
			$docbookXml = xslt_process($xsltProcessor,
									   $tmpXmlFilename,
									   "sxwToDocbook.xsl");
			unlink($tmpXmlFilename);

			// Parse the docbook to get the data.
			$docBookParser = new DocBookParser();
			$docBookParser->parseString($docbookXml, true);

			$article = new Article($articleNumber, $language);
			$article->setTitle($docBookParser->getTitle());
			$article->setIntro($docBookParser->getIntro());
			$article->setBody($docBookParser->getBody());

			// Go back to the "Edit Article" page.
			header("Location: /$ADMIN/articles/edit.php?Pub=$publication&Issue=$issue&Section=$section&Article=$articleNumber&Language=$language&sLanguage=$sLanguage");
		} // if (!is_null($xml))
	} // if ($zip)

	// Some sort of error occurred - show the upload page again.
	include("index.php");
} // fn upload_article_handler
 public function testSave()
 {
     $article = new Article();
     $article->setCreatedAt(time());
     $article->setTitle('test');
     $article->setText('test text');
     $this->assertTrue($this->db->save($article));
 }
 public function __invoke($args)
 {
     if (count($args) < 2) {
         throw new OrongoScriptParseException("Arguments missing for Articles.SetTitle()");
     }
     $article = new Article($args[0]);
     $article->setTitle($args[1]);
 }
Example #7
0
 public function executeAddArticleAndSave(sfWebRequest $request)
 {
     $article = new Article();
     $article->setTitle(__METHOD__ . '()');
     $category = CategoryPeer::retrieveByPK($request->getParameter('category_id'));
     $category->addArticle($article);
     $category->save();
     return sfView::NONE;
 }
 public function testGetInsertingData()
 {
     $article = new Article();
     $article->setCreatedAt(time());
     $article->setTitle('test');
     $article->setText('test text');
     $data = $this->helper->getInsertingData($article);
     $this->assertCount(3, $data);
     $this->assertArrayHasKey('created_at', $data);
     $this->assertArrayHasKey('title', $data);
     $this->assertArrayHasKey('text', $data);
 }
Example #9
0
 function getMyProfileArticleList($article_profile)
 {
     // 1 - SELECT nos profiles do Usuarios
     // 2 - Pra cada Profile: pego a lista de artigos (olho na profiele_article
     // 3 - devolvo array de perfis com os artigos
     $this->setMyProfiles($article_profile->getUserID());
     $profiles_result = $this->getMyProfiles();
     //$articleProfileList[] = array();
     for ($p = 0; $p < count($profiles_result); $p++) {
         $profile_id = $profiles_result[$p]['profile_id'];
         $profile_name = $profiles_result[$p]['profile_name'];
         $articleProfileList[intval($profile_id)] = array();
         $order = $_GET['order'];
         switch ($order) {
             case "date":
                 $order_by = " ORDER BY articles.publication_date desc";
                 break;
             case "relevance":
                 $order_by = " ORDER BY relevance desc";
                 break;
             default:
                 $order_by = null;
         }
         $where_new = isset($_GET['new']) ? ' and is_new=1' : null;
         $strsql = "SELECT profile_article.*,articles.publication_date FROM profile_article,articles WHERE articles.PID = profile_article.PID and profile_id = '" . $profile_id . "'" . $where_new . " " . $order_by;
         $result = $this->_db->databaseQuery($strsql);
         for ($i = 0; $i < count($result); $i++) {
             $relevance = $result[$i]['relevance'];
             $query_article = "SELECT * FROM articles WHERE PID = '" . $result[$i]['PID'] . "' LIMIT 1";
             $article_result = $this->_db->databaseQuery($query_article);
             $articleProfile = new MyProfileArticle();
             $article = new Article();
             $article->setPID($article_result[0]['PID']);
             $article->setURL($article_result[0]['url']);
             $article->setTitle($article_result[0]['title']);
             $article->setSerial($article_result[0]['serial']);
             $article->setVolume($article_result[0]['volume']);
             $article->setNumber($article_result[0]['number']);
             $article->setSuppl($article_result[0]['suppl']);
             $article->setYear($article_result[0]['year']);
             $article->setAuthorXML($article_result[0]['authors_xml']);
             $article->setKeywordXML($article_result[0]['keywords_xml']);
             $article->setRelevance($relevance);
             $article->setPublicationDate($article_result[0]['publication_date']);
             array_push($articleProfileList[$profile_id], array($profile_name, $article));
             //die(var_dump($articleProfileList));
         }
     }
     //var_dump($articleProfileList);die;
     return $articleProfileList;
 }
 /**
 * Carrega nos campos da classe os valores que estão armazenados no Banco de Dados
 * chamada pela getArticle para devolver o objeto artigo para a classe Article
 * @param integer $ID IDentificador do usuário
 * @returns integer $sucess 1 em caso de sucesso, 0 em caso de erro
 */
 function loadArticle($p)
 {
     $article = new Article();
     $article->setPID($p['PID']);
     $article->setTitle($p['title']);
     $article->setSerial($p['serial']);
     $article->setVolume($p['volume']);
     $article->setNumber($p['number']);
     $article->setSuppl($p['suppl']);
     $article->setYear($p['year']);
     $article->setUrl($p['url']);
     $article->setAuthorXML($p['authors_xml']);
     $article->setKeywordXML($p['keywords_xml']);
     return $article;
 }
Example #11
0
 public function getArticleDetail($id)
 {
     $sqlHelper = new SqlHelper();
     $article = new Article();
     $sql = "select * from lavender_article where id={$id}";
     $res = $sqlHelper->dql_arr($sql);
     $article->setId($res[0]['id']);
     $article->setPraise($res[0]['praise']);
     $article->setContent($res[0]['content']);
     $article->setDate($res[0]['date']);
     $article->setReadTime($res[0]['read_time']);
     $article->setImg($res[0]['img']);
     $article->setNoPraise($res[0]['no_praise']);
     $article->setTitle($res[0]['title']);
     return $article;
 }
Example #12
0
 function executeRandomArticle()
 {
     $post = new Article();
     $arr = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z');
     for ($i = 0; $i < 6; $i = $i + 1) {
         $index = rand(0, Count($arr));
         $title = $title . $arr[$index];
     }
     $post->setTitle($title);
     for ($i = 0; $i < 30; $i = $i + 1) {
         $index = rand(0, Count($arr));
         $content = $content . $arr[$index];
     }
     $post->setContent($content);
     $post->save();
     $this->redirect('adminblog/index');
 }
Example #13
0
 public function testAction()
 {
     $article = new Article();
     $article->setTitle("L'histoire d'un bon weekend !");
     $article->setContent("Le weekend était vraiment trop bien !");
     $article->setCreatedAt(new \DateTime('now', new \DateTimeZone('Europe/Paris')));
     $article->setEnabled(true);
     $em = $this->getDoctrine()->getManager();
     $user = $this->getUser();
     if ($user) {
         $article->setUser($user);
     }
     $em->persist($article);
     $em->flush();
     $url = $this->generateUrl('suplol_user_homepage');
     return $this->redirect($url);
 }
Example #14
0
 /**
  * Create an Article object from XML
  *
  * @param SimpleXMLElement $xml simpleXML element containing a single article XML
  *
  * @static
  *
  * @return phpOpenNOS\Model\Article
  */
 public static function fromXML(\SimpleXMLElement $xml)
 {
     $article = new Article();
     $article->setId((int) $xml->id);
     $article->setTitle((string) $xml->title);
     $article->setDescription((string) $xml->description);
     $article->setPublished((string) $xml->published);
     $article->setLastUpdate((string) $xml->last_update);
     $article->setThumbnailXS((string) $xml->thumbnail_xs);
     $article->setThumbnailS((string) $xml->thumbnail_s);
     $article->setThumbnailM((string) $xml->thumbnail_m);
     $article->setLink((string) $xml->link);
     $keywords = array();
     foreach ($xml->keywords->keyword as $keyword) {
         $keywords[] = (string) $keyword;
     }
     $article->setKeywords($keywords);
     return $article;
 }
 function oldgetArticles()
 {
     $tmp =& $this->domLiteDocument->getElementsByPath("/related/relatedlist/article");
     for ($i = 0; $i < $tmp->getLength(); $i++) {
         $item = $tmp->item($i);
         $article = new Article();
         $article->setPID($this->getNodeAttribute($item, 'pid'));
         $article->setURL($this->getURL($this->getNodeAttribute($item, 'source'), $this->getNodeAttribute($item, 'country'), $article->getPID()));
         $article->setTitle($this->getNodeXML($item, 'titles'));
         $article->setSerial($this->getNodeText($item, 'serial'));
         $article->setVolume($this->getNodeText($item, 'volume'));
         $article->setNumber($this->getNodeText($item, 'number'));
         $article->setSuppl($this->getNodeText($item, 'supplement'));
         $article->setYear($this->getNodeText($item, 'year'));
         $article->setAuthorXML($this->getNodeXML($item, 'authors'));
         $article->setKeywordXML($this->getNodeXML($item, 'keywords'));
         $articles[] = $article;
     }
     return $articles;
 }
Example #16
0
    public function create($title, $content, $image, $idAuthor)
    {
        $article = new Article($this->db);
        try {
            $article->setTitle($title);
            $article->setContent($content);
            $article->setImage($image);
            $article->setIdAuthor($idAuthor);
        } catch (Exception $e) {
            $errors = $e->getMessage();
            echo $errors;
        }
        if (!isset($err)) {
            $title = $this->db->quote($article->getTitle());
            $content = $this->db->quote($article->getContent());
            $idAuthor = $article->getIdAuthor();
            if ($image == "") {
                $query = 'INSERT INTO article(title, content, idAuthor)
						VALUE (' . $title . ',' . $content . ',' . $idAuthor . ')';
            } else {
                $image = $this->db->quote($article->getImage());
                $query = 'INSERT INTO article(title, content, image, idAuthor)
						VALUE (' . $title . ',' . $content . ',' . $image . ',' . $idAuthor . ')';
            }
        }
        $res = $this->db->exec($query);
        if ($res) {
            $id = $this->db->lastInsertId();
            if ($id) {
                return $this->findById($id);
            } else {
                throw new Exception('Database error');
            }
        } else {
            throw new Exception($errors);
        }
    }
Example #17
0
	function test_article() {
		$article = new Article(9000001,9000002,9000003,9000004);

		// Test create
		$article->create("Unit Test Long Name",
						 "Unit Test Short Name",
						 "fastnews");
		$this->assertTrue($article->exists());

		// Test SET functions
		$article->setTitle("Unit Test New Title");
		$article->setCreatorId(9000005);
		$article->setOnFrontPage(true);
		$article->setOnSection(true);
		$article->setWorkflowStatus('Y');
		$article->setKeywords("Unit, Test");
		$article->setIsIndexed(true);

		// Test GET functions
		$articleCopy = new Article(9000001, 9000002, 9000003, 9000004, $article->getArticleId());
		$this->assertEquals(9000001, $articleCopy->getPublicationId());
		$this->assertEquals(9000002, $articleCopy->getIssueNumber());
		$this->assertEquals(9000003, $articleCopy->getSectionNumber());
		$this->assertEquals(9000004, $articleCopy->getLanguageId());
		$this->assertEquals(9000005, $articleCopy->getCreatorId());
		$this->assertEquals("Unit Test New Title", $articleCopy->getTitle());
		$this->assertEquals(true, $articleCopy->onFrontPage());
		$this->assertEquals(true, $articleCopy->onSection());
		$this->assertEquals('Y', $articleCopy->getWorkflowStatus());
		$this->assertEquals("Unit, Test", $articleCopy->getKeywords());
		$this->assertEquals(true, $articleCopy->isIndexed());

		// Test DELETE functions
		$article->delete();
		$this->assertFalse($article->exists());
	}
$category1 = new Category();
$category1->setName('cat1');
$category1->save();
$category2 = new Category();
$category2->setName('cat2');
$category2->save();
$article1 = new Article();
$article1->setTitle('aaaaa');
$article1->setCategory($category1);
$article1->save();
$article2 = new Article();
$article2->setTitle('bbbbb');
$article2->setCategory($category1);
$article2->save();
$article3 = new Article();
$article3->setTitle('ccccc');
$article3->setCategory($category2);
$article3->save();
$finder = sfPropelFinder::from('Article')->
  join('Category c', 'Article.CategoryId', 'c.Id', 'INNER JOIN')->
  where('c.Name', 'cat1')->
  orWhere('c.Name', 'cat2');
$finder->count();
$t->is($finder->getLatestQuery(), propel_sql('SELECT COUNT([P13*][P12article.ID]) FROM article INNER JOIN category c ON (article.CATEGORY_ID=c.ID) WHERE (c.NAME=\'cat1\' OR c.NAME=\'cat2\')'), 'join() using an alias allows columns of joined table to be used in orWhere()');
$finder = sfPropelFinder::from('Article')->
  join('Category c', 'Article.CategoryId', 'c.Id', 'INNER JOIN')->
  whereCustom('c.Name = ?', 'cat1');
$finder->count();
$t->is($finder->getLatestQuery(), propel_sql('SELECT COUNT([P13*][P12article.ID]) FROM article INNER JOIN category c ON (article.CATEGORY_ID=c.ID) WHERE c.NAME = \'cat1\''), 'join() using an alias allows columns of joined table to be used in whereCustom()');
$finder = sfPropelFinder::from('Article')->
  join('Category c', 'Article.CategoryId', 'c.Id', 'INNER JOIN')->
sleep(2);
$finder->where('Title', 'foo')->findOne(); // re-write cache 1
$SQL3 = $finder->getLatestQuery();
$t->isnt($SQL1, $SQL3, 'The same query asked after the lifetime does not use the cache');
*/

$t->diag('Cached results');

$cache->clear();

ArticlePeer::doDeleteAll();
$article1 = new Article();
$article1->setTitle('foo1');
$article1->save();
$article2 = new Article();
$article2->setTitle('foo2');
$article2->save();

$finder = DbFinder::from('Article')->useCache($cache, 10);
           $finder->where('Title', 'foo1')->findOne(); // normal query
$article = $finder->where('Title', 'foo1')->findOne(); // cached query
$t->isa_ok($article, 'Article', 'Cached finder queries return Model objects');
$t->is($article->getId(), $article1->getId(), 'find() finder queries can be cached');
      $finder->where('Title', 'foo1')->count(); // normal query
$nb = $finder->where('Title', 'foo1')->count(); // cached query
$t->is($nb, 1, 'count() finder queries can be cached');

$cache->clear();

$finder = DbFinder::from('Article')->useCache($cache, 10);
           $finder->where('Title', 'foo1')->limit(1)->find(); // normal query
 function handleArticleNode(&$journal, &$articleNode, &$issue, &$section, &$article, &$publishedArticle, &$errors, &$user, $isCommandLine, &$dependentItems)
 {
     $errors = array();
     $journalSupportedLocales = array_keys($journal->getSupportedLocaleNames());
     // => journal locales must be set up before
     $journalPrimaryLocale = $journal->getPrimaryLocale();
     $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
     $articleDao =& DAORegistry::getDAO('ArticleDAO');
     $article = new Article();
     $article->setLocale($journalPrimaryLocale);
     // FIXME in bug #5543
     $article->setJournalId($journal->getId());
     $article->setUserId($user->getId());
     $article->setSectionId($section->getId());
     $article->setStatus(STATUS_PUBLISHED);
     $article->setSubmissionProgress(0);
     $article->setDateSubmitted(Core::getCurrentDate());
     $article->stampStatusModified();
     $titleExists = false;
     for ($index = 0; $node = $articleNode->getChildByName('title', $index); $index++) {
         $locale = $node->getAttribute('locale');
         if ($locale == '') {
             $locale = $journalPrimaryLocale;
         } elseif (!in_array($locale, $journalSupportedLocales)) {
             $errors[] = array('plugins.importexport.native.import.error.articleTitleLocaleUnsupported', array('articleTitle' => $node->getValue(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale));
             return false;
         }
         $article->setTitle($node->getValue(), $locale);
         $titleExists = true;
     }
     if (!$titleExists || $article->getTitle($journalPrimaryLocale) == "") {
         $errors[] = array('plugins.importexport.native.import.error.articleTitleMissing', array('issueTitle' => $issue->getIssueIdentification(), 'sectionTitle' => $section->getLocalizedTitle()));
         return false;
     }
     for ($index = 0; $node = $articleNode->getChildByName('abstract', $index); $index++) {
         $locale = $node->getAttribute('locale');
         if ($locale == '') {
             $locale = $journalPrimaryLocale;
         } elseif (!in_array($locale, $journalSupportedLocales)) {
             $errors[] = array('plugins.importexport.native.import.error.articleAbstractLocaleUnsupported', array('articleTitle' => $article->getLocalizedTitle(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale));
             return false;
         }
         $article->setAbstract($node->getValue(), $locale);
     }
     if ($indexingNode = $articleNode->getChildByName('indexing')) {
         for ($index = 0; $node = $indexingNode->getChildByName('discipline', $index); $index++) {
             $locale = $node->getAttribute('locale');
             if ($locale == '') {
                 $locale = $journalPrimaryLocale;
             } elseif (!in_array($locale, $journalSupportedLocales)) {
                 $errors[] = array('plugins.importexport.native.import.error.articleDisciplineLocaleUnsupported', array('articleTitle' => $article->getLocalizedTitle(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale));
                 return false;
             }
             $article->setDiscipline($node->getValue(), $locale);
         }
         for ($index = 0; $node = $indexingNode->getChildByName('type', $index); $index++) {
             $locale = $node->getAttribute('locale');
             if ($locale == '') {
                 $locale = $journalPrimaryLocale;
             } elseif (!in_array($locale, $journalSupportedLocales)) {
                 $errors[] = array('plugins.importexport.native.import.error.articleTypeLocaleUnsupported', array('articleTitle' => $article->getLocalizedTitle(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale));
                 return false;
             }
             $article->setType($node->getValue(), $locale);
         }
         for ($index = 0; $node = $indexingNode->getChildByName('subject', $index); $index++) {
             $locale = $node->getAttribute('locale');
             if ($locale == '') {
                 $locale = $journalPrimaryLocale;
             } elseif (!in_array($locale, $journalSupportedLocales)) {
                 $errors[] = array('plugins.importexport.native.import.error.articleSubjectLocaleUnsupported', array('articleTitle' => $article->getLocalizedTitle(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale));
                 return false;
             }
             $article->setSubject($node->getValue(), $locale);
         }
         for ($index = 0; $node = $indexingNode->getChildByName('subject_class', $index); $index++) {
             $locale = $node->getAttribute('locale');
             if ($locale == '') {
                 $locale = $journalPrimaryLocale;
             } elseif (!in_array($locale, $journalSupportedLocales)) {
                 $errors[] = array('plugins.importexport.native.import.error.articleSubjectClassLocaleUnsupported', array('articleTitle' => $article->getLocalizedTitle(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale));
                 return false;
             }
             $article->setSubjectClass($node->getValue(), $locale);
         }
         if ($coverageNode = $indexingNode->getChildByName('coverage')) {
             for ($index = 0; $node = $coverageNode->getChildByName('geographical', $index); $index++) {
                 $locale = $node->getAttribute('locale');
                 if ($locale == '') {
                     $locale = $journalPrimaryLocale;
                 } elseif (!in_array($locale, $journalSupportedLocales)) {
                     $errors[] = array('plugins.importexport.native.import.error.articleCoverageGeoLocaleUnsupported', array('articleTitle' => $article->getLocalizedTitle(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale));
                     return false;
                 }
                 $article->setCoverageGeo($node->getValue(), $locale);
             }
             for ($index = 0; $node = $coverageNode->getChildByName('chronological', $index); $index++) {
                 $locale = $node->getAttribute('locale');
                 if ($locale == '') {
                     $locale = $journalPrimaryLocale;
                 } elseif (!in_array($locale, $journalSupportedLocales)) {
                     $errors[] = array('plugins.importexport.native.import.error.articleCoverageChronLocaleUnsupported', array('articleTitle' => $article->getLocalizedTitle(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale));
                     return false;
                 }
                 $article->setCoverageChron($node->getValue(), $locale);
             }
             for ($index = 0; $node = $coverageNode->getChildByName('sample', $index); $index++) {
                 $locale = $node->getAttribute('locale');
                 if ($locale == '') {
                     $locale = $journalPrimaryLocale;
                 } elseif (!in_array($locale, $journalSupportedLocales)) {
                     $errors[] = array('plugins.importexport.native.import.error.articleCoverageSampleLocaleUnsupported', array('articleTitle' => $article->getLocalizedTitle(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale));
                     return false;
                 }
                 $article->setCoverageSample($node->getValue(), $locale);
             }
         }
     }
     for ($index = 0; $node = $articleNode->getChildByName('sponsor', $index); $index++) {
         $locale = $node->getAttribute('locale');
         if ($locale == '') {
             $locale = $journalPrimaryLocale;
         } elseif (!in_array($locale, $journalSupportedLocales)) {
             $errors[] = array('plugins.importexport.native.import.error.articleSponsorLocaleUnsupported', array('articleTitle' => $article->getLocalizedTitle(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale));
             return false;
         }
         $article->setSponsor($node->getValue(), $locale);
     }
     if ($node = $articleNode->getChildByName('pages')) {
         $article->setPages($node->getValue());
     }
     if ($language = $articleNode->getAttribute('language')) {
         $article->setLanguage($language);
     }
     /* --- Handle authors --- */
     $hasErrors = false;
     for ($index = 0; $node = $articleNode->getChildByName('author', $index); $index++) {
         if (!NativeImportDom::handleAuthorNode($journal, $node, $issue, $section, $article, $authorErrors)) {
             $errors = array_merge($errors, $authorErrors);
             $hasErrors = true;
         }
     }
     if ($hasErrors) {
         return false;
     }
     /* --- Handle covers --- */
     for ($index = 0; $node = $articleNode->getChildByName('cover', $index); $index++) {
         if (!NativeImportDom::handleArticleCoverNode($journal, $node, $article, $coverErrors, $isCommandLine)) {
             $errors = array_merge($errors, $coverErrors);
             $hasErrors = true;
         }
     }
     for ($index = 0; $node = $articleNode->getChildByName('id', $index); $index++) {
         switch ($node->getAttribute('type')) {
             case 'doi':
                 $article->setStoredDOI($node->getValue());
                 break;
         }
     }
     $articleDao->insertArticle($article);
     $dependentItems[] = array('article', $article);
     // Create submission mangement records
     $signoffDao =& DAORegistry::getDAO('SignoffDAO');
     $initialCopyeditSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_INITIAL', ASSOC_TYPE_ARTICLE, $article->getId());
     $initialCopyeditSignoff->setUserId(0);
     $signoffDao->updateObject($initialCopyeditSignoff);
     $authorCopyeditSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_AUTHOR', ASSOC_TYPE_ARTICLE, $article->getId());
     $authorCopyeditSignoff->setUserId(0);
     $signoffDao->updateObject($authorCopyeditSignoff);
     $finalCopyeditSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_FINAL', ASSOC_TYPE_ARTICLE, $article->getId());
     $finalCopyeditSignoff->setUserId(0);
     $signoffDao->updateObject($finalCopyeditSignoff);
     $layoutSignoff = $signoffDao->build('SIGNOFF_LAYOUT', ASSOC_TYPE_ARTICLE, $article->getId());
     $layoutSignoff->setUserId(0);
     $signoffDao->updateObject($layoutSignoff);
     $authorProofSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_AUTHOR', ASSOC_TYPE_ARTICLE, $article->getId());
     $authorProofSignoff->setUserId(0);
     $signoffDao->updateObject($authorProofSignoff);
     $proofreaderProofSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_PROOFREADER', ASSOC_TYPE_ARTICLE, $article->getId());
     $proofreaderProofSignoff->setUserId(0);
     $signoffDao->updateObject($proofreaderProofSignoff);
     $layoutProofSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_LAYOUT', ASSOC_TYPE_ARTICLE, $article->getId());
     $layoutProofSignoff->setUserId(0);
     $signoffDao->updateObject($layoutProofSignoff);
     // Log the import in the article event log.
     import('classes.article.log.ArticleLog');
     import('classes.article.log.ArticleEventLogEntry');
     ArticleLog::logEvent($article->getId(), ARTICLE_LOG_ARTICLE_IMPORT, ARTICLE_LOG_TYPE_DEFAULT, 0, 'log.imported', array('userName' => $user->getFullName(), 'articleId' => $article->getId()));
     // Insert published article entry.
     $publishedArticle = new PublishedArticle();
     $publishedArticle->setArticleId($article->getId());
     $publishedArticle->setIssueId($issue->getId());
     if ($node = $articleNode->getChildByName('date_published')) {
         $publishedDate = strtotime($node->getValue());
         if ($publishedDate === -1) {
             $errors[] = array('plugins.importexport.native.import.error.invalidDate', array('value' => $node->getValue()));
             return false;
         } else {
             $publishedArticle->setDatePublished($publishedDate);
         }
     }
     $node = $articleNode->getChildByName('open_access');
     $publishedArticle->setAccessStatus($node ? ARTICLE_ACCESS_OPEN : ARTICLE_ACCESS_ISSUE_DEFAULT);
     $publishedArticle->setSeq(REALLY_BIG_NUMBER);
     $publishedArticle->setViews(0);
     $publishedArticle->setPublicArticleId($articleNode->getAttribute('public_id'));
     $publishedArticle->setPubId($publishedArticleDao->insertPublishedArticle($publishedArticle));
     $publishedArticleDao->resequencePublishedArticles($section->getId(), $issue->getId());
     /* --- Galleys (html or otherwise handled simultaneously) --- */
     import('classes.file.ArticleFileManager');
     $articleFileManager = new ArticleFileManager($article->getId());
     /* --- Handle galleys --- */
     $hasErrors = false;
     $galleyCount = 0;
     for ($index = 0; $index < count($articleNode->children); $index++) {
         $node = $articleNode->children[$index];
         if ($node->getName() == 'htmlgalley') {
             $isHtml = true;
         } elseif ($node->getName() == 'galley') {
             $isHtml = false;
         } else {
             continue;
         }
         if (!NativeImportDom::handleGalleyNode($journal, $node, $issue, $section, $article, $galleyErrors, $isCommandLine, $isHtml, $galleyCount, $articleFileManager)) {
             $errors = array_merge($errors, $galleyErrors);
             $hasErrors = true;
         }
         $galleyCount++;
         unset($node);
     }
     if ($hasErrors) {
         return false;
     }
     /* --- Handle supplemental files --- */
     $hasErrors = false;
     for ($index = 0; $node = $articleNode->getChildByName('supplemental_file', $index); $index++) {
         if (!NativeImportDom::handleSuppFileNode($journal, $node, $issue, $section, $article, $suppFileErrors, $isCommandLine, $articleFileManager)) {
             $errors = array_merge($errors, $suppFileErrors);
             $hasErrors = true;
         }
     }
     if ($hasErrors) {
         return false;
     }
     // Index the inserted article.
     import('classes.search.ArticleSearchIndex');
     ArticleSearchIndex::indexArticleMetadata($article);
     ArticleSearchIndex::indexArticleFiles($article);
     return true;
 }
$category1 = new Category();
$category1->setName('cat1');
$category1->save();
$category2 = new Category();
$category2->setName('cat2');
$category2->save();
$article1 = new Article();
$article1->setTitle('art1');
$article1->setCategory($category1);
$article1->save();
$article2 = new Article();
$article2->setTitle('art2');
$article2->setCategory($category2);
$article2->save();
$article3 = new Article();
$article3->setTitle('art3');
$article3->setCategory($category1);
$article3->save();

$finder = sfPropelFinder::from('Article')->
  withColumn('Article.Title')->
  select('Article.Title');
$title = $finder->findOne();
$t->is($finder->getLatestQuery(), propel_sql('SELECT [P12article.ID, ]article.TITLE AS "Article.Title" FROM article LIMIT 1'), 'select() can cope with a column added with withColumn()');
$t->is($title, 'art1', 'select() can cope with a column added with withColumn()');

$finder = sfPropelFinder::from('Article')->
  join('Category')->
  withColumn('Category.Name')->
  select(array('Article.Title', 'Category.Name'));
$row = $finder->findOne();
Example #22
0
$app = 'frontend';
require_once(dirname(__FILE__).'/../bootstrap/functional.php');

$t = new lime_test(13);

$article = new Article();
$article->title = 'test';
$t->is($article->Translation['en']->title, 'test');

sfContext::getInstance()->getUser()->setCulture('fr');
$article->title = 'fr test';
$t->is($article->Translation['fr']->title, 'fr test');

$t->is($article->getTitle(), $article->title);
$article->setTitle('test');
$t->is($article->getTitle(), 'test');

$article->setTestColumn('test');
$t->is($article->getTestColumn(), 'test');
$t->is($article->Translation['fr']['test_column'], 'test');

$article->free(true);

class MyArticleForm extends ArticleForm
{
  public function configure()
  {
    parent::configure();

    $this->embedI18n(array('en', 'fr'));
Example #23
0
     }
     $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);
 } elseif ($f_action == "submit") {
     // Submit all the articles requested.
     $tmpArticles = array();
     foreach ($doAction as $articleNumber => $languageArray) {
         foreach ($languageArray as $languageId => $action) {
             $tmpArticle = new Article($languageId, $articleNumber);
             $tmpArticle->setTitle($articleNames[$articleNumber][$languageId]);
             // Check if the name already exists in the destination section.
             $conflictingArticles = Article::GetByName($tmpArticle->getTitle(), $f_destination_publication_id, $f_destination_issue_number, $f_destination_section_number, null, true);
             if (count($conflictingArticles) > 0) {
                 $conflictingArticle = array_pop($conflictingArticles);
                 $conflictingArticleLink = camp_html_article_url($conflictingArticle, $conflictingArticle->getLanguageId(), "edit.php");
                 camp_html_add_msg($translator->trans("The article could not be submitted.", array(), 'articles') . " " . $translator->trans("You cannot have two articles in the same section with the same name.  The article name you specified is already in use by the article '\$1'.", array('$1' => "<a href='{$conflictingArticleLink}'>" . $conflictingArticle->getName() . "</a>"), 'articles'));
                 $args = $_REQUEST;
                 unset($args["action_button"]);
                 unset($args["f_article_code"]);
                 $argsStr = camp_implode_keys_and_values($args, "=", "&");
                 foreach ($_REQUEST["f_article_code"] as $code) {
                     $argsStr .= "&f_article_code[]={$code}";
                 }
                 $backLink = "/{$ADMIN}/articles/duplicate.php?{$argsStr}";
                 camp_html_goto_page($backLink);
 /**
  * Save settings.
  */
 function execute($editArticleId)
 {
     $this->editArticleID = $editArticleId;
     $articleDao =& DAORegistry::getDAO('ArticleDAO');
     $signoffDao =& DAORegistry::getDAO('SignoffDAO');
     $sectionEditorSubmissionDao =& DAORegistry::getDAO('SectionEditorSubmissionDAO');
     $application =& PKPApplication::getApplication();
     $request =& $application->getRequest();
     $user =& $request->getUser();
     $router =& $request->getRouter();
     $journal =& $router->getContext($request);
     $article = new Article();
     $article->setLocale($journal->getPrimaryLocale());
     // FIXME in bug #5543
     $article->setUserId($user->getId());
     $article->setJournalId($journal->getId());
     $article->setSectionId($this->getData('sectionId'));
     $article->setLanguage(String::substr($journal->getPrimaryLocale(), 0, 2));
     $article->setTitle($this->getData('title'), null);
     // Localized
     //add Original Journal to Abstract
     $orig_journal = $this->getData('originalJournal');
     $abstr = $this->getData('abstract');
     foreach (array_keys($abstr) as $abs_key) {
         $abstr[$abs_key] .= '  <p id="originalPub"> ' . $orig_journal . ' </p> ';
         //		$abstr[$abs_key] .=  '  <p id="originalPub"> ' . $orig_journal[$abs_key]. ' </p> ';
         //OriginalJournal in EditPlugin only a string and not an array...
         $this->setData('abstract', $abstr);
     }
     $article->setAbstract($this->getData('abstract'), null);
     // Localized
     $article->setDiscipline($this->getData('discipline'), null);
     // Localized
     $article->setSubjectClass($this->getData('subjectClass'), null);
     // Localized
     $article->setSubject($this->getData('subject'), null);
     // Localized
     $article->setCoverageGeo($this->getData('coverageGeo'), null);
     // Localized
     $article->setCoverageChron($this->getData('coverageChron'), null);
     // Localized
     $article->setCoverageSample($this->getData('coverageSample'), null);
     // Localized
     $article->setType($this->getData('type'), null);
     // Localized
     $article->setSponsor($this->getData('sponsor'), null);
     // Localized
     $article->setCitations($this->getData('citations'));
     $article->setPages($this->getData('pages'));
     // Set some default values so the ArticleDAO doesn't complain when adding this article
     $article->setDateSubmitted(Core::getCurrentDate());
     $article->setStatus(STATUS_PUBLISHED);
     $article->setSubmissionProgress(0);
     $article->stampStatusModified();
     $article->setCurrentRound(1);
     $article->setFastTracked(1);
     $article->setHideAuthor(0);
     $article->setCommentsStatus(0);
     // As article has an ID already set it
     $article->setId($this->editArticleID);
     $articleId = $this->editArticleID;
     //delete prior Authors to prevent from double saving the same authors
     $authorDao =& DAORegistry::getDAO('AuthorDAO');
     $authorDao->deleteAuthorsByArticle($articleId);
     // Add authors
     $authors = $this->getData('authors');
     for ($i = 0, $count = count($authors); $i < $count; $i++) {
         if ($authors[$i]['authorId'] > 0) {
             // Update an existing author
             $author =& $article->getAuthor($authors[$i]['authorId']);
             $isExistingAuthor = true;
         } else {
             // Create a new author
             $author = new Author();
             $isExistingAuthor = false;
         }
         if ($author != null) {
             $author->setSubmissionId($articleId);
             $author->setFirstName($authors[$i]['firstName']);
             $author->setMiddleName($authors[$i]['middleName']);
             $author->setLastName($authors[$i]['lastName']);
             if (array_key_exists('affiliation', $authors[$i])) {
                 $author->setAffiliation($authors[$i]['affiliation'], null);
             }
             $author->setCountry($authors[$i]['country']);
             $author->setEmail($authors[$i]['email']);
             $author->setUrl($authors[$i]['url']);
             if (array_key_exists('competingInterests', $authors[$i])) {
                 $author->setCompetingInterests($authors[$i]['competingInterests'], null);
             }
             $author->setBiography($authors[$i]['biography'], null);
             $author->setPrimaryContact($this->getData('primaryContact') == $i ? 1 : 0);
             $author->setSequence($authors[$i]['seq']);
             if ($isExistingAuthor == false) {
                 $article->addAuthor($author);
             }
         }
     }
     // Check whether the user gave a handle and create a handleSubmissionFile in case
     $submissionHandle = $this->getData('submissionHandle');
     $handleSubmissionFileId;
     $handleCheck = FALSE;
     //import FileManager before creating files because otherwise naming of the copied files failes
     import('classes.file.ArticleFileManager');
     foreach (array_keys($submissionHandle) as $locale) {
         if (!empty($submissionHandle[$locale])) {
             $this->deleteOldFile("submission/original", $articleId);
             // $this->deleteOldFile("submission/copyedit", $articleId);
             $handleCheck = TRUE;
             $handleSubmissionId = $this->createHandleTXTFile($submissionHandle[$locale], $articleId, 'submission');
             $handleSubmissionPDFId = $this->createHandlePDF($submissionHandle[$locale], $articleId, 'submission');
             //Add the handle submission files as galley
             $this->setGalley($articleId, $handleSubmissionPDFId, $locale, 'application/pdf');
         }
         if ($handleCheck == TRUE) {
             if ($locale == $journal->getPrimaryLocale()) {
                 $article->setSubmissionFileId($handleSubmissionPDFId);
                 $article->SetReviewFileId($handleSubmissionPDFId);
             }
             // Update file search index
             import('classes.search.ArticleSearchIndex');
             if (isset($galley)) {
                 ArticleSearchIndex::updateFileIndex($galley->getArticleId(), ARTICLE_SEARCH_GALLEY_FILE, $galley->getFileId());
             }
         }
     }
     // Add the submission files as galleys
     import('classes.file.TemporaryFileManager');
     import('classes.file.ArticleFileManager');
     $tempFileIds = $this->getData('tempFileId');
     $temporaryFileManager = new TemporaryFileManager();
     $articleFileManager = new ArticleFileManager($articleId);
     $tempFileCheck = FALSE;
     foreach (array_keys($tempFileIds) as $locale) {
         $temporaryFile = $temporaryFileManager->getFile($tempFileIds[$locale], $user->getId());
         $fileId = null;
         if ($temporaryFile) {
             $this->deleteOldFile("submission/original", $articleId);
             $this->deleteOldFile("submission/copyedit", $articleId);
             $tempFileCheck = TRUE;
             $fileId = $articleFileManager->temporaryFileToArticleFile($temporaryFile, ARTICLE_FILE_SUBMISSION);
             $fileType = $temporaryFile->getFileType();
             $this->setGalley($articleId, $fileId, $locale, $fileType);
             // $galley =& $this->setGalley($articleId, $fileId, $locale, $fileType);
         }
         if ($tempFileCheck == TRUE) {
             if ($locale == $journal->getPrimaryLocale()) {
                 $article->setSubmissionFileId($fileId);
                 $article->SetReviewFileId($fileId);
             }
             // Update file search index
             import('classes.search.ArticleSearchIndex');
             if (isset($galley)) {
                 ArticleSearchIndex::updateFileIndex($galley->getArticleId(), ARTICLE_SEARCH_GALLEY_FILE, $galley->getFileId());
             }
         }
     }
     //Check whether the user gave a handle and create handleSupplFile in case
     $supplHandle = $this->getData('supplHandle');
     $handleSuppFileId = null;
     foreach (array_keys($supplHandle) as $locale) {
         if (!empty($supplHandle[$locale])) {
             $this->deleteOldFile("supp", $articleId);
             $handleSuppFileId = $this->createHandleTXTFile($supplHandle[$locale], $articleId, 'supplementary');
             $handleSupplPDFFileID = $this->createHandlePDF($submissionHandle[$locale], $articleId, 'supplementary');
         }
     }
     //Add uploaded Supplementary file
     $tempSupplFileIds = $this->getData('tempSupplFileId');
     foreach (array_keys($tempSupplFileIds) as $locale) {
         $temporaryFile = $temporaryFileManager->getFile($tempSupplFileIds[$locale], $user->getId());
         $fileId = null;
         if ($temporaryFile) {
             $this->deleteOldFile("supp", $articleId);
             $fileId = $articleFileManager->temporaryFileToArticleFile($temporaryFile, ARTICLE_FILE_SUPP);
             $fileType = $temporaryFile->getFileType();
         }
     }
     // Designate this as the review version by default.
     /*$authorSubmissionDao =& DAORegistry::getDAO('AuthorSubmissionDAO');
     		$authorSubmission =& $authorSubmissionDao->getAuthorSubmission($articleId);
     		import('classes.submission.author.AuthorAction');
     		AuthorAction::designateReviewVersion($authorSubmission, true);
     */
     // Accept the submission
     /*$sectionEditorSubmission =& $sectionEditorSubmissionDao->getSectionEditorSubmission($articleId);
     		$articleFileManager = new ArticleFileManager($articleId);
     		$sectionEditorSubmission->setReviewFile($articleFileManager->getFile($article->getSubmissionFileId()));
     		import('classes.submission.sectionEditor.SectionEditorAction');
     		SectionEditorAction::recordDecision($sectionEditorSubmission, SUBMISSION_EDITOR_DECISION_ACCEPT);
     */
     // Create signoff infrastructure
     $copyeditInitialSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_INITIAL', ASSOC_TYPE_ARTICLE, $articleId);
     $copyeditAuthorSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_AUTHOR', ASSOC_TYPE_ARTICLE, $articleId);
     $copyeditFinalSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_FINAL', ASSOC_TYPE_ARTICLE, $articleId);
     $copyeditInitialSignoff->setUserId(0);
     $copyeditAuthorSignoff->setUserId($user->getId());
     $copyeditFinalSignoff->setUserId(0);
     $signoffDao->updateObject($copyeditInitialSignoff);
     $signoffDao->updateObject($copyeditAuthorSignoff);
     $signoffDao->updateObject($copyeditFinalSignoff);
     $layoutSignoff = $signoffDao->build('SIGNOFF_LAYOUT', ASSOC_TYPE_ARTICLE, $articleId);
     $layoutSignoff->setUserId(0);
     $signoffDao->updateObject($layoutSignoff);
     $proofAuthorSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_AUTHOR', ASSOC_TYPE_ARTICLE, $articleId);
     $proofProofreaderSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_PROOFREADER', ASSOC_TYPE_ARTICLE, $articleId);
     $proofLayoutEditorSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_LAYOUT', ASSOC_TYPE_ARTICLE, $articleId);
     $proofAuthorSignoff->setUserId($user->getId());
     $proofProofreaderSignoff->setUserId(0);
     $proofLayoutEditorSignoff->setUserId(0);
     $signoffDao->updateObject($proofAuthorSignoff);
     $signoffDao->updateObject($proofProofreaderSignoff);
     $signoffDao->updateObject($proofLayoutEditorSignoff);
     import('classes.author.form.submit.AuthorSubmitForm');
     AuthorSubmitForm::assignEditors($article);
     $articleDao->updateArticle($article);
     // Add to end of editing queue
     import('classes.submission.editor.EditorAction');
     if (isset($galley)) {
         EditorAction::expediteSubmission($article);
     }
     // As the article already has an issue, just get it from database
     $issueDao =& DAORegistry::getDAO('IssueDAO');
     $issue =& $issueDao->getIssueByArticleId($this->editArticleID);
     $issueId = $issue->getIssueId();
     //$this->scheduleForPublication($articleId, $issueId);
     // Index article.
     import('classes.search.ArticleSearchIndex');
     ArticleSearchIndex::indexArticleMetadata($article);
     // Import the references list.
     $citationDao =& DAORegistry::getDAO('CitationDAO');
     $rawCitationList = $article->getCitations();
     $citationDao->importCitations($request, ASSOC_TYPE_ARTICLE, $articleId, $rawCitationList);
 }
Example #25
0
 public function fetchArticleById($id)
 {
     $this->db->select('name, content, imagePath, datePosted, author, visits')->where('id', (int) $id);
     $query = $this->db->get('website_news');
     if ($query->rowCount() > 0) {
         $row = $this->db->fetch($query);
         $article = new Article();
         $article->setTitle($row->name)->setID($id)->setContent($row->content)->setImage($row->imagePath)->setDate($row->datePosted)->setVisits($row->visits)->setAuthor($row->author);
         return $article;
     }
 }
Example #26
0
<?php

include_once 'business/Article.php';
include 'control/ArticleControls.php';
include_once 'business/Comment.php';
$article = new Article();
$control = new ArticleControls();
$article->setTitle($_POST['title']);
$article->setContent($_POST['category']);
// $article->setUser_name($_POST['name']);
// $article->setNews_id($_POST['id']);
// $article->setIp($_POST['ip']);
if ($control->addMail($article)) {
    header("location:../news.php?art_id=" . $_POST['id']);
} else {
    echo "La requête n'a pu être exécutée";
}
    public static function testArticle()
    {
        $article = new Article();
        return $article->setTitle('Symfony3 en version 3')->setSubtitle('Le framework intergalactique passe la troisième vitesse')->setTextFormatted('
                <p>tldr; Vous le connaissez certainement et l\'avez peut-être déjà utilisé : le framework PHP Symfony passe en version 3.
                A travers cet article, vous découvrirez (ou re-découvrerez) Symfony, ainsi que les différentes évolutions apportées
                par la toute dernière version (la 3ème va vous époustoufler).</p>

                <img src="http://www.staragora.com/images/flux/default/a/b/ba2c4e5eb40606b366bb9b451da9cf9053451a2559e5d.jpg" class="image-right size-medium" />
                <p>Je suis un framework PHP MVC reconnu dans le monde professionnel, ma première version a été déployée en 2005.
                    Mon but est d\'accélérer la création et la maintenance d\'applications web robustes dans un contexte professionnel,
                    et suis utilisé par des sites à fort traffic tels que Yahoo Answers, BlaBlaCar, Dailymotion, les Joies de SUPINFO
                    ou même YouP*rn. J\'ai été élu en 2015 framework préféré des Français tant sur le plan personnel que professionnel
                    (1), et suis inspiré d\'autres frameworks tels que Ruby on Rails, Django ou Spring. Je suis, je suis... Symfony !</p>

                <h3>Histoire</h3>
                <p>Pour la petite histoire : la première version de Symfony a été publiée en janvier 2007. Son cycle de release est
                    divisé entre des versions standard offrant un support d\'une durée de huit mois à un an et des versions LTS proposant
                    un support étendu d\'une durée de trois ans. Le cycle de vie de chaque version est divisé en trois phases : développement,
                    stabilisation, et maintenance :</p>

                <img src="http://symfony.com/doc/current/_images/release-process.jpg" class="image-center" />

                <p>Symfony a permis en quelques années de redorer le blason de PHP, longtemps considéré comme un langage de programmation
                    pour débutants et laissé de côté par les entreprises en faveur de technologies en apparence plus sexy et matures
                    telles que l\'ASP .Net, Ruby ou Java.</p>
            ')->setCreatedOn(new \DateTime())->setLastModificationDate(new \DateTime())->setRedactor((new Person())->setFirstName('Quentin')->setLastName('S.'))->setSlug('symfony3-en-version-3')->setCategory((new Category())->setTitle('Programmation')->setSlug('programmation'));
    }
 /**
  * Save settings.
  */
 function execute()
 {
     $articleDao =& DAORegistry::getDAO('ArticleDAO');
     $signoffDao =& DAORegistry::getDAO('SignoffDAO');
     $sectionEditorSubmissionDao =& DAORegistry::getDAO('SectionEditorSubmissionDAO');
     $application =& PKPApplication::getApplication();
     $request =& $application->getRequest();
     $user =& $request->getUser();
     $router =& $request->getRouter();
     $journal =& $router->getContext($request);
     $article = new Article();
     $article->setLocale($journal->getPrimaryLocale());
     // FIXME in bug #5543
     $article->setUserId($user->getId());
     $article->setJournalId($journal->getId());
     $article->setSectionId($this->getData('sectionId'));
     $article->setLanguage(String::substr($journal->getPrimaryLocale(), 0, 2));
     $article->setTitle($this->getData('title'), null);
     // Localized
     $article->setAbstract($this->getData('abstract'), null);
     // Localized
     $article->setDiscipline($this->getData('discipline'), null);
     // Localized
     $article->setSubjectClass($this->getData('subjectClass'), null);
     // Localized
     $article->setSubject($this->getData('subject'), null);
     // Localized
     $article->setCoverageGeo($this->getData('coverageGeo'), null);
     // Localized
     $article->setCoverageChron($this->getData('coverageChron'), null);
     // Localized
     $article->setCoverageSample($this->getData('coverageSample'), null);
     // Localized
     $article->setType($this->getData('type'), null);
     // Localized
     $article->setSponsor($this->getData('sponsor'), null);
     // Localized
     $article->setCitations($this->getData('citations'));
     $article->setPages($this->getData('pages'));
     // Set some default values so the ArticleDAO doesn't complain when adding this article
     $article->setDateSubmitted(Core::getCurrentDate());
     $article->setStatus(STATUS_PUBLISHED);
     $article->setSubmissionProgress(0);
     $article->stampStatusModified();
     $article->setCurrentRound(1);
     $article->setFastTracked(1);
     $article->setHideAuthor(0);
     $article->setCommentsStatus(0);
     // Insert the article to get it's ID
     $articleDao->insertArticle($article);
     $articleId = $article->getId();
     // Add authors
     $authors = $this->getData('authors');
     for ($i = 0, $count = count($authors); $i < $count; $i++) {
         if ($authors[$i]['authorId'] > 0) {
             // Update an existing author
             $author =& $article->getAuthor($authors[$i]['authorId']);
             $isExistingAuthor = true;
         } else {
             // Create a new author
             $author = new Author();
             $isExistingAuthor = false;
         }
         if ($author != null) {
             $author->setSubmissionId($articleId);
             $author->setFirstName($authors[$i]['firstName']);
             $author->setMiddleName($authors[$i]['middleName']);
             $author->setLastName($authors[$i]['lastName']);
             if (array_key_exists('affiliation', $authors[$i])) {
                 $author->setAffiliation($authors[$i]['affiliation'], null);
             }
             $author->setCountry($authors[$i]['country']);
             $author->setEmail($authors[$i]['email']);
             $author->setUrl($authors[$i]['url']);
             if (array_key_exists('competingInterests', $authors[$i])) {
                 $author->setCompetingInterests($authors[$i]['competingInterests'], null);
             }
             $author->setBiography($authors[$i]['biography'], null);
             $author->setPrimaryContact($this->getData('primaryContact') == $i ? 1 : 0);
             $author->setSequence($authors[$i]['seq']);
             if ($isExistingAuthor == false) {
                 $article->addAuthor($author);
             }
         }
     }
     // Add the submission files as galleys
     import('classes.file.TemporaryFileManager');
     import('classes.file.ArticleFileManager');
     $tempFileIds = $this->getData('tempFileId');
     $temporaryFileManager = new TemporaryFileManager();
     $articleFileManager = new ArticleFileManager($articleId);
     foreach (array_keys($tempFileIds) as $locale) {
         $temporaryFile = $temporaryFileManager->getFile($tempFileIds[$locale], $user->getId());
         $fileId = null;
         if ($temporaryFile) {
             $fileId = $articleFileManager->temporaryFileToArticleFile($temporaryFile, ARTICLE_FILE_SUBMISSION);
             $fileType = $temporaryFile->getFileType();
             if (strstr($fileType, 'html')) {
                 import('classes.article.ArticleHTMLGalley');
                 $galley = new ArticleHTMLGalley();
             } else {
                 import('classes.article.ArticleGalley');
                 $galley = new ArticleGalley();
             }
             $galley->setArticleId($articleId);
             $galley->setFileId($fileId);
             $galley->setLocale($locale);
             if ($galley->isHTMLGalley()) {
                 $galley->setLabel('HTML');
             } else {
                 if (strstr($fileType, 'pdf')) {
                     $galley->setLabel('PDF');
                 } else {
                     if (strstr($fileType, 'postscript')) {
                         $galley->setLabel('Postscript');
                     } else {
                         if (strstr($fileType, 'xml')) {
                             $galley->setLabel('XML');
                         } else {
                             $galley->setLabel(__('common.untitled'));
                         }
                     }
                 }
             }
             $galleyDao =& DAORegistry::getDAO('ArticleGalleyDAO');
             $galleyDao->insertGalley($galley);
         }
         if ($locale == $journal->getPrimaryLocale()) {
             $article->setSubmissionFileId($fileId);
             $article->SetReviewFileId($fileId);
         }
         // Update file search index
         import('classes.search.ArticleSearchIndex');
         if (isset($galley)) {
             ArticleSearchIndex::updateFileIndex($galley->getArticleId(), ARTICLE_SEARCH_GALLEY_FILE, $galley->getFileId());
         }
     }
     // Designate this as the review version by default.
     $authorSubmissionDao =& DAORegistry::getDAO('AuthorSubmissionDAO');
     $authorSubmission =& $authorSubmissionDao->getAuthorSubmission($articleId);
     import('classes.submission.author.AuthorAction');
     AuthorAction::designateReviewVersion($authorSubmission, true);
     // Accept the submission
     $sectionEditorSubmission =& $sectionEditorSubmissionDao->getSectionEditorSubmission($articleId);
     $articleFileManager = new ArticleFileManager($articleId);
     $sectionEditorSubmission->setReviewFile($articleFileManager->getFile($article->getSubmissionFileId()));
     import('classes.submission.sectionEditor.SectionEditorAction');
     SectionEditorAction::recordDecision($sectionEditorSubmission, SUBMISSION_EDITOR_DECISION_ACCEPT);
     // Create signoff infrastructure
     $copyeditInitialSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_INITIAL', ASSOC_TYPE_ARTICLE, $articleId);
     $copyeditAuthorSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_AUTHOR', ASSOC_TYPE_ARTICLE, $articleId);
     $copyeditFinalSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_FINAL', ASSOC_TYPE_ARTICLE, $articleId);
     $copyeditInitialSignoff->setUserId(0);
     $copyeditAuthorSignoff->setUserId($user->getId());
     $copyeditFinalSignoff->setUserId(0);
     $signoffDao->updateObject($copyeditInitialSignoff);
     $signoffDao->updateObject($copyeditAuthorSignoff);
     $signoffDao->updateObject($copyeditFinalSignoff);
     $layoutSignoff = $signoffDao->build('SIGNOFF_LAYOUT', ASSOC_TYPE_ARTICLE, $articleId);
     $layoutSignoff->setUserId(0);
     $signoffDao->updateObject($layoutSignoff);
     $proofAuthorSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_AUTHOR', ASSOC_TYPE_ARTICLE, $articleId);
     $proofProofreaderSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_PROOFREADER', ASSOC_TYPE_ARTICLE, $articleId);
     $proofLayoutEditorSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_LAYOUT', ASSOC_TYPE_ARTICLE, $articleId);
     $proofAuthorSignoff->setUserId($user->getId());
     $proofProofreaderSignoff->setUserId(0);
     $proofLayoutEditorSignoff->setUserId(0);
     $signoffDao->updateObject($proofAuthorSignoff);
     $signoffDao->updateObject($proofProofreaderSignoff);
     $signoffDao->updateObject($proofLayoutEditorSignoff);
     import('classes.author.form.submit.AuthorSubmitForm');
     AuthorSubmitForm::assignEditors($article);
     $articleDao->updateArticle($article);
     // Add to end of editing queue
     import('classes.submission.editor.EditorAction');
     if (isset($galley)) {
         EditorAction::expediteSubmission($article);
     }
     if ($this->getData('destination') == "issue") {
         // Add to an existing issue
         $issueId = $this->getData('issueId');
         $this->scheduleForPublication($articleId, $issueId);
     }
     // Index article.
     import('classes.search.ArticleSearchIndex');
     ArticleSearchIndex::indexArticleMetadata($article);
     // Import the references list.
     $citationDao =& DAORegistry::getDAO('CitationDAO');
     $rawCitationList = $article->getCitations();
     $citationDao->importCitations($request, ASSOC_TYPE_ARTICLE, $articleId, $rawCitationList);
 }
$t = new lime_test(33, new lime_output_color());

$article1 = new Article();
$article1->setTitle('tt1');
$article1->save();
$article2 = new Article();
$article2->setTitle('tt2');
$article2->save();
$article3 = new Article();
$article3->setTitle('tt3');
$article3->save();
$article4 = new Article();
$article4->setTitle('tt4');
$article4->save();
$article5 = new Article();
$article5->setTitle('t5');
$article5->save();

$t->diag('sfPropelFinderPager');

$pager = new sfPropelFinderPager('Article', 2);
$pager->setPage(1);
$pager->init();

$t->is($pager->getNbResults(), 5, 'sfPropelFinderPager::getNbResults() return the total nb of results');
$t->is($pager->getLastPage(), 3, 'sfPropelFinderPager::getLastPage() return the total nb of pages');
$t->is($pager->getFirstIndice(), 1, 'sfPropelFinderPager::getFirstIndice() return offset of the first result of the page');
$articles = $pager->getResults();
$t->is(count($articles), 2, 'sfPropelFinderPager::getResults() return an array of max $maxPerPage results');
$t->is(@$articles[0]->getTitle(), 'tt1', 'sfPropelFinderPager::getResults() return an array of BaseObject instances');
$t->is(@$articles[1]->getTitle(), 'tt2', 'sfPropelFinderPager::getResults() return an array of BaseObject instances');
Example #30
0
        // Sets the author type selected
        $author_type = $f_article_author_type[$i];
        $authorObj->setType($author_type);
        // Links the author to the article
        if ($authorObj->getId() != 0) {
            $articleAuthorObj = new ArticleAuthor($articleObj->getArticleNumber(), $articleObj->getLanguageId(), $authorObj->getId(), $author_type, $i + 1);
        }
        if (isset($articleAuthorObj) && !$articleAuthorObj->exists()) {
            $articleAuthorObj->create();
            $dispatcher->dispatch("user.set_points", new \Newscoop\EventDispatcher\Events\GenericEvent($this, array('authorId' => $articleAuthorObj->getAuthorId())));
        }
        $i++;
    }
}
// Update the article.
$articleObj->setTitle($f_article_title);
$articleObj->setIsIndexed(false);
if (!empty($f_comment_status)) {
    if ($f_comment_status == "enabled" || $f_comment_status == "locked") {
        $commentsEnabled = true;
    } else {
        $commentsEnabled = false;
    }
    // If status has changed, then you need to show/hide all the comments
    // as appropriate.
    if ($articleObj->commentsEnabled() != $commentsEnabled) {
        $articleObj->setCommentsEnabled($commentsEnabled);
        global $controller;
        $repository = $controller->getHelper('entity')->getRepository('Newscoop\\Entity\\Comment');
        $repository->setArticleStatus($f_article_number, $f_language_selected, $commentsEnabled ? STATUS_APPROVED : STATUS_HIDDEN);
        $repository->flush();