Example #1
0
        if ($module_name != 'System') {
            /**
             * 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']));
Example #2
0
            $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]'}());
}
Example #3
0
 if (!isset($rc[3])) {
     break;
 }
 $a->apply_button = false;
 $a->cancel_button_back = true;
 $permissions = Permission::instance()->get_all();
 $group_permissions = $Group->get_permissions($rc[3]);
 $tabs = [];
 $tabs_content = '';
 $blocks = [];
 foreach ($Config->components['blocks'] as $block) {
     $blocks[$block['index']] = $block['title'];
 }
 unset($block);
 foreach ($permissions as $group => $list) {
     $tabs[] = h::a($group, ['href' => '#permissions_group_' . strtr($group, '/', '_')]);
     $content = [];
     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);
Example #4
0
 /**
  * Substitutes header information about user, sign in/sign up forms, etc.
  *
  * @return Page
  */
 protected function get_header_info()
 {
     $L = Language::instance();
     $User = User::instance(true);
     $this->user_avatar_image = $User->avatar();
     if ($User->user()) {
         $this->header_info = h::{'div.cs-header-user-block'}(h::b("{$L->hello}, " . $User->username() . '! ' . h::{'icon.cs-header-sign-out-process'}('sign-out', ['style' => 'cursor: pointer;', 'data-title' => $L->sign_out])) . h::div(h::a($L->profile, ['href' => path($L->profile) . "/{$User->login}"]) . ' | ' . h::a($L->settings, ['href' => path($L->profile) . '/' . path($L->settings)])) . $this->header_info);
         Trigger::instance()->run('System/Page/get_header_info');
     } else {
         $external_systems_list = '';
         Trigger::instance()->run('System/Page/external_sign_in_list', ['list' => &$external_systems_list]);
         $this->header_info = h::{'div.cs-header-guest-form'}(h::b("{$L->hello}, {$L->guest}!") . h::div(h::{'button.cs-header-sign-in-slide.cs-button-compact.uk-icon-sign-in'}($L->sign_in) . h::{'button.cs-header-registration-slide.cs-button-compact.uk-icon-pencil'}($L->sign_up, ['data-title' => $L->quick_registration_form]))) . h::{'div.cs-header-restore-password-form'}(h::{'input.cs-no-ui.cs-header-restore-password-email[tabindex=1]'}(['placeholder' => $L->login_or_email, 'autocapitalize' => 'off', 'autocorrect' => 'off']) . h::br() . h::{'button.cs-header-restore-password-process.cs-button-compact.uk-icon-question[tabindex=2]'}($L->restore_password) . h::{'button.cs-button-compact.cs-header-back[tabindex=3]'}(h::icon('chevron-down'), ['data-title' => $L->back]), ['style' => 'display: none;']) . h::{'div.cs-header-registration-form'}(h::{'input.cs-no-ui.cs-header-registration-email[type=email][tabindex=1]'}(['placeholder' => $L->email, 'autocapitalize' => 'off', 'autocorrect' => 'off']) . h::br() . h::{'button.cs-header-registration-process.cs-button-compact.uk-icon-pencil[tabindex=2]'}($L->sign_up) . h::{'button.cs-button-compact.cs-header-back[tabindex=4]'}(h::icon('chevron-down'), ['data-title' => $L->back]), ['style' => 'display: none;']) . h::{'form.cs-header-sign-in-form.cs-no-ui'}(h::{'input.cs-no-ui.cs-header-sign-in-email[tabindex=1]'}(['placeholder' => $L->login_or_email, 'autocapitalize' => 'off', 'autocorrect' => 'off']) . h::{'input.cs-no-ui.cs-header-user-password[type=password][tabindex=2]'}(['placeholder' => $L->password]) . h::br() . h::{'button.cs-button-compact.uk-icon-sign-in[tabindex=3][type=submit]'}($L->sign_in) . h::{'button.cs-button-compact.cs-header-back[tabindex=5]'}(h::icon('chevron-down'), ['data-title' => $L->back]) . h::{'button.cs-button-compact.cs-header-restore-password-slide[tabindex=4]'}(h::icon('question'), ['data-title' => $L->restore_password]), ['style' => 'display: none;']) . $external_systems_list;
     }
     return $this;
 }
Example #5
0
 * @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))));
Example #6
0
require "lib.htmlgen.php";
h::set_variable("table_data", array("foo" => "bar", "hello" => "world", "123" => "456", "abc" => "xyz"));
h::set_indent_pattern("  ");
h::html(function () {
    h::head(function () {
        h::meta(array("charset" => "UTF-8"));
        h::link(array("rel" => "stylesheet", "type" => "text/css", "href" => "global.css"));
    });
    h::body(function () {
        h::div(array("id" => "wrapper"), function () {
            h::h1("Hello, World", array("class" => "title"));
            h::comment("navigation");
            h::ul(array("class" => "links"), function () {
                foreach (array(1, 2, 3) as $x) {
                    h::li(function () use($x) {
                        h::a("Link {$x}", "#{$x}");
                    });
                }
            });
            h::comment("let's see some text");
            h::p("Lorem ipsum dolor sit amet, consectetur adipisicing elit...");
            h::comment("now for a table");
            h::table(function () {
                $table_data = h::get_variable('table_data', array());
                h::tr(array("class" => "header"), function () {
                    h::th("key");
                    h::th("value");
                });
                foreach ($table_data as $k => $v) {
                    h::tr(array("class" => h::cycle(array("odd", "even"))), function () use($k, $v) {
                        h::td($k);
Example #7
0
            case 'Instagram':
                return 'instagram';
            case 'LinkedIn':
                return 'linkedin';
            case 'Tumblr':
                return 'tumbrl';
            case 'Twitter':
                return 'twitter';
            case 'Vkontakte':
                return 'vk';
            default:
                return false;
        }
    };
    $data['list'] = h::{'ul.cs-hybrid-auth-providers-list li'}([$L->or_sign_in_with, ['class' => 'uk-nav-header']], array_map(function ($provider) use($L, $icon_mapper) {
        return [h::a(h::icon($icon_mapper($provider)) . $L->{$provider}), ['data-provider' => $provider, 'class' => "cs-hybrid-auth-{$provider}"]];
    }, array_keys($providers)));
});
Trigger::instance()->register('System/User/registration/confirmation/after', function () {
    if ($referer = _getcookie('HybridAuth_referer')) {
        header("Refresh: 5; url={$referer}");
        _setcookie('HybridAuth_referer', '');
    }
});
Trigger::instance()->register('System/User/del/after', function ($data) {
    /**
     *	@var \cs\DB\_Abstract $cdb
     */
    $cdb = DB::instance()->{Config::instance()->module('HybridAuth')->db('integration')}();
    $cdb->q(["DELETE FROM `[prefix]users_social_integration`\n\t\t\t\tWHERE `id` = '%s'", "DELETE FROM `[prefix]users_social_integration_contacts`\n\t\t\t\tWHERE `id` = '%s'"], $data['id']);
});
Example #8
0
function get_pages_rows()
{
    $L = Language::instance();
    $Static_pages = Static_pages::instance();
    $categories = array_slice(Config::instance()->route, 2);
    $structure = $Static_pages->get_structure();
    $path = [];
    if (!empty($categories)) {
        foreach ($categories as $category) {
            $category = $Static_pages->get_category($category)['path'];
            if (isset($structure['categories'][$category])) {
                $structure = $structure['categories'][$category];
                $path[] = $structure['path'];
            }
        }
        unset($category);
    }
    Page::instance()->title($structure['id'] == 0 ? $L->root_category : $structure['title']);
    $path = !empty($path) ? implode('/', $path) . '/' : '';
    $content = [];
    if (!empty($structure['pages'])) {
        foreach ($structure['pages'] as &$page) {
            $page = $Static_pages->get($page);
            $content[] = [[h::a($page['title'], ['href' => $path . $page['path']]), ['class' => 'cs-static-pages-padding-left-0']], h::{'a.cs-button-compact'}([h::icon('file-text'), ['href' => "admin/Static_pages/edit_page/{$page['id']}", 'data-title' => $L->edit]], [h::icon('trash-o'), ['href' => "admin/Static_pages/delete_page/{$page['id']}", 'data-title' => $L->delete]])];
        }
    }
    return [$content];
}
Example #9
0
/**
 * Pages navigation based on links
 *
 * @param int				$page		Current page
 * @param int				$total		Total pages number
 * @param Closure|string	$url		if string - it will be formatted with sprintf with one parameter - page number<br>
 * 										if Closure - one parameter will be given, Closure should return url string
 * @param bool				$head_links	If <b>true</b> - links with rel="prev" and rel="next" will be added
 *
 * @return bool|string					<b>false</b> if single page, otherwise string, set of navigation links
 */
function pages($page, $total, $url, $head_links = false)
{
    if ($total == 1) {
        return false;
    }
    $Page = Page::instance();
    $output = [];
    if ($url instanceof Closure) {
        $url_func = $url;
    } else {
        $original_url = $url;
        $url_func = function ($page) use($original_url) {
            return sprintf($original_url, $page);
        };
    }
    $base_url = Config::instance()->base_url();
    $url = function ($page) use($url_func, $base_url) {
        $url = $url_func($page);
        if (is_string($url) && strpos($url, 'http') !== 0) {
            $url = $base_url . '/' . ltrim($url, '/');
        }
        return $url;
    };
    if ($total <= 11) {
        for ($i = 1; $i <= $total; ++$i) {
            $output[] = [$i, ['href' => $i == $page ? false : $url($i), 'class' => $i == $page ? 'cs-button uk-button-primary uk-frozen' : 'cs-button']];
            if ($head_links && ($i == $page - 1 || $i == $page + 1)) {
                $Page->link(['href' => $url instanceof Closure ? $url($i) : sprintf($url, $i), 'rel' => $i == $page - 1 ? 'prev' : ($i == $page + 1 ? 'next' : false)]);
            }
        }
    } else {
        if ($page <= 5) {
            for ($i = 1; $i <= 7; ++$i) {
                $output[] = [$i, ['href' => $i == $page ? false : $url($i), 'class' => $i == $page ? 'cs-button uk-button-primary uk-frozen' : 'cs-button']];
                if ($head_links && ($i == $page - 1 || $i == $page + 1)) {
                    $Page->link(['href' => $url instanceof Closure ? $url($i) : sprintf($url, $i), 'rel' => $i == $page - 1 ? 'prev' : ($i == $page + 1 ? 'next' : false)]);
                }
            }
            $output[] = ['...', ['class' => 'cs-button uk-frozen']];
            for ($i = $total - 2; $i <= $total; ++$i) {
                $output[] = [$i, ['href' => $url instanceof Closure ? $url($i) : sprintf($url, $i), 'class' => 'cs-button']];
            }
        } elseif ($page >= $total - 4) {
            for ($i = 1; $i <= 3; ++$i) {
                $output[] = [$i, ['href' => $url instanceof Closure ? $url($i) : sprintf($url, $i), 'class' => 'cs-button']];
            }
            $output[] = ['...', ['class' => 'cs-button uk-frozen']];
            for ($i = $total - 6; $i <= $total; ++$i) {
                $output[] = [$i, ['href' => $i == $page ? false : $url($i), 'class' => $i == $page ? 'cs-button uk-button-primary uk-frozen' : 'cs-button']];
                if ($head_links && ($i == $page - 1 || $i == $page + 1)) {
                    $Page->link(['href' => $url instanceof Closure ? $url($i) : sprintf($url, $i), 'rel' => $i == $page - 1 ? 'prev' : ($i == $page + 1 ? 'next' : false)]);
                }
            }
        } else {
            for ($i = 1; $i <= 2; ++$i) {
                $output[] = [$i, ['href' => $url instanceof Closure ? $url($i) : sprintf($url, $i), 'class' => 'cs-button']];
            }
            $output[] = ['...', ['class' => 'cs-button uk-frozen']];
            for ($i = $page - 1; $i <= $page + 3; ++$i) {
                $output[] = [$i, ['href' => $i == $page ? false : $url($i), 'class' => $i == $page ? 'cs-button uk-button-primary uk-frozen' : 'cs-button']];
                if ($head_links && ($i == $page - 1 || $i == $page + 1)) {
                    $Page->link(['href' => $url instanceof Closure ? $url($i) : sprintf($url, $i), 'rel' => $i == $page - 1 ? 'prev' : ($i == $page + 1 ? 'next' : false)]);
                }
            }
            $output[] = ['...', ['class' => 'cs-button uk-frozen']];
            for ($i = $total - 1; $i <= $total; ++$i) {
                $output[] = [$i, ['href' => $url instanceof Closure ? $url($i) : sprintf($url, $i), 'class' => 'cs-button']];
            }
        }
    }
    return h::a($output);
}
Example #10
0
 public function render()
 {
     $input = request::input();
     $settings = array();
     $settings['limit'] = @$input['limit'] ? @intval($input['limit']) : 20;
     $settings['offset'] = @intval(@$input['offset']);
     // show starting from this row
     $settings['orderby'] = isset($input['orderby']) ? $input['orderby'] : $this->list_orderby;
     // order by column
     $settings['orderdesc'] = isset($input['orderdesc']) ? $input['orderdesc'] : $this->list_orderdesc;
     // order direction
     $settings['took'] = microtime(true);
     // building sql for select
     $from = ' FROM ' . $this->list_table . @$this->left_join . ' WHERE 1=1';
     // full text search
     $full_text_search = array();
     $gist_columns = array();
     if (!empty($input['full_text_search']) && !empty($this->full_text_search_column)) {
         $full_text_search = db::tsquery($this->full_text_search_column, $input['full_text_search'], '|', true, array(), $this->link);
         $from .= $full_text_search['where'];
     }
     // other where
     if (!empty($this->where)) {
         $from .= $this->where;
     }
     // getting number of records
     if (@$this->list_count_rows) {
         $sql = 'SELECT COUNT(*) as rows_count ' . $from;
         $result = db::query($sql, '', array(), $this->link);
         if (@$result['error']) {
             layout::add_message($result['error'], 'error');
         }
         // use this variable to get number of rows, isset for verification
         $settings['count_rows'] = @$result['rows'][0]['rows_count'] ? $result['rows'][0]['rows_count'] : 0;
     } else {
         // EXPERIMENTAL: increase number of rows fetched by 1 to check whether next row exists
         $settings['limit']++;
     }
     // quering
     $sql = 'SELECT ' . $this->select . (!empty($full_text_search['rank']) ? ', ' . $full_text_search['rank'] . ' ts_rank2' : '') . $from;
     $sql .= ' ORDER BY ' . (@$full_text_search['orderby'] ? @$full_text_search['orderby'] . ", " : "") . $settings['orderby'] . ($settings['orderdesc'] ? ' DESC' : '');
     $sql .= $settings['limit'] ? ' LIMIT ' . $settings['limit'] : '';
     $sql .= $settings['offset'] ? ' OFFSET ' . $settings['offset'] : '';
     $result = db::query($sql, '', array(), $this->link);
     $settings['took'] = round(microtime(true) - $settings['took'], 2);
     // processing count
     if (!@$this->list_count_rows) {
         if (isset($result['rows'][$settings['limit'] - 1])) {
             $settings['flag_next_row_exists'] = true;
         }
         unset($result['rows'][$settings['limit'] - 1]);
         $settings['limit']--;
     }
     $settings['num_rows'] = count($result['rows']);
     // rendering list
     $ms = '';
     // Hidden elements
     $ms .= h::hidden(array('name' => 'orderby', 'id' => 'orderby', 'value' => $settings['orderby']));
     $ms .= h::hidden(array('name' => 'orderdesc', 'id' => 'orderdesc', 'value' => $settings['orderdesc']));
     $ms .= h::hidden(array('name' => 'offset', 'id' => 'offset', 'value' => $settings['offset']));
     $ms .= h::hidden(array('name' => 'limit', 'id' => 'limit', 'value' => $settings['limit']));
     // if we have no rows
     if (empty($result['rows'])) {
         $ms .= 'No records found!';
     } else {
         // main container
         $header = $this->header($settings);
         $ms .= $header;
         $ms .= '<br/>';
         $ms .= '<table cellpadding="0" cellspacing="0" class="editor table" width="100%">';
         // types
         $types = model_presets::get('he_post_type');
         // rows
         $row_counter = 1;
         foreach ($result['rows'] as $k => $v) {
             $ms .= '<tr>';
             $ms .= '<td class="editor cell numeration" valign="top">' . $row_counter . '.&nbsp;</td>';
             $ms .= '<td class="editor cell regular" align="left">';
             // generating urls
             $url_post = call_user_func_array($this->url_posts, array($v['type'], $v['post_id'], $v['uri']));
             $url_type = call_user_func_array($this->url_type, array($v['type']));
             // title with icon goes first
             $value = $v['title'];
             if ($v['type'] == 20) {
                 $v['icon'] = 'help16.png';
             } else {
                 if ($v['type'] == 10) {
                     $v['icon'] = 'faq16.png';
                 }
             }
             if (!empty($v['icon'])) {
                 $value = icon::render($v['icon']) . ' ' . $value;
             }
             $ms .= h::a(array('href' => $url_post, 'value' => $value));
             if (isset($v['ts_rank2'])) {
                 $ms .= ' [' . $v['ts_rank2'] . ']';
             }
             // entry type
             $ms .= ' ' . h::a(array('href' => $url_type, 'value' => $types[$v['type']]['name'], 'style' => 'color:black;'));
             $ms .= '<br/>';
             $ms .= h::a(array('href' => $url_post, 'value' => $url_post, 'style' => 'color: green;'));
             if (!empty($input['full_text_search'])) {
                 $ms .= '<br/>';
                 $temp = keywords::highlight($v['body'], $input['full_text_search'], array('<b style="color:red;">', '</b>'));
             } else {
                 $ms .= '<br/>';
                 $temp = $v['body'];
             }
             $ms .= $temp;
             $ms .= '<br/>';
             $ms .= '<br/>';
             $ms .= '</td>';
             $ms .= '</tr>';
             $row_counter++;
         }
         $ms .= '</table>';
         $ms .= $header;
         $ms .= '<br class="clearfloat">';
     }
     return $ms;
 }
Example #11
0
    /**
     * Loading of base system configuration, creating of missing directories
     */
    protected function construct()
    {
        if (!file_exists(CONFIG . '/main.json')) {
            error_code(500);
            Page::instance()->error(h::p('Config file not found, is system installed properly?') . h::a('How to install CleverStyle CMS', ['href' => 'https://github.com/nazar-pc/CleverStyle-CMS/wiki/Installation']));
            exit;
        }
        $this->config = file_get_json_nocomments(CONFIG . '/main.json');
        _include_once(CONFIG . '/main.php', false);
        defined('DEBUG') || define('DEBUG', false);
        define('DOMAIN', $this->config['domain']);
        date_default_timezone_set($this->config['timezone']);
        if ($clangs = Cache::instance()->{'languages/clangs'}) {
            if (is_array($clangs) && !empty($clangs)) {
                $clang = explode('/', trim($_SERVER['REQUEST_URI'], '/'), 2)[0];
                if (in_array($clang, $clangs)) {
                    $this->set('language', array_flip($clangs)[$clang]);
                    define('FIXED_LANGUAGE', true);
                }
                unset($clang);
            }
        }
        unset($clangs);
        if (!is_dir(STORAGE)) {
            @mkdir(STORAGE, 0755);
            file_put_contents(STORAGE . '/.htaccess', 'Allow From All');
        }
        if (!is_dir(CACHE)) {
            @mkdir(CACHE, 0700);
        }
        if (!is_dir(PCACHE)) {
            @mkdir(PCACHE, 0755);
            file_put_contents(PCACHE . '/.htaccess', '<FilesMatch "\\.(css|js)$">
	Allow From All
</FilesMatch>
<ifModule mod_expires.c>
	ExpiresActive On
	ExpiresDefault "access plus 1 month"
</ifModule>
<ifModule mod_headers.c>
	Header set Cache-Control "max-age=2592000, public"
</ifModule>
AddEncoding gzip .js
AddEncoding gzip .css
');
        }
        if (!is_dir(LOGS)) {
            @mkdir(LOGS, 0700);
        }
        if (!is_dir(TEMP)) {
            @mkdir(TEMP, 0755);
            file_put_contents(TEMP . '/.htaccess', 'Allow From All');
        }
        if (isset($_SERVER['CONTENT_TYPE']) && strpos($_SERVER['CONTENT_TYPE'], 'application/json') === 0) {
            $_POST = _json_decode(@file_get_contents('php://input')) ?: [];
            $_REQUEST = array_merge($_REQUEST, $_POST);
        } elseif (in_array(strtolower($_SERVER['REQUEST_METHOD']), ['head', 'put', 'delete'])) {
            if (isset($_SERVER['CONTENT_TYPE']) && strpos($_SERVER['CONTENT_TYPE'], 'application/x-www-form-urlencoded') === 0) {
                @parse_str(file_get_contents('php://input'), $_POST);
                $_REQUEST = array_merge($_REQUEST, $_POST);
            }
        }
        $this->constructed = true;
    }
Example #12
0
/**
 * @package        OAuth2 customization
 * @category       plugins
 * @author         Nazar Mokrynskyi <*****@*****.**>
 * @copyright      Copyright (c) 2014, Nazar Mokrynskyi
 * @license        MIT License, see license.txt
 */
namespace cs;

use h;
Trigger::instance()->register('OAuth2/custom_sign_in_page', function () {
    if (!in_array('OAuth2_customization', Config::instance()->components['plugins'])) {
        return true;
    }
    define('MOBILE_AUTH', true);
    $L = Language::instance();
    $Page = Page::instance();
    $Page->Title = [$Page->Title[0], $L->sign_in];
    $Page->content(h::{'section.cs-oauth2-customization'}(h::{'h2.uk-text-center.uk-margin-top'}($L->sign_in) . h::a(h::icon('facebook') . $L->sign_in_with('Facebook'), ['href' => 'HybridAuth/Facebook']) . h::a(h::icon('vk') . $L->sign_in_with('VK'), ['href' => 'HybridAuth/Vkontakte'])));
    return false;
})->register('System/Config/routing_replace', function () {
    if (!in_array('OAuth2_customization', Config::instance()->components['plugins'])) {
        return;
    }
    spl_autoload_register(function ($class) {
        if (ltrim($class, '\\') == 'cs\\modules\\OAuth2\\OAuth2') {
            include __DIR__ . '/OAuth2.php';
        }
    }, true, true);
});