Can’t find a certain feature you want ? You think that feature should be included ? You just saw a cool new tool in an external library ? Then, you can easily create and contribute it !
Simply follow this procedure when creating a new widget. This won’t tell you exactly what to do, but how to do it.
List the things your widget should do. Look for similar functionnalities in existing web-mapping application to work from.
Use the Developers mailing list to let the developers know of your intentions.
Create a new ticket in TRAC with complete details of the new features the widget should have.
Create a new directory for you widget (must be in lowercase). That same name will always be use thereafter so choose it wisely. You can also create a Sub-directories structure.
Copy all files from the Sample widget to your new widget directory. Change their name respecting the case, for example :
You might have copied the hidded svn folder too. Simply remove it if you did.
Edit the php file. Here’s what you need to change :
class name: | Change the class name to your widget name (case sensitive) |
---|---|
class action: | Set the widget action. Possible values are :
|
type: | Set the widget type, which is the name of the widget in lowercase. If you use the Sub-directories structure, use the complete name (with ‘_’). |
See also
Make the following changes in YourWidget.xslt
Namespace definition: | |
---|---|
Define the namespace of your widget. Example : xmlns:yourwidget="http://opensafemap.org/yourwidget"
|
|
Apply the namespaces to templates: | |
Set the namespace of your widget to all templates (functions) in this file. Example : <xsl:template name="yourwidget:printWidgetSource">
|
|
Included JS and CSS (optional): | |
In the printWidgetSource template, you define the external js/css files your widget includes. Change the <xsl:text>...</xsl:text>
portion for each external script/link your widget needs. Example (script) : <script>
<xsl:attribute name="src" >
<xsl:value-of select="$g_widgets_url"/>
<xsl:text>/yourwidget/YourWidget.js</xsl:text>
</xsl:attribute>
</script>
Example (link) : <link rel="stylesheet" type="text/css" >
<xsl:attribute name="href" >
<xsl:value-of select="$g_widgets_url"/>
<xsl:text>/yourwidget/YourWidget.css</xsl:text>
</xsl:attribute>
</link>
|
The global file is located in the [your_geoprisma_dir]/src/client/templates/inc directory.
Namespace definition: | |
---|---|
Add a namespace for your widget. Example : xmlns:yourwidget="http://opensafemap.org/yourwidget"
|
|
Extension prefix: | |
Add the extension prefix of your widget to the extension-element-prefixes
|
|
printAllWidgetSources: | |
Locate this template and the following lines to it : <xsl:when test="$WidgetType='yourwidget'">
<xsl:call-template name="yourwidget:printWidgetSource"/>
</xsl:when>
|
|
printAllWidgetExecutions: | |
Locate this template add the following lines to it : <xsl:when test="$WidgetType='yourwidget'">
<xsl:call-template name="yourwidget:printWidgetExecution">
<xsl:with-param name="pWidgetName" select="$WidgetName" />
<xsl:with-param name="pMapName" select="$pMapName" />
</xsl:call-template>
</xsl:when>
|
If your widget needs any specific styling, put it in the .css file, else simply remove it.
Create a new sample demonstrating the use of your widget. If your widget has many options, create a sample directory with many sub-directories of your widget with the use of those different options.
See also
Edit your sample’s Template (XSLT) .