function get_template($template_id, $section) { include STARRATING_PATH . 'code/t2/gd-star-t2-templates.php'; if (intval($template_id) == 0) { $t = GDSRDB::get_templates($section, true, true); $template_id = $t->template_id; } return new gdTemplateRender($template_id, $section); }
function render_templates_section($section, $name, $selected = "0", $width = 205) { $templates = GDSRDB::get_templates($section, true); ?> <select style="width: <?php echo $width; ?> px;" name="<?php echo $name; ?> " id="<?php echo $name; ?> "> <?php foreach ($templates as $t) { if ($t->template_id == $selected) { $select = ' selected="selected"'; } else { $select = ''; } echo sprintf('<option value="%s"%s>%s</option>', $t->template_id, $select, $t->name); } ?> </select> <?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 = GDSRDB::get_templates($filter_section); $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] . '</td>'; echo '<td>' . $t->description . '</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</a> | '; } if ($t->preinstalled == "0") {
function gdTemplateRender($id, $section) { $this->tpl = wp_gdsr_get_template($id); if (!is_object($this->tpl) || $this->tpl->section != $section) { $t = GDSRDB::get_templates($section, true, true); $id = $t->template_id; $this->tpl = wp_gdsr_get_template($id); } $this->dep = array(); $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) { preg_match_all('(%.+?%)', $value, $matches, PREG_PATTERN_ORDER); $this->tag[$key] = $matches[0]; } } }