VCL
[ class tree: VCL ] [ index: VCL ] [ all elements ]

Source for file designide.inc.php

Documentation is available at designide.inc.php

  1. <?php
  2. /**
  3. *  This file is part of the VCL for PHP project
  4. *
  5. *  Copyright (c) 2004-2007 qadram software <support@qadram.com>
  6. *
  7. *  Checkout AUTHORS file for more information on the developers
  8. *
  9. *  This library is free software; you can redistribute it and/or
  10. *  modify it under the terms of the GNU Lesser General Public
  11. *  License as published by the Free Software Foundation; either
  12. *  version 2.1 of the License, or (at your option) any later version.
  13. *
  14. *  This library is distributed in the hope that it will be useful,
  15. *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17. *  Lesser General Public License for more details.
  18. *
  19. *  You should have received a copy of the GNU Lesser General Public
  20. *  License along with this library; if not, write to the Free Software
  21. *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  22. *  USA
  23. *
  24. */
  25.  
  26. use_unit("classes.inc.php");
  27. use_unit("js/json.php");
  28.  
  29. /**
  30.  * Specifies to the IDE the title of this package
  31.  *
  32.  * @param string $packageTitle 
  33.  */
  34. function setPackageTitle($packageTitle)
  35. {
  36.         echo "packageTitle=$packageTitle\n";
  37. }
  38.  
  39. /**
  40.  * Specifies to the IDE the path to the icons for the components contained in this package (relative to the VCL path)
  41.  *
  42.  * @param string $iconPath 
  43.  */
  44. function setIconPath($iconPath)
  45. {
  46.         echo "iconPath=$iconPath\n";
  47. }
  48.  
  49. /**
  50.  * Registers components inside the IDE and places into the right palette page, it also allows the IDE to add the right unit to the source
  51.  *
  52.  * @param string $page 
  53.  * @param array $components 
  54.  * @param string $unit 
  55.  */
  56. function registerComponents($page,$components,$unit)
  57. {
  58.    echo "page=$page\n";
  59.    reset($components);
  60.    while (list($k,$v)=each($components))
  61.    {
  62.         echo "$v=$unit\n";
  63.    }
  64. }
  65.  
  66. /**
  67.  * Registers an asset for the Deployment wizard
  68.  *
  69.  * @param array $components Array of components you want to register the asset
  70.  * @param array $assets Array of folders you want to get copied when this component is used
  71.  */
  72. function registerAsset($components$assets)
  73. {
  74.         reset($components);
  75.         while (list($k,$v)=each($components))
  76.         {
  77.                 echo "asset=$v\n";
  78.                 reset($assets);
  79.                 while (list($c,$asset)=each($assets))
  80.                 {
  81.                         echo "value=".$asset."\n";
  82.                 }
  83.         }
  84. }
  85.  
  86. /**
  87.  * Registers a component editor to be used by a component when right clicking on it
  88.  *
  89.  * @param string $classname 
  90.  * @param string $componenteditorclassname 
  91.  * @param string $unitname 
  92.  */
  93. function registerComponentEditor($classname,$componenteditorclassname,$unitname)
  94. {
  95.    echo "componentclassname=$classname\n";
  96.    echo "componenteditorname=$componenteditorclassname\n";
  97.    echo "componenteditorunitname=$unitname\n";
  98. }
  99.  
  100. /**
  101.  * Registers a property editor to edit an specific property
  102.  *
  103.  * @param string $classname It can be an ancestor, property editors are also inherited
  104.  * @param string $property Property Name
  105.  * @param string $propertyclassname Property Editor class name
  106.  * @param string $unitname Unit that holds the property editor class
  107.  */
  108. function registerPropertyEditor($classname,$property,$propertyclassname,$unitname)
  109. {
  110.    echo "classname=$classname\n";
  111.    echo "property=$property\n";
  112.    echo "propertyeditor=$propertyclassname\n";
  113.    echo "propertyeditorunitname=$unitname\n";
  114. }
  115.  
  116. /**
  117.  * Register values to be shown for a dropdown property
  118.  *
  119.  * @param string $classname 
  120.  * @param string $property 
  121.  * @param array $values 
  122.  */
  123. function registerPropertyValues($classname,$property,$values)
  124. {
  125.    echo "classname=$classname\n";
  126.    echo "property=$property\n";
  127.  
  128.    reset($values);
  129.    while (list($k,$v)=each($values))
  130.    {
  131.         echo "value=$v\n";
  132.    }
  133. }
  134.  
  135. /**
  136.  * Registers a boolean property, so the Object Inspector offers a true/false dropdown
  137.  *
  138.  * @param string $classname 
  139.  * @param string $property 
  140.  */
  141. function registerBooleanProperty($classname,$property)
  142. {
  143.    $values=array('false','true');
  144.  
  145.    echo "classname=$classname\n";
  146.    echo "property=$property\n";
  147.  
  148.    reset($values);
  149.    while (list($k,$v)=each($values))
  150.    {
  151.         echo "value=$v\n";
  152.    }
  153. }
  154.  
  155. /**
  156.  * Registers a password property, so the Object Inspector doesn't show the value
  157.  *
  158.  * @param string $classname 
  159.  * @param string $property 
  160.  */
  161. function registerPasswordProperty($classname,$property)
  162. {
  163.    echo "classname=$classname\n";
  164.    echo "property=$property\n";
  165.    echo "value=password_protected\n";
  166. }
  167.  
  168. /**
  169.  * Register a component to be available but not visible
  170.  *
  171.  * @param array $components 
  172.  * @param string $unit 
  173.  */
  174. function registerNoVisibleComponents($components,$unit)
  175. {
  176.    echo "page=no\n";
  177.    reset($components);
  178.    while (list($k,$v)=each($components))
  179.    {
  180.         echo "$v=$unit\n";
  181.    }
  182. }
  183.  
  184. /**
  185.  * Base class for property editors
  186.  *
  187.  */
  188. class PropertyEditor extends Object
  189. {
  190.         public $value;
  191.  
  192.         /**
  193.          * Return specific attributes for the OI
  194.          *
  195.          * @return array 
  196.          */
  197.         function getAttributes()
  198.         {
  199.         }
  200.  
  201.         /**
  202.          * If required, returns a path to become the document root for the webserver to call the property editor
  203.          *
  204.          * @return string 
  205.          */
  206.         function getOutputPath()
  207.         {
  208.  
  209.         }
  210.  
  211.         /**
  212.          * Executes the property editor
  213.          *
  214.          * @param string $current_value  Current property value
  215.          */
  216.         function Execute($current_value)
  217.         {
  218.  
  219.         }
  220. }
  221.  
  222. /**
  223.  * Base class for component editors
  224.  *
  225.  */
  226. class ComponentEditor extends Object
  227. {
  228.         public $component=null;
  229.  
  230.         /**
  231.          * Return here an array of items to show when right clicking a component
  232.          * @return array 
  233.          */
  234.         function getVerbs()
  235.         {
  236.  
  237.         }
  238.  
  239.         /**
  240.          *  Depending on the verb, perform any action you want
  241.          *
  242.          * @param integer $verb Index of the verb the IDE wants to execute
  243.          */
  244.         function executeVerb($verb)
  245.         {
  246.  
  247.         }
  248.  
  249. }
  250.  
  251. /*
  252. //OLD CODE - DELETE
  253. class ColorPropertyEditor extends PropertyEditor
  254. {
  255.         function getAttributes()
  256.         {
  257.                 $result="sizeable=0\n";
  258.                 $result.="width=583\n";
  259.                 $result.="height=310\n";
  260.                 $result.="caption=Color Property editor - Copyright (c) 2000-02 Michael Bystrom\n";
  261.  
  262.                 return($result);
  263.         }
  264.  
  265.         function getOutputPath()
  266.         {
  267.                 return(dirname(__FILE__).'/resources/colorpropertyeditor/');
  268.         }
  269.  
  270.         function Execute($current_value)
  271.         {
  272.                 $this->value=$current_value;
  273.  
  274.                 if (isset($_POST['selcolor']))
  275.                 {
  276.                         echo "newvalue:\n";
  277.                         echo urldecode($_POST['selcolor']);
  278.                 }
  279.                 else
  280.                 {
  281.                         if ($this->value=="") $this->value="#FFFFFF";
  282.                         use_unit("resources/colorpropertyeditor/colorpicker.php");
  283.                 }
  284.         }
  285. }
  286. */
  287.  
  288. /**
  289.  * Editor for Color properties
  290.  *
  291.  */
  292. {
  293.         function getAttributes()
  294.         {
  295.                 $result="sizeable=0\n";
  296.                 $result.="width=557\n";
  297.                 $result.="height=314\n";
  298.                 $result.="caption=Color Property editor\n";
  299.  
  300.                 return($result);
  301.         }
  302.  
  303.         function getOutputPath()
  304.         {
  305.                 return(dirname(__FILE__).'/resources/coloreditor/');
  306.         }
  307.  
  308.         function Execute($current_value)
  309.         {
  310.                 $this->value=$current_value;
  311.  
  312.                 if (isset($_POST['selcolor']))
  313.                 {
  314.                         echo "newvalue:\n";
  315.                         echo urldecode($_POST['selcolor']);
  316.                 }
  317.                 else
  318.                 {
  319.                         if ($this->value==""$this->value="#FFFFFF";
  320.                         use_unit("resources/coloreditor/coloreditor.php");
  321.                 }
  322.         }
  323. }
  324.  
  325. /**
  326.  * Property Editor for StringLists
  327.  *
  328.  */
  329. {
  330.         function getAttributes()
  331.         {
  332.                 $result="sizeable=0\n";
  333.                 $result.="width=583\n";
  334.                 $result.="height=410\n";
  335.                 $result.="caption=StringList Editor\n";
  336.  
  337.                 return($result);
  338.         }
  339.  
  340.         function getOutputPath()
  341.         {
  342.                 return(dirname(__FILE__).'/resources/stringlisteditor/');
  343.                 return false;
  344.         }
  345.  
  346.         function Execute($current_value)
  347.         {
  348.                 $this->value=$current_value;
  349.  
  350.                 if (isset($_POST['listeditor']))
  351.                 {
  352.                         echo "newvalue:\n";
  353.                         if (trim($_POST['action'])=='OK')
  354.                         {
  355.                                 $value=$_POST['listeditor'];
  356.                                 //Carriage returns must be converted properly
  357.                                 $value=str_replace("\r",'',$value);
  358.                                 $value=str_replace("\n",'\n',$value);
  359.                                 echo $value;
  360.                         }
  361.                         else
  362.                         {
  363.                                 echo $this->value;
  364.                         }
  365.                 }
  366.                 else
  367.                 {
  368.                         use_unit("resources/stringlisteditor/stringlisteditor.php");
  369.                 }
  370.         }
  371. }
  372.  
  373. /**
  374.  * Array editor - not finished
  375.  *
  376.  */
  377. {
  378.         function getAttributes()
  379.         {
  380.                 $result="sizeable=0\n";
  381.                 $result.="height=320\n";
  382.                 $result.="width=513\n";
  383.                 $result.="caption=Array Editor\n";
  384.  
  385.                 return($result);
  386.         }
  387.  
  388.         function getOutputPath()
  389.         {
  390.                 return(dirname(__FILE__).'/resources/arrayeditor/');
  391.                 return false;
  392.         }
  393.  
  394.         function Execute($current_value)
  395.         {
  396.                 global $ArrayEditor;
  397.  
  398.                 $this->value=$current_value;
  399.  
  400.                 if (isset($_POST['btnOk']))
  401.                 {
  402.                         ob_start();
  403.                         use_unit("resources/arrayeditor/arrayeditor.php");
  404.                         ob_end_clean();
  405.  
  406.                         $items=$ArrayEditor->tvItems->Items;
  407.                         echo "newvalue:\n".serialize($items)."\n";
  408.                 }
  409.                 elseif (isset($_POST['btnCancel']))
  410.                 {
  411.                         echo "newvalue:\n";
  412.                         echo $this->value;
  413.                 }
  414.                 else
  415.                 {
  416.                         use_unit("resources/arrayeditor/arrayeditor.php");
  417.                 }
  418.         }
  419. }
  420.  
  421. /**
  422.  * Items property editor, for menus and treeviews
  423.  *
  424.  */
  425. {
  426.         function getAttributes()
  427.         {
  428.                 $result="sizeable=1\n";
  429.                 $result.="height=320\n";
  430.                 $result.="width=513\n";
  431.                 $result.="caption=Items Editor\n";
  432.  
  433.                 return($result);
  434.         }
  435.  
  436.         function getOutputPath()
  437.         {
  438.                 return(dirname(__FILE__).'/resources/menuitemeditor/');
  439.                 return false;
  440.         }
  441.  
  442.         /**
  443.         * Converts a JS array to a PHP array
  444.         *
  445.         * @param array $input 
  446.         * @return string 
  447.         */
  448.         function JSArrayToPHPArray($input)
  449.         {
  450.                 $output=array();
  451.                 $children=array();
  452.  
  453.                 reset($input);
  454.                 list($k,$props)=each($input);
  455.                 while (list($k,$child)=each($input))
  456.                 {
  457.                         $c=$this->JSArrayToPHPArray($child[0]);
  458.                         $children[]=$c[0];
  459.                 }
  460.  
  461.                 $caption=$props[0];
  462.                 if (isset($props[1])) $tag=$props[1];
  463.                 else $tag=0;
  464.  
  465.                 if (count($children)!=0)
  466.                 {
  467.                         $output[]=array('Caption'=>$caption,'Tag'=>$tag'Items'=>$children);
  468.                 }
  469.                 else
  470.                 {
  471.                         $output[]=array('Caption'=>$caption'Tag'=>$tag);
  472.                 }
  473.  
  474.                 return($output);
  475.         }
  476.  
  477.  
  478.         function Execute($current_value)
  479.         {
  480.                 global $MenuItemEditor;
  481.  
  482.                 $this->value=$current_value;
  483.  
  484.                 if (isset($_POST['items']))
  485.                 {
  486.                         $json_string=$_POST['items'];
  487.                         $json new Services_JSON();
  488.  
  489.                         $array=$json->decode($json_string);
  490.                         $phparray=$this->JSArrayToPHPArray($array[0]);
  491.                         $finalarray=$phparray[0]['Items'];
  492.                         echo "newvalue:\n".serialize($finalarray)."\n";
  493.                 }
  494.                 else
  495.                 {
  496.                         use_unit("resources/menuitemeditor/menuitemeditor.php");
  497.                 }
  498.         }
  499. }
  500.  
  501. /**
  502.  * HTML property editor, for captions and so on
  503.  *
  504.  */
  505. {
  506.         function getAttributes()
  507.         {
  508.                 $result="sizeable=1\n";
  509.                 $result.="width=740\n";
  510.                 $result.="height=540\n";
  511.                 $result.="caption=HTML Property editor (Xinha based)\n";
  512.  
  513.                 return($result);
  514.         }
  515.  
  516.         function getOutputPath()
  517.         {
  518.                 return(dirname(__FILE__).'/resources/xinha/');
  519.         }
  520.  
  521.         function Execute($current_value)
  522.         {
  523.                 $this->value=$current_value;
  524.  
  525.                 if (isset($_POST['myTextArea']))
  526.                 {
  527.                         echo "newvalue:\n";
  528.                         echo urldecode($_POST['myTextArea']);
  529.                 }
  530.                 else
  531.                 {
  532.                         use_unit("resources/xinha/htmlpropertyeditor.php");
  533.                 }
  534.         }
  535. }
  536.  
  537. /**
  538.  * Image property editor - not finished
  539.  *
  540.  */
  541.  
  542. {
  543.         function getAttributes()
  544.         {
  545. //                $result="sizeable=1\n";
  546. //                $result.="width=740\n";
  547. //                $result.="height=540\n";
  548.                 $result.="caption=Image Property editor (Xinha based)\n";
  549.  
  550.                 return($result);
  551.         }
  552.  
  553.         function getOutputPath()
  554.         {
  555.                 return(dirname(__FILE__).'/resources/xinha/plugins/ImageManager/');
  556.         }
  557.  
  558.         function Execute($current_value)
  559.         {
  560.                 $this->value=$current_value;
  561.                 
  562.                 if (isset($_POST['f_url']))
  563.                 {
  564.                         echo "newvalue:\n";
  565.                         echo urldecode($_POST['f_url']);
  566.                 }
  567.                 else
  568.                 {
  569.                         use_unit("resources/xinha/plugins/ImageManager/imagepropertyeditor.php");
  570.                 }
  571.         }
  572. }
  573.  
  574. {
  575.         function getVerbs()
  576.         {
  577.                 echo "Create Dictionary\n";
  578.         }
  579.  
  580.         function executeVerb($verb)
  581.         {
  582.                 switch($verb)
  583.                 {
  584.                         case 0:
  585.                                 $this->component->ControlState=0;
  586.                                 $this->component->open();
  587.                                 if ($this->component->createDictionaryTable())
  588.                                 {
  589.                                         echo "Dictionary created";
  590.                                 }
  591.                                 else
  592.                                 {
  593.                                     echo "Error creating Dictionary. Please check the connection settings and the Dictionary property.";
  594.                                 }
  595.                                 break;
  596.                 }
  597.         }
  598. }
  599.  
  600. ?>

Documentation generated on Tue, 27 Mar 2007 13:34:28 +0200 by phpDocumentor 1.3.1