コード例 #1
0
ファイル: BuildDocumentation.php プロジェクト: d-m-/docs
 protected function getSubTree($branch, $output, $prefix = '')
 {
     $directory = getcwd() . $this->rootdir;
     $slugify = new \Cocur\Slugify\Slugify();
     $tree = shell_exec('git ls-tree ' . $branch . " " . $prefix);
     $tree = array_filter(explode("\n", $tree));
     $filelist = array_map('str_getcsv', $tree, array_fill(0, count($tree), "\t"));
     foreach ($filelist as $source) {
         $filemeta = explode(' ', $source[0]);
         if ($filemeta[1] == 'blob') {
             $file = $source[1];
             $content = shell_exec('git show ' . $branch . ":" . $file);
             $folderName = $slugify->slugify($branch);
             @mkdir(dirname($directory . $folderName . '/' . $file), 0755, true);
             file_put_contents($directory . $folderName . '/' . $file, $content);
         } elseif ($filemeta[1] == 'tree') {
             $this->getSubTree($branch, $output, './' . $source[1] . '/');
         }
     }
     // Only get the menu, if we're in the ./source_docs/ top level.
     if ($prefix == './source_docs/') {
         $menu = shell_exec('git show ' . $branch . ":menu_docs.yml");
         file_put_contents($directory . $folderName . '/menu_docs.yml', $menu);
         $output->writeln("<info>Branch {$branch} written to {$directory}{$folderName}</info>");
     }
 }
コード例 #2
0
ファイル: string.php プロジェクト: ElBiniou/superbok
function slugify($string)
{
    static $driver;
    if (!$driver) {
        $driver = new \Cocur\Slugify\Slugify();
    }
    return $driver->slugify($string);
}
コード例 #3
0
ファイル: Convenia.php プロジェクト: brunocasado/convenia-dev
 private function converterString($str)
 {
     if (is_string($str)) {
         // Using slugify to avoid errors with special chars
         $slugify = new Cocur\Slugify\Slugify();
         // The slugify remove all glyphs and separators
         $str = $slugify->slugify($str, '');
         // Split each letter of string to array
         $arr = str_split($str, 1);
         foreach ($arr as $k => $v) {
             // Convert char to relative ascii int
             $arr[$k] = ord($v) - 96;
         }
         return $arr;
     }
     // Case $str type is not string, return false
     return false;
 }
コード例 #4
0
 public function imageUpload()
 {
     if (null === $this->getImage()) {
         return;
     }
     $slugify = new \Cocur\Slugify\Slugify();
     $filename = $slugify->slugify($this->getImage()->getClientOriginalName());
     $filename .= '_' . sha1(uniqid(mt_rand(), true)) . '.' . $this->getImage()->guessExtension();
     $this->getImage()->move($this->getImageUploadDir(), $filename);
     $this->setImageUrl($this->getImageUploadPath() . $filename);
     $this->setImage(null);
 }
コード例 #5
0
 public function convertMetasToEntryMetas($uploadPath, $uploadDir)
 {
     $slugify = new \Cocur\Slugify\Slugify();
     $metas = $this->getMetas();
     if (!empty($metas)) {
         foreach ($metas as $metaKey => $metaValue) {
             $metaEntity = new \Application\Entity\ParticipantMetaEntity();
             // Chek if it's a file!
             if ($metaValue instanceof \Symfony\Component\HttpFoundation\File\UploadedFile) {
                 $filename = $slugify->slugify($metaValue->getClientOriginalName());
                 $filename .= '_' . sha1(uniqid(mt_rand(), true)) . '.' . $metaValue->guessExtension();
                 $metaValue->move($uploadDir, $filename);
                 $metaValue = $uploadPath . $filename;
             }
             $metaEntity->setKey($metaKey)->setValue($metaValue);
             $this->addParticipantMeta($metaEntity);
         }
     }
 }
コード例 #6
0
 /**
  * Creates a slug.
  *
  * @param string $slugify_this The piece of text to transform into a slug.
  * @return string A safe slug.
  **/
 public function createSlug($slugify_this)
 {
     $slugify = new \Cocur\Slugify\Slugify();
     return $slugify->slugify($slugify_this);
 }
コード例 #7
0
ファイル: bootstrap.php プロジェクト: TrAsKiN/my-wow-hub
<?php

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Symfony\Component\Debug\ErrorHandler::register();
Symfony\Component\Debug\ExceptionHandler::register();
$curl = new Curl\Curl();
$curl->setOpt(CURLOPT_CONNECTTIMEOUT, 10);
$curl->setOpt(CURLOPT_RETURNTRANSFER, true);
$curl->setOpt(CURLOPT_HEADER, false);
$curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
$app['curl'] = $curl;
$app['locale'] = LOCALE;
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/views'));
$app['twig'] = $app->extend('twig', function (Twig_Environment $twig, $app) {
    $twig->addExtension(new Cocur\Slugify\Bridge\Twig\SlugifyExtension(Cocur\Slugify\Slugify::create()));
    if ($app['debug']) {
        $twig->addExtension(new Twig_Extension_Debug());
    }
    return $twig;
});
$app->register(new Silex\Provider\SessionServiceProvider());
$app->register(new Silex\Provider\ServiceControllerServiceProvider());
$app->register(new Silex\Provider\AssetServiceProvider());
if ($app['debug']) {
    $app->register(new Silex\Provider\VarDumperServiceProvider());
    $app->register(new Silex\Provider\MonologServiceProvider(), array('monolog.logfile' => __DIR__ . '/logs/silex_dev.log'));
    $app->register(new Silex\Provider\HttpFragmentServiceProvider());
    $app->register(new Silex\Provider\WebProfilerServiceProvider(), array('profiler.cache_dir' => __DIR__ . '/cache/profiler'));
}
$app->error(function (\Exception $e, Request $request, $code) use($app) {
コード例 #8
0
 /**
  * {@inheritdoc}
  */
 public function setName($name)
 {
     $this->name = $name;
     $slugify = new \Cocur\Slugify\Slugify();
     $this->setSlug($slugify->slugify($name));
 }