PKG 文件夹提交到版本管理服务器上。
This commit is contained in:
parent
0b5ff56be0
commit
a1009f166c
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,970 @@
|
|||
#
|
||||
# Based upon the NCSA server configuration files originally by Rob McCool.
|
||||
#
|
||||
# This is the main Apache server configuration file. It contains the
|
||||
# configuration directives that give the server its instructions.
|
||||
# See <URL:http://httpd.apache.org/docs-2.0/> for detailed information about
|
||||
# the directives.
|
||||
#
|
||||
# Do NOT simply read the instructions in here without understanding
|
||||
# what they do. They're here only as hints or reminders. If you are unsure
|
||||
# consult the online docs. You have been warned.
|
||||
#
|
||||
# The configuration directives are grouped into three basic sections:
|
||||
# 1. Directives that control the operation of the Apache server process as a
|
||||
# whole (the 'global environment').
|
||||
# 2. Directives that define the parameters of the 'main' or 'default' server,
|
||||
# which responds to requests that aren't handled by a virtual host.
|
||||
# These directives also provide default values for the settings
|
||||
# of all virtual hosts.
|
||||
# 3. Settings for virtual hosts, which allow Web requests to be sent to
|
||||
# different IP addresses or hostnames and have them handled by the
|
||||
# same Apache server process.
|
||||
#
|
||||
# Configuration and logfile names: If the filenames you specify for many
|
||||
# of the server's control files begin with "/" (or "drive:/" for Win32), the
|
||||
# server will use that explicit path. If the filenames do *not* begin
|
||||
# with "/", the value of ServerRoot is prepended -- so "logs/foo.log"
|
||||
# with ServerRoot set to "C:/Program Files/Apache Group/Apache2" will be interpreted by the
|
||||
# server as "C:/Program Files/Apache Group/Apache2/logs/foo.log".
|
||||
#
|
||||
# NOTE: Where filenames are specified, you must use forward slashes
|
||||
# instead of backslashes (e.g., "c:/apache" instead of "c:\apache").
|
||||
# If a drive letter is omitted, the drive on which Apache.exe is located
|
||||
# will be used by default. It is recommended that you always supply
|
||||
# an explicit drive letter in absolute paths, however, to avoid
|
||||
# confusion.
|
||||
#
|
||||
|
||||
### Section 1: Global Environment
|
||||
#
|
||||
# The directives in this section affect the overall operation of Apache,
|
||||
# such as the number of concurrent requests it can handle or where it
|
||||
# can find its configuration files.
|
||||
#
|
||||
|
||||
#
|
||||
# ServerRoot: The top of the directory tree under which the server's
|
||||
# configuration, error, and log files are kept.
|
||||
#
|
||||
# NOTE! If you intend to place this on an NFS (or otherwise network)
|
||||
# mounted filesystem then please read the LockFile documentation (available
|
||||
# at <URL:http://httpd.apache.org/docs-2.0/mod/mpm_common.html#lockfile>);
|
||||
# you will save yourself a lot of trouble.
|
||||
#
|
||||
# Do NOT add a slash at the end of the directory path.
|
||||
#
|
||||
ServerRoot "VTIGER_HOME/apache"
|
||||
#reference http://www.faqs.org/docs/securing/chap29sec245.html
|
||||
MaxRequestsPerChild 100000
|
||||
|
||||
#
|
||||
# ScoreBoardFile: File used to store internal server process information.
|
||||
# If unspecified (the default), the scoreboard will be stored in an
|
||||
# anonymous shared memory segment, and will be unavailable to third-party
|
||||
# applications.
|
||||
# If specified, ensure that no two invocations of Apache share the same
|
||||
# scoreboard file. The scoreboard file MUST BE STORED ON A LOCAL DISK.
|
||||
#
|
||||
#ScoreBoardFile logs/apache_runtime_status
|
||||
|
||||
#
|
||||
# PidFile: The file in which the server should record its process
|
||||
# identification number when it starts.
|
||||
#
|
||||
PidFile logs/httpd.pid
|
||||
|
||||
#
|
||||
# Timeout: The number of seconds before receives and sends time out.
|
||||
#
|
||||
Timeout 300
|
||||
|
||||
#
|
||||
# KeepAlive: Whether or not to allow persistent connections (more than
|
||||
# one request per connection). Set to "Off" to deactivate.
|
||||
#
|
||||
KeepAlive On
|
||||
|
||||
#
|
||||
# MaxKeepAliveRequests: The maximum number of requests to allow
|
||||
# during a persistent connection. Set to 0 to allow an unlimited amount.
|
||||
# We recommend you leave this number high, for maximum performance.
|
||||
# referred http://www.ece.concordia.ca/~daniel/tips/apache_tuning.html
|
||||
MaxKeepAliveRequests 300
|
||||
#
|
||||
# KeepAliveTimeout: Number of seconds to wait for the next request from the
|
||||
# same client on the same connection.
|
||||
#
|
||||
KeepAliveTimeout 10
|
||||
|
||||
##
|
||||
## Server-Pool Size Regulation (MPM specific)
|
||||
##
|
||||
|
||||
# WinNT MPM
|
||||
# ThreadsPerChild: constant number of worker threads in the server process
|
||||
# MaxRequestsPerChild: maximum number of requests a server process serves
|
||||
<IfModule mpm_winnt.c>
|
||||
ThreadsPerChild 250
|
||||
MaxRequestsPerChild 100000
|
||||
</IfModule>
|
||||
|
||||
#
|
||||
# Listen: Allows you to bind Apache to specific IP addresses and/or
|
||||
# ports, instead of the default. See also the <VirtualHost>
|
||||
# directive.
|
||||
#
|
||||
# Change this to Listen on specific IP addresses as shown below to
|
||||
# prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
|
||||
#
|
||||
#Listen 12.34.56.78:80
|
||||
Listen WEBSERVER_PORT
|
||||
|
||||
#
|
||||
# Dynamic Shared Object (DSO) Support
|
||||
#
|
||||
# To be able to use the functionality of a module which was built as a DSO you
|
||||
# have to place corresponding `LoadModule' lines at this location so the
|
||||
# directives contained in it are actually available _before_ they are used.
|
||||
# Statically compiled modules (those listed by `httpd -l') do not need
|
||||
# to be loaded here.
|
||||
#
|
||||
# Example:
|
||||
# LoadModule foo_module modules/mod_foo.so
|
||||
#
|
||||
LoadModule access_module modules/mod_access.so
|
||||
LoadModule actions_module modules/mod_actions.so
|
||||
LoadModule alias_module modules/mod_alias.so
|
||||
#LoadModule asis_module modules/mod_asis.so
|
||||
#LoadModule auth_module modules/mod_auth.so
|
||||
#LoadModule auth_anon_module modules/mod_auth_anon.so
|
||||
#LoadModule auth_dbm_module modules/mod_auth_dbm.so
|
||||
#LoadModule auth_digest_module modules/mod_auth_digest.so
|
||||
LoadModule autoindex_module modules/mod_autoindex.so
|
||||
#LoadModule cern_meta_module modules/mod_cern_meta.so
|
||||
#LoadModule cgi_module modules/mod_cgi.so
|
||||
#LoadModule dav_module modules/mod_dav.so
|
||||
#LoadModule dav_fs_module modules/mod_dav_fs.so
|
||||
LoadModule dir_module modules/mod_dir.so
|
||||
#LoadModule env_module modules/mod_env.so
|
||||
#LoadModule expires_module modules/mod_expires.so
|
||||
#LoadModule file_cache_module modules/mod_file_cache.so
|
||||
#LoadModule headers_module modules/mod_headers.so
|
||||
#LoadModule imap_module modules/mod_imap.so
|
||||
#LoadModule include_module modules/mod_include.so
|
||||
#LoadModule info_module modules/mod_info.so
|
||||
#LoadModule isapi_module modules/mod_isapi.so
|
||||
LoadModule log_config_module modules/mod_log_config.so
|
||||
LoadModule mime_module modules/mod_mime.so
|
||||
#LoadModule mime_magic_module modules/mod_mime_magic.so
|
||||
#LoadModule proxy_module modules/mod_proxy.so
|
||||
#LoadModule proxy_connect_module modules/mod_proxy_connect.so
|
||||
#LoadModule proxy_http_module modules/mod_proxy_http.so
|
||||
#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
|
||||
LoadModule negotiation_module modules/mod_negotiation.so
|
||||
#LoadModule rewrite_module modules/mod_rewrite.so
|
||||
LoadModule setenvif_module modules/mod_setenvif.so
|
||||
#LoadModule speling_module modules/mod_speling.so
|
||||
#LoadModule status_module modules/mod_status.so
|
||||
#LoadModule unique_id_module modules/mod_unique_id.so
|
||||
LoadModule userdir_module modules/mod_userdir.so
|
||||
#LoadModule usertrack_module modules/mod_usertrack.so
|
||||
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
|
||||
#LoadModule ssl_module modules/mod_ssl.so
|
||||
LoadModule php5_module "VTIGER_HOME/php/php5apache2.dll"
|
||||
#
|
||||
# ExtendedStatus controls whether Apache will generate "full" status
|
||||
# information (ExtendedStatus On) or just basic information (ExtendedStatus
|
||||
# Off) when the "server-status" handler is called. The default is Off.
|
||||
#
|
||||
#ExtendedStatus On
|
||||
|
||||
### Section 2: 'Main' server configuration
|
||||
#
|
||||
# The directives in this section set up the values used by the 'main'
|
||||
# server, which responds to any requests that aren't handled by a
|
||||
# <VirtualHost> definition. These values also provide defaults for
|
||||
# any <VirtualHost> containers you may define later in the file.
|
||||
#
|
||||
# All of these directives may appear inside <VirtualHost> containers,
|
||||
# in which case these default settings will be overridden for the
|
||||
# virtual host being defined.
|
||||
#
|
||||
|
||||
#
|
||||
# ServerAdmin: Your address, where problems with the server should be
|
||||
# e-mailed. This address appears on some server-generated pages, such
|
||||
# as error documents. e.g. admin@your-domain.com
|
||||
#
|
||||
ServerAdmin admin@vtiger.com
|
||||
|
||||
#
|
||||
# ServerName gives the name and port that the server uses to identify itself.
|
||||
# This can often be determined automatically, but we recommend you specify
|
||||
# it explicitly to prevent problems during startup.
|
||||
#
|
||||
# If this is not set to valid DNS name for your host, server-generated
|
||||
# redirections will not work. See also the UseCanonicalName directive.
|
||||
#
|
||||
# If your host doesn't have a registered DNS name, enter its IP address here.
|
||||
# You will have to access it by its address anyway, and this will make
|
||||
# redirections work in a sensible way.
|
||||
#
|
||||
ServerName crm-test1.vtiger.com:80
|
||||
|
||||
#
|
||||
# UseCanonicalName: Determines how Apache constructs self-referencing
|
||||
# URLs and the SERVER_NAME and SERVER_PORT variables.
|
||||
# When set "Off", Apache will use the Hostname and Port supplied
|
||||
# by the client. When set "On", Apache will use the value of the
|
||||
# ServerName directive.
|
||||
#
|
||||
UseCanonicalName Off
|
||||
|
||||
#
|
||||
# DocumentRoot: The directory out of which you will serve your
|
||||
# documents. By default, all requests are taken from this directory, but
|
||||
# symbolic links and aliases may be used to point to other locations.
|
||||
#
|
||||
DocumentRoot "VTIGER_HOME/apache/htdocs/vtigerCRM"
|
||||
|
||||
#
|
||||
# Each directory to which Apache has access can be configured with respect
|
||||
# to which services and features are allowed and/or disabled in that
|
||||
# directory (and its subdirectories).
|
||||
#
|
||||
# First, we configure the "default" to be a very restrictive set of
|
||||
# features.
|
||||
#
|
||||
<Directory />
|
||||
Options FollowSymLinks
|
||||
AllowOverride None
|
||||
</Directory>
|
||||
|
||||
#
|
||||
# Note that from this point forward you must specifically allow
|
||||
# particular features to be enabled - so if something's not working as
|
||||
# you might expect, make sure that you have specifically enabled it
|
||||
# below.
|
||||
#
|
||||
|
||||
#
|
||||
# This should be changed to whatever you set DocumentRoot to.
|
||||
#
|
||||
<Directory "VTIGER_HOME/apache/htdocs/vtigerCRM">
|
||||
|
||||
#
|
||||
# Possible values for the Options directive are "None", "All",
|
||||
# or any combination of:
|
||||
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
|
||||
#
|
||||
# Note that "MultiViews" must be named *explicitly* --- "Options All"
|
||||
# doesn't give it to you.
|
||||
#
|
||||
# The Options directive is both complicated and important. Please see
|
||||
# http://httpd.apache.org/docs-2.0/mod/core.html#options
|
||||
# for more information.
|
||||
#
|
||||
Options Indexes FollowSymLinks
|
||||
|
||||
#
|
||||
# AllowOverride controls what directives may be placed in .htaccess files.
|
||||
# It can be "All", "None", or any combination of the keywords:
|
||||
# Options FileInfo AuthConfig Limit
|
||||
#
|
||||
AllowOverride All
|
||||
|
||||
#
|
||||
# Controls who can get stuff from this server.
|
||||
#
|
||||
Order allow,deny
|
||||
Allow from all
|
||||
|
||||
</Directory>
|
||||
|
||||
#
|
||||
# UserDir: The name of the directory that is appended onto a user's home
|
||||
# directory if a ~user request is received. Be especially careful to use
|
||||
# proper, forward slashes here. On Windows NT, "Personal/My Website"
|
||||
# is a more appropriate choice.
|
||||
#
|
||||
UserDir "My Documents/My Website"
|
||||
|
||||
#
|
||||
# Control access to UserDir directories. The following is an example
|
||||
# for a site where these directories are restricted to read-only.
|
||||
#
|
||||
# You must correct the path for the root to match your system's configured
|
||||
# user directory location, e.g. "C:/WinNT/profiles/*/My Documents/My Website"
|
||||
# or whichever, as appropriate.
|
||||
#
|
||||
#<Directory "C:/Documents and Settings/*/My Documents/My Website">
|
||||
# AllowOverride FileInfo AuthConfig Limit
|
||||
# Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
|
||||
# <Limit GET POST OPTIONS PROPFIND>
|
||||
# Order allow,deny
|
||||
# Allow from all
|
||||
# </Limit>
|
||||
# <LimitExcept GET POST OPTIONS PROPFIND>
|
||||
# Order deny,allow
|
||||
# Deny from all
|
||||
# </LimitExcept>
|
||||
#</Directory>
|
||||
|
||||
#
|
||||
# DirectoryIndex: sets the file that Apache will serve if a directory
|
||||
# is requested.
|
||||
#
|
||||
# The index.html.var file (a type-map) is used to deliver content-
|
||||
# negotiated documents. The MultiViews Option can be used for the
|
||||
# same purpose, but it is much slower.
|
||||
#
|
||||
DirectoryIndex index.html index.html.var index.php
|
||||
|
||||
#
|
||||
# AccessFileName: The name of the file to look for in each directory
|
||||
# for additional configuration directives. See also the AllowOverride
|
||||
# directive.
|
||||
#
|
||||
AccessFileName .htaccess
|
||||
|
||||
#
|
||||
# The following lines prevent .htaccess and .htpasswd files from being
|
||||
# viewed by Web clients.
|
||||
#
|
||||
<Files ~ "^\.ht">
|
||||
Order allow,deny
|
||||
Deny from all
|
||||
</Files>
|
||||
|
||||
#
|
||||
# TypesConfig describes where the mime.types file (or equivalent) is
|
||||
# to be found.
|
||||
#
|
||||
TypesConfig conf/mime.types
|
||||
|
||||
#
|
||||
# DefaultType is the default MIME type the server will use for a document
|
||||
# if it cannot otherwise determine one, such as from filename extensions.
|
||||
# If your server contains mostly text or HTML documents, "text/plain" is
|
||||
# a good value. If most of your content is binary, such as applications
|
||||
# or images, you may want to use "application/octet-stream" instead to
|
||||
# keep browsers from trying to display binary files as though they are
|
||||
# text.
|
||||
#
|
||||
DefaultType text/plain
|
||||
|
||||
#
|
||||
# The mod_mime_magic module allows the server to use various hints from the
|
||||
# contents of the file itself to determine its type. The MIMEMagicFile
|
||||
# directive tells the module where the hint definitions are located.
|
||||
#
|
||||
<IfModule mod_mime_magic.c>
|
||||
MIMEMagicFile conf/magic
|
||||
</IfModule>
|
||||
|
||||
#
|
||||
# HostnameLookups: Log the names of clients or just their IP addresses
|
||||
# e.g., www.apache.org (on) or 204.62.129.132 (off).
|
||||
# The default is off because it'd be overall better for the net if people
|
||||
# had to knowingly turn this feature on, since enabling it means that
|
||||
# each client request will result in AT LEAST one lookup request to the
|
||||
# nameserver.
|
||||
#
|
||||
HostnameLookups Off
|
||||
|
||||
#
|
||||
# EnableMMAP: Control whether memory-mapping is used to deliver
|
||||
# files (assuming that the underlying OS supports it).
|
||||
# The default is on; turn this off if you serve from NFS-mounted
|
||||
# filesystems. On some systems, turning it off (regardless of
|
||||
# filesystem) can improve performance; for details, please see
|
||||
# http://httpd.apache.org/docs-2.0/mod/core.html#enablemmap
|
||||
#
|
||||
#EnableMMAP off
|
||||
|
||||
#
|
||||
# EnableSendfile: Control whether the sendfile kernel support is
|
||||
# used to deliver files (assuming that the OS supports it).
|
||||
# The default is on; turn this off if you serve from NFS-mounted
|
||||
# filesystems. Please see
|
||||
# http://httpd.apache.org/docs-2.0/mod/core.html#enablesendfile
|
||||
#
|
||||
#EnableSendfile off
|
||||
|
||||
#
|
||||
# ErrorLog: The location of the error log file.
|
||||
# If you do not specify an ErrorLog directive within a <VirtualHost>
|
||||
# container, error messages relating to that virtual host will be
|
||||
# logged here. If you *do* define an error logfile for a <VirtualHost>
|
||||
# container, that host's errors will be logged there and not here.
|
||||
#
|
||||
ErrorLog logs/error.log
|
||||
|
||||
#
|
||||
# LogLevel: Control the number of messages logged to the error.log.
|
||||
# Possible values include: debug, info, notice, warn, error, crit,
|
||||
# alert, emerg.
|
||||
#
|
||||
LogLevel warn
|
||||
|
||||
#
|
||||
# The following directives define some format nicknames for use with
|
||||
# a CustomLog directive (see below).
|
||||
#
|
||||
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
|
||||
LogFormat "%h %l %u %t \"%r\" %>s %b" common
|
||||
LogFormat "%{Referer}i -> %U" referer
|
||||
LogFormat "%{User-agent}i" agent
|
||||
|
||||
# You need to enable mod_logio.c to use %I and %O
|
||||
#LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
|
||||
|
||||
#
|
||||
# The location and format of the access logfile (Common Logfile Format).
|
||||
# If you do not define any access logfiles within a <VirtualHost>
|
||||
# container, they will be logged here. Contrariwise, if you *do*
|
||||
# define per-<VirtualHost> access logfiles, transactions will be
|
||||
# logged therein and *not* in this file.
|
||||
#
|
||||
CustomLog logs/access.log common
|
||||
|
||||
#
|
||||
# If you would like to have agent and referer logfiles, uncomment the
|
||||
# following directives.
|
||||
#
|
||||
#CustomLog logs/referer.log referer
|
||||
#CustomLog logs/agent.log agent
|
||||
|
||||
#
|
||||
# If you prefer a single logfile with access, agent, and referer information
|
||||
# (Combined Logfile Format) you can use the following directive.
|
||||
#
|
||||
#CustomLog logs/access.log combined
|
||||
|
||||
#
|
||||
# ServerTokens
|
||||
# This directive configures what you return as the Server HTTP response
|
||||
# Header. The default is 'Full' which sends information about the OS-Type
|
||||
# and compiled in modules.
|
||||
# Set to one of: Full | OS | Minor | Minimal | Major | Prod
|
||||
# where Full conveys the most information, and Prod the least.
|
||||
#
|
||||
ServerTokens Full
|
||||
|
||||
#
|
||||
# Optionally add a line containing the server version and virtual host
|
||||
# name to server-generated pages (internal error documents, FTP directory
|
||||
# listings, mod_status and mod_info output etc., but not CGI generated
|
||||
# documents or custom error documents).
|
||||
# Set to "EMail" to also include a mailto: link to the ServerAdmin.
|
||||
# Set to one of: On | Off | EMail
|
||||
#
|
||||
ServerSignature On
|
||||
|
||||
#
|
||||
# Aliases: Add here as many aliases as you need (with no limit). The format is
|
||||
# Alias fakename realname
|
||||
#
|
||||
# Note that if you include a trailing / on fakename then the server will
|
||||
# require it to be present in the URL. So "/icons" isn't aliased in this
|
||||
# example, only "/icons/". If the fakename is slash-terminated, then the
|
||||
# realname must also be slash terminated, and if the fakename omits the
|
||||
# trailing slash, the realname must also omit it.
|
||||
#
|
||||
# We include the /icons/ alias for FancyIndexed directory listings. If you
|
||||
# do not use FancyIndexing, you may comment this out.
|
||||
#
|
||||
Alias /icons/ "VTIGER_HOME/apache/icons/"
|
||||
|
||||
<Directory "VTIGER_HOME/apache/icons">
|
||||
Options Indexes MultiViews
|
||||
AllowOverride None
|
||||
Order allow,deny
|
||||
Allow from all
|
||||
</Directory>
|
||||
|
||||
#
|
||||
# This should be changed to the ServerRoot/manual/. The alias provides
|
||||
# the manual, even if you choose to move your DocumentRoot. You may comment
|
||||
# this out if you do not care for the documentation.
|
||||
#
|
||||
AliasMatch ^/manual(?:/(?:de|en|es|fr|ja|ko|ru))?(/.*)?$ "VTIGER_HOME/apache/manual$1"
|
||||
|
||||
<Directory "VTIGER_HOME/apache/manual">
|
||||
Options Indexes
|
||||
AllowOverride None
|
||||
Order allow,deny
|
||||
Allow from all
|
||||
|
||||
<Files *.html>
|
||||
SetHandler type-map
|
||||
</Files>
|
||||
|
||||
SetEnvIf Request_URI ^/manual/(de|en|es|fr|ja|ko|ru)/ prefer-language=$1
|
||||
RedirectMatch 301 ^/manual(?:/(de|en|es|fr|ja|ko|ru)){2,}(/.*)?$ /manual/$1$2
|
||||
</Directory>
|
||||
|
||||
#
|
||||
# ScriptAlias: This controls which directories contain server scripts.
|
||||
# ScriptAliases are essentially the same as Aliases, except that
|
||||
# documents in the realname directory are treated as applications and
|
||||
# run by the server when requested rather than as documents sent to the client.
|
||||
# The same rules about trailing "/" apply to ScriptAlias directives as to
|
||||
# Alias.
|
||||
#
|
||||
ScriptAlias /cgi-bin/ "VTIGER_HOME/apache/cgi-bin/"
|
||||
ScriptAlias /php/ "VTIGER_HOME/php/"
|
||||
Action application/x-httpd-php "/php/php.exe"
|
||||
AddType application/x-httpd-php .php
|
||||
|
||||
|
||||
#
|
||||
# "C:/Program Files/Apache Group/Apache2/cgi-bin" should be changed to whatever your ScriptAliased
|
||||
# CGI directory exists, if you have that configured.
|
||||
#
|
||||
<Directory "VTIGER_HOME/apache/cgi-bin">
|
||||
AllowOverride None
|
||||
Options None
|
||||
Order allow,deny
|
||||
Allow from all
|
||||
</Directory>
|
||||
|
||||
#
|
||||
# Redirect allows you to tell clients about documents which used to exist in
|
||||
# your server's namespace, but do not anymore. This allows you to tell the
|
||||
# clients where to look for the relocated document.
|
||||
# Example:
|
||||
# Redirect permanent /foo http://www.example.com/bar
|
||||
|
||||
#
|
||||
# Directives controlling the display of server-generated directory listings.
|
||||
#
|
||||
|
||||
#
|
||||
# IndexOptions: Controls the appearance of server-generated directory
|
||||
# listings.
|
||||
#
|
||||
IndexOptions FancyIndexing VersionSort
|
||||
|
||||
#
|
||||
# AddIcon* directives tell the server which icon to show for different
|
||||
# files or filename extensions. These are only displayed for
|
||||
# FancyIndexed directories.
|
||||
#
|
||||
AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip
|
||||
|
||||
AddIconByType (TXT,/icons/text.gif) text/*
|
||||
AddIconByType (IMG,/icons/image2.gif) image/*
|
||||
AddIconByType (SND,/icons/sound2.gif) audio/*
|
||||
AddIconByType (VID,/icons/movie.gif) video/*
|
||||
|
||||
AddIcon /icons/binary.gif .bin .exe
|
||||
AddIcon /icons/binhex.gif .hqx
|
||||
AddIcon /icons/tar.gif .tar
|
||||
AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
|
||||
AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
|
||||
AddIcon /icons/a.gif .ps .ai .eps
|
||||
AddIcon /icons/layout.gif .html .shtml .htm .pdf
|
||||
AddIcon /icons/text.gif .txt
|
||||
AddIcon /icons/c.gif .c
|
||||
AddIcon /icons/p.gif .pl .py
|
||||
AddIcon /icons/f.gif .for
|
||||
AddIcon /icons/dvi.gif .dvi
|
||||
AddIcon /icons/uuencoded.gif .uu
|
||||
AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
|
||||
AddIcon /icons/tex.gif .tex
|
||||
AddIcon /icons/bomb.gif core
|
||||
|
||||
AddIcon /icons/back.gif ..
|
||||
AddIcon /icons/hand.right.gif README
|
||||
AddIcon /icons/folder.gif ^^DIRECTORY^^
|
||||
AddIcon /icons/blank.gif ^^BLANKICON^^
|
||||
|
||||
#
|
||||
# DefaultIcon is which icon to show for files which do not have an icon
|
||||
# explicitly set.
|
||||
#
|
||||
DefaultIcon /icons/unknown.gif
|
||||
|
||||
#
|
||||
# AddDescription allows you to place a short description after a file in
|
||||
# server-generated indexes. These are only displayed for FancyIndexed
|
||||
# directories.
|
||||
# Format: AddDescription "description" filename
|
||||
#
|
||||
#AddDescription "GZIP compressed document" .gz
|
||||
#AddDescription "tar archive" .tar
|
||||
#AddDescription "GZIP compressed tar archive" .tgz
|
||||
|
||||
#
|
||||
# ReadmeName is the name of the README file the server will look for by
|
||||
# default, and append to directory listings.
|
||||
#
|
||||
# HeaderName is the name of a file which should be prepended to
|
||||
# directory indexes.
|
||||
ReadmeName README.html
|
||||
HeaderName HEADER.html
|
||||
|
||||
#
|
||||
# IndexIgnore is a set of filenames which directory indexing should ignore
|
||||
# and not include in the listing. Shell-style wildcarding is permitted.
|
||||
#
|
||||
IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t
|
||||
|
||||
#
|
||||
# DefaultLanguage and AddLanguage allows you to specify the language of
|
||||
# a document. You can then use content negotiation to give a browser a
|
||||
# file in a language the user can understand.
|
||||
#
|
||||
# Specify a default language. This means that all data
|
||||
# going out without a specific language tag (see below) will
|
||||
# be marked with this one. You probably do NOT want to set
|
||||
# this unless you are sure it is correct for all cases.
|
||||
#
|
||||
# * It is generally better to not mark a page as
|
||||
# * being a certain language than marking it with the wrong
|
||||
# * language!
|
||||
#
|
||||
# DefaultLanguage nl
|
||||
#
|
||||
# Note 1: The suffix does not have to be the same as the language
|
||||
# keyword --- those with documents in Polish (whose net-standard
|
||||
# language code is pl) may wish to use "AddLanguage pl .po" to
|
||||
# avoid the ambiguity with the common suffix for perl scripts.
|
||||
#
|
||||
# Note 2: The example entries below illustrate that in some cases
|
||||
# the two character 'Language' abbreviation is not identical to
|
||||
# the two character 'Country' code for its country,
|
||||
# E.g. 'Danmark/dk' versus 'Danish/da'.
|
||||
#
|
||||
# Note 3: In the case of 'ltz' we violate the RFC by using a three char
|
||||
# specifier. There is 'work in progress' to fix this and get
|
||||
# the reference data for rfc1766 cleaned up.
|
||||
#
|
||||
# Catalan (ca) - Croatian (hr) - Czech (cs) - Danish (da) - Dutch (nl)
|
||||
# English (en) - Esperanto (eo) - Estonian (et) - French (fr) - German (de)
|
||||
# Greek-Modern (el) - Hebrew (he) - Italian (it) - Japanese (ja)
|
||||
# Korean (ko) - Luxembourgeois* (ltz) - Norwegian Nynorsk (nn)
|
||||
# Norwegian (no) - Polish (pl) - Portugese (pt)
|
||||
# Brazilian Portuguese (pt-BR) - Russian (ru) - Swedish (sv)
|
||||
# Simplified Chinese (zh-CN) - Spanish (es) - Traditional Chinese (zh-TW)
|
||||
#
|
||||
AddLanguage ca .ca
|
||||
AddLanguage cs .cz .cs
|
||||
AddLanguage da .dk
|
||||
AddLanguage de .de
|
||||
AddLanguage el .el
|
||||
AddLanguage en .en
|
||||
AddLanguage eo .eo
|
||||
AddLanguage es .es
|
||||
AddLanguage et .et
|
||||
AddLanguage fr .fr
|
||||
AddLanguage he .he
|
||||
AddLanguage hr .hr
|
||||
AddLanguage it .it
|
||||
AddLanguage ja .ja
|
||||
AddLanguage ko .ko
|
||||
AddLanguage ltz .ltz
|
||||
AddLanguage nl .nl
|
||||
AddLanguage nn .nn
|
||||
AddLanguage no .no
|
||||
AddLanguage pl .po
|
||||
AddLanguage pt .pt
|
||||
AddLanguage pt-BR .pt-br
|
||||
AddLanguage ru .ru
|
||||
AddLanguage sv .sv
|
||||
AddLanguage zh-CN .zh-cn
|
||||
AddLanguage zh-TW .zh-tw
|
||||
|
||||
#
|
||||
# LanguagePriority allows you to give precedence to some languages
|
||||
# in case of a tie during content negotiation.
|
||||
#
|
||||
# Just list the languages in decreasing order of preference. We have
|
||||
# more or less alphabetized them here. You probably want to change this.
|
||||
#
|
||||
LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW
|
||||
|
||||
#
|
||||
# ForceLanguagePriority allows you to serve a result page rather than
|
||||
# MULTIPLE CHOICES (Prefer) [in case of a tie] or NOT ACCEPTABLE (Fallback)
|
||||
# [in case no accepted languages matched the available variants]
|
||||
#
|
||||
ForceLanguagePriority Prefer Fallback
|
||||
|
||||
#
|
||||
# Specify a default charset for all pages sent out. This is
|
||||
# always a good idea and opens the door for future internationalisation
|
||||
# of your web site, should you ever want it. Specifying it as
|
||||
# a default does little harm; as the standard dictates that a page
|
||||
# is in iso-8859-1 (latin1) unless specified otherwise i.e. you
|
||||
# are merely stating the obvious. There are also some security
|
||||
# reasons in browsers, related to javascript and URL parsing
|
||||
# which encourage you to always set a default char set.
|
||||
#
|
||||
#AddDefaultCharset ISO-8859-1
|
||||
AddDefaultCharset UTF-8
|
||||
|
||||
#
|
||||
# Commonly used filename extensions to character sets. You probably
|
||||
# want to avoid clashes with the language extensions, unless you
|
||||
# are good at carefully testing your setup after each change.
|
||||
# See http://www.iana.org/assignments/character-sets for the
|
||||
# official list of charset names and their respective RFCs.
|
||||
#
|
||||
AddCharset ISO-8859-1 .iso8859-1 .latin1
|
||||
AddCharset ISO-8859-2 .iso8859-2 .latin2 .cen
|
||||
AddCharset ISO-8859-3 .iso8859-3 .latin3
|
||||
AddCharset ISO-8859-4 .iso8859-4 .latin4
|
||||
AddCharset ISO-8859-5 .iso8859-5 .latin5 .cyr .iso-ru
|
||||
AddCharset ISO-8859-6 .iso8859-6 .latin6 .arb
|
||||
AddCharset ISO-8859-7 .iso8859-7 .latin7 .grk
|
||||
AddCharset ISO-8859-8 .iso8859-8 .latin8 .heb
|
||||
AddCharset ISO-8859-9 .iso8859-9 .latin9 .trk
|
||||
AddCharset ISO-2022-JP .iso2022-jp .jis
|
||||
AddCharset ISO-2022-KR .iso2022-kr .kis
|
||||
AddCharset ISO-2022-CN .iso2022-cn .cis
|
||||
AddCharset Big5 .Big5 .big5
|
||||
# For russian, more than one charset is used (depends on client, mostly):
|
||||
AddCharset WINDOWS-1251 .cp-1251 .win-1251
|
||||
AddCharset CP866 .cp866
|
||||
AddCharset KOI8-r .koi8-r .koi8-ru
|
||||
AddCharset KOI8-ru .koi8-uk .ua
|
||||
AddCharset ISO-10646-UCS-2 .ucs2
|
||||
AddCharset ISO-10646-UCS-4 .ucs4
|
||||
AddCharset UTF-8 .utf8
|
||||
|
||||
# The set below does not map to a specific (iso) standard
|
||||
# but works on a fairly wide range of browsers. Note that
|
||||
# capitalization actually matters (it should not, but it
|
||||
# does for some browsers).
|
||||
#
|
||||
# See http://www.iana.org/assignments/character-sets
|
||||
# for a list of sorts. But browsers support few.
|
||||
#
|
||||
AddCharset GB2312 .gb2312 .gb
|
||||
AddCharset utf-7 .utf7
|
||||
AddCharset utf-8 .utf8
|
||||
AddCharset big5 .big5 .b5
|
||||
AddCharset EUC-TW .euc-tw
|
||||
AddCharset EUC-JP .euc-jp
|
||||
AddCharset EUC-KR .euc-kr
|
||||
AddCharset shift_jis .sjis
|
||||
|
||||
#
|
||||
# AddType allows you to add to or override the MIME configuration
|
||||
# file mime.types for specific file types.
|
||||
#
|
||||
#AddType application/x-tar .tgz
|
||||
#
|
||||
# AddEncoding allows you to have certain browsers (Mosaic/X 2.1+) uncompress
|
||||
# information on the fly. Note: Not all browsers support this.
|
||||
# Despite the name similarity, the following Add* directives have nothing
|
||||
# to do with the FancyIndexing customization directives above.
|
||||
#
|
||||
#AddEncoding x-compress .Z
|
||||
#AddEncoding x-gzip .gz .tgz
|
||||
#
|
||||
# If the AddEncoding directives above are commented-out, then you
|
||||
# probably should define those extensions to indicate media types:
|
||||
#
|
||||
AddType application/x-compress .Z
|
||||
AddType application/x-gzip .gz .tgz
|
||||
|
||||
#
|
||||
# AddHandler allows you to map certain file extensions to "handlers":
|
||||
# actions unrelated to filetype. These can be either built into the server
|
||||
# or added with the Action directive (see below)
|
||||
#
|
||||
# To use CGI scripts outside of ScriptAliased directories:
|
||||
# (You will also need to add "ExecCGI" to the "Options" directive.)
|
||||
#
|
||||
#AddHandler cgi-script .cgi
|
||||
|
||||
#
|
||||
# For files that include their own HTTP headers:
|
||||
#
|
||||
#AddHandler send-as-is asis
|
||||
|
||||
#
|
||||
# For server-parsed imagemap files:
|
||||
#
|
||||
#AddHandler imap-file map
|
||||
|
||||
#
|
||||
# For type maps (negotiated resources):
|
||||
# (This is enabled by default to allow the Apache "It Worked" page
|
||||
# to be distributed in multiple languages.)
|
||||
#
|
||||
AddHandler type-map var
|
||||
|
||||
#
|
||||
# Filters allow you to process content before it is sent to the client.
|
||||
#
|
||||
# To parse .shtml files for server-side includes (SSI):
|
||||
# (You will also need to add "Includes" to the "Options" directive.)
|
||||
#
|
||||
#AddType text/html .shtml
|
||||
#AddOutputFilter INCLUDES .shtml
|
||||
|
||||
#
|
||||
# Action lets you define media types that will execute a script whenever
|
||||
# a matching file is called. This eliminates the need for repeated URL
|
||||
# pathnames for oft-used CGI file processors.
|
||||
# Format: Action media/type /cgi-script/location
|
||||
# Format: Action handler-name /cgi-script/location
|
||||
#
|
||||
|
||||
#
|
||||
# Customizable error responses come in three flavors:
|
||||
# 1) plain text 2) local redirects 3) external redirects
|
||||
#
|
||||
# Some examples:
|
||||
#ErrorDocument 500 "The server made a boo boo."
|
||||
#ErrorDocument 404 /missing.html
|
||||
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
|
||||
#ErrorDocument 402 http://www.example.com/subscription_info.html
|
||||
#
|
||||
|
||||
#
|
||||
# Putting this all together, we can internationalize error responses.
|
||||
#
|
||||
# We use Alias to redirect any /error/HTTP_<error>.html.var response to
|
||||
# our collection of by-error message multi-language collections. We use
|
||||
# includes to substitute the appropriate text.
|
||||
#
|
||||
# You can modify the messages' appearance without changing any of the
|
||||
# default HTTP_<error>.html.var files by adding the line:
|
||||
#
|
||||
# Alias /error/include/ "/your/include/path/"
|
||||
#
|
||||
# which allows you to create your own set of files by starting with the
|
||||
# @exp_errordir@/include/ files and copying them to /your/include/path/,
|
||||
# even on a per-VirtualHost basis. The default include files will display
|
||||
# your Apache version number and your ServerAdmin email address regardless
|
||||
# of the setting of ServerSignature.
|
||||
#
|
||||
# The internationalized error documents require mod_alias, mod_include
|
||||
# and mod_negotiation. To activate them, uncomment the following 30 lines.
|
||||
|
||||
# Alias /error/ "@exp_errordir@/"
|
||||
#
|
||||
# <Directory "@exp_errordir@">
|
||||
# AllowOverride None
|
||||
# Options IncludesNoExec
|
||||
# AddOutputFilter Includes html
|
||||
# AddHandler type-map var
|
||||
# Order allow,deny
|
||||
# Allow from all
|
||||
# LanguagePriority en cs de es fr it nl sv pt-br ro
|
||||
# ForceLanguagePriority Prefer Fallback
|
||||
# </Directory>
|
||||
#
|
||||
# ErrorDocument 400 /error/HTTP_BAD_REQUEST.html.var
|
||||
# ErrorDocument 401 /error/HTTP_UNAUTHORIZED.html.var
|
||||
# ErrorDocument 403 /error/HTTP_FORBIDDEN.html.var
|
||||
# ErrorDocument 404 /error/HTTP_NOT_FOUND.html.var
|
||||
# ErrorDocument 405 /error/HTTP_METHOD_NOT_ALLOWED.html.var
|
||||
# ErrorDocument 408 /error/HTTP_REQUEST_TIME_OUT.html.var
|
||||
# ErrorDocument 410 /error/HTTP_GONE.html.var
|
||||
# ErrorDocument 411 /error/HTTP_LENGTH_REQUIRED.html.var
|
||||
# ErrorDocument 412 /error/HTTP_PRECONDITION_FAILED.html.var
|
||||
# ErrorDocument 413 /error/HTTP_REQUEST_ENTITY_TOO_LARGE.html.var
|
||||
# ErrorDocument 414 /error/HTTP_REQUEST_URI_TOO_LARGE.html.var
|
||||
# ErrorDocument 415 /error/HTTP_UNSUPPORTED_MEDIA_TYPE.html.var
|
||||
# ErrorDocument 500 /error/HTTP_INTERNAL_SERVER_ERROR.html.var
|
||||
# ErrorDocument 501 /error/HTTP_NOT_IMPLEMENTED.html.var
|
||||
# ErrorDocument 502 /error/HTTP_BAD_GATEWAY.html.var
|
||||
# ErrorDocument 503 /error/HTTP_SERVICE_UNAVAILABLE.html.var
|
||||
# ErrorDocument 506 /error/HTTP_VARIANT_ALSO_VARIES.html.var
|
||||
|
||||
|
||||
|
||||
#
|
||||
# The following directives modify normal HTTP response behavior to
|
||||
# handle known problems with browser implementations.
|
||||
#
|
||||
BrowserMatch "Mozilla/2" nokeepalive
|
||||
BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
|
||||
BrowserMatch "RealPlayer 4\.0" force-response-1.0
|
||||
BrowserMatch "Java/1\.0" force-response-1.0
|
||||
BrowserMatch "JDK/1\.0" force-response-1.0
|
||||
|
||||
#
|
||||
# The following directive disables redirects on non-GET requests for
|
||||
# a directory that does not include the trailing slash. This fixes a
|
||||
# problem with Microsoft WebFolders which does not appropriately handle
|
||||
# redirects for folders with DAV methods.
|
||||
# Same deal with Apple's DAV filesystem and Gnome VFS support for DAV.
|
||||
#
|
||||
BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
|
||||
BrowserMatch "^WebDrive" redirect-carefully
|
||||
BrowserMatch "^WebDAVFS/1.[012]" redirect-carefully
|
||||
BrowserMatch "^gnome-vfs" redirect-carefully
|
||||
|
||||
#
|
||||
# Allow server status reports generated by mod_status,
|
||||
# with the URL of http://servername/server-status
|
||||
# Change the ".vtiger.com" to match your domain to enable.
|
||||
#
|
||||
#<Location /server-status>
|
||||
# SetHandler server-status
|
||||
# Order deny,allow
|
||||
# Deny from all
|
||||
# Allow from .vtiger.com
|
||||
#</Location>
|
||||
|
||||
#
|
||||
# Allow remote server configuration reports, with the URL of
|
||||
# http://servername/server-info (requires that mod_info.c be loaded).
|
||||
# Change the ".vtiger.com" to match your domain to enable.
|
||||
#
|
||||
#<Location /server-info>
|
||||
# SetHandler server-info
|
||||
# Order deny,allow
|
||||
# Deny from all
|
||||
# Allow from .vtiger.com
|
||||
#</Location>
|
||||
|
||||
|
||||
#
|
||||
# Bring in additional module-specific configurations
|
||||
#
|
||||
<IfModule mod_ssl.c>
|
||||
Include conf/ssl.conf
|
||||
</IfModule>
|
||||
|
||||
|
||||
### Section 3: Virtual Hosts
|
||||
#
|
||||
# VirtualHost: If you want to maintain multiple domains/hostnames on your
|
||||
# machine you can setup VirtualHost containers for them. Most configurations
|
||||
# use only name-based virtual hosts so the server doesn't need to worry about
|
||||
# IP addresses. This is indicated by the asterisks in the directives below.
|
||||
#
|
||||
# Please see the documentation at
|
||||
# <URL:http://httpd.apache.org/docs-2.0/vhosts/>
|
||||
# for further details before you try to setup virtual hosts.
|
||||
#
|
||||
# You may use the command line option '-S' to verify your virtual host
|
||||
# configuration.
|
||||
|
||||
#
|
||||
# Use name-based virtual hosting.
|
||||
#
|
||||
#NameVirtualHost *:80
|
||||
|
||||
#
|
||||
# VirtualHost example:
|
||||
# Almost any Apache directive may go into a VirtualHost container.
|
||||
# The first VirtualHost section is used for requests without a known
|
||||
# server name.
|
||||
#
|
||||
#<VirtualHost *:80>
|
||||
# ServerAdmin webmaster@dummy-host.example.com
|
||||
# DocumentRoot /www/docs/dummy-host.example.com
|
||||
# ServerName dummy-host.example.com
|
||||
# ErrorLog logs/dummy-host.example.com-error_log
|
||||
# CustomLog logs/dummy-host.example.com-access_log common
|
||||
#</VirtualHost>
|
|
@ -0,0 +1,381 @@
|
|||
echo off
|
||||
set ins_dir4_0_1=%~1
|
||||
set BINDIR=%cd%
|
||||
set VTIGER_HOME=%cd%
|
||||
echo VTIGERHOME=%VTIGER_HOME%
|
||||
set version="4.0.1"
|
||||
|
||||
:getinstalldir
|
||||
if NOT "X%ins_dir4_0_1%" == "X" goto checkdir
|
||||
|
||||
echo "*******************"
|
||||
echo "*******************"
|
||||
echo
|
||||
echo
|
||||
|
||||
set /P diffmac1="Is the vtiger CRM 4.0.1 mysql db in the same machine as the vtigerCRM4_2GA mysql db installation? (Y/N): "
|
||||
echo
|
||||
echo
|
||||
if "%diffmac1%"=="Y" goto samemac
|
||||
if "%diffmac1%"=="y" goto samemac
|
||||
|
||||
set diffmac_uname=
|
||||
set diffmac_password=
|
||||
set diffmac_port=
|
||||
set diffmac_hostname=
|
||||
set /P diffmac_hostname=Enter the hostname of the machine hosting the vtiger CRM 4.0.1:
|
||||
set /P diffmac_uname=Enter the vtiger CRM 4.0.1 mysql db username:
|
||||
set /P diffmac_password=Enter the vtiger CRM 4.0.1 mysql db password:
|
||||
set /P diffmac_port=Enter the vtiger CRM 4.0.1 mysql db port:
|
||||
|
||||
set mysql_dir=%BINDIR%\..\mysql\bin
|
||||
echo mysql_dir is %mysql_dir%
|
||||
echo
|
||||
echo writing to the mysql_params.bat file
|
||||
echo set mysql_username=%diffmac_uname%> mysql_params.bat
|
||||
echo set mysql_password=%diffmac_password%>> mysql_params.bat
|
||||
echo set mysql_port=%diffmac_port%>> mysql_params.bat
|
||||
echo set mysql_hostname=%diffmac_hostname%>> mysql_params.bat
|
||||
echo set mysql_bundled=false>> mysql_params.bat
|
||||
echo set mysql_dir=%mysql_dir%>> mysql_params.bat
|
||||
echo
|
||||
rem set /P hi=bye
|
||||
echo set FOREIGN_KEY_CHECKS=0; > vtiger_4_2_dump.txt
|
||||
set mysql_dir_4_2=%BINDIR%\..\mysql\bin
|
||||
echo mysql_dir again is %mysql_dir_4_2%
|
||||
echo
|
||||
echo
|
||||
echo username is %diffmac_uname%
|
||||
echo password is %diffmac_password%
|
||||
echo port is %diffmac_port%
|
||||
echo hostname is %diffmac_hostname%
|
||||
|
||||
echo about to take the dump of the 4.0.1 db and put it to vtiger_4_2_dump.txt file
|
||||
echo
|
||||
echo
|
||||
"%mysql_dir_4_2%\mysqldump" --host=%diffmac_hostname% --user=%diffmac_uname% --password=%diffmac_password% --port=%diffmac_port% vtigercrm4_0_1 >> vtiger_4_2_dump.txt
|
||||
IF ERRORLEVEL 1 (
|
||||
echo "Unable to take the vtiger CRM %version% database backup. vtigercrm database may be corrupted"
|
||||
goto exitmigration
|
||||
)
|
||||
|
||||
echo 4.0.1 dump taken successfully !
|
||||
rem set /P hi=bye
|
||||
echo
|
||||
echo
|
||||
echo
|
||||
echo
|
||||
call mysql_params.bat
|
||||
echo present directory is %cd%
|
||||
echo about to print the data into the migrator_connection.php file
|
||||
rem set /P hi=bye
|
||||
echo
|
||||
echo ^<?php > ..\apache\htdocs\vtigerCRM\migrator_connection.php
|
||||
echo $mysql_host_name_old = '%diffmac_hostname%'; >> ..\apache\htdocs\vtigerCRM\migrator_connection.php
|
||||
echo $mysql_username_old = '%diffmac_uname%'; >> ..\apache\htdocs\vtigerCRM\migrator_connection.php
|
||||
echo $mysql_password_old = '%diffmac_password%'; >> ..\apache\htdocs\vtigerCRM\migrator_connection.php
|
||||
echo $mysql_port_old = '%diffmac_port%'; >> ..\apache\htdocs\vtigerCRM\migrator_connection.php
|
||||
echo ?^> >> ..\apache\htdocs\vtigerCRM\migrator_connection.php
|
||||
rem set /P hi=bye
|
||||
call :echodumpstatus4diffmac
|
||||
goto set4_2version
|
||||
|
||||
:samemac
|
||||
|
||||
echo
|
||||
echo
|
||||
echo
|
||||
set /p ins_dir4_0_1="Enter the vtiger CRM 4.0.1 installation bin directory (For example: C:\Program Files\vtigerCRM4_0_1\bin: "
|
||||
goto checkdir
|
||||
|
||||
:findstrdir
|
||||
echo "4.0.1 install dir is %ins_dir4_0_1%"
|
||||
echo %WINDIR%
|
||||
set FIND_STR="%WINDIR%\system32\findstr.exe"
|
||||
set SLEEP_STR="%WINDIR%\system32\ping.exe"
|
||||
goto readMySQLparams
|
||||
|
||||
:checkdir
|
||||
if NOT EXIST "%ins_dir4_0_1%\startvTiger.bat" (
|
||||
echo "Kindly specify a valid vtigerCRM 4.0.1 installation directory please"
|
||||
set ins_dir4_0_1=
|
||||
goto getinstalldir
|
||||
)
|
||||
goto findstrdir
|
||||
|
||||
:readMySQLparams
|
||||
echo in read mysqlparams as a result of invocation for 4.2
|
||||
echo present dir is %cd%
|
||||
echo
|
||||
echo
|
||||
rem set /P hi=bye
|
||||
echo Reading the vtiger CRM %version% MySQL Parameters
|
||||
if %version% == "4.0.1" (
|
||||
echo "Inside 4.0.1 loop"
|
||||
echo 'about to parse the startvTiger.bat of the 4.0.1 server and populate to mysql_params file
|
||||
%FIND_STR% /C:"set mysql_" "%ins_dir4_0_1%\startvTiger.bat" > mysql_params.bat
|
||||
)
|
||||
if %version% == "4.2" (
|
||||
echo "Inside 4.2 loop"
|
||||
echo 'about to parse the startvTiger.bat of the 4.2 server and populate to mysql_params file
|
||||
%FIND_STR% /C:"set mysql_" startvTiger.bat > mysql_params.bat
|
||||
)
|
||||
echo after writing to the mysql_params.bat file
|
||||
rem set /P hi=bye
|
||||
call mysql_params.bat
|
||||
|
||||
echo %mysql_username%
|
||||
echo %mysql_password%
|
||||
echo %mysql_port%
|
||||
echo %mysql_bundled%
|
||||
echo %mysql_dir%
|
||||
|
||||
|
||||
rem set /P hi=bye
|
||||
|
||||
|
||||
if %version% == "4.0.1" (
|
||||
set /p mysql_host_name_4_0_1="Specify the host name of the vtiger CRM 4.0.1 mysql server: "
|
||||
|
||||
echo ^<?php > ..\apache\htdocs\vtigerCRM\migrator_connection.php
|
||||
echo $mysql_host_name_old = '%mysql_host_name_4_0_1%'; >> ..\apache\htdocs\vtigerCRM\migrator_connection.php
|
||||
echo $mysql_username_old = '%mysql_username%'; >> ..\apache\htdocs\vtigerCRM\migrator_connection.php
|
||||
echo $mysql_password_old = '%mysql_password%'; >> ..\apache\htdocs\vtigerCRM\migrator_connection.php
|
||||
echo $mysql_port_old = '%mysql_port%'; >> ..\apache\htdocs\vtigerCRM\migrator_connection.php
|
||||
echo ?^> >> ..\apache\htdocs\vtigerCRM\migrator_connection.php
|
||||
|
||||
echo about to invoke isMySQLRunning
|
||||
goto isMySQLRunning
|
||||
)
|
||||
|
||||
goto isMySQLRunning
|
||||
|
||||
|
||||
:isMySQLRunning
|
||||
echo MYSQLDIR=%mysql_dir%
|
||||
echo "Checking whether the vtiger CRM %version% MySQL server is already running"
|
||||
echo
|
||||
"%mysql_dir%\bin\mysql" --port=%mysql_port% --user=%mysql_username% --password=%mysql_password% -e "show databases" > NUL
|
||||
IF ERRORLEVEL 1 goto startmysql
|
||||
ECHO "vtiger CRM %version% MySQL Server is already started and running"
|
||||
if %version% == "4.0.1" goto dump4_0_1mysql
|
||||
if %version% == "4.2" goto dumpin4_2mysql
|
||||
rem set /P hi=bye
|
||||
|
||||
:startmysql
|
||||
echo "Starting %version% vtiger MySQL on port specified by the user"
|
||||
echo
|
||||
cd /D %mysql_dir%
|
||||
start mysqld -b .. --datadir=../data --port=%mysql_port%
|
||||
%SLEEP_STR% -n 11 127.0.0.1>nul
|
||||
"%mysql_dir%\bin\mysql" --port=%mysql_port% --user=%mysql_username% --password=%mysql_password% -e "show databases" > NUL
|
||||
IF ERRORLEVEL 1 goto notstarted
|
||||
echo "Started vtiger CRM %version% MySQL on port specified by the user"
|
||||
echo
|
||||
cd /d %VTIGER_HOME%
|
||||
if %version% == "4.0.1" goto dump4_0_1mysql
|
||||
if %version% == "4.2" goto dumpin4_2mysql
|
||||
|
||||
:notstarted
|
||||
cd /d %VTIGER_HOME%
|
||||
echo
|
||||
echo
|
||||
ECHO "Unable to start the vtiger CRM %version% MySQL server at port %mysql_port%. Check if the port is free"
|
||||
echo ""
|
||||
echo
|
||||
echo
|
||||
echo
|
||||
echo
|
||||
set /p pt=Free the port and Press Any Key to Continue...
|
||||
goto startmysql
|
||||
|
||||
:dump4_0_1mysql
|
||||
echo in dump4_0_1mysql method
|
||||
echo
|
||||
echo
|
||||
echo set FOREIGN_KEY_CHECKS=0; > vtiger_4_2_dump.txt
|
||||
"%mysql_dir%\bin\mysqldump" --user=%mysql_username% --password=%mysql_password% --port=%mysql_port% vtigercrm4_0_1 >> vtiger_4_2_dump.txt
|
||||
IF ERRORLEVEL 1 (
|
||||
echo "Unable to take the vtiger CRM %version% database backup. vtigercrm database may be corrupted"
|
||||
goto exitmigration
|
||||
)
|
||||
echo "Data dump taken successfully in vtiger_4_2_dump.txt"
|
||||
|
||||
goto echodumpstatus4samemac
|
||||
|
||||
:echodumpstatus4samemac
|
||||
echo
|
||||
echo
|
||||
echo
|
||||
echo database being created for vtigercrm4_0_1_bkp
|
||||
echo
|
||||
echo
|
||||
"%mysql_dir%\bin\mysql" --user=%mysql_username% --password=%mysql_password% --port=%mysql_port% -e "create database vtigercrm_4_0_1_bkp"
|
||||
|
||||
"%mysql_dir%\bin\mysql" --user=%mysql_username% --password=%mysql_password% --port=%mysql_port% --force vtigercrm_4_0_1_bkp < vtiger_4_2_dump.txt
|
||||
rem set /P hi=bye
|
||||
echo 'about to start the input from the DataMigration.php file '
|
||||
echo
|
||||
echo
|
||||
..\php\php.exe -f ..\apache\htdocs\vtigerCRM\Migrate.php
|
||||
echo 'exporting the migrated data to the dump file migrated_vtiger_4_0_1_dump file'
|
||||
|
||||
echo set FOREIGN_KEY_CHECKS=0; > migrated_vtiger_4_0_1_dump.txt
|
||||
"%mysql_dir%\bin\mysqldump" --user=%mysql_username% --password=%mysql_password% --port=%mysql_port% vtigercrm_4_0_1_bkp >> migrated_vtiger_4_0_1_dump.txt
|
||||
|
||||
rem set /P hi=bye
|
||||
echo ' about to drop the vtigercrm_4_0_1_bkp database '
|
||||
"%mysql_dir%\bin\mysql" --user=%mysql_username% --password=%mysql_password% --port=%mysql_port% -e "drop database vtigercrm_4_0_1_bkp"
|
||||
rem set /P hi=bye
|
||||
goto stopMySQL
|
||||
|
||||
:stopMySQL
|
||||
if %mysql_bundled%==true (
|
||||
cd /D %mysql_dir%
|
||||
echo "Going to stop vtiger CRM %version% MySQL server"
|
||||
"%mysql_dir%\bin\mysqladmin" --port=%mysql_port% --user=%mysql_username% --password=%mysql_password% shutdown
|
||||
echo "vtiger CRM MySQL Sever is shut down"
|
||||
cd /d %VTIGER_HOME%
|
||||
%SLEEP_STR% -n 11 127.0.0.1>nul
|
||||
)
|
||||
goto set4_2version
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
:set4_2version
|
||||
set version="4.2"
|
||||
echo
|
||||
echo
|
||||
echo '######################## version set as 4.2 vtiger CRM ######################## '
|
||||
goto findstrdir
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
:dumpin4_2mysql
|
||||
echo 'about to drop 4_2 db'
|
||||
"%mysql_dir%\bin\mysql" --user=%mysql_username% --password=%mysql_password% --port=%mysql_port% -e "drop database vtigercrm4_2"
|
||||
echo 'about create if not exists drop 4_2 db'
|
||||
"%mysql_dir%\bin\mysql" --user=%mysql_username% --password=%mysql_password% --port=%mysql_port% -e "create database if not exists vtigercrm4_2"
|
||||
echo 'about to force-dump data to the 4_2 db from the migrated_vtiger_4_0_1_dump file into the vtigercrm4_2 db'
|
||||
echo
|
||||
echo
|
||||
"%mysql_dir%\bin\mysql" --user=%mysql_username% --password=%mysql_password% --port=%mysql_port% vtigercrm4_2 --force < migrated_vtiger_4_0_1_dump.txt 2> migrate_log.txt
|
||||
IF ERRORLEVEL 1 (
|
||||
echo "Unable to dump data into the vtiger CRM %version% database vtigercrm4_2. Check the migrate_log.txt in the %VTIGER_HOME% directory"
|
||||
goto exitmigration
|
||||
)
|
||||
echo "Data successfully migrated into vtiger CRM 4.2 database"
|
||||
echo
|
||||
echo
|
||||
rem set /P hi=bye
|
||||
goto end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
:exitmigration
|
||||
echo "Exiting Migration"
|
||||
goto end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
rem dump status for different machines
|
||||
|
||||
:echodumpstatus4diffmac
|
||||
echo
|
||||
echo mysql directory is %mysql_dir%
|
||||
"%mysql_dir%\mysql" --host=%diffmac_hostname% --user=%diffmac_uname% --password=%diffmac_password% --port=%diffmac_port% -e "create database vtigercrm_4_0_1_bkp"
|
||||
|
||||
echo created database vtigercrm_4_0_1_bkup
|
||||
|
||||
"%mysql_dir%\mysql" --host=%diffmac_hostname% --user=%diffmac_uname% --password=%diffmac_password% --port=%diffmac_port% --force vtigercrm_4_0_1_bkp < vtiger_4_2_dump.txt
|
||||
|
||||
echo dumped data from the file vtiger_4_2_dump.txt into the vtigercrm_4_0_1_bkp database
|
||||
|
||||
echo
|
||||
echo
|
||||
echo
|
||||
echo 'about to start altering the database to get in sync with the 4.2 structure using the input from DataMigration.php file '
|
||||
echo
|
||||
echo present working directory is %cd%
|
||||
echo
|
||||
echo
|
||||
..\php\php.exe -f ..\apache\htdocs\vtigerCRM\Migrate.php
|
||||
|
||||
echo set FOREIGN_KEY_CHECKS=0; > migrated_vtiger_4_0_1_dump.txt
|
||||
|
||||
"%mysql_dir%\mysqldump" --host=%diffmac_hostname% --user=%diffmac_uname% --password=%diffmac_password% --port=%diffmac_port% vtigercrm_4_0_1_bkp >> migrated_vtiger_4_0_1_dump.txt
|
||||
echo dumped the database to migrated_vtiger_4_0_1_dump.txt file
|
||||
|
||||
rem set /P hi=bye
|
||||
echo
|
||||
echo
|
||||
echo
|
||||
echo
|
||||
echo ' about to drop the vtigercrm_4_0_1_bkp database '
|
||||
"%mysql_dir%\mysql" --host=%diffmac_hostname% --user=%diffmac_uname% --password=%diffmac_password% --port=%diffmac_port% -e "drop database vtigercrm_4_0_1_bkp"
|
||||
|
||||
goto end
|
||||
|
||||
|
||||
:end
|
||||
del mysql_params.bat
|
||||
rem exit
|
|
@ -0,0 +1,467 @@
|
|||
#/bin/sh
|
||||
#*********************************************************************************
|
||||
# The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
# ("License"); You may not use this file except in compliance with the License
|
||||
# The Original Code is: vtiger CRM Open Source
|
||||
# The Initial Developer of the Original Code is vtiger.
|
||||
# Portions created by vtiger are Copyright (C) vtiger.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# ********************************************************************************
|
||||
setVariables()
|
||||
{
|
||||
wdir=`pwd`
|
||||
echo 'copying the migrator_backup_connection file to the migrator_connection file'
|
||||
cp -f ../apache/htdocs/vtigerCRM/migrator_backup_connection.php ../apache/htdocs/vtigerCRM/migrator_connection.php
|
||||
chmod 777 ../apache/htdocs/vtigerCRM/migrator_connection.php
|
||||
export diffmac=0
|
||||
}
|
||||
|
||||
checkInstallDir()
|
||||
{
|
||||
bindir=$1
|
||||
retval=1
|
||||
if [ -d ${bindir} ]
|
||||
then
|
||||
if [ -f ${bindir}/startvTiger.sh -a -f ${bindir}/stopvTiger.sh ]
|
||||
then
|
||||
retval=0
|
||||
else
|
||||
echo "No such file ${bindir}/startvtiger.sh ${bindir}/stopvtiger.sh."
|
||||
echo "Invalid vtiger 4.0.1 directory specified"
|
||||
fi
|
||||
else
|
||||
echo "No such Directory: $bindir"
|
||||
fi
|
||||
return ${retval}
|
||||
}
|
||||
|
||||
getvtiger4_0_1_installdir()
|
||||
{
|
||||
cancontinue=false
|
||||
|
||||
while [ $cancontinue != "true" ]
|
||||
do
|
||||
local flag=0
|
||||
while [ $flag -eq 0 ]
|
||||
do
|
||||
echo ""
|
||||
echo "Is 4.0.1 mysql installed in the same machine as 4.2 GA? (Y/N)"
|
||||
echo ""
|
||||
|
||||
read RESPONSE
|
||||
case $RESPONSE in
|
||||
[nN]|[nN][oO])
|
||||
echo "**********************"
|
||||
echo "**********************"
|
||||
echo "**********************"
|
||||
echo "Please ensure that the mysql server instance for 4.0.1 is running "
|
||||
echo "**********************"
|
||||
echo "**********************"
|
||||
echo "**********************"
|
||||
|
||||
while [ "$macname" = "" ]
|
||||
do
|
||||
echo "Please enter the machine name"
|
||||
read macname
|
||||
done
|
||||
|
||||
while [ "$macport" = "" ]
|
||||
do
|
||||
echo "Please enter the mysql Port Number"
|
||||
read macport
|
||||
done
|
||||
|
||||
while [ "${username}" = "" ]
|
||||
do
|
||||
echo "Please enter the mysql User Name"
|
||||
read username
|
||||
done
|
||||
|
||||
echo "Please enter the mysql Password"
|
||||
read passwd
|
||||
|
||||
while [ "${apache_port_4_2}" = "" ]
|
||||
do
|
||||
echo ''
|
||||
echo "Specify the apache port of the vtiger CRM 4.2"
|
||||
read apache_port_4_2
|
||||
done
|
||||
|
||||
getRemoteMySQLDump $macname $macport $username $passwd
|
||||
export diffmac=1
|
||||
flag=1
|
||||
cancontinue=true
|
||||
;;
|
||||
|
||||
[yY]|[yY][eE][sS])
|
||||
echo ""
|
||||
flag=1
|
||||
;;
|
||||
|
||||
*) echo "invalid option"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ ${diffmac} -eq 0 ]
|
||||
then
|
||||
res=0
|
||||
|
||||
while [ "$dir_4_0" = "" ] || [ $res != 0 ]
|
||||
do
|
||||
echo ""
|
||||
echo "Specify the absolute path of the bin directory of the vtiger CRM 4.0.1"
|
||||
echo "(For example /home/test/vtigerCRM4_0_1/bin):"
|
||||
read dir_4_0
|
||||
if [ "${dir_4_0}" = "" ]
|
||||
then
|
||||
echo "Kindly enter a valid value please!"
|
||||
fi
|
||||
|
||||
checkInstallDir ${dir_4_0}
|
||||
res=$?
|
||||
##res stores the result of the previous op
|
||||
cancontinue=true
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo 'The 4.0.1 vtiger CRM installation directory is' $dir_4_0
|
||||
}
|
||||
|
||||
getvtiger4_0_1_data()
|
||||
{
|
||||
scrfile=${dir_4_0}/startvTiger.sh
|
||||
|
||||
while [ "${mysql_host_name_4_0}" = "" ]
|
||||
do
|
||||
echo ""
|
||||
echo "Specify the host name of the vtiger CRM 4.0.1 mysql server"
|
||||
read mysql_host_name_4_0
|
||||
done
|
||||
|
||||
while [ "${apache_port_4_0_1}" = "" ]
|
||||
do
|
||||
echo ''
|
||||
echo "Specify the apache port of the vtiger CRM 4.2"
|
||||
read apache_port_4_0_1
|
||||
done
|
||||
|
||||
mysql_dir=`grep "mysql_dir=" ${scrfile} | cut -d "=" -f2 | cut -d "'" -f2`
|
||||
echo 'mysql dir is ' $mysql_dir
|
||||
|
||||
mysql_username=`grep "mysql_username=" ${scrfile} | cut -d "=" -f2 | cut -d "'" -f2`
|
||||
echo 'mysql username is ' $mysql_username
|
||||
|
||||
mysql_password=`grep "mysql_password=" ${scrfile} | cut -d "=" -f2 | cut -d "'" -f2`
|
||||
echo 'mysql password is ' $mysql_password
|
||||
|
||||
mysql_port=`grep "mysql_port=" ${scrfile} | cut -d "=" -f2 | cut -d "'" -f2`
|
||||
echo 'mysql port is ' $mysql_port
|
||||
|
||||
mysql_socket=`grep "mysql_socket=" ${scrfile} | cut -d "=" -f2 | cut -d "'" -f2`
|
||||
echo $mysql_socket
|
||||
|
||||
mysql_bundled=`grep "mysql_bundled=" ${scrfile} | cut -d "=" -f2 | cut -d "'" -f2`
|
||||
echo $mysql_bundled
|
||||
|
||||
pwd
|
||||
src_file_4_0_1=./startvTiger.sh
|
||||
mysql_dir_4_0_1=`grep "mysql_dir=" ${src_file_4_0_1} | cut -d "=" -f2 | cut -d "'" -f2`
|
||||
echo $mysql_dir_4_0_1
|
||||
|
||||
finAndReplace ../apache/htdocs/vtigerCRM/migrator_connection.php MYSQLHOSTNAME ${mysql_host_name_4_0}
|
||||
finAndReplace ../apache/htdocs/vtigerCRM/migrator_connection.php MYSQLUSERNAME ${mysql_username}
|
||||
finAndReplace ../apache/htdocs/vtigerCRM/migrator_connection.php MYSQLPASSWORD ${mysql_password}
|
||||
finAndReplace ../apache/htdocs/vtigerCRM/migrator_connection.php MYSQLPORT ${mysql_port}
|
||||
chmod 777 ../apache/htdocs/vtigerCRM/migrator_connection.php
|
||||
}
|
||||
|
||||
finAndReplace()
|
||||
{
|
||||
fileName=$1
|
||||
var=$2
|
||||
val=$3
|
||||
|
||||
tmpFile=${fileName}.$$
|
||||
sed -e "s@${var}@${val}@g" ${fileName} > ${tmpFile}
|
||||
mv -f ${tmpFile} ${fileName}
|
||||
|
||||
}
|
||||
|
||||
isvtiger_MySQL_Running()
|
||||
{
|
||||
version=$1
|
||||
retval=1
|
||||
echo "select 1" | ${mysql_dir}/bin/mysql --user=${mysql_username} --password=${mysql_password} --port=${mysql_port} --socket=${mysql_socket} > /dev/null
|
||||
|
||||
exit_status=$?
|
||||
|
||||
if [ $exit_status -eq 0 ]
|
||||
then
|
||||
echo " "
|
||||
echo "The vtiger CRM $version MySQL server is running"
|
||||
echo " "
|
||||
retval=0
|
||||
fi
|
||||
|
||||
return ${retval}
|
||||
}
|
||||
|
||||
checkInput()
|
||||
{
|
||||
checkcharlower=$1
|
||||
checkcharupper=$2
|
||||
correctkey=false
|
||||
|
||||
while [ "${correctkey}" != "true" ]
|
||||
do
|
||||
read char
|
||||
if [ "$char" != "${checkcharlower}" -a "$char" != "${checkcharupper}" ]
|
||||
then
|
||||
echo "Press ${checkcharlower} (or) ${checkcharupper}"
|
||||
else
|
||||
correctkey=true
|
||||
fi
|
||||
done
|
||||
|
||||
}
|
||||
promptAndCheckMySQL()
|
||||
{
|
||||
version=$1
|
||||
echo ""
|
||||
echo "**************************************************"
|
||||
echo "Mysql server in the directory $mysql_dir is not running at port $mysql_port."
|
||||
echo "Start the vtiger CRM $version mysql server and then Press C to contiunue"
|
||||
echo "**************************************************"
|
||||
echo ""
|
||||
checkInput "c" "C"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
getRemoteMySQLDump()
|
||||
{
|
||||
machine_name=$1
|
||||
m_port=$2
|
||||
m_uname=$3
|
||||
m_passwd=$4
|
||||
|
||||
echo ''
|
||||
echo ''
|
||||
echo '###########################################################'
|
||||
echo '###########################################################'
|
||||
echo 'replacing the values in the migrator_connection.php file '
|
||||
echo '###########################################################'
|
||||
echo '###########################################################'
|
||||
echo ''
|
||||
echo ''
|
||||
|
||||
finAndReplace ../apache/htdocs/vtigerCRM/migrator_connection.php MYSQLHOSTNAME ${machine_name}
|
||||
finAndReplace ../apache/htdocs/vtigerCRM/migrator_connection.php MYSQLUSERNAME ${m_uname}
|
||||
finAndReplace ../apache/htdocs/vtigerCRM/migrator_connection.php MYSQLPASSWORD ${m_passwd}
|
||||
finAndReplace ../apache/htdocs/vtigerCRM/migrator_connection.php MYSQLPORT ${m_port}
|
||||
chmod 777 ../apache/htdocs/vtigerCRM/migrator_connection.php
|
||||
|
||||
scrfile=./startvTiger.sh
|
||||
mysql_dir=`grep "mysql_dir=" ${scrfile} | cut -d "=" -f2 | cut -d "'" -f2`
|
||||
#take the dump of the 4.0.1 mysql
|
||||
echo 'set FOREIGN_KEY_CHECKS=0;' > vtiger4_0_1_dump.txt
|
||||
${mysql_dir}/bin/mysqldump -u $m_uname -h $machine_name --port=$m_port --password=$m_passwd vtigercrm4_0_1 >> vtiger4_0_1_dump.txt
|
||||
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
echo 'Data dump taken successfully in vtiger_4_0_1_dump.txt'
|
||||
else
|
||||
echo 'Unable to take the database dump. vtigercrm database may be corrupted'
|
||||
exit
|
||||
fi
|
||||
#this should be the 4.0.1 mysql, so create the bkup database in it
|
||||
${mysql_dir}/bin/mysql -h $machine_name --user=$m_uname --password=$m_passwd --port=$m_port -e "create database vtigercrm_4_0_1_bkp"
|
||||
#dump the 4.0.1 dump into the bkup database
|
||||
${mysql_dir}/bin/mysql -h $machine_name --user=$m_uname --password=$m_passwd --port=$m_port vtigercrm_4_0_1_bkp < vtiger4_0_1_dump.txt
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
wget http://localhost:${apache_port_4_2}/Migrate.php
|
||||
|
||||
echo 'set FOREIGN_KEY_CHECKS=0;' > migrated_vtiger_4_2_dump.txt
|
||||
|
||||
#dump the migrated bkup database to a file
|
||||
|
||||
echo 'about to take the dump of the bkup file and put into the migrated_dump.txt file'
|
||||
|
||||
${mysql_dir}/bin/mysqldump -h $machine_name --user=$m_uname --password=$m_passwd --port=$m_port vtigercrm_4_0_1_bkp >> migrated_vtiger_4_2_dump.txt
|
||||
|
||||
echo 'about to drop the database vtigercrm_4_0_1_bkp'
|
||||
|
||||
#${mysql_dir}/bin/mysql -h $machine_name --user=$m_uname --password=$m_passwd --port=$m_port -e "drop database vtigercrm_4_0_1_bkp"
|
||||
|
||||
}
|
||||
#end of getRemoteMySQLDump
|
||||
|
||||
|
||||
startMySQL()
|
||||
{
|
||||
version=$1
|
||||
if [ "$mysql_bundled" == "false" ]
|
||||
then
|
||||
mysql_running=false
|
||||
while [ "${mysql_running}" != "true" ]
|
||||
do
|
||||
promptAndCheckMySQL $version
|
||||
isvtiger_MySQL_Running $version
|
||||
if [ $? = 0 ]
|
||||
then
|
||||
mysql_running=true
|
||||
fi
|
||||
done
|
||||
else
|
||||
mysql_running=false
|
||||
while [ "${mysql_running}" != "true" ]
|
||||
do
|
||||
echo "vtiger CRM $version Mysql Server is not running."
|
||||
echo "Going to start the vtiger CRM $version mysql server at port $mysql_port"
|
||||
${mysql_dir}/bin/mysqld_safe --basedir=$mysql_dir --datadir=$mysql_dir/data --socket=$mysql_socket --tmpdir=$mysql_dir/tmp --user=root --port=$mysql_port --default-table-type=INNODB > /dev/null &
|
||||
sleep 8
|
||||
isvtiger_MySQL_Running $version
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo ""
|
||||
echo "*****************************************"
|
||||
echo "Unable to start vtiger CRM $version mysql server."
|
||||
echo "Check whether the port $mysql_port is free."
|
||||
echo "Free the port and press c to continue"
|
||||
echo "*****************************************"
|
||||
echo ""
|
||||
checkInput "c" "C"
|
||||
else
|
||||
mysql_running=true
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
getdump4_0_1_db()
|
||||
{
|
||||
echo "********************************************"
|
||||
echo "Taking the dump of vtiger CRM 4.0.1 database"
|
||||
echo "*******************************************"
|
||||
echo 'set FOREIGN_KEY_CHECKS=0;' > vtiger_4_0_1_dump.txt
|
||||
${mysql_dir_4_0_1}/bin/mysqldump --user=$mysql_username --password=$mysql_password --port=$mysql_port --socket=$mysql_socket vtigercrm4_0_1 >> vtiger_4_0_1_dump.txt
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
echo 'Data dump taken successfully in vtiger_4_0_1_dump.txt'
|
||||
else
|
||||
echo 'Unable to take the database dump. vtigercrm database may be corrupted'
|
||||
exit
|
||||
fi
|
||||
|
||||
${mysql_dir}/bin/mysql --user=$mysql_username --password=$mysql_password --port=$mysql_port --socket=$mysql_socket -e "create database vtigercrm_4_0_1_bkp"
|
||||
${mysql_dir}/bin/mysql --user=$mysql_username --password=$mysql_password --port=$mysql_port --socket=$mysql_socket vtigercrm_4_0_1_bkp < vtiger_4_0_1_dump.txt
|
||||
wget http://localhost:${apache_port_4_0_1}/Migrate.php
|
||||
#${mysql_dir}/bin/mysql --user=$mysql_username --password=$mysql_password --port=$mysql_port --socket=$mysql_socket vtigercrm_4_0_bkp < migrate_4_0to4_0_1.sql
|
||||
echo 'set FOREIGN_KEY_CHECKS=0;' > migrated_vtiger_4_2_dump.txt
|
||||
${mysql_dir_4_0_1}/bin/mysqldump --user=$mysql_username --password=$mysql_password --port=$mysql_port --socket=$mysql_socket vtigercrm_4_0_1_bkp >> migrated_vtiger_4_2_dump.txt
|
||||
${mysql_dir}/bin/mysql --user=$mysql_username --password=$mysql_password --port=$mysql_port --socket=$mysql_socket -e "drop database vtigercrm_4_0_1_bkp"
|
||||
|
||||
}
|
||||
|
||||
|
||||
stopvtiger4_0_1MySQL()
|
||||
{
|
||||
echo "Shutting down the vtiger CRM 4.0.1 mysql server"
|
||||
${mysql_dir}/bin/mysqladmin --user=$mysql_username --password=$mysql_password --port=$mysql_port --socket=$mysql_socket shutdown
|
||||
echo "vtiger CRM 4.0.1 MySQL server shutdown"
|
||||
}
|
||||
|
||||
getvtiger4_2data()
|
||||
{
|
||||
echo 'in get vtiger 4_2 data '
|
||||
scrfile=./startvTiger.sh
|
||||
|
||||
echo ""
|
||||
mysql_dir=`grep "mysql_dir=" ${scrfile} | cut -d "=" -f2 | cut -d "'" -f2`
|
||||
echo "4.2 dir is$mysql_dir"
|
||||
|
||||
echo ""
|
||||
mysql_username=`grep "mysql_username=" ${scrfile} | cut -d "=" -f2 | cut -d "'" -f2`
|
||||
echo "4.2 user name is $mysql_username"
|
||||
|
||||
mysql_password=`grep "mysql_password=" ${scrfile} | cut -d "=" -f2 | cut -d "'" -f2`
|
||||
echo ""
|
||||
echo "4.2 password is $mysql_password"
|
||||
|
||||
echo ""
|
||||
mysql_port=`grep "mysql_port=" ${scrfile} | cut -d "=" -f2 | cut -d "'" -f2`
|
||||
echo "4.2 port is $mysql_port"
|
||||
|
||||
echo ""
|
||||
mysql_socket=`grep "mysql_socket=" ${scrfile} | cut -d "=" -f2 | cut -d "'" -f2`
|
||||
echo "4.2 socket is $mysql_socket"
|
||||
|
||||
echo ""
|
||||
mysql_bundled=`grep "mysql_bundled=" ${scrfile} | cut -d "=" -f2 | cut -d "'" -f2`
|
||||
echo "4.2 bundled status is $mysql_bundled"
|
||||
}
|
||||
|
||||
dumpinto4_2db()
|
||||
{
|
||||
${mysql_dir}/bin/mysql --user=$mysql_username --password=$mysql_password --port=$mysql_port --socket=$mysql_socket -e "drop database vtigercrm4_2"
|
||||
${mysql_dir}/bin/mysql --user=$mysql_username --password=$mysql_password --port=$mysql_port --socket=$mysql_socket -e "create database if not exists vtigercrm4_2"
|
||||
${mysql_dir}/bin/mysql --user=$mysql_username --password=$mysql_password --port=$mysql_port --socket=$mysql_socket vtigercrm4_2 --force < migrated_vtiger_4_2_dump.txt 2> migrate_log.txt
|
||||
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
echo 'vTiger CRM 4.0.1 Data successfully migrated into vtiger CRM 4.2 database vtigercrm4_2'
|
||||
else
|
||||
echo 'Unable to dump data into the vtiger CRM 4.2 database vtigercrm4_2. Check the migrate_log.txt in the $wdir directory'
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
setVariables $*
|
||||
getvtiger4_0_1_installdir
|
||||
|
||||
if [ ${diffmac} -eq 0 ]
|
||||
then
|
||||
getvtiger4_0_1_data
|
||||
isvtiger_MySQL_Running 4_0_1
|
||||
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
startMySQL 4_0_1
|
||||
fi
|
||||
getdump4_0_1_db
|
||||
if [ "$mysql_bundled" == "true" ]
|
||||
then
|
||||
stopvtiger4_0_1MySQL
|
||||
fi
|
||||
fi
|
||||
|
||||
getvtiger4_2data
|
||||
isvtiger_MySQL_Running 4_2
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
startMySQL 4_2
|
||||
fi
|
||||
dumpinto4_2db
|
||||
|
||||
}
|
||||
|
||||
main $*
|
|
@ -0,0 +1,16 @@
|
|||
echo off
|
||||
for /F "tokens=1,* delims==" %%a in (%1) do (
|
||||
if "%%b"=="%2;" (
|
||||
echo inside if
|
||||
echo %%a=%3;>> %1.tmp
|
||||
) else (
|
||||
echo inside else
|
||||
if "%%b"=="" (
|
||||
echo inside else if
|
||||
echo %%a>> %1.tmp
|
||||
) else (
|
||||
echo inside last else
|
||||
echo %%a=%%b>> %1.tmp
|
||||
))
|
||||
)
|
||||
move /Y %1.tmp %1
|
|
@ -0,0 +1,186 @@
|
|||
echo off
|
||||
set mysql_dir=MYSQLINSTALLDIR
|
||||
set mysql_username=MYSQLUSERNAME
|
||||
set mysql_password=MYSQLPASSWORD
|
||||
set mysql_port=MYSQLPORT
|
||||
set mysql_bundled=MYSQLBUNDLEDSTATUS
|
||||
set apache_dir=APACHEINSTALLDIR
|
||||
set apache_bin=APACHEBIN
|
||||
set apache_conf=APACHECONF
|
||||
set apache_port=APACHEPORT
|
||||
set apache_bundled=APACHEBUNDLED
|
||||
set apache_service=APACHESERVICE
|
||||
|
||||
|
||||
echo %WINDIR%
|
||||
set FIND_STR="%WINDIR%\system32\findstr.exe"
|
||||
set SLEEP_STR="%WINDIR%\system32\ping.exe"
|
||||
goto initiate
|
||||
|
||||
:initiate
|
||||
rem if true means , vtiger crm mysql is being used
|
||||
if "test" == "%1test" goto start1
|
||||
set VTIGER_HOME=%1
|
||||
goto start2
|
||||
|
||||
:start1
|
||||
cd ..
|
||||
set VTIGER_HOME=%cd%
|
||||
:start2
|
||||
|
||||
if %apache_bundled% == true goto checkBundledApache
|
||||
if %apache_bundled% == false goto checkUserApache
|
||||
|
||||
:checkBundledApache
|
||||
echo "APACHEBUNDLED"
|
||||
cd /d %apache_dir%
|
||||
if %apache_service% == true goto StartApacheService
|
||||
start bin\Apache -f conf\httpd.conf
|
||||
IF ERRORLEVEL 1 goto stopservice
|
||||
goto checkmysql
|
||||
|
||||
:StartApacheService
|
||||
echo ""
|
||||
echo "making an attempt to kill any existing vtigercrm service"
|
||||
echo ""
|
||||
bin\apache -k stop -n vtigercrm504
|
||||
bin\apache -k uninstall -n vtigercrm504
|
||||
echo "Uninstalling apache service again for confirmation after sleeping for 10 seconds"
|
||||
echo ""
|
||||
%SLEEP_STR% -n 10 127.0.0.1>nul
|
||||
bin\apache -k stop -n vtigercrm504
|
||||
bin\apache -k uninstall -n vtigercrm504
|
||||
echo ""
|
||||
echo ""
|
||||
echo "Installing vtigercrm504 apache service after sleeping for 10 seconds"
|
||||
echo ""
|
||||
%SLEEP_STR% -n 10 127.0.0.1>nul
|
||||
bin\apache -k install -n vtigercrm504 -f conf\httpd.conf
|
||||
echo ""
|
||||
echo "Starting vtigercrm504 apache service"
|
||||
echo ""
|
||||
bin\apache -n vtigercrm504 -k start
|
||||
IF ERRORLEVEL 1 goto stopservice
|
||||
goto checkmysql
|
||||
|
||||
:checkUserApache
|
||||
netstat -anp tcp >port.txt
|
||||
%FIND_STR% "\<%apache_port%\>" port.txt
|
||||
if ERRORLEVEL 1 goto apachenotrunning
|
||||
%FIND_STR% "\<%apache_port%\>" port.txt >list.txt
|
||||
%FIND_STR% "LISTEN.*" list.txt
|
||||
if ERRORLEVEL 1 goto apachenotrunning
|
||||
echo ""
|
||||
echo "Apache is running"
|
||||
echo ""
|
||||
goto checkmysql
|
||||
|
||||
:apachenotrunning
|
||||
echo ""
|
||||
echo ""
|
||||
echo "Apache in the location %apache_dir% is not running. Start Apache and then start vtiger crm"
|
||||
echo ""
|
||||
echo ""
|
||||
set /p pt=Press Any Key to Continue...
|
||||
goto end
|
||||
|
||||
:checkmysql
|
||||
cd /d %mysql_dir%\bin
|
||||
echo %cd%
|
||||
|
||||
echo ""
|
||||
echo "Checking the whether the MySQL server is already running"
|
||||
echo ""
|
||||
mysql --port=%mysql_port% --user=%mysql_username% --password=%mysql_password% -e "show databases" > NUL
|
||||
IF ERRORLEVEL 1 goto startmysql
|
||||
echo ""
|
||||
echo ""
|
||||
ECHO "MySQL is already started and running"
|
||||
echo ""
|
||||
echo ""
|
||||
goto checkdatabase
|
||||
|
||||
|
||||
:startmysql
|
||||
echo ""
|
||||
echo "Starting MySQL on port specified by the user"
|
||||
echo ""
|
||||
start mysqld-nt -b .. --skip-bdb --log-queries-not-using-indexes --log-slow-admin-statements --log-error --low-priority-updates --log-slow-queries=vtslowquery.log --default-storage-engine=InnoDB --datadir=../data --port=%mysql_port%
|
||||
%SLEEP_STR% -n 11 127.0.0.1>nul
|
||||
mysql --port=%mysql_port% --user=%mysql_username% --password=%mysql_password% -e "show databases" > NUL
|
||||
IF ERRORLEVEL 1 goto notstarted
|
||||
echo ""
|
||||
echo "Started MySQL on port specified by the user"
|
||||
echo ""
|
||||
goto checkdatabase
|
||||
|
||||
|
||||
:checkdatabase
|
||||
echo ""
|
||||
echo "check to see if vtigercrm504 database already exists"
|
||||
echo ""
|
||||
mysql --port=%mysql_port% --user=%mysql_username% --password=%mysql_password% -e "show databases like 'vtigercrm504'" | "%WINDIR%\system32\find.exe" "vtigercrm504" > NUL
|
||||
IF ERRORLEVEL 1 goto dbnotexists
|
||||
echo ""
|
||||
ECHO "vtigercrm504 database exists"
|
||||
echo ""
|
||||
goto end
|
||||
|
||||
|
||||
:dbnotexists
|
||||
echo ""
|
||||
ECHO "vtigercrm504 database does not exist"
|
||||
echo ""
|
||||
echo %cd%
|
||||
echo ""
|
||||
echo "Proceeding to create database vtigercrm504 and populate the same"
|
||||
echo ""
|
||||
mysql --user=%mysql_username% --password=%mysql_password% --port=%mysql_port% -e "create database if not exists vtigercrm504"
|
||||
echo ""
|
||||
echo "vtigercrm504 database created"
|
||||
echo ""
|
||||
goto end
|
||||
|
||||
:notstarted
|
||||
echo ""
|
||||
echo ""
|
||||
ECHO "Unable to start the MySQL server at port %mysql_port%. Check if the port is free"
|
||||
echo ""
|
||||
echo ""
|
||||
set /p pt=Press Any Key to Continue...
|
||||
goto end
|
||||
|
||||
:stopservice
|
||||
echo ""
|
||||
echo ""
|
||||
echo ""
|
||||
echo "********* Service not started as port # %apache_port% occupied ******* "
|
||||
echo ""
|
||||
echo ""
|
||||
echo ""
|
||||
echo ""
|
||||
echo "********* I am sorry. I am not able to start the product as the apache port that you have specified: port # %apache_port% seems to be occupied ******* "
|
||||
echo ""
|
||||
echo ""
|
||||
echo "You could give me a different port number if you wish by doing the following ...."
|
||||
echo ""
|
||||
echo ""
|
||||
echo "********* Open the apache/conf/httpd.conf file, search for 'Listen' and change the port number ******* "
|
||||
echo ""
|
||||
echo ""
|
||||
echo ""
|
||||
echo ""
|
||||
echo "********* Change the apache port in startvTiger.bat and stopvTiger.bat too and then access the product from the browser in the following manner http://localhost:apacheport******* "
|
||||
echo ""
|
||||
echo ""
|
||||
echo "Thank You"
|
||||
echo ""
|
||||
echo ""
|
||||
set /p pt=Press Any Key to Continue...
|
||||
goto end
|
||||
|
||||
|
||||
:end
|
||||
cd /d %VTIGER_HOME%\bin
|
||||
|
||||
|
|
@ -0,0 +1,133 @@
|
|||
#*********************************************************************************
|
||||
# The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
# ("License"); You may not use this file except in compliance with the License
|
||||
# The Original Code is: vtiger CRM Open Source
|
||||
# The Initial Developer of the Original Code is vtiger.
|
||||
# Portions created by vtiger are Copyright (C) vtiger.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# ********************************************************************************
|
||||
|
||||
cd ..
|
||||
export VTIGER_HOME=`pwd`
|
||||
echo "***************************************************************************************************"
|
||||
echo vtigerCRM home: `pwd`
|
||||
echo "**************************************************************************************************"
|
||||
|
||||
mysql_dir='MYSQLINSTALLDIR'
|
||||
mysql_username='MYSQLUSERNAME'
|
||||
mysql_password='MYSQLPASSWORD'
|
||||
mysql_port=MYSQLPORT
|
||||
mysql_socket='MYSQLSOCKET'
|
||||
mysql_bundled='MYSQLBUNDLEDSTATUS'
|
||||
apache_dir='APACHEINSTALLDIR'
|
||||
apache_bin='APACHEBIN'
|
||||
apache_conf='APACHECONF'
|
||||
apache_port='APACHEPORT'
|
||||
apache_bundled='APACHEBUNDLED'
|
||||
|
||||
if [ $apache_bundled == 'true' ];then
|
||||
APACHE_HOME=$apache_dir
|
||||
export APACHE_HOME
|
||||
cd $APACHE_HOME/bin
|
||||
echo ""
|
||||
echo "Starting apache at port $apache_port"
|
||||
echo ""
|
||||
|
||||
./apachectl -k restart
|
||||
if [ $? -ne 0 ]; then
|
||||
echo ""
|
||||
echo "*******************************************************************************"
|
||||
echo "Unable to start the apache server. Check whether the port $apache_port is free"
|
||||
echo "*******************************************************************************"
|
||||
echo ""
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $apache_bundled == 'false' ];then
|
||||
netstat -an | grep LISTEN | grep -w $apache_port
|
||||
apache_stat=$?
|
||||
if [ $apache_stat -ne 0 ];then
|
||||
echo ""
|
||||
echo "**************************************************************************************"
|
||||
echo "Apache Server is not running. Start the Apache server and then start the vtigerCRM application"
|
||||
echo "**************************************************************************************"
|
||||
echo ""
|
||||
exit
|
||||
else
|
||||
echo ""
|
||||
echo "Apache Server is running"
|
||||
echo ""
|
||||
fi
|
||||
fi
|
||||
|
||||
MYSQL_HOME=$mysql_dir
|
||||
|
||||
export MYSQL_HOME
|
||||
|
||||
cd $MYSQL_HOME
|
||||
echo ""
|
||||
echo MySQL home: `pwd`
|
||||
echo ""
|
||||
|
||||
echo ""
|
||||
echo "Checking whether the MySQL server is already running"
|
||||
echo ""
|
||||
echo "select 1"| ./bin/mysql --user=$mysql_username --password=$mysql_password --port=$mysql_port --socket=$mysql_socket > /dev/null
|
||||
exit_status=$?
|
||||
if [ $exit_status -eq 0 ];then
|
||||
echo " "
|
||||
echo "MySQL server is running"
|
||||
echo " "
|
||||
fi
|
||||
if [ $exit_status -ne 0 ]; then
|
||||
if [ $mysql_bundled == 'false' ];then
|
||||
echo ""
|
||||
echo "**************************************************************************************"
|
||||
echo "Mysql server in the directory $mysql_dir is not running at port $mysql_port. Start the mysql server and then start vtigerCRM application"
|
||||
echo "**************************************************************************************"
|
||||
echo ""
|
||||
|
||||
exit
|
||||
else
|
||||
echo ""
|
||||
echo "Mysql Server is not running. Going to start the mysql server at port $mysql_port"
|
||||
echo ""
|
||||
#chown -R nobody .
|
||||
#chgrp -R nobody .
|
||||
./bin/mysqld --skip-bdb --log-queries-not-using-indexes --log-slow-admin-statements --log-error --low-priority-updates --log-slow-queries=vtslowquery.log --basedir=$MYSQL_HOME --datadir=$MYSQL_HOME/data --socket=$mysql_socket --tmpdir=$MYSQL_HOME/tmp --user=root --port=$mysql_port --default-table-type=INNODB > /dev/null &
|
||||
sleep 8
|
||||
echo "select 1"| ./bin/mysql --user=$mysql_username --password=$mysql_password --port=$mysql_port --socket=$mysql_socket > /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo ""
|
||||
echo "****************************************************************************"
|
||||
echo "Unable to start the mysql server. Check whether the port $mysql_port is free"
|
||||
echo "****************************************************************************"
|
||||
echo ""
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
|
||||
fi
|
||||
echo ""
|
||||
echo "Checking if the vtigercrm540 database already exists"
|
||||
echo ""
|
||||
echo "select 1" | ./bin/mysql --user=$mysql_username --password=$mysql_password --port=$mysql_port --socket=$mysql_socket -D vtigercrm540 >/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo ""
|
||||
echo "Database vtigercrm540 does not exist. Creating database vtigercrm540"
|
||||
echo ""
|
||||
./bin/mysql --user=$mysql_username --password=$mysql_password --port=$mysql_port --socket=$mysql_socket -e "create database if not exists vtigercrm540"
|
||||
fi
|
||||
|
||||
host=`hostname`
|
||||
echo "*****************************************************************************************************"
|
||||
if [ $apache_bundled == 'false' ];then
|
||||
echo "Please access the product at http://${host}:<apache port>/vtigerCRM5/vtigerCRM"
|
||||
else
|
||||
echo "Please access the product at http://${host}:<apache port>"
|
||||
echo "*****************************************************************************************************"
|
||||
fi
|
||||
cd $VTIGER_HOME
|
||||
exit 0
|
|
@ -0,0 +1,56 @@
|
|||
@echo off
|
||||
cd ..
|
||||
set mysql_dir=MYSQLINSTALLDIR
|
||||
set mysql_username=MYSQLUSERNAME
|
||||
set mysql_password=MYSQLPASSWORD
|
||||
set mysql_port=MYSQLPORT
|
||||
set mysql_bundled=MYSQLBUNDLEDSTATUS
|
||||
set apache_dir=APACHEINSTALLDIR
|
||||
set apache_bin=APACHEBIN
|
||||
set apache_conf=APACHECONF
|
||||
set apache_port=APACHEPORT
|
||||
set apache_bundled=APACHEBUNDLED
|
||||
set apache_service=APACHESERVICE
|
||||
|
||||
set VTIGER_HOME=%cd%
|
||||
|
||||
|
||||
if %apache_bundled% == true goto StopApacheCheck
|
||||
goto StopMySQL
|
||||
|
||||
:StopApacheCheck
|
||||
if %apache_service% == true goto StopApacheService
|
||||
cd /d %apache_dir%
|
||||
rem shut down apache
|
||||
echo ""
|
||||
echo "stopping vtigercrm apache"
|
||||
echo ""
|
||||
bin\ShutdownApache logs\httpd.pid
|
||||
goto StopMySQL
|
||||
|
||||
:StopApacheService
|
||||
cd /d %apache_dir%
|
||||
rem shut down apache
|
||||
echo ""
|
||||
echo "stopping vtigercrm504 apache service"
|
||||
echo ""
|
||||
bin\apache -n vtigercrm504 -k stop
|
||||
echo ""
|
||||
echo "uninstalling vtigercrm504 apache service"
|
||||
echo ""
|
||||
bin\apache -k uninstall -n vtigercrm504
|
||||
rem .\bin\ShutdownApache.exe logs\httpd.pid
|
||||
goto StopMySQL
|
||||
|
||||
|
||||
:StopMySQL
|
||||
if %mysql_bundled% == true (
|
||||
rem cd /d %VTIGER_HOME%\mysql\bin
|
||||
rem shutdown mysql
|
||||
cd /d %mysql_dir%\bin
|
||||
mysqladmin --port=%mysql_port% --user=%mysql_username% --password=%mysql_password% shutdown
|
||||
echo ""
|
||||
echo "vtiger CRM MySQL Sever is shut down"
|
||||
echo ""
|
||||
cd /d %VTIGER_HOME%\bin
|
||||
)
|
|
@ -0,0 +1,43 @@
|
|||
#*********************************************************************************
|
||||
# The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
# ("License"); You may not use this file except in compliance with the License
|
||||
# The Original Code is: vtiger CRM Open Source
|
||||
# The Initial Developer of the Original Code is vtiger.
|
||||
# Portions created by vtiger are Copyright (C) vtiger.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# ********************************************************************************
|
||||
|
||||
cd ..
|
||||
export VTIGER_HOME=`pwd`
|
||||
|
||||
mysql_dir='MYSQLINSTALLDIR'
|
||||
mysql_username='MYSQLUSERNAME'
|
||||
mysql_password='MYSQLPASSWORD'
|
||||
mysql_port=MYSQLPORT
|
||||
mysql_socket='MYSQLSOCKET'
|
||||
mysql_bundled='MYSQLBUNDLEDSTATUS'
|
||||
apache_dir='APACHEINSTALLDIR'
|
||||
apache_bin='APACHEBIN'
|
||||
apache_conf='APACHECONF'
|
||||
apache_port='APACHEPORT'
|
||||
apache_bundled='APACHEBUNDLED'
|
||||
|
||||
if [ $apache_bundled == 'true' ];then
|
||||
cd $apache_bin
|
||||
echo "Shutting down apache !"
|
||||
./httpd -k stop
|
||||
fi
|
||||
|
||||
|
||||
if [ $mysql_bundled == 'true' ]; then
|
||||
MYSQL_HOME=$mysql_dir
|
||||
export MYSQL_HOME
|
||||
cd $MYSQL_HOME
|
||||
echo `pwd`
|
||||
echo "Shutting down the mysql server"
|
||||
./bin/mysqladmin --user=$mysql_username --password=$mysql_password --port=$mysql_port --socket=$mysql_socket shutdown
|
||||
echo "MySQL shutdown"
|
||||
fi
|
||||
|
||||
cd $VTIGER_HOME
|
|
@ -0,0 +1,59 @@
|
|||
#*********************************************************************************
|
||||
# The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
# ("License"); You may not use this file except in compliance with the License
|
||||
# The Original Code is: vtiger CRM Open Source
|
||||
# The Initial Developer of the Original Code is vtiger.
|
||||
# Portions created by vtiger are Copyright (C) vtiger.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# ********************************************************************************
|
||||
|
||||
INS_DIR="../.."
|
||||
WRKDIR=`pwd`
|
||||
PREV_DIR=".."
|
||||
|
||||
APACHE_STATUS=`cat startvTiger.sh | grep ^apache_bundled | cut -d "=" -f2 | cut -d "'" -f2`
|
||||
cd ${INS_DIR}
|
||||
cd ${PREV_DIR}
|
||||
if [ ${APACHE_STATUS} == "false" ]
|
||||
then
|
||||
diff conf/httpd.conf conf/vtiger_conf/vtigercrm-5.4.0/httpd.conf > /dev/null;
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
cp conf/vtigerCRMBackup/vtigercrm-5.4.0/httpd.vtiger.crm.conf conf/httpd.conf
|
||||
echo "The httpd.conf file successfully reverted"
|
||||
else
|
||||
echo "The httpd.conf file under apache/conf has been edited since installation. Hence the uninstallation will not revert the httpd.conf file. The original httpd.conf file is present in <apache home>/conf/vtigerCRMBackup/vtigercrm-5.4.0/httpd.vtiger.crm.conf. Kindly revert the same manually"
|
||||
fi
|
||||
|
||||
diff modules/libphp4.so modules/vtiger_modules/vtigercrm-5.4.0/libphp4.so > /dev/null;
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
cp modules/vtigerCRMBackup/vtigercrm-5.4.0/libphp4.vtiger.crm.so modules/libphp4.so
|
||||
echo "The libphp4.so file successfully reverted"
|
||||
else
|
||||
echo "The libphp4.so file under apache/modules has been edited since installation. Hence the uninstallation will not revert the libphp4.so file. The original libphp4.so file is present in <apache home>/modules/vtigerCRMBackup/vtigercrm-5.4.0/libphp4.vtiger.crm.so. Kindly revert the same manually"
|
||||
fi
|
||||
|
||||
cd -
|
||||
|
||||
if [ -d $PWD/vtigercrm-5.4.0 ]; then
|
||||
echo "Uninstalling vtigerCRM from the system..."
|
||||
rm -rf ../conf/vtiger_conf/vtigercrm-5.4.0
|
||||
rm -rf ../modules/vtiger_modules/vtigercrm-5.4.0
|
||||
rm -rf vtigercrm-5.4.0
|
||||
echo "Uninstallation of vtigerCRM completed"
|
||||
cd ${HOME}
|
||||
fi
|
||||
|
||||
else
|
||||
cd -
|
||||
if [ -d $PWD/vtigercrm-5.4.0 ]; then
|
||||
echo "Uninstalling vtigerCRM from the system..."
|
||||
rm -rf ../conf/vtiger_conf/vtigercrm-5.4.0
|
||||
rm -rf ../modules/vtiger_modules/vtigercrm-5.4.0
|
||||
rm -rf vtigercrm-5.4.0
|
||||
echo "Uninstallation of vtigerCRM completed"
|
||||
cd ${HOME}
|
||||
fi
|
||||
fi
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,214 @@
|
|||
<?php
|
||||
global $where_col,$orderby,$in_started,$count;
|
||||
$where_col = false;
|
||||
$orderby = false;
|
||||
$in_started = false;
|
||||
$count = false;
|
||||
function incrementN($lexer, $count){
|
||||
$i = 0;
|
||||
for(;$i<$count;$i++){
|
||||
incState($lexer);
|
||||
}
|
||||
}
|
||||
function incState($lexer){
|
||||
$lexer->current_state++;
|
||||
if($lexer->current_state === sizeof($lexer->mandatory_states)){
|
||||
$lexer->mandatory = false;
|
||||
}
|
||||
}
|
||||
function handleselect($lexer, $val){
|
||||
if($lexer->mandatory){
|
||||
if(strcasecmp($val, $lexer->mandatory_states[$lexer->current_state])===0){
|
||||
incState($lexer);
|
||||
return VTQL_Parser::SELECT;
|
||||
}
|
||||
}
|
||||
}
|
||||
function handlecolumn_list($lexer, $val){
|
||||
global $count;
|
||||
if($lexer->mandatory){
|
||||
if(!(strcasecmp($val, $lexer->mandatory_states[2])===0)){
|
||||
if(strcmp($val, "*")===0){
|
||||
if(!$count){
|
||||
incrementN($lexer, 1);
|
||||
}
|
||||
return VTQL_Parser::ASTERISK;
|
||||
}else if((strcmp($val, "(")===0)){
|
||||
return VTQL_Parser::PARENOPEN;
|
||||
}else if(strcmp($val, ")")===0){
|
||||
return VTQL_Parser::PARENCLOSE;
|
||||
}else if((strcasecmp($val, "count")===0)){
|
||||
$count = true;
|
||||
return VTQL_Parser::COUNT;
|
||||
}else if(strcmp($val, ",")===0){
|
||||
return VTQL_Parser::COMMA;
|
||||
}else{
|
||||
return VTQL_Parser::COLUMNNAME;
|
||||
}
|
||||
}else{
|
||||
incrementN($lexer, 2);
|
||||
return VTQL_Parser::FRM;
|
||||
}
|
||||
}
|
||||
}
|
||||
function handlefrom($lexer, $val){
|
||||
if((strcasecmp($val, $lexer->mandatory_states[$lexer->current_state])===0)){
|
||||
incState($lexer);
|
||||
return VTQL_Parser::FRM;
|
||||
}
|
||||
}
|
||||
function handletable($lexer, $val){
|
||||
if($lexer->mandatory){
|
||||
$lexer->current_state =0;
|
||||
$lexer->mandatory = false;
|
||||
if(!(strcasecmp($val, $lexer->optional_states[$lexer->current_state])===0)){
|
||||
return VTQL_Parser::TABLENAME;
|
||||
}
|
||||
}
|
||||
}
|
||||
function handlewhere($lexer, $val){
|
||||
global $where_col,$in_started;
|
||||
$val = trim($val);
|
||||
if((strcmp($val, "=")===0)){
|
||||
return VTQL_Parser::EQ;
|
||||
}else if((strcasecmp($val, $lexer->optional_states[$lexer->current_state])===0)){
|
||||
return VTQL_Parser::WHERE;
|
||||
}else if((strcmp($val, "<")===0)){
|
||||
return VTQL_Parser::LT;
|
||||
}else if((strcmp($val, "<=")===0)){
|
||||
return VTQL_Parser::LTE;
|
||||
}else if((strcmp($val, ">=")===0)){
|
||||
return VTQL_Parser::GTE;
|
||||
}else if((strcmp($val, "!=")===0)){
|
||||
return VTQL_Parser::NE;
|
||||
}else if((strcmp($val, ">")===0)){
|
||||
return VTQL_Parser::GT;
|
||||
}else if((strcmp($val, "(")===0)){
|
||||
return VTQL_Parser::PARENOPEN;
|
||||
}else if((strcmp($val, ")")===0)){
|
||||
if($in_started){
|
||||
$in_started = false;
|
||||
$where_col = false;
|
||||
}
|
||||
return VTQL_Parser::PARENCLOSE;
|
||||
}else if((strcasecmp($val, "and")===0)){
|
||||
return VTQL_Parser::LOGICAL_AND;
|
||||
}else if((strcasecmp($val, "or")===0)){
|
||||
return VTQL_Parser::LOGICAL_OR;
|
||||
}else if(!$where_col){
|
||||
$where_col = true;
|
||||
return VTQL_Parser::COLUMNNAME;
|
||||
}else if((strcasecmp($val, "in")===0)){
|
||||
$in_started = true;
|
||||
return VTQL_Parser::IN;
|
||||
}else if(strcmp($val, ",")===0){
|
||||
return VTQL_Parser::COMMA;
|
||||
}else if(strcasecmp($val, "like")===0){
|
||||
return VTQL_Parser::LIKE;
|
||||
}else if($where_col){
|
||||
if(!$in_started){
|
||||
$where_col = false;
|
||||
}
|
||||
return VTQL_Parser::VALUE;
|
||||
}
|
||||
}
|
||||
function handleorderby($lexer, $val){
|
||||
global $orderby;
|
||||
if(!$orderby){
|
||||
$orderby = true;
|
||||
return VTQL_Parser::ORDERBY;
|
||||
}
|
||||
if(strcmp($val, ",")===0){
|
||||
return VTQL_Parser::COMMA;
|
||||
}else if(strcasecmp($val, "asc")===0){
|
||||
return VTQL_Parser::ASC;
|
||||
}else if(strcasecmp($val, "desc")===0){
|
||||
return VTQL_Parser::DESC;
|
||||
}else{
|
||||
return VTQL_Parser::COLUMNNAME;
|
||||
}
|
||||
}
|
||||
function handlelimit($lexer, $val){
|
||||
if((strcasecmp($val, "limit")===0)){
|
||||
return VTQL_Parser::LIMIT;
|
||||
}else if((strcmp($val, "(")===0)){
|
||||
return VTQL_Parser::PARENOPEN;
|
||||
}else if((strcmp($val, ")")===0)){
|
||||
return VTQL_Parser::PARENCLOSE;
|
||||
}else if(strcmp($val, ",")===0){
|
||||
return VTQL_Parser::COMMA;
|
||||
}else{
|
||||
return VTQL_Parser::VALUE;
|
||||
}
|
||||
}
|
||||
function handleend($lexer, $val){
|
||||
return VTQL_Parser::SEMICOLON;
|
||||
}
|
||||
class VTQL_Lexer{
|
||||
private $index;
|
||||
public $token;
|
||||
public $value;
|
||||
public $linenum;
|
||||
public $state = 1;
|
||||
private $data;
|
||||
public $mandatory_states = array('select','column_list','from','table');
|
||||
public $optional_states = array('where', 'orderby', 'limit');
|
||||
public $mandatory ;
|
||||
public $current_state ;
|
||||
function __construct($data)
|
||||
{
|
||||
$this->index = 0;
|
||||
$this->data = $data;
|
||||
$this->linenum = 1;
|
||||
$this->mandatory = true;
|
||||
$this->current_state = 0;
|
||||
}
|
||||
function __toString(){
|
||||
return $this->token."";
|
||||
}
|
||||
/*!lex2php
|
||||
%input $this->data
|
||||
%counter $this->index
|
||||
%token $this->token
|
||||
%value $this->value
|
||||
%line $this->linenum
|
||||
query = /(\w+|'(?:[^']|'')+'|\(|\)|(\+|-)?\d+|,|\*|(?!<|>)=|<(?!=)|>(?!=)|<=|>=|!=|;)/
|
||||
whitespace = /[ \t\r\n]+/
|
||||
*/
|
||||
/*!lex2php
|
||||
%statename INITR
|
||||
query {
|
||||
global $orderby;
|
||||
//echo "<br> ql state: ",$this->current_state," ",$this->value,"<br>";
|
||||
if($this->mandatory){
|
||||
//echo "<br> ql state: ",$this->current_state," ",$this->value,"<br>";
|
||||
$handler = 'handle'.$this->mandatory_states[$this->current_state];
|
||||
$this->token = $handler($this, $this->value);
|
||||
}else{
|
||||
$str = $this->value;
|
||||
if(strcmp($this->value, ";")===0){
|
||||
$this->token = handleend($this, $this->value);
|
||||
return;
|
||||
}
|
||||
if(strcasecmp($this->value, "order")===0){
|
||||
$orderby = true;
|
||||
return false;
|
||||
}else if(strcasecmp($this->value, "by") ===0 && $orderby ===true){
|
||||
$orderby = false;
|
||||
$this->current_state = 1;
|
||||
}
|
||||
$index = array_search(strtolower($str), $this->optional_states, true);
|
||||
if($index !== false){
|
||||
$this->current_state = $index;
|
||||
}
|
||||
$handler = 'handle'.$this->optional_states[$this->current_state];
|
||||
$this->token = $handler($this, $this->value);
|
||||
}//$this->yypushstate($this->value);
|
||||
}
|
||||
whitespace {
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,478 @@
|
|||
%name VTQL_Parser
|
||||
//%left EQ LT GT LTE GTE NE IN LIKE.
|
||||
|
||||
sql ::= select_statement.
|
||||
select_statement ::= SELECT(SEL) selectcol_list FRM(F) table_list where_condition order_clause limit_clause end_stmt. {
|
||||
if(SEL){
|
||||
$this->out['select'] = SEL;
|
||||
}
|
||||
if(F){
|
||||
$this->out['from'] = F ;
|
||||
}
|
||||
if(SEMI){
|
||||
$this->out['semi_colon'] = SEMI;
|
||||
}
|
||||
if($this->out['select']){
|
||||
$this->buildSelectStmt($this->out);
|
||||
}
|
||||
}
|
||||
selectcol_list ::= selectcolumn_exp COLUMNNAME(CNAME). {
|
||||
$this->out['column_list'][] = CNAME;
|
||||
}
|
||||
selectcol_list ::= ASTERISK(A). {
|
||||
$this->out['column_list'][] = A;
|
||||
}
|
||||
selectcol_list ::= COUNT PARENOPEN ASTERISK PARENCLOSE. {
|
||||
$this->out['column_list'][] = 'count(*)';
|
||||
}
|
||||
selectcolumn_exp ::= selectcol_list COMMA.
|
||||
selectcolumn_exp ::= .
|
||||
table_list ::= TABLENAME(TNAME). {
|
||||
if(!in_array($this->out["column_list"], "*") && !in_array(array_map(strtolower, $this->out["column_list"]), "count(*)")){
|
||||
if(!in_array("id",$this->out["column_list"])){
|
||||
$this->out["column_list"][] = "id";
|
||||
}
|
||||
}
|
||||
$moduleName = TNAME;
|
||||
if(!$moduleName){
|
||||
$this->syntax_error = true;
|
||||
throw new WebServiceException(WebServiceErrorCode::$QUERYSYNTAX, "There is an syntax error in query");
|
||||
}
|
||||
global $adb;
|
||||
$handler = vtws_getModuleHandlerFromName($moduleName,$this->user);
|
||||
$objectMeta = $handler->getMeta();
|
||||
$this->out['moduleName'] = $moduleName;
|
||||
$this->out['tableName'] = implode(',',$objectMeta->getEntityTableList());
|
||||
}
|
||||
where_condition ::= WHERE(Wh) condition.
|
||||
where_condition ::= .
|
||||
condition ::= expr_set expr(E).
|
||||
expr_set ::= condition LOGICAL_AND(LAND). {
|
||||
$this->out['where_condition']['operators'][] = LAND;
|
||||
}
|
||||
expr_set ::= condition LOGICAL_OR(LOR). {
|
||||
$this->out['where_condition']['operators'][] = LOR;
|
||||
}
|
||||
expr_set ::= .
|
||||
expr ::= COLUMNNAME(ECNAME) logical_term valuelist.{
|
||||
$this->out['columnDone']=true;
|
||||
$this->out['where_condition']['column_names'][] = ECNAME;
|
||||
if(strcmp(ECNAME, 'id')===0){
|
||||
$prev = $this->out['where_condition']['column_values'][sizeof($this->out['where_condition']['column_values'])-1];
|
||||
if(is_array($prev)){
|
||||
$new = array();
|
||||
foreach($prev as $ind=>$val){
|
||||
$val = trim($val,'\'"');
|
||||
$value = vtws_getIdComponents($val);
|
||||
$new[] = $value[1];
|
||||
}
|
||||
$this->out['where_condition']['column_values'][sizeof($this->out['where_condition']['column_values'])-1] = $new;
|
||||
}else{
|
||||
$prev = trim($prev,'\'"');
|
||||
$value = vtws_getIdComponents($prev);
|
||||
if(strcasecmp($this->out['where_condition']['column_operators'][sizeof($this->out['where_condition']['column_operators'])-1],'like')===0){
|
||||
$value[1] = "'".$value[1]."'";
|
||||
}
|
||||
$this->out['where_condition']['column_values'][sizeof($this->out['where_condition']['column_values'])-1] = $value[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
valuelist ::= PARENOPEN valueref PARENCLOSE.
|
||||
valuelist ::= valueref.
|
||||
valueref ::= value_exp VALUE(VAL).{
|
||||
$length = sizeof($this->out['where_condition']['column_values']);
|
||||
$pos = $length - 1;
|
||||
if($pos < 0){
|
||||
$pos = 0;
|
||||
}
|
||||
if(strcasecmp($this->out['where_condition']['column_operators'][$pos],"in")===0 &&
|
||||
!empty($this->out['where_condition']['column_values'][$pos]) && !$this->out['columnDone']){
|
||||
if(!is_array($this->out['where_condition']['column_values'][$pos])){
|
||||
$prev = $this->out['where_condition']['column_values'][$pos];
|
||||
$this->out['where_condition']['column_values'][$pos] = array();
|
||||
$this->out['where_condition']['column_values'][$pos][] = $prev;
|
||||
}
|
||||
$this->out['where_condition']['column_values'][$pos][] = VAL;
|
||||
}else{
|
||||
$this->out['columnDone'] = false;
|
||||
$this->out['where_condition']['column_values'][] = VAL;
|
||||
}
|
||||
}
|
||||
value_exp ::= valueref COMMA.
|
||||
value_exp ::= .
|
||||
logical_term ::= EQ. {
|
||||
$this->out['where_condition']['column_operators'][] = '=';
|
||||
}
|
||||
logical_term ::= LT. {
|
||||
$this->out['where_condition']['column_operators'][] = '<';
|
||||
}
|
||||
logical_term ::= GT. {
|
||||
$this->out['where_condition']['column_operators'][] = '>';
|
||||
}
|
||||
logical_term ::= LTE. {
|
||||
$this->out['where_condition']['column_operators'][] = '<=';
|
||||
}
|
||||
logical_term ::= GTE. {
|
||||
$this->out['where_condition']['column_operators'][] = '>=';
|
||||
}
|
||||
logical_term ::= NE. {
|
||||
$this->out['where_condition']['column_operators'][] = '!=';
|
||||
}
|
||||
logical_term ::= IN. {
|
||||
$this->out['where_condition']['column_operators'][] = 'IN';
|
||||
}
|
||||
logical_term ::= LIKE. {
|
||||
$this->out['where_condition']['column_operators'][] = 'LIKE';
|
||||
}
|
||||
order_clause ::= ORDERBY column_group clause.
|
||||
order_clause ::= .
|
||||
column_group ::= column_list .
|
||||
column_list ::= column_exp COLUMNNAME(CN). {
|
||||
$this->out['orderby'][] = CN;
|
||||
}
|
||||
column_exp ::= column_list COMMA.
|
||||
column_exp ::= .
|
||||
clause ::= ASC. {
|
||||
$this->out['sortOrder'] = 'ASC';
|
||||
}
|
||||
clause ::= DESC. {
|
||||
$this->out['sortOrder'] = 'DESC';
|
||||
}
|
||||
clause ::= .
|
||||
limit_clause ::= LIMIT limit_set.
|
||||
limit_clause ::= .
|
||||
limit_set ::= VALUE(LV). {
|
||||
$this->out['limit'][] = LV;
|
||||
}
|
||||
limit_set ::= VALUE(LV) COMMA VALUE(LV2). {
|
||||
$this->out['limit'][] = LV;
|
||||
$this->out['limit'][] = LV2;
|
||||
}
|
||||
end_stmt ::= SEMICOLON(SEMI). {
|
||||
global $adb;
|
||||
if(!$this->out['meta']){
|
||||
$module = $this->out['moduleName'];
|
||||
$handler = vtws_getModuleHandlerFromName($module,$this->user);
|
||||
$objectMeta = $handler->getMeta();
|
||||
$this->out['meta'] = $objectMeta;
|
||||
$meta = $this->out['meta'];
|
||||
$fieldcol = $meta->getFieldColumnMapping();
|
||||
$columns = array();
|
||||
if(in_array($this->out['column_list'],'*')){
|
||||
$columns = array_values($fieldcol);
|
||||
}else if( !in_array(array_map(strcmp, $this->out['column_list']),'count(*)')){
|
||||
foreach($this->out['column_list'] as $ind=>$field){
|
||||
$columns[] = $fieldcol[$field];
|
||||
}
|
||||
}
|
||||
if($this->out['where_condition']){
|
||||
foreach($this->out['where_condition']['column_names'] as $ind=>$field){
|
||||
$columns[] = $fieldcol[$field];
|
||||
}
|
||||
}
|
||||
$tables = $this->getTables($this->out, $columns);
|
||||
if(!in_array($objectMeta->getEntityBaseTable(), $tables)){
|
||||
$tables[] = $objectMeta->getEntityBaseTable();
|
||||
}
|
||||
$defaultTableList = $objectMeta->getEntityDefaultTableList();
|
||||
foreach($defaultTableList as $tableName){
|
||||
if(!in_array($tableName,$tables)){
|
||||
array_push($tables,$tableName);
|
||||
}
|
||||
}
|
||||
$firstTable = $objectMeta->getEntityBaseTable();
|
||||
$tabNameIndex = $objectMeta->getEntityTableIndexList();
|
||||
$firstIndex = $tabNameIndex[$firstTable];
|
||||
foreach($tables as $ind=>$table){
|
||||
if($firstTable!=$table){
|
||||
if(!isset($tabNameIndex[$table]) && $table == "vtiger_crmentity"){
|
||||
$this->out['defaultJoinConditions'] = $this->out['defaultJoinConditions']." LEFT JOIN $table ON $firstTable.$firstIndex=$table.crmid";
|
||||
}else{
|
||||
$this->out['defaultJoinConditions'] = $this->out['defaultJoinConditions']." LEFT JOIN $table ON $firstTable.$firstIndex=$table.{$tabNameIndex[$table]}";
|
||||
}
|
||||
}else{
|
||||
$this->out['tableName'] = $table;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
%include_class {
|
||||
/*
|
||||
add this rule to add parenthesis support.
|
||||
condition ::= PARENOPEN expr_set expr(E) PARENCLOSE.
|
||||
sample format(for contacts) for generated sql object
|
||||
Array (
|
||||
[column_list] => c4,c3,c2,c1
|
||||
[tableName] => vtiger_crmentity,vtiger_contactdetails,vtiger_contactaddress,vtiger_contactsubdetails,vtiger_contactscf,vtiger_customerdetails
|
||||
[where_condition] => Array (
|
||||
[column_operators] => Array (
|
||||
[0] => =
|
||||
[1] => =
|
||||
[2] => =
|
||||
)
|
||||
[column_names] => Array (
|
||||
[0] => c1
|
||||
[1] => c2
|
||||
[2] => c3
|
||||
)
|
||||
[column_values] => Array (
|
||||
[0] => 'llet me'
|
||||
[1] => 45
|
||||
[2] => -1
|
||||
)
|
||||
//TO BE DONE
|
||||
[grouping] => Array (
|
||||
[0] => Array (
|
||||
[0] => 1
|
||||
[1] => 2
|
||||
)
|
||||
)
|
||||
[operators] => Array (
|
||||
[0] => and
|
||||
[1] => or
|
||||
)
|
||||
)
|
||||
[orderby] => Array (
|
||||
[0] => c4
|
||||
[1] => c5
|
||||
)
|
||||
[select] => SELECT
|
||||
[from] => from
|
||||
[semi_colon] => ;
|
||||
)*/
|
||||
private $out;
|
||||
public $lex;
|
||||
private $success ;
|
||||
private $query ;
|
||||
private $error_msg;
|
||||
private $syntax_error;
|
||||
private $user;
|
||||
function __construct($user, $lex,$out){
|
||||
if(!is_array($out)){
|
||||
$out = array();
|
||||
}
|
||||
$this->out = &$out;
|
||||
$this->lex = $lex;
|
||||
$this->success = false;
|
||||
$this->error_msg ='';
|
||||
$this->query = '';
|
||||
$this->syntax_error = false;
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
function __toString(){
|
||||
return $this->value."";
|
||||
}
|
||||
function buildSelectStmt($sqlDump){
|
||||
$meta = $sqlDump['meta'];
|
||||
$fieldcol = $meta->getFieldColumnMapping();
|
||||
$columnTable = $meta->getColumnTableMapping();
|
||||
$this->query = 'SELECT ';
|
||||
if(in_array($sqlDump['column_list'],'*')){
|
||||
$i=0;
|
||||
foreach($fieldcol as $field=>$col){
|
||||
if($i===0){
|
||||
$this->query = $this->query.$columnTable[$col].'.'.$col;
|
||||
$i++;
|
||||
}else{
|
||||
$this->query = $this->query.','.$columnTable[$col].'.'.$col;
|
||||
}
|
||||
}
|
||||
}else if(in_array($sqlDump['column_list'],'count(*)')){
|
||||
$this->query = $this->query." COUNT(*)";
|
||||
}else{
|
||||
$i=0;
|
||||
foreach($sqlDump['column_list'] as $ind=>$field){
|
||||
if(!$fieldcol[$field]){
|
||||
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to access '.$field.' attribute denied.");
|
||||
}
|
||||
if($i===0){
|
||||
$this->query = $this->query.$columnTable[$fieldcol[$field]].'.'.$fieldcol[$field];
|
||||
$i++;
|
||||
}else{
|
||||
$this->query = $this->query.','.$columnTable[$fieldcol[$field]].'.'.$fieldcol[$field];
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->query = $this->query.' FROM '.$sqlDump['tableName'].$sqlDump['defaultJoinConditions'];
|
||||
$deletedQuery = $meta->getEntityDeletedQuery();
|
||||
$accessControlQuery = $meta->getEntityAccessControlQuery();
|
||||
$this->query = $this->query.' '.$accessControlQuery;
|
||||
if($sqlDump['where_condition']){
|
||||
if((sizeof($sqlDump['where_condition']['column_names']) ==
|
||||
sizeof($sqlDump['where_condition']['column_values'])) &&
|
||||
(sizeof($sqlDump['where_condition']['column_operators']) == sizeof($sqlDump['where_condition']['operators'])+1)){
|
||||
$this->query = $this->query.' WHERE (';
|
||||
$i=0;
|
||||
$referenceFields = $meta->getReferenceFieldDetails();
|
||||
$ownerFields = $meta->getOwnerFields();
|
||||
for(;$i<sizeof($sqlDump['where_condition']['column_values']);++$i){
|
||||
if(!$fieldcol[$sqlDump['where_condition']['column_names'][$i]]){
|
||||
throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to access ".$sqlDump['where_condition']['column_names'][$i]." attribute denied.");
|
||||
}
|
||||
$whereField = $sqlDump['where_condition']['column_names'][$i];
|
||||
$whereOperator = $sqlDump['where_condition']['column_operators'][$i];
|
||||
$whereValue = $sqlDump['where_condition']['column_values'][$i];
|
||||
if(in_array($whereField,array_keys($referenceFields))){
|
||||
if(is_array($whereValue)){
|
||||
foreach($whereValue as $index=>$value){
|
||||
if(strpos($value,'x')===false){
|
||||
throw new WebServiceException(WebServiceErrorCode::$INVALIDID,"Id specified is incorrect");
|
||||
}
|
||||
}
|
||||
$whereValue = array_map(array($this, 'getReferenceValue'),$whereValue);
|
||||
}else if(strpos($whereValue,'x')!==false){
|
||||
$whereValue = $this->getReferenceValue($whereValue);
|
||||
if(strcasecmp($whereOperator,'like')===0){
|
||||
$whereValue = "'".$whereValue."'";
|
||||
}
|
||||
}else{
|
||||
throw new WebServiceException(WebServiceErrorCode::$INVALIDID,"Id specified is incorrect");
|
||||
}
|
||||
}else if(in_array($whereField,$ownerFields)){
|
||||
if(is_array($whereValue)){
|
||||
$groupId = array_map(array($this, 'getOwner'),$whereValue);
|
||||
}else{
|
||||
$groupId = $this->getOwner($whereValue);
|
||||
if(strcasecmp($whereOperator,'like')===0){
|
||||
$groupId = "'$groupId'";
|
||||
}
|
||||
}
|
||||
$whereValue = $groupId;
|
||||
}
|
||||
if(is_array($whereValue)){
|
||||
$whereValue = "(".implode(',',$whereValue).")";
|
||||
}elseif(strcasecmp($whereOperator, 'in') === 0){
|
||||
$whereValue = "($whereValue)";
|
||||
}
|
||||
$this->query = $this->query.$columnTable[$fieldcol[$whereField]].'.'.
|
||||
$fieldcol[$whereField]." ".$whereOperator." ".$whereValue;
|
||||
if($i <sizeof($sqlDump['where_condition']['column_values'])-1){
|
||||
$this->query = $this->query.' ';
|
||||
$this->query = $this->query.$sqlDump['where_condition']['operators'][$i].' ';
|
||||
}
|
||||
}
|
||||
}else{
|
||||
throw new WebServiceException(WebServiceErrorCode::$QUERYSYNTAX, "columns data inappropriate");
|
||||
}
|
||||
$this->query = $this->query.")";
|
||||
$nextToken = ' AND ';
|
||||
}else{
|
||||
if(!empty($deletedQuery)){
|
||||
$nextToken = " WHERE ";
|
||||
}
|
||||
}
|
||||
if(strcasecmp('calendar',$this->out['moduleName'])===0){
|
||||
$this->query = $this->query." $nextToken activitytype='Task' AND ";
|
||||
}elseif(strcasecmp('events',$this->out['moduleName'])===0){
|
||||
$this->query = $this->query."$nextToken activitytype!='Emails' AND activitytype!='Task' AND ";
|
||||
}else if(strcasecmp('emails',$this->out['moduleName'])===0){
|
||||
$this->query = $this->query."$nextToken activitytype='Emails' AND ";
|
||||
}elseif(!empty($deletedQuery)){
|
||||
$this->query = $this->query.$nextToken;
|
||||
}
|
||||
|
||||
$this->query = $this->query.' '.$deletedQuery;
|
||||
|
||||
if($sqlDump['orderby']){
|
||||
$i=0;
|
||||
$this->query = $this->query.' ORDER BY ';
|
||||
foreach($sqlDump['orderby'] as $ind=>$field){
|
||||
if($i===0){
|
||||
$this->query = $this->query.$columnTable[$fieldcol[$field]].".".$fieldcol[$field];
|
||||
$i++;
|
||||
}else{
|
||||
$this->query = $this->query.','.$columnTable[$fieldcol[$field]].".".$fieldcol[$field];
|
||||
}
|
||||
}
|
||||
if($sqlDump['sortOrder']) {
|
||||
$this->query .= ' '.$sqlDump['sortOrder'];
|
||||
}
|
||||
}
|
||||
if($sqlDump['limit']){
|
||||
$i=0;
|
||||
$offset =false;
|
||||
if(sizeof($sqlDump['limit'])>1){
|
||||
$offset = true;
|
||||
}
|
||||
$this->query = $this->query.' LIMIT ';
|
||||
foreach($sqlDump['limit'] as $ind=>$field){
|
||||
if(!$offset){
|
||||
$field = ($field>100)? 100: $field;
|
||||
}
|
||||
if($i===0){
|
||||
$this->query = $this->query.$field;
|
||||
$i++;
|
||||
$offset = false;
|
||||
}else{
|
||||
$this->query = $this->query.','.$field;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$this->query = $this->query.' LIMIT 100';
|
||||
}
|
||||
$this->query = $this->query.';';
|
||||
}
|
||||
function getTables($sqlDump,$columns){
|
||||
$meta = $sqlDump['meta'];
|
||||
$coltable = $meta->getColumnTableMapping();
|
||||
$tables = array();
|
||||
foreach($columns as $ind=>$col){
|
||||
$tables[$coltable[$col]] = $coltable[$col];
|
||||
}
|
||||
$tables = array_keys($tables);
|
||||
return ($tables);
|
||||
}
|
||||
function getReferenceValue($whereValue){
|
||||
$whereValue = trim($whereValue,'\'"');
|
||||
$whereValue = vtws_getIdComponents($whereValue);
|
||||
$whereValue = $whereValue[1];
|
||||
return $whereValue;
|
||||
}
|
||||
function getOwner($whereValue){
|
||||
$whereValue = trim($whereValue,'\'"');
|
||||
$whereValue = vtws_getIdComponents($whereValue);
|
||||
$whereValue = $whereValue[1];
|
||||
return $whereValue;
|
||||
}
|
||||
function isSuccess(){
|
||||
return $this->success;
|
||||
}
|
||||
function getErrorMsg(){
|
||||
return $this->error_msg;
|
||||
}
|
||||
function getQuery(){
|
||||
return $this->query;
|
||||
}
|
||||
function getObjectMetaData(){
|
||||
return $this->out['meta'];
|
||||
}
|
||||
}
|
||||
//%token_prefix VTQL_
|
||||
%declare_class {class VTQL_Parser}
|
||||
%parse_accept {
|
||||
$this->success = true;
|
||||
}
|
||||
|
||||
%parse_failure {
|
||||
if(!$this->syntax_error){
|
||||
throw new WebServiceException(WebServiceErrorCode::$QUERYSYNTAX, "Parsing failed");
|
||||
}
|
||||
}
|
||||
|
||||
%stack_overflow {
|
||||
throw new WebServiceException(WebServiceErrorCode::$QUERYSYNTAX, "Parser stack overflow");
|
||||
}
|
||||
|
||||
%syntax_error {
|
||||
$synMsg = "Syntax Error on line " . $this->lex->linenum . ": token '" .$this->lex->value."' ";
|
||||
$expect = array();
|
||||
foreach ($this->yy_get_expected_tokens($yymajor) as $token) {
|
||||
$expect[] = self::$yyTokenName[$token];
|
||||
}
|
||||
$synMsg =$synMsg.('Unexpected ' . $this->tokenName($yymajor) . '(' . $TOKEN
|
||||
. '), expected one of: ' . implode(',', $expect));
|
||||
|
||||
throw new WebServiceException(WebServiceErrorCode::$QUERYSYNTAX, $synMsg);
|
||||
}
|
||||
|
|
@ -0,0 +1,921 @@
|
|||
<?php
|
||||
/* Driver template for the PHP_ParserGenerator parser generator. (PHP port of LEMON)
|
||||
*/
|
||||
|
||||
/**
|
||||
* This can be used to store both the string representation of
|
||||
* a token, and any useful meta-data associated with the token.
|
||||
*
|
||||
* meta-data should be stored as an array
|
||||
*/
|
||||
class ParseyyToken implements ArrayAccess
|
||||
{
|
||||
public $string = '';
|
||||
public $metadata = array();
|
||||
|
||||
function __construct($s, $m = array())
|
||||
{
|
||||
if ($s instanceof ParseyyToken) {
|
||||
$this->string = $s->string;
|
||||
$this->metadata = $s->metadata;
|
||||
} else {
|
||||
$this->string = (string) $s;
|
||||
if ($m instanceof ParseyyToken) {
|
||||
$this->metadata = $m->metadata;
|
||||
} elseif (is_array($m)) {
|
||||
$this->metadata = $m;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function __toString()
|
||||
{
|
||||
return $this->_string;
|
||||
}
|
||||
|
||||
function offsetExists($offset)
|
||||
{
|
||||
return isset($this->metadata[$offset]);
|
||||
}
|
||||
|
||||
function offsetGet($offset)
|
||||
{
|
||||
return $this->metadata[$offset];
|
||||
}
|
||||
|
||||
function offsetSet($offset, $value)
|
||||
{
|
||||
if ($offset === null) {
|
||||
if (isset($value[0])) {
|
||||
$x = ($value instanceof ParseyyToken) ?
|
||||
$value->metadata : $value;
|
||||
$this->metadata = array_merge($this->metadata, $x);
|
||||
return;
|
||||
}
|
||||
$offset = count($this->metadata);
|
||||
}
|
||||
if ($value === null) {
|
||||
return;
|
||||
}
|
||||
if ($value instanceof ParseyyToken) {
|
||||
if ($value->metadata) {
|
||||
$this->metadata[$offset] = $value->metadata;
|
||||
}
|
||||
} elseif ($value) {
|
||||
$this->metadata[$offset] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
function offsetUnset($offset)
|
||||
{
|
||||
unset($this->metadata[$offset]);
|
||||
}
|
||||
}
|
||||
|
||||
/** The following structure represents a single element of the
|
||||
* parser's stack. Information stored includes:
|
||||
*
|
||||
* + The state number for the parser at this level of the stack.
|
||||
*
|
||||
* + The value of the token stored at this level of the stack.
|
||||
* (In other words, the "major" token.)
|
||||
*
|
||||
* + The semantic value stored at this level of the stack. This is
|
||||
* the information used by the action routines in the grammar.
|
||||
* It is sometimes called the "minor" token.
|
||||
*/
|
||||
class ParseyyStackEntry
|
||||
{
|
||||
public $stateno; /* The state-number */
|
||||
public $major; /* The major token value. This is the code
|
||||
** number for the token at this stack level */
|
||||
public $minor; /* The user-supplied minor token value. This
|
||||
** is the value of the token */
|
||||
};
|
||||
|
||||
// code external to the class is included here
|
||||
%%
|
||||
|
||||
// declare_class is output here
|
||||
%%
|
||||
{
|
||||
/* First off, code is included which follows the "include_class" declaration
|
||||
** in the input file. */
|
||||
%%
|
||||
|
||||
/* Next is all token values, as class constants
|
||||
*/
|
||||
/*
|
||||
** These constants (all generated automatically by the parser generator)
|
||||
** specify the various kinds of tokens (terminals) that the parser
|
||||
** understands.
|
||||
**
|
||||
** Each symbol here is a terminal symbol in the grammar.
|
||||
*/
|
||||
%%
|
||||
|
||||
/* Next are that tables used to determine what action to take based on the
|
||||
** current state and lookahead token. These tables are used to implement
|
||||
** functions that take a state number and lookahead value and return an
|
||||
** action integer.
|
||||
**
|
||||
** Suppose the action integer is N. Then the action is determined as
|
||||
** follows
|
||||
**
|
||||
** 0 <= N < self::YYNSTATE Shift N. That is,
|
||||
** push the lookahead
|
||||
** token onto the stack
|
||||
** and goto state N.
|
||||
**
|
||||
** self::YYNSTATE <= N < self::YYNSTATE+self::YYNRULE Reduce by rule N-YYNSTATE.
|
||||
**
|
||||
** N == self::YYNSTATE+self::YYNRULE A syntax error has occurred.
|
||||
**
|
||||
** N == self::YYNSTATE+self::YYNRULE+1 The parser accepts its
|
||||
** input. (and concludes parsing)
|
||||
**
|
||||
** N == self::YYNSTATE+self::YYNRULE+2 No such action. Denotes unused
|
||||
** slots in the yy_action[] table.
|
||||
**
|
||||
** The action table is constructed as a single large static array $yy_action.
|
||||
** Given state S and lookahead X, the action is computed as
|
||||
**
|
||||
** self::$yy_action[self::$yy_shift_ofst[S] + X ]
|
||||
**
|
||||
** If the index value self::$yy_shift_ofst[S]+X is out of range or if the value
|
||||
** self::$yy_lookahead[self::$yy_shift_ofst[S]+X] is not equal to X or if
|
||||
** self::$yy_shift_ofst[S] is equal to self::YY_SHIFT_USE_DFLT, it means that
|
||||
** the action is not in the table and that self::$yy_default[S] should be used instead.
|
||||
**
|
||||
** The formula above is for computing the action when the lookahead is
|
||||
** a terminal symbol. If the lookahead is a non-terminal (as occurs after
|
||||
** a reduce action) then the static $yy_reduce_ofst array is used in place of
|
||||
** the static $yy_shift_ofst array and self::YY_REDUCE_USE_DFLT is used in place of
|
||||
** self::YY_SHIFT_USE_DFLT.
|
||||
**
|
||||
** The following are the tables generated in this section:
|
||||
**
|
||||
** self::$yy_action A single table containing all actions.
|
||||
** self::$yy_lookahead A table containing the lookahead for each entry in
|
||||
** yy_action. Used to detect hash collisions.
|
||||
** self::$yy_shift_ofst For each state, the offset into self::$yy_action for
|
||||
** shifting terminals.
|
||||
** self::$yy_reduce_ofst For each state, the offset into self::$yy_action for
|
||||
** shifting non-terminals after a reduce.
|
||||
** self::$yy_default Default action for each state.
|
||||
*/
|
||||
%%
|
||||
/* The next thing included is series of defines which control
|
||||
** various aspects of the generated parser.
|
||||
** self::YYNOCODE is a number which corresponds
|
||||
** to no legal terminal or nonterminal number. This
|
||||
** number is used to fill in empty slots of the hash
|
||||
** table.
|
||||
** self::YYFALLBACK If defined, this indicates that one or more tokens
|
||||
** have fall-back values which should be used if the
|
||||
** original value of the token will not parse.
|
||||
** self::YYSTACKDEPTH is the maximum depth of the parser's stack.
|
||||
** self::YYNSTATE the combined number of states.
|
||||
** self::YYNRULE the number of rules in the grammar
|
||||
** self::YYERRORSYMBOL is the code number of the error symbol. If not
|
||||
** defined, then do no error processing.
|
||||
*/
|
||||
%%
|
||||
/** The next table maps tokens into fallback tokens. If a construct
|
||||
* like the following:
|
||||
*
|
||||
* %fallback ID X Y Z.
|
||||
*
|
||||
* appears in the grammer, then ID becomes a fallback token for X, Y,
|
||||
* and Z. Whenever one of the tokens X, Y, or Z is input to the parser
|
||||
* but it does not parse, the type of the token is changed to ID and
|
||||
* the parse is retried before an error is thrown.
|
||||
*/
|
||||
static public $yyFallback = array(
|
||||
%%
|
||||
);
|
||||
/**
|
||||
* Turn parser tracing on by giving a stream to which to write the trace
|
||||
* and a prompt to preface each trace message. Tracing is turned off
|
||||
* by making either argument NULL
|
||||
*
|
||||
* Inputs:
|
||||
*
|
||||
* - A stream resource to which trace output should be written.
|
||||
* If NULL, then tracing is turned off.
|
||||
* - A prefix string written at the beginning of every
|
||||
* line of trace output. If NULL, then tracing is
|
||||
* turned off.
|
||||
*
|
||||
* Outputs:
|
||||
*
|
||||
* - None.
|
||||
* @param resource
|
||||
* @param string
|
||||
*/
|
||||
static function Trace($TraceFILE, $zTracePrompt)
|
||||
{
|
||||
if (!$TraceFILE) {
|
||||
$zTracePrompt = 0;
|
||||
} elseif (!$zTracePrompt) {
|
||||
$TraceFILE = 0;
|
||||
}
|
||||
self::$yyTraceFILE = $TraceFILE;
|
||||
self::$yyTracePrompt = $zTracePrompt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output debug information to output (php://output stream)
|
||||
*/
|
||||
static function PrintTrace()
|
||||
{
|
||||
self::$yyTraceFILE = fopen('php://output', 'w');
|
||||
self::$yyTracePrompt = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @var resource|0
|
||||
*/
|
||||
static public $yyTraceFILE;
|
||||
/**
|
||||
* String to prepend to debug output
|
||||
* @var string|0
|
||||
*/
|
||||
static public $yyTracePrompt;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $yyidx; /* Index of top element in stack */
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $yyerrcnt; /* Shifts left before out of the error */
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $yystack = array(); /* The parser's stack */
|
||||
|
||||
/**
|
||||
* For tracing shifts, the names of all terminals and nonterminals
|
||||
* are required. The following table supplies these names
|
||||
* @var array
|
||||
*/
|
||||
static public $yyTokenName = array(
|
||||
%%
|
||||
);
|
||||
|
||||
/**
|
||||
* For tracing reduce actions, the names of all rules are required.
|
||||
* @var array
|
||||
*/
|
||||
static public $yyRuleName = array(
|
||||
%%
|
||||
);
|
||||
|
||||
/**
|
||||
* This function returns the symbolic name associated with a token
|
||||
* value.
|
||||
* @param int
|
||||
* @return string
|
||||
*/
|
||||
function tokenName($tokenType)
|
||||
{
|
||||
if ($tokenType === 0) {
|
||||
return 'End of Input';
|
||||
}
|
||||
if ($tokenType > 0 && $tokenType < count(self::$yyTokenName)) {
|
||||
return self::$yyTokenName[$tokenType];
|
||||
} else {
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The following function deletes the value associated with a
|
||||
* symbol. The symbol can be either a terminal or nonterminal.
|
||||
* @param int the symbol code
|
||||
* @param mixed the symbol's value
|
||||
*/
|
||||
static function yy_destructor($yymajor, $yypminor)
|
||||
{
|
||||
switch ($yymajor) {
|
||||
/* Here is inserted the actions which take place when a
|
||||
** terminal or non-terminal is destroyed. This can happen
|
||||
** when the symbol is popped from the stack during a
|
||||
** reduce or during error processing or when a parser is
|
||||
** being destroyed before it is finished parsing.
|
||||
**
|
||||
** Note: during a reduce, the only symbols destroyed are those
|
||||
** which appear on the RHS of the rule, but which are not used
|
||||
** inside the C code.
|
||||
*/
|
||||
%%
|
||||
default: break; /* If no destructor action specified: do nothing */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pop the parser's stack once.
|
||||
*
|
||||
* If there is a destructor routine associated with the token which
|
||||
* is popped from the stack, then call it.
|
||||
*
|
||||
* Return the major token number for the symbol popped.
|
||||
* @param ParseyyParser
|
||||
* @return int
|
||||
*/
|
||||
function yy_pop_parser_stack()
|
||||
{
|
||||
if (!count($this->yystack)) {
|
||||
return;
|
||||
}
|
||||
$yytos = array_pop($this->yystack);
|
||||
if (self::$yyTraceFILE && $this->yyidx >= 0) {
|
||||
fwrite(self::$yyTraceFILE,
|
||||
self::$yyTracePrompt . 'Popping ' . self::$yyTokenName[$yytos->major] .
|
||||
"\n");
|
||||
}
|
||||
$yymajor = $yytos->major;
|
||||
self::yy_destructor($yymajor, $yytos->minor);
|
||||
$this->yyidx--;
|
||||
return $yymajor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deallocate and destroy a parser. Destructors are all called for
|
||||
* all stack elements before shutting the parser down.
|
||||
*/
|
||||
function __destruct()
|
||||
{
|
||||
while ($this->yyidx >= 0) {
|
||||
$this->yy_pop_parser_stack();
|
||||
}
|
||||
if (is_resource(self::$yyTraceFILE)) {
|
||||
fclose(self::$yyTraceFILE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Based on the current state and parser stack, get a list of all
|
||||
* possible lookahead tokens
|
||||
* @param int
|
||||
* @return array
|
||||
*/
|
||||
function yy_get_expected_tokens($token)
|
||||
{
|
||||
$state = $this->yystack[$this->yyidx]->stateno;
|
||||
$expected = self::$yyExpectedTokens[$state];
|
||||
if (in_array($token, self::$yyExpectedTokens[$state], true)) {
|
||||
return $expected;
|
||||
}
|
||||
$stack = $this->yystack;
|
||||
$yyidx = $this->yyidx;
|
||||
do {
|
||||
$yyact = $this->yy_find_shift_action($token);
|
||||
if ($yyact >= self::YYNSTATE && $yyact < self::YYNSTATE + self::YYNRULE) {
|
||||
// reduce action
|
||||
$done = 0;
|
||||
do {
|
||||
if ($done++ == 100) {
|
||||
$this->yyidx = $yyidx;
|
||||
$this->yystack = $stack;
|
||||
// too much recursion prevents proper detection
|
||||
// so give up
|
||||
return array_unique($expected);
|
||||
}
|
||||
$yyruleno = $yyact - self::YYNSTATE;
|
||||
$this->yyidx -= self::$yyRuleInfo[$yyruleno]['rhs'];
|
||||
$nextstate = $this->yy_find_reduce_action(
|
||||
$this->yystack[$this->yyidx]->stateno,
|
||||
self::$yyRuleInfo[$yyruleno]['lhs']);
|
||||
if (isset(self::$yyExpectedTokens[$nextstate])) {
|
||||
$expected += self::$yyExpectedTokens[$nextstate];
|
||||
if (in_array($token,
|
||||
self::$yyExpectedTokens[$nextstate], true)) {
|
||||
$this->yyidx = $yyidx;
|
||||
$this->yystack = $stack;
|
||||
return array_unique($expected);
|
||||
}
|
||||
}
|
||||
if ($nextstate < self::YYNSTATE) {
|
||||
// we need to shift a non-terminal
|
||||
$this->yyidx++;
|
||||
$x = new ParseyyStackEntry;
|
||||
$x->stateno = $nextstate;
|
||||
$x->major = self::$yyRuleInfo[$yyruleno]['lhs'];
|
||||
$this->yystack[$this->yyidx] = $x;
|
||||
continue 2;
|
||||
} elseif ($nextstate == self::YYNSTATE + self::YYNRULE + 1) {
|
||||
$this->yyidx = $yyidx;
|
||||
$this->yystack = $stack;
|
||||
// the last token was just ignored, we can't accept
|
||||
// by ignoring input, this is in essence ignoring a
|
||||
// syntax error!
|
||||
return array_unique($expected);
|
||||
} elseif ($nextstate === self::YY_NO_ACTION) {
|
||||
$this->yyidx = $yyidx;
|
||||
$this->yystack = $stack;
|
||||
// input accepted, but not shifted (I guess)
|
||||
return $expected;
|
||||
} else {
|
||||
$yyact = $nextstate;
|
||||
}
|
||||
} while (true);
|
||||
}
|
||||
break;
|
||||
} while (true);
|
||||
return array_unique($expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Based on the parser state and current parser stack, determine whether
|
||||
* the lookahead token is possible.
|
||||
*
|
||||
* The parser will convert the token value to an error token if not. This
|
||||
* catches some unusual edge cases where the parser would fail.
|
||||
* @param int
|
||||
* @return bool
|
||||
*/
|
||||
function yy_is_expected_token($token)
|
||||
{
|
||||
if ($token === 0) {
|
||||
return true; // 0 is not part of this
|
||||
}
|
||||
$state = $this->yystack[$this->yyidx]->stateno;
|
||||
if (in_array($token, self::$yyExpectedTokens[$state], true)) {
|
||||
return true;
|
||||
}
|
||||
$stack = $this->yystack;
|
||||
$yyidx = $this->yyidx;
|
||||
do {
|
||||
$yyact = $this->yy_find_shift_action($token);
|
||||
if ($yyact >= self::YYNSTATE && $yyact < self::YYNSTATE + self::YYNRULE) {
|
||||
// reduce action
|
||||
$done = 0;
|
||||
do {
|
||||
if ($done++ == 100) {
|
||||
$this->yyidx = $yyidx;
|
||||
$this->yystack = $stack;
|
||||
// too much recursion prevents proper detection
|
||||
// so give up
|
||||
return true;
|
||||
}
|
||||
$yyruleno = $yyact - self::YYNSTATE;
|
||||
$this->yyidx -= self::$yyRuleInfo[$yyruleno]['rhs'];
|
||||
$nextstate = $this->yy_find_reduce_action(
|
||||
$this->yystack[$this->yyidx]->stateno,
|
||||
self::$yyRuleInfo[$yyruleno]['lhs']);
|
||||
if (isset(self::$yyExpectedTokens[$nextstate]) &&
|
||||
in_array($token, self::$yyExpectedTokens[$nextstate], true)) {
|
||||
$this->yyidx = $yyidx;
|
||||
$this->yystack = $stack;
|
||||
return true;
|
||||
}
|
||||
if ($nextstate < self::YYNSTATE) {
|
||||
// we need to shift a non-terminal
|
||||
$this->yyidx++;
|
||||
$x = new ParseyyStackEntry;
|
||||
$x->stateno = $nextstate;
|
||||
$x->major = self::$yyRuleInfo[$yyruleno]['lhs'];
|
||||
$this->yystack[$this->yyidx] = $x;
|
||||
continue 2;
|
||||
} elseif ($nextstate == self::YYNSTATE + self::YYNRULE + 1) {
|
||||
$this->yyidx = $yyidx;
|
||||
$this->yystack = $stack;
|
||||
if (!$token) {
|
||||
// end of input: this is valid
|
||||
return true;
|
||||
}
|
||||
// the last token was just ignored, we can't accept
|
||||
// by ignoring input, this is in essence ignoring a
|
||||
// syntax error!
|
||||
return false;
|
||||
} elseif ($nextstate === self::YY_NO_ACTION) {
|
||||
$this->yyidx = $yyidx;
|
||||
$this->yystack = $stack;
|
||||
// input accepted, but not shifted (I guess)
|
||||
return true;
|
||||
} else {
|
||||
$yyact = $nextstate;
|
||||
}
|
||||
} while (true);
|
||||
}
|
||||
break;
|
||||
} while (true);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the appropriate action for a parser given the terminal
|
||||
* look-ahead token iLookAhead.
|
||||
*
|
||||
* If the look-ahead token is YYNOCODE, then check to see if the action is
|
||||
* independent of the look-ahead. If it is, return the action, otherwise
|
||||
* return YY_NO_ACTION.
|
||||
* @param int The look-ahead token
|
||||
*/
|
||||
function yy_find_shift_action($iLookAhead)
|
||||
{
|
||||
$stateno = $this->yystack[$this->yyidx]->stateno;
|
||||
|
||||
/* if ($this->yyidx < 0) return self::YY_NO_ACTION; */
|
||||
if (!isset(self::$yy_shift_ofst[$stateno])) {
|
||||
// no shift actions
|
||||
return self::$yy_default[$stateno];
|
||||
}
|
||||
$i = self::$yy_shift_ofst[$stateno];
|
||||
if ($i === self::YY_SHIFT_USE_DFLT) {
|
||||
return self::$yy_default[$stateno];
|
||||
}
|
||||
if ($iLookAhead == self::YYNOCODE) {
|
||||
return self::YY_NO_ACTION;
|
||||
}
|
||||
$i += $iLookAhead;
|
||||
if ($i < 0 || $i >= self::YY_SZ_ACTTAB ||
|
||||
self::$yy_lookahead[$i] != $iLookAhead) {
|
||||
if (count(self::$yyFallback) && $iLookAhead < count(self::$yyFallback)
|
||||
&& ($iFallback = self::$yyFallback[$iLookAhead]) != 0) {
|
||||
if (self::$yyTraceFILE) {
|
||||
fwrite(self::$yyTraceFILE, self::$yyTracePrompt . "FALLBACK " .
|
||||
self::$yyTokenName[$iLookAhead] . " => " .
|
||||
self::$yyTokenName[$iFallback] . "\n");
|
||||
}
|
||||
return $this->yy_find_shift_action($iFallback);
|
||||
}
|
||||
return self::$yy_default[$stateno];
|
||||
} else {
|
||||
return self::$yy_action[$i];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the appropriate action for a parser given the non-terminal
|
||||
* look-ahead token $iLookAhead.
|
||||
*
|
||||
* If the look-ahead token is self::YYNOCODE, then check to see if the action is
|
||||
* independent of the look-ahead. If it is, return the action, otherwise
|
||||
* return self::YY_NO_ACTION.
|
||||
* @param int Current state number
|
||||
* @param int The look-ahead token
|
||||
*/
|
||||
function yy_find_reduce_action($stateno, $iLookAhead)
|
||||
{
|
||||
/* $stateno = $this->yystack[$this->yyidx]->stateno; */
|
||||
|
||||
if (!isset(self::$yy_reduce_ofst[$stateno])) {
|
||||
return self::$yy_default[$stateno];
|
||||
}
|
||||
$i = self::$yy_reduce_ofst[$stateno];
|
||||
if ($i == self::YY_REDUCE_USE_DFLT) {
|
||||
return self::$yy_default[$stateno];
|
||||
}
|
||||
if ($iLookAhead == self::YYNOCODE) {
|
||||
return self::YY_NO_ACTION;
|
||||
}
|
||||
$i += $iLookAhead;
|
||||
if ($i < 0 || $i >= self::YY_SZ_ACTTAB ||
|
||||
self::$yy_lookahead[$i] != $iLookAhead) {
|
||||
return self::$yy_default[$stateno];
|
||||
} else {
|
||||
return self::$yy_action[$i];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a shift action.
|
||||
* @param int The new state to shift in
|
||||
* @param int The major token to shift in
|
||||
* @param mixed the minor token to shift in
|
||||
*/
|
||||
function yy_shift($yyNewState, $yyMajor, $yypMinor)
|
||||
{
|
||||
$this->yyidx++;
|
||||
if ($this->yyidx >= self::YYSTACKDEPTH) {
|
||||
$this->yyidx--;
|
||||
if (self::$yyTraceFILE) {
|
||||
fprintf(self::$yyTraceFILE, "%sStack Overflow!\n", self::$yyTracePrompt);
|
||||
}
|
||||
while ($this->yyidx >= 0) {
|
||||
$this->yy_pop_parser_stack();
|
||||
}
|
||||
/* Here code is inserted which will execute if the parser
|
||||
** stack ever overflows */
|
||||
%%
|
||||
return;
|
||||
}
|
||||
$yytos = new ParseyyStackEntry;
|
||||
$yytos->stateno = $yyNewState;
|
||||
$yytos->major = $yyMajor;
|
||||
$yytos->minor = $yypMinor;
|
||||
array_push($this->yystack, $yytos);
|
||||
if (self::$yyTraceFILE && $this->yyidx > 0) {
|
||||
fprintf(self::$yyTraceFILE, "%sShift %d\n", self::$yyTracePrompt,
|
||||
$yyNewState);
|
||||
fprintf(self::$yyTraceFILE, "%sStack:", self::$yyTracePrompt);
|
||||
for($i = 1; $i <= $this->yyidx; $i++) {
|
||||
fprintf(self::$yyTraceFILE, " %s",
|
||||
self::$yyTokenName[$this->yystack[$i]->major]);
|
||||
}
|
||||
fwrite(self::$yyTraceFILE,"\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The following table contains information about every rule that
|
||||
* is used during the reduce.
|
||||
*
|
||||
* <pre>
|
||||
* array(
|
||||
* array(
|
||||
* int $lhs; Symbol on the left-hand side of the rule
|
||||
* int $nrhs; Number of right-hand side symbols in the rule
|
||||
* ),...
|
||||
* );
|
||||
* </pre>
|
||||
*/
|
||||
static public $yyRuleInfo = array(
|
||||
%%
|
||||
);
|
||||
|
||||
/**
|
||||
* The following table contains a mapping of reduce action to method name
|
||||
* that handles the reduction.
|
||||
*
|
||||
* If a rule is not set, it has no handler.
|
||||
*/
|
||||
static public $yyReduceMap = array(
|
||||
%%
|
||||
);
|
||||
/* Beginning here are the reduction cases. A typical example
|
||||
** follows:
|
||||
** #line <lineno> <grammarfile>
|
||||
** function yy_r0($yymsp){ ... } // User supplied code
|
||||
** #line <lineno> <thisfile>
|
||||
*/
|
||||
%%
|
||||
|
||||
/**
|
||||
* placeholder for the left hand side in a reduce operation.
|
||||
*
|
||||
* For a parser with a rule like this:
|
||||
* <pre>
|
||||
* rule(A) ::= B. { A = 1; }
|
||||
* </pre>
|
||||
*
|
||||
* The parser will translate to something like:
|
||||
*
|
||||
* <code>
|
||||
* function yy_r0(){$this->_retvalue = 1;}
|
||||
* </code>
|
||||
*/
|
||||
private $_retvalue;
|
||||
|
||||
/**
|
||||
* Perform a reduce action and the shift that must immediately
|
||||
* follow the reduce.
|
||||
*
|
||||
* For a rule such as:
|
||||
*
|
||||
* <pre>
|
||||
* A ::= B blah C. { dosomething(); }
|
||||
* </pre>
|
||||
*
|
||||
* This function will first call the action, if any, ("dosomething();" in our
|
||||
* example), and then it will pop three states from the stack,
|
||||
* one for each entry on the right-hand side of the expression
|
||||
* (B, blah, and C in our example rule), and then push the result of the action
|
||||
* back on to the stack with the resulting state reduced to (as described in the .out
|
||||
* file)
|
||||
* @param int Number of the rule by which to reduce
|
||||
*/
|
||||
function yy_reduce($yyruleno)
|
||||
{
|
||||
//int $yygoto; /* The next state */
|
||||
//int $yyact; /* The next action */
|
||||
//mixed $yygotominor; /* The LHS of the rule reduced */
|
||||
//ParseyyStackEntry $yymsp; /* The top of the parser's stack */
|
||||
//int $yysize; /* Amount to pop the stack */
|
||||
$yymsp = $this->yystack[$this->yyidx];
|
||||
if (self::$yyTraceFILE && $yyruleno >= 0
|
||||
&& $yyruleno < count(self::$yyRuleName)) {
|
||||
fprintf(self::$yyTraceFILE, "%sReduce (%d) [%s].\n",
|
||||
self::$yyTracePrompt, $yyruleno,
|
||||
self::$yyRuleName[$yyruleno]);
|
||||
}
|
||||
|
||||
$this->_retvalue = $yy_lefthand_side = null;
|
||||
if (array_key_exists($yyruleno, self::$yyReduceMap)) {
|
||||
// call the action
|
||||
$this->_retvalue = null;
|
||||
$this->{'yy_r' . self::$yyReduceMap[$yyruleno]}();
|
||||
$yy_lefthand_side = $this->_retvalue;
|
||||
}
|
||||
$yygoto = self::$yyRuleInfo[$yyruleno]['lhs'];
|
||||
$yysize = self::$yyRuleInfo[$yyruleno]['rhs'];
|
||||
$this->yyidx -= $yysize;
|
||||
for($i = $yysize; $i; $i--) {
|
||||
// pop all of the right-hand side parameters
|
||||
array_pop($this->yystack);
|
||||
}
|
||||
$yyact = $this->yy_find_reduce_action($this->yystack[$this->yyidx]->stateno, $yygoto);
|
||||
if ($yyact < self::YYNSTATE) {
|
||||
/* If we are not debugging and the reduce action popped at least
|
||||
** one element off the stack, then we can push the new element back
|
||||
** onto the stack here, and skip the stack overflow test in yy_shift().
|
||||
** That gives a significant speed improvement. */
|
||||
if (!self::$yyTraceFILE && $yysize) {
|
||||
$this->yyidx++;
|
||||
$x = new ParseyyStackEntry;
|
||||
$x->stateno = $yyact;
|
||||
$x->major = $yygoto;
|
||||
$x->minor = $yy_lefthand_side;
|
||||
$this->yystack[$this->yyidx] = $x;
|
||||
} else {
|
||||
$this->yy_shift($yyact, $yygoto, $yy_lefthand_side);
|
||||
}
|
||||
} elseif ($yyact == self::YYNSTATE + self::YYNRULE + 1) {
|
||||
$this->yy_accept();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The following code executes when the parse fails
|
||||
*
|
||||
* Code from %parse_fail is inserted here
|
||||
*/
|
||||
function yy_parse_failed()
|
||||
{
|
||||
if (self::$yyTraceFILE) {
|
||||
fprintf(self::$yyTraceFILE, "%sFail!\n", self::$yyTracePrompt);
|
||||
}
|
||||
while ($this->yyidx >= 0) {
|
||||
$this->yy_pop_parser_stack();
|
||||
}
|
||||
/* Here code is inserted which will be executed whenever the
|
||||
** parser fails */
|
||||
%%
|
||||
}
|
||||
|
||||
/**
|
||||
* The following code executes when a syntax error first occurs.
|
||||
*
|
||||
* %syntax_error code is inserted here
|
||||
* @param int The major type of the error token
|
||||
* @param mixed The minor type of the error token
|
||||
*/
|
||||
function yy_syntax_error($yymajor, $TOKEN)
|
||||
{
|
||||
%%
|
||||
}
|
||||
|
||||
/**
|
||||
* The following is executed when the parser accepts
|
||||
*
|
||||
* %parse_accept code is inserted here
|
||||
*/
|
||||
function yy_accept()
|
||||
{
|
||||
if (self::$yyTraceFILE) {
|
||||
fprintf(self::$yyTraceFILE, "%sAccept!\n", self::$yyTracePrompt);
|
||||
}
|
||||
while ($this->yyidx >= 0) {
|
||||
$stack = $this->yy_pop_parser_stack();
|
||||
}
|
||||
/* Here code is inserted which will be executed whenever the
|
||||
** parser accepts */
|
||||
%%
|
||||
}
|
||||
|
||||
/**
|
||||
* The main parser program.
|
||||
*
|
||||
* The first argument is the major token number. The second is
|
||||
* the token value string as scanned from the input.
|
||||
*
|
||||
* @param int the token number
|
||||
* @param mixed the token value
|
||||
* @param mixed any extra arguments that should be passed to handlers
|
||||
*/
|
||||
function doParse($yymajor, $yytokenvalue)
|
||||
{
|
||||
// $yyact; /* The parser action. */
|
||||
// $yyendofinput; /* True if we are at the end of input */
|
||||
$yyerrorhit = 0; /* True if yymajor has invoked an error */
|
||||
|
||||
/* (re)initialize the parser, if necessary */
|
||||
if ($this->yyidx === null || $this->yyidx < 0) {
|
||||
/* if ($yymajor == 0) return; // not sure why this was here... */
|
||||
$this->yyidx = 0;
|
||||
$this->yyerrcnt = -1;
|
||||
$x = new ParseyyStackEntry;
|
||||
$x->stateno = 0;
|
||||
$x->major = 0;
|
||||
$this->yystack = array();
|
||||
array_push($this->yystack, $x);
|
||||
}
|
||||
$yyendofinput = ($yymajor==0);
|
||||
|
||||
if (self::$yyTraceFILE) {
|
||||
fprintf(self::$yyTraceFILE, "%sInput %s\n",
|
||||
self::$yyTracePrompt, self::$yyTokenName[$yymajor]);
|
||||
}
|
||||
|
||||
do {
|
||||
$yyact = $this->yy_find_shift_action($yymajor);
|
||||
if ($yymajor < self::YYERRORSYMBOL &&
|
||||
!$this->yy_is_expected_token($yymajor)) {
|
||||
// force a syntax error
|
||||
$yyact = self::YY_ERROR_ACTION;
|
||||
}
|
||||
if ($yyact < self::YYNSTATE) {
|
||||
$this->yy_shift($yyact, $yymajor, $yytokenvalue);
|
||||
$this->yyerrcnt--;
|
||||
if ($yyendofinput && $this->yyidx >= 0) {
|
||||
$yymajor = 0;
|
||||
} else {
|
||||
$yymajor = self::YYNOCODE;
|
||||
}
|
||||
} elseif ($yyact < self::YYNSTATE + self::YYNRULE) {
|
||||
$this->yy_reduce($yyact - self::YYNSTATE);
|
||||
} elseif ($yyact == self::YY_ERROR_ACTION) {
|
||||
if (self::$yyTraceFILE) {
|
||||
fprintf(self::$yyTraceFILE, "%sSyntax Error!\n",
|
||||
self::$yyTracePrompt);
|
||||
}
|
||||
if (self::YYERRORSYMBOL) {
|
||||
/* A syntax error has occurred.
|
||||
** The response to an error depends upon whether or not the
|
||||
** grammar defines an error token "ERROR".
|
||||
**
|
||||
** This is what we do if the grammar does define ERROR:
|
||||
**
|
||||
** * Call the %syntax_error function.
|
||||
**
|
||||
** * Begin popping the stack until we enter a state where
|
||||
** it is legal to shift the error symbol, then shift
|
||||
** the error symbol.
|
||||
**
|
||||
** * Set the error count to three.
|
||||
**
|
||||
** * Begin accepting and shifting new tokens. No new error
|
||||
** processing will occur until three tokens have been
|
||||
** shifted successfully.
|
||||
**
|
||||
*/
|
||||
if ($this->yyerrcnt < 0) {
|
||||
$this->yy_syntax_error($yymajor, $yytokenvalue);
|
||||
}
|
||||
$yymx = $this->yystack[$this->yyidx]->major;
|
||||
if ($yymx == self::YYERRORSYMBOL || $yyerrorhit ){
|
||||
if (self::$yyTraceFILE) {
|
||||
fprintf(self::$yyTraceFILE, "%sDiscard input token %s\n",
|
||||
self::$yyTracePrompt, self::$yyTokenName[$yymajor]);
|
||||
}
|
||||
$this->yy_destructor($yymajor, $yytokenvalue);
|
||||
$yymajor = self::YYNOCODE;
|
||||
} else {
|
||||
while ($this->yyidx >= 0 &&
|
||||
$yymx != self::YYERRORSYMBOL &&
|
||||
($yyact = $this->yy_find_shift_action(self::YYERRORSYMBOL)) >= self::YYNSTATE
|
||||
){
|
||||
$this->yy_pop_parser_stack();
|
||||
}
|
||||
if ($this->yyidx < 0 || $yymajor==0) {
|
||||
$this->yy_destructor($yymajor, $yytokenvalue);
|
||||
$this->yy_parse_failed();
|
||||
$yymajor = self::YYNOCODE;
|
||||
} elseif ($yymx != self::YYERRORSYMBOL) {
|
||||
$u2 = 0;
|
||||
$this->yy_shift($yyact, self::YYERRORSYMBOL, $u2);
|
||||
}
|
||||
}
|
||||
$this->yyerrcnt = 3;
|
||||
$yyerrorhit = 1;
|
||||
} else {
|
||||
/* YYERRORSYMBOL is not defined */
|
||||
/* This is what we do if the grammar does not define ERROR:
|
||||
**
|
||||
** * Report an error message, and throw away the input token.
|
||||
**
|
||||
** * If the input token is $, then fail the parse.
|
||||
**
|
||||
** As before, subsequent error messages are suppressed until
|
||||
** three input tokens have been successfully shifted.
|
||||
*/
|
||||
if ($this->yyerrcnt <= 0) {
|
||||
$this->yy_syntax_error($yymajor, $yytokenvalue);
|
||||
}
|
||||
$this->yyerrcnt = 3;
|
||||
$this->yy_destructor($yymajor, $yytokenvalue);
|
||||
if ($yyendofinput) {
|
||||
$this->yy_parse_failed();
|
||||
}
|
||||
$yymajor = self::YYNOCODE;
|
||||
}
|
||||
} else {
|
||||
$this->yy_accept();
|
||||
$yymajor = self::YYNOCODE;
|
||||
}
|
||||
} while ($yymajor != self::YYNOCODE && $this->yyidx >= 0);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,184 @@
|
|||
<?php
|
||||
/**
|
||||
* PHP_LexerGenerator, a php 5 lexer generator.
|
||||
*
|
||||
* This lexer generator translates a file in a format similar to
|
||||
* re2c ({@link http://re2c.org}) and translates it into a PHP 5-based lexer
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* Copyright (c) 2006, Gregory Beaver <cellog@php.net>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the PHP_LexerGenerator nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category php
|
||||
* @package PHP_LexerGenerator
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 2006 Gregory Beaver
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
|
||||
* @version CVS: $Id$
|
||||
* @since File available since Release 0.1.0
|
||||
*/
|
||||
/**
|
||||
* The Lexer generation parser
|
||||
*/
|
||||
require_once 'PHP/LexerGenerator/Parser.php';
|
||||
/**
|
||||
* Hand-written lexer for lex2php format files
|
||||
*/
|
||||
require_once 'PHP/LexerGenerator/Lexer.php';
|
||||
/**
|
||||
* The basic home class for the lexer generator. A lexer scans text and
|
||||
* organizes it into tokens for usage by a parser.
|
||||
*
|
||||
* Sample Usage:
|
||||
* <code>
|
||||
* require_once 'PHP/LexerGenerator.php';
|
||||
* $lex = new PHP_LexerGenerator('/path/to/lexerfile.plex');
|
||||
* </code>
|
||||
*
|
||||
* A file named "/path/to/lexerfile.php" will be created.
|
||||
*
|
||||
* File format consists of a PHP file containing specially
|
||||
* formatted comments like so:
|
||||
*
|
||||
* <code>
|
||||
* /*!lex2php
|
||||
* {@*}
|
||||
* </code>
|
||||
*
|
||||
* The first lex2php comment must contain several declarations and define
|
||||
* all regular expressions. Declarations (processor instructions) start with
|
||||
* a "%" symbol and must be:
|
||||
*
|
||||
* - %counter
|
||||
* - %input
|
||||
* - %token
|
||||
* - %value
|
||||
* - %line
|
||||
*
|
||||
* token and counter should define the class variables used to define lexer input
|
||||
* and the index into the input. token and value should be used to define the class
|
||||
* variables used to store the token number and its textual value. Finally, line
|
||||
* should be used to define the class variable used to define the current line number
|
||||
* of scanning.
|
||||
*
|
||||
* For example:
|
||||
* <code>
|
||||
* /*!lex2php
|
||||
* %counter {$this->N}
|
||||
* %input {$this->data}
|
||||
* %token {$this->token}
|
||||
* %value {$this->value}
|
||||
* %line {%this->linenumber}
|
||||
* {@*}
|
||||
* </code>
|
||||
*
|
||||
* Patterns consist of an identifier containing upper or lower-cased letters, and
|
||||
* a descriptive match pattern.
|
||||
*
|
||||
* Descriptive match patterns may either be regular expressions (regexes) or
|
||||
* quoted literal strings. Here are some examples:
|
||||
*
|
||||
* <pre>
|
||||
* pattern = "quoted literal"
|
||||
* ANOTHER = /[a-zA-Z_]+/
|
||||
* </pre>
|
||||
*
|
||||
* Quoted strings must escape the \ and " characters with \" and \\.
|
||||
*
|
||||
* Regex patterns must be in Perl-compatible regular expression format (preg).
|
||||
* special characters (like \t \n or \x3H) can only be used in regexes, all
|
||||
* \ will be escaped in literal strings.
|
||||
*
|
||||
* Any sub-patterns must be defined using (?:) instead of ():
|
||||
*
|
||||
* <code>
|
||||
* /*!lex2php
|
||||
* %counter {$this->N}
|
||||
* %input {$this->data}
|
||||
* %token {$this->token}
|
||||
* %value {$this->value}
|
||||
* %line {%this->linenumber}
|
||||
* alpha = /[a-zA-Z]/
|
||||
* alphaplus = /[a-zA-Z]+/
|
||||
* number = /[0-9]/
|
||||
* numerals = /[0-9]+/
|
||||
* whitespace = /[ \t\n]+/
|
||||
* blah = "$\""
|
||||
* blahblah = /a\$/
|
||||
* GAMEEND = @(?:1\-0|0\-1|1/2\-1/2)@
|
||||
* PAWNMOVE = /P?[a-h](?:[2-7]|[18]\=(?:Q|R|B|N))|P?[a-h]x[a-h](?:[2-7]|[18]\=(?:Q|R|B|N))/
|
||||
* {@*}
|
||||
* </code>
|
||||
*
|
||||
* All regexes must be delimited. Any legal preg delimiter can be used (as in @ or / in
|
||||
* the example above)
|
||||
*
|
||||
*
|
||||
* @package PHP_LexerGenerator
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 2006 Gregory Beaver
|
||||
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
||||
* @version 0.2.0
|
||||
* @since Class available since Release 0.1.0
|
||||
* @example TestLexer.plex Example lexer source
|
||||
* @example TestLexer.php Example lexer php code
|
||||
* @example usage.php Example usage of PHP_LexerGenerator
|
||||
* @example Lexer.plex File_ChessPGN lexer source (complex)
|
||||
* @example Lexer.php File_ChessPGN lexer php code
|
||||
*/
|
||||
|
||||
class PHP_LexerGenerator
|
||||
{
|
||||
private $lex;
|
||||
private $parser;
|
||||
private $outfile;
|
||||
/**
|
||||
* Create a lexer file from its skeleton plex file.
|
||||
*
|
||||
* @param string $lexerfile path to the plex file
|
||||
*/
|
||||
function __construct($lexerfile)
|
||||
{
|
||||
$this->lex = new PHP_LexerGenerator_Lexer(file_get_contents($lexerfile));
|
||||
$info = pathinfo($lexerfile);
|
||||
$this->outfile = $info['dirname'] . DIRECTORY_SEPARATOR .
|
||||
substr($info['basename'], 0,
|
||||
strlen($info['basename']) - strlen($info['extension'])) . 'php';
|
||||
$this->parser = new PHP_LexerGenerator_Parser($this->outfile, $this->lex);
|
||||
$this->parser->PrintTrace();
|
||||
while ($this->lex->advance($this->parser)) {
|
||||
$this->parser->doParse($this->lex->token, $this->lex->value);
|
||||
}
|
||||
$this->parser->doParse(0, 0);
|
||||
}
|
||||
}
|
||||
//$a = new PHP_LexerGenerator('/development/File_ChessPGN/ChessPGN/Lexer.plex');
|
||||
?>
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
/**
|
||||
* PHP_LexerGenerator, a php 5 lexer generator.
|
||||
*
|
||||
* Exception classes for the lexer generator
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* Copyright (c) 2006, Gregory Beaver <cellog@php.net>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the PHP_LexerGenerator nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category php
|
||||
* @package PHP_LexerGenerator
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 2006 Gregory Beaver
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
|
||||
*/
|
||||
require_once 'PEAR/Exception.php';
|
||||
/**
|
||||
* @package PHP_LexerGenerator
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 2006 Gregory Beaver
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
|
||||
* @version @package_version@
|
||||
* @since File available since Release 0.1.0
|
||||
*/
|
||||
class PHP_LexerGenerator_Exception extends PEAR_Exception {}
|
||||
?>
|
|
@ -0,0 +1,465 @@
|
|||
<?php
|
||||
/**
|
||||
* PHP_LexerGenerator, a php 5 lexer generator.
|
||||
*
|
||||
* This lexer generator translates a file in a format similar to
|
||||
* re2c ({@link http://re2c.org}) and translates it into a PHP 5-based lexer
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.01 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_01.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category php
|
||||
* @package PHP_LexerGenerator
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 2006 Gregory Beaver
|
||||
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
||||
* @version CVS: $Id$
|
||||
* @since File available since Release 0.1.0
|
||||
*/
|
||||
require_once 'PHP/LexerGenerator/Parser.php';
|
||||
/**
|
||||
* Token scanner for plex files.
|
||||
*
|
||||
* This scanner detects comments beginning with "/*!lex2php" and
|
||||
* then returns their components (processing instructions, patterns, strings
|
||||
* action code, and regexes)
|
||||
* @package PHP_LexerGenerator
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 2006 Gregory Beaver
|
||||
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
||||
* @version 0.2.0
|
||||
* @since Class available since Release 0.1.0
|
||||
*/
|
||||
class PHP_LexerGenerator_Lexer
|
||||
{
|
||||
private $data;
|
||||
private $N;
|
||||
private $state;
|
||||
/**
|
||||
* Current line number in input
|
||||
* @var int
|
||||
*/
|
||||
public $line;
|
||||
/**
|
||||
* Number of scanning errors detected
|
||||
* @var int
|
||||
*/
|
||||
public $errors = 0;
|
||||
/**
|
||||
* integer identifier of the current token
|
||||
* @var int
|
||||
*/
|
||||
public $token;
|
||||
/**
|
||||
* string content of current token
|
||||
* @var string
|
||||
*/
|
||||
public $value;
|
||||
|
||||
const PHPCODE = PHP_LexerGenerator_Parser::PHPCODE;
|
||||
const COMMENTSTART = PHP_LexerGenerator_Parser::COMMENTSTART;
|
||||
const COMMENTEND = PHP_LexerGenerator_Parser::COMMENTEND;
|
||||
const QUOTE = PHP_LexerGenerator_Parser::QUOTE;
|
||||
const PATTERN = PHP_LexerGenerator_Parser::PATTERN;
|
||||
const CODE = PHP_LexerGenerator_Parser::CODE;
|
||||
const SUBPATTERN = PHP_LexerGenerator_Parser::SUBPATTERN;
|
||||
const PI = PHP_LexerGenerator_Parser::PI;
|
||||
|
||||
/**
|
||||
* prepare scanning
|
||||
* @param string the input
|
||||
*/
|
||||
function __construct($data)
|
||||
{
|
||||
$this->data = str_replace("\r\n", "\n", $data);
|
||||
$this->N = 0;
|
||||
$this->line = 1;
|
||||
$this->state = 'Start';
|
||||
$this->errors = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output an error message
|
||||
* @param string
|
||||
*/
|
||||
private function error($msg)
|
||||
{
|
||||
echo 'Error on line ' . $this->line . ': ' . $msg;
|
||||
$this->errors++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initial scanning state lexer
|
||||
* @return boolean
|
||||
*/
|
||||
private function lexStart()
|
||||
{
|
||||
if ($this->N >= strlen($this->data)) {
|
||||
return false;
|
||||
}
|
||||
$a = strpos($this->data, '/*!lex2php' . "\n", $this->N);
|
||||
if ($a === false) {
|
||||
$this->value = substr($this->data, $this->N);
|
||||
$this->N = strlen($this->data);
|
||||
$this->token = self::PHPCODE;
|
||||
return true;
|
||||
}
|
||||
if ($a > $this->N) {
|
||||
$this->value = substr($this->data, $this->N, $a - $this->N);
|
||||
$this->N = $a;
|
||||
$this->token = self::PHPCODE;
|
||||
return true;
|
||||
}
|
||||
$this->value = '/*!lex2php' . "\n";
|
||||
$this->N += 11; // strlen("/*lex2php\n")
|
||||
$this->token = self::COMMENTSTART;
|
||||
$this->state = 'Declare';
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* lexer for top-level canning state after the initial declaration comment
|
||||
* @return boolean
|
||||
*/
|
||||
private function lexStartNonDeclare()
|
||||
{
|
||||
if ($this->N >= strlen($this->data)) {
|
||||
return false;
|
||||
}
|
||||
$a = strpos($this->data, '/*!lex2php' . "\n", $this->N);
|
||||
if ($a === false) {
|
||||
$this->value = substr($this->data, $this->N);
|
||||
$this->N = strlen($this->data);
|
||||
$this->token = self::PHPCODE;
|
||||
return true;
|
||||
}
|
||||
if ($a > $this->N) {
|
||||
$this->value = substr($this->data, $this->N, $a - $this->N);
|
||||
$this->N = $a;
|
||||
$this->token = self::PHPCODE;
|
||||
return true;
|
||||
}
|
||||
$this->value = '/*!lex2php' . "\n";
|
||||
$this->N += 11; // strlen("/*lex2php\n")
|
||||
$this->token = self::COMMENTSTART;
|
||||
$this->state = 'Rule';
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* lexer for declaration comment state
|
||||
* @return boolean
|
||||
*/
|
||||
private function lexDeclare()
|
||||
{
|
||||
if ($this->data[$this->N] == '*' && $this->data[$this->N + 1] == '/') {
|
||||
$this->state = 'StartNonDeclare';
|
||||
$this->value = '*/';
|
||||
$this->N += 2;
|
||||
$this->token = self::COMMENTEND;
|
||||
return true;
|
||||
}
|
||||
if (preg_match('/^%([a-z]+)/', substr($this->data, $this->N), $token)) {
|
||||
$this->value = $token[1];
|
||||
$this->N += strlen($token[1]) + 1;
|
||||
$this->state = 'DeclarePI';
|
||||
$this->token = self::PI;
|
||||
return true;
|
||||
}
|
||||
if (preg_match('/^[a-zA-Z]+/', substr($this->data, $this->N), $token)) {
|
||||
$this->value = $token[0];
|
||||
$this->token = self::PATTERN;
|
||||
$this->N += strlen($token[0]);
|
||||
$this->state = 'DeclareEquals';
|
||||
return true;
|
||||
} else {
|
||||
$this->error('expecting declaration of sub-patterns');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* lexer for processor instructions within declaration comment
|
||||
* @return boolean
|
||||
*/
|
||||
private function lexDeclarePI()
|
||||
{
|
||||
while ($this->N < strlen($this->data) &&
|
||||
($this->data[$this->N] == ' ' ||
|
||||
$this->data[$this->N] == "\t")) {
|
||||
$this->N++; // skip whitespace
|
||||
}
|
||||
if ($this->data[$this->N] == "\n") {
|
||||
$this->N++;
|
||||
$this->state = 'Declare';
|
||||
$this->line++;
|
||||
return $this->lexDeclare();
|
||||
}
|
||||
if ($this->data[$this->N] == '{') {
|
||||
return $this->lexCode();
|
||||
}
|
||||
if (!preg_match("/[^\n]+/", substr($this->data, $this->N), $token)) {
|
||||
$this->error('Unexpected end of file');
|
||||
return false;
|
||||
}
|
||||
$this->value = $token[0];
|
||||
$this->N += strlen($this->value);
|
||||
$this->token = self::SUBPATTERN;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* lexer for processor instructions inside rule comments
|
||||
* @return boolean
|
||||
*/
|
||||
private function lexDeclarePIRule()
|
||||
{
|
||||
while ($this->N < strlen($this->data) &&
|
||||
($this->data[$this->N] == ' ' ||
|
||||
$this->data[$this->N] == "\t")) {
|
||||
$this->N++; // skip whitespace
|
||||
}
|
||||
if ($this->data[$this->N] == "\n") {
|
||||
$this->N++;
|
||||
$this->state = 'Rule';
|
||||
$this->line++;
|
||||
return $this->lexRule();
|
||||
}
|
||||
if ($this->data[$this->N] == '{') {
|
||||
return $this->lexCode();
|
||||
}
|
||||
if (!preg_match("/[^\n]+/", substr($this->data, $this->N), $token)) {
|
||||
$this->error('Unexpected end of file');
|
||||
return false;
|
||||
}
|
||||
$this->value = $token[0];
|
||||
$this->N += strlen($this->value);
|
||||
$this->token = self::SUBPATTERN;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* lexer for the state representing scanning between a pattern and the "=" sign
|
||||
* @return boolean
|
||||
*/
|
||||
private function lexDeclareEquals()
|
||||
{
|
||||
while ($this->N < strlen($this->data) &&
|
||||
($this->data[$this->N] == ' ' || $this->data[$this->N] == "\t")) {
|
||||
$this->N++; // skip whitespace
|
||||
}
|
||||
if ($this->N >= strlen($this->data)) {
|
||||
$this->error('unexpected end of input, expecting "=" for sub-pattern declaration');
|
||||
}
|
||||
if ($this->data[$this->N] != '=') {
|
||||
$this->error('expecting "=" for sub-pattern declaration');
|
||||
return false;
|
||||
}
|
||||
$this->N++;
|
||||
$this->state = 'DeclareRightside';
|
||||
while ($this->N < strlen($this->data) &&
|
||||
($this->data[$this->N] == ' ' || $this->data[$this->N] == "\t")) {
|
||||
$this->N++; // skip whitespace
|
||||
}
|
||||
if ($this->N >= strlen($this->data)) {
|
||||
$this->error('unexpected end of file, expecting right side of sub-pattern declaration');
|
||||
return false;
|
||||
}
|
||||
return $this->lexDeclareRightside();
|
||||
}
|
||||
|
||||
/**
|
||||
* lexer for the right side of a pattern, detects quotes or regexes
|
||||
* @return boolean
|
||||
*/
|
||||
private function lexDeclareRightside()
|
||||
{
|
||||
if ($this->data[$this->N] == "\n") {
|
||||
$this->state = 'lexDeclare';
|
||||
$this->N++;
|
||||
$this->line++;
|
||||
return $this->lexDeclare();
|
||||
}
|
||||
if ($this->data[$this->N] == '"') {
|
||||
return $this->lexQuote();
|
||||
}
|
||||
// match a pattern
|
||||
$test = $this->data[$this->N];
|
||||
$token = $this->N + 1;
|
||||
$a = 0;
|
||||
do {
|
||||
if ($a++) {
|
||||
$token++;
|
||||
}
|
||||
$token = strpos($this->data, $test, $token);
|
||||
} while ($token !== false && ($this->data[$token - 1] == '\\'
|
||||
&& $this->data[$token - 2] != '\\'));
|
||||
if ($token === false) {
|
||||
$this->error('Unterminated regex pattern (started with "' . $test . '"');
|
||||
return false;
|
||||
}
|
||||
if (substr_count($this->data, "\n", $this->N, $token - $this->N)) {
|
||||
$this->error('Regex pattern extends over multiple lines');
|
||||
return false;
|
||||
}
|
||||
$this->value = substr($this->data, $this->N + 1, $token - $this->N - 1);
|
||||
// unescape the regex marker
|
||||
// we will re-escape when creating the final regex
|
||||
$this->value = str_replace('\\' . $test, $test, $this->value);
|
||||
$this->N = $token + 1;
|
||||
$this->token = self::SUBPATTERN;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* lexer for quoted literals
|
||||
* @return boolean
|
||||
*/
|
||||
private function lexQuote()
|
||||
{
|
||||
$token = $this->N + 1;
|
||||
$a = 0;
|
||||
do {
|
||||
if ($a++) {
|
||||
$token++;
|
||||
}
|
||||
$token = strpos($this->data, '"', $token);
|
||||
} while ($token !== false && $token < strlen($this->data) &&
|
||||
($this->data[$token - 1] == '\\' && $this->data[$token - 2] != '\\'));
|
||||
if ($token === false) {
|
||||
$this->error('unterminated quote');
|
||||
return false;
|
||||
}
|
||||
if (substr_count($this->data, "\n", $this->N, $token - $this->N)) {
|
||||
$this->error('quote extends over multiple lines');
|
||||
return false;
|
||||
}
|
||||
$this->value = substr($this->data, $this->N + 1, $token - $this->N - 1);
|
||||
$this->value = str_replace('\\"', '"', $this->value);
|
||||
$this->value = str_replace('\\\\', '\\', $this->value);
|
||||
$this->N = $token + 1;
|
||||
$this->token = self::QUOTE;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* lexer for rules
|
||||
* @return boolean
|
||||
*/
|
||||
private function lexRule()
|
||||
{
|
||||
while ($this->N < strlen($this->data) &&
|
||||
($this->data[$this->N] == ' ' ||
|
||||
$this->data[$this->N] == "\t" ||
|
||||
$this->data[$this->N] == "\n")) {
|
||||
if ($this->data[$this->N] == "\n") {
|
||||
$this->line++;
|
||||
}
|
||||
$this->N++; // skip all whitespace
|
||||
}
|
||||
if ($this->N >= strlen($this->data)) {
|
||||
$this->error('unexpected end of input, expecting rule declaration');
|
||||
}
|
||||
if ($this->data[$this->N] == '*' && $this->data[$this->N + 1] == '/') {
|
||||
$this->state = 'StartNonDeclare';
|
||||
$this->value = '*/';
|
||||
$this->N += 2;
|
||||
$this->token = self::COMMENTEND;
|
||||
return true;
|
||||
}
|
||||
if (preg_match('/^%([a-z]+)/', substr($this->data, $this->N), $token)) {
|
||||
$this->value = $token[1];
|
||||
$this->N += strlen($token[1]) + 1;
|
||||
$this->state = 'DeclarePIRule';
|
||||
$this->token = self::PI;
|
||||
return true;
|
||||
}
|
||||
if ($this->data[$this->N] == "{") {
|
||||
return $this->lexCode();
|
||||
}
|
||||
if ($this->data[$this->N] == '"') {
|
||||
return $this->lexQuote();
|
||||
}
|
||||
if (preg_match('/^[a-zA-Z]+/', substr($this->data, $this->N), $token)) {
|
||||
$this->value = $token[0];
|
||||
$this->N += strlen($token[0]);
|
||||
$this->token = self::SUBPATTERN;
|
||||
return true;
|
||||
} else {
|
||||
$this->error('expecting token rule (quotes or sub-patterns)');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* lexer for php code blocks
|
||||
* @return boolean
|
||||
*/
|
||||
private function lexCode()
|
||||
{
|
||||
$cp = $this->N + 1;
|
||||
for ($level = 1; $cp < strlen($this->data) && ($level > 1 || $this->data[$cp] != '}'); $cp++) {
|
||||
if ($this->data[$cp] == '{') {
|
||||
$level++;
|
||||
} elseif ($this->data[$cp] == '}') {
|
||||
$level--;
|
||||
} elseif ($this->data[$cp] == '/' && $this->data[$cp + 1] == '/') {
|
||||
/* Skip C++ style comments */
|
||||
$cp += 2;
|
||||
$z = strpos($this->data, "\n", $cp);
|
||||
if ($z === false) {
|
||||
$cp = strlen($this->data);
|
||||
break;
|
||||
}
|
||||
$cp = $z;
|
||||
} elseif ($this->data[$cp] == "'" || $this->data[$cp] == '"') {
|
||||
/* String a character literals */
|
||||
$startchar = $this->data[$cp];
|
||||
$prevc = 0;
|
||||
for ($cp++; $cp < strlen($this->data) && ($this->data[$cp] != $startchar || $prevc === '\\'); $cp++) {
|
||||
if ($prevc === '\\') {
|
||||
$prevc = 0;
|
||||
} else {
|
||||
$prevc = $this->data[$cp];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($cp >= strlen($this->data)) {
|
||||
$this->error("PHP code starting on this line is not terminated before the end of the file.");
|
||||
$this->error++;
|
||||
return false;
|
||||
} else {
|
||||
$this->value = substr($this->data, $this->N + 1, $cp - $this->N - 1);
|
||||
$this->token = self::CODE;
|
||||
$this->N = $cp + 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Primary scanner
|
||||
*
|
||||
* In addition to lexing, this properly increments the line number of lexing.
|
||||
* This calls the proper sub-lexer based on the parser state
|
||||
* @param unknown_type $parser
|
||||
* @return unknown
|
||||
*/
|
||||
public function advance($parser)
|
||||
{
|
||||
if ($this->N >= strlen($this->data)) {
|
||||
return false;
|
||||
}
|
||||
if ($this->{'lex' . $this->state}()) {
|
||||
$this->line += substr_count($this->value, "\n");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,586 @@
|
|||
%name PHP_LexerGenerator_Parser
|
||||
%declare_class {class PHP_LexerGenerator_Parser}
|
||||
%include {
|
||||
/* ?><?php {//*/
|
||||
/**
|
||||
* PHP_LexerGenerator, a php 5 lexer generator.
|
||||
*
|
||||
* This lexer generator translates a file in a format similar to
|
||||
* re2c ({@link http://re2c.org}) and translates it into a PHP 5-based lexer
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* Copyright (c) 2006, Gregory Beaver <cellog@php.net>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the PHP_LexerGenerator nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category php
|
||||
* @package PHP_LexerGenerator
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 2006 Gregory Beaver
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
|
||||
* @version CVS: $Id$
|
||||
* @since File available since Release 0.1.0
|
||||
*/
|
||||
/**
|
||||
* For regular expression validation
|
||||
*/
|
||||
require_once 'PHP/LexerGenerator/Regex/Lexer.php';
|
||||
require_once 'PHP/LexerGenerator/Regex/Parser.php';
|
||||
require_once 'PHP/LexerGenerator/Exception.php';
|
||||
/**
|
||||
* Token parser for plex files.
|
||||
*
|
||||
* This parser converts tokens pulled from {@link PHP_LexerGenerator_Lexer}
|
||||
* into abstract patterns and rules, then creates the output file
|
||||
* @package PHP_LexerGenerator
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 2006 Gregory Beaver
|
||||
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
||||
* @version 0.2.0
|
||||
* @since Class available since Release 0.1.0
|
||||
*/
|
||||
}
|
||||
%syntax_error {
|
||||
echo "Syntax Error on line " . $this->lex->line . ": token '" .
|
||||
$this->lex->value . "' while parsing rule:";
|
||||
foreach ($this->yystack as $entry) {
|
||||
echo $this->tokenName($entry->major) . ' ';
|
||||
}
|
||||
foreach ($this->yy_get_expected_tokens($yymajor) as $token) {
|
||||
$expect[] = self::$yyTokenName[$token];
|
||||
}
|
||||
throw new Exception('Unexpected ' . $this->tokenName($yymajor) . '(' . $TOKEN
|
||||
. '), expected one of: ' . implode(',', $expect));
|
||||
}
|
||||
%include_class {
|
||||
private $patterns;
|
||||
private $out;
|
||||
private $lex;
|
||||
private $input;
|
||||
private $counter;
|
||||
private $token;
|
||||
private $value;
|
||||
private $line;
|
||||
private $_regexLexer;
|
||||
private $_regexParser;
|
||||
|
||||
public $transTable = array(
|
||||
1 => self::PHPCODE,
|
||||
2 => self::COMMENTSTART,
|
||||
3 => self::COMMENTEND,
|
||||
4 => self::QUOTE,
|
||||
5 => self::PATTERN,
|
||||
6 => self::CODE,
|
||||
7 => self::SUBPATTERN,
|
||||
8 => self::PI,
|
||||
);
|
||||
|
||||
function __construct($outfile, $lex)
|
||||
{
|
||||
$this->out = fopen($outfile, 'wb');
|
||||
if (!$this->out) {
|
||||
throw new Exception('unable to open lexer output file "' . $outfile . '"');
|
||||
}
|
||||
$this->lex = $lex;
|
||||
$this->_regexLexer = new PHP_LexerGenerator_Regex_Lexer('');
|
||||
$this->_regexParser = new PHP_LexerGenerator_Regex_Parser($this->_regexLexer);
|
||||
}
|
||||
|
||||
function outputRules($rules, $statename)
|
||||
{
|
||||
static $ruleindex = 1;
|
||||
$patterns = array();
|
||||
$pattern = '/';
|
||||
$ruleMap = array();
|
||||
$tokenindex = array();
|
||||
$i = 0;
|
||||
$actualindex = 1;
|
||||
foreach ($rules as $rule) {
|
||||
$ruleMap[$i++] = $actualindex;
|
||||
$tokenindex[$actualindex] = $rule['subpatterns'];
|
||||
$actualindex += $rule['subpatterns'] + 1;
|
||||
$patterns[] = '^(' . $rule['pattern'] . ')';
|
||||
}
|
||||
$tokenindex = var_export($tokenindex, true);
|
||||
$tokenindex = explode("\n", $tokenindex);
|
||||
// indent for prettiness
|
||||
$tokenindex = implode("\n ", $tokenindex);
|
||||
$pattern .= implode('|', $patterns);
|
||||
$pattern .= '/';
|
||||
if (!$statename) {
|
||||
$statename = $ruleindex;
|
||||
}
|
||||
fwrite($this->out, '
|
||||
function yylex' . $ruleindex . '()
|
||||
{
|
||||
$tokenMap = ' . $tokenindex . ';
|
||||
if (' . $this->counter . ' >= strlen(' . $this->input . ')) {
|
||||
return false; // end of input
|
||||
}
|
||||
');
|
||||
fwrite($this->out, '$yy_global_pattern = "' .
|
||||
$pattern . '";' . "\n");
|
||||
fwrite($this->out, '
|
||||
do {
|
||||
if (preg_match($yy_global_pattern, substr(' . $this->input . ', ' .
|
||||
$this->counter .
|
||||
'), $yymatches)) {
|
||||
$yysubmatches = $yymatches;
|
||||
$yymatches = array_filter($yymatches, \'strlen\'); // remove empty sub-patterns
|
||||
if (!count($yymatches)) {
|
||||
throw new Exception(\'Error: lexing failed because a rule matched\' .
|
||||
\'an empty string. Input "\' . substr(' . $this->input . ',
|
||||
' . $this->counter . ', 5) . \'... state ' . $statename . '\');
|
||||
}
|
||||
next($yymatches); // skip global match
|
||||
' . $this->token . ' = key($yymatches); // token number
|
||||
if ($tokenMap[' . $this->token . ']) {
|
||||
// extract sub-patterns for passing to lex function
|
||||
$yysubmatches = array_slice($yysubmatches, ' . $this->token . ' + 1,
|
||||
$tokenMap[' . $this->token . ']);
|
||||
} else {
|
||||
$yysubmatches = array();
|
||||
}
|
||||
' . $this->value . ' = current($yymatches); // token value
|
||||
$r = $this->{\'yy_r' . $ruleindex . '_\' . ' . $this->token . '}($yysubmatches);
|
||||
if ($r === null) {
|
||||
' . $this->counter . ' += strlen($this->value);
|
||||
' . $this->line . ' += substr_count("\n", ' . $this->value . ');
|
||||
// accept this token
|
||||
return true;
|
||||
} elseif ($r === true) {
|
||||
// we have changed state
|
||||
// process this token in the new state
|
||||
return $this->yylex();
|
||||
} elseif ($r === false) {
|
||||
' . $this->counter . ' += strlen($this->value);
|
||||
' . $this->line . ' += substr_count("\n", ' . $this->value . ');
|
||||
if (' . $this->counter . ' >= strlen(' . $this->input . ')) {
|
||||
return false; // end of input
|
||||
}
|
||||
// skip this token
|
||||
continue;
|
||||
} else {');
|
||||
fwrite($this->out, ' $yy_yymore_patterns = array(' . "\n");
|
||||
for($i = 0; count($patterns); $i++) {
|
||||
unset($patterns[$i]);
|
||||
fwrite($this->out, ' ' . $ruleMap[$i] . ' => "' .
|
||||
implode('|', $patterns) . "\",\n");
|
||||
}
|
||||
fwrite($this->out, ' );' . "\n");
|
||||
fwrite($this->out, '
|
||||
// yymore is needed
|
||||
do {
|
||||
if (!strlen($yy_yymore_patterns[' . $this->token . '])) {
|
||||
throw new Exception(\'cannot do yymore for the last token\');
|
||||
}
|
||||
if (preg_match($yy_yymore_patterns[' . $this->token . '],
|
||||
substr(' . $this->input . ', ' . $this->counter . '), $yymatches)) {
|
||||
$yymatches = array_filter($yymatches, \'strlen\'); // remove empty sub-patterns
|
||||
next($yymatches); // skip global match
|
||||
' . $this->token . ' = key($yymatches); // token number
|
||||
' . $this->value . ' = current($yymatches); // token value
|
||||
' . $this->line . ' = substr_count("\n", ' . $this->value . ');
|
||||
}
|
||||
} while ($this->{\'yy_r' . $ruleindex . '_\' . ' . $this->token . '}() !== null);
|
||||
// accept
|
||||
' . $this->counter . ' += strlen($this->value);
|
||||
' . $this->line . ' += substr_count("\n", ' . $this->value . ');
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
throw new Exception(\'Unexpected input at line\' . ' . $this->line . ' .
|
||||
\': \' . ' . $this->input . '[' . $this->counter . ']);
|
||||
}
|
||||
break;
|
||||
} while (true);
|
||||
} // end function
|
||||
|
||||
');
|
||||
if ($statename) {
|
||||
fwrite($this->out, '
|
||||
const ' . $statename . ' = ' . $ruleindex . ';
|
||||
');
|
||||
}
|
||||
foreach ($rules as $i => $rule) {
|
||||
fwrite($this->out, ' function yy_r' . $ruleindex . '_' . $ruleMap[$i] . '($yy_subpatterns)
|
||||
{
|
||||
' . $rule['code'] .
|
||||
' }
|
||||
');
|
||||
}
|
||||
$ruleindex++; // for next set of rules
|
||||
}
|
||||
|
||||
function error($msg)
|
||||
{
|
||||
echo 'Error on line ' . $this->lex->line . ': ' , $msg;
|
||||
}
|
||||
|
||||
function _validatePattern($pattern)
|
||||
{
|
||||
$this->_regexLexer->reset($pattern);
|
||||
try {
|
||||
while ($this->_regexLexer->yylex()) {
|
||||
$this->_regexParser->doParse(
|
||||
$this->_regexLexer->token, $this->_regexLexer->value);
|
||||
}
|
||||
$this->_regexParser->doParse(0, 0);
|
||||
} catch (PHP_LexerGenerator_Exception $e) {
|
||||
$this->error($e->getMessage());
|
||||
throw new PHP_LexerGenerator_Exception('Invalid pattern "' . $pattern . '"');
|
||||
}
|
||||
return $this->_regexParser->result;
|
||||
}
|
||||
}
|
||||
|
||||
start ::= lexfile.
|
||||
|
||||
lexfile ::= declare rules(B). {
|
||||
fwrite($this->out, '
|
||||
private $_yy_state = 1;
|
||||
private $_yy_stack = array();
|
||||
|
||||
function yylex()
|
||||
{
|
||||
return $this->{\'yylex\' . $this->_yy_state}();
|
||||
}
|
||||
|
||||
function yypushstate($state)
|
||||
{
|
||||
array_push($this->_yy_stack, $this->_yy_state);
|
||||
$this->_yy_state = $state;
|
||||
}
|
||||
|
||||
function yypopstate()
|
||||
{
|
||||
$this->_yy_state = array_pop($this->_yy_stack);
|
||||
}
|
||||
|
||||
function yybegin($state)
|
||||
{
|
||||
$this->_yy_state = $state;
|
||||
}
|
||||
|
||||
');
|
||||
foreach (B as $rule) {
|
||||
$this->outputRules($rule['rules'], $rule['statename']);
|
||||
if ($rule['code']) {
|
||||
fwrite($this->out, $rule['code']);
|
||||
}
|
||||
}
|
||||
}
|
||||
lexfile ::= declare(D) PHPCODE(B) rules(C). {
|
||||
fwrite($this->out, '
|
||||
private $_yy_state = 1;
|
||||
private $_yy_stack = array();
|
||||
|
||||
function yylex()
|
||||
{
|
||||
return $this->{\'yylex\' . $this->_yy_state}();
|
||||
}
|
||||
|
||||
function yypushstate($state)
|
||||
{
|
||||
array_push($this->_yy_stack, $this->_yy_state);
|
||||
$this->_yy_state = $state;
|
||||
}
|
||||
|
||||
function yypopstate()
|
||||
{
|
||||
$this->_yy_state = array_pop($this->_yy_stack);
|
||||
}
|
||||
|
||||
function yybegin($state)
|
||||
{
|
||||
$this->_yy_state = $state;
|
||||
}
|
||||
|
||||
');
|
||||
if (strlen(B)) {
|
||||
fwrite($this->out, B);
|
||||
}
|
||||
foreach (C as $rule) {
|
||||
$this->outputRules($rule['rules'], $rule['statename']);
|
||||
if ($rule['code']) {
|
||||
fwrite($this->out, $rule['code']);
|
||||
}
|
||||
}
|
||||
}
|
||||
lexfile ::= PHPCODE(B) declare(D) rules(C). {
|
||||
if (strlen(B)) {
|
||||
fwrite($this->out, B);
|
||||
}
|
||||
fwrite($this->out, '
|
||||
private $_yy_state = 1;
|
||||
private $_yy_stack = array();
|
||||
|
||||
function yylex()
|
||||
{
|
||||
return $this->{\'yylex\' . $this->_yy_state}();
|
||||
}
|
||||
|
||||
function yypushstate($state)
|
||||
{
|
||||
array_push($this->_yy_stack, $this->_yy_state);
|
||||
$this->_yy_state = $state;
|
||||
}
|
||||
|
||||
function yypopstate()
|
||||
{
|
||||
$this->_yy_state = array_pop($this->_yy_stack);
|
||||
}
|
||||
|
||||
function yybegin($state)
|
||||
{
|
||||
$this->_yy_state = $state;
|
||||
}
|
||||
|
||||
');
|
||||
foreach (C as $rule) {
|
||||
$this->outputRules($rule['rules'], $rule['statename']);
|
||||
if ($rule['code']) {
|
||||
fwrite($this->out, $rule['code']);
|
||||
}
|
||||
}
|
||||
}
|
||||
lexfile ::= PHPCODE(A) declare(D) PHPCODE(B) rules(C). {
|
||||
if (strlen(A)) {
|
||||
fwrite($this->out, A);
|
||||
}
|
||||
fwrite($this->out, '
|
||||
private $_yy_state = 1;
|
||||
private $_yy_stack = array();
|
||||
|
||||
function yylex()
|
||||
{
|
||||
return $this->{\'yylex\' . $this->_yy_state}();
|
||||
}
|
||||
|
||||
function yypushstate($state)
|
||||
{
|
||||
array_push($this->_yy_stack, $this->_yy_state);
|
||||
$this->_yy_state = $state;
|
||||
}
|
||||
|
||||
function yypopstate()
|
||||
{
|
||||
$this->_yy_state = array_pop($this->_yy_stack);
|
||||
}
|
||||
|
||||
function yybegin($state)
|
||||
{
|
||||
$this->_yy_state = $state;
|
||||
}
|
||||
|
||||
');
|
||||
if (strlen(B)) {
|
||||
fwrite($this->out, B);
|
||||
}
|
||||
foreach (C as $rule) {
|
||||
$this->outputRules($rule['rules'], $rule['statename']);
|
||||
if ($rule['code']) {
|
||||
fwrite($this->out, $rule['code']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare(A) ::= COMMENTSTART declarations(B) COMMENTEND. {
|
||||
A = B;
|
||||
$this->patterns = B['patterns'];
|
||||
}
|
||||
|
||||
declarations(A) ::= processing_instructions(B) pattern_declarations(C). {
|
||||
$expected = array(
|
||||
'counter' => true,
|
||||
'input' => true,
|
||||
'token' => true,
|
||||
'value' => true,
|
||||
'line' => true,
|
||||
);
|
||||
foreach (B as $pi) {
|
||||
if (isset($expected[$pi['pi']])) {
|
||||
unset($expected[$pi['pi']]);
|
||||
continue;
|
||||
}
|
||||
if (count($expected)) {
|
||||
throw new Exception('Processing Instructions "' .
|
||||
implode(', ', array_keys($expected)) . '" must be defined');
|
||||
}
|
||||
}
|
||||
$expected = array(
|
||||
'counter' => true,
|
||||
'input' => true,
|
||||
'token' => true,
|
||||
'value' => true,
|
||||
'line' => true,
|
||||
);
|
||||
foreach (B as $pi) {
|
||||
if (isset($expected[$pi['pi']])) {
|
||||
$this->{$pi['pi']} = $pi['definition'];
|
||||
continue;
|
||||
}
|
||||
$this->error('Unknown processing instruction %' . $pi['pi'] .
|
||||
', should be one of "' . implode(', ', array_keys($expected)) . '"');
|
||||
}
|
||||
A = array('patterns' => C, 'pis' => B);
|
||||
}
|
||||
|
||||
processing_instructions(A) ::= PI(B) SUBPATTERN(C). {
|
||||
A = array(array('pi' => B, 'definition' => C));
|
||||
}
|
||||
processing_instructions(A) ::= PI(B) CODE(C). {
|
||||
A = array(array('pi' => B, 'definition' => C));
|
||||
}
|
||||
processing_instructions(A) ::= processing_instructions(P) PI(B) SUBPATTERN(C). {
|
||||
A = P;
|
||||
A[] = array('pi' => B, 'definition' => C);
|
||||
}
|
||||
processing_instructions(A) ::= processing_instructions(P) PI(B) CODE(C). {
|
||||
A = P;
|
||||
A[] = array('pi' => B, 'definition' => C);
|
||||
}
|
||||
|
||||
pattern_declarations(A) ::= PATTERN(B) subpattern(C). {
|
||||
A = array(B => C);
|
||||
}
|
||||
pattern_declarations(A) ::= pattern_declarations(B) PATTERN(C) subpattern(D). {
|
||||
A = B;
|
||||
if (isset(A[C])) {
|
||||
throw new Exception('Pattern "' . C . '" is already defined as "' .
|
||||
A[C] . '", cannot redefine as "' . D->string . '"');
|
||||
}
|
||||
A[C] = D;
|
||||
}
|
||||
|
||||
rules(A) ::= COMMENTSTART rule(B) COMMENTEND. {
|
||||
A = array(array('rules' => B, 'code' => '', 'statename' => ''));
|
||||
}
|
||||
rules(A) ::= COMMENTSTART PI(P) SUBPATTERN(S) rule(B) COMMENTEND. {
|
||||
if (P != 'statename') {
|
||||
throw new Exception('Error: only %statename processing instruction ' .
|
||||
'is allowed in rule sections');
|
||||
}
|
||||
A = array(array('rules' => B, 'code' => '', 'statename' => S));
|
||||
}
|
||||
rules(A) ::= COMMENTSTART rule(B) COMMENTEND PHPCODE(C). {
|
||||
A = array(array('rules' => B, 'code' => C, 'statename' => ''));
|
||||
}
|
||||
rules(A) ::= COMMENTSTART PI(P) SUBPATTERN(S) rule(B) COMMENTEND PHPCODE(C). {
|
||||
if (P != 'statename') {
|
||||
throw new Exception('Error: only %statename processing instruction ' .
|
||||
'is allowed in rule sections');
|
||||
}
|
||||
A = array(array('rules' => B, 'code' => C, 'statename' => S));
|
||||
}
|
||||
rules(A) ::= rules(R) COMMENTSTART rule(B) COMMENTEND. {
|
||||
A = R;
|
||||
A[] = array('rules' => B, 'code' => '', 'statename' => '');
|
||||
}
|
||||
rules(A) ::= rules(R) PI(P) SUBPATTERN(S) COMMENTSTART rule(B) COMMENTEND. {
|
||||
if (P != 'statename') {
|
||||
throw new Exception('Error: only %statename processing instruction ' .
|
||||
'is allowed in rule sections');
|
||||
}
|
||||
A = R;
|
||||
A[] = array('rules' => B, 'code' => '', 'statename' => S);
|
||||
}
|
||||
rules(A) ::= rules(R) COMMENTSTART rule(B) COMMENTEND PHPCODE(C). {
|
||||
A = R;
|
||||
A[] = array('rules' => B, 'code' => C, 'statename' => '');
|
||||
}
|
||||
rules(A) ::= rules(R) COMMENTSTART PI(P) SUBPATTERN(S) rule(B) COMMENTEND PHPCODE(C). {
|
||||
if (P != 'statename') {
|
||||
throw new Exception('Error: only %statename processing instruction ' .
|
||||
'is allowed in rule sections');
|
||||
}
|
||||
A = R;
|
||||
A[] = array('rules' => B, 'code' => C, 'statename' => S);
|
||||
}
|
||||
|
||||
rule(A) ::= rule_subpattern(B) CODE(C). {
|
||||
if (@preg_match('/' . B[0] . '/', '')) {
|
||||
$this->error('Rule "' . B[2] . '" can match the empty string, this will break lexing');
|
||||
}
|
||||
A = array(array('pattern' => B[1], 'code' => C, 'subpatterns' => B[3]));
|
||||
}
|
||||
rule(A) ::= rule(R) rule_subpattern(B) CODE(C).{
|
||||
A = R;
|
||||
if (@preg_match('/' . B[0] . '/', '')) {
|
||||
$this->error('Rule "' . B[2] . '" can match the empty string, this will break lexing');
|
||||
}
|
||||
A[] = array('pattern' => B[1], 'code' => C, 'subpatterns' => B[3]);
|
||||
}
|
||||
|
||||
rule_subpattern(A) ::= QUOTE(B). {
|
||||
A = array(
|
||||
preg_quote(B, '/'),
|
||||
str_replace(array('\\', '"'), array('\\\\', '\\"'), preg_quote(B, '/')),
|
||||
'"' . str_replace('"', '\"', B) . '"', 0);
|
||||
}
|
||||
rule_subpattern(A) ::= SUBPATTERN(B). {
|
||||
if (!isset($this->patterns[B])) {
|
||||
$this->error('Undefined pattern "' . B . '" used in rules');
|
||||
throw new Exception('Undefined pattern "' . B . '" used in rules');
|
||||
}
|
||||
A = array($this->patterns[B]['pattern'], $this->patterns[B]->string, B, $this->patterns[B]['subpatterns']);
|
||||
}
|
||||
rule_subpattern(A) ::= rule_subpattern(B) QUOTE(C). {
|
||||
A = array(
|
||||
B[0] . preg_quote(C, '/'),
|
||||
B[1] . str_replace(array('\\', '"'), array('\\\\', '\\"'), preg_quote(C, '/')),
|
||||
B[2] . ' "' . str_replace('"', '\"', C) . '"', B[3]);
|
||||
}
|
||||
rule_subpattern(A) ::= rule_subpattern(B) SUBPATTERN(C). {
|
||||
if (!isset($this->patterns[C])) {
|
||||
$this->error('Undefined pattern "' . C . '" used in rules');
|
||||
throw new Exception('Undefined pattern "' . C . '" used in rules');
|
||||
}
|
||||
A = array(B[0] . $this->patterns[C]['pattern'], B[1] . $this->patterns[C]->string,
|
||||
B[2] . ' ' . C, B[3] + $this->patterns[C]['subpatterns']);
|
||||
}
|
||||
|
||||
subpattern(A) ::= QUOTE(B). {
|
||||
A = new PHP_LexerGenerator_ParseryyToken(str_replace(array('\\', '"'), array('\\\\', '\\"'), preg_quote(B, '/')), array(
|
||||
'pattern' => preg_quote(B, '/'), 'subpatterns' => 0));
|
||||
}
|
||||
subpattern(A) ::= SUBPATTERN(B). {
|
||||
A = $this->_validatePattern(B);
|
||||
}
|
||||
subpattern(A) ::= subpattern(B) QUOTE(C). {
|
||||
A = new PHP_LexerGenerator_ParseryyToken(B->string . str_replace(array('\\', '"'), array('\\\\', '\\"'), preg_quote(C, '/')), array(
|
||||
'pattern' => B['pattern'] . preg_quote(C, '/'), 'subpatterns' => B['subpatterns']));
|
||||
}
|
||||
subpattern(A) ::= subpattern(B) SUBPATTERN(C). {
|
||||
$x = $this->_validatePattern(C);
|
||||
A = new PHP_LexerGenerator_ParseryyToken(B->string . $x->string, array(
|
||||
'pattern' => B['pattern'] . $x['pattern'],
|
||||
'subpatterns' => $x['subpatterns'] + B['subpatterns']));
|
||||
}
|
843
pkg/vtiger/extensions/Webservices/third-party/LexerGenerator/Regex/Lexer.php
vendored
Normal file
843
pkg/vtiger/extensions/Webservices/third-party/LexerGenerator/Regex/Lexer.php
vendored
Normal file
|
@ -0,0 +1,843 @@
|
|||
<?php
|
||||
require_once dirname(__FILE__) . '/Parser.php';
|
||||
class PHP_LexerGenerator_Regex_Lexer
|
||||
{
|
||||
const MATCHSTART = PHP_LexerGenerator_Regex_Parser::MATCHSTART;
|
||||
const MATCHEND = PHP_LexerGenerator_Regex_Parser::MATCHEND;
|
||||
const CONTROLCHAR = PHP_LexerGenerator_Regex_Parser::CONTROLCHAR;
|
||||
const OPENCHARCLASS = PHP_LexerGenerator_Regex_Parser::OPENCHARCLASS;
|
||||
const FULLSTOP = PHP_LexerGenerator_Regex_Parser::FULLSTOP;
|
||||
const TEXT = PHP_LexerGenerator_Regex_Parser::TEXT;
|
||||
const BACKREFERENCE = PHP_LexerGenerator_Regex_Parser::BACKREFERENCE;
|
||||
const OPENASSERTION = PHP_LexerGenerator_Regex_Parser::OPENASSERTION;
|
||||
const COULDBEBACKREF = PHP_LexerGenerator_Regex_Parser::COULDBEBACKREF;
|
||||
const NEGATE = PHP_LexerGenerator_Regex_Parser::NEGATE;
|
||||
const HYPHEN = PHP_LexerGenerator_Regex_Parser::HYPHEN;
|
||||
const CLOSECHARCLASS = PHP_LexerGenerator_Regex_Parser::CLOSECHARCLASS;
|
||||
const BAR = PHP_LexerGenerator_Regex_Parser::BAR;
|
||||
const MULTIPLIER = PHP_LexerGenerator_Regex_Parser::MULTIPLIER;
|
||||
const INTERNALOPTIONS = PHP_LexerGenerator_Regex_Parser::INTERNALOPTIONS;
|
||||
const COLON = PHP_LexerGenerator_Regex_Parser::COLON;
|
||||
const OPENPAREN = PHP_LexerGenerator_Regex_Parser::OPENPAREN;
|
||||
const CLOSEPAREN = PHP_LexerGenerator_Regex_Parser::CLOSEPAREN;
|
||||
const PATTERNNAME = PHP_LexerGenerator_Regex_Parser::PATTERNNAME;
|
||||
const POSITIVELOOKBEHIND = PHP_LexerGenerator_Regex_Parser::POSITIVELOOKBEHIND;
|
||||
const NEGATIVELOOKBEHIND = PHP_LexerGenerator_Regex_Parser::NEGATIVELOOKBEHIND;
|
||||
const POSITIVELOOKAHEAD = PHP_LexerGenerator_Regex_Parser::POSITIVELOOKAHEAD;
|
||||
const NEGATIVELOOKAHEAD = PHP_LexerGenerator_Regex_Parser::NEGATIVELOOKAHEAD;
|
||||
const ONCEONLY = PHP_LexerGenerator_Regex_Parser::ONCEONLY;
|
||||
const COMMENT = PHP_LexerGenerator_Regex_Parser::COMMENT;
|
||||
const RECUR = PHP_LexerGenerator_Regex_Parser::RECUR;
|
||||
const ESCAPEDBACKSLASH = PHP_LexerGenerator_Regex_Parser::ESCAPEDBACKSLASH;
|
||||
private $input;
|
||||
private $N;
|
||||
public $token;
|
||||
public $value;
|
||||
public $line;
|
||||
|
||||
function __construct($data)
|
||||
{
|
||||
$this->input = $data;
|
||||
$this->N = 0;
|
||||
}
|
||||
|
||||
function reset($data)
|
||||
{
|
||||
$this->input = $data;
|
||||
$this->N = 0;
|
||||
$this->yybegin(self::INITIAL);
|
||||
}
|
||||
|
||||
|
||||
private $_yy_state = 1;
|
||||
private $_yy_stack = array();
|
||||
|
||||
function yylex()
|
||||
{
|
||||
return $this->{'yylex' . $this->_yy_state}();
|
||||
}
|
||||
|
||||
function yypushstate($state)
|
||||
{
|
||||
array_push($this->_yy_stack, $this->_yy_state);
|
||||
$this->_yy_state = $state;
|
||||
}
|
||||
|
||||
function yypopstate()
|
||||
{
|
||||
$this->_yy_state = array_pop($this->_yy_stack);
|
||||
}
|
||||
|
||||
function yybegin($state)
|
||||
{
|
||||
$this->_yy_state = $state;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function yylex1()
|
||||
{
|
||||
$tokenMap = array (
|
||||
1 => 0,
|
||||
2 => 0,
|
||||
3 => 0,
|
||||
4 => 0,
|
||||
5 => 0,
|
||||
6 => 0,
|
||||
7 => 0,
|
||||
8 => 0,
|
||||
9 => 0,
|
||||
10 => 0,
|
||||
11 => 0,
|
||||
12 => 0,
|
||||
13 => 0,
|
||||
14 => 0,
|
||||
15 => 0,
|
||||
16 => 0,
|
||||
17 => 0,
|
||||
18 => 0,
|
||||
19 => 0,
|
||||
20 => 0,
|
||||
21 => 0,
|
||||
22 => 0,
|
||||
23 => 0,
|
||||
);
|
||||
if ($this->N >= strlen($this->input)) {
|
||||
return false; // end of input
|
||||
}
|
||||
$yy_global_pattern = "/^(\\\\\\\\)|^([^[\\\\^$.|()?*+{}]+)|^(\\\\[][{}*.^$|?()+])|^(\\[)|^(\\|)|^(\\\\[0-9][0-9])|^(\\\\[frnt]|\\\\x[0-9a-fA-F][0-9a-fA-F]?|\\\\[0-7][0-7][0-7]|\\\\x\\{[0-9a-fA-F]+\\})|^(\\\\[abBGcedDsSwW0C])|^(\\^)|^(\\\\A)|^(\\))|^(\\$)|^([*?+]|\\{[0-9]+\\}|\\{[0-9]+,\\}|\\{[0-9]+,[0-9]+\\})|^(\\\\[zZ])|^(\\(\\?)|^(\\()|^(\\.)|^(\\\\[1-9])|^(\\\\p\\{\\^?..?\\}|\\\\P\\{..?\\}|\\\\X)|^(\\\\p\\{C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p\\{\\^C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p[CLMNPSZ])|^(\\\\)/";
|
||||
|
||||
do {
|
||||
if (preg_match($yy_global_pattern, substr($this->input, $this->N), $yymatches)) {
|
||||
$yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
|
||||
if (!count($yymatches)) {
|
||||
throw new Exception('Error: lexing failed because a rule matched' .
|
||||
'an empty string. Input "' . substr($this->input,
|
||||
$this->N, 5) . '... state INITIAL');
|
||||
}
|
||||
next($yymatches); // skip global match
|
||||
$this->token = key($yymatches); // token number
|
||||
// extract sub-patterns for passing to lex function
|
||||
$yysubmatches = array_slice($yymatches, $this->token,
|
||||
$tokenMap[$this->token]);
|
||||
$this->value = current($yymatches); // token value
|
||||
$r = $this->{'yy_r1_' . $this->token}($yysubmatches);
|
||||
if ($r === null) {
|
||||
$this->N += strlen($this->value);
|
||||
$this->line += substr_count("\n", $this->value);
|
||||
// accept this token
|
||||
return true;
|
||||
} elseif ($r === true) {
|
||||
// we have changed state
|
||||
// process this token in the new state
|
||||
return $this->yylex();
|
||||
} elseif ($r === false) {
|
||||
$this->N += strlen($this->value);
|
||||
$this->line += substr_count("\n", $this->value);
|
||||
if ($this->N >= strlen($this->input)) {
|
||||
return false; // end of input
|
||||
}
|
||||
// skip this token
|
||||
continue;
|
||||
} else { $yy_yymore_patterns = array(
|
||||
1 => "^([^[\\\\^$.|()?*+{}]+)|^(\\\\[][{}*.^$|?()+])|^(\\[)|^(\\|)|^(\\\\[0-9][0-9])|^(\\\\[frnt]|\\\\x[0-9a-fA-F][0-9a-fA-F]?|\\\\[0-7][0-7][0-7]|\\\\x\\{[0-9a-fA-F]+\\})|^(\\\\[abBGcedDsSwW0C])|^(\\^)|^(\\\\A)|^(\\))|^(\\$)|^([*?+]|\\{[0-9]+\\}|\\{[0-9]+,\\}|\\{[0-9]+,[0-9]+\\})|^(\\\\[zZ])|^(\\(\\?)|^(\\()|^(\\.)|^(\\\\[1-9])|^(\\\\p\\{\\^?..?\\}|\\\\P\\{..?\\}|\\\\X)|^(\\\\p\\{C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p\\{\\^C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p[CLMNPSZ])|^(\\\\)",
|
||||
2 => "^(\\\\[][{}*.^$|?()+])|^(\\[)|^(\\|)|^(\\\\[0-9][0-9])|^(\\\\[frnt]|\\\\x[0-9a-fA-F][0-9a-fA-F]?|\\\\[0-7][0-7][0-7]|\\\\x\\{[0-9a-fA-F]+\\})|^(\\\\[abBGcedDsSwW0C])|^(\\^)|^(\\\\A)|^(\\))|^(\\$)|^([*?+]|\\{[0-9]+\\}|\\{[0-9]+,\\}|\\{[0-9]+,[0-9]+\\})|^(\\\\[zZ])|^(\\(\\?)|^(\\()|^(\\.)|^(\\\\[1-9])|^(\\\\p\\{\\^?..?\\}|\\\\P\\{..?\\}|\\\\X)|^(\\\\p\\{C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p\\{\\^C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p[CLMNPSZ])|^(\\\\)",
|
||||
3 => "^(\\[)|^(\\|)|^(\\\\[0-9][0-9])|^(\\\\[frnt]|\\\\x[0-9a-fA-F][0-9a-fA-F]?|\\\\[0-7][0-7][0-7]|\\\\x\\{[0-9a-fA-F]+\\})|^(\\\\[abBGcedDsSwW0C])|^(\\^)|^(\\\\A)|^(\\))|^(\\$)|^([*?+]|\\{[0-9]+\\}|\\{[0-9]+,\\}|\\{[0-9]+,[0-9]+\\})|^(\\\\[zZ])|^(\\(\\?)|^(\\()|^(\\.)|^(\\\\[1-9])|^(\\\\p\\{\\^?..?\\}|\\\\P\\{..?\\}|\\\\X)|^(\\\\p\\{C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p\\{\\^C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p[CLMNPSZ])|^(\\\\)",
|
||||
4 => "^(\\|)|^(\\\\[0-9][0-9])|^(\\\\[frnt]|\\\\x[0-9a-fA-F][0-9a-fA-F]?|\\\\[0-7][0-7][0-7]|\\\\x\\{[0-9a-fA-F]+\\})|^(\\\\[abBGcedDsSwW0C])|^(\\^)|^(\\\\A)|^(\\))|^(\\$)|^([*?+]|\\{[0-9]+\\}|\\{[0-9]+,\\}|\\{[0-9]+,[0-9]+\\})|^(\\\\[zZ])|^(\\(\\?)|^(\\()|^(\\.)|^(\\\\[1-9])|^(\\\\p\\{\\^?..?\\}|\\\\P\\{..?\\}|\\\\X)|^(\\\\p\\{C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p\\{\\^C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p[CLMNPSZ])|^(\\\\)",
|
||||
5 => "^(\\\\[0-9][0-9])|^(\\\\[frnt]|\\\\x[0-9a-fA-F][0-9a-fA-F]?|\\\\[0-7][0-7][0-7]|\\\\x\\{[0-9a-fA-F]+\\})|^(\\\\[abBGcedDsSwW0C])|^(\\^)|^(\\\\A)|^(\\))|^(\\$)|^([*?+]|\\{[0-9]+\\}|\\{[0-9]+,\\}|\\{[0-9]+,[0-9]+\\})|^(\\\\[zZ])|^(\\(\\?)|^(\\()|^(\\.)|^(\\\\[1-9])|^(\\\\p\\{\\^?..?\\}|\\\\P\\{..?\\}|\\\\X)|^(\\\\p\\{C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p\\{\\^C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p[CLMNPSZ])|^(\\\\)",
|
||||
6 => "^(\\\\[frnt]|\\\\x[0-9a-fA-F][0-9a-fA-F]?|\\\\[0-7][0-7][0-7]|\\\\x\\{[0-9a-fA-F]+\\})|^(\\\\[abBGcedDsSwW0C])|^(\\^)|^(\\\\A)|^(\\))|^(\\$)|^([*?+]|\\{[0-9]+\\}|\\{[0-9]+,\\}|\\{[0-9]+,[0-9]+\\})|^(\\\\[zZ])|^(\\(\\?)|^(\\()|^(\\.)|^(\\\\[1-9])|^(\\\\p\\{\\^?..?\\}|\\\\P\\{..?\\}|\\\\X)|^(\\\\p\\{C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p\\{\\^C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p[CLMNPSZ])|^(\\\\)",
|
||||
7 => "^(\\\\[abBGcedDsSwW0C])|^(\\^)|^(\\\\A)|^(\\))|^(\\$)|^([*?+]|\\{[0-9]+\\}|\\{[0-9]+,\\}|\\{[0-9]+,[0-9]+\\})|^(\\\\[zZ])|^(\\(\\?)|^(\\()|^(\\.)|^(\\\\[1-9])|^(\\\\p\\{\\^?..?\\}|\\\\P\\{..?\\}|\\\\X)|^(\\\\p\\{C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p\\{\\^C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p[CLMNPSZ])|^(\\\\)",
|
||||
8 => "^(\\^)|^(\\\\A)|^(\\))|^(\\$)|^([*?+]|\\{[0-9]+\\}|\\{[0-9]+,\\}|\\{[0-9]+,[0-9]+\\})|^(\\\\[zZ])|^(\\(\\?)|^(\\()|^(\\.)|^(\\\\[1-9])|^(\\\\p\\{\\^?..?\\}|\\\\P\\{..?\\}|\\\\X)|^(\\\\p\\{C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p\\{\\^C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p[CLMNPSZ])|^(\\\\)",
|
||||
9 => "^(\\\\A)|^(\\))|^(\\$)|^([*?+]|\\{[0-9]+\\}|\\{[0-9]+,\\}|\\{[0-9]+,[0-9]+\\})|^(\\\\[zZ])|^(\\(\\?)|^(\\()|^(\\.)|^(\\\\[1-9])|^(\\\\p\\{\\^?..?\\}|\\\\P\\{..?\\}|\\\\X)|^(\\\\p\\{C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p\\{\\^C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p[CLMNPSZ])|^(\\\\)",
|
||||
10 => "^(\\))|^(\\$)|^([*?+]|\\{[0-9]+\\}|\\{[0-9]+,\\}|\\{[0-9]+,[0-9]+\\})|^(\\\\[zZ])|^(\\(\\?)|^(\\()|^(\\.)|^(\\\\[1-9])|^(\\\\p\\{\\^?..?\\}|\\\\P\\{..?\\}|\\\\X)|^(\\\\p\\{C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p\\{\\^C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p[CLMNPSZ])|^(\\\\)",
|
||||
11 => "^(\\$)|^([*?+]|\\{[0-9]+\\}|\\{[0-9]+,\\}|\\{[0-9]+,[0-9]+\\})|^(\\\\[zZ])|^(\\(\\?)|^(\\()|^(\\.)|^(\\\\[1-9])|^(\\\\p\\{\\^?..?\\}|\\\\P\\{..?\\}|\\\\X)|^(\\\\p\\{C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p\\{\\^C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p[CLMNPSZ])|^(\\\\)",
|
||||
12 => "^([*?+]|\\{[0-9]+\\}|\\{[0-9]+,\\}|\\{[0-9]+,[0-9]+\\})|^(\\\\[zZ])|^(\\(\\?)|^(\\()|^(\\.)|^(\\\\[1-9])|^(\\\\p\\{\\^?..?\\}|\\\\P\\{..?\\}|\\\\X)|^(\\\\p\\{C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p\\{\\^C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p[CLMNPSZ])|^(\\\\)",
|
||||
13 => "^(\\\\[zZ])|^(\\(\\?)|^(\\()|^(\\.)|^(\\\\[1-9])|^(\\\\p\\{\\^?..?\\}|\\\\P\\{..?\\}|\\\\X)|^(\\\\p\\{C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p\\{\\^C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p[CLMNPSZ])|^(\\\\)",
|
||||
14 => "^(\\(\\?)|^(\\()|^(\\.)|^(\\\\[1-9])|^(\\\\p\\{\\^?..?\\}|\\\\P\\{..?\\}|\\\\X)|^(\\\\p\\{C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p\\{\\^C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p[CLMNPSZ])|^(\\\\)",
|
||||
15 => "^(\\()|^(\\.)|^(\\\\[1-9])|^(\\\\p\\{\\^?..?\\}|\\\\P\\{..?\\}|\\\\X)|^(\\\\p\\{C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p\\{\\^C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p[CLMNPSZ])|^(\\\\)",
|
||||
16 => "^(\\.)|^(\\\\[1-9])|^(\\\\p\\{\\^?..?\\}|\\\\P\\{..?\\}|\\\\X)|^(\\\\p\\{C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p\\{\\^C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p[CLMNPSZ])|^(\\\\)",
|
||||
17 => "^(\\\\[1-9])|^(\\\\p\\{\\^?..?\\}|\\\\P\\{..?\\}|\\\\X)|^(\\\\p\\{C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p\\{\\^C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p[CLMNPSZ])|^(\\\\)",
|
||||
18 => "^(\\\\p\\{\\^?..?\\}|\\\\P\\{..?\\}|\\\\X)|^(\\\\p\\{C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p\\{\\^C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p[CLMNPSZ])|^(\\\\)",
|
||||
19 => "^(\\\\p\\{C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p\\{\\^C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p[CLMNPSZ])|^(\\\\)",
|
||||
20 => "^(\\\\p\\{\\^C[cfnos]?|L[lmotu]?|M[cen]?|N[dlo]?|P[cdefios]?|S[ckmo]?|Z[lps]?\\})|^(\\\\p[CLMNPSZ])|^(\\\\)",
|
||||
21 => "^(\\\\p[CLMNPSZ])|^(\\\\)",
|
||||
22 => "^(\\\\)",
|
||||
23 => "",
|
||||
);
|
||||
|
||||
// yymore is needed
|
||||
do {
|
||||
if (!strlen($yy_yymore_patterns[$this->token])) {
|
||||
throw new Exception('cannot do yymore for the last token');
|
||||
}
|
||||
if (preg_match($yy_yymore_patterns[$this->token],
|
||||
substr($this->input, $this->N), $yymatches)) {
|
||||
$yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
|
||||
next($yymatches); // skip global match
|
||||
$this->token = key($yymatches); // token number
|
||||
$this->value = current($yymatches); // token value
|
||||
$this->line = substr_count("\n", $this->value);
|
||||
}
|
||||
} while ($this->{'yy_r1_' . $this->token}() !== null);
|
||||
// accept
|
||||
$this->N += strlen($this->value);
|
||||
$this->line += substr_count("\n", $this->value);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
throw new Exception('Unexpected input at line' . $this->line .
|
||||
': ' . $this->input[$this->N]);
|
||||
}
|
||||
break;
|
||||
} while (true);
|
||||
} // end function
|
||||
|
||||
|
||||
const INITIAL = 1;
|
||||
function yy_r1_1($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::ESCAPEDBACKSLASH;
|
||||
}
|
||||
function yy_r1_2($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::TEXT;
|
||||
}
|
||||
function yy_r1_3($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::CONTROLCHAR;
|
||||
}
|
||||
function yy_r1_4($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::OPENCHARCLASS;
|
||||
$this->yybegin(self::CHARACTERCLASSSTART);
|
||||
}
|
||||
function yy_r1_5($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::BAR;
|
||||
}
|
||||
function yy_r1_6($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::COULDBEBACKREF;
|
||||
}
|
||||
function yy_r1_7($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::TEXT;
|
||||
}
|
||||
function yy_r1_8($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::CONTROLCHAR;
|
||||
}
|
||||
function yy_r1_9($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::MATCHSTART;
|
||||
}
|
||||
function yy_r1_10($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::MATCHSTART;
|
||||
}
|
||||
function yy_r1_11($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::CLOSEPAREN;
|
||||
$this->yybegin(self::INITIAL);
|
||||
}
|
||||
function yy_r1_12($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::MATCHEND;
|
||||
}
|
||||
function yy_r1_13($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::MULTIPLIER;
|
||||
}
|
||||
function yy_r1_14($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::MATCHEND;
|
||||
}
|
||||
function yy_r1_15($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::OPENASSERTION;
|
||||
$this->yybegin(self::ASSERTION);
|
||||
}
|
||||
function yy_r1_16($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::OPENPAREN;
|
||||
}
|
||||
function yy_r1_17($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::FULLSTOP;
|
||||
}
|
||||
function yy_r1_18($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::BACKREFERENCE;
|
||||
}
|
||||
function yy_r1_19($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::CONTROLCHAR;
|
||||
}
|
||||
function yy_r1_20($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::CONTROLCHAR;
|
||||
}
|
||||
function yy_r1_21($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::CONTROLCHAR;
|
||||
}
|
||||
function yy_r1_22($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::CONTROLCHAR;
|
||||
}
|
||||
function yy_r1_23($yy_subpatterns)
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function yylex2()
|
||||
{
|
||||
$tokenMap = array (
|
||||
1 => 0,
|
||||
2 => 0,
|
||||
3 => 0,
|
||||
);
|
||||
if ($this->N >= strlen($this->input)) {
|
||||
return false; // end of input
|
||||
}
|
||||
$yy_global_pattern = "/^(\\^)|^(\\])|^(.)/";
|
||||
|
||||
do {
|
||||
if (preg_match($yy_global_pattern, substr($this->input, $this->N), $yymatches)) {
|
||||
$yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
|
||||
if (!count($yymatches)) {
|
||||
throw new Exception('Error: lexing failed because a rule matched' .
|
||||
'an empty string. Input "' . substr($this->input,
|
||||
$this->N, 5) . '... state CHARACTERCLASSSTART');
|
||||
}
|
||||
next($yymatches); // skip global match
|
||||
$this->token = key($yymatches); // token number
|
||||
// extract sub-patterns for passing to lex function
|
||||
$yysubmatches = array_slice($yymatches, $this->token,
|
||||
$tokenMap[$this->token]);
|
||||
$this->value = current($yymatches); // token value
|
||||
$r = $this->{'yy_r2_' . $this->token}($yysubmatches);
|
||||
if ($r === null) {
|
||||
$this->N += strlen($this->value);
|
||||
$this->line += substr_count("\n", $this->value);
|
||||
// accept this token
|
||||
return true;
|
||||
} elseif ($r === true) {
|
||||
// we have changed state
|
||||
// process this token in the new state
|
||||
return $this->yylex();
|
||||
} elseif ($r === false) {
|
||||
$this->N += strlen($this->value);
|
||||
$this->line += substr_count("\n", $this->value);
|
||||
if ($this->N >= strlen($this->input)) {
|
||||
return false; // end of input
|
||||
}
|
||||
// skip this token
|
||||
continue;
|
||||
} else { $yy_yymore_patterns = array(
|
||||
1 => "^(\\])|^(.)",
|
||||
2 => "^(.)",
|
||||
3 => "",
|
||||
);
|
||||
|
||||
// yymore is needed
|
||||
do {
|
||||
if (!strlen($yy_yymore_patterns[$this->token])) {
|
||||
throw new Exception('cannot do yymore for the last token');
|
||||
}
|
||||
if (preg_match($yy_yymore_patterns[$this->token],
|
||||
substr($this->input, $this->N), $yymatches)) {
|
||||
$yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
|
||||
next($yymatches); // skip global match
|
||||
$this->token = key($yymatches); // token number
|
||||
$this->value = current($yymatches); // token value
|
||||
$this->line = substr_count("\n", $this->value);
|
||||
}
|
||||
} while ($this->{'yy_r2_' . $this->token}() !== null);
|
||||
// accept
|
||||
$this->N += strlen($this->value);
|
||||
$this->line += substr_count("\n", $this->value);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
throw new Exception('Unexpected input at line' . $this->line .
|
||||
': ' . $this->input[$this->N]);
|
||||
}
|
||||
break;
|
||||
} while (true);
|
||||
} // end function
|
||||
|
||||
|
||||
const CHARACTERCLASSSTART = 2;
|
||||
function yy_r2_1($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::NEGATE;
|
||||
}
|
||||
function yy_r2_2($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->yybegin(self::CHARACTERCLASS);
|
||||
$this->token = self::TEXT;
|
||||
}
|
||||
function yy_r2_3($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->yybegin(self::CHARACTERCLASS);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function yylex3()
|
||||
{
|
||||
$tokenMap = array (
|
||||
1 => 0,
|
||||
2 => 0,
|
||||
3 => 0,
|
||||
4 => 0,
|
||||
5 => 0,
|
||||
6 => 0,
|
||||
7 => 0,
|
||||
8 => 0,
|
||||
9 => 0,
|
||||
);
|
||||
if ($this->N >= strlen($this->input)) {
|
||||
return false; // end of input
|
||||
}
|
||||
$yy_global_pattern = "/^(\\\\\\\\)|^(\\])|^(\\\\[]\\.\\-\\^])|^(\\\\[frnt]|\\\\x[0-9a-fA-F][0-9a-fA-F]?|\\\\[0-7][0-7][0-7]|\\\\x\\{[0-9a-fA-F]+\\})|^(\\\\[bacedDsSwW0C]|\\\\x\\{[0-9a-fA-F]+\\})|^(-(?!]))|^([^\\-\\\\])|^(\\\\)|^(.)/";
|
||||
|
||||
do {
|
||||
if (preg_match($yy_global_pattern, substr($this->input, $this->N), $yymatches)) {
|
||||
$yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
|
||||
if (!count($yymatches)) {
|
||||
throw new Exception('Error: lexing failed because a rule matched' .
|
||||
'an empty string. Input "' . substr($this->input,
|
||||
$this->N, 5) . '... state CHARACTERCLASS');
|
||||
}
|
||||
next($yymatches); // skip global match
|
||||
$this->token = key($yymatches); // token number
|
||||
// extract sub-patterns for passing to lex function
|
||||
$yysubmatches = array_slice($yymatches, $this->token,
|
||||
$tokenMap[$this->token]);
|
||||
$this->value = current($yymatches); // token value
|
||||
$r = $this->{'yy_r3_' . $this->token}($yysubmatches);
|
||||
if ($r === null) {
|
||||
$this->N += strlen($this->value);
|
||||
$this->line += substr_count("\n", $this->value);
|
||||
// accept this token
|
||||
return true;
|
||||
} elseif ($r === true) {
|
||||
// we have changed state
|
||||
// process this token in the new state
|
||||
return $this->yylex();
|
||||
} elseif ($r === false) {
|
||||
$this->N += strlen($this->value);
|
||||
$this->line += substr_count("\n", $this->value);
|
||||
if ($this->N >= strlen($this->input)) {
|
||||
return false; // end of input
|
||||
}
|
||||
// skip this token
|
||||
continue;
|
||||
} else { $yy_yymore_patterns = array(
|
||||
1 => "^(\\])|^(\\\\[]\\.\\-\\^])|^(\\\\[frnt]|\\\\x[0-9a-fA-F][0-9a-fA-F]?|\\\\[0-7][0-7][0-7]|\\\\x\\{[0-9a-fA-F]+\\})|^(\\\\[bacedDsSwW0C]|\\\\x\\{[0-9a-fA-F]+\\})|^(-(?!]))|^([^\\-\\\\])|^(\\\\)|^(.)",
|
||||
2 => "^(\\\\[]\\.\\-\\^])|^(\\\\[frnt]|\\\\x[0-9a-fA-F][0-9a-fA-F]?|\\\\[0-7][0-7][0-7]|\\\\x\\{[0-9a-fA-F]+\\})|^(\\\\[bacedDsSwW0C]|\\\\x\\{[0-9a-fA-F]+\\})|^(-(?!]))|^([^\\-\\\\])|^(\\\\)|^(.)",
|
||||
3 => "^(\\\\[frnt]|\\\\x[0-9a-fA-F][0-9a-fA-F]?|\\\\[0-7][0-7][0-7]|\\\\x\\{[0-9a-fA-F]+\\})|^(\\\\[bacedDsSwW0C]|\\\\x\\{[0-9a-fA-F]+\\})|^(-(?!]))|^([^\\-\\\\])|^(\\\\)|^(.)",
|
||||
4 => "^(\\\\[bacedDsSwW0C]|\\\\x\\{[0-9a-fA-F]+\\})|^(-(?!]))|^([^\\-\\\\])|^(\\\\)|^(.)",
|
||||
5 => "^(-(?!]))|^([^\\-\\\\])|^(\\\\)|^(.)",
|
||||
6 => "^([^\\-\\\\])|^(\\\\)|^(.)",
|
||||
7 => "^(\\\\)|^(.)",
|
||||
8 => "^(.)",
|
||||
9 => "",
|
||||
);
|
||||
|
||||
// yymore is needed
|
||||
do {
|
||||
if (!strlen($yy_yymore_patterns[$this->token])) {
|
||||
throw new Exception('cannot do yymore for the last token');
|
||||
}
|
||||
if (preg_match($yy_yymore_patterns[$this->token],
|
||||
substr($this->input, $this->N), $yymatches)) {
|
||||
$yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
|
||||
next($yymatches); // skip global match
|
||||
$this->token = key($yymatches); // token number
|
||||
$this->value = current($yymatches); // token value
|
||||
$this->line = substr_count("\n", $this->value);
|
||||
}
|
||||
} while ($this->{'yy_r3_' . $this->token}() !== null);
|
||||
// accept
|
||||
$this->N += strlen($this->value);
|
||||
$this->line += substr_count("\n", $this->value);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
throw new Exception('Unexpected input at line' . $this->line .
|
||||
': ' . $this->input[$this->N]);
|
||||
}
|
||||
break;
|
||||
} while (true);
|
||||
} // end function
|
||||
|
||||
|
||||
const CHARACTERCLASS = 3;
|
||||
function yy_r3_1($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::ESCAPEDBACKSLASH;
|
||||
}
|
||||
function yy_r3_2($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->yybegin(self::INITIAL);
|
||||
$this->token = self::CLOSECHARCLASS;
|
||||
}
|
||||
function yy_r3_3($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::CONTROLCHAR;
|
||||
}
|
||||
function yy_r3_4($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::TEXT;
|
||||
}
|
||||
function yy_r3_5($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::CONTROLCHAR;
|
||||
}
|
||||
function yy_r3_6($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::HYPHEN;
|
||||
$this->yybegin(self::RANGE);
|
||||
}
|
||||
function yy_r3_7($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::TEXT;
|
||||
}
|
||||
function yy_r3_8($yy_subpatterns)
|
||||
{
|
||||
|
||||
return false; // ignore escaping of normal text
|
||||
}
|
||||
function yy_r3_9($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::TEXT;
|
||||
}
|
||||
|
||||
|
||||
function yylex4()
|
||||
{
|
||||
$tokenMap = array (
|
||||
1 => 0,
|
||||
2 => 0,
|
||||
3 => 0,
|
||||
4 => 0,
|
||||
5 => 0,
|
||||
);
|
||||
if ($this->N >= strlen($this->input)) {
|
||||
return false; // end of input
|
||||
}
|
||||
$yy_global_pattern = "/^(\\\\\\\\)|^(\\\\\\])|^(\\\\[bacedDsSwW0C]|\\\\x\\{[0-9a-fA-F]+\\})|^([^\\-\\\\])|^(\\\\)/";
|
||||
|
||||
do {
|
||||
if (preg_match($yy_global_pattern, substr($this->input, $this->N), $yymatches)) {
|
||||
$yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
|
||||
if (!count($yymatches)) {
|
||||
throw new Exception('Error: lexing failed because a rule matched' .
|
||||
'an empty string. Input "' . substr($this->input,
|
||||
$this->N, 5) . '... state RANGE');
|
||||
}
|
||||
next($yymatches); // skip global match
|
||||
$this->token = key($yymatches); // token number
|
||||
// extract sub-patterns for passing to lex function
|
||||
$yysubmatches = array_slice($yymatches, $this->token,
|
||||
$tokenMap[$this->token]);
|
||||
$this->value = current($yymatches); // token value
|
||||
$r = $this->{'yy_r4_' . $this->token}($yysubmatches);
|
||||
if ($r === null) {
|
||||
$this->N += strlen($this->value);
|
||||
$this->line += substr_count("\n", $this->value);
|
||||
// accept this token
|
||||
return true;
|
||||
} elseif ($r === true) {
|
||||
// we have changed state
|
||||
// process this token in the new state
|
||||
return $this->yylex();
|
||||
} elseif ($r === false) {
|
||||
$this->N += strlen($this->value);
|
||||
$this->line += substr_count("\n", $this->value);
|
||||
if ($this->N >= strlen($this->input)) {
|
||||
return false; // end of input
|
||||
}
|
||||
// skip this token
|
||||
continue;
|
||||
} else { $yy_yymore_patterns = array(
|
||||
1 => "^(\\\\\\])|^(\\\\[bacedDsSwW0C]|\\\\x\\{[0-9a-fA-F]+\\})|^([^\\-\\\\])|^(\\\\)",
|
||||
2 => "^(\\\\[bacedDsSwW0C]|\\\\x\\{[0-9a-fA-F]+\\})|^([^\\-\\\\])|^(\\\\)",
|
||||
3 => "^([^\\-\\\\])|^(\\\\)",
|
||||
4 => "^(\\\\)",
|
||||
5 => "",
|
||||
);
|
||||
|
||||
// yymore is needed
|
||||
do {
|
||||
if (!strlen($yy_yymore_patterns[$this->token])) {
|
||||
throw new Exception('cannot do yymore for the last token');
|
||||
}
|
||||
if (preg_match($yy_yymore_patterns[$this->token],
|
||||
substr($this->input, $this->N), $yymatches)) {
|
||||
$yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
|
||||
next($yymatches); // skip global match
|
||||
$this->token = key($yymatches); // token number
|
||||
$this->value = current($yymatches); // token value
|
||||
$this->line = substr_count("\n", $this->value);
|
||||
}
|
||||
} while ($this->{'yy_r4_' . $this->token}() !== null);
|
||||
// accept
|
||||
$this->N += strlen($this->value);
|
||||
$this->line += substr_count("\n", $this->value);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
throw new Exception('Unexpected input at line' . $this->line .
|
||||
': ' . $this->input[$this->N]);
|
||||
}
|
||||
break;
|
||||
} while (true);
|
||||
} // end function
|
||||
|
||||
|
||||
const RANGE = 4;
|
||||
function yy_r4_1($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::ESCAPEDBACKSLASH;
|
||||
}
|
||||
function yy_r4_2($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::TEXT;
|
||||
$this->yybegin(self::CHARACTERCLASS);
|
||||
}
|
||||
function yy_r4_3($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::CONTROLCHAR;
|
||||
$this->yybegin(self::CHARACTERCLASS);
|
||||
}
|
||||
function yy_r4_4($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::TEXT;
|
||||
$this->yybegin(self::CHARACTERCLASS);
|
||||
}
|
||||
function yy_r4_5($yy_subpatterns)
|
||||
{
|
||||
|
||||
return false; // ignore escaping of normal text
|
||||
}
|
||||
|
||||
|
||||
function yylex5()
|
||||
{
|
||||
$tokenMap = array (
|
||||
1 => 0,
|
||||
2 => 0,
|
||||
3 => 0,
|
||||
4 => 0,
|
||||
5 => 0,
|
||||
6 => 0,
|
||||
7 => 0,
|
||||
8 => 0,
|
||||
9 => 0,
|
||||
10 => 0,
|
||||
11 => 0,
|
||||
12 => 0,
|
||||
13 => 0,
|
||||
);
|
||||
if ($this->N >= strlen($this->input)) {
|
||||
return false; // end of input
|
||||
}
|
||||
$yy_global_pattern = "/^([imsxUX]+-[imsxUX]+|[imsxUX]+|-[imsxUX]+)|^(\\:)|^(\\))|^(P\\<[^>]+\\>)|^(\\<\\=)|^(\\<\\!)|^(\\=)|^(\\!)|^(\\>)|^(\\(\\?)|^(#[^)]+)|^(R)|^(.)/";
|
||||
|
||||
do {
|
||||
if (preg_match($yy_global_pattern, substr($this->input, $this->N), $yymatches)) {
|
||||
$yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
|
||||
if (!count($yymatches)) {
|
||||
throw new Exception('Error: lexing failed because a rule matched' .
|
||||
'an empty string. Input "' . substr($this->input,
|
||||
$this->N, 5) . '... state ASSERTION');
|
||||
}
|
||||
next($yymatches); // skip global match
|
||||
$this->token = key($yymatches); // token number
|
||||
// extract sub-patterns for passing to lex function
|
||||
$yysubmatches = array_slice($yymatches, $this->token,
|
||||
$tokenMap[$this->token]);
|
||||
$this->value = current($yymatches); // token value
|
||||
$r = $this->{'yy_r5_' . $this->token}($yysubmatches);
|
||||
if ($r === null) {
|
||||
$this->N += strlen($this->value);
|
||||
$this->line += substr_count("\n", $this->value);
|
||||
// accept this token
|
||||
return true;
|
||||
} elseif ($r === true) {
|
||||
// we have changed state
|
||||
// process this token in the new state
|
||||
return $this->yylex();
|
||||
} elseif ($r === false) {
|
||||
$this->N += strlen($this->value);
|
||||
$this->line += substr_count("\n", $this->value);
|
||||
if ($this->N >= strlen($this->input)) {
|
||||
return false; // end of input
|
||||
}
|
||||
// skip this token
|
||||
continue;
|
||||
} else { $yy_yymore_patterns = array(
|
||||
1 => "^(\\:)|^(\\))|^(P\\<[^>]+\\>)|^(\\<\\=)|^(\\<\\!)|^(\\=)|^(\\!)|^(\\>)|^(\\(\\?)|^(#[^)]+)|^(R)|^(.)",
|
||||
2 => "^(\\))|^(P\\<[^>]+\\>)|^(\\<\\=)|^(\\<\\!)|^(\\=)|^(\\!)|^(\\>)|^(\\(\\?)|^(#[^)]+)|^(R)|^(.)",
|
||||
3 => "^(P\\<[^>]+\\>)|^(\\<\\=)|^(\\<\\!)|^(\\=)|^(\\!)|^(\\>)|^(\\(\\?)|^(#[^)]+)|^(R)|^(.)",
|
||||
4 => "^(\\<\\=)|^(\\<\\!)|^(\\=)|^(\\!)|^(\\>)|^(\\(\\?)|^(#[^)]+)|^(R)|^(.)",
|
||||
5 => "^(\\<\\!)|^(\\=)|^(\\!)|^(\\>)|^(\\(\\?)|^(#[^)]+)|^(R)|^(.)",
|
||||
6 => "^(\\=)|^(\\!)|^(\\>)|^(\\(\\?)|^(#[^)]+)|^(R)|^(.)",
|
||||
7 => "^(\\!)|^(\\>)|^(\\(\\?)|^(#[^)]+)|^(R)|^(.)",
|
||||
8 => "^(\\>)|^(\\(\\?)|^(#[^)]+)|^(R)|^(.)",
|
||||
9 => "^(\\(\\?)|^(#[^)]+)|^(R)|^(.)",
|
||||
10 => "^(#[^)]+)|^(R)|^(.)",
|
||||
11 => "^(R)|^(.)",
|
||||
12 => "^(.)",
|
||||
13 => "",
|
||||
);
|
||||
|
||||
// yymore is needed
|
||||
do {
|
||||
if (!strlen($yy_yymore_patterns[$this->token])) {
|
||||
throw new Exception('cannot do yymore for the last token');
|
||||
}
|
||||
if (preg_match($yy_yymore_patterns[$this->token],
|
||||
substr($this->input, $this->N), $yymatches)) {
|
||||
$yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
|
||||
next($yymatches); // skip global match
|
||||
$this->token = key($yymatches); // token number
|
||||
$this->value = current($yymatches); // token value
|
||||
$this->line = substr_count("\n", $this->value);
|
||||
}
|
||||
} while ($this->{'yy_r5_' . $this->token}() !== null);
|
||||
// accept
|
||||
$this->N += strlen($this->value);
|
||||
$this->line += substr_count("\n", $this->value);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
throw new Exception('Unexpected input at line' . $this->line .
|
||||
': ' . $this->input[$this->N]);
|
||||
}
|
||||
break;
|
||||
} while (true);
|
||||
} // end function
|
||||
|
||||
|
||||
const ASSERTION = 5;
|
||||
function yy_r5_1($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::INTERNALOPTIONS;
|
||||
}
|
||||
function yy_r5_2($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::COLON;
|
||||
$this->yybegin(self::INITIAL);
|
||||
}
|
||||
function yy_r5_3($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::CLOSEPAREN;
|
||||
$this->yybegin(self::INITIAL);
|
||||
}
|
||||
function yy_r5_4($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::PATTERNNAME;
|
||||
$this->yybegin(self::INITIAL);
|
||||
}
|
||||
function yy_r5_5($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::POSITIVELOOKBEHIND;
|
||||
$this->yybegin(self::INITIAL);
|
||||
}
|
||||
function yy_r5_6($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::NEGATIVELOOKBEHIND;
|
||||
$this->yybegin(self::INITIAL);
|
||||
}
|
||||
function yy_r5_7($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::POSITIVELOOKAHEAD;
|
||||
$this->yybegin(self::INITIAL);
|
||||
}
|
||||
function yy_r5_8($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::NEGATIVELOOKAHEAD;
|
||||
$this->yybegin(self::INITIAL);
|
||||
}
|
||||
function yy_r5_9($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::ONCEONLY;
|
||||
$this->yybegin(self::INITIAL);
|
||||
}
|
||||
function yy_r5_10($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::OPENASSERTION;
|
||||
}
|
||||
function yy_r5_11($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::COMMENT;
|
||||
$this->yybegin(self::INITIAL);
|
||||
}
|
||||
function yy_r5_12($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = self::RECUR;
|
||||
}
|
||||
function yy_r5_13($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->yybegin(self::INITIAL);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
1942
pkg/vtiger/extensions/Webservices/third-party/LexerGenerator/Regex/Parser.php
vendored
Normal file
1942
pkg/vtiger/extensions/Webservices/third-party/LexerGenerator/Regex/Parser.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,4 @@
|
|||
<?php
|
||||
require_once 'PHP/LexerGenerator.php';
|
||||
$a = new PHP_LexerGenerator($_SERVER['argv'][1]);
|
||||
?>
|
|
@ -0,0 +1,734 @@
|
|||
<?php
|
||||
/**
|
||||
* PHP_ParserGenerator, a php 5 parser generator.
|
||||
*
|
||||
* This is a direct port of the Lemon parser generator, found at
|
||||
* {@link http://www.hwaci.com/sw/lemon/}
|
||||
*
|
||||
* There are a few PHP-specific changes to the lemon parser generator.
|
||||
*
|
||||
* - %extra_argument is removed, as class constructor can be used to
|
||||
* pass in extra information
|
||||
* - %token_type and company are irrelevant in PHP, and so are removed
|
||||
* - %declare_class is added to define the parser class name and any
|
||||
* implements/extends information
|
||||
* - %include_class is added to allow insertion of extra class information
|
||||
* such as constants, a class constructor, etc.
|
||||
*
|
||||
* Other changes make the parser more robust, and also make reporting
|
||||
* syntax errors simpler. Detection of expected tokens eliminates some
|
||||
* problematic edge cases where an unexpected token could cause the parser
|
||||
* to simply accept input.
|
||||
*
|
||||
* Otherwise, the file format is identical to the Lemon parser generator
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.01 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_01.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category php
|
||||
* @package PHP_ParserGenerator
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 2006 Gregory Beaver
|
||||
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
||||
* @version CVS: $Id$
|
||||
* @since File available since Release 0.1.0
|
||||
*/
|
||||
/**#@+
|
||||
* Basic components of the parser generator
|
||||
*/
|
||||
require_once 'PHP/ParserGenerator/Action.php';
|
||||
require_once 'PHP/ParserGenerator/ActionTable.php';
|
||||
require_once 'PHP/ParserGenerator/Config.php';
|
||||
require_once 'PHP/ParserGenerator/Data.php';
|
||||
require_once 'PHP/ParserGenerator/Symbol.php';
|
||||
require_once 'PHP/ParserGenerator/Rule.php';
|
||||
require_once 'PHP/ParserGenerator/Parser.php';
|
||||
require_once 'PHP/ParserGenerator/PropagationLink.php';
|
||||
require_once 'PHP/ParserGenerator/State.php';
|
||||
/**#@-*/
|
||||
/**
|
||||
* The basic home class for the parser generator
|
||||
*
|
||||
* @package PHP_ParserGenerator
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 2006 Gregory Beaver
|
||||
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
||||
* @version 0.1.0
|
||||
* @since Class available since Release 0.1.0
|
||||
* @example Lempar.php
|
||||
* @example examples/Parser.y Sample parser file format (PHP_LexerGenerator's parser)
|
||||
* @example examples/Parser.php Sample parser file format PHP code (PHP_LexerGenerator's parser)
|
||||
*/
|
||||
class PHP_ParserGenerator
|
||||
{
|
||||
/**
|
||||
* Set this to 1 to turn on debugging of Lemon's parsing of
|
||||
* grammar files.
|
||||
*/
|
||||
const DEBUG = 0;
|
||||
const MAXRHS = 1000;
|
||||
const OPT_FLAG = 1, OPT_INT = 2, OPT_DBL = 3, OPT_STR = 4,
|
||||
OPT_FFLAG = 5, OPT_FINT = 6, OPT_FDBL = 7, OPT_FSTR = 8;
|
||||
public $azDefine = array();
|
||||
private static $options = array(
|
||||
'b' => array(
|
||||
'type' => self::OPT_FLAG,
|
||||
'arg' => 'basisflag',
|
||||
'message' => 'Print only the basis in report.'
|
||||
),
|
||||
'c' => array(
|
||||
'type' => self::OPT_FLAG,
|
||||
'arg' => 'compress',
|
||||
'message' => 'Don\'t compress the action table.'
|
||||
),
|
||||
'D' => array(
|
||||
'type' => self::OPT_FSTR,
|
||||
'arg' => 'handle_D_option',
|
||||
'message' => 'Define an %ifdef macro.'
|
||||
),
|
||||
'g' => array(
|
||||
'type' => self::OPT_FLAG,
|
||||
'arg' => 'rpflag',
|
||||
'message' => 'Print grammar without actions.'
|
||||
),
|
||||
'm' => array(
|
||||
'type' => self::OPT_FLAG,
|
||||
'arg' => 'mhflag',
|
||||
'message' => 'Output a makeheaders compatible file'
|
||||
),
|
||||
'q' => array(
|
||||
'type' => self::OPT_FLAG,
|
||||
'arg' => 'quiet',
|
||||
'message' => '(Quiet) Don\'t print the report file.'
|
||||
),
|
||||
's' => array(
|
||||
'type' => self::OPT_FLAG,
|
||||
'arg' => 'statistics',
|
||||
'message' => 'Print parser stats to standard output.'
|
||||
),
|
||||
'x' => array(
|
||||
'type' => self::OPT_FLAG,
|
||||
'arg' => 'version',
|
||||
'message' => 'Print the version number.'
|
||||
)
|
||||
);
|
||||
|
||||
private $basisflag = 0;
|
||||
private $compress = 0;
|
||||
private $rpflag = 0;
|
||||
private $mhflag = 0;
|
||||
private $quiet = 0;
|
||||
private $statistics = 0;
|
||||
private $version = 0;
|
||||
private $size;
|
||||
/**
|
||||
* Process a flag command line argument.
|
||||
* @param int
|
||||
* @param array
|
||||
* @return int
|
||||
*/
|
||||
function handleflags($i, $argv)
|
||||
{
|
||||
if (!isset($argv[1]) || !isset(self::$options[$argv[$i][1]])) {
|
||||
throw new Exception('Command line syntax error: undefined option "' . $argv[$i] . '"');
|
||||
}
|
||||
$v = self::$options[$argv[$i][1]] == '-';
|
||||
if (self::$options[$argv[$i][1]]['type'] == self::OPT_FLAG) {
|
||||
$this->{self::$options[$argv[$i][1]]['arg']} = (int) $v;
|
||||
} elseif (self::$options[$argv[$i][1]]['type'] == self::OPT_FFLAG) {
|
||||
$this->{self::$options[$argv[$i][1]]['arg']}($v);
|
||||
} elseif (self::$options[$argv[$i][1]]['type'] == self::OPT_FSTR) {
|
||||
$this->{self::$options[$argv[$i][1]]['arg']}(substr($v, 2));
|
||||
} else {
|
||||
throw new Exception('Command line syntax error: missing argument on switch: "' . $argv[$i] . '"');
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a command line switch which has an argument.
|
||||
* @param int
|
||||
* @param array
|
||||
* @param array
|
||||
* @return int
|
||||
*/
|
||||
function handleswitch($i, $argv)
|
||||
{
|
||||
$lv = 0;
|
||||
$dv = 0.0;
|
||||
$sv = $end = $cp = '';
|
||||
$j; // int
|
||||
$errcnt = 0;
|
||||
$cp = strstr($argv[$i],'=');
|
||||
if (!$cp) {
|
||||
throw new Exception('INTERNAL ERROR: handleswitch passed bad argument, no "=" in arg');
|
||||
}
|
||||
$argv[$i] = substr($argv[$i], 0, strlen($argv[$i]) - strlen($cp));
|
||||
if (!isset(self::$options[$argv[$i]])) {
|
||||
throw new Exception('Command line syntax error: undefined option "' . $argv[$i] .
|
||||
$cp . '"');
|
||||
}
|
||||
$cp = substr($cp, 1);
|
||||
switch (self::$options[$argv[$i]]['type']) {
|
||||
case self::OPT_FLAG:
|
||||
case self::OPT_FFLAG:
|
||||
throw new Exception('Command line syntax error: option requires an argument "' .
|
||||
$argv[$i] . '=' . $cp . '"');
|
||||
case self::OPT_DBL:
|
||||
case self::OPT_FDBL:
|
||||
$dv = (double) $cp;
|
||||
break;
|
||||
case self::OPT_INT:
|
||||
case self::OPT_FINT:
|
||||
$lv = (int) $cp;
|
||||
break;
|
||||
case self::OPT_STR:
|
||||
case self::OPT_FSTR:
|
||||
$sv = $cp;
|
||||
break;
|
||||
}
|
||||
switch(self::$options[$argv[$i]]['type']) {
|
||||
case self::OPT_FLAG:
|
||||
case self::OPT_FFLAG:
|
||||
break;
|
||||
case self::OPT_DBL:
|
||||
$this->${self::$options[$argv[$i]]['arg']} = $dv;
|
||||
break;
|
||||
case self::OPT_FDBL:
|
||||
$this->${self::$options[$argv[$i]]['arg']}($dv);
|
||||
break;
|
||||
case self::OPT_INT:
|
||||
$this->${self::$options[$argv[$i]]['arg']} = $lv;
|
||||
break;
|
||||
case self::OPT_FINT:
|
||||
$this->${self::$options[$argv[$i]]['arg']}($lv);
|
||||
break;
|
||||
case self::OPT_STR:
|
||||
$this->${self::$options[$argv[$i]]['arg']} = $sv;
|
||||
break;
|
||||
case self::OPT_FSTR:
|
||||
$this->${self::$options[$argv[$i]]['arg']}($sv);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array arguments
|
||||
* @param array valid options
|
||||
* @return int
|
||||
*/
|
||||
function OptInit($a)
|
||||
{
|
||||
$errcnt = 0;
|
||||
$argv = $a;
|
||||
try {
|
||||
if (is_array($argv) && count($argv) && self::$options) {
|
||||
for($i = 1; $i < count($argv); $i++) {
|
||||
if ($argv[$i][0] == '+' || $argv[$i][0] == '-') {
|
||||
$errcnt += $this->handleflags($i, $argv);
|
||||
} elseif (strstr($argv[$i],'=')) {
|
||||
$errcnt += $this->handleswitch(i, $argv);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
OptPrint();
|
||||
echo $e;
|
||||
exit(1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the index of the N-th non-switch argument. Return -1
|
||||
* if N is out of range.
|
||||
* @param int
|
||||
* @return int
|
||||
*/
|
||||
private function argindex($n, $a)
|
||||
{
|
||||
$dashdash = 0;
|
||||
if (!is_array($a) || !count($a)) {
|
||||
return -1;
|
||||
}
|
||||
for ($i=1; $i < count($a); $i++) {
|
||||
if ($dashdash || !($a[$i][0] == '-' || $a[$i][0] == '+' ||
|
||||
strchr($a[$i], '='))) {
|
||||
if ($n == 0) {
|
||||
return $i;
|
||||
}
|
||||
$n--;
|
||||
}
|
||||
if ($_SERVER['argv'][$i] == '--') {
|
||||
$dashdash = 1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of the non-option argument as indexed by $i
|
||||
*
|
||||
* @param int
|
||||
* @param array the value of $argv
|
||||
* @return 0|string
|
||||
*/
|
||||
private function OptArg($i, $a)
|
||||
{
|
||||
if (-1 == ($ind = $this->argindex($i, $a))) {
|
||||
return 0;
|
||||
}
|
||||
return $a[$ind];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int number of arguments
|
||||
*/
|
||||
function OptNArgs($a)
|
||||
{
|
||||
$cnt = $dashdash = 0;
|
||||
if (is_array($a) && count($a)) {
|
||||
for($i = 1; $i < count($a); $i++) {
|
||||
if ($dashdash || !($a[$i][0] == '-' || $a[$i][0] == '+' ||
|
||||
strchr($a[$i], '='))) {
|
||||
$cnt++;
|
||||
}
|
||||
if ($a[$i] == "--") {
|
||||
$dashdash = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $cnt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print out command-line options
|
||||
*/
|
||||
function OptPrint()
|
||||
{
|
||||
$max = 0;
|
||||
foreach (self::$options as $label => $info) {
|
||||
$len = strlen($label) + 1;
|
||||
switch ($info['type']) {
|
||||
case self::OPT_FLAG:
|
||||
case self::OPT_FFLAG:
|
||||
break;
|
||||
case self::OPT_INT:
|
||||
case self::OPT_FINT:
|
||||
$len += 9; /* length of "<integer>" */
|
||||
break;
|
||||
case self::OPT_DBL:
|
||||
case self::OPT_FDBL:
|
||||
$len += 6; /* length of "<real>" */
|
||||
break;
|
||||
case self::OPT_STR:
|
||||
case self::OPT_FSTR:
|
||||
$len += 8; /* length of "<string>" */
|
||||
break;
|
||||
}
|
||||
if ($len > $max) {
|
||||
$max = $len;
|
||||
}
|
||||
}
|
||||
foreach (self::$options as $label => $info) {
|
||||
switch ($info['type']) {
|
||||
case self::OPT_FLAG:
|
||||
case self::OPT_FFLAG:
|
||||
printf(" -%-*s %s\n", $max, $label, $info['message']);
|
||||
break;
|
||||
case self::OPT_INT:
|
||||
case self::OPT_FINT:
|
||||
printf(" %s=<integer>%*s %s\n", $label, $max - strlen($label) - 9,
|
||||
$info['message']);
|
||||
break;
|
||||
case self::OPT_DBL:
|
||||
case self::OPT_FDBL:
|
||||
printf(" %s=<real>%*s %s\n", $label, $max - strlen($label) - 6,
|
||||
$info['message']);
|
||||
break;
|
||||
case self::OPT_STR:
|
||||
case self::OPT_FSTR:
|
||||
printf(" %s=<string>%*s %s\n", $label, $max - strlen($label) - 8,
|
||||
$info['message']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This routine is called with the argument to each -D command-line option.
|
||||
* Add the macro defined to the azDefine array.
|
||||
* @param string
|
||||
*/
|
||||
private function handle_D_option($z)
|
||||
{
|
||||
if ($a = strstr($z, '=')) {
|
||||
$z = substr($a, 1); // strip first =
|
||||
}
|
||||
$this->azDefine[] = $z;
|
||||
}
|
||||
|
||||
/**************** From the file "main.c" ************************************/
|
||||
/*
|
||||
** Main program file for the LEMON parser generator.
|
||||
*/
|
||||
|
||||
|
||||
/* The main program. Parse the command line and do it... */
|
||||
function main()
|
||||
{
|
||||
$lem = new PHP_ParserGenerator_Data;
|
||||
|
||||
$this->OptInit($_SERVER['argv']);
|
||||
if ($this->version) {
|
||||
echo "Lemon version 1.0/PHP_ParserGenerator port version 0.1.0\n";
|
||||
exit(0);
|
||||
}
|
||||
if ($this->OptNArgs($_SERVER['argv']) != 1) {
|
||||
echo "Exactly one filename argument is required.\n";
|
||||
exit(1);
|
||||
}
|
||||
$lem->errorcnt = 0;
|
||||
|
||||
/* Initialize the machine */
|
||||
$lem->argv0 = $_SERVER['argv'][0];
|
||||
$lem->filename = $this->OptArg(0, $_SERVER['argv']);
|
||||
$a = pathinfo($lem->filename);
|
||||
if (isset($a['extension'])) {
|
||||
$ext = '.' . $a['extension'];
|
||||
$lem->filenosuffix = substr($lem->filename, 0, strlen($lem->filename) - strlen($ext));
|
||||
} else {
|
||||
$lem->filenosuffix = $lem->filename;
|
||||
}
|
||||
$lem->basisflag = $this->basisflag;
|
||||
$lem->has_fallback = 0;
|
||||
$lem->nconflict = 0;
|
||||
$lem->name = $lem->include_code = $lem->include_classcode = $lem->arg =
|
||||
$lem->tokentype = $lem->start = 0;
|
||||
$lem->vartype = 0;
|
||||
$lem->stacksize = 0;
|
||||
$lem->error = $lem->overflow = $lem->failure = $lem->accept = $lem->tokendest =
|
||||
$lem->tokenprefix = $lem->outname = $lem->extracode = 0;
|
||||
$lem->vardest = 0;
|
||||
$lem->tablesize = 0;
|
||||
PHP_ParserGenerator_Symbol::Symbol_new("$");
|
||||
$lem->errsym = PHP_ParserGenerator_Symbol::Symbol_new("error");
|
||||
|
||||
/* Parse the input file */
|
||||
$parser = new PHP_ParserGenerator_Parser($this);
|
||||
$parser->Parse($lem);
|
||||
if ($lem->errorcnt) {
|
||||
exit($lem->errorcnt);
|
||||
}
|
||||
if ($lem->rule === 0) {
|
||||
printf("Empty grammar.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Count and index the symbols of the grammar */
|
||||
$lem->nsymbol = PHP_ParserGenerator_Symbol::Symbol_count();
|
||||
PHP_ParserGenerator_Symbol::Symbol_new("{default}");
|
||||
$lem->symbols = PHP_ParserGenerator_Symbol::Symbol_arrayof();
|
||||
for ($i = 0; $i <= $lem->nsymbol; $i++) {
|
||||
$lem->symbols[$i]->index = $i;
|
||||
}
|
||||
usort($lem->symbols, array('PHP_ParserGenerator_Symbol', 'sortSymbols'));
|
||||
for ($i = 0; $i <= $lem->nsymbol; $i++) {
|
||||
$lem->symbols[$i]->index = $i;
|
||||
}
|
||||
// find the first lower-case symbol
|
||||
for($i = 1; ord($lem->symbols[$i]->name[0]) < ord ('Z'); $i++);
|
||||
$lem->nterminal = $i;
|
||||
|
||||
/* Generate a reprint of the grammar, if requested on the command line */
|
||||
if ($this->rpflag) {
|
||||
$this->Reprint();
|
||||
} else {
|
||||
/* Initialize the size for all follow and first sets */
|
||||
$this->SetSize($lem->nterminal);
|
||||
|
||||
/* Find the precedence for every production rule (that has one) */
|
||||
$lem->FindRulePrecedences();
|
||||
|
||||
/* Compute the lambda-nonterminals and the first-sets for every
|
||||
** nonterminal */
|
||||
$lem->FindFirstSets();
|
||||
|
||||
/* Compute all LR(0) states. Also record follow-set propagation
|
||||
** links so that the follow-set can be computed later */
|
||||
$lem->nstate = 0;
|
||||
$lem->FindStates();
|
||||
$lem->sorted = PHP_ParserGenerator_State::State_arrayof();
|
||||
|
||||
/* Tie up loose ends on the propagation links */
|
||||
$lem->FindLinks();
|
||||
|
||||
/* Compute the follow set of every reducible configuration */
|
||||
$lem->FindFollowSets();
|
||||
|
||||
/* Compute the action tables */
|
||||
$lem->FindActions();
|
||||
|
||||
/* Compress the action tables */
|
||||
if ($this->compress===0) {
|
||||
$lem->CompressTables();
|
||||
}
|
||||
|
||||
/* Reorder and renumber the states so that states with fewer choices
|
||||
** occur at the end. */
|
||||
$lem->ResortStates();
|
||||
|
||||
/* Generate a report of the parser generated. (the "y.output" file) */
|
||||
if (!$this->quiet) {
|
||||
$lem->ReportOutput();
|
||||
}
|
||||
|
||||
/* Generate the source code for the parser */
|
||||
$lem->ReportTable($this->mhflag);
|
||||
|
||||
/* Produce a header file for use by the scanner. (This step is
|
||||
** omitted if the "-m" option is used because makeheaders will
|
||||
** generate the file for us.) */
|
||||
// if (!$this->mhflag) {
|
||||
// $this->ReportHeader();
|
||||
// }
|
||||
}
|
||||
if ($this->statistics) {
|
||||
printf("Parser statistics: %d terminals, %d nonterminals, %d rules\n",
|
||||
$lem->nterminal, $lem->nsymbol - $lem->nterminal, $lem->nrule);
|
||||
printf(" %d states, %d parser table entries, %d conflicts\n",
|
||||
$lem->nstate, $lem->tablesize, $lem->nconflict);
|
||||
}
|
||||
if ($lem->nconflict) {
|
||||
printf("%d parsing conflicts.\n", $lem->nconflict);
|
||||
}
|
||||
exit($lem->errorcnt + $lem->nconflict);
|
||||
return ($lem->errorcnt + $lem->nconflict);
|
||||
}
|
||||
|
||||
function SetSize($n)
|
||||
{
|
||||
$this->size = $n + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge in a merge sort for a linked list
|
||||
* Inputs:
|
||||
* - a: A sorted, null-terminated linked list. (May be null).
|
||||
* - b: A sorted, null-terminated linked list. (May be null).
|
||||
* - cmp: A pointer to the comparison function.
|
||||
* - offset: Offset in the structure to the "next" field.
|
||||
*
|
||||
* Return Value:
|
||||
* A pointer to the head of a sorted list containing the elements
|
||||
* of both a and b.
|
||||
*
|
||||
* Side effects:
|
||||
* The "next" pointers for elements in the lists a and b are
|
||||
* changed.
|
||||
*/
|
||||
static function merge($a, $b, $cmp, $offset)
|
||||
{
|
||||
if($a === 0) {
|
||||
$head = $b;
|
||||
} elseif ($b === 0) {
|
||||
$head = $a;
|
||||
} else {
|
||||
if (call_user_func($cmp, $a, $b) < 0) {
|
||||
$ptr = $a;
|
||||
$a = $a->$offset;
|
||||
} else {
|
||||
$ptr = $b;
|
||||
$b = $b->$offset;
|
||||
}
|
||||
$head = $ptr;
|
||||
while ($a && $b) {
|
||||
if (call_user_func($cmp, $a, $b) < 0) {
|
||||
$ptr->$offset = $a;
|
||||
$ptr = $a;
|
||||
$a = $a->$offset;
|
||||
} else {
|
||||
$ptr->$offset = $b;
|
||||
$ptr = $b;
|
||||
$b = $b->$offset;
|
||||
}
|
||||
}
|
||||
if ($a !== 0) {
|
||||
$ptr->$offset = $a;
|
||||
} else {
|
||||
$ptr->$offset = $b;
|
||||
}
|
||||
}
|
||||
return $head;
|
||||
}
|
||||
|
||||
/*
|
||||
** Inputs:
|
||||
** list: Pointer to a singly-linked list of structures.
|
||||
** next: Pointer to pointer to the second element of the list.
|
||||
** cmp: A comparison function.
|
||||
**
|
||||
** Return Value:
|
||||
** A pointer to the head of a sorted list containing the elements
|
||||
** orginally in list.
|
||||
**
|
||||
** Side effects:
|
||||
** The "next" pointers for elements in list are changed.
|
||||
*/
|
||||
#define LISTSIZE 30
|
||||
static function msort($list, $next, $cmp)
|
||||
{
|
||||
if ($list === 0) {
|
||||
return $list;
|
||||
}
|
||||
if ($list->$next === 0) {
|
||||
return $list;
|
||||
}
|
||||
$set = array_fill(0, 30, 0);
|
||||
while ($list) {
|
||||
$ep = $list;
|
||||
$list = $list->$next;
|
||||
$ep->$next = 0;
|
||||
for ($i = 0; $i < 29 && $set[$i] !== 0; $i++) {
|
||||
$ep = self::merge($ep, $set[$i], $cmp, $next);
|
||||
$set[$i] = 0;
|
||||
}
|
||||
$set[$i] = $ep;
|
||||
}
|
||||
$ep = 0;
|
||||
for ($i = 0; $i < 30; $i++) {
|
||||
if ($set[$i] !== 0) {
|
||||
$ep = self::merge($ep, $set[$i], $cmp, $next);
|
||||
}
|
||||
}
|
||||
return $ep;
|
||||
}
|
||||
|
||||
/* Find a good place to break "msg" so that its length is at least "min"
|
||||
** but no more than "max". Make the point as close to max as possible.
|
||||
*/
|
||||
static function findbreak($msg, $min, $max)
|
||||
{
|
||||
if ($min >= strlen($msg)) {
|
||||
return strlen($msg);
|
||||
}
|
||||
for ($i = $spot = $min; $i <= $max && $i < strlen($msg); $i++) {
|
||||
$c = $msg[$i];
|
||||
if ($c == '-' && $i < $max - 1) {
|
||||
$spot = $i + 1;
|
||||
}
|
||||
if ($c == ' ') {
|
||||
$spot = $i;
|
||||
}
|
||||
}
|
||||
return $spot;
|
||||
}
|
||||
|
||||
static function ErrorMsg($filename, $lineno, $format)
|
||||
{
|
||||
/* Prepare a prefix to be prepended to every output line */
|
||||
if ($lineno > 0) {
|
||||
$prefix = sprintf("%20s:%d: ", $filename, $lineno);
|
||||
} else {
|
||||
$prefix = sprintf("%20s: ", $filename);
|
||||
}
|
||||
$prefixsize = strlen($prefix);
|
||||
$availablewidth = 79 - $prefixsize;
|
||||
|
||||
/* Generate the error message */
|
||||
$ap = func_get_args();
|
||||
array_shift($ap); // $filename
|
||||
array_shift($ap); // $lineno
|
||||
array_shift($ap); // $format
|
||||
$errmsg = vsprintf($format, $ap);
|
||||
$linewidth = strlen($errmsg);
|
||||
/* Remove trailing "\n"s from the error message. */
|
||||
while ($linewidth > 0 && in_array($errmsg[$linewidth-1], array("\n", "\r"), true)) {
|
||||
--$linewidth;
|
||||
$errmsg = substr($errmsg, 0, strlen($errmsg) - 1);
|
||||
}
|
||||
|
||||
/* Print the error message */
|
||||
$base = 0;
|
||||
$errmsg = str_replace(array("\r", "\n", "\t"), array(' ', ' ', ' '), $errmsg);
|
||||
while (strlen($errmsg)) {
|
||||
$end = $restart = self::findbreak($errmsg, 0, $availablewidth);
|
||||
if (strlen($errmsg) <= 79 && $end < strlen($errmsg) && $end <= 79) {
|
||||
$end = $restart = strlen($errmsg);
|
||||
}
|
||||
while (isset($errmsg[$restart]) && $errmsg[$restart] == ' ') {
|
||||
$restart++;
|
||||
}
|
||||
printf("%s%.${end}s\n", $prefix, $errmsg);
|
||||
$errmsg = substr($errmsg, $restart);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate the input file without comments and without actions
|
||||
* on rules
|
||||
*/
|
||||
function Reprint()
|
||||
{
|
||||
printf("// Reprint of input file \"%s\".\n// Symbols:\n", $this->filename);
|
||||
$maxlen = 10;
|
||||
for ($i = 0; $i < $this->nsymbol; $i++) {
|
||||
$sp = $this->symbols[$i];
|
||||
$len = strlen($sp->name);
|
||||
if ($len > $maxlen ) {
|
||||
$maxlen = $len;
|
||||
}
|
||||
}
|
||||
$ncolumns = 76 / ($maxlen + 5);
|
||||
if ($ncolumns < 1) {
|
||||
$ncolumns = 1;
|
||||
}
|
||||
$skip = ($this->nsymbol + $ncolumns - 1) / $ncolumns;
|
||||
for ($i = 0; $i < $skip; $i++) {
|
||||
print "//";
|
||||
for ($j = $i; $j < $this->nsymbol; $j += $skip) {
|
||||
$sp = $this->symbols[$j];
|
||||
//assert( sp->index==j );
|
||||
printf(" %3d %-${maxlen}.${maxlen}s", $j, $sp->name);
|
||||
}
|
||||
print "\n";
|
||||
}
|
||||
for ($rp = $this->rule; $rp; $rp = $rp->next) {
|
||||
printf("%s", $rp->lhs->name);
|
||||
/* if ($rp->lhsalias) {
|
||||
printf("(%s)", $rp->lhsalias);
|
||||
}*/
|
||||
print " ::=";
|
||||
for ($i = 0; $i < $rp->nrhs; $i++) {
|
||||
$sp = $rp->rhs[$i];
|
||||
printf(" %s", $sp->name);
|
||||
if ($sp->type == PHP_ParserGenerator_Symbol::MULTITERMINAL) {
|
||||
for ($j = 1; $j < $sp->nsubsym; $j++) {
|
||||
printf("|%s", $sp->subsym[$j]->name);
|
||||
}
|
||||
}
|
||||
/* if ($rp->rhsalias[$i]) {
|
||||
printf("(%s)", $rp->rhsalias[$i]);
|
||||
}*/
|
||||
}
|
||||
print ".";
|
||||
if ($rp->precsym) {
|
||||
printf(" [%s]", $rp->precsym->name);
|
||||
}
|
||||
/* if ($rp->code) {
|
||||
print "\n " . $rp->code);
|
||||
}*/
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
//$a = new PHP_ParserGenerator;
|
||||
//$_SERVER['argv'] = array('lemon', '-s', '/development/lemon/PHP_Parser.y');
|
||||
//$_SERVER['argv'] = array('lemon', '-s', '/development/File_ChessPGN/ChessPGN/Parser.y');
|
||||
//$a->main();
|
|
@ -0,0 +1,180 @@
|
|||
<?php
|
||||
/**
|
||||
* PHP_ParserGenerator, a php 5 parser generator.
|
||||
*
|
||||
* This is a direct port of the Lemon parser generator, found at
|
||||
* {@link http://www.hwaci.com/sw/lemon/}
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.01 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_01.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category php
|
||||
* @package PHP_ParserGenerator
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 2006 Gregory Beaver
|
||||
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
||||
* @version CVS: $Id$
|
||||
* @since File available since Release 0.1.0
|
||||
*/
|
||||
/**
|
||||
* Every shift or reduce operation is stored as one of the following objects.
|
||||
*
|
||||
* @package PHP_ParserGenerator
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 2006 Gregory Beaver
|
||||
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
||||
* @version 0.1.0
|
||||
* @since Class available since Release 0.1.0
|
||||
*/
|
||||
class PHP_ParserGenerator_Action {
|
||||
const SHIFT = 1,
|
||||
ACCEPT = 2,
|
||||
REDUCE = 3,
|
||||
ERROR = 4,
|
||||
/**
|
||||
* Was a reduce, but part of a conflict
|
||||
*/
|
||||
CONFLICT = 5,
|
||||
/**
|
||||
* Was a shift. Precedence resolved conflict
|
||||
*/
|
||||
SH_RESOLVED = 6,
|
||||
/**
|
||||
* Was a reduce. Precedence resolved conflict
|
||||
*/
|
||||
RD_RESOLVED = 7,
|
||||
/**
|
||||
* Deleted by compression
|
||||
* @see PHP_ParserGenerator::CompressTables()
|
||||
*/
|
||||
NOT_USED = 8;
|
||||
/**
|
||||
* The look-ahead symbol that triggers this action
|
||||
* @var PHP_ParserGenerator_Symbol
|
||||
*/
|
||||
public $sp; /* The look-ahead symbol */
|
||||
/**
|
||||
* This defines the kind of action, and must be one
|
||||
* of the class constants.
|
||||
*
|
||||
* - {@link PHP_ParserGenerator_Action::SHIFT}
|
||||
* - {@link PHP_ParserGenerator_Action::ACCEPT}
|
||||
* - {@link PHP_ParserGenerator_Action::REDUCE}
|
||||
* - {@link PHP_ParserGenerator_Action::ERROR}
|
||||
* - {@link PHP_ParserGenerator_Action::CONFLICT}
|
||||
* - {@link PHP_ParserGenerator_Action::SH_RESOLVED}
|
||||
* - {@link PHP_ParserGenerator_Action:: RD_RESOLVED}
|
||||
* - {@link PHP_ParserGenerator_Action::NOT_USED}
|
||||
*/
|
||||
public $type;
|
||||
/**
|
||||
* The new state, if this is a shift,
|
||||
* the parser rule index, if this is a reduce.
|
||||
*
|
||||
* @var PHP_ParserGenerator_State|PHP_ParserGenerator_Rule
|
||||
*/
|
||||
public $x;
|
||||
/**
|
||||
* The next action for this state.
|
||||
* @var PHP_ParserGenerator_Action
|
||||
*/
|
||||
public $next;
|
||||
|
||||
/**
|
||||
* Compare two actions
|
||||
*
|
||||
* This is used by {@link Action_sort()} to compare actions
|
||||
*/
|
||||
static function actioncmp(PHP_ParserGenerator_Action $ap1,
|
||||
PHP_ParserGenerator_Action $ap2)
|
||||
{
|
||||
$rc = $ap1->sp->index - $ap2->sp->index;
|
||||
if ($rc === 0) {
|
||||
$rc = $ap1->type - $ap2->type;
|
||||
}
|
||||
if ($rc === 0) {
|
||||
if ($ap1->type != self::REDUCE &&
|
||||
$ap1->type != self::RD_RESOLVED &&
|
||||
$ap1->type != self::CONFLICT) {
|
||||
throw new Exception('action has not been processed: ' .
|
||||
$ap1->sp->name);
|
||||
}
|
||||
if ($ap2->type != self::REDUCE &&
|
||||
$ap2->type != self::RD_RESOLVED &&
|
||||
$ap2->type != self::CONFLICT) {
|
||||
throw new Exception('action has not been processed: ' .
|
||||
$ap2->sp->name);
|
||||
}
|
||||
$rc = $ap1->x->index - $ap2->x->index;
|
||||
}
|
||||
return $rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* create linked list of PHP_ParserGenerator_Actions
|
||||
*
|
||||
* @param PHP_ParserGenerator_Action|null
|
||||
* @param int one of the class constants from PHP_ParserGenerator_Action
|
||||
* @param PHP_ParserGenerator_Symbol
|
||||
* @param PHP_ParserGenerator_Symbol|PHP_ParserGenerator_Rule
|
||||
*/
|
||||
static function Action_add(&$app, $type, PHP_ParserGenerator_Symbol $sp, $arg)
|
||||
{
|
||||
$new = new PHP_ParserGenerator_Action;
|
||||
$new->next = $app;
|
||||
$app = $new;
|
||||
$new->type = $type;
|
||||
$new->sp = $sp;
|
||||
$new->x = $arg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort parser actions
|
||||
* @see PHP_ParserGenerator_Data::FindActions()
|
||||
*/
|
||||
static function Action_sort(PHP_ParserGenerator_Action $ap)
|
||||
{
|
||||
$ap = PHP_ParserGenerator::msort($ap, 'next', array('PHP_ParserGenerator_Action', 'actioncmp'));
|
||||
return $ap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print an action to the given file descriptor. Return FALSE if
|
||||
* nothing was actually printed.
|
||||
* @see PHP_ParserGenerator_Data::ReportOutput()
|
||||
*/
|
||||
function PrintAction($fp, $indent)
|
||||
{
|
||||
$result = 1;
|
||||
switch ($this->type)
|
||||
{
|
||||
case self::SHIFT:
|
||||
fprintf($fp, "%${indent}s shift %d", $this->sp->name, $this->x->statenum);
|
||||
break;
|
||||
case self::REDUCE:
|
||||
fprintf($fp, "%${indent}s reduce %d", $this->sp->name, $this->x->index);
|
||||
break;
|
||||
case self::ACCEPT:
|
||||
fprintf($fp, "%${indent}s accept", $this->sp->name);
|
||||
break;
|
||||
case self::ERROR:
|
||||
fprintf($fp, "%${indent}s error", $this->sp->name);
|
||||
break;
|
||||
case self::CONFLICT:
|
||||
fprintf($fp, "%${indent}s reduce %-3d ** Parsing conflict **", $this->sp->name, $this->x->index);
|
||||
break;
|
||||
case self::SH_RESOLVED:
|
||||
case self::RD_RESOLVED:
|
||||
case self::NOT_USED:
|
||||
$result = 0;
|
||||
break;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
269
pkg/vtiger/extensions/Webservices/third-party/ParserGenerator/ActionTable.php
vendored
Normal file
269
pkg/vtiger/extensions/Webservices/third-party/ParserGenerator/ActionTable.php
vendored
Normal file
|
@ -0,0 +1,269 @@
|
|||
<?php
|
||||
/**
|
||||
* PHP_ParserGenerator, a php 5 parser generator.
|
||||
*
|
||||
* This is a direct port of the Lemon parser generator, found at
|
||||
* {@link http://www.hwaci.com/sw/lemon/}
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.01 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_01.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category php
|
||||
* @package PHP_ParserGenerator
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 2006 Gregory Beaver
|
||||
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
||||
* @version CVS: $Id$
|
||||
* @since File available since Release 0.1.0
|
||||
*/
|
||||
/**
|
||||
* The state of the yy_action table under construction is an instance of
|
||||
* the following structure
|
||||
* @package PHP_ParserGenerator
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 2006 Gregory Beaver
|
||||
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
||||
* @version 0.1.0
|
||||
* @since Class available since Release 0.1.0
|
||||
*/
|
||||
class PHP_ParserGenerator_ActionTable
|
||||
{
|
||||
/**
|
||||
* Number of used slots in {@link $aAction}
|
||||
* @var int
|
||||
*/
|
||||
public $nAction = 0;
|
||||
/**
|
||||
* The $yy_action table under construction.
|
||||
*
|
||||
* Each entry is of format:
|
||||
* <code>
|
||||
* array(
|
||||
* 'lookahead' => -1, // Value of the lookahead token (symbol index)
|
||||
* 'action' => -1 // Action to take on the given lookahead (action index)
|
||||
* );
|
||||
* </code>
|
||||
* @see PHP_ParserGenerator_Data::compute_action()
|
||||
* @var array
|
||||
*/
|
||||
public $aAction =
|
||||
array(array(
|
||||
'lookahead' => -1,
|
||||
'action' => -1
|
||||
));
|
||||
/**
|
||||
* A single new transaction set.
|
||||
*
|
||||
* @see $aAction format of the internal array is described here
|
||||
* @var array
|
||||
*/
|
||||
public $aLookahead =
|
||||
array(array(
|
||||
'lookahead' => 0,
|
||||
'action' => 0
|
||||
));
|
||||
/**
|
||||
* The smallest (minimum) value of any lookahead token in {@link $aLookahead}
|
||||
*
|
||||
* The lowest non-terminal is always introduced earlier in the parser file,
|
||||
* and is therefore a more significant token.
|
||||
* @var int
|
||||
*/
|
||||
public $mnLookahead = 0;
|
||||
/**
|
||||
* The action associated with the smallest lookahead token.
|
||||
* @see $mnLookahead
|
||||
* @var int
|
||||
*/
|
||||
public $mnAction = 0;
|
||||
/**
|
||||
* The largest (maximum) value of any lookahead token in {@link $aLookahead}
|
||||
* @var int
|
||||
*/
|
||||
public $mxLookahead = 0;
|
||||
/**
|
||||
* The number of slots used in {@link $aLookahead}.
|
||||
*
|
||||
* This is the same as count($aLookahead), but there was no pressing reason
|
||||
* to change this when porting from C.
|
||||
* @see $mnLookahead
|
||||
* @var int
|
||||
*/
|
||||
public $nLookahead = 0;
|
||||
|
||||
/**
|
||||
* Add a new action to the current transaction set
|
||||
* @param int
|
||||
* @param int
|
||||
*/
|
||||
function acttab_action($lookahead, $action)
|
||||
{
|
||||
if ($this->nLookahead === 0) {
|
||||
$this->aLookahead = array();
|
||||
$this->mxLookahead = $lookahead;
|
||||
$this->mnLookahead = $lookahead;
|
||||
$this->mnAction = $action;
|
||||
} else {
|
||||
if ($this->mxLookahead < $lookahead) {
|
||||
$this->mxLookahead = $lookahead;
|
||||
}
|
||||
if ($this->mnLookahead > $lookahead) {
|
||||
$this->mnLookahead = $lookahead;
|
||||
$this->mnAction = $action;
|
||||
}
|
||||
}
|
||||
$this->aLookahead[$this->nLookahead] = array(
|
||||
'lookahead' => $lookahead,
|
||||
'action' => $action);
|
||||
$this->nLookahead++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the transaction set built up with prior calls to acttab_action()
|
||||
* into the current action table. Then reset the transaction set back
|
||||
* to an empty set in preparation for a new round of acttab_action() calls.
|
||||
*
|
||||
* Return the offset into the action table of the new transaction.
|
||||
* @return int Return the offset that should be added to the lookahead in
|
||||
* order to get the index into $yy_action of the action. This will be used
|
||||
* in generation of $yy_ofst tables (reduce and shift)
|
||||
* @throws Exception
|
||||
*/
|
||||
function acttab_insert()
|
||||
{
|
||||
if ($this->nLookahead <= 0) {
|
||||
throw new Exception('nLookahead is not set up?');
|
||||
}
|
||||
|
||||
/* Scan the existing action table looking for an offset where we can
|
||||
** insert the current transaction set. Fall out of the loop when that
|
||||
** offset is found. In the worst case, we fall out of the loop when
|
||||
** i reaches $this->nAction, which means we append the new transaction set.
|
||||
**
|
||||
** i is the index in $this->aAction[] where $this->mnLookahead is inserted.
|
||||
*/
|
||||
for ($i = 0; $i < $this->nAction + $this->mnLookahead; $i++) {
|
||||
if (!isset($this->aAction[$i])) {
|
||||
$this->aAction[$i] = array(
|
||||
'lookahead' => -1,
|
||||
'action' => -1,
|
||||
);
|
||||
}
|
||||
if ($this->aAction[$i]['lookahead'] < 0) {
|
||||
for ($j = 0; $j < $this->nLookahead; $j++) {
|
||||
if (!isset($this->aLookahead[$j])) {
|
||||
$this->aLookahead[$j] = array(
|
||||
'lookahead' => 0,
|
||||
'action' => 0,
|
||||
);
|
||||
}
|
||||
$k = $this->aLookahead[$j]['lookahead'] -
|
||||
$this->mnLookahead + $i;
|
||||
if ($k < 0) {
|
||||
break;
|
||||
}
|
||||
if (!isset($this->aAction[$k])) {
|
||||
$this->aAction[$k] = array(
|
||||
'lookahead' => -1,
|
||||
'action' => -1,
|
||||
);
|
||||
}
|
||||
if ($this->aAction[$k]['lookahead'] >= 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($j < $this->nLookahead ) {
|
||||
continue;
|
||||
}
|
||||
for ($j = 0; $j < $this->nAction; $j++) {
|
||||
if (!isset($this->aAction[$j])) {
|
||||
$this->aAction[$j] = array(
|
||||
'lookahead' => -1,
|
||||
'action' => -1,
|
||||
);
|
||||
}
|
||||
if ($this->aAction[$j]['lookahead'] == $j +
|
||||
$this->mnLookahead - $i) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($j == $this->nAction) {
|
||||
break; /* Fits in empty slots */
|
||||
}
|
||||
} elseif ($this->aAction[$i]['lookahead'] == $this->mnLookahead) {
|
||||
if ($this->aAction[$i]['action'] != $this->mnAction) {
|
||||
continue;
|
||||
}
|
||||
for ($j = 0; $j < $this->nLookahead; $j++) {
|
||||
$k = $this->aLookahead[$j]['lookahead'] -
|
||||
$this->mnLookahead + $i;
|
||||
if ($k < 0 || $k >= $this->nAction) {
|
||||
break;
|
||||
}
|
||||
if (!isset($this->aAction[$k])) {
|
||||
$this->aAction[$k] = array(
|
||||
'lookahead' => -1,
|
||||
'action' => -1,
|
||||
);
|
||||
}
|
||||
if ($this->aLookahead[$j]['lookahead'] !=
|
||||
$this->aAction[$k]['lookahead']) {
|
||||
break;
|
||||
}
|
||||
if ($this->aLookahead[$j]['action'] !=
|
||||
$this->aAction[$k]['action']) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($j < $this->nLookahead) {
|
||||
continue;
|
||||
}
|
||||
$n = 0;
|
||||
for ($j = 0; $j < $this->nAction; $j++) {
|
||||
if (!isset($this->aAction[$j])) {
|
||||
$this->aAction[$j] = array(
|
||||
'lookahead' => -1,
|
||||
'action' => -1,
|
||||
);
|
||||
}
|
||||
if ($this->aAction[$j]['lookahead'] < 0) {
|
||||
continue;
|
||||
}
|
||||
if ($this->aAction[$j]['lookahead'] == $j +
|
||||
$this->mnLookahead - $i) {
|
||||
$n++;
|
||||
}
|
||||
}
|
||||
if ($n == $this->nLookahead) {
|
||||
break; /* Same as a prior transaction set */
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Insert transaction set at index i. */
|
||||
for ($j = 0; $j < $this->nLookahead; $j++) {
|
||||
if (!isset($this->aLookahead[$j])) {
|
||||
$this->aLookahead[$j] = array(
|
||||
'lookahead' => 0,
|
||||
'action' => 0,
|
||||
);
|
||||
}
|
||||
$k = $this->aLookahead[$j]['lookahead'] - $this->mnLookahead + $i;
|
||||
$this->aAction[$k] = $this->aLookahead[$j];
|
||||
if ($k >= $this->nAction) {
|
||||
$this->nAction = $k + 1;
|
||||
}
|
||||
}
|
||||
$this->nLookahead = 0;
|
||||
$this->aLookahead = array();
|
||||
|
||||
/* Return the offset that is added to the lookahead in order to get the
|
||||
** index into yy_action of the action */
|
||||
return $i - $this->mnLookahead;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,546 @@
|
|||
<?php
|
||||
/**
|
||||
* PHP_ParserGenerator, a php 5 parser generator.
|
||||
*
|
||||
* This is a direct port of the Lemon parser generator, found at
|
||||
* {@link http://www.hwaci.com/sw/lemon/}
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.01 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_01.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category php
|
||||
* @package PHP_ParserGenerator
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 2006 Gregory Beaver
|
||||
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
||||
* @version CVS: $Id$
|
||||
* @since File available since Release 0.1.0
|
||||
*/
|
||||
/**
|
||||
/** A configuration is a production rule of the grammar together with
|
||||
* a mark (dot) showing how much of that rule has been processed so far.
|
||||
*
|
||||
* Configurations also contain a follow-set which is a list of terminal
|
||||
* symbols which are allowed to immediately follow the end of the rule.
|
||||
* Every configuration is recorded as an instance of the following class.
|
||||
*
|
||||
* @package PHP_ParserGenerator
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 2006 Gregory Beaver
|
||||
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
||||
* @version 0.1.0
|
||||
* @since Class available since Release 0.1.0
|
||||
*/
|
||||
class PHP_ParserGenerator_Config {
|
||||
const COMPLETE = 1;
|
||||
const INCOMPLETE = 2;
|
||||
/**
|
||||
* The parser rule upon with the configuration is based.
|
||||
*
|
||||
* A parser rule is something like:
|
||||
* <pre>
|
||||
* blah ::= FOO bar.
|
||||
* </pre>
|
||||
* @var PHP_ParserGenerator_Rule
|
||||
*/
|
||||
public $rp;
|
||||
/**
|
||||
* The parse point.
|
||||
*
|
||||
* This is the index into the right-hand side of a rule that is
|
||||
* represented by this configuration. In other words, possible
|
||||
* dots for this rule:
|
||||
*
|
||||
* <pre>
|
||||
* blah ::= FOO bar.
|
||||
* </pre>
|
||||
*
|
||||
* are (represented by "[here]"):
|
||||
*
|
||||
* <pre>
|
||||
* blah ::= [here] FOO bar.
|
||||
* blah ::= FOO [here] bar.
|
||||
* blah ::= FOO bar [here].
|
||||
* </pre>
|
||||
* @var int
|
||||
*/
|
||||
public $dot;
|
||||
/**
|
||||
* Follow-set for this configuration only
|
||||
*
|
||||
* This is the list of terminals and non-terminals that
|
||||
* can follow this configuration.
|
||||
* @var array
|
||||
*/
|
||||
public $fws;
|
||||
/**
|
||||
* Follow-set forward propagation links.
|
||||
* @var PHP_ParserGenerator_PropagationLink
|
||||
*/
|
||||
public $fplp;
|
||||
/**
|
||||
* Follow-set backwards propagation links
|
||||
* @var PHP_ParserGenerator_PropagationLink
|
||||
*/
|
||||
public $bplp;
|
||||
/**
|
||||
* State that contains this configuration
|
||||
* @var PHP_ParserGenerator_State
|
||||
*/
|
||||
public $stp;
|
||||
/* enum {
|
||||
COMPLETE, /* The status is used during followset and
|
||||
INCOMPLETE /* shift computations
|
||||
} */
|
||||
/**
|
||||
* Status during followset and shift computations.
|
||||
*
|
||||
* One of PHP_ParserGenerator_Config::COMPLETE or
|
||||
* PHP_ParserGenerator_Config::INCOMPLETE.
|
||||
* @var int
|
||||
*/
|
||||
public $status;
|
||||
/**
|
||||
* Next configuration in the state.
|
||||
*
|
||||
* Index of next PHP_ParserGenerator_Config object.
|
||||
* @var int
|
||||
*/
|
||||
public $next;
|
||||
/**
|
||||
* Index of the next basis configuration PHP_ParserGenerator_Config object
|
||||
* @var int
|
||||
*/
|
||||
public $bp;
|
||||
|
||||
/**
|
||||
* Top of the list of configurations for the current state.
|
||||
* @var PHP_ParserGenerator_Config
|
||||
*/
|
||||
static public $current;
|
||||
/**
|
||||
* Last on the list of configurations for the current state.
|
||||
* @var PHP_ParserGenerator_Config
|
||||
*/
|
||||
static public $currentend;
|
||||
|
||||
/**
|
||||
* Top of the list of basis configurations for the current state.
|
||||
* @var PHP_ParserGenerator_Config
|
||||
*/
|
||||
static public $basis;
|
||||
/**
|
||||
* Last on the list of basis configurations for the current state.
|
||||
* @var PHP_ParserGenerator_Config
|
||||
*/
|
||||
static public $basisend;
|
||||
|
||||
/**
|
||||
* Associative array representation of the linked list of configurations
|
||||
* found in {@link $current}
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static public $x4a = array();
|
||||
|
||||
/**
|
||||
* Return a pointer to a new configuration
|
||||
* @return PHP_ParserGenerator_Config
|
||||
*/
|
||||
private static function newconfig()
|
||||
{
|
||||
return new PHP_ParserGenerator_Config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the current configuration for the .out file
|
||||
*
|
||||
* @param PHP_ParserGenerator_Config $cfp
|
||||
* @see PHP_ParserGenerator_Data::ReportOutput()
|
||||
*/
|
||||
static function Configshow(PHP_ParserGenerator_Config $cfp)
|
||||
{
|
||||
$fp = fopen('php://output', 'w');
|
||||
while ($cfp) {
|
||||
if ($cfp->dot == $cfp->rp->nrhs) {
|
||||
$buf = sprintf('(%d)', $cfp->rp->index);
|
||||
fprintf($fp, ' %5s ', $buf);
|
||||
} else {
|
||||
fwrite($fp,' ');
|
||||
}
|
||||
$cfp->ConfigPrint($fp);
|
||||
fwrite($fp, "\n");
|
||||
if (0) {
|
||||
//SetPrint(fp,cfp->fws,$this);
|
||||
//PlinkPrint(fp,cfp->fplp,"To ");
|
||||
//PlinkPrint(fp,cfp->bplp,"From");
|
||||
}
|
||||
$cfp = $cfp->next;
|
||||
}
|
||||
fwrite($fp, "\n");
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the configuration list builder for a new state.
|
||||
*/
|
||||
static function Configlist_init()
|
||||
{
|
||||
self::$current = 0;
|
||||
self::$currentend = &self::$current;
|
||||
self::$basis = 0;
|
||||
self::$basisend = &self::$basis;
|
||||
self::$x4a = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all data from the table.
|
||||
*
|
||||
* Pass each data to the function $f as it is removed if
|
||||
* $f is a valid callback.
|
||||
* @param callback|null
|
||||
* @see Configtable_clear()
|
||||
*/
|
||||
static function Configtable_reset($f)
|
||||
{
|
||||
self::$current = 0;
|
||||
self::$currentend = &self::$current;
|
||||
self::$basis = 0;
|
||||
self::$basisend = &self::$basis;
|
||||
self::Configtable_clear(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all data from the associative array representation
|
||||
* of configurations.
|
||||
*
|
||||
* Pass each data to the function $f as it is removed if
|
||||
* $f is a valid callback.
|
||||
* @param callback|null
|
||||
*/
|
||||
static function Configtable_clear($f)
|
||||
{
|
||||
if (!count(self::$x4a)) {
|
||||
return;
|
||||
}
|
||||
if ($f) {
|
||||
for ($i = 0; $i < count(self::$x4a); $i++) {
|
||||
call_user_func($f, self::$x4a[$i]->data);
|
||||
}
|
||||
}
|
||||
self::$x4a = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the configuration list builder for a new state.
|
||||
* @see Configtable_clear()
|
||||
*/
|
||||
static function Configlist_reset()
|
||||
{
|
||||
self::Configtable_clear(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add another configuration to the configuration list for this parser state.
|
||||
* @param PHP_ParserGenerator_Rule the rule
|
||||
* @param int Index into the right-hand side of the rule where the dot goes
|
||||
* @return PHP_ParserGenerator_Config
|
||||
*/
|
||||
static function Configlist_add($rp, $dot)
|
||||
{
|
||||
$model = new PHP_ParserGenerator_Config;
|
||||
$model->rp = $rp;
|
||||
$model->dot = $dot;
|
||||
$cfp = self::Configtable_find($model);
|
||||
if ($cfp === 0) {
|
||||
$cfp = self::newconfig();
|
||||
$cfp->rp = $rp;
|
||||
$cfp->dot = $dot;
|
||||
$cfp->fws = array();
|
||||
$cfp->stp = 0;
|
||||
$cfp->fplp = $cfp->bplp = 0;
|
||||
$cfp->next = 0;
|
||||
$cfp->bp = 0;
|
||||
self::$currentend = $cfp;
|
||||
self::$currentend = &$cfp->next;
|
||||
self::Configtable_insert($cfp);
|
||||
}
|
||||
return $cfp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a basis configuration to the configuration list for this parser state.
|
||||
*
|
||||
* Basis configurations are the root for a configuration. This method also
|
||||
* inserts the configuration into the regular list of configurations for this
|
||||
* reason.
|
||||
* @param PHP_ParserGenerator_Rule the rule
|
||||
* @param int Index into the right-hand side of the rule where the dot goes
|
||||
* @return PHP_ParserGenerator_Config
|
||||
*/
|
||||
static function Configlist_addbasis($rp, $dot)
|
||||
{
|
||||
$model = new PHP_ParserGenerator_Config;
|
||||
$model->rp = $rp;
|
||||
$model->dot = $dot;
|
||||
$cfp = self::Configtable_find($model);
|
||||
if ($cfp === 0) {
|
||||
$cfp = self::newconfig();
|
||||
$cfp->rp = $rp;
|
||||
$cfp->dot = $dot;
|
||||
$cfp->fws = array();
|
||||
$cfp->stp = 0;
|
||||
$cfp->fplp = $cfp->bplp = 0;
|
||||
$cfp->next = 0;
|
||||
$cfp->bp = 0;
|
||||
self::$currentend = $cfp;
|
||||
self::$currentend = &$cfp->next;
|
||||
self::$basisend = $cfp;
|
||||
self::$basisend = &$cfp->bp;
|
||||
self::Configtable_insert($cfp);
|
||||
}
|
||||
return $cfp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the closure of the configuration list.
|
||||
*
|
||||
* This calculates all of the possible continuations of
|
||||
* each configuration, ensuring that each state accounts
|
||||
* for every configuration that could arrive at that state.
|
||||
*/
|
||||
static function Configlist_closure(PHP_ParserGenerator_Data $lemp)
|
||||
{
|
||||
for ($cfp = self::$current; $cfp; $cfp = $cfp->next) {
|
||||
$rp = $cfp->rp;
|
||||
$dot = $cfp->dot;
|
||||
if ($dot >= $rp->nrhs) {
|
||||
continue;
|
||||
}
|
||||
$sp = $rp->rhs[$dot];
|
||||
if ($sp->type == PHP_ParserGenerator_Symbol::NONTERMINAL) {
|
||||
if ($sp->rule === 0 && $sp !== $lemp->errsym) {
|
||||
PHP_ParserGenerator::ErrorMsg($lemp->filename, $rp->line,
|
||||
"Nonterminal \"%s\" has no rules.", $sp->name);
|
||||
$lemp->errorcnt++;
|
||||
}
|
||||
for ($newrp = $sp->rule; $newrp; $newrp = $newrp->nextlhs) {
|
||||
$newcfp = self::Configlist_add($newrp, 0);
|
||||
for ($i = $dot + 1; $i < $rp->nrhs; $i++) {
|
||||
$xsp = $rp->rhs[$i];
|
||||
if ($xsp->type == PHP_ParserGenerator_Symbol::TERMINAL) {
|
||||
$newcfp->fws[$xsp->index] = 1;
|
||||
break;
|
||||
} elseif ($xsp->type == PHP_ParserGenerator_Symbol::MULTITERMINAL) {
|
||||
for ($k = 0; $k < $xsp->nsubsym; $k++) {
|
||||
$newcfp->fws[$xsp->subsym[$k]->index] = 1;
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
$a = array_diff_key($xsp->firstset, $newcfp->fws);
|
||||
$newcfp->fws += $a;
|
||||
if ($xsp->lambda === false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($i == $rp->nrhs) {
|
||||
PHP_ParserGenerator_PropagationLink::Plink_add($cfp->fplp, $newcfp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the configuration list
|
||||
* @uses Configcmp()
|
||||
*/
|
||||
static function Configlist_sort()
|
||||
{
|
||||
$a = 0;
|
||||
//self::Configshow(self::$current);
|
||||
self::$current = PHP_ParserGenerator::msort(self::$current,'next', array('PHP_ParserGenerator_Config', 'Configcmp'));
|
||||
//self::Configshow(self::$current);
|
||||
self::$currentend = &$a;
|
||||
self::$currentend = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the configuration list
|
||||
* @uses Configcmp
|
||||
*/
|
||||
static function Configlist_sortbasis()
|
||||
{
|
||||
$a = 0;
|
||||
self::$basis = PHP_ParserGenerator::msort(self::$current,'bp', array('PHP_ParserGenerator_Config', 'Configcmp'));
|
||||
self::$basisend = &$a;
|
||||
self::$basisend = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a pointer to the head of the configuration list and
|
||||
* reset the list
|
||||
* @see $current
|
||||
* @return PHP_ParserGenerator_Config
|
||||
*/
|
||||
static function Configlist_return()
|
||||
{
|
||||
$old = self::$current;
|
||||
self::$current = 0;
|
||||
self::$currentend = &self::$current;
|
||||
return $old;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a pointer to the head of the basis list and
|
||||
* reset the list
|
||||
* @see $basis
|
||||
* @return PHP_ParserGenerator_Config
|
||||
*/
|
||||
static function Configlist_basis()
|
||||
{
|
||||
$old = self::$basis;
|
||||
self::$basis = 0;
|
||||
self::$basisend = &self::$basis;
|
||||
return $old;
|
||||
}
|
||||
|
||||
/**
|
||||
* Free all elements of the given configuration list
|
||||
* @param PHP_ParserGenerator_Config
|
||||
*/
|
||||
static function Configlist_eat($cfp)
|
||||
{
|
||||
for(; $cfp; $cfp = $nextcfp){
|
||||
$nextcfp = $cfp->next;
|
||||
if ($cfp->fplp !=0) {
|
||||
throw new Exception('fplp of configuration non-zero?');
|
||||
}
|
||||
if ($cfp->bplp !=0) {
|
||||
throw new Exception('bplp of configuration non-zero?');
|
||||
}
|
||||
if ($cfp->fws) {
|
||||
$cfp->fws = array();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two configurations for sorting purposes.
|
||||
*
|
||||
* Configurations based on higher precedence rules
|
||||
* (those earlier in the file) are chosen first. Two
|
||||
* configurations that are the same rule are sorted by
|
||||
* dot (see {@link $dot}), and those configurations
|
||||
* with a dot closer to the left-hand side are chosen first.
|
||||
* @param unknown_type $a
|
||||
* @param unknown_type $b
|
||||
* @return unknown
|
||||
*/
|
||||
static function Configcmp($a, $b)
|
||||
{
|
||||
$x = $a->rp->index - $b->rp->index;
|
||||
if (!$x) {
|
||||
$x = $a->dot - $b->dot;
|
||||
}
|
||||
return $x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print out information on this configuration.
|
||||
*
|
||||
* @param resource $fp
|
||||
* @see PHP_ParserGenerator_Data::ReportOutput()
|
||||
*/
|
||||
function ConfigPrint($fp)
|
||||
{
|
||||
$rp = $this->rp;
|
||||
fprintf($fp, "%s ::=", $rp->lhs->name);
|
||||
for ($i = 0; $i <= $rp->nrhs; $i++) {
|
||||
if ($i === $this->dot) {
|
||||
fwrite($fp,' *');
|
||||
}
|
||||
if ($i === $rp->nrhs) {
|
||||
break;
|
||||
}
|
||||
$sp = $rp->rhs[$i];
|
||||
fprintf($fp,' %s', $sp->name);
|
||||
if ($sp->type == PHP_ParserGenerator_Symbol::MULTITERMINAL) {
|
||||
for ($j = 1; $j < $sp->nsubsym; $j++) {
|
||||
fprintf($fp, '|%s', $sp->subsym[$j]->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash a configuration for the associative array {@link $x4a}
|
||||
*/
|
||||
private static function confighash(PHP_ParserGenerator_Config $a)
|
||||
{
|
||||
$h = 0;
|
||||
$h = $h * 571 + $a->rp->index * 37 + $a->dot;
|
||||
return $h;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a new record into the array. Return TRUE if successful.
|
||||
* Prior data with the same key is NOT overwritten
|
||||
*/
|
||||
static function Configtable_insert(PHP_ParserGenerator_Config $data)
|
||||
{
|
||||
$h = self::confighash($data);
|
||||
if (isset(self::$x4a[$h])) {
|
||||
$np = self::$x4a[$h];
|
||||
} else {
|
||||
$np = 0;
|
||||
}
|
||||
while ($np) {
|
||||
if (self::Configcmp($np->data, $data) == 0) {
|
||||
/* An existing entry with the same key is found. */
|
||||
/* Fail because overwrite is not allows. */
|
||||
return 0;
|
||||
}
|
||||
$np = $np->next;
|
||||
}
|
||||
/* Insert the new data */
|
||||
$np = array('data' => $data, 'next' => 0, 'from' => 0);
|
||||
$np = new PHP_ParserGenerator_StateNode;
|
||||
$np->data = $data;
|
||||
if (isset(self::$x4a[$h])) {
|
||||
self::$x4a[$h]->from = $np->next;
|
||||
$np->next = self::$x4a[$h];
|
||||
}
|
||||
$np->from = $np;
|
||||
self::$x4a[$h] = $np;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a pointer to data assigned to the given key. Return NULL
|
||||
* if no such key.
|
||||
* @return PHP_ParserGenerator_Config|0
|
||||
*/
|
||||
static function Configtable_find(PHP_ParserGenerator_Config $key)
|
||||
{
|
||||
$h = self::confighash($key);
|
||||
if (!isset(self::$x4a[$h])) {
|
||||
return 0;
|
||||
}
|
||||
$np = self::$x4a[$h];
|
||||
while ($np) {
|
||||
if (self::Configcmp($np->data, $key) == 0) {
|
||||
break;
|
||||
}
|
||||
$np = $np->next;
|
||||
}
|
||||
return $np ? $np->data : 0;
|
||||
}
|
||||
}
|
||||
?>
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,827 @@
|
|||
<?php
|
||||
/**
|
||||
* PHP_ParserGenerator, a php 5 parser generator.
|
||||
*
|
||||
* This is a direct port of the Lemon parser generator, found at
|
||||
* {@link http://www.hwaci.com/sw/lemon/}
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.01 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_01.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category php
|
||||
* @package PHP_ParserGenerator
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 2006 Gregory Beaver
|
||||
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
||||
* @version CVS: $Id$
|
||||
* @since File available since Release 0.1.0
|
||||
*/
|
||||
/**
|
||||
* The grammar parser for lemon grammar files.
|
||||
*
|
||||
* @package PHP_ParserGenerator
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 2006 Gregory Beaver
|
||||
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
||||
* @since Class available since Release 0.1.0
|
||||
*/
|
||||
class PHP_ParserGenerator_Parser
|
||||
{
|
||||
const INITIALIZE = 1;
|
||||
const WAITING_FOR_DECL_OR_RULE = 2;
|
||||
const WAITING_FOR_DECL_KEYWORD = 3;
|
||||
const WAITING_FOR_DECL_ARG = 4;
|
||||
const WAITING_FOR_PRECEDENCE_SYMBOL = 5;
|
||||
const WAITING_FOR_ARROW = 6;
|
||||
const IN_RHS = 7;
|
||||
const LHS_ALIAS_1 = 8;
|
||||
const LHS_ALIAS_2 = 9;
|
||||
const LHS_ALIAS_3 = 10;
|
||||
const RHS_ALIAS_1 = 11;
|
||||
const RHS_ALIAS_2 = 12;
|
||||
const PRECEDENCE_MARK_1 = 13;
|
||||
const PRECEDENCE_MARK_2 = 14;
|
||||
const RESYNC_AFTER_RULE_ERROR = 15;
|
||||
const RESYNC_AFTER_DECL_ERROR = 16;
|
||||
const WAITING_FOR_DESTRUCTOR_SYMBOL = 17;
|
||||
const WAITING_FOR_DATATYPE_SYMBOL = 18;
|
||||
const WAITING_FOR_FALLBACK_ID = 19;
|
||||
|
||||
/**
|
||||
* Name of the input file
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $filename;
|
||||
/**
|
||||
* Linenumber at which current token starts
|
||||
* @var int
|
||||
*/
|
||||
public $tokenlineno;
|
||||
/**
|
||||
* Number of parsing errors so far
|
||||
* @var int
|
||||
*/
|
||||
public $errorcnt;
|
||||
/**
|
||||
* Index of current token within the input string
|
||||
* @var int
|
||||
*/
|
||||
public $tokenstart;
|
||||
/**
|
||||
* Global state vector
|
||||
* @var PHP_ParserGenerator_Data
|
||||
*/
|
||||
public $gp;
|
||||
/**
|
||||
* Parser state (one of the class constants for this class)
|
||||
*
|
||||
* - PHP_ParserGenerator_Parser::INITIALIZE,
|
||||
* - PHP_ParserGenerator_Parser::WAITING_FOR_DECL_OR_RULE,
|
||||
* - PHP_ParserGenerator_Parser::WAITING_FOR_DECL_KEYWORD,
|
||||
* - PHP_ParserGenerator_Parser::WAITING_FOR_DECL_ARG,
|
||||
* - PHP_ParserGenerator_Parser::WAITING_FOR_PRECEDENCE_SYMBOL,
|
||||
* - PHP_ParserGenerator_Parser::WAITING_FOR_ARROW,
|
||||
* - PHP_ParserGenerator_Parser::IN_RHS,
|
||||
* - PHP_ParserGenerator_Parser::LHS_ALIAS_1,
|
||||
* - PHP_ParserGenerator_Parser::LHS_ALIAS_2,
|
||||
* - PHP_ParserGenerator_Parser::LHS_ALIAS_3,
|
||||
* - PHP_ParserGenerator_Parser::RHS_ALIAS_1,
|
||||
* - PHP_ParserGenerator_Parser::RHS_ALIAS_2,
|
||||
* - PHP_ParserGenerator_Parser::PRECEDENCE_MARK_1,
|
||||
* - PHP_ParserGenerator_Parser::PRECEDENCE_MARK_2,
|
||||
* - PHP_ParserGenerator_Parser::RESYNC_AFTER_RULE_ERROR,
|
||||
* - PHP_ParserGenerator_Parser::RESYNC_AFTER_DECL_ERROR,
|
||||
* - PHP_ParserGenerator_Parser::WAITING_FOR_DESTRUCTOR_SYMBOL,
|
||||
* - PHP_ParserGenerator_Parser::WAITING_FOR_DATATYPE_SYMBOL,
|
||||
* - PHP_ParserGenerator_Parser::WAITING_FOR_FALLBACK_ID
|
||||
* @var int
|
||||
*/
|
||||
public $state;
|
||||
/**
|
||||
* The fallback token
|
||||
* @var PHP_ParserGenerator_Symbol
|
||||
*/
|
||||
public $fallback;
|
||||
/**
|
||||
* Left-hand side of the current rule
|
||||
* @var PHP_ParserGenerator_Symbol
|
||||
*/
|
||||
public $lhs;
|
||||
/**
|
||||
* Alias for the LHS
|
||||
* @var string
|
||||
*/
|
||||
public $lhsalias;
|
||||
/**
|
||||
* Number of right-hand side symbols seen
|
||||
* @var int
|
||||
*/
|
||||
public $nrhs;
|
||||
/**
|
||||
* Right-hand side symbols
|
||||
* @var array array of {@link PHP_ParserGenerator_Symbol} objects
|
||||
*/
|
||||
public $rhs = array();
|
||||
/**
|
||||
* Aliases for each RHS symbol name (or NULL)
|
||||
* @var array array of strings
|
||||
*/
|
||||
public $alias = array();
|
||||
/**
|
||||
* Previous rule parsed
|
||||
* @var PHP_ParserGenerator_Rule
|
||||
*/
|
||||
public $prevrule;
|
||||
/**
|
||||
* Keyword of a declaration
|
||||
*
|
||||
* This is one of the %keyword keywords in the grammar file
|
||||
* @var string
|
||||
*/
|
||||
public $declkeyword;
|
||||
/**
|
||||
* Where the declaration argument should be put
|
||||
*
|
||||
* This is assigned as a reference to an internal variable
|
||||
* @var mixed
|
||||
*/
|
||||
public $declargslot = array();
|
||||
/**
|
||||
* Where the declaration linenumber is put
|
||||
*
|
||||
* This is assigned as a reference to an internal variable
|
||||
* @var mixed
|
||||
*/
|
||||
public $decllnslot;
|
||||
/*enum e_assoc*/
|
||||
public $declassoc; /* Assign this association to decl arguments */
|
||||
public $preccounter; /* Assign this precedence to decl arguments */
|
||||
/**
|
||||
* @var PHP_ParserGenerator_Rule
|
||||
*/
|
||||
public $firstrule; /* Pointer to first rule in the grammar */
|
||||
/**
|
||||
* @var PHP_ParserGenerator_Rule
|
||||
*/
|
||||
public $lastrule; /* Pointer to the most recently parsed rule */
|
||||
|
||||
/**
|
||||
* @var PHP_ParserGenerator
|
||||
*/
|
||||
private $lemon;
|
||||
|
||||
function __construct(PHP_ParserGenerator $lem)
|
||||
{
|
||||
$this->lemon = $lem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the preprocessor over the input file text. The Lemon variable
|
||||
* $azDefine contains the names of all defined
|
||||
* macros. This routine looks for "%ifdef" and "%ifndef" and "%endif" and
|
||||
* comments them out. Text in between is also commented out as appropriate.
|
||||
* @param string
|
||||
*/
|
||||
private function preprocess_input(&$z)
|
||||
{
|
||||
$lineno = $exclude = 0;
|
||||
for ($i=0; $i < strlen($z); $i++) {
|
||||
if ($z[$i] == "\n") {
|
||||
$lineno++;
|
||||
}
|
||||
if ($z[$i] != '%' || ($i > 0 && $z[$i-1] != "\n")) {
|
||||
continue;
|
||||
}
|
||||
if (substr($z, $i, 6) === "%endif" && trim($z[$i+6]) === '') {
|
||||
if ($exclude) {
|
||||
$exclude--;
|
||||
if ($exclude === 0) {
|
||||
for ($j = $start; $j < $i; $j++) {
|
||||
if ($z[$j] != "\n") $z[$j] = ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
for ($j = $i; $j < strlen($z) && $z[$j] != "\n"; $j++) {
|
||||
$z[$j] = ' ';
|
||||
}
|
||||
} elseif (substr($z, $i, 6) === "%ifdef" && trim($z[$i+6]) === '' ||
|
||||
substr($z, $i, 7) === "%ifndef" && trim($z[$i+7]) === '') {
|
||||
if ($exclude) {
|
||||
$exclude++;
|
||||
} else {
|
||||
$j = $i;
|
||||
$n = strtok(substr($z, $j), " \t");
|
||||
$exclude = 1;
|
||||
if (isset($this->lemon->azDefine[$n])) {
|
||||
$exclude = 0;
|
||||
}
|
||||
if ($z[$i + 3]=='n') {
|
||||
// this is a rather obtuse way of checking whether this is %ifndef
|
||||
$exclude = !$exclude;
|
||||
}
|
||||
if ($exclude) {
|
||||
$start = $i;
|
||||
$start_lineno = $lineno;
|
||||
}
|
||||
}
|
||||
//for ($j = $i; $j < strlen($z) && $z[$j] != "\n"; $j++) $z[$j] = ' ';
|
||||
$j = strpos(substr($z, $i), "\n");
|
||||
if ($j === false) {
|
||||
$z = substr($z, 0, $i); // remove instead of adding ' '
|
||||
} else {
|
||||
$z = substr($z, 0, $i) . substr($z, $i + $j); // remove instead of adding ' '
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($exclude) {
|
||||
throw new Exception("unterminated %ifdef starting on line $start_lineno\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* In spite of its name, this function is really a scanner.
|
||||
*
|
||||
* It reads in the entire input file (all at once) then tokenizes it.
|
||||
* Each token is passed to the function "parseonetoken" which builds all
|
||||
* the appropriate data structures in the global state vector "gp".
|
||||
* @param PHP_ParserGenerator_Data
|
||||
*/
|
||||
function Parse(PHP_ParserGenerator_Data $gp)
|
||||
{
|
||||
$startline = 0;
|
||||
|
||||
$this->gp = $gp;
|
||||
$this->filename = $gp->filename;
|
||||
$this->errorcnt = 0;
|
||||
$this->state = self::INITIALIZE;
|
||||
|
||||
/* Begin by reading the input file */
|
||||
$filebuf = file_get_contents($this->filename);
|
||||
if (!$filebuf) {
|
||||
PHP_ParserGenerator::ErrorMsg($this->filename, 0, "Can't open this file for reading.");
|
||||
$gp->errorcnt++;
|
||||
return;
|
||||
}
|
||||
if (filesize($this->filename) != strlen($filebuf)) {
|
||||
ErrorMsg($this->filename, 0, "Can't read in all %d bytes of this file.",
|
||||
filesize($this->filename));
|
||||
$gp->errorcnt++;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Make an initial pass through the file to handle %ifdef and %ifndef */
|
||||
$this->preprocess_input($filebuf);
|
||||
|
||||
/* Now scan the text of the input file */
|
||||
$lineno = 1;
|
||||
for ($cp = 0, $c = $filebuf[0]; $cp < strlen($filebuf); $cp++) {
|
||||
$c = $filebuf[$cp];
|
||||
if ($c == "\n") $lineno++; /* Keep track of the line number */
|
||||
if (trim($c) === '') {
|
||||
continue;
|
||||
} /* Skip all white space */
|
||||
if ($filebuf[$cp] == '/' && ($cp + 1 < strlen($filebuf)) && $filebuf[$cp + 1] == '/') {
|
||||
/* Skip C++ style comments */
|
||||
$cp += 2;
|
||||
$z = strpos(substr($filebuf, $cp), "\n");
|
||||
if ($z === false) {
|
||||
$cp = strlen($filebuf);
|
||||
break;
|
||||
}
|
||||
$lineno++;
|
||||
$cp += $z;
|
||||
continue;
|
||||
}
|
||||
if ($filebuf[$cp] == '/' && ($cp + 1 < strlen($filebuf)) && $filebuf[$cp + 1] == '*') {
|
||||
/* Skip C style comments */
|
||||
$cp += 2;
|
||||
$z = strpos(substr($filebuf, $cp), '*/');
|
||||
if ($z !== false) {
|
||||
$lineno += count(explode("\n", substr($filebuf, $cp, $z))) - 1;
|
||||
}
|
||||
$cp += $z + 1;
|
||||
continue;
|
||||
}
|
||||
$this->tokenstart = $cp; /* Mark the beginning of the token */
|
||||
$this->tokenlineno = $lineno; /* Linenumber on which token begins */
|
||||
if ($filebuf[$cp] == '"') { /* String literals */
|
||||
$cp++;
|
||||
$oldcp = $cp;
|
||||
$test = strpos(substr($filebuf, $cp), '"');
|
||||
if ($test === false) {
|
||||
PHP_ParserGenerator::ErrorMsg($this->filename, $startline,
|
||||
"String starting on this line is not terminated before the end of the file.");
|
||||
$this->errorcnt++;
|
||||
$nextcp = $cp = strlen($filebuf);
|
||||
} else {
|
||||
$cp += $test;
|
||||
$nextcp = $cp + 1;
|
||||
}
|
||||
$lineno += count(explode("\n", substr($filebuf, $oldcp, $cp - $oldcp))) - 1;
|
||||
} elseif ($filebuf[$cp] == '{') { /* A block of C code */
|
||||
$cp++;
|
||||
for ($level = 1; $cp < strlen($filebuf) && ($level > 1 || $filebuf[$cp] != '}'); $cp++) {
|
||||
if ($filebuf[$cp] == "\n") {
|
||||
$lineno++;
|
||||
} elseif ($filebuf[$cp] == '{') {
|
||||
$level++;
|
||||
} elseif ($filebuf[$cp] == '}') {
|
||||
$level--;
|
||||
} elseif ($filebuf[$cp] == '/' && $filebuf[$cp + 1] == '*') {
|
||||
/* Skip comments */
|
||||
$cp += 2;
|
||||
$z = strpos(substr($filebuf, $cp), '*/');
|
||||
if ($z !== false) {
|
||||
$lineno += count(explode("\n", substr($filebuf, $cp, $z))) - 1;
|
||||
}
|
||||
$cp += $z + 2;
|
||||
} elseif ($filebuf[$cp] == '/' && $filebuf[$cp + 1] == '/') {
|
||||
/* Skip C++ style comments too */
|
||||
$cp += 2;
|
||||
$z = strpos(substr($filebuf, $cp), "\n");
|
||||
if ($z === false) {
|
||||
$cp = strlen($filebuf);
|
||||
break;
|
||||
} else {
|
||||
$lineno++;
|
||||
}
|
||||
$cp += $z;
|
||||
} elseif ($filebuf[$cp] == "'" || $filebuf[$cp] == '"') {
|
||||
/* String a character literals */
|
||||
$startchar = $filebuf[$cp];
|
||||
$prevc = 0;
|
||||
for ($cp++; $cp < strlen($filebuf) && ($filebuf[$cp] != $startchar || $prevc === '\\'); $cp++) {
|
||||
if ($filebuf[$cp] == "\n") {
|
||||
$lineno++;
|
||||
}
|
||||
if ($prevc === '\\') {
|
||||
$prevc = 0;
|
||||
} else {
|
||||
$prevc = $filebuf[$cp];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($cp >= strlen($filebuf)) {
|
||||
PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
|
||||
"PHP code starting on this line is not terminated before the end of the file.");
|
||||
$this->errorcnt++;
|
||||
$nextcp = $cp;
|
||||
} else {
|
||||
$nextcp = $cp + 1;
|
||||
}
|
||||
} elseif (preg_match('/[a-zA-Z0-9]/', $filebuf[$cp])) {
|
||||
/* Identifiers */
|
||||
preg_match('/[a-zA-Z0-9_]+/', substr($filebuf, $cp), $preg_results);
|
||||
$cp += strlen($preg_results[0]);
|
||||
$nextcp = $cp;
|
||||
} elseif ($filebuf[$cp] == ':' && $filebuf[$cp + 1] == ':' &&
|
||||
$filebuf[$cp + 2] == '=') {
|
||||
/* The operator "::=" */
|
||||
$cp += 3;
|
||||
$nextcp = $cp;
|
||||
} elseif (($filebuf[$cp] == '/' || $filebuf[$cp] == '|') &&
|
||||
preg_match('/[a-zA-Z]/', $filebuf[$cp + 1])) {
|
||||
$cp += 2;
|
||||
preg_match('/[a-zA-Z0-9_]+/', substr($filebuf, $cp), $preg_results);
|
||||
$cp += strlen($preg_results[0]);
|
||||
$nextcp = $cp;
|
||||
} else {
|
||||
/* All other (one character) operators */
|
||||
$cp ++;
|
||||
$nextcp = $cp;
|
||||
}
|
||||
$this->parseonetoken(substr($filebuf, $this->tokenstart,
|
||||
$cp - $this->tokenstart)); /* Parse the token */
|
||||
$cp = $nextcp - 1;
|
||||
}
|
||||
$gp->rule = $this->firstrule;
|
||||
$gp->errorcnt = $this->errorcnt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a single token
|
||||
* @param string token
|
||||
*/
|
||||
function parseonetoken($token)
|
||||
{
|
||||
$x = $token;
|
||||
$this->a = 0; // for referencing in WAITING_FOR_DECL_KEYWORD
|
||||
if (PHP_ParserGenerator::DEBUG) {
|
||||
printf("%s:%d: Token=[%s] state=%d\n",
|
||||
$this->filename, $this->tokenlineno, $token, $this->state);
|
||||
}
|
||||
switch ($this->state) {
|
||||
case self::INITIALIZE:
|
||||
$this->prevrule = 0;
|
||||
$this->preccounter = 0;
|
||||
$this->firstrule = $this->lastrule = 0;
|
||||
$this->gp->nrule = 0;
|
||||
/* Fall thru to next case */
|
||||
case self::WAITING_FOR_DECL_OR_RULE:
|
||||
if ($x[0] == '%') {
|
||||
$this->state = self::WAITING_FOR_DECL_KEYWORD;
|
||||
} elseif (preg_match('/[a-z]/', $x[0])) {
|
||||
$this->lhs = PHP_ParserGenerator_Symbol::Symbol_new($x);
|
||||
$this->nrhs = 0;
|
||||
$this->lhsalias = 0;
|
||||
$this->state = self::WAITING_FOR_ARROW;
|
||||
} elseif ($x[0] == '{') {
|
||||
if ($this->prevrule === 0) {
|
||||
PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
|
||||
"There is no prior rule opon which to attach the code
|
||||
fragment which begins on this line.");
|
||||
$this->errorcnt++;
|
||||
} elseif ($this->prevrule->code != 0) {
|
||||
PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
|
||||
"Code fragment beginning on this line is not the first \
|
||||
to follow the previous rule.");
|
||||
$this->errorcnt++;
|
||||
} else {
|
||||
$this->prevrule->line = $this->tokenlineno;
|
||||
$this->prevrule->code = substr($x, 1);
|
||||
}
|
||||
} elseif ($x[0] == '[') {
|
||||
$this->state = self::PRECEDENCE_MARK_1;
|
||||
} else {
|
||||
PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
|
||||
"Token \"%s\" should be either \"%%\" or a nonterminal name.",
|
||||
$x);
|
||||
$this->errorcnt++;
|
||||
}
|
||||
break;
|
||||
case self::PRECEDENCE_MARK_1:
|
||||
if (!preg_match('/[A-Z]/', $x[0])) {
|
||||
PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
|
||||
"The precedence symbol must be a terminal.");
|
||||
$this->errorcnt++;
|
||||
} elseif ($this->prevrule === 0) {
|
||||
PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
|
||||
"There is no prior rule to assign precedence \"[%s]\".", $x);
|
||||
$this->errorcnt++;
|
||||
} elseif ($this->prevrule->precsym != 0) {
|
||||
PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
|
||||
"Precedence mark on this line is not the first to follow the previous rule.");
|
||||
$this->errorcnt++;
|
||||
} else {
|
||||
$this->prevrule->precsym = PHP_ParserGenerator_Symbol::Symbol_new($x);
|
||||
}
|
||||
$this->state = self::PRECEDENCE_MARK_2;
|
||||
break;
|
||||
case self::PRECEDENCE_MARK_2:
|
||||
if ($x[0] != ']') {
|
||||
PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
|
||||
"Missing \"]\" on precedence mark.");
|
||||
$this->errorcnt++;
|
||||
}
|
||||
$this->state = self::WAITING_FOR_DECL_OR_RULE;
|
||||
break;
|
||||
case self::WAITING_FOR_ARROW:
|
||||
if ($x[0] == ':' && $x[1] == ':' && $x[2] == '=') {
|
||||
$this->state = self::IN_RHS;
|
||||
} elseif ($x[0] == '(') {
|
||||
$this->state = self::LHS_ALIAS_1;
|
||||
} else {
|
||||
PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
|
||||
"Expected to see a \":\" following the LHS symbol \"%s\".",
|
||||
$this->lhs->name);
|
||||
$this->errorcnt++;
|
||||
$this->state = self::RESYNC_AFTER_RULE_ERROR;
|
||||
}
|
||||
break;
|
||||
case self::LHS_ALIAS_1:
|
||||
if (preg_match('/[A-Za-z]/', $x[0])) {
|
||||
$this->lhsalias = $x;
|
||||
$this->state = self::LHS_ALIAS_2;
|
||||
} else {
|
||||
PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
|
||||
"\"%s\" is not a valid alias for the LHS \"%s\"\n",
|
||||
$x, $this->lhs->name);
|
||||
$this->errorcnt++;
|
||||
$this->state = self::RESYNC_AFTER_RULE_ERROR;
|
||||
}
|
||||
break;
|
||||
case self::LHS_ALIAS_2:
|
||||
if ($x[0] == ')') {
|
||||
$this->state = self::LHS_ALIAS_3;
|
||||
} else {
|
||||
PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
|
||||
"Missing \")\" following LHS alias name \"%s\".",$this->lhsalias);
|
||||
$this->errorcnt++;
|
||||
$this->state = self::RESYNC_AFTER_RULE_ERROR;
|
||||
}
|
||||
break;
|
||||
case self::LHS_ALIAS_3:
|
||||
if ($x == '::=') {
|
||||
$this->state = self::IN_RHS;
|
||||
} else {
|
||||
PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
|
||||
"Missing \"->\" following: \"%s(%s)\".",
|
||||
$this->lhs->name, $this->lhsalias);
|
||||
$this->errorcnt++;
|
||||
$this->state = self::RESYNC_AFTER_RULE_ERROR;
|
||||
}
|
||||
break;
|
||||
case self::IN_RHS:
|
||||
if ($x[0] == '.') {
|
||||
$rp = new PHP_ParserGenerator_Rule;
|
||||
$rp->ruleline = $this->tokenlineno;
|
||||
for ($i = 0; $i < $this->nrhs; $i++) {
|
||||
$rp->rhs[$i] = $this->rhs[$i];
|
||||
$rp->rhsalias[$i] = $this->alias[$i];
|
||||
}
|
||||
$rp->lhs = $this->lhs;
|
||||
$rp->lhsalias = $this->lhsalias;
|
||||
$rp->nrhs = $this->nrhs;
|
||||
$rp->code = 0;
|
||||
$rp->precsym = 0;
|
||||
$rp->index = $this->gp->nrule++;
|
||||
$rp->nextlhs = $rp->lhs->rule;
|
||||
$rp->lhs->rule = $rp;
|
||||
$rp->next = 0;
|
||||
if ($this->firstrule === 0) {
|
||||
$this->firstrule = $this->lastrule = $rp;
|
||||
} else {
|
||||
$this->lastrule->next = $rp;
|
||||
$this->lastrule = $rp;
|
||||
}
|
||||
$this->prevrule = $rp;
|
||||
$this->state = self::WAITING_FOR_DECL_OR_RULE;
|
||||
} elseif (preg_match('/[a-zA-Z]/', $x[0])) {
|
||||
if ($this->nrhs >= PHP_ParserGenerator::MAXRHS) {
|
||||
PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
|
||||
"Too many symbols on RHS or rule beginning at \"%s\".",
|
||||
$x);
|
||||
$this->errorcnt++;
|
||||
$this->state = self::RESYNC_AFTER_RULE_ERROR;
|
||||
} else {
|
||||
if (isset($this->rhs[$this->nrhs - 1])) {
|
||||
$msp = $this->rhs[$this->nrhs - 1];
|
||||
if ($msp->type == PHP_ParserGenerator_Symbol::MULTITERMINAL) {
|
||||
$inf = array_reduce($msp->subsym,
|
||||
array($this, '_printmulti'), '');
|
||||
PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
|
||||
'WARNING: symbol ' . $x . ' will not' .
|
||||
' be part of previous multiterminal %s',
|
||||
substr($inf, 0, strlen($inf) - 1)
|
||||
);
|
||||
}
|
||||
}
|
||||
$this->rhs[$this->nrhs] = PHP_ParserGenerator_Symbol::Symbol_new($x);
|
||||
$this->alias[$this->nrhs] = 0;
|
||||
$this->nrhs++;
|
||||
}
|
||||
} elseif (($x[0] == '|' || $x[0] == '/') && $this->nrhs > 0) {
|
||||
$msp = $this->rhs[$this->nrhs - 1];
|
||||
if ($msp->type != PHP_ParserGenerator_Symbol::MULTITERMINAL) {
|
||||
$origsp = $msp;
|
||||
$msp = new PHP_ParserGenerator_Symbol;
|
||||
$msp->type = PHP_ParserGenerator_Symbol::MULTITERMINAL;
|
||||
$msp->nsubsym = 1;
|
||||
$msp->subsym = array($origsp);
|
||||
$msp->name = $origsp->name;
|
||||
$this->rhs[$this->nrhs - 1] = $msp;
|
||||
}
|
||||
$msp->nsubsym++;
|
||||
$msp->subsym[$msp->nsubsym - 1] = PHP_ParserGenerator_Symbol::Symbol_new(substr($x, 1));
|
||||
if (preg_match('/[a-z]/', $x[1]) ||
|
||||
preg_match('/[a-z]/', $msp->subsym[0]->name[0])) {
|
||||
PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
|
||||
"Cannot form a compound containing a non-terminal");
|
||||
$this->errorcnt++;
|
||||
}
|
||||
} elseif ($x[0] == '(' && $this->nrhs > 0) {
|
||||
$this->state = self::RHS_ALIAS_1;
|
||||
} else {
|
||||
PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
|
||||
"Illegal character on RHS of rule: \"%s\".", $x);
|
||||
$this->errorcnt++;
|
||||
$this->state = self::RESYNC_AFTER_RULE_ERROR;
|
||||
}
|
||||
break;
|
||||
case self::RHS_ALIAS_1:
|
||||
if (preg_match('/[A-Za-z]/', $x[0])) {
|
||||
$this->alias[$this->nrhs - 1] = $x;
|
||||
$this->state = self::RHS_ALIAS_2;
|
||||
} else {
|
||||
PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
|
||||
"\"%s\" is not a valid alias for the RHS symbol \"%s\"\n",
|
||||
$x, $this->rhs[$this->nrhs - 1]->name);
|
||||
$this->errorcnt++;
|
||||
$this->state = self::RESYNC_AFTER_RULE_ERROR;
|
||||
}
|
||||
break;
|
||||
case self::RHS_ALIAS_2:
|
||||
if ($x[0] == ')') {
|
||||
$this->state = self::IN_RHS;
|
||||
} else {
|
||||
PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
|
||||
"Missing \")\" following LHS alias name \"%s\".", $this->lhsalias);
|
||||
$this->errorcnt++;
|
||||
$this->state = self::RESYNC_AFTER_RULE_ERROR;
|
||||
}
|
||||
break;
|
||||
case self::WAITING_FOR_DECL_KEYWORD:
|
||||
if(preg_match('/[A-Za-z]/', $x[0])) {
|
||||
$this->declkeyword = $x;
|
||||
$this->declargslot = &$this->a;
|
||||
$this->decllnslot = &$this->a;
|
||||
$this->state = self::WAITING_FOR_DECL_ARG;
|
||||
if ('name' == $x) {
|
||||
$this->declargslot = &$this->gp->name;
|
||||
} elseif ('include' == $x) {
|
||||
$this->declargslot = &$this->gp->include_code;
|
||||
$this->decllnslot = &$this->gp->includeln;
|
||||
} elseif ('include_class' == $x) {
|
||||
$this->declargslot = &$this->gp->include_classcode;
|
||||
$this->decllnslot = &$this->gp->include_classln;
|
||||
} elseif ('declare_class' == $x) {
|
||||
$this->declargslot = &$this->gp->declare_classcode;
|
||||
$this->decllnslot = &$this->gp->declare_classln;
|
||||
} elseif ('code' == $x) {
|
||||
$this->declargslot = &$this->gp->extracode;
|
||||
$this->decllnslot = &$this->gp->extracodeln;
|
||||
} elseif ('token_destructor' == $x) {
|
||||
$this->declargslot = &$this->gp->tokendest;
|
||||
$this->decllnslot = &$this->gp->tokendestln;
|
||||
} elseif ('default_destructor' == $x) {
|
||||
$this->declargslot = &$this->gp->vardest;
|
||||
$this->decllnslot = &$this->gp->vardestln;
|
||||
} elseif ('token_prefix' == $x) {
|
||||
$this->declargslot = &$this->gp->tokenprefix;
|
||||
} elseif ('syntax_error' == $x) {
|
||||
$this->declargslot = &$this->gp->error;
|
||||
$this->decllnslot = &$this->gp->errorln;
|
||||
} elseif ('parse_accept' == $x) {
|
||||
$this->declargslot = &$this->gp->accept;
|
||||
$this->decllnslot = &$this->gp->acceptln;
|
||||
} elseif ('parse_failure' == $x) {
|
||||
$this->declargslot = &$this->gp->failure;
|
||||
$this->decllnslot = &$this->gp->failureln;
|
||||
} elseif ('stack_overflow' == $x) {
|
||||
$this->declargslot = &$this->gp->overflow;
|
||||
$this->decllnslot = &$this->gp->overflowln;
|
||||
} elseif ('token_type' == $x) {
|
||||
$this->declargslot = &$this->gp->tokentype;
|
||||
} elseif ('default_type' == $x) {
|
||||
$this->declargslot = &$this->gp->vartype;
|
||||
} elseif ('stack_size' == $x) {
|
||||
$this->declargslot = &$this->gp->stacksize;
|
||||
} elseif ('start_symbol' == $x) {
|
||||
$this->declargslot = &$this->gp->start;
|
||||
} elseif ('left' == $x) {
|
||||
$this->preccounter++;
|
||||
$this->declassoc = PHP_ParserGenerator_Symbol::LEFT;
|
||||
$this->state = self::WAITING_FOR_PRECEDENCE_SYMBOL;
|
||||
} elseif ('right' == $x) {
|
||||
$this->preccounter++;
|
||||
$this->declassoc = PHP_ParserGenerator_Symbol::RIGHT;
|
||||
$this->state = self::WAITING_FOR_PRECEDENCE_SYMBOL;
|
||||
} elseif ('nonassoc' == $x) {
|
||||
$this->preccounter++;
|
||||
$this->declassoc = PHP_ParserGenerator_Symbol::NONE;
|
||||
$this->state = self::WAITING_FOR_PRECEDENCE_SYMBOL;
|
||||
} elseif ('destructor' == $x) {
|
||||
$this->state = self::WAITING_FOR_DESTRUCTOR_SYMBOL;
|
||||
} elseif ('type' == $x) {
|
||||
$this->state = self::WAITING_FOR_DATATYPE_SYMBOL;
|
||||
} elseif ('fallback' == $x) {
|
||||
$this->fallback = 0;
|
||||
$this->state = self::WAITING_FOR_FALLBACK_ID;
|
||||
} else {
|
||||
PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
|
||||
"Unknown declaration keyword: \"%%%s\".", $x);
|
||||
$this->errorcnt++;
|
||||
$this->state = self::RESYNC_AFTER_DECL_ERROR;
|
||||
}
|
||||
} else {
|
||||
PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
|
||||
"Illegal declaration keyword: \"%s\".", $x);
|
||||
$this->errorcnt++;
|
||||
$this->state = self::RESYNC_AFTER_DECL_ERROR;
|
||||
}
|
||||
break;
|
||||
case self::WAITING_FOR_DESTRUCTOR_SYMBOL:
|
||||
if (!preg_match('/[A-Za-z]/', $x[0])) {
|
||||
PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
|
||||
"Symbol name missing after %destructor keyword");
|
||||
$this->errorcnt++;
|
||||
$this->state = self::RESYNC_AFTER_DECL_ERROR;
|
||||
} else {
|
||||
$sp = PHP_ParserGenerator_Symbol::Symbol_new($x);
|
||||
$this->declargslot = &$sp->destructor;
|
||||
$this->decllnslot = &$sp->destructorln;
|
||||
$this->state = self::WAITING_FOR_DECL_ARG;
|
||||
}
|
||||
break;
|
||||
case self::WAITING_FOR_DATATYPE_SYMBOL:
|
||||
if (!preg_match('/[A-Za-z]/', $x[0])) {
|
||||
PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
|
||||
"Symbol name missing after %destructor keyword");
|
||||
$this->errorcnt++;
|
||||
$this->state = self::RESYNC_AFTER_DECL_ERROR;
|
||||
} else {
|
||||
$sp = PHP_ParserGenerator_Symbol::Symbol_new($x);
|
||||
$this->declargslot = &$sp->datatype;
|
||||
$this->state = self::WAITING_FOR_DECL_ARG;
|
||||
}
|
||||
break;
|
||||
case self::WAITING_FOR_PRECEDENCE_SYMBOL:
|
||||
if ($x[0] == '.') {
|
||||
$this->state = self::WAITING_FOR_DECL_OR_RULE;
|
||||
} elseif (preg_match('/[A-Z]/', $x[0])) {
|
||||
$sp = PHP_ParserGenerator_Symbol::Symbol_new($x);
|
||||
if ($sp->prec >= 0) {
|
||||
PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
|
||||
"Symbol \"%s\" has already been given a precedence.", $x);
|
||||
$this->errorcnt++;
|
||||
} else {
|
||||
$sp->prec = $this->preccounter;
|
||||
$sp->assoc = $this->declassoc;
|
||||
}
|
||||
} else {
|
||||
PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
|
||||
"Can't assign a precedence to \"%s\".", $x);
|
||||
$this->errorcnt++;
|
||||
}
|
||||
break;
|
||||
case self::WAITING_FOR_DECL_ARG:
|
||||
if (preg_match('/[A-Za-z0-9{"]/', $x[0])) {
|
||||
if ($this->declargslot != 0) {
|
||||
PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
|
||||
"The argument \"%s\" to declaration \"%%%s\" is not the first.",
|
||||
$x[0] == '"' ? substr($x, 1) : $x, $this->declkeyword);
|
||||
$this->errorcnt++;
|
||||
$this->state = self::RESYNC_AFTER_DECL_ERROR;
|
||||
} else {
|
||||
$this->declargslot = ($x[0] == '"' || $x[0] == '{') ? substr($x, 1) : $x;
|
||||
$this->a = 1;
|
||||
if (!$this->decllnslot) {
|
||||
$this->decllnslot = $this->tokenlineno;
|
||||
}
|
||||
$this->state = self::WAITING_FOR_DECL_OR_RULE;
|
||||
}
|
||||
} else {
|
||||
PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
|
||||
"Illegal argument to %%%s: %s",$this->declkeyword, $x);
|
||||
$this->errorcnt++;
|
||||
$this->state = self::RESYNC_AFTER_DECL_ERROR;
|
||||
}
|
||||
break;
|
||||
case self::WAITING_FOR_FALLBACK_ID:
|
||||
if ($x[0] == '.') {
|
||||
$this->state = self::WAITING_FOR_DECL_OR_RULE;
|
||||
} elseif (!preg_match('/[A-Z]/', $x[0])) {
|
||||
PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
|
||||
"%%fallback argument \"%s\" should be a token", $x);
|
||||
$this->errorcnt++;
|
||||
} else {
|
||||
$sp = PHP_ParserGenerator_Symbol::Symbol_new($x);
|
||||
if ($this->fallback === 0) {
|
||||
$this->fallback = $sp;
|
||||
} elseif (is_object($sp->fallback)) {
|
||||
PHP_ParserGenerator::ErrorMsg($this->filename, $this->tokenlineno,
|
||||
"More than one fallback assigned to token %s", $x);
|
||||
$this->errorcnt++;
|
||||
} else {
|
||||
$sp->fallback = $this->fallback;
|
||||
$this->gp->has_fallback = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case self::RESYNC_AFTER_RULE_ERROR:
|
||||
/* if ($x[0] == '.') $this->state = self::WAITING_FOR_DECL_OR_RULE;
|
||||
** break; */
|
||||
case self::RESYNC_AFTER_DECL_ERROR:
|
||||
if ($x[0] == '.') {
|
||||
$this->state = self::WAITING_FOR_DECL_OR_RULE;
|
||||
}
|
||||
if ($x[0] == '%') {
|
||||
$this->state = self::WAITING_FOR_DECL_KEYWORD;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* return a descriptive string for a multi-terminal token.
|
||||
*
|
||||
* @param string $a
|
||||
* @param string $b
|
||||
* @return string
|
||||
*/
|
||||
private function _printmulti($a, $b)
|
||||
{
|
||||
if (!$a) {
|
||||
$a = '';
|
||||
}
|
||||
$a .= $b->name . '|';
|
||||
return $a;
|
||||
}
|
||||
}
|
93
pkg/vtiger/extensions/Webservices/third-party/ParserGenerator/PropagationLink.php
vendored
Normal file
93
pkg/vtiger/extensions/Webservices/third-party/ParserGenerator/PropagationLink.php
vendored
Normal file
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
/**
|
||||
* PHP_ParserGenerator, a php 5 parser generator.
|
||||
*
|
||||
* This is a direct port of the Lemon parser generator, found at
|
||||
* {@link http://www.hwaci.com/sw/lemon/}
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.01 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_01.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category php
|
||||
* @package PHP_ParserGenerator
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 2006 Gregory Beaver
|
||||
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
||||
* @version CVS: $Id$
|
||||
* @since File available since Release 0.1.0
|
||||
*/
|
||||
/**
|
||||
* A followset propagation link indicates that the contents of one
|
||||
* configuration followset should be propagated to another whenever
|
||||
* the first changes.
|
||||
*
|
||||
* @package PHP_ParserGenerator
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 2006 Gregory Beaver
|
||||
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
||||
* @version 0.1.0
|
||||
* @since Class available since Release 0.1.0
|
||||
*/
|
||||
|
||||
class PHP_ParserGenerator_PropagationLink {
|
||||
/**
|
||||
* The configuration that defines this propagation link
|
||||
* @var PHP_ParserGenerator_Config
|
||||
*/
|
||||
public $cfp;
|
||||
/**
|
||||
* The next propagation link
|
||||
* @var PHP_ParserGenerator_PropagationLink|0
|
||||
*/
|
||||
public $next = 0;
|
||||
|
||||
/**
|
||||
* Add a propagation link to the current list
|
||||
*
|
||||
* This prepends the configuration passed in to the first parameter
|
||||
* which is either 0 or a PHP_ParserGenerator_PropagationLink defining
|
||||
* an existing list.
|
||||
* @param PHP_ParserGenerator_PropagationLink|null
|
||||
* @param PHP_ParserGenerator_Config
|
||||
*/
|
||||
static function Plink_add(&$plpp, PHP_ParserGenerator_Config $cfp)
|
||||
{
|
||||
$new = new PHP_ParserGenerator_PropagationLink;
|
||||
$new->next = $plpp;
|
||||
$plpp = $new;
|
||||
$new->cfp = $cfp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transfer every propagation link on the list "from" to the list "to"
|
||||
*/
|
||||
static function Plink_copy(PHP_ParserGenerator_PropagationLink &$to,
|
||||
PHP_ParserGenerator_PropagationLink $from)
|
||||
{
|
||||
while ($from) {
|
||||
$nextpl = $from->next;
|
||||
$from->next = $to;
|
||||
$to = $from;
|
||||
$from = $nextpl;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete every propagation link on the list
|
||||
* @param PHP_ParserGenerator_PropagationLink|0
|
||||
*/
|
||||
static function Plink_delete($plp)
|
||||
{
|
||||
while ($plp) {
|
||||
$nextpl = $plp->next;
|
||||
$plp->next = 0;
|
||||
$plp = $nextpl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,116 @@
|
|||
<?php
|
||||
/**
|
||||
* PHP_ParserGenerator, a php 5 parser generator.
|
||||
*
|
||||
* This is a direct port of the Lemon parser generator, found at
|
||||
* {@link http://www.hwaci.com/sw/lemon/}
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.01 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_01.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category php
|
||||
* @package PHP_ParserGenerator
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 2006 Gregory Beaver
|
||||
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
||||
* @version CVS: $Id$
|
||||
* @since File available since Release 0.1.0
|
||||
*/
|
||||
/**
|
||||
* Each production rule in the grammar is stored in this class
|
||||
*
|
||||
* @package PHP_ParserGenerator
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 2006 Gregory Beaver
|
||||
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
||||
* @version 0.1.0
|
||||
* @since Class available since Release 0.1.0
|
||||
*/
|
||||
class PHP_ParserGenerator_Rule {
|
||||
/**
|
||||
* Left-hand side of the rule
|
||||
* @var array an array of {@link PHP_ParserGenerator_Symbol} objects
|
||||
*/
|
||||
public $lhs;
|
||||
/**
|
||||
* Alias for the LHS (NULL if none)
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $lhsalias = array();
|
||||
/**
|
||||
* Line number for the rule
|
||||
* @var int
|
||||
*/
|
||||
public $ruleline;
|
||||
/**
|
||||
* Number of right-hand side symbols
|
||||
*/
|
||||
public $nrhs;
|
||||
/**
|
||||
* The right-hand side symbols
|
||||
* @var array an array of {@link PHP_ParserGenerator_Symbol} objects
|
||||
*/
|
||||
public $rhs;
|
||||
/**
|
||||
* Aliases for each right-hand side symbol, or null if no alis.
|
||||
*
|
||||
* In this rule:
|
||||
* <pre>
|
||||
* foo ::= BAR(A) baz(B).
|
||||
* </pre>
|
||||
*
|
||||
* The right-hand side aliases are A for BAR, and B for baz.
|
||||
* @var array aliases are indexed by the right-hand side symbol index.
|
||||
*/
|
||||
public $rhsalias = array();
|
||||
/**
|
||||
* Line number at which code begins
|
||||
* @var int
|
||||
*/
|
||||
public $line;
|
||||
/**
|
||||
* The code executed when this rule is reduced
|
||||
*
|
||||
* <pre>
|
||||
* foo(R) ::= BAR(A) baz(B). {R = A + B;}
|
||||
* </pre>
|
||||
*
|
||||
* In the rule above, the code is "R = A + B;"
|
||||
* @var string|0
|
||||
*/
|
||||
public $code;
|
||||
/**
|
||||
* Precedence symbol for this rule
|
||||
* @var PHP_ParserGenerator_Symbol
|
||||
*/
|
||||
public $precsym;
|
||||
/**
|
||||
* An index number for this rule
|
||||
*
|
||||
* Used in both naming of reduce functions and determining which rule code
|
||||
* to use for reduce actions
|
||||
* @var int
|
||||
*/
|
||||
public $index;
|
||||
/**
|
||||
* True if this rule is ever reduced
|
||||
* @var boolean
|
||||
*/
|
||||
public $canReduce;
|
||||
/**
|
||||
* Next rule with the same left-hand side
|
||||
* @var PHP_ParserGenerator_Rule|0
|
||||
*/
|
||||
public $nextlhs;
|
||||
/**
|
||||
* Next rule in the global list
|
||||
* @var PHP_ParserGenerator_Rule|0
|
||||
*/
|
||||
public $next;
|
||||
}
|
|
@ -0,0 +1,253 @@
|
|||
<?php
|
||||
/**
|
||||
* PHP_ParserGenerator, a php 5 parser generator.
|
||||
*
|
||||
* This is a direct port of the Lemon parser generator, found at
|
||||
* {@link http://www.hwaci.com/sw/lemon/}
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.01 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_01.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category php
|
||||
* @package PHP_ParserGenerator
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 2006 Gregory Beaver
|
||||
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
||||
* @version CVS: $Id$
|
||||
* @since File available since Release 0.1.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* The structure used to represent a state in the associative array
|
||||
* for a PHP_ParserGenerator_Config.
|
||||
* @package PHP_ParserGenerator
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 2006 Gregory Beaver
|
||||
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
||||
* @version 0.1.0
|
||||
* @since Class available since Release 0.1.0
|
||||
*/
|
||||
class PHP_ParserGenerator_StateNode
|
||||
{
|
||||
public $key;
|
||||
public $data;
|
||||
public $from = 0;
|
||||
public $next = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Each state of the generated parser's finite state machine
|
||||
* is encoded as an instance of this class
|
||||
*
|
||||
* @package PHP_ParserGenerator
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 2006 Gregory Beaver
|
||||
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
||||
* @version 0.1.0
|
||||
* @since Class available since Release 0.1.0
|
||||
*/
|
||||
class PHP_ParserGenerator_State {
|
||||
/**
|
||||
* The basis configurations for this state
|
||||
* @var PHP_ParserGenerator_Config
|
||||
*/
|
||||
public $bp;
|
||||
/**
|
||||
* All configurations in this state
|
||||
* @var PHP_ParserGenerator_Config
|
||||
*/
|
||||
public $cfp;
|
||||
/**
|
||||
* Sequential number for this state
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $statenum;
|
||||
/**
|
||||
* Linked list of actions for this state.
|
||||
* @var PHP_ParserGenerator_Action
|
||||
*/
|
||||
public $ap;
|
||||
/**
|
||||
* Number of terminal (token) actions
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $nTknAct,
|
||||
/**
|
||||
* Number of non-terminal actions
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
$nNtAct;
|
||||
/**
|
||||
* The offset into the $yy_action table for terminal tokens.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $iTknOfst,
|
||||
/**
|
||||
* The offset into the $yy_action table for non-terminals.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
$iNtOfst;
|
||||
/**
|
||||
* Default action
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $iDflt;
|
||||
/**
|
||||
* Associative array of PHP_ParserGenerator_State objects
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $x3a = array();
|
||||
/**
|
||||
* Array of PHP_ParserGenerator_State objects
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $states = array();
|
||||
|
||||
/**
|
||||
* Compare two states for sorting purposes. The smaller state is the
|
||||
* one with the most non-terminal actions. If they have the same number
|
||||
* of non-terminal actions, then the smaller is the one with the most
|
||||
* token actions.
|
||||
*/
|
||||
static function stateResortCompare($a, $b)
|
||||
{
|
||||
$n = $b->nNtAct - $a->nNtAct;
|
||||
if ($n === 0) {
|
||||
$n = $b->nTknAct - $a->nTknAct;
|
||||
}
|
||||
return $n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two states based on their configurations
|
||||
*
|
||||
* @param PHP_ParserGenerator_Config|0 $a
|
||||
* @param PHP_ParserGenerator_Config|0 $b
|
||||
* @return int
|
||||
*/
|
||||
static function statecmp($a, $b)
|
||||
{
|
||||
for ($rc = 0; $rc == 0 && $a && $b; $a = $a->bp, $b = $b->bp) {
|
||||
$rc = $a->rp->index - $b->rp->index;
|
||||
if ($rc === 0) {
|
||||
$rc = $a->dot - $b->dot;
|
||||
}
|
||||
}
|
||||
if ($rc == 0) {
|
||||
if ($a) {
|
||||
$rc = 1;
|
||||
}
|
||||
if ($b) {
|
||||
$rc = -1;
|
||||
}
|
||||
}
|
||||
return $rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash a state based on its configuration
|
||||
* @return int
|
||||
*/
|
||||
private static function statehash(PHP_ParserGenerator_Config $a)
|
||||
{
|
||||
$h = 0;
|
||||
while ($a) {
|
||||
$h = $h * 571 + $a->rp->index * 37 + $a->dot;
|
||||
$a = $a->bp;
|
||||
}
|
||||
return (int) $h;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a pointer to data assigned to the given key. Return NULL
|
||||
* if no such key.
|
||||
* @param PHP_ParserGenerator_Config
|
||||
* @return null|PHP_ParserGenerator_State
|
||||
*/
|
||||
static function State_find(PHP_ParserGenerator_Config $key)
|
||||
{
|
||||
if (!count(self::$x3a)) {
|
||||
return 0;
|
||||
}
|
||||
$h = self::statehash($key);
|
||||
if (!isset(self::$x3a[$h])) {
|
||||
return 0;
|
||||
}
|
||||
$np = self::$x3a[$h];
|
||||
while ($np) {
|
||||
if (self::statecmp($np->key, $key) == 0) {
|
||||
break;
|
||||
}
|
||||
$np = $np->next;
|
||||
}
|
||||
return $np ? $np->data : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a new record into the array. Return TRUE if successful.
|
||||
* Prior data with the same key is NOT overwritten
|
||||
*
|
||||
* @param PHP_ParserGenerator_State $state
|
||||
* @param PHP_ParserGenerator_Config $key
|
||||
* @return unknown
|
||||
*/
|
||||
static function State_insert(PHP_ParserGenerator_State $state,
|
||||
PHP_ParserGenerator_Config $key)
|
||||
{
|
||||
$h = self::statehash($key);
|
||||
if (isset(self::$x3a[$h])) {
|
||||
$np = self::$x3a[$h];
|
||||
} else {
|
||||
$np = 0;
|
||||
}
|
||||
while ($np) {
|
||||
if (self::statecmp($np->key, $key) == 0) {
|
||||
/* An existing entry with the same key is found. */
|
||||
/* Fail because overwrite is not allows. */
|
||||
return 0;
|
||||
}
|
||||
$np = $np->next;
|
||||
}
|
||||
/* Insert the new data */
|
||||
$np = new PHP_ParserGenerator_StateNode;
|
||||
$np->key = $key;
|
||||
$np->data = $state;
|
||||
self::$states[] = $np;
|
||||
// the original lemon code sets the from link always to itself
|
||||
// setting up a faulty double-linked list
|
||||
// however, the from links are never used, so I suspect a copy/paste
|
||||
// error from a standard algorithm that was never caught
|
||||
if (isset(self::$x3a[$h])) {
|
||||
self::$x3a[$h]->from = $np; // lemon has $np->next here
|
||||
} else {
|
||||
self::$x3a[$h] = 0; // dummy to avoid notice
|
||||
}
|
||||
$np->next = self::$x3a[$h];
|
||||
self::$x3a[$h] = $np;
|
||||
$np->from = self::$x3a[$h];
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array indexed by state number
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function State_arrayof()
|
||||
{
|
||||
return self::$states;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,260 @@
|
|||
<?php
|
||||
/**
|
||||
* PHP_ParserGenerator, a php 5 parser generator.
|
||||
*
|
||||
* This is a direct port of the Lemon parser generator, found at
|
||||
* {@link http://www.hwaci.com/sw/lemon/}
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.01 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_01.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category php
|
||||
* @package PHP_ParserGenerator
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 2006 Gregory Beaver
|
||||
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
||||
* @version CVS: $Id$
|
||||
* @since File available since Release 0.1.0
|
||||
*/
|
||||
/**
|
||||
* Symbols (terminals and nonterminals) of the grammar are stored in this class
|
||||
*
|
||||
* @package PHP_ParserGenerator
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 2006 Gregory Beaver
|
||||
* @license http://www.php.net/license/3_01.txt PHP License 3.01
|
||||
* @version 0.1.0
|
||||
* @since Class available since Release 0.1.0
|
||||
*/
|
||||
class PHP_ParserGenerator_Symbol
|
||||
{
|
||||
/**
|
||||
* Symbols that start with a capital letter like FOO.
|
||||
*
|
||||
* These are tokens directly from the lexer
|
||||
*/
|
||||
const TERMINAL = 1;
|
||||
/**
|
||||
* Symbols that start with a lower-case letter like foo.
|
||||
*
|
||||
* These are grammar rules like "foo ::= BLAH."
|
||||
*/
|
||||
const NONTERMINAL = 2;
|
||||
/**
|
||||
* Multiple terminal symbols.
|
||||
*
|
||||
* These are a grammar rule that consists of several terminals like
|
||||
* FOO|BAR|BAZ. Note that non-terminals cannot be in a multi-terminal,
|
||||
* and a multi-terminal acts like a single terminal.
|
||||
*
|
||||
* "FOO|BAR FOO|BAZ" is actually two multi-terminals, FOO|BAR and FOO|BAZ.
|
||||
*/
|
||||
const MULTITERMINAL = 3;
|
||||
|
||||
const LEFT = 1;
|
||||
const RIGHT = 2;
|
||||
const NONE = 3;
|
||||
const UNK = 4;
|
||||
/**
|
||||
* Name of the symbol
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name;
|
||||
/**
|
||||
* Index of this symbol.
|
||||
*
|
||||
* This will ultimately end up representing the symbol in the generated
|
||||
* parser
|
||||
* @var int
|
||||
*/
|
||||
public $index;
|
||||
/**
|
||||
* Symbol type
|
||||
*
|
||||
* One of PHP_ParserGenerator_Symbol::TERMINAL,
|
||||
* PHP_ParserGenerator_Symbol::NONTERMINAL or
|
||||
* PHP_ParserGenerator_Symbol::MULTITERMINAL
|
||||
* @var int
|
||||
*/
|
||||
public $type;
|
||||
/**
|
||||
* Linked list of rules that use this symbol, if it is a non-terminal.
|
||||
* @var PHP_ParserGenerator_Rule
|
||||
*/
|
||||
public $rule;
|
||||
/**
|
||||
* Fallback token in case this token doesn't parse
|
||||
* @var PHP_ParserGenerator_Symbol
|
||||
*/
|
||||
public $fallback;
|
||||
/**
|
||||
* Precendence, if defined.
|
||||
*
|
||||
* -1 if no unusual precedence
|
||||
* @var int
|
||||
*/
|
||||
public $prec = -1;
|
||||
/**
|
||||
* Associativity if precedence is defined.
|
||||
*
|
||||
* One of PHP_ParserGenerator_Symbol::LEFT,
|
||||
* PHP_ParserGenerator_Symbol::RIGHT, PHP_ParserGenerator_Symbol::NONE
|
||||
* or PHP_ParserGenerator_Symbol::UNK
|
||||
* @var unknown_type
|
||||
*/
|
||||
public $assoc;
|
||||
/**
|
||||
* First-set for all rules of this symbol
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $firstset;
|
||||
/**
|
||||
* True if this symbol is a non-terminal and can generate an empty
|
||||
* result.
|
||||
*
|
||||
* For instance "foo ::= ."
|
||||
* @var boolean
|
||||
*/
|
||||
public $lambda;
|
||||
/**
|
||||
* Code that executes whenever this symbol is popped from the stack during
|
||||
* error processing.
|
||||
*
|
||||
* @var string|0
|
||||
*/
|
||||
public $destructor = 0;
|
||||
/**
|
||||
* Line number of destructor code
|
||||
* @var int
|
||||
*/
|
||||
public $destructorln;
|
||||
/**
|
||||
* Unused relic of the C version of Lemon.
|
||||
*
|
||||
* The data type of information held by this object. Only used
|
||||
* if this is a non-terminal
|
||||
* @var string
|
||||
*/
|
||||
public $datatype;
|
||||
/**
|
||||
* Unused relic of the C version of Lemon.
|
||||
*
|
||||
* The data type number. In the parser, the value
|
||||
* stack is a union. The .yy%d element of this
|
||||
* union is the correct data type for this object
|
||||
* @var string
|
||||
*/
|
||||
public $dtnum;
|
||||
/**#@+
|
||||
* The following fields are used by MULTITERMINALs only
|
||||
*/
|
||||
/**
|
||||
* Number of terminal symbols in the MULTITERMINAL
|
||||
*
|
||||
* This is of course the same as count($this->subsym)
|
||||
* @var int
|
||||
*/
|
||||
public $nsubsym;
|
||||
/**
|
||||
* Array of terminal symbols in the MULTITERMINAL
|
||||
* @var array an array of {@link PHP_ParserGenerator_Symbol} objects
|
||||
*/
|
||||
public $subsym = array();
|
||||
/**#@-*/
|
||||
/**
|
||||
* Singleton storage of symbols
|
||||
*
|
||||
* @var array an array of PHP_ParserGenerator_Symbol objects
|
||||
*/
|
||||
private static $symbol_table = array();
|
||||
/**
|
||||
* Return a pointer to the (terminal or nonterminal) symbol "x".
|
||||
* Create a new symbol if this is the first time "x" has been seen.
|
||||
* (this is a singleton)
|
||||
* @param string
|
||||
* @return PHP_ParserGenerator_Symbol
|
||||
*/
|
||||
public static function Symbol_new($x)
|
||||
{
|
||||
if (isset(self::$symbol_table[$x])) {
|
||||
return self::$symbol_table[$x];
|
||||
}
|
||||
$sp = new PHP_ParserGenerator_Symbol;
|
||||
$sp->name = $x;
|
||||
$sp->type = preg_match('/[A-Z]/', $x[0]) ? self::TERMINAL : self::NONTERMINAL;
|
||||
$sp->rule = 0;
|
||||
$sp->fallback = 0;
|
||||
$sp->prec = -1;
|
||||
$sp->assoc = self::UNK;
|
||||
$sp->firstset = array();
|
||||
$sp->lambda = false;
|
||||
$sp->destructor = 0;
|
||||
$sp->datatype = 0;
|
||||
self::$symbol_table[$sp->name] = $sp;
|
||||
return $sp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of unique symbols
|
||||
* @return int
|
||||
*/
|
||||
public static function Symbol_count()
|
||||
{
|
||||
return count(self::$symbol_table);
|
||||
}
|
||||
|
||||
public static function Symbol_arrayof()
|
||||
{
|
||||
return array_values(self::$symbol_table);
|
||||
}
|
||||
|
||||
public static function Symbol_find($x)
|
||||
{
|
||||
if (isset(self::$symbol_table[$x])) {
|
||||
return self::$symbol_table[$x];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort function helper for symbols
|
||||
*
|
||||
* Symbols that begin with upper case letters (terminals or tokens)
|
||||
* must sort before symbols that begin with lower case letters
|
||||
* (non-terminals). Other than that, the order does not matter.
|
||||
*
|
||||
* We find experimentally that leaving the symbols in their original
|
||||
* order (the order they appeared in the grammar file) gives the
|
||||
* smallest parser tables in SQLite.
|
||||
* @param PHP_ParserGenerator_Symbol
|
||||
* @param PHP_ParserGenerator_Symbol
|
||||
*/
|
||||
public static function sortSymbols($a, $b)
|
||||
{
|
||||
$i1 = $a->index + 10000000*(ord($a->name[0]) > ord('Z'));
|
||||
$i2 = $b->index + 10000000*(ord($b->name[0]) > ord('Z'));
|
||||
return $i1 - $i2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if two symbols are the same.
|
||||
*/
|
||||
public static function same_symbol(PHP_ParserGenerator_Symbol $a, PHP_ParserGenerator_Symbol $b)
|
||||
{
|
||||
if ($a === $b) return 1;
|
||||
if ($a->type != self::MULTITERMINAL) return 0;
|
||||
if ($b->type != self::MULTITERMINAL) return 0;
|
||||
if ($a->nsubsym != $b->nsubsym) return 0;
|
||||
for ($i = 0; $i < $a->nsubsym; $i++) {
|
||||
if ($a->subsym[$i] != $b->subsym[$i]) return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
require_once 'PHP/ParserGenerator.php';
|
||||
$me = new PHP_ParserGenerator;
|
||||
$me->main();
|
||||
?>
|
|
@ -0,0 +1,479 @@
|
|||
<?xml version='1.0'?>
|
||||
<module>
|
||||
<exporttime>2010-04-15 17:28:36</exporttime>
|
||||
<name>Assets</name>
|
||||
<label>Assets</label>
|
||||
<parent>Inventory</parent>
|
||||
<version>1.6</version>
|
||||
<dependencies>
|
||||
<vtiger_version>5.1.0</vtiger_version>
|
||||
<vtiger_max_version>5.*</vtiger_max_version>
|
||||
</dependencies>
|
||||
<tables>
|
||||
<table>
|
||||
<name>vtiger_assets</name>
|
||||
<sql><![CDATA[CREATE TABLE `vtiger_assets` (
|
||||
`assetsid` int(11) NOT NULL,
|
||||
`asset_no` varchar(30) NOT NULL,
|
||||
`account` int(19) NOT NULL,
|
||||
`product` int(19) NOT NULL,
|
||||
`serialnumber` varchar(200) NOT NULL,
|
||||
`datesold` date NOT NULL,
|
||||
`dateinservice` date NOT NULL,
|
||||
`assetstatus` varchar(200) default 'In Service',
|
||||
`tagnumber` varchar(300) default NULL,
|
||||
`invoiceid` int(19) default NULL,
|
||||
`shippingmethod` varchar(200) default NULL,
|
||||
`shippingtrackingnumber` varchar(200) default NULL,
|
||||
`assetname` varchar(100) default NULL,
|
||||
PRIMARY KEY (`assetsid`),
|
||||
CONSTRAINT `fk_1_vtiger_assets` FOREIGN KEY (`assetsid`) REFERENCES `vtiger_crmentity` (`crmid`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8]]></sql>
|
||||
</table>
|
||||
<table>
|
||||
<name>vtiger_assetscf</name>
|
||||
<sql><![CDATA[CREATE TABLE `vtiger_assetscf` (
|
||||
`assetsid` int(19) NOT NULL,
|
||||
PRIMARY KEY (`assetsid`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8]]></sql>
|
||||
</table>
|
||||
</tables>
|
||||
<blocks>
|
||||
<block>
|
||||
<label>LBL_ASSET_INFORMATION</label>
|
||||
<fields>
|
||||
<field>
|
||||
<fieldname>asset_no</fieldname>
|
||||
<uitype>4</uitype>
|
||||
<columnname>asset_no</columnname>
|
||||
<tablename>vtiger_assets</tablename>
|
||||
<generatedtype>1</generatedtype>
|
||||
<fieldlabel>Asset No</fieldlabel>
|
||||
<readonly>1</readonly>
|
||||
<presence>0</presence>
|
||||
<defaultvalue></defaultvalue>
|
||||
<sequence>2</sequence>
|
||||
<maximumlength>100</maximumlength>
|
||||
<typeofdata>V~O</typeofdata>
|
||||
<quickcreate>3</quickcreate>
|
||||
<quickcreatesequence>0</quickcreatesequence>
|
||||
<displaytype>1</displaytype>
|
||||
<info_type>BAS</info_type>
|
||||
<helpinfo><![CDATA[]]></helpinfo>
|
||||
<masseditable>0</masseditable>
|
||||
</field>
|
||||
<field>
|
||||
<fieldname>product</fieldname>
|
||||
<uitype>10</uitype>
|
||||
<columnname>product</columnname>
|
||||
<tablename>vtiger_assets</tablename>
|
||||
<generatedtype>1</generatedtype>
|
||||
<fieldlabel>Product Name</fieldlabel>
|
||||
<readonly>1</readonly>
|
||||
<presence>2</presence>
|
||||
<defaultvalue></defaultvalue>
|
||||
<sequence>3</sequence>
|
||||
<maximumlength>100</maximumlength>
|
||||
<typeofdata>V~M</typeofdata>
|
||||
<quickcreate>0</quickcreate>
|
||||
<quickcreatesequence>3</quickcreatesequence>
|
||||
<displaytype>1</displaytype>
|
||||
<info_type>BAS</info_type>
|
||||
<helpinfo><![CDATA[]]></helpinfo>
|
||||
<masseditable>1</masseditable>
|
||||
<relatedmodules>
|
||||
<relatedmodule>Products</relatedmodule>
|
||||
</relatedmodules>
|
||||
</field>
|
||||
<field>
|
||||
<fieldname>serialnumber</fieldname>
|
||||
<uitype>2</uitype>
|
||||
<columnname>serialnumber</columnname>
|
||||
<tablename>vtiger_assets</tablename>
|
||||
<generatedtype>1</generatedtype>
|
||||
<fieldlabel>Serial Number</fieldlabel>
|
||||
<readonly>1</readonly>
|
||||
<presence>2</presence>
|
||||
<defaultvalue></defaultvalue>
|
||||
<sequence>4</sequence>
|
||||
<maximumlength>100</maximumlength>
|
||||
<typeofdata>V~M</typeofdata>
|
||||
<quickcreate>0</quickcreate>
|
||||
<quickcreatesequence>5</quickcreatesequence>
|
||||
<displaytype>1</displaytype>
|
||||
<info_type>BAS</info_type>
|
||||
<helpinfo><![CDATA[]]></helpinfo>
|
||||
<masseditable>1</masseditable>
|
||||
</field>
|
||||
<field>
|
||||
<fieldname>datesold</fieldname>
|
||||
<uitype>5</uitype>
|
||||
<columnname>datesold</columnname>
|
||||
<tablename>vtiger_assets</tablename>
|
||||
<generatedtype>1</generatedtype>
|
||||
<fieldlabel>Date Sold</fieldlabel>
|
||||
<readonly>1</readonly>
|
||||
<presence>2</presence>
|
||||
<defaultvalue></defaultvalue>
|
||||
<sequence>5</sequence>
|
||||
<maximumlength>100</maximumlength>
|
||||
<typeofdata>D~M~OTH~GE~datesold~Date Sold</typeofdata>
|
||||
<quickcreate>0</quickcreate>
|
||||
<quickcreatesequence>0</quickcreatesequence>
|
||||
<displaytype>1</displaytype>
|
||||
<info_type>BAS</info_type>
|
||||
<helpinfo><![CDATA[]]></helpinfo>
|
||||
<masseditable>1</masseditable>
|
||||
</field>
|
||||
<field>
|
||||
<fieldname>dateinservice</fieldname>
|
||||
<uitype>5</uitype>
|
||||
<columnname>dateinservice</columnname>
|
||||
<tablename>vtiger_assets</tablename>
|
||||
<generatedtype>1</generatedtype>
|
||||
<fieldlabel>Date in Service</fieldlabel>
|
||||
<readonly>1</readonly>
|
||||
<presence>2</presence>
|
||||
<defaultvalue></defaultvalue>
|
||||
<sequence>6</sequence>
|
||||
<maximumlength>100</maximumlength>
|
||||
<typeofdata>D~M~OTH~GE~dateinservice~Date in Service</typeofdata>
|
||||
<quickcreate>0</quickcreate>
|
||||
<quickcreatesequence>4</quickcreatesequence>
|
||||
<displaytype>1</displaytype>
|
||||
<info_type>BAS</info_type>
|
||||
<helpinfo><![CDATA[]]></helpinfo>
|
||||
<masseditable>1</masseditable>
|
||||
</field>
|
||||
<field>
|
||||
<fieldname>assetstatus</fieldname>
|
||||
<uitype>15</uitype>
|
||||
<columnname>assetstatus</columnname>
|
||||
<tablename>vtiger_assets</tablename>
|
||||
<generatedtype>1</generatedtype>
|
||||
<fieldlabel>Status</fieldlabel>
|
||||
<readonly>1</readonly>
|
||||
<presence>2</presence>
|
||||
<defaultvalue></defaultvalue>
|
||||
<sequence>7</sequence>
|
||||
<maximumlength>100</maximumlength>
|
||||
<typeofdata>V~M</typeofdata>
|
||||
<quickcreate>0</quickcreate>
|
||||
<quickcreatesequence></quickcreatesequence>
|
||||
<displaytype>1</displaytype>
|
||||
<info_type>BAS</info_type>
|
||||
<helpinfo><![CDATA[]]></helpinfo>
|
||||
<masseditable>1</masseditable>
|
||||
<picklistvalues>
|
||||
<picklistvalue>In Service</picklistvalue>
|
||||
<picklistvalue>Out-of-service</picklistvalue>
|
||||
</picklistvalues>
|
||||
</field>
|
||||
<field>
|
||||
<fieldname>tagnumber</fieldname>
|
||||
<uitype>2</uitype>
|
||||
<columnname>tagnumber</columnname>
|
||||
<tablename>vtiger_assets</tablename>
|
||||
<generatedtype>1</generatedtype>
|
||||
<fieldlabel>Tag Number</fieldlabel>
|
||||
<readonly>1</readonly>
|
||||
<presence>2</presence>
|
||||
<defaultvalue></defaultvalue>
|
||||
<sequence>8</sequence>
|
||||
<maximumlength>100</maximumlength>
|
||||
<typeofdata>V~O</typeofdata>
|
||||
<quickcreate>1</quickcreate>
|
||||
<quickcreatesequence></quickcreatesequence>
|
||||
<displaytype>1</displaytype>
|
||||
<info_type>BAS</info_type>
|
||||
<helpinfo><![CDATA[]]></helpinfo>
|
||||
<masseditable>1</masseditable>
|
||||
</field>
|
||||
<field>
|
||||
<fieldname>invoiceid</fieldname>
|
||||
<uitype>10</uitype>
|
||||
<columnname>invoiceid</columnname>
|
||||
<tablename>vtiger_assets</tablename>
|
||||
<generatedtype>1</generatedtype>
|
||||
<fieldlabel>Invoice Name</fieldlabel>
|
||||
<readonly>1</readonly>
|
||||
<presence>2</presence>
|
||||
<defaultvalue></defaultvalue>
|
||||
<sequence>9</sequence>
|
||||
<maximumlength>100</maximumlength>
|
||||
<typeofdata>V~O</typeofdata>
|
||||
<quickcreate>1</quickcreate>
|
||||
<quickcreatesequence></quickcreatesequence>
|
||||
<displaytype>1</displaytype>
|
||||
<info_type>BAS</info_type>
|
||||
<helpinfo><![CDATA[]]></helpinfo>
|
||||
<masseditable>1</masseditable>
|
||||
<relatedmodules>
|
||||
<relatedmodule>Invoice</relatedmodule>
|
||||
</relatedmodules>
|
||||
</field>
|
||||
<field>
|
||||
<fieldname>shippingmethod</fieldname>
|
||||
<uitype>2</uitype>
|
||||
<columnname>shippingmethod</columnname>
|
||||
<tablename>vtiger_assets</tablename>
|
||||
<generatedtype>1</generatedtype>
|
||||
<fieldlabel>Shipping Method</fieldlabel>
|
||||
<readonly>1</readonly>
|
||||
<presence>2</presence>
|
||||
<defaultvalue></defaultvalue>
|
||||
<sequence>10</sequence>
|
||||
<maximumlength>100</maximumlength>
|
||||
<typeofdata>V~O</typeofdata>
|
||||
<quickcreate>1</quickcreate>
|
||||
<quickcreatesequence></quickcreatesequence>
|
||||
<displaytype>1</displaytype>
|
||||
<info_type>BAS</info_type>
|
||||
<helpinfo><![CDATA[]]></helpinfo>
|
||||
<masseditable>1</masseditable>
|
||||
</field>
|
||||
<field>
|
||||
<fieldname>shippingtrackingnumber</fieldname>
|
||||
<uitype>2</uitype>
|
||||
<columnname>shippingtrackingnumber</columnname>
|
||||
<tablename>vtiger_assets</tablename>
|
||||
<generatedtype>1</generatedtype>
|
||||
<fieldlabel>Shipping Tracking Number</fieldlabel>
|
||||
<readonly>1</readonly>
|
||||
<presence>2</presence>
|
||||
<defaultvalue></defaultvalue>
|
||||
<sequence>11</sequence>
|
||||
<maximumlength>100</maximumlength>
|
||||
<typeofdata>V~O</typeofdata>
|
||||
<quickcreate>1</quickcreate>
|
||||
<quickcreatesequence></quickcreatesequence>
|
||||
<displaytype>1</displaytype>
|
||||
<info_type>BAS</info_type>
|
||||
<helpinfo><![CDATA[]]></helpinfo>
|
||||
<masseditable>1</masseditable>
|
||||
</field>
|
||||
<field>
|
||||
<fieldname>assigned_user_id</fieldname>
|
||||
<uitype>53</uitype>
|
||||
<columnname>smownerid</columnname>
|
||||
<tablename>vtiger_crmentity</tablename>
|
||||
<generatedtype>1</generatedtype>
|
||||
<fieldlabel>Assigned To</fieldlabel>
|
||||
<readonly>1</readonly>
|
||||
<presence>2</presence>
|
||||
<defaultvalue></defaultvalue>
|
||||
<sequence>4</sequence>
|
||||
<maximumlength>100</maximumlength>
|
||||
<typeofdata>V~M</typeofdata>
|
||||
<quickcreate>0</quickcreate>
|
||||
<quickcreatesequence>2</quickcreatesequence>
|
||||
<displaytype>1</displaytype>
|
||||
<info_type>BAS</info_type>
|
||||
<helpinfo><![CDATA[]]></helpinfo>
|
||||
<masseditable>1</masseditable>
|
||||
</field>
|
||||
<field>
|
||||
<fieldname>assetname</fieldname>
|
||||
<uitype>1</uitype>
|
||||
<columnname>assetname</columnname>
|
||||
<tablename>vtiger_assets</tablename>
|
||||
<generatedtype>1</generatedtype>
|
||||
<fieldlabel>Asset Name</fieldlabel>
|
||||
<readonly>1</readonly>
|
||||
<presence>0</presence>
|
||||
<defaultvalue></defaultvalue>
|
||||
<sequence>12</sequence>
|
||||
<maximumlength>100</maximumlength>
|
||||
<typeofdata>V~M</typeofdata>
|
||||
<quickcreate>0</quickcreate>
|
||||
<quickcreatesequence>6</quickcreatesequence>
|
||||
<displaytype>1</displaytype>
|
||||
<info_type>BAS</info_type>
|
||||
<helpinfo><![CDATA[]]></helpinfo>
|
||||
<masseditable>1</masseditable>
|
||||
<entityidentifier>
|
||||
<entityidfield>assetsid</entityidfield>
|
||||
<entityidcolumn>assetsid</entityidcolumn>
|
||||
</entityidentifier>
|
||||
</field>
|
||||
<field>
|
||||
<fieldname>account</fieldname>
|
||||
<uitype>10</uitype>
|
||||
<columnname>account</columnname>
|
||||
<tablename>vtiger_assets</tablename>
|
||||
<generatedtype>1</generatedtype>
|
||||
<fieldlabel>Customer Name</fieldlabel>
|
||||
<readonly>1</readonly>
|
||||
<presence>2</presence>
|
||||
<defaultvalue></defaultvalue>
|
||||
<sequence>13</sequence>
|
||||
<maximumlength>100</maximumlength>
|
||||
<typeofdata>V~M</typeofdata>
|
||||
<quickcreate>0</quickcreate>
|
||||
<quickcreatesequence></quickcreatesequence>
|
||||
<displaytype>1</displaytype>
|
||||
<info_type>BAS</info_type>
|
||||
<helpinfo><![CDATA[]]></helpinfo>
|
||||
<masseditable>1</masseditable>
|
||||
<relatedmodules>
|
||||
<relatedmodule>Accounts</relatedmodule>
|
||||
</relatedmodules>
|
||||
</field>
|
||||
<field>
|
||||
<fieldname>createdtime</fieldname>
|
||||
<uitype>70</uitype>
|
||||
<columnname>createdtime</columnname>
|
||||
<tablename>vtiger_crmentity</tablename>
|
||||
<generatedtype>1</generatedtype>
|
||||
<fieldlabel>Created Time</fieldlabel>
|
||||
<readonly>1</readonly>
|
||||
<presence>0</presence>
|
||||
<defaultvalue></defaultvalue>
|
||||
<sequence>14</sequence>
|
||||
<maximumlength>100</maximumlength>
|
||||
<typeofdata>T~O</typeofdata>
|
||||
<quickcreate>3</quickcreate>
|
||||
<quickcreatesequence></quickcreatesequence>
|
||||
<displaytype>2</displaytype>
|
||||
<info_type>BAS</info_type>
|
||||
<helpinfo><![CDATA[]]></helpinfo>
|
||||
<masseditable>0</masseditable>
|
||||
</field>
|
||||
<field>
|
||||
<fieldname>modifiedtime</fieldname>
|
||||
<uitype>70</uitype>
|
||||
<columnname>modifiedtime</columnname>
|
||||
<tablename>vtiger_crmentity</tablename>
|
||||
<generatedtype>1</generatedtype>
|
||||
<fieldlabel>Modified Time</fieldlabel>
|
||||
<readonly>1</readonly>
|
||||
<presence>0</presence>
|
||||
<defaultvalue></defaultvalue>
|
||||
<sequence>15</sequence>
|
||||
<maximumlength>100</maximumlength>
|
||||
<typeofdata>T~O</typeofdata>
|
||||
<quickcreate>3</quickcreate>
|
||||
<quickcreatesequence></quickcreatesequence>
|
||||
<displaytype>2</displaytype>
|
||||
<info_type>BAS</info_type>
|
||||
<helpinfo><![CDATA[]]></helpinfo>
|
||||
<masseditable>0</masseditable>
|
||||
</field>
|
||||
<field>
|
||||
<fieldname>modifiedby</fieldname>
|
||||
<uitype>52</uitype>
|
||||
<columnname>modifiedby</columnname>
|
||||
<tablename>vtiger_crmentity</tablename>
|
||||
<generatedtype>1</generatedtype>
|
||||
<fieldlabel>Last Modified By</fieldlabel>
|
||||
<readonly>1</readonly>
|
||||
<presence>0</presence>
|
||||
<defaultvalue></defaultvalue>
|
||||
<sequence>16</sequence>
|
||||
<maximumlength>100</maximumlength>
|
||||
<typeofdata>V~O</typeofdata>
|
||||
<quickcreate>3</quickcreate>
|
||||
<quickcreatesequence></quickcreatesequence>
|
||||
<displaytype>3</displaytype>
|
||||
<info_type>BAS</info_type>
|
||||
<helpinfo><![CDATA[]]></helpinfo>
|
||||
<masseditable>0</masseditable>
|
||||
</field>
|
||||
</fields>
|
||||
</block>
|
||||
<block>
|
||||
<label>LBL_CUSTOM_INFORMATION</label>
|
||||
</block>
|
||||
<block>
|
||||
<label>LBL_DESCRIPTION_INFORMATION</label>
|
||||
<fields>
|
||||
<field>
|
||||
<fieldname>description</fieldname>
|
||||
<uitype>19</uitype>
|
||||
<columnname>description</columnname>
|
||||
<tablename>vtiger_crmentity</tablename>
|
||||
<generatedtype>1</generatedtype>
|
||||
<fieldlabel>Notes</fieldlabel>
|
||||
<readonly>1</readonly>
|
||||
<presence>2</presence>
|
||||
<defaultvalue></defaultvalue>
|
||||
<sequence>1</sequence>
|
||||
<maximumlength>100</maximumlength>
|
||||
<typeofdata>V~O</typeofdata>
|
||||
<quickcreate>1</quickcreate>
|
||||
<quickcreatesequence></quickcreatesequence>
|
||||
<displaytype>1</displaytype>
|
||||
<info_type>BAS</info_type>
|
||||
<helpinfo><![CDATA[]]></helpinfo>
|
||||
<masseditable>1</masseditable>
|
||||
</field>
|
||||
</fields>
|
||||
</block>
|
||||
</blocks>
|
||||
<customviews>
|
||||
<customview>
|
||||
<viewname>All</viewname>
|
||||
<setdefault>true</setdefault>
|
||||
<setmetrics>false</setmetrics>
|
||||
<fields>
|
||||
<field>
|
||||
<fieldname>asset_no</fieldname>
|
||||
<columnindex>0</columnindex>
|
||||
</field>
|
||||
<field>
|
||||
<fieldname>assetname</fieldname>
|
||||
<columnindex>1</columnindex>
|
||||
</field>
|
||||
<field>
|
||||
<fieldname>account</fieldname>
|
||||
<columnindex>2</columnindex>
|
||||
</field>
|
||||
<field>
|
||||
<fieldname>product</fieldname>
|
||||
<columnindex>3</columnindex>
|
||||
</field>
|
||||
</fields>
|
||||
</customview>
|
||||
</customviews>
|
||||
<sharingaccess>
|
||||
<default>public_readwritedelete</default>
|
||||
</sharingaccess>
|
||||
<actions>
|
||||
<action>
|
||||
<name><![CDATA[Import]]></name>
|
||||
<status>enabled</status>
|
||||
</action>
|
||||
<action>
|
||||
<name><![CDATA[Export]]></name>
|
||||
<status>enabled</status>
|
||||
</action>
|
||||
<action>
|
||||
<name><![CDATA[DuplicatesHandling]]></name>
|
||||
<status>enabled</status>
|
||||
</action>
|
||||
</actions>
|
||||
<relatedlists>
|
||||
<relatedlist>
|
||||
<function>get_related_list</function>
|
||||
<label>HelpDesk</label>
|
||||
<sequence>1</sequence>
|
||||
<presence>0</presence>
|
||||
<actions>
|
||||
<action>ADD</action>
|
||||
<action>SELECT</action>
|
||||
</actions>
|
||||
<relatedmodule>HelpDesk</relatedmodule>
|
||||
</relatedlist>
|
||||
<relatedlist>
|
||||
<function>get_attachments</function>
|
||||
<label>Documents</label>
|
||||
<sequence>11</sequence>
|
||||
<presence>0</presence>
|
||||
<actions>
|
||||
<action>ADD</action>
|
||||
<action>SELECT</action>
|
||||
</actions>
|
||||
<relatedmodule>Documents</relatedmodule>
|
||||
</relatedlist>
|
||||
</relatedlists>
|
||||
</module>
|
|
@ -0,0 +1,341 @@
|
|||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
document.write("<script type='text/javascript' src='modules/Products/multifile.js'></"+"script>");
|
||||
document.write("<script type='text/javascript' src='include/js/Merge.js'></"+"script>");
|
||||
function updateListPrice(unitprice,fieldname, oSelect)
|
||||
{
|
||||
if(oSelect.checked == true)
|
||||
{
|
||||
document.getElementById(fieldname).style.visibility = 'visible';
|
||||
document.getElementById(fieldname).value = unitprice;
|
||||
}else
|
||||
{
|
||||
document.getElementById(fieldname).style.visibility = 'hidden';
|
||||
}
|
||||
}
|
||||
|
||||
function check4null(form)
|
||||
{
|
||||
var isError = false;
|
||||
var errorMessage = "";
|
||||
if (trim(form.productname.value) =='') {
|
||||
isError = true;
|
||||
errorMessage += "\n Product Name";
|
||||
form.productname.focus();
|
||||
}
|
||||
|
||||
if (isError == true) {
|
||||
alert(alert_arr.MISSING_REQUIRED_FIELDS + errorMessage);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function set_return(product_id, product_name) {
|
||||
if(document.getElementById('from_link').value != '') {
|
||||
window.opener.document.QcEditView.parent_name.value = product_name;
|
||||
window.opener.document.QcEditView.parent_id.value = product_id;
|
||||
} else {
|
||||
window.opener.document.EditView.parent_name.value = product_name;
|
||||
window.opener.document.EditView.parent_id.value = product_id;
|
||||
}
|
||||
}
|
||||
function set_return_specific(product_id, product_name) {
|
||||
//getOpenerObj used for DetailView
|
||||
|
||||
if(document.getElementById('from_link').value != '')
|
||||
{
|
||||
var fldName = window.opener.document.QcEditView.product_name;
|
||||
var fldId = window.opener.document.QcEditView.product_id;
|
||||
}else if(typeof(window.opener.document.DetailView) != 'undefined')
|
||||
{
|
||||
var fldName = window.opener.document.DetailView.product_name;
|
||||
var fldId = window.opener.document.DetailView.product_id;
|
||||
}else
|
||||
{
|
||||
var fldName = window.opener.document.EditView.product_name;
|
||||
var fldId = window.opener.document.EditView.product_id;
|
||||
}
|
||||
fldName.value = product_name;
|
||||
fldId.value = product_id;
|
||||
}
|
||||
|
||||
function set_return_formname_specific(formname,product_id, product_name) {
|
||||
window.opener.document.EditView1.product_name.value = product_name;
|
||||
window.opener.document.EditView1.product_id.value = product_id;
|
||||
}
|
||||
function add_data_to_relatedlist(entity_id,recordid) {
|
||||
|
||||
opener.document.location.href="index.php?module={RETURN_MODULE}&action=updateRelations&smodule={SMODULE}&destination_module=Products&entityid="+entity_id+"&parentid="+recordid;
|
||||
}
|
||||
|
||||
function set_return_inventory(product_id,product_name,unitprice,taxstr,curr_row,desc) {
|
||||
window.opener.document.EditView.elements["productName"+curr_row].value = product_name;
|
||||
window.opener.document.EditView.elements["hdnProductId"+curr_row].value = product_id;
|
||||
window.opener.document.EditView.elements["listPrice"+curr_row].value = unitprice;
|
||||
window.opener.document.EditView.elements["comment"+curr_row].value = desc;
|
||||
|
||||
// Apply decimal round-off to value
|
||||
if(!isNaN(parseFloat(unitprice))) unitprice = roundPriceValue(unitprice);
|
||||
window.opener.document.EditView.elements["listPrice"+curr_row].value = unitprice;
|
||||
|
||||
var tax_array = new Array();
|
||||
var tax_details = new Array();
|
||||
tax_array = taxstr.split(',');
|
||||
for(var i=0;i<tax_array.length;i++)
|
||||
{
|
||||
tax_details = tax_array[i].split('=');
|
||||
}
|
||||
|
||||
window.opener.document.EditView.elements["qty"+curr_row].focus()
|
||||
}
|
||||
|
||||
function set_return_inventory_po(product_id,product_name,unitprice,taxstr,curr_row,desc) {
|
||||
window.opener.document.EditView.elements["productName"+curr_row].value = product_name;
|
||||
window.opener.document.EditView.elements["hdnProductId"+curr_row].value = product_id;
|
||||
window.opener.document.EditView.elements["listPrice"+curr_row].value = unitprice;
|
||||
window.opener.document.EditView.elements["comment"+curr_row].value = desc;
|
||||
//getOpenerObj("unitPrice"+curr_row).innerHTML = unitprice;
|
||||
|
||||
// Apply decimal round-off to value
|
||||
if(!isNaN(parseFloat(unitprice))) unitprice = roundPriceValue(unitprice);
|
||||
window.opener.document.EditView.elements["listPrice"+curr_row].value = unitprice;
|
||||
|
||||
var tax_array = new Array();
|
||||
var tax_details = new Array();
|
||||
tax_array = taxstr.split(',');
|
||||
for(var i=0;i<tax_array.length;i++)
|
||||
{
|
||||
tax_details = tax_array[i].split('=');
|
||||
}
|
||||
|
||||
window.opener.document.EditView.elements["qty"+curr_row].focus()
|
||||
}
|
||||
|
||||
function InventorySelectAllServices(mod,z,image_pth)
|
||||
{
|
||||
if(document.selectall.selected_id != undefined)
|
||||
{
|
||||
var x = document.selectall.selected_id.length;
|
||||
var y=0;
|
||||
idstring = "";
|
||||
namestr = "";
|
||||
var action_str="";
|
||||
if ( x == undefined) {
|
||||
if (document.selectall.selected_id.checked) {
|
||||
idstring = document.selectall.selected_id.value;
|
||||
c = document.selectall.selected_id.value;
|
||||
var prod_array = JSON.parse($('popup_product_'+c).attributes['vt_prod_arr'].nodeValue);
|
||||
var prod_id = prod_array['entityid'];
|
||||
var prod_name = prod_array['prodname'];
|
||||
var unit_price = prod_array['unitprice'];
|
||||
var taxstring = prod_array['taxstring'];
|
||||
var desc = prod_array['desc'];
|
||||
var row_id = prod_array['rowid'];
|
||||
set_return_inventory(prod_id,prod_name,unit_price,taxstring,parseInt(row_id),desc);
|
||||
y=1;
|
||||
} else {
|
||||
alert(alert_arr.SELECT);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
y=0;
|
||||
for(i = 0; i < x ; i++) {
|
||||
if(document.selectall.selected_id[i].checked) {
|
||||
idstring = document.selectall.selected_id[i].value+";"+idstring;
|
||||
c = document.selectall.selected_id[i].value;
|
||||
var prod_array = JSON.parse($('popup_product_'+c).attributes['vt_prod_arr'].nodeValue);
|
||||
var prod_id = prod_array['entityid'];
|
||||
var prod_name = prod_array['prodname'];
|
||||
var unit_price = prod_array['unitprice'];
|
||||
var taxstring = prod_array['taxstring'];
|
||||
var desc = prod_array['desc'];
|
||||
if(y>0) {
|
||||
var row_id = window.opener.fnAddProductRow(mod,image_pth);
|
||||
} else {
|
||||
var row_id = prod_array['rowid'];
|
||||
}
|
||||
|
||||
set_return_inventory(prod_id,prod_name,unit_price,taxstring,parseInt(row_id),desc);
|
||||
y=y+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (y != 0) {
|
||||
document.selectall.idlist.value=idstring;
|
||||
return true;
|
||||
} else {
|
||||
alert(alert_arr.SELECT);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function set_return_product(product_id, product_name) {
|
||||
if(document.getElementById('from_link').value != '') {
|
||||
window.opener.document.QcEditView.parent_name.value = product_name;
|
||||
window.opener.document.QcEditView.parent_id.value = product_id;
|
||||
} else {
|
||||
window.opener.document.EditView.product_name.value = product_name;
|
||||
window.opener.document.EditView.product_id.value = product_id;
|
||||
}
|
||||
}
|
||||
function getImageListBody() {
|
||||
if (browser_ie) {
|
||||
var ImageListBody=getObj("ImageList")
|
||||
} else if (browser_nn4 || browser_nn6) {
|
||||
if (getObj("ImageList").childNodes.item(0).tagName=="TABLE") {
|
||||
var ImageListBody=getObj("ImageList")
|
||||
} else {
|
||||
var ImageListBody=getObj("ImageList")
|
||||
}
|
||||
}
|
||||
return ImageListBody;
|
||||
}
|
||||
|
||||
// Function to Round off the Price Value
|
||||
function roundPriceValue(val) {
|
||||
val = parseFloat(val);
|
||||
val = Math.round(val*100)/100;
|
||||
val = val.toString();
|
||||
|
||||
if (val.indexOf(".")<0) {
|
||||
val+=".00"
|
||||
} else {
|
||||
var dec=val.substring(val.indexOf(".")+1,val.length)
|
||||
if (dec.length>2)
|
||||
val=val.substring(0,val.indexOf("."))+"."+dec.substring(0,2)
|
||||
else if (dec.length==1)
|
||||
val=val+"0"
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
// End
|
||||
|
||||
function fnAddServiceRow(module,image_path){
|
||||
rowCnt++;
|
||||
|
||||
var tableName = document.getElementById('proTab');
|
||||
var prev = tableName.rows.length;
|
||||
var count = eval(prev)-1;//As the table has two headers, we should reduce the count
|
||||
var row = tableName.insertRow(prev);
|
||||
row.id = "row"+count;
|
||||
row.style.verticalAlign = "top";
|
||||
|
||||
var colone = row.insertCell(0);
|
||||
var coltwo = row.insertCell(1);
|
||||
if(module == "PurchaseOrder"){
|
||||
var colfour = row.insertCell(2);
|
||||
var colfive = row.insertCell(3);
|
||||
var colsix = row.insertCell(4);
|
||||
var colseven = row.insertCell(5);
|
||||
}
|
||||
else{
|
||||
var colthree = row.insertCell(2);
|
||||
var colfour = row.insertCell(3);
|
||||
var colfive = row.insertCell(4);
|
||||
var colsix = row.insertCell(5);
|
||||
var colseven = row.insertCell(6);
|
||||
}
|
||||
/* Product Re-Ordering Feature Code Addition Starts */
|
||||
iMax = tableName.rows.length;
|
||||
for(iCount=1;iCount<=iMax-3;iCount++)
|
||||
{
|
||||
if(document.getElementById("row"+iCount) && document.getElementById("row"+iCount).style.display != 'none')
|
||||
{
|
||||
iPrevRowIndex = iCount;
|
||||
}
|
||||
}
|
||||
iPrevCount = eval(iPrevRowIndex);
|
||||
var oPrevRow = tableName.rows[iPrevRowIndex+1];
|
||||
var delete_row_count=count;
|
||||
/* Product Re-Ordering Feature Code Addition ends */
|
||||
|
||||
|
||||
//Delete link
|
||||
colone.className = "crmTableRow small";
|
||||
colone.id = row.id+"_col1";
|
||||
colone.innerHTML='<img src="themes/images/delete.gif" border="0" onclick="deleteRow(\''+module+'\','+count+',\''+image_path+'\')"><input id="deleted'+count+'" name="deleted'+count+'" type="hidden" value="0"><br/><br/> <a href="javascript:moveUpDown(\'UP\',\''+module+'\','+count+')" title="Move Upward"><img src="themes/images/up_layout.gif" border="0"></a>';
|
||||
/* Product Re-Ordering Feature Code Addition Starts */
|
||||
if(iPrevCount != 1)
|
||||
{
|
||||
oPrevRow.cells[0].innerHTML = '<img src="themes/images/delete.gif" border="0" onclick="deleteRow(\''+module+'\','+iPrevCount+')"><input id="deleted'+iPrevCount+'" name="deleted'+iPrevCount+'" type="hidden" value="0"><br/><br/> <a href="javascript:moveUpDown(\'UP\',\''+module+'\','+iPrevCount+')" title="Move Upward"><img src="themes/images/up_layout.gif" border="0"></a> <a href="javascript:moveUpDown(\'DOWN\',\''+module+'\','+iPrevCount+')" title="Move Downward"><img src="themes/images/down_layout.gif" border="0"></a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
oPrevRow.cells[0].innerHTML = '<input id="deleted'+iPrevCount+'" name="deleted'+iPrevCount+'" type="hidden" value="0"><br/><br/><a href="javascript:moveUpDown(\'DOWN\',\''+module+'\','+iPrevCount+')" title="Move Downward"><img src="themes/images/down_layout.gif" border="0"></a>';
|
||||
}
|
||||
/* Product Re-Ordering Feature Code Addition ends */
|
||||
|
||||
//Product Name with Popup image to select product
|
||||
coltwo.className = "crmTableRow small"
|
||||
coltwo.innerHTML= '<table border="0" cellpadding="1" cellspacing="0" width="100%"><tr><td class="small"><input id="productName'+count+'" name="productName'+count+'" class="small" style="width: 70%;" value="" readonly="readonly" type="text" />'+
|
||||
'<input id="hdnProductId'+count+'" name="hdnProductId'+count+'" value="" type="hidden" /><input type="hidden" id="lineItemType'+count+'" name="lineItemType'+count+'" value="Services" />'+
|
||||
' <img id="searchIcon'+count+'" title="Services" src="themes/images/services.gif" style="cursor: pointer;" onclick="servicePickList(this,\''+module+'\','+count+')" align="absmiddle">'+
|
||||
'</td></tr><tr><td class="small"><input type="hidden" value="" id="subproduct_ids'+count+'" name="subproduct_ids'+count+'" /><span id="subprod_names'+count+'" name="subprod_names'+count+'" style="color:#C0C0C0;font-style:italic;"> </span>'+
|
||||
'</td></tr><tr><td class="small" id="setComment'+count+'"><textarea id="comment'+count+'" name="comment'+count+'" class=small style="width:70%;height:40px"></textarea><img src="themes/images/clear_field.gif" onClick="getObj(\'comment'+count+'\').value=\'\'"; style="cursor:pointer;" /></td></tr></tbody></table>';
|
||||
|
||||
//Quantity In Stock - only for SO, Quotes and Invoice
|
||||
if(module != "PurchaseOrder"){
|
||||
colthree.className = "crmTableRow small"
|
||||
colthree.innerHTML='<span id="qtyInStock'+count+'">NA</span>';
|
||||
}
|
||||
|
||||
//Quantity
|
||||
var temp='';
|
||||
colfour.className = "crmTableRow small"
|
||||
temp='<input id="qty'+count+'" name="qty'+count+'" type="text" class="small " style="width:50px" onfocus="this.className=\'detailedViewTextBoxOn\'" onBlur="settotalnoofrows(); calcTotal(); loadTaxes_Ajax('+count+');';
|
||||
temp+='" onChange="setDiscount(this,'+count+')" value=""/><br>';
|
||||
colfour.innerHTML=temp;
|
||||
//List Price with Discount, Total after Discount and Tax labels
|
||||
colfive.className = "crmTableRow small"
|
||||
colfive.innerHTML='<table width="100%" cellpadding="0" cellspacing="0"><tr><td align="right"><input id="listPrice'+count+'" name="listPrice'+count+'" value="0.00" type="text" class="small " style="width:70px" onBlur="calcTotal();setDiscount(this,'+count+');callTaxCalc('+count+'); calcTotal();"/> <img src="themes/images/pricebook.gif" onclick="priceBookPickList(this,'+count+')"></td></tr><tr><td align="right" style="padding:5px;" nowrap> (-) <b><a href="javascript:doNothing();" onClick="displayCoords(this,\'discount_div'+count+'\',\'discount\','+count+')" >'+product_labelarr.DISCOUNT+'</a> : </b><div class=\"discountUI\" id=\"discount_div'+count+'"><input type="hidden" id="discount_type'+count+'" name="discount_type'+count+'" value=""><table width="100%" border="0" cellpadding="5" cellspacing="0" class="small"><tr><td id="discount_div_title'+count+'" nowrap align="left" ></td><td align="right"><img src="themes/images/close.gif" border="0" onClick="fnHidePopDiv(\'discount_div'+count+'\')" style="cursor:pointer;"></td></tr><tr><td align="left" class="lineOnTop"><input type="radio" name="discount'+count+'" checked onclick="setDiscount(this,'+count+'); callTaxCalc('+count+');calcTotal();"> '+product_labelarr.ZERO_DISCOUNT+'</td><td class="lineOnTop"> </td></tr><tr><td align="left"><input type="radio" name="discount'+count+'" onclick="setDiscount(this,'+count+'); callTaxCalc('+count+');calcTotal();"> % '+product_labelarr.PERCENT_OF_PRICE+' </td><td align="right"><input type="text" class="small" size="2" id="discount_percentage'+count+'" name="discount_percentage'+count+'" value="0" style="visibility:hidden" onBlur="setDiscount(this,'+count+'); callTaxCalc('+count+');calcTotal();"> %</td></tr><tr><td align="left" nowrap><input type="radio" name="discount'+count+'" onclick="setDiscount(this,'+count+'); callTaxCalc('+count+');calcTotal();"> '+product_labelarr.DIRECT_PRICE_REDUCTION+'</td><td align="right"><input type="text" id="discount_amount'+count+'" name="discount_amount'+count+'" size="5" value="0" style="visibility:hidden" onBlur="setDiscount(this,'+count+'); callTaxCalc('+count+');calcTotal();"></td></tr></table></div></td></tr><tr> <td align="right" style="padding:5px;" nowrap><b>'+product_labelarr.TOTAL_AFTER_DISCOUNT+' :</b></td></tr><tr id="individual_tax_row'+count+'" class="TaxShow"><td align="right" style="padding:5px;" nowrap>(+) <b><a href="javascript:doNothing();" onClick="displayCoords(this,\'tax_div'+count+'\',\'tax\','+count+')" >'+product_labelarr.TAX+' </a> : </b><div class="discountUI" id="tax_div'+count+'"></div></td></tr></table> ';
|
||||
|
||||
//Total and Discount, Total after Discount and Tax details
|
||||
colsix.className = "crmTableRow small"
|
||||
colsix.innerHTML = '<table width="100%" cellpadding="5" cellspacing="0"><tr><td id="productTotal'+count+'" align="right"> </td></tr><tr><td id="discountTotal'+count+'" align="right">0.00</td></tr><tr><td id="totalAfterDiscount'+count+'" align="right"> </td></tr><tr><td id="taxTotal'+count+'" align="right">0.00</td></tr></table>';
|
||||
|
||||
//Net Price
|
||||
colseven.className = "crmTableRow small";
|
||||
colseven.align = "right";
|
||||
colseven.style.verticalAlign = "bottom";
|
||||
colseven.innerHTML = '<span id="netPrice'+count+'"><b> </b></span>';
|
||||
|
||||
//This is to show or hide the individual or group tax
|
||||
decideTaxDiv();
|
||||
|
||||
calcTotal();
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
function servicePickList(currObj,module, row_no) {
|
||||
var trObj=currObj.parentNode.parentNode
|
||||
|
||||
var rowId = row_no;
|
||||
var currentRowId = parseInt(currObj.id.match(/([0-9]+)$/)[1]);
|
||||
|
||||
// If we have mismatching rowId and currentRowId, it is due swapping of rows
|
||||
if(rowId != currentRowId) {
|
||||
rowId = currentRowId;
|
||||
}
|
||||
|
||||
var currencyid = document.getElementById("inventory_currency").value;
|
||||
|
||||
popuptype = 'inventory_service';
|
||||
var record_id = '';
|
||||
if(document.getElementsByName("account_id").length != 0)
|
||||
record_id= document.EditView.account_id.value;
|
||||
if(record_id != '')
|
||||
window.open("index.php?module=Services&action=Popup&html=Popup_picker&select=enable&form=HelpDeskEditView&popuptype="+popuptype+"&curr_row="+rowId+"&relmod_id="+record_id+"&parent_module=Accounts&return_module="+module+"¤cyid="+currencyid,"productWin","width=640,height=600,resizable=0,scrollbars=0,status=1,top=150,left=200");
|
||||
else
|
||||
window.open("index.php?module=Services&action=Popup&html=Popup_picker&select=enable&form=HelpDeskEditView&popuptype="+popuptype+"&curr_row="+rowId+"&return_module="+module+"¤cyid="+currencyid,"productWin","width=640,height=600,resizable=0,scrollbars=0,status=1,top=150,left=200");
|
||||
}
|
|
@ -0,0 +1,422 @@
|
|||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once('data/CRMEntity.php');
|
||||
require_once('data/Tracker.php');
|
||||
|
||||
class Assets extends CRMEntity {
|
||||
var $db, $log; // Used in class functions of CRMEntity
|
||||
|
||||
var $table_name = 'vtiger_assets';
|
||||
var $table_index= 'assetsid';
|
||||
var $column_fields = Array();
|
||||
|
||||
/** Indicator if this is a custom module or standard module */
|
||||
var $IsCustomModule = true;
|
||||
|
||||
/**
|
||||
* Mandatory table for supporting custom fields.
|
||||
*/
|
||||
var $customFieldTable = Array('vtiger_assetscf', 'assetsid');
|
||||
|
||||
/**
|
||||
* Mandatory for Saving, Include tables related to this module.
|
||||
*/
|
||||
var $tab_name = Array('vtiger_crmentity','vtiger_assets','vtiger_assetscf');
|
||||
|
||||
/**
|
||||
* Mandatory for Saving, Include tablename and tablekey columnname here.
|
||||
*/
|
||||
var $tab_name_index = Array(
|
||||
'vtiger_crmentity'=>'crmid',
|
||||
'vtiger_assets'=>'assetsid',
|
||||
'vtiger_assetscf'=>'assetsid');
|
||||
|
||||
/**
|
||||
* Mandatory for Listing (Related listview)
|
||||
*/
|
||||
var $list_fields = Array(
|
||||
/* Format: Field Label => Array(tablename, columnname) */
|
||||
// tablename should not have prefix 'vtiger_'
|
||||
'Asset No'=>Array('assets'=>'asset_no'),
|
||||
'Asset Name'=>Array('assets'=>'assetname'),
|
||||
'Customer Name'=>Array('account'=>'account'),
|
||||
'Product Name'=>Array('products'=>'product'),
|
||||
);
|
||||
var $list_fields_name = Array(
|
||||
/* Format: Field Label => fieldname */
|
||||
'Asset No'=>'asset_no',
|
||||
'Asset Name'=>'assetname',
|
||||
'Customer Name'=>'account',
|
||||
'Product Name'=>'product',
|
||||
);
|
||||
|
||||
// Make the field link to detail view
|
||||
var $list_link_field= 'assetname';
|
||||
|
||||
// For Popup listview and UI type support
|
||||
var $search_fields = Array(
|
||||
/* Format: Field Label => Array(tablename, columnname) */
|
||||
// tablename should not have prefix 'vtiger_'
|
||||
'Asset No'=>Array('assets'=>'asset_no'),
|
||||
'Asset Name'=>Array('assets'=>'assetname'),
|
||||
'Customer Name'=>Array('account'=>'account'),
|
||||
'Product Name'=>Array('products'=>'product')
|
||||
);
|
||||
var $search_fields_name = Array(
|
||||
/* Format: Field Label => fieldname */
|
||||
'Asset No'=>'asset_no',
|
||||
'Asset Name'=>'assetname',
|
||||
'Customer Name'=>'account',
|
||||
'Product Name'=>'product'
|
||||
);
|
||||
|
||||
// For Popup window record selection
|
||||
var $popup_fields = Array ('assetname','account','product');
|
||||
|
||||
// Placeholder for sort fields - All the fields will be initialized for Sorting through initSortFields
|
||||
var $sortby_fields = Array();
|
||||
|
||||
// For Alphabetical search
|
||||
var $def_basicsearch_col = 'assetname';
|
||||
|
||||
// Required Information for enabling Import feature
|
||||
var $required_fields = Array('assetname'=>1);
|
||||
|
||||
// Used when enabling/disabling the mandatory fields for the module.
|
||||
// Refers to vtiger_field.fieldname values.
|
||||
var $mandatory_fields = Array('assetname', 'product');
|
||||
|
||||
// Callback function list during Importing
|
||||
var $special_functions = Array('set_import_assigned_user');
|
||||
|
||||
var $default_order_by = 'assetname';
|
||||
var $default_sort_order='ASC';
|
||||
|
||||
var $unit_price;
|
||||
|
||||
/** Constructor which will set the column_fields in this object
|
||||
*/
|
||||
function __construct() {
|
||||
global $log;
|
||||
$this->column_fields = getColumnFields('Assets');
|
||||
$this->db = PearDatabase::getInstance();
|
||||
$this->log = $log;
|
||||
}
|
||||
|
||||
function save_module($module){
|
||||
//module specific save
|
||||
}
|
||||
|
||||
/**
|
||||
* Return query to use based on given modulename, fieldname
|
||||
* Useful to handle specific case handling for Popup
|
||||
*/
|
||||
function getQueryByModuleField($module, $fieldname, $srcrecord) {
|
||||
// $srcrecord could be empty
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list view query.
|
||||
*/
|
||||
function getListQuery($module, $where='') {
|
||||
$query = "SELECT vtiger_crmentity.*, $this->table_name.*";
|
||||
|
||||
// Select Custom Field Table Columns if present
|
||||
if(!empty($this->customFieldTable)) $query .= ", " . $this->customFieldTable[0] . ".* ";
|
||||
|
||||
$query .= " FROM $this->table_name";
|
||||
|
||||
$query .= " INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = $this->table_name.$this->table_index";
|
||||
|
||||
// Consider custom table join as well.
|
||||
if(!empty($this->customFieldTable)) {
|
||||
$query .= " INNER JOIN ".$this->customFieldTable[0]." ON ".$this->customFieldTable[0].'.'.$this->customFieldTable[1] .
|
||||
" = $this->table_name.$this->table_index";
|
||||
}
|
||||
$query .= " LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid";
|
||||
$query .= " LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
|
||||
|
||||
|
||||
$linkedModulesQuery = $this->db->pquery("SELECT distinct fieldname, columnname, relmodule FROM vtiger_field" .
|
||||
" INNER JOIN vtiger_fieldmodulerel ON vtiger_fieldmodulerel.fieldid = vtiger_field.fieldid" .
|
||||
" WHERE uitype='10' AND vtiger_fieldmodulerel.module=?", array($module));
|
||||
$linkedFieldsCount = $this->db->num_rows($linkedModulesQuery);
|
||||
|
||||
for($i=0; $i<$linkedFieldsCount; $i++) {
|
||||
$related_module = $this->db->query_result($linkedModulesQuery, $i, 'relmodule');
|
||||
$fieldname = $this->db->query_result($linkedModulesQuery, $i, 'fieldname');
|
||||
$columnname = $this->db->query_result($linkedModulesQuery, $i, 'columnname');
|
||||
|
||||
$other = CRMEntity::getInstance($related_module);
|
||||
vtlib_setup_modulevars($related_module, $other);
|
||||
|
||||
$query .= " LEFT JOIN $other->table_name ON $other->table_name.$other->table_index = $this->table_name.$columnname";
|
||||
}
|
||||
|
||||
$query .= " WHERE vtiger_crmentity.deleted = 0 ".$where;
|
||||
$query .= $this->getListViewSecurityParameter($module);
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply security restriction (sharing privilege) query part for List view.
|
||||
*/
|
||||
function getListViewSecurityParameter($module) {
|
||||
global $current_user;
|
||||
require('user_privileges/user_privileges_'.$current_user->id.'.php');
|
||||
require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
|
||||
|
||||
$sec_query = '';
|
||||
$tabid = getTabid($module);
|
||||
|
||||
if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1
|
||||
&& $defaultOrgSharingPermission[$tabid] == 3) {
|
||||
|
||||
$sec_query .= " AND (vtiger_crmentity.smownerid in($current_user->id) OR vtiger_crmentity.smownerid IN
|
||||
(
|
||||
SELECT vtiger_user2role.userid FROM vtiger_user2role
|
||||
INNER JOIN vtiger_users ON vtiger_users.id=vtiger_user2role.userid
|
||||
INNER JOIN vtiger_role ON vtiger_role.roleid=vtiger_user2role.roleid
|
||||
WHERE vtiger_role.parentrole LIKE '".$current_user_parent_role_seq."::%'
|
||||
)
|
||||
OR vtiger_crmentity.smownerid IN
|
||||
(
|
||||
SELECT shareduserid FROM vtiger_tmp_read_user_sharing_per
|
||||
WHERE userid=".$current_user->id." AND tabid=".$tabid."
|
||||
)
|
||||
OR
|
||||
(";
|
||||
|
||||
// Build the query based on the group association of current user.
|
||||
if(sizeof($current_user_groups) > 0) {
|
||||
$sec_query .= " vtiger_groups.groupid IN (". implode(",", $current_user_groups) .") OR ";
|
||||
}
|
||||
$sec_query .= " vtiger_groups.groupid IN
|
||||
(
|
||||
SELECT vtiger_tmp_read_group_sharing_per.sharedgroupid
|
||||
FROM vtiger_tmp_read_group_sharing_per
|
||||
WHERE userid=".$current_user->id." and tabid=".$tabid."
|
||||
)";
|
||||
$sec_query .= ")
|
||||
)";
|
||||
}
|
||||
return $sec_query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create query to export the records.
|
||||
*/
|
||||
function create_export_query($where)
|
||||
{
|
||||
global $current_user;
|
||||
$thismodule = $_REQUEST['module'];
|
||||
|
||||
include("include/utils/ExportUtils.php");
|
||||
|
||||
//To get the Permitted fields query and the permitted fields list
|
||||
$sql = getPermittedFieldsQuery($thismodule, "detail_view");
|
||||
|
||||
$fields_list = getFieldsListFromQuery($sql);
|
||||
|
||||
$query = "SELECT $fields_list, vtiger_users.user_name AS user_name
|
||||
FROM vtiger_crmentity INNER JOIN $this->table_name ON vtiger_crmentity.crmid=$this->table_name.$this->table_index";
|
||||
|
||||
if(!empty($this->customFieldTable)) {
|
||||
$query .= " INNER JOIN ".$this->customFieldTable[0]." ON ".$this->customFieldTable[0].'.'.$this->customFieldTable[1] .
|
||||
" = $this->table_name.$this->table_index";
|
||||
}
|
||||
|
||||
$query .= " LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
|
||||
$query .= " LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid = vtiger_users.id and vtiger_users.status='Active'";
|
||||
|
||||
$where_auto = " vtiger_crmentity.deleted=0";
|
||||
|
||||
if($where != '') $query .= " WHERE ($where) AND $where_auto";
|
||||
else $query .= " WHERE $where_auto";
|
||||
|
||||
require('user_privileges/user_privileges_'.$current_user->id.'.php');
|
||||
require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
|
||||
|
||||
// Security Check for Field Access
|
||||
if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[getTabid('Assets')] == 3)
|
||||
{
|
||||
//Added security check to get the permitted records only
|
||||
$query = $query." ".getListViewSecurityParameter($thismodule);
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform the value while exporting
|
||||
*/
|
||||
function transform_export_value($key, $value) {
|
||||
if($key == 'owner') return getOwnerName($value);
|
||||
return parent::transform_export_value($key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function which will give the basic query to find duplicates
|
||||
*/
|
||||
function getDuplicatesQuery($module,$table_cols,$field_values,$ui_type_arr,$select_cols='') {
|
||||
$select_clause = "SELECT ". $this->table_name .".".$this->table_index ." AS recordid, vtiger_users_last_import.deleted,".$table_cols;
|
||||
|
||||
// Select Custom Field Table Columns if present
|
||||
if(isset($this->customFieldTable)) $query .= ", " . $this->customFieldTable[0] . ".* ";
|
||||
|
||||
$from_clause = " FROM $this->table_name";
|
||||
|
||||
$from_clause .= " INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = $this->table_name.$this->table_index";
|
||||
|
||||
// Consider custom table join as well.
|
||||
if(isset($this->customFieldTable)) {
|
||||
$from_clause .= " INNER JOIN ".$this->customFieldTable[0]." ON ".$this->customFieldTable[0].'.'.$this->customFieldTable[1] .
|
||||
" = $this->table_name.$this->table_index";
|
||||
}
|
||||
$from_clause .= " LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid
|
||||
LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
|
||||
|
||||
$where_clause = " WHERE vtiger_crmentity.deleted = 0";
|
||||
$where_clause .= $this->getListViewSecurityParameter($module);
|
||||
|
||||
if (isset($select_cols) && trim($select_cols) != '') {
|
||||
$sub_query = "SELECT $select_cols FROM $this->table_name AS t " .
|
||||
" INNER JOIN vtiger_crmentity AS crm ON crm.crmid = t.".$this->table_index;
|
||||
// Consider custom table join as well.
|
||||
if(isset($this->customFieldTable)) {
|
||||
$sub_query .= " INNER JOIN ".$this->customFieldTable[0]." tcf ON tcf.".$this->customFieldTable[1]." = t.$this->table_index";
|
||||
}
|
||||
$sub_query .= " WHERE crm.deleted=0 GROUP BY $select_cols HAVING COUNT(*)>1";
|
||||
} else {
|
||||
$sub_query = "SELECT $table_cols $from_clause $where_clause GROUP BY $table_cols HAVING COUNT(*)>1";
|
||||
}
|
||||
|
||||
|
||||
$query = $select_clause . $from_clause .
|
||||
" LEFT JOIN vtiger_users_last_import ON vtiger_users_last_import.bean_id=" . $this->table_name .".".$this->table_index .
|
||||
" INNER JOIN (" . $sub_query . ") AS temp ON ".get_on_clause($field_values,$ui_type_arr,$module) .
|
||||
$where_clause .
|
||||
" ORDER BY $table_cols,". $this->table_name .".".$this->table_index ." ASC";
|
||||
|
||||
return $query;
|
||||
}
|
||||
/**
|
||||
* Handle saving related module information.
|
||||
* NOTE: This function has been added to CRMEntity (base class).
|
||||
* You can override the behavior by re-defining it here.
|
||||
*/
|
||||
// function save_related_module($module, $crmid, $with_module, $with_crmid) { }
|
||||
|
||||
/**
|
||||
* Handle deleting related module information.
|
||||
* NOTE: This function has been added to CRMEntity (base class).
|
||||
* You can override the behavior by re-defining it here.
|
||||
*/
|
||||
//function delete_related_module($module, $crmid, $with_module, $with_crmid) { }
|
||||
|
||||
/**
|
||||
* Handle getting related list information.
|
||||
* NOTE: This function has been added to CRMEntity (base class).
|
||||
* You can override the behavior by re-defining it here.
|
||||
*/
|
||||
//function get_related_list($id, $cur_tab_id, $rel_tab_id, $actions=false) { }
|
||||
|
||||
|
||||
/*
|
||||
* Function to get the primary query part of a report
|
||||
* @param - $module primary module name
|
||||
* returns the query string formed on fetching the related data for report for secondary module
|
||||
*/
|
||||
// function generateReportsQuery($module){ }
|
||||
|
||||
/*
|
||||
* Function to get the secondary query part of a report
|
||||
* @param - $module primary module name
|
||||
* @param - $secmodule secondary module name
|
||||
* returns the query string formed on fetching the related data for report for secondary module
|
||||
*/
|
||||
// function generateReportsSecQuery($module,$secmodule){ }
|
||||
|
||||
// Function to unlink all the dependent entities of the given Entity by Id
|
||||
function unlinkDependencies($module, $id) {
|
||||
global $log;
|
||||
parent::unlinkDependencies($module, $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked when special actions are performed on the module.
|
||||
* @param String Module name
|
||||
* @param String Event Type
|
||||
*/
|
||||
function vtlib_handler($moduleName, $eventType) {
|
||||
require_once('include/utils/utils.php');
|
||||
global $adb;
|
||||
|
||||
if($eventType == 'module.postinstall') {
|
||||
//Add Assets Module to Customer Portal
|
||||
global $adb;
|
||||
|
||||
$this->addModuleToCustomerPortal();
|
||||
|
||||
include_once('vtlib/Vtiger/Module.php');
|
||||
|
||||
// Mark the module as Standard module
|
||||
$adb->pquery('UPDATE vtiger_tab SET customized=0 WHERE name=?', array($moduleName));
|
||||
|
||||
//adds sharing accsess
|
||||
$AssetsModule = Vtiger_Module::getInstance('Assets');
|
||||
Vtiger_Access::setDefaultSharing($AssetsModule);
|
||||
|
||||
//Showing Assets module in the related modules in the More Information Tab
|
||||
$assetInstance = Vtiger_Module::getInstance('Assets');
|
||||
$assetLabel = 'Assets';
|
||||
|
||||
$accountInstance = Vtiger_Module::getInstance('Accounts');
|
||||
$accountInstance->setRelatedlist($assetInstance,$assetLabel,array(ADD),'get_dependents_list');
|
||||
|
||||
$productInstance = Vtiger_Module::getInstance('Products');
|
||||
$productInstance->setRelatedlist($assetInstance,$assetLabel,array(ADD),'get_dependents_list');
|
||||
|
||||
$InvoiceInstance = Vtiger_Module::getInstance('Invoice');
|
||||
$InvoiceInstance->setRelatedlist($assetInstance,$assetLabel,array(ADD),'get_dependents_list');
|
||||
|
||||
} else if($eventType == 'module.disabled') {
|
||||
// TODO Handle actions when this module is disabled.
|
||||
} else if($eventType == 'module.enabled') {
|
||||
// TODO Handle actions when this module is enabled.
|
||||
} else if($eventType == 'module.preuninstall') {
|
||||
// TODO Handle actions when this module is about to be deleted.
|
||||
} else if($eventType == 'module.preupdate') {
|
||||
// TODO Handle actions before this module is updated.
|
||||
} else if($eventType == 'module.postupdate') {
|
||||
$this->addModuleToCustomerPortal();
|
||||
}
|
||||
}
|
||||
|
||||
function addModuleToCustomerPortal() {
|
||||
$adb = PearDatabase::getInstance();
|
||||
|
||||
$assetsResult = $adb->pquery('SELECT tabid FROM vtiger_tab WHERE name=?', array('Assets'));
|
||||
$assetsTabId = $adb->query_result($assetsResult, 0, 'tabid');
|
||||
if(getTabid('CustomerPortal') && $assetsTabId) {
|
||||
$checkAlreadyExists = $adb->pquery('SELECT 1 FROM vtiger_customerportal_tabs WHERE tabid=?', array($assetsTabId));
|
||||
if($checkAlreadyExists && $adb->num_rows($checkAlreadyExists) < 1) {
|
||||
$maxSequenceQuery = $adb->query("SELECT max(sequence) as maxsequence FROM vtiger_customerportal_tabs");
|
||||
$maxSequence = $adb->query_result($maxSequenceQuery, 0, 'maxsequence');
|
||||
$nextSequence = $maxSequence+1;
|
||||
$adb->query("INSERT INTO vtiger_customerportal_tabs(tabid,visible,sequence) VALUES ($assetsTabId,1,$nextSequence)");
|
||||
}
|
||||
$checkAlreadyExists = $adb->pquery('SELECT 1 FROM vtiger_customerportal_prefs WHERE tabid=?', array($assetsTabId));
|
||||
if($checkAlreadyExists && $adb->num_rows($checkAlreadyExists) < 1) {
|
||||
$adb->query("INSERT INTO vtiger_customerportal_prefs(tabid,prefkey,prefvalue) VALUES ($assetsTabId,'showrelatedinfo',1)");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once('include/Ajax/CommonAjax.php');
|
||||
?>
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once('Smarty_setup.php');
|
||||
require_once('user_privileges/default_module_view.php');
|
||||
|
||||
global $mod_strings, $app_strings, $currentModule, $current_user, $theme, $singlepane_view;
|
||||
|
||||
$category = getParentTab();
|
||||
$action = vtlib_purify($_REQUEST['action']);
|
||||
$record = vtlib_purify($_REQUEST['record']);
|
||||
$isduplicate = vtlib_purify($_REQUEST['isDuplicate']);
|
||||
|
||||
if($singlepane_view == 'true' && $action == 'CallRelatedList') {
|
||||
header("Location:index.php?action=DetailView&module=$currentModule&record=$record&parenttab=$category");
|
||||
} else {
|
||||
|
||||
$tool_buttons = Button_Check($currentModule);
|
||||
|
||||
$focus = CRMEntity::getInstance($currentModule);
|
||||
if($record != '') {
|
||||
$focus->retrieve_entity_info($record, $currentModule);
|
||||
$focus->id = $record;
|
||||
$service_base_currency = getProductBaseCurrency($focus->id,$currentModule);
|
||||
} else {
|
||||
$service_base_currency = fetchCurrency($current_user->id);
|
||||
}
|
||||
|
||||
$smarty = new vtigerCRM_Smarty;
|
||||
|
||||
if($isduplicate == 'true') $focus->id = '';
|
||||
if(isset($_REQUEST['mode']) && $_REQUEST['mode'] != ' ') $smarty->assign("OP_MODE",vtlib_purify($_REQUEST['mode']));
|
||||
if(!$_SESSION['rlvs'][$currentModule]) unset($_SESSION['rlvs']);
|
||||
|
||||
// Identify this module as custom module.
|
||||
$smarty->assign('CUSTOM_MODULE', true);
|
||||
|
||||
$smarty->assign('APP', $app_strings);
|
||||
$smarty->assign('MOD', $mod_strings);
|
||||
$smarty->assign('MODULE', $currentModule);
|
||||
// TODO: Update Single Module Instance name here.
|
||||
$smarty->assign('SINGLE_MOD', getTranslatedString($currentModule));
|
||||
$smarty->assign('CATEGORY', $category);
|
||||
$smarty->assign('IMAGE_PATH', "themes/$theme/images/");
|
||||
$smarty->assign('THEME', $theme);
|
||||
$smarty->assign('ID', $focus->id);
|
||||
$smarty->assign('MODE', $focus->mode);
|
||||
$smarty->assign('CHECK', $tool_buttons);
|
||||
|
||||
$smarty->assign('NAME', $focus->column_fields[$focus->def_detailview_recname]);
|
||||
$smarty->assign('UPDATEINFO',updateInfo($focus->id));
|
||||
|
||||
$smarty->assign("CURRENCY_ID",$service_base_currency);
|
||||
|
||||
// Module Sequence Numbering
|
||||
$mod_seq_field = getModuleSequenceField($currentModule);
|
||||
if ($mod_seq_field != null) {
|
||||
$mod_seq_id = $focus->column_fields[$mod_seq_field['name']];
|
||||
} else {
|
||||
$mod_seq_id = $focus->id;
|
||||
}
|
||||
$smarty->assign('MOD_SEQ_ID', $mod_seq_id);
|
||||
// END
|
||||
|
||||
$related_array = getRelatedLists($currentModule, $focus);
|
||||
$smarty->assign('RELATEDLISTS', $related_array);
|
||||
|
||||
require_once('include/ListView/RelatedListViewSession.php');
|
||||
if(!empty($_REQUEST['selected_header']) && !empty($_REQUEST['relation_id'])) {
|
||||
$relationId = vtlib_purify($_REQUEST['relation_id']);
|
||||
RelatedListViewSession::addRelatedModuleToSession($relationId,
|
||||
vtlib_purify($_REQUEST['selected_header']));
|
||||
}
|
||||
$open_related_modules = RelatedListViewSession::getRelatedModulesFromSession();
|
||||
$smarty->assign("SELECTEDHEADERS", $open_related_modules);
|
||||
|
||||
$smarty->display('RelatedLists.tpl');
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
include('modules/CustomView/index.php');
|
||||
|
||||
?>
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
global $currentModule;
|
||||
$focus = CRMEntity::getInstance($currentModule);
|
||||
|
||||
$record = vtlib_purify($_REQUEST['record']);
|
||||
$module = vtlib_purify($_REQUEST['module']);
|
||||
$return_module = vtlib_purify($_REQUEST['return_module']);
|
||||
$return_action = vtlib_purify($_REQUEST['return_action']);
|
||||
$return_id = vtlib_purify($_REQUEST['return_id']);
|
||||
$parenttab = getParentTab();
|
||||
|
||||
//Added to fix 4600
|
||||
$url = getBasic_Advance_SearchURL();
|
||||
|
||||
DeleteEntity($currentModule, $return_module, $focus, $record, $return_id);
|
||||
|
||||
$parenttab = getParentTab();
|
||||
|
||||
if(isset($_REQUEST['activity_mode']))
|
||||
$url .= '&activity_mode='.vtlib_purify($_REQUEST['activity_mode']);
|
||||
|
||||
header("Location: index.php?module=$return_module&action=$return_action&record=$return_id&parenttab=$parenttab&relmodule=$module".$url);
|
||||
|
||||
?>
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
/*+********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
global $adb;
|
||||
global $log;
|
||||
$return_id = vtlib_purify($_REQUEST['return_id']);
|
||||
$record = vtlib_purify($_REQUEST['record']);
|
||||
$return_module = vtlib_purify($_REQUEST['return_module']);
|
||||
$return_action = vtlib_purify($_REQUEST['return_action']);
|
||||
|
||||
if($return_action !='' && $return_module == "PriceBooks" && $return_action == "CallRelatedList") {
|
||||
$log->info("Products :: Deleting Price Book - Delete from PriceBook RelatedList");
|
||||
$query = "delete from vtiger_pricebookproductrel where pricebookid=? and productid=?";
|
||||
$adb->pquery($query, array($return_id, $record));
|
||||
} else {
|
||||
$log->info("Products :: Deleting Price Book");
|
||||
$query = "delete from vtiger_pricebookproductrel where pricebookid=? and productid=?";
|
||||
$adb->pquery($query, array($record, $return_id));
|
||||
}
|
||||
|
||||
header("Location: index.php?module=".$return_module."&action=".$return_module."Ajax&file=$return_action&ajax=delpbprorel&record=".$return_id);
|
||||
?>
|
|
@ -0,0 +1,110 @@
|
|||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once('Smarty_setup.php');
|
||||
require_once('user_privileges/default_module_view.php');
|
||||
|
||||
global $mod_strings, $app_strings, $currentModule, $current_user, $theme, $singlepane_view;
|
||||
|
||||
$focus = CRMEntity::getInstance($currentModule);
|
||||
|
||||
$tool_buttons = Button_Check($currentModule);
|
||||
$smarty = new vtigerCRM_Smarty();
|
||||
|
||||
$record = $_REQUEST['record'];
|
||||
$isduplicate = vtlib_purify($_REQUEST['isDuplicate']);
|
||||
$tabid = getTabid($currentModule);
|
||||
$category = getParentTab($currentModule);
|
||||
|
||||
if($record != '') {
|
||||
$focus->id = $record;
|
||||
$focus->retrieve_entity_info($record, $currentModule);
|
||||
}
|
||||
if($isduplicate == 'true') $focus->id = '';
|
||||
|
||||
// Identify this module as custom module.
|
||||
$smarty->assign('CUSTOM_MODULE', true);
|
||||
|
||||
$smarty->assign('APP', $app_strings);
|
||||
$smarty->assign('MOD', $mod_strings);
|
||||
$smarty->assign('MODULE', $currentModule);
|
||||
// TODO: Update Single Module Instance name here.
|
||||
$smarty->assign('SINGLE_MOD', 'SINGLE_'.$currentModule);
|
||||
$smarty->assign('CATEGORY', $category);
|
||||
$smarty->assign('IMAGE_PATH', "themes/$theme/images/");
|
||||
$smarty->assign('THEME', $theme);
|
||||
$smarty->assign('ID', $focus->id);
|
||||
$smarty->assign('MODE', $focus->mode);
|
||||
|
||||
$recordName = array_values(getEntityName($currentModule, $focus->id));
|
||||
$recordName = $recordName[0];
|
||||
$smarty->assign('NAME', $recordName);
|
||||
$smarty->assign('UPDATEINFO',updateInfo($focus->id));
|
||||
|
||||
// Module Sequence Numbering
|
||||
$mod_seq_field = getModuleSequenceField($currentModule);
|
||||
if ($mod_seq_field != null) {
|
||||
$mod_seq_id = $focus->column_fields[$mod_seq_field['name']];
|
||||
} else {
|
||||
$mod_seq_id = $focus->id;
|
||||
}
|
||||
$smarty->assign('MOD_SEQ_ID', $mod_seq_id);
|
||||
// END
|
||||
|
||||
$validationArray = split_validationdataArray(getDBValidationData($focus->tab_name, $tabid));
|
||||
$smarty->assign('VALIDATION_DATA_FIELDNAME',$validationArray['fieldname']);
|
||||
$smarty->assign('VALIDATION_DATA_FIELDDATATYPE',$validationArray['datatype']);
|
||||
$smarty->assign('VALIDATION_DATA_FIELDLABEL',$validationArray['fieldlabel']);
|
||||
|
||||
$smarty->assign('EDIT_PERMISSION', isPermitted($currentModule, 'EditView', $record));
|
||||
$smarty->assign('CHECK', $tool_buttons);
|
||||
|
||||
if(PerformancePrefs::getBoolean('DETAILVIEW_RECORD_NAVIGATION', true) && isset($_SESSION[$currentModule.'_listquery'])){
|
||||
$recordNavigationInfo = ListViewSession::getListViewNavigation($focus->id);
|
||||
VT_detailViewNavigation($smarty,$recordNavigationInfo,$focus->id);
|
||||
}
|
||||
|
||||
$smarty->assign('IS_REL_LIST', isPresentRelatedLists($currentModule));
|
||||
$smarty->assign('SinglePane_View', $singlepane_view);
|
||||
|
||||
if($singlepane_view == 'true') {
|
||||
$related_array = getRelatedLists($currentModule,$focus);
|
||||
$smarty->assign("RELATEDLISTS", $related_array);
|
||||
|
||||
require_once('include/ListView/RelatedListViewSession.php');
|
||||
if(!empty($_REQUEST['selected_header']) && !empty($_REQUEST['relation_id'])) {
|
||||
RelatedListViewSession::addRelatedModuleToSession(vtlib_purify($_REQUEST['relation_id']),
|
||||
vtlib_purify($_REQUEST['selected_header']));
|
||||
}
|
||||
$open_related_modules = RelatedListViewSession::getRelatedModulesFromSession();
|
||||
$smarty->assign("SELECTEDHEADERS", $open_related_modules);
|
||||
}
|
||||
|
||||
if(isPermitted($currentModule, 'EditView', $record) == 'yes')
|
||||
$smarty->assign('EDIT_DUPLICATE', 'permitted');
|
||||
if(isPermitted($currentModule, 'Delete', $record) == 'yes')
|
||||
$smarty->assign('DELETE', 'permitted');
|
||||
|
||||
$smarty->assign('BLOCKS', getBlocks($currentModule,'detail_view','',$focus->column_fields));
|
||||
|
||||
// Gather the custom link information to display
|
||||
include_once('vtlib/Vtiger/Link.php');
|
||||
$customlink_params = Array('MODULE'=>$currentModule, 'RECORD'=>$focus->id, 'ACTION'=>vtlib_purify($_REQUEST['action']));
|
||||
$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid($currentModule), Array('DETAILVIEWBASIC','DETAILVIEW','DETAILVIEWWIDGET'), $customlink_params));
|
||||
// END
|
||||
|
||||
// Record Change Notification
|
||||
$focus->markAsViewed($current_user->id);
|
||||
// END
|
||||
|
||||
$smarty->assign('DETAILVIEW_AJAX_EDIT', PerformancePrefs::getBoolean('DETAILVIEW_AJAX_EDIT', true));
|
||||
|
||||
$smarty->display('DetailView.tpl');
|
||||
|
||||
?>
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
global $currentModule;
|
||||
$modObj = CRMEntity::getInstance($currentModule);
|
||||
|
||||
$ajaxaction = $_REQUEST["ajxaction"];
|
||||
if($ajaxaction == 'DETAILVIEW')
|
||||
{
|
||||
$crmid = $_REQUEST['recordid'];
|
||||
$tablename = $_REQUEST['tableName'];
|
||||
$fieldname = $_REQUEST['fldName'];
|
||||
$fieldvalue = utf8RawUrlDecode($_REQUEST['fieldValue']);
|
||||
if($crmid != '')
|
||||
{
|
||||
$modObj->retrieve_entity_info($crmid, $currentModule);
|
||||
$modObj->column_fields[$fieldname] = $fieldvalue;
|
||||
$modObj->id = $crmid;
|
||||
$modObj->mode = 'edit';
|
||||
$modObj->save($currentModule);
|
||||
if($modObj->id != '')
|
||||
{
|
||||
echo ':#:SUCCESS';
|
||||
}else
|
||||
{
|
||||
echo ':#:FAILURE';
|
||||
}
|
||||
}else
|
||||
{
|
||||
echo ':#:FAILURE';
|
||||
}
|
||||
} elseif($ajaxaction == "LOADRELATEDLIST" || $ajaxaction == "DISABLEMODULE"){
|
||||
require_once 'include/ListView/RelatedListViewContents.php';
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
/*+********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
global $mod_strings;
|
||||
global $app_strings;
|
||||
global $theme;
|
||||
$theme_path="themes/".$theme."/";
|
||||
$image_path=$theme_path."images/";
|
||||
|
||||
if(isset($_REQUEST['return_module']) && $_REQUEST['return_module']=="PriceBooks")
|
||||
{
|
||||
$pricebook_id = vtlib_purify($_REQUEST['pricebook_id']);
|
||||
$product_id = vtlib_purify($_REQUEST['record']);
|
||||
$listprice = vtlib_purify($_REQUEST['listprice']);
|
||||
$return_action = "CallRelatedList";
|
||||
$return_id = vtlib_purify($_REQUEST['pricebook_id']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$product_id = vtlib_purify($_REQUEST['record']);
|
||||
$pricebook_id = vtlib_purify($_REQUEST['pricebook_id']);
|
||||
$listprice = getListPrice($product_id,$pricebook_id);
|
||||
$return_action = "CallRelatedList";
|
||||
$return_id = vtlib_purify($_REQUEST['pricebook_id']);
|
||||
}
|
||||
$output='';
|
||||
$output ='<div id="roleLay" style="display:block;" class="layerPopup">
|
||||
<form action="index.php" name="index" onSubmit="if(verify_data(index) == true) gotoUpdateListPrice('.$return_id.','.$pricebook_id.','.$product_id.'); else document.getElementById(\'roleLay\').style.display=\'inline\'; return false;" >
|
||||
<input type="hidden" name="module" value="Products">
|
||||
<input type="hidden" name="action" value="UpdateListPrice">
|
||||
<input type="hidden" name="record" value="'.$return_id.'">
|
||||
<input type="hidden" name="pricebook_id" value="'.$pricebook_id.'">
|
||||
<input type="hidden" name="product_id" value="'.$product_id.'">
|
||||
<table border=0 cellspacing=0 cellpadding=5 width=100% class=layerHeadingULine>
|
||||
<tr>
|
||||
<td class=layerPopupHeading " align="left">'.$mod_strings["LBL_EDITLISTPRICE"].'</td>
|
||||
<td align="right" class="small"><img src="' . vtiger_imageurl('close.gif', $theme) . '" border=0 alt="'.$app_strings["LBL_CLOSE"].'" title="'.$app_strings["LBL_CLOSE"].'" style="cursor:pointer" onClick="document.getElementById(\'editlistprice\').style.display=\'none\';"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table border=0 cellspacing=0 cellpadding=5 width=95% align=center>
|
||||
<tr>
|
||||
<td class="small">
|
||||
<table border=0 celspacing=0 cellpadding=5 width=100% align=center bgcolor=white>
|
||||
<tr>
|
||||
<td width="50%" class="cellLabel small"><b>'.$mod_strings["LBL_EDITLISTPRICE"].'</b></td>
|
||||
<td width="50%" class="cellText small"><input class="dataInput" type="text" id="list_price" name="list_price" value="'.$listprice.'" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table border=0 cellspacing=0 cellpadding=5 width=100% class="layerPopupTransport">
|
||||
<tr>
|
||||
<td colspan="3" align="center" class="small">
|
||||
<input type="submit" name="button" value="'.$app_strings["LBL_SAVE_BUTTON_LABEL"].'" class="crmbutton small save">
|
||||
<input title="'.$app_strings["LBL_CANCEL_BUTTON_LABEL"].'" accessKey="'.$app_strings["LBL_CANCEL_BUTTON_KEY"].'" class="crmbutton small cancel" onClick="document.getElementById(\'editlistprice\').style.display=\'none\';" type="button" name="button" value="'.$app_strings["LBL_CANCEL_BUTTON_LABEL"].'">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>';
|
||||
|
||||
echo $output;
|
||||
|
||||
?>
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
|
||||
require_once 'modules/Vtiger/EditView.php';
|
||||
|
||||
$smarty->display('salesEditView.tpl');
|
||||
|
||||
?>
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once('include/utils/ExportRecords.php');
|
||||
|
||||
?>
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
/*+********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
require_once 'modules/Vtiger/FindDuplicateRecords.php';
|
||||
|
||||
?>
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once('modules/Import/index.php');
|
||||
|
||||
?>
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
/*********************************************************************************
|
||||
** The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
********************************************************************************/
|
||||
|
||||
global $theme, $log;
|
||||
$theme_path="themes/".$theme."/";
|
||||
$image_path=$theme_path."images/";
|
||||
|
||||
$currencyid = $_REQUEST['currencyid'];
|
||||
$products_list = $_REQUEST['productsList'];
|
||||
|
||||
$product_ids = explode("::", $products_list);
|
||||
|
||||
$price_list = array();
|
||||
|
||||
if (count($product_ids) > 0) {
|
||||
$product_prices = getPricesForProducts($currencyid, $product_ids);
|
||||
}
|
||||
|
||||
// To get the Price Values in the same order as the Products
|
||||
for ($i=0;$i<count($product_ids);++$i) {
|
||||
$product_id = $product_ids[$i];
|
||||
$price_list[] = $product_prices[$product_id];
|
||||
}
|
||||
|
||||
$price_values = implode("::", $price_list);
|
||||
echo "SUCCESS$".$price_values;
|
||||
|
||||
?>
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
/*+********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
global $theme, $mod_strings, $app_strings;
|
||||
$theme_path="themes/".$theme."/";
|
||||
|
||||
$productid = vtlib_purify($_REQUEST['productid']);
|
||||
$rowid = vtlib_purify($_REQUEST['curr_row']);
|
||||
$product_total = vtlib_purify($_REQUEST['productTotal']);
|
||||
|
||||
$tax_details = getTaxDetailsForProduct($productid,'all');//we should pass available instead of all if we want to display only the available taxes.
|
||||
$associated_tax_count = count($tax_details);
|
||||
|
||||
|
||||
$tax_div = '
|
||||
<table width="100%" border="0" cellpadding="5" cellspacing="0" class="small" id="tax_table'.$rowid.'">
|
||||
<tr>
|
||||
<td id="tax_div_title'.$rowid.'" nowrap align="left" ><b>'.$app_strings['LABEL_SET_TAX_FOR'].' : '.$product_total.'</b></td>
|
||||
<td> </td>
|
||||
<td align="right"><img src="'. vtiger_imageurl('close.gif', $theme) .'" border="0" onClick="fnHidePopDiv(\'tax_div'.$rowid.'\')" style="cursor:pointer;"></td>
|
||||
</tr>
|
||||
';
|
||||
|
||||
$net_tax_total = 0.00;
|
||||
for($i=0,$j=$i+1;$i<count($tax_details);$i++,$j++)
|
||||
{
|
||||
$tax_name = $tax_details[$i]['taxname'];
|
||||
$tax_label = $tax_details[$i]['taxlabel'];
|
||||
$tax_percentage = $tax_details[$i]['percentage'];
|
||||
$tax_name_percentage = $tax_name."_percentage".$rowid;
|
||||
$tax_id_name = "hidden_tax".$j."_percentage".$rowid;//used to store the tax name, used in function callTaxCalc
|
||||
$tax_name_total = "popup_tax_row".$rowid;//$tax_name."_total".$rowid;
|
||||
$tax_total = $product_total*$tax_percentage/100.00;
|
||||
|
||||
$net_tax_total += $tax_total;
|
||||
$tax_div .= '
|
||||
<tr>
|
||||
<td align="left" class="lineOnTop">
|
||||
<input type="text" class="small" size="5" name="'.$tax_name_percentage.'" id="'.$tax_name_percentage.'" value="'.$tax_percentage.'" onBlur="calcCurrentTax(\''.$tax_name_percentage.'\','.$rowid.','.$i.');calcTotal();"> %
|
||||
<input type="hidden" id="'.$tax_id_name.'" value="'.$tax_name_percentage.'">
|
||||
</td>
|
||||
<td align="center" class="lineOnTop">'.$tax_label.'</td>
|
||||
<td align="right" class="lineOnTop">
|
||||
<input type="text" class="small" size="6" name="'.$tax_name_total.'" id="'.$tax_name_total.'" style="cursor:pointer;" value="'.$tax_total.'" readonly>
|
||||
</td>
|
||||
</tr>
|
||||
';
|
||||
}
|
||||
|
||||
$tax_div .= '</table>';
|
||||
|
||||
if($associated_tax_count == 0)
|
||||
{
|
||||
$tax_div .= '<div align="left" class="lineOnTop" width="100%">'.$mod_strings['LBL_NO_TAXES_ASSOCIATED'].'.</div>';
|
||||
}
|
||||
|
||||
$tax_div .= '<input type="hidden" id="hdnTaxTotal'.$rowid.'" name="hdnTaxTotal'.$rowid.'" value="'.$net_tax_total.'">';
|
||||
|
||||
echo $tax_div;
|
||||
|
||||
?>
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
|
||||
require_once('modules/Vtiger/ListView.php');
|
||||
|
||||
?>
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
/*+*******************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
*********************************************************************************/
|
||||
require_once 'include/ListView/ListViewPagging.php';
|
||||
?>
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
|
||||
require_once('modules/Vtiger/MassEdit.php');
|
||||
|
||||
?>
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
/*+********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
global $currentModule, $rstart;
|
||||
|
||||
$focus = CRMEntity::getInstance($currentModule);
|
||||
|
||||
$idlist= vtlib_purify($_REQUEST['massedit_recordids']);
|
||||
$viewid = vtlib_purify($_REQUEST['viewname']);
|
||||
$return_module = vtlib_purify($_REQUEST['massedit_module']);
|
||||
$return_action = 'index';
|
||||
|
||||
//Added to fix 4600
|
||||
$url = getBasic_Advance_SearchURL();
|
||||
|
||||
if(isset($_REQUEST['start']) && $_REQUEST['start']!=''){
|
||||
$rstart = "&start=".vtlib_purify($_REQUEST['start']);
|
||||
}
|
||||
|
||||
if(isset($idlist)) {
|
||||
$recordids = explode(';', $idlist);
|
||||
for($index = 0; $index < count($recordids); ++$index) {
|
||||
$recordid = $recordids[$index];
|
||||
if($recordid == '') continue;
|
||||
if(isPermitted($currentModule,'EditView',$recordid) == 'yes') {
|
||||
// Save each module record with update value.
|
||||
$focus->retrieve_entity_info($recordid, $currentModule);
|
||||
$focus->mode = 'edit';
|
||||
$focus->id = $recordid;
|
||||
foreach($focus->column_fields as $fieldname => $val)
|
||||
{
|
||||
if(isset($_REQUEST[$fieldname."_mass_edit_check"])) {
|
||||
if($fieldname == 'assigned_user_id'){
|
||||
if($_REQUEST['assigntype'] == 'U') {
|
||||
$value = $_REQUEST['assigned_user_id'];
|
||||
} elseif($_REQUEST['assigntype'] == 'T') {
|
||||
$value = $_REQUEST['assigned_group_id'];
|
||||
}
|
||||
} else {
|
||||
if(is_array($_REQUEST[$fieldname]))
|
||||
$value = $_REQUEST[$fieldname];
|
||||
else
|
||||
$value = trim($_REQUEST[$fieldname]);
|
||||
}
|
||||
$focus->column_fields[$fieldname] = $value;
|
||||
}
|
||||
else {
|
||||
$focus->column_fields[$fieldname] = decode_html($focus->column_fields[$fieldname]);
|
||||
}
|
||||
}
|
||||
$focus->save($currentModule);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$parenttab = getParentTab();
|
||||
header("Location: index.php?module=$return_module&action=$return_action&parenttab=$parenttab$rstart");
|
||||
?>
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once('Popup.php');
|
||||
?>
|
|
@ -0,0 +1,134 @@
|
|||
<?php
|
||||
/*********************************************************************************
|
||||
** The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
********************************************************************************/
|
||||
require_once('Smarty_setup.php');
|
||||
require_once('database/DatabaseConnection.php');
|
||||
require_once('modules/Users/Users.php');
|
||||
require_once('include/utils/utils.php');
|
||||
|
||||
$module = vtlib_purify($_REQUEST['module']);
|
||||
$focus = CRMEntity::getInstance($module);
|
||||
|
||||
global $mod_strings, $app_strings, $app_list_strings;
|
||||
global $current_language, $currentModule, $theme;
|
||||
global $adb;
|
||||
|
||||
$theme_path="themes/".$theme."/";
|
||||
$image_path=$theme_path."images/";
|
||||
|
||||
$mode = $_REQUEST['mergemode'];
|
||||
|
||||
if($mode == 'mergesave') {
|
||||
|
||||
$return_module=vtlib_purify($_REQUEST['return_module']);
|
||||
$action=vtlib_purify($_REQUEST['action']);
|
||||
$return_action=vtlib_purify($_REQUEST['return_action']);
|
||||
$parenttab=vtlib_purify($_REQUEST['parent']);
|
||||
$merge_id=vtlib_purify($_REQUEST['record']);
|
||||
$recordids=vtlib_purify($_REQUEST['pass_rec']);
|
||||
|
||||
$result = $adb->pquery("SELECT count(*) AS count FROM vtiger_crmentity WHERE crmid=? and deleted=0", array($merge_id));
|
||||
$count = $adb->query_result($result,0,'count');
|
||||
|
||||
if($count > 0)
|
||||
{
|
||||
// First, save the primary record
|
||||
$focus->mode="edit";
|
||||
setObjectValuesFromRequest($focus);
|
||||
$focus->save($module);
|
||||
$rec_values=$focus->column_fields;
|
||||
|
||||
// Remove the id of primary record from the list of records to be deleted.
|
||||
$del_value=explode(",",$recordids,-1);
|
||||
$offset = array_search($merge_id,$del_value);
|
||||
unset($del_value[$offset]);
|
||||
|
||||
// Transfer the related lists of the records to be deleted, to the primary record's related list
|
||||
if(method_exists($focus, 'transferRelatedRecords')){
|
||||
$focus->transferRelatedRecords($module,$del_value,$merge_id);
|
||||
} else {
|
||||
transferRelatedRecords($module,$del_value,$merge_id);
|
||||
}
|
||||
|
||||
// Delete the records by id specified in the list
|
||||
foreach($del_value as $value)
|
||||
{
|
||||
DeleteEntity($_REQUEST['module'],$_REQUEST['return_module'],$focus,$value,"");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<script>
|
||||
window.self.close();window.opener.location.href=window.opener.location.href;
|
||||
</script>
|
||||
<?php
|
||||
} elseif ($mode == 'mergefields') {
|
||||
|
||||
$idstring=vtlib_purify($_REQUEST['passurl']);
|
||||
$parent_tab=getParentTab();
|
||||
|
||||
$exploded_id=explode(",",$idstring,-1);
|
||||
$record_count = count($exploded_id);
|
||||
|
||||
$smarty = new vtigerCRM_Smarty;
|
||||
$smarty->assign("EDIT_DUPLICATE","");
|
||||
if($record_count == 2) {
|
||||
if(isPermitted($currentModule,"EditView",$exploded_id[0]) == 'yes' && isPermitted($currentModule,"EditView",$exploded_id[1]) == 'yes'
|
||||
&& isPermitted($currentModule,"Delete",$exploded_id[0]) == 'yes' && isPermitted($currentModule,"Delete",$exploded_id[1]) == 'yes')
|
||||
$smarty->assign("EDIT_DUPLICATE","permitted");
|
||||
}
|
||||
else {
|
||||
if(isPermitted($currentModule,"EditView",$exploded_id[0]) == 'yes' && isPermitted($currentModule,"EditView",$exploded_id[1]) == 'yes' && isPermitted($currentModule,"EditView",$exploded_id[2]) == 'yes'
|
||||
&& isPermitted($currentModule,"Delete",$exploded_id[0]) == 'yes' && isPermitted($currentModule,"Delete",$exploded_id[1]) == 'yes' && isPermitted($currentModule,"Delete",$exploded_id[2]) == 'yes')
|
||||
$smarty->assign("EDIT_DUPLICATE","permitted");
|
||||
}
|
||||
|
||||
$all_values_array=getRecordValues($exploded_id,$module);
|
||||
$all_values=$all_values_array[0];
|
||||
$js_arr_val=$all_values_array[1];
|
||||
$fld_array=$all_values_array[2];
|
||||
$js_arr=implode(",",$js_arr_val);
|
||||
|
||||
$imported_records = Array();
|
||||
$sql="select bean_id from vtiger_users_last_import where bean_type=? and deleted=0";
|
||||
$result = $adb->pquery($sql, array($module));
|
||||
$num_rows=$adb->num_rows($result);
|
||||
$count=0;
|
||||
for($i=0; $i<$num_rows;$i++)
|
||||
{
|
||||
foreach($exploded_id as $value)
|
||||
if($value == $adb->query_result($result,$i,"bean_id"))
|
||||
$count++;
|
||||
array_push($imported_records,$adb->query_result($result,$i,"bean_id"));
|
||||
}
|
||||
|
||||
if ($record_count == $count)
|
||||
$no_existing=1;
|
||||
else
|
||||
$no_existing=0;
|
||||
|
||||
$smarty->assign("MOD", $mod_strings);
|
||||
$smarty->assign("APP", $app_strings);
|
||||
$smarty->assign("RECORD_COUNT",$record_count);
|
||||
$smarty->assign("THEME", $theme);
|
||||
$smarty->assign("IMAGE_PATH", $image_path);
|
||||
$smarty->assign("MODULENAME", $module);
|
||||
$smarty->assign("PARENT_TAB", $parent_tab);
|
||||
$smarty->assign("JS_ARRAY", $js_arr);
|
||||
$smarty->assign("ID_ARRAY", $exploded_id);
|
||||
$smarty->assign("IDSTRING",$idstring);
|
||||
$smarty->assign("ALLVALUES", $all_values);
|
||||
$smarty->assign("FIELD_ARRAY", $fld_array);
|
||||
$smarty->assign("IMPORTED_RECORDS", $imported_records);
|
||||
$smarty->assign("NO_EXISTING", $no_existing);
|
||||
$smarty->display("MergeFields.tpl");
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once('include/quickcreate.php');
|
||||
?>
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
global $current_user, $currentModule;
|
||||
|
||||
checkFileAccessForInclusion("modules/$currentModule/$currentModule.php");
|
||||
require_once("modules/$currentModule/$currentModule.php");
|
||||
|
||||
$focus = new $currentModule();
|
||||
setObjectValuesFromRequest($focus);
|
||||
|
||||
$mode = $_REQUEST['mode'];
|
||||
$record=$_REQUEST['record'];
|
||||
if($mode) $focus->mode = $mode;
|
||||
if($record)$focus->id = $record;
|
||||
|
||||
$currencyid=fetchCurrency($current_user->id);
|
||||
$rate_symbol = getCurrencySymbolandCRate($currencyid);
|
||||
$rate = $rate_symbol['rate'];
|
||||
|
||||
if($_REQUEST['assigntype'] == 'U') {
|
||||
$focus->column_fields['assigned_user_id'] = $_REQUEST['assigned_user_id'];
|
||||
} elseif($_REQUEST['assigntype'] == 'T') {
|
||||
$focus->column_fields['assigned_user_id'] = $_REQUEST['assigned_group_id'];
|
||||
}
|
||||
|
||||
$focus->save($currentModule);
|
||||
$return_id = $focus->id;
|
||||
|
||||
$search = vtlib_purify($_REQUEST['search_url']);
|
||||
|
||||
$parenttab = getParentTab();
|
||||
if($_REQUEST['return_module'] != '') {
|
||||
$return_module = vtlib_purify($_REQUEST['return_module']);
|
||||
} else {
|
||||
$return_module = $currentModule;
|
||||
}
|
||||
|
||||
if($_REQUEST['return_action'] != '') {
|
||||
$return_action = vtlib_purify($_REQUEST['return_action']);
|
||||
} else {
|
||||
$return_action = "DetailView";
|
||||
}
|
||||
|
||||
if($_REQUEST['return_id'] != '') {
|
||||
$return_id = vtlib_purify($_REQUEST['return_id']);
|
||||
}
|
||||
|
||||
if(isset($_REQUEST['activity_mode'])) $return_action .= '&activity_mode='.vtlib_purify($_REQUEST['activity_mode']);
|
||||
|
||||
header("Location: index.php?action=$return_action&module=$return_module&record=$return_id&parenttab=$parenttab&start=".vtlib_purify($_REQUEST['pagenumber']).$search);
|
||||
|
||||
?>
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
|
||||
include('modules/Vtiger/Settings.php');
|
||||
|
||||
?>
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once('include/Ajax/TagCloud.php');
|
||||
?>
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
/*+*******************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
*********************************************************************************/
|
||||
require_once 'modules/Home/UnifiedSearch.php';
|
||||
?>
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
/*+********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
global $adb;
|
||||
global $log;
|
||||
$log->debug("Going to update the ListPrice in (modules/Products/UpdateListPrice.php).");
|
||||
$record = vtlib_purify($_REQUEST['record']);
|
||||
$pricebook_id = vtlib_purify($_REQUEST['pricebook_id']);
|
||||
$product_id = vtlib_purify($_REQUEST['product_id']);
|
||||
$listprice = vtlib_purify($_REQUEST['list_price']);
|
||||
$return_action = vtlib_purify($_REQUEST['return_action']);
|
||||
$return_module = vtlib_purify($_REQUEST['return_module']);
|
||||
|
||||
$query = "update vtiger_pricebookproductrel set listprice=? where pricebookid=? and productid=?";
|
||||
$adb->pquery($query, array($listprice, $pricebook_id, $product_id));
|
||||
header("Location: index.php?module=$return_module&action=".$return_module."Ajax&file=$return_action&ajax=updatelistprice&record=$record");
|
||||
?>
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
global $currentModule;
|
||||
|
||||
checkFileAccessForInclusion("modules/$currentModule/ListView.php");
|
||||
include_once("modules/$currentModule/ListView.php");
|
||||
|
||||
?>
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
|
||||
$mod_strings = Array(
|
||||
/*some general information*/
|
||||
'LBL_MODULE_NAME'=>'Assets',
|
||||
'SINGLE_Assets'=>'Asset',
|
||||
|
||||
/*blocks for the module*/
|
||||
'LBL_ASSET_INFORMATION'=>'Asset Information',
|
||||
'LBL_CUSTOM_INFORMATION'=>'Custom Information',
|
||||
'LBL_DESCRIPTION_INFORMATION'=>'Notes',
|
||||
|
||||
/*fields for the module*/
|
||||
'Assets'=>'Assets',
|
||||
'Asset Name' => 'Asset Name',
|
||||
'Customer Name'=>'Customer Name',
|
||||
'Product Name'=>'Product Name',
|
||||
'Serial Number'=>'Serial Number',
|
||||
'Asset No'=>'Asset No',
|
||||
'Date Sold'=>'Date Sold',
|
||||
'Date in Service'=>'Date in Service',
|
||||
'Status'=>'Status',
|
||||
'Shipping Method'=>'Shipping Method',
|
||||
'Shipping Tracking Number'=>'Shipping Tracking Number',
|
||||
'Tag Number'=>'Tag Number',
|
||||
'Notes'=>'Notes',
|
||||
'Invoice Name'=>'Invoice Name',
|
||||
|
||||
/*picklist values*/
|
||||
'In Service'=>'In Service',
|
||||
'Out-of-service'=>'Out-of-service',
|
||||
'Assets ID'=>'Assets ID',
|
||||
|
||||
);
|
||||
?>
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version='1.0'?>
|
||||
<schema>
|
||||
<tables>
|
||||
<table>
|
||||
<name>vtiger_assets</name>
|
||||
<sql><![CDATA[CREATE TABLE `vtiger_assets` (
|
||||
`assetsid` int(11) NOT NULL,
|
||||
`asset_no` varchar(30) NOT NULL,
|
||||
`accountid` int(19) NOT NULL,
|
||||
`product_id` int(19) NOT NULL,
|
||||
`serialnumber` varchar(200) NOT NULL,
|
||||
`datesold` date NOT NULL,
|
||||
`dateinservice` date NOT NULL,
|
||||
`assetstatus` varchar(200) default 'In Service',
|
||||
`tagnumber` varchar(300) default NULL,
|
||||
`invoiceid` int(19) default NULL,
|
||||
`shippingmethod` varchar(200) default NULL,
|
||||
`shippingtrackingnumber` varchar(200) default NULL,
|
||||
PRIMARY KEY (`assetsid`),
|
||||
CONSTRAINT `fk_1_vtiger_assets` FOREIGN KEY (`assetsid`) REFERENCES `vtiger_crmentity` (`crmid`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8]]></sql>
|
||||
</table>
|
||||
<table>
|
||||
<name>vtiger_assetscf</name>
|
||||
<sql><![CDATA[CREATE TABLE `vtiger_assetscf` (
|
||||
`assetsid` int(19) NOT NULL,
|
||||
PRIMARY KEY (`assetsid`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8]]></sql>
|
||||
</table>
|
||||
</tables>
|
||||
</schema>
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once('include/database/PearDatabase.php');
|
||||
@include_once('user_privileges/default_module_view.php');
|
||||
|
||||
global $singlepane_view, $currentModule;
|
||||
$idlist = vtlib_purify($_REQUEST['idlist']);
|
||||
$destinationModule = vtlib_purify($_REQUEST['destination_module']);
|
||||
$parenttab = getParentTab();
|
||||
|
||||
$forCRMRecord = vtlib_purify($_REQUEST['parentid']);
|
||||
$mode = $_REQUEST['mode'];
|
||||
|
||||
if($singlepane_view == 'true')
|
||||
$action = "DetailView";
|
||||
else
|
||||
$action = "CallRelatedList";
|
||||
|
||||
$storearray = array();
|
||||
if(!empty($_REQUEST['idlist'])) {
|
||||
// Split the string of ids
|
||||
$storearray = explode (";",trim($idlist,";"));
|
||||
} else if(!empty($_REQUEST['entityid'])){
|
||||
$storearray = array($_REQUEST['entityid']);
|
||||
}
|
||||
$focus = CRMEntity::getInstance($currentModule);
|
||||
if($mode == 'delete') {
|
||||
// Split the string of ids
|
||||
$ids = explode (";",$idlist);
|
||||
if(!empty($ids)) {
|
||||
$focus->delete_related_module($currentModule, $forCRMRecord, $destinationModule, $ids);
|
||||
}
|
||||
} else {
|
||||
if(!empty($_REQUEST['idlist'])) {
|
||||
// Split the string of ids
|
||||
$ids = explode (";",trim($idlist,";"));
|
||||
} else if(!empty($_REQUEST['entityid'])){
|
||||
$ids = $_REQUEST['entityid'];
|
||||
}
|
||||
if(!empty($ids)) {
|
||||
relateEntities($focus, $currentModule, $forCRMRecord, $destinationModule, $ids);
|
||||
}
|
||||
}
|
||||
|
||||
header("Location: index.php?module=$currentModule&record=$forCRMRecord&action=$action&parenttab=$parenttab");
|
||||
?>
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version='1.0'?>
|
||||
<module>
|
||||
<exporttime>2010-12-23 13:46:05</exporttime>
|
||||
<name>ConfigEditor</name>
|
||||
<label>ConfigEditor</label>
|
||||
<parent></parent>
|
||||
<type>extension</type>
|
||||
<version>1.9</version>
|
||||
<dependencies>
|
||||
<vtiger_version>5.1.0</vtiger_version>
|
||||
<vtiger_max_version>5.*</vtiger_max_version>
|
||||
</dependencies>
|
||||
<tables>
|
||||
</tables>
|
||||
</module>
|
|
@ -0,0 +1,45 @@
|
|||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
function replaceUploadSize(){
|
||||
var upload = document.getElementById('key_upload_maxsize').value;
|
||||
upload = "'"+upload+"'";
|
||||
upload = upload.replace(/000000/g,"");
|
||||
upload = upload.replace(/'/g,"");
|
||||
document.getElementById('key_upload_maxsize').value = upload;
|
||||
}
|
||||
|
||||
|
||||
function vtlib_field_help_show_this(basenode, fldname) {
|
||||
var domnode = $('vtlib_fieldhelp_div');
|
||||
|
||||
|
||||
|
||||
var helpcontent = document.getElementById('helpInfo').value;
|
||||
|
||||
|
||||
if(!domnode) {
|
||||
domnode = document.createElement('div');
|
||||
domnode.id = 'vtlib_fieldhelp_div';
|
||||
domnode.className = 'dvtSelectedCell';
|
||||
domnode.style.position = 'absolute';
|
||||
domnode.style.width = '150px';
|
||||
domnode.style.padding = '4px';
|
||||
domnode.style.fontWeight = 'normal';
|
||||
document.body.appendChild(domnode);
|
||||
|
||||
domnode = $('vtlib_fieldhelp_div');
|
||||
Event.observe(domnode, 'mouseover', function() { $('vtlib_fieldhelp_div').show(); });
|
||||
Event.observe(domnode, 'mouseout', vtlib_field_help_hide);
|
||||
}
|
||||
else {
|
||||
domnode.show();
|
||||
}
|
||||
domnode.innerHTML = helpcontent;
|
||||
fnvshobj(basenode,'vtlib_fieldhelp_div');
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
|
||||
class ConfigEditor {
|
||||
|
||||
/**
|
||||
* Invoked when special actions are performed on the module.
|
||||
* @param String Module name
|
||||
* @param String Event Type (module.postinstall, module.disabled, module.enabled, module.preuninstall)
|
||||
*/
|
||||
function vtlib_handler($modulename, $event_type) {
|
||||
|
||||
$registerLink = false;
|
||||
|
||||
if($event_type == 'module.postinstall') {
|
||||
$registerLink = true;
|
||||
} else if($event_type == 'module.disabled') {
|
||||
// TODO Handle actions when this module is disabled.
|
||||
$registerLink = false;
|
||||
} else if($event_type == 'module.enabled') {
|
||||
// TODO Handle actions when this module is enabled
|
||||
$registerLink = true;
|
||||
} else if($event_type == 'module.preuninstall') {
|
||||
return;
|
||||
} else if($event_type == 'module.preupdate') {
|
||||
return;
|
||||
} else if($event_type == 'module.postupdate') {
|
||||
return;
|
||||
}
|
||||
|
||||
$displayLabel = 'Configuration Editor';
|
||||
|
||||
global $adb;
|
||||
if ($registerLink) {
|
||||
$blockid = $adb->query_result(
|
||||
$adb->pquery("SELECT blockid FROM vtiger_settings_blocks WHERE label='LBL_OTHER_SETTINGS'",array()),
|
||||
0, 'blockid');
|
||||
$sequence = (int)$adb->query_result(
|
||||
$adb->pquery("SELECT max(sequence) as sequence FROM vtiger_settings_field WHERE blockid=?",array($blockid)),
|
||||
0, 'sequence') + 1;
|
||||
$fieldid = $adb->getUniqueId('vtiger_settings_field');
|
||||
$adb->pquery("INSERT INTO vtiger_settings_field (fieldid,blockid,sequence,name,iconpath,description,linkto)
|
||||
VALUES (?,?,?,?,?,?,?)", array($fieldid, $blockid,$sequence,$displayLabel,'migrate.gif','Update configuration file of the application', 'index.php?module=ConfigEditor&action=index'));
|
||||
} else {
|
||||
$adb->pquery("DELETE FROM vtiger_settings_field WHERE name=?", array($displayLabel));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once('include/Ajax/CommonAjax.php');
|
||||
?>
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
class ConfigEditorHandler extends VTEventHandler {
|
||||
|
||||
function handleEvent($eventName, $data) {
|
||||
|
||||
if($eventName == 'vtiger.entity.beforesave') {
|
||||
// Entity is about to be saved, take required action
|
||||
}
|
||||
|
||||
if($eventName == 'vtiger.entity.aftersave') {
|
||||
// Entity has been saved, take next action
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,305 @@
|
|||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
|
||||
/**
|
||||
* Configuration file reader
|
||||
*/
|
||||
class ConfigFileReader {
|
||||
// Each line is treated as configuration row
|
||||
protected $rows;
|
||||
// Path to configuration file
|
||||
protected $filepath;
|
||||
|
||||
// Iteration support for rows
|
||||
protected $rowIndex;
|
||||
|
||||
// Editables and Viewables
|
||||
protected $viewables;
|
||||
protected $editables;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* You can restrict variable display for viewing and editing
|
||||
*/
|
||||
function __construct($path, $viewables=array(), $editables=array()) {
|
||||
$this->filepath = $path;
|
||||
$this->viewables = $viewables;
|
||||
$this->editables = $editables;
|
||||
$this->read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Read and parse the configuration file contents.
|
||||
*/
|
||||
protected function read() {
|
||||
$fileContent = trim(file_get_contents($this->filepath));
|
||||
$pattern = '/\$([^=]+)=([^;]+);/';
|
||||
$matches = null;
|
||||
$matchesFound = preg_match_all($pattern, $fileContent, $matches);
|
||||
$configContents = array();
|
||||
if($matchesFound) {
|
||||
$configContents = $matches[0];
|
||||
}
|
||||
$this->rows = array();
|
||||
foreach($configContents as $configLine) {
|
||||
$this->rows[] = new ConfigFileRow($configLine, $this);
|
||||
}
|
||||
$this->rowIndex = -1;
|
||||
unset($fileContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the rows back to configuration.
|
||||
*/
|
||||
function save() {
|
||||
$fileContent = trim(file_get_contents($this->filepath));
|
||||
if ($this->rows) {
|
||||
$fp = fopen($this->filepath, 'w');
|
||||
$rowcount = count($this->rows);
|
||||
for($index = 0; $index < $rowcount; ++$index) {
|
||||
$row = $this->rows[$index];
|
||||
if($row->isEditable()) {
|
||||
$variableName = $row->variableName();
|
||||
$newVariableValue = $row->variableValue();
|
||||
$pattern = '/\$'.$variableName.'[\s]+=([^;]+);/';
|
||||
$replacement = $row->toString();
|
||||
$fileContent = preg_replace($pattern, $replacement, $fileContent);
|
||||
}
|
||||
}
|
||||
fwrite($fp, $fileContent);
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
function editables($key = false) {
|
||||
if ($key === false) return array_keys($this->editables);
|
||||
return $this->editables[$key];
|
||||
}
|
||||
|
||||
function viewables($key = false) {
|
||||
if ($key === false) return array_keys($this->viewables);
|
||||
return $this->viewables[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set new value to the desired variable.
|
||||
*/
|
||||
function setVariableValue($name, $value) {
|
||||
if ($this->rows) {
|
||||
foreach($this->rows as $row) {
|
||||
if ($row->matchesVariableName($name)) {
|
||||
if($name == 'upload_maxsize'){
|
||||
return $row->setVariableValue($value*1000000);
|
||||
}else{
|
||||
return $row->setVariableValue($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the rows
|
||||
*/
|
||||
function getAll() {
|
||||
return $this->rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Has next row to read?
|
||||
*/
|
||||
function next() {
|
||||
if ($this->rowIndex++ < count($this->rows)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current row during iteration (please call next() before this)
|
||||
*/
|
||||
function get() {
|
||||
return $this->rows[$this->rowIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
* Rewind the iteration
|
||||
*/
|
||||
function rewind() {
|
||||
$this->rowIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration file row class
|
||||
*/
|
||||
class ConfigFileRow {
|
||||
// Actual line content
|
||||
protected $lineContent;
|
||||
// Parsed variable name and value
|
||||
protected $parsedVarName = false;
|
||||
protected $parsedVarValue= '';
|
||||
|
||||
// Is the variable of string type?
|
||||
protected $isValueString = false;
|
||||
|
||||
// Some variables which is never editable
|
||||
protected static $alltimeNoneditableVars = array(
|
||||
"dbconfig['db_server']",
|
||||
"application_unique_key"
|
||||
);
|
||||
|
||||
// Editable and Viewable variable names
|
||||
protected $parent;
|
||||
|
||||
// Is the variable value editable?
|
||||
protected $isValueEditable = false;
|
||||
|
||||
// Regex to detect variable name and its safe value
|
||||
static $variableRegex = '/^[ \t]*\\$([^=]+)=([^;]+)/';
|
||||
//Regex to detect support name,it doesnt allow any single quote,and special characters,it does allow only alpha numeric,utf8,.com,@
|
||||
static $variableUnSafeValueRegex = "/[\x{4e00}-\x{9fa5}[:print:]]+.*\-/u";
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function __construct($content, $parent) {
|
||||
$this->lineContent = $content;
|
||||
$this->parent = $parent;
|
||||
$this->parse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the content
|
||||
*/
|
||||
protected function parse() {
|
||||
if (preg_match(self::$variableRegex, $this->lineContent, $m)) {
|
||||
$this->parsedVarName = trim($m[1]);
|
||||
$this->parsedVarValue = trim($m[2]);
|
||||
// Is variable string type?
|
||||
if (strpos($this->parsedVarValue, "'") === 0 || strpos($this->parsedVarValue, '"') === 0) {
|
||||
$this->isValueString = true;
|
||||
$this->parsedVarValue = trim($m[2], "'\" ");
|
||||
}
|
||||
if (!in_array($this->parsedVarName, self::$alltimeNoneditableVars)) {
|
||||
$this->isValueEditable = true;
|
||||
} else {
|
||||
$this->isValueEditable = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the row represent variable?
|
||||
*/
|
||||
function isVariable() {
|
||||
return ($this->parsedVarName !== false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the variable viewable?
|
||||
*/
|
||||
function isViewable() {
|
||||
if ($this->isVariable()) {
|
||||
$editables = $this->parent->editables();
|
||||
if (!empty($editables)) {
|
||||
return in_array($this->parsedVarName, $this->parent->viewables());
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the variable editable?
|
||||
*/
|
||||
function isEditable() {
|
||||
if ($this->isVariable()) {
|
||||
$editables = $this->parent->editables();
|
||||
if (empty($editables)) {
|
||||
return $this->isValueEditable;
|
||||
}
|
||||
return ((in_array($this->parsedVarName, $editables) !== false) && $this->isValueEditable);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get variable name
|
||||
*/
|
||||
function variableName() {
|
||||
return $this->parsedVarName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the variable name matches with input
|
||||
*/
|
||||
function matchesVariableName($input) {
|
||||
$input = ltrim($input, '$');
|
||||
return ($input == $this->parsedVarName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get variable value
|
||||
*/
|
||||
function variableValue() {
|
||||
return $this->parsedVarValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the variable value string type?
|
||||
*/
|
||||
function isValueString() {
|
||||
return $this->isValueString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the variable value
|
||||
*/
|
||||
function setVariableValue($value) {
|
||||
// TODO Avoid any PHP String concate hacks
|
||||
if (preg_match(self::$variableUnSafeValueRegex, $value, $m)) {
|
||||
return false;
|
||||
}
|
||||
// Should the value be restricted to a set?
|
||||
$meta = $this->meta();
|
||||
if (isset($meta['values']) && is_array($meta['values']) ) {
|
||||
$allowedValues = array_keys($meta['values']);
|
||||
if (!empty($allowedValues) && !in_array($value, $allowedValues)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$this->parsedVarValue = $value;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the meta information
|
||||
*/
|
||||
function meta() {
|
||||
if ($this->isEditable()) return $this->parent->editables($this->parsedVarName);
|
||||
if ($this->isViewable()) return $this->parent->viewables($this->parsedVarName);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* String representation of the instance
|
||||
*/
|
||||
function toString() {
|
||||
if ($this->isVariable()) {
|
||||
$encloseWith = "";
|
||||
if ($this->isValueString()) {
|
||||
$encloseWith = "'";
|
||||
}
|
||||
return sprintf("\$%s = %s%s%s;", $this->parsedVarName, $encloseWith, $this->parsedVarValue, $encloseWith);
|
||||
}
|
||||
return $this->lineContent;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
require_once 'include/utils/utils.php';
|
||||
class ConfigurationUtils{
|
||||
static function getEntityModule() {
|
||||
global $adb;
|
||||
$unusedmodules = array('Events','Emails');
|
||||
$additionalModules = array('Home');
|
||||
$query = "SELECT name FROM vtiger_tab WHERE isentitytype = 1";
|
||||
$res = $adb->pquery($query, array());
|
||||
$rows = $adb->num_rows($res);
|
||||
for($i=0; $i <$rows; $i++) {
|
||||
$module[] = $adb->query_result($res, $i, 'name');
|
||||
}
|
||||
$modules = array_merge($module,$additionalModules);
|
||||
$modules = array_diff($modules,$unusedmodules);
|
||||
return $modules;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
class ConfigEditor_Request {
|
||||
protected $valuemap;
|
||||
|
||||
function __construct($values) {
|
||||
$this->valuemap = $values;
|
||||
}
|
||||
|
||||
function get($key, $defvalue='') {
|
||||
$value = $defvalue;
|
||||
if (isset($this->valuemap[$key])) {
|
||||
$value = $this->valuemap[$key];
|
||||
}
|
||||
if (!empty($value)) {
|
||||
$value = vtlib_purify($value);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
function values() {
|
||||
return $this->valuemap;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once('Smarty_setup.php');
|
||||
|
||||
class ConfigEditor_Viewer extends vtigerCRM_Smarty {
|
||||
function ConfigEditor_Viewer() {
|
||||
parent::vtigerCRM_Smarty();
|
||||
|
||||
global $app_strings, $mod_strings, $currentModule, $theme;
|
||||
|
||||
$this->assign('CUSTOM_MODULE', true);
|
||||
|
||||
$this->assign('APP', $app_strings);
|
||||
$this->assign('MOD', $mod_strings);
|
||||
$this->assign('MODULE', $currentModule);
|
||||
// TODO: Update Single Module Instance name here.
|
||||
$this->assign('SINGLE_MOD', 'SINGLE_'.$currentModule);
|
||||
$this->assign('CATEGORY', 'Settings');
|
||||
$this->assign('IMAGE_PATH', "themes/$theme/images/");
|
||||
$this->assign('THEME', $theme);
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
include('ConfigurationUtils.php');
|
||||
$modules = ConfigurationUtils::getEntityModule();
|
||||
$moduleLabels = array();
|
||||
foreach($modules as $module) {
|
||||
$moduleLabels[$module] = getTranslatedString($module, $module);
|
||||
}
|
||||
|
||||
$trueFalseArray = array(
|
||||
'true' => getTranslatedString('LBL_TRUE','ConfigEditor'),
|
||||
'false' => getTranslatedString('LBL_FALSE','ConfigEditor')
|
||||
);
|
||||
|
||||
$__ConfigEditor_Config = array(
|
||||
|
||||
'edit.filepath' => dirname(__FILE__) . '/../../config.inc.php',
|
||||
|
||||
/* CONFIGURE:
|
||||
* List the configuration variables that user can set.
|
||||
* By setting it to array() lets allows editing of all variables but it is not RECOMMENDED
|
||||
*/
|
||||
'allow.editing.variables' => array(
|
||||
'CALENDAR_DISPLAY' => array('label'=>getTranslatedString('LBL_MINI_CALENDAR_DISPLAY','ConfigEditor'),'values'=>$trueFalseArray),
|
||||
'WORLD_CLOCK_DISPLAY' => array('label'=> getTranslatedString('LBL_WORLD_CLOCK_DISPLAY','ConfigEditor'),'values'=>$trueFalseArray),
|
||||
'CALCULATOR_DISPLAY' => array('label' => getTranslatedString('LBL_CALCULATOR_DISPLAY','ConfigEditor') , 'values'=>$trueFalseArray),
|
||||
'USE_RTE' => array('label'=>getTranslatedString('LBL_USE_RTE','ConfigEditor'), 'values'=>$trueFalseArray),
|
||||
'HELPDESK_SUPPORT_EMAIL_ID'=>array('label'=>getTranslatedString('LBL_HELPDESK_SUPPORT_EMAILID','ConfigEditor'),'values'=>array()),
|
||||
'HELPDESK_SUPPORT_NAME' => array('label' => getTranslatedString('LBL_HELPDESK_SUPPORT_NAME','ConfigEditor'),'values'=>array()),
|
||||
'upload_maxsize' => array('label'=>getTranslatedString('LBL_MAX_UPLOAD_SIZE','ConfigEditor'),'values'=>array()),
|
||||
'history_max_viewed' => array('label'=>getTranslatedString('LBL_MAX_HISTORY_VIEWED','ConfigEditor'),'values'=>array()),
|
||||
'default_module' => array('label'=>getTranslatedString('LBL_DEFAULT_MODULE','ConfigEditor'),'values'=>$moduleLabels),
|
||||
'listview_max_textlength' => array('label' => getTranslatedString('LBL_MAX_TEXT_LENGTH_IN_LISTVIEW','ConfigEditor'), 'values' => array() ),
|
||||
'list_max_entries_per_page' => array('label' => getTranslatedString('LBL_MAX_ENTRIES_PER_PAGE_IN_LISTVIEW','ConfigEditor'), 'values'=> array()),
|
||||
)
|
||||
|
||||
);
|
||||
?>
|
|
@ -0,0 +1,113 @@
|
|||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
include_once dirname(__FILE__) . '/Request.php';
|
||||
include_once dirname(__FILE__) . '/Viewer.php';
|
||||
include_once dirname(__FILE__) . '/ConfigFileReader.php';
|
||||
include_once dirname(__FILE__) . '/config.php';
|
||||
|
||||
/**
|
||||
* Main controller of actions
|
||||
*/
|
||||
class ConfigEditor_Controller {
|
||||
|
||||
/**
|
||||
* Get Viewer for displaying UI
|
||||
*/
|
||||
protected function getViewer() {
|
||||
return new ConfigEditor_Viewer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Configuration file reader
|
||||
*/
|
||||
protected function getReader() {
|
||||
global $__ConfigEditor_Config;
|
||||
$configFile = $__ConfigEditor_Config['edit.filepath'];
|
||||
if (file_exists($configFile)) {
|
||||
if (is_writeable($configFile)) {
|
||||
return new ConfigFileReader(
|
||||
$configFile,
|
||||
$__ConfigEditor_Config['allow.editing.variables'], // What variables to view
|
||||
$__ConfigEditor_Config['allow.editing.variables'] // What variables to edit
|
||||
);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform logged in user check and allow only administrators
|
||||
*/
|
||||
protected function authCheck() {
|
||||
global $current_user;
|
||||
if (is_admin($current_user)) return;
|
||||
|
||||
$viewer = $this->getViewer();
|
||||
$viewer->display(vtlib_getModuleTemplate('Vtiger', 'OperationNotPermitted.tpl'));
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Core processing method
|
||||
*/
|
||||
function process(ConfigEditor_Request $request) {
|
||||
$this->authCheck();
|
||||
$type = $request->get('type');
|
||||
if ($type == 'save') {
|
||||
$this->processSave($request);
|
||||
} else {
|
||||
$this->processDefault($request);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Default action
|
||||
*/
|
||||
protected function processDefault($request) {
|
||||
global $currentModule;
|
||||
|
||||
$configReader = $this->getReader();
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
if (is_null($configReader)) {
|
||||
$viewer->assign('WARNING', 'Configuration file is not writeable!');
|
||||
} else if ($configReader === false) {
|
||||
$viewer->assign('WARNING', 'Configuration file not found!');
|
||||
} else {
|
||||
$viewer->assign('CONFIGREADER', $configReader);
|
||||
}
|
||||
$viewer->display(vtlib_getModuleTemplate($currentModule, 'index.tpl'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Save action
|
||||
*/
|
||||
protected function processSave($request) {
|
||||
$configReader = $this->getReader();
|
||||
|
||||
if ($configReader) {
|
||||
$reqvalues = $request->values();
|
||||
foreach($reqvalues as $k => $v) {
|
||||
if (preg_match("/key_([^ ]+)/", $k, $m)) {
|
||||
$configReader->setVariableValue($m[1], $v);
|
||||
}
|
||||
}
|
||||
$configReader->save();
|
||||
}
|
||||
header('Location: index.php?module=ConfigEditor&action=index');
|
||||
}
|
||||
}
|
||||
|
||||
$controller = new ConfigEditor_Controller();
|
||||
$controller->process(new ConfigEditor_Request($_REQUEST));
|
||||
|
||||
?>
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
$mod_strings = Array (
|
||||
|
||||
'ConfigEditor' => 'ConfigEditor',
|
||||
'LBL_CONFIG_EDITOR' => 'Configuration Editor',
|
||||
'LBL_SETTINGS' => 'Settings',
|
||||
'LBL_CONFIG_EDIT'=>'Edit the Configuration details of vtiger CRM',
|
||||
'SINGLE_ConfigEditor' => 'ConfigEditor',
|
||||
'LBL_TRUE'=> 'true',
|
||||
'LBL_FALSE'=> 'false',
|
||||
'LBL_MAX_UPLOAD_SIZE_MSG'=> 'Maximum upload size is 5MB',
|
||||
'LBL_INVALID_EMAIL_MSG'=>'Invalid Email Address',
|
||||
'LBL_EMPTY_NAME_MSG'=> 'Support Name cannot be empty',
|
||||
'LBL_MAX_LISTVIEW_ENTRIES_MSG'=>'Maximum entries in the ListView is 100',
|
||||
'LBL_MAX_HISTORY_VIEWED_MSG'=>'Please enter a number in the range 1-5',
|
||||
'LBL_MAX_TEXTLENGTH_LISTVIEW_MSG'=>'Maximum text length is 100',
|
||||
'LBL_MB'=>'MB',
|
||||
'LBL_MINI_CALENDAR_DISPLAY' => 'Mini Calendar Display',
|
||||
'LBL_WORLD_CLOCK_DISPLAY'=>'World Clock Display',
|
||||
'LBL_CALCULATOR_DISPLAY'=>'Calculator Display',
|
||||
'LBL_USE_RTE'=>'Use RTE',
|
||||
'LBL_HELPDESK_SUPPORT_EMAILID'=>'Helpdesk Support Email-Id',
|
||||
'LBL_HELPDESK_SUPPORT_NAME'=>'Helpdesk Support Name',
|
||||
'LBL_MAX_UPLOAD_SIZE'=>'Max.Upload Size (Max 5MB)',
|
||||
'LBL_MAX_HISTORY_VIEWED'=>'Max. History Viewed',
|
||||
'LBL_DEFAULT_MODULE'=>'Default Module',
|
||||
'LBL_MAX_TEXT_LENGTH_IN_LISTVIEW'=>'Max. text length in listview',
|
||||
'LBL_MAX_ENTRIES_PER_PAGE_IN_LISTVIEW'=>'Max. entries per page in listview',
|
||||
'LBL_CONFIG_FILE'=>'config.inc.php',
|
||||
'LBL_CONFIG_EDIT_CAUTION_INFO' =>'You are editing the configuration details of vtiger CRM.',
|
||||
'LBL_DOUBLE_CHECK_INFO'=>'Please do double check before saving the values.',
|
||||
'LBL_HELP_INFO'=>"This is used as a 'From email-id' to send a mail to a new user created about his login credentials,
|
||||
send a mail to trouble-ticket owner about the ticket assigned,send a mail about reminder and notification.",
|
||||
'LBL_RESTRICTED_CHARACTERS'=>"Special characters like ' " and ; are not allowed",
|
||||
|
||||
);
|
||||
|
||||
?>
|
|
@ -0,0 +1,280 @@
|
|||
{*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************}
|
||||
{literal}
|
||||
<style type="text/css">
|
||||
.detailedViewTextBoxThisOn {
|
||||
background-color:#FFFFDD;
|
||||
border:1px solid #BABABA;
|
||||
color:#000000;
|
||||
font-family:Arial,Helvetica,sans-serif;
|
||||
font-size:11px;
|
||||
padding-left:5px;
|
||||
width:20%;
|
||||
}
|
||||
|
||||
.detailedViewTextBoxThis {
|
||||
background-color:#FFFFFF;
|
||||
border:1px solid #BABABA;
|
||||
color:#000000;
|
||||
font-family:Arial,Helvetica,sans-serif;
|
||||
font-size:11px;
|
||||
padding-left:5px;
|
||||
width:20%;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
function msg()
|
||||
{
|
||||
alert("invalid entry");
|
||||
exit;
|
||||
}
|
||||
|
||||
function trim(str)
|
||||
{
|
||||
while (str.substring(0,1) == ' ') // check for white spaces from beginning
|
||||
{
|
||||
str = str.substring(1, str.length);
|
||||
}
|
||||
while (str.substring(str.length-1, str.length) == ' ') // check white space from end
|
||||
{
|
||||
str = str.substring(0,str.length-1);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
function valid(name) {
|
||||
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
|
||||
var id=document.getElementById('key_HELPDESK_SUPPORT_EMAIL_ID');
|
||||
var name = document.getElementById('key_HELPDESK_SUPPORT_NAME');
|
||||
var size = document.getElementById('key_upload_maxsize');
|
||||
var maxEntries = document.getElementById('key_list_max_entries_per_page');
|
||||
var history1 = document.getElementById('key_history_max_viewed');
|
||||
var maxtext = document.getElementById('key_listview_max_textlength');
|
||||
var reg1 = /^([0-9]*)$/;
|
||||
name.value = trim(name.value);
|
||||
if ((name.value).indexOf("\"") != -1 || (name.value).indexOf("'") != -1 || (name.value).indexOf(";") != -1){
|
||||
var invalidSupportName = document.getElementById('invalidSupportName').value;
|
||||
document.getElementById('msg_HELPDESK_SUPPORT_NAME').innerHTML = invalidSupportName;
|
||||
name.focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
maxEntries.value = trim(maxEntries.value);
|
||||
size.value = trim(size.value);
|
||||
history1.value = trim(history1.value);
|
||||
maxtext.value = trim(maxtext.value);
|
||||
var uploadSize = document.getElementById('uploadSize').value;
|
||||
var invalidEmail = document.getElementById('invalidEmail').value;
|
||||
var emptyName = document.getElementById('emptyName').value;
|
||||
var maxListEntries= document.getElementById('maxListEntries').value;
|
||||
var maxHistory= document.getElementById('maxHistory').value;
|
||||
var maxTextLength= document.getElementById('maxTextLength').value;
|
||||
if(reg.test(id.value) == false){
|
||||
document.getElementById('msg_HELPDESK_SUPPORT_EMAIL_ID').innerHTML = invalidEmail;
|
||||
id.focus();
|
||||
return false;
|
||||
}else if(name.value == ''){
|
||||
document.getElementById('msg_HELPDESK_SUPPORT_NAME').innerHTML = emptyName;
|
||||
name.focus();
|
||||
return false;
|
||||
}else if((reg1.test(size.value) == false) || (size.value <= 0) || (size.value > 5) || (size.value == NaN)){
|
||||
document.getElementById('msg_upload_maxsize').innerHTML =uploadSize;
|
||||
size.focus();
|
||||
return false;
|
||||
}else if((reg1.test(maxEntries.value) == false)||(maxEntries.value <= 0) || (maxEntries.value>100)){
|
||||
document.getElementById('msg_list_max_entries_per_page').innerHTML=maxListEntries;
|
||||
maxEntries.focus();
|
||||
return false;
|
||||
}else if((reg1.test(history1.value) == false)||(history1.value <= 0) || (history1.value > 5)){
|
||||
document.getElementById('msg_history_max_viewed').innerHTML=maxHistory;
|
||||
history1.focus();
|
||||
return false;
|
||||
}else if((reg1.test(maxtext.value) == false) || (maxtext.value < 0) || (maxtext.value > 100) || (maxtext.value === "")){
|
||||
document.getElementById('msg_listview_max_textlength').innerHTML=maxTextLength;
|
||||
maxtext.focus();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
{/literal}
|
||||
<script language="JavaScript" type="text/javascript" src="modules/{$MODULE}/{$MODULE}.js"></script>
|
||||
<body onload="replaceUploadSize();">
|
||||
<input type="hidden" value="{$MOD.LBL_MAX_UPLOAD_SIZE_MSG}" id="uploadSize"></input>
|
||||
<input type="hidden" value="{$MOD.LBL_INVALID_EMAIL_MSG}" id="invalidEmail"></input>
|
||||
<input type="hidden" value="{$MOD.LBL_RESTRICTED_CHARACTERS}" id="invalidSupportName"></input>
|
||||
<input type="hidden" value="{$MOD.LBL_MAX_LISTVIEW_ENTRIES_MSG}" id="maxListEntries"></input>
|
||||
<input type="hidden" value="{$MOD.LBL_MAX_HISTORY_VIEWED_MSG}" id="maxHistory"></input>
|
||||
<input type="hidden" value="{$MOD.LBL_MAX_TEXTLENGTH_LISTVIEW_MSG}" id="maxTextLength"></input>
|
||||
<input type="hidden" value="{$MOD.LBL_EMPTY_NAME_MSG}" id="emptyName"></input>
|
||||
<input type="hidden" value="{$MOD.LBL_HELP_INFO}" id="helpInfo"></input>
|
||||
|
||||
<table cellspacing="0" cellpadding="2" border="0" width="100%" class="level2Bg">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<table cellspacing="0" cellpadding="0" border="0">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td nowrap="" class="level2SelTab"><a href="index.php?module=Settings&action=index&parenttab=Settings">Settings</a></td>
|
||||
<td nowrap="" class="level2SelTab"><a href="index.php?module=Settings&action=ModuleManager&parenttab=Settings">Module Manager</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<table border=0 cellspacing=0 cellpadding=0 width=98% align=center>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign=top align=right width=8><img src="{'showPanelTopLeft.gif'|@vtiger_imageurl:$THEME}"></td>
|
||||
<td class="showPanelBg" valign="top" width="100%" >
|
||||
|
||||
<div style="padding: 20px;">
|
||||
<form onsubmit="VtigerJS_DialogBox.block();" action="index.php" method="POST" name="EditView">
|
||||
<div align="center">
|
||||
{include file="SetMenu.tpl"}
|
||||
<table cellspacing="0" cellpadding="5" border="0" width="100%" class="settingsSelUITopLine">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td width="50" valign="top" rowspan="2"><img height="48" border="0" width="48" title="Users" alt="Users" src="themes/images/migrate.gif"></td>
|
||||
<td valign="bottom" class="heading2"><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > {$MOD.LBL_CONFIG_EDITOR} </b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"class="small">{$MOD.LBL_CONFIG_EDIT}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br>
|
||||
<br>
|
||||
<table width="95%" cellspacing="0" cellpadding="0" border="0" class="small" align="center">
|
||||
<tr>
|
||||
<td>
|
||||
<table width="100%" cellspacing="0" cellpadding="3" border="0" class="small">
|
||||
<tr>
|
||||
<td nowrap="" style="width: 10px;" class="dvtTabCache"> </td>
|
||||
<td width="75" nowrap="" align="center" class="dvtSelectedCell" style="width: 15%;"><b>{$MOD.LBL_CONFIG_FILE}</b></td>
|
||||
<td nowrap="" align="center" style="width: 100px;" class="dvtTabCache">
|
||||
{if $WARNING}
|
||||
<div style='background-color: #FFFABF; padding: 2px; margin: 0 0 2px 0; border: 1px solid yellow'>
|
||||
<b style='color: red'>{$WARNING}</b>
|
||||
{/if}
|
||||
</td>
|
||||
<td nowrap="" style="width: 65%;" class="dvtTabCache"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" align="left">
|
||||
<div id="basicTab">
|
||||
<table border=0 cellspacing=0 cellpadding=3 width=100% class="dvtContentSpace">
|
||||
<tr>
|
||||
<td align="left" style="padding:10px;">
|
||||
<table border=0 cellspacing=0 cellpadding=5 width=100% class="small">
|
||||
<tr>
|
||||
<td colspan=2>
|
||||
<div align="center">
|
||||
<input type='submit' class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="if(valid(this)){ldelim}return true;{rdelim}else{ldelim}return false;{rdelim}">
|
||||
<input type='button' class="crmbutton small cancel" value="{$APP.LBL_CANCEL_BUTTON_LABEL}" onclick="location.href='index.php?module=Settings&action=index&parenttab=Settings'">
|
||||
|
||||
<input type='hidden' name='module' value='ConfigEditor'>
|
||||
<input type='hidden' name='action' value='ConfigEditorAjax'>
|
||||
<input type='hidden' name='file' value='index'>
|
||||
<input type='hidden' name='type' value='save'>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{if $CONFIGREADER}
|
||||
<tr>
|
||||
<td class="detailedViewHeader" colspan="2">
|
||||
{$MOD.LBL_CONFIG_EDIT_CAUTION_INFO}<b>{$MOD.LBL_DOUBLE_CHECK_INFO}</b>
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
|
||||
{foreach item=CONFIGLINE from=$CONFIGREADER->getAll()}
|
||||
{if $CONFIGLINE->isViewable() || $CONFIGLINE->isEditable()}
|
||||
|
||||
{assign var="VARMETA" value=$CONFIGLINE->meta()}
|
||||
|
||||
<tr bgcolor=white valign=center style="height:25px;">
|
||||
<td class="dvtCellLabel" width="15%">
|
||||
{if $VARMETA.label}
|
||||
{if $VARMETA.label == 'Helpdesk Support Email-Id'}
|
||||
{$VARMETA.label} <img border="0" src="themes/images/help_icon.gif" onclick="vtlib_field_help_show_this(this, '{$CONFIGLINE->variableName()}' );" style="cursor: pointer;">
|
||||
{else}
|
||||
{$VARMETA.label}
|
||||
{/if}
|
||||
{else}
|
||||
{$CONFIGLINE->variableName()}
|
||||
{/if}
|
||||
</td>
|
||||
<td class="dvtCellInfo">
|
||||
{if $CONFIGLINE->isEditable()}
|
||||
{if $VARMETA.values}
|
||||
<select class="small" name="key_{$CONFIGLINE->variableName()}" id="key_{$CONFIGLINE->variableName()}">
|
||||
{foreach item=VARVALUEOPTION key=VARVALUEOPTIONKEY from=$VARMETA.values}
|
||||
<option value="{$VARVALUEOPTIONKEY}" {if $CONFIGLINE->variableValue() eq $VARVALUEOPTIONKEY}selected=true{/if}>{$VARVALUEOPTION}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
{else}
|
||||
<b><span class="warning" id="msg_{$CONFIGLINE->variableName()}"></span></b>
|
||||
{if $CONFIGLINE->variableName() == 'upload_maxsize'}
|
||||
<input size="2" type="text" name="key_{$CONFIGLINE->variableName()}" id="key_{$CONFIGLINE->variableName()}" value="{$CONFIGLINE->variableValue()}" onblur="class='detailedViewTextBoxThis'" onfocus="class='detailedViewTextBoxThisOn'" class="detailedViewTextBoxThis" > {$MOD.LBL_MB}
|
||||
{else}
|
||||
<input type="text" name="key_{$CONFIGLINE->variableName()}" id="key_{$CONFIGLINE->variableName()}" value="{$CONFIGLINE->variableValue()}" onblur="this.className='detailedViewTextBox'" onfocus="this.className='detailedViewTextBoxOn'" class="detailedViewTextBox" >
|
||||
{/if}
|
||||
{/if}
|
||||
{else}
|
||||
{$CONFIGLINE->variableValue()}
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</table>
|
||||
|
||||
<tr>
|
||||
<td colspan=2>
|
||||
<div align="center">
|
||||
<input type='submit' class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="if(valid(this)){ldelim}return true;{rdelim}else{ldelim}return false;{rdelim}">
|
||||
<input type='button' class="crmbutton small cancel" value="{$APP.LBL_CANCEL_BUTTON_LABEL}" onclick="location.href='index.php?module=Settings&action=index&parenttab=Settings'">
|
||||
|
||||
<input type='hidden' name='module' value='ConfigEditor'>
|
||||
<input type='hidden' name='action' value='ConfigEditorAjax'>
|
||||
<input type='hidden' name='file' value='index'>
|
||||
<input type='hidden' name='type' value='save'>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
<td valign=top align=right><img src="{'showPanelTopRight.gif'|@vtiger_imageurl:$THEME}"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version='1.0'?>
|
||||
<module>
|
||||
<name>CronTasks</name>
|
||||
<label>CronTasks</label>
|
||||
<parent></parent>
|
||||
<type>extension</type>
|
||||
<version>1.1</version>
|
||||
<dependencies>
|
||||
<vtiger_version>5.3.1</vtiger_version>
|
||||
<vtiger_max_version>5.*</vtiger_max_version>
|
||||
</dependencies>
|
||||
</module>
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
/*+*******************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
global $adb,$log;
|
||||
|
||||
$id = $_REQUEST['record'];
|
||||
$move = $_REQUEST['move'];
|
||||
$log->fatal("$id,$move");
|
||||
|
||||
if($move == 'Down'){
|
||||
$sequence = $adb->pquery("SELECT sequence FROM vtiger_cron_task WHERE id = ?", array($id));
|
||||
$oldsequence = $adb->query_result($sequence,0,'sequence');
|
||||
|
||||
$nexttab = $adb->pquery("SELECT sequence,id FROM vtiger_cron_task WHERE sequence > ? ORDER BY SEQUENCE LIMIT 0,1", array($oldsequence));
|
||||
$newsequence = $adb->query_result($nexttab,0,'sequence');
|
||||
$rightid = $adb->query_result($nexttab,0,'id');
|
||||
|
||||
$adb->pquery("UPDATE vtiger_cron_task set sequence=? WHERE id = ?", array($newsequence, $id));
|
||||
$adb->pquery("UPDATE vtiger_cron_task set sequence=? WHERE id = ?", array($oldsequence, $rightid));
|
||||
}elseif ($move == 'Up') {
|
||||
$sequence = $adb->pquery("SELECT sequence FROM vtiger_cron_task WHERE id = ?", array($id));
|
||||
$oldsequence = $adb->query_result($sequence,0,'sequence');
|
||||
|
||||
$nexttab = $adb->pquery("SELECT sequence,id FROM vtiger_cron_task WHERE sequence < ? ORDER BY SEQUENCE DESC LIMIT 0,1", array($oldsequence));
|
||||
$newsequence = $adb->query_result($nexttab,0,'sequence');
|
||||
$leftid = $adb->query_result($nexttab,0,'id');
|
||||
|
||||
$adb->pquery("UPDATE vtiger_cron_task SET sequence=? WHERE id = ?", array($newsequence, $id));
|
||||
$adb->pquery("UPDATE vtiger_cron_task SET sequence=? WHERE id = ?", array($oldsequence, $leftid));
|
||||
|
||||
}
|
||||
$loc = "Location: index.php?action=CronTasksAjax&file=ListCronJobs&module=CronTasks&directmode=ajax";
|
||||
header($loc);
|
||||
?>
|
|
@ -0,0 +1,86 @@
|
|||
/*********************************************************************************
|
||||
** The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
|
||||
function fetchSaveCron(id)
|
||||
{
|
||||
|
||||
var status = $("cron_status").value;
|
||||
var timeValue= $("CronTime").value;
|
||||
var time = $("cron_time").value;
|
||||
var min_freq =parseInt($("min_freq").value,10);
|
||||
if(!numValidate("CronTime","","any",true)){
|
||||
return false;
|
||||
}
|
||||
if((timeValue % 1) !=0){
|
||||
alert("only integer values are allowed");
|
||||
return false;
|
||||
}
|
||||
if((timeValue < min_freq && time == "min") || timeValue <= 0 || timeValue == '' ){
|
||||
alert($("desc").value);
|
||||
|
||||
}
|
||||
else{
|
||||
$("editdiv").style.display="none";
|
||||
$("status").style.display="inline";
|
||||
new Ajax.Request(
|
||||
'index.php',
|
||||
{
|
||||
queue: {
|
||||
position: 'end',
|
||||
scope: 'command'
|
||||
},
|
||||
method: 'post',
|
||||
postBody: 'action=CronTasksAjax&module=CronTasks&file=SaveCron&record='+id+'&status='+status+'&timevalue='+timeValue+'&time='+time,
|
||||
onComplete: function(response) {
|
||||
$("status").style.display="none";
|
||||
$("notifycontents").innerHTML=response.responseText;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function fetchEditCron(id)
|
||||
{
|
||||
$("status").style.display="inline";
|
||||
new Ajax.Request(
|
||||
'index.php',
|
||||
{
|
||||
queue: {
|
||||
position: 'end',
|
||||
scope: 'command'
|
||||
},
|
||||
method: 'post',
|
||||
postBody: 'action=CronTasksAjax&module=CronTasks&file=EditCron&record='+id,
|
||||
onComplete: function(response) {
|
||||
$("status").style.display="none";
|
||||
$("editdiv").innerHTML=response.responseText;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
function move_module(tabid,move){
|
||||
|
||||
//$('vtbusy_info').style.display = "block";
|
||||
new Ajax.Request(
|
||||
'index.php',
|
||||
{
|
||||
queue: {
|
||||
position: 'end',
|
||||
scope: 'command'
|
||||
},
|
||||
method: 'post',
|
||||
postBody: 'module=CronTasks&action=CronTasksAjax&file=CronSequence&parenttab=Settings&record='+tabid+'&move='+move,
|
||||
onComplete: function(response) {
|
||||
$("notifycontents").innerHTML=response.responseText;
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
/*+********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
*******************************************************************************/
|
||||
|
||||
class CronTasks {
|
||||
|
||||
/**
|
||||
* Invoked when special actions are performed on the module.
|
||||
* @param String Module name
|
||||
* @param String Event Type
|
||||
*/
|
||||
function vtlib_handler($moduleName, $eventType) {
|
||||
|
||||
require_once('include/utils/utils.php');
|
||||
global $adb,$mod_strings;
|
||||
|
||||
if($eventType == 'module.postinstall') {
|
||||
$fieldid = $adb->getUniqueID('vtiger_settings_field');
|
||||
$blockid = getSettingsBlockId('LBL_OTHER_SETTINGS');
|
||||
$seq_res = $adb->pquery("SELECT max(sequence) AS max_seq FROM vtiger_settings_field WHERE blockid = ?", array($blockid));
|
||||
if ($adb->num_rows($seq_res) > 0) {
|
||||
$cur_seq = $adb->query_result($seq_res, 0, 'max_seq');
|
||||
if ($cur_seq != null) $seq = $cur_seq + 1;
|
||||
}
|
||||
|
||||
$adb->pquery('INSERT INTO vtiger_settings_field(fieldid, blockid, name, iconpath, description, linkto, sequence)
|
||||
VALUES (?,?,?,?,?,?,?)', array($fieldid, $blockid, 'Scheduler', 'Cron.png', 'Allows you to Configure Cron Task', 'index.php?module=CronTasks&action=ListCronJobs&parenttab=Settings', $seq));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
/*********************************************************************************
|
||||
** The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
********************************************************************************/
|
||||
require_once('include/Ajax/CommonAjax.php');
|
||||
?>
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
/*********************************************************************************
|
||||
** The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
********************************************************************************/
|
||||
|
||||
require_once('Smarty_setup.php');
|
||||
require_once('config.php');
|
||||
require_once('vtlib/Vtiger/Cron.php');
|
||||
require_once('config.inc.php');
|
||||
global $mod_strings, $app_strings, $current_language;
|
||||
global $theme;
|
||||
$theme_path="themes/".$theme."/";
|
||||
$image_path=$theme_path."images/";
|
||||
|
||||
$smarty = new vtigerCRM_Smarty;
|
||||
if(isset($_REQUEST['record']) && $_REQUEST['record']!='') {
|
||||
$id = $_REQUEST['record'];
|
||||
$cronTask = Vtiger_cron::getInstanceById($id);
|
||||
$label = getTranslatedString($cronTask->getName(),$cronTask->getModule());
|
||||
$cron_status = $cronTask->getStatus();
|
||||
$cron_freq = $cronTask->getFrequency();
|
||||
$cron_desc = $cronTask->getDescription();
|
||||
$cron = Array();
|
||||
$cron['label'] = $label;
|
||||
if($cron_freq/(60*60)>1){
|
||||
$cron['frequency']=(int)($cron_freq/(60*60));
|
||||
$cron['time'] = 'hour';
|
||||
}
|
||||
else{
|
||||
$cron['frequency']=(int)($cron_freq/60);
|
||||
$cron['time'] = 'min';
|
||||
}
|
||||
$cron['status'] = $cron_status;
|
||||
$cron['description'] = $cron_desc;
|
||||
$cron['id']=$id;
|
||||
|
||||
|
||||
$smarty->assign("CRON_DETAILS",$cron);
|
||||
$smarty->assign("MOD", return_module_language($current_language,'CronTasks'));
|
||||
$smarty->assign("THEME", $theme);
|
||||
$smarty->assign("IMAGE_PATH",$image_path);
|
||||
$smarty->assign("APP", $app_strings);
|
||||
$smarty->assign("CMOD", $mod_strings);
|
||||
$smarty->assign("MIN_CRON_FREQUENCY", getMinimumCronFrequency());
|
||||
$smarty->display("modules/CronTasks/EditCron.tpl");
|
||||
}
|
||||
else {
|
||||
header("Location:index.php?module=CronTasks&action=ListCronJobs&directmode=ajax");
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
/*********************************************************************************
|
||||
** The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
********************************************************************************/
|
||||
|
||||
require_once('Smarty_setup.php');
|
||||
require_once('vtlib/Vtiger/Cron.php');
|
||||
require_once ('include/utils/utils.php');
|
||||
|
||||
global $theme,$app_strings,$mod_strings,$current_language;
|
||||
$theme_path="themes/".$theme."/";
|
||||
$image_path=$theme_path."images/";
|
||||
$smarty = new vtigerCRM_Smarty;
|
||||
$cronTasks = Vtiger_Cron::listAllActiveInstances(1);
|
||||
$output = Array();
|
||||
|
||||
foreach ($cronTasks as $cronTask) {
|
||||
$out = Array();
|
||||
$cron_id = $cronTask->getId();
|
||||
$cron_mod = $cronTask->getName();
|
||||
$cron_freq = $cronTask->getFrequency();
|
||||
$cron_st = $cronTask->getStatus();
|
||||
if($cronTask->getLastStart() != 0) {
|
||||
$start_ts = $cronTask->getLastStart();
|
||||
$end_ts = time();
|
||||
$cron_started = dateDiffAsString($start_ts, $end_ts);
|
||||
}
|
||||
else {
|
||||
$cron_started = '';
|
||||
}
|
||||
if($cronTask->getLastEnd() != 0) {
|
||||
$start_ts = $cronTask->getLastEnd();
|
||||
$end_ts = time();
|
||||
$cron_end = dateDiffAsString($start_ts, $end_ts);
|
||||
}
|
||||
else {
|
||||
$cron_end = '';
|
||||
}
|
||||
$out ['cronname'] = getTranslatedString($cron_mod,$cronTask->getModule());
|
||||
|
||||
$out['hours'] = str_pad((int)(($cron_freq/(60*60))),2,0,STR_PAD_LEFT);
|
||||
$out['mins'] =str_pad((int)(($cron_freq%(60*60))/60),2,0,STR_PAD_LEFT);
|
||||
$out ['id'] = $cron_id;
|
||||
$out ['status'] = $cron_st;
|
||||
$out['laststart']= $cron_started;
|
||||
$out['lastend'] =$cron_end;
|
||||
if($out['status'] == Vtiger_Cron::$STATUS_DISABLED )
|
||||
$out['status'] = $mod_strings['LBL_INACTIVE'];
|
||||
elseif($out['status'] == Vtiger_Cron::$STATUS_ENABLED)
|
||||
$out['status'] = $mod_strings['LBL_ACTIVE'];
|
||||
else
|
||||
$out['status'] = $mod_strings['LBL_RUNNING'];
|
||||
|
||||
$output [] = $out;
|
||||
}
|
||||
|
||||
$smarty->assign("CRON",$output);
|
||||
$smarty->assign("MOD", return_module_language($current_language,'CronTasks'));
|
||||
$smarty->assign("MIN_CRON_FREQUENCY",getMinimumCronFrequency());
|
||||
$smarty->assign("THEME", $theme);
|
||||
$smarty->assign("IMAGE_PATH",$image_path);
|
||||
$smarty->assign("APP", $app_strings);
|
||||
$smarty->assign("CMOD", $mod_strings);
|
||||
|
||||
if($_REQUEST['directmode'] != '')
|
||||
$smarty->display("modules/CronTasks/CronContents.tpl");
|
||||
else {
|
||||
$smarty->display("modules/CronTasks/Cron.tpl");
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
/*********************************************************************************
|
||||
** The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
********************************************************************************/
|
||||
|
||||
require_once('include/database/PearDatabase.php');
|
||||
require_once('include/utils/VtlibUtils.php');
|
||||
require_once('vtlib/Vtiger/Cron.php');
|
||||
global $adb;
|
||||
if(isset($_REQUEST['record']) && $_REQUEST['record']!='') {
|
||||
$cronTask = Vtiger_Cron::getInstanceById($_REQUEST['record']);
|
||||
$cronTask->updateStatus($_REQUEST['status']);
|
||||
if($_REQUEST['timevalue'] != '') {
|
||||
|
||||
if($_REQUEST['time'] == 'min') {
|
||||
|
||||
$time = $_REQUEST['timevalue']*60;
|
||||
}
|
||||
else {
|
||||
$time = $_REQUEST['timevalue']*60*60;
|
||||
}
|
||||
$cronTask->updateFrequency($time);
|
||||
}
|
||||
}
|
||||
$loc = "Location: index.php?action=CronTasksAjax&file=ListCronJobs&module=CronTasks&directmode=ajax";
|
||||
header($loc);
|
||||
?>
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
/** YOUR LICENSE TEXT HERE **/
|
||||
$mod_strings = Array (
|
||||
'LBL_ACTIVE' => 'Active',
|
||||
'LBL_INACTIVE' => 'InActive',
|
||||
'LBL_STATUS' => 'Status',
|
||||
'LBL_SCHEDULER' => 'Scheduler',
|
||||
'LBL_SETTINGS' => 'Settings',
|
||||
'LBL_FREQUENCY'=> 'Frequency',
|
||||
'LBL_HOURMIN' => '(H:M)',
|
||||
'LAST_START'=>'Last Scan Started',
|
||||
'LAST_END'=>'Last Scan Ended',
|
||||
'LBL_SEQUENCE'=>'Sequence',
|
||||
'LBL_TOOLS' =>'Tools',
|
||||
'LBL_DAYS'=>'Days',
|
||||
'LBL_HOURS'=>'Hours',
|
||||
'LBL_MINS'=>'Mins',
|
||||
'LBL_RUNNING'=>'Running',
|
||||
'LBL_MINIMUM_FREQUENCY'=>'Frequency of any cron job in configured to be greater than',
|
||||
'LBL_SECONDS'=>'sec ago',
|
||||
'LBL_MINUTES'=>'min(s) ago',
|
||||
'LBL_HOURS'=>'hr(s) ago',
|
||||
'LBL_DAYS'=>'day(s) ago',
|
||||
'LBL_MONTHS'=>'month(s) ago',
|
||||
'LBL_YEARS'=>'year(s) ago',
|
||||
);
|
||||
?>
|
|
@ -0,0 +1,67 @@
|
|||
{*<!--
|
||||
/*********************************************************************************
|
||||
** The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
********************************************************************************/
|
||||
-->*}
|
||||
<script language="JAVASCRIPT" type="text/javascript" src="include/js/smoothscroll.js"></script>
|
||||
<script language="JavaScript" type="text/javascript" src="include/js/menu.js"></script>
|
||||
<script language="JavaScript" type="text/javascript" src="modules/CronTasks/CronTasks.js"></script><br>
|
||||
<table align="center" border="0" cellpadding="0" cellspacing="0" width="98%">
|
||||
<tbody><tr>
|
||||
<td valign="top"><img src="{'showPanelTopLeft.gif'|@vtiger_imageurl:$THEME}"></td>
|
||||
<td class="showPanelBg" style="padding: 10px;" valign="top" width="100%">
|
||||
<br>
|
||||
<div align=center>
|
||||
{include file='SetMenu.tpl'}
|
||||
<!-- DISPLAY -->
|
||||
<table border=0 cellspacing=0 cellpadding=5 width=100% class="settingsSelUITopLine">
|
||||
<tr>
|
||||
<td width="50" rowspan="2" valign="top"><img src="{'Cron.png'|@vtiger_imageurl:$THEME}" alt="{$MOD.LBL_USERS}" width="48" height="48" border=0 title="{$MOD.LBL_USERS}"></td>
|
||||
<td colspan="2" class="heading2" valign=bottom align="left"><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > {$MOD.LBL_SCHEDULER} </b></td>
|
||||
<td rowspan=2 class="small" align=right> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign=top class="small" align="left">{$MOD.LBL_SCHEDULER}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table border=0 cellspacing=0 cellpadding=5 width=100% class="tableHeading">
|
||||
<tr><td> </td></tr>
|
||||
</table>
|
||||
<table width="100%" border="0" cellpadding="5" cellspacing="0" class="listTableTopButtons">
|
||||
<tr >
|
||||
<td style="padding-left:5px;" class="big">{$MOD.LBL_SCHEDULER}</td>
|
||||
<td align="right"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div id="notifycontents">
|
||||
{include file='modules/CronTasks/CronContents.tpl'}
|
||||
</div>
|
||||
|
||||
<table border=0 cellspacing=0 cellpadding=5 width=100% >
|
||||
<tr><td class="small" nowrap align=right><a href="#top">{$MOD.LBL_SCROLL}</a></td></tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
</td>
|
||||
<td valign="top"><img src="{'showPanelTopRight.gif'|@vtiger_imageurl:$THEME}"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div id="editdiv" style="display:none;position:absolute;width:450px;"></div>
|
|
@ -0,0 +1,53 @@
|
|||
{*<!--
|
||||
/*********************************************************************************
|
||||
** The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
********************************************************************************/
|
||||
-->*}
|
||||
<table width="100%" cellpadding="5" cellspacing="0" class="listTable" >
|
||||
<tr>
|
||||
<td class="colHeader small" width="5%">#</td>
|
||||
<td class="colHeader small" width="20%">Cron Job</td>
|
||||
<td class="colHeader small" width="15%">{$MOD.LBL_FREQUENCY}{$MOD.LBL_HOURMIN}</td>
|
||||
<td class="colHeader small" width="10%">{$CMOD.LBL_STATUS}</td>
|
||||
<td class="colHeader small" width="20%">{$MOD.LAST_START}</td>
|
||||
<td class="colHeader small" width="15%">{$MOD.LAST_END}</td>
|
||||
<td class="colHeader small" width='10%'>{$MOD.LBL_SEQUENCE}</td>
|
||||
<td class="colHeader small" width="5%">{$MOD.LBL_TOOLS}</td>
|
||||
</tr>
|
||||
{foreach name=cronlist item=elements from=$CRON}
|
||||
<tr>
|
||||
<td class="listTableRow small">{$smarty.foreach.cronlist.iteration}</td>
|
||||
<td class="listTableRow small">{$elements.cronname}</td>
|
||||
<td class="listTableRow small">{$elements.days} {$elements.hours}:{$elements.mins}</td>
|
||||
{if $elements.status eq 'Active'}
|
||||
<td class="listTableRow small active">{$elements.status}</td>
|
||||
{else}
|
||||
<td class="listTableRow small inactive">{$elements.status}</td>
|
||||
{/if}
|
||||
<td class="listTableRow small">{$elements.laststart}</td>
|
||||
<td class="listTableRow small">{$elements.lastend}</td>
|
||||
{if $smarty.foreach.cronlist.first neq true}
|
||||
<td align="center" class="listTableRow"><a href="javascript:move_module('{$elements.id}','Up');" ><img src="{'arrow_up.png'|@vtiger_imageurl:$THEME}" style="width:16px;height:16px;" border="0" /></a>
|
||||
{/if}
|
||||
{if $smarty.foreach.cronlist.last eq true}
|
||||
<img src="{'blank.gif'|@vtiger_imageurl:$THEME}" style="width:16px;height:16px;" border="0" />
|
||||
{/if}
|
||||
{if $smarty.foreach.cronlist.first eq true}
|
||||
<td align="center" class="listTableRow"><img src="{'blank.gif'|@vtiger_imageurl:$THEME}" style="width:16px;height:16px;" border="0" />
|
||||
<a href="javascript:move_module('{$elements.id}','Down');" ><img src="{'arrow_down.png'|@vtiger_imageurl:$THEME}" style="width:16px;height:16px;" border="0" /></a></td>
|
||||
{/if}
|
||||
|
||||
{if $smarty.foreach.cronlist.last neq true && $smarty.foreach.cronlist.first neq true}
|
||||
<a href="javascript:move_module('{$elements.id}','Down');" ><img src="{'arrow_down.png'|@vtiger_imageurl:$THEME}" style="width:16px;height:16px;" border="0" /></a></td>
|
||||
{/if}
|
||||
<td class="listTableRow small" align="center" ><img onClick="fnvshobj(this,'editdiv');fetchEditCron('{$elements.id}');" style="cursor:pointer;" src="{'editfield.gif'|@vtiger_imageurl:$THEME}" title="{$APP.LBL_EDIT}"></td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</table>
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
{*<!--
|
||||
/*********************************************************************************
|
||||
** The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
********************************************************************************/
|
||||
-->*}
|
||||
<div id="EditInv" class="layerPopup">
|
||||
<input id="min_freq" type="hidden" value="{$MIN_CRON_FREQUENCY}">
|
||||
<input id="desc" type="hidden" value="{'LBL_MINIMUM_FREQUENCY'|@getTranslatedString:$MODULE} {$MIN_CRON_FREQUENCY} {'LBL_MINS'|@getTranslatedString:$MODULE}" size="35" maxlength="40">
|
||||
<table border=0 cellspacing=0 cellpadding=5 width=100% class=layerHeadingULine>
|
||||
<tr>
|
||||
<td class="layerPopupHeading" align="left">{$CRON_DETAILS.label}</td>
|
||||
<td align="right" class="small"><img onClick="hide('editdiv');" style="cursor:pointer;" src="{'close.gif'|@vtiger_imageurl:$THEME}" align="middle" border="0"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table border=0 cellspacing=0 cellpadding=5 width=95% align=center>
|
||||
<tr>
|
||||
<td class="small">
|
||||
<table border=0 celspacing=0 cellpadding=5 width=100% align=center bgcolor=white>
|
||||
<tr>
|
||||
<td align="right" class="cellLabel small" width="40%"><b>{$MOD.LBL_STATUS} :</b></td>
|
||||
<td align="left" class="cellText small" width="60%">
|
||||
<select class="small" id="cron_status" name="cron_status">
|
||||
{if $CRON_DETAILS.status eq 1}
|
||||
<option value="1" selected>{$MOD.LBL_ACTIVE}</option>
|
||||
<option value="0">{$MOD.LBL_INACTIVE}</option>
|
||||
{else}
|
||||
<option value="1">{$MOD.LBL_ACTIVE}</option>
|
||||
<option value="0" selected>{$MOD.LBL_INACTIVE}</option>
|
||||
{/if}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" class="cellLabel small"><b>{$MOD.LBL_FREQUENCY}</b></td>
|
||||
<td align="left" class="cellText small" width="104px"><input class="txtBox" id="CronTime" name="CronTime" value="{$CRON_DETAILS.frequency}" style="width:25px;" type="text">
|
||||
<select class="small" id="cron_time" name="cron_status">
|
||||
{if $CRON_DETAILS.time eq 'min'}
|
||||
<option value="min" selected>{$MOD.LBL_MINS}</option>
|
||||
<option value="hours">{$MOD.LBL_HOURS}</option>
|
||||
{else}
|
||||
<option value="min" >{$MOD.LBL_MINS}</option>
|
||||
<option value="hours" selected>{$MOD.LBL_HOURS}</option>
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan=2>
|
||||
{$CRON_DETAILS.description}
|
||||
</td>
|
||||
<tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table border=0 cellspacing=0 cellpadding=5 width=100% class="layerPopupTransport">
|
||||
<tr>
|
||||
<td align="center" class="small">
|
||||
<input name="save" value="{$APP.LBL_SAVE_BUTTON_LABEL}" class="crmButton small save" type="button" onClick="fetchSaveCron('{$CRON_DETAILS.id}')">
|
||||
<input name="cancel" value="{$APP.LBL_CANCEL_BUTTON_LABEL}" class="crmButton small cancel" type="button" onClick="hide('editdiv');">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version='1.0'?>
|
||||
<module>
|
||||
<exporttime>2009-03-03 08:18:37</exporttime>
|
||||
<name>CustomerPortal</name>
|
||||
<label>CustomerPortal</label>
|
||||
<parent></parent>
|
||||
<type>extension</type>
|
||||
<version>1.4</version>
|
||||
<dependencies>
|
||||
<vtiger_version>5.1.0</vtiger_version>
|
||||
<vtiger_max_version>5.*</vtiger_max_version>
|
||||
</dependencies>
|
||||
<migrations>
|
||||
<migration version='1.0'>
|
||||
</migration>
|
||||
<migration version='1.1'>
|
||||
</migration>
|
||||
</migrations>
|
||||
<tables>
|
||||
<table>
|
||||
<name>vtiger_customerportal_fields</name>
|
||||
<sql><![CDATA[CREATE TABLE `vtiger_customerportal_fields` (
|
||||
`tabid` int(19) NOT NULL,
|
||||
`fieldid` int(19) default NULL,
|
||||
`visible` int(1) default NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8]]></sql>
|
||||
</table>
|
||||
</tables>
|
||||
</module>
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
/*********************************************************************************
|
||||
** The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
********************************************************************************/
|
||||
|
||||
global $app_strings, $mod_strings, $current_language, $currentModule, $theme,$current_user;
|
||||
require_once('Smarty_setup.php');
|
||||
require_once('modules/CustomerPortal/PortalUtils.php');
|
||||
require('user_privileges/user_privileges_'.$current_user->id.'.php');
|
||||
|
||||
if(!$is_admin) {
|
||||
echo "<table border='0' cellpadding='5' cellspacing='0' width='100%' height='450px'><tr><td align='center'>";
|
||||
echo "<div style='border: 3px solid rgb(153, 153, 153); background-color: rgb(255, 255, 255); width: 55%; position: relative; z-index: 10000000;'>
|
||||
|
||||
<table border='0' cellpadding='5' cellspacing='0' width='98%'>
|
||||
<tbody><tr>
|
||||
<td rowspan='2' width='11%'><img src= " . vtiger_imageurl('denied.gif', $theme) . " ></td>
|
||||
<td style='border-bottom: 1px solid rgb(204, 204, 204);' nowrap='nowrap' width='70%'>
|
||||
<span class='genHeaderSmall'>$app_strings[LBL_PERMISSION]</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='small' align='right' nowrap='nowrap'>
|
||||
<a href='javascript:window.history.back();'>$app_strings[LBL_GO_BACK]</a><br>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
</div>";
|
||||
echo "</td></tr></table>";
|
||||
exit;
|
||||
}
|
||||
|
||||
$mode = $_REQUEST['mode'];
|
||||
if($mode !='' && $mode == 'save') {
|
||||
cp_saveAdvancedSettings($_REQUEST);
|
||||
}
|
||||
$category = getParentTab();
|
||||
$smarty = new vtigerCRM_Smarty();
|
||||
$smarty->assign("THEME", $theme);
|
||||
$smarty->assign('MOD', $mod_strings);
|
||||
$smarty->assign('APP', $app_strings);
|
||||
$smarty->assign('MODULE', $currentModule);
|
||||
$smarty->assign('CATEGORY', $category);
|
||||
$smarty->assign('BUTTONS', $list_buttons);
|
||||
$smarty->assign('CHECK', $tool_buttons);
|
||||
$smarty->assign('IMAGE_PATH', "themes/$theme/images/");
|
||||
$smarty->assign('MODULE_VIEWALL',cp_getContactsViewInfo());
|
||||
|
||||
$smarty->assign('USERS', cp_getUsers());
|
||||
$smarty->assign('USERID',cp_getCurrentUser());
|
||||
$smarty->display(vtlib_getModuleTemplate($currentModule,'AdvancedSettings.tpl'));
|
||||
?>
|
|
@ -0,0 +1,63 @@
|
|||
/*********************************************************************************
|
||||
** The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
********************************************************************************/
|
||||
|
||||
function moveUp(moduleObj,sequence) {
|
||||
var oldSequence = moduleObj[sequence]['sequence'];
|
||||
var changeSequence = oldSequence - 1;
|
||||
|
||||
moduleObj[sequence]['sequence'] = moduleObj[changeSequence]['sequence'];
|
||||
moduleObj[changeSequence]['sequence']=oldSequence;
|
||||
|
||||
temp = new Object();
|
||||
temp=moduleObj[sequence];
|
||||
moduleObj[sequence]=moduleObj[changeSequence];
|
||||
moduleObj[changeSequence]=temp;
|
||||
|
||||
renderModuleSettings(moduleObj);
|
||||
}
|
||||
|
||||
function moveDown(moduleObj,sequence) {
|
||||
var oldSequence = moduleObj[sequence]['sequence'];
|
||||
var changeSequence = parseInt(oldSequence) + 1;
|
||||
|
||||
moduleObj[sequence]['sequence'] = moduleObj[changeSequence]['sequence'];
|
||||
moduleObj[changeSequence]['sequence']=oldSequence;
|
||||
|
||||
temp = new Object();
|
||||
temp=moduleObj[sequence];
|
||||
moduleObj[sequence]=moduleObj[changeSequence];
|
||||
moduleObj[changeSequence]=temp;
|
||||
renderModuleSettings(moduleObj);
|
||||
}
|
||||
|
||||
Object.prototype.size = function () {
|
||||
var len = this.length ? --this.length : -1;
|
||||
for (var k in this)
|
||||
len++;
|
||||
return len;
|
||||
}
|
||||
|
||||
function visibleValueChange(sequence,tabid,moduleObj) {
|
||||
if(moduleObj[sequence]['sequence'] == sequence && moduleObj[sequence]['tabid'] == tabid){
|
||||
if(moduleObj[sequence]['visible'] == 1)
|
||||
moduleObj[sequence]['visible'] = '0';
|
||||
else
|
||||
moduleObj[sequence]['visible'] = '1';
|
||||
}
|
||||
}
|
||||
|
||||
function prefValueChange(sequence,tabid,moduleObj) {
|
||||
if(moduleObj[sequence]['sequence'] == sequence && moduleObj[sequence]['tabid'] == tabid){
|
||||
if(moduleObj[sequence]['value'] == 1)
|
||||
moduleObj[sequence]['value'] = '0';
|
||||
else
|
||||
moduleObj[sequence]['value'] = '1';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
/*+********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
*******************************************************************************/
|
||||
|
||||
class CustomerPortal {
|
||||
|
||||
/**
|
||||
* Invoked when special actions are performed on the module.
|
||||
* @param String Module name
|
||||
* @param String Event Type
|
||||
*/
|
||||
function vtlib_handler($moduleName, $eventType) {
|
||||
|
||||
require_once('include/utils/utils.php');
|
||||
global $adb,$mod_strings;
|
||||
|
||||
if($eventType == 'module.postinstall') {
|
||||
$portalModules = array("HelpDesk","Faq","Invoice","Quotes","Products","Services","Documents",
|
||||
"Contacts","Accounts","Project","ProjectTask","ProjectMilestone","Assets");
|
||||
|
||||
$query = "SELECT max(sequence) AS max_tabseq FROM vtiger_customerportal_tabs";
|
||||
$res = $adb->pquery($query,array());
|
||||
$tabseq = $adb->query_result($res,0,'max_tabseq');
|
||||
$i = ++$tabseq;
|
||||
foreach($portalModules as $module) {
|
||||
$tabIdResult = $adb->pquery('SELECT tabid FROM vtiger_tab WHERE name=?', array($module));
|
||||
$tabId = $adb->query_result($tabIdResult, 0, 'tabid');
|
||||
if($tabId) {
|
||||
++$i;
|
||||
$adb->query("INSERT INTO vtiger_customerportal_tabs (tabid,visible,sequence) VALUES ($tabId,1,$i)");
|
||||
$adb->query("INSERT INTO vtiger_customerportal_prefs(tabid,prefkey,prefvalue) VALUES ($tabId,'showrelatedinfo',1)");
|
||||
}
|
||||
}
|
||||
|
||||
$adb->query("INSERT INTO vtiger_customerportal_prefs(tabid,prefkey,prefvalue) VALUES (0,'userid',1)");
|
||||
$adb->query("INSERT INTO vtiger_customerportal_prefs(tabid,prefkey,prefvalue) VALUES (0,'defaultassignee',1)");
|
||||
|
||||
// Mark the module as Standard module
|
||||
$adb->pquery('UPDATE vtiger_tab SET customized=0 WHERE name=?', array($moduleName));
|
||||
|
||||
$fieldid = $adb->getUniqueID('vtiger_settings_field');
|
||||
$blockid = getSettingsBlockId('LBL_OTHER_SETTINGS');
|
||||
$seq_res = $adb->pquery("SELECT max(sequence) AS max_seq FROM vtiger_settings_field WHERE blockid = ?", array($blockid));
|
||||
if ($adb->num_rows($seq_res) > 0) {
|
||||
$cur_seq = $adb->query_result($seq_res, 0, 'max_seq');
|
||||
if ($cur_seq != null) $seq = $cur_seq + 1;
|
||||
}
|
||||
|
||||
$adb->pquery('INSERT INTO vtiger_settings_field(fieldid, blockid, name, iconpath, description, linkto, sequence)
|
||||
VALUES (?,?,?,?,?,?,?)', array($fieldid, $blockid, 'LBL_CUSTOMER_PORTAL', 'portal_icon.png', 'PORTAL_EXTENSION_DESCRIPTION', 'index.php?module=CustomerPortal&action=index&parenttab=Settings', $seq));
|
||||
|
||||
|
||||
} else if($eventType == 'module.disabled') {
|
||||
// TODO Handle actions when this module is disabled.
|
||||
} else if($eventType == 'module.enabled') {
|
||||
// TODO Handle actions when this module is enabled.
|
||||
} else if($eventType == 'module.preuninstall') {
|
||||
// TODO Handle actions when this module is about to be deleted.
|
||||
} else if($eventType == 'module.preupdate') {
|
||||
// TODO Handle actions before this module is updated.
|
||||
} else if($eventType == 'module.postupdate') {
|
||||
// TODO Handle actions after this module is updated.
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
/*********************************************************************************
|
||||
** The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
********************************************************************************/
|
||||
require_once('include/Ajax/CommonAjax.php');
|
||||
?>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue