Skip to content

Commit

Permalink
Merge pull request #9800 from hypeJunction/merge_1.12_2.0
Browse files Browse the repository at this point in the history
Merge 1.12 2.0
  • Loading branch information
hypeJunction committed May 7, 2016
2 parents 544dd73 + c8cdeac commit 260a17a
Show file tree
Hide file tree
Showing 21 changed files with 45 additions and 52 deletions.
4 changes: 2 additions & 2 deletions docs/guides/i18n.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ To first test whether ``elgg_echo()`` can find a translation:
Javascript API
==============

``elgg.echo(key, args, language)``
``elgg.echo(key, args)``

This function is the exact counterpart to ``elgg_echo`` in PHP.
This function is like ``elgg_echo`` in PHP.

Client-side translations are loaded asynchronously. Ensure translations are available by requiring the "elgg" AMD module:

Expand Down
7 changes: 7 additions & 0 deletions engine/classes/ElggAutoP.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ protected function addParagraphs(DOMElement $el) {
$isElement = ($node->nodeType === XML_ELEMENT_NODE);
if ($isElement) {
$isBlock = in_array($node->nodeName, $this->_blocks);
if (!$isBlock) {
// if we start with an inline element we don't need to do this
$ltrimFirstTextNode = false;
}
} else {
$isBlock = false;
}
Expand All @@ -241,7 +245,9 @@ protected function addParagraphs(DOMElement $el) {

if ($isText) {
$nodeText = $node->nodeValue;

if ($ltrimFirstTextNode) {
// we're at the beginning of a sequence of text/inline elements
$nodeText = ltrim($nodeText);
$ltrimFirstTextNode = false;
}
Expand All @@ -250,6 +256,7 @@ protected function addParagraphs(DOMElement $el) {
$nodeText = substr($nodeText, strlen($m[0]));
}
if ($isLastInline) {
// we're at the end of a sequence of text/inline elements
$nodeText = rtrim($nodeText);
}
$nodeText = str_replace("\n", $this->_unique . 'NL', $nodeText);
Expand Down
6 changes: 5 additions & 1 deletion engine/lib/comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,12 @@ function _elgg_comments_notification_email_subject($hook, $type, $returnvalue, $
return;
}

if (empty($returnvalue['params']['notification'])) {
return;
}

/** @var Elgg\Notifications\Notification */
$notification = elgg_extract('notification', $returnvalue['params']);
$notification = $returnvalue['params']['notification'];

if ($notification instanceof Elgg\Notifications\Notification) {
$object = elgg_extract('object', $notification->params);
Expand Down
1 change: 1 addition & 0 deletions engine/lib/elgglib.php
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,7 @@ function _elgg_php_exception_handler($exception) {
} catch (Exception $e) {
$timestamp = time();
$message = $e->getMessage();
http_response_code(500);
echo "Fatal error in exception handler. Check log for Exception #$timestamp";
error_log("Exception #$timestamp : fatal error in exception handler : $message");
}
Expand Down
29 changes: 1 addition & 28 deletions engine/lib/output.php
Original file line number Diff line number Diff line change
Expand Up @@ -534,33 +534,6 @@ function _elgg_get_display_query($string) {
return htmlspecialchars($display_query, ENT_QUOTES, 'UTF-8', false);
}

/**
* Unit tests for Output
*
* @param string $hook unit_test
* @param string $type system
* @param mixed $value Array of tests
* @param mixed $params Params
*
* @return array
* @access private
*/
function _elgg_output_unit_test($hook, $type, $value, $params) {
global $CONFIG;
$value[] = "{$CONFIG->path}engine/tests/ElggCoreOutputAutoPTest.php";
return $value;
}

/**
* Initialize the output subsystem.
*
* @return void
* @access private
*/
function _elgg_output_init() {
elgg_register_plugin_hook_handler('unit_test', 'system', '_elgg_output_unit_test');
}

return function(\Elgg\EventsService $events, \Elgg\HooksRegistrationService $hooks) {
$events->registerHandler('init', 'system', '_elgg_output_init');

};
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php
/**
* Test case for \ElggAutoP functionality.
*/
class ElggCoreOutputAutoPTest extends \ElggCoreUnitTest {

class ElggAutoPTest extends \PHPUnit_Framework_TestCase {

/**
* @var \ElggAutoP
Expand All @@ -14,7 +12,7 @@ public function setUp() {
}

public function testDomRoundtrip() {
$d = dir(dirname(__FILE__) . '/test_files/output/autop');
$d = dir(__DIR__ . '/test_files/autop');
$in = file_get_contents($d->path . "/domdoc_in.html");
$exp = file_get_contents($d->path . "/domdoc_exp.html");
$exp = $this->flattenString($exp);
Expand All @@ -28,23 +26,22 @@ public function testDomRoundtrip() {
list($out) = explode('</body>', $out, 2);
$out = $this->flattenString($out);

$this->assertEqual($exp, $out, "DOMDocument's parsing/serialization roundtrip");
$this->assertEquals($exp, $out, "DOMDocument's parsing/serialization roundtrip");
}

public function testProcess() {
$data = $this->provider();
foreach ($data as $row) {
list($test, $in, $exp) = $row;
$exp = $this->flattenString($exp);
$out = $this->_autop->process($in);
$out = $this->flattenString($out);

$this->assertEqual($exp, $out, "Equality case {$test}");
}
/**
* @dataProvider provider
*/
public function testProcess($test, $in, $exp) {
$exp = $this->flattenString($exp);
$out = $this->_autop->process($in);
$out = $this->flattenString($out);

$this->assertEquals($exp, $out, "Equality case {$test}");
}

public function provider() {
$d = dir(dirname(__FILE__) . '/test_files/output/autop');
$d = dir(__DIR__ . '/test_files/autop');
$tests = array();
while (false !== ($entry = $d->read())) {
if (preg_match('/^([a-z\\-]+)\.in\.html$/i', $entry, $m)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p><b></b> test</p>

<p><b> test</b></p>
3 changes: 3 additions & 0 deletions engine/tests/phpunit/test_files/autop/begins-with-tag.in.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<b></b> test

<b> test</b>
13 changes: 9 additions & 4 deletions js/lib/languages.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,16 @@ elgg.get_language = function() {
/**
* Translates a string
*
* @param {String} key The string to translate
* @param {Array} argv vsprintf support
* @param {String} language The language to display it in
* @note The current system only loads a single language module per page, and it comes pre-merged with English
* translations. Hence, elgg.echo() can only return translations in the language returned by
* elgg.get_language(). Requests for other languages will fail unless a 3rd party plugin has manually
* used elgg.add_translation() to merge the language module ahead of time.
*
* @return {String} The translation
* @param {String} key Message key
* @param {Array} argv vsprintf() arguments
* @param {String} language Requested language. Not recommended (see above).
*
* @return {String} The translation or the given key if no translation available
*/
elgg.echo = function(key, argv, language) {
//elgg.echo('str', 'en')
Expand Down

0 comments on commit 260a17a

Please sign in to comment.