本文整理汇总了PHP中Gantry\Framework\Gantry类的典型用法代码示例。如果您正苦于以下问题:PHP Gantry类的具体用法?PHP Gantry怎么用?PHP Gantry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Gantry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __construct
protected function __construct()
{
parent::__construct();
$gantry = Gantry::instance();
if (isset($gantry['file.yaml.cache.path'])) {
$this->setCachePath($gantry['file.yaml.cache.path']);
}
}
开发者ID:JozefAB,项目名称:neoacu,代码行数:8,代码来源:CompiledYamlFile.php
示例2: save
/**
* Save assignments for the configuration.
*
* @param array $data
*/
public function save(array $data)
{
$data = $data['assignments'];
foreach ($data as $tname => &$type) {
foreach ($type as $gname => &$group) {
foreach ($group as $key => $value) {
if (!$value) {
unset($group[$key]);
} else {
$group[$key] = (bool) $value;
}
}
if (empty($group)) {
unset($type[$gname]);
}
}
if (empty($type)) {
unset($data[$tname]);
}
}
$gantry = Gantry::instance();
/** @var UniformResourceLocator $locator */
$locator = $gantry['locator'];
// Save layout into custom directory for the current theme.
$save_dir = $locator->findResource("gantry-config://{$this->configuration}", true, true);
$filename = "{$save_dir}/assignments.yaml";
$file = YamlFile::instance($filename);
$file->save($data);
$file->free();
}
开发者ID:Tanver186,项目名称:gantry5,代码行数:35,代码来源:Assignments.php
示例3: getThemes
/**
* @return array
*/
public static function getThemes()
{
$gantry = Gantry::instance();
/** @var UniformResourceLocator $locator */
$locator = $gantry['locator'];
$files = Folder::all('gantry-themes://', ['recursive' => false, 'files' => false]);
/** @var array|ThemeDetails[] $list */
$list = [];
natsort($files);
foreach ($files as $theme) {
if ($locator('gantry-themes://' . $theme . '/gantry/theme.yaml')) {
$details = new ThemeDetails($theme);
// Stream needs to be valid URL.
$streamName = 'gantry-themes-' . preg_replace('|[^a-z\\d+.-]|ui', '-', $theme);
if (!$locator->schemeExists($streamName)) {
$locator->addPath($streamName, '', $details->getPaths());
}
$details['name'] = $theme;
$details['title'] = $details['details.name'];
$details['preview_url'] = $gantry['platform']->getThemePreviewUrl($theme);
$details['admin_url'] = $gantry['platform']->getThemeAdminUrl($theme);
$details['params'] = [];
$list[$details->name] = $details;
}
}
// Add Thumbnails links after adding all the paths to the locator.
foreach ($list as $details) {
$details['thumbnail'] = $details->getUrl("details.images.thumbnail");
}
return $list;
}
开发者ID:legutierr,项目名称:gantry5,代码行数:34,代码来源:ThemeList.php
示例4: onThemeInitialized
public function onThemeInitialized()
{
/** @var UniformResourceLocator $locator */
$locator = $this->grav['locator'];
$path = $locator('theme://');
$name = $this->name;
if (!class_exists('\\Gantry5\\Loader')) {
if ($this->isAdmin()) {
$messages = $this->grav['messages'];
$messages->add('Please enable Gantry 5 plugin in order to use current theme!', 'error');
return;
} else {
throw new \LogicException('Please install and enable Gantry 5 Framework plugin!');
}
}
// Setup Gantry 5 Framework or throw exception.
\Gantry5\Loader::setup();
// Get Gantry instance.
$gantry = Gantry::instance();
// Set the theme path from Grav variable.
$gantry['theme.path'] = $path;
$gantry['theme.name'] = $name;
// Define the template.
require $locator('theme://includes/theme.php');
// Define Gantry services.
$gantry['theme'] = function ($c) {
return new \Gantry\Theme\Hydrogen($c['theme.path'], $c['theme.name']);
};
}
开发者ID:sam-suresh,项目名称:gantry5,代码行数:29,代码来源:theme.php
示例5: init
/**
* @see AbstractTheme::init()
*/
protected function init()
{
parent::init();
$gantry = Gantry::instance();
/** @var UniformResourceLocator $locator */
$locator = $gantry['locator'];
\JPluginHelper::importPlugin('gantry5');
// Trigger the onGantryThemeInit event.
$dispatcher = \JEventDispatcher::getInstance();
$dispatcher->trigger('onGantry5ThemeInit', ['theme' => $this]);
$lang = \JFactory::getLanguage();
// FIXME: Do not hardcode this file.
$lang->load('files_gantry5_nucleus', JPATH_SITE);
if (\JFactory::getApplication()->isSite()) {
// Load our custom positions file as frontend requires the strings to be there.
$filename = $locator("gantry-theme://language/en-GB/en-GB.tpl_{$this->name}_positions.ini");
if ($filename) {
$lang->load("tpl_{$this->name}_positions", dirname(dirname(dirname($filename))), 'en-GB');
}
}
$doc = \JFactory::getDocument();
$this->language = $doc->language;
$this->direction = $doc->direction;
$this->url = \JUri::root(true) . '/templates/' . $this->name;
}
开发者ID:legutierr,项目名称:gantry5,代码行数:28,代码来源:Theme.php
示例6: gantry_admin_print_scripts
function gantry_admin_print_scripts()
{
$scripts = \Gantry\Framework\Gantry::instance()->scripts();
if ($scripts) {
echo implode("\n", $scripts) . "\n";
}
}
开发者ID:xmasviex,项目名称:gantry5,代码行数:7,代码来源:init.php
示例7: gantry
/**
* Get global Gantry instance.
*
* @return Gantry
*/
public static function gantry()
{
// We cannot set variable directly for the trait as it doesn't work in HHVM.
if (!self::$gantry) {
self::$gantry = Gantry::instance();
}
return self::$gantry;
}
开发者ID:JozefAB,项目名称:neoacu,代码行数:13,代码来源:GantryTrait.php
示例8: delete
public static function delete($id)
{
$gantry = Gantry::instance();
/** @var UniformResourceLocator $locator */
$locator = $gantry['locator'];
$path = $locator->findResource('gantry-config://' . $id, true, true);
if (is_dir($path)) {
Folder::delete($path, true);
}
}
开发者ID:nmsde,项目名称:gantry5,代码行数:10,代码来源:StyleHelper.php
示例9: widgets_init
public function widgets_init()
{
$gantry = Gantry::instance();
$positions = $gantry['configurations']->positions();
foreach ($positions as $name => $title) {
// FIXME
// This should be handled by theme so translation plugins could catch it as part of theme.
// This stuff might also need take Joomla chromes into account for cross-compatibility reasons
register_sidebar(array('name' => __($title, 'gantry5'), 'id' => $name, 'description' => __($title, 'gantry5'), 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>'));
}
}
开发者ID:xmasviex,项目名称:gantry5,代码行数:11,代码来源:Theme.php
示例10: __construct
public function __construct()
{
$gantry = Gantry::instance();
/** @var UniformResourceLocator $locator */
$locator = $gantry['locator'];
$finder = new ConfigFileFinder();
// Generate a flat list of all existing pages containing a list of file paths with timestamps.
$this->items = $finder->listFiles($locator->findResources('gantry-pages://'), '|\\.html\\.twig|');
// And list the pages in alphabetical order.
ksort($this->items);
}
开发者ID:nmsde,项目名称:gantry5,代码行数:11,代码来源:Pages.php
示例11: bodyAttributes
public function bodyAttributes($attributes = [])
{
$gantry = Gantry::instance();
$classes = ['site', "dir-ltr", "outline-{$gantry['configuration']}"];
$baseAttributes = (array) $this->config->get('page.body.attribs', []);
if (!empty($baseAttributes['class'])) {
$baseAttributes['class'] = array_merge((array) $baseAttributes['class'], $classes);
} else {
$baseAttributes['class'] = $classes;
}
return $this->getAttributes($baseAttributes, $attributes);
}
开发者ID:Tanver186,项目名称:gantry5,代码行数:12,代码来源:Page.php
示例12: loadAssignments
public function loadAssignments()
{
$gantry = Gantry::instance();
/** @var UniformResourceLocator $locator */
$locator = $gantry['locator'];
// Find all the assignment files.
$paths = $locator->findResources("gantry-config://");
$files = (new ConfigFileFinder())->locateFileInFolder('assignments', $paths);
$cache = $locator->findResource('gantry-cache://theme/compiled/config', true, true);
$config = new CompiledConfig($cache, [$files]);
return $config->load();
}
开发者ID:nmsde,项目名称:gantry5,代码行数:12,代码来源:OutlineChooser.php
示例13: add_to_twig
public function add_to_twig(\Twig_Environment $twig, \Twig_Loader_Filesystem $loader = null)
{
$gantry = \Gantry\Framework\Gantry::instance();
/** @var UniformResourceLocator $locator */
$locator = $gantry['locator'];
if (!$loader) {
$loader = $twig->getLoader();
}
$loader->setPaths($locator->findResources('gantry-admin://templates'), 'gantry-admin');
$twig->addExtension(new TwigExtension());
return $twig;
}
开发者ID:Acidburn0zzz,项目名称:gantry5,代码行数:12,代码来源:Theme.php
示例14: onGlobalSave
public function onGlobalSave(Event $event)
{
$gantry = Gantry::instance();
/** @var UniformResourceLocator $locator */
$locator = $gantry['locator'];
$filename = 'config://plugins/gantry5.yaml';
$file = YamlFile::instance($locator->findResource($filename, true, true));
$content = $file->content();
$content['production'] = (bool) $event->data['production'];
$file->save($content);
$file->free();
}
开发者ID:legutierr,项目名称:gantry5,代码行数:12,代码来源:EventListener.php
示例15: widgets_init
public function widgets_init()
{
$gantry = Gantry::instance();
$positions = (array) $gantry['config']->get('positions');
foreach ($positions as $name => $params) {
$params = (array) $params;
if (!isset($params['name'])) {
$params['name'] = ucfirst($name);
}
register_sidebar(array('name' => __($params['name'], 'gantry5'), 'id' => $name, 'description' => __($params['name'], 'gantry5'), 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>'));
}
}
开发者ID:Acidburn0zzz,项目名称:gantry5,代码行数:12,代码来源:Theme.php
示例16: gantry5_install_clear_cache
function gantry5_install_clear_cache($upgrader, $options)
{
// Clear gantry cache after plugin / theme installs.
if (isset($options['type']) && in_array($options['type'], array('plugin', 'theme')) && class_exists('Gantry\\Framework\\Gantry')) {
global $wp_filesystem;
$gantry = \Gantry\Framework\Gantry::instance();
$path = $gantry['platform']->getCachePath();
if ($wp_filesystem->is_dir($path)) {
$wp_filesystem->rmdir($path);
}
$upgrader->skin->feedback('Gantry 5 cache cleared.');
}
}
开发者ID:Tanver186,项目名称:gantry5,代码行数:13,代码来源:gantry5.php
示例17: render
public function render($file, array $context = array())
{
$gantry = \Gantry\Framework\Gantry::instance();
/** @var UniformResourceLocator $locator */
$locator = $gantry['locator'];
$loader = new \Twig_Loader_Filesystem($locator->findResources('gantry-admin://templates'));
$params = array('cache' => $locator->findResource('gantry-cache://theme/twig', true, true), 'debug' => true, 'auto_reload' => true, 'autoescape' => 'html');
$twig = new \Twig_Environment($loader, $params);
$this->add_to_twig($twig);
// Include Gantry specific things to the context.
$context = $this->add_to_context($context);
return $twig->render($file, $context);
}
开发者ID:nmsde,项目名称:gantry5,代码行数:13,代码来源:Theme.php
示例18: copy
public static function copy($style, $old, $new)
{
$gantry = Gantry::instance();
/** @var UniformResourceLocator $locator */
$locator = $gantry['locator'];
$oldPath = $locator->findResource('gantry-config://' . $old, true, true);
$newPath = $locator->findResource('gantry-config://' . $new, true, true);
if (file_exists($oldPath)) {
Folder::copy($oldPath, $newPath);
}
$installer = new TemplateInstaller($style->extension_id);
$installer->updateStyle($new, ['configuration' => $new]);
}
开发者ID:Ettore495,项目名称:Ettore-Work,代码行数:13,代码来源:StyleHelper.php
示例19: __construct
protected function __construct()
{
parent::__construct();
$gantry = Gantry::instance();
/** @var Config $global */
$global = $gantry['global'];
if (!$global->get('compile_yaml', 1)) {
$this->caching(false);
}
if (isset($gantry['file.yaml.cache.path'])) {
$this->setCachePath($gantry['file.yaml.cache.path']);
}
}
开发者ID:lucian0308,项目名称:gantry5,代码行数:13,代码来源:CompiledYamlFile.php
示例20: __construct
public function __construct()
{
global $pagenow;
parent::__construct('particle_widget', __('Gantry 5 Particle', 'gantry5'), ['description' => __('Displays Gantry 5 particle instance in a widget position.', 'gantry5'), 'gantry5' => true]);
try {
$this->container = Gantry::instance();
} catch (Exception $e) {
}
$ajax = $pagenow === 'admin-ajax.php' && (isset($_POST['action']) && $_POST['action'] === 'save-widget');
if (is_admin() && (in_array($pagenow, ['widgets.php', 'customize.php']) || $ajax)) {
// Initialize administrator if already not done that.
$this->initialiseGantry();
}
}
开发者ID:Tanver186,项目名称:gantry5,代码行数:14,代码来源:Particle.php
注:本文中的Gantry\Framework\Gantry类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论