Exemple #1
0
function send_email($to, $data, $template, $subject = 'No Subject', $reply_to = false, $attachments = false)
{
    global $email_from;
    $boundary = uniqid('veev');
    $boundar2 = uniqid('inner');
    $headers = 'From: ' . $email_from . ($reply_to == false ? '' : "\r\n" . 'Sender: ' . $email_from . "\r\n" . 'Reply-To: ' . $reply_to) . "\r\n" . 'MIME-Version: 1.0' . "\r\n" . 'Content-Type: multipart/related; boundary=' . $boundary . "\r\n" . '--' . $boundary . "\r\n" . 'Content-Type: multipart/alternative; boundary=' . $boundar2 . "\r\n";
    //
    $message = render_view('email/' . $template . '.php', $data);
    //
    $message = "\r\n" . '--' . $boundar2 . "\r\n" . 'Content-type: text/plain; charset=utf-8' . "\r\n\r\n" . strip_tags($message) . "\r\n\r\n--" . $boundar2 . "\r\n" . 'Content-type: text/html; charset=utf-8' . "\r\n\r\n" . $message . "\r\n\r\n" . '--' . $boundar2 . '--' . "\r\n" . '--' . $boundary;
    if ($attachments !== false) {
        foreach ($attachments as $filename => $data) {
            if (!isset($data) && file_exists($filename)) {
                $data = base64_encode(file_get_contents($filename));
                $filename = substr($filename, strrpos($filename, '/') + 1);
            } else {
                if (strlen($data) < 128 && file_exists($data)) {
                    $data = base64_encode(file_get_contents($data));
                }
            }
            $message .= "\r\n" . 'Content-Type: application/octet-stream; name="' . $filename . '"' . "\r\n" . 'Content-Transfer-Encoding: base64' . "\r\n" . 'Content-Disposition: attachment' . "\r\n\r\n" . $data . "\r\n--" . $boundary;
        }
    }
    $message .= '--';
    $mail_sent = @mail($to, $subject, $message, $headers);
    return $mail_sent;
}
 public function onBefore()
 {
     //render header
     if (!$this->isAjax()) {
         render_view("header");
     }
 }
function show_form()
{
    $name = _req('name');
    $teacher = _req('teacher');
    $description = _req('description');
    $teachers = Teacher::search()->find(Searcher::KEY_VALUE_PAIR);
    render_view('master', compact('teachers', 'name', 'teacher', 'description'));
}
function show_form()
{
    $genders = $GLOBALS['config']['gender'];
    $name = _req('name');
    $gender = _req('gender');
    $description = _req('description');
    render_view('master', compact('genders', 'name', 'gender', 'description'));
}
/**
 * @author  ryan <*****@*****.**>
 */
function comment_add_GET($teacher, $comment)
{
    $has_login = $GLOBALS['has_login'];
    if (!$has_login) {
        return;
    }
    $teacher = new Teacher($teacher);
    $comment = new Comment($comment);
    render_view('master', compact('teacher', 'comment', 'has_login'));
}
Exemple #6
0
/**
 * @author  ryan <*****@*****.**>
 */
function register_GET()
{
    if ($GLOBALS['has_login']) {
        redirect();
    }
    $config = $GLOBALS['config'];
    $genders = $config['gender'];
    $schools = $config['school'];
    render_view('master', compact('genders', 'schools'));
}
Exemple #7
0
/**
 * @file    index
 * @author  ryan <*****@*****.**>
 * @created Jun 27, 2012 6:24:01 PM
 */
function index()
{
    $recentTeachers = Teacher::search()->orderBy('touched DESC')->find();
    $recentComments = Comment::search()->OrderBy('id DESC')->find();
    $data = compact('recentTeachers', 'recentCourses', 'recentComments');
    if ($GLOBALS['has_login']) {
        $timelines = Timeline::search()->filterBy('user', $GLOBALS['user'])->find();
        $data['timelines'] = $timelines;
    }
    render_view('master', $data);
}
Exemple #8
0
function login_end()
{
    // if user is already logged in,
    // to index since we didn't provide such a link
    if ($GLOBALS['has_login']) {
        redirect();
        // to index
    }
    $username = _req('username');
    render_view('master', array('msg' => $GLOBALS['msg'], 'username' => $username));
}
Exemple #9
0
/**
 * @author  ryan <*****@*****.**>
 */
function teacher_GET($id)
{
    $teacher = new Teacher($id);
    $comments = Comment::search()->filterBy('teacher', $id)->find();
    $has_login = $GLOBALS['has_login'];
    if ($has_login) {
        $teacher->commentedByMe = $teacher->commentedByUser($GLOBALS['user']);
    }
    $schools = $GLOBALS['config']['school'];
    render_view('master', compact('teacher', 'courses', 'comments', 'has_login', 'schools'));
}
Exemple #10
0
function send_email($to, $data, $template, $subject = 'No Subject', $reply_to = false, $attachments = false)
{
    global $email_from, $admin_email;
    $boundary = uniqid('np');
    $headers = 'To: ' . $to . "\r\n" . 'From: ' . $email_from . ($reply_to == false ? '' : "\r\n" . 'Sender: ' . $email_from . "\r\n" . 'Reply-To: ' . $reply_to) . "\r\n" . 'MIME-Version: 1.0' . "\r\n" . 'Content-Type: multipart/alternative; boundary=' . $boundary . "\r\n";
    //
    $message = render_view('email/' . $template . '.php', $data);
    //
    $message = strip_tags($message) . "\r\n\r\n--" . $boundary . "\r\n" . 'Content-type: text/html;charset=utf-8' . "\r\n\r\n" . $message . "\r\n\r\n--" . $boundary . '--';
    $mail_sent = @mail($to, $subject, $message, $headers);
    return $mail_sent;
}
Exemple #11
0
/**
 * @author  ryan <*****@*****.**>
 */
function course_GET($id)
{
    $course = new Course($id);
    $teacher = $course->teacher();
    $comments = $course->comments();
    $has_login = $GLOBALS['has_login'];
    $data = compact('course', 'teacher', 'canStar', 'has_login', 'comments');
    if ($has_login) {
        $data['myStar'] = $course->starBy($GLOBALS['user']);
    }
    render_view('master', $data);
}
 function frontend_render_cell_content($target)
 {
     global $ddl_fields_api;
     $ddl_fields_api->set_current_cell_content($this->get_content());
     if (function_exists('render_view')) {
         global $WPV_view_archive_loop, $wp_query;
         $WPV_view_archive_loop->query = clone $wp_query;
         $WPV_view_archive_loop->in_the_loop = true;
         $target->cell_content_callback(render_view(array('id' => get_ddl_field('ddl_layout_view_id'))), $this);
         $WPV_view_archive_loop->in_the_loop = false;
     } else {
         $target->cell_content_callback(WPDDL_Messages::views_missing_message(), $this);
     }
 }
Exemple #13
0
/**
 * @author  ryan <*****@*****.**>
 */
function comment($teacher, $comment)
{
    $teacher = new Teacher($teacher);
    $comment = new Comment($comment);
    $additions = $comment->additions();
    $discusses = $comment->discusses();
    $has_login = $GLOBALS['has_login'];
    if ($has_login) {
        $u = $GLOBALS['user'];
        $comment->likedByMe = $comment->attitudeByUser('like', $u);
        $comment->hatedByMe = $comment->attitudeByUser('hate', $u);
        $commentedByMe = $comment->user == $u->id;
    }
    render_view('master', compact('teacher', 'comment', 'has_login', 'discusses', 'commentedByMe', 'additions'));
}
 /**
  * handle exception in runtime
  *
  * @param Exception $exception exception to handle
  */
 public function exceptionHandler($exception)
 {
     $message = $exception->getMessage();
     render_view("exception", array("message" => $message));
     render_view("footer");
     exit;
 }
/*
 * Making sure Wordless plugin is enabled
 */
if (!class_exists("Wordless")) {
    echo "This theme requires the <a href='https://github.com/welaika/wordless'>Wordless plugin</a> in order to work. Please, install it now!";
    die;
}
/*
 * In this page, you need to setup Wordless routing: you first
 * determine the type of the page using WordPress conditional tags,
 * and then delegate the rendering to some particular view using
 * the `render_view()` helper.
 *
 * To specify a layout other than the default one, please pass it as
 * the second parameter to the `render_view()` method.
 *
 * For a list of conditional tags, please see here: http://codex.wordpress.org/Conditional_Tags
 */
if (is_front_page()) {
    // Home Template
    render_view("pages/home");
} elseif (is_single()) {
    // Single Post on Blog Template
    render_view("posts/single");
} elseif (is_page()) {
    // Single Page Template
    render_view("pages/single");
} else {
    // Archive Template
    render_view("posts/archive");
}
Exemple #16
0
 public function get()
 {
     return render_view('user', array('user' => \Model\User::current()));
 }
function wpv_update_parametric_search() {
	$view_id = $_POST['viewid'];
	$getthis = $_POST['getthis'];
	$args = array(
		'id' => $view_id
	);
	$get_override = array();
	if ( isset( $_POST['valz'] ) && is_array( $_POST['valz'] ) ) {
		foreach ( $_POST['valz'] as $getter ) {
			if ( isset( $getter['name'] ) && isset( $getter['value'] ) ) {
				if ( strlen( $getter['name'] ) > 2 && substr( $getter['name'], -2 ) == '[]' ) {
					$real_name = substr( $getter['name'], 0, -2 );
					if ( isset( $get_override[$real_name] ) && is_array( $get_override[$real_name] ) ) {
						$get_override[$real_name][] = $getter['value'];
					} else {
						$get_override[$real_name] = array( $getter['value'] );
					}
				} else if ( $getter['name'] == 'wpv_post_id' ) {
					global $WP_Views, $post, $authordata, $id;
					$post_id = esc_attr( $getter['value'] ); // we need to set this for the post_type_dont_include_current_page setting to work
					$post = get_post($post_id);
					$WP_Views->top_current_page = $post;
					$authordata = new WP_User($post->post_author);
					$id = $post->ID;
					$WP_Views->current_page = array( $post );
				} else if ( $getter['name'] == 'wpv_aux_parent_term_id' ) {
					$WP_Views->parent_taxonomy = esc_attr( $getter['value'] );
				} else if ( $getter['name'] == 'wpv_aux_parent_user_id' ) {
					$WP_Views->parent_user = esc_attr( $getter['value'] );
				} else if ( in_array( $getter['name'], array( 'wpv_column_sort_id', 'wpv_column_sort_dir' ) ) ) {
					// @todo temporary workaround
					if ( 
						$getter['value'] != ''
					) {
						$get_override[$getter['name']] = $getter['value'];
					}
				} else {
					$get_override[$getter['name']] = $getter['value'];
				}
			}
		}
	}
	if ( isset( $_POST['targetid'] ) ) {
		$args['target_id'] = $_POST['targetid'];
	}
	if ( isset( $_POST['attributes'] ) && is_array( $_POST['attributes'] ) ) {
		$args = array_merge( $args, $_POST['attributes'] );
	}
	
	// Switch WPML to the correct language.
    if (isset($get_override['lang'])) {
        global $sitepress;
        if (method_exists($sitepress, 'switch_lang')) {
            $sitepress->switch_lang($get_override['lang']);
        }
    }
	
	$response = array();
	
	if ( $getthis == 'form' ) {
		if ( isset( $args['target_id'] ) ) {
			$response['form'] = render_view( $args, $get_override );
			unset( $args['target_id'] );
		}
		$response['full'] = '';
	} else if ( $getthis == 'full' ) {
		$response['form'] = '';
		if ( isset( $args['target_id'] ) ) {
			unset( $args['target_id'] );
		}
		$response['full'] = render_view( $args, $get_override );
	} else if ( $getthis == 'both' ) {
		if ( isset( $args['target_id'] ) ) {
			$response['form'] = render_view( $args, $get_override );
			unset( $args['target_id'] );
		}
		$response['full'] = render_view( $args, $get_override );
	} else {
		$response['form'] = '';
		$response['full'] = '';
	}
	/*
	$response['full'] = render_view( $args, $get_override );
	if ( isset( $args['target_id'] ) ) {
		$response['form'] = render_view( $args, $get_override );
		unset( $args['target_id'] );
	}
	$response['full'] = render_view( $args, $get_override );
	*/
	echo json_encode( $response );
	die();
}
<?php

/*
	Template Name: Landing Template
*/
get_header();
render_view('blog', $ctx);
get_footer();
<?php

/*
	Template Name: Landing Template
*/
get_header();
render_view('landing', $ctx);
get_footer();
Exemple #20
0
<?php

render_view("Main:Layouts:header.php");
?>

<h3>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sed
	tortor vitae felis mollis dapibus id sit amet lectus. Maecenas
	vulputate sem in lectus eleifend vulputate. Class aptent taciti
	sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.
	Phasellus ullamcorper magna in leo faucibus pretium.</h3>
<h2 class="center-text">
	<a href="<?php 
echo get_url('login');
?>
">Login</a>
</h2>
<p class="center-text">
	<img src="<?php 
asset('img/timetable.jpg');
?>
" width="300" height="220"
		alt="Timetable" />
</p>

<?php 
render_view("Main:Layouts:footer.php");
Exemple #21
0
 public function get()
 {
     return render_view('index');
 }
 /**
  * Render settings.  Shouldn't need to override though.
  */
 public function renderSettings()
 {
     echo render_view('base/ilab-settings.php', ['title' => $this->toolInfo['title'], 'group' => $this->options_group, 'page' => $this->options_page]);
 }
Exemple #23
0
    }
    if (!req()->isAjax()) {
        require ROOT_DIR . '/view/_error/500.php';
    }
    echo ob_get_clean();
    die(1);
});
try {
    $resp = app()->run();
} catch (Lysine\HttpError $ex) {
    if (req()->isAjax()) {
        throw $ex;
    }
    $code = $ex->getCode();
    if ($code == 404) {
        $resp = resp()->reset()->setCode($code)->setBody(render_view('_error/404', array('exception' => $ex)));
    } else {
        throw $ex;
    }
}
$profiler = Lysine\Utils\Profiler::instance();
$profiler->end(true);
$resp->setHeader('X-Runtime: ' . round($profiler->getRuntime('__MAIN__') ?: 0, 6))->sendHeader();
echo $resp;
// 尽快返回结果给fastcgi,剩下的环境清理工作已经和客户端无关
// php-fpm fastcgi特性
//
// 如果使用FirePHP/FireLogger这种通过header传递数据的调试工具
// 由于这些工具的header输出步骤都是注册到register_shutdown_function()
// 所以会在fastcgi_finish_request()之后才产生,客户端无法拿到调试信息
if (!DEBUG && PHP_SAPI == 'fpm-fcgi') {
 function loop_end($query)
 {
     if ($this->loop_found) {
         ob_end_clean();
         if ($this->loop_has_no_posts) {
             // Reset everything if the loop has no posts.
             // Then the View will render with no posts.
             global $post, $wp_query;
             $this->post_count = 0;
             $this->query->post_count = 0;
             $wp_query->post_count = 0;
             $wp_query->posts = array();
             $this->query->posts = array();
             $post = null;
         }
         $query->post_count = $this->post_count;
         $this->in_the_loop = true;
         echo render_view(array('id' => $this->view_id));
         $this->in_the_loop = false;
         $this->loop_found = false;
     }
 }
Exemple #25
0
<?php

get_header();
render_view('post', $ctx);
get_footer();
Exemple #26
0
<?php

/*
 * Making sure Wordless plugin is enabled
 */
if (!class_exists("Wordless")) {
    echo "This theme requires the <a href='https://github.com/welaika/wordless'>Wordless plugin</a> in order to work. Please, install it now!";
    die;
}
//for single pages
if (is_singular()) {
    $page_title = str_replace('-', ' ', ucfirst(get_the_category()[0]->slug));
    $page_id = get_page_by_path($page_title)->ID;
    if (is_single() && get_page_template_slug($page_id) == 'custom.php') {
        render_view("pages/index");
    } else {
        render_view("posts/single");
    }
    //for blog page
} else {
    if (is_home()) {
        render_view("posts/index");
    }
}
Exemple #27
0
<?php

/*
 * Making sure Wordless plugin is enabled
 */
if (!class_exists("Wordless")) {
    echo "This theme requires the <a href='https://github.com/welaika/wordless'>Wordless plugin</a> in order to work. Please, install it now!";
    die;
}
/*
 * In this page, you need to setup Wordless routing: you first
 * determine the type of the page using WordPress conditional tags,
 * and then delegate the rendering to some particular view using
 * the `render_view()` helper.
 *
 * To specify a layout other than the default one, please pass it as
 * the second parameter to the `render_view()` method.
 *
 * For a list of conditional tags, please see here: http://codex.wordpress.org/Conditional_Tags
 */
if (is_singular()) {
    if (get_the_title() == "Home") {
        render_view("pages/home");
    } else {
        render_view("pages/thank-you");
    }
} else {
    render_view("posts/404");
}
Exemple #28
0
<?php

// Template Name: Standard
render_view("pages/standard");
render_partial("tools/debug");
//debug data
<?php

/*
	Template Name: Landing Template
*/
get_header();
render_view('contact', $ctx);
get_footer();
Exemple #30
0
<?php

get_header();
render_view('404', $ctx);
get_footer();