Example #1
0
 public function export()
 {
     $postsList = $this->loadTopic($this->getTopicId());
     $topicInfo = get_topic_settings($this->getTopicId());
     $this->createPDF($topicInfo['topic_title']);
     $this->pdf->AddPage();
     $htmlContent = '<p>' . "\n" . '<table cellspacing="0" cellpadding="2" border="1">' . "\n" . '<tbody>' . "\n" . '<tr>' . "\n" . '<th colspan="2" style="font-weight: bold; background-color: #EDF1E3; color: #669933; border-bottom: 1px solid #96BB7A;">' . claro_utf8_encode($topicInfo['topic_title']) . '</th>' . '</tr>' . "\n";
     foreach ($postsList as $post) {
         $htmlContent .= '<tr>' . "\n" . '<td style="width: 150px; background-color: #EEEEEE;">' . "\n" . '<div style="font-weight: bold;">' . claro_utf8_encode($post['firstname'] . ' ' . $post['lastname'], get_conf('charset')) . '</div>' . "\n" . '<small>' . claro_html_localised_date(get_locale('dateTimeFormatLong'), datetime_to_timestamp($post['post_time'])) . '</small>' . "\n" . '</td>' . "\n" . '<td style="width: 354px;">' . claro_utf8_encode(claro_parse_user_text(strip_tags($post['post_text'])), get_conf('charset')) . '</td>' . "\n" . '</tr>' . "\n";
     }
     $htmlContent .= '</tbody>' . "\n" . '</table>' . "\n" . '</p>';
     //exit( claro_utf8_decode($htmlContent) );
     $this->pdf->writeHTML($htmlContent, true, 0, true, 0);
     switch ($this->output) {
         case 'screen':
             $this->pdf->Output(claro_utf8_encode($topicInfo['topic_id'] . '_' . $topicInfo['topic_title'] . '.pdf'), 'D');
             break;
         default:
             $path = get_conf('rootSys') . get_conf('tmpPathSys') . '/forum_export/';
             claro_mkdir($path);
             $this->pdf->Output($path . claro_utf8_encode(replace_dangerous_char($topicInfo['topic_id'] . '_' . $topicInfo['topic_title']) . '.pdf'), 'F');
             break;
     }
     return true;
 }
Example #2
0
/**
 * CLAROLINE
 *
 * MyCalendar portlet ajax backend
 *
 * @version     $Revision: 14315 $
 * @copyright   (c) 2001-2011, Universite catholique de Louvain (UCL)
 * @license     http://www.gnu.org/copyleft/gpl.html (GPL) GENERAL PUBLIC LICENSE
 * @package     DESKTOP
 * @author      Claroline team <*****@*****.**>
 * @since       1.9
 */
if (isset($_REQUEST['location'])) {
    // Call the right class according to the location
    if ($_REQUEST['location'] == 'coursehomepage') {
        require_once dirname(__FILE__) . '/../../claroline/inc/claro_init_global.inc.php';
        require_once dirname(__FILE__) . '/lib/coursehomepagecalendar.lib.php';
        $cal = new CourseHomePageCalendar(claro_htmlentities($_REQUEST['courseCode']));
    } elseif ($_REQUEST['location'] == 'userdesktop') {
        require_once dirname(__FILE__) . '/../../claroline/inc/claro_init_global.inc.php';
        require_once dirname(__FILE__) . '/lib/desktopcalendar.lib.php';
        $cal = new UserDesktopCalendar();
    }
    if (isset($_REQUEST['year'])) {
        $cal->setYear((int) $_REQUEST['year']);
    }
    if (isset($_REQUEST['month'])) {
        $cal->setMonth((int) $_REQUEST['month']);
    }
    echo claro_utf8_encode($cal->render(), get_conf('charset'));
}
Example #3
0
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// Date in the past
if ($cmd == 'getFileList') {
    $it = new DirectoryIterator($pathSys . $relPath);
    /*
     * Output
     */
    $out = "\n" . '<ul id="files">' . "\n";
    if (!empty($relPath)) {
        $parentPath = dirname($relPath);
        $out .= '<li>' . "\n" . '<a href="#" onclick="setFileList(\'' . $parentPath . '\')">' . '<img src="' . get_icon_url('parent') . '" />' . '..' . '</a>' . '</li>' . "\n";
    }
    // directories
    foreach ($it as $file) {
        if ($file->isDir() && !$file->isDot()) {
            // get relative path from allowed root (document/img or platform/document) to target
            $relativePath = str_replace(realpath($pathSys), '', realpath($file->getPathname()));
            $out .= '<li>' . "\n" . '<a href="#" class="selectFolder" onclick="setFileList(\'' . str_replace('\\', '/', $relativePath) . '\')">' . '<img src="' . get_icon_url('folder') . '" />' . claro_htmlspecialchars($file->getFileName()) . '</a>' . '</li>' . "\n";
        }
    }
    // then the files
    foreach ($it as $file) {
        if ($file->isFile() && is_image($file->getFileName())) {
            $path = '/' . $relPath . $file->getFileName();
            $url = claro_get_file_download_url($path);
            $out .= '<li>' . "\n" . '<a href="#" onclick="selectImage(\'' . $url . '\')">' . '<img src="' . get_icon_url(choose_image($file->getFileName())) . '" />' . claro_htmlspecialchars($file->getFileName()) . '</a>' . '</li>' . "\n";
        }
    }
    $out .= '</ul>' . "\n";
    echo claro_utf8_encode($out);
}
Example #4
0
function claro_utf8_encode_array(&$var)
{
    if (!is_array($var)) {
        $var = claro_utf8_encode($var);
    } else {
        array_walk($var, 'claro_utf8_encode_array');
    }
}
Example #5
0
 /**
  * Export the question as an IMS/QTI Item.
  *
  * This is a default behaviour, some classes may want to override this.
  *
  * @param $standalone: Boolean stating if it should be exported as a stand-alone question
  * @return A string, the XML flow for an Item.
  */
 function export($standalone = False)
 {
     $head = $foot = "";
     if ($standalone) {
         $head = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . "\n";
     }
     $out = $head . $this->start_item() . $this->answer->qti2ExportResponsesDeclaration($this->questionIdent) . $this->start_item_body() . $this->object_attached_file() . $this->answer->qti2ExportResponses($this->questionIdent, $this->question->description) . $this->end_item_body() . $this->add_response_processing() . $this->end_item() . $foot;
     return claro_utf8_encode($out);
 }
Example #6
0
/**
 * replaces some dangerous character in a file name
 * This function is broken !
 *
 * @param   string $string
 * @param   string $strict (optional) removes also scores and simple quotes
 * @since   Claroline 1.11.0-beta1 $strict is ignored !
 * @return  string : the string cleaned of dangerous character
 * @todo    function broken !
 */
function replace_dangerous_char($string, $strict = 'loose')
{
    // workaround for mac os x
    $string = preg_replace('/&#\\d+;/', '_', $string);
    $search[] = ' ';
    $replace[] = '_';
    $search[] = '/';
    $replace[] = '-';
    $search[] = '\\';
    $replace[] = '-';
    $search[] = '"';
    $replace[] = '-';
    $search[] = '\'';
    $replace[] = '_';
    $search[] = '?';
    $replace[] = '-';
    $search[] = '*';
    $replace[] = '-';
    $search[] = '>';
    $replace[] = '';
    $search[] = '<';
    $replace[] = '-';
    $search[] = '|';
    $replace[] = '-';
    $search[] = ':';
    $replace[] = '-';
    $search[] = '$';
    $replace[] = '-';
    $search[] = '(';
    $replace[] = '-';
    $search[] = ')';
    $replace[] = '-';
    $search[] = '^';
    $replace[] = '-';
    $search[] = '[';
    $replace[] = '-';
    $search[] = ']';
    $replace[] = '-';
    $search[] = '°';
    $replace[] = '';
    foreach ($search as $key => $char) {
        $string = str_replace($char, $replace[$key], $string);
    }
    $string = preg_replace('~&([a-z]{1,2})(acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i', '$1', claro_htmlentities(claro_utf8_encode($string), ENT_QUOTES, 'UTF-8'));
    $string = str_replace("'", '', $string);
    return $string;
}
Example #7
0
if ($cmd == 'rqFlush' && $is_allowedToEdit) {
    $msgList = new ChatMsgList($courseId, $groupId);
    if ($msgList->flush()) {
        $dialogBox = new DialogBox();
        $dialogBox->success(get_lang('Chat reset'));
        echo claro_utf8_encode($dialogBox->render());
    }
    return;
}
if ($cmd == 'rqLogs' && $is_allowedToEdit) {
    $msgList = new ChatMsgList($courseId, $groupId);
    $msgList->load(1, $_SESSION['chat_connectionTime']);
    echo claro_utf8_encode($msgList->render());
    return;
}
if ($cmd == 'rqArchive' && $is_allowedToEdit) {
    $msgList = new ChatMsgList($courseId, $groupId);
    $msgList->load();
    if ($chatFilename = $msgList->archive()) {
        $downloadLink = '<a href="' . get_module_url('CLDOC') . '/document.php' . claro_url_relay_context('?') . '">' . basename($chatFilename) . '</a>';
        $dialogBox = new DialogBox();
        $dialogBox->success(get_lang('%chat_filename is now in the document tool. (<em>This file is visible</em>)', array('%chat_filename' => $downloadLink)));
        echo claro_utf8_encode($dialogBox->render());
        return;
    } else {
        $dialogBox = new DialogBox();
        $dialogBox->error(get_lang('Store failed'));
        echo claro_utf8_encode($dialogBox->render());
        return;
    }
}
Example #8
0
function build_rss($context)
{
    if (is_array($context) && count($context) > 0) {
        $rss = new UniversalFeedCreator();
        if (array_key_exists(CLARO_CONTEXT_COURSE, $context)) {
            // $rssFilePath .= $context[CLARO_CONTEXT_COURSE] . '.';
            $_course = claro_get_course_data($context[CLARO_CONTEXT_COURSE]);
            $rss->title = '[' . get_conf('siteName') . '] ' . $_course['officialCode'];
            $rss->description = $_course['name'];
            $rss->editor = $_course['titular'] == '' ? get_conf('administrator_name') : $_course['titular'];
            $rss->editorEmail = $_course['email'] == '' ? get_conf('administrator_email') : $_course['email'];
            $rss->link = get_path('rootWeb') . get_path('coursesRepositoryAppend') . claro_get_course_path();
            $rss->generator = 'Feedcreator';
            if (array_key_exists(CLARO_CONTEXT_GROUP, $context)) {
                // $rssFilePath .= 'g'.$context[CLARO_CONTEXT_GROUP] . '.';
                $rss->title .= '[' . get_lang('Group') . $context[CLARO_CONTEXT_GROUP] . ']';
                $rss->description .= get_lang('Group') . $context[CLARO_CONTEXT_GROUP];
            }
        } else {
            $rss->title = '[' . get_conf('siteName') . '] ' . $_course['officialCode'];
            $rss->description = $_course['name'];
            $rss->editor = get_conf('administrator_name');
            $rss->editorEmail = get_conf('administrator_email');
            $rss->link = get_path('rootWeb');
        }
        $rss->language = get_locale('iso639_1_code');
        $rss->docs = 'http://blogs.law.harvard.edu/tech/rss';
        $rss->pubDate = date("r", time());
        $toolLabelList = rss_get_tool_compatible_list();
        //var_dump($toolLabelList);
        $rssItems = array();
        foreach ($toolLabelList as $toolLabel) {
            /*var_dump(is_tool_activated_in_course(
                  get_tool_id_from_module_label( $toolLabel ),
                  $context[CLARO_CONTEXT_COURSE]
              ));*/
            if (is_tool_activated_in_course(get_tool_id_from_module_label($toolLabel), $context[CLARO_CONTEXT_COURSE])) {
                if (!is_module_installed_in_course($toolLabel, $context[CLARO_CONTEXT_COURSE])) {
                    install_module_in_course($toolLabel, $context[CLARO_CONTEXT_COURSE]);
                }
                $rssToolLibPath = get_module_path($toolLabel) . '/connector/rss.write.cnr.php';
                $rssToolFuncName = $toolLabel . '_write_rss';
                if (file_exists($rssToolLibPath)) {
                    include_once $rssToolLibPath;
                    if (function_exists($rssToolFuncName)) {
                        $rssItems = array_merge($rssItems, call_user_func($rssToolFuncName, $context));
                    }
                }
            }
        }
        $sortDate = array();
        foreach ($rssItems as $key => $rssItem) {
            $sortDate[$key] = $rssItem['pubDate'];
        }
        // die(var_export($sortDate, true));
        array_multisort($sortDate, SORT_DESC, $rssItems);
        foreach ($rssItems as $rssItem) {
            $item = new FeedItem();
            $item->title = claro_utf8_encode($rssItem['title'], get_conf('charset'));
            $item->description = claro_utf8_encode($rssItem['description']);
            $item->category = $rssItem['category'];
            $item->guid = $rssItem['guid'];
            $item->link = $rssItem['link'];
            $item->date = $rssItem['pubDate'];
            $rss->addItem($item);
        }
        return $rss->outputFeed("RSS2.0");
    }
    return false;
}
Example #9
0
                     $ql['answer'] .= ' [';
                     $_qr = '';
                     foreach ($question['rightList'] as $qr) {
                         if ($_qr) {
                             $_qr .= ' , ';
                         }
                         $_qr .= $qr['answer'];
                     }
                     $ql['answer'] .= $_qr;
                     $ql['answer'] .= '] ';
                     $htmlcontent .= '<tr>' . "\n" . '<td colspan="2" style="background-color: #EEE;">' . claro_htmlspecialchars(strip_tags($ql['answer'])) . '</td>' . "\n" . '</tr>' . "\n";
                 }
                 break;
         }
         $htmlcontent .= '</tbody>' . "\n" . '</table></p>' . "\n";
         $pdf->writeHTML(claro_utf8_encode($htmlcontent, get_conf('charset')), true, 0, true, 0);
         $i++;
     }
     //Close and output PDF document
     $pdf->Output('exercise' . $exercise->getId() . '.pdf', 'D');
     exit;
 }
 //-- delete
 if ($cmd == 'exDel' && $exId) {
     $exercise = new Exercise();
     $exercise->load($exId);
     $exercise->delete();
     //notify manager that the exercise is deleted
     $eventNotifier->notifyCourseEvent("exercise_deleted", claro_get_current_course_id(), claro_get_current_tool_id(), $exId, claro_get_current_group_id(), "0");
 }
 //-- change visibility