Example #1
0
    /**
     * @return string
     */
    protected function fetchSortForbiddenHtml()
    {
        $html = <<<HTML
<i class="glyphicon glyphicon-remove-circle text-danger text-danger" aria-hidden="true" title="%s"></i>
HTML;
        return sprintf($html, $this->translator->t('system', 'move_impossible'));
    }
Example #2
0
 /**
  * Saves the menu items to the cache
  *
  * @return boolean
  */
 public function saveMenusCache()
 {
     $menuItems = $this->menuItemRepository->getAllMenuItems();
     $cMenuItems = count($menuItems);
     if ($cMenuItems > 0) {
         $menus = $this->menuRepository->getAllMenus();
         $cMenus = count($menus);
         for ($i = 0; $i < $cMenus; ++$i) {
             $this->saveVisibleMenuItemsCache($menus[$i]['index_name']);
         }
         for ($i = 0; $i < $cMenuItems; ++$i) {
             for ($j = 0; $j < $cMenus; ++$j) {
                 if ($menuItems[$i]['block_id'] == $menus[$j]['id']) {
                     $menuItems[$i]['block_title'] = $menus[$j]['title'];
                     $menuItems[$i]['block_name'] = $menus[$j]['index_name'];
                 }
             }
         }
         $modeSearch = ['1', '2', '3', '4'];
         $modeReplace = [$this->translator->t('menus', 'module'), $this->translator->t('menus', 'dynamic_page'), $this->translator->t('menus', 'hyperlink'), $this->translator->t('menus', 'article')];
         for ($i = 0; $i < $cMenuItems; ++$i) {
             $menuItems[$i]['mode_formatted'] = str_replace($modeSearch, $modeReplace, $menuItems[$i]['mode']);
             $menuItems[$i]['first'] = $this->isFirstItemInSet($i, $menuItems);
             $menuItems[$i]['last'] = $this->isLastItemInSet($i, $menuItems);
         }
     }
     return $this->cache->save(self::CACHE_ID, $menuItems);
 }
 /**
  * @inheritdoc
  */
 public function isValid($data, $field = '', array $extra = [])
 {
     if (is_array($data) && array_key_exists($field, $data)) {
         return $this->isValid($data[$field], $field, $extra);
     }
     return $this->translator->languagePackExists($data);
 }
 /**
  * @param \ACP3\Core\Helpers\DataGrid\ColumnRenderer\Event\CustomOptionEvent $customOptionEvent
  */
 public function onDataGridCustomOptionBefore(CustomOptionEvent $customOptionEvent)
 {
     if ($customOptionEvent->getIdentifier() === '#newsletter-data-grid' && $this->acl->hasPermission('admin/newsletter/index/send') === true) {
         $dbResultRow = $customOptionEvent->getDbResultRow();
         if (array_key_exists('status', $dbResultRow) && $dbResultRow['status'] != 1) {
             $customOptionEvent->getOptionRenderer()->addOption('acp/newsletter/index/send/id_' . $dbResultRow['id'], $this->translator->t('newsletter', 'send'), 'glyphicon-envelope', 'btn-primary', true);
         }
     }
 }
 /**
  * @param \ACP3\Core\Breadcrumb\Title $title
  */
 private function addPageTitlePostfix(Title $title)
 {
     if ($this->request->getModule() !== 'acp') {
         if (!empty($title->getPageTitlePostfix())) {
             $title->setPageTitlePostfix($title->getPageTitlePostfix() . $title->getPageTitleSeparator() . $this->translator->t('acp', 'acp'));
         } else {
             $title->setPageTitlePostfix($this->translator->t('acp', 'acp'));
         }
     }
 }
Example #6
0
 /**
  * @param array $search
  * @param string $translatorPrefix
  * @return array
  */
 protected function cacheLocalizedDate(array $search, $translatorPrefix)
 {
     if (!isset($this->cache[$translatorPrefix])) {
         $buffer = [];
         foreach ($search as $key) {
             $buffer[$key] = $this->translator->t('system', $translatorPrefix . '_' . strtolower($key));
         }
         $this->cache[$translatorPrefix] = $buffer;
     }
     return $this->cache[$translatorPrefix];
 }
Example #7
0
 /**
  * Formats a given single date or date range into the desired format
  *
  * @param string $start
  * @param string $end
  * @param string $format
  *
  * @return string
  */
 public function formatTimeRange($start, $end = '', $format = 'long')
 {
     if (empty($end) || $start >= $end) {
         if (empty($end)) {
             $title = $this->date->format($start, $format);
         } else {
             $title = $this->translator->t('system', 'date_published_since', ['%date%' => $this->date->format($start, $format)]);
         }
         return $this->generateTimeTag($start, $format, $title);
     } else {
         $dateRange = $this->generateTimeTag($start, $format);
         $dateRange .= '&ndash;';
         $dateRange .= $this->generateTimeTag($end, $format);
         return $dateRange;
     }
 }
 /**
  * @inheritdoc
  */
 protected function getDbValueIfExists(array $dbResultRow, $field)
 {
     if (isset($dbResultRow[$field])) {
         if ((int) $dbResultRow[$field] === 0) {
             $route = $this->router->route('acp/newsletter/accounts/activate/id_' . $dbResultRow[$this->primaryKey]);
             $title = $this->translator->t('newsletter', 'activate_account');
             $value = '<a href="' . $route . '" title="' . $title . '">';
             $value .= '<i class="glyphicon glyphicon-remove text-danger"></i>';
             $value .= '</a>';
         } else {
             $value = '<i class="glyphicon glyphicon-ok text-success"></i>';
         }
         return $value;
     }
     return null;
 }
Example #9
0
 /**
  * @param array  $moduleInfo
  * @param string $moduleName
  *
  * @return string
  */
 protected function getModuleName(array $moduleInfo, $moduleName)
 {
     if (isset($moduleInfo['name']['lang']) && $moduleInfo['name']['lang'] === 'true') {
         return $this->translator->t($moduleName, $moduleName);
     }
     return $moduleInfo['name'];
 }
Example #10
0
 /**
  * @param array|string $page
  * @param int          $pageNumber
  * @param bool         $titlesFromDb
  *
  * @return string
  */
 protected function fetchTocPageTitle($page, $pageNumber, $titlesFromDb)
 {
     if ($titlesFromDb === false && is_array($page) === false) {
         $page = $this->getHtmlAttributes($page);
     }
     $transPageNumber = $this->translator->t('system', 'toc_page', ['%page%' => $pageNumber]);
     return !empty($page['title']) ? $page['title'] : $transPageNumber;
 }
Example #11
0
File: Steps.php Project: acp3/core
 /**
  * Sets the breadcrumb steps cache for frontend action requests
  */
 protected function buildBreadcrumbCacheForFrontend()
 {
     if (empty($this->steps)) {
         $this->append($this->translator->t($this->request->getModule(), $this->request->getModule()), $this->request->getModule());
         $this->appendControllerActionBreadcrumbs();
     }
     $this->breadcrumbCache = $this->steps;
 }
Example #12
0
File: Action.php Project: acp3/core
 /**
  * @param array $entries
  *
  * @return string
  */
 private function prepareConfirmationBoxText(array $entries)
 {
     $entriesCount = count($entries);
     if ($entriesCount === 1) {
         return $this->translator->t('system', 'confirm_delete_single');
     }
     return $this->translator->t('system', 'confirm_delete_multiple', ['{items}' => $entriesCount]);
 }
Example #13
0
 /**
  * @inheritdoc
  */
 public function fetchDataAndRenderColumn(array $column, array $dbResultRow)
 {
     $this->eventDispatcher->dispatch('data_grid.column_renderer.custom_option_before', new CustomOptionEvent($this->optionRenderer, $dbResultRow, $this->identifier));
     if ($column['custom']['can_edit']) {
         $resourcePathEdit = $column['custom']['resource_path_edit'];
         $resourcePathEdit .= !preg_match('=/$=', $resourcePathEdit) ? '/' : '';
         $this->optionRenderer->addOption($resourcePathEdit . 'id_' . $dbResultRow[$this->primaryKey], $this->translator->t('system', 'edit'), 'glyphicon-edit', 'btn-default');
     }
     $this->eventDispatcher->dispatch('data_grid.column_renderer.custom_option_between', new CustomOptionEvent($this->optionRenderer, $dbResultRow, $this->identifier));
     if ($column['custom']['can_delete']) {
         $resourcePathDelete = $column['custom']['resource_path_delete'];
         $resourcePathDelete .= !preg_match('=/$=', $resourcePathDelete) ? '/' : '';
         $this->optionRenderer->addOption($resourcePathDelete . 'entries_' . $dbResultRow[$this->primaryKey], $this->translator->t('system', 'delete'), 'glyphicon-remove', 'btn-danger');
     }
     $this->eventDispatcher->dispatch('data_grid.column_renderer.custom_option_after', new CustomOptionEvent($this->optionRenderer, $dbResultRow, $this->identifier));
     return $this->render($column, $this->collectOptions());
 }
Example #14
0
 /**
  * @return $this
  * @throws Core\ACL\Exception\AccessForbiddenException
  */
 public function preDispatch()
 {
     $path = $this->request->getArea() . '/' . $this->request->getFullPathWithoutArea();
     if ($this->acl->hasPermission($path) === false) {
         throw new Core\ACL\Exception\AccessForbiddenException();
     }
     $this->view->assign(['PHP_SELF' => $this->appPath->getPhpSelf(), 'ROOT_DIR' => $this->appPath->getWebRoot(), 'HOST_NAME' => $this->request->getHttpHost(), 'ROOT_DIR_ABSOLUTE' => $this->request->getScheme() . '://' . $this->request->getHttpHost() . $this->appPath->getWebRoot(), 'DESIGN_PATH' => $this->appPath->getDesignPathWeb(), 'DESIGN_PATH_ABSOLUTE' => $this->appPath->getDesignPathAbsolute(), 'LANG_DIRECTION' => $this->translator->getDirection(), 'LANG' => $this->translator->getShortIsoCode()]);
     return $this;
 }
Example #15
0
 /**
  * @param bool $canDelete
  * @param bool $canEdit
  */
 protected function addDefaultColumns($canDelete, $canEdit)
 {
     if ($this->enableMassAction && $canDelete) {
         $this->addColumn(['label' => $this->identifier, 'type' => MassActionColumnRenderer::class, 'class' => 'datagrid-column datagrid-column__mass-action', 'sortable' => false, 'custom' => ['can_delete' => $canDelete]], 1000);
     }
     if ($this->enableOptions) {
         $this->addColumn(['label' => $this->translator->t('system', 'action'), 'type' => OptionColumnRenderer::class, 'class' => 'datagrid-column datagrid-column__actions', 'sortable' => false, 'custom' => ['can_delete' => $canDelete, 'can_edit' => $canEdit, 'resource_path_delete' => $this->resourcePathDelete, 'resource_path_edit' => $this->resourcePathEdit]], 0);
     }
 }
Example #16
0
 /**
  * @param array  $params
  * @param string $action
  * @param string $area
  *
  * @return array
  */
 private function collectData(array $params, $action, $area)
 {
     $accessCheck = [];
     $accessCheck['uri'] = $this->router->route($params['path']);
     if (isset($params['title'])) {
         $accessCheck['title'] = $params['title'];
     }
     if (isset($params['lang'])) {
         $langArray = explode('|', $params['lang']);
         $accessCheck['lang'] = $this->translator->t($langArray[0], $langArray[1]);
     } else {
         $accessCheck['lang'] = $this->translator->t($action[0], $area . '_' . $action[1] . '_' . $action[2]);
     }
     if (isset($params['class'])) {
         $accessCheck['class'] = $params['class'];
     }
     $accessCheck['mode'] = $params['mode'];
     return $accessCheck;
 }
 /**
  * @param FormValidationEvent $event
  */
 public function validateManageMenuItem(FormValidationEvent $event)
 {
     $formData = $event->getFormData();
     if ($this->acl->hasPermission('admin/menus/items/create') === true && isset($formData['create']) === true) {
         $event->getValidator()->addConstraint(NotEmptyValidationRule::class, ['data' => $formData, 'field' => 'menu_item_title', 'message' => $this->translator->t('menus', 'title_to_short')])->addConstraint(IntegerValidationRule::class, ['data' => $formData, 'field' => 'block_id', 'message' => $this->translator->t('menus', 'select_menu_bar')])->addConstraint(ParentIdValidationRule::class, ['data' => $formData, 'field' => 'parent_id', 'message' => $this->translator->t('menus', 'select_superior_page')])->addConstraint(InArrayValidationRule::class, ['data' => $formData, 'field' => 'display', 'message' => $this->translator->t('menus', 'select_item_visibility'), 'extra' => ['haystack' => [0, 1]]])->addConstraint(AllowedMenuValidationRule::class, ['data' => $formData, 'field' => ['parent_id', 'block_id'], 'message' => $this->translator->t('menus', 'superior_page_not_allowed')]);
     }
 }
Example #18
0
 /**
  * Listet alle Kategorien eines Moduls auf
  *
  * @param string $module
  * @param string $categoryId
  * @param boolean $categoryCreate
  * @param string $formFieldName
  * @param string $customText
  *
  * @return array
  */
 public function categoriesList($module, $categoryId = '', $categoryCreate = false, $formFieldName = 'cat', $customText = '')
 {
     $categories = [];
     $categories['custom_text'] = !empty($customText) ? $customText : $this->translator->t('system', 'pls_select');
     $categories['name'] = $formFieldName;
     $categories['categories'] = $this->categoriesCache->getCache($module);
     $cData = count($categories['categories']);
     for ($i = 0; $i < $cData; ++$i) {
         $categories['categories'][$i]['selected'] = $this->formsHelper->selectEntry($formFieldName, $categories['categories'][$i]['id'], $categoryId);
     }
     if ($categoryCreate === true && $this->acl->hasPermission('admin/categories/index/create') === true) {
         $categories['create']['name'] = $formFieldName . '_create';
         $categories['create']['value'] = $this->request->getPost()->get('create', ['name' => ''])['name'];
     }
     return $categories;
 }
Example #19
0
 /**
  * Configures the CKEditor instance
  *
  * @return string
  */
 private function configure()
 {
     $this->config['entities'] = false;
     $this->config['extraPlugins'] = 'divarea,oembed,codemirror';
     $this->config['allowedContent'] = true;
     $this->config['language'] = $this->translator->getShortIsoCode();
     $this->config['codemirror'] = ['theme' => 'default', 'lineNumbers' => true, 'lineWrapping' => true, 'matchBrackets' => true, 'autoCloseTags' => true, 'autoCloseBrackets' => true, 'enableSearchTools' => true, 'enableCodeFolding' => true, 'enableCodeFormatting' => true, 'autoFormatOnStart' => true, 'autoFormatOnUncomment' => true, 'highlightActiveLine' => true, 'highlightMatches' => true, 'showFormatButton' => false, 'showCommentButton' => false, 'showUncommentButton' => false];
     // Full toolbar
     if (!isset($this->config['toolbar']) || $this->config['toolbar'] !== 'Basic') {
         $this->configureFullToolbar();
     } else {
         // basic toolbar
         $this->configureBasicToolbar();
     }
     return json_encode($this->config);
 }
Example #20
0
 /**
  * @param string $emailAddress
  * @param string $hash
  *
  * @return bool
  */
 protected function sendDoubleOptInEmail($emailAddress, $hash)
 {
     $url = $this->router->route('newsletter/index/activate/hash_' . $hash, true);
     $systemSettings = $this->config->getSettings(\ACP3\Modules\ACP3\System\Installer\Schema::MODULE_NAME);
     $settings = $this->config->getSettings(Schema::MODULE_NAME);
     $subject = $this->translator->t('newsletter', 'subscribe_mail_subject', ['%title%' => $systemSettings['site_title']]);
     $body = $this->translator->t('newsletter', 'subscribe_mail_body', ['{host}' => $this->request->getHost()]) . "\n\n";
     $from = ['email' => $settings['mail'], 'name' => $systemSettings['site_title']];
     $this->mailer->reset()->setFrom($from)->setSubject($subject)->setMailSignature($settings['mailsig']);
     if ($settings['html'] == 1) {
         $this->mailer->setTemplate('newsletter/layout.email.tpl');
         $body .= '<a href="' . $url . '">' . $url . '<a>';
         $this->mailer->setHtmlBody($this->stringFormatter->nl2p($body));
     } else {
         $body .= $url;
         $this->mailer->setBody($body);
     }
     $this->mailer->setRecipients($emailAddress);
     return $this->mailer->send();
 }
Example #21
0
 /**
  * @param string $link
  * @param array  $range
  */
 private function showLastPageLink($link, array $range)
 {
     if ($this->totalPages > $this->showFirstLast && $this->totalPages !== $range['end']) {
         $this->pagination[] = $this->buildPageNumber('&raquo;', $link . 'page_' . $this->totalPages . '/' . $this->urlFragment, $this->translator->t('system', 'last_page'));
     }
 }
 /**
  * @param \ACP3\Core\Breadcrumb\Event\StepsBuildCacheEvent $event
  */
 public function execute(StepsBuildCacheEvent $event)
 {
     $event->getSteps()->append($this->translator->t('acp', 'acp'), 'acp/acp');
 }
Example #23
0
File: Forms.php Project: acp3/core
 /**
  * @param string $formFieldName
  * @param string $currentValue
  *
  * @return array
  */
 public function yesNoCheckboxGenerator($formFieldName, $currentValue = '')
 {
     $values = [1 => $this->translator->t('system', 'yes'), 0 => $this->translator->t('system', 'no')];
     return $this->checkboxGenerator($formFieldName, $values, $currentValue);
 }
Example #24
0
 /**
  * @param array $formData
  * @param string $phrase
  * @return string
  */
 protected function buildEmailBody(array $formData, $phrase)
 {
     return $this->translator->t('contact', $phrase, ['%name%' => $formData['name'], '%mail%' => $formData['mail'], '%message%' => $this->secure->strEncode($formData['message'], true)]);
 }
Example #25
0
 /**
  * @param string $name
  * @param string $markAllId
  *
  * @return string
  */
 public function execute($name, $markAllId = '')
 {
     $markAllId = !empty($markAllId) ? $markAllId : 'mark-all';
     $deleteOptions = json_encode(['checkBoxName' => $name, 'language' => ['confirmationTextSingle' => $this->translator->t('system', 'confirm_delete_single'), 'confirmationTextMultiple' => $this->translator->t('system', 'confirm_delete_multiple'), 'noEntriesSelectedText' => $this->translator->t('system', 'no_entries_selected')]]);
     return 'data-mark-all-id="' . $markAllId . '" data-checkbox-name="' . $name . '" data-delete-options=\'' . $deleteOptions . '\'';
 }
 /**
  * @param int $currentValue
  * @return array
  */
 private function fetchCreateMenuItemOption($currentValue = 0)
 {
     $createMenuItem = [1 => $this->translator->t('menus', 'create_menu_item')];
     return $this->forms->checkboxGenerator('create', $createMenuItem, $currentValue);
 }
Example #27
0
 /**
  * @param int $currentGender
  *
  * @return array
  */
 protected function fetchGenderField($currentGender)
 {
     $genders = [1 => $this->translator->t('users', 'gender_not_specified'), 2 => $this->translator->t('users', 'gender_female'), 3 => $this->translator->t('users', 'gender_male')];
     return $this->formsHelpers->choicesGenerator('gender', $genders, $currentGender);
 }
Example #28
0
 /**
  * @return array
  */
 protected function getRobotsChoicesGeneratorValues()
 {
     return [0 => $this->translator->t('seo', 'robots_use_system_default', ['%default%' => $this->metaStatements->getRobotsSetting()]), 1 => $this->translator->t('seo', 'robots_index_follow'), 2 => $this->translator->t('seo', 'robots_index_nofollow'), 3 => $this->translator->t('seo', 'robots_noindex_follow'), 4 => $this->translator->t('seo', 'robots_noindex_nofollow')];
 }
Example #29
0
 /**
  * @inheritdoc
  */
 public function process(array $params, \Smarty_Internal_Template $smarty)
 {
     $values = explode('|', $params['t']);
     $params = isset($params['args']) && is_array($params['args']) ? $params['args'] : [];
     return $this->translator->t($values[0], $values[1], $params);
 }
 /**
  * @param FormValidationEvent $event
  */
 public function validateCaptcha(FormValidationEvent $event)
 {
     $event->getValidator()->addConstraint(CaptchaValidationRule::class, ['data' => $event->getFormData(), 'field' => 'captcha', 'message' => $this->translator->t('captcha', 'invalid_captcha_entered')]);
 }