-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from designermonkey/integration
Version 1.2.0
- Loading branch information
Showing
6 changed files
with
413 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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` | ||
"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 & reformatting | ||
- Improved Readme & fixed Meta | ||
- PHP 7.0 compatibility | ||
- Symphony 2.6 & 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 & 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> |
Oops, something went wrong.