function grid_comments_list($controller) { $options = array('is_sortable' => true, 'is_filter' => true, 'is_pagination' => true, 'is_draggable' => false, 'order_by' => 'date_pub', 'order_to' => 'desc', 'show_id' => true); $columns = array('id' => array('title' => 'id', 'width' => 30), 'date_pub' => array('title' => LANG_DATE, 'width' => 110, 'handler' => function ($value, $item) { return html_date($value, true); }, 'filter' => 'date'), 'target_id' => array('title' => LANG_COMMENTS_TEXT, 'handler' => function ($value, $row) use($controller) { return '<a title="' . LANG_COMMENTS_EDIT_TEXT . '" class="ajax-modal comment_text_edit" href="' . href_to($controller->root_url, 'text_edit', array($row['id'])) . '">' . string_short($row['content_html'], 350) . '</a>'; }), 'user_id' => array('title' => LANG_AUTHOR, 'width' => 180, 'handler' => function ($value, $row) { if ($row['user_id']) { $v = '<a target="_blank" href="' . href_to('users', $row['user_id']) . '">' . $row['user_nickname'] . '</a>'; } else { $v = '<span class="guest_name">' . $row['author_name'] . '</span>'; if (!empty($row['author_email'])) { $v .= '<span>, ' . $row['author_email'] . '</span>'; } } return $v; }), 'author_url' => array('title' => LANG_COMMENTS_IP, 'width' => 120, 'filter' => 'like', 'handler' => function ($value) { if ($value) { return '<a href="#" class="ajaxlink filter_ip tooltip" title="' . LANG_CP_USER_FIND_BYIP . '">' . $value . '</a> <a class="view_target tooltip" href="https://apps.db.ripe.net/search/query.html?searchtext=' . $value . '#resultsAnchor" target="_blank" title="' . LANG_CP_USER_RIPE_SEARCH . '"></a>'; } return ''; }), 'rating' => array('title' => LANG_RATING, 'width' => 50, 'handler' => function ($value, $row) { return '<span class="' . html_signed_class($value) . '">' . html_signed_num($value) . '</span>'; }, 'filter' => 'exact'), 'is_deleted' => array('title' => LANG_COMMENTS_IS_DELETED, 'flag' => 'flag_lock', 'flag_toggle' => href_to($controller->root_url, 'toggle_item', array('{id}', 'comments', 'is_deleted')), 'width' => 50, 'filter' => 'exact'), 'is_approved' => array('title' => LANG_MODERATION, 'flag' => true, 'width' => 50, 'filter' => 'exact', 'handler' => function ($value, $item) { if (!$item['is_approved']) { return '<div class="flag_trigger flag_off"><span><a class="approve_comment" title="' . LANG_COMMENTS_APPROVE . '" href="#" data-approve-url="' . href_to('comments', 'approve') . '?id=' . $item['id'] . '"></a></span></div>'; } return '<div class="flag_trigger flag_on"></div>'; }), 'is_private' => array('title' => LANG_COMMENTS_IS_PRIVATE, 'flag' => true, 'width' => 50, 'filter' => 'exact')); $actions = array(array('title' => LANG_COMMENTS_VIEW, 'class' => 'view tooltip', 'href' => href_to('{target_url}', '#comment_{id}')), array('title' => LANG_DELETE, 'class' => 'delete', 'href' => href_to($controller->root_url, 'comments_delete', array('{id}')), 'confirm' => LANG_COMMENTS_DELETE_CONFIRM)); return array('options' => $options, 'columns' => $columns, 'actions' => $actions); }
public function parseTeaser($value) { $max_len = $this->getOption('teaser_len'); if ($max_len) { $url = href_to($this->item['ctype']['name'], $this->item['slug'] . ".html"); $value = string_short($value, $max_len); $value .= '<a class="read-more" href="' . $url . '">' . LANG_MORE . '</a>'; } return $value; }
public function insert($value = "") { switch ($value) { case 'story': $story_title = $this->input->post('name'); $story_url = string_short(convert_accented_characters($story_title)); $story_thumb = $this->input->post('img'); $story_sumary = $this->input->post('sumary'); $story_realname = $this->input->post('realname'); $story_author = $this->input->post('author'); $story_type = $this->input->post('type'); $story_time = time(); $sql = "INSERT INTO story(story_id, story_title, story_url, story_thumb, story_sumary, story_time, story_realname, story_author, story_type)\n VALUES(NULL, '{$story_title}', '{$story_url}', '{$story_thumb}', '{$story_sumary}', {$story_time}, '{$story_realname}', '{$story_author}', '{$story_type}')"; if (strlen($story_title) > 2) { $this->db->query($sql); } $result = $this->db->query("SELECT story_id FROM story WHERE story_url = '{$story_url}'")->result(); echo $result[0]->story_id; break; case 'chapter': $story_id = $this->input->post('story'); $chapter_title = $this->input->post('title'); $chapter_url = string_short(convert_accented_characters($chapter_title)); $chapter_content = $this->input->post('img'); $chapter_time = time(); $chapter_title = str_replace("Chương ", "", $chapter_title); $sql = "INSERT INTO chapter(chapter_id, story_id, chapter_title, chapter_url, chapter_content, chapter_time)\n VALUES(NULL, {$story_id}, {$chapter_title}, '{$chapter_url}', '{$chapter_content}', {$chapter_time})"; if (strlen($chapter_url) > 2) { $this->db->query($sql); } echo 'TRUE'; break; default: # code... break; } }
public function run($comment_id) { if (!$this->request->isAjax()) { cmsCore::error404(); } $is_submit = $this->request->get('save', 0); $comment = $this->model->getComment($comment_id); if (!$is_submit) { return $this->cms_template->render('backend/text_edit', array('comment' => $comment, 'action' => href_to($this->root_url, 'text_edit', array($comment['id'])))); } $csrf_token = $this->request->get('csrf_token', ''); if (!cmsForm::validateCSRFToken($csrf_token) || !$comment) { $this->cms_template->renderJSON(array('errors' => true)); } $content = $this->request->get('content', ''); // Типографируем текст $content_html = cmsEventsManager::hook('html_filter', $content); if (!$content_html) { $this->cms_template->renderJSON(array('errors' => array('content' => ERR_VALIDATE_REQUIRED))); } list($comment_id, $content, $content_html) = cmsEventsManager::hook('comment_before_update', array($comment_id, $content, $content_html)); $this->model->updateCommentContent($comment_id, $content, $content_html); return $this->cms_template->renderJSON(array('errors' => false, 'callback' => 'successSaveComment', 'comment_id' => $comment_id, 'text' => string_short($content_html, 350))); }
/** * Подготавливает текст для использования в теге meta description * * @param string $text * @param int $limit Максимальная длина результата * @return string */ function string_get_meta_description($text, $limit = 250) { return string_short($text, $limit); }
html(LANG_PRIVACY_PRIVATE); ?> "></span> <?php } ?> </div> <?php if ($teaser_field && !empty($item[$teaser_field])) { ?> <div class="teaser"> <?php if (!$is_private) { ?> <?php echo string_short($item[$teaser_field], $teaser_len); ?> <?php } else { ?> <!--noindex--><div class="private_field_hint"><?php echo LANG_PRIVACY_PRIVATE_HINT; ?> </div><!--/noindex--> <?php } ?> </div> <?php } ?>
<?php } ?> <?php foreach ($item['fields'] as $field => $value) { ?> <?php if (!$value) { continue; } ?> <div class="field search_field_<?php echo $field; ?> "><?php echo mb_strlen($value) > 280 ? string_short($value, 280) : $value; ?> </div> <?php } ?> <div class="info"><span class="date"><?php echo html_date_time($item['date_pub']); ?> </span></div> </div> <?php } ?> </div> <?php