Skip to content

Commit

Permalink
change topics implementation in AES
Browse files Browse the repository at this point in the history
  • Loading branch information
takeit committed Dec 2, 2014
1 parent d052e3e commit e0a40a4
Show file tree
Hide file tree
Showing 16 changed files with 372 additions and 243 deletions.
17 changes: 10 additions & 7 deletions newscoop/admin-files/articles/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
// Whether to show comments at the bottom of the article
// (you may not want to show them to speed up your loading time)
// Selected language of the article
$f_language_selected = (int)camp_session_get('f_language_selected', 0);
$f_language_selected = (int) camp_session_get('f_language_selected', 0);

if (!Input::IsValid()) {
camp_html_display_error($translator->trans('Invalid input: $1', array('$1' => Input::GetErrorString())), $_SERVER['REQUEST_URI']);
Expand Down Expand Up @@ -67,7 +67,11 @@
$lockUserObj = new User($articleObj->getLockedByUser());
$articleCreator = new User($articleObj->getCreatorId());
$articleEvents = ArticlePublish::GetArticleEvents($f_article_number, $f_language_selected, TRUE);
$articleTopics = ArticleTopic::GetArticleTopics($f_article_number);
$em = \Zend_Registry::get('container')->getService('em');
$articleTopics = $em->getRepository("Newscoop\Entity\ArticleTopic")
->getArticleTopicsQuery($f_article_number)
->getResult();
//ArticleTopic::GetArticleTopics($f_article_number);
$articleFiles = ArticleAttachment::GetAttachmentsByArticleNumber($f_article_number, $f_language_selected);
$articleLanguages = $articleObj->getLanguages();

Expand Down Expand Up @@ -220,7 +224,7 @@ function parseTextBody($text, $articleNumber)

if (isset($imageMatches[1][0])) {
if (isset($titles) && sizeof($titles) > 0) {
for($x = 0; $x < sizeof($titles[0]); $x++) {
for ($x = 0; $x < sizeof($titles[0]); $x++) {
$text = preg_replace("/\s*".preg_replace('~\/~', '\/',
preg_quote($titles[0][$x]))."/", ' title="'.$titles[1][$x].'"', $text);
}
Expand Down Expand Up @@ -255,12 +259,13 @@ function parseTextBody($text, $articleNumber)
print ('<script type="text/javascript">window.location.reload();</script>');
}
}

return $text;
}

$hasMultiDates = false;
$multiDatesFields = array();
include_once('edit_html.php');
include_once 'edit_html.php';

// Display tinymce loading code if required
$hasArticleBodyField = FALSE;
Expand Down Expand Up @@ -307,6 +312,4 @@ function parseTextBody($text, $articleNumber)
}
}

include ("edit_javascript.php");

?>
include 'edit_javascript.php';
38 changes: 12 additions & 26 deletions newscoop/admin-files/articles/edit_topics_box.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class="input_text" value="<?php echo $articleObj->getKeywords(); ?>" onkeyup=""
</fieldset>
</form>
<script type="text/javascript">
$(document).ready(function() {
$('form#article-keywords').submit(function() {
$(document).ready(function () {
$('form#article-keywords').submit(function () {
if (!$(this).hasClass('changed')) {
return false;
}
Expand All @@ -26,13 +26,14 @@ class="input_text" value="<?php echo $articleObj->getKeywords(); ?>" onkeyup=""
callServer(['Article', 'setKeywords'], [
<?php echo $f_language_selected; ?>,
<?php echo $articleObj->getArticleNumber(); ?>,
keywords], function(json) {
keywords], function (json) {
flashMessage('<?php echo $translator->trans('Keywords saved.', array(), 'articles'); ?>');
});

$(this).removeClass('changed');

return false;
}).change(function() {
}).change(function () {
$(this).addClass('changed');
});
});
Expand All @@ -46,33 +47,18 @@ class="ui-icon ui-icon-pencil"></span><?php echo $translator->trans('Edit'); ?><
<?php } ?>
<label class="left-floated block-label"><?php echo $translator->trans('Topics'); ?></label>
<div class="clear"></div>
<?php if (sizeof($articleTopics) > 0) { ?>
<?php if (count($articleTopics) > 0) { ?>
<ul class="block-list">
<?php
$em = \Zend_Registry::get('container')->getService('em');
$repo = $em->getRepository("Newscoop\NewscoopBundle\Entity\Topic");
$language = $em->getReference("Newscoop\Entity\Language", $f_language_id);
foreach ($articleTopics as $tmpArticleTopic) {
$tmpArticleTopic = $tmpArticleTopic->getTopic();
$detachUrl = "/$ADMIN/articles/topics/do_del.php?f_article_number=$f_article_number&f_topic_id=".$tmpArticleTopic->getTopicId()."&f_language_selected=$f_language_selected&f_language_id=$f_language_id&".SecurityToken::URLParameter();
$path = $tmpArticleTopic->getPath();
$pathStr = '';
foreach ($path as $element) {
$name = $element->getName($f_language_selected);
if (empty($name)) {
// For backwards compatibility -
// get the english translation if the translation
// doesnt exist for the article's language.
$name = $element->getName(1);
if (empty($name)) {
$name = '-----';
}
}
$pathStr .= ' / '. htmlspecialchars($name);
}

$pathStr = $repo->getReadablePath($tmpArticleTopic, $language->getCode());
// Get the topic name for the 'detach topic' dialog box, below.
$tmpTopicName = $tmpArticleTopic->getName($f_language_selected);
// For backwards compatibility.
if (empty($tmpTopicName)) {
$tmpTopicName = $tmpArticleTopic->getName(1);
}
$tmpTopicName = $tmpArticleTopic->getName();
?>
<li><?php p(wordwrap($pathStr, 45, '<br />&nbsp;&nbsp;')); ?>
<?php if ($inEditMode && $g_user->hasPermission('AttachTopicToArticle')) { ?>
Expand Down
Loading

0 comments on commit e0a40a4

Please sign in to comment.