/** */ public function show() { css(' #faq-search { padding-top: 20px; } #faq-items { padding-top: 20px; padding-bottom: 20px; } #faq-items li.li-header { list-style: none; display:none; } #faq-items li.li-level-0 { display: block; font-size: 15px; } #faq-items li.li-level-1 { padding-top: 10px; font-size: 13px; } span.highlight { background-color: #ff0; } '); asset('jquery-highlight'); jquery(' var url_hash = window.location.hash.replace("/", ""); if (url_hash) { $("li.li-level-0" + url_hash + " .li-level-1", "#faq-items").show(); } $(".li-level-0", "#faq-items").click(function(){ $(".li-level-1", this).toggle() }) $("input#search", "#faq-search").on("change keyup", function(){ var words = $(this).val(); $("#faq-items").unhighlight(); $("#faq-items").highlight(words); $(".li-level-1").hide().filter(":has(\'span.highlight\')").show(); }) '); $items = []; foreach ((array) db()->from(self::table)->where('active', 1)->where('locale', conf('language'))->get_all() as $a) { $items[$a['id']] = ['parent_id' => $a['parent_id'], 'name' => _truncate(trim($a['title']), 60, true, '...'), 'link' => url('/@object/#/faq' . $a['id']), 'id' => 'faq' . $a['id']]; if ($a['text']) { $items['1111' . $a['id']] = ['parent_id' => $a['id'], 'body' => trim($a['text'])]; } } return tpl()->parse_string($this->_tpl, ['items' => html()->li_tree($items)]); }
/** */ function _init() { asset('animate-css'); jquery(' $(\'.news_item_title\').hover(function(){ $(this).parent().find(\'.news_btn\').addClass(\'active_news_btn\'); },function(){ $(this).parent().find(\'.news_btn\').removeClass(\'active_news_btn\'); }); $(\'.news_btn\').hover(function(){ $(this).parent().parent().find(\'.news_item_title\').addClass(\'active_news\'); },function(){ $(this).parent().parent().find(\'.news_item_title\').removeClass(\'active_news\'); }); '); css(' .news .news_item { font-size: 13px; font-weight:normal; margin-bottom: 20px; margin-top: 20px; } .news h1 { font-size: 18px; margin-bottom: 20px; } .news h3 { font-size: 18px; margin-top: 5px; } .news .news_item_content { } .news .news_item_content h1, .news .news_item_content h2, .news .news_item_content h3, .news .news_item_content h4, .news .news_item_content h5, .news .news_item_content h6 { font-size: 13px; font-weight:normal; } .news .news_item_footer { color: #aaa; } .news .news_item_date { color: #777; } .news .news_item_social { margin-top: 20px; } .news .news_item_comments { margin-top: 20px; } '); }
/** */ function postload($params = [], $table) { $attr_postload_url = $params['attr_postload_url'] ?: 'postload-url'; $tr_id_key = $params['tr_id_key'] ?: 'name'; $jquery = ' var attr_postload_url = "' . $attr_postload_url . '" , tr_id_key = "' . $tr_id_key . '" ; var process_ajax_data_func = function(data, table) { var th_id_prefix = "th_" , th_id_cut_len = th_id_prefix.length , tr_id_prefix = "tr_" , tr_id_cut_len = tr_id_prefix.length , th_positions = { } ; table.find("th").each(function(i) { var th_id = $(this).attr("id"); if (th_id && th_id.substring(0, th_id_cut_len) == th_id_prefix) { th_positions[th_id.substring(th_id_cut_len)] = i; } }) table.find("tr").each(function(i) { var tr = $(this) , tr_id = tr.attr("id") ; if (tr_id && tr_id.length && tr_id.substring(0, tr_id_cut_len) == tr_id_prefix) { tr_id = tr_id.substring(tr_id_cut_len) } if (!tr_id) { return; } for (key1 in data) { var td = tr.find("td").eq(th_positions[key1]) , ajax_arr = data[key1][tr_id] , td_a = td.find("a") ; if (td_a) { td_a.text(ajax_arr) } else { td.text(ajax_arr) } } }) }; $("table[data-" + attr_postload_url + "]").each(function(){ var table = $(this) , url = table.data(attr_postload_url) , spinner = table.before("<i class=\\"icon icon-spinner icon-2x icon-spin fa fa-spinner fa-2x fa-spin\\" id=\\"table_ajax_spinner\\" style=\\"position:fixed;\\"></i>").prev() ; $.post(url, function(data) { process_ajax_data_func(data, table); spinner.remove(); }) }); '; jquery($jquery); return $table; }
public function render() { $sort = front()->registry()->get('get', 'sort'); $page = front()->registry()->get('get', 'page'); $query = front()->registry()->get('get', 'q'); $this->_body['summarize'] = true; //create a common search //->addFilter('post1.post_type=%s', 'question') //->setColumns(...,'COALESCE(SUM(vote_value), 0) as votes', // '(SELECT COUNT(*) as answers FROM post as post2 // WHERE post2.post_type=\'answer\' AND post2.post_parent=post1.post_id // AND (post2.post_active > 0 OR post2.post_active BETWEEN -1 AND -4)) // AS answers //->addFilter('(post1.post_active = 1 OR post1.post_active BETWEEN -2 AND -1)') ////->sortByVotes('DESC') $search = front()->jobpost()->search()->setColumns('job.*', 'company.*')->setTable('jobpost AS job')->leftJoinOn('company', 'company.company_id= job.jobpost_company')->setGroup('job.jobpost_id')->setRange(self::RANGE); //if this is a search query if (trim($query)) { //set the query and filter $this->_body['query'] = $query; $search->addFilter('(jobpost_title LIKE %s OR jobpost_detail LIKE %s)', '%' . $query . '%', '%' . $query . '%'); } //case for sorting switch ($sort) { case 'new': $search->sortByJobpostCreated('DESC'); break; case 'old': $search->sortByJobpostCreated('ASC'); break; case 'unanswered': $search->sortByJobpostAnswers('ASC'); break; default: // $search->sortByVotes('DESC'); break; } //case for pagination if (is_numeric($page)) { $search->setPage($page); } else { $page = 1; } //now generate the final collection $this->_body['collection'] = $search->getCollection(); //add extra collection details foreach ($this->_body['collection'] as $jobpost) { $author = front()->user()->model($jobpost->getJobpostUser()); $jobpost['user_name'] = $author->getUserName(); } //$jobpost['user_facebook'] = $author->getAttributes('facebook_id'); // $jobpost['user_picture'] = $author->getAttributes('picture'); // $jobpost['tags'] = $jobpost->getCategories(); //create a pagination block $this->_body['pagination'] = front()->template(__DIR__ . '/_pagination.phtml', jquery()->block()->pagination($search->getTotal())->setRange(self::RANGE)->setPage($page)->setUrl('/')->setQuery($_GET)->getVariables()); return $this->_page(); }
/** */ function edit() { $a = $this->_get_info(); if (!$a) { return _404(); } $a['back_link'] = url('/@object'); $form_id = 'content_form'; jquery(' var form_id = "' . $form_id . '"; var bak_action = $("form#" + form_id).attr("action"); var preview_url = "' . url_user('/dynamic/preview/static_pages/' . $a['id']) . '"; $("[type=submit].preview", "form#" + form_id).on("click", function() { $(this).closest("form").attr("target", "_blank").attr("action", preview_url) }) $("[type=submit]:not(.preview)", "form#" + form_id).on("click", function() { $(this).closest("form").attr("target", "").attr("action", bak_action) }) '); // Prevent execution of template tags when editing page content $exec_fix = ['{' => '{', '}' => '}']; $keys_to_fix = ['text']; foreach ((array) $keys_to_fix as $k) { if (false !== strpos($a[$k], '{') && false !== strpos($a[$k], '}')) { $a[$k] = str_replace(array_keys($exec_fix), array_values($exec_fix), $a[$k]); } } $a = (array) $_POST + (array) $a; if (is_post()) { foreach ((array) $keys_to_fix as $k) { if (false !== strpos($_POST[$k], '{') && false !== strpos($_POST[$k], '}')) { $_POST[$k] = str_replace(array_values($exec_fix), array_keys($exec_fix), $_POST[$k]); } } } $_this = $this; return form($a, ['hide_empty' => true, 'id' => $form_id])->validate(['__before__' => 'trim', 'name' => ['required', function (&$in) use($_this) { $in = $_this->_fix_page_name($in); return (bool) strlen($in); }, function ($name, $tmp, $d, &$error) use($_this, $a) { $id = db()->from($_this::table)->where('locale', $a['locale'])->where('name', $name)->get_one('id'); if ($id && $id != $a['id']) { $error = t('Page with this name and locale already exists'); } return $error ? false : true; }], 'text' => 'required'])->update_if_ok(self::table, ['name', 'text', 'page_title', 'page_heading', 'meta_keywords', 'meta_desc', 'active'], 'id=' . $a['id'])->on_before_update(function () use($a, $_this) { module_safe('manage_revisions')->add(['object_name' => $_this::table, 'object_id' => $a['id'], 'old' => $a, 'new' => $_POST, 'action' => 'update']); })->on_after_update(function () { common()->admin_wall_add(['static page updated: ' . $a['name'], $a['id']]); cache_del('static_pages_names'); })->container($this->_get_lang_links($a['locale'], $a['name'], 'edit'))->text('name')->textarea('text', ['id' => 'text', 'cols' => 200, 'rows' => 10, 'ckeditor' => ['config' => _class('admin_methods')->_get_cke_config()]])->text('page_title')->text('page_heading')->text('meta_keywords')->text('meta_desc')->active_box()->save_and_back()->preview(); }
/** * Embedding ckeditor (http://ckeditor.com/) with kcfinder (http://kcfinder.sunhater.com/). * You can include it into project like this: * * git submodule add https://github.com/yfix/ckeditor-releases.git www/ckeditor/ && cd www/ckeditor/ && git checkout latest/full * git submodule add https://github.com/yfix/kcfinder.git www/kcfinder * * 'www/' usually means PROJECT_PATH inside project working copy. * P.S. You can use free CDN for ckeditor as alternate solution. */ function _ckeditor_html($extra = [], $replace = [], $form) { if (!is_array($extra)) { return ''; } $params = $extra['ckeditor']; if (!is_array($params)) { $params = []; } js('ckeditor'); // Theme-wide ckeditor config inside stpl (so any engine vars can be processed or included there) $stpl_name = 'ckeditor_config'; // Example filesystem location: PROJECT_PATH.'templates/admin/ckeditor_config.stpl' if (!isset($replace['content_id'])) { $replace['content_id'] = $content_id; } $content_id = $extra['id'] ? $extra['id'] : 'content_editable'; $hidden_id = $params['hidden_id'] ? $params['hidden_id'] : ''; if (isset($params['config'])) { if (is_array($params['config'])) { $config_js = ' try { CKEDITOR.' . ($hidden_id ? 'inline' : 'replace') . '("' . $content_id . '", ' . json_encode($params['config']) . '); } catch (e) { console.error("ckeditor init failed:", e); } '; } elseif (is_callable($params['config'])) { $func = $params['config']; $config_js = $func($extra, $replace, $form); } else { $config_js = $params['config']; } } else { $config_js = tpl()->_stpl_exists($stpl_name) ? tpl()->parse($stpl_name, (array) $extra + (array) $replace) : ''; } if (strlen($config_js)) { js($config_js); } if (strlen($hidden_id) && strlen($content_id)) { jquery(' var _content_id = "#' . $content_id . '"; var _hidden_id = "#' . $hidden_id . '"; $(_content_id).parents("form").submit(function(){ $("input[type=hidden]" + _hidden_id).val( $(_content_id).html() ); }) '); } return $body; }
/** * http://omnipotent.net/jquery.sparkline */ function jquery_sparklines($data, $extra = []) { $extra['id'] = $extra['id'] ?: __FUNCTION__ . '_' . ++$this->_ids[__FUNCTION__]; if (!is_array($data) || !$data) { return false; } $extra['trim'] = isset($extra['trim']) ? $extra['trim'] : true; // Trim empty data left and right if ($extra['trim']) { foreach ((array) $data as $k => $v) { if (is_array($v)) { if (!array_sum($v)) { unset($data[$k]); continue; } } elseif (!$v) { unset($data[$k]); continue; } break; } foreach (array_reverse($data, $preserve_keys = true) as $k => $v) { if (is_array($v)) { if (array_sum($v)) { break; } } elseif ($v) { break; } unset($data[$k]); } if (!$data) { return false; } } $extra['type'] = $extra['type'] ?: 'bar'; asset('jquery-sparklines'); jquery(' $("#' . $extra['id'] . '").sparkline(' . json_encode(array_values($data)) . ', { type: "' . $extra['type'] . '", enableTagOptions: true, tooltipFormat: "{{offset:key}}: {{value}}", tooltipValueLookups: { key: ' . json_encode(array_keys($data)) . ' } }); '); return '<span id="' . $extra['id'] . '" class="sparkline"></span>'; }
/** * Star selector, got from http://fontawesome.io/examples/#custom. Require this CSS: * '<style> * .rating { unicode-bidi:bidi-override;direction:rtl;font-size:20px } * .rating span.star { font-family:FontAwesome;font-weight:normal;font-style:normal;display:inline-block } * .rating span.star:hover { cursor:pointer } * .rating span.star:before { content:"\f006";padding-right:0.2em;color:#999 } * .rating span.star:hover:before, .rating span.star:hover~span.star:before{ content:"\f005";color:#e3cf7a } * </style>'; */ function stars_select($name = '', $desc = '', $extra = [], $replace = [], $form) { if (is_array($desc)) { $extra += $desc; $desc = ''; } if (!is_array($extra)) { $extra = []; } $extra['name'] = $extra['name'] ?: ($name ?: 'stars'); $extra['desc'] = $form->_prepare_desc($extra, $desc); $func = function ($extra, $r, $form) { $form->_prepare_inline_error($extra); $max = $extra['max'] ?: 5; $stars = $extra['stars'] ?: 5; $class = $extra['class'] ?: 'star'; $body[] = '<span class="rating">'; foreach (range(1, $stars) as $num) { $body[] = '<span class="' . $class . ' ' . $extra['name'] . '" data-name="' . $extra['name'] . '" data-value="' . ($stars - $num + 1) . '"></span>'; } $body[] = '</span>'; $body[] = '<input type="hidden" name="' . $extra['name'] . '" id=' . $extra['name'] . ' value="0">'; jquery('$(".' . $class . '.' . $extra['name'] . '").on("click",function() { var value = $(this).attr("data-value"); $("#"+$(this).attr("data-name")).val(value); $(".rating.star.' . $extra['name'] . '").each(function() { $(this).attr("data-value"); if (value>=$(this).attr("data-value")) { $(this).addClass("rating_selected"); } else { $(this).removeClass("rating_selected"); } }); });'); return $form->_row_html(implode('', $body), $extra, $r); }; if ($form->_chained_mode) { $form->_body[] = ['func' => $func, 'extra' => $extra, 'replace' => $replace, 'name' => __FUNCTION__]; return $form; } return $func($extra, $replace, $form); }
/** */ function _ace_editor_html($extra = [], $replace = [], $form) { $extra['id'] = $extra['id'] ?: 'editor_html'; asset('ace-editor'); $opts = ['fontSize' => $extra['ace_editor']['font-size'] ?: '16px']; $jq = ' try { var ace_editor = ace.edit("' . addslashes($extra['id']) . '"); ace_editor.setTheme("ace/theme/' . ($extra['ace_editor']['theme'] ?: 'tomorrow_night') . '"); ace_editor.getSession().setMode("ace/mode/' . ($extra['ace_editor']['mode'] ?: 'html') . '"); ace_editor.setPrintMarginColumn(false); ace_editor.setOptions(' . str_replace('\\/', '/', json_encode($opts)) . '); $("#' . addslashes($extra['id']) . '").data("ace_editor", ace_editor); } catch (e) { console.log(e) } '; jquery($jq); return $body; }
function show() { if (!main()->TRACK_ONLINE_STATUS) { return t('online users tracking is disabled'); } jquery(' setTimeout(function(){ window.location.reload(1); }, 60000); '); $filter_name = $_GET['object']; if (!$_SESSION[$filter_name]['user_type']) { $_SESSION[$filter_name]['user_type'] = 'user_id'; } if (main()->TRACK_ONLINE_DETAILS) { return table('SELECT *,`user_id` AS `id` FROM ' . db('users_online_details'), ['filter' => $_SESSION[$filter_name]])->text('user_id')->text('url')->text('ip')->text('session_id')->text('user_agent')->date('time', ['format' => 'full', 'nowrap' => 1])->btn('send notification', './?object=manage_notifications&action=add&receiver_id=%d&receiver_type=' . $_SESSION[$filter_name]['user_type']); } else { return table('SELECT *,`user_id` AS `id` FROM ' . db('users_online'), ['filter' => $_SESSION[$filter_name]])->text('user_id')->date('time', ['format' => 'full', 'nowrap' => 1])->btn('send notification', './?object=manage_notifications&action=add&receiver_id=%d&receiver_type=' . $_SESSION[$filter_name]['user_type']); } }
is_hidden = false; } is_hidden && side_area_close(); // init toggle_btn.on("click", function() { if (is_hidden) { side_area_open() } else { side_area_close() } try { $.cookie(cookie_name, is_hidden ? 1 : 0, {path: "/"}); } catch(e) { } }) '; $css = ' .center_area_wide { margin-left:1%; width:98%; } .center_area_narrow { margin-left: 25% !important; width: 74% !important; } '; if ($is_hidden) { $css .= ' .center_area { margin-left:1%; width:98%; } .left_area { display: none; } '; } jquery($jquery); js('jquery-cookie'); css($css); $body .= '<a class="btn btn-default btn-small" id="' . $id . '" style="position:fixed; top:45px; left:5px;"> <i class="' . ($is_hidden ? $icons['closed'] : $icons['open']) . '"></i></a>' . ($is_hidden ? '<style type="text/css">.left_area {display:none;}</style>' : ''); return $body; });
function htmlHeader($title) { $htmlCode = metaTags() . titleTag($title) . siteCSS() . jquery() . checkboxStyling() . styledFileUpload() . customJquery() . tooltips() . calendar() . pngFix() . tinyMceEditor() . treeMenu() . fancyBox(); return $htmlCode; }
<title><?php if (!empty($title)) { echo $title . ' | '; } ?> Stencil by Scotch.io</title> <?php echo chrome_frame(); echo view_port(); echo apple_mobile('black-translucent'); echo $meta; ?> <!-- icons and icons and icons and icons and icons and a tile --> <?php echo windows_tile(array('name' => 'Stencil', 'image' => base_url() . '/assets/img/icons/tile.png', 'color' => '#4eb4e5')); echo favicons(); ?> <!-- crayons and paint --> <?php echo add_css(array('bootstrap', 'bootstrap-responsive', 'style')); echo $css; ?> <!-- magical wizardry --> <?php echo jquery('1.9.1'); echo shiv(); echo add_js(array('bootstrap.min', 'scripts')); echo $js;
.social-buttons { display: block; list-style: none; padding: 0; margin: 20px; } .social-buttons > li { display: block; margin: 0; padding: 10px; float: left; } .social-buttons .socialite { display: block; position: relative; background: url("//rawgit.yfix.net/yfix/Socialite/master/images/social-sprite.png") 0 0 no-repeat; } .social-buttons .socialite-loaded { background: none !important; } /* .social-buttons .twitter-share { width: 55px; height: 65px; background-position: 0 0; } .social-buttons .googleplus-one { width: 50px; height: 65px; background-position: -75px 0; } .social-buttons .facebook-like { width: 50px; height: 65px; background-position: -145px 0; } */ '); jquery(' Socialite.setup({ facebook: { lang: "ru_RU", appId: 123456789 }, twitter: { lang: "ru" }, googleplus: { lang: "ru-RU" }, vkontakte: { lang: "ru" }, youtube: { lang: "ru-RU" }, }); $("article.text").one("mouseenter", function() { Socialite.load($(this)[0]); }); '); $text = SITE_ADVERT_NAME; $url = WEB_PATH; return ' <article class="text"> <h2>Article Title</h2> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ut suscipit felis. Duis massa lectus, vulputate a condimentum eget, pulvinar eget erat. Aliquam erat volutpat. Integer viverra nunc at metus interdum nec luctus felis dapibus. Cras blandit ipsum vel nibh cursus sed condimentum ante hendrerit. Aliquam pulvinar tincidunt dui quis consequat. Donec erat odio, faucibus ac hendrerit et, iaculis vitae enim. Sed volutpat aliquet tempus. Suspendisse sodales mollis varius. Morbi libero turpis, elementum ac hendrerit ac, lobortis a ligula. In hac habitasse platea dictumst.</p> <p>Praesent euismod tincidunt felis, quis elementum lorem suscipit sed. Ut adipiscing, tortor elementum hendrerit blandit, lorem lectus tempor magna, vitae semper metus turpis ac leo. Nulla in dui sit amet nulla condimentum ornare. Maecenas sed egestas felis. Nulla porta leo sit amet augue ullamcorper rhoncus. Donec sodales, dui luctus sollicitudin scelerisque, dui risus iaculis magna, id ultricies ipsum arcu eu dui. Etiam gravida sagittis nunc, ut molestie enim placerat et. Ut imperdiet sapien nec est pulvinar ullamcorper. Etiam ac risus diam, vitae rutrum diam. Donec et nulla dolor.</p> <ul class="social-buttons cf"> <li><a href="http://twitter.com/share" class="socialite twitter-share" data-text="' . _prepare_html($text) . '" data-url="' . _prepare_html($url) . '" data-count="" rel="nofollow" target="_blank"><span class="vhidden">Share on Twitter</span></a></li> <li><a href="https://plus.google.com/share?url=' . urlencode($url) . '" class="socialite googleplus-one" data-size="" data-href="' . _prepare_html($url) . '" rel="nofollow" target="_blank"><span class="vhidden">Share on Google+</span></a></li>
/** * Returns jquery * * @return Jquery */ public function jquery() { return jquery(); }
</div> <div class="progress"> <div class="progress-bar progress-bar-warning progress-bar-striped active" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%"> Created by<a class="label" style="font-size:14px;" href="https://github.com/AlexBeznos">AlexBeznos</a> </div> </div> <?php echo jquery('1.11.2'); ?> <?php echo js('bootstrap.min.js'); ?> <?php echo js('docs.min.js'); ?> <script> $(document).ready(function() { $('.progress').css('top', $(document).height()); }); </script> </body> </html>
} if (isset($_POST["Niveau3"])) { $niveau = 3; } if (isset($niveau)) { horizontaalZoeken($woordenzoeker, $gesplitst, $niveau); verticaalZoeken($woordenzoeker, $gesplitst, $niveau); } ?> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> <?php jquery($gevondenWoordenCoordinaten, $zoekwoorden); function highlight($text, $words, $color = 'yellow', $case = '1') { $words = trim($words); $wordsArray = explode(' ', $words); foreach ($wordsArray as $word) { if (strlen(trim($word)) != 0) { if ($case) { $text = eregi_replace($word, '<font style="background:' . $color . '";>\\0</font>', $text); } else { $text = ereg_replace($word, '<font style="background:' . $color . '";>\\0</font>', $text); } } } return $text; }
public function test_jquery() { $url = _class('assets')->get_asset('jquery', 'js'); $this->assertNotEmpty($url); $jquery_js = 'var i = 0; $("#id").on("click", ".sub_selector", function(){ return false; });'; $expected_jquery_lib = '<script src="' . $url . '" type="text/javascript"></script>'; $expected_js = '<script type="text/javascript">' . PHP_EOL . '$(function(){' . PHP_EOL . $jquery_js . PHP_EOL . '})' . PHP_EOL . '</script>'; $jquery_result = jquery($jquery_js); $this->assertInstanceOf(get_class(_class('assets')), $jquery_result); $this->assertEquals($expected_jquery_lib . PHP_EOL . $expected_js, _class('assets')->show_js()); $this->assertEmpty(_class('assets')->show_js(), 'Calling output method again should return nothing'); // Second call should avoid adding jquery again $jquery_result = jquery($jquery_js); $this->assertSame(_class('assets'), $jquery_result); $this->assertEquals($expected_jquery_lib . PHP_EOL . $expected_js, _class('assets')->show_js()); $this->assertEmpty(_class('assets')->show_js(), 'Calling output method again should return nothing'); _class('assets')->clean_all(); _class('assets')->ADD_IS_DIRECT_OUT = true; $jquery_result = js('jquery'); $this->assertSame($expected_jquery_lib, $jquery_result); $this->assertEmpty(_class('assets')->show_js(), 'Calling output method again should return nothing'); _class('assets')->clean_all(); $jquery_result = jquery($jquery_js); $this->assertSame($expected_jquery_lib . PHP_EOL . $expected_js, $jquery_result); $this->assertEmpty(_class('assets')->show_js(), 'Calling output method again should return nothing'); _class('assets')->ADD_IS_DIRECT_OUT = false; # _class('assets')->clean_all(); # $jquery_result = js('jquery', 'auto', array('direct_out' => true)); # $this->assertSame( $expected_jquery_lib, $jquery_result ); # $this->assertEmpty( _class('assets')->show_js(), 'Calling output method again should return nothing' ); # _class('assets')->clean_all(); # $jquery_result = jquery($jquery_js, array('direct_out' => true)); # $this->assertSame( $expected_jquery_lib. PHP_EOL. $expected_js, $jquery_result ); # $this->assertEmpty( _class('assets')->show_js(), 'Calling output method again should return nothing' ); }
echo view_port(); echo apple_mobile('black-translucent'); echo $meta; ?> <!-- icons and icons and icons and icons and icons and a tile --> <?php echo windows_tile(array('name' => 'Sport', 'image' => base_url() . '/assets/img/icons/tile.png', 'color' => '#4eb4e5')); echo favicons(); ?> <!-- crayons and paint --> <?php echo add_css(array('frontend_css/reset', 'frontend_css/responsive', 'frontend_css/styles')); echo $css; ?> <!-- magical wizardry --> <?php echo jquery('1.10.2'); ?> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <?php echo shiv(); ?> <?php echo add_js(array('bootstrap.min', 'scripts', 'file/validation/jquery.validate.min', 'file/validation/additional-methods.min')); echo $js; ?> <!--<script id="facebook-jssdk" src="//connect.facebook.net/en_US/all.js" type="text/javascript"></script>-->
/** */ function display_what() { $hooks_data = _class('admin_methods')->call_hooks('settings', $r); $avail_hook_modules = []; foreach ((array) $hooks_data as $k => $v) { list($module_name, ) = explode('___', $k); $avail_hook_modules[$module_name] = $k; } $settings = $this->_get_settings($hooks_data); if (main()->is_post()) { parse_str($_POST['sort'], $tmp); $posted_sort = []; foreach ((array) $tmp['sort'] as $v) { $posted_sort[$v] = $v; } foreach ((array) $settings as $s) { $name = $s['item']; $_n = str_replace('_', '', $name); if (!isset($avail_hook_modules[$name])) { unset($posted_sort[$_n]); continue; } $posted_sort[$_n] = $name; } $to_save = []; foreach ((array) $posted_sort as $_n => $name) { $to_save[$name] = ['item' => $name, 'value' => isset($_POST['check'][$_n]) ? 1 : 0, 'order' => ++$i]; } if ($to_save) { db()->query('TRUNCATE TABLE ' . db('settings')); db()->insert_safe('settings', $to_save); } return js_redirect('/@object/@action'); } jquery(' var container = $("#settings-sortable-container") container.find("ul").sortable(); container.closest("form").on("submit", function(){ $(this).find("input[name=sort][type=hidden]").val( container.find("ul").sortable("serialize", { key: "sort[]" }) ) }); '); $container_html = ' <div class="span6" id="settings-sortable-container"> <ul class="nav nav-pills nav-stacked" id="sortable_settings"> '; foreach ((array) $settings as $s) { $name = $s['item']; if (!isset($avail_hook_modules[$name])) { continue; } $hooks = $hooks_data[$avail_hook_modules[$name]]; $is_checked = $s['value'] ? 1 : 0; $container_html .= '<li class="item" id="liitem_' . str_replace('_', '', $name) . '"><a style="cursor:move;"><i class="icon icon-move fa fa-arrows"></i> ' . t($name) . ' (' . count($hooks) . ')' . ' <input type="checkbox" name="check[' . str_replace('_', '', $name) . ']" value="1" style="float:right;"' . ($is_checked ? ' checked="checked"' : '') . '></a></li>' . PHP_EOL; } $container_html .= ' </ul> </div> '; $a['back_link'] = url('/@object'); return form($a, ['legend' => 'Settings items'])->hidden('sort')->container($container_html, ['wide' => 1])->save_and_back(); }
return function () { asset('gridster'); css(' .gridster { width: 960px; margin: 0 auto; } .gridster .gs-w { background: #FFF; cursor: pointer; -webkit-box-shadow: 0 0 5px rgba(0,0,0,0.3); box-shadow: 0 0 5px rgba(0,0,0,0.3); } .gridster .player { -webkit-box-shadow: 3px 3px 5px rgba(0,0,0,0.3); box-shadow: 3px 3px 5px rgba(0,0,0,0.3); } .gridster .gs-w.try { background-image: url(../img/sprite.png); background-repeat: no-repeat; background-position: 37px -169px; } .gridster .preview-holder { border: none!important; border-radius: 0!important; background: rgba(255,255,255,.2)!important; } .gridster [hidden] { display: none; } .gridster ul, .gridster ol { list-style: none; } '); jquery(' $(".gridster ul").gridster({ widget_margins: [10, 10], widget_base_dimensions: [140, 140], min_cols: 6, resize: { enabled: true } }); '); return ' <div class="gridster"> <ul> <li data-row="1" data-col="1" data-sizex="1" data-sizey="1"></li> <li data-row="2" data-col="1" data-sizex="1" data-sizey="1"></li> <li data-row="3" data-col="1" data-sizex="1" data-sizey="1"></li> <li data-row="1" data-col="2" data-sizex="2" data-sizey="1"></li> <li data-row="2" data-col="2" data-sizex="2" data-sizey="2"></li> <li data-row="1" data-col="4" data-sizex="1" data-sizey="1"></li>
<title><?php if (!empty($title)) { echo $title; } ?> </title> <?php echo chrome_frame(); echo view_port(); echo apple_mobile('black-translucent'); echo $meta; ?> <!-- icons and icons and icons and icons and icons and a tile --> <?php echo windows_tile(array('name' => 'Stencil', 'image' => base_url() . '/assets/img/icons/tile.png', 'color' => '#4eb4e5')); echo favicons(); ?> <!-- crayons and paint --> <?php echo add_css(array('bootstrap.min', 'bootstrap-theme.min.css', 'style')); echo $css; ?> <!-- magical wizardry --> <?php echo jquery(); echo shiv(); echo add_js(array('bootstrap.min')); echo $js;
/** */ function show_files() { $self_page_css = 'body.get-object-' . $_GET['object']; css(' ' . $self_page_css . ' li.li-header { list-style: none; display:none; } ' . $self_page_css . ' li.li-level-0 { display: block; font-size: 15px; } ' . $self_page_css . ' li.li-level-1 { padding-top: 10px; font-size: 13px; } ' . $self_page_css . ' .source_container { width: 90%; height: 400px; } '); jquery(' var self_page = "' . $self_page_css . '"; $(".li-level-0 > a", self_page).before(" <button class=\\"btn btn-mini btn-xs btn-default\\" class=\\"toggle_source\\"><i class=\\"fa fa-toggle-down\\"></i> Toggle source</button> ") $(".li-level-0 .togle_source", self_page).click(function(){ $(".li-level-1", $(this).closest(".li-level-0")).toggle() }) $(".li-level-0", self_page).click(function(){ $(".li-level-1", this).toggle() }) '); $all_langs = (array) $this->_cur_langs; foreach ((array) $all_langs as $lang => $lang_name) { list($lang_vars, $var_files, $lang_files) = $this->_get_vars_from_files($lang); if (!$lang_files) { continue; } $body[] = '<h3>' . html()->icon('bfh-flag-' . $this->lang_def_country[$lang], strtoupper($lang)) . '</h3>'; $body[] = $this->_show_files_for_lang($lang, $lang_files, $var_files); } return implode(PHP_EOL, $body); }
/** */ function view_order() { $_GET['id'] = intval($_GET['id']); if ($_GET['id']) { if ($this->SUPPLIER_ID) { $sql = 'SELECT o.* FROM ' . db('shop_orders') . ' AS o INNER JOIN ' . db('shop_order_items') . ' AS i ON i.order_id = o.id INNER JOIN ' . db('shop_products') . ' AS p ON i.product_id = p.id INNER JOIN ' . db('shop_admin_to_supplier') . ' AS m ON m.supplier_id = p.supplier_id WHERE o.id=' . intval($_GET['id']) . ' AND m.admin_id=' . intval(main()->ADMIN_ID) . ' GROUP BY o.id'; } else { $sql = 'SELECT * FROM ' . db('shop_orders') . ' WHERE id=' . intval($_GET['id']); } $order_info = db()->query_fetch($sql); } if (empty($order_info)) { return _e('No such order'); } $recount_price = false; $_class_price = _class('_shop_price', 'modules/shop/'); $_class_units = _class('_shop_product_units', 'modules/shop/'); $_class_basket = _class('shop_basket', 'modules/shop/'); if (main()->is_post()) { module('manage_shop')->_product_check_first_revision('order', intval($_GET['id'])); $order_id = (int) $_GET['id']; foreach ($_POST as $k => $v) { if ($k == 'status_item') { foreach ($v as $k1 => $status) { list($product_id, $param_id) = explode('_', $k1); db()->UPDATE(db('shop_order_items'), ['status' => $status], ' order_id=' . $_GET['id'] . ' AND product_id=' . intval($product_id) . ' AND param_id=' . intval($param_id)); } } elseif ($k == 'delete') { foreach ($v as $k1 => $is_del) { list($product_id, $param_id) = explode('_', $k1); if ($is_del == 1) { db()->query('DELETE FROM ' . db('shop_order_items') . ' WHERE order_id=' . $_GET['id'] . ' AND product_id=' . intval($product_id) . ' AND param_id=' . intval($param_id)); } } $recount_price = true; } elseif ($k == 'qty') { foreach ($v as $k1 => $qty) { list($product_id, $param_id) = explode('_', $k1); if (intval($qty) == 0) { db()->query('DELETE FROM ' . db('shop_order_items') . ' WHERE order_id=' . $_GET['id'] . ' AND product_id=' . intval($product_id) . ' AND param_id=' . intval($param_id)); } else { db()->UPDATE(db('shop_order_items'), ['quantity' => intval($qty)], ' order_id=' . $_GET['id'] . ' AND product_id=' . intval($product_id) . ' AND param_id=' . intval($param_id)); } $recount_price = true; } } elseif ($k == 'unit') { foreach ($v as $k1 => $unit) { $unit = (int) $unit; list($product_id, $param_id) = explode('_', $k1); $product_id = (int) $product_id; $param_id = (int) $param_id; if ($unit > 0) { $units = $_class_units->get_by_product_ids($product_id); if (isset($units[$product_id][$unit])) { db()->UPDATE(db('shop_order_items'), ['unit' => $unit], ' order_id=' . $order_id . ' AND product_id=' . $product_id . ' AND param_id=' . $param_id); $products = db_get_all('SELECT * FROM ' . db('shop_products') . ' WHERE id = ' . $product_id); $product = $products[$product_id]; list($price) = $_class_price->markup_down($product['price'], $product_id); $item = ['price' => $price, 'unit' => $unit, 'units' => $units[$product_id]]; $price_one = $_class_basket->_get_price_one($item); $item = ['order_id' => $order_id, 'product_id' => $product_id, 'param_id' => $param_id]; $item_price = $item + ['price' => $price_one]; $this->_item_update_price_unit($item_price); $recount_price = true; } } } } elseif ($k == 'price_unit') { foreach ($v as $k1 => $price) { list($product_id, $param_id) = explode('_', $k1); $this->_item_update_price_unit(['price' => $price, 'order_id' => $order_id, 'product_id' => (int) $product_id, 'param_id' => (int) $param_id]); $recount_price = true; } } } $sql = []; foreach (['address', 'phone', 'address', 'house', 'apartment', 'floor', 'porch', 'intercom', 'delivery_price', 'status', 'region', 'discount', 'discount_add', 'delivery_type', 'delivery_id', 'delivery_location'] as $f) { if (isset($_POST[$f])) { $sql[$f] = $_POST[$f]; if ($f == 'delivery_price' && $_POST['delivery_price'] != $order_info['delivery_price']) { $sql['is_manual_delivery_price'] = 1; $order_info['is_manual_delivery_price'] = 1; $order_info['delivery_price'] = $sql['delivery_price']; $recount_price = true; } if ($f == 'discount') { $discount = $_class_price->_number_mysql($sql['discount']); $order_info['discount'] = $discount; $sql['discount'] = $discount; $recount_price = true; } if ($f == 'discount_add') { $discount = $_class_price->_number_mysql($sql['discount_add']); $order_info['discount_add'] = $discount; $sql['discount_add'] = $discount; } if ($f == 'delivery_id') { $value = (int) $sql[$f]; $value = $value > 0 ? $value : $order_info[$f]; $sql[$f] = $value; } if ($f == 'delivery_type') { $value = (int) $sql[$f]; $order_info['payment'] = $value; $sql['payment'] = $value; } } } if (count($sql) > 0) { db()->update_safe(db('shop_orders'), $sql, 'id=' . intval($_GET['id'])); } if ($recount_price) { list($order_info['total_sum'], $order_info['delivery_price']) = $this->_order_recount_price($order_info['id'], $order_info); } module('manage_shop')->_order_add_revision('edit', intval($_GET['id'])); return js_redirect('./?object=' . main()->_get('object') . '&action=view_order&id=' . $order_info['id']); } $products_ids = []; $Q = db()->query('SELECT * FROM ' . db('shop_order_items') . ' WHERE `order_id`=' . intval($order_info['id'])); while ($_info = db()->fetch_assoc($Q)) { if ($_info['product_id']) { $products_ids[$_info['product_id']] = $_info['product_id']; } $order_items[$_info['product_id'] . "_" . $_info['param_id']] = $_info; } if (!empty($products_ids)) { $products_infos = db()->query_fetch_all('SELECT * FROM ' . db('shop_products') . ' WHERE id IN(' . implode(',', $products_ids) . ')'); $products_atts = module('manage_shop')->_get_products_attributes($products_ids); } $price_total = 0; foreach ((array) $order_items as $_info) { $_product = $products_infos[$_info['product_id']]; $_units = []; if (intval($_info['type']) == 1) { $images[0]['thumb'] = _class('_shop_products', 'modules/shop/')->_product_set_image($_info["product_id"], $_product['cat_id'], 'thumb', false); $link = './?object=' . main()->_get('object') . '&action=product_set_edit&id=' . $_info['product_id']; } else { $images = _class('_shop_products', 'modules/shop/')->_product_image($_info["product_id"], false, false); $link = './?object=' . main()->_get('object') . '&action=product_edit&id=' . $_info['product_id']; $_units = $_class_units->get_by_product_ids($_info['product_id']); } $image = $images[0]['thumb'] ?: _class('_shop_categories', 'modules/shop/')->get_icon_url($_product['cat_id'], 'item'); $dynamic_atts = []; if (strlen($_info['attributes']) > 3) { foreach ((array) unserialize($_info['attributes']) as $_attr_id) { $_attr_info = $products_atts[$_info['product_id']][$_attr_id]; $dynamic_atts[$_attr_id] = '- ' . $_attr_info['name'] . ' ' . $_attr_info['value']; $price += $_attr_info['price']; } } $product_id = (int) $_info['product_id']; $param_id = (int) $_info['param_id']; $price_one = tofloat($_info['price']); $quantity = (int) $_info['quantity']; $price_item = $price_one * $quantity; // product unit $unit = (int) $_info['unit']; $units = null; $unit_name = 'шт.'; if ($_units[$product_id]) { $units = $_units[$product_id]; $units[$unit] && ($unit_name = $units[$unit]['title']); } $products[$_info['product_id'] . '_' . $_info['param_id']] = ['product_id' => intval($_info['product_id']), 'param_id' => intval($_info['param_id']), 'param_name' => _class('_shop_product_params', 'modules/shop/')->_get_name_by_option_id($_info['param_id']), 'name' => _prepare_html($_product['name']), 'image' => $image, 'link' => $link, 'unit' => $unit, 'unit_name' => $unit_name, 'units' => $units, 'price_unit' => $price_one, 'price' => $price_item, 'currency' => _prepare_html(module('manage_shop')->CURRENCY), 'quantity' => intval($_info['quantity']), 'details_link' => process_url('./?object=' . main()->_get('object') . '&action=view&id=' . $_product['id']), 'dynamic_atts' => !empty($dynamic_atts) ? implode('<br />' . PHP_EOL, $dynamic_atts) : '', 'status' => module('manage_shop')->_box('status_item', $_info['status']), 'delete' => '']; $price_total += $price_item; } // discount $discount = $order_info['discount']; $discount_add = $order_info['discount_add']; $_discount = $discount; $discount_price = $_class_price->apply_price($price_total, $_discount); $discount_price -= $price_total; $discount_price = $_class_price->_number_round($discount_price); $_discount = $discount_add; $discount_add_price = $_class_price->apply_price($price_total, $_discount); $discount_add_price -= $price_total; $total_price = tofloat($order_info['total_sum']); $replace = my_array_merge($replace, _prepare_html($order_info)); $replace = my_array_merge($replace, ['form_action' => './?object=' . main()->_get('object') . '&action=' . $_GET['action'] . '&id=' . $_GET['id'], 'order_id' => $order_info['id'], 'price_total_info' => module('manage_shop')->_format_price($price_total), 'discount' => $_class_price->_number_format($discount), 'discount_add' => $_class_price->_number_format($discount_add), 'discount_price_info' => $_class_price->_price_format($discount_price), 'discount_add_price_info' => $_class_price->_price_format($discount_add_price), 'delivery_info' => module('manage_shop')->_format_price($order_info['delivery_price']), 'total_sum' => module('manage_shop')->_format_price($total_price), 'user_link' => _profile_link($order_info['user_id']), 'user_name' => _display_name(user($order_info['user_id'])), 'error_message' => _e(), 'products' => (array) $products, 'total_price' => module('manage_shop')->_format_price($total_price), 'ship_type' => module('manage_shop')->_ship_types[$order_info['ship_type']], 'pay_type' => module('manage_shop')->_pay_types[$order_info['pay_type']], 'date' => $order_info['date'], 'status_box' => module('manage_shop')->_box('status', $order_info['status']), 'back_url' => './?object=' . main()->_get('object') . '&action=show_orders', 'print_url' => './?object=' . main()->_get('object') . '&action=show_print&id=' . $order_info['id'], 'payment' => common()->get_static_conf('payment_methods', $order_info['payment'])]); $link_invoice = './?object=manage_shop&action=invoice&id=' . $replace['id']; $link_invoice_add = $link_invoice . '&with_discount_add=y'; $link_pdf_invoice = $link_invoice . '&pdf=y'; $link_pdf_invoice_add = $link_invoice_add . '&pdf=y'; $region = _class('_shop_region', 'modules/shop/')->_get_list(); array_unshift($region, '- регион не выбран -'); $out = form2($replace, ['dd_mode' => 1, 'big_labels' => true])->info('id')->info('price_total_info', ['desc' => 'Сумма'])->row_start(['desc' => 'Скидка, %'])->number('discount', ['desc' => 'Скидка, %'])->info('discount_price_info')->link('Invoice', $link_invoice, ['title' => 'Накладная без учета добавочной скидки', 'icon' => 'fa fa-file-o', 'target' => '_blank'])->link('PDF', $link_pdf_invoice, ['title' => 'Накладная PDF без учета добавочной скидки', 'icon' => 'fa fa-file-text-o', 'target' => '_blank'])->row_end()->row_start(['desc' => 'Скидка добавочная, %'])->number('discount_add', ['desc' => 'Скидка добавочная, %'])->info('discount_add_price_info', ['desc' => ' '])->link(t('Invoice') . '+', $link_invoice_add, ['title' => 'Накладная с учетом добавочной скидки', 'icon' => 'fa fa-file-o', 'target' => '_blank'])->link(t('PDF') . '+', $link_pdf_invoice_add, ['title' => 'Накладная PDF с учетом добавочной скидки', 'icon' => 'fa fa-file-text-o', 'target' => '_blank'])->row_end()->info('delivery_info', ['desc' => 'Доставка'])->info('total_sum', '', ['desc' => 'Итоговая сумма', 'tip' => 'Итоговая сумма без учета добавочной скидки', 'no_escape' => 1])->info_date('date', ['format' => 'full'])->info('name')->email('email')->info('phone')->container('<a href="./?object=' . main()->_get('object') . '&action=send_sms&phone=' . urlencode($replace["phone"]) . '" class="btn">Send SMS</a><br /><br />')->select_box('region', $region, ['desc' => 'Регион доставки', 'class_add_wrapper' => 'region_type_wrap'])->select_box('delivery_type', _class('_shop_delivery', 'modules/shop/')->_get_types(), ['desc' => 'Тип доставки', 'class_add_wrapper' => 'delivery_type_wrap'])->select_box('delivery_id', _class('_shop_delivery', 'modules/shop/')->_get_locations_by_type($replace['delivery_type']), ['class' => 'delivery_id', 'class_add_wrapper' => 'delivery_id_wrap', 'desc' => 'Отделение'])->text('delivery_location', 'Отделение доставки', ['class' => 'delivery_location', 'class_add_wrapper' => 'delivery_location_wrap'])->text('address')->text('house')->text('apartment')->text('floor')->text('porch')->text('intercom')->info('comment')->text('delivery_time')->price('delivery_price')->user_info('user_id')->info('payment', 'Payment method')->info('transaction_id', 'Transaction id')->container(table2($products)->image('product_id', ['width' => '50px', 'no_link' => true, 'web_path' => '', 'img_path_check' => false, 'img_path_callback' => function ($_p1, $_p2, $row) { return $row['image']; }])->func('link', function ($f, $p, $row) { $result = "<a class='btn' href='{$row[link]}'>{$row[product_id]}</a>"; return $result; })->func('name', function ($f, $p, $row) { $row['name'] = $row['name'] . ($row['param_name'] != '' ? "<br /><small>" . $row['param_name'] . "</small>" : ''); return $row['name']; })->func('unit', function ($f, $p, $row) { $values = []; if (!empty($row['units'])) { $values[0] = ' - '; foreach ($row['units'] as $id => $item) { $values[$id] = $item['title']; } } $desc = 'Ед. измерения'; $width = '7em'; $result = sprintf(' <style> .unit_current { width: %s; } </style> <div class="unit_current"> %s <span class="btn btn-mini unit_change"> <i class="icon-edit fa fa-edit"></i> </span> </div> ', $width, $row['unit_name']) . _class('html')->select2_box(['desc' => $desc, 'name' => 'unit[' . $row['product_id'] . '_' . $row['param_id'] . ']', 'values' => $values, 'js_options' => ['width' => $width, 'containerCssClass' => 'select2_box']]); return $result; })->func('quantity', function ($f, $p, $row) { $row['quantity'] = "<input type='text' name='qty[" . $row['product_id'] . "_" . $row['param_id'] . "]' value='" . intval($row['quantity']) . "' style='width:50px;'>"; return $row['quantity']; })->func('price_unit', function ($f, $p, $row) { $row['price_unit'] = "<input type='text' name='price_unit[" . $row['product_id'] . "_" . $row['param_id'] . "]' value='" . $row['price_unit'] . "' style='width:100px;'>"; return $row['price_unit']; })->text('price')->func('status', function ($f, $p, $row) { $row['status'] = str_replace("status_item", "status_item[" . $row['product_id'] . "_" . $row['param_id'] . "]", $row['status']); return $row['status']; })->func('delete', function ($f, $p, $row) { $row['delete'] = "<input type='checkbox' name='delete[" . $row['product_id'] . "_" . $row['param_id'] . "]' value='1'>"; return $row['delete']; }), ['wide' => 1])->container(tpl()->parse('manage_shop/product_search_order', ['order_id' => $_GET['id']]), 'Add product')->box('status_box', 'Status order', ['selected' => $order_info['status']])->save_and_back(); // misc handlers css(' .select2_box { display: none; } .unit_current { position : relative; } .btn.unit_change { display : none; position : absolute; right : 0; } '); jquery(' $(".delivery_id").on( "change", function( event ) { var location = $(this).find( "option:selected" ).text(); $(".delivery_location").val( location ); }); var delivery_type__on_change = function( target ) { var value = +$(target).find( "option:selected" ).val(); if( value == 1 ) { $(".delivery_id_wrap").hide(); $(".delivery_location_wrap").hide(); } else if( value == 2 ) { var count = +$(".delivery_id_wrap").find( "option" ).length; if( count > 1 ) { $(".delivery_id_wrap").show(); $(".delivery_location_wrap").show(); } } } delivery_type__on_change( $(".delivery_type_wrap") ); $(".delivery_type_wrap").on( "change", function( event ) { delivery_type__on_change( event.target ); }); $( ".unit_change" ).on( "click", function( event ) { var $this = $( this ); var $select2 = $this.parent().next(); $select2.toggle() }).each( function( i ) { var $this = $( this ); if( $this.parent().next().length ) { $this.show(); } }); '); // get similar orders $sql = "SELECT o.*, COUNT(*) AS num_items FROM `" . db('shop_orders') . "` AS `o`\n\t\t\t\tINNER JOIN " . db('shop_order_items') . " AS i ON i.order_id = o.id\n\t\t\t\tWHERE `o`.`id`!='" . $order_info['id'] . "'\n\t\t\t\t\tAND `o`.`phone`='" . $order_info['phone'] . "'\n\t\t\t\t\tAND `o`.`status`='" . $order_info['status'] . "'\n\t\t\t\tGROUP BY o.id ORDER BY o.id DESC"; $out .= "<br /><br /><h3>" . t('Similar orders') . "</h3>" . table($sql)->text('id')->date('date', ['format' => 'full', 'nowrap' => 1])->user('user_id')->text('name')->text('phone')->text('total_sum', ['nowrap' => 1])->text('num_items')->btn_edit('', './?object=' . main()->_get('object') . '&action=view_order&id=%d', ['no_ajax' => 1])->btn('Merge', './?object=' . main()->_get('object') . '&action=merge_order&id=' . $order_info['id'] . '&merge_id=%d', ['no_ajax' => 1]); // $out .= tpl()->parse('manage_shop/product_search',array()); return $out; }
/** */ function date_picker($name, $cur_date = '') { js('jquery-ui'); css('jquery-ui'); jquery('$(".datepicker").datepicker({ dateFormat: "yy-mm-dd" });'); css('//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.4/css/jquery.ui.datepicker.min.css'); $extra['id'] = $extra['id'] ?: __FUNCTION__ . '_' . ++$this->_ids[__FUNCTION__]; // TODO: use input() unified control return '<input type="text" name="' . $name . '" class="datepicker" value="' . $cur_date . '" style="width:80px" readonly="true" id="' . $extra['id'] . '" />'; }
/** */ function phone_box($name = '', $extra = [], $replace = []) { if (is_array($name)) { $extra = (array) $extra + $name; } else { $extra['name'] = $name; } if (!$extra['name']) { $name = $extra['name'] = 'phone'; } $func = function ($extra, $r, $form) { asset('jquery-formvalidation'); jquery(' var yf_phone_callback = function(value, validator, $field) { var isValid = value === "" || $field.intlTelInput("isValidNumber"), err = $field.intlTelInput("getValidationError"), message = null; switch (err) { case intlTelInputUtils.validationError.INVALID_COUNTRY_CODE: message = "' . t('The country code is not valid') . '"; break; case intlTelInputUtils.validationError.TOO_SHORT: message = "' . t('The phone number is too short') . '"; break; case intlTelInputUtils.validationError.TOO_LONG: message = "' . t('The phone number is too long') . '"; break; case intlTelInputUtils.validationError.NOT_A_NUMBER: message = "' . t('The value is not a number') . '"; break; default: message = "' . t('The phone number is not valid') . '"; break; } return { valid: isValid, message: message }; } var form = $("#' . addslashes($extra['name']) . '").closest("form") form.formValidation({ framework: "bootstrap", fields: { "' . addslashes($extra['name']) . '": { validators: { callback: { callback: yf_phone_callback, } } } } }) // Revalidate the number when changing the country .on("click", ".country-list", function() { form.formValidation("revalidateField", "' . addslashes($extra['name']) . '"); }); '); $form->_prepare_inline_error($extra); $extra['edit_link'] = $extra['edit_link'] ? isset($r[$extra['edit_link']]) ? $r[$extra['edit_link']] : $extra['edit_link'] : ''; $extra['selected'] = $form->_prepare_selected($extra['name'], $extra, $r); $extra['value'] =& $extra['selected']; $extra['id'] = $extra['id'] ?: $extra['name']; $extra = $form->_input_assign_params_from_validate($extra); $content = _class('html')->phone_box($extra); if ($extra['no_label'] || $form->_params['no_label']) { $extra['desc'] = ''; } if ($extra['hide_empty'] && !strlen($content)) { return ''; } return $form->_row_html($content, $extra, $r); }; if ($this->_chained_mode) { $this->_body[] = ['func' => $func, 'extra' => $extra, 'replace' => $replace, 'name' => __FUNCTION__]; return $this; } return $func((array) $extra + (array) $this->_extra, (array) $replace + (array) $this->_replace, $this); }
/** */ function ui_range($name, $desc = '', $extra = [], $replace = [], $form) { if (is_array($desc)) { $extra += $desc; $desc = ''; } $extra['name'] = $extra['name'] ?: $name; $extra['min'] = $extra['min'] ?: 1; $extra['max'] = $extra['max'] ?: 500; $extra['max'] = $extra['max'] ?: 500; $extra['step'] = $extra['step'] ?: 1; $extra['value_min'] = $extra['value_min'] ?: $extra['min']; $extra['value_max'] = $extra['value_max'] ?: $extra['max']; $extra['value'] = $extra['value_min'] ?: '75'; $extra['orientation'] = $extra['orientation'] ?: 'horizontal'; //horizontal", "vertical". $extra['range'] = isset($extra['range']) ? $extra['range'] : 'true'; // true , false, min, max $extra['animate'] = isset($extra['animate']) ? $extra['animate'] : 'false'; // boolean, string("slow", "normal", "fast), int $extra['disabled'] = isset($extra['disabled']) ? $extra['disabled'] : 'false'; // boolean $extra['hidden_inputs'] = isset($extra['hidden_inputs']) ? $extra['hidden_inputs'] : true; $extra['create_inputs'] = isset($extra['create_inputs']) ? $extra['create_inputs'] : true; // range can be true , false, min, max if ($extra['range'] === true) { $extra['range'] = 'true'; } elseif ($extra['range'] === false) { $extra['range'] = 'false'; } elseif (in_array($extra['range'], ["min", "max"])) { $extra['range'] = '"' . $extra['range'] . '"'; } if ($extra['disabled'] === false) { $extra['disabled'] = 'false'; } elseif ($extra['disabled'] === true) { $extra['disabled'] = 'true'; } // boolean, string("slow", "normal", "fast), int if ($extra['animate'] === false) { $extra['animate'] = 'false'; } elseif ($extra['animate'] === true) { $extra['animate'] = 'true'; } elseif (in_array($extra['animate'], ["slow", "normal", "fast"])) { $extra['animate'] = '"' . $extra['animate'] . '"'; } if ($extra['range'] == 'true') { $extra['values'] = 'values: [ ' . $extra['value_min'] . ', ' . $extra['value_max'] . ' ], '; $extra['feedback'] = ' $("input#' . $extra['name'] . '").on("change", function() { // $("input#' . $extra['name'] . '").on("keyup change", function() { var value1 = $("input#' . $extra['name'] . '").val(); var value2 = $("input#' . $extra['name'] . '_and").val(); if (value1 < ' . $extra['min'] . ') { value1 = ' . $extra['min'] . '; $("input#' . $extra['name'] . '").val(value1) } if(parseInt(value1) > parseInt(value2)){ value1 = value2; $("input#' . $extra['name'] . '").val(value1); } $("#slider-' . $extra['name'] . '").slider("values",0,value1); }); // $("input#' . $extra['name'] . '_and").on("keyup change", function() { $("input#' . $extra['name'] . '_and").on("change", function() { var value1 = $("input#' . $extra['name'] . '").val(); var value2 = $("input#' . $extra['name'] . '_and").val(); if (value2 > ' . $extra['max'] . ') { value2 = ' . $extra['max'] . '; $("input#' . $extra['name'] . '_and").val(value2) } if(parseInt(value1) > parseInt(value2)){ value2 = value1; $("input#' . $extra['name'] . '_and").val(value2); } $("#slider-' . $extra['name'] . '").slider("values",1,value2); }); '; } else { $extra['values'] = 'value: ' . $extra['value_min'] . ' , '; $extra['feedback'] = ' $("input#' . $extra['name'] . '").on("change", function() { // $("input#' . $extra['name'] . '").on("keyup change", function() { var value = $("input#' . $extra['name'] . '").val(); if (value < ' . $extra['min'] . ') { value = ' . $extra['min'] . '; $("input#' . $extra['name'] . '").val(value) } $("#slider-' . $extra['name'] . '").slider("value",value); }); '; //$extra['values'] = 'value: [ '.$extra['value_min'].' ], '; // $values = 'value: '.$extra['value_min'].' ], } //events: $extra['start_event'] = $extra['start_event'] ? 'start: function( event, ui ) {' . $extra['start_event'] . ' },' : ''; $extra['create_event'] = $extra['create_event'] ? 'create: function( event, ui ) {' . $extra['create_event'] . '},' : ''; $extra['slide_event'] = $extra['slide_event'] ? 'slide: function( event, ui ) {' . $extra['slide_event'] . '},' : ''; $extra['change_event'] = $extra['change_event'] ? 'chsnge: function( event, ui ) {' . $extra['change_event'] . '},' : ''; $extra['stop_event'] = $extra['stop_event'] ? 'stop: function( event, ui ) {' . $extra['stop_event'] . '},' : ''; $extra['desc'] = $form->_prepare_desc($extra, $desc); $func = function ($extra, $r, $form) { // TODO: upgrade look and feel and connect $field__and for filter $form->_prepare_inline_error($extra); asset('jquery-ui'); jquery(' $( "#slider-' . $extra['name'] . '" ).slider({ range: ' . $extra['range'] . ', min: ' . $extra['min'] . ', max: ' . $extra['max'] . ', disabled: ' . $extra['disabled'] . ', orientation: "' . $extra['orientation'] . '", animate: ' . $extra['animate'] . ', ' . $extra['values'] . ' ' . $extra['start_event'] . ' ' . $extra['create_event'] . ' ' . $extra['slide_event'] . ' ' . $extra['change_event'] . ' ' . $extra['stop_event'] . ' }); ' . $extra['feedback'] . ' // $( "#amount" ).val( "$" + $( "#slider-range" ).slider( "values", 0 ) + // " - $" + $( "#slider-range" ).slider( "values", 1 ) ); '); $inputs = ''; if ($extra['create_inputs']) { $hide = $extra['hidden_inputs'] ? ' type="hidden"' : 'type="text"'; $inputs = '<input ' . $hide . ' id="' . $extra['name'] . '" name="' . $extra['name'] . '" value="' . $extra['value_min'] . '" />'; if ($extra['range']) { $inputs .= '<input ' . $hide . ' id="' . $extra['name'] . '_and" name="' . $extra['name'] . '_and" value="' . $extra['value_max'] . '" />'; } } $body = ' <div class="span10"> <div class="ui-slider " id="slider-' . $extra['name'] . '"></div> </div> ' . $inputs . ' '; return $form->_row_html($body, $extra, $r); }; if ($form->_chained_mode) { $form->_body[] = ['func' => $func, 'extra' => $extra, 'replace' => $replace, 'name' => __FUNCTION__]; return $form; } return $func($extra, $replace, $form); }
/** * Daterange picker http://www.daterangepicker.com/#examples */ function daterange_select($name = '', $desc = '', $extra = [], $replace = [], $form) { if (is_array($desc)) { $extra += $desc; $desc = ''; } if (!is_array($extra)) { $extra = []; } $extra['name'] = $extra['name'] ?: ($name ?: 'date'); $extra['desc'] = $form->_prepare_desc($extra, $desc); /* $extra['limit_date_format'] = $extra['limit_date_format'] ? $extra['limit_date_format'] : 'm/d/Y H:i'; $format = $format_php = $placeholder = array(); $extra['no_time'] = $extra['with_time'] ? !$extra['with_time'] : $extra['no_time']; $extra['no_time'] = isset( $extra['no_time'] ) ? $extra['no_time'] : 1; if ($extra['no_date'] != 1) { $format_js[] = !empty($extra['date_format_js']) ? $extra['date_format_js'] : 'DD.MM.YYYY'; $format_php[] = !empty($extra['date_format_php']) ? $extra['date_format_php'] : 'd.m.Y'; $placeholder[] = !empty($extra['date_placeholder']) ? $extra['date_placeholder'] : 'ДД.ММ.ГГГГ'; } if ($extra['no_time'] != 1) { $format_js[] = !empty($extra['time_format_js']) ? $extra['time_format_js'] : 'HH:mm'; $format_php[] = !empty($extra['time_format_php']) ? $extra['time_format_php'] : 'H:i'; $placeholder[] = !empty($extra['time_placeholder']) ? $extra['time_placeholder'] : 'ЧЧ:ММ'; } $_format_js = implode(' ', $format_js); $_format_php = implode(' ', $format_php); $_placeholder = implode(' ', $placeholder); */ $extra['placeholder'] = $extra['placeholder'] ?: $_placeholder; // Compatibility with filter if (!strlen($extra['value'])) { if (isset($extra['selected'])) { $value = $extra['selected']; } elseif (isset($form->_params['selected'])) { $value = $form->_params['selected'][$extra['name']]; } elseif (isset($form->_replace[$extra['name']])) { $value = $form->_replace[$extra['name']]; } $extra['value'] = empty($value) || $value == '0000-00-00 00:00:00' ? null : strtotime($value); } $extra['value'] = empty($extra['value']) ? '' : date($_format_php, $extra['value']); asset('bootstrap-daterangepicker'); jquery('$("input#' . $extra['name'] . '").daterangepicker({ format: "' . ($extra['format'] ?: 'DD.MM.YYYY') . '", minDate: "' . $extra['min_date'] . '", maxDate: "' . $extra['max_date'] . '", startDate: "' . ($extra['start_date'] ?: $extra['min_date']) . '", endDate: "' . ($extra['end_date'] ?: $extra['max_date']) . '", ranges: { "' . t('Today') . '": [moment(), moment()], "' . t('Yesterday') . '": [moment().subtract(1, "days"), moment().subtract(1, "days")], "' . t('Last 7 Days') . '": [moment().subtract(6, "days"), moment()], "' . t('Last 30 Days') . '": [moment().subtract(29, "days"), moment()], "' . t('This Month') . '": [moment().startOf("month"), moment().endOf("month")], "' . t('Last Month') . '": [moment().subtract(1, "month").startOf("month"), moment().subtract(1, "month").endOf("month")] } });'); $extra['type'] = 'text'; $extra['class_add'] = 'input-medium'; // daterangepicker'; $extra['prepend'] = isset($extra['prepend']) ? $extra['prepend'] : '<i class="' . $form->CLASS_ICON_CALENDAR . '"></i>'; return $form->input($extra['name'], $extra['desc'], $extra, $replace); }
/** */ function edit_item() { // TODO: save file revision to db on each save if (!empty($_GET['id'])) { $file_name = urldecode($_GET['id']); $file_path = $file_name; $dir_name = dirname($file_path); } else { foreach ((array) $_REQUEST as $k => $v) { $tmp = substr($k, 0, 2); if ($tmp == 'd_' || $tmp == 'f_') { $name = $v; break; } } $dir_name = urldecode($_REQUEST['dir_name']); $file_name = str_replace("\\", '/', $dir_name . '/' . $name); $file_path = $file_name; } if (main()->is_post()) { $file_name = urldecode($_GET['file_name']); file_put_contents($file_name, $_POST['file_text_hidden']); return js_redirect('/@object/show/' . urlencode($_GET['dir_name'])); } $_tmp_array = []; $tmp_path = '/'; foreach ((array) explode('/', dirname($file_name)) as $_folder) { if ($_folder) { $tmp_path .= $_folder . '/'; $_tmp_array[] = a('/@object/show/' . urlencode($tmp_path), $_folder); } } if ($_tmp_array) { $file_name = '/' . implode('/', $_tmp_array) . '/' . _prepare_html(basename($file_name), 0); } $file_text = _prepare_html(file_get_contents($file_path), 0); $replace = ['form_action' => url('/@object/@action/' . urlencode($file_path)), 'back_link' => url('/@object/show/' . urlencode($_REQUEST['dir_name']))]; $div_id = 'editor_html'; $hidden_id = 'file_text_hidden'; $ace_mode = common()->get_file_ext($file_path); $ace_mode == 'stpl' && ($ace_mode = 'html'); jquery(' var h = $(window).height() - $(".navbar").height() - $("h4").height() * 2 - $("[type=submit]").height() * 5 $("#' . $div_id . '").height(h); '); return '<h4>Edit: ' . $file_name . '</h4>' . form($replace, ['data-onsubmit' => '$(this).find("#' . $hidden_id . '").val( $("#' . $div_id . '").data("ace_editor").session.getValue() );'])->container('<div id="' . $div_id . '" style="width: 100%; min-height: 500px;">' . $file_text . '</div>', '', ['id' => $div_id, 'wide' => 1, 'ace_editor' => ['mode' => $ace_mode, 'hScrollBarAlwaysVisible' => false, 'vScrollBarAlwaysVisible' => false]])->hidden($hidden_id)->save_and_back(); }
/** * Datetimepicker, src: http://tarruda.github.io/bootstrap-datetimepicker/ * params : no_date // no date picker * no_time // no time picker * min_date // min available date */ function datetime_select($name = '', $desc = '', $extra = [], $replace = [], $form) { if (is_array($desc)) { $extra += $desc; $desc = ''; } if (!is_array($extra)) { $extra = []; } $extra['name'] = $extra['name'] ?: ($name ?: 'date'); $extra['desc'] = $form->_prepare_desc($extra, $desc); $extra['limit_date_format'] = $extra['limit_date_format'] ? $extra['limit_date_format'] : 'm/d/Y H:i'; $format = $format_php = $placeholder = []; $extra['no_time'] = $extra['with_time'] ? !$extra['with_time'] : $extra['no_time']; $extra['no_time'] = isset($extra['no_time']) ? $extra['no_time'] : 1; if ($extra['no_date'] != 1) { $format_js[] = !empty($extra['date_format_js']) ? $extra['date_format_js'] : 'DD.MM.YYYY'; $format_php[] = !empty($extra['date_format_php']) ? $extra['date_format_php'] : 'd.m.Y'; $placeholder[] = !empty($extra['date_placeholder']) ? $extra['date_placeholder'] : 'ДД.ММ.ГГГГ'; } if ($extra['no_time'] != 1) { $format_js[] = !empty($extra['time_format_js']) ? $extra['time_format_js'] : 'HH:mm'; $format_php[] = !empty($extra['time_format_php']) ? $extra['time_format_php'] : 'H:i'; $placeholder[] = !empty($extra['time_placeholder']) ? $extra['time_placeholder'] : 'ЧЧ:ММ'; } $_format_js = implode(' ', $format_js); $_format_php = implode(' ', $format_php); $_placeholder = implode(' ', $placeholder); $extra['placeholder'] = $extra['placeholder'] ?: $_placeholder; // Compatibility with filter if (!strlen($extra['value'])) { if (isset($extra['selected'])) { $value = $extra['selected']; } elseif (isset($form->_params['selected'])) { $value = $form->_params['selected'][$extra['name']]; } elseif (isset($form->_replace[$extra['name']])) { $value = $form->_replace[$extra['name']]; } $extra['value'] = empty($value) || $value == '0000-00-00 00:00:00' ? null : strtotime($value); } $extra['value'] = empty($extra['value']) ? '' : date($_format_php, $extra['value']); $debug_picker = isset($extra['debug_picker']) ? $extra['debug_picker'] : !MAIN_TYPE_ADMIN && (bool) @constant('DEBUG_MODE'); asset('bootstrap-datetimepicker'); jquery(' $("#' . $extra['name'] . '").datetimepicker({ locale: "' . conf('language') . '" , icons: { time: "icon icon-time fa fa-clock-o", date: "icon icon-calendar fa fa-calendar", up: "icon icon-arrow-up fa fa-arrow-up", down: "icon icon-arrow-down fa fa-arrow-down" } ' . ($extra['min_date'] ? ', minDate: \'' . date($extra['limit_date_format'], $extra['min_date']) . '\'' : '') . ($extra['max_date'] ? ', maxDate: \'' . date($extra['limit_date_format'], $extra['max_date']) . '\'' : '') . ($extra['default_date'] ? ', defaultDate: \'' . date($extra['limit_date_format'], $extra['default_date']) . '\'' : '') . ($extra['side_by_side'] && $extra['no_time'] != 1 ? ', sideBySide: true' : '') . ($extra['stepping'] ? ', stepping: ' . $extra['stepping'] : '') . ($extra['widgetPositioning'] ? ', widgetPositioning: ' . $extra['widgetPositioning'] : '') . ($debug_picker ? ', debug: true' : '') . ' }); '); $extra['data-date-format'] = $_format_js; $extra['type'] = 'text'; $extra['class_add'] = 'input-medium datetimepicker'; $extra['prepend'] = isset($extra['prepend']) ? $extra['prepend'] : '<i class="' . $form->CLASS_ICON_CALENDAR . '"></i>'; return $form->input($extra['name'], $extra['desc'], $extra, $replace); }