Example #1
0
function ultimatum_list_layouts()
{
    require_once 'ultimatum-widgets.php';
    global $wp_registered_widgets, $wp_registered_widget_controls;
    $sidebars_widgets = wp_get_sidebars_widgets();
    global $wpdb;
    $table = $wpdb->prefix . 'ultimatum_layout';
    $atable = $wpdb->prefix . 'ultimatum_layout_assign';
    $rtable = $wpdb->prefix . 'ultimatum_rows';
    $ctable = $wpdb->prefix . 'ultimatum_css';
    if ($_GET['delassigner']) {
        $sql1 = "DELETE FROM {$atable} WHERE `post_type`='" . $_GET['delassigner'] . "' AND `template`='" . THEME_CODE . "'";
        $wpdb->query($sql1);
        $url = "admin.php?page=wonder-layout&theme=" . $_GET['theme'];
        ?>
		<script language="JavaScript">
		parent.location.href='<?php 
        echo $url;
        ?>
';
		</script>
		<?php 
    }
    if ($_POST) {
        switch ($_POST[action]) {
            case 'delete':
                echo '<p>Deleting Layout :' . $layout['title'] . '... ';
                $sql1 = "DELETE FROM {$ctable} WHERE `layout_id`='{$_POST['source']}'";
                $wpdb->query($sql1);
                $sql1 = "DELETE FROM {$rtable} WHERE `layout_id`='{$_POST['source']}'";
                $wpdb->query($sql1);
                $sql1 = "DELETE FROM {$atable} WHERE `layout_id`='{$_POST['source']}'";
                $wpdb->query($sql1);
                $sql1 = "DELETE FROM {$table} WHERE `id`='{$_POST['source']}'";
                $wpdb->query($sql1);
                if (function_exists(ult_ms_getter)) {
                    $prel = ult_ms_getter();
                }
                $files[] = THEME_CACHE_DIR . '/skin_' . $prel . $_POST[source] . '.css';
                $files[] = THEME_CACHE_DIR . '/custom_' . $prel . $_POST[source] . '.css';
                $files[] = THEME_CACHE_DIR . '/layout_' . $prel . $_POST[source] . '.css';
                $files[] = THEME_CACHE_DIR . '/cufon_' . $prel . $_POST[source] . '.php';
                $files[] = THEME_CACHE_DIR . '/google_' . $prel . $_POST[source] . '.php';
                $files[] = THEME_CACHE_DIR . '/fontface_' . $prel . $_POST[source] . '.css';
                foreach ($files as $file) {
                    if (file_exists($file)) {
                        unlink($file);
                    }
                }
                echo 'Done.</p>';
                $url = curPageURL();
                ?>
			<script language="JavaScript">
				parent.location.href='<?php 
                echo $url;
                ?>
';
			</script>
			<?php 
                break;
            case 'create_new':
                $query = "INSERT INTO {$table} (`title`, `type`,`theme`) VALUES ('{$_POST['title']}', '{$_POST['type']}','{$_REQUEST['theme']}')";
                $wpdb->query($query);
                $layoutid = $wpdb->insert_id;
                if ($_POST[type] == "full") {
                    if (function_exists(ult_ms_getter)) {
                        $prel = ult_ms_getter();
                    }
                    $defql = "SELECT * FROM {$table} WHERE  `theme`='{$_REQUEST['theme']}' AND `default`=1";
                    $dfetch = $wpdb->get_row($defql, ARRAY_A);
                    $dlayout = $dfetch["id"];
                    $option = get_option(THEME_SLUG . '_' . $dlayout . '_css');
                    $newopt = update_option(THEME_SLUG . '_' . $layoutid . '_css', $option);
                    $file1 = THEME_CACHE_DIR . '/skin_' . $prel . $dlayout . '.css';
                    $file1new = THEME_CACHE_DIR . '/skin_' . $prel . $layoutid . '.css';
                    $file2 = THEME_CACHE_DIR . '/cufon_' . $prel . $dlayout . '.php';
                    $file2new = THEME_CACHE_DIR . '/cufon_' . $prel . $layoutid . '.php';
                    $file3 = THEME_CACHE_DIR . '/google_' . $prel . $dlayout . '.php';
                    $file3new = THEME_CACHE_DIR . '/google_' . $prel . $layoutid . '.php';
                    $file4 = THEME_CACHE_DIR . '/fontface_' . $prel . $dlayout . '.css';
                    $file4new = THEME_CACHE_DIR . '/fontface_' . $prel . $layoutid . '.css';
                    $file5 = THEME_CACHE_DIR . '/custom_' . $prel . $dlayout . '.css';
                    $file5new = THEME_CACHE_DIR . '/custom_' . $prel . $layoutid . '.css';
                    if (file_exists($file1)) {
                        copy($file1, $file1new);
                    }
                    if (file_exists($file2)) {
                        copy($file2, $file2new);
                    }
                    if (file_exists($file3)) {
                        copy($file3, $file3new);
                    }
                    if (file_exists($file4)) {
                        copy($file4, $file4new);
                    }
                    if (file_exists($file5)) {
                        copy($file5, $file5new);
                    }
                }
                $url = curPageURL() . '&task=edit&layoutid=' . $layoutid;
                ?>
			<script language="JavaScript">
				parent.location.href='<?php 
                echo $url;
                ?>
';
			</script>
			<?php 
                break;
            case 'copycss':
                if (function_exists(ult_ms_getter)) {
                    $prel = ult_ms_getter();
                }
                $tobecloned = $_POST["source"];
                $cloneid = $_POST["cloneid"];
                $select = "SELECT * FROM {$table} WHERE `id`='{$tobecloned}'";
                $sourcelayout = $wpdb->get_row($select, ARRAY_A);
                $option = get_option(THEME_SLUG . '_' . $tobecloned . '_css');
                $newopt = update_option(THEME_SLUG . '_' . $cloneid . '_css', $option);
                $file1 = THEME_CACHE_DIR . '/skin_' . $prel . $tobecloned . '.css';
                $file1new = THEME_CACHE_DIR . '/skin_' . $prel . $cloneid . '.css';
                $file2 = THEME_CACHE_DIR . '/cufon_' . $prel . $tobecloned . '.php';
                $file2new = THEME_CACHE_DIR . '/cufon_' . $prel . $cloneid . '.php';
                $file3 = THEME_CACHE_DIR . '/google_' . $prel . $tobecloned . '.php';
                $file3new = THEME_CACHE_DIR . '/google_' . $prel . $cloneid . '.php';
                $file4 = THEME_CACHE_DIR . '/fontface_' . $prel . $tobecloned . '.css';
                $file4new = THEME_CACHE_DIR . '/fontface_' . $prel . $cloneid . '.css';
                $file5 = THEME_CACHE_DIR . '/custom_' . $prel . $tobecloned . '.css';
                $file5new = THEME_CACHE_DIR . '/custom_' . $prel . $cloneid . '.css';
                if (file_exists($file1)) {
                    copy($file1, $file1new);
                }
                if (file_exists($file2)) {
                    copy($file2, $file2new);
                }
                if (file_exists($file3)) {
                    copy($file3, $file3new);
                }
                if (file_exists($file4)) {
                    copy($file4, $file4new);
                }
                if (file_exists($file5)) {
                    copy($file5, $file5new);
                }
                $url = 'admin.php?page=wonder-css&layout=' . $cloneid;
                ?>
			<script language="JavaScript">
				parent.location.href='<?php 
                echo $url;
                ?>
';
			</script>
			<?php 
                break;
            case 'clone':
                $messedids = array();
                if (function_exists(ult_ms_getter)) {
                    $prel = ult_ms_getter();
                }
                $ultimatum_sidebars_widgets = get_option('ultimatum_sidebars_widgets');
                $tobecloned = $_POST["source"];
                $select = "SELECT * FROM {$table} WHERE `id`='{$tobecloned}'";
                $sourcelayout = $wpdb->get_row($select, ARRAY_A);
                // Clone it and get its id
                $title = $sourcelayout[title] . '(copy)';
                $cloneql = "INSERT INTO {$table} (`title`,`type`,`before`,`after`,`theme`) VALUES ('{$title}','{$sourcelayout['type']}','{$sourcelayout['before']}','{$sourcelayout['after']}','{$sourcelayout['theme']}')";
                $cloneql = $wpdb->query($cloneql);
                $cloneid = $wpdb->insert_id;
                $option = get_option(THEME_SLUG . '_' . $tobecloned . '_css');
                $newopt = update_option(THEME_SLUG . '_' . $cloneid . '_css', $option);
                $file1 = THEME_CACHE_DIR . '/skin_' . $prel . $tobecloned . '.css';
                $file1new = THEME_CACHE_DIR . '/skin_' . $prel . $cloneid . '.css';
                $file2 = THEME_CACHE_DIR . '/cufon_' . $prel . $tobecloned . '.php';
                $file2new = THEME_CACHE_DIR . '/cufon_' . $prel . $cloneid . '.php';
                $file3 = THEME_CACHE_DIR . '/google_' . $prel . $tobecloned . '.php';
                $file3new = THEME_CACHE_DIR . '/google_' . $prel . $cloneid . '.php';
                $file4 = THEME_CACHE_DIR . '/fontface_' . $prel . $tobecloned . '.css';
                $file4new = THEME_CACHE_DIR . '/fontface_' . $prel . $cloneid . '.css';
                $file5 = THEME_CACHE_DIR . '/custom_' . $prel . $tobecloned . '.css';
                $file5new = THEME_CACHE_DIR . '/custom_' . $prel . $cloneid . '.css';
                if (file_exists($file1)) {
                    copy($file1, $file1new);
                }
                if (file_exists($file2)) {
                    copy($file2, $file2new);
                }
                if (file_exists($file3)) {
                    copy($file3, $file3new);
                }
                if (file_exists($file4)) {
                    copy($file4, $file4new);
                }
                if (file_exists($file5)) {
                    copy($file5, $file5new);
                }
                // Do the Rows
                $rows = explode(',', $sourcelayout["rows"]);
                foreach ($rows as $row) {
                    $query = "SELECT * FROM {$rtable} WHERE id={$row}";
                    $sourcerow = $wpdb->get_row($query, ARRAY_A);
                    $rtype = $sourcerow["type_id"];
                    $insertrow = "INSERT INTO {$rtable} (`layout_id`,`type_id`) VALUES ('{$cloneid}','{$rtype}')";
                    $insertrow = $wpdb->query($insertrow);
                    $newrowid = $wpdb->insert_id;
                    $newrows[] = $newrowid;
                    // DO CSS
                    // 1- Wrapper
                    $oldw = 'wrapper-' . $row;
                    $qw = "SELECT * FROM {$ctable} WHERE `container`='{$oldw}' AND `layout_id`='{$tobecloned}'";
                    $qwf = $wpdb->get_row($qw, ARRAY_A);
                    if ($qwf) {
                        $neww = 'wrapper-' . $newrowid;
                        $newwi = "INSERT INTO {$ctable} (`container`,`layout_id`,`element`,`properties`) VALUES ('{$neww}','{$cloneid}','{$qwf['element']}','{$qwf['properties']}')";
                        $newwi = $wpdb->query($newwi);
                    }
                    // 2- Container
                    $oldw = 'container-' . $row;
                    $qw = "SELECT * FROM {$ctable} WHERE `container`='{$oldw}' AND `layout_id`='{$tobecloned}'";
                    $qwf = $wpdb->get_row($qw, ARRAY_A);
                    if ($qwf) {
                        $neww = 'container-' . $newrowid;
                        $newwi = "INSERT INTO {$ctable} (`container`,`layout_id`,`element`,`properties`) VALUES ('{$neww}','{$cloneid}','{$qwf['element']}','{$qwf['properties']}')";
                        $newwi = $wpdb->query($newwi);
                    }
                    // 3- Columns
                    global $wp_registered_widgets;
                    for ($j = 1; $j <= 5; $j++) {
                        $oldw = 'col-' . $row . '-' . $j;
                        $olds = 'sidebar-' . $row . '-' . $j;
                        $neww = 'col-' . $newrowid . '-' . $j;
                        $newsb = 'sidebar-' . $newrowid . '-' . $j;
                        // 4- Widgets !!! next_widget_id_number
                        if (count($ultimatum_sidebars_widgets[$olds]) >= 1) {
                            foreach ($ultimatum_sidebars_widgets[$olds] as $id) {
                                if (isset($wp_registered_widgets[$id])) {
                                    $fwidget = $wp_registered_widgets[$id];
                                    $id_base = $wp_registered_widget_controls[$fwidget['id']]['id_base'];
                                    $currentwid = str_replace($id_base . '-', '', $fwidget[id]);
                                    $callback = $wp_registered_widgets[$id]['callback'][0];
                                    $option = $callback->option_name;
                                    $warray = get_option($option);
                                    if (isset($messedids[$option])) {
                                        $nextid = $messedids[$option] + 1;
                                        $messedids[$option] = $nextid;
                                    } else {
                                        $nextid = next_widget_id_number($id_base);
                                        $messedids[$option] = $nextid;
                                    }
                                    $warray[$nextid] = $warray[$currentwid];
                                    //print_r($warray);
                                    update_option($option, $warray);
                                    $ultimatum_sidebars_widgets[$newsb][] = $id_base . '-' . $nextid;
                                    update_option('ultimatum_sidebars_widgets', $ultimatum_sidebars_widgets);
                                    unset($warray);
                                }
                            }
                        }
                        $qw = "SELECT * FROM {$ctable} WHERE `container`='{$oldw}' AND `layout_id`='{$tobecloned}'";
                        $qwf = $wpdb->get_row($qw, ARRAY_A);
                        if ($qwf) {
                            $newwi = "INSERT INTO {$ctable} (`container`,`layout_id`,`element`,`properties`) VALUES ('{$neww}','{$cloneid}','{$qwf['element']}','{$qwf['properties']}')";
                            $newwi = $wpdb->query($newwi);
                        }
                    }
                }
                // Insert rows
                $newrow = implode(',', $newrows);
                $update = "UPDATE {$table} SET `rows`='{$newrow}' WHERE id='{$cloneid}'";
                $wpdb->query($update);
                // Generate CSS file
                $query = "SELECT * FROM {$ctable} WHERE layout_id='{$cloneid}'";
                $res = $wpdb->get_results($query, ARRAY_A);
                $css = '';
                foreach ($res as $fetch) {
                    if ($fetch["element"] == 'general') {
                        if ($fetch["container"] != 'body') {
                            if (eregi('col-', $fetch["container"])) {
                                $el = '#' . $fetch["container"] . ' .colwrapper';
                            } else {
                                $el = '#' . $fetch["container"];
                            }
                        } else {
                            $el = $fetch["container"];
                        }
                    } elseif ($fetch["container"] == 'body') {
                        if ($fetch["element"] == 'h1' || $fetch["element"] == 'h2' || $fetch["element"] == 'h3' || $fetch["element"] == 'h4' || $fetch["element"] == 'h5' || $fetch["element"] == 'h6') {
                            $fetch["element"] = $fetch["element"] . ', ' . $fetch["element"] . ' a,' . $fetch["element"] . ' a:hover';
                        }
                        $el = $fetch["element"];
                        if ($el == 'ahover') {
                            $el = 'a:hover';
                        }
                    } else {
                        if ($fetch["element"] == 'ahover') {
                            $fetch["element"] = 'a:hover';
                        }
                        if ($fetch["element"] == 'h1' || $fetch["element"] == 'h2' || $fetch["element"] == 'h3' || $fetch["element"] == 'h4' || $fetch["element"] == 'h5' || $fetch["element"] == 'h6') {
                            //$fetch["element"]=$fetch["element"].', '.$fetch["element"].' a,'.$fetch["element"].' a:hover';
                            $el = '#' . $fetch["container"] . ' ' . $fetch["element"] . ', #' . $fetch["container"] . ' ' . $fetch["element"] . ' a, #' . $fetch["container"] . ' ' . $fetch["element"] . ' a:hover';
                        } else {
                            $el = '#' . $fetch["container"] . ' ' . $fetch["element"];
                        }
                    }
                    $proprties = parseCSS($fetch["properties"]);
                    if (count($proprties) != 0) {
                        $css .= $el . '{' . implode(';', $proprties) . '}';
                    }
                }
                if (is_multisite()) {
                    global $blog_id;
                    $file = THEME_CACHE_DIR . '/layout_' . $blog_id . '_' . $cloneid . '.css';
                } else {
                    $file = THEME_CACHE_DIR . '/layout_' . $cloneid . '.css';
                }
                $fhandle = @fopen($file, 'w+');
                if ($fhandle) {
                    fwrite($fhandle, $css, strlen($css));
                }
                unset($_POST);
                $url = curPageURL();
                ?>
			<script language="JavaScript">
				parent.location.href='<?php 
                echo $url;
                ?>
';
			</script>
			<?php 
                break;
            case 'assign':
                //
                $query = "REPLACE INTO {$atable} VALUES ('" . THEME_CODE . "','{$_POST['posttype']}','{$_POST['layout']}')";
                $wpdb->query($query);
                break;
            case 'setdefault':
                $query = "UPDATE {$table} SET `default`=0 WHERE `theme`='{$_REQUEST['theme']}'";
                $wpdb->query($query);
                $query = "UPDATE {$table} SET `default`=1 WHERE `id`='{$_POST['default']}'";
                $wpdb->query($query);
                unset($_POST);
                $url = curPageURL();
                ?>
			<script language="JavaScript">
				parent.location.href='<?php 
                echo $url;
                ?>
';
			</script>
			<?php 
                break;
            default:
                echo '<h3>Illegal operation</h3>';
                break;
        }
    }
    $query = "SELECT * FROM {$table} WHERE `type`='full' AND `theme`='{$_REQUEST['theme']}' ORDER BY `default` DESC, `title` ASC";
    $result = $wpdb->get_results($query, ARRAY_A);
    $queryp = "SELECT * FROM {$table} WHERE `type`='part' AND `theme`='{$_REQUEST['theme']}' ORDER BY `title` ASC";
    $resultp = $wpdb->get_results($queryp, ARRAY_A);
    foreach ($result as $layout) {
        $full[] = $layout;
        $lid = $layout["id"];
    }
    $next_id = $lid + 1;
    ?>
	<script langage="JavaScript">
<!--

function confirmSubmit()
{
var agree=confirm("Are you sure you wish to continue?");
if (agree)
	return true ;
else
	return false ;
}
// -->
</script>
	<h2><?php 
    echo _e('Layouts', THEME_ADMIN_LANG_DOMAIN);
    ?>
 - <?php 
    themeName($_REQUEST['theme']);
    ?>
</h2>
<table width="100%">
	<tr valign="top">
		<td rowspan="2">
				<form method="post" action="">
				<table class="widefat" style="height:100%">
					<thead>
						<tr>
							<th colspan="2"><?php 
    _e('Create a new Layout', THEME_ADMIN_LANG_DOMAIN);
    ?>
</th>
						</tr>
					</thead>
					<tfoot>
						<tr>
							<td colspan="2">
								<input type="hidden" name="action" value="create_new" />
								
								<input type="submit" value="<?php 
    _e('Save', THEME_ADMIN_LANG_DOMAIN);
    ?>
" />
							</td>
						</tr>
					</tfoot>
					<tbody>
						<tr>
							<td nowrap="nowrap"><label><?php 
    _e('Layout Name', THEME_ADMIN_LANG_DOMAIN);
    ?>
 :</label></td>
							<td><input type="text" name="title" value="<?php 
    _e('Layout Name', THEME_ADMIN_LANG_DOMAIN);
    ?>
" /></td>
						</tr>
						<tr>
							<td nowrap="nowrap">
								<label><?php 
    _e('Layout Type', THEME_ADMIN_LANG_DOMAIN);
    ?>
 :</label>
							</td>
							<td>
							<p><i><strong><?php 
    _e('Full Layouts', THEME_ADMIN_LANG_DOMAIN);
    ?>
</strong> <?php 
    _e('are the main layouts that you can assign to post types and posts or pages.', THEME_ADMIN_LANG_DOMAIN);
    ?>
</i></p>
							<p><i><strong><?php 
    _e('Partial Layouts', THEME_ADMIN_LANG_DOMAIN);
    ?>
</strong> <?php 
    _e('are the layouts that you might want to use more then once. You can include them before or after the main section of a full layout.', THEME_ADMIN_LANG_DOMAIN);
    ?>
</i></p>
								<select name="type">
									<option value="full"><?php 
    _e('Full', THEME_ADMIN_LANG_DOMAIN);
    ?>
</option>
									<option value="part"><?php 
    _e('Part', THEME_ADMIN_LANG_DOMAIN);
    ?>
</option>
								</select>
							</td>
						</tr>
						
					</tbody>
				</table>
				</form>
		</td>
		<td>
			<form method="post" action="">
			<table class="widefat">
					<thead>
						<tr>
							<th colspan="2"><?php 
    _e('Set Default Layout', THEME_ADMIN_LANG_DOMAIN);
    ?>
</th>
						</tr>
					</thead>
					<tfoot>
						<tr>
							<td colspan="2">
								<input type="hidden" name="action" value="setdefault" />
								<input type="submit" value="<?php 
    _e('Save', THEME_ADMIN_LANG_DOMAIN);
    ?>
" />
							</td>
						</tr>
					</tfoot>
					<tbody>
						<tr>
							<td>
								<label><?php 
    _e('Layout', THEME_ADMIN_LANG_DOMAIN);
    ?>
:</label>
							</td>
							<td>
								<p><i><?php 
    _e('If no layouts for the requested page/post and their types this layout will be shown', THEME_ADMIN_LANG_DOMAIN);
    ?>
.</i></p>
								<select name="default">
									<?php 
    if ($full) {
        foreach ($full as $layout) {
            echo '<option value="' . $layout["id"] . '">' . $layout["title"] . '</option>';
        }
    }
    ?>
								</select>
							</td>
						</tr>
					</tbody>
				</table>
				</form>
		</td>
	</tr>
	<tr>
		<td>
			<form method="post" action="">
			<table class="widefat">
					<thead>
						<tr>
							<th colspan="2"><?php 
    _e('Assign Layout to Post/Page Types', THEME_ADMIN_LANG_DOMAIN);
    ?>
</th>
						</tr>
					</thead>
					<tfoot>
						<tr>
							<td colspan="2">
								<input type="hidden" name="action" value="assign" />
								<input type="submit" value="<?php 
    _e('Save', THEME_ADMIN_LANG_DOMAIN);
    ?>
" />
							</td>
						</tr>
					</tfoot>
					<tbody>
						<tr>
							<td>
								<label><?php 
    _e('Layout', THEME_ADMIN_LANG_DOMAIN);
    ?>
:</label>
							</td>
							<td>
								<p><i><?php 
    _e('If no layouts for the requested page/post this layout will be shown for it', THEME_ADMIN_LANG_DOMAIN);
    ?>
.</i></p>
								<select name="layout">
								
									<?php 
    if ($full) {
        foreach ($full as $layout) {
            echo '<option value="' . $layout["id"] . '">' . $layout["title"] . '</option>';
        }
    }
    ?>
								
								</select>
							</td>
						</tr>
						<tr>
							<td nowrap="nowrap">
								<label><?php 
    _e('Post/Page Type', THEME_ADMIN_LANG_DOMAIN);
    ?>
:</label>
							</td>
							<td>
								<select name="posttype">
									<optgroup label="Core">
										<option value="search"><?php 
    _e('Search', THEME_ADMIN_LANG_DOMAIN);
    ?>
</option>
										<option value="404">404</option>
										<option value="author"><?php 
    _e('author', THEME_ADMIN_LANG_DOMAIN);
    ?>
</option>
									</optgroup>
									<optgroup label="<?php 
    _e('Post Types', THEME_ADMIN_LANG_DOMAIN);
    ?>
">
									<option value="page">page</option>
									<?php 
    $args = array('public' => true, 'publicly_queryable' => true);
    $post_types = get_post_types($args, 'names');
    foreach ($post_types as $post_type) {
        if ($post_type != 'attachment') {
            echo '<option value="' . $post_type . '">' . $post_type . '</option>';
            echo '<option value="' . $post_type . '-single">' . $post_type . '-' . __('single', THEME_ADMIN_LANG_DOMAIN) . '</option>';
        }
    }
    echo '</optgroup>';
    $entries = get_categories('title_li=&orderby=name&hide_empty=1');
    if (count($entries) >= 1) {
        echo '<optgroup label="' . __('Categories (post)', THEME_ADMIN_LANG_DOMAIN) . '">';
        foreach ($entries as $key => $entry) {
            echo '<option value="cat-' . $entry->term_id . '" ' . '>' . $entry->name . '</option>';
        }
        echo '</optgroup>';
    }
    $termstable = $wpdb->prefix . 'ultimatum_tax';
    $termsql = "SELECT * FROM {$termstable}";
    $termresult = $wpdb->get_results($termsql, ARRAY_A);
    foreach ($termresult as $term) {
        $properties = unserialize($term["properties"]);
        echo '<optgroup label="' . $properties["label"] . '(' . $term["pname"] . ')">';
        $entries = get_terms($properties["name"], 'orderby=name&hide_empty=1');
        foreach ($entries as $key => $entry) {
            $optiont = $term["pname"] . '-' . $term["tname"] . '-' . $entry->slug;
            echo '<option value="' . $optiont . '" ' . '>' . $entry->name . '</option>';
        }
        echo '</optgroup>';
    }
    ?>
								</select>
							</td>
						</tr>
					</tbody>
				</table>
				</form>			
		</td>
	</tr>
</table>
	<h2><a name="full"><?php 
    _e('Full Layouts', THEME_ADMIN_LANG_DOMAIN);
    ?>
</a></h2>
	<table class="widefat wp-list-table">
	<thead>
	<tr>
		<th><?php 
    _e('Layout Name', THEME_ADMIN_LANG_DOMAIN);
    ?>
</th>
		<th><?php 
    _e('Assigned to', THEME_ADMIN_LANG_DOMAIN);
    ?>
</th>
		<th><?php 
    _e('Actions', THEME_ADMIN_LANG_DOMAIN);
    ?>
</th>
	</tr>
	</thead>
	<tbody>
	<?php 
    if ($full) {
        foreach ($full as $layout) {
            echo '<tr style="height:40px;">';
            echo '<td style="font-size:14px;">';
            echo '<a href="./admin.php?page=wonder-layout&task=edit&theme=' . $_REQUEST['theme'] . '&layoutid=' . $layout["id"] . '">' . $layout["title"] . '</a>';
            if ($layout['default'] == '1') {
                echo '[default] ';
            }
            echo '</td>';
            echo '<td>';
            $getassigned = "SELECT * FROM {$atable} WHERE `layout_id`='{$layout['id']}'";
            $gres = $wpdb->get_results($getassigned, ARRAY_A);
            foreach ($gres as $gfecth) {
                if (eregi('cat-', $gfecth["post_type"])) {
                    $cat = str_replace('cat-', '', $gfecth["post_type"]);
                    $thisCat = get_category($cat, false);
                    $gfecth["post_type"] = 'posts-' . $thisCat->name;
                }
                $posttypes[] = $gfecth["post_type"];
            }
            if (isset($posttypes)) {
                foreach ($posttypes as $posttyped) {
                    ?>
		<div style="margin-right:10px;height:25px;line-height:25px;padding:5px;background:#d3d3d3;border-radius:4px;width:auto;float:left;">
		<a style="color:red;margin-left:-3px;margin-top:-15px;" href="admin.php?page=wonder-layout&delassigner=<?php 
                    echo $posttyped;
                    ?>
&theme=<?php 
                    echo $_REQUEST['theme'];
                    ?>
">x</a>
		<?php 
                    echo $posttyped;
                    ?>
		</div>
		<?php 
                }
                unset($posttypes);
            }
            echo '</td>';
            echo '<td><p>';
            echo '<a class="button-primary autowidth" href="./admin.php?page=wonder-layout&task=edit&theme=' . $_REQUEST['theme'] . '&layoutid=' . $layout["id"] . '">' . __('Edit', THEME_ADMIN_LANG_DOMAIN) . '</a>&nbsp;<a class="button-primary autowidth" href="./admin.php?page=wonder-css&&layout=' . $layout["id"] . '">' . __('Edit CSS', THEME_ADMIN_LANG_DOMAIN) . '</a>';
            echo '<form method="post" action=""><input type="hidden" name="action" value="clone"/><input type="hidden" name="source" value="' . $layout["id"] . '" /><input type="submit" value="' . __('Clone Layout', THEME_ADMIN_LANG_DOMAIN) . '" /></form>';
            echo '<form method="post" action=""><input type="hidden" name="action" value="delete"/><input type="hidden" name="source" value="' . $layout["id"] . '" /><input type="submit" value="' . __('Delete Layout', THEME_ADMIN_LANG_DOMAIN) . '" onClick="return confirmSubmit()" /></form>';
            echo '</p></td>';
            echo '</tr>';
        }
    }
    ?>
	</tbody>
	</table>
	<h2><a name="part"><?php 
    _e('Partial Layouts', THEME_ADMIN_LANG_DOMAIN);
    ?>
</a></h2>
	<table class="widefat">
	<thead>
	<tr>
		<th><?php 
    _e('Layout Name', THEME_ADMIN_LANG_DOMAIN);
    ?>
</th>
		<th><?php 
    _e('Actions', THEME_ADMIN_LANG_DOMAIN);
    ?>
</th>
	</tr>
	</thead>
	<tbody>
	<?php 
    foreach ($resultp as $layout) {
        echo '<tr style="height:40px;">';
        echo '<td style="font-size:14px;">';
        echo '<a href="./admin.php?page=wonder-layout&task=edit&layoutid=' . $layout["id"] . '">' . $layout["title"] . '</a></td>';
        echo '<td>';
        echo '<a class="button-primary autowidth" href="./admin.php?page=wonder-layout&task=edit&theme=' . $_REQUEST['theme'] . '&layoutid=' . $layout["id"] . '">' . __('Edit', THEME_ADMIN_LANG_DOMAIN) . '</a>';
        echo '<form method="post" action=""><input type="hidden" name="action" value="delete"/><input type="hidden" name="source" value="' . $layout["id"] . '" /><input type="submit" value="' . __('Delete Layout', THEME_ADMIN_LANG_DOMAIN) . '" onClick="return confirmSubmit()" /></form>';
        echo '</td>';
        echo '</tr>';
    }
    ?>
	</tbody>
	</table>
	<?php 
}
Example #2
0
<?php

/**
 * @var GameServersController $this
 * @var Gs $gs
 * @var ShopCategories $category
 * @var ShopItemsPacks $pack
 * @var ShopItems[] $model
 */
$assetsUrl = app()->getAssetManager()->publish(Yii::getPathOfAlias('webroot.themes.' . themeName() . '.assets'), FALSE, -1, YII_DEBUG);
js($assetsUrl . '/js/typeahead.bundle.min.js', CClientScript::POS_END);
js($assetsUrl . '/js/search-items.js', CClientScript::POS_END);
$title__ = Yii::t('backend', 'Наборы');
$this->pageTitle = $title__;
$this->breadcrumbs = array(Yii::t('backend', 'Сервера') => array('/backend/gameServers/index'), $gs->name . ' - ' . Yii::t('backend', 'Магазин') => array('/backend/gameServers/shop', 'gs_id' => $gs->id), Yii::t('backend', 'Наборы для категории - :category_name', array(':category_name' => $category->name)) => array('/backend/gameServers/shopCategoryPacks', 'gs_id' => $gs->id, 'category_id' => $category->id), Yii::t('backend', 'Предметы в наборе - :pack_name', array(':pack_name' => $pack->title)) => array('/backend/gameServers/shopCategoryPackItems', 'gs_id' => $gs->id, 'category_id' => $category->id, 'pack_id' => $pack->id), $this->getAction()->id == 'shopCategoryPackCreateItem' ? Yii::t('backend', 'Добавление предмета') : Yii::t('backend', 'Редактирование предмета'));
?>

<script>
    var urlItemInfo = '<?php 
echo $this->createUrl('/backend/default/getItemInfo');
?>
';
</script>

<?php 
$form = $this->beginWidget('ActiveForm', array('id' => $this->getId() . '-form', 'htmlOptions' => array('class' => 'form-horizontal')));
?>

    <?php 
echo $form->errorSummary($model);
?>
Example #3
0
function theme()
{
    return 'themes/' . themeName();
}