protected function build()
 {
     $this->btn_group('submit', 'back');
     for ($i = 0; $i < count($this->_files); $i++) {
         $file = $this->_files[$i];
         $this->markup('line');
         $element = $this->element('title', 'text', array('group' => TRUE));
         $this->markup('filename', array('file' => $file));
         $this->markup('/line');
         $element->value(ucfirst(FS::name_body($file)));
         $element->rule('not_empty');
     }
 }
 /**
  * increment file id, or create file id, windows style
  * 
  * "file" will become "file(2)"
  * "file(2)" will become "file(3)" etc.
  *
  * @return string
  */
 public static function name_unique($name, $path)
 {
     $extension = FS::name_extension($name);
     $body = FS::name_body($name);
     while (file_exists($path . $name)) {
         if (substr($body, -1) == ')') {
             // if the body ends in ')'
             // strip the trailing ')' and explode on '('
             $bodyParts = explode('(', substr($body, 0, strlen($body) - 1));
             if (is_numeric($bodyParts[count($bodyParts) - 1])) {
                 // if the last part of the explode is numeric, it means
                 // the last part was '('numeric')'
                 // get the number as int
                 $number = (int) $bodyParts[count($bodyParts) - 1];
                 // increment
                 $number++;
                 //remove last part of the name bodyparts
                 array_pop($bodyParts);
                 // stick it back on
                 // implode on '(' because we explode on '(' before
                 // so this way we reinsert '(' elsewhere in the body name
                 $body = implode('(', $bodyParts) . '(' . $number . ')';
             } else {
                 // last part was not (numeric)
                 // just stick (2) on it
                 $body = $body . '(2)';
             }
         } else {
             // last part was not (numeric)
             // just stick (2) on it
             $body = $body . '(2)';
         }
         // reassemble name
         $name = $body . '.' . $extension;
     }
     return $name;
 }