本文整理汇总了PHP中api::files方法的典型用法代码示例。如果您正苦于以下问题:PHP api::files方法的具体用法?PHP api::files怎么用?PHP api::files使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api
的用法示例。
在下文中一共展示了api::files方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
public function show($id = null)
{
$filename = get('filename');
$page = $this->page($id);
$file = $this->file($page, $filename);
$blueprint = blueprint::find($page);
$fields = $blueprint->files()->fields($page);
$meta = $file->meta()->toArray();
$files = api::files($page, $blueprint);
$index = $files->indexOf($file);
$next = $files->nth($index + 1);
$prev = $files->nth($index - 1);
// breadcrumb items
if ($page->isSite()) {
$items = array(array('url' => purl('metatags'), 'title' => l('metatags')), array('url' => purl('files/index'), 'title' => l('metatags.files')), array('url' => purl($file, 'show'), 'title' => $file->filename()));
} else {
$items = array(array('url' => purl('files/index/' . $page->id()), 'title' => l('files')), array('url' => purl($file, 'show'), 'title' => $file->filename()));
}
// file info display
$info = array();
$info[] = $file->type();
$info[] = $file->niceSize();
if ((string) $file->dimensions() != '0 x 0') {
$info[] = $file->dimensions();
}
return view('files/show', array('topbar' => new Snippet('pages/topbar', array('menu' => new Snippet('menu'), 'breadcrumb' => new Snippet('pages/breadcrumb', array('page' => $page, 'items' => $items)), 'search' => purl($page, 'search'))), 'form' => new Form($fields->toArray(), $meta), 'p' => $page, 'f' => $file, 'next' => $next, 'prev' => $prev, 'info' => implode(' / ', $info)));
}
示例2: show
public function show($id)
{
$page = $this->page($id);
$blueprint = blueprint::find($page);
$fields = $blueprint->fields($page);
$content = $page->content()->toArray();
$files = null;
$subpages = null;
$preview = null;
// create the preview link
if ($previewSetting = $blueprint->preview()) {
switch ($previewSetting) {
case 'parent':
$preview = $page->parent() ? $page->parent()->url() : $page->url();
break;
case 'first-child':
$preview = $page->children()->first() ? $page->children()->first()->url() : false;
break;
case 'last-child':
$preview = $page->children()->last() ? $page->children()->last()->url() : false;
break;
default:
$preview = $page->url();
break;
}
}
// make sure the title is always there
$content['title'] = $page->title();
// create the form
$form = new Form($fields->toArray(), $content);
// check for untranslatable fields
if (site()->language() != site()->defaultLanguage()) {
foreach ($form->fields() as $field) {
if ($field->translate() == false) {
$field->readonly = true;
$field->disabled = true;
}
}
}
// create the subpages if they exist
if ($blueprint->pages()->max() !== 0 and $blueprint->pages()->hide() == false) {
// fetch all subpages in the right order
$children = api::subpages($page->children(), $blueprint);
// add pagination to the subpages
if ($limit = $blueprint->pages()->limit()) {
$children = $children->paginate($limit, array('page' => get('page')));
}
// create the snippet and fill it with all data
$subpages = new Snippet('pages/sidebar/subpages', array('title' => l('pages.show.subpages.title'), 'page' => $page, 'subpages' => $children, 'addbutton' => !api::maxPages($page, $blueprint->pages()->max()), 'pagination' => $children->pagination()));
}
// create the files
if ($blueprint->files()->max() !== 0 and $blueprint->files()->hide() == false) {
$files = new Snippet('pages/sidebar/files', array('page' => $page, 'files' => api::files($page, $blueprint)));
}
// create the monster sidebar
$sidebar = new Snippet('pages/sidebar', array('page' => $page, 'preview' => $preview, 'deletable' => !$page->hasChildren() and $page->isDeletable() and $blueprint->deletable(), 'subpages' => $subpages, 'files' => $files));
return view('pages/show', array('topbar' => new Snippet('pages/topbar', array('breadcrumb' => new Snippet('pages/breadcrumb', array('page' => $page)), 'search' => purl($page, 'search'))), 'sidebar' => $sidebar, 'form' => $form, 'page' => $page, 'notitle' => !$form->fields()->get('title')));
}
示例3: index
public function index()
{
$site = site();
$blueprint = blueprint::find($site);
$fields = $blueprint->fields($site)->toArray();
$content = $site->content()->toArray();
$files = null;
// create the files
if ($blueprint->files()->max() !== 0 and $blueprint->files()->hide() == false) {
$files = new Snippet('pages/sidebar/files', array('page' => $site, 'files' => api::files($site, $blueprint)));
}
return view('metatags/index', array('topbar' => new Snippet('pages/topbar', array('breadcrumb' => new Snippet('breadcrumb', array('items' => array(array('title' => l('metatags'), 'url' => purl('metatags/'))))), 'search' => purl('pages/search/'))), 'form' => new Form($fields, $content), 's' => $site, 'files' => $files, 'license' => panel()->license()));
}
示例4: show
public function show($id)
{
$filename = get('filename');
$page = $this->page($id);
$file = $this->file($page, $filename);
$blueprint = blueprint::find($page);
$fields = $blueprint->files()->fields($page);
$meta = $file->meta()->toArray();
$files = api::files($page, $blueprint);
$index = $files->indexOf($file);
$next = $files->nth($index + 1);
$prev = $files->nth($index - 1);
return view('files/show', array('topbar' => new Snippet('pages/topbar', array('menu' => new Snippet('menu'), 'breadcrumb' => new Snippet('pages/breadcrumb', array('page' => $page, 'items' => array(array('url' => purl('files/index/' . $page->id()), 'title' => l('files')), array('url' => purl($file, 'show'), 'title' => $file->filename())))), 'search' => purl($page, 'search'))), 'form' => new Form($fields->toArray(), $meta), 'p' => $page, 'f' => $file, 'next' => $next, 'prev' => $prev));
}