-
Notifications
You must be signed in to change notification settings - Fork 1
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 #32 from delcroip/develop
1.0.2
- Loading branch information
Showing
39 changed files
with
1,341 additions
and
1,202 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [{ | ||
"name": "Listen for XDebug on Docker App", | ||
"type": "php", | ||
"request": "launch", | ||
"port": 9000, | ||
"pathMappings": { | ||
"/var/www/html": "${workspaceFolder}" | ||
}, | ||
"hostname": "localhost", | ||
"xdebugSettings": { | ||
"max_data": 65535, | ||
"show_hidden": 1, | ||
"max_children": 100, | ||
"max_depth": 5 | ||
} | ||
},] | ||
} |
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 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,179 @@ | ||
<?php | ||
|
||
use Symfony\Component\Finder\Finder; | ||
|
||
/** | ||
* This is project's console commands configuration for Robo task runner. | ||
* | ||
* @see http://robo.li/ | ||
*/ | ||
class RoboFile extends \Robo\Tasks { | ||
|
||
protected $name = "openmedis"; | ||
protected $issues = "https://github.com/delcroip/glpi_plugin_openmedis"; | ||
protected $locale_keywords = "t_openmedis"; | ||
|
||
protected function getLocaleFiles() { | ||
$finder = new Finder(); | ||
$finder | ||
->files() | ||
->name('*.po') | ||
->in('locales'); | ||
|
||
$files = []; | ||
foreach ($finder as $file) { | ||
$files[] = str_replace('\\', '/', $file->getRelativePathname()); | ||
} | ||
|
||
return $files; | ||
} | ||
|
||
public function compile_locales() { | ||
$files = $this->getLocaleFiles(); | ||
|
||
foreach ($files as $file) { | ||
$lang = basename($file, ".po"); | ||
|
||
$this->taskExec('msgfmt')->args([ | ||
"locales/$lang.po", | ||
"-o", | ||
"locales/$lang.mo", | ||
])->run(); | ||
} | ||
} | ||
|
||
public function update_locales() { | ||
$finder = new Finder(); | ||
$finder | ||
->files() | ||
->name('*.php') | ||
->in(__DIR__) | ||
->exclude([ | ||
'vendor' | ||
]) | ||
->sortByName(); | ||
|
||
if (!$finder->hasResults()) { | ||
return false; | ||
} | ||
|
||
$args = []; | ||
|
||
foreach ($finder as $file) { | ||
$args[] = str_replace('\\', '/', $file->getRelativePathname()); | ||
} | ||
|
||
$args[] = '-D'; | ||
$args[] = '.'; | ||
$args[] = '-o'; | ||
$args[] = "locales/{$this->name}.pot"; | ||
$args[] = '-L'; | ||
$args[] = 'PHP'; | ||
$args[] = '--add-comments=TRANS'; | ||
$args[] = '--from-code=UTF-8'; | ||
$args[] = '--force-po'; | ||
$args[] = "--keyword={$this->locale_keywords}"; | ||
$args[] = "--package-name={$this->name}"; | ||
|
||
if ($this->issues) { | ||
$args[] = "--msgid-bugs-address={$this->issues}"; | ||
} | ||
|
||
try { | ||
$content = file_get_contents('setup.php'); | ||
$name = 'PLUGIN_' . strtoupper($this->name) . '_VERSION'; | ||
preg_match("/'$name',\s*'([\w\.]+)'/", $content, $matches); | ||
$args[] = '--package-version=' . $matches[1]; | ||
} catch (\Exception $ex) { | ||
echo $ex->getMessage(); | ||
} | ||
|
||
putenv("LANG=C"); | ||
|
||
$this->taskExec('xgettext')->args($args)->run(); | ||
|
||
$this->taskReplaceInFile("locales/{$this->name}.pot") | ||
->from('CHARSET') | ||
->to('UTF-8') | ||
->run(); | ||
|
||
$this->taskExec('msginit')->args([ | ||
'--no-translator', | ||
'-i', | ||
"locales/{$this->name}.pot", | ||
'-l', | ||
'en_GB.UTF8', | ||
'-o', | ||
'locales/en_GB.po', | ||
])->run(); | ||
|
||
$files = $this->getLocaleFiles(); | ||
|
||
foreach ($files as $file) { | ||
$lang = basename($file, ".po"); | ||
|
||
if ($lang === "en_GB") { | ||
continue; | ||
} | ||
|
||
$this->taskExec('msgmerge')->args([ | ||
"--update", | ||
"locales/$lang.po", | ||
"locales/{$this->name}.pot", | ||
"--lang=$lang", | ||
"--backup=off", | ||
])->run(); | ||
} | ||
|
||
$this->compile_locales(); | ||
} | ||
|
||
public function build() { | ||
$this->_remove(["$this->name.zip", "$this->name.tgz"]); | ||
|
||
$this->compile_locales(); | ||
|
||
$tmpPath = $this->_tmpDir(); | ||
|
||
$exclude = glob(__DIR__ . '/.*'); | ||
$exclude[] = 'plugin.xml'; | ||
$exclude[] = 'screenshots'; | ||
$exclude[] = 'tools'; | ||
$exclude[] = 'vendor'; | ||
$exclude[] = "$this->name.zip"; | ||
$exclude[] = "$this->name.tgz"; | ||
|
||
$this->taskCopyDir([__DIR__ => $tmpPath]) | ||
->exclude($exclude) | ||
->run(); | ||
|
||
$composer_file = "$tmpPath/composer.json"; | ||
if (file_exists($composer_file)) { | ||
$hasDep = false; | ||
try { | ||
$data = json_decode(file_get_contents($composer_file), true); | ||
$hasDep = isset($data['require']) && count($data['require']) > 0; | ||
} catch (\Exception $ex) { | ||
$hasDep = true; | ||
} | ||
|
||
if ($hasDep) { | ||
$this->taskComposerInstall() | ||
->workingDir($tmpPath) | ||
->noDev() | ||
->run(); | ||
} | ||
} | ||
|
||
$this->_remove("$tmpPath/composer.lock"); | ||
|
||
// Pack | ||
$this->taskPack("$this->name.zip") | ||
->addDir($this->name, $tmpPath) | ||
->run(); | ||
|
||
$this->taskPack("$this->name.tgz") | ||
->addDir($this->name, $tmpPath) | ||
->run(); | ||
} | ||
} |
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,13 @@ | ||
# openmedis plugin change log | ||
|
||
## 1.0.2: | ||
- MD category used for accessory too | ||
- Report MD per utilization | ||
|
||
## < 1.0.1 | ||
- list of Medical Device | ||
- category of MD (similar to Type of other GLPI asset) | ||
- model of MD | ||
- MD accessory | ||
- model of MD | ||
- Medical consulmables |
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,74 @@ | ||
# GPLI plugin Development lesson learned | ||
|
||
Glpi rely a lot on the database schema a naming, therefore tables or class name that are compliant will generate bugs or will limits the acces to glpi functions | ||
|
||
Table should have this form: glpi_plugin_[pluginname (all lower and without _)]_[elementname (all lower)] | ||
The class should have this form Plugin[Pluginname(only first letter in CAP)][ElementName (singular form, start with CAP, may have CAP in it)] | ||
|
||
## Asset | ||
|
||
### Schema fields | ||
when creating an asset there is fields that must be created | ||
ticket_tco | ||
is_deleted | ||
name | ||
id | ||
... | ||
|
||
if you want to have devices per entity | ||
is_recursive | ||
entity_id | ||
|
||
|
||
### other schema | ||
|
||
<AssetClass>Type is a std class expected by some reports, alias works when the class have a differnet name | ||
|
||
|
||
## component | ||
|
||
add the "component/ itemDevice" types you want while registering the function | ||
|
||
eg. pluginopenmedisitemdevicemedicalaccessory_types | ||
|
||
and "$this->addStandardTab('Item_Devices', $ong, $options);" in defineTabs function | ||
|
||
## consumable | ||
|
||
you may use the std consomable or create your own class then, in both cases you will have to add the left menu | ||
|
||
$this->addStandardTab('PluginOpenmedisMedicalConsumable', $ong, $options); | ||
|
||
|
||
|
||
## reservation | ||
|
||
use "reservation_types" to activate the reservation | ||
|
||
and "$this->addStandardTab('Reservation', $ong, $options);" in defineTabs function | ||
|
||
Do NOT add the "planning_types", this type is reserved to planning class | ||
|
||
## class function | ||
|
||
getIcon(): Define the icon used in UI (awsome font) | ||
getTypeName: return the string to be displayed for the asset type | ||
getTypes($all = false): Get the allowed component type (to be confirmed) | ||
getType(): return the type of the asset | ||
registerType($type): For other plugins, add a type to the linkable types | ||
getLinkedItems: get linked compenent, all components are in "glpi_computers_items" but the itemtype specify to which asset () use get Type | ||
rawSearchOptions(): used for the list search in the asset pages | ||
getSpecificMassiveActions($checkitem = null): specifiy massive actions | ||
showForm($ID, $options = []): template for the UI | ||
prepareInputForAdd() unction called before the creation of an item, can be usefule when cloning | ||
post_addItem() function called after the creation of an item, can be usefule when cloning | ||
defineTabs($options = []): define the tab to be showed (to be used coherently with _types registered) | ||
redirectToList(): link for the asset list page | ||
|
||
## financial information | ||
|
||
in order to activate "infocom_types" on asset, the fields "ticket_tco" must be part of the database table | ||
|
||
then just add "infocom_types" when regestering your class in setup.php | ||
|
||
and "$this->addStandardTab('Infocom', $ong, $options);" in defineTabs function |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.