Guest User

Untitled

a guest
Jan 19th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.07 KB | None | 0 0
  1. <?php session_start(); ?>
  2.  
  3. <?php $tmp_head = $tmp_body = $tmp_finish = $id = $title = $key = null; include_once 'template.php';  ?>
  4. <?php echo $tmp_head ?>
  5. <title></title>
  6. <?php echo $tmp_body ?>
  7.  
  8. <?php
  9.  
  10. if (isset ($_SESSION['id'])) {
  11.  
  12.     echo '<ul id="listaPodstron">', "\n";
  13.    
  14.     require_once('connect.php');
  15.     $pullContentList = "SELECT id, title FROM content";
  16.     $pullContentList2 = mysql_query($pullContentList) or die($error[23]);
  17.    
  18.     $num_rows = mysql_num_rows($pullContentList2);
  19.     if($num_rows !== 0) {
  20.  
  21.         while($row = mysql_fetch_assoc($pullContentList2)) {
  22.             $id[$row['id']] = $row['id'];
  23.             $title[$row['id']] = $row['title'];
  24.         }
  25.        
  26.         foreach($id as $key) {
  27.             echo '  <li><span class="istniejacyTitle" id="', $id[$key], '">', $title[$key], '</span> <span id="del_', $id[$key], '" onClick="usunTenArtykul(this.id);">DELETE</span></li>', "\n";
  28.         }
  29.        
  30.     }
  31.    
  32.     echo '  <li><a id="niekliknieteDodawanie" href="#">Dodaj nową podstronę</a></li>', "\n", '</ul>';
  33.  
  34. } else echo 'Najpierw <a href="index.php" title="">podaj swoje hasło</a>';
  35.  
  36. ?>
  37.  
  38. <script type="text/javascript">
  39.    
  40.     // zainiciuj
  41.     przyciskRozpoczynajacyEdycje();
  42.     przyciskPokazujacyInputBox();
  43.    
  44.     function usunTenArtykul(nierozbiteId) {
  45.         var el = nierozbiteId.substr(4);
  46.        
  47.         if ( el !== '' ) {
  48.            
  49.             var xmlhttp;
  50.            
  51.             if (window.XMLHttpRequest) {
  52.                 xmlhttp=new XMLHttpRequest();
  53.             } else {
  54.                 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  55.             }
  56.        
  57.             xmlhttp.onreadystatechange=function() {
  58.                 if (xmlhttp.readyState==4 && xmlhttp.status==200) {
  59.                     document.getElementById("del_"+el).outer = '';
  60.                     document.getElementById(el).outer = '';
  61.                 }
  62.             };
  63.    
  64.             xmlhttp.open("GET","process_article_delete_inSelection.php?&id=" + (el),true);
  65.             xmlhttp.send();    
  66.         }
  67.     }
  68.    
  69.     function przyciskRozpoczynajacyEdycje() { // function to prepare Event Linteners for clickable titles
  70.  
  71.         <?php foreach($id as $key) echo "var items = document.getElementById('", $id[$key], "'); items.addEventListener(\"click\", function () { rozpocznijEdycjePodstrony(this.id) });"; ?>
  72.  
  73.     }
  74.    
  75.     function przyciskPokazujacyInputBox() { // function to prepare Event Listeners for adding new title
  76.         document.getElementById('niekliknieteDodawanie').addEventListener("click", function () { narysuj_Input_Box() });
  77.     }
  78.    
  79.     function narysuj_Input_Box() { // function to add Input box to add new title
  80.         // narysuj Inputa
  81.         document.getElementById('niekliknieteDodawanie').outerHTML = '<li id="dodawarka"><input type="text" name="input_givenToAdd" id="input_givenToAdd" maxlength="64"><a id="kliknieteZapisywanie" href="#">Zapisz tę podstronę</a></li>';
  82.         // dodaj instrukcje dla narysowanego przycisku obok inputa
  83.         document.getElementById('kliknieteZapisywanie').addEventListener("click", function () { zapiszNowyTitle() });
  84.     }
  85.    
  86.     function zapiszNowyTitle() { // function to save given title
  87.         var el = document.getElementById('input_givenToAdd').value;
  88.        
  89.         if ( el !== '' ) {
  90.        
  91.             var xmlhttp;
  92.            
  93.             if (window.XMLHttpRequest) {
  94.                 xmlhttp=new XMLHttpRequest();
  95.             } else {
  96.                 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  97.             }
  98.        
  99.             xmlhttp.onreadystatechange=function() {
  100.                 if (xmlhttp.readyState==4 && xmlhttp.status==200) {
  101.                     document.getElementById('dodawarka').outerHTML = '<li><span class="istniejacyTitle">' + xmlhttp.responseText + '</span></li>' + "\r\n" + '<li><a id="niekliknieteDodawanie" href="#">Dodaj nową podstronę</a></li>' + "\r\n";
  102.                     przyciskPokazujacyInputBox();
  103.            
  104.                 }
  105.             };
  106.            
  107.             el = encodeURIComponent(el);
  108.             el = el.replace(/\#/g, '&#35;'); // replaces all '#'
  109.  
  110.             xmlhttp.open("GET","process_add_article.php?&title=" + (el),true);
  111.             xmlhttp.send();    
  112.  
  113.         } else {
  114.        
  115.             alert('Proszę podać nazwę nowej podstrony!');
  116.            
  117.         }
  118.     }
  119.    
  120.     function rozpocznijEdycjePodstrony(el) { // function to send edited map info to DB
  121.        
  122.         el = encodeURIComponent(el);
  123.         el = el.replace(/\#/g, '&#35;'); // replaces all '#'
  124.        
  125.         window.location.href = "process_article_selection.php?&id=" + (el);
  126.            
  127.     }
  128. </script>
  129. <div id="WYSWIG"></div>
  130. <?php echo $tmp_finish ?>
Add Comment
Please, Sign In to add comment