Skip to content

Commit

Permalink
Merge branch 'release/2013-09.02'
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlaefer committed Sep 20, 2013
2 parents 2d529f6 + d99b940 commit 6ccb720
Show file tree
Hide file tree
Showing 19 changed files with 156 additions and 144 deletions.
2 changes: 1 addition & 1 deletion app/Config/version.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?php
Configure::write('Saito.v', '2013-09.01');
Configure::write('Saito.v', '2013-09.02');
14 changes: 9 additions & 5 deletions app/Controller/Component/ShoutsComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ public function startup(Controller $controller) {
public function setShoutsForView() {
$this->_controller->loadModel('Shout');
$shouts = $this->_controller->Shout->get();
$cached_shouts = Cache::read('Shouts.html');
if ($cached_shouts && $shouts[0]['Shout']['id'] === $cached_shouts['lastId']) {
$this->_controller->set('shouts', $cached_shouts['html']);
if (empty($shouts)) {
$this->_controller->set('shouts', null);
} else {
$this->_controller->initBbcode();
$this->_controller->set('shouts', $shouts);
$cached_shouts = Cache::read('Shouts.html');
if ($cached_shouts && $shouts[0]['Shout']['id'] === $cached_shouts['lastId']) {
$this->_controller->set('shouts', $cached_shouts['html']);
} else {
$this->_controller->initBbcode();
$this->_controller->set('shouts', $shouts);
}
}
}

Expand Down
44 changes: 24 additions & 20 deletions app/Controller/EntriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,24 +300,24 @@ public function add($id = null) {

// show add form
} else {
// answering is always a ajax request, prevents add/1234 GET-requests
if (!$this->request->is('ajax') && $id !== null) {
$this->Session->setFlash(__('js-required'), 'flash/error');
$this->redirect($this->referer());
}

$is_answer = $id !== null;
$this->request->data = null;
if ($id !== null) {
$this->request->data = $this->Entry->get($id, true);
}

if (!empty($this->request->data)): // answer to existing posting
if ($is_answer) {
if ($this->request->is('ajax') === false) {
$this->Session->setFlash(__('js-required'), 'flash/error');
$this->redirect($this->referer());
return;
}

$this->request->data = $this->Entry->get($id, true);

if ($this->Entry->isAnsweringForbidden($this->request->data)) {
throw new ForbiddenException;
}

// create new subentry
unset($this->request->data['Entry']['id']);
$this->request->data['Entry']['pid'] = $id;
// we assume that an answers to a nsfw posting isn't nsfw itself
unset($this->request->data['Entry']['nsfw']);
Expand All @@ -343,19 +343,21 @@ public function add($id = null) {
$headerSubnavLeftTitle = __(
'back_to_posting_from_linkname',
$this->request->data['User']['username']
); else:
);

$this->set('form_title', __('answer_marking'));
} else {
// new posting which creates new thread
$this->request->data['Entry']['pid'] = 0;
$this->request->data['Entry']['tid'] = 0;

$headerSubnavLeftTitle = __('back_to_overview_linkname');
endif;

if ($this->request->is('ajax')):
$this->set('form_title', __('answer_marking'));
endif;
}
}

$this->set('is_answer', (int)$this->request->data['Entry']['pid'] !== 0);
$this->set('is_inline', (int)$this->request->data['Entry']['pid'] !== 0);
$this->set('form_id', $this->request->data['Entry']['pid']);
$this->set('headerSubnavLeftTitle', $headerSubnavLeftTitle);
$this->set('headerSubnavLeftUrl', '/entries/index');

Expand Down Expand Up @@ -447,6 +449,10 @@ public function edit($id = null) {
);
$this->set('notis', $notis);

$this->set('is_answer', (int)$this->request->data['Entry']['pid'] !== 0);
$this->set('is_inline', false);
$this->set('form_id', $this->request->data['Entry']['pid']);

// set headers
$this->set('headerSubnavLeftUrl', '/entries/index');
$this->set(
Expand Down Expand Up @@ -616,7 +622,7 @@ public function preview() {
if ($this->request->is('ajax') === false) {
throw new BadRequestException();
}
if ($this->request->is('put') === false) {
if ($this->request->is('get')) {
throw new MethodNotAllowedException();
}

Expand All @@ -639,9 +645,7 @@ public function preview() {
$this->Entry->prepare($newEntry);
$this->Entry->set($newEntry);

$this->Entry->validates(
array('fieldList' => array('subject', 'text', 'category'))
);
$this->Entry->validates(['fieldList' => ['subject', 'text', 'category']]);
$errors = $this->Entry->validationErrors;

if (count($errors) === 0) :
Expand Down
8 changes: 4 additions & 4 deletions app/Test/Selenium/InlineAnswerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class InlineAnswerTest extends SaitoSeleniumTestCase {

public $nextId = 10;
public $nextId = 11;

public function testInlineAnswer() {
$this->login();
Expand Down Expand Up @@ -40,7 +40,7 @@ protected function _testInlineAnswerCloseButton($id) {
for ($second = 0; ; $second++) {
if ($second >= 60) $this->fail("timeout");
try {
if (!$this->isElementPresent("css=.js-thread_line[data-id={$id}] #entry_reply")) break;
if (!$this->isElementPresent("css=.js-thread_line[data-id={$id}] .entry.reply")) break;
} catch (Exception $e) {}
sleep(1);
}
Expand Down Expand Up @@ -75,7 +75,7 @@ protected function _createNewInlineAnswer($parentId) {
$this->fail("timeout");
}
try {
if ($this->isVisible("css=.js-thread_line[data-id={$parentId}] #entry_reply")
if ($this->isVisible("css=.js-thread_line[data-id={$parentId}] .entry.reply")
) {
break;
}
Expand Down Expand Up @@ -136,7 +136,7 @@ protected function _waitForThreadlineVisible($id) {
}

protected function _waitForAnsweringVisible($id) {
$this->waitForVisibleJq(".js-thread_line[data-id={$id}] #entry_reply");
$this->waitForVisibleJq(".js-thread_line[data-id={$id}] .entry.reply");
}

protected function _isThreadlineVisible($id) {
Expand Down
2 changes: 1 addition & 1 deletion app/Test/Selenium/Lib/SaitoSeleniumTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public function openAnswerForm() {
$this->_testCase->fail("timeout");
}
try {
if ($this->_testCase->isElementPresent("entry_reply")) {
if ($this->_testCase->isElementPresent("css=.entry.reply")) {
break;
}
} catch (Exception $e) {
Expand Down
2 changes: 1 addition & 1 deletion app/Test/Selenium/mixViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function tes1MixView() {
$this->waitForPageToLoad("30000");

// test if mix view is opened
$this->assertTrue($this->isElementPresent("entry_mix"));
$this->assertTrue($this->isElementPresent("css=.entry.mix"));
// test if back button is present
$this->assertTrue($this->isElementPresent("//div[@class='btn-strip-back']"));

Expand Down
115 changes: 30 additions & 85 deletions app/View/Entries/add.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,8 @@
array('class' => 'textlink', 'escape' => false)
);
$this->end();

// new entries have no id (i.e. no reply an no edit), so wie set a filler var
if (!isset($this->request->data['Entry']['id'])) {
$this->request->data['Entry']['id'] = 'foo';
}

// cite entry text if necessary
if ($this->getVar('citeText')) {
$citeText = $this->Bbcode->citeText($this->getVar('citeText'));
}

$posting_type = ($this->request->is('ajax')) ? 'reply' : 'add';
?>
<div id="entry_<?= $posting_type ?>" class="entry <?= $posting_type ?>">

<div class="entry <?= ($is_answer) ? 'reply' : 'add' ?> <?= ($is_inline) ? '' : 'add-not-inline' ?>">
<div class="preview">
<div class="l-box-header box-header">
<div>
Expand Down Expand Up @@ -83,21 +70,22 @@
'Saito.Settings.subject_maxlength'
),
'label' => false,
'class' => 'inp-subject',
'tabindex' => 2,
'error' => [
'notEmpty' => __('error_subject_empty'),
'maxLength' => __('error_subject_max_length')
],
'div' => ['class' => 'required'],
'placeholder' => (!empty($citeSubject)) ? $citeSubject : __('Subject'),
'required' => ($posting_type === 'reply') ? false : "required"
'required' => ($is_answer) ? false : "required"
]
);
?>
<?= $this->Form->hidden('pid'); ?>
<?php
echo $this->MarkitupEditor->getButtonSet(
'markItUp_' . $this->request->data['Entry']['id']
'markItUp_' . $form_id
);
echo $this->MarkitupEditor->editor(
'text',
Expand All @@ -111,78 +99,35 @@
]
);
?>
<?php
// add original posting contents
if (isset($citeText) && !empty($citeText)) : ?>
<div
id="<?php echo "btn_insert_original_text_{$this->request->data['Entry']['id']}"; ?>">
<?php
echo $this->Html->scriptBlock(
"var quote_{$this->request->data['Entry']['id']} = " . json_encode(
$citeText
) . "; ",
['inline' => 'true']
);
// empty the textarea
echo $this->Html->scriptBlock(
"$('#markItUp_{$this->request->data['Entry']['id']} #EntryText').val('')",
['inline' => 'true']
);
echo $this->Html->link(
Configure::read('Saito.Settings.quote_symbol') . ' ' . __(
'Cite'
),
'#',
[
'onclick' => "$('#markItUp_{$this->request->data['Entry']['id']} #EntryText').val(quote_{$this->request->data['Entry']['id']} + '" . '\n\n' . "' + $('#markItUp_{$this->request->data['Entry']['id']} #EntryText').val());"
. "$('#btn_insert_original_text_{$this->request->data['Entry']['id']}').slideToggle();"
. "$('#markItUp_{$this->request->data['Entry']['id']} #EntryText').focus();"
. "return false;",
'class' => 'label'
]
);
?>
</div>
<br/>
<?php endif; //add original posting contents ?>
<?php if (empty($citeText) === false) : ?>
<div class="cite-container">
<?=
$this->Html->link(
Configure::read('Saito.Settings.quote_symbol')
. ' ' . __('Cite'),
'#',
[
'data-text' => $this->Bbcode->citeText($citeText),
'class' => 'btn-cite label'
]
);
?>
<br/><br/>
</div>
<?php endif; ?>

<div class="bp-threeColumn">
<div class="left">
<?php
# @bogus
if (!$this->request->is(
'ajax'
) || (isset($lastAction) && ($lastAction === 'mix' || $lastAction === 'view' || $lastAction === 'add'))
) {
echo $this->Form->submit(
__('submit_button'),
[
'id' => 'btn-submit',
'class' => 'btn btn-submit',
'tabindex' => 4,
'onclick' => "
if (typeof this.validity === 'object') {
if (this.form.checkValidity()) {
this.disabled = true;
}
} else {
this.disabled = true;
}
this.form.submit();
"
]
);
} # !i$this->request->is('ajax')
else {
echo $this->Form->submit(
__('submit_button'),
[
'id' => 'btn-submit',
'class' => 'btn btn-submit js-inlined',
'tabindex' => 4
]
);
}
<?=
$this->Form->button(
__('submit_button'),
[
'id' => 'btn-submit',
'class' => 'btn btn-submit',
'tabindex' => 4,
'type' => 'button'
]
);
?>
&nbsp;
<?=
Expand Down
2 changes: 1 addition & 1 deletion app/View/Entries/index.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
endif;
$this->end();
?>
<div id="entry_index" class="entry index">
<div class="entry index">
<?= $this->element(
'entry/thread_cached_init',
['entries_sub' => $entries, 'level' => 0]
Expand Down
6 changes: 3 additions & 3 deletions app/View/Entries/json/preview.ctp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
$out =
array(
[
'html' => $this->element(
'/entry/view_content',
array('entry' => $entry, 'level' => 0)
['entry' => $entry, 'level' => 0]
)
);
];
$out += $this->JsData->getAppJsMessages();
echo json_encode($out);
4 changes: 2 additions & 2 deletions app/View/Entries/json/thread_line.ctp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
$out = array(
$out = [
'id' => $entry_sub['Entry']['id'],
'html' => $this->EntryH->threadCached($entry_sub, $CurrentUser, $level)
);
];
echo json_encode($out);
2 changes: 1 addition & 1 deletion app/View/Entries/mix.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
$this->end();
?>

<div id="entry_mix" class="entry mix" style="position:relative;">
<div class="entry mix" style="position:relative;">
<?php
echo $this->Html->link(
'<div class="btn-strip btn-strip-back">&nbsp;</div>',
Expand Down
2 changes: 1 addition & 1 deletion app/View/Entries/search.ctp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div id="entry_search">
<div class="entry search">
<div class="search_form_wrapper" style="<?php
if ( isset($this->request->params['data']['Entry']['adv']) ) {
echo "display:none;";
Expand Down
2 changes: 1 addition & 1 deletion app/View/Entries/view.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
);
}
?>
<div id="entry_view" class="entry view">
<div class="entry view">
<div class="box-content">
<?=
$this->element(
Expand Down
2 changes: 1 addition & 1 deletion app/View/Themed/Default/webroot/css/src/base/_search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

// entry_search
// -------------------------------------
#entry_search {
.entry.search {
.search_form_wrapper {
display: table;
width: 100%;
Expand Down
Loading

0 comments on commit 6ccb720

Please sign in to comment.