Skip to content

Commit

Permalink
Merge pull request #1136 from ahilles107/translations_fixes
Browse files Browse the repository at this point in the history
translations fixes
  • Loading branch information
Paweł Mikołajczuk committed May 25, 2015
2 parents b670a03 + 8c71179 commit 58aaee5
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ $this->headLink()->appendStylesheet($this->baseUrl('/admin-style/image_managemen
$languageSelectedObj = new Language((int) camp_session_get('LoginLanguageId', 0));
$editorLanguage = !empty($_COOKIE['TOL_Language']) ? $_COOKIE['TOL_Language'] : $languageSelectedObj->getCode();

$loadAsRichtext[] = 'image_description_'.$image->getId();
$loadAsRichtext[] = 'image_description_'.$image->getId().'_tinymce';
?>
<textarea name="data[<?php echo $image->getId(); ?>][description]" id="image_description_<?php echo $image->getId(); ?>" rows="4" class="image-description" style="float:none; width:380px;"><?php echo $image->getDescription(); ?></textarea>
<textarea name="data[<?php echo $image->getId(); ?>][description]" id="image_description_<?php echo $image->getId(); ?>_tinymce" rows="4" class="image-description" style="float:none; width:380px;"><?php echo $image->getDescription(); ?></textarea>
<?php
} else {
?>
<input name="data[<?php echo $image->getId(); ?>][description]" id="image_description_<?php echo $image->getId(); ?>" class="image-place" value="<?php echo htmlspecialchars(strip_tags($image->getDescription())); ?>" style="float:none; width:380px;" maxlength="<?php echo $preferencesService->MediaCaptionLength; ?>"><br/>
<input name="data[<?php echo $image->getId(); ?>][description]" id="image_description_<?php echo $image->getId(); ?>" class="image-description" value="<?php echo htmlspecialchars(strip_tags($image->getDescription())); ?>" style="float:none; width:380px;" maxlength="<?php echo $preferencesService->MediaCaptionLength; ?>"><br/>
<?php
}
?>
Expand Down
27 changes: 25 additions & 2 deletions newscoop/classes/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,12 @@ public function copy($p_destPublicationId = 0, $p_destIssueNumber = 0,
}
$values['Name'] = $articleCopy->getUniqueName($copyMe->m_data['Name']);

// for internall relations in entity we need also to keep sectionId and issueId
$issueObj = new Issue($articleCopy->m_data['IdPublication'], $articleCopy->m_data['IdLanguage'], $articleCopy->m_data['NrIssue']);
$sectionObj = new Section($articleCopy->m_data['IdPublication'], $articleCopy->m_data['NrIssue'], $articleCopy->m_data['IdLanguage'], $articleCopy->m_data['NrSection']);
$values['issue_id'] = $issueObj->getIssueId();
$values['section_id'] = $sectionObj->getSectionId();

$articleCopy->__create($values);
$articleCopy->setProperty('UploadDate', 'NOW()', true, true);
$articleCopy->setProperty('LockUser', 'NULL', true, true);
Expand Down Expand Up @@ -657,6 +663,12 @@ public function createTranslation($p_languageId, $p_userId, $p_name)
$values['IsIndexed'] = 'N';
$values['IdUser'] = $p_userId;

// for internall relations in entity we need also to keep sectionId and issueId
$issueObj = new Issue($this->m_data['IdPublication'], $p_languageId, $this->m_data['NrIssue']);
$sectionObj = new Section($this->m_data['IdPublication'], $this->m_data['NrIssue'], $p_languageId, $this->m_data['NrSection']);
$values['issue_id'] = $issueObj->getIssueId();
$values['section_id'] = $sectionObj->getSectionId();

// Create the record
$success = $articleCopy->__create($values);
if (!$success) {
Expand Down Expand Up @@ -756,9 +768,20 @@ public function delete()
$this->m_data['IdLanguage']);
$articleData->delete();

// Delete webcode
$em = Zend_Registry::get('container')->getService('em');
$article = $em->getRepository('Newscoop\Entity\Article')
->find(array(
'number' => $this->getArticleNumber(),
'language' => $this->getLanguageId(),
));
$webcode = $article->getWebcodeEntity($article);

$em->remove($webcode);
$em->flush();
$em->detach($article);

$tmpObj = clone $this; // for log
$tmpData = $this->m_data;
$tmpData['languageName'] = $this->getLanguageName();
// Delete row from Articles table.
$deleted = parent::delete();

Expand Down
2 changes: 1 addition & 1 deletion newscoop/classes/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public static function ArticleMessage(Article $p_article, $p_text, $p_userId = N
echo $translator->trans('Action') . ': ', $p_text;

$message = ob_get_clean();
self::Message($message, $p_userId, $p_eventId);
self::Message(substr($message, 0, 254), $p_userId, $p_eventId);
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
UPDATE `Articles` AS a LEFT JOIN Issues AS i ON a.`NrIssue`= i.Number SET `issue_id`= i.id;
UPDATE `Articles` AS a LEFT JOIN Sections AS s ON a.`NrSection` = s.Number SET `section_id` = s.id;
14 changes: 14 additions & 0 deletions newscoop/library/Newscoop/Entity/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,20 @@ public function getWebcode()
return $this->webcode->getWebcode();
}

/**
* Get webcode object
*
* @return string
*/
public function getWebcodeEntity()
{
if (!$this->webcode) {
return null;
}

return $this->webcode;
}

/**
* Test if article has webcode
*
Expand Down

0 comments on commit 58aaee5

Please sign in to comment.