Dwoo doesn't support Smarty's nl2br syntax

Bug #1275481 reported by Gregor Anželj on 2014-02-02
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Medium
Gregor Anželj

Bug Description

Found out that Dwoo doesn't support Smarty's nl2br syntax.

Dwoo's nl2br syntax can be found here: https://github.com/emulienfou/dwoo/wiki/Functions:nl2br

Changed in mahara:
assignee: nobody → Gregor Anželj (gregor-anzelj)

Can you please provide an example of how to test this on the front end, Gregor?

Changed in mahara:
importance: Undecided → Medium
status: New → In Progress
Gregor Anželj (gregor-anzelj) wrote :

Tis is not quite easy and it has to be explained. I've created (well updated) "linkedinprofile" bolcktype to display LinkedIn basic or full profile or only contact information on Mahara webpage.

I've said that it is updated, since when I first created it, the LinkedIn didn't offer their API, so the plugin was basically a hack which connected to user's public profile, fetched the webpage and extracted the relevant part.

Now that LinkedIn offers developers to use their API, the plugin is "properly" coded so the user first has to authenticate againt LinkedIn API to allow access to their information, etc.

After that long introduction, let's get to the problem. In my LinkedIn profile I've entered fake address in three lines (see "nl2br-1.png"). When I want to display the address and other contact information on my Mahara page then the following happens. If I use the old markup in the template, e.g.: {$variable|nl2br} then everything is displayed in one line (see "nl2br-2,png"). If I use the new markup, e.g.: {nl2br($variable)} then the address is displayed in three lines as it should be (see "nl2br-3.png").

Below I'm attacing all three screenshots and the source code of the plugin (which wasn't released yet, but it is ready).

Installation instructions (to replicate the problem):
1. install the plugin in admin area
2. Set up the plugin (you'll have to create LinkedIn application in order to get API key and Secret key - then paste those keys into appropriate fields in the form)
3. Update your LinkedIn profile and enter address with more than one line
4. In Mahara create new page
5. Add LinkedIn profile block to that page
6. In LinkedIn profile block authenticate against LinkedIn API and allow access (you'll be redirected to mahara pages index)
7. Edit previously created page and edit LinkedIn block once more
8. Select "contact information" to display LinkedIn contact information

To test nl2br syntax, change it form new to old in the template file: htdocs/blocktype/linkedinprofile/theme/raw/contactinfo.tpl

PS:
* all three screenshots and plugin sourcecode are attached inside one zip file
* My environment: windows, xampp, php, mysql
* I've entered address in windows so maybe there are issues connected to different display of \r an \n characters in different OS-es (windows, linux, mac)?

HTH, Gregor

Reviewed: https://reviews.mahara.org/2975
Committed: http://gitorious.org/mahara/mahara/commit/d5b71b488a298aae2cd92fc0c6eefee4c877f31e
Submitter: Robert Lyon (<email address hidden>)
Branch: master

commit d5b71b488a298aae2cd92fc0c6eefee4c877f31e
Author: Gregor Anzelj <email address hidden>
Date: Sun Feb 2 17:08:53 2014 +0100

Dwoo doesn't support Smarty's nl2br syntax (Bug #1275481)

While programming other things I've needed to use nl2br function inside Dwoo template file. Then I've discovered that nl2br syntax has changed in Dwoo from what it was in Smarty.

Dwoo's nl2br syntax: https://github.com/emulienfou/dwoo/wiki/Functions:nl2br

Change-Id: I203ccf73a97a2b9eb25c0bab4de4aee1a43f8828
Signed-off-by: Gregor Anzelj <email address hidden>

Aaron Wells (u-aaronw) on 2014-02-25
Changed in mahara:
milestone: none → 1.9.0
status: In Progress → Fix Committed
tags: added: api dwoo
Robert Lyon (robertl-9) on 2014-04-22
Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Bug attachments