Documentation

FLAscheme for custom CMS


Contents


Yahoo! I suppose you want to integrate FLAscheme in your favorite CMS. So:

Step 1: Download the demo distributive

http://flascheme.com/app/d/WebServersFS.rar (just for Windows – if you work in Mac or Linux, please, e-mail me)


Unrar it, and run start.bat. The Denwer will run Apache with PHP for you, and you will visit http://localhost/flascheme/ Choose index_editor.php
For stop, run stop.bat.

Step 2: Explanations

FLAscheme consist of several main parts (they can be found in home/localhost/www/flascheme):


1. FlaScheme.swf – main swf file, that contains editor, images etc. You will not change it.
2. index_editor.php – an example of embedding FlaScheme in webpage. It just embed this SWF file with several parameters (license, page_id and some other – they will be described below).
3. server/get.php – return XML data about current scheme (in this example – the content of data.txt)
4. server/set.php – save current scheme XML data (in this example – to data.txt)


SET and GET files calls with params, that you can adjust in HTML during SWF embedding – such parameters as page_id (so you can difference schemes between pages), session_id (so you can track the user rights for page edit) etc.


So, to integrate FLAscheme you must understand:

  • what kind of pages you will edit with FLAscheme, and how you will save scheme data in this pages.
  • where can you place your SET and GET php files with it's functionality.

Step 3: Adjusting params


So, I'll try to explain the params in index_editor.php. I'm strongly recommend to make a string to FLAscheme.swf with the same code:


<?php
// -------- init vars -----------
$flparam = array();
$flparam["urlcom"] = 'http://localhost/flascheme/server/';
$flparam["urlget"] = 'get.php';
$flparam["urlset"] = 'set.php';

$flparam["sid"] = session_id();
$flparam["pageid"] = "pageidval";
$flparam["pageintid"] = "pageintidval";
$flparam["time"] = "00:00:00";
$flparam["p1"] = 'p1val';
$flparam["p2"] = 'p2val';

$flparam["lkey"] = 'b686e469e7b40ae95b5ee654c3fadb09|pro'// for localhost
$flparam["editable"] = '1';

// -----  make a string --------
$paramstr "";
foreach(
$flparam as $key => $val) {
  
$paramstr .= '&'.$key.'='.urlencode($val);
}

// -------- some HTML ------------

echo "FlaScheme.swf?x".$paramstr;
?>


The params:

  • urlcom – common URL for both GET and SET handlers;
  • urlget – GET url (urlcom+urlget)
  • urlset – SET url (urlcom+urlset)
  • sid – PHP session ID, strongly recommended for user authorization
  • pageid – page id, can be used to identify the ID of your page
  • pageintid – ID scheme inside the current page, if you want to have a several schemes inside the one page
  • time – additional param, can be used to different the versions of wiki pages
  • p1 – additional param 1
  • p2 – additional param 2

Important: pageid, pageintid, time, p1 and p2 will be available both in SET and GET php files ad $_REQUEST params.

  • lkey – license key 
  • editable – can be set depend on current user rights. If set to 1, user can see “Edit” button.

Step 4: Example of GET and SET handlers


GET.php:

<?php
// requested params:
  // $_GET["pageId"]
  // $_GET["pageInternalId"]
  // $_GET["revisionTime"]
  // $_GET["param1"]
  // $_GET["param2"]

  
session_start();
  echo 
file_get_contents('data.txt');
?>


SET.PHP:

<?php
//preprocessing for magic quotes options of PHP
  
function magicQuotesSuck(&$a)
  {
  if (
is_array($a))
  {
    foreach (
$a as $k => $v)
    {
      if (
is_array($v))
        
magicQuotesSuck($a[$k]);
      else
        
$a[$k] = stripslashes($v);
    }
   }
  }
set_magic_quotes_runtime(0);
if (
get_magic_quotes_gpc())
{
  
magicQuotesSuck($_POST);
  
magicQuotesSuck($_GET);
  
magicQuotesSuck($_COOKIE);
  
magicQuotesSuck($_SERVER);
  
magicQuotesSuck($_REQUEST);
}

  
// if necessary:
  // $_POST["pageId"]
  // $_POST["pageInternalId"]
  // $_POST["revisionTime"]
  // $_POST["param1"]
  // $_POST["param2"]

  // real code
  
session_start();
  
file_put_contents('data.txt'$_POST["fschemeData"]);
  echo 
"<result><status>OK</status></result>";
?>

Step 5: Have a problem?...


Contact me