source: branches/unified_backend/utils/lib/svn_commit_preproc.php @ 66

Last change on this file since 66 was 66, checked in by yermol, 15 years ago

test commit using front end script to make current version number appear
in the about box.

  • Property svn:executable set to *
File size: 3.1 KB
RevLine 
[66]1#!/usr/local/bin/php
2<?php
3
4/*
5# -----------------------------------------------------------------
6# Copyright (C) DTLink, LLC.
7# http://www.dtlink.com and http://www.formvista.com
8#
9# Use of this code is granted by the terms of the htmlArea License (based on
10# BSD license) please read license.txt in this package for details.
11#
12# All software distributed under the Licenses is provided strictly on
13# an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR
14# IMPLIED, AND DTLINK LLC HEREBY DISCLAIMS ALL SUCH
15# WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
16# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT,
17# OR NON-INFRINGEMENT.
18# ------------------------------------------------------------------
19*/
20
21/**
22*
23* Wrapper around "svn commit" to force popups/about.html to be updated.
24*
25* Subversion has no good way to pull the current HEAD version out of a
26* repository. This wrapper forces an update to popups/about.html which
27* will then get the current $Rev$ number.
28*
29* This code was originally part of the formVista business component
30* framework.
31*
32* @package xinha
33* @subpackage misc_utils
34* @author DTLink Software
35* @copyright Copyright 2005 (c), DTLink L.L.C.
36*/
37
38/**
39*
40*/
41
42// ----------------------------------------------------------------
43//
44//      Wrapper around svn_commit so we can get the build number.
45//
46// REVISION HISTORY:
47//
48// 2003-08-13 YmL:
49// . intial revision.
50//
51// 2005-04-12 YmL:
52//      .       repurposed and relicensed for use with Xinha.
53// ----------------------------------------------------------------
54// Increment commit number.
55//
56// Commit number is enclosed in [@@ .. @@] tags.
57
58function increment_commit_count( $inpath, $outpath )
59{
60
61// kludgey way of pulling in the source file.
62
63print( "Attempting to pull in '$inpath' to '$outpath'\n" );
64
65if (( $content_array = file($inpath)) == NULL )
66        {
67        print( "ERROR - unable open file '$inpath'\n" );
68        return( false );
69        }
70
71$content = implode("", $content_array);
72
73// find the number - a bit of a kludge. Couldn't get preg_replace to just
74// pull out the number from the file. Contrary to the docs it doesn't seem
75// to treat all lines as one lines regardless of the /m switch.
76
77$tmpArray = array();
78
79preg_match( "/.*\[@@(.*)@@\].*/", $content, $tmpArray );
80
81$commit_count = preg_replace( "/.*\[@@(.*)@@\].*/", "$1", $tmpArray[0] );
82
83// replace variable references
84
85$commit_count++;
86
87$replacement = "[@@" . $commit_count . "@@]";
88
89$content_replaced = preg_replace( "/\[@@(.*?)@@\]/" , $replacement, $content );
90
91// write the file out.
92
93if (( $outfile = fopen( $outpath, "w" )) == NULL )
94        {
95        print( "ERROR - unable to open '$outpath'\n" );
96        return( false );
97        }
98
99fwrite( $outfile, $content_replaced );
100
101fclose( $outfile );
102
103return( true );
104
105}       // end of increment_commit_count()
106
107// ---------------------------------------------------------------
108//                      TEMPLATE EXPANSION
109// ---------------------------------------------------------------
110
111// VERSION.php
112
113if ( increment_commit_count( realpath( "./popups/about.html" ),
114realpath( "./" ) . "/popups/about.html" ))
115   {
116   print( "popups/about.html updated.\n" );
117   }
118else
119   {
120   print( "popups/about.html NOT updated due to error\n" );
121   }
122
123// END
124
125?>
Note: See TracBrowser for help on using the repository browser.