Beispiel #1
0
 public static function renderFormFieldByType($f, $values)
 {
     $value = isset($values[$f['id']]) ? $values[$f['id']] : '';
     $attributes = array();
     switch ($f['type']) {
         case 'file':
             $html = '';
             if ($value > 0) {
                 if ($a = Doctrine_Core::getTable('Attachments')->find($value)) {
                     $html = '<br>' . Attachments::getLink($a) . input_hidden_tag('extra_fields_files[' . $f['id'] . ']', $value) . '<br>' . input_checkbox_tag('extra_fields_files_delete[' . $f['id'] . ']', $value) . ' <label for="extra_fields_files_delete_' . $f['id'] . '">' . __('Delete') . '</label>';
                     $attributes['class'] = '';
                 }
             }
             return input_file_tag('extra_fields[' . $f['id'] . ']', '', $attributes) . $html;
             break;
         case 'number':
             return input_tag('extra_fields[' . $f['id'] . ']', $value, $attributes);
             break;
         case 'text':
         case 'url':
             $attributes['size'] = '40';
             return input_tag('extra_fields[' . $f['id'] . ']', $value, $attributes);
             break;
         case 'textarea':
             return textarea_tag('extra_fields[' . $f['id'] . ']', $value, $attributes);
             break;
         case 'textarea_wysiwyg':
             if (isset($attributes['class'])) {
                 $attributes['class'] .= ' editor';
             } else {
                 $attributes['class'] = 'editor';
             }
             return textarea_tag('extra_fields[' . $f['id'] . ']', $value, $attributes);
             break;
         case 'date':
             if (isset($attributes['class'])) {
                 $attributes['class'] .= ' datepicker';
             } else {
                 $attributes['class'] = 'datepicker';
             }
             $attributes['size'] = '11';
             return input_tag('extra_fields[' . $f['id'] . ']', $value, $attributes);
             break;
         case 'date_range':
             if (isset($attributes['class'])) {
                 $attributes['class'] .= ' datepicker';
             } else {
                 $attributes['class'] = 'datepicker';
             }
             $attributes['size'] = '11';
             if (strlen($value) > 0) {
                 $value = explode('|', $value);
             } else {
                 $value = array('', '');
             }
             return __('From') . ': ' . input_tag('extra_fields[' . $f['id'] . '][from]', $value[0], $attributes) . ' ' . __('To') . ': ' . input_tag('extra_fields[' . $f['id'] . '][to]', $value[1], $attributes);
             break;
         case 'date_time':
             if (isset($attributes['class'])) {
                 $attributes['class'] .= ' datetimepicker';
             } else {
                 $attributes['class'] = 'datetimepicker';
             }
             $attributes['size'] = '17';
             return input_tag('extra_fields[' . $f['id'] . ']', $value, $attributes);
             break;
         case 'date_dropdown':
             $years = range(date('Y') - 100, date('Y') + 20);
             $w = new sfWidgetFormDate(array('years' => array_combine($years, $years), 'format' => __('Year') . ':%year% ' . __('Month') . ':%month% ' . __('Day') . ':%day%'));
             return $w->render('extra_fields[' . $f['id'] . ']', $value, $attributes);
             break;
         case 'pull_down':
             $choices = array();
             foreach (explode("\n", $f['default_values']) as $v) {
                 $choices[trim($v)] = trim($v);
             }
             return select_tag('extra_fields[' . $f['id'] . ']', $value, array('choices' => $choices), $attributes);
             break;
         case 'checkbox':
             $choices = array();
             foreach (explode("\n", $f['default_values']) as $v) {
                 $choices[trim($v)] = trim($v);
             }
             return '<div id="checkboxesList' . $f['id'] . '" class="checkboxesList">' . select_tag('extra_fields[' . $f['id'] . ']', explode("\n", $value), array('choices' => $choices, 'expanded' => true, 'multiple' => true), $attributes) . '</div>';
             break;
         case 'radiobox':
             $choices = array();
             foreach (explode("\n", $f['default_values']) as $v) {
                 $choices[trim($v)] = trim($v);
             }
             return select_tag('extra_fields[' . $f['id'] . ']', $value, array('choices' => $choices, 'expanded' => true), $attributes);
             break;
     }
 }
Beispiel #2
0
<?php

foreach ($attachments as $a) {
    $file_path = sfConfig::get('sf_upload_dir') . '/attachments/' . $a->getFile();
    ?>
  <div id="attachedFile<?php 
    echo $a->getId();
    ?>
">
    <table>
      <tr>
        <td colspan="2"><?php 
    echo Attachments::getFileIcon($a->getFile()) . ' ' . (is_file($file_path) ? getimagesize($file_path) ? link_to(substr($a->getFile(), 7), 'attachments/view?id=' . $a->getId(), array('target' => '_blank', 'absolute' => true)) : Attachments::getLink($a) : substr($a->getFile(), 7));
    ?>
</td>
      </tr>                                                                                     
      </tr>
        <?php 
    if ($a->getBindType() != 'wiki') {
        ?>
        <td><?php 
        echo __('Description') . ':</td><td> ' . textarea_tag('attachments_info[' . $a->getId() . ']', $a->getInfo(), array('style' => 'height: 50px;', 'class' => 'attachments_textarea'));
        ?>
</td>
        <?php 
    }
    ?>
        
        <td><a href="#" onClick="return deleteAttachments(<?php 
    echo $a->getId();
    ?>