private function getArticleLink(Article $article)
 {
     $params = array('f_publication_id' => $article->getPublicationId(), 'f_issue_number' => $article->getIssueNumber(), 'f_section_number' => $article->getSectionNumber(), 'f_article_number' => $article->getArticleNumber(), 'f_language_id' => $article->getLanguageId(), 'f_language_selected' => $article->getLanguageId());
     $queryString = implode('&', array_map(function ($property) use($params) {
         return $property . '=' . $params[$property];
     }, array_keys($params)));
     return $this->view->baseUrl("/admin/articles/edit.php?{$queryString}");
 }
Example #2
0
 /**
  * Get article edit link
  *
  * @param Article $article
  * @return string
  */
 public function getEditLink($article)
 {
     $params = array('f_publication_id' => $article->getPublicationId(), 'f_issue_number' => $article->getIssueNumber(), 'f_section_number' => $article->getSectionNumber(), 'f_article_number' => $article->getArticleNumber(), 'f_language_id' => $article->getLanguageId(), 'f_language_selected' => $article->getLanguageId());
     $paramsStrings = array();
     foreach ($params as $key => $val) {
         $paramsStrings[] = "{$key}={$val}";
     }
     return '/admin/articles/edit.php?' . implode('&', $paramsStrings);
 }
Example #3
0
 /**
  * Log article related event.
  *
  * @param Article $p_article
  * @param string $p_text
  * @param int $p_userId
  * @param int $p_eventId
  * @param bool $p_short
  *
  * @return void
  */
 public static function ArticleMessage(Article $p_article, $p_text, $p_userId = NULL, $p_eventId = 0, $p_short = FALSE)
 {
     ob_start();
     echo getGS('Article'), ': ', $p_article->getTitle();
     if (!$p_short) {
         // add publication, issue, section
         echo ' (';
         echo getGS('Publication'), ': ', $p_article->getPublicationId();
         echo ', ';
         echo getGS('Issue'), ': ', $p_article->getIssueNumber();
         echo ', ';
         echo getGS('Section'), ': ', $p_article->getSectionNumber();
         echo ")\n";
     }
     // generate url
     $url = ShortURL::GetURL($p_article->getPublicationId(), $p_article->getLanguageId(), $p_article->getIssueNumber(), $p_article->getSectionNumber(), $p_article->getArticleNumber());
     if (strpos($url, 'http') !== FALSE) {
         // no url for deleted
         echo getGS('Article URL'), ': ', $url, "\n";
     }
     echo getGS('Article Number'), ': ', $p_article->getArticleNumber(), "\n";
     echo getGS('Language'), ': ', $p_article->getLanguageName(), "\n";
     echo "\n";
     echo getGS('Action') . ': ', $p_text;
     $message = ob_get_clean();
     self::Message($message, $p_userId, $p_eventId);
 }
Example #4
0
 /**
  * Log article related event.
  *
  * @param Article $p_article
  * @param string $p_text
  * @param int $p_userId
  * @param int $p_eventId
  * @param bool $p_short
  *
  * @return void
  */
 public static function ArticleMessage(Article $p_article, $p_text, $p_userId = NULL, $p_eventId = 0, $p_short = FALSE)
 {
     ob_start();
     $translator = \Zend_Registry::get('container')->getService('translator');
     echo $translator->trans('Article'), ': ', $p_article->getTitle();
     if (!$p_short) {
         // add publication, issue, section
         echo ' (';
         echo $translator->trans('Publication'), ': ', $p_article->getPublicationId();
         echo ', ';
         echo $translator->trans('Issue'), ': ', $p_article->getIssueNumber();
         echo ', ';
         echo $translator->trans('Section'), ': ', $p_article->getSectionNumber();
         echo ")\n";
     }
     // generate url
     $url = ShortURL::GetURL($p_article->getPublicationId(), $p_article->getLanguageId(), $p_article->getIssueNumber(), $p_article->getSectionNumber(), $p_article->getArticleNumber());
     if (strpos($url, 'http') !== FALSE) {
         // no url for deleted
         echo $translator->trans('Article URL', array(), 'api'), ': ', $url, "\n";
     }
     echo $translator->trans('Article Number', array(), 'api'), ': ', $p_article->getArticleNumber(), "\n";
     echo $translator->trans('Language'), ': ', $p_article->getLanguageName(), "\n";
     echo "\n";
     echo $translator->trans('Action') . ': ', $p_text;
     $message = ob_get_clean();
     self::Message(substr($message, 0, 254), $p_userId, $p_eventId);
 }
 /**
  * Send request to refresh article cache on Facebook
  *
  * @param int $number
  * @param int $languageId
  *
  * @return mixed response from Facebook about url, or array with error message
  */
 private function clearpageCache($number, $languageId)
 {
     $article = new \Article($languageId, $number);
     if (!$article->isPublished()) {
         return array('message' => $this->get('translator')->trans('fb.label.errornot'));
     }
     $url = \ShortURL::GetURL($article->getPublicationId(), $article->getLanguageId(), $article->getIssueNumber(), $article->getSectionNumber(), $article->getArticleNumber());
     try {
         $curlClient = new \Buzz\Client\Curl();
         $curlClient->setTimeout(10000);
         $browser = new \Buzz\Browser($curlClient);
         $result = $browser->post('https://graph.facebook.com/?id=' . $url . '&scrape=true');
         $urlInfo = json_decode($result->getContent(), true);
     } catch (\Buzz\Exception\ClientException $e) {
         return array('message' => $this->get('translator')->trans('fb.label.error'));
     }
     return $urlInfo;
 }
Example #6
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());
	}
Example #7
0
    $diffSeconds = time() - strtotime($articleObj->getLockTime());
    $hours = floor($diffSeconds / 3600);
    $diffSeconds -= $hours * 3600;
    $minutes = floor($diffSeconds / 60);
    $lockUser = new User($articleObj->getLockedByUser());
    camp_html_add_msg($translator->trans('Could not save the article. It has been locked by $1 $2 hours and $3 minutes ago.', array('$1' => $lockUser->getRealName(), '$2' => $hours, '$3' => $minutes), 'articles'));
    camp_html_goto_page($BackLink);
    exit;
}
// Update the article author
$blogService = Zend_Registry::get('container')->getService('blog');
$blogInfo = $blogService->getBlogInfo($g_user);
if (!empty($f_article_author)) {
    $em = Zend_Registry::get('container')->getService('em');
    $dispatcher = Zend_Registry::get('container')->getService('dispatcher');
    $language = $em->getRepository('Newscoop\\Entity\\Language')->findOneById($articleObj->getLanguageId());
    $authors = $em->getRepository('Newscoop\\Entity\\ArticleAuthor')->getArticleAuthors($articleObj->getArticleNumber(), $language->getCode())->getArrayResult();
    ArticleAuthor::OnArticleLanguageDelete($articleObj->getArticleNumber(), $articleObj->getLanguageId());
    foreach ($authors as $author) {
        $dispatcher->dispatch("user.set_points", new \Newscoop\EventDispatcher\Events\GenericEvent($this, array('authorId' => $author['fk_author_id'])));
    }
    $i = 0;
    foreach ($f_article_author as $author) {
        $authorObj = new Author($author);
        $author = trim($author);
        if (!$authorObj->exists() && isset($author[0])) {
            if ($blogService->isBlogger($g_user)) {
                // blogger can't create authors
                continue;
            }
            $authorData = Author::ReadName($author);
Example #8
0
                putGS('You can not schedule opposing events at the same time');
                ?>
';
			        parent.$.fancybox.close();
			    } catch (e) {
			    }
			    </script>
			    <?php 
                exit;
            }
        }
    }
    $articlePublishObj = new ArticlePublish();
    $articlePublishObj->create();
    $articlePublishObj->setArticleNumber($tmpArticle->getArticleNumber());
    $articlePublishObj->setLanguageId($tmpArticle->getLanguageId());
    $articlePublishObj->setActionTime($publishTime);
    if ($f_publish_action == "P" || $f_publish_action == "U") {
        $articlePublishObj->setPublishAction($f_publish_action);
    }
    if ($f_front_page_action == "S" || $f_front_page_action == "R") {
        $articlePublishObj->setFrontPageAction($f_front_page_action);
    }
    if ($f_section_page_action == "S" || $f_section_page_action == "R") {
        $articlePublishObj->setSectionPageAction($f_section_page_action);
    }
    Log::ArticleMessage($tmpArticle, getGS('Scheduled action added'), $g_user->getUserId(), 37);
}
if ($f_mode == "multi") {
    $args = $_REQUEST;
    unset($args["f_article_code"]);
Example #9
0
 /**
  * Process item
  * @param  Article $article
  * @return array
  */
 public function processItem(Article $article)
 {
     global $g_user, $Campsite;
     $translator = \Zend_Registry::get('container')->getService('translator');
     return array($article->getArticleNumber(), $article->getLanguageId(), sprintf('
             <div class="context-item" langid="%s">
                 <div class="context-drag-topics"><a href="#" title="drag to sort"></a></div>
                 <div class="context-item-header">
                     <div class="context-item-date">%s (%s) (%s)</div>
                     <a href="#" class="view-article" onClick="viewArticle($(this).parent(\'div\').parent(\'div\').parent(\'td\').parent(\'tr\').attr(\'id\'), $(this).parents(\'.context-item:eq(0)\').attr(\'langid\'));">%s</a>
                 </div>
                 <a href="javascript:void(0)" class="corner-button" style="display: none" onClick="removeFromContext($(this).parent(\'div\').parent(\'td\').parent(\'tr\').attr(\'id\'));removeFromContext($(this).parents(\'.item:eq(0)\').attr(\'id\'));toggleDragZonePlaceHolder();"><span class="ui-icon ui-icon-closethick"></span></a>
                 <div class="context-item-summary">%s</div>
                 </div>
         ', $article->getLanguageId(), $article->getLastModified(), $article->getWorkflowDisplayString(), $article->getType(), $translator->trans('View article', array(), 'library'), $article->getName()));
 }
Example #10
0
/**
 * Create a link to an article.
 *
 * @param Article $p_articleObj
 *		The article we want to display.
 *
 * @param int $p_sectionLanguageId
 *		The language ID for the publication/issue/section.
 *
 * @param string $p_targetFileName
 *		Which file in the "articles" directory to call.
 *
 * @param string $p_backLink
 *		A URL to get back to the previous page the user was on.
 *
 * @param string $p_extraParams
 */
function camp_html_article_url($p_articleObj, $p_sectionLanguageId, $p_targetFileName = "", $p_backLink = "", $p_extraParams = null, $p_securityParameter = false)
{
    global $ADMIN;
    $str = "/{$ADMIN}/articles/" . $p_targetFileName . "?f_publication_id=" . $p_articleObj->getPublicationId() . "&f_issue_number=" . $p_articleObj->getIssueNumber() . "&f_section_number=" . $p_articleObj->getSectionNumber() . "&f_article_number=" . $p_articleObj->getArticleNumber() . "&f_language_id=" . $p_sectionLanguageId . "&f_language_selected=" . $p_articleObj->getLanguageId();
    if ($p_securityParameter) {
        $str .= '&' . SecurityToken::URLParameter();
    }
    if ($p_backLink != "") {
        $str .= "&Back=" . urlencode($p_backLink);
    }
    if (!is_null($p_extraParams)) {
        $str .= $p_extraParams;
    }
    return $str;
}
Example #11
0
});

window.load_events = function(start, end, callback, url) {
// TODO: use start/end to limit the amount of loaded data
    callServer(
        {
            'url': url,
            'method': 'GET'
        },
        {
            articleId : "<?php 
echo $articleId;
?>
",
            languageId : "<?php 
echo $article->getLanguageId();
?>
"
        },
        function(res) {
            callback(res);
        },
        true
    );

};

</script>

</head>
<body onLoad="return false;" style="background: none repeat scroll 0 0 #FFFFFF;">
Example #12
0
    $diffSeconds = time() - strtotime($articleObj->getLockTime());
    $hours = floor($diffSeconds / 3600);
    $diffSeconds -= $hours * 3600;
    $minutes = floor($diffSeconds / 60);
    $lockUser = new User($articleObj->getLockedByUser());
    camp_html_add_msg($translator->trans('Could not save the article. It has been locked by $1 $2 hours and $3 minutes ago.', array('$1' => $lockUser->getRealName(), '$2' => $hours, '$3' => $minutes), 'articles'));
    camp_html_goto_page($BackLink);
    exit;
}
// Update the article author
$blogService = Zend_Registry::get('container')->getService('blog');
$blogInfo = $blogService->getBlogInfo($g_user);
if (!empty($f_article_author)) {
    $em = Zend_Registry::get('container')->getService('em');
    $dispatcher = Zend_Registry::get('container')->getService('dispatcher');
    $language = $em->getRepository('Newscoop\\Entity\\Language')->findOneById($articleObj->getLanguageId());
    $authors = $em->getRepository('Newscoop\\Entity\\ArticleAuthor')->getArticleAuthors($articleObj->getArticleNumber(), $language->getCode())->getArrayResult();
    ArticleAuthor::OnArticleLanguageDelete($articleObj->getArticleNumber(), $articleObj->getLanguageId());
    foreach ($authors as $author) {
        $dispatcher->dispatch("user.set_points", new \Newscoop\EventDispatcher\Events\GenericEvent($this, array('authorId' => $author['fk_author_id'])));
    }
    $i = 0;
    foreach ($f_article_author as $author) {
        $authorObj = new Author($author);
        $author = trim($author);
        if (!$authorObj->exists() && isset($author[0])) {
            if ($blogService->isBlogger($g_user)) {
                // blogger can't create authors
                continue;
            }
            $authorData = Author::ReadName($author);
Example #13
0
 /**
  * Test if given article is from users blog
  *
  * @param Article $article
  * @param Newscoop\Entity\User $user
  * @return bool
  */
 public function isUsersArticle(\Article $article, User $user)
 {
     $section = $this->getSection($user);
     return $section->getSectionNumber() == $article->getSectionNumber() && $section->getPublicationId() == $article->getPublicationId() && $section->getIssueNumber() == $article->getIssueNumber() && $section->getLanguageId() == $article->getLanguageId();
 }
Example #14
0
$savedOn = getdate($lastModified);
$savedToday = true;
if ($today['year'] != $savedOn['year'] || $today['mon'] != $savedOn['mon'] || $today['mday'] != $savedOn['mday']) {
    $savedToday = FALSE;
}
$sectionObj = null;
$showComments = FALSE;
$showCommentControls = FALSE;
if ($f_publication_id > 0) {
    $publicationObj = new Publication($f_publication_id);
    if ($publicationObj->exists()) {
        $issueObj = new Issue($f_publication_id, $f_language_id, $f_issue_number);
        if ($issueObj->exists()) {
            $sectionObj = new Section($f_publication_id, $f_issue_number, $f_language_id, $f_section_number);
            if ($sectionObj->exists()) {
                $languageObj = new Language($articleObj->getLanguageId());
            } else {
                $sectionObj = null;
            }
        } else {
            $issueObj = null;
        }
    } else {
        $publicationObj = null;
    }
    $showCommentControls = $publicationObj->commentsEnabled() && $articleType->commentsEnabled();
    $showComments = $showCommentControls && $articleObj->commentsEnabled();
}
if ($showComments) {
    //    $comments = array();
    /**
Example #15
0
$f_language_selected = (int) camp_session_get('f_language_selected', 0);
// Fetch article
$articleObj = new Article($f_language_selected, $f_article_number);
if (!$articleObj->exists()) {
    camp_html_display_error($translator->trans('No such article.', array(), 'articles'));
    exit;
}
//getArticleAuthors()
$articleInfo = array();
$articleData = $articleObj->getArticleData();
// Get article type fields.
$dbColumns = $articleData->getUserDefinedColumns(false, true);
foreach ($dbColumns as $dbColumn) {
    if ($dbColumn->getType() == ArticleTypeField::TYPE_SWITCH) {
        $value = $articleData->getProperty($dbColumn->getName()) ? $translator->trans('On', array(), 'articles') : $translator->trans('Off', array(), 'articles');
        $articleInfo[htmlspecialchars($dbColumn->getDisplayName($articleObj->getLanguageId()))] = $value;
    } else {
        $articleInfo[htmlspecialchars($dbColumn->getDisplayName($articleObj->getLanguageId()))] = $articleData->getProperty($dbColumn->getName());
    }
}
$articleInfo[$translator->trans('Title', array(), 'articles')] = $articleObj->getTitle();
// THIS IS REALLY BAD, NEVER LOCALIZE INTERNALLY
$articleInfo[$translator->trans('Date')] = $articleObj->getCreationDate();
// But I don't know what possibly depends on this so we leave it for now
$articleInfo['title'] = $articleObj->getTitle();
$articleInfo['date'] = $articleObj->getCreationDate();
$authors = ArticleAuthor::GetAuthorsByArticle($articleObj->getArticleNumber(), $articleObj->getLanguageId());
$authorsNames = array();
foreach ($authors as $author) {
    $authorsNames[] = $author->getName();
}
Example #16
0
    exit;
}
// Only users with a lock on the article can change it.
if ($articleObj->isLocked() && $g_user->getUserId() != $articleObj->getLockedByUser()) {
    $diffSeconds = time() - strtotime($articleObj->getLockTime());
    $hours = floor($diffSeconds / 3600);
    $diffSeconds -= $hours * 3600;
    $minutes = floor($diffSeconds / 60);
    $lockUser = new User($articleObj->getLockedByUser());
    camp_html_add_msg($translator->trans('Could not save the article. It has been locked by $1 $2 hours and $3 minutes ago.', array('$1' => $lockUser->getRealName(), '$2' => $hours, '$3' => $minutes), 'articles'));
    camp_html_goto_page($BackLink);
    exit;
}
// Update the article author
if (!empty($f_article_author)) {
    ArticleAuthor::OnArticleLanguageDelete($articleObj->getArticleNumber(), $articleObj->getLanguageId());
    $i = 0;
    foreach ($f_article_author as $author) {
        $authorObj = new Author($author);
        if (!$authorObj->exists() && strlen(trim($author)) > 0) {
            $authorData = Author::ReadName($author);
            $authorObj->create($authorData);
        }
        // Sets the author type selected
        $author_type = $f_article_author_type[$i];
        $authorObj->setType($author_type);
        // Links the author to the article
        $articleAuthorObj = new ArticleAuthor($articleObj->getArticleNumber(), $articleObj->getLanguageId(), $authorObj->getId(), $author_type);
        if (!$articleAuthorObj->exists()) {
            $articleAuthorObj->create();
        }
Example #17
0
 /**
  * Test article authors
  */
 private function checkAuthors($count, \Article $article, Feed $feed)
 {
     $authors = \ArticleAuthor::GetAuthorsByArticle($article->getArticleNumber(), $article->getLanguageId());
     $this->assertEquals(1, count($authors), 'Authors count fails.');
     $this->assertEquals($feed->getTitle(), $authors[0]->getName());
 }
    /**
     * Create the first message for an article, which is a blank message
     * with the title of the article as the subject.
     *
     * @param Article $p_article
     * @param int $p_forumId
     * @return mixed
     * 		The comment created (or the one that already exists) on success,
     *  	or false on error.
     */
    private function CreateFirstComment($p_article, $p_forumId)
    {
        // Check if the first post already exists.
        $articleNumber = $p_article->getArticleNumber();
        $languageId = $p_article->getLanguageId();
        $firstPost = ArticleComment::GetCommentThreadId($articleNumber, $languageId);
        if ($firstPost) {
            return new Phorum_message($firstPost);
        }

        // Get article creator
        $user = new User($p_article->getCreatorId());
        if ($user->exists()) {
            $userId = $user->getUserId();
            $userEmail = $user->getEmail();
            $userPasswd = $user->getPassword();
            $userName = $user->getUserName();
            $userRealName = $user->getRealName();

            // Create phorum user if necessary
            $phorumUser = Phorum_user::GetByUserName($userName);
            if (!is_object($phorumUser)) {
                $phorumUser = new Phorum_user();
            }
            if (!$phorumUser->CampUserExists($userId)
            && !$phorumUser->create($userName, $userPasswd, $userEmail, $userId)) {
                return null;
            }
        } else {
            $userId = null;
            $userEmail = '';
            $userRealName = '';
        }

        // Create the comment.
        $title = $p_article->getTitle();
        $commentObj = new Phorum_message();
        if ($commentObj->create($p_forumId, $title, '', 0, 0, $userRealName,
        $userEmail, is_null($userId) ? 0 : $userId)) {
            // Link the message to the current article.
            ArticleComment::Link($articleNumber, $languageId, $commentObj->getMessageId(), true);
            return $commentObj;
        } else {
            return null;
        }
    } // method CreateFirstComment
Example #19
0
 /**
  * Process item
  * @param Article $article
  * @return array
  */
 public function processItem(Article $article)
 {
     global $g_user, $Campsite;
     return array($article->getArticleNumber(), $article->getLanguageId(), sprintf('
             <div class="context-item" langid="%s">
                 <div class="context-drag-topics"><a href="#" title="drag to sort"></a></div>
                 <div class="context-item-header">
                     <div class="context-item-date">%s</div>
                     <a href="#" class="view-article" onClick="viewArticle($(this).parent(\'div\').parent(\'div\').parent(\'td\').parent(\'tr\').attr(\'id\'), $(this).parents(\'.context-item:eq(0)\').attr(\'langid\'));">%s</a>
                 </div>
                 <a href="javascript:void(0)" class="corner-button" style="display: none" onClick="removeFromContext($(this).parent(\'div\').parent(\'td\').parent(\'tr\').attr(\'id\'));removeFromContext($(this).parents(\'.item:eq(0)\').attr(\'id\'));toggleDragZonePlaceHolder();"><span class="ui-icon ui-icon-closethick"></span></a>
                 <div class="context-item-summary">%s</div>
                 </div>
         ', $article->getLanguageId(), $article->getCreationDate(), getGS('View article'), $article->getName()));
 }
Example #20
0
 /**
  * Process item
  * @param Article $article
  * @return array
  */
 public function processItem(Article $article)
 {
     global $g_user, $Campsite;
     $articleLinkParams = '?f_publication_id=' . $article->getPublicationId() . '&amp;f_issue_number=' . $article->getIssueNumber() . '&amp;f_section_number=' . $article->getSectionNumber() . '&amp;f_article_number=' . $article->getArticleNumber() . '&amp;f_language_id=' . $article->getLanguageId() . '&amp;f_language_selected=' . $article->getLanguageId();
     $articleLinkParamsTranslate = $articleLinkParams . '&amp;f_action=translate&amp;f_action_workflow=' . $article->getWorkflowStatus() . '&amp;f_article_code=' . $article->getArticleNumber() . '_' . $article->getLanguageId();
     $articleLink = $Campsite['WEBSITE_URL'] . '/admin/articles/edit.php' . $articleLinkParams;
     $previewLink = $Campsite['WEBSITE_URL'] . '/admin/articles/preview.php' . $articleLinkParams;
     $htmlPreviewLink = '<a href="' . $previewLink . '" target="_blank" title="' . getGS('Preview') . '">' . getGS('Preview') . '</a>';
     $translateLink = $Campsite['WEBSITE_URL'] . '/admin/articles/translate.php' . $articleLinkParamsTranslate;
     $htmlTranslateLink = '<a href="' . $translateLink . '" target="_blank" title="' . getGS('Translate') . '">' . getGS('Translate') . '</a>';
     $lockInfo = '';
     $lockHighlight = false;
     $timeDiff = camp_time_diff_str($article->getLockTime());
     if ($article->isLocked() && $timeDiff['days'] <= 0) {
         $lockUser = new User($article->getLockedByUser());
         if ($timeDiff['hours'] > 0) {
             $lockInfo = getGS('The article has been locked by $1 ($2) $3 hour(s) and $4 minute(s) ago.', htmlspecialchars($lockUser->getRealName()), htmlspecialchars($lockUser->getUserName()), $timeDiff['hours'], $timeDiff['minutes']);
         } else {
             $lockInfo = getGS('The article has been locked by $1 ($2) $3 minute(s) ago.', htmlspecialchars($lockUser->getRealName()), htmlspecialchars($lockUser->getUserName()), $timeDiff['minutes']);
         }
         if ($article->getLockedByUser() != $g_user->getUserId()) {
             $lockHighlight = true;
         }
     }
     $tmpUser = new User($article->getCreatorId());
     $tmpArticleType = new ArticleType($article->getType());
     $tmpAuthor = new Author();
     $articleAuthors = ArticleAuthor::GetAuthorsByArticle($article->getArticleNumber(), $article->getLanguageId());
     foreach ((array) $articleAuthors as $author) {
         if (strtolower($author->getAuthorType()->getName()) == 'author') {
             $tmpAuthor = $author;
             break;
         }
     }
     if (!$tmpAuthor->exists() && isset($articleAuthors[0])) {
         $tmpAuthor = $articleAuthors[0];
     }
     $onFrontPage = $article->onFrontPage() ? getGS('Yes') : getGS('No');
     $onSectionPage = $article->onSectionPage() ? getGS('Yes') : getGS('No');
     $imagesNo = (int) ArticleImage::GetImagesByArticleNumber($article->getArticleNumber(), true);
     $topicsNo = (int) ArticleTopic::GetArticleTopics($article->getArticleNumber(), true);
     $commentsNo = '';
     if ($article->commentsEnabled()) {
         global $controller;
         $repositoryComments = $controller->getHelper('entity')->getRepository('Newscoop\\Entity\\Comment');
         $filter = array('thread' => $article->getArticleNumber(), 'language' => $article->getLanguageId());
         $params = array('sFilter' => $filter);
         $commentsNo = $repositoryComments->getCount($params);
     } else {
         $commentsNo = 'No';
     }
     // get language code
     $language = new Language($article->getLanguageId());
     return array($article->getArticleNumber(), $article->getLanguageId(), $article->getOrder(), sprintf('%s <a href="%s" title="%s %s">%s</a>', $article->isLocked() ? '<span class="ui-icon ui-icon-locked' . (!$lockHighlight ? ' current-user' : '') . '" title="' . $lockInfo . '"></span>' : '', $articleLink, getGS('Edit'), htmlspecialchars($article->getName() . " ({$article->getLanguageName()})"), htmlspecialchars($article->getName() . (empty($_REQUEST['language']) ? " ({$language->getCode()})" : ''))), htmlspecialchars($article->getSection()->getName()), $article->getWebcode(), htmlspecialchars($tmpArticleType->getDisplayName()), htmlspecialchars($tmpUser->getRealName()), htmlspecialchars($tmpAuthor->getName()), $article->getWorkflowStatus(), $onFrontPage, $onSectionPage, $imagesNo, $topicsNo, $commentsNo, (int) $article->getReads(), Geo_Map::GetArticleMapId($article) != NULL ? getGS('Yes') : getGS('No'), (int) sizeof(Geo_Map::GetLocationsByArticle($article)), $article->getCreationDate(), $article->getPublishDate(), $article->getLastModified(), $htmlPreviewLink, $htmlTranslateLink);
 }
Example #21
0
}
// Only users with a lock on the article can change it.
if ($articleObj->isLocked() && ($g_user->getUserId() != $articleObj->getLockedByUser())) {
	$diffSeconds = time() - strtotime($articleObj->getLockTime());
	$hours = floor($diffSeconds/3600);
	$diffSeconds -= $hours * 3600;
	$minutes = floor($diffSeconds/60);
	$lockUser = new User($articleObj->getLockedByUser());
	camp_html_add_msg(getGS('Could not save the article. It has been locked by $1 $2 hours and $3 minutes ago.', $lockUser->getRealName(), $hours, $minutes));
	camp_html_goto_page($BackLink);
	exit;
}

// Update the first comment if the article title has changed
if ($f_article_title != $articleObj->getTitle()) {
	$firstPostId = ArticleComment::GetCommentThreadId($articleObj->getArticleNumber(), $articleObj->getLanguageId());
	if ($firstPostId) {
		$firstPost = new Phorum_message($firstPostId);
		$firstPost->setSubject($f_article_title);
	}
}

// Update the article author
if (!empty($f_article_author)) {
    ArticleAuthor::OnArticleLanguageDelete($articleObj->getArticleNumber(), $articleObj->getLanguageId());
    $i = 0;
    foreach ($f_article_author as $author) {
        $authorObj = new Author($author);
        if (!$authorObj->exists()  && strlen(trim($author)) > 0) {
            $authorData = Author::ReadName($author);
            $authorObj->create($authorData);
 /**
  * @Route("/redirect/{languageId}/{articleNumber}/")
  */
 public function redirectToArticleAction($languageId, $articleNumber, Request $request)
 {
     $legacyArticleLink = '';
     // find article
     $article = new \Article($languageId, $articleNumber);
     if (!$article->exists()) {
         throw new Exception($this->container->get('translator')->trans('plugin.ingest.entries.articlenotfound', array('%language%' => $languageId, '%article%' => $articleNumber)), 1);
     }
     $legacyArticleLink = '/admin/articles/edit.php?f_publication_id=' . $article->getPublicationId() . '&f_issue_number=' . $article->getIssueNumber() . '&f_section_number=' . $article->getSectionNumber() . '&f_article_number=' . $article->getArticleNumber() . '&f_language_id=' . $article->getLanguageId() . '&f_language_selected=' . $article->getLanguageId();
     return $this->redirect($legacyArticleLink);
 }