Forum Webmastera, HTML, CSS, PHP, MySQL, Hosting, Domeny - Forum dla Webmasterów
Pytanie o rozwijana listę - Wersja do druku

+- Forum Webmastera, HTML, CSS, PHP, MySQL, Hosting, Domeny - Forum dla Webmasterów (https://www.webmastertalk.pl)
+-- Dział: Technologie internetowe - tworzenie stron WWW (https://www.webmastertalk.pl/forum-technologie-internetowe-tworzenie-stron-www)
+--- Dział: Początkujący webmaster (https://www.webmastertalk.pl/forum-poczatkujacy-webmaster)
+--- Wątek: Pytanie o rozwijana listę (/thread-pytanie-o-rozwijana-liste)



Pytanie o rozwijana listę - Lampek - 21-03-2012

Witam
Mam pytanko otóż mam skrypt który pobiera pliki z katalogu następnie wypisuje ich listę na stronę a obok każdego wypisanego pliku jest opcja edytuj. Po kliknięciu w opcje edytuj zawartość pliku jest przenoszony do edytora elrte. I teraz zamiast wyświetlać wszystko na raz chciał bym zrobić listy rozwijaną z której będzie się wybierać plik i będzie się klikać edytuj.
Poniżej zamieszczam kod jak to mam narazie zrobione ale proszę również o wyrozumiałość bo jestem naprawdę początkującym "programistą" Tongue

Kod PHP:
<?php
session_start
();
error_reporting(E_ALL^E_NOTICE);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Edycja</title>
<!-- jQuery and jQuery UI -->
        <script src="elrte/js/jquery-1.4.4.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="elrte/js/jquery-ui-1.8.7.custom.min.js" type="text/javascript" charset="utf-8"></script>
        <link rel="stylesheet" href="elrte/css/smoothness/jquery-ui-1.8.7.custom.css" type="text/css" media="screen" charset="utf-8">

        <!-- elRTE -->
        <script src="elrte/js/elrte.min.js" type="text/javascript" charset="utf-8"></script>
        <link rel="stylesheet" href="elrte/css/elrte.min.css" type="text/css" media="screen" charset="utf-8">

        <!-- elFinder -->
        <link rel="stylesheet" href="elrte/css/elfinder.css" type="text/css" media="screen" charset="utf-8" /> 
        <script src="elrte/js/elfinder.full.js"            type="text/javascript" charset="utf-8"></script> 
        <script src="elrte/js/i18n/elrte.pl.js" type="text/javascript" charset="utf-8"></script>
         <script src="elrte/js/i18n/elfinder.pl.js" type="text/javascript" charset="utf-8"></script>
        <!-- elRTE and elFinder translation messages -->
        <!--<script src="js/i18n/elrte.ru.js" type="text/javascript" charset="utf-8"></script>
        <script src="js/i18n/elfinder.ru.js" type="text/javascript" charset="utf-8"></script>-->
            
        <script type="text/javascript" charset="utf-8">
            // elRTE with elFinder on a textarea
            $().ready(function() {
                var opts = {
                    cssClass : 'el-rte',
                    lang     : 'pl',  // Set your language
                    allowSource : 1,
                    height   : 450,
                    toolbar  : 'maxi',   // 'tiny', 'compact', 'normal', 'complete', 'maxi', or 'custom' (see advanced documentation for 'custom')
                    cssfiles : ['elrte/css/elrte-inner.css'],
                    fmAllow  : 1,
                    fmOpen : function(callback) {
                        $('<div id="myelfinder" />').elfinder({
                            url : 'elrte/connectors/php/connector.php',
                            places : '',
                            lang : 'pl',    //Set your language
                            dialog : { width : 900, modal : true, title : 'Files' }, // Open in dialog window
                            closeOnEditorCallback : true, // Close after file select
                            editorCallback : callback     // Pass callback to file manager
                        })
                    }
                    
                }
                $('#editor').elrte(opts);
            // Text field with elFinder
                var opt = {
                    url : 'elrte/connectors/php/connector.php',
                    places : '',
                    lang : 'pl',
                    editorCallback : function(url) {document.getElementById('field').value=url;},        // The id of the field we want elfinder to return a value to.
                    closeOnEditorCallback : true,
                    docked : false,
                    dialog : { title : 'File Manager', height: 500 },
                }
                
                $('#open').click(function() {                    // The id of the button that opens elfinder
                    $('#finder').elfinder(opt)                    // The id of the div that elfinder will open in
                    $('#finder').elfinder($(this).attr('id'));    // It also has to be entered here.
                })
            // Second text field with elFinder
                var opt2 = {                                                                            //Must change variable name
                    url : 'elrte/connectors/php/connector.php',
                    places : '',
                    lang : 'pl',
                    editorCallback : function(url) {document.getElementById('field2').value=url;},        //Must change the text field id
                    closeOnEditorCallback : true,
                    docked : false,
                    dialog : { title : 'File Manager', height: 500 },
                }
                
                $('#open2').click(function() {                                                            //Must change the button id
                    $('#finder2').elfinder(opt2)                                                        //Must update the div id
                    $('#finder2').elfinder($(this).attr('id'));                                            //Must update the div id
                })
            })
        </script>
        
        <style type="text/css" media="screen">
            body { padding:20px;}
        </style>
</head>
<body>
<?php
echo get_magic_quotes_gpc();?>
<br />
<?php
require_once('wszystkie_f.php');
if(isset( 
$_SESSION["zalogowany"]) && $_SESSION["zalogowany"] == 'ok') {
//if (1) {
echo 'Edytuja zawartość strony!';?>
<br />
<?php
echo '<a href="logout.php">Wyloguj się</a>'?>
<br />
<?php
$edycja 
$_SERVER['DOCUMENT_ROOT'].'/included/'.sanitize($_GET['edycja'], true);
//echo $_SERVER['DOCUMENT_ROOT'].'/'.$edycja;
$katalog opendir("included/");
 while (
$plik strtolower(readdir($katalog))) {
  if (
$plik!="." && $plik!=".." && $plik!="panel.php"$lista[]=$plik;
 }
 
closedir($katalog);
 if (
count($lista)>0) {
  echo 
"Wybierz plik do edycj:";
  
sort($lista);
 }
  for (
$i=0;$i<count($lista);$i++) {
str_replace(".php"""$lista[$i]);
echo 
"<br />Edytuj plik <b>".str_replace(".php"""$lista[$i])."</b><a href=\"panel.php?edycja=$lista[$i]\"> - Edytuj plik</a>";
 }
  
// zmiana zawartosci pliku

$doedycji $_SERVER['DOCUMENT_ROOT'].'/included/'.sanitize($_POST['edycja'], true);
if (
$_POST['editor']!=NULL && file_exists($doedycji) && is_file($doedycji)) {
  
//$f = fopen($edycja,"w");
  //fputs($f, $_POST["editor1"]);
  //fclose($f);
  
file_put_contents($doedycji$_POST['editor']);
 }
  
// umieszczenie pliku w formularzu
 
if ($_GET['edycja']!=NULL && file_exists($edycja)) {
  echo 
"<p> </p>Edycja plik: <b>$edycja</b>";
  echo 
'<form action="panel.php" method="post"><input type="hidden" name="edycja" value="'.$_GET['edycja'].'" />'?>
  
  <textarea id="editor" name="editor">
  <?php

  
/*$plik = fopen($edycja, "r");

  if ($plik === false) {

    echo "Błąd otwarcia pliku";

  } else { 

    while (!feof($plik)) {

      $bufor = fgets($plik);

      echo "$bufor <br />";

    }

    fclose($plik);

  }*/
  
echo file_get_contents($edycja);

?>
  </textarea>

  <?php echo '<input type="submit" value="Zapisz" /></form>';
$editor_data $_POST'editor' ];
 }
}
else {
echo 
'Nie masz dostępu do tej strony najpierw się zaloguj:';
include(
'form.php');
}
?>
</body>
</html> 



RE: Pytanie o rozwijana listę - Marys - 24-03-2012

O takie coś chodzi -> http://www.kurshtml.edu.pl/html/lista_rozwijalna,formularze.html ?