ActionApps PHP Cross Reference Groupware Applications

Source: /admin/se_views.php3 - 198 lines - 7136 bytes - Summary - Text - Print

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

title

Description

title

Description

title

Description

title

title

Body