本文整理汇总了PHP中Resources类的典型用法代码示例。如果您正苦于以下问题:PHP Resources类的具体用法?PHP Resources怎么用?PHP Resources使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Resources类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getConfig
public static function getConfig()
{
if (!isset(static::$json)) {
$resources = new Resources();
$configPath = $resources->getPath('config');
static::$json = json_decode(file_get_contents($configPath . 'packages.json'), true);
}
return static::$json;
}
示例2: __construct
protected function __construct($languageCode = null)
{
$resources = new Resources();
if (!empty($languageCode)) {
$resources->SetLanguage($languageCode);
}
$this->email = new SmartyPage($resources);
$this->Set('ScriptUrl', Configuration::Instance()->GetScriptUrl());
$this->Set('Charset', $resources->Charset);
}
示例3: FormatDate
public function FormatDate($params, &$smarty)
{
if (isset($params['format'])) {
return $params['date']->Format($params['format']);
}
$key = 'general_date';
if (isset($params['key'])) {
$key = $params['key'];
}
return $params['date']->Format($this->Resources->GetDateFormat($key));
}
示例4: Validate
/**
* @param ReservationSeries $reservationSeries
* @return ReservationRuleResult
*/
public function Validate($reservationSeries)
{
$userId = $reservationSeries->UserId();
$resourceId = $reservationSeries->ResourceId();
$isOk = !empty($userId) && !empty($resourceId);
return new ReservationRuleResult($isOk, Resources::GetInstance()->GetString('InvalidReservationData'));
}
示例5: action_responsible_teacher
public function action_responsible_teacher()
{
$programs = Model_Education_Programs::create();
$request = $this->getRequest();
$method = 'post';
if (empty($request->{$method})) {
$users = Model_User::create();
$this->set('teachers', $users->getTeachersList());
$this->set('disciplines', $programs->getDisciplinesResponsibleTeachersList());
$this->set('courses', $programs->getCoursesResponsibleTeachersList());
$this->render('assignment/responsible_teacher');
} else {
/**
* @todo Переделать для использования Form_Abstract.
*/
$requestData = $request->{$method};
if (isset($requestData['courses'])) {
foreach ($requestData['courses'] as $courseId => $teacherId) {
$programs->setCoursesResponsibleTeacher($courseId, $teacherId);
}
}
if (isset($requestData['disciplines'])) {
foreach ($requestData['disciplines'] as $disciplineId => $teacherId) {
$programs->setDisciplineResponsibleTeacher($disciplineId, $teacherId);
}
}
$links = Resources::getInstance()->links;
$this->flash('Ответсвенные преподаватели успешно назначены', $links->get('admin.responsible-teachers'), 3);
}
}
示例6: assignCompanyInfoAndTheme
function assignCompanyInfoAndTheme()
{
$this->assign('url', Settings::Get('hosturl', Resources::Get('site.url')));
$this->assign('company', Settings::Get('company_name', Resources::Get('company.webim')));
$this->assign('logo', Settings::Get('logo', WEBIM_ROOT . '/themes/default/images/logo.gif'));
$this->assign('theme', Browser::getCurrentTheme());
}
示例7: HandleInvitationAction
/**
* @param $invitationAction
* @return string|null
*/
private function HandleInvitationAction($invitationAction)
{
$referenceNumber = $this->page->GetInvitationReferenceNumber();
$userId = $this->page->GetUserId();
Log::Debug('Invitation action %s for user %s and reference number %s', $invitationAction, $userId, $referenceNumber);
$series = $this->reservationRepository->LoadByReferenceNumber($referenceNumber);
if ($invitationAction == InvitationAction::Accept) {
$series->AcceptInvitation($userId);
foreach ($series->AllResources() as $resource) {
if (!$resource->HasMaxParticipants()) {
continue;
}
/** @var $instance Reservation */
foreach ($series->Instances() as $instance) {
$numberOfParticipants = count($instance->Participants());
if ($numberOfParticipants > $resource->GetMaxParticipants()) {
return Resources::GetInstance()->GetString('MaxParticipantsError', array($resource->GetName(), $resource->GetMaxParticipants()));
}
}
}
}
if ($invitationAction == InvitationAction::Decline) {
$series->DeclineInvitation($userId);
}
if ($invitationAction == InvitationAction::CancelInstance) {
$series->CancelInstanceParticipation($userId);
}
if ($invitationAction == InvitationAction::CancelAll) {
$series->CancelAllParticipation($userId);
}
$this->reservationRepository->Update($series);
return null;
}
示例8: action_add
/**
* Добавление нового платежа
*/
public function action_add(array $params = array())
{
$links = Resources::getInstance()->links;
$request = $this->getRequest();
if (empty($params)) {
$this->flash('Не указан идентификатор заявки', $links->get('admin.applications', array('sort_field' => 'fio', 'sort_direction' => 'asc')));
}
$app_id = intval(array_shift($params));
$opts = array('app_id' => $app_id);
$action = $links->get('payments.add', $opts);
$form = Form_Payment_Add::create($action);
$this->set('form', $form);
$method = $form->method();
if (empty($request->{$method})) {
$this->render();
}
if (!$form->validate($request)) {
$this->render();
}
$payment = Model_Payment::create();
$amount = $form->amount->value;
if (!$payment->add($amount, $app_id)) {
$msg = 'Не удалось добавить платёж';
} else {
$msg = 'Платёж успешно добавлен';
}
$this->flash($msg, $links->get('admin.applications', array('sort_field' => 'fio', 'sort_direction' => 'asc')));
}
示例9: PageLoad
public function PageLoad()
{
$this->Set('DefaultTitle', Resources::GetInstance()->GetString('NoTitleLabel'));
$this->presenter->SetSearchCriteria(ReservationViewRepository::ALL_USERS, ReservationUserLevel::ALL);
$this->presenter->PageLoad();
$this->Display('admin_upcoming_reservations.tpl');
}
示例10: generate_pagination
function generate_pagination($pagination)
{
$result = Resources::Get('tag.pagination.info', array($pagination['page'], $pagination['total'], $pagination['start'] + 1, $pagination['end'], $pagination['count'])) . '<br/>';
if ($pagination['total'] > 1) {
$result .= "<br/><div class='pagination'>";
$curr_page = $pagination['page'];
$minPage = max($curr_page - LINKS_ON_PAGE, 1);
$maxPage = min($curr_page + LINKS_ON_PAGE, $pagination['total']);
if ($curr_page > 1) {
$result .= generate_pagination_link($curr_page - 1, generate_pagination_image('prevpage')) . PAGINATION_SPACING;
}
for ($i = $minPage; $i <= $maxPage; ++$i) {
$title = abs($curr_page - $i) >= LINKS_ON_PAGE && $i != 1 ? '...' : $i;
if ($i != $curr_page) {
$result .= generate_pagination_link($i, $title);
} else {
$result .= "<span class=\"pagecurrent\">{$title}</span>";
}
if ($i < $maxPage) {
$result .= PAGINATION_SPACING;
}
}
if ($curr_page < $pagination['total']) {
$result .= PAGINATION_SPACING . generate_pagination_link($curr_page + 1, generate_pagination_image('nextpage'));
}
$result .= '</div>';
}
return $result;
}
示例11: CreateRecurRule
/**
* @param ReservationItemView|ReservationView $res
* @return null|string
*/
private function CreateRecurRule($res)
{
if (is_a($res, 'ReservationItemView')) {
// don't populate the recurrance rule when a list of reservation is being exported
return null;
}
### !!! THIS DOES NOT WORK BECAUSE EXCEPTIONS TO RECURRENCE RULES ARE NOT PROPERLY HANDLED !!!
### see bug report http://php.brickhost.com/forums/index.php?topic=11450.0
if (empty($res->RepeatType) || $res->RepeatType == RepeatType::None) {
return null;
}
$freqMapping = array(RepeatType::Daily => 'DAILY', RepeatType::Weekly => 'WEEKLY', RepeatType::Monthly => 'MONTHLY', RepeatType::Yearly => 'YEARLY');
$freq = $freqMapping[$res->RepeatType];
$interval = $res->RepeatInterval;
$format = Resources::GetInstance()->GetDateFormat('ical');
$end = $res->RepeatTerminationDate->SetTime($res->EndDate->GetTime())->Format($format);
$rrule = sprintf('FREQ=%s;INTERVAL=%s;UNTIL=%s', $freq, $interval, $end);
if ($res->RepeatType == RepeatType::Monthly) {
if ($res->RepeatMonthlyType == RepeatMonthlyType::DayOfMonth) {
$rrule .= ';BYMONTHDAY=' . $res->StartDate->Day();
}
}
if (!empty($res->RepeatWeekdays)) {
$dayMapping = array('SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA');
$days = '';
foreach ($res->RepeatWeekdays as $weekDay) {
$days .= $dayMapping[$weekDay] . ',';
}
$days = substr($days, 0, -1);
$rrule .= ';BYDAY=' . $days;
}
return $rrule;
}
示例12: __construct
protected function __construct($titleKey = '', $pageDepth = 0)
{
$this->SetSecurityHeaders();
$this->path = str_repeat('../', $pageDepth);
$this->server = ServiceLocator::GetServer();
$resources = Resources::GetInstance();
ExceptionHandler::SetExceptionHandler(new WebExceptionHandler(array($this, 'RedirectToError')));
$this->smarty = new SmartyPage($resources, $this->path);
$userSession = ServiceLocator::GetServer()->GetUserSession();
$this->smarty->assign('Charset', $resources->Charset);
$this->smarty->assign('CurrentLanguage', $resources->CurrentLanguage);
$this->smarty->assign('HtmlLang', $resources->HtmlLang);
$this->smarty->assign('HtmlTextDirection', $resources->TextDirection);
$appTitle = Configuration::Instance()->GetKey(ConfigKeys::APP_TITLE);
$pageTile = $resources->GetString($titleKey);
$this->smarty->assign('Title', (empty($appTitle) ? 'Booked' : $appTitle) . (empty($pageTile) ? '' : ' - ' . $pageTile));
$this->smarty->assign('CalendarJSFile', $resources->CalendarLanguageFile);
$this->smarty->assign('LoggedIn', $userSession->IsLoggedIn());
$this->smarty->assign('Version', Configuration::VERSION);
$this->smarty->assign('Path', $this->path);
$this->smarty->assign('ScriptUrl', Configuration::Instance()->GetScriptUrl());
$this->smarty->assign('UserName', !is_null($userSession) ? $userSession->FirstName : '');
$this->smarty->assign('DisplayWelcome', $this->DisplayWelcome());
$this->smarty->assign('UserId', $userSession->UserId);
$this->smarty->assign('CanViewAdmin', $userSession->IsAdmin);
$this->smarty->assign('CanViewGroupAdmin', $userSession->IsGroupAdmin);
$this->smarty->assign('CanViewResourceAdmin', $userSession->IsResourceAdmin);
$this->smarty->assign('CanViewScheduleAdmin', $userSession->IsScheduleAdmin);
$this->smarty->assign('CanViewResponsibilities', !$userSession->IsAdmin && ($userSession->IsGroupAdmin || $userSession->IsResourceAdmin || $userSession->IsScheduleAdmin));
$allowAllUsersToReports = Configuration::Instance()->GetSectionKey(ConfigSection::REPORTS, ConfigKeys::REPORTS_ALLOW_ALL, new BooleanConverter());
$this->smarty->assign('CanViewReports', $allowAllUsersToReports || $userSession->IsAdmin || $userSession->IsGroupAdmin || $userSession->IsResourceAdmin || $userSession->IsScheduleAdmin);
$timeout = Configuration::Instance()->GetKey(ConfigKeys::INACTIVITY_TIMEOUT);
if (!empty($timeout)) {
$this->smarty->assign('SessionTimeoutSeconds', max($timeout, 1) * 60);
}
$this->smarty->assign('ShouldLogout', $this->GetShouldAutoLogout());
$this->smarty->assign('CssExtensionFile', Configuration::Instance()->GetKey(ConfigKeys::CSS_EXTENSION_FILE));
$this->smarty->assign('UseLocalJquery', Configuration::Instance()->GetKey(ConfigKeys::USE_LOCAL_JQUERY, new BooleanConverter()));
$this->smarty->assign('EnableConfigurationPage', Configuration::Instance()->GetSectionKey(ConfigSection::PAGES, ConfigKeys::PAGES_ENABLE_CONFIGURATION, new BooleanConverter()));
$this->smarty->assign('ShowParticipation', !Configuration::Instance()->GetSectionKey(ConfigSection::RESERVATION, ConfigKeys::RESERVATION_PREVENT_PARTICIPATION, new BooleanConverter()));
$this->smarty->assign('LogoUrl', 'booked.png');
if (file_exists($this->path . 'img/custom-logo.png')) {
$this->smarty->assign('LogoUrl', 'custom-logo.png');
}
if (file_exists($this->path . 'img/custom-logo.gif')) {
$this->smarty->assign('LogoUrl', 'custom-logo.gif');
}
if (file_exists($this->path . 'img/custom-logo.jpg')) {
$this->smarty->assign('LogoUrl', 'custom-logo.jpg');
}
$this->smarty->assign('CssUrl', 'null-style.css');
if (file_exists($this->path . 'css/custom-style.css')) {
$this->smarty->assign('CssUrl', 'custom-style.css');
}
$logoUrl = Configuration::Instance()->GetKey(ConfigKeys::HOME_URL);
if (empty($logoUrl)) {
$logoUrl = $this->path . Pages::UrlFromId($userSession->HomepageId);
}
$this->smarty->assign('HomeUrl', $logoUrl);
}
示例13: smarty_function_get_res
function smarty_function_get_res($params, &$smarty)
{
if (!isset($params['code'])) {
return '';
}
return Resources::Get($params['code'], $params, $smarty->_tpl_vars['current_locale']);
}
示例14: Validate
public function Validate($category, $attributeValues, $entityId = null, $ignoreEmpty = false)
{
$isValid = true;
$errors = array();
$resources = Resources::GetInstance();
$values = array();
foreach ($attributeValues as $av) {
$values[$av->AttributeId] = $av->Value;
}
$attributes = $this->attributeRepository->GetByCategory($category);
foreach ($attributes as $attribute) {
if ($attribute->UniquePerEntity() && $entityId != $attribute->EntityId()) {
continue;
}
$value = trim($values[$attribute->Id()]);
$label = $attribute->Label();
if (empty($value) && $ignoreEmpty) {
continue;
}
if (!$attribute->SatisfiesRequired($value)) {
$isValid = false;
$errors[] = $resources->GetString('CustomAttributeRequired', $label);
}
if (!$attribute->SatisfiesConstraint($value)) {
$isValid = false;
$errors[] = $resources->GetString('CustomAttributeInvalid', $label);
}
}
return new AttributeServiceValidationResult($isValid, $errors);
}
示例15: action_index
public function action_index()
{
$materialId = $this->request->param('id');
$materials = new Model_Material('groups');
//получить содержимое папки
$data = $materials->getMaterial($materialId);
$fields = $materials->getFields2($materialId, TRUE);
$model = array("photos" => array());
$model["id"] = Arr::get($data, "id");
$model["name"] = Arr::get($data, "name");
$model["article"] = Arr::get($data, "art");
$model["price"] = number_format(Arr::get($fields, 'price'), 0, "", " ");
Resources::add_scripts(array("js/modules/material/material.js"), get_class());
// --- Фотки ----------------------------------------------------
// есть фото
if (isset($fields["photos"][0])) {
$photos = $fields["photos"];
$model["general_photo"] = $photos[0]["value"];
// Фоток больше 1
if (count($photos) > 1) {
foreach ($photos as $photo) {
$model["photos"][] = array("original" => $photo["value"], "mini" => Route::url("miniimg2", array("filename" => $photo["value"])));
}
}
} else {
$model["general_photo"] = "/img/noimg.png";
}
// --- /Фотки ----------------------------------------------------
// --- Коментарии ------------------------------------------------
echo '<script>window.material_id = JSON.parse(\'' . $materialId . '\');</script>';
$this->load_module("comments", "/widgets/Comments/index");
// --- /Коментарии -----------------------------------------------
$this->set_template("/widgets/material/material.php", "twig")->render($model)->body();
}