Skip to content

Commit

Permalink
Merge pull request #10 from designermonkey/integration
Browse files Browse the repository at this point in the history
Version 1.2.0
  • Loading branch information
twiro authored Jan 29, 2018
2 parents be8312b + 915618b commit d973df6
Show file tree
Hide file tree
Showing 6 changed files with 413 additions and 215 deletions.
6 changes: 3 additions & 3 deletions LICENCE
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
All source code included in the "Field: Number" Symphony Extension archive
is, unless otherwise specified, released under the MIT licence as follows:
All source code included in the "Incremental Number Field" archive is,
unless otherwise specified, released under the MIT licence as follows:

----- begin license block -----

Copyright 2008 Alistair Kearney, Allen Chang, Scott Hughes
Copyright 2011–2018 John Porter

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
15 changes: 0 additions & 15 deletions README.markdown

This file was deleted.

16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Incremental Number Field

A field that automatically increments it's value by one for each new entry in a section.

## 1. Installation

1. Upload the `/incremental_number` folder in this archive to your Symphony `/extensions` folder.
2. Go to '**System → Extensions**' in your Symphony admin area.
3. Enable the extension by selecting '**Field: Incremental Number**', choose '**Enable**' from the '**With Selected…**' menu, then click '**Apply**'.

## 2. Usage

1. Add the field type '**Incremental Number**' to a section of your choice.
2. Define a valid '**Start Number**' for the field (has to be a natural number, e.g. `0` or `1`).
3. Now each time you create an entry in this section the '**Incremental Number**'-field will automatically get populated by fetching the '**Incremental Number**'-value of the previous entry and incrementing it by 1. If there is no previous entry in the section the field will instead get populated with the given '**Start Number**'.
4. You can't manually edit the values of an '**Incremental Number Field**' – they're read-only.
110 changes: 77 additions & 33 deletions extension.driver.php
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,33 +1,77 @@
<?php

Class extension_incremental_number extends Extension
{

public function uninstall(){
try{
Symphony::Database()->query("DROP TABLE `tbl_fields_incremental_number`");
}
catch( Exception $e ){
}

return true;
}


public function install(){
try{
Symphony::Database()->query(
"CREATE TABLE `tbl_fields_incremental_number` (
`id` int(11) unsigned NOT NULL auto_increment,
`field_id` int(11) unsigned NOT NULL,
`start_number` int(11) unsigned NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `field_id` (`field_id`)
) TYPE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"
);
} catch( Exception $e ){
}

return true;
}
}
<?php

class extension_incremental_number extends Extension
{
/**
*
* Name of the extension field table
* @var string
*
* @since version 1.2.0
*/

const FIELD_TBL_NAME = 'tbl_fields_incremental_number';

/**
*
* install the extension
*
* @since version 1.0.0
*/

public function install()
{
return self::createFieldTable();
}

/**
*
* create the field table
*
* @since version 1.2.0
*/

public static function createFieldTable()
{
$tbl = self::FIELD_TBL_NAME;

return Symphony::Database()->query("
CREATE TABLE IF NOT EXISTS `$tbl` (
`id` int(11) unsigned NOT NULL auto_increment,
`field_id` int(11) unsigned NOT NULL,
`start_number` int(11) unsigned NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `field_id` (`field_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
");
}

/**
*
* uninstall
*
* @since version 1.0.0
*/

public function uninstall()
{
return self::deleteFieldTable();
}

/**
*
* delete the field table
*
* @since version 1.2.0
*/

public static function deleteFieldTable()
{
$tbl = self::FIELD_TBL_NAME;

return Symphony::Database()->query("
DROP TABLE IF EXISTS `$tbl`
");
}

}
39 changes: 20 additions & 19 deletions extension.meta.xml
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension id="incremental_number" status="released" xmlns="http://symphony-cms.com/schemas/extension/1.0">
<extension id="incremental_number" status="released" xmlns="http://getsymphony.com/schemas/extension/1.0">
<name>Incremental Number Field</name>

<description>Increment a number per entry in a section</description>

<description>A field that automatically increments it's value by one for each new entry in a section.</description>
<repo type="github">https://github.com/designermonkey/incremental_number</repo>

<url type="discuss">http://symphony-cms.com/discuss/thread/81151/</url>

<url type="issues">https://github.com/designermonkey/incremental_number/issues</url>
<url type="discuss">http://www.getsymphony.com/discuss/thread/81151/</url>
<types>
<type>Field Types</type>
<type>Field</type>
</types>

<authors>
<author>
<name github="designermonkey" symphony="designermonkey">John Porter</name>
<website>http://designermonkey.co.uk</website>
</author>
<author>
<name github="vlad-ghita" symphony="vladG">Vlad Ghita</name>
<email>[email protected]</email>
<website>http://www.xanderadvertising.com</website>
<name github="twiro" symphony="roman">Roman Klein</name>
<website>https://github.com/twiro</website>
</author>
</authors>

<releases>
<release version="1.1.0" date="2012-05-24" min="2.3"><![CDATA[
* Cleanup & Symphony 2.3 compatibility.
]]></release>

<release version="1.0.0" date="2011-11-28" min="2.2" />
<release version="1.2.0" date="2018-01-29" min="2.4.0" max="2.x.x">
- Code cleanup &amp; reformatting
- Improved Readme &amp; fixed Meta
- PHP 7.0 compatibility
- Symphony 2.6 &amp; 2.7 compatibility [#8](https://github.com/designermonkey/incremental_number/issues/8)
- Added field settings validation [#9](https://github.com/designermonkey/incremental_number/issues/9)
</release>
<release version="1.1.0" date="2012-05-24" min="2.3.0" max="2.6.x">
- Cleanup &amp; Symphony 2.3 compatibility.
</release>
<release version="1.0.0" date="2011-11-28" min="2.2.0" max="2.2.x">
- Initial release
</release>
</releases>

</extension>
Loading

0 comments on commit d973df6

Please sign in to comment.