/** * Constructs a new model field label decorator * @param zibo\library\i18n\translation\Translator $translator * @return null */ public function __construct(Translator $translator = null) { if (!$translator) { $translator = I18n::getInstance()->getTranslator(); } $this->translator = $translator; }
/** * Prepare the taskbar for the API module * @param zibo\library\admin\view\taskbar\Taskbar $taskbar * @return null */ public function prepareTaskbar(Taskbar $taskbar) { $translator = I18n::getInstance()->getTranslator(); $settingsMenu = $taskbar->getSettingsMenu(); $systemMenu = $settingsMenu->getItem($translator->translate(BaseView::TRANSLATION_TASKBAR_SYSTEM)); $systemMenu->addMenuItem(new MenuItem($translator->translate(self::TRANSLATION_API), self::ROUTE_API)); }
/** * Constructs a new install/upgrade decorator * @param zibo\admin\model\Installer $installer Module installer * @param string $installAction URL to the install action * @param string $upgradeAction URL to the upgrade action * @return null */ public function __construct(Installer $installer, $installAction, $upgradeAction) { $this->installer = $installer; $this->installAction = $installAction; $this->upgradeAction = $upgradeAction; $this->translator = I18n::getInstance()->getTranslator(); }
/** * Constructs a new properties form * @param string $action URL where this form will point to * @param joppa\model\Node $node * @param joppa\content\model\ContentProperties $properties * @return null */ public function __construct($action, Node $node, ContentProperties $properties) { parent::__construct($action, self::NAME, self::TRANSLATION_SAVE); $translator = I18n::getInstance()->getTranslator(); $modelManager = ModelManager::getInstance(); $fieldFactory = FieldFactory::getInstance(); $model = $properties->getModelName(); $fields = $properties->getModelFields(); $recursiveDepth = $properties->getRecursiveDepth(); $includeUnlocalized = $properties->getIncludeUnlocalized(); $view = $properties->getView(); $modelField = $fieldFactory->createField(FieldFactory::TYPE_LIST, self::FIELD_MODEL, $model); $modelField->setOptions($this->getModelOptions($modelManager)); $modelField->addEmpty(); $fieldsField = $fieldFactory->createField(FieldFactory::TYPE_LIST, self::FIELD_FIELDS, $fields); $fieldsField->setOptions(self::getModelFieldOptions($modelManager, $model)); $fieldsField->setIsMultiple(true); $recursiveDepthField = $fieldFactory->createField(FieldFactory::TYPE_LIST, self::FIELD_RECURSIVE_DEPTH, $recursiveDepth); $recursiveDepthField->setOptions($this->getNumericOptions(0, 5)); $includeUnlocalizedField = $fieldFactory->createField(FieldFactory::TYPE_LIST, self::FIELD_INCLUDE_UNLOCALIZED, $includeUnlocalized); $includeUnlocalizedField->setOptions($this->getIncludeUnlocalizedOptions($translator)); $viewField = $fieldFactory->createField(FieldFactory::TYPE_LIST, self::FIELD_VIEW, $view); $viewField->setOptions($this->getViewOptions($translator)); $this->addField($modelField); $this->addField($fieldsField); $this->addField($recursiveDepthField); $this->addField($includeUnlocalizedField); $this->addField($viewField); }
/** * Initialize this field by setting the available locales as options * @return null */ protected function init() { parent::init(); $locales = I18n::getInstance()->getAllLocales(); $this->setOptions($locales); $this->setValueDecorator(new LocaleCodeDecorator()); }
/** * Constructs a new namespace decorator * @param string $action URL where the link behind the namespace name will point to. The name of the namespace will be concatted to this URL * @return null */ public function __construct($action) { $this->action = $action; $this->translator = I18n::getInstance()->getTranslator(); $image = new Image(ModuleNamespace::ICON); $this->image = $image->getHtml(); }
/** * Constructs a new queue detail decorator * @param string $action URL for the action behind this decorator * @return null */ public function __construct($action) { $this->action = $action; $i18n = I18n::getInstance(); $this->locale = $i18n->getLocale(); $this->translator = $i18n->getTranslator(); }
function smarty_function_pagination($params, &$smarty) { $translator = I18n::getInstance()->getTranslator(); $page = 0; $pages = null; $href = null; $onclick = null; $label = null; foreach ($params as $k => $v) { switch ($k) { case 'label': case 'page': case 'pages': case 'href': case 'onclick': ${$k} = $v; break; } } $pagination = new Pagination($pages, $page); $pagination->setHref($href); $pagination->setOnclick($onclick); if ($label) { $pagination->setLabel($label); } return $pagination->getHtml(); }
function smarty_function_link($params, &$smarty) { if (empty($params['name'])) { throw new Exception('No name parameter provided for the link'); } if (empty($params['href'])) { throw new Exception('No href parameter provided for the link'); } $name = $params['name']; $href = $params['href']; unset($params['name']); unset($params['href']); $title = $name; if (!empty($params['title'])) { $title = $params['title']; unset($params['title']); } $translator = I18n::getInstance()->getTranslator(); $name = $translator->translate($name); $title = $translator->translate($title); $anchor = new Anchor($name, $href); $anchor->setAttribute('title', $title); foreach ($params as $key => $value) { $anchor->setAttribute($key, $value); } return $anchor->getHtml(); }
/** * Construct this view * @param joppa\form\backend\SiteSelectForm $siteSelectForm form to select another site * @param joppa\model\Site $site the current site (optional) * @param joppa\model\Node $node the current node (optional) * @return null */ public function __construct(SiteSelectForm $siteSelectForm, Site $site = null, Node $node = null) { parent::__construct('joppa/backend/sidebar'); $createActions = array(); $baseUrl = $this->get('_baseUrl') . '/'; $nodeTypeFacade = NodeTypeFacade::getInstance(); $nodeTreeHtml = null; if ($site) { $this->setSubview('tree', new TreeView($site, $node)); $toggleAction = $baseUrl . Module::ROUTE_AJAX_TREE; $orderAction = $baseUrl . Module::ROUTE_JOPPA . '/node/order/'; $translator = I18n::getInstance()->getTranslator(); $deleteConfirmMessage = $translator->translate(self::TRANSLATION_DELETE_NODE_CONFIRM); $this->addJavascript(self::SCRIPT_TREE); $this->addInlineJavascript("joppaInitializeNodeTree('{$toggleAction}', '{$orderAction}', '{$deleteConfirmMessage}');"); $labels = $nodeTypeFacade->getLabels(); foreach ($labels as $type => $label) { $action = array('type' => $type, 'label' => $label, 'url' => $baseUrl . Module::ROUTE_JOPPA . '/' . $type . '/add'); $createActions[] = $action; } } else { $createActions[] = array('type' => SiteModel::NODE_TYPE, 'label' => $nodeTypeFacade->getLabel(SiteModel::NODE_TYPE), 'url' => $baseUrl . Module::ROUTE_JOPPA . '/' . SiteModel::NODE_TYPE . '/add'); } $this->set('formSiteSelect', $siteSelectForm); $this->set('createActions', $createActions); }
/** * Constructs a new localize view * @param $meta * @param $id * @param $action * @param $field * @return null */ public function __construct(ModelMeta $meta, $data, $action = null) { parent::__construct(self::TEMPLATE); $localizedModel = $meta->getLocalizedModel(); $localizedFields = $meta->getLocalizedFields(); $currentLocale = LocalizeController::getLocale(); $allLocales = I18n::getInstance()->getAllLocales(); unset($allLocales[$currentLocale]); $locales = array(); foreach ($allLocales as $locale) { $locale = $locale->getCode(); $localizedId = $localizedModel->getLocalizedId($data->id, $locale); if ($localizedId === null) { $locales[$locale] = null; continue; } $localesData = clone $data; $localizedData = $localizedModel->findById($localizedId); foreach ($localizedFields as $fieldName => $localizedField) { $localesData->{$fieldName} = $localizedData->{$fieldName}; } $localesData->localizedLabel = $meta->formatData($localesData); $locales[$locale] = $localesData; } $this->set('locales', $locales); $this->set('action', $action); }
/** * Constructs a new log change table * @param array $changes */ public function __construct(array $changes) { parent::__construct($changes); $translator = I18n::getInstance()->getTranslator(); $this->addDecorator(new ZebraDecorator(new LogValueDecorator('fieldName')), new StaticDecorator($translator->translate('orm.label.field'))); $this->addDecorator(new LogValueDecorator('oldValue'), new StaticDecorator($translator->translate('orm.label.value.old'))); $this->addDecorator(new LogValueDecorator('newValue'), new StaticDecorator($translator->translate('orm.label.value.new'))); }
/** * Gets the view of this step * @return zibo\core\View */ public function getView() { $installer = $this->wizard->getInstaller(); $profile = $this->wizard->getProfile(); $requirements = $installer->getRequirements($profile); $translator = I18n::getInstance()->getTranslator(); return new InstallStepRequirementView($requirements, $translator); }
function smarty_modifier_formatDate($string, $format = null) { $locale = I18n::getInstance()->getLocale(); if ($format) { return $locale->formatDate($string, $format); } return $locale->formatDate($string); }
/** * Constructs a new localize decorator * @param zibo\library\orm\model\Model $model Model of the data * @param string $action URL where the locale code should point to * @return null */ public function __construct(Model $model, $action = null) { $this->action = $action; $this->meta = $model->getMeta(); $this->localizedModel = $this->meta->getLocalizedModel(); $this->currentLocale = LocalizeController::getLocale(); $this->locales = I18n::getInstance()->getLocaleCodeList(); unset($this->locales[$this->currentLocale]); }
public function __construct(array $reports) { parent::__construct(self::TEMPLATE); $this->set('translator', I18n::getInstance()->getTranslator()); $this->set('reports', $reports); foreach ($reports as $index => $report) { $this->setSubview('report' . $index, $report->getView()); } }
/** * Construct the taskbar * @return null */ public function __construct() { $translator = I18n::getInstance()->getTranslator(); $this->applicationsMenu = new Menu($translator->translate(self::TRANSLATION_APPLICATIONS)); $this->applicationsMenu->setId(self::APPLICATIONS_STYLE_ID); $this->applicationsMenu->setClass(self::APPLICATIONS_STYLE_CLASS); $this->settingsMenu = new Menu($translator->translate(self::TRANSLATION_SETTINGS)); $this->notificationPanels = array(); }
/** * Construct a new localized message * @param string $message translation key of the message * @param string $type type of this message * @param array $vars variables for the translation * @param zibo\library\i18n\translation\Translator $translator * @return null */ public function __construct($message, $type = null, array $vars = null, Translator $translator = null) { if ($translator === null) { $i18n = I18n::getInstance(); $translator = $i18n->getTranslator(); } $message = $translator->translate($message, $vars); parent::__construct($message, $type); }
/** * Installs or updates the continents and countries from the data directory into the model. * @return null */ public function install() { $modelManager = ModelManager::getInstance(); $continentModel = $modelManager->getModel(ContinentModel::NAME); $countryModel = $modelManager->getModel(CountryModel::NAME); $locales = I18n::getInstance()->getLocaleCodeList(); $continents = $continentModel->installContinents($locales); $countryModel->installCountries($locales, $continents); }
/** * Constructs a new properties form * @param string $action URL where this form will point to * @param joppa\model\Node $node * @param joppa\content\model\ContentProperties $properties * @return null */ public function __construct($action, Node $node, ContentProperties $properties) { parent::__construct($action, $node, $properties); $translator = I18n::getInstance()->getTranslator(); $fieldFactory = FieldFactory::getInstance(); $parameterId = $properties->getParameterId(); $parameterIdField = $fieldFactory->createField(FieldFactory::TYPE_OPTION, self::FIELD_PARAMETER_ID, $parameterId); $parameterIdField->setOptions($this->getParameterIdOptions($translator)); $this->addField($parameterIdField); }
/** * Gets the HTML of this boolean field * @return string */ public function getHtml() { $html = '<select' . $this->getNameHtml() . $this->getIdHtml() . $this->getClassHtml() . $this->getAttributesHtml() . $this->getIsDisabledHtml() . '>'; $selected = $this->getDisplayValue(); $translator = I18n::getInstance()->getTranslator(); $html .= $this->getHtmlOption('', '---', $selected); $html .= $this->getHtmlOption('0', $translator->translate('label.no'), $selected); $html .= $this->getHtmlOption('1', $translator->translate('label.yes'), $selected); $html .= '</select>'; return $html; }
public function __construct($step, View $contentView = null) { $tempDirectory = Module::getTempDirectory(); parent::__construct(self::TEMPLATE, $tempDirectory); $this->set('step', $step); $this->set('locale', I18n::getInstance()->getLocale()->getCode()); if ($contentView) { $this->setSubview('content', $contentView); } $this->addStyle(self::STYLE); }
/** * Gets the HTML of the localized image * @return string The HTML of the localized image */ private function getLocalizedImageHtml() { if ($this->localizedImage) { return $this->localizedImage; } $translator = I18n::getInstance()->getTranslator(); $image = new Image(self::IMAGE_LOCALIZED); $image->setAttribute('title', $translator->translate(self::TRANSLATION_LOCALIZED)); $this->localizedImage = $image->getHtml(); return $this->localizedImage; }
/** * Constructs a new log view * @param string $modelName Name of the model * @param int $id Primary key of the data * @return null */ public function __construct($modelName, $id) { parent::__construct(self::TEMPLATE); $request = Zibo::getInstance()->getRequest(); $dataUrl = $request->getBaseUrl() . '/' . Module::ROUTE_LOG_AJAX . '/' . $modelName . '/' . $id; $translator = I18n::getInstance()->getTranslator(); $labelShow = $translator->translate(self::TRANSLATION_SHOW); $labelHide = $translator->translate(self::TRANSLATION_HIDE); $this->addStyle(self::STYLE); $this->addJavascript(self::SCRIPT); $this->addInlineJavascript('ziboOrmInitializeLog("' . $labelShow . '", "' . $labelHide . '", "' . $dataUrl . '");'); }
/** * Constructs a new decorator * @param string $value The value to set to the cells * @param boolean $translate Set to true to translate the value * @return null * @throws zibo\ZiboException when an empty value is provided and the translate flag is set to true */ public function __construct($value, $translate = false) { if (!$translate) { $this->value = $value; return; } if (String::isEmpty($value)) { throw new ZiboException('The provided value is empty. When translating the value, a value is required'); } $translator = I18n::getInstance()->getTranslator(); $this->value = $translator->translate($value); }
/** * Validate a date configuration value * @param string $date date configuration value * @param zibo\library\validation\exception\ValidationException $validationException when a ValidationError occures, it will be added to this exception and null will be returned * @param string $fieldName name of the field to register possible errors to the ValidationException * @return string valid date configuration value */ private function validateDate($date, ValidationException $validationException, $fieldName) { try { $locale = I18n::getInstance()->getLocale(); $timestamp = $locale->parseDate($date, NodeSettingModel::DATE_FORMAT); return $locale->formatDate($timestamp, NodeSettingModel::DATE_FORMAT); } catch (Exception $exception) { $error = new ValidationError('joppa.error.date', $exception->getMessage(), array('date' => $date)); $validationException->addErrors($fieldName, array($error)); } return null; }
/** * Construct the main dashboard view * @param array $widgets * @param string $returnAction * @param string $saveAction * @return null */ public function __construct(array $widgets, $returnAction, $saveAction) { parent::__construct('dashboard/widget.add'); $translator = I18n::getInstance()->getTranslator(); $saveMessage = $translator->translate('dashboard.message.added'); $this->set('returnAction', $returnAction); $this->set('widgets', $widgets); $this->addStyle(Module::STYLE_DASHBOARD); $this->addJavascript(Module::SCRIPT_DASHBOARD); $this->addInlineJavascript('dashboardSaveAction = "' . $saveAction . '";'); $this->addInlineJavascript('dashboardSaveMessage = "' . $saveMessage . '";'); }
/** * Sets the locale of this PDF document * @param string $locale The locale to use for this document. If not provided, the current locale of Zibo will be used * @return null */ public function setLocale($locale = null) { if (!$locale) { $locale = I18n::getInstance()->getLocale(); $locale = $locale->getCode(); } if (!array_key_exists($locale, $this->locales)) { throw new ZiboException('Could not set the locale for this PDF document: ' . $locale . ' is not mapped'); } require_once K_PATH_MAIN . 'config/lang/' . $this->locales[$locale] . '.php'; global $l; $this->setLanguageArray($l); }
/** * Prepares the wizard form for this step * @return null */ public function prepareForm() { $fieldFactory = FieldFactory::getInstance(); $translator = I18n::getInstance()->getTranslator(); $installer = $this->wizard->getInstaller(); $languages = $installer->getLanguages(); $selectedLanguages = $this->wizard->getLanguages(); $selectedLanguages = array_flip($selectedLanguages); $languageField = $fieldFactory->createField(FieldFactory::TYPE_OPTION, self::FIELD_LANGUAGES, $selectedLanguages); $languageField->setOptions($languages); $languageField->setIsMultiple(true); $this->wizard->addField($languageField); }
/** * Action to reorder the preference of the locales * @return null */ public function orderAction() { if (!isset($_POST['locale'])) { return; } $order = $_POST['locale']; $i18n = I18n::getInstance(); foreach ($order as $localeCode) { // exception is thrown by getLocale() if locale with the specified code is not found $locale = $i18n->getLocale($localeCode); } $localeOrder = implode(',', $order); Zibo::getInstance()->setConfigValue(Manager::CONFIG_LOCALE_ORDER, $localeOrder); }