mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +09:00
Change behavior of \@mobile directive in template v2 #2510
This commit is contained in:
parent
82195c3e14
commit
800eb2f444
4 changed files with 15 additions and 5 deletions
|
|
@ -945,6 +945,16 @@ class Template
|
|||
return count($args) ? in_array((string)$validator_id, $args, true) : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current visitor is using a mobile device for v2.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function _v2_isMobile(): bool
|
||||
{
|
||||
return UA::isMobile() && (config('mobile.tablets') || !UA::isTablet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Lang shortcut for v2.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -104,8 +104,8 @@ class TemplateParser_v2
|
|||
'cannot' => ['if ($this->_v2_checkCapability(2, %s)):', 'endif;'],
|
||||
'canany' => ['if ($this->_v2_checkCapability(3, %s)):', 'endif;'],
|
||||
'guest' => ['if (!$this->user->isMember()):', 'endif;'],
|
||||
'desktop' => ["if (!\\Context::get('m')):", 'endif;'],
|
||||
'mobile' => ["if (\\Context::get('m')):", 'endif;'],
|
||||
'desktop' => ['if (!$this->_v2_isMobile()):', 'endif;'],
|
||||
'mobile' => ['if ($this->_v2_isMobile()):', 'endif;'],
|
||||
'env' => ['if (!empty($_ENV[%s])):', 'endif;'],
|
||||
'else' => ['else:'],
|
||||
'elseif' => ['elseif (%s):'],
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@
|
|||
<?php (function($__filename, $__vars, $__varname, $__empty = null) { if (!$__vars): $__vars = []; if ($__empty): $__filename = $__empty; $__vars[] = ''; endif; endif; foreach ($__vars as $__var): echo $this->_v2_include("include", $__filename, [(string)$__varname => $__var]); endforeach; })('incl/eachtest', $__Context->bar, 'var'); ?>
|
||||
<?php (function($__filename, $__vars, $__varname, $__empty = null) { if (!$__vars): $__vars = []; if ($__empty): $__filename = $__empty; $__vars[] = ''; endif; endif; foreach ($__vars as $__var): echo $this->_v2_include("include", $__filename, [(string)$__varname => $__var]); endforeach; })('incl/eachtest', [], 'anything', 'incl/empty'); ?>
|
||||
|
||||
<?php if (!\Context::get('m')): ?>
|
||||
<?php if (!$this->_v2_isMobile()): ?>
|
||||
<p>The full class name is <?php echo htmlspecialchars(get_class(new Rhymix\Framework\Push), \ENT_QUOTES, 'UTF-8', true); ?>, <?php echo $this->config->context === 'JS' ? escape_js(Rhymix\Framework\Push::class) : htmlspecialchars(Rhymix\Framework\Push::class, \ENT_QUOTES, 'UTF-8', false); ?> really.</p>
|
||||
<?php endif; ?>
|
||||
|
||||
|
|
|
|||
|
|
@ -858,10 +858,10 @@ class TemplateParserV2Test extends \Codeception\Test\Unit
|
|||
'@endmobile',
|
||||
]);
|
||||
$target = implode("\n", [
|
||||
"<?php if (!\\Context::get('m')): ?>",
|
||||
'<?php if (!$this->_v2_isMobile()): ?>',
|
||||
'<p>4K or GTFO!</p>',
|
||||
'<?php endif; ?>',
|
||||
"<?php if (\\Context::get('m')): ?>",
|
||||
'<?php if ($this->_v2_isMobile()): ?>',
|
||||
'<p>USB C is the way to go~</p>',
|
||||
'<?php endif; ?>',
|
||||
]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue