public function replace_tag($tagdata = '', $params = '') { if ($tagdata == '') { return $tagdata; } $raw_content = parent::replace_tag($tagdata, $params); $content_obj = json_decode($raw_content); if (isset($content_obj->title_text)) { $tagdata = str_replace('{title_text}', $content_obj->title_text, $tagdata); } if (isset($content_obj->assets_file_id)) { ee()->load->add_package_path(PATH_THIRD . 'assets/'); require_once PATH_THIRD . 'assets/sources/ee/file.ee.php'; require_once PATH_THIRD . 'assets/helper.php'; ee()->load->library('Assets_lib'); $assets_file = ee()->assets_lib->get_file_by_id($content_obj->assets_file_id); $assets_helper = new Assets_helper(); $tagdata = $assets_helper->parse_file_tag(array($assets_file), $tagdata); } else { if (isset($content_obj->file_id)) { require_once APPPATH . 'fieldtypes/file/ft.file.php'; $ee_file = new File_ft(); $file_info = ee()->file_field->parse_field($content_obj->file_id); if ($file_info) { $tagdata = $ee_file->replace_tag($file_info, $params, $tagdata); } } } return $tagdata; }
/** * Get files and parse them */ public function files() { $tagdata = $this->EE->TMPL->tagdata; // Ignore if there's no tagdata if (!$tagdata) { return ''; } $parameters = $this->_gather_file_parameters(); $files = $this->EE->assets_lib->get_files($parameters); if ($files) { // is there a var_prefix? if (($var_prefix = $this->EE->TMPL->fetch_param('var_prefix')) !== FALSE) { $var_prefix = rtrim($var_prefix, ':') . ':'; $tagdata = str_replace($var_prefix, '', $tagdata); } return Assets_helper::parse_file_tag($files, $tagdata); } else { return $this->EE->TMPL->no_results(); } }
/** * Replace Tag */ function replace_tag($data, $params = array(), $tagdata = FALSE) { // return the full URL if there's no tagdata if (!$tagdata) { return $this->replace_url($data, $params); } $var_prefix = isset($params['var_prefix']) && $params['var_prefix'] ? rtrim($params['var_prefix'], ':') . ':' : ''; // get the absolute number of files before we run the filters $vars[$var_prefix . 'absolute_total_files'] = count($data); $this->_apply_params($data, $params); // Only trigger this for Low Variables if (!$data && $this->var_id) { return $this->EE->TMPL->no_results(); } // get the filtered number of files $vars[$var_prefix . 'total_files'] = count($data); // parse {total_files} and {absolute_total_files} now, since they'll never change $tagdata = $this->EE->TMPL->parse_variables_row($tagdata, $vars); $r = Assets_helper::parse_file_tag($data, $tagdata, $var_prefix); // ------------------------------------------- // Backspace param // ------------------------------------------- if (isset($params['backspace'])) { $chop = strlen($r) - $params['backspace']; $r = substr($r, 0, $chop); } return $r; }