This is an old revision of the document!


Table of Contents

Check Version In Store (code snippet)

Description

Using either the Store Id or the Plugin Name (title) or Plugin Filename retrieves the current Plugin Store version. The current plugin filename can be obtained using fhGetContextInfo('CI_PLUGIN_NAME')

Requires: luacom

Code

require('luacom')
 
function checkVersionInStore(type,value)
--[[
@description: Checks the version in the plugin store by name or id
@Parms:
1: String, must be either 'id' or 'name' or file
2: String where name search or number where id search
@Returns:
1: nil where value not found or parameter 1 is invalid,
or the value of the plugins version field
]]
    if type ~= 'id' and type ~= 'name' and type ~= 'file' then
        return nil
    end
    if value then
        local http = luacom.CreateObject("winhttp.winhttprequest.5.1")
        strRequest ='http://www.family-historian.co.uk/lnk/checkpluginversion.php?'..type..'='..value
 
        http:Open("GET",strRequest,false)
        http:Send()
        local strReturn = http.Responsebody
        local ver = ''
        local ref = ''
        if strReturn ~= nil then
            ver,ref = strReturn:match('(%d.*),(%d*)')
        end
        return ver,ref
 
    else
        return nil
    end
end

Example Usage

pluginname = fhGetContextInfo('CI_PLUGIN_NAME')..'.fh_lua'
version,reference = checkVersionInStore('file',pluginname)
print(pluginname,version,reference)
 
print(checkVersionInStore('id',199))
print(checkVersionInStore('name','Timeline Chart'))

Section plugins:code_snippets

plugins/code_snippets/check_version_in_store.1338279338.txt.gz · Last modified: 2012/05/29 03:15 by jane
CC Attribution-Noncommercial-Share Alike 3.0 Unported
Driven by DokuWiki Recent changes RSS feed Valid XHTML 1.0