Ejemplo n.º 1
0
 /**
  * render questions per page
  */
 protected function renderPage()
 {
     global $ilCtrl, $lng, $tpl, $rbacsystem;
     $pages = $this->object->getSurveyPages();
     $this->has_next_page = $this->current_page < sizeof($pages);
     $this->has_previous_page = $this->current_page > 1;
     $this->has_datasets = $this->object->_hasDatasets($this->object->getSurveyId());
     if ($this->has_datasets) {
         $link = $ilCtrl->getLinkTargetByClass(array("ilobjsurveygui", "ilsurveyparticipantsgui"), "maintenance");
         $link = "<a href=\"" . $link . "\">" . $lng->txt("survey_has_datasets_warning_page_view_link") . "</a>";
         ilUtil::sendInfo($lng->txt("survey_has_datasets_warning_page_view") . " " . $link);
     }
     $ilCtrl->setParameter($this, "pg", $this->current_page);
     $ilCtrl->setParameter($this, "pgov", "");
     $this->renderToolbar($pages);
     if ($pages) {
         $ttpl = new ilTemplate("tpl.il_svy_svy_page_view.html", true, true, "Modules/Survey");
         $ttpl->setVariable("FORM_ACTION", $ilCtrl->getFormAction($this));
         $ttpl->setVariable("WYSIWYG_ACTION", $ilCtrl->getFormAction($this));
         $lng->loadLanguageModule("form");
         $read_only = $this->has_datasets || !$rbacsystem->checkAccess("write", $this->ref_id);
         $commands = $multi_commands = array();
         if (!$read_only) {
             // clipboard is empty
             if (!$_SESSION["survey_page_view"][$this->ref_id]["clipboard"]) {
                 $multi_commands[] = array("cmd" => "multiDelete", "text" => $lng->txt("delete"));
                 $multi_commands[] = array("cmd" => "multiCut", "text" => $lng->txt("cut"));
                 $multi_commands[] = array("cmd" => "multiCopy", "text" => $lng->txt("copy"));
             } else {
                 if (!$this->suppress_clipboard_msg) {
                     ilUtil::sendInfo($lng->txt("survey_clipboard_notice"));
                 }
                 $multi_commands[] = array("cmd" => "clearClipboard", "text" => $lng->txt("survey_dnd_clear_clipboard"));
             }
             // help
             $ttpl->setCurrentBlock("help_img");
             $ttpl->setVariable("IMG_HELP", ilUtil::getImagePath("streaked_area.png"));
             $ttpl->parseCurrentBlock();
             $ttpl->setCurrentBlock("help_section");
             $ttpl->setVariable("TXT_HELP", $lng->txt("form_hierarchy_add_elements"));
             $ttpl->parseCurrentBlock();
             $ttpl->setCurrentBlock("help_img");
             $ttpl->setVariable("IMG_HELP", ilUtil::getImagePath("icon_cont_el_s.png"));
             $ttpl->parseCurrentBlock();
             $ttpl->setVariable("IMG_HELP", ilUtil::getImagePath("drop_streaked_area.png"));
             $ttpl->parseCurrentBlock();
             $ttpl->setCurrentBlock("help_section");
             $ttpl->setVariable("TXT_HELP", $lng->txt("form_hierarchy_drag_drop_help"));
             $ttpl->parseCurrentBlock();
             $ttpl->setCurrentBlock("help_img");
             $ttpl->setVariable("IMG_HELP", ilUtil::getImagePath("icon_cont_el_s.png"));
             $ttpl->parseCurrentBlock();
             $ttpl->setCurrentBlock("help_section");
             $ttpl->setVariable("TXT_HELP", $lng->txt("survey_dnd_double_click_to_delete"));
             $ttpl->parseCurrentBlock();
             $ttpl->setVariable("DND_INIT_JS", "initDragElements();");
             // tiny mce
             include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
             $tags = ilObjAdvancedEditing::_getUsedHTMLTags("survey");
             include_once "./Services/RTE/classes/class.ilTinyMCE.php";
             $tiny = new ilTinyMCE("3.3.9.2");
             $ttpl->setVariable("WYSIWYG_BLOCKFORMATS", $tiny->_buildAdvancedBlockformatsFromHTMLTags($tags));
             $ttpl->setVariable("WYSIWYG_VALID_ELEMENTS", $tiny->_getValidElementsFromHTMLTags($tags));
             $buttons_1 = $tiny->_buildAdvancedButtonsFromHTMLTags(1, $tags);
             $buttons_2 = $tiny->_buildAdvancedButtonsFromHTMLTags(2, $tags) . ',' . $tiny->_buildAdvancedTableButtonsFromHTMLTags($tags) . ($tiny->getStyleSelect() ? ',styleselect' : '');
             $buttons_3 = $tiny->_buildAdvancedButtonsFromHTMLTags(3, $tags);
             $ttpl->setVariable('WYSIWYG_BUTTONS_1', $tiny->_removeRedundantSeparators($buttons_1));
             $ttpl->setVariable('WYSIWYG_BUTTONS_2', $tiny->_removeRedundantSeparators($buttons_2));
             $ttpl->setVariable('WYSIWYG_BUTTONS_3', $tiny->_removeRedundantSeparators($buttons_3));
         }
         // commands
         if (count($multi_commands) > 0 || count($commands) > 0) {
             $single = false;
             foreach ($commands as $cmd) {
                 $ttpl->setCurrentBlock("cmd");
                 $ttpl->setVariable("ORG_CMD", "renderPage");
                 $ttpl->setVariable("CMD", $cmd["cmd"]);
                 $ttpl->setVariable("CMD_TXT", $cmd["text"]);
                 $ttpl->parseCurrentBlock();
                 $single = true;
             }
             $multi = false;
             foreach ($multi_commands as $cmd) {
                 $ttpl->setCurrentBlock("multi_cmd");
                 $ttpl->setVariable("ORG_CMD_MULTI", "renderPage");
                 $ttpl->setVariable("MULTI_CMD", $cmd["cmd"]);
                 $ttpl->setVariable("MULTI_CMD_TXT", $cmd["text"]);
                 $ttpl->parseCurrentBlock();
                 $multi = true;
             }
             if ($multi) {
                 $ttpl->setCurrentBlock("multi_cmds");
                 $ttpl->setVariable("MCMD_ALT", $lng->txt("commands"));
                 $ttpl->setVariable("MCMD_IMG", ilUtil::getImagePath("arrow_downright.png"));
                 $ttpl->parseCurrentBlock();
             }
             if ($single || $multi) {
                 $ttpl->setCurrentBlock("commands");
                 $ttpl->parseCurrentBlock();
             }
         }
         // nodes
         $ttpl->setVariable("NODES", $this->getPageNodes($pages[$this->current_page - 1], $this->has_previous_page, $this->has_next_page, $read_only));
         $tpl->setContent($ttpl->get());
         // add js to template
         include_once "./Services/YUI/classes/class.ilYuiUtil.php";
         ilYuiUtil::initDragDrop();
         $tpl->addJavascript("./Modules/Survey/js/SurveyPageView.js");
         $tpl->addJavascript("./Services/RTE/tiny_mce_3_3_9_2/tiny_mce_src.js");
     }
 }
Ejemplo n.º 2
0
 function _buildButtonsFromHTMLTags($a_html_tags)
 {
     $theme_advanced_buttons = array();
     if (in_array("strong", $a_html_tags)) {
         array_push($theme_advanced_buttons, "bold");
     }
     if (in_array("em", $a_html_tags)) {
         array_push($theme_advanced_buttons, "italic");
     }
     if (in_array("u", $a_html_tags)) {
         array_push($theme_advanced_buttons, "underline");
     }
     if (in_array("strike", $a_html_tags)) {
         array_push($theme_advanced_buttons, "strikethrough");
     }
     if (in_array("p", $a_html_tags)) {
         array_push($theme_advanced_buttons, "justifyleft");
         array_push($theme_advanced_buttons, "justifycenter");
         array_push($theme_advanced_buttons, "justifyright");
         array_push($theme_advanced_buttons, "justifyfull");
     }
     if (strlen(ilTinyMCE::_buildAdvancedBlockformatsFromHTMLTags($a_html_tags))) {
         array_push($theme_advanced_buttons, "formatselect");
     }
     if (in_array("hr", $a_html_tags)) {
         array_push($theme_advanced_buttons, "hr");
     }
     if (in_array("sub", $a_html_tags)) {
         array_push($theme_advanced_buttons, "sub");
     }
     if (in_array("sup", $a_html_tags)) {
         array_push($theme_advanced_buttons, "sup");
     }
     if (in_array("font", $a_html_tags)) {
         array_push($theme_advanced_buttons, "fontselect");
         array_push($theme_advanced_buttons, "fontsizeselect");
     }
     if (in_array("ol", $a_html_tags) && in_array("li", $a_html_tags)) {
         array_push($theme_advanced_buttons, "bullist");
     }
     if (in_array("ul", $a_html_tags) && in_array("li", $a_html_tags)) {
         array_push($theme_advanced_buttons, "numlist");
     }
     if (in_array("cite", $a_html_tags)) {
         array_push($theme_advanced_buttons, "cite");
     }
     if (in_array("abbr", $a_html_tags)) {
         array_push($theme_advanced_buttons, "abbr");
     }
     if (in_array("acronym", $a_html_tags)) {
         array_push($theme_advanced_buttons, "acronym");
     }
     if (in_array("del", $a_html_tags)) {
         array_push($theme_advanced_buttons, "del");
     }
     if (in_array("ins", $a_html_tags)) {
         array_push($theme_advanced_buttons, "ins");
     }
     if (in_array("blockquote", $a_html_tags)) {
         array_push($theme_advanced_buttons, "indent");
         array_push($theme_advanced_buttons, "outdent");
     }
     if (in_array("img", $a_html_tags)) {
         //array_push($theme_advanced_buttons, "advimage");
         array_push($theme_advanced_buttons, "image");
         array_push($theme_advanced_buttons, "ibrowser");
         array_push($theme_advanced_buttons, "ilimgupload");
     }
     if (in_array("a", $a_html_tags)) {
         array_push($theme_advanced_buttons, "link");
         array_push($theme_advanced_buttons, "unlink");
         array_push($theme_advanced_buttons, "anchor");
     }
     $remove_buttons = $this->getDisabledButtons();
     if (is_array($remove_buttons)) {
         foreach ($remove_buttons as $buttontext) {
             if (($res = array_search($buttontext, $theme_advanced_buttons)) !== FALSE) {
                 unset($theme_advanced_buttons[$res]);
             }
         }
     }
     return join(",", $theme_advanced_buttons);
 }