本文整理汇总了PHP中Chamilo\CoreBundle\Framework\Container::getTemplate方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::getTemplate方法的具体用法?PHP Container::getTemplate怎么用?PHP Container::getTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chamilo\CoreBundle\Framework\Container
的用法示例。
在下文中一共展示了Container::getTemplate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isset
$course['teachers'] = $course_teachers;
//$course['user_id'] = $teacher_id;
$course['wanted_code'] = $course['visual_code'];
$course['gradebook_model_id'] = isset($course['gradebook_model_id']) ? $course['gradebook_model_id'] : null;
// Fixing category code
$course['course_category'] = $course['category_code'];
$course_info = CourseManager::create_course($course);
header('Location: course_list.php'.($course_info===false?'?action=show_msg&warn='.api_get_last_failure():''));
exit;
}*/
// Display the form.
$content = $form->return_form();
//echo $content;
$em = Container::getEntityManager();
$request = Container::getRequest();
$course = new Course();
$builder = Container::getFormFactory()->createBuilder(new CourseType(), $course);
$form = $builder->getForm();
$form->handleRequest($request);
if ($form->isValid()) {
$course = $form->getData();
$em->persist($course);
$em->flush();
Container::addFlash(get_lang('Updated'));
$url = Container::getRouter()->generate('main', array('name' => 'admin/course_list.php'));
header('Location: ' . $url);
exit;
}
echo Container::getTemplate()->render('ChamiloCoreBundle:Legacy:form.html.twig', array('form' => $form->createView(), 'url' => api_get_self()));
示例2: isset
//.........这里部分代码省略.........
if ($ok_to_register_course) {
/** @var Course $course */
$course = self::getCourseManager()->create();
$course->setCode($code)->setDirectory($directory)->setCourseLanguage($course_language)->setTitle($title)->setDescription(get_lang('CourseDescription'))->setCategoryCode($category_code)->setVisibility($visibility)->setShowScore(1)->setDiskQuota($disk_quota)->setCreationDate(new \DateTime())->setExpirationDate(new \DateTime($expiration_date))->setDepartmentName($department_name)->setDepartmentUrl($department_url)->setSubscribe($subscribe)->setUnsubscribe($unsubscribe)->setVisualCode($visual_code);
self::getCourseManager()->save($course, true);
$course_id = $course->getId();
/*// Here we must add 2 fields.
$sql = "INSERT INTO ".$TABLECOURSE . " SET
code = '".Database :: escape_string($code) . "',
directory = '".Database :: escape_string($directory) . "',
course_language = '".Database :: escape_string($course_language) . "',
title = '".Database :: escape_string($title) . "',
description = '".Database::escape_string(get_lang('CourseDescription')) . "',
category_code = '".Database :: escape_string($category_code) . "',
visibility = '".$visibility . "',
show_score = '1',
disk_quota = '".intval($disk_quota) . "',
creation_date = '$time',
expiration_date = '".$expiration_date . "',
last_edit = '$time',
last_visit = NULL,
tutor_name = '".Database :: escape_string($tutor_name) . "',
department_name = '".Database :: escape_string($department_name) . "',
department_url = '".Database :: escape_string($department_url) . "',
subscribe = '".intval($subscribe) . "',
unsubscribe = '".intval($unsubscribe) . "',
visual_code = '".Database :: escape_string($visual_code) . "'";
Database::query($sql);
$course_id = Database::insert_id();*/
//$course->addUsers()
if ($course_id) {
$settingsManager = Container::getCourseSettingsManager();
$schemas = $settingsManager->getSchemas();
$schemas = array_keys($schemas);
/**
* @var string $key
* @var \Sylius\Bundle\SettingsBundle\Schema\SchemaInterface $schema
*/
foreach ($schemas as $schema) {
$settings = $settingsManager->loadSettings($schema);
$settingsManager->setCourse($course);
$settingsManager->saveSettings($schema, $settings);
}
$sort = api_max_sort_value('0', api_get_user_id());
$i_course_sort = CourseManager::userCourseSort($user_id, $code);
if (!empty($user_id)) {
$sql = "INSERT INTO " . $TABLECOURSUSER . " SET\n c_id = '" . Database::escape_string($course_id) . "',\n user_id = '" . intval($user_id) . "',\n status = '1',\n tutor_id = '0',\n sort = '" . $i_course_sort . "',\n user_course_cat = '0'";
Database::query($sql);
}
if (!empty($teachers)) {
if (!is_array($teachers)) {
$teachers = array($teachers);
}
foreach ($teachers as $key) {
//just in case
if ($key == $user_id) {
continue;
}
if (empty($key)) {
continue;
}
$sql = "INSERT INTO " . $TABLECOURSUSER . " SET\n c_id = '" . Database::escape_string($course_id) . "',\n user_id = '" . Database::escape_string($key) . "',\n status = '1',\n role = '',\n tutor_id = '0',\n sort = '" . ($sort + 1) . "',\n user_course_cat = '0'";
Database::query($sql);
}
}
// Adding the course to an URL
if (api_is_multiple_url_enabled()) {
$url_id = 1;
if (api_get_current_access_url_id() != -1) {
$url_id = api_get_current_access_url_id();
}
UrlManager::add_course_to_url($course_id, $url_id);
} else {
UrlManager::add_course_to_url($course_id, 1);
}
// Add event to the system log.
$user_id = api_get_user_id();
Event::addEvent(LOG_COURSE_CREATE, LOG_COURSE_CODE, $code, api_get_utc_datetime(), $user_id, $code);
$send_mail_to_admin = api_get_setting('course.send_email_to_admin_when_create_course');
// @todo Improve code to send to all current portal administrators.
if ($send_mail_to_admin == 'true') {
$siteName = api_get_setting('platform.site_name');
$recipient_email = api_get_setting('platform.administrator_email');
$recipient_name = api_get_person_name(api_get_setting('platform.administrator_name'), api_get_setting('platform.administrator_surname'));
$iname = api_get_setting('platform.institution');
$subject = get_lang('NewCourseCreatedIn') . ' ' . $siteName . ' - ' . $iname;
$body = get_lang('Dear') . ' ' . $recipient_name . ",\n\n" . get_lang('MessageOfNewCourseToAdmin') . ' ' . $siteName . ' - ' . $iname . "\n";
$body .= get_lang('CourseName') . ' ' . $title . "\n";
$body .= get_lang('Category') . ' ' . $category_code . "\n";
$body .= get_lang('Tutor') . ' ' . $tutor_name . "\n";
$body .= get_lang('Language') . ' ' . $course_language;
//api_mail_html($recipient_name, $recipient_email, $subject, $message, $siteName, $recipient_email);
$message = \Swift_Message::newInstance()->setSubject($subject)->setFrom($recipient_email)->setTo($recipient_email)->setBody(Container::getTemplate()->render('ChamiloCoreBundle:Mailer:Course/new_course.html.twig', array('recipient_name' => $recipient_name, 'sitename' => $siteName, 'institution' => $iname, 'course_name' => $title, 'category' => $category_code, 'tutor' => $tutor_name, 'language' => $course_language)));
Container::getMailer()->send($message);
}
}
}
return $course_id;
}
示例3: time
$image_dir = $image_path['dir'];
$image = $image_path['file'];
$image_file = $image != '' ? $image_dir . $image : api_get_path(WEB_IMG_PATH) . 'unknown.jpg';
$image_size = api_getimagesize($image_file);
// get the path,width and height from original picture
$big_image = $image_dir . 'big_' . $image;
$big_image_size = api_getimagesize($big_image);
$big_image_width = $big_image_size['width'];
$big_image_height = $big_image_size['height'];
$url_big_image = $big_image . '?rnd=' . time();
// Display form
$content = $form->return_form();
$em = Container::getEntityManager();
$request = Container::getRequest();
$user = new User();
if (!empty($user_id)) {
$user = $em->getRepository('ChamiloUserBundle:User')->find($user_id);
}
$builder = Container::getFormFactory()->createBuilder(new UserType(Container::getSecurity()), $user);
$form = $builder->getForm();
$form->handleRequest($request);
if ($form->isValid()) {
$em->flush();
Container::addFlash(get_lang('Updated'));
$url = Container::getRouter()->generate('main', array('name' => 'admin/user_list.php'));
header('Location: ' . $url);
exit;
}
$urlAction = api_get_self() . '?user_id=' . $user_id;
echo Container::getTemplate()->render('ChamiloCoreBundle:User:create.html.twig', array('form' => $form->createView(), 'url' => $urlAction));
示例4: api_mail_html
/**
* Sends an HTML email using the phpmailer class (and multipart/alternative to downgrade gracefully)
* Sender name and email can be specified, if not specified
* name and email of the platform admin are used
*
* @author Bert Vanderkimpen ICT&O UGent
* @author Yannick Warnier <yannick.warnier@beeznest.com>
*
* @param string name of recipient
* @param string email of recipient
* @param string email subject
* @param string email body
* @param string sender name
* @param string sender e-mail
* @param array extra headers in form $headers = array($name => $value) to allow parsing
* @param array data file (path and filename)
* @param array data to attach a file (optional)
* @param bool True for attaching a embedded file inside content html (optional)
* @return returns true if mail was sent
* @see class.phpmailer.php
*/
function api_mail_html($recipient_name, $recipient_email, $subject, $body, $sender_name = '', $sender_email = '', $extra_headers = null, $data_file = array(), $embedded_image = false, $text_body = null)
{
$reply_to_mail = $sender_email;
$reply_to_name = $sender_name;
if (isset($extra_headers['reply_to'])) {
$reply_to_mail = $extra_headers['reply_to']['mail'];
$reply_to_name = $extra_headers['reply_to']['name'];
}
// Forcing the conversion.
if (strpos($body, '<html>') === false) {
$htmlBody = str_replace(array("\n\r", "\n", "\r"), '<br />', $body);
$htmlBody = '<html><head></head><body>' . $htmlBody . '</body></html>';
} else {
$htmlBody = $body;
}
if (!empty($text_body)) {
$textBody = $text_body;
} else {
$textBody = $body;
}
try {
$message = \Swift_Message::newInstance()->setSubject($subject)->setFrom(array($sender_email => $sender_name))->setTo(array($recipient_email => $recipient_name))->setReplyTo(array($reply_to_mail => $reply_to_name))->setBody(Container::getTemplate()->render('ChamiloCoreBundle:Mailer:Default/default.html.twig', array('content' => $htmlBody)), 'text/html')->addPart(Container::getTemplate()->render('ChamiloCoreBundle:Mailer:Default/default.text.twig', array('content' => $textBody)), 'text/plain')->setEncoder(Swift_Encoding::get8BitEncoding());
if (!empty($data_file)) {
// Attach it to the message
$message->attach(Swift_Attachment::fromPath($data_file['path']))->setFilename($data_file['filename']);
}
$type = $message->getHeaders()->get('Content-Type');
$type->setValue('text/html');
$type->setParameter('charset', 'utf-8');
Container::getMailer()->send($message);
return true;
} catch (Exception $e) {
error_log($e->getMessage());
}
return false;
}
示例5: create_user
//.........这里部分代码省略.........
}
$creator_id = api_get_user_id();
// First check wether the login already exists
if (!self::is_username_available($loginName)) {
return api_set_failure('login-pass already taken');
}
if (empty($encrypt_method)) {
$password = api_get_encrypted_password($password);
} else {
if ($_configuration['password_encryption'] === $encrypt_method) {
if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) {
return api_set_failure('encrypt_method invalid');
} else {
if ($encrypt_method == 'sha1' && !preg_match('/^[A-Fa-f0-9]{40}$/', $password)) {
return api_set_failure('encrypt_method invalid');
}
}
} else {
return api_set_failure('encrypt_method invalid');
}
}
//@todo replace this date with the api_get_utc_date function big problem with users that are already registered
$current_date = api_get_utc_datetime();
$em = Database::getManager();
$expirationDate = new \DateTime($expiration_date);
$user = new \Chamilo\UserBundle\Entity\User();
$user->setLastname($lastName)->setFirstname($firstName)->setUsername($loginName)->setPassword($password)->setEmail($email)->setOfficialCode($official_code)->setPictureUri($picture_uri)->setCreatorId($creator_id)->setAuthSource($auth_source)->setPhone($phone)->setLanguage($language)->setExpirationDate($expirationDate)->setHrDeptId($hr_dept_id)->setActive($active);
/*$sql = "INSERT INTO $table_user ".
"SET lastname = '".Database::escape_string(trim($lastName))."',".
"firstname = '".Database::escape_string(trim($firstName))."',".
"username = '".Database::escape_string(trim($loginName))."',".
"status = '".Database::escape_string($status)."',".
"password = '".Database::escape_string($password)."',".
"email = '".Database::escape_string($email)."',".
"official_code = '".Database::escape_string($official_code)."',".
"picture_uri = '".Database::escape_string($picture_uri)."',".
"creator_id = '".Database::escape_string($creator_id)."',".
"auth_source = '".Database::escape_string($auth_source)."',".
"phone = '".Database::escape_string($phone)."',".
"language = '".Database::escape_string($language)."',".
"registration_date = '".$current_date."',".
"expiration_date = '".Database::escape_string($expiration_date)."',".
"hr_dept_id = '".Database::escape_string($hr_dept_id)."',".
"active = '".Database::escape_string($active)."'";
$result = Database::query($sql);*/
$em->persist($user);
$em->flush();
if ($user) {
$userId = $user->getId();
if (api_get_multiple_access_url()) {
UrlManager::add_user_to_url($userId, api_get_current_access_url_id());
} else {
//we are adding by default the access_url_user table with access_url_id = 1
UrlManager::add_user_to_url($userId, 1);
}
$group = $em->getRepository('ChamiloUserBundle:Group')->find($status);
$user->addGroup($group);
//$user->addRole($roleName);
$em->persist($user);
$em->flush();
if (!empty($email) && $send_mail) {
$recipient_name = api_get_person_name($firstName, $lastName, null, PERSON_NAME_EMAIL_ADDRESS);
$emailsubject = '[' . api_get_setting('platform.site_name') . '] ' . get_lang('YourReg') . ' ' . api_get_setting('platform.site_name');
$sender_name = api_get_person_name(api_get_setting('platform.administrator_name'), api_get_setting('platform.administrator_surname'), null, PERSON_NAME_EMAIL_ADDRESS);
$email_admin = api_get_setting('platform.administrator_email');
$params = array('complete_user_name' => api_get_person_name($firstName, $lastName), 'login_name' => $loginName, 'password' => stripslashes($original_password));
$message = \Swift_Message::newInstance()->setSubject($emailsubject)->setFrom(array($email_admin => $sender_name))->setTo(array($email => $recipient_name))->setBody(Container::getTemplate()->render('ChamiloCoreBundle:Mailer:User/new_user.html.twig', $params), 'text/html')->addPart(Container::getTemplate()->render('ChamiloCoreBundle:Mailer:User/new_user.text.twig', $params), 'text/plain')->setEncoder(Swift_Encoding::get8BitEncoding());
$type = $message->getHeaders()->get('Content-Type');
$type->setValue('text/html');
$type->setParameter('charset', 'utf-8');
Container::getMailer()->send($message);
/* MANAGE EVENT WITH MAIL */
/*if (EventsMail::check_if_using_class('user_registration')) {
$values["about_user"] = $return;
$values["password"] = $original_password;
$values["send_to"] = array($return);
$values["prior_lang"] = null;
EventsDispatcher::events('user_registration', $values);
} else {
@api_mail_html($recipient_name, $email, $emailsubject, $emailbody, $sender_name, $email_admin);
}*/
/* ENDS MANAGE EVENT WITH MAIL */
}
// Add event to system log
$user_id_manager = api_get_user_id();
$user_info = api_get_user_info($userId);
Event::addEvent(LOG_USER_CREATE, LOG_USER_ID, $userId, api_get_utc_datetime(), $user_id_manager);
Event::addEvent(LOG_USER_CREATE, LOG_USER_OBJECT, $user_info, api_get_utc_datetime(), $user_id_manager);
} else {
return api_set_failure('error inserting in Database');
}
if (is_array($extra) && count($extra) > 0) {
$res = true;
foreach ($extra as $fname => $fvalue) {
$res = $res && self::update_extra_field_value($userId, $fname, $fvalue);
}
}
self::update_extra_field_value($userId, 'already_logged_in', 'false');
return $userId;
}