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; }
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); }
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)); }
/** * @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')); }
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); } }
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()); }
/** * @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; }
/** * Добавление нового платежа */ 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'))); }
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'); }
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; }
/** * @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; }
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); }
function smarty_function_get_res($params, &$smarty) { if (!isset($params['code'])) { return ''; } return Resources::Get($params['code'], $params, $smarty->_tpl_vars['current_locale']); }
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); }
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(); }
public function Execute(ISqlCommand $sqlCommand) { mysqli_set_charset($this->_db, Resources::GetInstance()->Charset); $mysqlCommand = new MySqlCommandAdapter($sqlCommand, $this->_db); Log::Sql('MySql Execute: ' . str_replace('%', '%%', $mysqlCommand->GetQuery())); $result = mysqli_query($this->_db, $mysqlCommand->GetQuery()); $this->_handleError($result); }
public function __construct() { parent::__construct(); //$this->storage = new Storage ('../private/materials'); $this->storage = Resources::getInstance()->materials_storage; $this->attachObserver(Model_ControlWork::create()); $this->_checkRightsObject = Model_CheckRigths::create(); }
public static function deleteResourceSchedule($type, $id) { $resource = Resources::loadModelByPid($type, $id); if ($resource != null) { foreach ($resource as $res) { $res->delete(); } } }
public function testLanguageIsLoadedCorrectlyWhenSet() { $langFile = 'en_us.php'; $lang = 'en_us'; $this->Resources = Resources::GetInstance(); $this->Resources->SetLanguage($lang); $this->assertEquals($lang, $this->Resources->CurrentLanguage); $this->assertEquals($langFile, $this->Resources->LanguageFile); }
protected function GetFullName(ReservationItemView $reservation) { $shouldHide = Configuration::Instance()->GetSectionKey(ConfigSection::PRIVACY, ConfigKeys::PRIVACY_HIDE_USER_DETAILS, new BooleanConverter()); if ($shouldHide && (is_null($this->user) || $this->user->UserId != $reservation->UserId)) { return Resources::GetInstance()->GetString('Private'); } $name = new FullName($reservation->FirstName, $reservation->LastName); return $name->__toString(); }
private function showSecurimage() { Log::Debug('CaptchaControl using Securimage'); $url = CaptchaService::Create()->GetImageUrl(); $label = Resources::GetInstance()->GetString('SecurityCode'); $formName = FormKeys::CAPTCHA; echo "<img src='{$url}' alt='captcha' id='captchaImg'/>"; echo "<br/><label class=\"reg\">{$label}<br/><input type=\"text\" class=\"input\" name=\"{$formName}\" size=\"20\" id=\"captchaValue\"/>"; }
public function action_index($options = array("items_position_type" => "half")) { $model = array(); Resources::add_scripts(array("js/classes/LexCookie.js", "js/modules/item_position/script.js"), get_class()); Resources::add_styles(array("css/modules/item_position/default.less"), get_class()); $this->setopt(array("name" => "items_position_type", "description" => "Способ отображения item'ов", "default" => $options["items_position_type"])); $model["items_position_type"] = Arr::get($_COOKIE, "items_position_type", $this->getopt("items_position_type")); $this->set_template("/widgets/w_item_position.php", "twig")->render($model)->body(); }
/** * @return void */ public function ProcessPageLoad() { $this->Set('untitled', Resources::GetInstance()->GetString('NoTitleLabel')); $this->Set('RepeatEveryOptions', range(1, 20)); $this->Set('RepeatOptions', array('none' => array('key' => 'Never', 'everyKey' => ''), 'daily' => array('key' => 'Daily', 'everyKey' => 'days'), 'weekly' => array('key' => 'Weekly', 'everyKey' => 'weeks'), 'monthly' => array('key' => 'Monthly', 'everyKey' => 'months'), 'yearly' => array('key' => 'Yearly', 'everyKey' => 'years'))); $this->Set('DayNames', array(0 => 'DaySundayAbbr', 1 => 'DayMondayAbbr', 2 => 'DayTuesdayAbbr', 3 => 'DayWednesdayAbbr', 4 => 'DayThursdayAbbr', 5 => 'DayFridayAbbr', 6 => 'DaySaturdayAbbr')); $this->presenter->PageLoad(); $this->Display('Reports/saved-reports.tpl'); }
/** * Закрывает доступ к разделу. */ public function action_remove_pass($params) { $model_checkpoint = Model_Checkpoint::create(); $model_education_programs = Model_Education_Programs::create(); $model_checkpoint->removeCheckpointPass($params['student_id'], $params['section_id']); $discipline_id = $model_education_programs->getDisciplineNumberBySection($params['section_id']); $links = Resources::getInstance()->links; $link = $links->get('teacher.discipline', array('discipline_id' => $discipline_id['discipline_id'])); $this->flash('Доступ к разделу закрыт', $link); }
public function Validate() { if ($this->file == null) { return; } $this->isValid = in_array($this->file->Extension(), $this->allowedTypes); if (!$this->IsValid()) { $this->AddMessage(Resources::GetInstance()->GetString('InvalidAttachmentExtension', array(implode(',', $this->allowedTypes)))); } }
public function __construct($id_planet) { parent::__construct($id_planet); $db = new Connect(); $sql = $db->query("SELECT imagen,nombre,campos,campos_usados,temperatura,pos,sistema,metal,cristal,tritio,materia\n FROM planetas WHERE id_planeta='{$id_planet}' LIMIT 1;"); $planeta = $db->recorrer($sql); $this->planet = array('image' => $planeta['imagen'], 'name' => $planeta['nombre'], 'fields' => $planeta['campos'], 'used_fields' => $planeta['campos_usados'], 'temperature' => $planeta['temperatura'], 'orbit' => $planeta['pos'], 'solar' => $planeta['sistema'], 'metal' => $planeta['metal'], 'cristal' => $planeta['cristal'], 'tritio' => $planeta['tritio'], 'matter' => $planeta['materia']); $db->liberar($sql); $db->close(); unset($planeta, $db, $sql); }
public function __construct(IReport $report, $timezone) { $dateFormat = Resources::GetInstance()->GeneralDateTimeFormat(); $orderedColumns = array(ColumnNames::ACCESSORY_NAME => new ReportStringColumn('Accessory', ChartColumnDefinition::Label(ColumnNames::ACCESSORY_ID, ChartGroup::Accessory)), ColumnNames::RESOURCE_NAME_ALIAS => new ReportStringColumn('Resource', ChartColumnDefinition::Label(ColumnNames::RESOURCE_ID, ChartGroup::Resource)), ColumnNames::QUANTITY => new ReportStringColumn('QuantityReserved', ChartColumnDefinition::Total()), ColumnNames::RESERVATION_START => new ReportDateColumn('BeginDate', $timezone, $dateFormat, ChartColumnDefinition::Date()), ColumnNames::RESERVATION_END => new ReportDateColumn('EndDate', $timezone, $dateFormat, ChartColumnDefinition::Null()), ColumnNames::RESERVATION_TITLE => new ReportStringColumn('Title', ChartColumnDefinition::Null()), ColumnNames::RESERVATION_DESCRIPTION => new ReportStringColumn('Description', ChartColumnDefinition::Null()), ColumnNames::REFERENCE_NUMBER => new ReportStringColumn('ReferenceNumber', ChartColumnDefinition::Null()), ColumnNames::OWNER_FULL_NAME_ALIAS => new ReportStringColumn('User', ChartColumnDefinition::Label(ColumnNames::OWNER_USER_ID)), ColumnNames::GROUP_NAME_ALIAS => new ReportStringColumn('Group', ChartColumnDefinition::Label(ColumnNames::GROUP_ID)), ColumnNames::SCHEDULE_NAME_ALIAS => new ReportStringColumn('Schedule', ChartColumnDefinition::Label(ColumnNames::SCHEDULE_ID)), ColumnNames::RESERVATION_CREATED => new ReportDateColumn('Created', $timezone, $dateFormat, ChartColumnDefinition::Null()), ColumnNames::RESERVATION_MODIFIED => new ReportDateColumn('LastModified', $timezone, $dateFormat, ChartColumnDefinition::Null()), ColumnNames::TOTAL => new ReportStringColumn('Total', ChartColumnDefinition::Total()), ColumnNames::TOTAL_TIME => new ReportTimeColumn('Total', ChartColumnDefinition::Total())); $reportColumns = $report->GetColumns(); foreach ($orderedColumns as $key => $column) { if ($reportColumns->Exists($key)) { $this->columns[$key] = $column; } } }
public function action_index($options = array()) { Resources::add_scripts(array("js/classes/LexComments.js", "js/modules/comments/comments.js"), get_class()); Resources::add_styles(array("css/modules/comments/default.less"), get_class()); $model = array(); $model["captcha"] = Captcha::instance()->render(); $model["comments"] = array(); $model["comments"][] = array("name" => "lexa4ok", "comment" => "test1"); $model["comments"][] = array("name" => "lexa4ok2", "comment" => "test2"); $this->set_template("/widgets/comments/default.php", "twig")->render($model)->body(); }
public function Validate($reservationSeries) { foreach ($reservationSeries->AllResources() as $resource) { if (!$resource->GetAllowMultiday()) { $schedule = $this->scheduleRepository->LoadById($reservationSeries->ScheduleId()); $tz = $schedule->GetTimezone(); $isSameDay = $reservationSeries->CurrentInstance()->StartDate()->ToTimezone($tz)->DateEquals($reservationSeries->CurrentInstance()->EndDate()->ToTimezone($tz)); return new ReservationRuleResult($isSameDay, Resources::GetInstance()->GetString('MultiDayRule', $resource->GetName())); } } return new ReservationRuleResult(); }
public function run() { $controller = $this->controller; $id = $_GET['id']; $res = new Resources(); Resources::deleteResourceSchedule('Employees', $id); Resources::deleteResourceSchedule('Hardware', $id); Resources::deleteResourceSchedule('Facilities', $id); Resources::deleteResourceSchedule('CustomResources', $id); $controller->loadModel($id)->delete(); $controller->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('project/list')); }