Хранилища Subversion ant

Редакция

Редакция 292 | Авторство | Сравнить с предыдущей | Последнее изменение | Открыть журнал | Скачать | RSS

<?php

/**
 * Project:     Ant: sources.list generator
 * File:        modern.php
 *
 * This application is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This application is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */



require_once dirname(__FILE__)."/lib/init.php";

$scripts = "
(function($){
  // очищаем select
  $.fn.clearSelect = function() {
          return this.each(function(){
                  if(this.tagName=='SELECT') {
                      this.options.length = 0;
                      $(this).attr('disabled','disabled');
                  }
          });
  }
  // заполняем select
  $.fn.fillSelect = function(dataArray) {
          return this.clearSelect().each(function(){
                  if(this.tagName=='SELECT') {
                          var currentSelect = this;
                          $.each(dataArray,function(index,data){
                                  var option = new Option(data.text,data.value);
                                  if($.support.cssFloat) {
                                          currentSelect.add(option,null);
                                  } else {
                                          currentSelect.add(option);
                                  }
                          });
                  }
          });
  }
})(jQuery);
</script>
<script type='text/javascript'>
$(document).ready(function(){
  // выбор дистрибутива
  function adjustDistro(){
        var distroValue = $('#distro').val();
        var tmpSelect = $('#distver');
        if(distroValue.length == 0) {
                tmpSelect.attr('disabled','disabled');
                tmpSelect.clearSelect();
                adjustReps();
                $('#replist').css('display','none');
                $('#getfile').css('display','none');
                $('#reps').css('display','none');
        $('#vdist').css('visibility','hidden');
        } else {
                $.getJSON('./m-process.php',{d:distroValue,status:1},function(data) { tmpSelect.fillSelect(data).attr('disabled',''); adjustReps(); });
                $('#replist').css('display','none');
                $('#getfile').css('display','none');
                $('#reps').css('display','none');
        $('#vdist').css('visibility','visible');
        }
  };
  // Выбор версии дистрибутива
  function adjustReps(){  
        var distroValue = $('#distro').val();
        var versionValue = $('#distver').val();
        if (distroValue != 0 && versionValue != 0) {
                $.get('./m-process.php',{d:distroValue,v:versionValue,status:2},function(data){ $('#reps').css('display','block'); $('#reps').html(data);adjustRepos(); });
        } else {
                $('#replist').css('display','none');
                $('#getfile').css('display','none');
                $('#reps').css('display','none');
        }
  }
  // Выбор репозиториев дистрибутива
  function adjustRepos(){
        var distroValue = $('#distro').val();
        var versionValue = $('#distver').val();
        if (distroValue != 0 && versionValue != 0) {
            var repar = $('input.repbox:checked');
            if(repar.length==0){
                $('#replist').css('display','none');
                $('#getfile').css('display','none');
            }else{
                repar=repar.serialize();
                $('#replist').css('display','block');
                $('#getfile').css('display','block');
                $('#replist').load('./m-process.php?status=3&d='+distroValue+'&v='+versionValue+'&'+repar);
                $('#getfile').load('./m-process.php?status=4&d='+distroValue+'&v='+versionValue+'&'+repar);
            }
        } else {
                $('#replist').css('display','none');
                $('#getfile').css('display','none');
        }
  }

  $('#distro').change(adjustDistro);
  $('#distver').change(adjustReps);
  $('#reps').click(adjustRepos);
});

"
;

$query =& $db->query("SELECT * FROM distribution");
while ($query->fetchInto($data, DB_FETCHMODE_ASSOC)) {
        $linux .= "<option value='".$data["dist_id"]."'>".$secure->stripStr($data["distname"])."</option>\n";
}

$modern .= "<h2>"._("Generator of sources.list")."</h2>";
$modern .= "<div class='border'>";
$modern .= "<label>"._("Distributive")."</label><br>";
$modern .= "<select id='distro'>\n<option value=''>"._("Choose distro")."</option>\n";
$modern .= $linux."</select>";
$modern .= "</div><div class='border' id='vdist'>";
$modern .= "<label>"._("Version of distro")."</label><br>";
$modern .= "<select id='distver' disabled='disabled'><option></option>";
$modern .= "</select></div>";
$modern .= "<pre id='reps'></pre>";
$modern .= "<pre id='replist'></pre>";
$modern .= "<p id='getfile'></p>";

$smarty->assign('feedaddr',$_SERVER["HTTP_HOST"].dirname($_SERVER["PHP_SELF"]));
$smarty->assign('modern',$modern);
$smarty->assign('scripts',$scripts);
$smarty->assign('antversion',$core->getSetting('version',$db));
$smarty->assign('title',$core->getSetting('codename',$db));
$smarty->assign('interface'," &bull; <a href='./changelog.php'>"._("Changes")."</a> &bull; ".$core->getInterfacesList($_SERVER["REQUEST_URI"],$db));
$smarty->assign('style',$core->getCSSList($db));
$smarty->assign('theme',$theme->getThemeName($core,$db));

$smarty->display('modern.tpl');

?>