private function _dialog_template()
    {
        global $wpdb, $wpddlayout;
        ob_start();
        ?>

				<?php 
        if (isset($_GET['layout_id'])) {
            $layout = $wpddlayout->get_layout_settings($_GET['layout_id'], true);
            if ($layout && isset($layout->has_child) && ($layout->has_child === 'true' || $layout->has_child === true)) {
                ?>
						<ul class="tree js-child-layout-list">
							 <li class="js-tree-category js-tree-category-title">
								<h3 class="tree-category-title">
									<?php 
                _e('Select Child layout for editing', 'ddl-layouts');
                ?>
								</h3>

								<ul class="js-tree-category-items">

									<?php 
                $layout_slug = $layout->slug;
                $post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_type=%s AND post_status = 'publish'", WPDDL_LAYOUTS_POST_TYPE));
                foreach ($post_ids as $post_id) {
                    $layout = $wpddlayout->get_layout_settings($post_id, true);
                    if (is_object($layout) && property_exists($layout, 'parent') && $layout->parent == $layout_slug) {
                        ?>

												<li class="js-tree-category-item">
													<p class="item-name-wrap js-item-name-wrap">
														<a href="#" class="js-switch-to-layout" data-layout-id="<?php 
                        echo $post_id;
                        ?>
">
															<span class="js-item-name js-child-layout-item"><?php 
                        echo $layout->name;
                        ?>
</span>
														</a>
													</p>
												</li> <!-- .js-tree-category-item -->

												<?php 
                    }
                }
                ?>

									<?php 
                // ( while ( has_child_ddl_layouts() ) : the_child_layout(); )
                ?>
								</ul> <!-- . js-tree-category-items -->
							</li>

						</ul> <!-- .js-tree-category-items -->
						<?php 
            }
        }
        ?>

                    <?php 
        if ($wpddlayout->is_embedded() === false) {
            ?>
					<input type="button" class="button js-create-new-child-layout" data-url="<?php 
            echo admin_url() . 'admin.php?page=dd_layouts&new_layout=true';
            ?>
" value="<?php 
            _e('Create a new child layout', 'ddl-layouts');
            ?>
">
					<?php 
        }
        ?>

					<?php 
        ddl_add_help_link_to_dialog(WPDLL_CHILD_LAYOUT_CELL, __('Learn about the Child layout cell', 'ddl-layouts'));
        ?>
					

		<?php 
        return ob_get_clean();
    }
    private function _dialog_template()
    {
        add_filter('user_can_richedit', array(__CLASS__, '__true'), 100);
        ob_start();
        ?>
			<div class="ddl-form">

				<div class="ddl-form-item">
					<fieldset>
						<p class="fields-group">
							<label class="checkbox" for="<?php 
        the_ddl_name_attr('responsive_images');
        ?>
">
								<input type="checkbox" name="<?php 
        the_ddl_name_attr('responsive_images');
        ?>
" id="<?php 
        the_ddl_name_attr('responsive_images');
        ?>
">
								<?php 
        _e('Display images with responsive size', 'ddl-layouts');
        ?>
							</label>
						</p>
					</fieldset>
				</div>

				<div class="ddl-form-item">
					<fieldset>
						<p class="fields-group">
							<label class="checkbox" for="<?php 
        the_ddl_name_attr('disable_auto_p');
        ?>
">
								<input type="checkbox" name="<?php 
        the_ddl_name_attr('disable_auto_p');
        ?>
" id="<?php 
        the_ddl_name_attr('disable_auto_p');
        ?>
">
								<?php 
        _e('Disable automatic paragraphs', 'ddl-layouts');
        ?>
							</label>
						</p>
						
					</fieldset>
				</div>
				
				<div class="js-visual-editor-views-shortcode-notification"
					 data-view="<?php 
        esc_attr_e("It looks like you are trying to display a View. For your convenience, Layouts now comes with a View cell, which will let you achieve this much easier. We suggest that you try the new 'Views Content Grid' cell. You will be able to insert an existing View or create a new View.", 'ddl-layouts');
        ?>
"
					 data-content-template="<?php 
        esc_attr_e("It looks like you are trying to display fields. For your convenience, Layouts now comes with a Content Template cell, which will let you achieve this much easier.", 'ddl-layouts');
        ?>
"
					 data-cred="<?php 
        esc_attr_e("It looks like you are trying to display a Form. For your convenience, Layouts now comes with a CRED form cell, which will let you achieve this much easier. We suggest that you try the new 'CRED Form' cell. You will be able to insert an existing Form or create a new Form.", 'ddl-layouts');
        ?>
">
				</div>
			</div>

            <div id="visual-editor-editor-container" class="js-visual-editor-editor-container ddl-form">
                <div id="js-visual-editor-tinymce">
                    <?php 
        $this->do_tinymce();
        ?>
                </div>
                <div id="js-visual-editor-codemirror">
                    <?php 
        $this->do_codemirror();
        ?>
                </div>
                <div id="visual-editor-editor-switch-message"></div>
                <p id="visual-editor-editor-switch-container">
                    <a class="js-visual-editor-toggle" data-editor="tinymce"><?php 
        esc_attr_e('Switch to the WordPress Visual Editor', 'ddl-layouts');
        ?>
</a>
                    <a class="js-visual-editor-toggle" data-editor="codemirror"><?php 
        esc_attr_e('Switch to HTML editing', 'ddl-layouts');
        ?>
</a>
                    <input type="hidden" id="preferred_editor" value="<?php 
        $ddl_preferred_editor = get_user_option('ddl_preferred_editor', get_current_user_id());
        echo esc_attr($ddl_preferred_editor !== false ? $ddl_preferred_editor : 'tinymce');
        ?>
">
                </p>
            </div>

			<div class="ddl-form">
				<div class="ddl-form-item">
					<br />
					<?php 
        ddl_add_help_link_to_dialog(WPDLL_RICH_CONTENT_CELL, __('Learn about the Visual editor cell', 'ddl-layouts'));
        ?>
				</div>
			</div>
		<?php 
        return ob_get_clean();
    }
    private function _dialog_template()
    {
        global $wp_registered_sidebars;
        ob_start();
        ?>

		<div class="ddl-form">
			<p class="js-widget-area-select">
				<label for="<?php 
        echo $this->element_name('widget_area');
        ?>
"><?php 
        _e('Select an existing widget area', 'ddl-layouts');
        ?>
</label>
				<select name="<?php 
        echo $this->element_name('widget_area');
        ?>
">
				<?php 
        foreach ($wp_registered_sidebars as $sidebar) {
            ?>
					<option val="<?php 
            echo $sidebar['id'];
            ?>
"><?php 
            echo $sidebar['name'];
            ?>
</option>
				<?php 
        }
        ?>
				</select>
			</p>

			<?php 
        ddl_add_help_link_to_dialog(WPDLL_WIDGET_AREA_CELL, __('Learn about the Widget Area cell', 'ddl-layouts'));
        ?>
			
			<?php 
        // Don't show the create new widget area button in this version
        // We'll complete this later
        ?>
			<p class="js-create-new-widget-area-button ddl-form hidden">
				<label><?php 
        _e('Or', 'ddl-layouts');
        ?>
</label>
				<button class="js-create-new-sidebar button-secondary"><?php 
        _e('Create a new widget area', 'ddl-layouts');
        ?>
</button>
			</p>
		</div>

		<ul class="create-new-sidebar-div js-create-new-sidebar-div ddl-form hidden">
			<li>
				<label for="ddl-sidebar-name"><?php 
        _e('Name:', 'ddl-layouts');
        ?>
</label>
				<input type='text' name="ddl-sidebar-name">
			</li>
			<li>
				<label for="ddl-sidebar-description"><?php 
        _e('Description:', 'ddl-layouts');
        ?>
</label>
				<input type='text' name="ddl-sidebar-description">
			</li>
			<li>
				<label for="ddl-sidebar-class"><?php 
        _e('Class:', 'ddl-layouts');
        ?>
</label>
				<input type='text' name="ddl-sidebar-class">
			</li>
			<li>
				<label for="ddl-sidebar-before-widget"><?php 
        _e('Before widget:', 'ddl-layouts');
        ?>
</label>
				<input type='text' name="ddl-sidebar-before-widget" value="">
			</li>
			<li>
				<label for="ddl-sidebar-after-widget"><?php 
        _e('After widget:', 'ddl-layouts');
        ?>
</label>
				<input type='text' name="ddl-sidebar-after-widget" value="">
			</li>
			<li>
				<label for="ddl-sidebar-before-title"><?php 
        _e('Before title:', 'ddl-layouts');
        ?>
</label>
				<input type='text' name="ddl-sidebar-before-title" value="">
			</li>
			<li>
				<label for="ddl-sidebar-after-title"><?php 
        _e('After title:', 'ddl-layouts');
        ?>
</label>
				<input type='text' name="ddl-sidebar-after-title" value="">
			</li>
			<li>
				<a href="http://codex.wordpress.org/Function_Reference/register_sidebar" target="_blank"><?php 
        _e('Information about these settings', 'ddl-layouts');
        ?>
</a>
			</li>

		</ul>

		<?php 
        // TODO: Review this. I don't understand why this footer is displayed here
        ?>
		<div class="ddl-dialog-footer js-widget-area-footer hidden">
			<input type="button" class="button-secondary js-cancel-create-new-sidebar" value="<?php 
        _e('Cancel', 'ddl-layouts');
        ?>
">
			<input type="button" class="button-primary js-create-the-new-sidebar js-save-dialog-settings" value="<?php 
        _e('Create the new widget area', 'ddl-layouts');
        ?>
">
		</div>

		<?php 
        return ob_get_clean();
    }
        function cred_cell_dialog_template_callback()
        {
            ob_start();
            ?>

            <div class="ddl-form cred-edit-cells-form">
                <?php 
            if (defined('CRED_FORMS_CUSTOM_POST_NAME')) {
                ?>
                    <?php 
                require_once CRED_CLASSES_PATH . "/CRED.php";
                if (method_exists('CRED_CRED', 'is_embedded')) {
                    $cred_embedded = CRED_CRED::is_embedded();
                } else {
                    $cred_embedded = false;
                }
                ?>

                    <?php 
                if (!$cred_embedded) {
                    ?>
                        <fieldset>
                            <div class="fields-group">
                                <label class="radio">
                                    <input type="radio" name="cred-action" class="js-ddl-cred-form-create" value="new_form" >
                                    <?php 
                    _e('Create a new CRED Post Form', 'ddl-layouts');
                    ?>
                                </label>
                                <span class="desc ddl-form-indent js-ddl-newcred"><?php 
                    _e('CRED Post Forms allow you to create content or edit your content. Choose what you want this form to do and the type of content it will work with.', 'ddl-layouts');
                    ?>
</span>
                                <br class="js-ddl-newcred" />
                            </div>
                        </fieldset>

                        <fieldset class="js-ddl-newcred">
                            <legend><?php 
                    _e('This form will:', 'ddl-layouts');
                    ?>
</legend>
                            <select class="js-cred-new-mode ddl-form-indent">
                                <option value="new"><?php 
                    _e('Create content', 'ddl-layouts');
                    ?>
</option>
                                <option value="edit"><?php 
                    _e('Edit content', 'ddl-layouts');
                    ?>
</option>
                            </select>
                        </fieldset>

                        <fieldset class="js-ddl-newcred">
                            <?php 
                    $post_types = CRED_Loader::get('MODEL/Fields')->getPostTypes();
                    ?>

                            <legend><?php 
                    _e('Content type:', 'ddl-layouts');
                    ?>
</legend>
                            <select class="js-cred-post-type ddl-form-indent">
                                <?php 
                    foreach ($post_types as $post_type) {
                        ?>
                                    <option value="<?php 
                        echo $post_type['type'];
                        ?>
"><?php 
                        echo $post_type['name'];
                        ?>
</option>
                                <?php 
                    }
                    ?>
                            </select>

                        </fieldset>

                        <fieldset class="js-ddl-newcred">
                            <div class="fields-group ddl-form-indent">
                                <button class="button button-primary js-ddl-create-cred-form">
                                    <?php 
                    _e('Create Cell', 'ddl-layouts');
                    ?>
                                </button>
                                <p class="js-cred-form-create-error toolset toolset-alert-error alert ddl-form-input-alert" style="display:none">
                                </p>
                            </div>
                        </fieldset>
                    <?php 
                }
                // end of full cred.
                ?>

                    <fieldset class="ddl-dialog-fieldset">
                        <div class="fields-group" <?php 
                if ($cred_embedded) {
                    echo 'style="display:none"';
                }
                ?>
>
                            <label class="radio">
                                <input type="radio" name="cred-action" class="js-ddl-cred-form-existing" value="existing" >
                                <?php 
                _e('Use an existing CRED Post Form', 'ddl-layouts');
                ?>
                            </label>
                        </div>
                    </fieldset>


                    <fieldset class="js-ddl-select-existing-cred">
                        <legend><?php 
                _e('Form:', 'ddl-layouts');
                ?>
</legend>
                        <select name="<?php 
                the_ddl_name_attr('ddl_layout_cred_id');
                ?>
"
                                class="ddl-cred-select js-ddl-cred-select <?php 
                if (!$cred_embedded) {
                    echo 'ddl-form-indent';
                }
                ?>
"
                                data-new="<?php 
                _e('create', 'ddl-layout');
                ?>
"
                                data-edit="<?php 
                _e('edit', 'ddl-layouts');
                ?>
">

                            <option value=""><?php 
                _e('--- Select form ---', 'ddl-layouts');
                ?>
</option>';
                            <?php 
                $fm = CRED_Loader::get('MODEL/Forms');
                $posts = $fm->getAllForms();
                foreach ($posts as $post) {
                    $form = $fm->getForm($post->ID);
                    echo $this->ddl_cred_get_option_element($post->ID, $post->post_title, $form->fields['form_settings']->form['type'], $form->fields['form_settings']->post['post_type']);
                }
                ?>
                        </select>
                        <?php 
                if (!$cred_embedded) {
                    ?>
                            <div class="fields-group ddl-form-indent">
                                <button class="button button-primary js-ddl-edit-cred-link"
                                        data-close-cred-text="<?php 
                    _e('Save and Close this form and return to the layout', 'ddl-layouts');
                    ?>
"
                                        data-discard-cred-text="<?php 
                    _e('Close this form and discard any changes', 'ddl-layouts');
                    ?>
">
                                    <?php 
                    _e('Create Cell', 'ddl-layouts');
                    ?>
                                </button>
                            </div>
                        <?php 
                }
                ?>
                    </fieldset>

                    <?php 
                if ($cred_embedded) {
                    ?>
                        <fieldset>
                            <div class="fields-group">
                                <div class="toolset-alert toolset-alert-info">
                                    <?php 
                    _e('You are using the embedded version of CRED. Install and activate the full version of CRED and you will be able to create custom forms.', 'ddl-layouts');
                    ?>
                                    <br>
                                    <a class="fieldset-inputs" href="http://wp-types.com/home/cred/?utm_source=layoutsplugin&utm_campaign=layouts&utm_medium=cred-cell&utm_term=get-cred" target="_blank">
                                        <?php 
                    _e('About CRED', 'ddl-layouts');
                    ?>
                                    </a>

                                </div>
                            </div>
                        </fieldset>
                    <?php 
                }
                ?>

                <?php 
            } else {
                ?>
                    <div class="toolset-alert toolset-alert-info js-ddl-cred-not-activated">
                        <p>
                            <i class="icon-cred-logo ont-color-orange ont-icon-24"></i>
                            <?php 
                _e('This cell requires the CRED plugin. Install and activate the CRED plugin and you will be able to create custom forms for creating and editing content.', 'ddl-layouts');
                ?>
                            <br>
                            <br>

                            &nbsp;&nbsp;
                            <a class="fieldset-inputs" href="http://wp-types.com/home/cred/?utm_source=layoutsplugin&utm_campaign=layouts&utm_medium=cred-cell&utm_term=get-cred" target="_blank">
                                <?php 
                _e('About CRED', 'ddl-layouts');
                ?>
                            </a>

                        </p>
                    </div>
                <?php 
            }
            ?>

                <div>
                    <?php 
            ddl_add_help_link_to_dialog(WPDLL_CRED_CELL, __('Learn about the CRED Post Form cell', 'ddl-layouts'));
            ?>
                </div>


            </div>

            <div id="ddl-cred-preview" style="display:none">
                -			<p><strong><?php 
            _e('This form is used to %EDIT% %POST_TYPE%', 'ddl-layouts');
            ?>
</strong></p>
                <div class="ddl-cred-preview">
                    <img src="<?php 
            echo WPDDL_RES_RELPATH . '/images/cell-icons/cred-form.svg';
            ?>
" height="130px">
                </div>
            </div>

            <div id="ddl-cred-preview-cred-not-found" style="display:none">
                <h2><?php 
            _e('The CRED Post Form was not found. It may have been deleted.', 'ddl-layouts');
            ?>
</h2>
            </div>

            <?php 
            echo wp_nonce_field('ddl_layout_cred_nonce', 'ddl_layout_cred_nonce', true, false);
            return ob_get_clean();
        }
    private function _dialog_template()
    {
        ob_start();
        ?>
		<ul class="ddl-form">
			<li>
				<fieldset>
					<legend><?php 
        _e('Display content for:', 'ddl-layouts');
        ?>
</legend>
					<div class="fields-group">
						<ul>
							<li>
								<label class="post-content-page">
									<input type="radio" name="<?php 
        the_ddl_name_attr('page');
        ?>
" value="current_page" checked="checked"/>
									<?php 
        _e('Current page', 'ddl-layouts');
        ?>
								</label>
							</li>
							<li>
								<label class="post-content-page">
									<input type="radio" name="<?php 
        the_ddl_name_attr('page');
        ?>
" value="this_page" />
									<?php 
        _e('A specific page:', 'ddl-layouts');
        ?>
								</label>
							</li>
							<li id="js-post-content-specific-page">
								<select name="<?php 
        the_ddl_name_attr('post_content_post_type');
        ?>
" class="js-ddl-post-content-post-type" data-nonce="<?php 
        echo wp_create_nonce('ddl-post-content-post-type-select');
        ?>
">
									<option value="ddl-all-post-types"><?php 
        _e('All post types', 'ddl-layouts');
        ?>
</option>
									<?php 
        $post_types = get_post_types(array('public' => true), 'objects');
        foreach ($post_types as $post_type) {
            $count_posts = wp_count_posts($post_type->name);
            if ($count_posts->publish > 0) {
                ?>
												<option value="<?php 
                echo $post_type->name;
                ?>
"<?php 
                if ($post_type->name == 'page') {
                    echo ' selected="selected"';
                }
                ?>
>
													<?php 
                echo $post_type->labels->singular_name;
                ?>
												</option>
											<?php 
            }
        }
        ?>
								</select>
								<?php 
        $keys = array_keys($post_types);
        $post_types_array = array_shift($keys);
        $this->show_posts_dropdown($post_types_array, get_ddl_name_attr('selected_post'));
        ?>
							</li>
						</ul>
					</div>
				</fieldset>
			</li>
		

		</ul>
		<?php 
        ddl_add_help_link_to_dialog(WPDLL_POST_CONTENT_CELL, __('Learn about the Post Content cell', 'ddl-layouts'));
        ?>
		<?php 
        wp_nonce_field('wpv-ct-inline-edit', 'wpv-ct-inline-edit');
        ?>

		<?php 
        return ob_get_clean();
    }
    function comments_cell_dialog_template_callback()
    {
        ob_start();
        ?>
		<h3 class="ddl-section-title">
			<?php 
        _e('Comments list', 'ddl-layouts');
        ?>
		</h3>
		<div class="ddl-form">
			<p>
				<label for="<?php 
        the_ddl_name_attr('avatar_size');
        ?>
"><?php 
        _e('Avatar size', 'ddl-layouts');
        ?>
:</label>
				<input type="number" value="24" placeholder="<?php 
        _e('32', 'ddl-layouts');
        ?>
" name="<?php 
        the_ddl_name_attr('avatar_size');
        ?>
" id="<?php 
        the_ddl_name_attr('avatar_size');
        ?>
" class="ddl-narrow-width" onkeypress='return event.charCode >= 48 && event.charCode <= 57'>
			</p>			
		</div>
		<h3 class="ddl-section-title">
			<?php 
        _e('Title for comments list', 'ddl-layouts');
        ?>
		</h3>
		<div class="ddl-form">
			<p>
				<label for="<?php 
        the_ddl_name_attr('title_one_comment');
        ?>
"><?php 
        _e('For one comment', 'ddl-layouts');
        ?>
:</label>
				<input type="text" name="<?php 
        the_ddl_name_attr('title_one_comment');
        ?>
" id="<?php 
        the_ddl_name_attr('title_one_comment');
        ?>
" value="<?php 
        _e('One thought on %TITLE%', 'ddl-layouts');
        ?>
">
				<div id="title_one_comment_message"></div>
			</p>
			<p>
				<label for="<?php 
        the_ddl_name_attr('title_multi_comments');
        ?>
"><?php 
        _e('For two or more', 'ddl-layouts');
        ?>
:</label>
				<input type="text" name="<?php 
        the_ddl_name_attr('title_multi_comments');
        ?>
" id="<?php 
        the_ddl_name_attr('title_multi_comments');
        ?>
" value="<?php 
        _e('%COUNT% thoughts on %TITLE%', 'ddl-layouts');
        ?>
">
				<div id="title_multi_comments_message"></div>
				<span class="desc"><?php 
        _e('Use the %TITLE% placeholder to display the post title and the %COUNT% placeholder to display the number of comments.', 'ddl-layouts');
        ?>
</span>
			</p>
		</div>
		<h3 class="ddl-section-title">
			<?php 
        _e('Navigation and miscellaneous texts', 'ddl-layouts');
        ?>
		</h3>
		<div class="ddl-form">			
			<p>
				<label for="<?php 
        the_ddl_name_attr('ddl_prev_link_text');
        ?>
"><?php 
        _e('Previous link text', 'ddl-layouts');
        ?>
:</label>
				<input type="text" name="<?php 
        the_ddl_name_attr('ddl_prev_link_text');
        ?>
" id="<?php 
        the_ddl_name_attr('ddl_prev_link_text');
        ?>
" value="<?php 
        _e('<< Older Comments', 'ddl-layouts');
        ?>
">
			</p>
			<p>
				<label for="<?php 
        the_ddl_name_attr('ddl_next_link_text');
        ?>
"><?php 
        _e('Next link text', 'ddl-layouts');
        ?>
:</label>
				<input type="text" name="<?php 
        the_ddl_name_attr('ddl_next_link_text');
        ?>
" id="<?php 
        the_ddl_name_attr('ddl_next_link_text');
        ?>
" value="<?php 
        _e('Newer Comments >>', 'ddl-layouts');
        ?>
">
			</p>
			<p>
				<label for="<?php 
        the_ddl_name_attr('comments_closed_text');
        ?>
"><?php 
        _e('Comments closed text', 'ddl-layouts');
        ?>
:</label>
				<input type="text" name="<?php 
        the_ddl_name_attr('comments_closed_text');
        ?>
" id="<?php 
        the_ddl_name_attr('comments_closed_text');
        ?>
" value="<?php 
        _e('Comments are closed', 'ddl-layouts');
        ?>
">
                <div id="comments_closed_text_message"></div>
			</p>
			<p>
				<label for="<?php 
        the_ddl_name_attr('reply_text');
        ?>
"><?php 
        _e('Reply text', 'ddl-layouts');
        ?>
:</label>
				<input type="text" name="<?php 
        the_ddl_name_attr('reply_text');
        ?>
" id="<?php 
        the_ddl_name_attr('reply_text');
        ?>
" value="<?php 
        _e('Reply', 'ddl-layouts');
        ?>
">
                <div id="reply_text_message"></div>
			</p>
			<p>
				<label for="<?php 
        the_ddl_name_attr('password_text');
        ?>
"><?php 
        _e('Password protected text', 'ddl-layouts');
        ?>
:</label>
				<input type="text" name="<?php 
        the_ddl_name_attr('password_text');
        ?>
" id="<?php 
        the_ddl_name_attr('password_text');
        ?>
" value="<?php 
        _e('This post is password protected. Enter the password to view any comments.', 'ddl-layouts');
        ?>
">
                <div id="password_text_message"></div>
			</p>

		</div>
		<div class="ddl-form">
			<div class="ddl-form-item">
				<br />
				<?php 
        ddl_add_help_link_to_dialog(WPDLL_COMMENTS_CELL, __('Learn about the Comments cell', 'ddl-layouts'));
        ?>
			</div>
		</div>
		<?php 
        global $current_user;
        get_currentuserinfo();
        ?>

		<?php 
        return ob_get_clean();
    }
    function views_content_grid_dialog_template_callback()
    {
        global $WP_Views;
        ob_start();
        ?>
        <div class="ddl-form">
            <?php 
        echo wp_nonce_field('ddl_layout_view_nonce', 'ddl_layout_view_nonce', true, false);
        if (class_exists('WP_Views')) {
            if (defined('WPV_VERSION')) {
                if (version_compare(WPV_VERSION, '1.6.1', '<=')) {
                    ?>
                        <input type="hidden" value="0" class="js-views-content-is_views_installed" />
                        <input type="hidden" value="0" class="js-views-content-is_views_embedded" />
                        <div class="toolset-alert toolset-alert-info">
                            <p>
                                <i class="icon-views-logo ont-color-orange ont-icon-24"></i>
                                <?php 
                    _e('This cell requires Views plugin above version 1.6.1 to create custom content-driven cells.', 'ddl-layouts');
                    ?>



                                &nbsp;&nbsp;
                                <a class="fieldset-inputs" href="http://wp-types.com/home/views-create-elegant-displays-for-your-content?utm_source=layoutsplugin&utm_campaign=layouts&utm_medium=views-content-grid-cell&utm_term=get-views" target="_blank">
                                    <?php 
                    _e('About Views', 'ddl-layouts');
                    ?>
                                </a>

                            </p>
                        </div>
                    <?php 
                } else {
                    ?>
                        <input type="hidden" value="1" class="js-views-content-is_views_installed" />
                        <?php 
                    if ($WP_Views->is_embedded()) {
                        ?>
                            <input type="hidden" value="1" class="js-views-content-is_views_embedded" />
                        <?php 
                    } else {
                        ?>
                            <input type="hidden" value="0" class="js-views-content-is_views_embedded" />
                        <?php 
                    }
                    if (version_compare(WPV_VERSION, '1.7', '>=')) {
                        ?>
                            <input type="hidden" value="1" class="js-views-content-is_views_above_oneseven" />
                        <?php 
                    } else {
                        ?>
                            <input type="hidden" value="0" class="js-views-content-is_views_above_oneseven" />
                        <?php 
                    }
                    ?>

                        <fieldset class="js-view-result-missing" style="display:none; margin-top:-20px">
                            <div class="fields-group">
                                <div class="toolset-alert toolset-alert-warning">
                                    <p><i class="icon-warning-sign"></i> <?php 
                    _e('This layout has a search form, but is missing the results.', 'ddl-layouts');
                    ?>
</p>
                                    <div>
                                        <ul>
                                            <li>
                                                <label class="radio">
                                                    <input type="radio" class="js-ddl-complete-search" value="complete" data-cell-name-text="<?php 
                    _e('%CELL_NAME% search results', 'ddl-layouts');
                    ?>
" />
                                                    <?php 
                    _e('Complete the parametric search setup by inserting a cell for the results', 'ddl-layouts');
                    ?>
                                                </label>
                                            </li>
                                            <li>
                                                <label class="radio">
                                                    <input type="radio" class="js-ddl-different-view" value="cancel" />
                                                    <?php 
                    _e('Insert a different View, not related to the parametric search results', 'ddl-layouts');
                    ?>
                                                </label>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </fieldset>


                        <fieldset class="js-view-result-ok">
                            <legend><?php 
                    _e('View:', 'ddl-layouts');
                    ?>
</legend>
                            <div class="fields-group">
                                <?php 
                    if ($WP_Views->is_embedded()) {
                        ?>
                                    <p style="display: none;">
                                        <label class="radio">
                                            <input type="radio" name="view-grid-view-action" class="js-ddl-views-grid-create" value="new_layout" />
                                            <?php 
                        _e('Create new View', 'ddl-layouts');
                        ?>
                                        </label>
                                    </p>
                                    <p style="display:none;">
                                        <label class="radio">
                                            <input type="radio" name="view-grid-view-action" class="js-ddl-views-grid-existing" value="existing_layout" checked="checked" />
                                            <?php 
                        _e('Use an existing View', 'ddl-layouts');
                        ?>
                                        </label>
                                    </p>
                                <?php 
                    } else {
                        ?>
                                    <p>
                                        <label class="radio">
                                            <input type="radio" name="view-grid-view-action" class="js-ddl-views-dialog-mode js-ddl-views-grid-create" <?php 
                        checked(get_ddl_field('ddl_layout_view_id'), '');
                        ?>
 value="new_layout" />
                                            <?php 
                        _e('Create new View', 'ddl-layouts');
                        ?>
                                        </label>
                                    </p>
                                    <p>
                                        <label class="radio">
                                            <?php 
                        $checked = get_ddl_field('ddl_layout_view_id') != '' ? ' checked="checked" ' : '';
                        ?>
                                            <input type="radio" name="view-grid-view-action" class="js-ddl-views-dialog-mode js-ddl-views-grid-existing" value="existing_layout" <?php 
                        echo $checked;
                        ?>
 />
                                            <?php 
                        _e('Use an existing View', 'ddl-layouts');
                        ?>
                                        </label>
                                    </p>
                                <?php 
                    }
                    $hidden = '';
                    if (get_ddl_field('ddl_layout_view_id') == '') {
                        $hidden = ' style="display:none;" ';
                    }
                    ?>
                                <p class="js-ddl-select-existing-view"<?php 
                    echo $hidden;
                    ?>
>
                                    <?php 
                    $i = 0;
                    $wpv_args = array('post_type' => 'view', 'posts_per_page' => -1, 'order' => 'ASC', 'orderby' => 'title', 'post_status' => 'publish');
                    $wpv_query = get_posts($wpv_args);
                    $wpv_count_posts = count($wpv_query);
                    $views_as_options = '';
                    $wpv_total_archives = 0;
                    $wpv_total_views = 0;
                    if ($wpv_count_posts > 0) {
                        foreach ($wpv_query as $post) {
                            $view_settings = $WP_Views->get_view_settings($post->ID);
                            if (isset($view_settings['view-query-mode']) && $view_settings['view-query-mode'] == 'archive' || $view_settings['view-query-mode'] == 'layouts-loop') {
                                $wpv_total_archives++;
                            } else {
                                $wpv_total_views++;
                            }
                            if ($WP_Views->does_view_have_form_controls($post->ID)) {
                                $purpose = 'parametric';
                            } else {
                                $purpose = isset($view_settings['view_purpose']) ? $view_settings['view_purpose'] : 'full';
                                if ($purpose == 'bootstrap-grid') {
                                    $purpose = 'full';
                                }
                            }
                            $i++;
                            $views_query_mode = isset($view_settings['view-query-mode']) ? $view_settings['view-query-mode'] : 'normal';
                            $views_as_options .= '<option data-id="' . $post->ID . '" value="' . $post->ID . '" data-mode="' . $views_query_mode . '" data-purpose="' . $purpose . '">' . $post->post_title . '</option>';
                        }
                    }
                    ?>
                                    <input type="hidden" value="<?php 
                    echo $wpv_total_archives;
                    ?>
" class="js-wpv-total-archives" />
                                    <input type="hidden" value="<?php 
                    echo $wpv_total_views;
                    ?>
" class="js-wpv-total-views" />
                                    <?php 
                    if ($i > 0) {
                        ?>
                                    <select name="<?php 
                        the_ddl_name_attr('ddl_layout_view_id');
                        ?>
" class="ddl-view-select js-ddl-view-select">
                                        <option value="" data-mode="both"><?php 
                        _e('--- Select View ---', 'ddl-layouts');
                        ?>
</option>
                                        <?php 
                        echo $views_as_options;
                        ?>
                                    </select>
                                    <?php 
                        if ($WP_Views->is_embedded()) {
                            ?>
                                <div class="toolset-alert toolset-alert-info">
                                    <?php 
                            _e('You are using the embedded version of Views. Install and activate the full version of Views and you will be able to create custom content-driven grids.', 'ddl-layouts');
                            ?>

                                    &nbsp;&nbsp;
                                    <a class="fieldset-inputs" href="http://wp-types.com/home/views-create-elegant-displays-for-your-content?utm_source=layoutsplugin&utm_campaign=layouts&utm_medium=views-content-grid-cell&utm_term=get-views" target="_blank">
                                        <?php 
                            _e('About Views', 'ddl-layouts');
                            ?>
                                    </a>
                                </div>
                            <?php 
                        }
                    } else {
                        if ($WP_Views->is_embedded()) {
                            ?>
                                    <div class="toolset-alert toolset-alert-info js-data-embedded_no_views_at_all" data-embedded_no_views_at_all="yes">
                                        <?php 
                            _e('You are using the embedded version of the Views Plugin and there are no Views available.', 'ddl-layouts');
                            ?>
                                        <!--<br />
                                        <?php 
                            _e('You can download pre-built modules using the Module Manager plugin.', 'ddl-layouts');
                            ?>
                                        <br />
                                        <br />
                                        <?php 
                            if (defined('MODMAN_CAPABILITY')) {
                                ?>
                                            <a class="fieldset-inputs button button-primary-toolset" href="<?php 
                                echo admin_url('admin.php?page=ModuleManager_Modules&amp;tab=library&amp;module_cat=layouts');
                                ?>
" target="_blank">
                                                <i class="icon-download-alt"></i> <?php 
                                _e('Download Modules', 'ddl-layouts');
                                ?>
                                            </a>
                                        <?php 
                            } else {
                                ?>
                                            <a class="fieldset-inputs button button-primary-toolset" href="http://wp-types.com/home/module-manager?utm_source=layoutsplugin&utm_campaign=layouts&utm_medium=views-content-grid-cell&utm_term=get-module-manager" target="_blank">
                                                <?php 
                                _e('Get Module Manager plugin', 'ddl-layouts');
                                ?>
                                            </a>
                                        <?php 
                            }
                            ?>
                                        -->
                                    </div>
                                <?php 
                        } else {
                            ?>
                                    <select name="<?php 
                            the_ddl_name_attr('ddl_layout_view_id');
                            ?>
" class="ddl-view-select js-ddl-view-select" style="display:none;">
                                        <option value="" data-mode="both"><?php 
                            _e('None', 'ddl-layouts');
                            ?>
</option>
                                    </select>
                                    <?php 
                            /*<div class="toolset-alert toolset-alert-info">
                            			<?php _e('There are no Views available.', 'ddl-layouts'); ?>
                            			<br />
                            			<?php _e('You can create one or download pre-built modules using the Module Manager plugin.', 'ddl-layouts'); ?>
                            			<br />
                            			<br />
                            			<?php if (defined( 'MODMAN_CAPABILITY' )) { ?>
                            				<a class="fieldset-inputs button button-primary-toolset" href="<?php echo admin_url('admin.php?page=ModuleManager_Modules&amp;tab=library&amp;module_cat=layouts'); ?>" target="_blank">
                            					<i class="icon-download-alt"></i> <?php _e('Download Modules', 'ddl-layouts');?>
                            				</a>
                            			<?php } else { ?>
                            				<a class="fieldset-inputs button button-primary-toolset" href="http://wp-types.com/home/module-manager?utm_source=layoutsplugin&utm_campaign=layouts&utm_medium=views-content-grid-cell&utm_term=get-module-manager" target="_blank">
                            					<?php _e('Get Module Manager plugin', 'ddl-layouts');?>
                            				</a>
                            			<?php } ?>
                            		</div>
                            		<?php
                            		*/
                        }
                    }
                    ?>
                                <div class="toolset-alert toolset-alert-info js-no-views-message" style="display: none;">
                                    <span class="js-no-views-message-views" style="display: none;"><?php 
                    _e('There are no Views available.', 'ddl-layouts');
                    ?>
</span>
                                    <span class="js-no-views-message-archives" style="display: none;"><?php 
                    _e('There are no Archive Views available.', 'ddl-layouts');
                    ?>
</span>
                                    <!--<br />
                                    <?php 
                    _e('You can create one or download pre-built modules using the Module Manager plugin.', 'ddl-layouts');
                    ?>
                                    <br />
                                    <br />
                                    <?php 
                    if (defined('MODMAN_CAPABILITY')) {
                        ?>
                                        <a class="fieldset-inputs button button-primary-toolset" href="<?php 
                        echo admin_url('admin.php?page=ModuleManager_Modules&amp;tab=library&amp;module_cat=layouts');
                        ?>
" target="_blank">
                                            <i class="icon-download-alt"></i> <?php 
                        _e('Download Modules', 'ddl-layouts');
                        ?>
                                        </a>
                                    <?php 
                    } else {
                        ?>
                                        <a class="fieldset-inputs button button-primary-toolset" href="http://wp-types.com/home/module-manager?utm_source=layoutsplugin&utm_campaign=layouts&utm_medium=views-content-grid-cell&utm_term=get-module-manager" target="_blank">
                                            <?php 
                        _e('Get Module Manager plugin', 'ddl-layouts');
                        ?>
                                        </a>
                                    <?php 
                    }
                    ?>
                                    -->
                                </div>
                                </p>
                            </div>
                        </fieldset>
                        <?php 
                    $hidden = '';
                    if ($WP_Views->is_embedded()) {
                        $hidden = ' style="display:none;" ';
                    }
                    ?>
                        <fieldset class="js-ddl-set-view-purpose"<?php 
                    echo $hidden;
                    ?>
>
                            <legend><?php 
                    _e('View purpose:', 'ddl-layouts');
                    ?>
</legend>
                            <div class="fields-group ddl-form-indent" style="background:#f0f0f0;padding:1px 10px 10px">
                                <ul>
                                    <li>
                                        <label>
                                            <input type="radio" name="view_purpose" class="js-view-purpose" id="view_purpose_all" value="all" />
                                            <?php 
                    _e('Display all results', 'ddl-layouts');
                    ?>
                                        </label>
                                        <span class="desc"><?php 
                    _e('The View will output all the results returned from the query section.', 'ddl-layouts');
                    ?>
</span>
                                    </li>
                                    <li>
                                        <label>
                                            <input type="radio" name="view_purpose" class="js-view-purpose" id="view_purpose_pagination" value="pagination" />
                                            <?php 
                    _e('Display the results with pagination', 'ddl-layouts');
                    ?>
                                        </label>
                                        <span class="desc"><?php 
                    _e('The View will display the query results in pages.', 'ddl-layouts');
                    ?>
</span>
                                    </li>
                                    <li>
                                        <label>
                                            <input type="radio" name="view_purpose" class="js-view-purpose" id="view_purpose_slider" value="slider" />
                                            <?php 
                    _e('Display the results as a slider', 'ddl-layouts');
                    ?>
                                        </label>
                                        <span class="desc"><?php 
                    _e('The View will display the query results as slides.', 'ddl-layouts');
                    ?>
</span>
                                    </li>
                                    <li>
                                        <label>
                                            <input type="radio" name="view_purpose" class="js-view-purpose" id="view_purpose_parametric" value="parametric" />
                                            <?php 
                    _e('Display the results as a parametric search', 'ddl-layouts');
                    ?>
                                        </label>
                                        <span class="desc"><?php 
                    _e('Visitors will be able to search through your content using different search criteria.', 'ddl-layouts');
                    ?>
</span>
                                    </li>
                                    <li>
                                        <label>
                                            <input type="radio" name="view_purpose" class="js-view-purpose" id="view_purpose_full" value="full" checked="checked" />
                                            <?php 
                    _e('Full custom display mode', 'ddl-layouts');
                    ?>
                                        </label>
                                        <span class="desc"><?php 
                    _e('See all the View controls open and set up things manually.', 'ddl-layouts');
                    ?>
</span>
                                    </li>
                                </ul>
                            </div>
                        </fieldset>
                        <fieldset class="js-ddl-view-main-buttons">

                            <button data-close="no" class="button button-primary js-ddl-create-edit-view ddl-toolset-cell-button">
                                <?php 
                    _e('Create', 'ddl-layouts');
                    ?>
                            </button>
                        </fieldset>
                        <fieldset class="js-wpv-settings-views-layouts-parametric-extra" style="display:none">
                            <div id="views-layouts-parametric-div"
                                 class="wpv-setting-container js-wpv-display-for-purpose js-wpv-display-for-purpose-parametric"
                                 data-notice-1="<?php 
                    _e('Since you are only displaying the %NNN% in this cell, the %MMM% section is disabled. A parametric search should have the %NNN% and %MMM%. To display the %MMM% you need to:', 'ddl-layouts');
                    ?>
"
                                 data-notice-2="<?php 
                    _e('Create a different Layout cell and display this View.', 'ddl-layouts');
                    ?>
"
                                 data-notice-3="<?php 
                    _e('Choose to display the %MMM%', 'ddl-layouts');
                    ?>
"
                                 data-notice-form="<?php 
                    _e('search form', 'ddl-layouts');
                    ?>
"
                                 data-notice-results="<?php 
                    _e('search results', 'ddl-layouts');
                    ?>
"
                                >
                                <div class="wpv-setting js-wpv-setting">
                                    <h3><?php 
                    _e('What do you want to display in this cell?', 'ddl-layouts');
                    ?>
</h3>
                                    <ul>
                                        <li>
                                            <input type="radio" id="wpv-ddl-parametric-mode-full" class="js-wpv-ddl-parametric-mode" name="<?php 
                    the_ddl_name_attr('parametric_mode');
                    ?>
" value="full" />
                                            <label for="wpv-ddl-parametric-mode-full"><?php 
                    _e('The search form and the results', 'ddl-layouts');
                    ?>
</label>
                                        </li>
                                        <li>
                                            <input type="radio" id="wpv-ddl-parametric-mode-form" class="js-wpv-ddl-parametric-mode" name="<?php 
                    the_ddl_name_attr('parametric_mode');
                    ?>
" value="form" />
                                            <label for="wpv-ddl-parametric-mode-form"><?php 
                    _e('Only the search form', 'ddl-layouts');
                    ?>
</label>
                                            <div class="js-wpv-ddl-parametric-mode-form-settings wpv-advanced-setting" style="margin:10px 0 10px 20px;">
                                                <p>
                                                    <?php 
                    _e('Where do you want to display the results?', 'ddl-layouts');
                    ?>
                                                </p>
                                                <ul>
                                                    <li>
                                                        <input id="wpv-filter-form-target-self" value="self" type="radio" name="<?php 
                    the_ddl_name_attr('parametric_mode_target');
                    ?>
" class="js-wpv-ddl-parametric-target" />
                                                        <label for="wpv-filter-form-target-self"><?php 
                    _e('In other place on this same page', 'ddl-layouts');
                    ?>
</label>
                                                    </li>
                                                    <li>
                                                        <input id="wpv-filter-form-target-other" value="other" type="radio" name="<?php 
                    the_ddl_name_attr('parametric_mode_target');
                    ?>
" class="js-wpv-ddl-parametric-target" />
                                                        <label for="wpv-filter-form-target-other"><?php 
                    _e('On another page', 'ddl-layouts');
                    ?>
</label>
													<span class="toolset-alert" id="wpv-ddl-target-other-forbidden" style="display:none;">
														<?php 
                    _e('If you want to display the results on a different page, the View form must contain a search button', 'ddl-layouts');
                    ?>
													</span>
                                                    </li>
                                                </ul>
                                                <div class="js-wpv-ddl-parametric-target-other-div" style="margin:0 20px 10px;">
                                                    <p>
                                                        <label for="wpv-ddl-parametric-mode-form-target-title"><?php 
                    _e('Target page to show the results:', 'ddl-layouts');
                    ?>
</label>
                                                        <input type="text" id="wpv-ddl-parametric-mode-form-target-title" name="<?php 
                    the_ddl_name_attr('parametric_target_title');
                    ?>
" class="widefat js-wpv-widget-form-target-suggest-title" placeholder="<?php 
                    echo esc_attr(__('Please type', 'ddl-layouts'));
                    ?>
" />
                                                        <input type="hidden" id="wpv-ddl-parametric-mode-form-target-id" name="<?php 
                    the_ddl_name_attr('parametric_target_id');
                    ?>
" class="widefat js-wpv-widget-form-target-id" />
                                                    </p>
                                                    <div class="js-wpv-check-target-setup-box" style="display:none;">
                                                        <?php 
                    _e('Be sure to complete the setup:', 'ddl-layouts');
                    ?>
<br />
                                                        <a href="#" target="_blank" class="button-primary js-wpv-ddl-insert-view-form-target-set-existing-link" data-editurl="<?php 
                    echo admin_url('post.php');
                    ?>
?post="><?php 
                    _e('Add the search results to this page', 'ddl-layouts');
                    ?>
</a>
                                                        <a href="#" class="button-secondary js-wpv-ddl-discard-target-setup-link"><?php 
                    _e('Not now', 'ddl-layouts');
                    ?>
</a>
                                                    </div>
                                                </div>
                                            </div>
                                        </li>
                                        <li>
                                            <input type="radio" id="wpv-ddl-parametric-mode-results" class="js-wpv-ddl-parametric-mode" name="<?php 
                    the_ddl_name_attr('parametric_mode');
                    ?>
" value="results" />
                                            <label for="wpv-ddl-parametric-mode-results"><?php 
                    _e('Only the results', 'ddl-layouts');
                    ?>
</label>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </fieldset>
                    <?php 
                }
            } else {
                ?>
                    <input type="hidden" value="0" class="js-views-content-is_views_installed" />
                    <div class="toolset-alert toolset-alert-info">
                        <p>
                            <i class="icon-views-logo ont-color-orange ont-icon-24"></i>
                            <?php 
                _e('This cell requires Views plugin. Install and activate Views and you will be able to create custom content-driven cells.', 'ddl-layouts');
                ?>

                            &nbsp;&nbsp;
                            <a class="fieldset-inputs" href="http://wp-types.com/home/views-create-elegant-displays-for-your-content?utm_source=layoutsplugin&utm_campaign=layouts&utm_medium=views-content-grid-cell&utm_term=get-views" target="_blank">
                                <?php 
                _e('About Views', 'ddl-layouts');
                ?>
                            </a>
                        </p>
                    </div>
                <?php 
            }
        } else {
            ?>
                <input type="hidden" value="0" class="js-views-content-is_views_installed" />
                <div class="toolset-alert toolset-alert-info">
                    <p>
                        <i class="icon-views-logo ont-color-orange ont-icon-24"></i>
                        <?php 
            _e('This cell requires Views plugin. Install and activate Views and you will be able to create custom content-driven cells.', 'ddl-layouts');
            ?>

                        &nbsp;&nbsp;
                        <a class="fieldset-inputs" href="http://wp-types.com/home/views-create-elegant-displays-for-your-content?utm_source=layoutsplugin&utm_campaign=layouts&utm_medium=views-content-grid-cell&utm_term=get-views" target="_blank">
                            <?php 
            _e('About Views', 'ddl-layouts');
            ?>
                        </a>
                    </p>
                </div>
            <?php 
        }
        ?>
            <div class="js-views-content-grid-help">
                <?php 
        ddl_add_help_link_to_dialog(WPDLL_VIEWS_CONTENT_GRID_CELL, __('Learn about the Views cell', 'ddl-layouts'));
        ?>
            </div>
        </div>
        <?php 
        return ob_get_clean();
    }
    private function _dialog_template()
    {
        global $WPV_templates, $WP_Views;
        $views_1_6_available = defined('WPV_VERSION') && version_compare(WPV_VERSION, '1.6.1', '>') && isset($WP_Views) && class_exists('WP_Views') && !$WP_Views->is_embedded();
        $views_1_6_embedded_available = defined('WPV_VERSION') && version_compare(WPV_VERSION, '1.6.1', '>') && isset($WP_Views) && class_exists('WP_Views') && $WP_Views->is_embedded();
        $view_tempates_available = $this->_get_view_templates_available();
        ob_start();
        ?>
		<script type="text/javascript">
			var ddl_new_ct_default_name = '<?php 
        echo __('Content Template for %s Layout', 'ddl-layouts');
        ?>
';
			var ddl_views_1_6_available = <?php 
        echo $views_1_6_available ? 'true' : 'false';
        ?>
;
			var ddl_views_1_6_embedded_available = <?php 
        echo $views_1_6_embedded_available ? 'true' : 'false';
        ?>
;
		</script>

		<ul class="ddl-form">
			<li>
				<fieldset>
					<legend><?php 
        _e('Display content for:', 'ddl-layouts');
        ?>
</legend>
					<div class="fields-group">
						<ul>
							<li>
								<label class="post-content-page">
									<input type="radio" name="<?php 
        the_ddl_name_attr('page');
        ?>
" value="current_page" checked="checked"/>
									<?php 
        _e('A page using this layout', 'ddl-layouts');
        ?>
								</label>
							</li>
							<li>
								<label class="post-content-page">
									<input type="radio" name="<?php 
        the_ddl_name_attr('page');
        ?>
" value="this_page" />
									<?php 
        _e('A specific page:', 'ddl-layouts');
        ?>
								</label>
							</li>
							<li id="js-post-content-specific-page">
								<select name="<?php 
        the_ddl_name_attr('post_content_post_type');
        ?>
" class="js-ddl-post-content-post-type" data-nonce="<?php 
        echo wp_create_nonce('ddl-post-content-post-type-select');
        ?>
">
									<option value="ddl-all-post-types"><?php 
        _e('All post types', 'ddl-layouts');
        ?>
</option>
									<?php 
        $post_types = get_post_types(array('public' => true), 'objects');
        foreach ($post_types as $post_type) {
            $count_posts = wp_count_posts($post_type->name);
            if ($count_posts->publish > 0) {
                ?>
												<option value="<?php 
                echo $post_type->name;
                ?>
"<?php 
                if ($post_type->name == 'page') {
                    echo ' selected="selected"';
                }
                ?>
>
													<?php 
                echo $post_type->labels->singular_name;
                ?>
												</option>
											<?php 
            }
        }
        ?>
								</select>
								<?php 
        //	$keys = array_keys( $post_types );
        //	$post_types_array = array_shift(  $keys  );
        //	$this->show_posts_dropdown( $post_types_array, get_ddl_name_attr( 'selected_post' ) );
        ?>
							</li>
						</ul>
					</div>
				</fieldset>
			</li>

			<?php 
        if ($views_1_6_available || defined('WPV_VERSION') && sizeof($view_tempates_available) > 0) {
            ?>
			<li>
				<fieldset>
					<div class="fields-group">
						<ul>
							<li class="js-post-content-ct js-ct-selector js-ct-select-box">
								<?php 
            echo $this->_get_view_template_select_box($view_tempates_available);
            ?>
							</li>
							<?php 
            if ($views_1_6_available) {
                ?>
								<li class="js-post-content-ct js-ct-selector" style="text-align: right;">

                                    <a href="#" class="js-create-new-ct button button-large"><?php 
                _e('Create a new one', 'ddl-layouts');
                ?>
</a>
								</li>
							<?php 
            }
            ?>
						</ul>
					</div>
				</fieldset>
			</li>

			<?php 
        }
        ?>


			<?php 
        if ($views_1_6_available) {
            ?>
				<li class="js-post-content-ct js-ct-edit">
					<input class="js-ct-edit-name" type="text" style="float: left; width: 50%" /><span class="js-ct-editing"><strong><?php 
            _e('Editing', 'ddl-layouts');
            ?>
 :</strong> <span class="js-ct-name ct-name-span"></span></span>
                    <a style="float: right" href="#" class="js-load-different-ct button button-large"><?php 
            _e('Load a different Content Template', 'ddl-layouts');
            ?>
</a>
				</li>
				<li class="js-post-content-ct js-ct-edit">
			        <div class="js-wpv-ct-inline-edit wpv-ct-inline-edit wpv-ct-inline-edit hidden"><?php 
            echo '';
            ?>
</div>
				</li>
			<?php 
        } else {
            ?>
				<li>
					<div class="toolset-alert toolset-alert-info">
						<?php 
            if (sizeof($view_tempates_available) > 0) {
                ?>
							<p>
								<i class="icon-views-logo ont-color-orange ont-icon-24"></i>
								<?php 
                _e('This cell can display the post content using a Content Template, but your site does not have any Content Template yet. Install and activate the Views plugin, and you will be able to create Content Templates to display post fields', 'ddl-layouts');
                ?>

								&nbsp;&nbsp;
								<a class="fieldset-inputs" href="http://wp-types.com/home/views-create-elegant-displays-for-your-content?utm_source=layoutsplugin&utm_campaign=layouts&utm_medium=content-template-cell&utm_term=get-views" target="_blank">
									<?php 
                _e('About Views', 'ddl-layouts');
                ?>
								</a>
							</p>
						<?php 
            } else {
                ?>
							<p>
								<i class="icon-module-logo ont-color-orange ont-icon-24"></i>
								<?php 
                _e('This cell can display the post content using fields and there are no Content Templates available.', 'ddl-layouts');
                ?>
								<br />
								<?php 
                _e('You can download pre-built modules using the Module Manager plugin.', 'ddl-layouts');
                ?>
								<br />
								<br />
								<?php 
                if (defined('MODMAN_CAPABILITY')) {
                    ?>
									<a class="fieldset-inputs button button-primary-toolset" href="<?php 
                    echo admin_url('admin.php?page=ModuleManager_Modules&amp;tab=library&amp;module_cat=layouts');
                    ?>
" target="_blank">
										<i class="icon-download-alt"></i> <?php 
                    _e('Download Modules', 'ddl-layouts');
                    ?>
									</a>
								<?php 
                } else {
                    ?>
									<a class="fieldset-inputs button button-primary-toolset" href="http://wp-types.com/home/module-manager?utm_source=layoutsplugin&utm_campaign=layouts&utm_medium=content-template-cell&utm_term=get-module-manager" target="_blank">
										<?php 
                    _e('Get Module Manager plugin', 'ddl-layouts');
                    ?>
									</a>
								<?php 
                }
                ?>
							</p>
						<?php 
            }
            ?>
					</div>
				</li>
				<li class="js-post-content-ct js-ct-edit">
			        <div class="js-wpv-ct-inline-edit wpv-ct-inline-edit wpv-ct-inline-edit hidden"><?php 
            echo '';
            ?>
</div>
				</li>

			<?php 
        }
        ?>



		</ul>
		<?php 
        ddl_add_help_link_to_dialog(WPDLL_CONTENT_TEMPLATE_CELL, __('Learn about the Content Template cell', 'ddl-layouts'));
        ?>
		<?php 
        wp_nonce_field('wpv-ct-inline-edit', 'wpv-ct-inline-edit');
        ?>
        <?php 
        wp_nonce_field('wpv_inline_content_template', 'wpv_inline_content_template');
        ?>

		<?php 
        return ob_get_clean();
    }
 private function _dialog_template()
 {
     ob_start();
     ddl_add_help_link_to_dialog(WPDLL_LOOP_CONTENT_CELL, __('Learn about the Post Loop cell', 'ddl-layouts'));
     return ob_get_clean();
 }
function widget_cell_dialog_template_callback()
{
    if (!empty($GLOBALS['wp_widget_factory'])) {
        $widgets = $GLOBALS['wp_widget_factory']->widgets;
    } else {
        $widgets = array();
    }
    add_action('wp_ajax_get_widget_controls', 'widget_cell_get_controls');
    ob_start();
    ?>

		<?php 
    /*
     * Use the the_ddl_name_attr function to get the
     * name of the text box. Layouts will then handle loading and
     * saving of this UI element automatically.
     */
    ?>

		<ul class="ddl-form widget-cell">
			<li>
				<label for="<?php 
    the_ddl_name_attr('widget_type');
    ?>
"><?php 
    _e('Widget type:', 'ddl-layouts');
    ?>
</label>
				<select name="<?php 
    the_ddl_name_attr('widget_type');
    ?>
" data-nonce="<?php 
    echo wp_create_nonce('ddl-get-widget');
    ?>
">
					<?php 
    foreach ($widgets as $widget) {
        ?>
						<?php 
        if (!is_array($widget->widget_options['classname']) && !is_array($widget->name)) {
            ?>
							<option value="<?php 
            echo $widget->widget_options['classname'];
            ?>
"><?php 
            echo $widget->name;
            ?>
</option>
						<?php 
        }
        ?>
					<?php 
    }
    ?>
				</select>
			</li>
			<li>
				<fieldset class="js-widget-cell-fieldset hidden">
					<legend><?php 
    _e('Widget settings', 'ddl-layouts');
    ?>
:</legend>
					<div class="fields-group widget-cell-controls js-widget-cell-controls">
					</div>
				</fieldset>
			</li>

			<li>
				<?php 
    ddl_add_help_link_to_dialog(WPDLL_WIDGET_CELL, __('Learn about the Widget cell', 'ddl-layouts'));
    ?>
			</li>			
			
		</ul>

	<?php 
    return ob_get_clean();
}