Ejemplo n.º 1
0
 public function basename($suffix = true)
 {
     if ($suffix == false) {
         return pathinfo($this->pathName(), PATHINFO_FILENAME);
     }
     return parent::getBasename($suffix);
 }
Ejemplo n.º 2
0
 public function __construct(\SPLFileInfo $asset, Pg $db)
 {
     $this->location = realpath($asset->getPathname());
     $dbSql = $this->dbSql = $db->query(new Query("SELECT * FROM build.assets WHERE location = %location:%", array('location' => $this->location)))->fetch(Result::FETCH_SINGLE);
     if ($dbSql) {
         $diff = new Diff();
         $this->diffText = $diff->diff($dbSql['sql'], file_get_contents($this->location));
     } else {
         $this->diffText = 'Asset not in database';
     }
     $this->message = sprintf("Database asset `%s` at %s changed at %s.\n%s", substr($asset->getBasename(), 0, -4), $this->location, date('Y-m-d H:i:s', $asset->getMTime()), $this->diffText);
 }
Ejemplo n.º 3
0
/**
 * Get file informations (size, name ...)
 *
 * @param Application $app Silex Application
 * @param Request $request Request parameters
 *
 * @return JsonResponse Object containing file informations
 */
function get_infos(Application $app, Request $request)
{
    if ($app["rights.canPlayMedia"] == false) {
        $app->abort(403, "This user doesn't have the rights to retrieve file informations");
    }
    $filepath = Utils\check_path($app['cakebox.root'], $request->get('path'));
    if (!isset($filepath)) {
        $app->abort(400, "Missing parameters");
    }
    $file = new \SPLFileInfo("{$app['cakebox.root']}/{$filepath}");
    $fileinfo = [];
    $fileinfo["name"] = $file->getBasename("." . $file->getExtension());
    $fileinfo["fullname"] = $file->getFilename();
    $fileinfo["mimetype"] = mime_content_type($file->getPathName());
    $fileinfo["access"] = str_replace('%2F', '/', rawurlencode("{$app['cakebox.access']}/{$filepath}"));
    $fileinfo["size"] = $file->getSize();
    return $app->json($fileinfo);
}