/**
  * Whenever we save the content source, we want to disconnect 
  * the repository so that it reconnects with whatever new connection
  * details are provided
  * 
  * @see sapphire/core/model/DataObject#onBeforeWrite()
  */
 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     $repo = $this->getRemoteRepository();
     if ($repo->isConnected()) {
         $repo->disconnect();
     }
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->addFieldToTab('Root.Main', new TextField('Query', _t('TwitterConnector.SEARCH_QUERY', 'Search Query (optional)')));
     $fields->addFieldToTab('Root.Main', new TextField('Username', _t('ExternalContentSource.USER', 'Username')));
     $fields->addFieldToTab('Root.Main', new TextField('Password', _t('ExternalContentSource.PASS', 'Password')));
     return $fields;
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->addFieldToTab('Root.Main', new TextField('Host', _t('LdapContentSource.HOST', 'Host')));
     $fields->addFieldToTab('Root.Main', new TextField('Port', _t('LdapContentSource.PORT', 'Port'), 389));
     $fields->addFieldToTab('Root.Main', new TextField('BaseDN', _t('LdapContentSource.BASEDN', 'Base DN')));
     $fields->addFieldToTab('Root.Main', new TextField('BindUser', _t('LdapContentSource.BINDUSER', 'Bind User (if any)')));
     $fields->addFieldToTab('Root.Main', new PasswordField('BindPass', _t('LdapContentSource.BINDPASS', 'Bind Pass (if any)')));
     return $fields;
 }
 public function onAfterWrite()
 {
     parent::onAfterWrite();
     $urlList = $this->urlList();
     if ($this->isChanged('UrlProcessor') && $urlList->hasCrawled()) {
         if ($processorClass = $this->UrlProcessor) {
             $urlList->setUrlProcessor(new $processorClass());
         } else {
             $urlList->setUrlProcessor(null);
         }
         $urlList->reprocessUrls();
     }
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     Requirements::css('rssconnector/css/RssContentAdmin.css');
     $fields->addFieldToTab('Root.Main', new TextField('Url', 'RSS/Atom Feed URL'), 'ShowContentInMenu');
     $fields->addFieldToTab('Root.Advanced', new NumericField('CacheLifetime', 'Cache Lifetime (in seconds)'));
     if (!$this->Url || !($client = $this->getClient())) {
         return $fields;
     }
     if ($client->error) {
         $message = 'The feed URL entered appears to be invalid, or could not be loaded.';
         $error = $client->error;
         $fields->addFieldToTab('Root.Main', new LiteralField('InvalidFeed', sprintf('<p id="invalid-feed">%s<span>%s</span></p>', $message, $error)), 'Name');
         return $fields;
     }
     $fields->addFieldsToTab('Root.Main', array(new HeaderField('FeedDetailsHeader', 'Feed Details'), new ReadonlyField('FeedTitle', 'Title', $client->get_title()), new ReadonlyField('FeedDescription', 'Description', $client->get_description()), new ReadonlyField('FeedLink', 'Link', $client->get_link())));
     // If the blog module doesn't exist, we can't run imports.
     if (!class_exists('BlogEntry')) {
         $fields->addFieldToTab('Root.Import', new LiteralField('RequiresBlogImport', '<p>The RSS connector requires the blog ' . 'module to import RSS items.</p>'));
         return $fields;
     }
     $fields->addFieldsToTab('Root.Import', array(new HeaderField('PostImportHeader', 'Post Import Settings'), new CheckboxField('PublishPosts', 'Publish imported posts?', true), new CheckboxField('ProvideComments', 'Allow comments on imported posts?', true), new HeaderField('TagsImportHeader', 'Tags Import Settings'), new CheckboxField('ImportCategories', 'Import categories as tags?', true), new DropdownField('UnknownCategories', 'Unknown categories', array('create' => 'Have a tag created for them', 'skip' => 'Are ignored')), new TextField('ExtraTags', 'Tags to include on imported posts (comma separated)'), new HeaderField('GeneralImportHeader', 'General Import Settings')));
     return $fields;
 }
 /**
  * Returns whether or not this source can be imported, defaulting to the
  * linked source's permission.
  *
  * @return bool
  */
 public function canImport()
 {
     return $this->source->canImport();
 }
 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     $this->FolderPath = str_replace('\\', '/', $this->FolderPath);
 }
 /**
  * @return array
  */
 public function fieldLabels($includerelations = true)
 {
     return array_merge(parent::fieldLabels($includerelations), array('ConnError' => _t('DrupalConnector.CONNERROR', 'Could not connect to the Drupal site:'), 'BaseUrl' => _t('DrupalConnector.WPBASEURL', 'Drupal Base URL'), 'Username' => _t('DrupalConnector.WPUSER', 'Drupal Username'), 'Password' => _t('DrupalConnector.WPPASS', 'Drupal Password')));
 }
 /**
  * @return array
  */
 public function fieldLabels($includerelations = true)
 {
     return array_merge(parent::fieldLabels(), array('ConnError' => _t('WordpresConnector.CONNERROR', 'Could not connect to the wordpress site:'), 'BaseUrl' => _t('WordpressConnector.WPBASEURL', 'Wordpress Base URL'), 'BlogId' => _t('WordpressConnector.BLOGID', 'Wordpress Blog ID'), 'Username' => _t('WordpressConnector.WPUSER', 'Wordpress Username'), 'Password' => _t('WordpressConnector.WPPASS', 'Wordpress Password')));
 }