Пример #1
0
 /**
  * Creates ajax file field
  *
  * @param string $name - name of the html field
  * @param string $accept - accepted file types
  * @param string $value - possible value for the inbox
  * @param string $class - class name
  * @param string $task - task override
  * @param array $scripts - custom JavaScript files
  * @param array $request - custom request
  * @return string
  */
 public static function _fileUpload($name, $accept = '*', $value = null, $class = 'spFileUpload', $task = 'file.upload', $scripts = array('jquery', 'jquery-form', 'fileupload'), $request = null)
 {
     if (is_string($scripts)) {
         $scripts = SPFactory::config()->structuralData($scripts);
     }
     SPFactory::header()->addJsFile($scripts);
     if (!$request) {
         $request = array('option' => 'com_sobipro', 'task' => $task, 'sid' => Sobi::Section(), 'ident' => $name . '-file', SPFactory::mainframe()->token() => 1, 'format' => 'raw');
     }
     $classes = array('class' => 'hide spFileUploadHidden');
     SPLoader::loadClass('env.browser');
     $browser = SPBrowser::getInstance()->get('browser');
     $stupidInternetExplorer = false;
     if (strstr(strtolower($browser), 'internet explorer')) {
         $classes = array('class' => '');
         $stupidInternetExplorer = true;
     }
     if (Sobi::Cfg('template.bootstrap3-styles')) {
         $column = "col-sm-";
     } else {
         $column = "span";
     }
     $f = null;
     $f .= "<div class=\"{$class}\" data-section=" . Sobi::Section() . ">";
     $f .= '<div class="file">';
     $f .= self::file($name . '-file', 0, $classes, $accept);
     $f .= '</div>';
     $b3class = '';
     if (Sobi::Cfg('template.bootstrap3-styles')) {
         $b3class = ' form-control';
     }
     if (!$stupidInternetExplorer) {
         $f .= "<input type=\"text\" readonly=\"readonly\" class=\"input-large selected pull-left{$b3class}\" value=\"{$value}\"/>";
     }
     $f .= '<div class="btn-group">';
     if (!$stupidInternetExplorer) {
         $f .= '<button class="btn btn-default select" type="button"><i class="' . Sobi::Ico('upload-field.search-button') . '"></i>&nbsp;' . Sobi::Txt('UPLOAD_SELECT') . '</button>';
     }
     $f .= '<button class="btn btn-default upload hide" disabled="disabled" type="button" rel=\'' . json_encode($request) . '\'>' . Sobi::Txt('START_UPLOAD') . '&nbsp;<i class="icon-upload-alt"></i></button>';
     $f .= '<button class="btn btn-default remove" disabled="disabled" type="button">' . '&nbsp;<i class="' . Sobi::Ico('upload-field.remove-button') . '"></i></button>';
     $f .= '</div>';
     $f .= '<div class="hide progress-container row">';
     $f .= '<div class="' . $column . '1">';
     $f .= '<span class="progress-message badge badge-success">0%</span>';
     $f .= '</div>';
     $f .= '<div class="progress progress-success ' . $column . '6"><div class="bar"></div></div>';
     $f .= '</div>';
     $f .= '<div class="alert hide"><button type="button" class="close" data-dismiss="alert">×</button><div>&nbsp;</div></div>';
     $f .= "<input type=\"hidden\" name=\"{$name}\" value=\"\" class='idStore'/>";
     $f .= '</div>';
     return $f;
 }