yf_test user module| File | plugins/test/modules/yf_test.class.php |
|---|---|
| Use | module('test'), URL ?object=test |
| Property | Default | Description |
|---|---|---|
| None declared in this class. | ||
public function change_debug()
public function change_debug()
{
if ( ! DEBUG_MODE) {
return;
}
if (is_post()) {
$_SESSION['debug_console_light'] = (int) ((bool) $_POST['debug_console_light']);
$_SESSION['locale_vars_edit'] = (int) ((bool) $_POST['locale_edit']);
return js_redirect($_SERVER['HTTP_REFERER'], 0);
}
$a = $_POST + $_SESSION;
return form($a)
->active_box('debug_console_light', ['selected' => $_SESSION['debug_console_light']])
->active_box('locale_edit', ['selected' => $_SESSION['locale_vars_edit']])
->save();
}
public function html5fw($params = [])
Css frameworks lister.
public function html5fw($params = [])
{
main()->no_graphics(true);
_class('assets')->clean_all();
if ( ! $params['use_yf_fixes'] && ! ($_GET['use_yf_fixes'] ?? null)) {
_class('assets')->MAIN_TPL_JS = '';
_class('assets')->MAIN_TPL_CSS = '';
}
asset('bootstrap-theme');
$links = [];
$prefix = 'html5fw_';
foreach (get_class_methods($this) as $name) {
if ($name[0] !== '_' && substr($name, 0, strlen($prefix)) === $prefix) {
$links[url('/@object/' . $name)] = substr($name, strlen($prefix));
}
}
$body = _class('html')->navlist($links);
echo '<html><head>' . _class('assets')->show_css() . '</head><body>' . $body . _class('assets')->show_js() . '</body></html>';
}
public function html5fw_bs3($params = [])
public function html5fw_bs3($params = [])
{
return $this->_html5fw_test('bs3', function ($fw, $params) {
asset('bootstrap-theme');
}, $params);
}
public function html5fw_bs4($params = [])
public function html5fw_bs4($params = [])
{
return $this->_html5fw_test('bs4', function ($fw, $params) {
asset('bootstrap-theme');
}, $params);
}
public function html5fw_bs5($params = [])
public function html5fw_bs5($params = [])
{
return $this->_html5fw_test('bs5', function ($fw, $params) {
asset('bootstrap-theme');
}, $params);
}
public function html5fw_empty($params = [])
public function html5fw_empty($params = [])
{
return $this->_html5fw_test('empty', function ($fw, $params) {
}, $params);
}
public function oauth($params = [])
public function oauth($params = [])
{
return module('login_form')->oauth($params);
}
public function placeholder()
public function placeholder()
{
$body[] = module('dynamic')->placeholder_img();
$body[] = module('dynamic')->placeholder_img(['text' => 'Hello']);
$body[] = module('dynamic')->placeholder_img(['text' => 'Hello', 'color_text' => 'f00']);
$body[] = module('dynamic')->placeholder_img(['text' => 'Hello', 'color_text' => 'fff', 'color_bg' => '000']);
$body[] = module('dynamic')->placeholder_img(['text' => 'Hello', 'color_text' => 'fff', 'color_bg' => '000', 'width' => '120', 'height' => '70']);
$body[] = module('dynamic')->placeholder_img(['text' => 'Hello', 'color_text' => '000', 'color_bg' => 'fff', 'width' => '120', 'height' => '70', 'opacity_bg' => 127]);
$body[] = module('dynamic')->placeholder_img(['text' => 'Hello', 'color_text' => '00f', 'width' => '120', 'height' => '70', 'transparent_bg' => true]);
$body[] = $this->_transparent_png();
return implode(PHP_EOL, $body);
}
public function show()
public function show()
{
if ( ! DEBUG_MODE) {
return;
}
$methods = [];
$class_name = get_class($this);
foreach ((array) get_class_methods($class_name) as $_method_name) {
if ($_method_name[0] == '_' || $_method_name == $class_name || $_method_name == __FUNCTION__) {
continue;
}
$methods[$_method_name] = './?object=' . ($_GET['object'] ?? null) . '&action=' . $_method_name;
}
$body[] = '<ul class="nav nav-list span3">';
foreach ((array) $methods as $name => $link) {
$body[] = '<li><a href="' . $link . '"><i class="icon-chevron-right fa fa-chevron-right"></i> ' . $name . '</a></li>';
}
$body[] = '</ul>';
return implode(PHP_EOL, $body);
}
public function true_for_unittest($out = '')
public function true_for_unittest($out = '')
{
return $out ? (is_array($out) ? implode(',', $out) : $out) : 'true';
}
_ hooks and helpers; not routable as page actionspublic function _html5fw_test($fw = 'bs3', $callback = null, $params = [])
Css frameworks acceptance testing unified method.
public function _html5fw_test($fw = 'bs3', $callback = null, $params = [])
{
main()->no_graphics(true);
_class('assets')->clean_all();
if ( ! $params['use_yf_fixes'] && ! ($_GET['use_yf_fixes'] ?? null)) {
_class('assets')->MAIN_TPL_JS = '';
_class('assets')->MAIN_TPL_CSS = '';
}
conf('css_framework', $fw);
// yf_html caches the framework classes when it is created
_class('html')->_init();
$callback($fw, $params);
$method = (string) $_GET['id'];
$obj = _class('test_html5fw_' . $fw, 'modules/test/');
if ($method === '' || $method[0] === '_' || ! method_exists($obj, $method)) {
$links = [];
foreach (get_class_methods($obj) as $name) {
if ($name[0] !== '_') {
$links[url('/@object/@action/' . $name)] = $name;
}
}
$body = _class('html')->navlist($links);
} else {
$body = $obj->$method($params);
}
echo '<html><head>' . _class('assets')->show_css() . '</head><body>' . $body . _class('assets')->show_js() . '</body></html>';
}
public function _transparent_png()
public function _transparent_png()
{
$w = $h = 200;
$k = 4;
$image = imagecreatetruecolor($w, $h);
imagealphablending($image, false);
$color_bg = imagecolorallocatealpha($image, 255, 255, 255, 127);
imagefilledrectangle($image, 0, 0, $w, $h, $color_bg);
imagealphablending($image, true);
$color2 = imagecolorallocatealpha($image, 0, 0, 0, 0);
imagefilledrectangle($image, 0, 0, $w / $k, $h / $k, $color2);
imagefilledrectangle($image, $w - $w / $k, $h - $h / $k, $w, $h, $color2);
imagefilledrectangle($image, 0, $h - $h / $k, $w / $k, $h, $color2);
imagefilledrectangle($image, $w - $w / $k, 0, $w, $h / $k, $color2);
imagealphablending($image, true);
$color3 = imagecolorallocatealpha($image, 0, 0, 127, 100);
imagefilledrectangle($image, $w / 2 - $w / $k, $h / 2 - $h / $k, $w / 2 + $w / $k, $h / 2 + $h / $k, $color3);
imagealphablending($image, false);
imagesavealpha($image, true);
ob_start();
imagepng($image);
$img_data = ob_get_clean();
unset($image);
return '<img src="data:image/png;base64,' . base64_encode($img_data) . '" width="' . $w . '" height="' . $h . '" />';
}