/** */ 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)]); }
public function test_strings() { $sentence = 'пользователь должен быть у Вас в друзьях а Вы у него'; $testcase = ['tHe QUIcK bRoWn' => 'QUI', 'frànçAIS' => 'çAI', 'über-åwesome' => '-åw']; foreach ((array) $testcase as $input => $output) { $this->assertEquals(_substr($input, 4, 3), $output); } $this->assertEquals(_truncate($sentence, 10), 'пользовате'); $this->assertEquals(_truncate($sentence, 15, true), 'пользователь'); $this->assertEquals(_truncate($sentence, 15, true, true), 'пользовател...'); }
/** */ function _show_for_lang($lang) { $_GET['page'] = $lang; // Needed for html()->tree links $all = $this->_get_items($lang); $items = []; foreach ($all as $a) { $items[$a['id']] = ['parent_id' => $a['parent_id'], 'name' => _truncate($a['title'], 60, true, '...'), 'link' => url('/@object/edit/' . $a['id'] . '/@page'), 'active' => $a['active']]; } return html()->tree($items, ['form_action' => url('/@object/save/@id/@page'), 'draggable' => true, 'class_add' => 'no_hide_controls', 'back_link' => '', 'add_link' => url('/@object/add/@id/@page'), 'add_no_ajax' => true, 'no_expand' => true, 'opened_levels' => 10, 'show_controls' => function ($id, $item) { $form = form_item($item + ['add_link' => url('/@object/add/' . $id . '/@page'), 'edit_link' => url('/@object/edit/' . $id . '/@page'), 'delete_link' => url('/@object/delete/' . $id . '/@page'), 'active_link' => url('/@object/active/' . $id . '/@page')]); return implode(PHP_EOL, [$form->tbl_link_add(['hide_text' => 1, 'no_ajax' => 1]), $form->tbl_link_edit(['hide_text' => 1, 'no_ajax' => 1]), $form->tbl_link_delete(['hide_text' => 1, 'no_ajax' => 1]), $form->tbl_link_active()]); }]); }
/** */ function edit() { $a = $this->_get_info(); if (!$a) { return _404(); } $a['redirect_link'] = url('/@object/@action/@id'); $a['back_link'] = url('/@object'); // Prevent execution of template tags when editing page content $exec_fix = ['{' => '{', '}' => '}']; $keys_to_fix = ['head_text', 'full_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)->validate(['__before__' => 'trim', 'title' => 'required', 'head_text' => 'required', 'full_text' => 'required', 'url' => 'required', 'locale' => 'required'])->on_post(function () { if (strlen($_POST['url'])) { $_POST['url'] = preg_replace('~[\\s/]+~', '-', trim($_POST['url'])); } if (strlen($_POST['title']) && !strlen($_POST['url'])) { $_POST['url'] = common()->_propose_url_from_name($_POST['title']); } else { if (!strlen($_POST['head_text']) && strlen($_POST['full_text'])) { $_POST['head_text'] = _truncate($_POST['full_text'], 200, false, false); } } })->update_if_ok(self::table, ['title', 'head_text', 'full_text', 'meta_keywords', 'meta_desc', 'url', 'active', 'locale'])->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(['news updated: ' . $a['id'], $a['id']]); })->text('title')->textarea('head_text', ['cols' => 200, 'rows' => 5, 'ckeditor' => ['config' => _class('admin_methods')->_get_cke_config()]])->textarea('full_text', ['cols' => 200, 'rows' => 20, 'ckeditor' => ['config' => _class('admin_methods')->_get_cke_config()]])->text('url')->text('meta_keywords')->text('meta_desc')->locale_box('locale')->active_box()->save_and_back(); }
<a href="<?php echo site_url("project/view/" . $story->storyID); ?> "> <div class="title"> <?php echo h($story->title); ?> </div> <div class="date"> <?php echo h(_date_format($story->createDate)); ?> </div> <div class="caption"> </div> <div class="desc"><?php echo _truncate(strip_tags($story->content), 80); ?> </div> </a> </div> </div> <?php } ?> <?php for ($ind = 0; $ind < 0; ++$ind) { ?> <div class="item"> <div class="item-image"> <div class="item-image-content"> <div class="tags">
/** * Meta tags injection */ function _hook_meta($meta = []) { $a = $this->_current; if ($a) { $desc = _truncate($a['meta_desc'], 250); $url = url('/@object/show/' . ($a['url'] ?: $a['id'])); $meta = ['keywords' => $a['meta_keywords'], 'news_keywords' => $a['meta_keywords'], 'description' => $desc, 'og:description' => $desc, 'og:title' => $a['title'], 'og:type' => 'article', 'og:url' => $url, 'og:site_name' => SITE_ADVERT_NAME, 'canonical' => $url, 'article:published_time' => date('Y-m-d', $a['add_date'])] + (array) $meta; } return $meta; }
/** * */ function view_unread() { if (empty(main()->USER_ID)) { return; } $OBJ = module('unread'); if (is_object($OBJ)) { $ids = $OBJ->_get_unread('comments'); } $BB_CODES_OBJ = _class('bb_codes'); if (!empty($ids)) { $sql = 'SELECT text,object_name,id,object_id FROM ' . db('comments') . ' WHERE id IN(' . implode(',', (array) $ids) . ')'; $order_sql = ' ORDER BY add_date DESC'; list($add_sql, $pages, $total) = common()->divide_pages($sql); $Q = db()->query($sql . $order_sql . $add_sql); while ($A = db()->fetch_assoc($Q)) { $A['text'] = _truncate($A['text'], 50, true); $A['text'] = $BB_CODES_OBJ->_force_close_bb_codes($A['text']); $A['text'] = $this->_format_text($A['text']) . ' ...'; $OBJ = module($A['object_name']); if (is_object($OBJ)) { $action = $OBJ->_comments_params['return_action']; $A['action'] = $action; } $comments_info[$A['id']] = $A; } } $replace = ['items' => $comments_info, 'pages' => $pages]; return tpl()->parse($_GET['object'] . '/unread', $replace); }
<div class="activity-content article-content"> <a href="<?php echo site_url("project/view/" . $act->storyID); ?> "> <div class="title"> <?php echo h($act->title); ?> </div> <div class="date"> <?php echo _date_format($act->createDate); ?> </div> <div class="desc"><?php echo _truncate(strip_tags($act->intro), 60); ?> </div> </a> </div> </div> <?php } ?> <?php for ($ind = 0; $ind < 0; ++$ind) { ?> <div class="activity"> <div class="activity-image"> <div class="activity-image-content"> <div class="tags">
/** * Currently designed only for admin usage */ function user($name = '', $extra = []) { if (is_array($name)) { $extra = (array) $extra + $name; $name = ''; } if (!is_array($extra)) { $extra = []; } $name = $extra['name'] ?: $name; if (!$extra['link']) { $extra['link'] = url_admin('/members/edit/%d'); } $func_name = __FUNCTION__; $this->on_before_render(function ($p, $data, $table) use($name, $extra, $func_name) { if (!$data) { return false; } $field = $name; $user_ids = []; foreach ((array) $data as $a) { $id = $a[$field]; if (!$id) { continue; } if (is_numeric($id)) { $id && ($user_ids[$id] = $id); } elseif (is_array($id)) { foreach ((array) $id as $_id) { $_id && ($user_ids[$_id] = $_id); } } elseif (false !== strpos($id, ',')) { foreach (explode(',', $id) as $_id) { $_id = (int) trim($_id); $_id && ($user_ids[$_id] = $_id); } } } if (!$user_ids) { return false; } foreach ((array) from('user')->whereid(array_keys($user_ids))->all('id,name,login,email,phone,active') as $a) { $table->_data_for_func[$func_name][$a['id']] = $a; } }); return $this->func($name, function ($id, $e, $a, $p, $table) use($func_name) { if (!$id) { return false; } $out = []; $user_ids = []; if (is_numeric($id)) { $user_ids[$id] = $id; } elseif (is_array($id)) { foreach ((array) $id as $_id) { $_id && ($user_ids[$_id] = $_id); } } elseif (false !== strpos($id, ',')) { foreach (explode(',', $id) as $_id) { $_id = (int) trim($_id); $_id && ($user_ids[$_id] = $_id); } } foreach ((array) $user_ids as $id) { if (!isset($table->_data_for_func[$func_name][$id])) { $out[$id] = $id; continue; } $u = $table->_data_for_func[$func_name][$id]; $uname = $u['login'] ?: $u['name'] ?: $u['email'] ?: $u['phone']; $out[$id] = a(str_replace('%d', $id, $e['extra']['link']), _truncate($uname, 50) . ' [' . $id . ']', 'fa fa-user'); } return implode(PHP_EOL, $out); }, $extra); }