本文整理汇总了PHP中Chamilo\CoreBundle\Framework\Container类的典型用法代码示例。如果您正苦于以下问题:PHP Container类的具体用法?PHP Container怎么用?PHP Container使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Container类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUserImageBlock
/**
* Returns an HTML block with the user picture (as a link in a <div>)
* @param int User ID (if not provided, will use the user ID from session)
* @return string HTML div with a link to the user's profile
* @uses UserManager::get_user_pictur_path_by_id() to get the image path
* @uses UserManager::get_picture_user() to get the details of the image in a specific format
* @uses PageController::show_right_block() to include the image in a larger user block
*/
public function setUserImageBlock($user_id = null)
{
if (empty($user_id)) {
$user_id = api_get_user_id();
}
//Always show the user image
$img_array = UserManager::get_user_picture_path_by_id($user_id, 'web', true, true);
$no_image = false;
if ($img_array['file'] == 'unknown.jpg') {
$no_image = true;
}
$img_array = UserManager::get_picture_user($user_id, $img_array['file'], 100, USER_IMAGE_SIZE_ORIGINAL);
$profile_content = null;
if (api_get_setting('social.allow_social_tool') == 'true') {
if (!$no_image) {
$profile_content .= '<a style="text-align:center" href="' . api_get_path(WEB_CODE_PATH) . 'social/home.php">
<img src="' . $img_array['file'] . '"></a>';
} else {
$profile_content .= '<a style="text-align:center" href="' . Container::getRouter()->generate('fos_user_profile_edit') . '">
<img title="' . get_lang('EditProfile') . '" src="' . $img_array['file'] . '"></a>';
}
}
if (!empty($profile_content)) {
$this->show_right_block(null, null, 'user_image_block', array('content' => $profile_content));
}
}
示例2: classicAction
/**
* @param string $name
* @param Request $request
* @return Response
*/
public function classicAction($name, Request $request)
{
// get.
$_GET = $request->query->all();
// post.
$_POST = $request->request->all();
$rootDir = $this->get('kernel')->getRealRootDir();
//$_REQUEST = $request->request->all();
$mainPath = $rootDir . 'main/';
$fileToLoad = $mainPath . $name;
// Setting legacy values inside the container
/** @var Connection $dbConnection */
$dbConnection = $this->container->get('database_connection');
$em = $this->get('kernel')->getContainer()->get('doctrine.orm.entity_manager');
$database = new \Database($dbConnection, array());
$database->setConnection($dbConnection);
$database->setManager($em);
Container::$container = $this->container;
Container::$dataDir = $this->container->get('kernel')->getDataDir();
Container::$courseDir = $this->container->get('kernel')->getDataDir();
//Container::$configDir = $this->container->get('kernel')->getConfigDir();
$this->container->get('twig')->addGlobal('api_get_cidreq', api_get_cidreq());
//$breadcrumb = $this->container->get('chamilo_core.block.breadcrumb');
if (is_file($fileToLoad) && \Security::check_abs_path($fileToLoad, $mainPath)) {
// Files inside /main need this variables to be set
$is_allowed_in_course = api_is_allowed_in_course();
$is_courseAdmin = api_is_course_admin();
$is_platformAdmin = api_is_platform_admin();
$toolNameFromFile = basename(dirname($fileToLoad));
$charset = 'UTF-8';
// Default values
$_course = api_get_course_info();
$_user = api_get_user_info();
$debug = $this->container->get('kernel')->getEnvironment() == 'dev' ? true : false;
// Loading file
ob_start();
require_once $fileToLoad;
$out = ob_get_contents();
ob_end_clean();
// No browser cache when executing an exercise.
if ($name == 'exercice/exercise_submit.php') {
$responseHeaders = array('cache-control' => 'no-store, no-cache, must-revalidate');
}
$js = isset($htmlHeadXtra) ? $htmlHeadXtra : array();
// $interbreadcrumb is loaded in the require_once file.
$interbreadcrumb = isset($interbreadcrumb) ? $interbreadcrumb : null;
$template = Container::$legacyTemplate;
$defaultLayout = 'layout_one_col.html.twig';
if (!empty($template)) {
$defaultLayout = $template;
}
return $this->render('ChamiloCoreBundle::' . $defaultLayout, array('legacy_breadcrumb' => $interbreadcrumb, 'content' => $out, 'js' => $js));
} else {
// Found does not exist
throw new NotFoundHttpException();
}
}
示例3: __construct
/**
* Class Constructor
* @param string $name
* @param string $elementLabel HTML editor label
* @param array $attributes Attributes for the textarea
* @param array $config Optional configuration settings for the online editor.
*
*/
public function __construct($name = null, $elementLabel = null, $attributes = [], $config = [])
{
if (empty($name)) {
return false;
}
parent::__construct($name, $elementLabel, $attributes);
$this->_persistantFreeze = true;
$this->_type = 'html_editor';
$editor = Container::getHtmlEditor();
if ($editor) {
$this->editor = $editor;
$this->editor->setName($name);
$this->editor->processConfig($config);
}
}
示例4: HTML_QuickForm_html_editor
/**
* Class constructor
* @param string HTML editor name/id
* @param string HTML editor label
* @param array Attributes for the textarea
* @param array $config Optional configuration settings for the online editor.
* @return bool
*/
public function HTML_QuickForm_html_editor($name = null, $label = null, $attributes = null, $config = null)
{
if (empty($name)) {
return false;
}
HTML_QuickForm_element::HTML_QuickForm_element($name, $label, $attributes);
$this->_persistantFreeze = true;
$this->_type = 'html_editor';
global $fck_attribute;
$editor = Container::getHtmlEditor();
if ($editor) {
$this->editor = $editor;
$this->editor->setName($name);
$this->editor->processConfig($fck_attribute);
$this->editor->processConfig($config);
}
}
示例5: array
/**
* Class constructor
*/
function HTML_QuickForm_Select_Language($elementName = null, $elementLabel = null, $options = null, $attributes = null)
{
if (!isset($attributes['class'])) {
$attributes['class'] = 'chzn-select';
}
parent::HTML_QuickForm_Select($elementName, $elementLabel, $options, $attributes);
// Get all languages
$languages = api_get_languages();
$this->_options = array();
$this->_values = array();
$platformLanguage = Container::getTranslator()->getLocale();
foreach ($languages as $language) {
if ($language['isocode'] == $platformLanguage) {
$this->addOption($language['english_name'], $language['isocode'], array('selected' => 'selected'));
} else {
$this->addOption($language['english_name'], $language['isocode']);
}
}
}
示例6: array
$template->addGlobal('is_allowed_to_edit', $is_allowed_to_edit);
$template->addGlobal('gamification_mode', $gamificationMode);
$template->addGlobal('breadcrumb', $breadcrumb);
$template->addGlobal('button_home_url', $buttonHomeUrl);
$template->addGlobal('button_home_text', $buttonHomeText);
$template->addGlobal('navigation_bar', $navigation_bar);
$template->addGlobal('progress_bar', $progress_bar);
$template->addGlobal('show_audio_player', $show_audioplayer);
$template->addGlobal('media_player', $mediaplayer);
$template->addGlobal('toc_list', $get_toc_list);
$template->addGlobal('teacher_toc_buttons', $get_teacher_buttons);
$template->addGlobal('iframe_src', $src);
$template->addGlobal('navigation_bar_bottom', $navigation_bar_bottom);
if ($gamificationMode == 1) {
$template->addGlobal('gamification_stars', $learnPath->getCalculateStars($sessionId));
$template->addGlobal('gamification_points', $learnPath->getCalculateScore($sessionId));
}
$template->addGlobal('lp_preview_image', Display::img($lpPreviewImagePath, $learnPath->name, array('class' => 'img-circle'), ICON_SIZE_BIG));
$template->addGlobal('lp_author', $learnPath->get_author());
$template->addGlobal('lp_mode', $learnPath->mode);
$template->addGlobal('lp_title_scorm', $learnPath->name);
$template->addGlobal('lp_html_toc', $learnPath->get_html_toc($get_toc_list));
$template->addGlobal('lp_id', $learnPath->lp_id);
$template->addGlobal('lp_current_item_id', $learnPath->get_current_item_id());
$content = $template->render('@template_style/learnpath/view.html.twig');
echo $content;
// Restore a global setting.
$_setting['show_navigation_menu'] = $save_setting;
// Hide headers
Container::$legacyTemplate = 'layout_one_col_no_content.html.twig';
$learnPath->updateCurrentLpFromSession();
示例7: array
$text_after_registration .= $form_register->returnForm();
// Just in case
Session::erase('course_redirect');
Session::erase('exercise_redirect');
if (CustomPages::enabled()) {
CustomPages::display(CustomPages::REGISTRATION_FEEDBACK, array('info' => $text_after_registration));
} else {
//$tpl = new Template($tool_name);
echo Container::getTemplating()->render('@template_style/auth/inscription.html.twig', ['inscription_content' => $content, 'text_after_registration' => $text_after_registration, 'hide_header' => $hideHeaders]);
}
} else {
// Custom pages
if (CustomPages::enabled()) {
CustomPages::display(CustomPages::REGISTRATION, array('form' => $form));
} else {
if (!api_is_anonymous()) {
// Saving user to course if it was set.
if (!empty($course_code_redirect)) {
$course_info = api_get_course_info($course_code_redirect);
if (!empty($course_info)) {
if (in_array($course_info['visibility'], array(COURSE_VISIBILITY_OPEN_PLATFORM, COURSE_VISIBILITY_OPEN_WORLD))) {
CourseManager::subscribe_user($user_id, $course_info['code']);
}
}
}
CourseManager::redirectToCourse([]);
}
//$tpl = new Template($tool_name);
echo Container::getTemplating()->render('@template_style/auth/inscription.html.twig', ['inscription_header' => Display::page_header($tool_name), 'inscription_content' => $content, 'hide_header' => $hideHeaders, 'form', $form->returnForm()]);
}
}
示例8: 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()));
示例9: Agenda
if (isset($_REQUEST['cidReq']) && !empty($_REQUEST['cidReq'])) {
$type = 'course';
}
$agenda = new Agenda();
$agenda->type = $type;
$is_group_tutor = false;
$session_id = api_get_session_id();
$group_id = api_get_group_id();
if (!empty($group_id)) {
$is_group_tutor = GroupManager::is_tutor_of_group(api_get_user_id(), $group_id);
$group_properties = GroupManager::get_group_properties($group_id);
$interbreadcrumb[] = array("url" => api_get_path(WEB_CODE_PATH) . "group/group.php?" . api_get_cidreq(), "name" => get_lang('Groups'));
$interbreadcrumb[] = array("url" => api_get_path(WEB_CODE_PATH) . "group/group_space.php?" . api_get_cidreq(), "name" => get_lang('GroupSpace') . ' ' . $group_properties['name']);
}
$app['title'] = get_lang('Agenda');
$tpl = Container::getTwig();
$tpl->addGlobal('use_google_calendar', 0);
$can_add_events = 0;
switch ($type) {
case 'admin':
api_protect_admin_script();
$this_section = SECTION_PLATFORM_ADMIN;
if (api_is_platform_admin()) {
$can_add_events = 1;
}
break;
case 'course':
api_protect_course_script(true);
$this_section = SECTION_COURSES;
if (api_is_allowed_to_edit()) {
$can_add_events = 1;
示例10: isset
}
$courses_controller->sessionsList($action, $nameTools, $limit);
break;
case 'subscribe_to_session':
if (!$user_can_view_page) {
api_not_allowed(true);
}
$userId = api_get_user_id();
$confirmed = isset($_GET['confirm']);
$sessionId = intval($_GET['session_id']);
if (empty($userId)) {
api_not_allowed();
exit;
}
if (!$confirmed) {
echo Container::getTemplating()->render('@template_style/auth/confirm_session_subscription.html.twig', ['session_id' => $sessionId]);
exit;
}
$registrationAllowed = api_get_setting('session.catalog_allow_session_auto_subscription');
if ($registrationAllowed === 'true') {
$entityManager = Database::getManager();
$repository = $entityManager->getRepository('ChamiloCoreBundle:SequenceResource');
$sequences = $repository->getRequirements($sessionId, SequenceResource::SESSION_TYPE);
if (count($sequences) > 0) {
$requirementsData = SequenceResourceManager::checkRequirementsForUser($sequences, SequenceResource::SESSION_TYPE, $userId);
$continueWithSubscription = SequenceResourceManager::checkSequenceAreCompleted($requirementsData);
if (!$continueWithSubscription) {
header('Location: ' . api_get_path(WEB_CODE_PATH) . 'auth/courses.php');
exit;
}
}
示例11: str_replace
// Setting the extension
$extension = 'html';
$content = Security::remove_XSS($values['content'], COURSEMANAGERLOWSECURITY);
/*if (strpos($content, '/css/frames.css') == false) {
$content = str_replace('</head>', '<link rel="stylesheet" href="./css/frames.css" type="text/css" /><style> body{margin:50px;}</style></head>', $content);
}*/
// Don't create file with the same name.
if (file_exists($filepath . $filename . '.' . $extension)) {
Display::display_header($nameTools, 'Doc');
Display::display_error_message(get_lang('FileExists') . ' ' . $title, false);
Display::display_footer();
exit;
}
if ($fp = @fopen($filepath . $filename . '.' . $extension, 'w')) {
//$courseUrl = \Chamilo\CoreBundle\Framework\Container::getUrlGenerator()->generate('course_url').'/';
$content = str_replace(api_get_path(WEB_COURSE_PATH), Container::getUrlAppend() . '/courses/', $content);
fputs($fp, $content);
fclose($fp);
chmod($filepath . $filename . '.' . $extension, api_get_permissions_for_new_files());
$file_size = filesize($filepath . $filename . '.' . $extension);
$save_file_path = $dir . $filename . '.' . $extension;
$document_id = add_document($_course, $save_file_path, 'file', $file_size, $title, null, $readonly);
if ($document_id) {
api_item_property_update($_course, TOOL_DOCUMENT, $document_id, 'DocumentAdded', $userId, $to_group_id, null, null, null, $current_session_id);
// Update parent folders
item_property_update_on_folder($_course, $dir, $userId);
$new_comment = isset($_POST['comment']) ? trim($_POST['comment']) : '';
$new_title = isset($_POST['title']) ? trim($_POST['title']) : '';
$new_title = htmlspecialchars($new_title);
if ($new_comment || $new_title) {
$ct = '';
示例12: getSkillBlock
/**
* Get HTML code block for user skills
* @param int $userId The user ID
* @return string
*/
public static function getSkillBlock($userId)
{
if (api_get_setting('skill.allow_skills_tool') !== 'true') {
return null;
}
$skill = new Skill();
$ranking = $skill->get_user_skill_ranking($userId);
$skills = $skill->get_user_skills($userId, true);
return Container::getTemplating()->render('@template_style/social/skills_block.html.twig', ['ranking' => $ranking, 'skills' => $skills, 'user_id' => $userId, 'show_skills_report_link' => api_is_student() || api_is_student_boss() || api_is_drh()]);
}
示例13: return_user_image_block
/**
* @return null|string
*/
public function return_user_image_block()
{
$html = null;
if (!api_is_anonymous()) {
$userPicture = UserManager::getUserPicture(api_get_user_id());
$content = null;
if (api_get_setting('social.allow_social_tool') == 'true') {
$content .= '<a style="text-align:center" href="' . api_get_path(WEB_PATH) . 'main/social/home.php">
<img class="img-circle" src="' . $userPicture . '" ></a>';
} else {
$edit = Container::getRouter()->generate('fos_user_profile_edit');
$content .= '<a style="text-align:center" href="' . $edit . '">
<img class="img-circle" title="' . get_lang('EditProfile') . '" src="' . $userPicture . '" ></a>';
}
$html = self::show_right_block(null, $content, 'user_image_block', array('style' => 'text-align:center;'));
}
return $html;
}
示例14: formatContent
/**
* Formats the content in order to add the welcome message,
* the notification preference, etc
* @param string $content
* @param array $senderInfo result of api_get_user_info() or
* GroupPortalManager:get_group_data()
*
* @return string
* */
public function formatContent($content, $senderInfo)
{
$hook = HookNotificationContent::create();
if (!empty($hook)) {
$hook->setEventData(array('content' => $content));
$data = $hook->notifyNotificationContent(HOOK_EVENT_TYPE_PRE);
if (isset($data['content'])) {
$content = $data['content'];
}
}
$newMessageText = $linkToNewMessage = '';
switch ($this->type) {
case self::NOTIFICATION_TYPE_DIRECT_MESSAGE:
$newMessageText = '';
$linkToNewMessage = Display::url(get_lang('SeeMessage'), api_get_path(WEB_CODE_PATH) . 'messages/inbox.php');
break;
case self::NOTIFICATION_TYPE_MESSAGE:
if (!empty($senderInfo)) {
$senderName = api_get_person_name($senderInfo['firstname'], $senderInfo['lastname'], null, PERSON_NAME_EMAIL_ADDRESS);
$newMessageText = sprintf(get_lang('YouHaveANewMessageFromX'), $senderName);
}
$linkToNewMessage = Display::url(get_lang('SeeMessage'), api_get_path(WEB_CODE_PATH) . 'messages/inbox.php');
break;
case self::NOTIFICATION_TYPE_INVITATION:
if (!empty($senderInfo)) {
$senderName = api_get_person_name($senderInfo['firstname'], $senderInfo['lastname'], null, PERSON_NAME_EMAIL_ADDRESS);
$newMessageText = sprintf(get_lang('YouHaveANewInvitationFromX'), $senderName);
}
$linkToNewMessage = Display::url(get_lang('SeeInvitation'), api_get_path(WEB_CODE_PATH) . 'social/invitations.php');
break;
case self::NOTIFICATION_TYPE_GROUP:
$topic_page = intval($_REQUEST['topics_page_nr']);
if (!empty($senderInfo)) {
$senderName = $senderInfo['group_info']['name'];
$newMessageText = sprintf(get_lang('YouHaveReceivedANewMessageInTheGroupX'), $senderName);
$senderName = api_get_person_name($senderInfo['user_info']['firstname'], $senderInfo['user_info']['lastname'], null, PERSON_NAME_EMAIL_ADDRESS);
$senderName = Display::url($senderName, api_get_path(WEB_CODE_PATH) . 'social/profile.php?' . $senderInfo['user_info']['user_id']);
$newMessageText .= '<br />' . get_lang('User') . ': ' . $senderName;
}
$group_url = api_get_path(WEB_CODE_PATH) . 'social/group_topics.php?id=' . $senderInfo['group_info']['id'] . '&topic_id=' . $senderInfo['group_info']['topic_id'] . '&msg_id=' . $senderInfo['group_info']['msg_id'] . '&topics_page_nr=' . $topic_page;
$linkToNewMessage = Display::url(get_lang('SeeMessage'), $group_url);
break;
}
$preference_url = Container::getRouter()->generate('fos_user_profile_edit');
// You have received a new message text
if (!empty($newMessageText)) {
$content = $newMessageText . '<br /><hr><br />' . $content;
}
// See message with link text
if (!empty($linkToNewMessage) && api_get_setting('message.allow_message_tool') == 'true') {
$content = $content . '<br /><br />' . $linkToNewMessage;
}
// You have received this message because you are subscribed text
$content = $content . '<br /><hr><i>' . sprintf(get_lang('YouHaveReceivedThisNotificationBecauseYouAreSubscribedOrInvolvedInItToChangeYourNotificationPreferencesPleaseClickHereX'), Display::url($preference_url, $preference_url)) . '</i>';
if (!empty($hook)) {
$hook->setEventData(array('content' => $content));
$data = $hook->notifyNotificationContent(HOOK_EVENT_TYPE_POST);
if (isset($data['content'])) {
$content = $data['content'];
}
}
return $content;
}
示例15: switch
} else {
// Update
$sequenceResource->getSequence()->setGraphAndSerialize($graph);
}
$em->persist($sequenceResource);
$em->flush();
echo Display::return_message(get_lang('Saved'), 'success');
break;
}
break;
case 'get_requirements':
$userId = api_get_user_id();
switch ($type) {
case SequenceResource::SESSION_TYPE:
$session = api_get_session_info($id);
$sequences = $repository->getRequirements($session['id'], $type);
if (count($sequences) === 0) {
break;
}
$sequenceList = SequenceResourceManager::checkRequirementsForUser($sequences, $type, $userId);
$allowSubscription = SequenceResourceManager::checkSequenceAreCompleted($sequenceList);
$courseController = new CoursesController();
$subscribeButton = '';
if ($allowSubscription) {
$subscribeButton = $courseController->getRegisteredInSessionButton($session['id'], $session['name'], false);
}
echo Container::getTemplating()->render('@template_style/sequence_resource/session_requirements.html.twig', ['sequences' => $sequenceList, 'allow_subscription' => $allowSubscription, 'subscribe_button' => $subscribeButton]);
break;
}
break;
}