Enter fullscreen mode

Displaying MediaGlyphs

Some background information

The MediaGlyphic language is made of images and these are appropriately displayed in browsers or with customized display programs.
Every MG concept has a code assigned (made by a sequence of letters or numbers) and by this code the MG concept (glyphs or phonemes) is accessed, displayed, transmitted.
More information is available on the MG encoding scheme

From codes to images

Say we have or we've received a MG sentence, in its encoded form:
@baH@kQC@bbt

Those codes represent the following glyphs:
MG: I; me MG: think; intend; consider; ponder; cogitate; cerebrate MG: you MG: hear MG: I; me MG: speak; talk; say; express in words

Unless you are using a specific MG-plugin for your browser or a specific MG standalone program, the easiest way to display a MG sentence on any internet browser is to call a script from the MG website (or from your favourite MG mirror), specifying the encoded sentence like this:
http://www.mediaglyphs.org/mgs.php?mg=@baH@kQC@bbt
You can try how that works by copy&pasting that URL into your browser or simply by clicking here

In the same way you can display not only sentences but of course every component of the MG language like:

single glyphs
(http://mediaglyphs.org/mgs.php?mg=ee)

composites
(http://mediaglyphs.org/mgs.php?mg=^2kbt)

phonetic names
(http://mediaglyphs.org/mgs.php?mg===eng:James==)

and so on...

Integrating MediaGlyphs sentences inside your own web pages

There are several ways of showing glyphs on your own web pages. Let's review some of them, according to the kind of web page you are using: .html .shtml or .php

1) HTML Hyperlink

The simplest alternative, which will work in any situation, is to link to the php script (from any MG mirror) using an a href= html tag.
Simply add a hyperlink to the mgs.php script, specifying the desired MG codes:
Which will show up as:
Here is an example MG sentence: I'm eating pizza!
Main advantage of this method: it works remotely without problems
Main disadvantage of this method: it doesn't directly display the glyphs: only after clicking on the hyperlinked item the glyphs will be displayed

2) Frames over simple html

One simple way to integrate MG in plain html pages is to call the above mentioned script from an IFRAME (inline frame) tag, as in the following example:
which displays as:

Did you notice there is a bHTML=1 flag specified in the call to mgs.php script? That will prevent the script to add any HTML header or footer to the output, returning instead only the display of the MG sentence. This flag will be used in each of the following examples. (All the possible flags are detailed in a paragraph below).

The same result can be achieved with the tag <object>:


Main advantage of this method: it will work on any html from any computer
Main disadvantage of this method: proper size of the INLINE frame or OBJECT should better be specified, to achieve a good display. Also the tooltips can be partly hidden when their edges move out of the edges of the inline frame.

3) JavaScript <script> snippets

A way which is both simple, powerful and easy to customize: using JS code snippets inside your html page to retrive the html from a remote mgs.php script.
Note: for this to work, be sure to include the flag escaped=1 when calling mgs.php from a JS script.
Check the two following code examples, which detail two different ways of displaying MG with JS:
which will use document.write to print the MG sentence wherever the mgs.php script is called.
It displays as:
You need to insert the first snippet (first line in the above code) only once in your webpage, and you can then call the mgs.php (as in the second line of code above) as many times as desired, to display several MG sentences in the same webpage.
The third line (calling the tooltips code) needs to be inserted at the end of your webpage (or anyway after the MG lines to be displayed), and only if you want to have tooltips displayed over the glyphs.

Another way is to specify where the MG should be displayed using a div id tag, as in the following example:

which displays as:

Loading glyphs...

Main advantage of this method: it will work on any html from any computer. Additionally, it doesn't create inline frames, but outputs directly to the html page
Main disadvantage of this method: some users have JS turned off in their browser settings. In that case, obviously, no MG will be displayed.

4) "Virtual" over SSI .shtml

By using SSI (.shtml pages), integrating MG is very simple: just add a virtual include directive to your webpage, calling the mgs.php script, as in the following example code:

Main advantage of this method: it's clean and simple
Main disadvantage of this method: it will not work across different computers, so it's only useful for developers of pages to be placed on the MG website

5) PHP readfile()

If your webpage is a php script (or if you can execute php script snippets from your html), include a remote call to the mgs.php script from the MG mirror closer to you, as in the following example:

Main advantage of this method: it works remotely without problems
Main disadvantage of this method: it can only be used in php pages. Furthermore, the capability of readfile() to fetch remote documents depends on a php.ini flag (allow_url_fopen) which may be turned off in some installations
NOTE:: did you notice that among the MGcodes passed to the mg= field, there are the characters "%2B"? They represent the "+" character, in URL escape codes. This is because the "+" code cannot be directly used in a URL address, and has to be escaped.
This is the only precaution to remember when passing MG codes over the internet to a php script

6) AJAX call

By using a JS framework like prototype (and remember to include the call to prototype.js in your page!) and AJAX, as in the following example:
which would display as:
Loading glyphs...

Main disadvantage of this method: you need to install or code a /proxy on your website that can circumvent the cross-domain security issues and make the remote MG call appear as local to your system.

7) Glyph sentence as a single remotely loaded IMG

Instead of the full html display of MG, a simpler (and easier to implement) way is to insert an IMG html tag with SRC pointing to the mediaglyphs url of the mgs.php script, passing the image=1 flag. The glyph sentence specified will be rendered as a single IMG and passed with content type PNG:

which would appear as: example of image=1 flag

Options that can be passed to the mgs.php script:

bHTML=1
This flag, as mentioned above, prevents the script to return HTML headers and footers, showing instead only the MG sentence.

remote=1
This flag is important to tell the script to hardcode all hyperlinks so that they are marked with the full URL to MG's website. This allows the served pages to be included remotely.

popoutlinks=1
This flag is important when displaying MG under an IFRAME or OBJECT html tag (as explained above in point 1): without it, clicking on the glyphs will open the explanation page inside the small inline frame, which is awkward and counterintuitive. By setting the flag, clicking the links will open the explanation page in the current page, as expected.

escaped=1
This flag, as mentioned above, is necessary for JS/PHP integration: if passed, the php script will not return raw HTML, but instead return a call to a javascript function (insertMG) whose argument is the HTML for displaying the MG sentence. The display can then be customized using JS code.

tooltips=0
If this flag is unset, there will be no translation tooltips appearing when hovering the mouse over the glyphs.

nojs=1
If this flag is specified, the html will not return a call to the tooltip.js script, to avoid having redundant multiple calls. So if you want tooltips to appear, be sure to specify the js call somewhere in your document:

intrans=1
If this flag is set, a translation of each glyph (like the one in tooltips) will be printed inline next to each glyph/concept. (Example1) (Example2)

titles=1
Another alternative to tooltips is to use the standard HTML title attributes, placing there the translations of the glyphs/concepts. It is used in the examples of method 2) above.

noborder=1
If noborder=1 flag is set, the glyphs or MG concepts will not receive the morphology colouring. I.e. they will not have a distinctive border colour according to their morphology (black for nouns, yellow for adjectives, green for verbs...).
Please note that the border colours are specified as CLASS html tags and hence depend on a CSS style sheet. Include "http://mediaglyphs.org/css/mg.css" to make them work, or write your own CSS to display the border colours appropriately. E.g. add:

tooltips=0 & explflag=0
If both these flags are unset, there will be no hyperlinking of glyphs to their explanation pages. Also, the border colours will not be working (as they depend on a href html tags).

textflag=0 subflag=1
Passing these two flags to the mgs.php script will allow it to parse the subcomponents of a complex MG concept. This only works if a single MG concept is given, and it is relevant only for phrases, composites or reclarified. In those cases, the composites or phrases get analysed in their subcomponents, separating the glyphs/elements they are made of and linking each of them separately to their explanation page. For example try the following and see the difference of having the subcomponents separately linked:

(http://mediaglyphs.org/mgs.php?mg=^2kbt)


(http://mediaglyphs.org/mgs.php?mg=^2kbt&textflag=0&subflag=1)

addpron=1
to add pronunciation icons (Example)

sortable=1
to add "handles" for usage with scriptaculous sortables

codearray=1
instead of displaying, it will return a php array of codes for the images or text to display

image=1
instead of displaying html, it will generate a single png image and output it Example: example of image=1 flag

fav="eng"
to override the preferred language settings from your browser and instead specify a languagecode for the translation (in tooltips, inline translations, titles) (Example)
 
 
What is MG?
First appearance: Tue Sep 9 18:28:20 CST 2008 - | - Last modified: Fri Sep 28 16:26:54 CEST 2018
{MG: downMG: pull; draw; force}lower; pull down; take down; let down; get down; bring down