public function setup()
 {
     parent::setup();
     $this->useFields(array('source', 'destination', 'content_id'));
     // Setup the content_id widget
     sfSympalFormToolkit::changeContentWidget($this);
 }
 public function setup()
 {
     parent::setup();
     if (isset($this['value'])) {
         sfSympalFormToolkit::changeContentSlotValueWidget($this->object->sfSympalContentSlot, $this);
     }
 }
 protected function setupValueField()
 {
     if (isset($this['value'])) {
         $this->useFields(array('value', 'type'));
         sfSympalFormToolkit::changeContentSlotValueWidget($this->object, $this);
     }
 }
 /**
  * Converts some fields to rich date fields
  */
 protected function setupRichDateFields(sfForm $form)
 {
     $richDateForms = sfSympalConfig::get('form', 'rich_date_forms', array());
     $formClass = get_class($form);
     $fields = isset($richDateForms[$formClass]) ? $richDateForms[$formClass] : array();
     foreach ($fields as $name) {
         $widget = $form[$name]->getWidget();
         if ($widget instanceof sfWidgetFormDateTime || $widget instanceof sfWidgetFormDate) {
             sfSympalFormToolkit::changeDateWidget($name, $form);
         }
     }
 }
 public function setup()
 {
     parent::setup();
     $this->validatorSchema->setOption('allow_extra_fields', true);
     unset($this['site_id'], $this['created_at'], $this['updated_at'], $this['last_updated_by_id'], $this['slots_list'], $this['links_list'], $this['assets_list'], $this['comments_list']);
     $field = sfApplicationConfiguration::getActive()->getPluginConfiguration('sfThemePlugin')->getThemeToolkit()->getThemeWidgetAndValidator();
     $this->widgetSchema['theme'] = $field['widget'];
     $this->validatorSchema['theme'] = $field['validator'];
     // Sets up the template widget
     sfSympalFormToolkit::changeTemplateWidget($this);
     // Sets up the module widget
     sfSympalFormToolkit::changeModuleWidget($this);
     if (!$this->object->content_type_id) {
         $this->object->Type = Doctrine_Core::getTable('sfSympalContentType')->findOneBySlug('page');
     } else {
         $this->object->Type;
     }
     $this->configureMenuSection();
     $this->_embedTypeForm();
 }
 public function setup()
 {
     parent::setup();
     $field = sfApplicationConfiguration::getActive()->getPluginConfiguration('sfThemePlugin')->getThemeToolkit()->getThemeWidgetAndValidator();
     $this->widgetSchema['theme'] = $field['widget'];
     $this->validatorSchema['theme'] = $field['validator'];
     $this->widgetSchema['name']->setLabel('Model name');
     $models = Doctrine_Core::loadModels(sfConfig::get('sf_lib_dir') . '/model/doctrine');
     // Sets up the template widget
     sfSympalFormToolkit::changeTemplateWidget($this);
     // Sets up the module widget
     sfSympalFormToolkit::changeModuleWidget($this);
     foreach ($models as $model) {
         $table = Doctrine_Core::getTable($model);
         if (!$table->hasTemplate('sfSympalContentTypeTemplate')) {
             unset($models[$model]);
         }
     }
     $models = array_merge(array('' => ''), $models);
     $this->widgetSchema['name'] = new sfWidgetFormChoice(array('choices' => $models));
 }
 public function run(sfEvent $event)
 {
     $form = $event->getSubject();
     if ($form instanceof sfFormDoctrine) {
         sfSympalFormToolkit::embedI18n($form->getObject(), $form);
         if (sfSympalConfig::get('remove_timestampable_from_forms', null, true)) {
             unset($form['created_at'], $form['updated_at']);
         }
     }
     $widgetSchema = $form->getWidgetSchema();
     $requiredFields = $form->getRequiredFields();
     $widgetSchema->addOption('required_fields', $requiredFields);
     $widgetSchema->addFormFormatter('table', new sfSympalWidgetFormSchemaFormatterTable($widgetSchema));
     if ($form->hasRecaptcha()) {
         sfSympalFormToolkit::embedRecaptcha($form);
     }
     if (isset($form['template'])) {
         sfSympalFormToolkit::changeTemplateWidget($form);
     }
     if (isset($form['theme'])) {
         sfSympalFormToolkit::changeThemeWidget($form);
     }
     if (isset($form['module'])) {
         sfSympalFormToolkit::changeModuleWidget($form);
     }
     if (isset($form['content_id']) || isset($form['content_list'])) {
         sfSympalFormToolkit::changeContentWidget($form);
     }
     $richDateForms = sfSympalConfig::get('rich_date_forms');
     $formClass = get_class($form);
     if (isset($richDateForms[$formClass])) {
         foreach ($form as $name => $field) {
             $widget = $field->getWidget();
             if (in_array($name, $richDateForms[$formClass]) && ($widget instanceof sfWidgetFormDateTime || $widget instanceof sfWidgetFormDate)) {
                 sfSympalFormToolkit::changeDateWidget($name, $form);
             }
         }
     }
 }
 /**
  * Retrieves the form class used to edit slot for "column slots".
  * 
  * This is used by sfSympalFormToolkit::changeContentSlotValueWidget()
  * to extract the widget & validator out so we can put it into the 
  * content slot form
  * 
  * @return sfForm
  */
 protected function _getContentSlotColumnForm()
 {
     $content = $this->getContentRenderedFor();
     $contentTable = $content->getTable();
     if ($contentTable->hasField($this->name)) {
         $formClass = sfSympalConfig::get('inline_editing', 'default_column_form');
         $form = new $formClass($content);
         $form->useFields(array($this->name));
         /*
          * For "column" slots, the widget and validator of the type are
          * not set automatically in the form itself (as opposed to true
          * slots who use sfSympalContentSlotForm, where the widget and
          * validator are setup automatically. This is a shortcoming. We
          * manually set the widget and validator here for content slots
          */
         sfSympalFormToolkit::changeContentSlotValueWidget($this, $form);
     }
     if (sfSympalConfig::isI18nEnabled('sfSympalContent')) {
         $contentTranslationTable = Doctrine::getTable('sfSympalContentTranslation');
         if ($contentTranslationTable->hasField($this->name)) {
             $formClass = sfSympalConfig::get('inline_editing', 'default_column_form');
             $form = new $formClass($content);
             $form->useFields(array(sfContext::getInstance()->getUser()->getEditCulture()));
             /*
              * @TODO There should be a changeContentSlotValueWidget() call here,
              * but I don't seem to have access to the underlying translation
              * form, which is what you really want to pass into that function
              */
         }
     }
     $contentTypeClassName = $content->getContentTypeClassName();
     $contentTypeFormClassName = sfSympalConfig::get($contentTypeClassName, 'default_inline_editing_column_form', $contentTypeClassName . 'Form');
     $contentTypeTable = Doctrine_Core::getTable($contentTypeClassName);
     if ($contentTypeTable->hasField($this->name)) {
         $form = new $contentTypeFormClassName($content->getRecord());
         $form->useFields(array($this->name));
         //See above note about this
         sfSympalFormToolkit::changeContentSlotValueWidget($this, $form);
     }
     if (sfSympalConfig::isI18nEnabled($contentTypeClassName)) {
         $contentTypeTranslationClassName = $contentTypeClassName . 'Translation';
         $contentTypeTranslationFormClassName = sfSympalConfig::get($contentTypeTranslationClassName, 'default_inline_editing_column_form', $contentTypeTranslationClassName . 'Form');
         $contentTypeTranslationTable = Doctrine_Core::getTable($contentTypeTranslationClassName);
         if ($contentTypeTranslationTable->hasField($this->name)) {
             $form = new $contentTypeFormClassName($content->getRecord());
             $i18nForm = $form->getEmbeddedForm($language = sfContext::getInstance()->getUser()->getEditCulture());
             $i18nForm->useFields(array($this->name));
             //See above note about this
             sfSympalFormToolkit::changeContentSlotValueWidget($this, $form);
             unset($form[$language]);
             $form->embedForm($language, $i18nForm);
             $form->useFields(array($language));
         }
     }
     if (!$form) {
         throw new InvalidArgumentException('Invalid content slot');
     }
     return $form;
 }
 public function setup()
 {
     parent::setup();
     sfSympalFormToolkit::changeContentSlotTypeWidget($this, true);
 }
 public function configure()
 {
     parent::configure();
     unset($this['value']);
     sfSympalFormToolkit::changeContentWidget($this, 'content_list');
 }
 public function loadConfigForm(sfEvent $event)
 {
     $form = $event->getSubject();
     $form->addSetting(null, 'rows_per_page', 'Rows Per Page');
     if (sfSympalConfig::isI18nEnabled()) {
         $cultures = sfCultureInfo::getCultures(sfCultureInfo::NEUTRAL);
         $languages = array();
         foreach ($cultures as $key => $value) {
             $formatted = format_language($value);
             if (!$formatted) {
                 $formatted = format_language($value, 'en');
             }
             if ($formatted) {
                 $languages[$value] = $formatted;
             }
         }
         asort($languages);
         $widget = new sfWidgetFormChoice(array('multiple' => true, 'choices' => $languages));
         $validator = new sfValidatorChoice(array('multiple' => true, 'choices' => array_keys($languages)));
         $form->addSetting(null, 'language_codes', 'Available Cultures', $widget, $validator);
         $languageForm = new sfFormLanguage(sfContext::getInstance()->getUser(), array('languages' => sfSympalConfig::getLanguageCodes()));
         $widgetSchema = $languageForm->getWidgetSchema();
         $validatorSchema = $languageForm->getValidatorSchema();
         $form->addSetting(null, 'default_culture', 'Default Culture', $widgetSchema['language'], $validatorSchema['language']);
     }
     $array = sfSympalFormToolkit::getThemeWidgetAndValidator();
     $form->addSetting(null, 'default_theme', 'Default Theme', $array['widget'], $array['validator']);
     $form->addSetting(null, 'default_rendering_module', 'Default Rendering Module');
     $form->addSetting(null, 'default_rendering_action', 'Default Rendering Action');
     $form->addSetting(null, 'recaptcha_public_key', 'Recaptcha Public Key');
     $form->addSetting(null, 'recaptcha_private_key', 'Recaptcha Private Key');
     $form->addSetting(null, 'breadcrumbs_separator', 'Breadcrumbs Separator');
     $form->addSetting(null, 'default_from_email_address', 'Default From Address');
     $form->addSetting(null, 'enable_markdown_editor', 'Enable Markdown Editor', 'InputCheckbox', 'Boolean');
     $form->addSetting(null, 'elastic_textareas', 'Elastic Textareas', 'InputCheckbox', 'Boolean');
     $form->addSetting(null, 'check_for_upgrades_on_dashboard', 'Check for Upgrades', 'InputCheckbox', 'Boolean');
     $form->addSetting('plugin_api', 'username', 'Username or API Key');
     $form->addSetting('plugin_api', 'password');
     $form->addSetting('page_cache', 'enabled', 'Enabled?', 'InputCheckbox', 'Boolean');
     $form->addSetting('page_cache', 'super', 'Enable Super Cache?', 'InputCheckbox', 'Boolean');
     $form->addSetting('page_cache', 'with_layout', 'With layout?', 'InputCheckbox', 'Boolean');
     $form->addSetting('page_cache', 'lifetime', 'Lifetime');
 }