public function update_action() { if (!$this->input->is_ajax_request()) { show_404(); } $name = $this->input->post('name', true); $link = $this->input->post('link', true); $info = $this->input->post('info', true); $sort = (int) $this->input->post('sort'); $data['name'] = trim($name); $data['link'] = $link; $data['info'] = substring(format_content($info), 240); $data['sort'] = $sort > 255 ? 255 : $sort; if (!$data['name'] or !$data['link']) { JSON('error', '对不起,请填写必填字段!'); } if (!is_url($data['link'])) { JSON('error', '请填写有效的网站 URL 地址!'); } $lid = (int) $this->input->post('lid'); $this->db->update('link', $data, array('lid' => $lid)); if ($this->db->affected_rows()) { JSON('success', '恭喜,链接已更新成功!'); } else { JSON('error', '对不起,链接没有更新名更新失败!'); } }
public function update_action() { if (!$this->input->is_ajax_request()) { show_404(); } $cid = (int) $this->input->post('cid'); if ($cid === 0) { JSON('error', '对不起,更新分类提交失败!'); } $name = $this->input->post('name', true); $link = $this->input->post('link', true); $keyword = $this->input->post('keyword', true); $description = $this->input->post('description', true); $sort = (int) $this->input->post('sort'); $data['name'] = trim($name); $data['link'] = url_title($link, 'underscore', true); $data['sort'] = $sort > 255 ? 255 : $sort; $data['keyword'] = format_keyword($keyword); $data['description'] = substring(format_content($description), 240); if (!$data['name'] or !$data['link']) { JSON('error', '对不起,请填写必填字段!'); } if ($this->category_model->get_info(array('cid !=' => $cid, 'name' => $name))) { JSON('error', '对不起,分类名称已经存在!'); } if ($this->category_model->get_info(array('cid !=' => $cid, 'link' => $link))) { JSON('error', '对不起,分类链接名称已经存在!'); } $this->db->update('category', $data, array('cid' => $cid)); if ($this->db->affected_rows()) { JSON('success', '恭喜,分类 ' . $data['name'] . ' 更新成功!'); } else { JSON('error', '对不起,分类没有更新或更新失败!'); } }
function populate_a4a($cid, $content, $formatting) { global $db, $my_files, $content_base_href, $contentManager; // Defining alternatives is only available for content type "html". // But don't clean up the a4a tables at other content types in case the user needs them back at html. if ($formatting != 1) { return; } include_once AT_INCLUDE_PATH . '../mods/_core/imsafa/classes/A4a.class.php'; include_once AT_INCLUDE_PATH . 'classes/XML/XML_HTMLSax/XML_HTMLSax.php'; /* for XML_HTMLSax */ include_once AT_INCLUDE_PATH . 'classes/ContentOutputParser.class.php'; /* for parser */ // initialize content_base_href; used in format_content if (!isset($content_base_href)) { $result = $contentManager->getContentPage($cid); // return if the cid is not found foreach ($result as $content_row) { if (count($content_row) < 1) { return; } else { $content_base_href = $content_row["content_path"] . '/'; } } } $body = format_content($content, $formatting, array()); $handler = new ContentOutputParser(); $parser = new XML_HTMLSax(); $parser->set_object($handler); $parser->set_element_handler('openHandler', 'closeHandler'); $my_files = array(); $parser->parse($body); $my_files = array_unique($my_files); foreach ($my_files as $file) { /* filter out full urls */ $url_parts = @parse_url($file); // file should be relative to content if (substr($file, 0, 1) == '/') { continue; } // The URL of the movie from youtube.com has been converted above in embed_media(). // For example: http://www.youtube.com/watch?v=a0ryB0m0MiM is converted to // http://www.youtube.com/v/a0ryB0m0MiM to make it playable. This creates the problem // that the parsed-out url (http://www.youtube.com/v/a0ryB0m0MiM) does not match with // the URL saved in content table (http://www.youtube.com/watch?v=a0ryB0m0MiM). // The code below is to convert the URL back to original. $file = convert_youtube_playURL_to_watchURL($file); $resources[] = convert_amp($file); // converts & to & } $a4a = new A4a($cid); $db_primary_resources = $a4a->getPrimaryResources(); // clean up the removed resources foreach ($db_primary_resources as $primary_rid => $db_resource) { //if this file from our table is not found in the $resource, then it's not used. if (count($resources) == 0 || !in_array($db_resource['resource'], $resources)) { $a4a->deletePrimaryResource($primary_rid); } } if (count($resources) == 0) { return; } // insert the new resources foreach ($resources as $primary_resource) { if (!$a4a->getPrimaryResourceByName($primary_resource)) { $a4a->setPrimaryResource($cid, $primary_resource, $_SESSION['lang']); } } }
public function send_mail($entity_type, $entity_id, $post_id) { // We need the automailer require AT_INCLUDE_PATH . 'classes/phpmailer/atutormailer.class.php'; //Also, we need to know what ballpark we're in $ent_param = $this->entity_switch($entity_type); // Now, what are we going to send? $fetch = !empty($ent_param[content_head]) ? $ent_param[content_head] . "," . $ent_param[content_body] : $ent_param[content_body]; $sql = "SELECT {$fetch} FROM {$ent_param['content_table']} WHERE {$ent_param['content_id']} = '{$post_id}'"; $post = queryDB($sql, array()); //Get all subscribers $sql = "SELECT t1.email, t1.member_id FROM " . TABLE_PREFIX . "members t1, {$ent_param['sub_table']} t2 WHERE t2.{$ent_param['sub_id']} = '{$entity_id}' AND t1.member_id=t2.member_id"; $rows_subscribers = queryDB($sql, array()); //get system email $sysinfo = $this->get_system_email(); //Send lots of mails foreach ($rows_subscribers as $subscriber) { $mail = new ATutorMailer(); $mail->AddAddress($subscriber['email'], get_display_name($subscriber['member_id'])); $body = $ent_param[mail_header]; $body .= "<hr />"; $body .= _AT('posted_by') . ": " . get_display_name($_SESSION['member_id']) . "<br />"; $body .= !empty($ent_param[content_head]) ? "<h2>" . $post[$ent_param[content_head]] . "</h2><br />" : ''; $body .= format_content($post[$ent_param[content_body]], $_POST['formatting'], $glossary) . "<br />"; $mail->CharSet = 'utf-8'; $mail->ContentType = 'text/html'; $mail->FromName = $sysinfo['site_name']; $mail->From = $sysinfo['contact_email']; $mail->Subject = $ent_param[mail_subject]; $mail->Body = $body; if (!$mail->Send()) { $msg->addError('SENDING_ERROR'); } unset($mail); } }
public function edit($node_id, $topic_id, $id) { if (empty($node_id) || empty($topic_id) || empty($id)) { show_message('缺少参数哟', site_url('topic/show/' . $topic_id)); } $this->load->model('comment_m'); $data['comment'] = $this->comment_m->get_comment_by_id($id); if ($this->auth->is_admin() || $this->auth->is_master($node_id) || $this->auth->is_user($data['comment']['uid'])) { //无编辑器时的处理 //if($this->config->item('show_editor')=='off'){ // $data['comment']['content'] = filter_check($data['comment']['content']); // $this->load->helper('format_content'); // $data['comment']['content'] = format_content($data['comment']['content']); // $data['comment']['content'] =br2nl($data['comment']['content'] ); //} $data['comment']['content'] = br2nl($data['comment']['content']); $data['comment']['content'] = $this->input->post('content') ? $this->input->post('content') : $data['comment']['content']; $data['comment']['content'] = decode_format($data['comment']['content']); $data['comment']['node_id'] = $node_id; //加载form类,为调用错误函数,需view前加载 $this->load->helper('form'); if ($this->form_validation->run('comment/edit') === TRUE) { //数据处理 $comment = array('content' => $this->input->post('content', true), 'replytime' => time()); $this->load->helper('format_content'); $comment['content'] = format_content($comment['content']); if ($this->db->where('id', $id)->update('comments', $comment)) { //更新贴子回复时间 $this->load->model('topic_m'); $this->db->set('lastreply', time(), FALSE)->where('topic_id', $topic_id)->update('topics'); redirect('topic/show/' . $topic_id); exit; } } $data['title'] = '编辑回贴'; $data['csrf_name'] = $this->security->get_csrf_token_name(); $data['csrf_token'] = $this->security->get_csrf_hash(); $this->load->view('comment_edit', $data); } else { show_message('非本人或管理员或本版块版主不能操作', site_url('topic/show/' . $topic_id)); } }
return strip_tags($title); } // Format content accordingly function format_content($content) { // Convert all \n into <br/> for proper content display return str_replace("\n", '<br />', $content); } $post_controller = new PostController($db); // Initialize Post Controller // HTTP Requests if (isset($_POST['add'])) { // Publish a post $post_controller->publish($_SESSION['userid'], format_title($_POST['title']), format_content($_POST['content'])); } if (isset($_GET['delete'])) { // Delete a post $post = $post_controller->search_by_id($_GET['id']); // Ensure that only authors can delete their own posts if ($_SESSION['userid'] == $post['author_id']) { // Authorized $post_controller->delete($post['id']); } else { // Not Authorized header('Location: index.php'); } } if (isset($_POST['update'])) { // Update an existing post $post_controller->update($_POST['id'], format_title($_POST['title']), format_content($_POST['content'])); }
} else { header('Location: ' . url_rewrite('mods/_standard/tests/test_intro.php?tid=' . $pre_test_id . SEP . 'cid=' . $cid, AT_PRETTY_URL_IS_HEADER)); exit; } } // if one of the prerequisite test(s) has expired, student cannot view the content if (intval($pre_test_id) != -1 || authenticate(AT_PRIV_CONTENT, AT_PRIV_RETURN)) { // find whether the body has alternatives defined list($has_text_alternative, $has_audio_alternative, $has_visual_alternative, $has_sign_lang_alternative) = provide_alternatives($cid, $content_row['text'], true); // apply alternatives if (intval($_GET['alternative']) > 0) { $content = provide_alternatives($cid, $content_row['text'], false, intval($_GET['alternative'])); } else { $content = provide_alternatives($cid, $content_row['text']); } $content = format_content($content, $content_row['formatting'], $glossary); $content_array = get_content_table($content); // Create the array of alternative information for generating the AFA tool bar $alt_infos = array(); $pause_image = find_image("pause.png"); if ($has_text_alternative) { $alt_infos['has_text_alternative'] = array('3', _AT('apply_text_alternatives'), _AT('stop_apply_text_alternatives'), $pause_image, find_image('text_alternative.png')); } if ($has_audio_alternative) { $alt_infos['has_audio_alternative'] = array('1', _AT('apply_audio_alternatives'), _AT('stop_apply_audio_alternatives'), $pause_image, find_image('audio_alternative.png')); } if ($has_visual_alternative) { $alt_infos['has_visual_alternative'] = array('4', _AT('apply_visual_alternatives'), _AT('stop_apply_visual_alternatives'), $pause_image, find_image('visual_alternative.png')); } if ($has_sign_lang_alternative) { $alt_infos['has_sign_lang_alternative'] = array('2', _AT('apply_sign_lang_alternatives'), _AT('stop_apply_sign_lang_alternatives'), $pause_image, find_image('sign_lang_alternative.png'));
</time>, <?php echo $contributors; ?> </span> </p> <div class="controls"> <a href="#!show-hide" class="expand" style="display:none"><span class="hidden">show / hide details</span></a> <a href="#!show-hide" class="contract" style="display:block"><span class="hidden">show / hide details</span></a> </div> <div class="event-detail"> <?php echo format_content($post->post_content); ?> <?php $eventdate = strtotime(get_post_meta(get_the_ID(), 'events-date', true)); ?> <a class="button" href="mailto:marketing@futurestep.com?Subject=Register%20for%20event%20<?php echo date('d/m/Y', $eventdate); ?> ,%20<?php the_title(); ?> ">Register for event</a> </div> </li>
function print_organizations($parent_id, &$_menu, $depth, $path = '', $children, &$string) { global $html_content_template, $default_html_style, $zipfile, $resources, $ims_template_xml, $parser, $my_files; global $used_glossary_terms, $course_id, $course_language_charset, $course_language_code; static $paths, $zipped_files; global $glossary; global $test_zipped_files, $use_a4a, $db; $space = ' '; $prefix = ' '; if ($depth == 0) { $string .= '<ul>'; } $top_level = $_menu[$parent_id]; if (!is_array($paths)) { $paths = array(); } if (!is_array($zipped_files)) { $zipped_files = array(); } if (is_array($top_level)) { $counter = 1; $num_items = count($top_level); foreach ($top_level as $garbage => $content) { $link = ''; if ($content['content_path']) { $content['content_path'] .= '/'; } //if this is a folder, export it without identifierref if ($content['content_type'] == CONTENT_TYPE_FOLDER) { $link = $prevfix . '<item identifier="MANIFEST01_ITEM' . $content['content_id'] . '">' . "\n"; } else { $link = $prevfix . '<item identifier="MANIFEST01_ITEM' . $content['content_id'] . '" identifierref="MANIFEST01_RESOURCE' . $content['content_id'] . '" parameters="' . htmlentities($content['test_message'], ENT_QUOTES, 'UTF-8') . '">' . "\n"; } $html_link = '<a href="resources/' . $content['content_path'] . $content['content_id'] . '.html" target="body">' . $content['title'] . '</a>'; /* save the content as HTML files */ /* @See: include/lib/format_content.inc.php */ $content['text'] = str_replace('CONTENT_DIR/', '', $content['text']); /* get all the glossary terms used */ $terms = find_terms($content['text']); if (is_array($terms)) { foreach ($terms[2] as $term) { $used_glossary_terms[] = $term; } } /** Test dependency **/ $test_dependency = ''; //Template for test $sql = "SELECT * FROM %scontent_tests_assoc WHERE content_id=%d"; $rows_assocs = queryDB($sql, array(TABLE_PREFIX, $content['content_id'])); foreach ($rows_assocs as $row) { //add test dependency ontop to forums dependency $test_dependency .= $prefix . $space . '<dependency identifierref="MANIFEST01_RESOURCE_QTI' . $row['test_id'] . '" />'; } /* calculate how deep this page is: */ $path = '../'; if ($content['content_path']) { $depth = substr_count($content['content_path'], '/'); $path .= str_repeat('../', $depth); } $content['text'] = format_content($content['text'], $content['formatting'], $glossary, $path); /* add HTML header and footers to the files */ /* use default style if <style> is not in imported html head */ $head = ''; if ($content['use_customized_head']) { if (strpos(strtolower($content['head']), '<style') > 0) { $head = $content['head']; } else { if (strlen($content['head']) > 0) { $head = $content['head'] . $default_html_style; } else { $head = $default_html_style; } } } $content['text'] = str_replace(array('{TITLE}', '{CONTENT}', '{KEYWORDS}', '{COURSE_PRIMARY_LANGUAGE_CHARSET}', '{COURSE_PRIMARY_LANGUAGE_CODE}', '{HEAD}'), array($content['title'], $content['text'], $content['keywords'], $course_language_charset, $course_language_code, $head), $html_content_template); /* duplicate the paths in the content_path field in the zip file */ if ($content['content_path']) { if (!in_array($content['content_path'], $paths)) { $zipfile->create_dir('resources/' . $content['content_path'], time()); $paths[] = $content['content_path']; } } $zipfile->add_file($content['text'], 'resources/' . $content['content_path'] . $content['content_id'] . '.html', $content['u_ts']); $content['title'] = htmlspecialchars($content['title']); /* add the resource dependancies */ if ($my_files == null) { $my_files = array(); } $content_files = "\n"; $parser->parse($content['text']); /* generate the IMS QTI resource and files */ global $contentManager; //check if test export is allowed. if ($contentManager->allowTestExport($content['content_id'])) { $content_test_rs = $contentManager->getContentTestsAssoc($content['content_id']); $test_ids = array(); //reset test ids //$my_files = array(); //reset myfiles. foreach ($content_test_rs as $content_test_row) { //export $test_ids[] = $content_test_row['test_id']; //the 'added_files' is for adding into the manifest file in this zip $added_files = test_qti_export($content_test_row['test_id'], '', $zipfile); //Save all the xml files in this array, and then print_organizations will add it to the manifest file. foreach ($added_files as $filename => $file_array) { $my_files[] = $filename; foreach ($file_array as $garbage => $filename2) { if (!in_array($filename2, $my_files)) { $my_files[] = $filename2; } } } //Save all the xml files in this array, and then print_organizations will add it to the manifest file. $resources .= str_replace(array('{TEST_ID}', '{PATH}', '{FILES}'), array($content_test_row['test_id'], 'tests_' . $content_test_row['test_id'] . '.xml', $added_files_xml), $ims_template_xml['resource_test']); } } /* generate the a4a files */ $a4a_xml_array = array(); //http://atutor.ca/atutor/mantis/view.php?id=4593 if ($content['formatting'] === 0) { $use_a4a = false; } if ($use_a4a == true) { $a4aExport = new A4aExport($content['content_id']); // $a4aExport->setRelativePath('resources/'.$content['content_path']); $secondary_files = $a4aExport->getAllSecondaryFiles(); $a4a_xml_array = $a4aExport->exportA4a(); $my_files = array_merge($my_files, $a4aExport->getAllSecondaryFiles()); } /* handle @import */ $import_files = get_import_files($content['text']); if (count($import_files) > 0) { $my_files = array_merge($my_files, $import_files); } foreach ($my_files as $file) { /* filter out full urls */ $url_parts = @parse_url($file); if (isset($url_parts['scheme'])) { continue; } /* file should be relative to content. let's double check */ if (substr($file, 0, 1) == '/') { continue; } $file_path = realpath(AT_CONTENT_DIR . $course_id . '/' . $content['content_path'] . $file); /* check if this file exists in the content dir, if not don't include it */ if (file_exists($file_path) && is_file($file_path) && !in_array($file_path, $zipped_files)) { $zipped_files[] = $file_path; $dir = substr(dirname($file_path), strlen(AT_CONTENT_DIR . $course_id)); if (!in_array($dir, $paths) && $dir) { $dir = str_replace('\\', '/', substr($dir, 1)); $zipfile->create_dir('resources/' . $dir, time()); $paths[] = $dir; } $file_info = stat($file_path); //Fixes relative paths, so folder1/folder2/../file.jpg will become just folder1/file.jpg $file_save_path = str_replace(AT_CONTENT_DIR . $course_id . DIRECTORY_SEPARATOR, '', $file_path); $file_save_path = str_replace('\\', '/', $file_save_path); //condition checks if the file has been added, so then the test won't be added to all the subchildren //leads to normal images not capable to be extracted. if ((empty($test_zipped_files) || is_array($test_zipped_files) && !in_array($file_path, $test_zipped_files)) && file_exists($file_path)) { $zipfile->add_file(@file_get_contents($file_path), 'resources/' . $file_save_path, $file_info['mtime']); // $test_zipped_files[] = $content['content_path'] . $file; $test_zipped_files[] = $file_path; } elseif (!is_array($test_zipped_files) && file_exists($file_path) && !in_array($file_path, $zipped_files)) { $zipfile->add_file(@file_get_contents($file_path), 'resources/' . $file_save_path, $file_info['mtime']); } //a4a secondary files have mapping, save the ones that we want in order to add the tag in $a4a_secondary_files = array(); foreach ($a4a_xml_array as $a4a_filename => $a4a_filearray) { if (preg_match('/(.*)\\sto\\s(.*)/', $a4a_filename, $matches)) { //save the actual file name $a4a_secondary_files[$matches[1]][] = $a4a_filename; //values are holders } } // If this file has a4a alternatives, link it. if (isset($a4a_xml_array[$file]) || isset($a4a_secondary_files[$file])) { //if this is an array, meaning that it has more than 1 alternatives, print all if (is_array($a4a_secondary_files[$file])) { $all_secondary_files_md = ''; //reinitialize string to null foreach ($a4a_secondary_files[$file] as $v) { foreach ($a4a_xml_array[$v] as $v2) { $all_secondary_files_md .= $v2; //all the meta data } } $content_files .= str_replace(array('{FILE}', '{FILE_META_DATA}'), array('resources/' . $file_save_path, $all_secondary_files_md), $ims_template_xml['file_meta']); } else { $content_files .= str_replace(array('{FILE}', '{FILE_META_DATA}'), array('resources/' . $file_save_path, $a4a_xml_array[$file]), $ims_template_xml['file_meta']); } } else { //if this file is in the test array, add an extra link to the direct file, if (!empty($test_zipped_files) && in_array($file_path, $test_zipped_files)) { $content_files .= str_replace('{FILE}', $file_save_path, $ims_template_xml['file']); } else { $content_files .= str_replace('{FILE}', $file_save_path, $ims_template_xml['file']); } } } /* check if this file is one of the test xml file, if so, we need to add the dependency * Note: The file has already been added to the archieve before this is called. */ /* taken out as of nov 17th, used dependency instead if (preg_match('/tests\_[0-9]+\.xml$/', $file) && !in_array($file, $test_zipped_files)){ $content_files .= str_replace('{FILE}', $file, $ims_template_xml['xml']); $test_zipped_files[] = $file; } */ } /******************************/ $resources .= str_replace(array('{CONTENT_ID}', '{PATH}', '{FILES}', '{DEPENDENCY}'), array($content['content_id'], $content['content_path'], $content_files, $test_dependency), $ims_template_xml['resource']); for ($i = 0; $i < $depth; $i++) { $link .= $space; } $title = $prefix . $space . '<title>' . $content['title'] . '</title>'; if (is_array($_menu[$content['content_id']])) { /* has children */ $html_link = '<li>' . $html_link . '<ul>'; for ($i = 0; $i < $depth; $i++) { if ($children[$i] == 1) { echo $space; //$html_link = $space.$html_link; } else { echo $space; //$html_link = $space.$html_link; } } } else { /* doesn't have children */ $html_link = '<li>' . $html_link . '</li>'; if ($counter == $num_items) { for ($i = 0; $i < $depth; $i++) { if ($children[$i] == 1) { echo $space; //$html_link = $space.$html_link; } else { echo $space; //$html_link = $space.$html_link; } } } else { for ($i = 0; $i < $depth; $i++) { echo $space; //$html_link = $space.$html_link; } } $title = $space . $title; } echo $prefix . $link; echo $title; echo "\n"; $string .= $html_link . "\n"; $depth++; print_organizations($content['content_id'], $_menu, $depth, $path . $counter . '.', $children, $string); $depth--; $counter++; for ($i = 0; $i < $depth; $i++) { echo $space; } echo $prefix . '</item>'; echo "\n"; } $string .= '</ul>'; if ($depth > 0) { $string .= '</li>'; } } }
} if (defined('AT_FORCE_GET_FILE') && AT_FORCE_GET_FILE) { $course_base_href = 'get.php/'; } else { $course_base_href = 'content/' . $_SESSION['course_id'] . '/'; } if ($content_row['content_path']) { $content_base_href .= $content_row['content_path'] . '/'; } require AT_INCLUDE_PATH . 'header.inc.php'; ?> <div class="row"> <?php echo '<h2>' . AT_print($stripslashes($_POST['title']), 'content.title') . '</h2>'; if ($_POST['formatting'] == CONTENT_TYPE_WEBLINK) { $url = $_POST['weblink_text']; $validated_url = isValidURL($url); if (!validated_url || $validated_url !== $url) { $msg->addError(array('INVALID_INPUT', _AT('weblink'))); $msg->printErrors(); } else { echo format_content($url, $_POST['formatting'], array()); } } else { echo format_content($stripslashes($_POST['body_text']), $_POST['formatting'], $_POST['glossary_defs']); } ?> </div> <?php require AT_INCLUDE_PATH . 'footer.inc.php';
function display($row, $response = '') { // print the generic question header $this->displayHeader($row['weight']); // print the question specific template $row['question'] = format_content($row['question'], 1, ''); $this->assignDisplayVariables($row, $response); $this->savant->display('test_questions/' . $this->sPrefix . '.tmpl.php'); // print the generic question footer $this->displayFooter(); }
FROM ".TABLE_PREFIX."news N, ".TABLE_PREFIX."members M WHERE N.course_id=$course_id AND N.member_id = M.member_id ORDER BY date DESC LIMIT $offset, $results_per_page"; $result = mysql_query($sql, $db); while ($row = mysql_fetch_assoc($result)) { /* this can't be cached because it called _AT */ $news[$row['news_id']] = array( 'date' => AT_date( _AT('announcement_date_format'), $row['date'], AT_DATE_MYSQL_DATETIME), 'author' => $row['first_name'] . ' ' . $row['last_name'], 'title' => AT_print($row['title'], 'news.title'), 'body' => format_content($row['body'], $row['formatting'], $glossary)); } } $sql = "SELECT banner FROM ".TABLE_PREFIX."courses WHERE course_id=$course_id"; $result = mysql_query($sql, $db); if ($row = mysql_fetch_assoc($result)) { $savant->assign('banner', AT_print($row['banner'], 'courses.banner')); } else { $savant->assign('banner', ''); } $savant->assign('view_mode', $home_view); $savant->assign('announcements', $news); $savant->assign('num_pages', $num_pages);
// LastModifed:2007-08-20 // copyright (c)2007 millken@gmail.com //==================================================== session_start(); if (!$_SESSION['webmaster']) { header("location:login.php"); } require_once '../common.php'; include '../include/xajax.inc.php'; if ($action == 'save') { $a_sort = $_POST['level1']; $a_ztid = $_POST['level2'] ? $_POST['level2'] : 'NULL'; $aid = $_POST['level3'] ? $_POST['level3'] : 'NULL'; $title = format_content($_POST['name']); $suggest = $_POST['suggest']; $content = format_content($_POST['content']); $file = $_FILES['uploadpic']; $author = $_SESSION['adminname']; /* if(empty($name) || empty($p_xilie)){ refer('文章名称和文章系列不能为空!'); }elseif((!preg_match("/[0-9]{,4}/i",$price) && !empty($price)) || (!preg_match("/[0-9]{,4}/i",$p_num) && !empty($p_num))){ refer('文章价格和数量只能是数值,请重新填写!'); }*/ // print_r($file); //Array ( [name] => a002d.gif [type] => image/gif [tmp_name] => d:/webserver/Server/TEMP\php8E.tmp [error] => 0 [size] => 19675 ) if (!empty($file['name'])) { $uf = new FileUploader($_FILE['uploadpic']); $pic = $uf->move(ROOT_PATH . 'article_upimg', 2); $uppic = $pic[0] ? get_basename($pic[0]) : 'NULL'; $img = new image(ROOT_PATH . 'article_upimg/' . $uppic);
public function edit($topic_id) { //加载form类,为调用错误函数,需view前加载 $this->load->helper('form'); $data['title'] = '编辑话题'; $data['item'] = $this->topic_m->get_topic_by_topic_id($topic_id); //权限修改判断 if (!$this->auth->is_login()) { show_message('请登录后再编辑', site_url('user/login')); } if ($this->auth->is_user($data['item']['uid']) || $this->auth->is_admin() || $this->auth->is_master($data['item']['node_id'])) { //对内容进行br转换 $this->load->helper('br2nl'); $data['item']['content'] = br2nl($data['item']['content']); //反转义 $data['item']['content'] = stripslashes($data['item']['content']); //反format $data['item']['content'] = decode_format($data['item']['content']); //获取所有分类 $data['cates'] = $this->cate_m->get_all_cates(); //获取当前分类(包括已选择) $node_id = $this->input->post('node_id') ? $this->input->post('node_id') : $data['item']['node_id']; $data['cate'] = $this->db->get_where('nodes', array('node_id' => $node_id))->row_array(); //标题编辑(包括已输入) $data['item']['title'] = $this->input->post('title') ? $this->input->post('title') : $data['item']['title']; //内容编辑(包括已输入) $data['item']['content'] = $this->input->post('content') ? $this->input->post('content') : $data['item']['content']; if ($this->form_validation->run('topic/add') === TRUE) { $str = array('title' => $this->input->post('title'), 'content' => $this->input->post('content'), 'node_id' => $this->input->post('node_id'), 'updatetime' => time()); $this->load->helper('format_content'); $str['content'] = format_content($str['content']); if ($this->topic_m->update_topic($topic_id, $str)) { show_message('修改成功', site_url('topic/show/' . $topic_id), 1); } } //开启storage config $this->load->config('qiniu'); $data['csrf_name'] = $this->security->get_csrf_token_name(); $data['csrf_token'] = $this->security->get_csrf_hash(); $this->load->view('topic_edit', $data); } else { show_message('你无权修改此贴子'); } }
function table_for(moojon_model_collection $models, $column_names = array(), $attributes = array(), $no_records_message = null, $count = null) { $no_records_message = $no_records_message ? $no_records_message : moojon_config::get('no_records_message'); if ($models->count) { $attributes = try_set_attribute($attributes, 'cellpadding', '0'); $attributes = try_set_attribute($attributes, 'cellspacing', '0'); $model = $models->first; $model_class = get_class($model); $ths = array(th_tag(title_text($model->get_to_string_column()))); $column_names = $column_names ? $column_names : $model->get_ui_column_names(); foreach ($column_names as $column_name) { if ($model->to_string_column != $column_name) { $ths[] = th_tag(title_text($column_name)); } } $ths[] = th_tag('Edit'); $ths[] = th_tag('Delete'); $trs = array(); $primary_key = moojon_primary_key::NAME; $counter = 0; foreach ($models as $model) { $counter++; $tds = array(td_tag(member_tag($model))); foreach ($column_names as $column_name) { if ($model->to_string_column != $column_name) { if (method_exists($model, "get_{$column_name}") || method_exists($model, $column_name)) { $content = $model->{$column_name}; if (is_object($content) && is_subclass_of($content, 'moojon_base_column')) { $column = $content; $content = $column->get_value(); } else { $column = new moojon_string_column($column_name); $column->set_value($content); } } else { $column = $model->get_column($column_name); if ($relationship = find_has_one_relationship($model, $column_name)) { $name = $relationship->get_name(); $content = member_tag($model->{$name}); } else { if ($relationship = find_belongs_to_relationship($model, $column_name)) { $name = $relationship->get_name(); $content = member_tag($model->{$name}); } else { $content = $model->{$column_name}; } } } $tds[] = td_tag(format_content($model, $column, $content)); } } $tds[] = td_tag(edit_member_tag($model)); $tds[] = td_tag(delete_member_tag($model)); $trs[] = tr_tag($tds, array('class' => 'row' . $counter % 2)); } $children = array(thead_tag(tr_tag($ths)), tbody_tag($trs)); if ($count) { $ul = paginator_ul($count); $children[] = tfoot_tag(tr_tag(td_tag($ul, array('colspan' => count($column_names) + 2)))); } $child = table_tag($children, $attributes); } else { $child = p_tag($no_records_message); } return div_tag($child); }
$news = array(); } else { $sql = "SELECT COUNT(*) AS cnt FROM " . TABLE_PREFIX . "news WHERE course_id={$course_id}"; $result = mysql_query($sql, $db); } if ($result && ($row = mysql_fetch_assoc($result))) { $num_results = $row['cnt']; $results_per_page = NUM_ANNOUNCEMENTS; $num_pages = ceil($num_results / $results_per_page); $count = ($page - 1) * $results_per_page + 1; $offset = ($page - 1) * $results_per_page; $sql = "SELECT N.*, DATE_FORMAT(N.date, '%Y-%m-%d %H:%i:%s') AS date, first_name, last_name \n\t FROM " . TABLE_PREFIX . "news N, " . TABLE_PREFIX . "members M \n\t WHERE N.course_id={$course_id} \n\t AND N.member_id = M.member_id\n\t ORDER BY date DESC LIMIT {$offset}, {$results_per_page}"; $result = mysql_query($sql, $db); while ($row = mysql_fetch_assoc($result)) { /* this can't be cached because it called _AT */ $news[$row['news_id']] = array('date' => AT_date(_AT('announcement_date_format'), $row['date'], AT_DATE_MYSQL_DATETIME), 'author' => $row['first_name'] . ' ' . $row['last_name'], 'title' => AT_print($row['title'], 'news.title'), 'body' => format_content($row['body'], $row['formatting'], $glossary)); } } $sql = "SELECT banner FROM " . TABLE_PREFIX . "courses WHERE course_id={$course_id}"; $result = mysql_query($sql, $db); if ($row = mysql_fetch_assoc($result)) { $savant->assign('banner', AT_print($row['banner'], 'courses.banner')); } else { $savant->assign('banner', ''); } $savant->assign('view_mode', $home_view); $savant->assign('announcements', $news); $savant->assign('num_pages', $num_pages); $savant->assign('current_page', $page); $savant->display('index.tmpl.php'); require AT_INCLUDE_PATH . 'footer.inc.php';
function print_organizations($parent_id, &$_menu, $depth, $path = '', $children, &$string) { global $html_content_template, $default_html_style, $zipfile, $resources, $ims_template_xml, $parser, $my_files; global $used_glossary_terms, $course_id, $course_language_charset, $course_language_code; static $paths, $zipped_files; global $glossary; global $test_list, $test_zipped_files, $test_files, $test_xml_items, $use_a4a; /* added by bologna*/ //TODO***********BOLOGNA**************REMOVE ME*****************/ global $db, $forum_list; //forum_list contiene tutti i forum distinti associati ai contenuti. poich� la funzione in questione � ricorsiva deve essere globale in modo che in fase di creazione dell'archivio zip i file descrittori dei forum non vengano ripetuti $space = ' '; $prefix = ' '; if ($depth == 0) { $string .= '<ul>'; } $top_level = $_menu[$parent_id]; if (!is_array($paths)) { $paths = array(); } if (!is_array($zipped_files)) { $zipped_files = array(); } if (is_array($top_level)) { $counter = 1; $num_items = count($top_level); foreach ($top_level as $garbage => $content) { $link = ''; //XSL characters handling $content['title'] = str_replace('&', '&', $content['title']); if ($content['content_path'] && substr($content['content_path'], -1) != '/') { $content['content_path'] .= '/'; } /* * generate weblinks * Reason to put it here is cause we don't want the content to be overwrittened. */ if ($content['content_type'] == CONTENT_TYPE_WEBLINK) { $wl = new Weblinks($content['title'], $content['text']); $wlexport = new WeblinksExport($wl); $wl_xml = $wlexport->export(); $wl_filename = 'weblinks_' . $content['content_id'] . '.xml'; $zipfile->add_file($wl_xml, 'Weblinks/' . $wl_filename, $content['u_ts']); $resources .= str_replace(array('{PATH}', '{CONTENT_ID}'), array($wl_filename, $content['content_id']), $ims_template_xml['resource_weblink']); //Done. // continue; } if ($content['content_type'] == CONTENT_TYPE_FOLDER) { $link .= $prefix . '<item identifier="MANIFEST01_FOLDER' . $content['content_id'] . '">' . "\n"; $link .= $prefix . $space . '<title>' . $content['title'] . '</title>' . "\n"; } else { $link .= '<item identifier="MANIFEST01_ITEM' . $content['content_id'] . '" identifierref="MANIFEST01_RESOURCE' . $content['content_id'] . '">' . "\n"; $link .= $prefix . $space . '<title>' . $content['title'] . '</title>' . "\n{$prefix}{$space}"; } $html_link = '<a href="resources/' . $content['content_path'] . $content['content_id'] . '.html" target="body">' . $content['title'] . '</a>'; /* save the content as HTML files */ /* @See: include/lib/format_content.inc.php */ $content['text'] = str_replace('CONTENT_DIR/', '', $content['text']); /* get all the glossary terms used */ $terms = find_terms($content['text']); if (is_array($terms)) { foreach ($terms[2] as $term) { $used_glossary_terms[] = $term; } } //TODO**************BOLOGNA****************REMOVE ME************/ $f_count = count($forum_list); //count all distinct forum_id associated to a content page //la funzione è ricorsiva quindi lo devo ricavare attraverso la variabile globale forum_list /* TODO *************BOLOGNA*************REMOVE ME*********/ //recupero i forum associati al contenuto corrente $sql = "SELECT cf.forum_id, f.title, f.description FROM (SELECT * FROM " . TABLE_PREFIX . "content_forums_assoc WHERE content_id={$content['content_id']}) AS cf LEFT JOIN " . TABLE_PREFIX . "forums f ON cf.forum_id=f.forum_id"; $result_cf = mysql_query($sql, $db); $cf_count = mysql_num_rows($result_cf); //per ogni forum ottenuto controllo se è già stato caricato nell'array //necessario mantenerlo distinto poichè NON si prevedono funzioni sul //controllo dei nomi nell'inserimento di file nell'archivio. $find = false; $forums_dependency = ''; //template for associate Discussion Topic to the current content into the manifest while ($current_forum = mysql_fetch_assoc($result_cf)) { for ($j = 0; $j < $f_count; $j++) { if ($forum_list[$j]['id'] == $current_forum['forum_id']) { $find = true; } } if (!$find) { $forum_list[$f_count]['id'] = $current_forum['forum_id']; $forum_list[$f_count]['title'] = $current_forum['title']; $forum_list[$f_count]['description'] = $current_forum['description']; $find = false; $f_count++; } $forums_dependency .= $prefix . $space . '<dependency identifierref="Forum' . $current_forum['forum_id'] . '_R" />'; } /** Test dependency **/ $sql = 'SELECT * FROM ' . TABLE_PREFIX . 'content_tests_assoc WHERE content_id=' . $content['content_id']; $result = mysql_query($sql, $db); while ($row = mysql_fetch_assoc($result)) { //add test dependency on top of forum dependency $forums_dependency .= $prefix . $space . '<dependency identifierref="MANIFEST01_RESOURCE_QTI' . $row['test_id'] . '" />'; } /* calculate how deep this page is: */ $path = '../'; if ($content['content_path']) { $depth = substr_count($content['content_path'], '/'); $path .= str_repeat('../', $depth); } $content['text'] = format_content($content['text'], $content['formatting'], $glossary, $path); /* add HTML header and footers to the files */ /* use default style if <style> is not in imported html head */ $head = ''; if ($content['use_customized_head']) { if (strpos(strtolower($content['head']), '<style') > 0) { $head = $content['head']; } else { if (strlen($content['head']) > 0) { $head = $content['head'] . $default_html_style; } else { $head = $default_html_style; } } } $content['text'] = str_replace(array('{TITLE}', '{CONTENT}', '{KEYWORDS}', '{COURSE_PRIMARY_LANGUAGE_CHARSET}', '{COURSE_PRIMARY_LANGUAGE_CODE}', '{HEAD}'), array($content['title'], $content['text'], $content['keywords'], $course_language_charset, $course_language_code, $head), $html_content_template); /* duplicate the paths in the content_path field in the zip file */ if ($content['content_path']) { if (!in_array($content['content_path'], $paths)) { $zipfile->create_dir('resources/' . $content['content_path'], time()); $paths[] = $content['content_path']; } } //add the file iff it's a content file if ($content['content_type'] == CONTENT_TYPE_CONTENT) { $zipfile->add_file($content['text'], 'resources/' . $content['content_path'] . $content['content_id'] . '.html', $content['u_ts']); } $content['title'] = htmlspecialchars($content['title']); /* add the resource dependancies */ if ($my_files == null) { $my_files = array(); } $content_files = "\n"; $parser->parse($content['text']); /* generate the IMS QTI resource and files */ global $contentManager; //check if test export is allowed. if ($contentManager->allowTestExport($content['content_id'])) { $content_test_rs = $contentManager->getContentTestsAssoc($content['content_id']); $test_ids = array(); //reset test ids //$my_files = array(); //reset myfiles. while ($content_test_row = mysql_fetch_assoc($content_test_rs)) { //export $test_ids[] = $content_test_row['test_id']; //the 'added_files' is for adding into the manifest file in this zip $added_files = test_qti_export($content_test_row['test_id'], '', $zipfile); foreach ($added_files as $xml_file => $chunk) { foreach ($chunk as $xml_filename) { $added_files_xml .= str_replace('{FILE}', 'resources/' . $xml_filename, $ims_template_xml['xml']); } } //Save all the xml files in this array, and then print_organizations will add it to the manifest file. $resources .= str_replace(array('{TEST_ID}', '{PATH}', '{FILES}'), array($content_test_row['test_id'], 'tests_' . $content_test_row['test_id'] . '.xml', $added_files_xml), $ims_template_xml['resource_test']); /* Taken out since we are gonna use dependency instead $test_xml_items .= str_replace( array('{TEST_ID}'), array($content_test_row['test_id']), $ims_template_xml['test']); */ foreach ($test_files as $filename => $realfilepath) { $zipfile->add_file(@file_get_contents($realfilepath), 'resources/' . $filename, filemtime($realfilepath)); } } } /* generate the a4a files */ $a4a_xml_array = array(); //don't export a4a if this is in plain text, plain text has no media //http://atutor.ca/atutor/mantis/view.php?id=4593 if ($content['formatting'] === 0) { $use_a4a = false; } if ($use_a4a == true) { $a4aExport = new A4aExport($content['content_id']); // $a4aExport->setRelativePath('resources/'.$content['content_path']); $secondary_files = $a4aExport->getAllSecondaryFiles(); $a4a_xml_array = $a4aExport->exportA4a(); $my_files = array_merge($my_files, $a4aExport->getAllSecondaryFiles()); } /* handle @import */ $import_files = get_import_files($content['text']); if (count($import_files) > 0) { $my_files = array_merge($my_files, $import_files); } foreach ($my_files as $file) { /* filter out full urls */ $url_parts = @parse_url($file); // if (isset($url_parts['scheme'])) { // continue; // } /* file should be relative to content. let's double check */ if (substr($file, 0, 1) == '/') { continue; } if (substr($file, 0, 7) != 'http://' && substr($file, 0, 8) != 'https://') { $file_path = realpath(AT_CONTENT_DIR . $course_id . '/' . $content['content_path'] . $file); /* check if the path contains AT_CONTENT_DIR in it, if not, skip it, it's trying to scan through * the file system */ if (strpos($file_path, AT_CONTENT_DIR) !== 0) { continue; //skip } /* check if this file exists in the content dir, if not don't include it */ if (file_exists($file_path) && is_file($file_path) && !in_array($file_path, $zipped_files)) { $zipped_files[] = $file_path; $dir = substr(dirname($file_path), strlen(AT_CONTENT_DIR . $course_id)); if (!in_array($dir, $paths) && $dir) { $dir = str_replace('\\', '/', substr($dir, 1)); $zipfile->create_dir('resources/' . $dir, time()); $paths[] = $dir; } $file_info = stat($file_path); //remove relative path in the content_path. $filepath_array = explode('/', 'resources/' . $content['content_path'] . $file); $new_filepath_array = array(); if (in_array('..', $filepath_array)) { while (!empty($filepath_array)) { $temp = array_shift($filepath_array); if ($temp == '..') { array_pop($new_filepath_array); } else { array_push($new_filepath_array, $temp); } } $zip_path = implode('/', $new_filepath_array); } else { $zip_path = 'resources/' . $content['content_path'] . $file; } $zipfile->add_file(@file_get_contents($file_path), $zip_path, $file_info['mtime']); } } //a4a secondary files have mapping, save the ones that we want in order to add the tag in $a4a_secondary_files = array(); foreach ($a4a_xml_array as $a4a_filename => $a4a_filearray) { if (preg_match('/(.*)\\sto\\s(.*)/', $a4a_filename, $matches)) { //save the actual file name $a4a_secondary_files[$matches[1]][] = $a4a_filename; //values are holders } } /** * A hack to fix youtube links. one uses youtube.com?watch=xxx, the other uses youtube.com/v/xxx, * in which both points to the same file, but needed different links to play. * in A4a, these youtube links are always stored as "?watch=xxx", however, output.inc.php converted * these to /v/xxx for rendering purposes. Convert it back if youtube exists in url. * http://atutor.ca/atutor/mantis/view.php?id=4548 * @harris 9/30/2010 */ if (strpos($file, 'youtube.com') !== false) { //apply the conversion before linking the alternatives. Otherwise it will not be added. $file = convert_youtube_playURL_to_watchURL($file); } // If this file has a4a alternatives, link it. if (isset($a4a_xml_array[$file]) || isset($a4a_secondary_files[$file])) { //if this is an array, meaning that it has more than 1 alternatives, print all if (substr($file, 0, 7) == 'http://' || substr($file, 0, 8) == 'https://') { $name_in_file_meta = $file; } else { $name_in_file_meta = 'resources/' . $content['content_path'] . $file; } if (is_array($a4a_secondary_files[$file])) { $all_secondary_files_md = ''; //reinitialize string to null foreach ($a4a_secondary_files[$file] as $v) { foreach ($a4a_xml_array[$v] as $v2) { $all_secondary_files_md .= $v2; //all the meta data } } $content_files .= str_replace(array('{FILE}', '{FILE_META_DATA}'), array($name_in_file_meta, $all_secondary_files_md), $ims_template_xml['file_meta']); } else { $content_files .= str_replace(array('{FILE}', '{FILE_META_DATA}'), array($name_in_file_meta, $a4a_xml_array[$file]), $ims_template_xml['file_meta']); } } else { //if this file is in the test array, add an extra link to the direct file, if (!empty($test_zipped_files) && in_array($file_path, $test_zipped_files)) { $content_files .= str_replace('{FILE}', $file, $ims_template_xml['file']); } else { if (preg_match('/^http[s]?\\:/', $file) == 1) { if ($use_a4a) { $content_files .= str_replace('{FILE}', $file, $ims_template_xml['xml']); } } elseif (file_exists($file_path) && is_file($file_path)) { //http://www.atutor.ca/atutor/mantis/view.php?id=4313 //relative link that goes beyond get.php shouldn't be added //relative link that does not exist shouldn't be added. $filepath_array = explode('/', $content['content_path'] . $file); $new_filepath_array = array(); if (in_array('..', $filepath_array)) { while (!empty($filepath_array)) { $temp = array_shift($filepath_array); if ($temp == '..') { array_pop($new_filepath_array); } else { array_push($new_filepath_array, $temp); } } $file = implode('/', $new_filepath_array); } else { $file = $content['content_path'] . $file; } $content_files .= str_replace('{FILE}', $file, $ims_template_xml['file']); } } } /* check if this file is one of the test xml file, if so, we need to add the dependency * Note: The file has already been added to the archieve before this is called. */ if (preg_match('/tests\\_[0-9]+\\.xml$/', $file) && !in_array($file, $test_zipped_files)) { $content_files .= str_replace('{FILE}', 'QTI/' . $file, $ims_template_xml['xml']); $test_zipped_files[] = $file; } } /****************************** * http://www.atutor.ca/atutor/mantis/view.php?id=4383 */ $my_files = array(); /******************************/ //add it to the resources section if it hasn't been added. //Weblinks have been added. //Folders aren't resourecs, they shouldn't be added if ($content['content_type'] == CONTENT_TYPE_CONTENT) { $resources .= str_replace(array('{CONTENT_ID}', '{PATH}', '{FILES}', '{DEPENDENCY}'), array($content['content_id'], $content['content_path'], $content_files, $forums_dependency), $ims_template_xml['resource']); } for ($i = 0; $i < $depth; $i++) { $link .= $space; } if (is_array($_menu[$content['content_id']])) { /* has children */ $html_link = '<li>' . $html_link . '<ul>'; for ($i = 0; $i < $depth; $i++) { if ($children[$i] == 1) { echo $space; //$html_link = $space.$html_link; } else { echo $space; //$html_link = $space.$html_link; } } } else { /* doesn't have children */ $html_link = '<li>' . $html_link . '</li>'; if ($counter == $num_items) { for ($i = 0; $i < $depth; $i++) { if ($children[$i] == 1) { echo $space; //$html_link = $space.$html_link; } else { echo $space; //$html_link = $space.$html_link; } } } else { for ($i = 0; $i < $depth; $i++) { echo $space; //$html_link = $space.$html_link; } } $title = $space . $title; } echo $prefix . $link; // echo $title; echo "\n"; $string .= $html_link . "\n"; $depth++; print_organizations($content['content_id'], $_menu, $depth, $path . $counter . '.', $children, $string); $depth--; $counter++; for ($i = 0; $i < $depth; $i++) { echo $space; } //debug($_menu, $content['content_id']); // if (!empty($_menu[$content['content_id']])){ echo $prefix . '</item>'; // } echo "\n"; } $string .= '</ul>'; if ($depth > 0) { $string .= '</li>'; } } }