# Forums | Mahara Community

## Developers / Strings in mahara

Posts: 112

25 January 2010, 5:22 PM

Hello all,

I could use some help from the developers who created mahara on this issue. The strings in the lang file show up in text form. Is there a way to add images instead of text? We have added social links to the users profile. So, if they have profiles on myspace, facebook, etc... they can add a link to their profile. Everything went as planned except the ability to add the social networking icon. Our links look like this:

By adding the icons our links should look like this:

Any Help is appreciated. Thanks

Posts: 808
##### Re: Strings in mahara

26 January 2010, 12:31 AM

Hi Allen,

Are you trying to add <img> tags into the strings and finding that they get html-escaped?  You'll notice in the templates that some variables get run through the 'escape' function, which escapes all html, for example:

 <h4>{$title|escape}</h4> That is what we usually do when we expect a variable to contain text only. If we expecting the variable to contain html, then we will use the clean_html function instead, e.g.:  <div>{$blog->description|clean_html}</div>

So you might want to edit the template to change the 'escape' to 'clean_html'.  If the variable containing the string is not being run through escape inside the template, you might also find that that it's escaped directly in the php code, using the 'hsc' function.  You could use clean_html there too if you need to.

Alternatively you could keep a list of the image urls in another variable, add the img tags to the template and put the right thing into the src attribute.

Posts: 112
##### Re: Strings in mahara

26 January 2010, 9:10 AM

Richard,

That's what I was missing. I knew there was something that I was missing but, couldn't put my figure on it. Thanks for your help.

Posts: 112
##### Re: Strings in mahara

26 January 2010, 5:56 PM

Hello Richard,

I am confused at this point. I read your post but, maybe I missed something. I changed the appropiate code but, I get the following issues.

When you view a profile the icons show up and everything is the way it's suppose to look.

However when a person edits their profile they are getting <img ......................... where the icon is suppose to be. I thought that the strings were controlled by the same coding?

I have looked through the lib.php, index.php to find any code using the escape function. (looked in artefact/internal/ directory) Below is the code that I came up with by looking at the index.php to allow users to add the social links. I also added other coding in the lib.php for the url to work right. I don't think that the code I added in the lib.php file as anything to do with the strings.

'social' => array(
'type' => 'fieldset',
'legend' => get_string('social', 'artefact.internal'),
'class' => $fieldset != 'social' ? 'collapsed' : '', 'elements' => get_desired_fields($items, array('bebo', 'blogger', 'brightkite', 'delicious', 'designfloat', 'designmoo', 'devianart', 'digg', 'dopplr', 'facebook', 'flickr', 'twitter'), 'social'),
),

At this point I would be happy to add other text strings for when the person edits the links. I must be missing something that would cause an issue like this.

Posts: 808
##### Re: Strings in mahara

26 January 2010, 7:01 PM

Yeah, I agree that's tricky, because on the edit profile page the html is created by the pieform function, and the form label strings are escaped in there by default.  But if you delve around in there a bit (pieform.php, inside the build_element_html function), you can see that this behaviour is controlled by the 'labelescaped'  item in the pieform element array, so you can set labelescaped to true on the form element array, for example, change this:

    $items[$element] = array(        'type'  => $type, 'title' => get_string($element, 'artefact.internal'),    );

to this:

    $items[$element] = array(        'type'  => $type, 'labelescaped' => true, 'title' => get_string($element, 'artefact.internal'),    );

in artefact/internal/index.php.

Posts: 112
##### Re: Strings in mahara

26 January 2010, 11:41 PM

At least I know I am not going crazy here. That didn't work or at least for now it doesn't. At this point I am going to take a break until tomorrow. Then I will take another crack at it. It's almost there and I can't give up yet.

Here is another idea of mine. On the Edit profile form is it possible to call another string for this?  Having text there would be better than the icons. Our main concern was to have the icon show up on the profile itself not really the edit part.

Thanks for your help and knowledge.

Posts: 112
##### Re: Strings in mahara

27 January 2010, 8:56 AM

Hello Richard,

Just a question here. When the icon and link shows on their profile they have bullets and : after the icon. This is written in the content.tpl with the following code:

{if $profileinfo && (count($profileinfo) != 1 || !$profileinfo.introduction)}<ul> {foreach from=$profileinfo key=key item=item}
{if !in_array($key, array('introduction'))} <li><strong>{str tag=$key section=artefact.internal}</strong> {\$item}</li>
{/if}
{/foreach}
</ul>{/if}

Is there a way to call certain items to be displayed like that and then have another code that has the following striped out?

<ul>

<li><strong></strong</li>

</ul>

If so, could you give me a vague idea of the coding.

Thanks in advanced for your help and support.

Posts: 112
##### Re: Strings in mahara

06 February 2010, 12:44 AM

Hey Richard,

I took a break from troubleshooting the html issues in the strings. When I went back to work I figured out what I was doing wrong. In the pieforms.php around line 1249 I removed the Pieform::hsc and replaced with clean_html and it worked like a charm. I think tis is what you were trying to tell me when my brain was fryed.lol

Posts: 112
##### Re: Strings in mahara

26 March 2010, 11:33 AM

Hi,

I am posting a new question to this topic so, I don't have to start a new one. Where are the strings kept for forms? We changed how the user logs in. Now they use their e-mail address instead of a username. However, I can't seem to find where I can place a new string to state e-mail instead of username.

If you change the usrname string to e-mail then in the admin user search section it displays e-mail for the username. I looked for alot of files but, couldn't determine what calls the strings. Any help is appreciated. Thanks

Posts: 808
##### Re: Strings in mahara

28 March 2010, 6:55 PM

Hi Allen,

They're spread around the place in all the language packs, and when you want to change or override all instances of a particular string there's really no easy alternative to searching through the language pack and finding them all. I tend to use commands like this:

 find . -name "*\.php" | grep "en\.utf8" | xargs grep Username

For something like "Username" this isn't too bad (~15 results), but more common strings will give you more problems.

The trouble is that you probably want to change 'username' to 'e-mail' in some places but not others.  If so, you can't do it at the langpack level.  You can either search through all the code for instances of the 'username' string key (which will give you heaps more results to look through and deal with) or just fix them one by one as you find them.

R.

11 results