public function uninstall() { //CREATE THE HORRIBLE FILTER STRING $this->dsFilter = ' //PREVIEW LINK EXTENSION: Remove Filters' . PHP_EOL; $this->dsFilter .= ' if (!strpos($_SERVER[‘HTTP_USER_AGENT’],"Googlebot")) {' . PHP_EOL; $this->dsFilter .= ' if(sha1($_GET["entryid"]) == $_GET["key"]) {' . PHP_EOL; $this->dsFilter .= ' $filters = $this->dsParamFILTERS;' . PHP_EOL; $this->dsFilter .= ' foreach($filters as $key=>$filter) {' . PHP_EOL; $this->dsFilter .= ' unset($this->dsParamFILTERS[$key]);' . PHP_EOL; $this->dsFilter .= ' }' . PHP_EOL; $this->dsFilter .= ' $this->dsParamFILTERS["id"] = $_GET["entryid"];' . PHP_EOL; $this->dsFilter .= ' }' . PHP_EOL; $this->dsFilter .= ' }'; //Loop through all datasources and remove the preview code if present. if (!isset(self::$datasourceManager)) { self::$datasourceManager = new DatasourceManager(Symphony::Engine()); } $dses = self::$datasourceManager->listAll(); foreach ($dses as $ds) { $file = self::$datasourceManager->__getDriverPath($ds['handle']); //FIRST GET FILE CONTENTS $current_content = file_get_contents($file); //THEN REMOVE FILTER CODE $new_content = str_replace(PHP_EOL . PHP_EOL . $this->dsFilter, '', $current_content); //THEN REPALCE FILE CONTENTS file_put_contents($file, $new_content); } //DROP THE DB TABLE $this->_Parent->Database->query("DROP TABLE `tbl_fields_preview_url`"); }
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); } }