Location: PHPKode > scripts > AIRProjectXML > airprojectxml/sample.php
<?php

require_once 'AIRProjectXML.php';


// Define initial window parameters
$initialWindow = new AIRProjectXML_initialWindow('HelloWorld.html');
$initialWindow->title = 'Hello World';
$initialWindow->systemChrome = APX_SYSTEM_CHROME_NONE;
$initialWindow->transparent = false;
$initialWindow->visible = true;
$initialWindow->minimizable = true;
$initialWindow->maximizable = true;
$initialWindow->resizable = true;
$initialWindow->width = 640;
$initialWindow->height = 480;
$initialWindow->x = 30;
$initialWindow->y = 20;
$initialWindow->minSize = AIRProjectXML::setSize(320, 240);
$initialWindow->maxSize = AIRProjectXML::setSize(1280, 960);


// Define application icon
$icon = new AIRProjectXML_icon('icons/medium_icon.png', APX_ICON_32);
$icon->image16x16 = 'icons/small_icon.png';
$icon->image48x48 = 'icons/big_icon.png';
$icon->image128x128 = 'icons/biggest_icon.png';


// Define file types associated with application
$avfIcon = new AIRProjectXML_icon('icons/avf32.png', APX_ICON_32);
$avfIcon->image16x16 = 'icons/avf16.png';
$avfIcon->image48x48 = 'icons/avf48.png';
$avfIcon->image128x128 = 'icons/avf128.png';
$avfFileType = new AIRProjectXML_fileType('adobe.VideoFile', 'avf');
$avfFileType->description = 'Adobe Video File';
$avfFileType->contentType = 'application/vnd.adobe.video-file';
$avfFileType->icon = $avfIcon;


// Define application parameters
$application = new AIRProjectXML_application('com.example.HelloWorld', 'HelloWorld', '1.0', $initialWindow);
//$application->name = 'Example Co. AIR Hello World';
//$application->name = AIRProjectXML::appendMultilanguage(array('en' => 'Hello World', 'ru' => 'Hello World Russia!'));
$application->name = 'Hello World';
$lStr = array(
    'en' => 'This is an example.',
    'fr' => 'C\'est un exemple.',
    'es' => 'Esto es un ejemplo.'
);
$application->description = AIRProjectXML::appendMultilanguage($lStr);
$application->copyright = 'Copyright (c) 2008 Example Co.';
$application->installFolder = 'Example Co/Hello World';
$application->programMenuFolder = 'Example Co';
$application->icon = $icon;
$application->customUpdateUI = false;
$application->allowBrowserInvocation = false;
$application->fileTypes = array($avfFileType);


// Construct AIRProjectXML object
$projectXML = new AIRProjectXML($application);
$projectXML->lineBreak = "\r\n";
$projectXML->indent = "\t";

// Use one of the following methods: saveFile(), forceDownload() or getString()
//$projectXML->saveFile('application.xml');
//$projectXML->forceDownload('application.xml');
$xml = $projectXML->getString();
echo '<pre>' . htmlspecialchars($xml) . '</pre>';


// Test the parser class
$parser = new AIRProjectXMLParser();
//$parser->parseXMLFile('application.xml');
$parser->parseXMLString($xml) or die('Unable to parse the string!');

ob_start();
print_r($parser->application);
$dump = ob_get_contents();
ob_end_clean();
echo '<hr /><pre>' . htmlspecialchars($dump) . '</pre>';

function printStr($lStr)
{
    echo '<ul>' . "\n";
    if (is_array($lStr)) {
        // The string is in multilanguage format
        foreach ($lStr as $lang => $value) {
            echo '<li>' . $lang . ' = ' . $value . '</li>' . "\n";
        }
    } else {
        // Simple string
        echo '<li>' . $lStr . '</li>' . "\n";
    }
    echo '</ul>' . "\n";
}

echo '<hr />';

printStr($parser->parseMultilanguageString($parser->application->name));
printStr($parser->parseMultilanguageString($parser->application->description));

?>
Return current item: AIRProjectXML