Skip to content

Instantly share code, notes, and snippets.

@tao-s
Created February 24, 2016 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tao-s/bb62af5b1dd181bd564c to your computer and use it in GitHub Desktop.
Save tao-s/bb62af5b1dd181bd564c to your computer and use it in GitHub Desktop.
concrete5 5.7系でファイル一覧を吐くだけのURLを作る
<?php
//application/bootstrap/app.php
/**
* ----------------------------------------------------------------------------
* # Custom Application Handler
*
* You can do a lot of things in this file.
*
* ## Set a theme by route:
*
* Route::setThemeByRoute('/login', 'greek_yogurt');
*
*
* ## Register a class override.
*
* Core::bind('helper/feed', function() {
* return new \Application\Core\CustomFeedHelper();
* });
*
* Core::bind('\Concrete\Attribute\Boolean\Controller', function($app, $params) {
* return new \Application\Attribute\Boolean\Controller($params[0]);
* });
*
* ## Register Events.
*
* Events::addListener('on_page_view', function($event) {
* $page = $event->getPageObject();
* });
*
*
* ## Register some custom MVC Routes
*
* Route::register('/test', function() {
* print 'This is a contrived example.';
* });
*
* Route::register('/custom/view', '\My\Custom\Controller::view');
* Route::register('/custom/add', '\My\Custom\Controller::add');
*
* ## Pass some route parameters
*
* Route::register('/test/{foo}/{bar}', function($foo, $bar) {
* print 'Here is foo: ' . $foo . ' and bar: ' . $bar;
* });
*
*
* ## Override an Asset
*
* use \Concrete\Core\Asset\AssetList;
* AssetList::getInstance()
* ->getAsset('javascript', 'jquery')
* ->setAssetURL('/path/to/new/jquery.js');
*
* or, override an asset by providing a newer version.
*
* use \Concrete\Core\Asset\AssetList;
* use \Concrete\Core\Asset\Asset;
* $al = AssetList::getInstance();
* $al->register(
* 'javascript', 'jquery', 'path/to/new/jquery.js',
* array('version' => '2.0', 'position' => Asset::ASSET_POSITION_HEADER, 'minify' => false, 'combine' => false)
* );
*
* ----------------------------------------------------------------------------
*/
Route::register('/sicms/file_list', 'Application\Controller\File::ViewList');
<?php
//application/controllers/file.php
namespace Application\Controller;
use Concrete\Core\File\FileList;
class File extends \Concrete\Core\Controller\Controller{
public function ViewList(){
$fl = new FileList();
//$fl->filterByIsCommon(1);
$rs = $fl->get();
$output = array();
header("Content-Type: text/plain; charset=UTF-8");
foreach($rs as $f){
//File Object
$fv = $f->getApprovedVersion();
print $fv->getURL()."\n";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment