function gv_entry_link($entry, $post_id = NULL) { return GravityView_API::entry_link($entry, $post_id); }
/** * Get the output for a specific entry * * @param array $entry GF Entry array * * @since 1.7.2 * * @uses gravityview_get_link * @uses GravityView_API::entry_link * @uses GravityView_API::replace_variables * * @return string HTML output for the entry */ private function get_item_output($entry) { $link = GravityView_API::entry_link($entry, $this->post_id); $item_output = gravityview_get_link($link, $this->link_format); if (!empty($this->after_link)) { /** * Modify the item output HTML * * @since 1.7.2 * * @param string $item_output The HTML output for the after_link content * @param array $entry Gravity Forms entry array * @param GravityView_Entry_List $this The current class instance */ $after_link = apply_filters('gravityview/entry-list/after-link', '<div>' . $this->after_link . '</div>', $entry, $this); $item_output .= $after_link; } $item_output = GravityView_API::replace_variables($item_output, $this->form, $entry); $item_output = '<' . $this->item_tag . '>' . $item_output . '</' . $this->item_tag . '>'; /** * Modify the item output HTML * * @since 1.7.2 * * @param string $item_output The HTML output for the item * @param array $entry Gravity Forms entry array * @param GravityView_Entry_List $this The current class instance */ $item_output = apply_filters('gravityview/entry-list/item', $item_output, $entry, $this); return $item_output; }
/** * Return an array of files prepared for output. * * Processes files by file type and generates unique output for each. * * Returns array for each file, with the following keys: * * `file_path` => The file path of the file, with a line break * `html` => The file output HTML formatted * * @since 1.2 * @todo Support `playlist` shortcode for playlist of video/audio * @usedby gravityview_get_files_array() * @param string $value Field value passed by Gravity Forms. String of file URL, or serialized string of file URL array * @param string $gv_class Field class to add to the output HTML * @return array Array of file output, with `file_path` and `html` keys (see comments above) */ static function get_files_array($value, $gv_class) { $gravityview_view = GravityView_View::getInstance(); extract($gravityview_view->getCurrentField()); $output_arr = array(); // Get an array of file paths for the field. $file_paths = rgar($field, 'multipleFiles') ? json_decode($value) : array($value); // Process each file path foreach ($file_paths as $file_path) { // If the site is HTTPS, use HTTPS if (function_exists('set_url_scheme')) { $file_path = set_url_scheme($file_path); } // This is from Gravity Forms's code $file_path = esc_attr(str_replace(" ", "%20", $file_path)); // If the field is set to link to the single entry, link to it. $link = !empty($field_settings['show_as_link']) ? GravityView_API::entry_link($entry, $field) : $file_path; // Get file path information $file_path_info = pathinfo($file_path); $html_format = NULL; $disable_lightbox = false; $disable_wrapped_link = false; // Is this an image? $image = new GravityView_Image(array('src' => $file_path, 'class' => 'gv-image gv-field-id-' . $field_settings['id'], 'alt' => $field_settings['label'], 'width' => gravityview_get_context() === 'single' ? NULL : 250)); $content = $image->html(); // The new default content is the image, if it exists. If not, use the file name as the content. $content = !empty($content) ? $content : $file_path_info['basename']; // If pathinfo() gave us the extension of the file, run the switch statement using that. $extension = empty($file_path_info['extension']) ? NULL : strtolower($file_path_info['extension']); switch (true) { // Audio file case in_array($extension, wp_get_audio_extensions()): $disable_lightbox = true; if (shortcode_exists('audio')) { $disable_wrapped_link = true; /** * Modify the settings passed to the `wp_video_shortcode()` function * * @since 1.2 * @var array */ $audio_settings = apply_filters('gravityview_audio_settings', array('src' => $file_path, 'class' => 'wp-audio-shortcode gv-audio gv-field-id-' . $field_settings['id'])); /** * Generate the audio shortcode * @link http://codex.wordpress.org/Audio_Shortcode * @link https://developer.wordpress.org/reference/functions/wp_audio_shortcode/ */ $content = wp_audio_shortcode($audio_settings); } break; // Video file // Video file case in_array($extension, wp_get_video_extensions()): $disable_lightbox = true; if (shortcode_exists('video')) { $disable_wrapped_link = true; /** * Modify the settings passed to the `wp_video_shortcode()` function * * @since 1.2 * @var array */ $video_settings = apply_filters('gravityview_video_settings', array('src' => $file_path, 'class' => 'wp-video-shortcode gv-video gv-field-id-' . $field_settings['id'])); /** * Generate the video shortcode * @link http://codex.wordpress.org/Video_Shortcode * @link https://developer.wordpress.org/reference/functions/wp_video_shortcode/ */ $content = wp_video_shortcode($video_settings); } break; // PDF // PDF case $extension === 'pdf': // PDF needs to be displayed in an IFRAME $link = add_query_arg(array('TB_iframe' => 'true'), $link); break; // if not image, do not set the lightbox (@since 1.5.3) // if not image, do not set the lightbox (@since 1.5.3) case !in_array($extension, array('jpg', 'jpeg', 'jpe', 'gif', 'png')): $disable_lightbox = true; break; } // If using Link to File, override the content. // (We do this here so that the $disable_lightbox can be set. Yes, there's a little more processing time, but oh well.) if (!empty($field_settings['link_to_file'])) { // Force the content to be the file name $content = $file_path_info["basename"]; // Restore the wrapped link $disable_wrapped_link = false; } // Whether to use lightbox or not if ($disable_lightbox || empty($gravityview_view->atts['lightbox']) || !empty($field_settings['show_as_link'])) { $link_atts = empty($field_settings['show_as_link']) ? "target='_blank'" : ''; $link_atts = apply_filters('gravityview/fields/fileupload/link_atts', $link_atts, $gravityview_view->getCurrentField()); } else { $link_atts = sprintf("rel='%s-{$entry['id']}' class='thickbox' target='_blank'", $gv_class); } /** * Filter to alter the default behaviour of wrapping images (or image names) with a link to the content object * * @since 1.5.1 * * @param bool $disable_wrapped_link whether to wrap the content with a link to the content object. * @param array $gravityview_view->field_data * * @see GravityView_API:field_value() for info about $gravityview_view->field_data * */ $disable_wrapped_link = apply_filters('gravityview/fields/fileupload/disable_link', $disable_wrapped_link, $gravityview_view->getCurrentField()); // If the HTML output hasn't been overridden by the switch statement above, use the default format if (!empty($content) && empty($disable_wrapped_link)) { /** * Modify the link text (defaults to the file name) * * @since 1.7 * * @param string $content The existing anchor content. Could be `<img>` tag, audio/video embed or the file name * @param array $field GravityView array of the current field being processed */ $content = apply_filters('gravityview/fields/fileupload/link_content', $content, $gravityview_view->getCurrentField()); $content = '<a href="' . esc_url_raw($link) . '" ' . $link_atts . '>' . $content . '</a>'; } $output_arr[] = array('file_path' => $file_path, 'content' => $content); } // End foreach loop /** * Modify the files array * * @since 1.7 * * @param array $output_arr Associative array of files { * @type string $file_path The path to the file as stored in Gravity Forms * @type string $content The generated output for the file * } * @param array $field GravityView array of the current field being processed */ $output_arr = apply_filters('gravityview/fields/fileupload/files_array', $output_arr, $gravityview_view->getCurrentField()); return $output_arr; }
/** * Get the URL for the entry. * * Uses the `post_id`, `view_id` params as defined in the shortcode attributes. * * @since 1.15 * * @param string|null $content Content inside shortcode, if defined * * @return string|boolean If URL is fetched, the URL to the entry link. If not found, returns false. */ private function get_url() { // if post_id is not defined, default to view_id $post_id = empty($this->settings['post_id']) ? $this->view_id : absint($this->settings['post_id']); switch ($this->settings['action']) { case 'edit': $url = GravityView_Edit_Entry::get_edit_link($this->entry, $this->view_id, $post_id); break; case 'delete': $url = GravityView_Delete_Entry::get_delete_link($this->entry, $this->view_id, $post_id); break; case 'read': default: $url = GravityView_API::entry_link($this->entry, $post_id); } $url = $this->maybe_add_field_values_query_args($url); return $url; }