本文整理汇总了PHP中Context::last方法的典型用法代码示例。如果您正苦于以下问题:PHP Context::last方法的具体用法?PHP Context::last怎么用?PHP Context::last使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Context
的用法示例。
在下文中一共展示了Context::last方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
$conf = Context::last()->config->get('modules/drawtext');
if (isset($conf['font'])) {
$this->setFont($conf['font']);
}
}
示例2: moveFileToS3
/**
* Загружает файл в S3.
*/
public static function moveFileToS3($fileName, $mimeType = null, $baseName = null)
{
self::checkEnv($ctx = Context::last());
$conf = $ctx->config->get('modules/s3');
$s3 = new S3($conf['accesskey'], $conf['secretkey']);
if (!($bucketName = trim($ctx->config->get('modules/s3/bucket', 'files'), '/'))) {
throw new RuntimeException(t('Модуль s3 не настроен (bucket).'));
}
if ($folderName = $ctx->config->get('module/s3/folder', 'files')) {
$folderName .= '/';
}
/*
if (!in_array($bucketName, $s3->listBuckets()))
throw new RuntimeException(t('Нет такой папки: ' . $bucketName));
*/
if ($f = fopen($fileName, 'rb')) {
if (null === $baseName) {
$baseName = basename($fileName);
}
if (!($r = S3::inputResource($f, filesize($fileName)))) {
throw new RuntimeException(t('Не удалось создать ресурс из файла %filename.', array('%filename' => $fileName)));
}
if (!($response = S3::putObject($r, $bucketName, $folderName . $baseName, S3::ACL_PUBLIC_READ))) {
throw new RuntimeException(t('Не удалось загрузить файл %filename в папку %bucket.', array('%filename' => $fileName, '%bucket' => $bucketName)));
}
$url = 'http://' . $bucketName . '.s3.amazonaws.com/' . $folderName . $baseName;
Logger::log('S3: ' . $url);
return $url;
}
}
示例3: on_clone
/**
* Клонирование прав при клонировании объекта.
* @mcms_message ru.molinos.cms.node.clone
*/
public static function on_clone(Node $node)
{
if ($node instanceof UserNode) {
$node->name .= '/tmp' . rand();
}
$node->uid = Context::last()->user->getNode();
}
示例4: format
/**
* Форматирование значения. Вызывает обработчики вроде типографа.
*/
public function format(Node $node, $em)
{
$value = $node->{$this->value};
$ctx = Context::last();
$ctx->registry->broadcast('ru.molinos.cms.format.text', array($ctx, $this->value, &$value));
return html::wrap($em, html::cdata($value));
}
示例5: on_get_settings
/**
* @mcms_message ru.molinos.cms.module.settings.drawtext
*/
public static function on_get_settings(Context $ctx)
{
$fonts = array();
foreach (Node::find(Context::last()->db, array('class' => 'file', 'filetype' => 'application/x-font-ttf')) as $n) {
$fonts[$n->id] = isset($n->name) ? $n->name : $n->filename;
}
return new Schema(array('font' => array('type' => 'EnumControl', 'label' => t('Шрифт по умолчанию'), 'default' => t('(не использовать)'), 'options' => $fonts, 'description' => t('Вы можете <a href=\'@url\'>загрузить новый шрифт</a> в файловый архив.', array('@url' => '?q=admin/content/create&type=file&destination=CURRENT')))));
}
示例6: getSelected
public function getSelected($data)
{
if (null === ($email = $this->findEmail($data))) {
return array();
}
$tags = Context::last()->db->getResultsV("tid", "SELECT tid FROM node__rel WHERE nid IN (SELECT id FROM node WHERE class = 'subscription' AND deleted = 0 AND name = ?)", array($email));
return is_array($tags) ? $tags : array();
}
示例7: getEnabledSections
public function getEnabledSections()
{
$conf = Context::last()->config->get('modules/subscription');
if (!array_key_exists('sections', $conf)) {
return array();
}
return $conf['sections'];
}
示例8: isActive
private function isActive($data)
{
if ($data->id) {
return false;
}
$ctx = Context::last();
if ($ctx->user->id and !$this->required) {
return false;
}
return true;
}
示例9: checkPermission
public function checkPermission($perm)
{
$user = Context::last()->user;
mcms::debug($this->uid, $this->re);
if ($this->cmp($this->uid, $user->id)) {
return true;
}
if ($this->cmp($this->re, $user->id)) {
return true;
}
return false;
}
示例10: __construct
public function __construct($url = '', $code = 302)
{
if ('POST' == $_SERVER['REQUEST_METHOD']) {
$code = self::OTHER;
}
$u = new url($url);
$url = $u->getAbsolute(Context::last());
$this->url = $url;
$message = t('<html><head><title>Redirecting</title>' . '<meta http-equiv=\'refresh\' content=\'0; url=@url\' />' . '</head><body>' . '<h1>Redirecting</h1><p>Redirecting to <a href=\'@url\'>a new location</a>.</p>' . '</body></html>', array('@url' => $url));
$this->headers[] = 'Location: ' . $this->url;
parent::__construct($message, 'text/html', $code);
}
示例11: getProfileFields
private static function getProfileFields()
{
$result = array();
foreach (Schema::load(Context::last()->db, 'user') as $k => $v) {
$result[$k] = $v->label;
}
if (isset($result['groups'])) {
unset($result['groups']);
}
asort($result);
return $result;
}
示例12: getExtraXMLContent
/**
* Добавляет в комментарий информацию о ноде.
*/
public function getExtraXMLContent()
{
$content = parent::getExtraXMLContent();
$db = Context::last()->db;
$node = $this->node ? $this->node : $db->fetch("SELECT `tid` FROM `node__rel` WHERE `nid` = ? LIMIT 1", array($this->id));
if ($node) {
if ($data = $db->getResults("SELECT id, class, name FROM node WHERE id = ?", array($node))) {
$content .= html::em('node', $data[0]);
}
}
return $content;
}
示例13: login
/**
* Переключается в указанного пользователя, проверяет его статус.
*/
private static function login($uid)
{
if ($uid) {
$data = Context::last()->db->fetch("SELECT `id`, `published` FROM `node` WHERE `class` = 'user' AND `deleted` = 0 AND `id` = ?", array($uid));
if (empty($data)) {
throw new ForbiddenException(t('Нет такого пользователя.'));
} elseif (empty($data['published'])) {
throw new ForbiddenException(t('Ваш профиль заблокирован.'));
}
}
User::storeSessionData($uid);
}
示例14: format
public function format(Node $node, $em)
{
$result = '';
$value = $node->{$this->value};
if (!empty($value) and is_array($value)) {
$params = array();
$data = (array) Context::last()->db->getResults($sql = "SELECT `id`, `published`, `name` FROM `node` WHERE `class` = 'label' AND `deleted` = 0 AND `id` " . sql::in(array_keys($value), $params), $params);
foreach ($data as $row) {
$result .= html::em('label', array('id' => $row['id'], 'published' => (bool) $row['published']), html::cdata($row['name']));
}
}
return html::wrap($em, $result);
}
示例15: getProductLink
private function getProductLink(array $item)
{
$ctx = Context::last();
if (empty($item['id'])) {
return htmlspecialchars($item['name']);
}
if (0 === strpos($ctx->query(), 'admin/')) {
$url = '?q=admin/edit/' . $item['id'] . '&destination=admin';
} else {
$url = '?q=nodeapi.rpc&action=locate&node=' . $item['id'];
}
return html::link($url, html::plain($item['name']));
}