Example #1
0
 /**
  *	\brief Gera o slug de um string
  *
  *	@param[in] $txt String a ser convertida em slug
  *	@paran[in] $space String que será usada para substituir os espaços em $txt.
  *		Se for omitido utiliza '-' como padrão.
  *	\return Uma string com o slug
  */
 public static function slug_generator($txt, $space = '-')
 {
     if (mb_check_encoding($txt, 'UTF-8')) {
         $txt = Strings_UTF8::toSlug($txt, $space);
     } else {
         $txt = Strings_UTF8::toSlug($txt, $space);
         //$txt = Strings_ANSI::remove_accented_chars($txt);
     }
     return preg_replace('/[-]+/', '-', $txt);
 }
Example #2
0
 static function enviarArquivosTemp($file_transfer = null, $receive = array())
 {
     ini_set('upload_tmp_dir', Kernel::get_conf('tmp_path'));
     foreach (glob(Kernel::get_conf('tmp_path') . '/*') as $key => $file) {
         if (time() - filemtime($file) > 3600) {
             @unlink($file);
         }
     }
     $upload = $file_transfer instanceof Zend_File_Transfer ? $file_transfer : new Zend_File_Transfer();
     //$upload->clearValidators();
     $files = array();
     foreach ($upload->getFileInfo() as $name => $file) {
         if (count($receive) > 0 and !in_array($name, $receive)) {
             continue;
         }
         if ($upload->isUploaded($name) and !$upload->isReceived($name)) {
             $upload->addFilter('Rename', array('target' => Kernel::get_conf('tmp_path') . DIRECTORY_SEPARATOR . 'tmp-' . preg_replace('/[\\.\\,]/', 'x', microtime(TRUE)) . '-' . Strings_UTF8::toSlug($upload->getFileName($name, false)), 'overwrite' => true));
             if ($upload->receive($name)) {
                 $files[$name] = $upload->getFileName($name);
             }
         }
     }
     return $file_transfer ? $upload : $files;
 }