function get_template($template_id, $section) { if (intval($template_id) == 0) { $t = gdTemplateDB::get_templates($section, true, true); $template_id = $t->template_id; wp_gdtpl_cache_template($t); } return new gdTemplateRender($template_id, $section); }
function get_template($template_id, $section) { include STARRATING_PATH . 'code/t2/templates.php'; if (intval($template_id) == 0) { $t = gdTemplateDB::get_templates($section, true, true); $template_id = $t->template_id; wp_gdtpl_cache_template($t); } return new gdTemplateRender($template_id, $section); }
function star_menu_t2() { $options = $this->g->o; $wpv = $this->g->wp_version; include STARRATING_PATH . 'code/t2/templates.php'; if (isset($_GET["tplid"])) { $id = $_GET["tplid"]; $mode = $_GET["mode"]; include STARRATING_PATH . 'gdt2/form_editor.php'; } else { if (isset($_POST["gdsr_create"])) { $id = 0; $mode = "new"; include STARRATING_PATH . 'gdt2/form_editor.php'; } else { if (isset($_POST["gdsr_setdefaults"])) { gdTemplateDB::set_templates_defaults($_POST["gdsr_section"]); } if (isset($_POST["gdsr_setdepends"])) { gdTemplateDB::set_templates_dependes($_POST["gdsr_tpl_dep"]); } include STARRATING_PATH . 'options/templates.php'; } } }
?> </th> <th scope="col"><?php _e("Tag", "gd-star-rating"); ?> </th> <th scope="col" style="text-align: right"><?php _e("Options", "gd-star-rating"); ?> </th> </tr> </thead> <tbody> <?php $templates = gdTemplateDB::get_templates_paged($filter_section, ($page_id - 1) * $posts_per_page, $posts_per_page); $tr_class = ""; foreach ($templates as $t) { $mode = $t->preinstalled == "0" ? "edit" : "copy"; $url = "admin.php?page=gd-star-rating-t2&"; echo '<tr id="post-' . $t->template_id . '" class="' . $tr_class . ' author-self status-publish" valign="top">'; echo '<td><strong>' . $t->template_id . '</strong></td>'; echo '<td><strong><a href="' . $url . 'mode=' . $mode . '&tplid=' . $t->template_id . '">' . $t->name . '</a></strong></td>'; echo '<td>' . $all_sections[$t->section] . ' [' . $t->section . ']' . '</td>'; echo '<td>' . $tpls->find_template_tag($t->section) . '</td>'; echo '<td style="text-align: right">'; if ($t->preinstalled == "0") { echo '<a href="' . $url . 'deltpl=' . $t->template_id . '">' . __("delete", "gd-star-rating") . '</a> | '; echo '<a href="' . $url . 'mode=edit&tplid=' . $t->template_id . '">' . __("edit", "gd-star-rating") . '</a> | '; } echo '<a href="' . $url . 'mode=copy&tplid=' . $t->template_id . '">' . __("duplicate", "gd-star-rating") . '</a>';
/** * Templates operations. */ function init_templates() { if (isset($_GET["deltpl"])) { $del_id = $_GET["deltpl"]; gdTemplateDB::delete_template($del_id); $url = remove_query_arg("deltpl"); wp_redirect($url); exit; } if (isset($_POST["gdsr_save_tpl"])) { $general = array(); $general["name"] = stripslashes(htmlentities($_POST['tpl_gen_name'], ENT_QUOTES, STARRATING_ENCODING)); $general["desc"] = stripslashes(htmlentities($_POST['tpl_gen_desc'], ENT_QUOTES, STARRATING_ENCODING)); $general["section"] = $_POST["tpl_section"]; $general["dependencies"] = $_POST["tpl_tpl"]; $general["id"] = $_POST["tpl_id"]; $general["preinstalled"] = '0'; $tpl_input = $_POST["tpl_element"]; $elements = array(); foreach ($tpl_input as $key => $value) { $elements[$key] = stripslashes(htmlentities($value, ENT_QUOTES, STARRATING_ENCODING)); } if ($general["id"] == 0) { $general["id"] = gdTemplateDB::add_template($general, $elements); } else { gdTemplateDB::edit_template($general, $elements); } if (isset($_POST["tpl_dep_rewrite"])) { gdTemplateDB::rewrite_dependencies($general["section"], $general["id"]); } if (isset($_POST["tpl_default_rewrite"])) { gdTemplateDB::rewrite_defaults($general["section"], $general["id"]); } $url = remove_query_arg("tplid"); $url = remove_query_arg("mode", $url); wp_redirect($url); exit; } }
<?php if (isset($_POST["gdsr_t2imp_own"])) { if (is_uploaded_file($_FILES["gdsr_t2_import_own"]["tmp_name"])) { $t2 = file($_FILES["gdsr_t2_import_own"]["tmp_name"]); unlink($_FILES["gdsr_t2_import_own"]["tmp_name"]); gdTemplateDB::import_templates_own($t2); } } if (isset($_POST["gdsr_t2imp_all"])) { if (is_uploaded_file($_FILES["gdsr_t2_import_all"]["tmp_name"])) { $t2 = file_get_contents($_FILES["gdsr_t2_import_all"]["tmp_name"]); unlink($_FILES["gdsr_t2_import_all"]["tmp_name"]); gdTemplateDB::import_templates_full($t2); } } ?> <div class="wrap"><h2 class="gdptlogopage">GD Star Rating: <?php _e("T2 Templates", "gd-star-rating"); ?> </h2> <div class="gdsr"> <div id="gdsr_tabs" class="gdsrtabs"> <ul> <li><a href="#fragment-1"><span><?php _e("Templates", "gd-star-rating"); ?> </span></a></li> <li><a href="#fragment-2"><span><?php
?> </th> <th scope="col"><?php _e("Name", "gd-star-rating"); ?> </th> <th scope="col"><?php _e("Dependencies", "gd-star-rating"); ?> </th> </tr> </thead> <tbody> <?php $templates = gdTemplateDB::get_templates_dep(); $tr_class = ""; foreach ($templates as $t) { $dependencies = unserialize($t->dependencies); if (is_array($dependencies)) { echo '<tr id="post-' . $t->template_id . '" class="' . $tr_class . ' author-self status-publish" valign="top">'; echo '<td><strong>' . $t->template_id . '</strong></td>'; echo '<td>' . $t->section . '</td>'; echo '<td>' . $t->name . '</td>'; echo '<td>'; gdTemplateHelper::prepare_dependencies($all_sections, $templates, $dependencies, $t->template_id); echo '</td>'; echo '</tr>'; if ($tr_class == "") { $tr_class = "alternate "; } else {
function gdTemplateRender($id, $section) { $this->dep = $this->tag = array(); $this->tpl = wp_gdtpl_get_template($id); if (!is_object($this->tpl) || $this->tpl->section != $section) { $t = gdTemplateDB::get_templates($section, true, true); $id = $t->template_id; $this->tpl = wp_gdtpl_get_template($id); } $dependencies = unserialize($this->tpl->dependencies); if (is_array($dependencies)) { foreach ($dependencies as $key => $value) { $this->dep[$key] = new gdTemplateRender($value, $key); } } $this->elm = unserialize($this->tpl->elements); if (is_array($this->elm)) { foreach ($this->elm as $key => $value) { $this->tag[$key] = array(); $this->custom[$key] = array(); $this->custom[$key] = wp_get_custom_tags($value); preg_match_all('(%.+?%)', $value, $matches, PREG_PATTERN_ORDER); if (is_array($matches[0])) { $this->tag[$key] = $matches[0]; } } } }