static function FileSearchContent(&$ref_content) { wpfb_loadclass('ListTpl'); $tpl = WPFB_ListTpl::Get(WPFB_Core::$settings->search_result_tpl); if ($tpl !== null) { $ref_content .= $tpl->Generate(null, array('page_limit' => WPFB_Core::$settings->filelist_num)); } else { $files = WPFB_File::GetFiles2(self::SearchWhereSql(WPFB_Core::$settings->search_id3, stripslashes($_GET['wpfb_s'])), WPFB_Core::$settings->hide_inaccessible); foreach ($files as $file) { $ref_content .= $file->GenTpl2(); } } }
static function TplForm($type, $tpl_tag = null) { $new = empty($tpl_tag); $cat = $type == 'cat'; $list = $type == 'list'; $code_id = 'tplinp_' . $type; if (!$list) { if ($new) { $tpl_code = empty($_POST['tplcode']) ? '' : $_POST['tplcode']; } else { $tpl_code = WPFB_Core::GetTpls($type, $tpl_tag); if (empty($tpl_code)) { $tpl_code = ''; } } $item = $cat ? self::$sample_cat : self::$sample_file; } else { $tpl = $new ? new WPFB_ListTpl() : WPFB_ListTpl::Get($tpl_tag); } ?> <h2><?php $new ? _e('Add Template', 'wp-filebase') : _e('Edit Template', 'wp-filebase'); if (!empty($tpl_tag)) { echo ' ' . self::TplTitle($tpl_tag); } ?> </h2> <form action="<?php echo remove_query_arg(array('action', 'type', 'tpl')) . '#' . $type; ?> " method="post"> <?php wp_nonce_field(($new ? 'add' : 'update') . '-' . $type, 'wpfb-tpl-nonce'); ?> <input type="hidden" name="action" value="<?php echo $new ? 'add' : 'update'; ?> " /> <input type="hidden" name="type" value="<?php echo $type; ?> " /> <?php if ($new) { ?> <p> <label for="tpltag"><?php _e('Template Tag (a single word to describe the template):', 'wp-filebase'); ?> </label> <input type="text" name="tpltag" value="<?php if (!empty($_POST['tpltag'])) { echo esc_attr($_POST['tpltag']); } ?> " tabindex="1" maxlength="20" /> </p> <?php } else { ?> <input type="hidden" name="tpltag" value="<?php echo esc_attr($tpl_tag); ?> " /><?php } if ($list) { ?> <table class="form-table"> <tr class="form-field"> <th scope="row" valign="top"><label for="tpl-list-header"><?php _e('Header', 'wp-filebase'); ?> </label></th> <td width="100%"> <textarea id="tpl-list-header" name="tpl-list-header" cols="70" rows="<?php echo max(2, count(explode("\n", $tpl->header))) + 3; ?> " wrap="off" class="codepress html wpfilebase-tpledit" onkeyup="WPFB_PreviewTpl(this, '<?php echo $type; ?> ')" onchange="WPFB_PreviewTpl(this, '<?php echo $type; ?> ')"><?php echo htmlspecialchars($tpl->header); ?> </textarea><br /> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"><label for="tpl-list-cat-tpl"><?php _e('Category Template', 'wp-filebase'); ?> </label></th> <td width=""> <select id="tpl-list-cat-tpl" name="tpl-list-cat-tpl" onchange="WPFB_PreviewTpl(this, '<?php echo $type; ?> ')"><?php echo WPFB_Admin::TplDropDown('cat', $tpl->cat_tpl_tag); ?> </select> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"><label for="tpl-list-file-tpl"><?php _e('File Template', 'wp-filebase'); ?> </label></th> <td> <select id="tpl-list-file-tpl" name="tpl-list-file-tpl" onchange="WPFB_PreviewTpl(this, '<?php echo $type; ?> ')"><?php echo WPFB_Admin::TplDropDown('file', $tpl->file_tpl_tag); ?> </select> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"><label for="tpl-list-footer"><?php _e('Footer', 'wp-filebase'); ?> </label></th> <td> <textarea id="tpl-list-footer" name="tpl-list-footer" cols="70" rows="<?php echo max(2, count(explode("\n", $tpl->footer))) + 3; ?> " wrap="off" class="codepress html wpfilebase-tpledit" onkeyup="WPFB_PreviewTpl(this, '<?php echo $type; ?> ')" onchange="WPFB_PreviewTpl(this, '<?php echo $type; ?> ')"><?php echo htmlspecialchars($tpl->footer); ?> </textarea><br /> </td> </tr> </table> <?php } else { ?> <p> <?php _e('Template Code:', 'wp-filebase'); ?> <br /> <textarea id="<?php echo $code_id; ?> " cols="70" rows="<?php echo max(2, count(explode("\n", $tpl_code))) + 3; ?> " wrap="off" name="tplcode" class="codepress html wpfilebase-tpledit" onkeyup="WPFB_PreviewTpl(this, '<?php echo $type; ?> ')" onchange="WPFB_PreviewTpl(this, '<?php echo $type; ?> ')"><?php echo htmlspecialchars($tpl_code); ?> </textarea><br /> <?php wpfb_loadclass('Models'); echo WPFB_Models::TplFieldsSelect($code_id, false, $cat); ?> </p> <?php } ?> <p class="submit"><input type="submit" name="submit" class="button-primary" value="<?php echo esc_attr__($new ? 'Add Template' : 'Submit Template Changes', 'wp-filebase'); ?> " /></p> </form> <div class="entry-content wpfilebase-tpl-preview"> <div id="<?php echo $code_id; ?> _preview"><?php if ($list) { echo $tpl->Sample(self::$sample_cat, self::$sample_file); } else { echo empty($tpl_code) ? '<i>' . __('Preview') . '</i>' : $item->GenTpl(WPFB_TplLib::Parse($tpl_code), 'sample'); } ?> </div> <div style="height: 50px; float: left;"></div> <div class="clear"></div> </div> <?php }
?> " /> <?php wp_head(); ?> </head> <body class="single single-post"> <div id="page" class="site"> <div id="main" class="wrapper"> <div id="primary" class="site-content"> <div id="content" role="main"> <div class="entry-content"> <?php if ($list) { $tpl = WPFB_ListTpl::Get($tag); if (is_null($tpl)) { exit; } echo do_shortcode($tpl->Sample(WPFB_AdminGuiTpls::$sample_cat, WPFB_AdminGuiTpls::$sample_file)); } else { $tpl_src = WPFB_Core::GetTpls($type, $tag); if (!is_string($tpl_src) || empty($tpl_src)) { exit; } $table_found = strpos($tpl_src, '<table') !== false; if (!$list && !$table_found && strpos($tpl_src, '<tr') !== false) { $tpl_src = "<table>{$tpl_src}</table>"; } $item = $type == 'cat' ? WPFB_AdminGuiTpls::$sample_cat : WPFB_AdminGuiTpls::$sample_file; echo do_shortcode($item->GenTpl(WPFB_TplLib::Parse($tpl_src), 'sample'));
static function FileList($args) { global $wpdb; wpfb_loadclass('File', 'Category', 'ListTpl'); $tpl_tag = empty($args['tpl']) ? 'default' : $args['tpl']; $tpl = WPFB_ListTpl::Get($tpl_tag); if (empty($tpl)) { if (current_user_can('edit_posts')) { return "<p>[" . WPFB_PLUGIN_NAME . "]: <b>WARNING</b>: List template {$tpl_tag} does not exist!</p>"; } elseif (is_null($tpl = WPFB_ListTpl::Get('default'))) { return ''; } } $cats = empty($args['id']) || $args['id'] == -1 ? $args['showcats'] ? WPFB_Category::GetCats() : null : array_filter(array_map(array('WPFB_Category', 'GetCat'), explode(',', $args['id']))); return $tpl->Generate($cats, array('cat_grouping' => $args['showcats'], 'cat_order' => $args['sortcats'], 'file_order' => $args['sort'], 'page_limit' => $args['num'], 'hide_pagenav' => isset($args['pagenav']) && !(int) $args['pagenav'])); }