Welcome Guest, Not a member yet? Register   Sign In
Best practices - integrating other code into CI
#1

[eluser]Myles Wakeham[/eluser]
I have a large framework of code that I've built up over the past year or so with CI and its great. However its not AJAX enabled, and along comes a really great tool that I want to use (Delphi for PHP) that implements a really nice WYSIWYG IDE for code generation, and is based on the Qooxdoo AJAX framework.

So I have started to try and integrate the code that it creates into my CI framework. The code that it builds is a PHP file with typically a class per form, a series of require_once lines for included code, and an associated XML file that contains all the properties of the class that are used for display.

The HTML that it sends to the browser has a bunch of included Javascript libraries for the AJAX stuff, but this is typically generated and sent through the PHP code that it creates.

I've tried to work out how best to integrate this sort of code. Its not a CI library, nor is it a plug-in. I use Smarty a lot and I'd like to integrate these pages as 'blocks' of HTML within my existing page templates, but that doesn't work very well because of all the Javascript header content. So I moved all of their JS files into my template header (which worked ok) and now I'm left with the resulting code to integrate.

If anyone has had experience in trying to integrate code produced by other 3rd party code generators, etc. into CI and has some suggestions on things they did that worked well, I'm all ears.

Thanks
Myles
#2

[eluser]Myles Wakeham[/eluser]
To further illustrate this, I have put a very simple Delphi 4 PHP unit together that opens a floating window in PHP. Here's what it produces:

Code:
<?php
        //Includes
        require_once("vcl/vcl.inc.php");
        use_unit("buttons.inc.php");
        use_unit("checklst.inc.php");
        use_unit("comctrls.inc.php");
        use_unit("forms.inc.php");
        use_unit("extctrls.inc.php");
        use_unit("stdctrls.inc.php");

        //Class definition
        class Unit_TestAllocation extends Page
        {
               public $SpeedButton1 = null;
               public $CheckListBox2 = null;
               public $CheckListBox1 = null;
               public $BitBtn1 = null;
               public $GroupBox1 = null;
               public $Window1 = null;
               function BitBtn1Click($sender, $params)
               {
                $this->Window1->IsVisible = false;


               }

               function Unit_TestAllocationCreate($sender, $params)
               {
                $this->Window1->Visible = true;
              

               }

        }

        global $application;

        global $Unit_TestAllocation;

        //Creates the form
        $Unit_TestAllocation=new Unit_TestAllocation($application);

        //Read from resource file
        $Unit_TestAllocation->loadResource(__FILE__);

        //Shows the form
        $Unit_TestAllocation->show();

?>

This is then matched against what is basically a 'resource' file for the visual object, which is represented in XML like this:

Code:
<?php
<object class="Unit_TestAllocation" name="unit_TestAllocation" baseclass="page">
  <property name="Background"></property>
  <property name="Caption">Unit4</property>
  <property name="DocType">dtNone</property>
  <property name="Font">
    <property name="Align">taNone</property>
    <property name="Case"></property>
    <property name="Color"></property>
    <property name="Family">Tahoma</property>
    <property name="LineHeight"></property>
    <property name="Size">8px</property>
    <property name="Style"></property>
    <property name="Variant"></property>
    <property name="Weight"></property>
  </property>
  <property name="Height">600</property>
  <property name="IsMaster">0</property>
  <property name="Layout">
    <property name="Cols">5</property>
    <property name="Rows">5</property>
    <property name="Type">ABS_XY_LAYOUT</property>
  </property>
  <property name="Name">unit_TestAllocation</property>
  <property name="Width">800</property>
  <property name="OnAfterShow"></property>
  <property name="OnAfterShowFooter"></property>
  <property name="OnBeforeShow"></property>
  <property name="OnBeforeShowHeader"></property>
  <property name="OnCreate">unit_TestAllocationCreate</property>
  <property name="OnShow"></property>
  <property name="OnShowHeader"></property>
  <property name="OnStartBody"></property>
  <property name="OnTemplate"></property>
  &lt;object class="Window" name="Window1" &gt;
    <property name="Caption">Update Allocations</property>
    <property name="Height">400</property>
    <property name="Left">104</property>
    <property name="Name">Window1</property>
    <property name="Resizeable">0</property>
    <property name="ShowIcon">0</property>
    <property name="ShowMaximize">0</property>
    <property name="ShowMinimize">0</property>
    <property name="Top">88</property>
    <property name="Width">408</property>
    <property name="OnAfterShow"></property>
    <property name="OnBeforeShow"></property>
    <property name="OnShow"></property>
    &lt;object class="GroupBox" name="GroupBox1" &gt;
      <property name="Caption">Allocations</property>
      <property name="Font">
            <property name="Align">taNone</property>
            <property name="Case"></property>
            <property name="Color"></property>
            <property name="Family">Verdana</property>
            <property name="LineHeight"></property>
            <property name="Size">10px</property>
            <property name="Style"></property>
            <property name="Variant"></property>
            <property name="Weight"></property>
      </property>
      <property name="Height">336</property>
      <property name="Left">8</property>
      <property name="Name">GroupBox1</property>
      <property name="Top">24</property>
      <property name="Width">392</property>
      <property name="OnAfterShow"></property>
      <property name="OnBeforeShow"></property>
      <property name="OnShow"></property>
      &lt;object class="CheckListBox" name="CheckListBox1" &gt;
        <property name="Font">
                <property name="Align">taNone</property>
                <property name="Case"></property>
                <property name="Color"></property>
                <property name="Family">Verdana</property>
                <property name="LineHeight"></property>
                <property name="Size">10px</property>
                <property name="Style"></property>
                <property name="Variant"></property>
                <property name="Weight"></property>
        </property>
  [snip]

When deployed, it creates a folder in the same level as the PHP file called 'VCL' and in that are about 50 PHP files, Javascript libraries, JSON stuff, etc. That is deployed with the code for reference.

So what I'm trying to do is to find a way to best represent this in CI so that I can include this code with my 'normal' CI framework MVC code.

Myles




Theme © iAndrew 2016 - Forum software by © MyBB