Exemple #1
0
        }
        $insertSql = $insertSql . " where id ={$id}";
        //print $insertSql;
        $result = mysql_query($insertSql);
        if (!$result) {
            throw new Exception("错误!,sql为:{$insertSql}");
        }
        echo "<script>alert('修改成功!');window.location='{$link}" . (substr_count($link, "?") == 0 ? "?" : "&") . "pageNo={$pageNo}'</script>";
    } else {
        if ($type == "delete") {
            deleteTableById($tablename, $id);
            echo "<script>alert('删除成功!');window.location='{$link}" . (substr_count($link, "?") == 0 ? "?" : "&") . "pageNo={$pageNo}'</script>";
        } else {
            if ($type == "ajax") {
                $sql = stripcslashes($_REQUEST["sql"]);
                $result = mysql_query($sql);
                if (!$result) {
                    throw new Exception("错误!,sql为:{$sql}");
                }
                $returnList = array();
                while ($row = mysql_fetch_object($result)) {
                    array_push($returnList, $row);
                }
                echo json_encode(object_decode($returnList));
            }
        }
    }
}
mysql_close($con);
?>
 
        /**
         * Shows all the instructors of the given course.
         *
         * Four styles are supported:
         *
         * * style="block" - List profile blocks including name, avatar, description (optional) and profile link. You can choose to make the entire block clickable ( link_all="yes" ) or only the profile link ( link_all="no", Default).
         * * style="list"  - Lists instructor display names (separated by list_separator).
         * * style="link"  - Same as 'list', but returns hyperlinks to instructor profiles.
         * * style="count" - Outputs a simple integer value with the total of instructors for the course.
         *
         * @since 1.0.0
         */
        function course_instructors($atts)
        {
            global $wp_query;
            global $instructor_profile_slug;
            extract(shortcode_atts(array('course_id' => in_the_loop() ? get_the_ID() : '', 'course' => false, 'label' => __('Instructor', 'cp'), 'label_plural' => __('Instructors', 'cp'), 'label_delimeter' => ':&nbsp;', 'label_tag' => '', 'count' => false, 'list' => false, 'link' => 'false', 'link_text' => __('View Full Profile', 'cp'), 'show_label' => 'no', 'summary_length' => 50, 'style' => 'block', 'list_separator' => ', ', 'avatar_size' => 80, 'default_avatar' => '', 'show_divider' => 'yes', 'link_all' => 'no', 'class' => ''), $atts, 'course_instructors'));
            if (!empty($course_id)) {
                $course_id = (int) $course_id;
            }
            $label = sanitize_text_field($label);
            $label_plural = sanitize_text_field($label_plural);
            $label_delimeter = sanitize_text_field($label_delimeter);
            $label_tag = sanitize_html_class($label_tag);
            $link = sanitize_text_field($link);
            $link = 'true' == $link ? true : false;
            $link_text = sanitize_text_field($link_text);
            $show_label = sanitize_text_field($show_label);
            $summary_length = (int) $summary_length;
            $style = sanitize_html_class($style);
            $list_separator = sanitize_text_field($list_separator);
            $avatar_size = (int) $avatar_size;
            $show_divider = sanitize_html_class($show_divider);
            $link_all = sanitize_html_class($link_all);
            $class = sanitize_html_class($class);
            // Support previous arguments
            $style = $count ? 'count' : $style;
            $style = $list ? 'list-flat' : $style;
            $show_label = 'list-flat' == $style && !$show_label ? 'yes' : $show_label;
            $course = empty($course) ? new Course($course_id) : object_decode($course, 'Course');
            $instructors = Course::get_course_instructors($course_id);
            $list = array();
            $content = '';
            if (0 < count($instructors) && 'yes' == $show_label) {
                if (!empty($label_tag)) {
                    $content .= '<' . $label_tag . '>';
                }
                $content .= count($instructors) > 1 ? $label_plural . $label_delimeter : $label . $label_delimeter;
                if (!empty($label_tag)) {
                    $content .= '</' . $label_tag . '>';
                }
            }
            if ('count' != $style) {
                if (!empty($instructors)) {
                    foreach ($instructors as $instructor) {
                        $profile_href = trailingslashit(home_url()) . trailingslashit($instructor_profile_slug);
                        $profile_href .= get_option('show_instructor_username', 1) == 1 ? trailingslashit($instructor->user_login) : trailingslashit(md5($instructor->user_login));
                        switch ($style) {
                            case 'block':
                                ob_start();
                                ?>
								<div class="instructor-profile <?php 
                                echo $class;
                                ?>
">
									<?php 
                                if ('yes' == $link_all) {
                                    ?>
									<a href="<?php 
                                    echo $profile_href;
                                    ?>
">
										<?php 
                                }
                                ?>
										<div class="profile-name"><?php 
                                echo $instructor->display_name;
                                ?>
</div>
										<div class="profile-avatar">
											<?php 
                                echo get_avatar($instructor->ID, $avatar_size, $default_avatar, $instructor->display_name);
                                ?>
										</div>
										<div class="profile-description"><?php 
                                echo $this->author_description_excerpt($instructor->ID, $summary_length);
                                ?>
</div>
										<div class="profile-link">
											<?php 
                                if ('no' == $link_all) {
                                    ?>
											<a href="<?php 
                                    echo $profile_href;
                                    ?>
">
												<?php 
                                }
                                ?>
												<?php 
                                echo $link_text;
                                ?>
												<?php 
                                if ('no' == $link_all) {
                                    ?>
												</a>
										<?php 
                                }
                                ?>
										</div>
										<?php 
                                if ('yes' == $link_all) {
                                    ?>
										</a>
								<?php 
                                }
                                ?>
								</div>
								<?php 
                                $content .= ob_get_clean();
                                break;
                            case 'link':
                            case 'list':
                            case 'list-flat':
                                $list[] = $link ? '<a href="' . $profile_href . '">' . $instructor->display_name . '</a>' : $instructor->display_name;
                                break;
                        }
                    }
                }
            }
            switch ($style) {
                case 'block':
                    $content = '<div class="instructor-block ' . $class . '">' . $content . '</div>';
                    if ($show_divider == 'yes' && 0 < count($instructors)) {
                        $content .= '<div class="divider"></div>';
                    }
                    break;
                case 'list-flat':
                    // $content = '';
                    // if( 0 < count( $instructors ) && ! empty( $label ) ) {
                    // 	$content = count( $instructors ) > 1 ? $label_plural . $label_delimeter : $label . $label_delimeter;
                    // }
                    $content .= implode($list_separator, $list);
                    $content = '<div class="instructor-list instructor-list-flat ' . $class . '">' . $content . '</div>';
                    break;
                case 'list':
                    // $content = '';
                    // if( 0 < count( $instructors ) && ! empty( $label ) ) {
                    // 	$content = count( $instructors ) > 1 ? $label_plural . $label_delimeter : $label . $label_delimeter;
                    // }
                    $content .= '<ul>';
                    foreach ($list as $instructor) {
                        $content .= '<li>' . $instructor . '</li>';
                    }
                    $content .= '</ul>';
                    $content = '<div class="instructor-list ' . $class . '">' . $content . '</div>';
                    break;
                case 'count':
                    $content = count($instructors);
                    break;
            }
            return $content;
        }