Example #1
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
Example #2
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;
 }