本文整理汇总了PHP中Load::getModulePath方法的典型用法代码示例。如果您正苦于以下问题:PHP Load::getModulePath方法的具体用法?PHP Load::getModulePath怎么用?PHP Load::getModulePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Load
的用法示例。
在下文中一共展示了Load::getModulePath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: placeholder
/**
* Placeholder code adapted from dummyimage.com
*/
public static function placeholder($width, $height)
{
$file_format = 'gif';
$width = $width;
$height = $height;
$text_angle = 0;
$font = Load::getModulePath('media') . 'assets/mplus-1c-medium.ttf';
$img = imageCreate($width, $height);
$bg_color = imageColorAllocate($img, 196, 196, 196);
$fg_color = imageColorAllocate($img, 94, 94, 94);
$lines = 1;
$text = $width . 'x' . $height;
$fontsize = max(min($width / strlen($text) * 1.15, $height * 0.5), 5);
$textBox = self::_imagettfbbox_t($fontsize, $text_angle, $font, $text);
$textWidth = ceil(($textBox[4] - $textBox[1]) * 1.07);
$textHeight = ceil((abs($textBox[7]) + abs($textBox[1])) * 1);
$textX = ceil(($width - $textWidth) / 2);
$textY = ceil(($height - $textHeight) / 2 + $textHeight);
imageFilledRectangle($img, 0, 0, $width, $height, $bg_color);
imagettftext($img, $fontsize, $text_angle, $textX, $textY, $fg_color, $font, $text);
$offset = 60 * 60 * 24 * 14;
//14 Days
$ExpStr = "Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT";
header($ExpStr);
//Set a far future expire date. This keeps the image locally cached by the user for less hits to the server.
header('Cache-Control: max-age=120');
header("Last-Modified: " . gmdate("D, d M Y H:i:s", time() - $offset) . " GMT");
header('Content-type: image/' . $file_format);
//Set the header so the browser can interpret it as an image and not a bunch of weird text.
switch ($file_format) {
case 'gif':
imagegif($img);
break;
case 'png':
imagepng($img);
break;
case 'jpg':
imagejpeg($img);
break;
case 'jpeg':
imagejpeg($img);
break;
}
imageDestroy($img);
exit;
}
示例2: elseif
} elseif (!String::startsWith($currentRoute, 'admin/login')) {
$noAccess = !User::current()->hasPermission('admin.access');
$isAnon = User::current()->isAnonymous();
if (!$isAnon && $noAccess) {
Message::error('You do not have admin access permissions.');
unset($_SESSION[Config::get('user.session_key')]);
}
if ($isAnon || $noAccess) {
Url::redirect('admin/login');
}
}
Admin::setInAdmin(true);
View::setPath(ROOT . 'core/admin/');
}
}, 'module.response' => function ($response = null) {
if (Admin::inAdmin()) {
View::data('adminContent', $response);
}
}, 'view.load' => function ($module, $controller, $method) {
if (Admin::inAdmin()) {
$paths = array(sprintf('%s/%s', $controller, $method), sprintf('%s_%s', $controller, $method));
foreach ($paths as $path) {
$viewFile = Load::getModulePath($module) . Config::get('view.dir') . $path . EXT;
Log::debug('admin', 'Checking for custom view: ' . $viewFile);
if (file_exists($viewFile)) {
Log::debug('admin', 'Loading custom view: ' . $viewFile);
return $viewFile;
}
}
}
}));