Example #1
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 #2
0
 public function choix()
 {
     $requete = $this->_db->prepare('select id , nom from article');
     $requete->execute(array());
     $results = $requete->fetchAll();
     $tabobject = array();
     if (empty($results)) {
         return false;
     }
     foreach ($results as $result) {
         $monarticle = new Article();
         $monarticle->setId($result['id'])->setNom($result['nom']);
         array_push($tabobject, $monarticle);
         // Push l'objet $article dans le tableau $tabobject
     }
     return $tabobject;
 }
Example #3
0
 public function retour_article_one($idarticle)
 {
     $requete = $this->_db->prepare('select * from article where id=:id');
     $requete->execute(array(':id' => $idarticle));
     $results = $requete->fetchAll();
     $tabobject = array();
     if (empty($results)) {
         return false;
     }
     foreach ($results as $result) {
         $monarticle = new Article();
         $monarticle->setId($result['id'])->setNom($result['nom'])->setPoints($result['points'])->setMarque($result['marque'])->setDescription($result['description'])->setImg($result['img']);
         array_push($tabobject, $monarticle);
         // Push l'objet $article dans le tableau $tabobject
     }
     return $tabobject;
 }
Example #4
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;
 }
Example #5
0
<?php

include_once 'data/CategoryDAO.php';
include_once 'control/ArticleControls.php';
include_once 'business/Article.php';
$categoryDao = new CategoryDao();
$articleController = new ArticleControls();
$article = new Article();
$article->setName($_POST['title']);
$article->setId(intval($_POST['id']));
$article->setContent($_POST['editor']);
$article->setSumup($_POST['sumup_editor']);
$article->setTags($_POST['tags']);
$ret = $articleController->alterArticle($article);
if ($ret) {
    header("location:../news.php?art_id=" . $_POST['id']);
} else {
    echo "Unexpected exception";
}
 function _addPost($data, $_debug)
 {
     if ($data["title"] == NULL) {
         $data["title"] = "No Title Entered.";
     }
     if ($data["text"] == NULL) {
         $data["text"] = "No Body Entered.";
     }
     if ($data["category"] == NULL) {
         $data["category"] = 1;
     }
     if ($data["user_id"] == NULL) {
         $data["user_id"] = 1;
     }
     if ($data["blog_id"] == NULL) {
         $data["blog_id"] = 1;
     }
     if ($data["status"] == NULL) {
         $data["status"] = POST_STATUS_PUBLISHED;
     }
     if ($data["comments"] == NULL) {
         $data["comments"] = true;
     }
     $articles = new Articles();
     // verify that article does not exist in database
     $artss = $articles->getBlogArticles($data["blog_id"]);
     $exists = 0;
     foreach ($artss as $art) {
         if ($art->getTopic() == $data["title"]) {
             $exists = $art->getId();
             break;
         }
     }
     /*
     $exists = $articles->getBlogArticleByTitle( 
     			TextFilter::urlize($data["title"]) ,
     			$data["blog_id"], 
     			true, -1 -1 -1, POST_STATUS_PUBLISHED );
     
     if (!$exists) 
     {
     	$exists = $articles->getBlogArticleByTitle( 
     			TextFilter::urlize($data["title"]) ,
     			$data["blog_id"], 
     			true, -1 -1 -1, POST_STATUS_DRAFT );
     }
     */
     if (!$exists) {
         // verify that desired post id does not exist.  Otherwise, create new id.
         if (!$articles->getUserArticle($data["id"])) {
             $post_id = $data["id"];
         }
         if ($_debug) {
             print "--- --- adding post " . $data["title"] . " to db.<br />\n\r";
         }
         $cat[0] = $data["category"];
         $article = new Article($data["title"], $data["text"], $cat, $data["user_id"], $data["blog_id"], $data["status"], 0);
         if ($data["date"]) {
             $article->setDate($data["date"]);
         }
         if ($post_id) {
             $article->setId($post_id);
         }
         $article->setCommentsEnabled($data["comments"]);
         $artId = $articles->addArticle($article);
         $this->_stats["posts"]["write"]++;
         // remap comments to $artId
         if ($this->_container["comments"]) {
             foreach ($this->_t_container["comments"] as $comment => $val) {
                 if ($this->container["comments"][$comment]["article_id"] == $data["id"] || $val["article_id"] == NULL) {
                     $this->_container["comments"][$comment]["article_id"] = $artId;
                     if ($_debug) {
                         print "--- --- remapping comment entry #" . $comment . " to proper article id<br />\n\r";
                     }
                 }
             }
         }
     } else {
         $artId = $exists;
         if ($_debug) {
             print "--- --- post already exists, aborting operation.<br />\n\r";
         }
     }
     return $artId;
 }
Example #7
0
 /**
  * Callback dealing with ArticleDAO::getArticle()
  * calls via our mock ArticleDAO.
  *
  * @see ArticleDAO::getArticle()
  */
 public function callbackGetArticle($articleId, $journalId = null, $useCache = false)
 {
     // Create an article instance with the correct id.
     $article = new Article();
     $article->setId($articleId);
     return $article;
 }
 public static function fromJson($json)
 {
     $article = new Article();
     return $article->setId($json->Id)->setSlug($json->Slug)->setTitle($json->Title)->setSubtitle($json->SubTitle)->setTextFormatted($json->TextFormatted)->setCreatedOn(new \DateTime($json->CreatedOn))->setLastModificationDate(new \DateTime($json->LastModificationDate))->setRedactor(Person::fromJson($json->Redactor))->setCategory(Category::fromJson($json->Category));
 }
 function perform()
 {
     $status = POST_STATUS_DRAFT;
     $articles = new Articles();
     $postText = Textfilter::xhtmlize($this->_postText) . POST_EXTENDED_TEXT_MODIFIER . Textfilter::xhtmlize($this->_postExtendedText);
     $article = new Article($this->_postTopic, $postText, $this->_postCategories, $this->_userInfo->getId(), $this->_blogInfo->getId(), $status, 0, array(), $this->_postSlug);
     // set also the date before it's too late
     $article->setDateObject($this->_postTimestamp);
     $article->setCommentsEnabled($this->_commentsEnabled);
     // prepare the custom fields
     $fields = array();
     if (is_array($this->_customFields)) {
         foreach ($this->_customFields as $fieldId => $fieldValue) {
             // 3 of those parameters are not really need when creating a new object... it's enough that
             // we know the field definition id.
             $customField = new CustomFieldValue($fieldId, $fieldValue, "", -1, "", $artId, $this->_blogInfo->getId(), -1);
             array_push($fields, $customField);
         }
         $article->setFields($fields);
     }
     // in case the post is already in the db
     if ($this->_postId != "") {
         $article->setId($this->_postId);
         $postSavedOk = $articles->updateArticle($article);
         if ($postSavedOk) {
             $artId = $this->_postId;
         } else {
             $artId = false;
         }
     } else {
         $artId = $articles->addArticle($article);
     }
     // once we have built the object, we can add it to the database
     $this->_view = new AdminXmlView($this->_blogInfo, "response");
     $this->_view->setValue("method", "saveXmlDraft");
     if ($artId) {
         $this->_view->setValue("result", $artId);
     } else {
         $this->_view->setValue("result", "0");
     }
     return true;
 }
 /**
  * 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);
 }
<?php

/**
 * Created by PhpStorm.
 * User: Florent
 * Date: 17/04/2015
 * Time: 10:48
 */
require_once '../Navbar/navbar.php';
require_once '../Database/pdo.php';
require_once '../Entity/Article.php';
require_once '../EntityManager/ArticleManager.php';
$monarticle = new Article();
$monarticle->setId($_POST['id'])->setTypeid($_POST['type'])->setNom($_POST['nom'])->setMarque($_POST['marque'])->setPoints($_POST['points'])->setDescription($_POST['description']);
$monmanagerarticle = new ArticleManager($bdd);
$monmanagerarticle->modification($monarticle);
header('Location:../Main/article.php');
Example #12
0
            <?php 
include 'header.php';
?>
        </header>
        <section>
            <div class="row">
                <div class="col-sm-6 col-sm-offset-3">
            <?php 
if (htmlentities(addslashes(isset($_POST['id'])))) {
    $news = $controleur->getNewsId($_POST['id']);
    echo "<form method='POST' action='updateNews.php'>\n                        <fieldset>\n                            <legend>Form update news</legend>\n                            <input type='hidden' id='id' name='id' value='" . $_POST['id'] . "'/>\n                            <label class='col-sm-4' for='title'>Title: </label>\n                            <input class='col-sm-8' type='text' id='title' name='title' value='" . $news->getTitle() . "' maxlength='100'/>\n                            <label class='col-sm-4' for='abstract'>Abstract: </label>\n                            <textarea class='col-sm-8' id='abstract' name='abstract'>" . $news->getAbstractNews() . "</textarea>\n                            <label class='col-sm-4' for='content'>Content: </label>\n                            <textarea class='col-sm-8' id='content' name='content'>" . $news->getContent() . "</textarea>\n                            <input type='hidden' id='datecreated' name='datecreated' value='" . $news->getDateCreated() . "'/>\n                            <input class='col-sm-8 col-sm-offset-4 btn btn-primary' type='submit' name='btnupdatenews' value='UPDATE'/>\n                        </fieldset>                                                                     </form>";
} else {
    if (isset($_POST['btnupdatenews'])) {
        $image = array();
        //TEMP
        $controleur = new Controleur();
        $news = new Article(htmlentities(addslashes($_POST['title'])), htmlentities(addslashes($_POST['abstract'])), htmlentities(addslashes($_POST['content'])), htmlentities(addslashes($_POST['datecreated'])), date("Y-m-d"), $image);
        $news->setId($_POST['id']);
        $controleur->updateNews($news);
        header('Location: news.php');
    } else {
        header('Location:home.php');
    }
}
?>
                </div>
            </div>
        </section>
         <script                                                 src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>          
    </body>
</html>
Example #13
0
 public function addArticle($title, $textId)
 {
     $article = new Article($this->addSubElement("article"));
     $article->setId($this->getId() . "_article_" . $this->getNewArticleId());
     $article->setTitle($title);
     $article->setText($textId);
     $this->saveDOM();
     return $article;
 }
Example #14
0
 /**
  * When string is passed to setId it throws InvalidArgumetException
  *
  * @expectedException InvalidArgumentException
  */
 public function testSetIdWithParamIsString()
 {
     $article = new Article();
     $article->setId('lala');
 }