[ PHPXref.com ] [ Generated: Sun Jul 20 16:25:17 2008 ] [ ActionApps 2.8.1b ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/admin/ -> se_views.php3 (source)

   1  <?php
   2  //$Id: se_views.php3,v 1.26 2005/04/24 22:55:06 honzam Exp $
   3  /*
   4  Copyright (C) 1999, 2000 Association for Progressive Communications
   5  http://www.apc.org/
   6  
   7      This program is free software; you can redistribute it and/or modify
   8      it under the terms of the GNU General Public License as published by
   9      the Free Software Foundation; either version 2 of the License, or
  10      (at your option) any later version.
  11  
  12      This program is distributed in the hope that it will be useful,
  13      but WITHOUT ANY WARRANTY; without even the implied warranty of
  14      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15      GNU General Public License for more details.
  16  
  17      You should have received a copy of the GNU General Public License
  18      along with this program (LICENSE); if not, write to the Free Software
  19      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  20  */
  21  
  22  // expected $view_id for editing specified view
  23  
  24  require_once  "../include/init_page.php3";
  25  require_once $GLOBALS['AA_INC_PATH']."formutil.php3";
  26  require_once $GLOBALS['AA_INC_PATH']."varset.php3";
  27  require_once $GLOBALS['AA_INC_PATH']."item.php3";     // GetAliasesFromField funct def
  28  require_once $GLOBALS['AA_INC_PATH']."pagecache.php3";
  29  require_once $GLOBALS['AA_INC_PATH']."msgpage.php3";
  30  
  31  if ($cancel)
  32    go_url( $sess->url(self_base() . "index.php3"));
  33  
  34  if (!IfSlPerm(PS_FULLTEXT)) {
  35    MsgPageMenu($sess->url(self_base())."index.php3", _m("You do not have permission to change views"), "admin");
  36    exit;
  37  }
  38  
  39  $err["Init"] = "";          // error array (Init - just for initializing variable
  40  $varset = new Cvarset();
  41  $p_slice_id = q_pack_id($slice_id);
  42  
  43  if ( $del ) {
  44    // check if deleted view is from this slice (for security)
  45    $SQL = "DELETE FROM view WHERE id='$vid' AND slice_id='$p_slice_id'";
  46    if (!$db->query($SQL)) {  // not necessary - we have set the halt_on_error
  47      $err["DB"] = MsgErr("Can't delete view");
  48      break;
  49    }
  50    $GLOBALS[pagecache]->invalidateFor("slice_id=$slice_id");  // invalidate old cached values
  51  
  52    $Msg = MsgOK(_m("View successfully deleted"));
  53  }
  54  
  55  function PrintViewRow($id, $name, $type) {
  56    global $sess;
  57    $VIEW_TYPES = getViewTypes();
  58    $name=safe($name); $id=safe($id);
  59  
  60    $edit_url = con_url($sess->url("./se_view.php3"), "view_id=$id&view_type=$type");
  61    $view_url = AA_INSTAL_URL. "view.php3?vid=$id&rXn=1";
  62  
  63    echo "<tr class=tabtxt>
  64            <td class=tabtxt><a href=\"$edit_url\">$id</a></td>
  65            <td class=tabtxt>". $VIEW_TYPES[$type]["name"] ."</td>
  66            <td class=tabtxt>$name</td>
  67            <td class=tabtxt><a href=\"$edit_url\">". _m("Edit") . "</a></td>
  68            <td class=tabtxt><a href=\"javascript:OpenWindowTop('$view_url')\" title=\"". _m('show this view') ."\">". _m("Show") . "</a></td>
  69            <td class=tabtxt><a href=\"javascript:DeleteView('$id')\">". _m("Delete") ."</a></td>
  70           </tr>";
  71  }
  72  
  73  // returns javascript row for view selection
  74  function GetViewJSArray( $sid, $id, $name, $type, $i ) {
  75    $id=safe($id);
  76    return "\n vs[$i]=\"x$sid\"; vv[$i]=\"$id\"; vn[$i]=\"".safe(substr($name,0,20))."\";";
  77  }
  78  
  79  HtmlPageBegin();   // Print HTML start page tags (html begin, encoding, style sheet, but no title)
  80  echo "<TITLE>". _m("Admin - design View") ."</TITLE>";
  81  FrmJavascriptFile('javascript/js_lib.js');
  82  $js = '
  83       function DeleteView(id) {
  84         if ( !confirm("'. _m("Are you sure you want to delete selected view?") .'"))
  85           return
  86         var url="'. $sess->url(con_url("./se_views.php3", "del=1")) .'"
  87         document.location=url + "&vid=" + escape(id);
  88       }
  89  
  90       function SelectViewSlice() {
  91         var i,j;
  92         var xsid=document.fvtype.view_slice.options[document.fvtype.view_slice.selectedIndex].value;
  93           // clear selectbox
  94         for ( i=(document.fvtype.view_view.options.length-1); i>=0; i--){
  95           document.fvtype.view_view.options[i] = null
  96         }
  97           // fill selectbox from the right slice
  98         j=0;
  99         for ( i=0; i<vs.length ; i++) {
 100           if ( vs[i] == xsid ) {
 101             document.fvtype.view_view.options[j++] = new Option(vv[i]+\' - \'+vn[i], vv[i])
 102           }
 103         }
 104       }
 105       ';
 106  
 107  FrmJavascript($js);
 108  echo "</HEAD>\n";
 109  
 110  $useOnLoad = ($new_compact ? true : false);
 111  require_once $GLOBALS['AA_INC_PATH']."menu.php3";
 112  showMenu($aamenus, "sliceadmin","views");
 113  
 114  echo "<H1><B>" . _m("Admin - design View") . "</B></H1>";
 115  PrintArray($err);
 116  echo $Msg;
 117  
 118  /*<table width="440" border="0" cellspacing="0" cellpadding="1" bgcolor="<?php echo COLOR_TABTITBG ?>" align="center">
 119  <tr><td class=tabtit><b>&nbsp;<?php echo _m("Defined Views")?></b><BR></td></tr>
 120  <tr>
 121  <form name="fvtype" method=post action="<?php echo $sess->url("./se_view.php3") ?>">
 122  <td>
 123  <table width="100%" border="0" cellspacing="0" cellpadding="4" bgcolor="<?php echo COLOR_TABBG ?>">*/
 124  
 125  echo '<form name="fvtype" method=post action="'. $sess->url("./se_view.php3"). '">';
 126  
 127  FrmTabCaption(_m("Defined Views"));
 128  
 129  // -- get all views --
 130  $SQL = "SELECT * FROM view ORDER BY id";
 131  $db->query($SQL);
 132  $i=0;
 133  while ( $db->next_record() ) {
 134    $view_sid = unpack_id128($db->f(slice_id));
 135    if ( $view_sid == $slice_id ) // list views for this slice
 136      PrintViewRow($db->f(id), $db->f(name), $db->f(type));
 137    if ($g_modules[$view_sid]) {  // if user has any permission for the view's slice
 138      $view_array .= GetViewJSArray( $view_sid, $db->f(id), $db->f(name), $db->f(type), $i++ );
 139      $sliceWview[$view_sid]=1;  // mark the slices, where is an view
 140    }
 141  }
 142  
 143    // row for new view creaded from view type selection
 144  echo "</td>
 145       </tr>";
 146      FrmTabseparator(_m("Create new view"));
 147  echo "
 148        <tr class=tabtxt>
 149          <td>"._m("by&nbsp;type:")."</td>
 150          <td align=right><select name='view_type'>";
 151  $VIEW_TYPES = getViewTypes();
 152  reset($VIEW_TYPES);
 153  while (list($k, $v) = each($VIEW_TYPES)) {
 154    echo "<option value='$k'> ". htmlspecialchars($v["name"]) ." </option>";
 155  }
 156  echo "</select></td>
 157          <td><input type=submit name=new value='". _m("New") ."'></td>
 158       </tr>";
 159  
 160    // row for new view creaded from template
 161  echo "<tr class=tabtxt>
 162          <td>"._m("by&nbsp;template:")."</td>
 163          <td align=right>
 164           <select name='view_slice' OnChange='SelectViewSlice()'>";
 165    // slice selection
 166  reset($g_modules);
 167  while (list($k, $v) = each($g_modules)) {
 168    if ( ($v['type'] != 'S') OR !$sliceWview[$k] )
 169      continue;                            // we can feed just between slices ('S')
 170    $selected = ( (string)$slice_id == (string)$k ) ? "selected" : "";
 171    echo "<option value='x$k' $selected>". safe($v['name']) ."</option>\n";
 172  }
 173  echo "   </select>&nbsp;<select name='view_view'>
 174            <option> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </option>
 175           </select>
 176           </td>
 177          <td><input type=submit name='new_templ' value='". _m("New") ."'></td>
 178       </tr>
 179      </table>
 180  </td>
 181     </form>
 182   </tr>
 183  </table><br>
 184  ";
 185  
 186  FrmJavascript("
 187    var vs, vv, vn;
 188    vs=new Array();
 189    vn=new Array();
 190    vv=new Array();
 191    $view_array
 192    SelectViewSlice();");
 193  
 194  
 195  $viewuri = ereg_replace("/admin/.*", "/view.php3", $PHP_SELF); //include help
 196  echo _m("<br>To include slice in your webpage type next line \n                         to your shtml code: ") ."<br><pre>&lt;!--#include virtual=&quot;" . $viewuri .
 197           '?vid=<i>ID</i>&quot;--&gt;</pre>';
 198  HtmlPageEnd();
 199  page_close();
 200  
 201  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]