public function __viewInfo() { $this->setPageType('form'); $datasource = DatasourceManager::create($this->_context[1], array(), false); $about = $datasource->about(); $this->setTitle(__('%1$s – %2$s – %3$s', array($about['name'], __('Data Source'), __('Symphony')))); $this->appendSubheading($this->_context[0] == 'info' ? $about['name'] : __('Untitled')); $this->insertBreadcrumbs(array(Widget::Anchor(__('Data Sources'), SYMPHONY_URL . '/blueprints/datasources/'))); $this->Form->setAttribute('id', 'controller'); $link = $about['author']['name']; if (isset($about['author']['website'])) { $link = Widget::Anchor($about['author']['name'], General::validateURL($about['author']['website'])); } elseif (isset($about['author']['email'])) { $link = Widget::Anchor($about['author']['name'], 'mailto:' . $about['author']['email']); } foreach ($about as $key => $value) { $fieldset = null; switch ($key) { case 'author': if ($link) { $fieldset = new XMLElement('fieldset'); $fieldset->appendChild(new XMLElement('legend', __('Author'))); $fieldset->appendChild(new XMLElement('p', $link->generate(false))); } break; case 'version': $fieldset = new XMLElement('fieldset'); $fieldset->appendChild(new XMLElement('legend', __('Version'))); $release_date = array_key_exists('release-date', $about) ? $about['release-date'] : filemtime(DatasourceManager::__getDriverPath($this->_context[1])); if (preg_match('/^\\d+(\\.\\d+)*$/', $value)) { $fieldset->appendChild(new XMLElement('p', __('%1$s released on %2$s', array($value, DateTimeObj::format($release_date, __SYM_DATE_FORMAT__))))); } else { $fieldset->appendChild(new XMLElement('p', __('Created by %1$s at %2$s', array($value, DateTimeObj::format($release_date, __SYM_DATE_FORMAT__))))); } break; case 'description': $fieldset = new XMLElement('fieldset'); $fieldset->appendChild(new XMLElement('legend', __('Description'))); $fieldset->appendChild(is_object($about['description']) ? $about['description'] : new XMLElement('p', $about['description'])); break; case 'example': if (is_callable(array($datasource, 'example'))) { $fieldset = new XMLElement('fieldset'); $fieldset->appendChild(new XMLElement('legend', __('Example XML'))); $example = $datasource->example(); if (is_object($example)) { $fieldset->appendChild($example); } else { $p = new XMLElement('p'); $p->appendChild(new XMLElement('pre', '<code>' . str_replace('<', '<', $example) . '</code>')); $fieldset->appendChild($p); } } break; } if ($fieldset) { $fieldset->setAttribute('class', 'settings'); $this->Form->appendChild($fieldset); } } // Display source $file = DatasourceManager::__getClassPath($this->_context[1]) . '/data.' . $this->_context[1] . '.php'; if (file_exists($file)) { $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings'); $fieldset->appendChild(new XMLElement('legend', __('Source'))); $source = file_get_contents($file); $code = new XMLElement('code', htmlspecialchars($source)); $pre = new XMLElement('pre'); $pre->appendChild($code); $fieldset->appendChild($pre); $this->Form->appendChild($fieldset); } }