本文整理汇总了PHP中FrmAppHelper::truncate方法的典型用法代码示例。如果您正苦于以下问题:PHP FrmAppHelper::truncate方法的具体用法?PHP FrmAppHelper::truncate怎么用?PHP FrmAppHelper::truncate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FrmAppHelper
的用法示例。
在下文中一共展示了FrmAppHelper::truncate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wp_pages_dropdown
function wp_pages_dropdown($field_name, $page_id, $truncate = false)
{
$pages = FrmAppHelper::get_pages();
?>
<select name="<?php
echo $field_name;
?>
" id="<?php
echo $field_name;
?>
" class="frm-dropdown frm-pages-dropdown">
<option value=""></option>
<?php
foreach ($pages as $page) {
?>
<option value="<?php
echo $page->ID;
?>
" <?php
echo (isset($_POST[$field_name]) and $_POST[$field_name] == $page->ID or !isset($_POST[$field_name]) and $page_id == $page->ID) ? ' selected="selected"' : '';
?>
><?php
echo $truncate ? FrmAppHelper::truncate($page->post_title, $truncate) : $page->post_title;
?>
</option>
<?php
}
?>
</select>
<?php
}
示例2: create
public static function create($values)
{
global $wpdb;
self::sanitize_entry_post($values);
$values = apply_filters('frm_pre_create_entry', $values);
if (!isset($values['item_key'])) {
$values['item_key'] = '';
}
$item_name = self::get_new_entry_name($values, $values['item_key']);
$new_values = array('item_key' => FrmAppHelper::get_unique_key($values['item_key'], $wpdb->prefix . 'frm_items', 'item_key'), 'name' => FrmAppHelper::truncate($item_name, 255, 1, ''), 'ip' => FrmAppHelper::get_ip_address(), 'is_draft' => isset($values['frm_saving_draft']) && $values['frm_saving_draft'] == 1 || isset($values['is_draft']) && $values['is_draft'] == 1 ? 1 : 0, 'form_id' => isset($values['form_id']) ? (int) $values['form_id'] : null, 'post_id' => isset($values['post_id']) ? (int) $values['post_id'] : 0, 'parent_item_id' => isset($values['parent_item_id']) ? (int) $values['parent_item_id'] : 0, 'created_at' => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1), 'updated_at' => isset($values['updated_at']) ? $values['updated_at'] : (isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1)));
if (is_array($new_values['name'])) {
$new_values['name'] = reset($new_values['name']);
}
if (isset($values['description']) && !empty($values['description'])) {
$new_values['description'] = maybe_serialize($values['description']);
} else {
$new_values['description'] = serialize(array('browser' => FrmAppHelper::get_server_value('HTTP_USER_AGENT'), 'referrer' => FrmAppHelper::get_server_value('HTTP_REFERER')));
}
//if(isset($values['id']) and is_numeric($values['id']))
// $new_values['id'] = $values['id'];
if (isset($values['frm_user_id']) && (is_numeric($values['frm_user_id']) || FrmAppHelper::is_admin())) {
$new_values['user_id'] = $values['frm_user_id'];
} else {
$user_ID = get_current_user_id();
$new_values['user_id'] = $user_ID ? $user_ID : 0;
}
$new_values['updated_by'] = isset($values['updated_by']) ? $values['updated_by'] : $new_values['user_id'];
// don't create duplicate entry
if (self::is_duplicate($new_values, $values)) {
return false;
}
$query_results = $wpdb->insert($wpdb->prefix . 'frm_items', $new_values);
if (!$query_results) {
return false;
}
$entry_id = $wpdb->insert_id;
global $frm_vars;
if (!isset($frm_vars['saved_entries'])) {
$frm_vars['saved_entries'] = array();
}
$frm_vars['saved_entries'][] = (int) $entry_id;
if (isset($values['item_meta'])) {
FrmEntryMeta::update_entry_metas($entry_id, $values['item_meta']);
}
self::clear_cache();
// this is a child entry
$is_child = isset($values['parent_form_id']) && isset($values['parent_nonce']) && !empty($values['parent_form_id']) && wp_verify_nonce($values['parent_nonce'], 'parent');
do_action('frm_after_create_entry', $entry_id, $new_values['form_id'], compact('is_child'));
do_action('frm_after_create_entry_' . $new_values['form_id'], $entry_id, compact('is_child'));
return $entry_id;
}
示例3: forms_dropdown
function forms_dropdown($field_name, $field_value = '', $blank = true, $field_id = false, $onchange = false)
{
global $frm_form;
if (!$field_id) {
$field_id = $field_name;
}
$where = apply_filters('frm_forms_dropdown', "is_template=0 AND (status is NULL OR status = '' OR status = 'published')", $field_name);
$forms = $frm_form->getAll($where, ' ORDER BY name');
?>
<select name="<?php
echo $field_name;
?>
" id="<?php
echo $field_id;
?>
" class="frm-dropdown" <?php
if ($onchange) {
echo 'onchange="' . $onchange . '"';
}
?>
>
<?php
if ($blank) {
?>
<option value=""><?php
echo $blank == 1 ? '' : '- ' . $blank . ' -';
?>
</option>
<?php
}
?>
<?php
foreach ($forms as $form) {
?>
<option value="<?php
echo $form->id;
?>
" <?php
selected($field_value, $form->id);
?>
><?php
echo FrmAppHelper::truncate($form->name, 33);
?>
</option>
<?php
}
?>
</select>
<?php
}
示例4: manage_columns
public static function manage_columns($columns)
{
global $frm_vars, $wpdb;
$form_id = FrmForm::get_current_form_id();
$columns[$form_id . '_id'] = 'ID';
$columns[$form_id . '_item_key'] = esc_html__('Entry Key', 'formidable');
if (!$form_id) {
return $columns;
}
$form_cols = FrmField::get_all_for_form($form_id, '', 'include');
foreach ($form_cols as $form_col) {
if (FrmField::is_no_save_field($form_col->type)) {
continue;
}
if ($form_col->type == 'form' && isset($form_col->field_options['form_select']) && !empty($form_col->field_options['form_select'])) {
$sub_form_cols = FrmField::get_all_for_form($form_col->field_options['form_select']);
if ($sub_form_cols) {
foreach ($sub_form_cols as $k => $sub_form_col) {
if (FrmField::is_no_save_field($sub_form_col->type)) {
unset($sub_form_cols[$k]);
continue;
}
$columns[$form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id] = FrmAppHelper::truncate($sub_form_col->name, 35);
unset($sub_form_col);
}
}
unset($sub_form_cols);
} else {
$col_id = $form_col->field_key;
if ($form_col->form_id != $form_id) {
$col_id .= '-_-form' . $form_col->form_id;
}
if (isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value']) {
$columns[$form_id . '_frmsep_' . $col_id] = FrmAppHelper::truncate($form_col->name, 35);
}
$columns[$form_id . '_' . $col_id] = FrmAppHelper::truncate($form_col->name, 35);
}
}
$columns[$form_id . '_created_at'] = __('Entry creation date', 'formidable');
$columns[$form_id . '_updated_at'] = __('Entry update date', 'formidable');
$columns[$form_id . '_ip'] = 'IP';
$frm_vars['cols'] = $columns;
$action = FrmAppHelper::simple_get('frm_action', 'sanitize_title');
if (FrmAppHelper::is_admin_page('formidable-entries') && in_array($action, array('', 'list', 'destroy'))) {
add_screen_option('per_page', array('label' => __('Entries', 'formidable'), 'default' => 20, 'option' => 'formidable_page_formidable_entries_per_page'));
}
return $columns;
}
示例5: display_value
function display_value($value, $field, $atts = array())
{
global $wpdb;
$defaults = array('type' => '', 'show_icon' => true, 'show_filename' => true, 'truncate' => false, 'sep' => ', ', 'post_id' => 0, 'form_id' => $field->form_id, 'field' => $field);
$atts = wp_parse_args($atts, $defaults);
$field->field_options = maybe_unserialize($field->field_options);
if (!isset($field->field_options['post_field'])) {
$field->field_options['post_field'] = '';
}
if (!isset($field->field_options['custom_field'])) {
$field->field_options['custom_field'] = '';
}
if ($atts['post_id'] and ($field->field_options['post_field'] or $atts['type'] == 'tag')) {
$atts['pre_truncate'] = $atts['truncate'];
$atts['truncate'] = true;
$atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
$value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
$atts['truncate'] = $atts['pre_truncate'];
}
if ($value == '') {
return $value;
}
$value = maybe_unserialize($value);
if (is_array($value)) {
$value = stripslashes_deep($value);
}
$value = apply_filters('frm_display_value_custom', $value, $field, $atts);
$new_value = '';
if (is_array($value)) {
foreach ($value as $val) {
if (is_array($val)) {
//TODO: add options for display (li or ,)
$new_value .= implode($atts['sep'], $val);
if ($atts['type'] != 'data') {
$new_value .= "<br/>";
}
}
unset($val);
}
}
if (!empty($new_value)) {
$value = $new_value;
} else {
if (is_array($value)) {
$value = implode($atts['sep'], $value);
}
}
if ($atts['truncate'] and $atts['type'] != 'image') {
$value = FrmAppHelper::truncate($value, 50);
}
if ($atts['type'] == 'image') {
$value = '<img src="' . $value . '" height="50px" alt="" />';
} else {
if ($atts['type'] == 'user_id') {
$value = FrmProFieldsHelper::get_display_name($value);
} else {
if ($atts['type'] == 'file') {
$old_value = $value;
$value = '';
if ($atts['show_icon']) {
$value .= FrmProFieldsHelper::get_file_icon($old_value);
}
if ($atts['show_icon'] and $atts['show_filename']) {
$value .= '<br/>';
}
if ($atts['show_filename']) {
$value .= FrmProFieldsHelper::get_file_name($old_value);
}
} else {
if ($atts['type'] == 'date') {
$value = FrmProFieldsHelper::get_date($value);
} else {
if ($atts['type'] == 'data') {
if (!is_numeric($value)) {
$value = explode($atts['sep'], $value);
if (is_array($value)) {
$new_value = '';
foreach ($value as $entry_id) {
if (!empty($new_value)) {
$new_value .= $atts['sep'];
}
if (is_numeric($entry_id)) {
$new_value .= FrmProFieldsHelper::get_data_value($entry_id, $field, $atts);
} else {
$new_value .= $entry_id;
}
}
$value = $new_value;
}
} else {
//replace item id with specified field
$value = FrmProFieldsHelper::get_data_value($value, $field, $atts);
if ($field->field_options['data_type'] == 'data' or $field->field_options['data_type'] == '') {
$linked_field = FrmField::getOne($field->field_options['form_select']);
if ($linked_field->type == 'file') {
$old_value = $value;
$value = '<img src="' . $value . '" height="50px" alt="" />';
if ($atts['show_filename']) {
$value .= '<br/>' . $old_value;
}
//.........这里部分代码省略.........
示例6: replace_shortcodes
//.........这里部分代码省略.........
$inc_html = (isset($atts['html']) and $atts['html']) ? true : false;
$inc_links = (isset($atts['links']) and $atts['links']) ? true : false;
$sep = isset($atts['sep']) ? $atts['sep'] : ' ';
$show_filename = (isset($atts['show_filename']) and $atts['show_filename']) ? true : false;
if ($size != 'id' && !empty($replace_with)) {
$replace_with = FrmProFieldsHelper::get_media_from_id($replace_with, $size, array('html' => $inc_html, 'links' => $inc_links, 'show_filename' => $show_filename));
} else {
if (is_array($replace_with)) {
$replace_with = array_filter($replace_with);
}
}
unset($size);
}
if (isset($replace_with) and is_array($replace_with)) {
$replace_with = implode($sep, $replace_with);
}
if ($conditional) {
if (!isset($replace_with)) {
$replace_with = '';
}
$replace_with = apply_filters('frm_conditional_value', $replace_with, $atts, $field, $tag);
$start_pos = strpos($content, $shortcodes[0][$short_key]);
if ($start_pos !== false) {
$start_pos_len = strlen($shortcodes[0][$short_key]);
$end_pos = strpos($content, '[/if ' . $tag . ']', $start_pos);
$end_pos_len = strlen('[/if ' . $tag . ']');
if ($end_pos !== false) {
if (empty($replace_with)) {
$total_len = $end_pos + $end_pos_len - $start_pos;
$content = substr_replace($content, '', $start_pos, $total_len);
} else {
$content = substr_replace($content, '', $end_pos, $end_pos_len);
$content = substr_replace($content, '', $start_pos, $start_pos_len);
}
}
}
} else {
if ($field) {
if (isset($atts['show']) and $atts['show'] == 'field_label') {
$replace_with = $field->name;
} else {
if (isset($atts['show']) and $atts['show'] == 'description') {
$replace_with = $field->description;
} else {
if (empty($replace_with) and $replace_with != '0') {
$replace_with = '';
if ($field->type == 'number') {
$replace_with = '0';
}
} else {
$replace_with = FrmProFieldsHelper::get_display_value($replace_with, $field, $atts);
}
}
}
}
if (isset($atts['sanitize'])) {
$replace_with = sanitize_title_with_dashes($replace_with);
}
if (isset($atts['sanitize_url'])) {
if (seems_utf8($replace_with)) {
$replace_with = utf8_uri_encode($replace_with, 200);
}
$replace_with = urlencode(htmlentities($replace_with));
}
if (isset($atts['truncate'])) {
if (isset($atts['more_text'])) {
$more_link_text = $atts['more_text'];
} else {
$more_link_text = isset($atts['more_link_text']) ? $atts['more_link_text'] : '. . .';
}
if ($display and $display->frm_show_count == 'dynamic') {
$more_link_text = ' <a href="' . $detail_link . '">' . $more_link_text . '</a>';
$replace_with = FrmAppHelper::truncate($replace_with, (int) $atts['truncate'], 3, $more_link_text);
} else {
$replace_with = wp_specialchars_decode(strip_tags($replace_with), ENT_QUOTES);
$part_one = substr($replace_with, 0, (int) $atts['truncate']);
$part_two = substr($replace_with, (int) $atts['truncate']);
if (!empty($part_two)) {
$replace_with = $part_one . '<a href="#" onclick="jQuery(this).next().css(\'display\', \'inline\');jQuery(this).css(\'display\', \'none\');return false;" class="frm_text_exposed_show"> ' . $more_link_text . '</a><span style="display:none;">' . $part_two . '</span>';
}
}
}
if (isset($atts['clickable'])) {
$replace_with = make_clickable($replace_with);
}
if (!isset($replace_with)) {
$replace_with = '';
}
$content = str_replace($shortcodes[0][$short_key], $replace_with, $content);
}
unset($replace_with);
if (isset($field)) {
unset($field);
}
}
unset($atts);
unset($conditional);
}
return $content;
}
示例7: display_value
public static function display_value($value, $field, $atts = array())
{
global $wpdb, $frm_field;
$defaults = array('type' => '', 'show_icon' => true, 'show_filename' => true, 'truncate' => false, 'sep' => ', ', 'post_id' => 0, 'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0);
$atts = wp_parse_args($atts, $defaults);
$atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
if (!isset($field->field_options['post_field'])) {
$field->field_options['post_field'] = '';
}
if (!isset($field->field_options['custom_field'])) {
$field->field_options['custom_field'] = '';
}
if ($atts['post_id'] and ($field->field_options['post_field'] or $atts['type'] == 'tag')) {
$atts['pre_truncate'] = $atts['truncate'];
$atts['truncate'] = true;
$atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
$value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
$atts['truncate'] = $atts['pre_truncate'];
}
if ($value == '') {
return $value;
}
$value = maybe_unserialize($value);
$value = apply_filters('frm_display_value_custom', $value, $field, $atts);
$new_value = '';
if (is_array($value)) {
foreach ($value as $val) {
if (is_array($val)) {
//TODO: add options for display (li or ,)
$new_value .= implode($atts['sep'], $val);
if ($atts['type'] != 'data') {
$new_value .= "<br/>";
}
}
unset($val);
}
}
if (!empty($new_value)) {
$value = $new_value;
} else {
if (is_array($value)) {
$value = implode($atts['sep'], $value);
}
}
if ($atts['truncate'] and $atts['type'] != 'image') {
$value = FrmAppHelper::truncate($value, 50);
}
if ($atts['type'] == 'image') {
$value = '<img src="' . $value . '" height="50px" alt="" />';
} else {
if ($atts['type'] == 'user_id') {
$value = FrmProFieldsHelper::get_display_name($value);
} else {
if ($atts['type'] == 'file') {
$old_value = explode(', ', $value);
$value = '';
foreach ($old_value as $mid) {
$value .= '<div class="frm_file_container">';
if ($atts['show_icon']) {
$img = FrmProFieldsHelper::get_file_icon($mid);
$value .= $img;
if ($atts['show_filename'] and $img and preg_match("/wp-includes\\/images\\/crystal/", $img)) {
//prevent two filenames
$atts['show_filename'] = $show_filename = false;
}
unset($img);
}
if ($atts['show_icon'] and $atts['show_filename']) {
$value .= '<br/>';
}
if ($atts['show_filename']) {
$value .= FrmProFieldsHelper::get_file_name($mid);
}
if (isset($show_filename)) {
//if skipped filename, show it for the next file
$atts['show_filename'] = true;
unset($show_filename);
}
$value .= '</div>';
}
} else {
if ($atts['type'] == 'date') {
$value = FrmProFieldsHelper::get_date($value);
} else {
if ($atts['type'] == 'data') {
if (!is_numeric($value)) {
$value = explode($atts['sep'], $value);
if (is_array($value)) {
$new_value = '';
foreach ($value as $entry_id) {
if (!empty($new_value)) {
$new_value .= $atts['sep'];
}
if (is_numeric($entry_id)) {
$dval = FrmProFieldsHelper::get_data_value($entry_id, $field, $atts);
if (is_array($dval)) {
$dval = implode($atts['sep'], $dval);
}
$new_value .= $dval;
} else {
//.........这里部分代码省略.........
示例8: render_meta_box_content
public static function render_meta_box_content($post)
{
global $frm_vars;
$i = 1;
echo '<p>';
foreach ((array) $frm_vars['post_forms'] as $form) {
if ($i != 1) {
echo ' | ';
}
$i++;
echo '<a href="javascript:frmCreatePostEntry(' . (int) $form->id . ',' . (int) $post->ID . ')">' . esc_html(FrmAppHelper::truncate($form->name, 15)) . '</a>';
unset($form);
}
echo '</p>';
}
示例9: display_value
/**
* Prepare the saved value for display
* @return string
*/
public static function display_value($value, $field, $atts = array())
{
$defaults = array('type' => '', 'html' => false, 'show_filename' => true, 'truncate' => false, 'sep' => ', ', 'post_id' => 0, 'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0, 'return_array' => false);
$atts = wp_parse_args($atts, $defaults);
$atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
if (!isset($field->field_options['post_field'])) {
$field->field_options['post_field'] = '';
}
if (!isset($field->field_options['custom_field'])) {
$field->field_options['custom_field'] = '';
}
if (FrmAppHelper::pro_is_installed() && $atts['post_id'] && ($field->field_options['post_field'] || $atts['type'] == 'tag')) {
$atts['pre_truncate'] = $atts['truncate'];
$atts['truncate'] = true;
$atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
$value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
$atts['truncate'] = $atts['pre_truncate'];
}
if ($value == '') {
return $value;
}
$value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts);
$value = apply_filters('frm_display_' . $field->type . '_value_custom', $value, compact('field', 'atts'));
$new_value = '';
if (is_array($value) && $atts['type'] != 'file') {
foreach ($value as $val) {
if (is_array($val)) {
//TODO: add options for display (li or ,)
$new_value .= implode($atts['sep'], $val);
if ($atts['type'] != 'data') {
$new_value .= '<br/>';
}
}
unset($val);
}
}
if (!empty($new_value)) {
$value = $new_value;
} else {
if (is_array($value) && $atts['type'] != 'file' && !$atts['return_array']) {
$value = implode($atts['sep'], $value);
}
}
if ($atts['truncate'] && $atts['type'] != 'image') {
$value = FrmAppHelper::truncate($value, 50);
}
if (!$atts['keepjs'] && !is_array($value)) {
$value = wp_kses_post($value);
}
return apply_filters('frm_display_value', $value, $field, $atts);
}
示例10: search_box
public function search_box($text, $input_id)
{
if (!$this->has_items() && !isset($_REQUEST['s'])) {
return;
}
if (isset($this->params['form'])) {
$form = FrmForm::getOne($this->params['form']);
} else {
$form = FrmForm::get_published_forms(array(), 1);
}
if ($form) {
$field_list = FrmField::getAll(array('fi.form_id' => $form->id, 'fi.type not' => FrmField::no_save_fields()), 'field_order');
}
$fid = isset($_REQUEST['fid']) ? esc_attr(stripslashes($_REQUEST['fid'])) : '';
$input_id = $input_id . '-search-input';
$search_str = isset($_REQUEST['s']) ? esc_attr(stripslashes($_REQUEST['s'])) : '';
foreach (array('orderby', 'order') as $get_var) {
if (!empty($_REQUEST[$get_var])) {
echo '<input type="hidden" name="' . esc_attr($get_var) . '" value="' . esc_attr($_REQUEST[$get_var]) . '" />';
}
}
?>
<div class="search-box frm_sidebar">
<label class="screen-reader-text" for="<?php
echo esc_attr($input_id);
?>
"><?php
echo esc_attr($text);
?>
:</label>
<input type="text" id="<?php
echo esc_attr($input_id);
?>
" name="s" value="<?php
echo esc_attr($search_str);
?>
" />
<?php
if (isset($field_list) && !empty($field_list)) {
?>
<select name="fid" class="hide-if-js">
<option value="">— <?php
_e('All Fields', 'formidable');
?>
—</option>
<option value="created_at" <?php
selected($fid, 'created_at');
?>
><?php
_e('Entry creation date', 'formidable');
?>
</option>
<option value="id" <?php
selected($fid, 'id');
?>
><?php
_e('Entry ID', 'formidable');
?>
</option>
<?php
foreach ($field_list as $f) {
?>
<option value="<?php
echo $f->type == 'user_id' ? 'user_id' : $f->id;
?>
" <?php
selected($fid, $f->id);
?>
><?php
echo FrmAppHelper::truncate($f->name, 30);
?>
</option>
<?php
}
?>
</select>
<div class="button dropdown hide-if-no-js">
<a href="#" id="frm-fid-search" class="frm-dropdown-toggle" data-toggle="dropdown"><?php
_e('Search', 'formidable');
?>
<b class="caret"></b></a>
<ul class="frm-dropdown-menu pull-right" id="frm-fid-search-menu" role="menu" aria-labelledby="frm-fid-search">
<li><a href="#" id="fid-">— <?php
_e('All Fields', 'formidable');
?>
—</a></li>
<li><a href="#" id="fid-created_at"><?php
_e('Entry creation date', 'formidable');
?>
</a></li>
<li><a href="#" id="fid-id"><?php
_e('Entry ID', 'formidable');
?>
</a></li>
<?php
foreach ($field_list as $f) {
?>
<li><a href="#" id="fid-<?php
echo $f->type == 'user_id' ? 'user_id' : $f->id;
//.........这里部分代码省略.........
示例11: single_row
public function single_row($item, $style = '')
{
// Set up the hover actions for this user
$actions = array();
$view_link = '?page=formidable-entries&frm_action=show&id=' . $item->id;
$this->get_actions($actions, $item, $view_link);
$action_links = $this->row_actions($actions);
// Set up the checkbox ( because the user is editable, otherwise its empty )
$checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />";
$r = "<tr id='item-action-{$item->id}'{$style}>";
list($columns, $hidden, , $primary) = $this->get_column_info();
$action_col = false;
foreach ($columns as $column_name => $column_display_name) {
$class = $column_name . ' column-' . $column_name;
if ($column_name === $primary) {
$class .= ' column-primary';
}
if (in_array($column_name, $hidden)) {
$class .= ' frm_hidden';
} else {
if (!$action_col && !in_array($column_name, array('cb', 'id', 'form_id', 'post_id'))) {
$action_col = $column_name;
}
}
$attributes = 'class="' . esc_attr($class) . '"';
unset($class);
$attributes .= ' data-colname="' . $column_display_name . '"';
$col_name = preg_replace('/^(' . $this->params['form'] . '_)/', '', $column_name);
$this->column_name = $col_name;
switch ($col_name) {
case 'cb':
$r .= "<th scope='row' class='check-column'>{$checkbox}</th>";
break;
case 'ip':
case 'id':
case 'item_key':
$val = $item->{$col_name};
break;
case 'name':
case 'description':
$val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100);
break;
case 'created_at':
case 'updated_at':
$date = FrmAppHelper::get_formatted_time($item->{$col_name});
$val = '<abbr title="' . esc_attr(FrmAppHelper::get_formatted_time($item->{$col_name}, '', 'g:i:s A')) . '">' . $date . '</abbr>';
break;
case 'is_draft':
$val = empty($item->is_draft) ? __('No') : __('Yes');
break;
case 'form_id':
$val = FrmFormsHelper::edit_form_link($item->form_id);
break;
case 'post_id':
$val = FrmAppHelper::post_edit_link($item->post_id);
break;
case 'user_id':
$user = get_userdata($item->user_id);
$val = $user->user_login;
break;
default:
$val = apply_filters('frm_entries_' . $col_name . '_column', false, compact('item'));
if ($val === false) {
$this->get_column_value($item, $val);
}
break;
}
if (isset($val)) {
$r .= "<td {$attributes}>";
if ($column_name == $action_col) {
$edit_link = '?page=formidable-entries&frm_action=edit&id=' . $item->id;
$r .= '<a href="' . esc_url(isset($actions['edit']) ? $edit_link : $view_link) . '" class="row-title" >' . $val . '</a> ';
$r .= $action_links;
} else {
$r .= $val;
}
$r .= '</td>';
}
unset($val);
}
$r .= '</tr>';
return $r;
}
示例12: render_meta_box_content
function render_meta_box_content($post)
{
global $frm_post_forms, $frm_ajax_url;
$count = count($frm_post_forms);
$i = 1;
echo '<p>';
foreach ($frm_post_forms as $form) {
if ($i != 1) {
echo ' | ';
}
$i++;
echo '<a href="javascript:frm_create_post_entry(' . $form->id . ',' . $post->ID . ')">' . stripslashes(FrmAppHelper::truncate($form->name, 15)) . '</a>';
unset($form);
}
unset($i);
echo '</p>';
echo "<script type='text/javascript'>function frm_create_post_entry(id,post_id){\njQuery('#frm_create_entry p').replaceWith('<img src=\"" . FRM_IMAGES_URL . "/wpspin_light.gif\" alt=\"" . __('Loading...', 'formidable') . "\" />');\njQuery.ajax({type:'POST',url:'{$frm_ajax_url}',data:'action=frm_create_post_entry&id='+id+'&post_id='+post_id,\nsuccess:function(msg){jQuery('#frm_create_entry').fadeOut('slow');}\n});\n};</script>";
}
示例13: package_entry_data
/**
* Prepare the new values for inserting into the database
*
* @since 2.0.16
* @param array $values
* @return array $new_values
*/
private static function package_entry_data(&$values)
{
global $wpdb;
if (!isset($values['item_key'])) {
$values['item_key'] = '';
}
$item_name = self::get_new_entry_name($values, $values['item_key']);
$new_values = array('item_key' => FrmAppHelper::get_unique_key($values['item_key'], $wpdb->prefix . 'frm_items', 'item_key'), 'name' => FrmAppHelper::truncate($item_name, 255, 1, ''), 'ip' => FrmAppHelper::get_ip_address(), 'is_draft' => self::get_is_draft_value($values), 'form_id' => self::get_form_id($values), 'post_id' => self::get_post_id($values), 'parent_item_id' => self::get_parent_item_id($values), 'created_at' => self::get_created_at($values), 'updated_at' => self::get_updated_at($values), 'description' => self::get_entry_description($values), 'user_id' => self::get_entry_user_id($values));
if (is_array($new_values['name'])) {
$new_values['name'] = reset($new_values['name']);
}
$new_values['updated_by'] = isset($values['updated_by']) ? $values['updated_by'] : $new_values['user_id'];
return $new_values;
}
示例14: single_row
function single_row($item, $style = '')
{
global $frmpro_is_installed, $frm_entry;
$checkbox = '';
// Set up the hover actions for this user
$actions = array();
$title = esc_attr(strip_tags(stripslashes($item->name)));
$edit_link = "?page=formidable&frm_action=edit&id={$item->id}";
$actions['edit'] = "<a href='" . wp_nonce_url($edit_link) . "'>" . __('Edit', 'formidable') . "</a>";
$duplicate_link = "?page=formidable&frm_action=duplicate&id={$item->id}";
$view_link = "?page=formidable-{$this->page_name}&frm_action=show&id={$item->id}";
if ($this->params['template']) {
$actions['duplicate'] = "<a href='" . wp_nonce_url($duplicate_link) . "'>" . __('Create Form from Template', 'formidable') . "</a>";
} else {
$actions['settings'] = "<a href='" . wp_nonce_url("?page=formidable&frm_action=settings&id={$item->id}") . "'>" . __('Settings', 'formidable') . "</a>";
$actions['entries'] = "<a href='" . wp_nonce_url("?page=formidable-entries&form={$item->id}") . "' title='{$title} " . __('Entries', 'formidable') . "'>" . __('Entries', 'formidable') . "</a>";
$actions['reports'] = "<a href='" . wp_nonce_url("?page=formidable-reports&form={$item->id}") . "' title='{$title} " . __('Reports', 'formidable') . "'>" . __('Reports', 'formidable') . "</a>";
if ($frmpro_is_installed and current_user_can('frm_create_entries')) {
$actions['entry'] = "<a href='" . wp_nonce_url("?page=formidable-entries&frm_action=new&form={$item->id}") . "' title='" . __('New', 'formidable') . " {$title} " . __('Entry', 'formidable') . "'>" . __('New Entry', 'formidable') . "</a>";
}
$actions['duplicate'] = "<a href='" . wp_nonce_url($duplicate_link) . "' title='" . __('Copy', 'formidable') . " {$title}'>" . __('Duplicate', 'formidable') . "</a>";
if ($frmpro_is_installed) {
$actions['template'] = "<a href='" . wp_nonce_url("?page=formidable&frm_action=duplicate&id={$item->id}&template=1") . "' title='" . __('Create Template', 'formidable') . "'>" . __('Create Template', 'formidable') . "</a>";
}
}
if ($frmpro_is_installed) {
$actions['export_template'] = "<a href='" . wp_nonce_url(FRM_SCRIPT_URL . "&controller=forms&frm_action=export&id={$item->id}") . "' title='{$title} " . __('Export Template', 'formidable') . "'>" . __('Export Template', 'formidable') . "</a>";
}
$delete_link = "?page=formidable&frm_action=destroy&id={$item->id}";
$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url($delete_link) . "' onclick='return confirm(\"" . __('Are you sure you want to delete that?', 'formidable') . "\")'>" . __('Delete', 'formidable') . "</a>";
if (!current_user_can('frm_view_entries')) {
if (isset($actions['entries'])) {
unset($actions['entries']);
}
if (isset($actions['reports'])) {
unset($actions['reports']);
}
}
if (!current_user_can('frm_edit_forms')) {
unset($actions['edit']);
unset($actions['duplicate']);
if (isset($actions['settings'])) {
unset($actions['settings']);
}
if (!$frmpro_is_installed) {
unset($actions['duplicate']);
}
}
if (!current_user_can('frm_delete_forms')) {
unset($actions['delete']);
}
$action_links = $this->row_actions($actions);
// Set up the checkbox ( because the user is editable, otherwise its empty )
$checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />";
$r = "<tr id='item-action-{$item->id}'{$style}>";
list($columns, $hidden) = $this->get_column_info();
$action_col = false;
foreach ($columns as $column_name => $column_display_name) {
$class = "class=\"{$column_name} column-{$column_name}\"";
$style = '';
if (in_array($column_name, $hidden)) {
$style = ' style="display:none;"';
} else {
if (!$action_col and !in_array($column_name, array('cb', 'id'))) {
$action_col = $column_name;
}
}
$attributes = "{$class}{$style}";
switch ($column_name) {
case 'cb':
$r .= "<th scope='row' class='check-column'>{$checkbox}</th>";
break;
case 'id':
case 'form_key':
$val = stripslashes($item->{$column_name});
break;
case 'name':
case 'description':
$val = FrmAppHelper::truncate(strip_tags(stripslashes($item->{$column_name})), 100);
break;
case 'created_at':
$format = 'Y/m/d';
//get_option('date_format');
$date = date($format, strtotime($item->{$column_name}));
$val = "<abbr title='" . date($format . ' g:i:s A', strtotime($item->{$column_name})) . "'>" . $date . "</abbr>";
break;
case 'shortcode':
$val = "<input type='text' style='font-size:10px;width:100%;' readonly='true' onclick='this.select();' onfocus='this.select();' value='[formidable id={$item->id}]' /><br/>";
$val .= "<input type='text' style='font-size:10px;width:100%;' readonly='true' onclick='this.select();' onfocus='this.select();' value='[formidable key={$item->form_key}]' />";
break;
case 'entries':
$text = $frm_entry->getRecordCount($item->id);
$text = sprintf(_n('%1$s Entry', '%1$s Entries', $text, 'formidable'), $text);
$val = current_user_can('frm_view_entries') ? '<a href="' . esc_url(admin_url('admin.php') . '?page=formidable-entries&form=' . $item->id) . '">' . $text . '</a>' : $text;
unset($text);
break;
case 'link':
$target_url = FrmFormsHelper::get_direct_link($item->form_key, $item->prli_link_id);
$val = '<input type="text" style="font-size:10px;width:100%;" readonly="true" onclick="this.select();" onfocus="this.select();" value="' . esc_html($target_url) . '" /><br/><a href="' . esc_html($target_url) . '" target="blank">' . __('View Form', 'formidable') . '</a>';
unset($target_url);
//.........这里部分代码省略.........
示例15: replace_shortcodes
//.........这里部分代码省略.........
}
}
if (!empty($replace_with)) {
$replace_with = '<a href="' . $replace_with . '" class="frm_edit_link ' . $class . '">' . $link_text . '</a>';
}
}
unset($class);
} else {
$field = $frm_field->getOne($tag);
}
}
$sep = isset($atts['sep']) ? $atts['sep'] : ', ';
if (!isset($field)) {
$field = false;
}
if ($field) {
$field->field_options = maybe_unserialize($field->field_options);
$replace_with = FrmProEntryMetaHelper::get_post_or_meta_value($entry, $field, $atts);
$replace_with = maybe_unserialize($replace_with);
$atts['entry_id'] = $entry->id;
$atts['entry_key'] = $entry->item_key;
$atts['post_id'] = $entry->post_id;
$replace_with = apply_filters('frmpro_fields_replace_shortcodes', $replace_with, $tag, $atts, $field);
}
if (isset($replace_with) and is_array($replace_with)) {
$replace_with = implode($sep, $replace_with);
}
if ($field and $field->type == 'file') {
//size options are thumbnail, medium, large, or full
$size = isset($atts['size']) ? $atts['size'] : 'thumbnail';
if ($size != 'id') {
$replace_with = FrmProFieldsHelper::get_media_from_id($replace_with, $size);
}
}
if ($conditional) {
$replace_with = apply_filters('frm_conditional_value', $replace_with, $atts, $field, $tag);
if ($atts) {
$content = str_replace($shortcodes[0][$short_key], '[if ' . $tag . ']', $content);
}
if (empty($replace_with)) {
$content = preg_replace('/(\\[if\\s+' . $tag . '\\])(.*?)(\\[\\/if\\s+' . $tag . '\\])/mis', '', $content);
} else {
$content = preg_replace('/(\\[if\\s+' . $tag . '\\])/', '', $content, 1);
$content = preg_replace('/(\\[\\/if\\s+' . $tag . '\\])/', '', $content, 1);
}
} else {
if ($field) {
if (isset($atts['show']) and $atts['show'] == 'field_label') {
$replace_with = stripslashes($field->name);
} else {
if (empty($replace_with) and $replace_with != '0') {
$replace_with = '';
if ($field->type == 'number') {
$replace_with = '0';
}
} else {
$replace_with = FrmProFieldsHelper::get_display_value($replace_with, $field, $atts);
}
}
}
if (isset($atts['sanitize'])) {
$replace_with = sanitize_title_with_dashes($replace_with);
}
if (isset($atts['sanitize_url'])) {
$replace_with = urlencode(htmlentities($replace_with));
}
if (isset($atts['truncate'])) {
if (isset($atts['more_text'])) {
$more_link_text = $atts['more_text'];
} else {
$more_link_text = isset($atts['more_link_text']) ? $atts['more_link_text'] : '. . .';
}
if ($display and $show == 'all') {
$more_link_text = ' <a href="' . $detail_link . '">' . $more_link_text . '</a>';
$replace_with = FrmAppHelper::truncate($replace_with, (int) $atts['truncate'], 3, $more_link_text);
} else {
$replace_with = wp_specialchars_decode(strip_tags($replace_with), ENT_QUOTES);
$part_one = substr($replace_with, 0, (int) $atts['truncate']);
$part_two = substr($replace_with, (int) $atts['truncate']);
$replace_with = $part_one . '<a onclick="jQuery(this).next().css(\'display\', \'inline\');jQuery(this).css(\'display\', \'none\')" class="frm_text_exposed_show"> ' . $more_link_text . '</a><span style="display:none;">' . $part_two . '</span>';
}
}
if (isset($atts['clickable'])) {
$replace_with = make_clickable($replace_with);
}
if (!isset($replace_with)) {
$replace_with = '';
}
$content = str_replace($shortcodes[0][$short_key], $replace_with, $content);
}
unset($replace_with);
if (isset($field)) {
unset($field);
}
}
unset($atts);
unset($conditional);
}
return $content;
}