Source for file admin.installer.html.php

Documentation is available at admin.installer.html.php

  1. <?php
  2. /**
  3. @package Mambo
  4. @subpackage Installer
  5. @copyright  Refer to copyright.php
  6. @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
  7. @author Mambo Foundation Inc see README.php
  8. */
  9.  
  10. /** ensure this file is being included by a parent file */
  11. defined'_VALID_MOS' or die'Direct Access to this location is not allowed.' );
  12.  
  13. function writableCell$folder {
  14.     echo '<tr>';
  15.     echo '<td class="item">' $folder '/</td>';
  16.     echo '<td align="right">';
  17.     echo is_writable$GLOBALS['mosConfig_absolute_path''/' $folder '<b><span class="green">'.T_('Writeable').'</span></b>' '<b><span class="red">'.T_('Unwriteable').'</span></b>' '</td>';
  18.     echo '</tr>';
  19. }
  20.  
  21. /**
  22. @package Mambo
  23. */
  24. class HTML_installer {
  25.  
  26.     function showInstallForm$title$option$element$client ""$p_startdir ""$backLink="" {
  27.         ?>
  28.         <script language="javascript" type="text/javascript">
  29.         function submitbutton3(pressbutton) {
  30.             var form = document.adminForm_dir;
  31.  
  32.             // do field validation
  33.             if (form.userfile.value == ""){
  34.                 alert( "<?php echo T_('Please select a directory')?>" );
  35.             } else {
  36.                 form.submit();
  37.             }
  38.         }
  39.         </script>
  40.         <form enctype="multipart/form-data" action="index2.php" method="post" name="filename">
  41.         <table class="adminheading">
  42.         <tr>
  43.             <th class="install">
  44.             <?php echo $title;?>
  45.             </th>
  46.             <td align="right" nowrap="true">
  47.             <?php echo $backLink;?>
  48.             </td>
  49.         </tr>
  50.         </table>
  51.  
  52.         <table class="adminform">
  53.         <tr>
  54.             <th>
  55.             <?php echo T_('Upload Package File')?>
  56.             </th>
  57.         </tr>
  58.         <tr>
  59.             <td align="right">
  60.             <?php echo T_('Package File:')?>
  61.             <input class="text_area" name="userfile" type="file" size="70"/>
  62.             <input class="button" type="submit" value="<?php echo T_('Upload File &amp; Install')?>" />
  63.             </td>
  64.         </tr>
  65.         </table>
  66.  
  67.         <input type="hidden" name="task" value="uploadfile"/>
  68.         <input type="hidden" name="option" value="<?php echo $option;?>"/>
  69.         <input type="hidden" name="element" value="<?php echo $element;?>"/>
  70.         <input type="hidden" name="client" value="<?php echo $client;?>"/>
  71.         </form>
  72.         <br />
  73.  
  74.         <?php
  75.         if (ini_get('allow_url_fopen')) HTML_installer::showUrlForm('http://'$option$element$client);
  76.         ?>
  77.         
  78.         <form action="index2.php" method="post" name="adminForm_dir">
  79.         <table class="adminform">
  80.         <tr>
  81.             <th>
  82.             <?php echo T_('Install from directory')?>
  83.             </th>
  84.         </tr>
  85.         <tr>
  86.             <td align="right">
  87.             <?php echo T_('Install directory:')?>&nbsp;
  88.             <input type="text" name="userfile" class="text_area" size="65" value="<?php echo $p_startdir?>"/>&nbsp;
  89.             <input type="button" class="button" value="<?php echo T_('Install')?>" onclick="submitbutton3()" />
  90.             </td>
  91.         </tr>
  92.         </table>
  93.  
  94.         <input type="hidden" name="task" value="installfromdir" />
  95.         <input type="hidden" name="option" value="<?php echo $option;?>"/>
  96.         <input type="hidden" name="element" value="<?php echo $element;?>"/>
  97.         <input type="hidden" name="client" value="<?php echo $client;?>"/>
  98.         </form>
  99.         <br />
  100.         <?php
  101.     }
  102.  
  103.     function showUrlForm ($prompt$option$element$client{
  104.         ?>
  105.         <form action="index2.php" method="post" name="adminForm_url">
  106.         <table class="adminform">
  107.         <tr>
  108.             <th>
  109.             <?php echo T_('Install from HTTP URL')?>
  110.             </th>
  111.         </tr>
  112.         <tr>
  113.             <td align="right">
  114.             <?php echo T_('Install HTTP URL:')?>&nbsp;
  115.             <input type="text" name="userurl[]" class="text_area" size="65" value="<?php echo $prompt?>" />&nbsp;
  116.             <input type="submit" class="button" value="<?php echo T_('Upload URL &amp; Install')?>" />
  117.             </td>
  118.         </tr>
  119.         </table>
  120.         <input type="hidden" name="task" value="installfromurl" />
  121.         <input type="hidden" name="option" value="<?php echo $option;?>"/>
  122.         <input type="hidden" name="element" value="<?php echo $element;?>"/>
  123.         <input type="hidden" name="client" value="<?php echo $client;?>"/>
  124.         </form>
  125.         <br />
  126.         <?php
  127.     }
  128.  
  129.     function AddonForm ($prompt$option$element$client{
  130.         ?>
  131.         <form action="index2.php" method="post" name="adminForm_url">
  132.           <?php //Load Addon XML file from The Source
  133.             
  134.         $fhandle @fopen("http://source.mambo-foundation.org/external/config/addon.xml""r");
  135.         if (!$fhandle{
  136.             $error T_('Failed to open addon.xml on The Source (source.mambo-foundation.org).  Check your Internet connection.');
  137.             exit($error);
  138.         else {
  139.                $addon simplexml_load_file('http://source.mambo-foundation.org/external/config/addon.xml');
  140.         }
  141.         
  142.         //Count the number of items in the XML file
  143.         $addon_count 0;
  144.            foreach($addon->name as $i$addon_count++
  145.         ?>
  146.           <table width="100%" border="1" cellpadding="0"
  147.          cellspacing="1" class="adminform">
  148.         
  149.           <tr>
  150.           <th colspan="7" style="text-align: right;"><?php echo T_('Add-On Installation'?></th>
  151.            </tr>
  152.           <tr>
  153.           <th colspan="7" style="text-align: right;"><input type="submit" name="install_packages" value="<?php echo T_('Install Package(s)'?>" />
  154.           <i><?php echo T_('Note: Check the package or packages you wish to install below. Any number of packages or types may be installed with a single click.'?></i></th>
  155.           </tr>
  156.         <tr style="background-color: Orange; font-weight: bold; text-align: center;">
  157.           <td width="185"><?php echo T_('Mark for installation'?></td>
  158.           <td width="159"><?php echo T_('Add-On Package'?></td>
  159.           <td width="168"><?php echo T_('Package Description'?></td>
  160.           <td width="168"><?php echo T_('Author'?></td>
  161.           <td width="107"><?php echo T_('Latest Version')?></td>
  162.           <td width="107"><?php echo T_('Installed Version')?></td>
  163.           </tr>
  164.          <!-- Display the Mambots -->
  165.           <tr>
  166.             <td style="background-color: Yellow; font-weight: bold; text-align: center;"><strong><?php echo T_('Package Type: Mambots'?></strong></td>
  167.           </tr>        
  168.           <?php for $counter 0$counter $addon_count$counter++
  169.           if ($addon->type[$counter]=='Mambot'?>
  170.           <tr>
  171.           <td style="text-align: center;"><div align="center">
  172.           <input name="userurl[]" value="<?php echo $addon->url[$counter?>" type="checkbox" />
  173.           </div></td>
  174.           <td><div align="right"><?php echo $addon->name[$counter?></div></td>
  175.           <td><?php echo $addon->desc[$counter?></td>
  176.           <td><div align="right"><?php echo $addon->author[$counter?></div></td>
  177.           <?php 
  178.           //Find current version if installed
  179.           $LatestVersion $addon->version[$counter];
  180.           $addonXMLpath $addon->xmlfile[$counter];
  181.           $InstalledVersion getCurrentAddonVersion($addonXMLpath);
  182.           ?>
  183.           <td><?php echo $LatestVersion?></td>
  184.           <td <?php if ($InstalledVersion!="Not Installed" && strcmp($InstalledVersion$LatestVersion)<0
  185.               echo "style=\"background-color: Red; color: White; font-weight: bold;\""
  186.               ?> >
  187.           <?php echo $InstalledVersion?>
  188.           </td>
  189.         </tr>
  190.          <?php } } ?>
  191.          <!-- Display the Components -->
  192.           <tr>
  193.             <td style="background-color: Yellow; font-weight: bold; text-align: center;"><strong><?php echo T_('Package Type: Components'?></strong></td>
  194.           </tr>        
  195.           <?php for $counter 0$counter $addon_count$counter++
  196.           if ($addon->type[$counter]=='Component'?>
  197.           <tr>
  198.           <td style="text-align: center;"><div align="center">
  199.           <input name="userurl[]" value="<?php echo $addon->url[$counter?>" type="checkbox" />
  200.           </div></td>
  201.           <td><div align="right"><?php echo $addon->name[$counter?></div></td>
  202.           <td><?php echo $addon->desc[$counter?></td>
  203.           <td><div align="right"><?php echo $addon->author[$counter?></div></td>
  204.           <?php 
  205.           //Find current version if installed
  206.           $LatestVersion $addon->version[$counter];
  207.           $addonXMLpath $addon->xmlfile[$counter];
  208.           $InstalledVersion getCurrentAddonVersion($addonXMLpath);
  209.           ?>
  210.           <td><?php echo $LatestVersion?></td>
  211.           <td <?php if ($InstalledVersion!="Not Installed" && strcmp($InstalledVersion$LatestVersion)<0
  212.               echo "style=\"background-color: Red; color: White; font-weight: bold;\""
  213.               ?> >
  214.           <?php echo $InstalledVersion?>
  215.           </td>
  216.         </tr>
  217.          <?php } } ?>
  218.          <!-- Display the Modules -->
  219.           <tr>
  220.             <td style="background-color: Yellow; font-weight: bold; text-align: center;"><strong><?php echo T_('Package Type: Modules'?></strong></td>
  221.           </tr>      
  222.           <?php for $counter 0$counter $addon_count$counter++
  223.           if ($addon->type[$counter]=='Module'?>
  224.           <tr>
  225.           <td style="text-align: center;"><div align="center">
  226.           <input name="userurl[]" value="<?php echo $addon->url[$counter?>" type="checkbox" />
  227.           </div></td>
  228.           <td><div align="right"><?php echo $addon->name[$counter?></div></td>
  229.           <td><?php echo $addon->desc[$counter?></td>
  230.           <td><div align="right"><?php echo $addon->author[$counter?></div></td>
  231.           <?php 
  232.           //Find current version if installed
  233.           $LatestVersion $addon->version[$counter];
  234.           $addonXMLpath $addon->xmlfile[$counter];
  235.           $InstalledVersion getCurrentAddonVersion($addonXMLpath);
  236.           ?>
  237.           <td><?php echo $LatestVersion?></td>
  238.           <td <?php if ($InstalledVersion!="Not Installed" && strcmp($InstalledVersion$LatestVersion)<0
  239.               echo "style=\"background-color: Red; color: White; font-weight: bold;\""
  240.               ?> >
  241.           <?php echo $InstalledVersion?>
  242.           </td>
  243.         </tr>
  244.          <?php } } ?>
  245.         <?php //Load Certified 3rd Party Addon XML file from The Source
  246.            if (fopen("http://source.mambo-foundation.org/external/config/external_addon.xml""r")) {
  247.              $exaddon simplexml_load_file('http://source.mambo-foundation.org/external/config/external_addon.xml');
  248.         else {
  249.                exit('Failed to open external_addon.xml on The Source (source.mambo-foundation.org).');
  250.         }
  251.         //Count the number of items in the XML file
  252.         $exaddon_count 0;
  253.            foreach($exaddon->name as $i$exaddon_count++
  254.         ?>
  255.           <tr>
  256.           <th colspan="7" style="text-align: right;"><?php echo T_('Peer Reviewed / Certified 3rd Party Add-On Installation')?></th>
  257.         </tr>
  258.         <tr style="background-color: Orange; font-weight: bold; text-align: center;">
  259.           <td width="185"><?php echo T_('Mark for installation')?></td>
  260.           <td width="159"><?php echo T_('Add-On Package')?></td>
  261.           <td width="168"><?php echo T_('Package Description')?></td>
  262.           <td width="168"><?php echo T_('Author')?></td>
  263.           <td width="107"><?php echo T_('Latest Version')?></td>
  264.           <td width="107"><?php echo T_('Installed Version')?></td>
  265.           </tr>
  266.           <!-- Display the Mambots -->
  267.           <tr>
  268.             <td style="background-color: Yellow; font-weight: bold; text-align: center;"><strong><?php echo T_('Package Type: Mambots'?></strong></td>
  269.           </tr> 
  270.           <?php 
  271.           //Setup variable to test for the existance of packages
  272.           $exmambot_count 0;
  273.           for $counter 0$counter $exaddon_count$counter++
  274.           if ($exaddon->type[$counter]=='Mambot'
  275.           //If we are here then 3rd party mambots exist
  276.           $exmambot_count 1;
  277.           ?>
  278.           <tr>
  279.           <td style="text-align: center;"><div align="center">
  280.           <input name="userurl" value="<?php echo $exaddon->url[$counter?>" type="checkbox">
  281.           </div></td>
  282.           <td><div align="right"><?php echo $exaddon->name[$counter?></div></td>
  283.           <td><?php echo $exaddon->desc[$counter?></td>
  284.           <td><div align="right"><?php echo $exaddon->author[$counter?></div></td>
  285.           <td><?php echo $exaddon->version[$counter?></td>
  286.         </tr>
  287.          <?php } } 
  288.          //If no 3rd party mambots exist then display the message below
  289.          if ($exmambot_count == 0{?>
  290.          <tr>
  291.          <td></td>
  292.          <td>
  293.          <?php 
  294.          echo T_('There are no qualifying packages at this time'?></td>
  295.          </tr>
  296.         <?php ?>
  297.          <!-- Display the Components -->
  298.           <tr>
  299.             <td style="background-color: Yellow; font-weight: bold; text-align: center;"><strong><?php echo T_('Package Type: Components'?></strong></td>
  300.           </tr> 
  301.           <?php 
  302.           //Setup variable to test for the existance of packages
  303.           $excomponent_count 0;
  304.           for $counter 0$counter $exaddon_count$counter++
  305.           if ($exaddon->type[$counter]=='Component'
  306.           //If we are here then 3rd party components exist
  307.           $excomponent_count 1;
  308.           ?>
  309.           <tr>
  310.           <td style="text-align: center;"><div align="center">
  311.           <input name="userurl" value="<?php echo $exaddon->url[$counter?>" type="checkbox">
  312.           </div></td>
  313.           <td><div align="right"><?php echo $exaddon->name[$counter?></div></td>
  314.           <td><?php echo $exaddon->desc[$counter?></td>
  315.           <td><div align="right"><?php echo $exaddon->author[$counter?></div></td>
  316.           <td><?php echo $exaddon->version[$counter?></td>
  317.         </tr>
  318.          <?php } } 
  319.          //If no 3rd party components exist then display the message below
  320.          if ($excomponent_count == 0{?>
  321.          <tr>
  322.          <td></td>
  323.          <td><?php echo T_('There are no qualifying packages at this time'?></td>
  324.          </tr>
  325.         <?php ?>
  326.          <!-- Display the Modules -->
  327.           <tr>
  328.             <td style="background-color: Yellow; font-weight: bold; text-align: center;"><strong><?php echo T_('Package Type: Modules'?></strong></td>
  329.           </tr> 
  330.           <?php 
  331.           //Setup variable to test for the existance of packages
  332.           $exmodule_count 0;
  333.           for $counter 0$counter $exaddon_count$counter++
  334.           if ($exaddon->type[$counter]=='Module'
  335.           //If we are here then 3rd party modules exist
  336.           $exmodule_count 1;
  337.           ?>
  338.           <tr>
  339.           <td style="text-align: center;"><div align="center">
  340.           <input name="userurl" value="<?php echo $exaddon->url[$counter?>" type="checkbox">
  341.           </div></td>
  342.           <td><div align="right"><?php echo $exaddon->name[$counter?></div></td>
  343.           <td><?php echo $exaddon->desc[$counter?></td>
  344.           <td><div align="right"><?php echo $exaddon->author[$counter?></div></td>
  345.           <td><?php echo $exaddon->version[$counter?></td>
  346.         </tr>
  347.          <?php } } 
  348.          //If no 3rd party modules exist then display the message below
  349.          if ($exmodule_count == 0{?>
  350.          <tr>
  351.          <td></td>
  352.          <td><?php echo T_('There are no qualifying packages at this time'?></td>
  353.          </tr>
  354.         <?php ?>
  355.           </table>
  356.           <input name="task" value="installfromurl" type="hidden" />
  357.           <input name="option" value="<?php echo $option;?>" type="hidden" />
  358.           <input name="element" value="<?php echo $element;?>" type="hidden" />
  359.           <input name="client" value="<?php echo $client;?>" type="hidden" />
  360.         </form> 
  361.         <br />
  362.         <?php
  363.     }
  364.     
  365.     function theSourceForm ($option$element$client{
  366.         HTML_installer::showUrlForm(''$option$element$client);
  367.         echo '<object type="text/html" data="http://source.mambo-foundation.org/component/syndstyle/option,com_remository/" width="500" height="1000">'
  368.             .T_('Sorry, it seems that The Source is not available').'</object>';
  369.     }
  370.  
  371.     /**
  372.     * @param string 
  373.     * @param string 
  374.     * @param string 
  375.     * @param string 
  376.     */
  377.     function showInstallMessage ($messages$title$return{
  378.         global $PHP_SELF;
  379.         if (!$return$return mamboCore::get('mosConfig_live_site').'/administrator/index2.php';
  380.         ?>
  381.         <table class="adminheading">
  382.         <tr>
  383.             <th class="install">
  384.             <?php echo $title?>
  385.             </th>
  386.         </tr>
  387.         </table>
  388.  
  389.         <table class="adminform">
  390.         <?php
  391.         if (!is_array($messages)) $messages array($messages);
  392.         foreach ($messages as $message{
  393.             switch ($message->level{
  394.                 case _MOS_ERROR_INFORM:
  395.                 $colour 'green';
  396.                 $level 'Information: ';
  397.                 break;
  398.                 case _MOS_ERROR_WARN:
  399.                 $colour 'red';
  400.                 $level 'Warning: ';
  401.                 break;
  402.                 case _MOS_ERROR_SEVERE:
  403.                 $colour 'red';
  404.                 $level 'Severe: ';
  405.                 break;
  406.                 case _MOS_ERROR_FATAL:
  407.                 $colour 'red';
  408.                 $level 'Fatal: ';
  409.                 break;
  410.             }
  411.             ?>
  412.             <tr>
  413.                 <td align="right">
  414.                 <span class="<?php echo $colour?>"><strong><?php echo $level.$message->text?></strong></span>
  415.                 </td>
  416.         </tr>
  417.         <?php
  418.         }
  419.         ?>
  420.         <tr>
  421.             <td colspan="2" align="center">
  422.             [&nbsp;<a href="<?php echo $return;?>" style="font-size: 16px; font-weight: bold"><?php echo T_('Continue ...')?></a>&nbsp;]
  423.             </td>
  424.         </tr>
  425.         </table>
  426.         <?php
  427.     }
  428. }
  429. ?>

Documentation generated on Mon, 05 May 2008 16:15:11 +0400 by phpDocumentor 1.4.0