#!/usr/bin/env python
# -*- coding: UTF-8 -*-



##################################################
## DEPENDENCIES
import sys
import os
import os.path
from os.path import getmtime, exists
import time
import types
import __builtin__
from Cheetah.Version import MinCompatibleVersion as RequiredCheetahVersion
from Cheetah.Version import MinCompatibleVersionTuple as RequiredCheetahVersionTuple
from Cheetah.Template import Template
from Cheetah.DummyTransaction import DummyTransaction
from Cheetah.NameMapper import NotFound, valueForName, valueFromSearchList, valueFromFrameOrSearchList
from Cheetah.CacheRegion import CacheRegion
import Cheetah.Filters as Filters
import Cheetah.ErrorCatchers as ErrorCatchers

##################################################
## MODULE CONSTANTS
try:
    True, False
except NameError:
    True, False = (1==1), (1==0)
VFFSL=valueFromFrameOrSearchList
VFSL=valueFromSearchList
VFN=valueForName
currentTime=time.time
__CHEETAH_version__ = '2.0.1'
__CHEETAH_versionTuple__ = (2, 0, 1, 'final', 0)
__CHEETAH_genTime__ = 1225031610.0116551
__CHEETAH_genTimestamp__ = 'Sun Oct 26 14:33:30 2008'
__CHEETAH_src__ = 'ChangeLinkTemplate.tmpl'
__CHEETAH_srcLastModified__ = 'Fri Jan 19 14:16:23 2007'
__CHEETAH_docstring__ = 'Autogenerated by CHEETAH: The Python-Powered Template Engine'

if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
    raise AssertionError(
      'This template was compiled with Cheetah version'
      ' %s. Templates compiled before version %s must be recompiled.'%(
         __CHEETAH_version__, RequiredCheetahVersion))

##################################################
## CLASSES

class ChangeLinkTemplate(Template):

    ##################################################
    ## CHEETAH GENERATED METHODS


    def __init__(self, *args, **KWs):

        Template.__init__(self, *args, **KWs)
        if not self._CHEETAH__instanceInitialized:
            cheetahKWArgs = {}
            allowedKWs = 'searchList namespaces filter filtersLib errorCatcher'.split()
            for k,v in KWs.items():
                if k in allowedKWs: cheetahKWArgs[k] = v
            self._initCheetahInstance(**cheetahKWArgs)
        

    def respond(self, trans=None):



        ## CHEETAH: main method generated for this template
        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
            trans = self.transaction # is None unless self.awake() was called
        if not trans:
            trans = DummyTransaction()
            _dummyTrans = True
        else: _dummyTrans = False
        write = trans.response().write
        SL = self._CHEETAH__searchList
        _filter = self._CHEETAH__currentFilter
        
        ########################################
        ## START - generated method body
        
        #  $Id: ChangeLinkTemplate.tmpl 3809 2007-01-19 14:16:23Z jodal $
        # 
        #  Copyright 2003 Norwegian University of Science and Technology
        # 
        #  This file is part of Network Administration Visualized (NAV)
        # 
        #  NAV is free software; you can redistribute it and/or modify
        #  it under the terms of the GNU General Public License as published by
        #  the Free Software Foundation; either version 2 of the License, or
        #  (at your option) any later version.
        # 
        #  NAV 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 General Public License for more details.
        # 
        #  You should have received a copy of the GNU General Public License
        #  along with NAV; if not, write to the Free Software
        #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
        # 
        # 
        #  Authors: Magnar Sveen <magnars@stud.ntnu.no>
        # 
        write('''
<html>
  <head>
    <style type="text/css">

      BODY { 
        font-family: verdana, arial, helvetica, sans-serif; 
        background-color: white; 
      }

      table.header-active { 
        font-size: 15px;
        border: 1px solid #666;
        background-color: #ccf;
        background-image: url(\'/images/form/fill-active.gif\');
        p: 5px
      }

      td.header-active {
        border: 1px solid #69c;
        text-align: center;
      }

      table.options {
        font-size: 13px;
        border: 1px solid #666;
        background-color: #fff;
      }

      table.header-inactive {
        font-size: 15px;
        border: 1px solid #666;
        background-color: #eee;
        background-image: url(\'/images/form/fill-inactive.gif\');
      }

      td.header-inactive {
        border: 1px solid #bcd;
        text-align: center;
      }

      tr.inactive { background-color: #fff; }
      td.inactive { border: 1px solid #ccc; text-align: center }

    </style>

    <script language="JavaScript" type="text/javascript">
    <!-- BEGIN

      function testURL() {
        var url=document.getElementById("url").value;
        var popup = window.open(url,"","width=400,height=500,toolbar,location,directories,status,scrollbars,menubar,resizable,");
        if (!popup.focus) {
          alert("This function does not work with popups disabled.");
        }
      }

    // END -->
    </script>
  </head>
  <body>

    <div style="position: absolute; width=300; left: 50%; top: 20%; margin: 0px 0px 0px -150px;">
''')
        if VFFSL(SL,"link",True): # generated from line 89, col 1
            write('''      <form method="post" action="updatelink">
''')
        else: # generated from line 91, col 1
            write('''      <form method="post" action="savenewlink">
''')
        write('''      <table width="300" cellspacing="5" cellpadding="0" border="0">
        <tr>
          <td>
            <table width="100%" height="50" cellspacing="5" cellpadding="5" border="0" class="header-active">
              <tr>
                <td nowrap class="header-active">
''')
        if VFFSL(SL,"link",True): # generated from line 100, col 1
            write('''                  Edit ''')
            _v = VFFSL(SL,"type",True) # '$type' on line 101, col 24
            if _v is not None: write(_filter(_v, rawExpr='$type')) # from line 101, col 24.
            write(''' link
''')
        else: # generated from line 102, col 1
            write('''                  Add ''')
            _v = VFFSL(SL,"type",True) # '$type' on line 103, col 23
            if _v is not None: write(_filter(_v, rawExpr='$type')) # from line 103, col 23.
            write(''' link
''')
        write('''                </td>
              </tr>
            </table>
          </td>
        </tr>
        <tr>
          <td>
            <table width="100%" height="50" cellspacing="5" cellpadding="5" border="0" class="options">
              <tr class="inactive">
                <td nowrap class="inactive" width="30%">
                  Name
                </td>
                <td nowrap class="inactive" width="70%">
''')
        if VFFSL(SL,"link",True): # generated from line 118, col 1
            write('''                  <input name="name" type="text" style="width: 90%; border: 1px solid #999;" value="''')
            _v = VFFSL(SL,"link.name",True) # '$link.name' on line 119, col 101
            if _v is not None: write(_filter(_v, rawExpr='$link.name')) # from line 119, col 101.
            write('''">
''')
        else: # generated from line 120, col 1
            write('''                  <input name="name" type="text" style="width: 90%; border: 1px solid #999;">
''')
        write('''                </td>
              </tr>
              <tr class="inactive">
                <td nowrap class="inactive" width="30%">
                  URL
                </td>
                <td nowrap class="inactive" width="70%">
''')
        if VFFSL(SL,"link",True): # generated from line 130, col 1
            write('''                  <input name="url" id="url" value="''')
            _v = VFFSL(SL,"link.uri",True) # '$link.uri' on line 131, col 53
            if _v is not None: write(_filter(_v, rawExpr='$link.uri')) # from line 131, col 53.
            write('''" type=text style="width: 90%; border: 1px solid #999;">
''')
        else : # generated from line 132, col 1
            write('''                  <input name="url" id="url" value="http://" type=text style="width: 90%; border: 1px solid #999;">
''')
        write('''                </td>
              </tr>
''')
        if not VFFSL(SL,"link",True): # generated from line 137, col 1
            write('''              <tr class="inactive">
                <td nowrap class="inactive" width="30%">
                  Use in
                </td>
                <td nowrap class="inactive" width="70%">
                  <select name="usein" style="width: 90%;">
                    <option>None</a>
                    <option value="navbar">Navbar</a>
                    <option value="qlink1">Quicklink #1</a>
                    <option value="qlink2">Quicklink #2</a>
\t          </select>
                </td>
              </tr>
''')
        write('''            </table>
          </td>
        </tr>
        <tr>
          <td>

            <table width="100%" height="50" cellspacing="5" cellpadding="5" border="0" class="header-inactive">
              <tr>
                <td nowrap class="header-inactive">
                  <input type="button" value="Cancel" onclick="top.location=\'javascript:history.back(1)\'">
                </td>
                <td nowrap class="header-inactive">
                  <input type="button" value="Test URL" onClick="testURL();">
                </td>
                <td nowrap class="header-inactive">
''')
        if VFFSL(SL,"link",True): # generated from line 167, col 1
            write('''                  <input type="hidden" name="id" value="''')
            _v = VFFSL(SL,"link.id",True) # '$link.id' on line 168, col 57
            if _v is not None: write(_filter(_v, rawExpr='$link.id')) # from line 168, col 57.
            write('''">
                  <input type="submit" value=" Save ">
''')
        else: # generated from line 170, col 1
            write('''                  <input type="submit" value=" Add ">
''')
        write('''                </td>
              </tr>
            </table>
            
          </td>
        </tr>
      </table>
      </form>
    </div>

  </body>
</html>
''')
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        
    ##################################################
    ## CHEETAH GENERATED ATTRIBUTES


    _CHEETAH__instanceInitialized = False

    _CHEETAH_version = __CHEETAH_version__

    _CHEETAH_versionTuple = __CHEETAH_versionTuple__

    _CHEETAH_genTime = __CHEETAH_genTime__

    _CHEETAH_genTimestamp = __CHEETAH_genTimestamp__

    _CHEETAH_src = __CHEETAH_src__

    _CHEETAH_srcLastModified = __CHEETAH_srcLastModified__

    type = "personal"

    _mainCheetahMethod_for_ChangeLinkTemplate= 'respond'

## END CLASS DEFINITION

if not hasattr(ChangeLinkTemplate, '_initCheetahAttributes'):
    templateAPIClass = getattr(ChangeLinkTemplate, '_CHEETAH_templateClass', Template)
    templateAPIClass._addCheetahPlumbingCodeToClass(ChangeLinkTemplate)


# CHEETAH was developed by Tavis Rudd and Mike Orr
# with code, advice and input from many other volunteers.
# For more information visit http://www.CheetahTemplate.org/

##################################################
## if run from command line:
if __name__ == '__main__':
    from Cheetah.TemplateCmdLineIface import CmdLineIface
    CmdLineIface(templateObj=ChangeLinkTemplate()).run()


