예제 #1
0
파일: Log.php 프로젝트: nidzix/Newscoop
 /**
  * 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);
 }
예제 #2
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);
 }
예제 #3
0
 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}");
 }
예제 #4
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);
 }
 /**
  * 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;
 }
예제 #6
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;
}
예제 #7
0
 /**
  * Get article
  *
  * @param int $articleNo
  * @param MetaLanguage $language
  * @return MetaArticle
  */
 private function _getArticle($articleNo, MetaLanguage $language)
 {
     if (empty($articleNo)) {
         return null;
     }
     $articleObj = new Article($language->number, $articleNo);
     if (!$articleObj->exists() || !$this->m_preview && !$articleObj->isPublished()) {
         throw new InvalidArgumentException("Invalid article identifier in URL.", self::INVALID_ARTICLE);
     }
     return new MetaArticle($language->number, $articleObj->getArticleNumber());
 }
예제 #8
0
    /**
     * Create a copy of the article, but make it a translation
     * of the current one.
     *
     * @param int $p_languageId
     * @param int $p_userId
     * @param string $p_name
     * @return Article
     */
    public function createTranslation($p_languageId, $p_userId, $p_name)
    {
        // Construct the duplicate article object.
        $articleCopy = new Article();
        $articleCopy->m_data['IdPublication'] = $this->m_data['IdPublication'];
        $articleCopy->m_data['NrIssue'] = $this->m_data['NrIssue'];
        $articleCopy->m_data['NrSection'] = $this->m_data['NrSection'];
        $articleCopy->m_data['IdLanguage'] = $p_languageId;
        $articleCopy->m_data['Number'] = $this->m_data['Number'];
        $values = array();
        // Copy some attributes
        $values['ShortName'] = $this->m_data['ShortName'];
        $values['Type'] = $this->m_data['Type'];
        $values['OnFrontPage'] = $this->m_data['OnFrontPage'];
        $values['OnSection'] = $this->m_data['OnFrontPage'];
        $values['Public'] = $this->m_data['Public'];
        $values['ArticleOrder'] = $this->m_data['ArticleOrder'];
        $values['comments_enabled'] = $this->m_data['comments_enabled'];
        $values['comments_locked'] = $this->m_data['comments_locked'];
        // Change some attributes
        $values['Name'] = $p_name;
        $values['Published'] = 'N';
        $values['IsIndexed'] = 'N';
        $values['LockUser'] = 0;
        $values['LockTime'] = 0;
        $values['IdUser'] = $p_userId;

        // Create the record
        $success = $articleCopy->__create($values);
        if (!$success) {
            return false;
        }

        $articleCopy->setProperty('UploadDate', 'NOW()', true, true);

        // Insert an entry into the article type table.
        $articleCopyData = new ArticleData($articleCopy->m_data['Type'],
            $articleCopy->m_data['Number'], $articleCopy->m_data['IdLanguage']);
        $articleCopyData->create();

        $origArticleData = $this->getArticleData();
        $origArticleData->copyToExistingRecord($articleCopy->getArticleNumber(), $p_languageId);

        if (function_exists("camp_load_translation_strings")) {
            camp_load_translation_strings("api");
        }
        $logtext = getGS('Article translated to "$4" ($5)',
            $articleCopy->getTitle(), $articleCopy->getLanguageName());
        Log::ArticleMessage($this, $logtext, null, 31);

        // geo-map processing
        Geo_Map::OnCreateTranslation($this->m_data['Number'], $this->m_data['IdLanguage'], $p_languageId);

        return $articleCopy;
    } // fn createTranslation
예제 #9
0
        				<TD ALIGN="RIGHT" valign="top" style="padding-left: 1em;"><b><?php  putGS("Type"); ?>:</b></TD>
        				<TD align="left" valign="top">
        					<?php print htmlspecialchars($dest->getDisplayName()); ?>
        				</TD>
        				<TD ALIGN="RIGHT" valign="top" style="padding-left: 1em;"><b><nobr><?php  putGS("Creation date"); ?>:</nobr></b></TD>
        				<TD align="left" valign="top" nowrap>
        					<?php print $curPreview->getCreationDate(); ?>
        				</TD>
        				<TD ALIGN="RIGHT" valign="top" style="padding-left: 1em;"></TD>
        				<TD align="left" valign="top"  style="padding-top: 0.25em;">
        				<?php  putGS('Show article on section page'); ?>
        				</TD>
        			</TR>
        			<TR>
        			    <td align="right" valign="top" nowrap><b><?php putGS("Number"); ?>:</b></td>
        			    <td align="left" valign="top"  style="padding-top: 2px; padding-left: 4px;"><?php p($curPreview->getArticleNumber()); ?> <?php if (isset($publicationObj) && $publicationObj->getUrlTypeId() == 2) { ?>
        &nbsp;(<a href="/<?php echo $languageObj->getCode()."/".$issueObj->getUrlName()."/".$sectionObj->getUrlName()."/".$curPreview->getUrlName(); ?>"><?php putGS("Link to public page"); ?></a>)<?php } ?></td>

        				<TD ALIGN="RIGHT" valign="top" style="padding-left: 1em;"><b><?php  putGS("Publish date"); ?>:</b></TD>
        				<TD align="left" valign="top">
        					<?php print htmlspecialchars($curPreview->getPublishDate()); ?>
        				</TD>
        				<TD ALIGN="RIGHT" valign="top" style="padding-left: 1em;"></TD>
        				<TD align="left" valign="top" style="padding-top: 0.25em;">
        				<?php putGS('Allow users without subscriptions to view the article'); ?>
        				</TD>
        			</TR>
        			</TABLE>
        		</TD>
        	</TR>
예제 #10
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()));
 }
 /**
  * Set images for the article
  *
  * @param \Article                                  $article
  * @param \Newscoop\IngestPluginBundle\Entity\Entry $entry
  */
 protected function setArticleImagesLegacy(\Article $article, \Newscoop\IngestPluginBundle\Entity\Feed\Entry $entry)
 {
     $images = $entry->getImages();
     if (!is_array($images) || empty($images)) {
         return;
     }
     $oldImages = \ArticleImage::GetImagesByArticleNumber($article->getArticleNumber());
     if (is_array($oldImages)) {
         foreach ($oldImages as $image) {
             $image->delete();
         }
     }
     $filesystem = new Filesystem();
     foreach ($images as $image) {
         if (!array_key_exists('location', $image) || !$image['location']) {
             continue;
         }
         $imagePath = '';
         if ($filesystem->exists($image['location'])) {
             $basename = basename($image['location']);
             $imagePath = $image['location'];
         } else {
             $tmpPath = tempnam(sys_get_temp_dir(), 'NWSIMG');
             try {
                 $filesystem->copy($image['location'], $tmpPath, true);
             } catch (IOExceptionInterface $e) {
                 continue;
             }
             $imagePath = $tmpPath;
             $basename = basename($image['location']);
         }
         $imagesize = getimagesize($imagePath);
         $info = array('name' => $basename, 'type' => $imagesize['mime'], 'tmp_name' => $imagePath, 'size' => filesize($imagePath), 'error' => 0);
         $attributes = array('Photographer' => array_key_exists('photographer', $image) ? $image['photographer'] : '', 'Description' => array_key_exists('description', $image) ? $image['description'] : '', 'Source' => 'newsfeed', 'Status' => 'approved');
         try {
             $image = \Image::OnImageUpload($info, $attributes, null, null, true);
             \ArticleImage::AddImageToArticle($image->getImageId(), $article->getArticleNumber(), null);
         } catch (\Exception $e) {
             var_dump($e);
             exit;
         }
     }
 }
예제 #12
0
}
if ($f_publish_hour == "" || $f_publish_minute == "") {
    camp_html_add_msg(getGS('You must fill in the $1 field.', '<B>' . getGS('Time') . '</B>'));
}
if ($f_publish_action != "P" && $f_publish_action != "U" && $f_front_page_action != "S" && $f_front_page_action != "R" && $f_section_page_action != "S" && $f_section_page_action != "R") {
    camp_html_add_msg(getGS('You must select an action.'));
}
if (count($articles) == 0 && count($errorArticles) > 0) {
    camp_html_add_msg(getGS("The article is new; it is not possible to schedule it for automatic publishing."));
}
if (camp_html_has_msgs()) {
    camp_html_goto_page($backLink);
}
$publishTime = $f_publish_date . " " . $f_publish_hour . ":" . $f_publish_minute . ":00";
foreach ($articles as $tmpArticle) {
    $articleEvents = ArticlePublish::GetArticleEvents($tmpArticle->getArticleNumber(), $f_language_selected, TRUE);
    foreach ($articleEvents as $event) {
        if ($event->getActionTime() == $publishTime) {
            if ($f_publish_action != $event->getPublishAction()) {
                ?>
			    <script type="text/javascript">
			    try {
			        parent.$.fancybox.reload = true;
			        parent.$.fancybox.message = '<?php 
                putGS('You can not schedule opposing events at the same time');
                ?>
';
			        parent.$.fancybox.close();
			    } catch (e) {
			    }
			    </script>
예제 #13
0
	camp_html_add_msg(getGS('You must select an action.'));
}

if ( (count($articles) == 0) && (count($errorArticles) > 0) ) {
	camp_html_add_msg(getGS("The article is new; it is not possible to schedule it for automatic publishing."));
}

if (camp_html_has_msgs()) {
	camp_html_goto_page($backLink);
}

$publishTime = $f_publish_date . " " . $f_publish_hour . ":" . $f_publish_minute . ":00";
foreach ($articles as $tmpArticle) {
	$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;
예제 #14
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();
        }
예제 #15
0
    /**
     * Sets the URL values.
     *
     * Algorithm:
	 * - identify object (e.g.: publication, language, issue, section, article)
	 *     - object defined
	 *         - valid object?
	 *             - yes: set
	 *             - no: return error
	 *     - object undefined
	 *         - has default value?
	 *             - yes: set
	 *             - no:
	 *                 - object mandatory?
	 *                     - yes: return error
	 *                     - no: continue
     *
     * @return PEAR_Error
     *
     */
    private function setURL()
    {
        $this->setQueryVar('acid', null);

        $this->m_publication = null;
        $this->m_language = null;
        $this->m_issue = null;
        $this->m_section = null;
        $this->m_article = null;

        // gets the publication object based on site name (URI host)
        $alias = preg_replace('/^'.$this->getScheme().':\/\//', '', $this->getBase());
        $aliasObj = new Alias($alias);
        if ($aliasObj->exists()) {
            $this->m_publication = new MetaPublication($aliasObj->getPublicationId());
        }
        if (is_null($this->m_publication) || !$this->m_publication->defined()) {
            return new PEAR_Error("Invalid site name '$alias' in URL.", self::INVALID_SITE_NAME);
        }

        // reads parameters values if any
        $params = str_replace($this->m_config->getSetting('SUBDIR'), '', $this->getPath());
        $cParams = explode('/', trim($params, '/'));
        $cParamsSize = sizeof($cParams);
        if ($cParamsSize >= 1) {
            $cLangCode = $cParams[0];
        }
        if ($cParamsSize >= 2) {
            $cIssueSName = $cParams[1];
        }
        if ($cParamsSize >= 3) {
            $cSectionSName = $cParams[2];
        }
        if ($cParamsSize >= 4) {
            $cArticleSName = $cParams[3];
        }

        // gets the language identifier and sets the language code
        if (!empty($cLangCode)) {
            $langArray = Language::GetLanguages(null, $cLangCode);
            if (is_array($langArray) && sizeof($langArray) == 1) {
                $this->m_language = new MetaLanguage($langArray[0]->getLanguageId());
            }
        } else {
            $this->m_language = new MetaLanguage($this->m_publication->default_language->number);
        }
        if (is_null($this->m_language) || !$this->m_language->defined()) {
            return new PEAR_Error("Invalid language identifier in URL.", self::INVALID_LANGUAGE);
        }

        // gets the issue number and sets the issue short name
        if (!empty($cIssueSName)) {
        	$publishedOnly = !$this->m_preview;
            $issueArray = Issue::GetIssues($this->m_publication->identifier,
            $this->m_language->number, null, $cIssueSName, null, $publishedOnly);
            if (is_array($issueArray) && sizeof($issueArray) == 1) {
                $this->m_issue = new MetaIssue($this->m_publication->identifier,
                $this->m_language->number,
                $issueArray[0]->getIssueNumber());
            } else {
                return new PEAR_Error("Invalid issue identifier in URL.", self::INVALID_ISSUE);
	        }
        } else {
            $issueObj = Issue::GetCurrentIssue($this->m_publication->identifier,
            $this->m_language->number);
            $this->m_issue = new MetaIssue($this->m_publication->identifier,
            $this->m_language->number, $issueObj->getIssueNumber());
            if (!$this->m_issue->defined()) {
                return new PEAR_Error("No published issue was found.", self::INVALID_ISSUE);
            }
        }

        // gets the section number and sets the section short name
        if (!empty($cSectionSName)) {
            $sectionArray = Section::GetSections($this->m_publication->identifier,
            $this->m_issue->number,
            $this->m_language->number,
            $cSectionSName);
            if (is_array($sectionArray) && sizeof($sectionArray) == 1) {
                $this->m_section = new MetaSection($this->m_publication->identifier,
                $this->m_issue->number,
                $this->m_language->number,
                $sectionArray[0]->getSectionNumber());
            } else {
                return new PEAR_Error("Invalid section identifier in URL.", self::INVALID_SECTION);
            }
        }

        // gets the article number and sets the article short name
        if (!empty($cArticleSName)) {
            // we pass article short name as article identifier as they are
            // the same for Campsite, we will have to change this in the future
            $articleObj = new Article($this->m_language->number, $cArticleSName);
            if (!$articleObj->exists() || (!$this->m_preview && !$articleObj->isPublished())) {
                return new PEAR_Error("Invalid article identifier in URL.", self::INVALID_ARTICLE);
            }
            $this->m_article = new MetaArticle($this->m_language->number,
            $articleObj->getArticleNumber());
        }

        $templateId = CampRequest::GetVar(CampRequest::TEMPLATE_ID);
        $this->m_template = new MetaTemplate($this->getTemplate($templateId));
        if (!$this->m_template->defined()) {
            return new PEAR_Error("Invalid template in URL or no default template specified.",
            self::INVALID_TEMPLATE);
        }

        $this->m_validURI = true;
        $this->validateCache(false);
    } // fn setURL
예제 #16
0
    $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);
            $authorObj->create($authorData);
예제 #17
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);
 }
예제 #18
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()));
 }
예제 #19
0
파일: merge3.php 프로젝트: nidzix/Newscoop
        ?>
        				</TD>
        				<TD ALIGN="RIGHT" valign="top" style="padding-left: 1em;"></TD>
        				<TD align="left" valign="top"  style="padding-top: 0.25em;">
        				<?php 
        putGS('Show article on section page');
        ?>
        				</TD>
        			</TR>
        			<TR>
        			    <td align="right" valign="top" nowrap><b><?php 
        putGS("Number");
        ?>
:</b></td>
        			    <td align="left" valign="top"  style="padding-top: 2px; padding-left: 4px;"><?php 
        p($curPreview->getArticleNumber());
        ?>
 <?php 
        if (isset($publicationObj) && $publicationObj->getUrlTypeId() == 2) {
            ?>
        &nbsp;(<a href="/<?php 
            echo $languageObj->getCode() . "/" . $issueObj->getUrlName() . "/" . $sectionObj->getUrlName() . "/" . $curPreview->getUrlName();
            ?>
"><?php 
            putGS("Link to public page");
            ?>
</a>)<?php 
        }
        ?>
</td>
예제 #20
0
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();
}
$articleInfo['authors'] = $authorsNames;
$articleInfo['authorsLabel'] = $translator->trans('Authors', array(), 'articles');
echo $this->view->json($articleInfo);
예제 #21
0
    $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);
            $authorObj->create($authorData);
예제 #22
0
}

$articleObj = new Article($f_article_language, $f_article_number);
if (!$articleObj->exists()) {
	camp_html_display_error(getGS('Article does not exist.'));
	exit;
}

switch ($f_move) {
case 'up_rel':
	$articleObj->positionRelative('up', 1);
	break;
case 'down_rel':
	$articleObj->positionRelative('down', 1);
	break;
case 'abs':
	$articleObj->positionAbsolute($f_position);
	break;
default: ;
}

$url = "/$ADMIN/articles/index.php"
		."?f_publication_id=".$articleObj->getPublicationId()
		."&f_issue_number=".$articleObj->getIssueNumber()
		."&f_section_number=".$articleObj->getSectionNumber()
		."&f_article_number=".$articleObj->getArticleNumber()
		."&f_language_selected=$f_language_selected"
		."&f_language_id=".$f_language_id;
camp_html_add_msg(getGS("Article order changed."), "ok");
camp_html_goto_page($url);
?>
    /**
     * 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
예제 #24
0
window.opener.location.reload();
</script>
<?php
	exit;
}

$f_language_selected = Input::Get('f_language_selected', 'int', 0);
$f_article_number = Input::Get('f_article_number', 'int', 0);
$articleObj = new Article($f_language_selected, $f_article_number);
if (!$articleObj->exists()) {
	camp_html_display_error(getGS("Article does not exist."), null, true);
	exit;
}

foreach ((array) $_POST['item'] as $attachmentId) {
    ArticleAttachment::AddFileToArticle((int) $attachmentId, $articleObj->getArticleNumber());
}
$logtext = getGS('$1 file/s attached to article', sizeof($_POST['item']));
Log::ArticleMessage($articleObj, $logtext, null, 38, TRUE);

?>
<script type="text/javascript">
try {
    parent.$.fancybox.reload = true;
    parent.$.fancybox.message = '<?php putGS('Files attached.'); ?>';
    parent.$.fancybox.close();
} catch (e) {}
</script>

<?php exit; ?>
예제 #25
0
 /**
  * Get article
  *
  * @param  int          $articleNo
  * @param  MetaLanguage $language
  * @return MetaArticle
  */
 private function _getArticle($articleNo, MetaLanguage $language)
 {
     if (empty($articleNo)) {
         return null;
     }
     $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache');
     $cacheKey = $cacheService->getCacheKey(array('getArticle', $articleNo, $language->number), 'article');
     if ($cacheService->contains($cacheKey)) {
         $metaArticle = $cacheService->fetch($cacheKey);
     } else {
         $articleObj = new Article($language->number, $articleNo);
         if (!$articleObj->exists() || !$this->m_preview && !$articleObj->isPublished()) {
             throw new InvalidArgumentException("Invalid article identifier in URL.", self::INVALID_ARTICLE);
         }
         $metaArticle = new MetaArticle($language->number, $articleObj->getArticleNumber());
         $cacheService->save($cacheKey, $metaArticle);
     }
     return $metaArticle;
 }
예제 #26
0
if (!$issueObj->exists()) {
    camp_html_display_error($translator->trans('Issue does not exist.'));
    exit;
}
$sectionObj = new Section($f_publication_id, $f_issue_number, $f_language_id, $f_section_number);
if (!$sectionObj->exists()) {
    camp_html_display_error($translator->trans('Section does not exist.'));
    exit;
}
$articleObj = new Article($f_article_language, $f_article_number);
if (!$articleObj->exists()) {
    camp_html_display_error($translator->trans('Article does not exist.'));
    exit;
}
switch ($f_move) {
    case 'up_rel':
        $articleObj->positionRelative('up', 1);
        break;
    case 'down_rel':
        $articleObj->positionRelative('down', 1);
        break;
    case 'abs':
        $articleObj->positionAbsolute($f_position);
        break;
    default:
}
$cacheService = \Zend_Registry::get('container')->getService('newscoop.cache');
$cacheService->clearNamespace('article');
$url = "/{$ADMIN}/articles/index.php" . "?f_publication_id=" . $articleObj->getPublicationId() . "&f_issue_number=" . $articleObj->getIssueNumber() . "&f_section_number=" . $articleObj->getSectionNumber() . "&f_article_number=" . $articleObj->getArticleNumber() . "&f_language_selected={$f_language_selected}" . "&f_language_id=" . $f_language_id;
camp_html_add_msg($translator->trans("Article order changed.", array(), 'articles'), "ok");
camp_html_goto_page($url);
예제 #27
0
 /**
  * Test if author is blog author
  *
  * @param Author $author
  * @param Article $blogInfo
  * @return bool
  */
 public function isBlogAuthor(\Author $author, \Article $blogInfo)
 {
     return in_array($author->getId(), array_map(function ($blogAuthor) {
         return $blogAuthor->getId();
     }, \ArticleAuthor::GetAuthorsByArticle($blogInfo->getArticleNumber(), $blogInfo->getLanguageId())));
 }
예제 #28
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);
예제 #29
0
 /**
  * Create a copy of the article, but make it a translation
  * of the current one.
  *
  * @param  int     $p_languageId
  * @param  int     $p_userId
  * @param  string  $p_name
  * @return Article
  */
 public function createTranslation($p_languageId, $p_userId, $p_name)
 {
     $translator = \Zend_Registry::get('container')->getService('translator');
     // Construct the duplicate article object.
     $articleCopy = new Article();
     $articleCopy->m_data['IdPublication'] = $this->m_data['IdPublication'];
     $articleCopy->m_data['NrIssue'] = $this->m_data['NrIssue'];
     $articleCopy->m_data['NrSection'] = $this->m_data['NrSection'];
     $articleCopy->m_data['IdLanguage'] = $p_languageId;
     $articleCopy->m_data['Number'] = $this->m_data['Number'];
     $values = array();
     // Copy some attributes
     $values['ShortName'] = $this->m_data['ShortName'];
     $values['Type'] = $this->m_data['Type'];
     $values['OnFrontPage'] = $this->m_data['OnFrontPage'];
     $values['OnSection'] = $this->m_data['OnFrontPage'];
     $values['Public'] = $this->m_data['Public'];
     $values['ArticleOrder'] = $this->m_data['ArticleOrder'];
     $values['comments_enabled'] = $this->m_data['comments_enabled'];
     $values['comments_locked'] = $this->m_data['comments_locked'];
     $values['rating_enabled'] = $this->m_data['rating_enabled'];
     // Change some attributes
     $values['Name'] = $p_name;
     $values['Published'] = 'N';
     $values['IsIndexed'] = 'N';
     $values['IdUser'] = $p_userId;
     // Create the record
     $success = $articleCopy->__create($values);
     if (!$success) {
         return false;
     }
     $articleCopy->setProperty('UploadDate', 'NOW()', true, true);
     $articleCopy->setProperty('LockUser', 'NULL', true, true);
     $articleCopy->setProperty('LockTime', 'NULL', true, true);
     // Insert an entry into the article type table.
     $articleCopyData = new ArticleData($articleCopy->m_data['Type'], $articleCopy->m_data['Number'], $articleCopy->m_data['IdLanguage']);
     $articleCopyData->create();
     $origArticleData = $this->getArticleData();
     $origArticleData->copyToExistingRecord($articleCopy->getArticleNumber(), $p_languageId);
     $logtext = $translator->trans('Article translated to $4 ($5)', array('$4' => $articleCopy->getTitle(), '$5' => $articleCopy->getLanguageName()), 'api');
     Log::ArticleMessage($this, $logtext, null, 31);
     // geo-map processing
     Geo_Map::OnCreateTranslation($this->m_data['Number'], $this->m_data['IdLanguage'], $p_languageId);
     return $articleCopy;
 }
예제 #30
0
 /**
  * Set article images
  *
  * @param Article $article
  * @param array $images
  * @return void
  */
 private function setArticleImages(\Article $article, $images)
 {
     if (empty($images)) {
         return;
     }
     $oldImages = \ArticleImage::GetImagesByArticleNumber($article->getArticleNumber());
     foreach ($oldImages as $image) {
         $image->delete();
     }
     foreach ($images as $basename => $caption) {
         $file = $this->config['image_path'] . "/{$basename}";
         $realpath = realpath($file);
         if (!$realpath) {
             continue;
         }
         $imagesize = getimagesize($realpath);
         $info = array('name' => $basename, 'type' => $imagesize['mime'], 'tmp_name' => $realpath, 'size' => filesize($realpath), 'error' => 0);
         $attributes = array('Photographer' => 'sda', 'Description' => $caption, 'Source' => 'newsfeed');
         try {
             $image = \Image::OnImageUpload($info, $attributes, null, null, true);
             \ArticleImage::AddImageToArticle($image->getImageId(), $article->getArticleNumber(), null);
         } catch (\Exception $e) {
             var_dump($e);
             exit;
         }
     }
 }