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