コード例 #1
0
ファイル: ListTpl.php プロジェクト: parsonsc/dofe
 private function ParseHeaderFooter($str, $uid = null)
 {
     $str = preg_replace_callback('/%sort_?link:([a-z0-9_]+)%/i', array(__CLASS__, 'GenSortlink'), $str);
     if (strpos($str, '%search_form%') !== false) {
         wpfb_loadclass('Output');
         $str = str_replace('%search_form%', WPFB_Output::GetSearchForm("", $_GET), $str);
     }
     $str = preg_replace_callback('/%print_?(script|style):([a-z0-9_-]+)%/i', array(__CLASS__, 'PrintScriptCallback'), $str);
     if (empty($uid)) {
         $uid = uniqid();
     }
     $str = str_replace('%uid%', $uid, $str);
     $count = 0;
     $str = preg_replace("/jQuery\\((.+?)\\)\\.dataTable\\s*\\((.*?)\\)(\\.?.*?)\\s*;/", 'jQuery($1).dataTable((function(options){/*%WPFB_DATA_TABLE_OPTIONS_FILTER%*/})($2))$3;', $str, -1, $count);
     if ($count > 0) {
         $dataTableOptions = array();
         list($sort_field, $sort_dir) = wpfb_call('Output', 'ParseSorting', $this->current_list->file_order);
         $file_tpl = WPFB_Core::GetTpls('file', $this->file_tpl_tag);
         if (($p = strpos($file_tpl, "%{$sort_field}%")) > 0) {
             // get the column index of field to sort
             $col_index = substr_count($file_tpl, "</t", 0, $p);
             $dataTableOptions["aaSorting"] = array(array($col_index, strtolower($sort_dir)));
         }
         if ($this->current_list->page_limit > 0) {
             $dataTableOptions["iDisplayLength"] = $this->current_list->page_limit;
         }
         $str = str_replace('/*%WPFB_DATA_TABLE_OPTIONS_FILTER%*/', " var wpfbOptions = " . json_encode($dataTableOptions) . "; " . " if('object' == typeof(options)) { for (var v in options) { wpfbOptions[v] = options[v]; } }" . " return wpfbOptions; ", $str);
     }
     return $str;
 }
コード例 #2
0
    static function Display()
    {
        wpfb_loadclass('Output', 'File', 'Category', 'TplLib');
        $content = '';
        $file_tpls = WPFB_Core::GetTpls('file');
        $cat_tpls = WPFB_Core::GetTpls('cat');
        if (true || !isset($file_tpls['filebrowser_admin'])) {
            $file_tpls['filebrowser_admin'] = '%file_small_icon% ' . '%file_display_name% (%file_size%) ' . '<!-- IF %file_user_can_edit% --><a href="%file_edit_url%" class="edit" onclick="wpfbFBEditFile(event)">%\'Edit\'%</a><!-- ENDIF -->' . '<!-- IF %file_user_can_edit% --><a href="#" class="delete" onclick="return confirm(\'Sure?\') && wpfbFBDelete(event) && false;">%\'Delete\'%</a><!-- ENDIF -->';
            WPFB_Core::SetFileTpls($file_tpls);
            //WPFB_Admin::ParseTpls();
        }
        if (true || !isset($cat_tpls['filebrowser_admin'])) {
            $cat_tpls['filebrowser_admin'] = '<span class="cat-icon" style="background-image:url(\'%cat_icon_url%\');"><span class="cat-icon-overlay"></span></span>' . '%cat_name% ' . '<!-- IF %cat_user_can_edit% --><a href="%cat_edit_url%" class="edit" onclick="wpfbFBEditCat(event)">%\'Edit\'%</a><!-- ENDIF -->' . '<!-- IF %cat_user_can_edit% --><a href="#" class="delete" onclick="return confirm(\'Sure?\') && wpfbFBDelete(event) && false;">%\'Delete\'%</a><!-- ENDIF -->';
            WPFB_Core::SetCatTpls($cat_tpls);
            WPFB_Admin::ParseTpls();
        }
        WPFB_Output::FileBrowser($content, 0, empty($_GET['wpfb_cat']) ? 0 : intval($_GET['wpfb_cat']));
        WPFB_Core::PrintJS();
        ?>
    <div class="wrap filebrowser-admin"> 
    <h2><?php 
        _e('File Browser', 'wp-filebase');
        ?>
</h2>    
<?php 
        echo '<div>' . __('You can Drag &amp; Drop (multiple) files directly on Categories to upload them. Dragging a category or an existing file to another category is also possible.', 'wp-filebase') . '</div>';
        echo $content;
        ?>
	 </div>
<script>
	function wpfbFBEditCat(e) {
		e.stopPropagation();
	}
	
	function wpfbFBEditFile(e) {
		e.stopPropagation();
	}	
	
	function wpfbFBDelete(e) {
		e.stopPropagation();
		var t = jQuery(e.currentTarget).parents('li').first();		
		var d = {wpfb_action: 'delete'};
		var tid = t.attr('id').split('-');
		d[tid[tid.length-2]+'_id'] = +tid[tid.length-1];
		jQuery.ajax({type: 'POST', url: wpfbConf.ajurl, data: d,
			//async: false,
			success: (function (data) {
				if (data == '1') {
					t.fadeOut(300, function() { t.remove(); });
				}
			})
		});
	
		return false;
	}	
</script>
	
<?php 
    }
コード例 #3
0
    static function Display()
    {
        wpfb_loadclass('Output', 'File', 'Category', 'TplLib');
        $content = '';
        $file_tpls = WPFB_Core::GetTpls('file');
        $cat_tpls = WPFB_Core::GetTpls('cat');
        if (true || !isset($file_tpls['filebrowser_admin'])) {
            $file_tpls['filebrowser_admin'] = '%file_small_icon% ' . '%file_display_name% (%file_size%) ' . '<!-- IF %file_user_can_edit% --><a href="%file_edit_url%" class="edit" onclick="wpfbFBEditFile(event)">%\'Edit\'%</a><!-- ENDIF -->';
            WPFB_Core::SetFileTpls($file_tpls);
            //WPFB_Admin::ParseTpls();
        }
        if (true || !isset($cat_tpls['filebrowser_admin'])) {
            $cat_tpls['filebrowser_admin'] = '<span class="cat-icon" style="background-image:url(\'%cat_icon_url%\');"><span class="cat-icon-overlay"></span></span>' . '%cat_name% ' . '<!-- IF %cat_user_can_edit% --><a href="%cat_edit_url%" class="edit" onclick="wpfbFBEditCat(event)">%\'Edit\'%</a><!-- ENDIF -->';
            WPFB_Core::SetCatTpls($cat_tpls);
            WPFB_Admin::ParseTpls();
        }
        WPFB_Output::FileBrowser($content, 0, empty($_GET['wpfb_cat']) ? 0 : intval($_GET['wpfb_cat']));
        WPFB_Core::PrintJS();
        ?>
    <div class="wrap filebrowser-admin"> 
    <h2><?php 
        _e('File Browser', WPFB);
        ?>
</h2>    
<?php 
        echo '<div>' . __('You can Drag &amp; Drop (multiple) files directly on Categories to upload them. Dragging a category or an existing file to another category is also possible.', WPFB) . '</div>';
        echo $content;
        ?>
	 </div>
<script>
	function wpfbFBEditCat(e) {
		e.stopPropagation();
	}
	
	function wpfbFBEditFile(e) {
		e.stopPropagation();
	}	
</script>
	
<?php 
    }
コード例 #4
0
ファイル: tpl-preview.php プロジェクト: TishoTM/WP-Filebase
<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'));
}
?>
				</div>
			</div>
		</div>
	</div>
コード例 #5
0
ファイル: Admin.php プロジェクト: parsonsc/dofe
 static function TplDropDown($type, $selected = null)
 {
     $tpls = WPFB_Core::GetTpls($type);
     $content = '<option value="default">' . __('Default') . '</option>';
     foreach ($tpls as $tag => $tpl) {
         if ($tag != 'default') {
             $content .= '<option value="' . $tag . '"' . ($selected == $tag ? ' selected="selected"' : '') . '>' . __(__(esc_attr(WPFB_Output::Filename2Title($tag))), WPFB) . '</option>';
         }
     }
     return $content;
 }
コード例 #6
0
ファイル: AdminGuiTpls.php プロジェクト: TishoTM/WP-Filebase
    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 
    }