inst-resources/applist.nsh
author Dan Fuhry <dan@enanocms.org>
Sat, 21 Aug 2010 18:19:58 -0400
changeset 10 014d58335b6d
parent 0 67e1cc6cd929
permissions -rw-r--r--
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
     1
/**
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
     2
 * Inserts an HTML file at the necessary point in applications.html.
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
     3
 * @param string HTML file
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
     4
 */
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
     5
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
     6
Function BNRegisterApplicationToList
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
     7
  ClearErrors
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
     8
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
     9
  ; Make sure it's not already in there
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    10
  FileOpen $0 "$stack_instdir\apache2\htdocs\applications.html" "r"
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    11
  IfErrors 0 +3
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    12
    SetErrors
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    13
    Return
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    14
    
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    15
  loop:
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    16
    FileRead $0 $1
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    17
    IfErrors EOF
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    18
    Push $1
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    19
    Push "Module ${PRODUCT_SHORTNAME}"
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    20
    Call StrStr
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    21
    Pop $1
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    22
    StrCmp $1 "" +3
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    23
      ; found it, skip write
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    24
      FileClose $0
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    25
      Return
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    26
    Goto loop
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    27
  EOF:
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    28
  FileClose $0
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    29
  
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    30
  Pop $0
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    31
  Push "$stack_instdir\apache2\htdocs\applications.html"
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    32
  Push $0
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    33
  Push "<!-- @@BITNAMI_MODULE_PLACEHOLDER@@ -->"
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    34
  Call AppendBeforeSubstring
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    35
FunctionEnd
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    36
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    37
Function AppendBeforeSubstring
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    38
  Pop $R2 ; marker
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    39
  Pop $R1 ; file to insert
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    40
  Pop $R0 ; file to modify
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    41
  
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    42
  StrCpy $R7 0 ; $R7 = current offset
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    43
  
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    44
  ClearErrors
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    45
  FileOpen $R3 $R0 "a" ; $R3 = handle
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    46
  FileSeek $R3 0
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    47
  IfErrors 0 +3
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    48
    SetErrors
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    49
    Return
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    50
    
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    51
  loop:
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    52
    FileRead $R3 $R4 ${NSIS_MAX_STRLEN} ; $R4 = line
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    53
    IfErrors 0 +3
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    54
      DetailPrint "EOF"
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    55
      Goto EOF
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    56
    StrLen $R8 $R4 ; $R8 = length of line
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    57
    IntOp $R7 $R7 + $R8
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    58
    
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    59
    Push $R4
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    60
    Push $R2
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    61
    Call StrStr
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    62
    Pop $R5 ; $R5 = substring test
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    63
    StrCmp $R5 "" /* no match */ loop
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    64
    
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    65
    ; got a match!
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    66
    StrLen $R6 $R5 ; Length of found substring
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    67
    ; rewind a little bit, to right before the substring
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    68
    IntOp $R8 $R7 - $R6
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    69
    FileSeek $R3 -$R6 CUR $R5
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    70
    
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    71
    ; store the rest of the file
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    72
    StrCpy $R9 ""
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    73
    remainderloop:
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    74
      ClearErrors
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    75
      FileRead $R3 $R7
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    76
      StrCpy $R9 "$R9$R7"
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    77
      IfErrors 0 remainderloop
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    78
    ; now jump back to our point
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    79
    FileSeek $R3 $R5
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    80
    
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    81
    ; Now, write it all in
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    82
    FileOpen $R4 $R1 "r"
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    83
    IfErrors 0 +3
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    84
      SetErrors
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    85
      Return
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    86
    loop2:
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    87
      FileRead $R4 $R5 ${NSIS_MAX_STRLEN}
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    88
      IfErrors EOF2
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    89
      FileWrite $R3 $R5
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    90
      Goto loop2
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    91
      EOF2:
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    92
        FileClose $R5
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    93
      
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    94
    FileWrite $R3 $R9
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    95
  EOF:
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    96
  FileClose $R3
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    97
FunctionEnd
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    98
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    99
Function enano_add_to_applist
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
   100
  StrCmp $PLUGINSDIR "" 0 +2
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
   101
    InitPluginsDir
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
   102
    
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
   103
  SetOutPath "$stack_instdir\apache2\htdocs\img"
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
   104
  File "gfx\enanocms-module.png"
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
   105
  SetOutPath "$PLUGINSDIR"
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
   106
  File "gfx\application.html"
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
   107
  Push "$PLUGINSDIR\application.html"
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
   108
  Call BNRegisterApplicationToList
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
   109
  IfErrors 0 +2
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
   110
    MessageBox MB_OK|MB_ICONEXCLAMATION "There was an error adding the application to the list."
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
   111
FunctionEnd
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
   112