/** * Formulaire de connexion */ public function actionLogin() { /** @var myWebUser $webUser */ if (Yii::app()->user->isGuest) { $model = new UserLogin(); if (isset($_POST['UserLogin'])) { // Connexion demandée $model->attributes = $_POST['UserLogin']; if ($model->validate()) { if (!$this->registerLastLogin()) { Yii::log(h::_('Erreur sur registerLastLogin()', __FILE__, __LINE__, __METHOD__), CLogger::LEVEL_ERROR); } Yii::app()->user->setFlash('success', Yii::t('UserModule.msg', 'You are now logged to your user account')); if (Yii::app()->user->returnUrl == '/index.php') { Yii::log(h::_(Yii::app()->user->getId(), __FILE__, __LINE__, __METHOD__), 'debug'); $this->redirect(Yii::app()->controller->module->returnUrl); } else { Yii::log(h::_(Yii::app()->user->getId(), __FILE__, __LINE__, __METHOD__), 'debug'); Yii::log(h::_(Yii::app()->user->returnUrl, __FILE__, __LINE__, __METHOD__), 'debug'); $this->redirect(Yii::app()->user->returnUrl); } } } // Affichage du formulaire de connexion (affichage initial ou erreur de validation) $this->render('/user/login', array('model' => $model)); } else { // Utilisateur déjà connecté, RAF $this->redirect(Yii::app()->controller->module->returnUrl); } }
/** * Retrieves a list of models based on the current search/filter conditions. * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions. */ public function search() { $criteria = new CDbCriteria(); $criteria->compare('event_date', h::inputDateToSQL($this->event_date), true); $criteria->compare('enabled', $this->enabled); $criteria->compare('category_id', $this->category_id); return new CActiveDataProvider($this, array('criteria' => $criteria)); }
/** * @test */ public function getShortHTMLText() { // Sans ajouter de bouton... $fullText = "Mauris facilisis, erat sollicitudin porttitor imperdiet, {{LIRE_LA_SUITE}}nulla nibh ultrices quam"; $expected = "Mauris facilisis, erat sollicitudin porttitor imperdiet,"; $this->assertEquals($expected, h::trim(ViewHelper::getShortHTMLText($fullText, ''))); // Avec un bouton ajouté... $fullText = "Mauris facilisis, erat sollicitudin porttitor imperdiet, {{LIRE_LA_SUITE}}nulla nibh ultrices quam"; $buttonMore = ViewHelper::getButtonMore(); $expected = "Mauris facilisis, erat sollicitudin porttitor imperdiet, {$buttonMore}"; $this->assertEquals($expected, h::trim(ViewHelper::getShortHTMLText($fullText))); }
public function getView() { $o = $this; h::div(array('class' => 'clearfix'), function () use($o) { h::label(array('for' => 'username'), 'API Username'); h::div(array('class' => 'input'), function () use($o) { h::input(array('class' => 'span6', 'type' => 'text', 'name' => 'username', 'value' => $o->getUsername())); }); }); h::div(array('class' => 'clearfix'), function () use($o) { h::label(array('for' => 'key'), 'API Secret'); h::div(array('class' => 'input'), function () use($o) { h::input(array('class' => 'span6', 'type' => 'text', 'name' => 'key', 'value' => $o->getKey())); }); }); }
/** * @param string $body * @param string $signature * * @return string */ protected function body_normalization($body, $signature) { if (strpos($body, '<!doctype') === 0 && strpos($body, '<body') !== false) { $body = "<!doctype html>\n{$body}"; } if (strpos($body, '<html') === false) { if (substr($body, 0, 5) != '<body') { $body = h::body($body . $signature); } else { $body = str_replace('</body>', "{$signature}</body>", $body); } $body = h::html(h::{'head meta'}(['content' => 'text/html; charset=utf-8', 'http-equiv' => 'Content-Type']) . $body); } else { $body = str_replace('</body>', "{$signature}</body>", $body); } return $body; }
/** * Dans le code $fullHtml, remplace la chaîne $needle par l'élément $replace. Cette fonctionnalité sert par exemple à insérer un * bouton 'lire la suite' à la place du marqueur {{LIRE_LA_SUITE}} dans un bloc de texte qu'on ne veut pas afficher entièrement. * @param string $fullHtml Le code HTML à traiter * @param string $needle Le marqueur * @param string $replace Le code de remplacement * @return string|bool Le code HTML modifié, false en cas d'erreur * @throws \Exception */ public function trimFromHTMLString($fullHtml, $needle, $replace = "") { $text = trim(html_entity_decode($fullHtml)); if (!Inflector::seemsUtf8($text)) { // @internal Conserver ce bloc car le serveur de production pose des problèmes d'encodage... require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'ForceUTF8' . DIRECTORY_SEPARATOR . 'Encoding.php'; $text = ForceUTF8\Encoding::toUTF8($text); } // On charge le texte dans un DOMDocument pour le manipuler proprement $this->dom = new DOMDocument(); $htmlHead = '<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"><title>***</title></head><body>'; $htmlFoot = '</body></html>'; if (!$this->dom->loadHTML($htmlHead . $text . $htmlFoot)) { Yii::log(h::_("Erreur sur loadXML()\n{$text}", __FILE__, __LINE__, __METHOD__), CLogger::LEVEL_ERROR); return false; } // On récupère le noeud texte contenant $needle. // Si aucun noeud n'a été trouvé, on renvoie le texte complet tel qu'on l'a reçu. $zeunode = $this->findStringNode($needle, $this->dom); if (!$zeunode) { Yii::log(h::_("!!!! Pas de noeud contenant -> {$needle} <-", __FILE__, __LINE__, __METHOD__), 'debug'); Yii::log(h::_(h::xmlTreeDump($this->dom), __FILE__, __LINE__, __METHOD__), 'debug'); return $fullHtml; } // On supprime tout le texte après $needle et tous les noeuds suivant $zeunode $zeunode->data = preg_replace("/({$needle}).*/ms", "\$1", $zeunode->data); $this->removeNextNodes($zeunode); $out = $this->dom->saveHTML(); // On retire le code HTML ajouté de part et d'autre de $text // On remplace le marqueur $needle par le code HTML $replace if (($pos = strpos($out, $htmlHead)) === false) { Yii::log(h::_("Erreur sur : strpos({$htmlHead}, {$out})", __FILE__, __LINE__, __METHOD__), CLogger::LEVEL_ERROR); } else { $out = substr($out, $pos + strlen($htmlHead)); } $out = str_replace($htmlFoot, '', $out); $out = trim(preg_replace("/{$needle}/", $replace, $out)); return $out; }
/** * Tronque un texte formatté en HTML à partir du marqueur {{LIRE_LA_SUITE}}. * Toutes les balises ouvertes sont refermées pour que le texte renvoyé soit toujours du HTML correct. * Le marqueur {{LIRE_LA_SUITE}} est remplacé par le bouton $buttonMore * @param string $fullText * @param string $buttonMore * @return string */ public static function getShortHTMLText($fullText, $buttonMore = null) { $tag = '{{LIRE_LA_SUITE}}'; if (strpos($fullText, $tag) === false) { // Si le marqueur n'est pas là, inutile de faire tous ces traitements... return $fullText; } if (is_null($buttonMore)) { $buttonMore = self::getButtonMore(); } $helper = new DOMHelper(); try { if (!($out = $helper->trimFromHTMLString($fullText, $tag, $buttonMore))) { Yii::log(h::_("Erreur sur l'appel à trimFromHTMLString()", __FILE__, __LINE__, __METHOD__), CLogger::LEVEL_ERROR); return $fullText; } } catch (Exception $x) { Yii::log(h::_($x, __FILE__, __LINE__, __METHOD__), CLogger::LEVEL_ERROR); return "<error>" . $x->getMessage() . "</error>"; } return $out; }
$permission = (int) $_POST['permission']; $content = []; foreach ($users_list as $user) { if (in_array($user, $found_users)) { continue; } $found_users[] = $user; $value = $User->db()->qfs(["SELECT `value`\n\t\t\t\t\tFROM `[prefix]users_permissions`\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t`id`\t\t\t= '%s' AND\n\t\t\t\t\t\t`permission`\t= '%s'", $user, $permission]); $content[] = h::th($User->username($user)) . h::{'td input[type=radio]'}(['name' => 'users[' . $user . ']', 'checked' => $value !== false ? $value : -1, 'value' => [-1, 0, 1], 'in' => [$L->inherited . ' (' . ($value !== false && !$value ? '-' : '+') . ')', $L->deny, $L->allow]]); } $Page->content(h::{'table.cs-table-borderless.cs-center-all tr'}($content)); break; } } if ($form) { $a->reset_button = false; $a->post_buttons .= h::{'button.cs-reload-button'}($L->reset); $blocks_array = ['top' => '', 'left' => '', 'floating' => '', 'right' => '', 'bottom' => '']; if (!empty($Config->components['blocks'])) { foreach ($Config->components['blocks'] as $id => $block) { $blocks_array[$block['position']] .= h::li(h::{'div.cs-blocks-items-title'}("#{$block['index']} " . get_block_title($id)) . h::a([h::{'div icon'}('pencil'), ['href' => "{$a->action}/edit/{$id}", 'data-title' => $L->edit]], [h::{'div icon'}('key'), ['href' => "{$a->action}/permissions/{$id}", 'data-title' => $L->edit_permissions]], [h::{'div icon'}($block['active'] ? 'minus' : 'check'), ['href' => "{$a->action}/" . ($block['active'] ? 'disable' : 'enable') . "/{$id}", 'data-title' => $L->{$block['active'] ? 'disable' : 'enable'}]], [h::{'div icon'}('trash-o'), ['href' => "{$a->action}/delete/{$id}", 'data-title' => $L->delete]]), ['id' => "block{$id}", 'class' => $block['active'] ? 'uk-button-success' : 'uk-button-default']); unset($block_data); } unset($id, $block); } foreach ($blocks_array as $position => &$content) { $content = h::{'td.cs-blocks-items-groups ul.cs-blocks-items'}(h::{'li.uk-button-primary'}($L->{"{$position}_blocks"}, ['onClick' => "cs.blocks_toggle('{$position}');"]) . $content, ['data-mode' => 'open', 'id' => "cs-{$position}-blocks-items"]); } unset($position, $content); $a->content(h::{'table.cs-table-borderless tr'}([h::td() . $blocks_array['top'] . h::td(), "{$blocks_array['left']}{$blocks_array['floating']}{$blocks_array['right']}", h::td() . $blocks_array['bottom'] . h::td()]) . h::{'p.cs-left a.cs-button'}("{$L->add} {$L->block}", ['href' => "admin/System/{$rc['0']}/{$rc['1']}/add"]) . h::{'input#cs-blocks-position[type=hidden][name=position]'}()); }
foreach ($list as $label => $id) { $content[] = h::th($group == 'Block' ? Text::instance()->process($Config->module('System')->db('texts'), $blocks[$label]) : $label) . h::{'td input[type=radio]'}(['name' => "permission[{$id}]", 'checked' => isset($group_permissions[$id]) ? $group_permissions[$id] : -1, 'value' => [-1, 0, 1], 'in' => [$L->not_specified, $L->deny, $L->allow]]); } if (count($list) % 2) { $content[] = h::{'td[colspan=2]'}(); } $count = count($content); $content_ = []; for ($i = 0; $i < $count; $i += 2) { $content_[] = $content[$i] . $content[$i + 1]; } $tabs_content .= h::{'div#permissions_group_' . strtr($group, '/', '_') . ' table.cs-table-borderless.cs-center-all tr'}(h::{'td.cs-left-all[colspan=4]'}(h::{'button.cs-permissions-invert'}($L->invert) . h::{'button.cs-permissions-deny-all'}($L->deny_all) . h::{'button.cs-permissions-allow-all'}($L->allow_all)), $content_); } unset($content, $content_, $count, $i, $permissions, $group, $list, $label, $id, $blocks); $Page->title($L->permissions_for_group($Group->get($rc[3], 'title'))); $a->content(h::{'p.lead.cs-center'}($L->permissions_for_group($Group->get($rc[3], 'title'))) . h::{'ul.cs-tabs li'}($tabs) . h::div($tabs_content) . h::br() . h::{'input[type=hidden]'}(['name' => 'id', 'value' => $rc[3]])); break; } $a->content(h::{'input[type=hidden]'}(['name' => 'mode', 'value' => $rc[2]])); } else { $a->buttons = false; $groups_ids = $Group->get_all(); $groups_list = []; foreach ($groups_ids as $id) { $id = $id['id']; $group_data = $Group->get($id); $groups_list[] = [h::{'a.cs-button-compact'}(h::icon('pencil'), ['href' => "{$a->action}/edit/{$id}", 'data-title' => $L->edit_group_information]) . ($id != User::ADMIN_GROUP_ID && $id != User::USER_GROUP_ID && $id != User::BOT_GROUP_ID ? h::{'a.cs-button-compact'}(h::icon('trash-o'), ['href' => "{$a->action}/delete/{$id}", 'data-title' => $L->delete]) : '') . h::{'a.cs-button-compact'}(h::icon('key'), ['href' => "{$a->action}/permissions/{$id}", 'data-title' => $L->edit_group_permissions]), $id, $group_data['title'], $group_data['description']]; } unset($id, $group_data, $groups_ids); $a->content(h::{'table.cs-table.cs-center-all'}(h::{'thead tr th'}($L->action, 'id', $L->group_name, $L->description) . h::{'tbody tr| td'}($groups_list)) . h::{'p.cs-left a.cs-button'}($L->add_group, ['href' => "admin/System/{$rc['0']}/{$rc['1']}/add"])); }
$Index->content(h::{'button[type=submit][name=action][value=remove_confirmed]'}($L->yes) . h::{'input[type=hidden]'}(['name' => 'remove_theme_confirmed', 'value' => $_POST['remove_theme']])); return; break; case 'remove_confirmed': $theme = $_POST['remove_theme_confirmed']; if ($theme == 'CleverStyle' || $theme == $Config->core['theme']) { break; } $ok = true; get_files_list(THEMES . "/{$theme}", false, 'fd', true, true, false, false, true, function ($item) use(&$ok) { if (is_writable($item)) { is_dir($item) ? @rmdir($item) : @unlink($item); } else { $ok = false; } }); if ($ok && @rmdir(THEMES . "/{$theme}")) { $Index->save(); } else { $Index->save(false); } break; } } $Config->reload_themes(); $themes_for_removal = array_values(array_filter(get_files_list(THEMES, '/[^CleverStyle)]/', 'd'), function ($theme) use($Config) { return $theme != $Config->core['theme']; })); $Index->file_upload = true; $Index->content(h::{'table.cs-table-borderless.cs-left-even.cs-right-odd tr| td'}(core_select($Config->core['themes'], 'theme', 'change_theme', 'current_theme'), core_select($Config->core['color_schemes'][$Config->core['theme']], 'color_scheme', 'change_color_scheme')) . h::p(h::{'input[type=file][name=upload_theme]'}() . h::{'button[type=submit][name=action][value=upload]'}(h::icon('upload') . $L->upload_and_install_update_theme, ['formaction' => $Index->action])) . ($themes_for_removal ? h::p(h::{'select[name=remove_theme]'}($themes_for_removal) . h::{'button[type=submit][name=action][value=remove]'}(h::icon('trash-o') . $L->complete_theme_removal, ['formaction' => $Index->action])) : ''));
/** * Ajoute une traduction à la news * @param News $news * @return boolean */ private function addTranslationTo(News $news) { $translation = new TranslatedNews(); $availableLanguages = $news->getUnusedLanguages(); /** @var myWebUser $webUser */ /** @noinspection PhpUndefinedFieldInspection */ $webUser = Yii::app()->user; if (!$availableLanguages) { $webUser->setFlash('warning', Yii::t('NewsModule.msg', 'There is no language left for this news')); return false; } $tmpLanguage = $availableLanguages[0]; $translation->title = $tmpLanguage->code; $translation->content = '...'; $translation->news_id = $news->id; $translation->language_id = $tmpLanguage->id; if (!$translation->save()) { $webUser->setFlash('error', Yii::t('msg', 'There are errors. Please check the form')); Yii::log(h::_($translation->errors, __FILE__, __LINE__, __METHOD__), CLogger::LEVEL_ERROR); return false; } $webUser->setFlash('success', Yii::t('NewsModule.msg', 'A new translation has been added to your news')); return true; }
<?php /** * @package CleverStyle CMS * @subpackage System module * @category modules * @author Nazar Mokrynskyi <*****@*****.**> * @copyright Copyright (c) 2011-2014, Nazar Mokrynskyi * @license MIT License, see license.txt */ namespace cs\modules\System; use h, cs\Config, cs\Cache, cs\Index, cs\Language; $Config = Config::instance(); $L = Language::instance(); $sa = $Config->core['simple_admin_mode']; Index::instance()->content(h::{'table.cs-table-borderless.cs-left-even.cs-right-odd tr| td'}(core_input('gzip_compression', 'radio', null, zlib_compression()), core_input('cache_compress_js_css', 'radio'), core_input('put_js_after_body', 'radio'), !$sa ? core_input('inserts_limit', 'number', null, false, 1) : false, !$sa ? core_input('update_ratio', 'number', null, false, 0, 100) : false, [h::{'div#clean_cache'}(), h::{'div#clean_pcache'}()], [h::button($L->clean_settings_cache, Cache::instance()->cache_state() ? ['onMouseDown' => "cs.admin_cache('#clean_cache', '{$Config->base_url()}/api/System/admin/cache/clean_cache');"] : ['disabled']), h::button($L->clean_scripts_styles_cache, $Config->core['cache_compress_js_css'] ? ['onMouseDown' => "cs.admin_cache('#clean_pcache', '{$Config->base_url()}/api/System/admin/cache/clean_pcache');"] : ['disabled'])]));
/** * */ public function toHtml(array $params = array(), array $innerCallbacks = array()) { require_once 'lib/lib.htmlgen.php'; $o = $this; //h::li(function () use ($o, $params, $innerCallbacks) { h::li(array('id' => $o->getInternalId()), function () use($o, $params, $innerCallbacks) { h::div(array('class' => 'builderElementLine'), function () use($o, $params) { h::h3($params['title']); /* h::div(array('class' => 'builderElementActionItems'), function() use ($o) { if ($o->isEditable()) { h::a('Details', '#', array('class' => 'btn details')); } if ($o->isDeletable()) { h::a('Delete', '#', array('class' => 'delete btn danger')); } });*/ }); h::div(array('class' => 'popover builderElementPopover right'), function () use($o, $params, $innerCallbacks) { h::div(array('class' => 'arrow')); h::div(array('class' => 'inner'), function () use($o, $params, $innerCallbacks) { h::h3(array('class' => 'title'), function () use($o, $params) { h::div(array('class' => 'actualTitle'), 'Details for ' . $params['title']); }); h::div(array('class' => 'content'), function () use($o, $innerCallbacks) { h::form(array('class' => 'form', 'action' => ''), function () use($o, $innerCallbacks) { h::fieldset(function () use($o, $innerCallbacks) { $params = array('help' => "Uncheck this if you don't want this task to execute at all.", 'label' => 'Active?', 'name' => 'active', 'checked' => $o->isActive()); $o->getHtmlInputCheckbox($params); foreach ($innerCallbacks as $cb) { // // Filesets are special cases, because we might need to // iterate on more than one (in the future) // if ($cb['cb'] == 'getFilesets') { if ($o->getFilesets()) { $filesets = $o->getFilesets(); foreach ($filesets as $fileset) { $fileset->toHtml(); } } // // Normal to-HTML callbacks // } else { call_user_func(array($o, $cb['cb']), $cb); } } h::div(array('class' => 'actions'), function () { h::input(array('type' => 'submit', 'class' => 'btn', 'value' => 'Nothing to save', 'disabled' => 'disabled')); h::button(array('class' => 'btn delete danger'), 'Delete'); }); }); }); }); }); }); }); //}); }
/** * Affiche un bloc HTML correspondant à une actualité * @param TranslatedNews $news */ protected function renderItem(TranslatedNews $news) { $url = Yii::app()->createAbsoluteUrl('news/news/show', array('id' => $news->id, 'slug' => h::slugify($news->title))); $this->render('lastNews', array('translatedNews' => $news, 'url' => $url)); }
public function getViewExecutables() { require_once 'lib/lib.htmlgen.php'; $o = $this; h::fieldset(function () use($o) { h::div(array('class' => 'clearfix'), function () use($o) { h::label(array('for' => SystemSettings::EXECUTABLE_PHP), 'PHP'); h::div(array('class' => 'input'), function () use($o) { h::input(array('type' => 'text', 'class' => 'span6', 'name' => SystemSettings::EXECUTABLE_PHP, 'value' => $o[SystemSettings::EXECUTABLE_PHP])); h::span(array('class' => 'help-block'), "The path to the host system's PHP executable."); }); }); h::div(array('class' => 'clearfix'), function () use($o) { h::label(array('for' => SystemSettings::EXECUTABLE_GIT), 'Git'); h::div(array('class' => 'input'), function () use($o) { h::input(array('type' => 'text', 'class' => 'span6', 'name' => SystemSettings::EXECUTABLE_GIT, 'value' => $o[SystemSettings::EXECUTABLE_GIT])); h::span(array('class' => 'help-block'), "The path to the host system's Git executable. Required in order to allow Git as the configured SCM for projects."); }); }); h::div(array('class' => 'clearfix'), function () use($o) { h::label(array('for' => SystemSettings::EXECUTABLE_SVN), 'SVN'); h::div(array('class' => 'input'), function () use($o) { h::input(array('type' => 'text', 'class' => 'span6', 'name' => SystemSettings::EXECUTABLE_SVN, 'value' => $o[SystemSettings::EXECUTABLE_SVN])); h::span(array('class' => 'help-block'), "The path to the host system's SVN executable. Required in order to allow SVN as the configured SCM for projects."); }); }); /* }); h::fieldset(function () use ($o) { h::legend('Archivers');*/ h::div(array('class' => 'clearfix'), function () use($o) { h::label(array('for' => SystemSettings::EXECUTABLE_TAR), 'tar'); h::div(array('class' => 'input'), function () use($o) { h::input(array('type' => 'text', 'class' => 'span6', 'name' => SystemSettings::EXECUTABLE_TAR, 'value' => $o[SystemSettings::EXECUTABLE_TAR])); h::span(array('class' => 'help-block'), "The path to the host system's tar executable. Will be used to generate all release packages."); }); }); }); }
/** * @test */ public function trim() { $input = "Une chaîne\n sur deux lignes avec des blancs et des tabulations "; $expected = "Une chaîne sur deux lignes avec des blancs et des tabulations"; $this->assertEquals($expected, h::trim($input)); }
/** * @package Streams * @category modules * @author Nazar Mokrynskyi <*****@*****.**> * @copyright Copyright (c) 2014, Nazar Mokrynskyi * @license MIT License, see license.txt */ namespace cs\modules\Streams; use h, cs\Index, cs\Page, cs\User; $Page = Page::instance(); $Index = Index::instance(); $Index->title_auto = false; $Page->Description = 'opir.org - Тут ви можете з орієнтуватися на самому майдані, дізнатися де проходять суди над евромайданівцями, бути попередженим про появлення тітушок'; $User = User::instance(); $Page->title('Камери'); $Page->og('image', 'https://opir.org/components/modules/Home/includes/img/share.png'); $Page->og('image:secure_url', 'https://opir.org/components/modules/Home/includes/img/share.png'); if (isset($Index->route_ids[0])) { $stream = Streams::instance()->get($Index->route_ids[0]); if (preg_match('/youtube.com\\/embed\\/(.*)/', $stream['stream_url'], $image)) { $Page->replace('https://opir.org/components/modules/Home/includes/img/share.png', "https://i1.ytimg.com/vi/{$image['1']}/hqdefault.jpg"); } unset($stream, $image); } $Page->link(['rel' => 'image_src', 'href' => 'https://opir.org/components/modules/Home/includes/img/share.png']); $Page->css('body>header{height:62px}#map{top:62px;left:0;}', 'code'); $Page->Header = h::{'div.cs-home-logo'}(h::{'a[href=/] img'}(['src' => "components/modules/Home/includes/img/logo.png"]) . '<div class="yashare-auto-init" data-yashareL10n="uk" data-yashareQuickServices="facebook" data-yashareLink="https://www.facebook.com/opir.org" data-yashareTheme="counter" data-yashareImage="https://opir.org/components/modules/Home/includes/img/share.png"></div>' . '<div class="yashare-auto-init" data-yashareL10n="uk" data-yashareQuickServices="vkontakte,twitter" data-yashareTheme="counter" data-yashareImage="https://opir.org/components/modules/Home/includes/img/share.png"></div>') . h::{'button.cs-stream-add'}('Додати камеру') . h::{'a.cs-home-home[href=/]'}() . ($User->user() ? h::{'button.cs-home-sign-out'}() : h::{'button.cs-home-sign-in'}()) . h::{'button.cs-home-donate'}('Допомогти ініціативі'); $Page->content(h::{'aside.cs-stream-add-panel'}() . h::{'aside.cs-stream-filter-panel'}(h::{"div.uk-button-dropdown[data-uk-dropdown={mode:'click'}]"}(h::{'button.uk-button'}(h::icon('caret-down') . ' ' . h::span('Показати карту')) . h::{'div.uk-dropdown ul.cs-stream-show.uk-nav.uk-nav-dropdown'}(h::{'li[data-mode=map] a'}('Показати карту') . h::{'li[data-mode=list] a'}('Показати список'))) . h::{'div.cs-stream-added-tags[level=0]'}() . h::{'input.cs-stream-filter'}(['placeholder' => 'Фільтр по адресі']) . h::{'div.cs-stream-found-tags[level=0]'}()) . h::{'div.cs-stream-filter-hide.uk-icon-chevron-right'}() . h::{'div.cs-stream-list'}());
/** * Modification du profil utilisateur */ public function actionEdit() { /** @var myWebUser $webUser */ $webUser = Yii::app()->user; $currentUser = $webUser->getUser(); $profile = $currentUser->profile; if (isset($_POST['ajax']) && $_POST['ajax'] === 'profile-form') { echo UActiveForm::validate(array($currentUser, $profile)); Yii::app()->end(); } // @internal $current->username a déjà la nouvelle valeur (voir pourquoi...) // On utilise donc $webUser->username pour vérifier les changements $oldUsername = $webUser->username; if (isset($_POST['User'])) { $currentUser->attributes = $_POST['User']; $profile->attributes = $_POST[get_class($profile)]; if ($currentUser->validate() && $profile->validate()) { $transaction = Yii::app()->db->beginTransaction(); if (!$currentUser->save()) { $transaction->rollback(); $msg = array("Erreur sur \$currentUser->save()", $currentUser); Yii::log(h::_($msg, __FILE__, __LINE__, __METHOD__), CLogger::LEVEL_ERROR); $webUser->setFlash('error', UserModule::t("Unable to validate user data")); } elseif (!$profile->save()) { $transaction->rollback(); $msg = array("Erreur sur \$profile->save()", $profile); Yii::log(h::_($msg, __FILE__, __LINE__, __METHOD__), CLogger::LEVEL_ERROR); $webUser->setFlash('error', UserModule::t("Unable to validate profile data")); } else { // Tout va bien, on enregistre les modifications dans la base de données $transaction->commit(); // Si l'utilisateur a modifié son username, on le déconnecte pour forcer une ré-authentification if ($currentUser->username != $oldUsername) { $this->redirect('/user/logout'); } $webUser->setFlash('success', UserModule::t("Profile updated")); $this->redirect(array('/user/profile')); } } } $this->renderProfilePanel('edit', $currentUser, $profile); }
unset($tag, $file); /** * License */ if (file_exists($file = PLUGINS . "/{$plugin}/license.txt") || file_exists($file = PLUGINS . "/{$plugin}/license.html")) { if (substr($file, -3) == 'txt') { $tag = 'pre'; } else { $tag = 'div'; } $addition_state .= h::{'div.uk-modal.cs-left'}(h::{"{$tag}.uk-modal-dialog-large"}($tag == 'pre' ? prepare_attr_value(file_get_contents($file)) : file_get_contents($file)), ['id' => "{$plugin}_license", 'title' => "{$plugin} -> {$L->license}"]) . h::{'icon.cs-pointer'}('legal', ['data-title' => $L->license . h::br() . $L->click_to_view_details, 'onClick' => "\$('#{$plugin}_license').cs().modal('show');"]); } unset($tag, $file); $state = in_array($plugin, $Config->components['plugins']); $action .= h::{'a.cs-button-compact'}(h::icon($state ? 'minus' : 'check'), ['href' => $a->action . ($state ? '/disable/' : '/enable/') . $plugin, 'data-title' => $state ? $L->disable : $L->enable]); $plugin_info = false; if (file_exists(PLUGINS . "/{$plugin}/meta.json")) { $plugin_meta = file_get_json(PLUGINS . "/{$plugin}/meta.json"); $plugin_info = $L->plugin_info($plugin_meta['package'], $plugin_meta['version'], $plugin_meta['description'], $plugin_meta['author'], isset($plugin_meta['website']) ? $plugin_meta['website'] : $L->none, $plugin_meta['license'], isset($plugin_meta['provide']) ? implode(', ', (array) $plugin_meta['provide']) : $L->none, isset($plugin_meta['require']) ? implode(', ', (array) $plugin_meta['require']) : $L->none, isset($plugin_meta['conflict']) ? implode(', ', (array) $plugin_meta['conflict']) : $L->none, isset($plugin_meta['optional']) ? implode(', ', (array) $plugin_meta['optional']) : $L->none, isset($plugin_meta['multilingual']) && in_array('interface', $plugin_meta['multilingual']) ? $L->yes : $L->no, isset($plugin_meta['multilingual']) && in_array('content', $plugin_meta['multilingual']) ? $L->yes : $L->no, isset($plugin_meta['languages']) ? implode(', ', $plugin_meta['languages']) : $L->none); } unset($plugin_meta); $plugins_list[] = [h::span($L->{$plugin}, ['data-title' => $plugin_info]), h::icon($state ? 'check' : 'minus', ['data-title' => $state ? $L->enabled : $L->disabled]) . $addition_state, $action]; unset($plugin_info); } unset($plugin, $state, $addition_state, $action); } $plugins_for_removal = array_values(array_filter($plugins, function ($plugin) use($Config) { return !in_array($plugin, $Config->components['plugins']); })); $a->content(h::{'table.cs-table.cs-center-all'}(h::{'thead tr th'}($L->plugin_name, $L->state, $L->action) . h::{'tbody tr| td'}([$plugins_list ?: false])) . h::p(h::{'input[type=file][name=upload_plugin]'}(['style' => 'position: relative;']) . h::{'button[type=submit]'}(h::icon('upload') . $L->upload_and_install_update_plugin, ['formaction' => "{$a->action}/enable/upload"])) . ($plugins_for_removal ? h::p(h::{'select[name=remove_plugin]'}($plugins_for_removal) . h::{'button[type=submit]'}(h::icon('trash-o') . $L->complete_plugin_removal, ['formaction' => "{$a->action}/remove"])) : ''));
<?php # hunch utils error_reporting(E_ALL); date_default_timezone_set(@date_default_timezone_get()); # ------------------------------------------------------------------------------ class h { static $basedir = null; static $magicQuotes = false; } # derive basedir, given we live in <basedir>/something/h.php h::$basedir = dirname(dirname(__FILE__)); h::$magicQuotes = !!(function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()); # autoload classes from the same directory as we live in @ini_set('include_path', ini_get('include_path') . ':' . h::$basedir . '/lib'); function __autoload($classname) { require $classname . '.php'; } # ------------------------------------------------------------------------------ class hlog { static $file = null; # append |prefix| + |msg| to end of |hlog::$file| using an exclusive flock static function append($prefix, $msg = false) { if (!self::$file) { throw new Exception('hlog::$file is not set'); } if ($msg === false) {
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. */ public function actionUpdate() { $model = $this->loadModel(); $this->performAjaxValidation($model); if (isset($_POST['User'])) { /** @var myWebUser $webUser */ $webUser = Yii::app()->user; $model->attributes = $_POST['User']; if ($model->validate()) { /** @noinspection PhpUndefinedMethodInspection */ $old_password = User::model()->findByPk($model->id); if ($old_password->password != $model->password) { /** @var UserModule $module */ $module = Yii::app()->controller->module; $model->password = $module->encrypting($model->password); $model->activkey = $module->encrypting(microtime() . $model->password); } if (!$model->save()) { $msg = array("Erreur sur \$model->save()", $model); Yii::log(h::_($msg, __FILE__, __LINE__, __METHOD__), CLogger::LEVEL_ERROR); $webUser->setFlash('error', Yii::t('UserModule.user', 'There are errors. Please check the form')); } else { // Sauvegarde OK $webUser->setFlash('success', Yii::t('UserModule.user', 'User saved')); if (isset($_POST['backToList'])) { // On a cliqué le bouton 'revenir à la liste' et le formulaire a bien été traité $this->redirect(array('admin')); } } } } $this->render('update', array('model' => $model)); }
* @category modules * @author Nazar Mokrynskyi <*****@*****.**> * @copyright Copyright (c) 2014, Nazar Mokrynskyi * @license MIT License, see license.txt */ namespace cs\modules\Precincts; use h, cs\Core, cs\Index, cs\Language, cs\Page, cs\User; $Index = Index::instance(); $Index->title_auto = false; $L = Language::instance(); $Page = Page::instance(); if (isset($Index->route_path[0], $Index->route_ids[1]) && $Index->route_path[0] == 'violation') { $violation = Violations::instance()->get($Index->route_ids[1]); if ($violation['images']) { $Page->replace('/<meta content="[^"]*share.png" property="og:image">/Uims', ''); $Page->replace('/<link href="[^"]*share.png" rel="image_src">/Uims', ''); $Page->link(['rel' => 'image_src', 'href' => $violation['images'][0]]); foreach ($violation['images'] as $image) { $Page->og('image', $image); $Page->og('image:secure_url', $image); } } if ($violation['text']) { $Page->Description = description($violation['text']); } } $Page->Header .= h::{'button.cs-elections-add-violation'}(h::{'i.uk-icon-plus'}() . " {$L->add_violation}") . h::{'button.cs-elections-last-violations'}(); $Page->js("window.disqus_shortname = '" . Core::instance()->disqus_shortname . "';", 'code'); $Page->content(h::{'div.cs-elections-last-violations-panel'}(h::h2($L->last_violations) . h::{'section'}()) . h::{'aside.cs-elections-precinct-sidebar'}() . h::{'aside.cs-elections-add-violation-sidebar'}() . h::{'aside.cs-elections-violation-read-more-sidebar'}() . h::{'aside.cs-elections-main-sidebar'}(h::{'div.cs-elections-opirzagin a[href=become_eyes]'}($L->become_eyes) . h::{'div.cs-elections-opirzagin a[href=opirzagin]'}($L->opircrew) . h::{'div.cs-elections-opirzagin a[href=instruktsia]'}($L->instruktsia) . h::{'div.cs-elections-socials'}('<div class="yashare-auto-init" data-yashareL10n="uk" data-yashareQuickServices="facebook" data-yashareLink="https://www.facebook.com/opir.org" data-yashareTheme="counter" data-yashareImage="https://opir.org/components/modules/Common/includes/img/share.png"></div>' . '<div class="yashare-auto-init" data-yashareL10n="uk" data-yashareQuickServices="vkontakte,twitter" data-yashareLink="https://opir.org/" data-yashareTheme="counter" data-yashareImage="https://opir.org/components/modules/Common/includes/img/share.png"></div>') . h::h2($L->precincts_search) . h::{'input.cs-elections-precincts-search[type=search]'}(['placeholder' => $L->number_or_address]) . h::{'section.cs-elections-precincts-search-results[level=0]'}() . h::h2($L->mobile_apps) . h::{'div.cs-elections-mobile-apps'}(h::{'a[target=_blank'}($L->download_in('App Store'), ['href' => 'https://itunes.apple.com/ua/app/opir.org/id896488790']) . h::{'a[target=_blank]'}($L->download_in('Google Play'), ['href' => 'https://play.google.com/store/apps/details?id=example.yariksoffice']) . h::{'a[target=_blank]'}($L->download_in('Market Place'), ['onclick' => "\$.cs.simple_modal('{$L->soon}')"])) . h::h2($L->contacts) . h::{'div.cs-elections-contacts'}(h::a(h::icon('phone') . '+38 093 012 22 11') . h::a(h::icon('phone') . '+38 067 708 42 90') . h::{'a[href=mailto:info@opir.org]'}(h::icon('envelope') . '*****@*****.**')) . h::h2($L->map_legend) . h::{'div.cs-elections-map-legend'}(h::div($L->precincts_with_violations) . h::div($L->precincts_without_violations) . h::div($L->district_precincts))));
<?php /** * Affiche le lien vers la news suivante et la news précédente * @var $this NewsController * @var $model TranslatedNews */ ?> <div class="newsNavigationLinks"> <?php if ($previous = $model->getPrevious()) { $slug = h::slugify($previous->title); echo CHtml::link(Yii::t('NewsModule.labels', 'Previous'), array('news/show', 'id' => $previous->id, 'slug' => $slug), array('title' => $slug, 'class' => 'previousItem')); } if ($next = $model->getNext()) { $slug = h::slugify($next->title); echo CHtml::link(Yii::t('NewsModule.labels', 'Next'), array('news/show', 'id' => $next->id, 'slug' => $slug), array('title' => $slug, 'class' => 'nextItem')); } ?> </div>
<?php /** * @package CleverStyle CMS * @subpackage System module * @category modules * @author Nazar Mokrynskyi <*****@*****.**> * @copyright Copyright (c) 2011-2014, Nazar Mokrynskyi * @license MIT License, see license.txt */ namespace cs\modules\System; use h, cs\Config, cs\Index, cs\Language; $Config = Config::instance(); $L = Language::instance(); $sa = $Config->core['simple_admin_mode']; Index::instance()->content(h::{'table.cs-table-borderless.cs-left-even.cs-right-odd tr| td'}(core_input('site_mode', 'radio'), core_input('closed_title'), core_textarea('closed_text', 'SIMPLE_EDITOR'), core_input('title_delimiter'), core_input('title_reverse', 'radio'), core_textarea('footer_text', 'SIMPLE_EDITOR'), core_input('show_footer_info', 'radio'), core_input('show_tooltips', 'radio', false), core_input('og_support', 'radio'), core_input('simple_admin_mode', 'radio'), !$sa ? [$L->debug, [h::{'table tr| td'}(core_input('show_db_queries', 'radio'), core_input('show_cookies', 'radio')), ['class' => 'cs-padding-left']]] : false, !$sa ? [h::info('routing'), h::{'table.cs-table-borderless tr| td'}([h::info('routing_in'), h::info('routing_out')], [h::textarea($Config->routing['in'], ['name' => 'routing[in]']), h::textarea($Config->routing['out'], ['name' => 'routing[out]'])])] : false, !$sa ? [h::info('replace'), h::{'table.cs-table-borderless tr| td'}([h::info('replace_in'), h::info('replace_out')], [h::textarea($Config->replace['in'], ['name' => 'replace[in]']), h::textarea($Config->replace['out'], ['name' => 'replace[out]'])])] : false));
<?php /** * @package CleverStyle CMS * @subpackage System module * @category modules * @author Nazar Mokrynskyi <*****@*****.**> * @copyright Copyright (c) 2011-2014, Nazar Mokrynskyi * @license MIT License, see license.txt */ namespace cs\modules\System; use h, cs\Config, cs\Index, cs\Language; $Config = Config::instance(); $L = Language::instance(); Index::instance()->content(h::{'table.cs-table-borderless.cs-left-even.cs-right-odd tr| td'}(core_input('session_expire', 'number', null, false, 1, false, $L->seconds), core_input('online_time', 'number', null, false, 1, false, $L->seconds), [h::info('sign_in_attempts_block_count'), h::{'input[type=number]'}(['name' => 'core[sign_in_attempts_block_count]', 'value' => $Config->core['sign_in_attempts_block_count'], 'min' => 0, 'onChange' => "if (\$(this).val() == 0) { \$('.cs-sign-in-attempts-block-count').hide(); } else { \$('.cs-sign-in-attempts-block-count').show(); }"])], [core_input('sign_in_attempts_block_time', 'number', null, false, 1, false, $L->seconds), ['style' => $Config->core['sign_in_attempts_block_count'] == 0 ? 'display: none;' : '', 'class' => 'cs-sign-in-attempts-block-count']], core_input('remember_user_ip', 'radio'), core_input('password_min_length', 'number', null, false, 4), core_input('password_min_strength', 'range', null, false, 0, 7), [h::info('allow_user_registration'), h::{'input[type=radio]'}(['name' => 'core[allow_user_registration]', 'checked' => $Config->core['allow_user_registration'], 'value' => [0, 1], 'in' => [$L->off, $L->on], 'onchange' => ["\$('.cs-allow-user-registration').hide();", "\$('.cs-allow-user-registration').show();" . "if (!\$('.cs-allow-user-registration input[value=1]').prop('checked')) { \$('.cs-require-registration-confirmation').hide(); }"]])], [[h::info('require_registration_confirmation'), h::{'input[type=radio]'}(['name' => 'core[require_registration_confirmation]', 'checked' => $Config->core['require_registration_confirmation'], 'value' => [0, 1], 'in' => [$L->off, $L->on], 'onchange' => ["\$('.cs-require-registration-confirmation').hide();", "\$('.cs-require-registration-confirmation').show();"]])], ['style' => $Config->core['allow_user_registration'] == 0 ? 'display: none;' : '', 'class' => 'cs-allow-user-registration']], [core_input('registration_confirmation_time', 'number', null, false, 1, false, $L->days), ['style' => $Config->core['allow_user_registration'] == 1 && $Config->core['require_registration_confirmation'] == 1 ? '' : 'display: none;', 'class' => 'cs-allow-user-registration cs-require-registration-confirmation']], [core_input('auto_sign_in_after_registration', 'radio'), ['style' => $Config->core['allow_user_registration'] == 1 && $Config->core['require_registration_confirmation'] == 1 ? '' : 'display: none;', 'class' => 'cs-allow-user-registration cs-require-registration-confirmation']], core_textarea('rules', 'SIMPLE_EDITOR')));
<?php /** * Résumé d'une actualité : on y présente les tags, le titre, la date et le début du texte avec un lien vers * la news complète * @var $this myController * @var $data TranslatedNews * @internal ce fragment est appelé entre autres par une CListView, ne pas changer le nom de variable de $data */ Yii::import('news.*'); Yii::app()->clientScript->registerPackage('news'); $newsUrl = Yii::app()->createAbsoluteUrl('/news/news/show', array('id' => $data->id, 'slug' => h::slugify($data->title))); ?> <div class="news"> <div class="header"> <div class="eventDate"><?php echo Yii::app()->format->date($data->news->event_date); ?> </div> <?php // NB : on indique le chemin complet au fragment _tags parce que cette vue peut être appelée en dehors // du module 'news' (par exemple : dans la page d'accueil du site) $this->renderPartial('news.views.news._tags', array('news' => $data)); ?> <div class="clear"></div> </div> <h2><?php echo CHtml::link(CHtml::encode($data->title), $newsUrl); ?> </h2>
/** * Link to the module admin page */ if (file_exists(MODULES . "/{$module_name}/admin/index.php") || file_exists(MODULES . "/{$module_name}/admin/index.json")) { $action .= h::{'a.cs-button-compact'}(h::icon('wrench'), ['href' => "admin/{$module_name}", 'data-title' => $L->module_admin_page]); $admin_link = true; } if ($module_name != $Config->core['default_module']) { $action .= h::{'a.cs-button-compact'}(h::icon($module_data['active'] == 1 ? 'minus' : 'check'), ['href' => $a->action . ($module_data['active'] == 1 ? '/disable/' : '/enable/') . $module_name, 'data-title' => $module_data['active'] == 1 ? $L->disable : $L->enable]) . h::{'a.cs-button-compact'}(h::icon('trash-o'), ['href' => "{$a->action}/uninstall/{$module_name}", 'data-title' => $L->uninstall]); } } /** * If module uninstalled or not installed yet */ } else { $action .= h::{'a.cs-button-compact'}(h::icon('download'), ['href' => "{$a->action}/install/{$module_name}", 'data-title' => $L->install]); } $module_info = false; if (file_exists(MODULES . "/{$module_name}/meta.json")) { $module_meta = file_get_json(MODULES . "/{$module_name}/meta.json"); $module_info = $L->module_info($module_meta['package'], $module_meta['version'], $module_meta['description'], $module_meta['author'], isset($module_meta['website']) ? $module_meta['website'] : $L->none, $module_meta['license'], isset($module_meta['db_support']) ? implode(', ', $module_meta['db_support']) : $L->none, isset($module_meta['storage_support']) ? implode(', ', $module_meta['storage_support']) : $L->none, isset($module_meta['provide']) ? implode(', ', (array) $module_meta['provide']) : $L->none, isset($module_meta['require']) ? implode(', ', (array) $module_meta['require']) : $L->none, isset($module_meta['conflict']) ? implode(', ', (array) $module_meta['conflict']) : $L->none, isset($module_meta['optional']) ? implode(', ', (array) $module_meta['optional']) : $L->none, isset($module_meta['multilingual']) && in_array('interface', $module_meta['multilingual']) ? $L->yes : $L->no, isset($module_meta['multilingual']) && in_array('content', $module_meta['multilingual']) ? $L->yes : $L->no, isset($module_meta['languages']) ? implode(', ', $module_meta['languages']) : $L->none); } unset($module_meta); $modules_list[] = [h::a($L->{$module_name}, ['href' => $admin_link ? "admin/{$module_name}" : false, 'data-title' => $module_info]), h::icon($module_data['active'] == 1 ? $module_name == $Config->core['default_module'] ? 'home' : 'check' : ($module_data['active'] == 0 ? 'minus' : 'times'), ['data-title' => $module_data['active'] == 1 ? $module_name == $Config->core['default_module'] ? $L->default_module : $L->enabled : ($module_data['active'] == 0 ? $L->disabled : "{$L->uninstalled} ({$L->not_installed})")]) . $addition_state, [$action, ['class' => 'cs-left-all']]]; unset($module_info); } $modules_for_removal = array_keys(array_filter($Config->components['modules'], function ($module_data) { return $module_data['active'] == '-1'; })); $a->content(h::{'table.cs-table.cs-center-all'}(h::{'thead tr th'}($L->module_name, $L->state, $L->action) . h::{'tbody tr| td'}([$modules_list])) . h::p(h::{'input[type=file][name=upload_module]'}() . h::{'button[type=submit]'}(h::icon('upload') . $L->upload_and_install_update_module, ['formaction' => "{$a->action}/install/upload"])) . h::p(h::{'input[type=file][name=upload_system]'}() . h::{'button[type=submit]'}(h::icon('upload') . $L->upload_and_update_system, ['formaction' => "{$a->action}/update_system"])) . ($modules_for_removal ? h::p(h::{'select[name=remove_module]'}($modules_for_removal) . h::{'button[type=submit]'}(h::icon('trash-o') . $L->complete_module_removal, ['formaction' => "{$a->action}/remove"])) : '') . h::{'button[type=submit]'}(h::icon('refresh') . $L->update_modules_list, ['data-title' => $L->update_modules_list_info, 'name' => 'update_modules_list']));
/** * Page generation */ function __finish() { static $executed = false; if ($executed) { return; } $executed = true; /** * Cleaning of output */ if (OUT_CLEAN) { ob_end_clean(); } /** * Detection of compression */ $ob = false; $Config = Config::instance(true); if (API || $Config && !zlib_compression() && $Config->core['gzip_compression']) { ob_start('ob_gzhandler'); $ob = true; } /** * For AJAX and API requests only content without page template */ if (!$this->interface) { /** * Processing of replacing in content */ echo $this->process_replacing($this->Content ?: (API ? 'null' : '')); } else { Trigger::instance()->run('System/Page/pre_display'); class_exists('\\cs\\Error', false) && Error::instance(true)->display(); /** * Processing of template, substituting of content, preparing for the output */ $this->prepare(); /** * Processing of replacing in content */ $this->Html = $this->process_replacing($this->Html); /** * Getting of debug information */ if (DEBUG && (User::instance(true)->admin() || $Config->can_be_admin && $Config->core['ip_admin_list_only'])) { $this->get_debug_info(); } Trigger::instance()->run('System/Page/display'); echo str_replace(['<!--debug_info-->', '<!--generate time-->', '<!--peak memory usage-->'], [$this->debug_info ? h::level(h::{'div#cs-debug.uk-modal div.uk-modal-dialog-large'}(h::level($this->debug_info), ['title' => Language::instance()->debug, 'style' => 'margin-left: -45%; width: 90%;']), $this->level['debug_info']) : '', format_time(round(microtime(true) - MICROTIME, 5)), format_filesize(memory_get_usage(), 5) . h::{'sup[level=0]'}(format_filesize(memory_get_peak_usage(), 5))], rtrim($this->Html)); } if ($ob) { ob_end_flush(); } }
* @author Nazar Mokrynskyi <*****@*****.**> * @copyright Copyright (c) 2011-2014, Nazar Mokrynskyi * @license MIT License, see license.txt */ namespace cs\modules\System; use h, cs\Config, cs\Core, cs\Index, cs\Language; $Config = Config::instance(); $L = Language::instance(); $Config->reload_languages(); $translate_engines = _mb_substr(get_files_list(ENGINES . '/Text', '/^[^_].*?\\.php$/i', 'f'), 0, -4); $translate_engines_settings = []; $current_engine_settings = ''; foreach ($translate_engines as $engine) { $parameters = file_get_json(ENGINES . '/Text/' . $engine . '.json'); if (is_array($parameters) && !empty($parameters)) { $table = ''; foreach ($parameters as $paremeter => $description) { $table .= h::{'tr td'}([$description, h::input(['name' => 'core[auto_translation_engine][' . $paremeter . ']', 'value' => isset($Config->core['auto_translation_engine'][$paremeter]) ? $Config->core['auto_translation_engine'][$paremeter] : ''])]); } $translate_engines_settings[] = base64_encode(h::table($table)); } else { $translate_engines_settings[] = base64_encode($parameters ?: $L->no_settings_found); } if ($engine == $Config->core['auto_translation_engine']['name']) { $current_engine_settings = base64_decode(array_slice($translate_engines_settings, -1)[0]); } } unset($engine, $parameters, $paremeter, $description, $table); Index::instance()->content(h::{'p.lead.cs-center'}(FIXED_LANGUAGE ? $L->language_fixed_as . ' ' . Core::instance()->language : false) . h::{'table.cs-table-borderless.cs-left-even.cs-right-odd tr| td'}(core_select($Config->core['active_languages'], 'language', 'change_language', 'current_language'), core_select($Config->core['languages'], 'active_languages', 'change_active_languages', null, true), [h::info('multilingual'), h::{'input[type=radio]'}(['name' => 'core[multilingual]', 'checked' => $Config->core['multilingual'], 'value' => [0, 1], 'in' => [$L->off, $L->on], 'OnClick' => ["\$('.cs-multilingual').hide(); \$('.cs-auto-translation').hide();", "\$('.cs-multilingual').show(); if (\$('#auto_translation [value=1]').prop('checked')) \$('.cs-auto-translation').show();"]])], [[h::info('auto_translation'), h::{'input[type=radio]'}(['name' => 'core[auto_translation]', 'checked' => $Config->core['auto_translation'], 'value' => [0, 1], 'in' => [$L->off, $L->on], 'OnClick' => ["\$('.cs-auto-translation').hide();", "\$('.cs-auto-translation').show();"]])], ['style' => !$Config->core['multilingual'] ? 'display: none; ' : '', 'id' => 'auto_translation', 'class' => 'cs-multilingual']], [[h::info('auto_translation_engine'), h::select($translate_engines, ['name' => 'core[auto_translation_engine][name]', 'selected' => $Config->core['auto_translation_engine']['name'], 'data-settings' => $translate_engines_settings, 'size' => 5])], ['style' => !$Config->core['multilingual'] || !$Config->core['auto_translation'] ? 'display: none; ' : '', 'id' => 'auto_translation_engine', 'class' => 'cs-auto-translation']], [[$L->auto_translation_engine_settings, ['style' => !$Config->core['multilingual'] || !$Config->core['auto_translation'] ? 'display: none; ' : '', 'class' => 'cs-auto-translation cs-multilingual']], [$current_engine_settings, ['style' => !$Config->core['multilingual'] || !$Config->core['auto_translation'] ? 'display: none; ' : '', 'id' => 'auto_translation_engine_settings', 'class' => 'cs-auto-translation']]]));
<?php /** * @package Common * @category modules * @author Nazar Mokrynskyi <*****@*****.**> * @copyright Copyright (c) 2014, Nazar Mokrynskyi * @license MIT License, see license.txt */ namespace cs; use h, cs\modules\Info\Info, cs\modules\Help\Help; Trigger::instance()->register('System/Index/construct', function () { if (!API && !ADMIN && Config::instance()->module('Common')->active()) { $L = Language::instance(); $Page = Page::instance(); $Page->Description = 'opir.org - ми контролюємо вибори'; $Page->og('image', 'https://opir.org/components/modules/Common/includes/img/share.png'); $Page->og('image:secure_url', 'https://opir.org/components/modules/Common/includes/img/share.png'); $Page->link(['rel' => 'image_src', 'href' => 'https://opir.org/components/modules/Common/includes/img/share.png']); $Page->Header = h::{'div.cs-elections-logo'}(h::{'a[href=/] img'}(['src' => "components/modules/Common/includes/img/logo-{$L->clang}.png"])) . h::{'nav.cs-elections-switch-language'}(h::span("{$L->clang} " . h::icon('caret-down'), ['class' => $L->clang]) . h::{'div a[href=/$i[lang]][in=$i[language]]'}(['class' => '$i[lang]', 'insert' => [['lang' => 'uk', 'language' => 'Українська'], ['lang' => 'ru', 'language' => 'Русский'], ['lang' => 'en', 'language' => 'English']]])) . h::{'button.cs-elections-info'}() . h::{'button.cs-elections-help-initiative'}($L->help_initiative); $Page->content(h::{'section.cs-elections-info-modal[style=display:none] article[style=width:800px;]'}(Info::get()) . h::{'section.cs-elections-help-initiative-modal[style=display:none] article[style=width:800px;]'}(Help::get())); } });