Aikimarkup

From Aikiframework wiki

Jump to: navigation, search


We are discussing future aikimarkup possibilities right now on the Aiki Developers list. The spec is here: https://blueprints.launchpad.net/aikiframework/+spec/fix-aikimarkup Please join us! https://launchpad.net/~aikiframework-devel

Contents

This page is to describe the current aikimarkup, please feel free to add your suggestions as it still in active development

aiki framework have many kinds of markups, all of them can be mixed together and used inside other output markups like html/xhtml/xml ....

Widget setup markup

create form for inserting new record by form number

  • (#(form:add:_form_number_)#)

create form for inserting new record by unique form name

  • (#(form:add:_unique_form_name_)#)

handle form as ajax

will send and handle the post as json data via ajax request

  • (#(form:add:_form_number_:ajax)#)

create form for editing a record

  • (#(form:edit:_form_number_:_record_number_)#)

Add custom HTTP header

  • (#(header:cache-control: no-cache)#)

get info from the url

noloop()noloop and noloop_bottom()noloop_bottom

  • used if you want a part of the current widget to be out of the loop created by sql statement. the content of noloop will be displayed once. before the loop begin
    • (noloop(_some_html_)noloop)
  • Similar to noloop()noloop, but the content will be displayed once. after the loop end
    • (noloop_bottom(_some_html_)noloop_bottom)

Display widget content inline

  • (#(widget:97)#)
  • (#(inherit:97)#)
  • Gets the content from the specified widget and runs the new sql statment over it, even if the widget itself contains a different query
    • (#(inherit:97|SQL NEW SELECT STATMENT)#)

hits

  • This appears to be openclipart specific aiki function to get number of hits to a file availabe and display it. Needs to be investigated
    • (#(hits:ocal_files|id=((id))|file_num_download)#)
+This section is incomplete. You can help by expanding it.

group_by

  • in link example you can specify the pages groups by using:
    • config[group_by:10] after the link i.e: widgets?page=[page] config[group_by:10]
+This section is incomplete. You can help by expanding it.

display content of external file

display content of external file inside the widget (can display php source files)

 (#(inline:[root]/weather.php?city=(!(1)!))#)

run inline sql

SYNTAX
 (sql(
    [ (SELECT statement || html_with_fields ) (IF_NO_RESULTS || html_when_no_results ) ]
 )sql) 


EXAMPLE
(sql(

  (SELECT * FROM aiki_users||<li>[-[username]-]</li>)    

)sql)
(sql(

  (SELECT * FROM aiki_users WHERE username=(!(2)!) ||<li>[-[username]-]</li>)    
  (IF_NO_RESULTS|| No user found )

)sql)


(sql(

  (SELECT foo FROM bar || some-data-here)    
  (SELECT bar FROM bar || more-data-here)
  (IF_NO_RESULTS|| no bar data)
)sql)


Values from that query is written always as [-[field name]-]

permissions

  • (#(permissions:Permissions group||html output)#) in widget permission

eg.:

(#(permissions:SystemGOD||<a href="[root]/admin">Admin</a>)#)

will show link to admin only if user is SystemGOD (administrator)

AJAX markup

Generic Usage

On page "test" load the widget "source" inside widget "target"

Either target widget id or widget name can be used in the rel

<a href="[root]/test" rel="source" rev="#target">

(ajax_a()ajax_a)

There is also some markup for ajax used in the admin interface.

(ajax_a(SEMICOLON_SEPARATED_STRING)ajax_a)
(ajax_a(structur_button; ['[root]/index.php?widget=structur_accordion','#ui-layout-west', 'structur_accordion()'])ajax_a)
(ajax_a(system_button;['[root]/index.php?widget=system_accordion','#ui-layout-west', 'system_accordion()'])ajax_a)

RSS and XML markup

Display rss feed | doing rss the rss way ;)

<rss>
  <url>http://planet.openclipart.org/news/rss20.xml</url>
  <limit>3</limit>
  <output>
    <div class='news'>
      <h4>[[title]]</h4>
      <p>[[pubDate]]</p>
      <a href='[[link]]'>[[guid]]</a>
      <div>[[description]]</div>
    </div>
   //can use [[link:href]] to get href attribute from link
   //or [[author->name]] to get child data
  </output>
<type>rss</type> //is the default and can be atom
</rss>

For ATOM feeds:

//can use link:href to get href attribute from link
//or [[author->name]] to get child data
// here's how you can parse a date:

<php $aiki->web2date->parseweb2date( pubDate ); php>
<rss>
  <url>http://feeds.launchpad.net/openclipart/latest-bugs.atom</url>
  <limit>7</limit>
  <output>
    <div class='news'>
      <h4><a href='[[link:href]]'>[[title]]</a></h4>
      <p>[[published]]</p>
      <div><a href='[[author->uri]]'>[[author->name]]</a></div>
    </div>
  </output>
<type>atom</type>
</rss>

Database markup

Create edit in place for one db field

<edit>
  <table>news</table>
  <field>upload_tags</field>
  <primary>id</primary>
  <type>textarea</type>
  <label>Click here to edit</label>
  <permissions>SystemGOD</permissions>
  <user>user_name</user>
  <output>(#(tags:upload_tags||tags/_self)#)</output>
</edit>

<edit>
  <table>ocal_files</table>
  <field>upload_published</field>
  <primary>id</primary>
  <type>select:Active>1&Hidden>0</type>
  <output>  </output>
  <permissions>librarian</permissions>
  <user>user_name</user>
</edit>

Aiki will get the value of 'id' field from you select query

((variable_name))

  • display the field title if returned by the current sql statement
    • ((title))
  • display the field "featuring" from the serialized array stored in db field "upload_extra" if exists
    • ((upload_extra[featuring]))
  • will display "Title is: _value of title_" only if title is returned by the db query, this is more useful when used in image html for example: ((if||filename||<img src="images/thumb-_self" align="left" hspace="12" vspace="0">)) so the whole img tag will only show if there is a filename
    • ((if||title||Title is: _self))

utility functions

  • apply nl2br function to the text. can be used with (( )) to display fields [br[((bodytext))]br]
    • [br[html or db field]br]
  • convert new lines to paragraphs. can be used with (( )) to display fields [p[((bodytext))]p]
    • [p[html or db field]p]
  • display date where publish_date is a database field that store unix time stamp
    • (#(datetime:publish_date)#)
  • Get similar related keywords and output some html that can be formatted as a cloud of similar topics (in parser.php
    • (#(related:some||keywords||here)#)

Data display markup

Display a link

  • display http://www.google.com link
  • (+(http://www.google.com)+)
  • (+(google=http://www.google.com)+) display the word google and link it to http://www.google.com

Disable aiki parsing on a block

  • <noaiki>disable aiki markup for this data</noaiki>

Get POST variable

  • POST[something]

Get GET variable

  • GET[something]: inserts the 'value' of the query 'something' from the current URL: e.g. mysite/page/?something=value

Translate a word

  • __term__ display term from aiki_dictionary for usage on multi language sites

Generate a tag cloud

  • Generate a tag cloud from tags stored about widget
    • (#(tags: some, tags, go, here)#)

Display a saved image including link

  • Display some stored image in the aiki photo_archive database
    • {+{SOME_STORED_IMAGE_NAME|alternative text|float|vspace attribute|hspace attribute|path prefix|description}+}
  • example:
    • {+{sexysurfer.png|surfer|left|v:|h:|90px/svg_to_png|Some Sexy Serfer}+}

Script functions

Aiki has a embed script language that can do certain transformation or functions.

It's called by markup

(script( .. )script)


NOTE': before revison 942 (script( is named as <php. This markup is maintained for backward compatibly, but use (script(

NOTE: These are parsed PHP functions, and not pure PHP functions, so they would work even if the aiki core is the ruby or C++ version. The full PHP language is not supported, and only a subset.

str_replace

Replace (search, replace, subject) search and replace substring.

(script(str_replace(a,b,$var); )script)
<img alt="#" src="[root]/image/90px/svg_to_png/(script( str_replace(.svg,.png,((filename))); )script)"/>

substr

substr (string,index [,length]).

(script( substr($string,$index,$length); )script)

conditionals

  • if cond then expresion1 [else expresion2]

if "cond" is true ( not cero and not whitespace ), expresion1 is return. Else, if existe, expresion2. In cond, those operators can be used: <,>, >=, <=, <>, = or == , in, not in. Also references to PHP superglobal arrays ( $_REQUEST, $_GET, $_SESSION, $_COOKIE, $POST). </nowiki>.

Examples:

(script( if (!(0)!)==news then class='active' )script)
(script( if ((extension)) in jpg,gif,svg then good else bad )script)
(script( if ((uploads)) > 100 then Very popular )script)
(script( if ((upload_extra[featuring])) then ((upload_extra[featuring])) )script)
(script( if ( $_GET['search'] )) then Searching )script)
(script( if ( $_COOKIE['iwasthere'] )) then Hi, nice to see you again )script)

Global Aiki Object

The global $aiki object is used for calling some special functions and for calling up extensions.

(script( $aiki->web2date->parseweb2date( ((upload_date)) ); )script)

odd

  • odd. print the literal odd or even, alternatively.

use: (script( odd(); )script) Example:

<tr class='(script( odd(); )script)'>

mod

  • mod (module) print the module (rest of division) of the internal counter. The result is a sequence of number like

0 1 2 ... n-1 0 1 2 .. n-1 (where n is the parameter you give) Example:

<img class='row-(script( mod(3); )script)' >
with this css your obtain a 'table' of images.
img { float: left}
img.row-0 { clear: left }

counters

  • counter( idCounter). Print the internal counter whose id is given, and increment it. By default, if the counter don't exist, is assumes 0 as initial value, and 1 as increment.
<div class='search-result>(script( counter(search); )script) ... 
  • setcounter ( idCounter, initValue, increment)

Set the counter with the init value and increment given. Increment can be negative.

setcounter(countdown,10,-1)
<div>(script( counter(author); )script)...print the counter of author 
      (script( setcounter(images,1,1); )script) reset the counter of author's images
       (script( counter(images); )script)<img src..>   

wiki markup

Parse

  • (script( $aiki->wiki->parse( ((text)) ); )script)

This is a list of current status of MediaWiki compatibility

Section Headings

   ==Section==
   ===Section===
   ====Section====
   =====Section=====
   ======Section======

Tables

{|
	|-
		| Reco
		| Reco 2
	|-
		| Reco 3
		| Reco 4
|}


{| class="wikitable" border="1" dir="ltr"
	|-
		| Reco
		| Reco 2
	|-
		| Reco 3
		| Reco 4
|}

Bold text

'''Bold text'''

Italicized Text

''Italic text''

View markup

Abstract

In widget html we can use this markup to filter content by view or language.

Sintaxis

(view( conditions :
....
)view)

Examples

(view( dark_night:
...this code would only appears in dark view.
)view)

(view( */pl:
...this code would only appears in german (any theme)
)view)

(view( bluemarine dark_night:
...this code would only appears in bluemarine or dark theme
)view)

You can nested "(view(" block.

Restrictions

View is one of the first parser, so you can't use other parser in conditions

(view( <php strlen... php>: WILL NOT WORK ... )view)

CSS parser

Abstract

This markup must be used in widget_css You can insert in plain css:

  • variables: predefined or custom.
  • expression:
  • Conditional block

Insert variables

With a php similar sintaxis, you can insert some predefined variables in css (field widget_css) like

a.search_buttton { background-image: url(images/$language/search.png); }
body { background-image: url(images/$view/body.png) ;...)

There are three predefined variables: $site, $view and $language. No echo or markup is required. Only $ and variable name.

Create own variables

You can create your own variables using a declarations block;

(declarations(
$w = 500  /* coment is allowed using css style)
$col_w = ($w/2)
$title_color= #red;
$basefont= 12
$linefont = ($basefont*1.2) /* expression must be surrounde by () */
)declarations)

(declarations( tablet:
$w= 400
)declarations)

Expressions

You can insert expressions in css, always delimited by ():

div.col {
width: ($width/3) }

A css for each view / language

You can filter css block by view/language (language is optional):

(css( bluemarine:
body { background-color: bluemarine)
)css)

(css( */arabic
body { text-direction:...
)css)

You can make this combination

(css( bluemarine dark :... )css)  ->one or more condition. Only one must match (or)
(css( */en :          all view in english
(css( */!ru )css)     all excepts russion

You can nested "(css(" block and include declarations blocks.;

(css(tablet:

(declarations( *:
$width:600
)declartions)

(css(bluemarine:   ..)css)
(css(dark: ..)css))


in few words

  • Operators allowed: + - * / \ (integer division)  % (module), parentesis (),
  • Variables: begin with $, then one letter or underscore then more letters, underscore or numbers.
  • declarations blocks contains:
    • one declaration (var = something) by line. Not ending ";"
    • not nested
    • can be conditional as css
  • css conditional:
    • can be nested
    • can contain declarations block, o text block.

See Related Pages

Personal tools