1: <?php
2:
3: /**
4: *
5: * @package Plugin
6: * @subpackage FormAssistant
7: * @author Marcus Gnaß <marcus.gnass@4fb.de>
8: * @copyright four for business AG
9: * @link http://www.4fb.de
10: */
11:
12: // assert CONTENIDO framework
13: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
14:
15: plugin_include(Pifa::getName(), 'classes/class.pifa.external_options_datasource_interface.php');
16:
17: /**
18: * This is an example for an external options data source.
19: *
20: * @author Marcus Gnaß <marcus.gnass@4fb.de>
21: */
22: class ExampleOptionsDatasource extends PifaExternalOptionsDatasourceInterface {
23:
24: /**
25: * Stores the options as associative array which maps values to labels.
26: *
27: * @var array
28: */
29: protected $_options = NULL;
30:
31: /**
32: * Gets options from an external data source and return them as associative
33: * array which maps values to labels.
34: *
35: * @return array
36: */
37: protected function _getData() {
38: $options = array(
39: 'n/a' => mi18n("CHOOSE_OPTION"),
40: 'foo' => mi18n("FOO"),
41: 'bar' => mi18n("BAR")
42: );
43:
44: return $options;
45: }
46:
47: /**
48: *
49: * @see ExternalOptionsDatasourceInterface::getOptionLabels()
50: */
51: public function getOptionLabels() {
52: if (NULL === $this->_options) {
53: $this->_options = $this->_getData();
54: }
55: return array_values($this->_options);
56: }
57:
58: /**
59: *
60: * @see ExternalOptionsDatasourceInterface::getOptionValues()
61: */
62: public function getOptionValues() {
63: if (NULL === $this->_options) {
64: $this->_options = $this->_getData();
65: }
66: return array_keys($this->_options);
67: }
68: }
69: