Example #1
0
 /**
  * Tests books.
  */
 public function testBooks()
 {
     // Assert that books are not included in the sitemap by default.
     $this->drupalGet('/sitemap');
     $elements = $this->cssSelect(".sitemap-box h2:contains('Books')");
     $this->assertEqual(count($elements), 0, 'Books are not included.');
     // Create new book.
     $nodes = $this->createBook();
     $book = $this->book;
     // Configure sitemap to show the test book.
     $bid = $book->id();
     $edit = array('show_books[' . $bid . ']' => $bid);
     $this->drupalPostForm('admin/config/search/sitemap', $edit, t('Save configuration'));
     // Assert that all book links are displayed by default.
     $this->drupalGet('/sitemap');
     $this->assertLink($this->book->getTitle());
     foreach ($nodes as $node) {
         $this->assertLink($node->getTitle());
     }
     // Configure sitemap to not expand books.
     $edit = array('books_expanded' => FALSE);
     $this->drupalPostForm('admin/config/search/sitemap', $edit, t('Save configuration'));
     // Assert that the top-level book link is displayed, but that the others are
     // not.
     $this->drupalGet('/sitemap');
     $this->assertLink($this->book->getTitle());
     foreach ($nodes as $node) {
         $this->assertNoLink($node->getTitle());
     }
 }
 /**
  * Method to get a tree for sharing nodes
  * @param string $contextId The Context Id
  * @param string $mode The type of tree , either DHTML or Dropdown
  * @return string 
  * @access public
  */
 function getTree($contextId, $mode = NULL, $modeParams = NULL)
 {
     $icon = 'folder_up.gif';
     $expandedIcon = 'folder-expanded.gif';
     $link = '';
     $rootnodeid = $this->objDBContext->getRootNodeId($contextId);
     $rootlabel = '';
     //Create a new menu
     $menu = new treemenu();
     $contentlink = $this->URI(array('action', 'contenthome'), $this->module);
     //create base node
     $basenode = new treenode(array('text' => $rootlabel, 'link' => $contentlink, 'icon' => 'base.gif', 'expandedIcon' => 'base.gif'));
     $this->objDBContentNodes->resetTable();
     $nodesArr = $this->objDBContentNodes->getAll("WHERE tbl_context_parentnodes_id='{$rootnodeid}'");
     $this->objDBContentNodes->changeTable('tbl_context_nodes_has_tbl_context_page_content');
     foreach ($nodesArr as $node) {
         if ($node['parent_Node'] == null) {
             $basenode->addItem($this->getChildNodes($nodesArr, $node['id'], stripslashes($this->shortenString($node['title']))));
         }
     }
     $this->objDBContentNodes->resetTable();
     $menu->addItem($basenode);
     //$menu->addItem($this->recurTree($rootnodeid,$rootlabel));
     // Create the presentation class
     $treeMenu =& new dhtml($menu, array('images' => $this->objSkin->getSkinURL() . '/treeimages/imagesAlt2', 'defaultClass' => 'treeMenuDefault'));
     if ($mode == 'listbox') {
         $listBox =& new listbox($menu, array('linkTarget' => '_self', 'submitText' => $modeParams['submitText'], 'promoText' => $modeParams['promoText']));
         return $listBox->getMenu();
     }
     return '<h5>' . $this->objDBContext->getTitle() . '</h5>' . $treeMenu->getMenu();
 }
Example #3
0
 /**
  * Extract values from an object
  *
  * @param  object $object
  *
  * @return array
  */
 public function extract($object)
 {
     if (!$object instanceof Post) {
         return array();
     }
     return array('id' => $object->getId(), 'title' => $object->getTitle(), 'slug' => $object->getSlug(), 'content' => $object->getContent(), 'created' => $object->getCreated());
 }
Example #4
0
 /**
  * create zip from created font
  *
  * @param object $currentFont
  * @return string
  */
 public static function createZip($currentFont)
 {
     // general vars
     $cleanTitle = strtolower(preg_replace(array('/\\s+/', '/[^a-zA-Z0-9]/'), array('-', ''), $currentFont->getTitle()));
     $fontPath = PATH_site . 'fileadmin/' . $currentFont->getDestination() . $cleanTitle . '/';
     $fileName = $destinationPath = PATH_site . 'fileadmin/' . $currentFont->getDestination() . $cleanTitle . '_' . $currentFont->getVersion() . '_' . date('YmdHi', $GLOBALS['EXEC_TIME']) . '.zip';
     $zip = new \ZipArchive();
     $zip->open($fileName, \ZipArchive::CREATE);
     // Get all the files of the extension, but exclude the ones specified in the excludePattern
     $files = GeneralUtility::getAllFilesAndFoldersInPath(array(), $fontPath, '', TRUE, PHP_INT_MAX);
     // Make paths relative to extension root directory.
     $files = GeneralUtility::removePrefixPathFromList($files, $fontPath);
     // Remove the one empty path that is the extension dir itself.
     $files = array_filter($files);
     foreach ($files as $file) {
         $fullPath = $fontPath . $file;
         // Distinguish between files and directories, as creation of the archive
         // fails on Windows when trying to add a directory with "addFile".
         if (is_dir($fullPath)) {
             $zip->addEmptyDir($file);
         } else {
             $zip->addFile($fullPath, $file);
         }
     }
     $zip->close();
     return $fileName;
 }
Example #5
0
 /**
  * Get values for edit form
  *
  * @return array
  */
 protected function getEditFormValues()
 {
     $values["title"] = $this->object->getTitle();
     $values["desc"] = $this->object->getLongDescription();
     $this->getEditFormCustomValues($values);
     return $values;
 }
 /**
  * create Font via Python with FontForge
  *
  * @param int $fontUid
  * @param object $currentFont
  * @return array
  */
 public static function createFont($fontUid, $currentFont)
 {
     // general vars
     $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['fontawesomeplus']);
     $pathToPythonBin = escapeshellarg($extConf['pathToPython']);
     $pathToScript = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('fontawesomeplus') . 'Resources/Private/Python/fontawesomeplus.py';
     $iconRepository = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\FileRepository::class);
     $iconReferences = $iconRepository->findByRelation('tx_fontawesomeplus_domain_model_font', 'icons', $fontUid);
     $svgArray = array();
     foreach ($iconReferences as $key => $value) {
         $svgArray[$key] = PATH_site . 'fileadmin' . $value->getIdentifier();
     }
     $unicodeArray = array();
     $i = hexdec(self::HEXADECIMAL);
     foreach ($svgArray as $key => $value) {
         $unicodeArray[$key] = $i . ',uni' . dechex($i);
         $i++;
     }
     $fontPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('fontawesomeplus') . 'Resources/Public/Contrib/' . self::FACONTRIB . '/fonts/fontawesome-webfont.svg';
     $fontForgeArray = CommandUtility::escapeShellArgument(json_encode(array_combine($svgArray, $unicodeArray), JSON_UNESCAPED_SLASHES));
     $fontName = strtolower(preg_replace(array('/\\s+/', '/[^a-zA-Z0-9]/'), array('-', ''), $currentFont->getTitle()));
     $comment = CommandUtility::escapeShellArgument(str_replace(array("\r\n", "\n", "\r"), ' ', $currentFont->getDescription()));
     $copyright = CommandUtility::escapeShellArgument('netweiser');
     $version = CommandUtility::escapeShellArgument($currentFont->getVersion());
     GeneralUtility::mkdir_deep(PATH_site . 'fileadmin/' . $currentFont->getDestination(), $fontName . '/fonts/');
     $savedir = PATH_site . 'fileadmin/' . $currentFont->getDestination() . $fontName . '/fonts/';
     CommandUtility::exec("{$pathToPythonBin} {$pathToScript} {$fontPath} {$fontForgeArray} {$fontName} {$comment} {$copyright} {$version} {$savedir} 2>&1", $feedback, $returnCode);
     if ((int) $returnCode !== 0) {
         return $feedback;
     }
 }
Example #7
0
 /**
  * Returns the title of a certain sheet
  * @param object $sheet The PHPExcel Sheet object
  * @return string The title of the sheet
  */
 public function getSheetTitle($sheet)
 {
     try {
         $result = $sheet->getTitle();
     } catch (Exception $ex) {
         $result = "";
     }
     return $result;
 }
 /**
  * Creates a question from a QTI file
  *
  * Receives parameters from a QTI parser and creates a valid ILIAS question object
  *
  * @param object $item The QTI item object
  * @param integer $questionpool_id The id of the parent questionpool
  * @param integer $tst_id The id of the parent test if the question is part of a test
  * @param object $tst_object A reference to the parent test object
  * @param integer $question_counter A reference to a question counter to count the questions of an imported question pool
  * @param array $import_mapping An array containing references to included ILIAS objects
  * @access public
  */
 function fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
 {
     global $ilUser;
     // empty session variable for imported xhtml mobs
     unset($_SESSION["import_mob_xhtml"]);
     $presentation = $item->getPresentation();
     $duration = $item->getDuration();
     $now = getdate();
     $created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
     $feedbacksgeneric = array();
     $this->object->setTitle($item->getTitle());
     $this->object->setNrOfTries($item->getMaxattempts());
     $this->object->setComment($item->getComment());
     $this->object->setAuthor($item->getAuthor());
     $this->object->setOwner($ilUser->getId());
     $this->object->setQuestion($this->object->QTIMaterialToString($item->getQuestiontext()));
     $this->object->setObjId($questionpool_id);
     $this->object->setEstimatedWorkingTime($duration["h"], $duration["m"], $duration["s"]);
     $this->object->setPoints($item->getMetadataEntry("points"));
     $this->object->setOrderText($item->getMetadataEntry("ordertext"));
     $this->object->setTextSize($item->getMetadataEntry("textsize"));
     $this->object->setSeparator($item->getMetadataEntry("separator"));
     $this->object->saveToDb();
     // handle the import of media objects in XHTML code
     $questiontext = $this->object->getQuestion();
     if (is_array($_SESSION["import_mob_xhtml"])) {
         include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
         include_once "./Services/RTE/classes/class.ilRTE.php";
         foreach ($_SESSION["import_mob_xhtml"] as $mob) {
             if ($tst_id > 0) {
                 $importfile = $this->getTstImportArchivDirectory() . '/' . $mob["uri"];
             } else {
                 $importfile = $this->getQplImportArchivDirectory() . '/' . $mob["uri"];
             }
             $GLOBALS['ilLog']->write(__METHOD__ . ': import mob from dir: ' . $importfile);
             $media_object =& ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, FALSE);
             ilObjMediaObject::_saveUsage($media_object->getId(), "qpl:html", $this->object->getId());
             $questiontext = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $questiontext);
         }
     }
     $this->object->setQuestion(ilRTE::_replaceMediaObjectImageSrc($questiontext, 1));
     $this->object->saveToDb();
     if (count($item->suggested_solutions)) {
         foreach ($item->suggested_solutions as $suggested_solution) {
             $this->object->setSuggestedSolution($suggested_solution["solution"]->getContent(), $suggested_solution["gap_index"], true);
         }
         $this->object->saveToDb();
     }
     if ($tst_id > 0) {
         $q_1_id = $this->object->getId();
         $question_id = $this->object->duplicate(true, null, null, null, $tst_id);
         $tst_object->questions[$question_counter++] = $question_id;
         $import_mapping[$item->getIdent()] = array("pool" => $q_1_id, "test" => $question_id);
     } else {
         $import_mapping[$item->getIdent()] = array("pool" => $this->object->getId(), "test" => 0);
     }
 }
Example #9
0
 /**
  * callback function for usort
  * @param object $a
  * @param object $b
  * @return boolean
  */
 private static function pluginSort($a, $b)
 {
     if ($a->getWeight() > $b->getWeight()) {
         return -1;
     } elseif ($a->getWeight() < $b->getWeight()) {
         return 1;
     } else {
         return strcmp($a->getTitle(), $b->getTitle());
     }
 }
 /**
  * Method to get all the context by a filter
  * @param string $filter
  */
 public function getContextList()
 {
     $contexts = $this->objDBContext->getAll();
     $arr = array();
     foreach ($contexts as $context) {
         $arr[$this->objDBContext->getTitle($context['contextcode'])] = $context['contextcode'];
         //$user['userid'];
     }
     return $arr;
 }
 /**
  * Normalizes an object into a set of arrays/scalars.
  *
  * @param object $object object to normalize
  * @param string $format format the normalization result will be encoded as
  * @param array $context Context options for the normalizer
  *
  * @return array|string|bool|int|float|null
  */
 public function normalize($object, $format = null, array $context = array())
 {
     /** @var Payer $object */
     $hasComments = true;
     $comments = $object->getComments();
     if (is_null($comments) || $comments->getSize() == 0) {
         $hasComments = false;
     } else {
         $comments = $comments->getComments();
     }
     return array_filter(array('@type' => $object->getType(), '@ref' => $object->getRef(), 'title' => $object->getTitle(), 'firstname' => $object->getFirstName(), 'surname' => $object->getSurname(), 'company' => $object->getCompany(), 'address' => $object->getAddress(), 'phonenumbers' => $object->getPhoneNumbers(), 'email' => $object->getEmail(), 'comments' => $hasComments ? array('comment' => $comments) : array()), array(NormaliserHelper::GetClassName(), "filter_data"));
 }
 /**
  * Method to create  the first node
  */
 public function createParentNode()
 {
     if (!$this->objDBParents->valueExists('tbl_context_parentnodes_has_tbl_context_tbl_context_contextCode', $this->objDBContext->getContextCode())) {
         $contextId = $this->objDBContext->getContextId();
         $contextCode = $this->objDBContext->getContextCode();
         //add a bridge to context and parent
         $this->objDBContextParents->insert(array('tbl_context_id' => $contextId, 'tbl_context_contextCode' => $contextCode));
         //add a parent node
         $parentId = $this->objDBParents->insert(array('tbl_context_parentnodes_has_tbl_context_tbl_context_id' => $contextId, 'tbl_context_parentnodes_has_tbl_context_tbl_context_contextCode' => $contextCode, 'userId' => $this->userId, 'dateCreated' => $this->objDBContext->getDate(), 'datemodified' => $this->objDBContext->getDate(), 'menu_text' => $this->objDBContext->getMenuText(), 'title' => $this->objDBContext->getTitle()));
     }
     $this->resetTable();
 }
Example #13
0
 /**
  * Constructor
  */
 public function init()
 {
     try {
         $this->objContext = $this->getObject('dbcontext');
         $this->contextCode = $this->objContext->getContextCode();
         $this->setVarByRef('contextCode', $this->contextCode);
         $this->contextTitle = $this->objContext->getTitle();
         $this->setVarByRef('contextTitle', $this->contextTitle);
         $this->objLanguage = $this->getObject('language', 'language');
         $this->objUser = $this->getObject('user', 'security');
         $this->objContextBlocks = $this->getObject('dbcontextblocks');
         $this->objDynamicBlocks = $this->getObject('dynamicblocks', 'blocks');
         $this->objBlocks = $this->getObject('blocks', 'blocks');
         //Load Module Catalogue Class
         $this->objModuleCatalogue = $this->getObject('modules', 'modulecatalogue');
         $this->objContextGroups = $this->getObject('managegroups', 'contextgroups');
         if ($this->objModuleCatalogue->checkIfRegistered('activitystreamer')) {
             $this->objActivityStreamer = $this->getObject('activityops', 'activitystreamer');
             $this->eventDispatcher->addObserver(array($this->objActivityStreamer, 'postmade'));
             $this->eventsEnabled = TRUE;
         } else {
             $this->eventsEnabled = FALSE;
         }
         //Check if contentblocks is installed
         $this->cbExists = $this->objModuleCatalogue->checkIfRegistered("contentblocks");
         if ($this->cbExists) {
             $this->objBlocksContent = $this->getObject('dbcontentblocks', 'contentblocks');
             $this->objTxtBlockBase = $this->getObject("contentblockbase", "contentblocks");
         }
         $this->dbSysConfig = $this->getObject('dbsysconfig', 'sysconfig');
         $disableActivityStreamer = $this->dbSysConfig->getValue('DISABLE_ACTIVITYSTREAMER', 'context');
         if ($disableActivityStreamer == 'TRUE' || $disableActivityStreamer == 'true') {
             $this->eventsEnabled = FALSE;
         }
     } catch (customException $e) {
         customException::cleanUp();
         //Load Module Catalogue Class
         //$this->objModuleCatalogue = $this->getObject('modules', 'modulecatalogue');
     }
 }
Example #14
0
 /**
  * Constructor
  *
  * @return  void
  * @since   1.5.5
  */
 public function __construct($config = array())
 {
     parent::__construct($config);
     $this->_ambit = JoomAmbit::getInstance();
     $this->_config = JoomConfig::getInstance();
     $this->_mainframe = JFactory::getApplication('site');
     $this->_user = JFactory::getUser();
     $this->_doc = JFactory::getDocument();
     JHtml::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . '/helpers/html');
     // If we are just displaying an image we don't need anything else
     if (JRequest::getCmd('format') == 'raw' || JRequest::getCmd('format') == 'jpg' || JRequest::getCmd('format') == 'json' || JRequest::getCmd('format') == 'feed') {
         return;
     }
     // Add the CSS file generated from backend settings
     $this->_doc->addStyleSheet($this->_ambit->getStyleSheet($this->_config->getStyleSheetName()));
     // Add the main CSS file
     $this->_doc->addStyleSheet($this->_ambit->getStyleSheet('joomgallery.css'));
     // Add the RTL CSS file if an RTL language is used
     if (JFactory::getLanguage()->isRTL()) {
         $this->_doc->addStyleSheet($this->_ambit->getStyleSheet('joomgallery_rtl.css'));
     }
     // Add individual CSS file if it exists
     if (file_exists(JPATH_ROOT . '/media/joomgallery/css/joom_local.css')) {
         $this->_doc->addStyleSheet($this->_ambit->getStyleSheet('joom_local.css'));
     }
     $pngbehaviour = "  <!-- Do not edit IE conditional style below -->" . "\n" . "  <!--[if lte IE 6]>" . "\n" . "  <style type=\"text/css\">\n" . "    .pngfile {\n" . "      behavior:url('" . JURI::root() . "media/joomgallery/js/pngbehavior.htc') !important;\n" . "    }\n" . "  </style>\n" . "  <![endif]-->" . "\n" . "  <!-- End Conditional Style -->";
     $this->_doc->addCustomTag($pngbehaviour);
     // Set documents meta data taken from menu entry definition
     $params = $this->_mainframe->getParams();
     if ($params->get('menu-meta_description')) {
         $this->_doc->setDescription($params->get('menu-meta_description'));
     }
     if ($params->get('menu-meta_keywords')) {
         $this->_doc->setMetadata('keywords', $params->get('menu-meta_keywords'));
     }
     if ($params->get('robots')) {
         $this->_doc->setMetadata('robots', $params->get('robots'));
     }
     // Page title
     $pagetitle = JoomHelper::addSitenameToPagetitle($this->_doc->getTitle());
     $this->_doc->setTitle($pagetitle);
     // Check for alternative layout only if this is not the active menu item
     $active = $this->_mainframe->getMenu()->getActive();
     if (!$active || strpos($active->link, 'view=' . $this->getName()) === false) {
         // Get the default layout from the configuration
         if ($layout = $this->_config->get('jg_alternative_layout')) {
             $this->setLayout($layout);
         }
     }
 }
 /**
  * Update solr index for ad
  *
  * @param object $ad ad object
  *
  * @throws
  */
 public function updateSolrIndex($ad)
 {
     try {
         $ping = $this->masterClient->createPing();
     } catch (Solarium\Exception $e) {
         throw \Exception('Ping query failed');
     }
     if (!$this->update) {
         $this->update = $this->masterClient->createUpdate();
     }
     $contentArr = array();
     $doc = $this->update->createDocument();
     $doc->id = $ad->getId();
     $doc->vertical_i = $ad->getVertical()->getId();
     $doc->user_i = $ad->getUser()->getId();
     $doc->cat1_i = $ad->getCategory1()->getId();
     if ($ad->getCategory2()) {
         $doc->cat2_i = $ad->getCategory2()->getId();
     }
     if ($ad->getCategory3()) {
         $doc->cat3_i = $ad->getCategory3()->getId();
     }
     $doc->status_s = $ad->getStatus();
     $doc->price_d = $ad->getPrice();
     $doc->currency_i = $ad->getCurrency()->getId();
     $title = preg_replace('/[\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F\\x7F]/', '', $ad->getTitle());
     $doc->title_s = $title;
     $contentArr[] = $title;
     $contentArr[] = $ad->getDescription();
     $doc->seller_type_s = $ad->getUser()->isPrivateAdvertiser() ? 'PrivateAdvertiser' : 'BusinessAdvertiser';
     $userTypes = array();
     if ($ad->getUser()->getRoles()) {
         foreach ($ad->getUser()->getRoles() as $role) {
             $userTypes[] = $role ? $role->getId() : 0;
         }
     }
     if (count($userTypes)) {
         $doc->userType_is = array_unique($userTypes);
     }
     $doc->createdAt_dt = $ad->getCreatedAt();
     $doc->createdAt_i = $ad->getCreatedAt()->getTimestamp();
     $doc->updatedAt_dt = $ad->getUpdatedAt();
     $doc->updatedAt_i = $ad->getUpdatedAt()->getTimestamp();
     $doc->content = $contentArr;
     return $doc;
 }
Example #16
0
/**
 * wfElggNotifyCurlUpdate 
 * 
 * @param object $article 
 * @param object $user 
 * @param bool $isMinor 
 * @param bool $isWatch 
 * @return bool
 */
function wfElggNotifyCurlUpdate($article, $user, $text, $summary, $isMinor, $isWatch, $section, $flags, $revision)
{
    if ($isMinor) {
        $editStatus = 'minor';
    } else {
        $editStatus = 'major';
    }
    $title = $article->getTitle();
    $page = wfUrlencode($title->getPrefixedDBkey());
    $username = $user->mName;
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, ELGG_URL . "mod/mediawiki/edit_notify.php");
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "page={$page}&mediawiki_username={$username}&edit_status={$editStatus}");
    curl_exec($ch);
    curl_close($ch);
    return true;
}
/**
 * Filters a new comment post and sends email replies to previous posters
 * @param object $comment the comment
 * @param object $owner the element commented upon.
 */
function emailReply($comment, $owner)
{
    $gallery = new Gallery();
    if ($comment->getInModeration() || $comment->getPrivate()) {
        return $comment;
        // we are not going to e-mail unless the comment has passed.
    }
    $oldcomments = $owner->comments;
    $emails = array();
    foreach ($oldcomments as $oldcomment) {
        $name = $oldcomment['name'];
        $emails[$name] = $oldcomment['email'];
    }
    $emails = array_unique($emails);
    switch ($comment->getType()) {
        case "albums":
            $url = "album=" . urlencode($owner->name);
            $action = sprintf(gettext('A reply has been posted on album "%1$s".'), $owner->name);
            break;
        case "news":
            $url = "p=" . ZENPAGE_NEWS . "&title=" . urlencode($owner->getTitlelink());
            $action = sprintf(gettext('A reply has been posted on article "%1$s".'), $owner->getTitlelink());
            break;
        case "pages":
            $url = "p=" . ZENPAGE_PAGES . "&title=" . urlencode($owner->getTitlelink());
            $action = sprintf(gettext('A reply has been posted on page "%1$s".'), $owner->getTitlelink());
            break;
        default:
            // all image types
            $url = "album=" . urlencode($owner->album->name) . "&image=" . urlencode($owner->filename);
            $action = sprintf(gettext('A reply has been posted on "%1$s" the album "%2$s".'), $owner->getTitle(), $owner->getAlbumName());
    }
    if ($comment->getAnon()) {
        $email = $name = '<' . gettext("Anonymous") . '>';
    } else {
        $name = $comment->getname();
        $email = $comment->getEmail();
    }
    $message = $action . "\n\n" . sprintf(gettext('Author: %1$s' . "\n" . 'Email: %2$s' . "\n" . 'Website: %3$s' . "\n" . 'Comment:' . "\n\n" . '%4$s'), $name, $email, $comment->getWebsite(), $comment->getComment()) . "\n\n" . sprintf(gettext('You can view all comments about this item here:' . "\n" . '%1$s'), 'http://' . $_SERVER['SERVER_NAME'] . WEBPATH . '/index.php?' . $url) . "\n\n";
    $on = gettext('Reply posted');
    zp_mail("[" . $gallery->getTitle() . "] {$on}", $message, $emails);
    return $comment;
}
 function setQuestionTabsForClass($guiclass)
 {
     global $rbacsystem, $ilTabs;
     $this->ctrl->setParameterByClass("{$guiclass}", "sel_question_types", $this->getQuestionType());
     $this->ctrl->setParameterByClass("{$guiclass}", "q_id", $_GET["q_id"]);
     if ($_GET["calling_survey"] > 0 || $_GET["new_for_survey"] > 0) {
         $ref_id = $_GET["calling_survey"];
         if (!strlen($ref_id)) {
             $ref_id = $_GET["new_for_survey"];
         }
         $addurl = "";
         if (strlen($_GET["new_for_survey"])) {
             $addurl = "&new_id=" . $_GET["q_id"];
         }
         if ($_REQUEST["pgov"]) {
             $addurl .= "&pgov=" . $_REQUEST["pgov"];
             $addurl .= "&pgov_pos=" . $_REQUEST["pgov_pos"];
         }
         $ilTabs->setBackTarget($this->lng->txt("menubacktosurvey"), "ilias.php?baseClass=ilObjSurveyGUI&ref_id={$ref_id}&cmd=questions" . $addurl);
     } else {
         $this->ctrl->setParameterByClass("ilObjSurveyQuestionPoolGUI", "q_id_table_nav", $_SESSION['q_id_table_nav']);
         $ilTabs->setBackTarget($this->lng->txt("spl"), $this->ctrl->getLinkTargetByClass("ilObjSurveyQuestionPoolGUI", "questions"));
     }
     if ($_GET["q_id"]) {
         $ilTabs->addTarget("preview", $this->ctrl->getLinkTargetByClass("{$guiclass}", "preview"), "preview", "{$guiclass}");
     }
     if ($rbacsystem->checkAccess('edit', $_GET["ref_id"])) {
         $ilTabs->addTarget("edit_properties", $this->ctrl->getLinkTargetByClass("{$guiclass}", "editQuestion"), array("editQuestion", "save", "cancel", "originalSyncForm"), "{$guiclass}");
     }
     if ($_GET["q_id"]) {
         $ilTabs->addTarget("material", $this->ctrl->getLinkTargetByClass("{$guiclass}", "material"), array("material", "cancelExplorer", "linkChilds", "addGIT", "addST", "addPG", "addMaterial", "removeMaterial"), "{$guiclass}");
     }
     if ($this->object->getId() > 0) {
         $title = $this->lng->txt("edit") . " &quot;" . $this->object->getTitle() . "&quot";
     } else {
         $title = $this->lng->txt("create_new") . " " . $this->lng->txt($this->getQuestionType());
     }
     $this->tpl->setVariable("HEADER", $title);
 }
Example #19
0
 /**
  * Step 4 - Selecting modules to be used in context
  */
 private function __step4()
 {
     $contextCode = $this->getSession('contextCode');
     //Get Context Title
     $contextTitle = $this->objContext->getTitle($contextCode);
     if (empty($contextTitle)) {
         $contextTitle = $this->objContext->getMenuText($contextCode);
     }
     if ($contextTitle == FALSE) {
         return $this->nextAction(NULL);
     }
     $this->setVar('mode', $this->getParam('mode'));
     $this->setVar('contextCode', $contextCode);
     $this->setVar('contextTitle', $contextTitle);
     $objContextModules = $this->getObject('dbcontextmodules', 'context');
     $objModules = $this->getObject('modules', 'modulecatalogue');
     $contextModules = $objContextModules->getContextModules($contextCode);
     $plugins = $objModules->getListContextPlugins();
     $this->setVarByRef('contextModules', $contextModules);
     $this->setVarByRef('plugins', $plugins);
     return 'step4.php';
 }
Example #20
0
 /**
  * Add basic question form properties:
  * assessment: title, author, description, question, working time
  *
  * @return	int	Default Nr of Tries
  */
 function addBasicQuestionFormProperties($form)
 {
     // title
     $title = new ilTextInputGUI($this->lng->txt("title"), "title");
     $title->setValue($this->object->getTitle());
     $title->setRequired(TRUE);
     $form->addItem($title);
     if (!$this->object->getSelfAssessmentEditingMode()) {
         // author
         $author = new ilTextInputGUI($this->lng->txt("author"), "author");
         $author->setValue($this->object->getAuthor());
         $author->setRequired(TRUE);
         $form->addItem($author);
         // description
         $description = new ilTextInputGUI($this->lng->txt("description"), "comment");
         $description->setValue($this->object->getComment());
         $description->setRequired(FALSE);
         $form->addItem($description);
     } else {
         // author as hidden field
         $hi = new ilHiddenInputGUI("author");
         $author = ilUtil::prepareFormOutput($this->object->getAuthor());
         if (trim($author) == "") {
             $author = "-";
         }
         $hi->setValue($author);
         $form->addItem($hi);
     }
     // questiontext
     $question = new ilTextAreaInputGUI($this->lng->txt("question"), "question");
     $question->setValue($this->object->prepareTextareaOutput($this->object->getQuestion()));
     $question->setRequired(TRUE);
     $question->setRows(10);
     $question->setCols(80);
     if (!$this->object->getSelfAssessmentEditingMode()) {
         if ($this->object->getAdditionalContentEditingMode() != assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_PAGE_OBJECT) {
             $question->setUseRte(TRUE);
             include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
             $question->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("assessment"));
             $question->addPlugin("latex");
             $question->addButton("latex");
             $question->addButton("pastelatex");
             $question->setRTESupport($this->object->getId(), "qpl", "assessment");
         }
     } else {
         $question->setRteTags(self::getSelfAssessmentTags());
         $question->setUseTagsForRteOnly(false);
     }
     $form->addItem($question);
     if (!$this->object->getSelfAssessmentEditingMode()) {
         // duration
         $duration = new ilDurationInputGUI($this->lng->txt("working_time"), "Estimated");
         $duration->setShowHours(TRUE);
         $duration->setShowMinutes(TRUE);
         $duration->setShowSeconds(TRUE);
         $ewt = $this->object->getEstimatedWorkingTime();
         $duration->setHours($ewt["h"]);
         $duration->setMinutes($ewt["m"]);
         $duration->setSeconds($ewt["s"]);
         $duration->setRequired(FALSE);
         $form->addItem($duration);
     } else {
         // number of tries
         if (strlen($this->object->getNrOfTries())) {
             $nr_tries = $this->object->getNrOfTries();
         } else {
             $nr_tries = $this->object->getDefaultNrOfTries();
         }
         if ($nr_tries < 1) {
             $nr_tries = "";
         }
         $ni = new ilNumberInputGUI($this->lng->txt("qst_nr_of_tries"), "nr_of_tries");
         $ni->setValue($nr_tries);
         $ni->setMinValue(0);
         $ni->setSize(5);
         $ni->setMaxLength(5);
         $form->addItem($ni);
     }
 }
 /**
  * Creates a question from a QTI file
  *
  * Receives parameters from a QTI parser and creates a valid ILIAS question object
  *
  * @param object $item The QTI item object
  * @param integer $questionpool_id The id of the parent questionpool
  * @param integer $tst_id The id of the parent test if the question is part of a test
  * @param object $tst_object A reference to the parent test object
  * @param integer $question_counter A reference to a question counter to count the questions of an imported question pool
  * @param array $import_mapping An array containing references to included ILIAS objects
  * @access public
  */
 function fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
 {
     global $ilUser;
     // empty session variable for imported xhtml mobs
     unset($_SESSION["import_mob_xhtml"]);
     $presentation = $item->getPresentation();
     $duration = $item->getDuration();
     $now = getdate();
     $created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
     $feedbacksgeneric = array();
     $this->object->setTitle($item->getTitle());
     $this->object->setNrOfTries($item->getMaxattempts());
     $this->object->setComment($item->getComment());
     $this->object->setAuthor($item->getAuthor());
     $this->object->setOwner($ilUser->getId());
     $this->object->setQuestion($this->object->QTIMaterialToString($item->getQuestiontext()));
     $this->object->setObjId($questionpool_id);
     $this->object->setEstimatedWorkingTime($duration["h"], $duration["m"], $duration["s"]);
     $this->object->setWidth($item->getMetadataEntry("width"));
     $this->object->setHeight($item->getMetadataEntry("height"));
     $this->object->setApplet($item->getMetadataEntry("applet"));
     $this->object->setParameters(unserialize($item->getMetadataEntry("params")));
     $this->object->setPoints($item->getMetadataEntry("points"));
     $this->object->saveToDb();
     $flashapplet =& base64_decode($item->getMetadataEntry("swf"));
     if (!file_exists($this->object->getFlashPath())) {
         include_once "./Services/Utilities/classes/class.ilUtil.php";
         ilUtil::makeDirParents($this->object->getFlashPath());
     }
     $filename = $this->object->getFlashPath() . $this->object->getApplet();
     $fh = fopen($filename, "wb");
     if ($fh == false) {
         //									global $ilErr;
         //									$ilErr->raiseError($this->object->lng->txt("error_save_image_file") . ": $php_errormsg", $ilErr->MESSAGE);
         //									return;
     } else {
         fwrite($fh, $flashapplet);
         fclose($fh);
     }
     $feedbacksgeneric = $this->getFeedbackGeneric($item);
     // handle the import of media objects in XHTML code
     $questiontext = $this->object->getQuestion();
     if (is_array($_SESSION["import_mob_xhtml"])) {
         include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
         include_once "./Services/RTE/classes/class.ilRTE.php";
         foreach ($_SESSION["import_mob_xhtml"] as $mob) {
             if ($tst_id > 0) {
                 $importfile = $this->getTstImportArchivDirectory() . '/' . $mob["uri"];
             } else {
                 $importfile = $this->getQplImportArchivDirectory() . '/' . $mob["uri"];
             }
             $GLOBALS['ilLog']->write(__METHOD__ . ': import mob from dir: ' . $importfile);
             $media_object =& ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, FALSE);
             ilObjMediaObject::_saveUsage($media_object->getId(), "qpl:html", $this->object->getId());
             $questiontext = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $questiontext);
             foreach ($feedbacksgeneric as $correctness => $material) {
                 $feedbacksgeneric[$correctness] = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $material);
             }
         }
     }
     $this->object->setQuestion(ilRTE::_replaceMediaObjectImageSrc($questiontext, 1));
     foreach ($feedbacksgeneric as $correctness => $material) {
         $this->object->saveFeedbackGeneric($correctness, ilRTE::_replaceMediaObjectImageSrc($material, 1));
     }
     $this->object->saveToDb();
     if (count($item->suggested_solutions)) {
         foreach ($item->suggested_solutions as $suggested_solution) {
             $this->object->setSuggestedSolution($suggested_solution["solution"]->getContent(), $suggested_solution["gap_index"], true);
         }
         $this->object->saveToDb();
     }
     if ($tst_id > 0) {
         $q_1_id = $this->object->getId();
         $question_id = $this->object->duplicate(true, null, null, null, $tst_id);
         $tst_object->questions[$question_counter++] = $question_id;
         $import_mapping[$item->getIdent()] = array("pool" => $q_1_id, "test" => $question_id);
     } else {
         $import_mapping[$item->getIdent()] = array("pool" => $this->object->getId(), "test" => 0);
     }
 }
Example #22
0
 /**
  * Callback function for sorting module objects by name.
  *
  * @param object $oModule1 module object
  * @param object $oModule2 module object
  *
  * @return bool
  */
 protected function _sortModules($oModule1, $oModule2)
 {
     return strcasecmp($oModule1->getTitle(), $oModule2->getTitle());
 }
Example #23
0
 /**
  * Process Query Results
  *
  * @access	private
  * @param	object	Mediawiki Result Object
  * @return	array	Array of Article objects.
  */
 private function processQueryResults($result)
 {
     /*******************************/
     /* Random Count Pick Generator */
     /*******************************/
     $randomCount = $this->parameters->getParameter('randomcount');
     if ($randomCount > 0) {
         $nResults = $this->DB->numRows($result);
         //mt_srand() seeding was removed due to PHP 5.2.1 and above no longer generating the same sequence for the same seed.
         //Constrain the total amount of random results to not be greater than the total results.
         if ($randomCount > $nResults) {
             $randomCount = $nResults;
         }
         //This is 50% to 150% faster than the old while (true) version that could keep rechecking the same random key over and over again.
         //Generate pick numbers for results.
         $pick = range(1, $nResults);
         //Shuffle the pick numbers.
         shuffle($pick);
         //Select pick numbers from the beginning to the maximum of $randomCount.
         $pick = array_slice($pick, 0, $randomCount);
     }
     $articles = [];
     /**********************/
     /* Article Processing */
     /**********************/
     $i = 0;
     while ($row = $result->fetchRow()) {
         $i++;
         //In random mode skip articles which were not chosen.
         if ($randomCount > 0 && !in_array($i, $pick)) {
             continue;
         }
         if ($this->parameters->getParameter('goal') == 'categories') {
             $pageNamespace = NS_CATEGORY;
             $pageTitle = $row['cl_to'];
         } elseif ($this->parameters->getParameter('openreferences')) {
             if (count($this->parameters->getParameter('imagecontainer')) > 0) {
                 $pageNamespace = NS_FILE;
                 $pageTitle = $row['il_to'];
             } else {
                 //Maybe non-existing title
                 $pageNamespace = $row['pl_namespace'];
                 $pageTitle = $row['pl_title'];
             }
         } else {
             //Existing PAGE TITLE
             $pageNamespace = $row['page_namespace'];
             $pageTitle = $row['page_title'];
         }
         // if subpages are to be excluded: skip them
         if (!$this->parameters->getParameter('includesubpages') && strpos($pageTitle, '/') !== false) {
             continue;
         }
         $title = \Title::makeTitle($pageNamespace, $pageTitle);
         $thisTitle = $this->parser->getTitle();
         //Block recursion from happening by seeing if this result row is the page the DPL query was ran from.
         if ($this->parameters->getParameter('skipthispage') && $thisTitle->equals($title)) {
             continue;
         }
         $articles[] = Article::newFromRow($row, $this->parameters, $title, $pageNamespace, $pageTitle);
     }
     $this->DB->freeResult($result);
     return $articles;
 }
Example #24
0
/**
 * puts out a row in the edit album table
 *
 * @param object $album is the album being emitted
 * @param bool $show_thumb set to false to show thumb standin image rather than album thumb
 * @param object $owner the parent album (or NULL for gallery)
 *
 * */
function printAlbumEditRow($album, $show_thumb, $owner)
{
    global $_zp_current_admin_obj;
    $enableEdit = $album->subRights() & MANAGED_OBJECT_RIGHTS_EDIT;
    if (is_object($owner)) {
        $owner = $owner->name;
    }
    ?>
		<div class='page-list_row'>

			<div class="page-list_albumthumb">
				<?php 
    if ($show_thumb) {
        $thumbimage = $album->getAlbumThumbImage();
        $thumb = getAdminThumb($thumbimage, 'small');
    } else {
        $thumb = 'images/thumb_standin.png';
    }
    if ($enableEdit) {
        ?>
					<a href="?page=edit&amp;album=<?php 
        echo html_encode(pathurlencode($album->name));
        ?>
" title="<?php 
        echo sprintf(gettext('Edit this album: %s'), $album->name);
        ?>
">
						<?php 
    }
    ?>
					<img src="<?php 
    echo html_encode(pathurlencode($thumb));
    ?>
" width="<?php 
    echo ADMIN_THUMB_SMALL;
    ?>
" height="<?php 
    echo ADMIN_THUMB_SMALL;
    ?>
" alt="" title="album thumb" />
					<?php 
    if ($enableEdit) {
        ?>
					</a>
					<?php 
    }
    ?>
			</div>
			<div class="page-list_albumtitle">
				<?php 
    if ($enableEdit) {
        ?>
					<a href="?page=edit&amp;album=<?php 
        echo html_encode(pathurlencode($album->name));
        ?>
" title="<?php 
        echo sprintf(gettext('Edit this album: %s'), $album->name);
        ?>
">
						<?php 
    }
    echo html_encode(getBare($album->getTitle()));
    if ($enableEdit) {
        ?>
					</a>
					<?php 
    }
    ?>
			</div>
			<?php 
    if ($album->isDynamic()) {
        $imgi = '<img src="images/pictures_dn.png" alt="" title="' . gettext('images') . '" />';
        $imga = '<img src="images/folder_picture_dn.png" alt="" title="' . gettext('albums') . '" />';
    } else {
        $imgi = '<img src="images/pictures.png" alt="" title="' . gettext('images') . '" />';
        $imga = '<img src="images/folder_picture.png" alt="" title="' . gettext('albums') . '" />';
    }
    $ci = count($album->getImages());
    $si = sprintf('%1$s <span>(%2$u)</span>', $imgi, $ci);
    if ($ci > 0 && !$album->isDynamic()) {
        $si = '<a href="?page=edit&amp;album=' . html_encode(pathurlencode($album->name)) . '&amp;tab=imageinfo" title="' . gettext('Subalbum List') . '">' . $si . '</a>';
    }
    $ca = $album->getNumAlbums();
    $sa = sprintf('%1$s <span>(%2$u)</span>', $imga, $ca);
    if ($ca > 0 && !$album->isDynamic()) {
        $sa = '<a href="?page=edit&amp;album=' . html_encode(pathurlencode($album->name)) . '&amp;tab=subalbuminfo" title="' . gettext('Subalbum List') . '">' . $sa . '</a>';
    }
    ?>
			<div class="page-list_extra">
				<?php 
    echo $sa;
    ?>
			</div>
			<div class="page-list_extra">
				<?php 
    echo $si;
    ?>
			</div>
			<?php 
    $wide = '40px';
    ?>
			<div class="page-list_iconwrapperalbum">
				<div class="page-list_icon">
					<?php 
    $pwd = $album->getPassword();
    if (!empty($pwd)) {
        echo '<a title="' . gettext('Password protected') . '"><img src="images/lock.png" style="border: 0px;" alt="" title="' . gettext('Password protected') . '" /></a>';
    }
    ?>
				</div>
				<div class="page-list_icon">
					<?php 
    echo linkPickerIcon($album);
    ?>
				</div>
				<div class="page-list_icon">
					<?php 
    if ($album->getShow()) {
        if ($enableEdit) {
            ?>
							<a href="?action=publish&amp;value=0&amp;album=<?php 
            echo html_encode(pathurlencode($album->name));
            ?>
&amp;return=*<?php 
            echo html_encode(pathurlencode($owner));
            ?>
&amp;XSRFToken=<?php 
            echo getXSRFToken('albumedit');
            ?>
" title="<?php 
            echo sprintf(gettext('Un-publish the album %s'), $album->name);
            ?>
" >
								<?php 
        }
        ?>
							<img src="images/pass.png" style="border: 0px;" alt="" title="<?php 
        echo gettext('Published');
        ?>
" />
							<?php 
        if ($enableEdit) {
            ?>
							</a>
							<?php 
        }
    } else {
        if ($enableEdit) {
            ?>
							<a href="?action=publish&amp;value=1&amp;album=<?php 
            echo html_encode(pathurlencode($album->name));
            ?>
&amp;return=*<?php 
            echo html_encode(pathurlencode($owner));
            ?>
&amp;XSRFToken=<?php 
            echo getXSRFToken('albumedit');
            ?>
" title="<?php 
            echo sprintf(gettext('Publish the album %s'), $album->name);
            ?>
">
								<?php 
        }
        if ($album->getPublishDate() > date('Y-m-d H:i:s')) {
            ?>
								<img src="images/clock.png" alt="<?php 
            echo gettext("Un-published");
            ?>
" title= "<?php 
            echo gettext("Publish (override scheduling)");
            ?>
" />
								<?php 
        } else {
            ?>
								<img src="images/action.png" style="border: 0px;" alt="" title="<?php 
            echo sprintf(gettext('Unpublished'), $album->name);
            ?>
" />
								<?php 
        }
        if ($enableEdit) {
            ?>
							</a>
							<?php 
        }
    }
    ?>
				</div>
				<div class="page-list_icon">
					<?php 
    if ($album->getCommentsAllowed()) {
        if ($enableEdit) {
            ?>
							<a href="?action=comments&amp;commentson=0&amp;album=<?php 
            echo html_encode($album->getFileName());
            ?>
&amp;return=*<?php 
            echo html_encode(pathurlencode($owner));
            ?>
&amp;XSRFToken=<?php 
            echo getXSRFToken('albumedit');
            ?>
" title="<?php 
            echo gettext('Disable comments');
            ?>
">
								<?php 
        }
        ?>
							<img src="images/comments-on.png" alt="" title="<?php 
        echo gettext("Comments on");
        ?>
" style="border: 0px;"/>
							<?php 
        if ($enableEdit) {
            ?>
							</a>
							<?php 
        }
    } else {
        if ($enableEdit) {
            ?>
							<a href="?action=comments&amp;commentson=1&amp;album=<?php 
            echo html_encode($album->getFileName());
            ?>
&amp;return=*<?php 
            echo html_encode(pathurlencode($owner));
            ?>
&amp;XSRFToken=<?php 
            echo getXSRFToken('albumedit');
            ?>
" title="<?php 
            echo gettext('Enable comments');
            ?>
">
								<?php 
        }
        ?>
							<img src="images/comments-off.png" alt="" title="<?php 
        echo gettext("Comments off");
        ?>
" style="border: 0px;"/>
							<?php 
        if ($enableEdit) {
            ?>
							</a>
							<?php 
        }
    }
    ?>
				</div>
				<div class="page-list_icon">
					<a href="<?php 
    echo WEBPATH;
    ?>
/index.php?album=<?php 
    echo html_encode(pathurlencode($album->name));
    ?>
" title="<?php 
    echo gettext("View album");
    ?>
">
						<img src="images/view.png" style="border: 0px;" alt="" title="<?php 
    echo sprintf(gettext('View album %s'), $album->name);
    ?>
" />
					</a>
				</div>
				<div class="page-list_icon">
					<?php 
    if ($album->isDynamic() || !$enableEdit) {
        ?>
						<img src="images/icon_inactive.png" style="border: 0px;" alt="" title="<?php 
        echo gettext('unavailable');
        ?>
" />
						<?php 
    } else {
        ?>
						<a class="warn" href="admin-refresh-metadata.php?page=edit&amp;album=<?php 
        echo html_encode(pathurlencode($album->name));
        ?>
&amp;return=*<?php 
        echo html_encode(pathurlencode($owner));
        ?>
&amp;XSRFToken=<?php 
        echo getXSRFToken('refresh');
        ?>
" title="<?php 
        echo sprintf(gettext('Refresh metadata for the album %s'), $album->name);
        ?>
">
							<img src="images/refresh.png" style="border: 0px;" alt="" title="<?php 
        echo sprintf(gettext('Refresh metadata in the album %s'), $album->name);
        ?>
" />
						</a>
						<?php 
    }
    ?>
				</div>
				<?php 
    if (extensionEnabled('hitcounter')) {
        ?>
					<div class="page-list_icon">
						<?php 
        if (!$enableEdit) {
            ?>
							<img src="images/icon_inactive.png" style="border: 0px;" alt="" title="<?php 
            echo gettext('unavailable');
            ?>
" />
							<?php 
        } else {
            ?>
							<a class="reset" href="?action=reset_hitcounters&amp;albumid=<?php 
            echo $album->getID();
            ?>
&amp;album=<?php 
            echo html_encode(pathurlencode($album->name));
            ?>
&amp;subalbum=true&amp;return=*<?php 
            echo html_encode(pathurlencode($owner));
            ?>
&amp;XSRFToken=<?php 
            echo getXSRFToken('hitcounter');
            ?>
" title="<?php 
            echo sprintf(gettext('Reset hit counters for album %s'), $album->name);
            ?>
">
								<img src="images/reset.png" style="border: 0px;" alt="" title="<?php 
            echo sprintf(gettext('Reset hit counters for the album %s'), $album->name);
            ?>
" />
							</a>
							<?php 
        }
        ?>
					</div>
					<?php 
    }
    ?>
				<div class="page-list_icon">
					<?php 
    $myalbum = $_zp_current_admin_obj->getAlbum();
    $supress = !zp_loggedin(MANAGE_ALL_ALBUM_RIGHTS) && $myalbum && $album->getID() == $myalbum->getID();
    if (!$enableEdit || $supress) {
        ?>
						<img src="images/icon_inactive.png" style="border: 0px;" alt="" title="<?php 
        echo gettext('unavailable');
        ?>
" />
						<?php 
    } else {
        ?>
						<a class="delete" href="javascript:confirmDeleteAlbum('?page=edit&amp;action=deletealbum&amp;album=<?php 
        echo urlencode(pathurlencode($album->name));
        ?>
&amp;return=<?php 
        echo html_encode(pathurlencode($owner));
        ?>
&amp;XSRFToken=<?php 
        echo getXSRFToken('delete');
        ?>
');" title="<?php 
        echo sprintf(gettext("Delete the album %s"), js_encode($album->name));
        ?>
">
							<img src="images/fail.png" style="border: 0px;" alt="" title="<?php 
        echo sprintf(gettext('Delete the album %s'), js_encode($album->name));
        ?>
" />
						</a>
						<?php 
    }
    ?>
				</div>
				<?php 
    if ($enableEdit) {
        ?>
					<div class="page-list_icon">
						<input class="checkbox" type="checkbox" name="ids[]" value="<?php 
        echo $album->getFileName();
        ?>
" onclick="triggerAllBox(this.form, 'ids[]', this.form.allbox);" <?php 
        if ($supress) {
            echo ' disabled="disabled"';
        }
        ?>
 />
					</div>
					<?php 
    }
    ?>
			</div>
		</div>
		<?php 
}
 /**
  * Creates a question from a QTI file
  *
  * Receives parameters from a QTI parser and creates a valid ILIAS question object
  *
  * @param object $item The QTI item object
  * @param integer $questionpool_id The id of the parent questionpool
  * @param integer $tst_id The id of the parent test if the question is part of a test
  * @param object $tst_object A reference to the parent test object
  * @param integer $question_counter A reference to a question counter to count the questions of an imported question pool
  * @param array $import_mapping An array containing references to included ILIAS objects
  * @access public
  */
 function fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
 {
     global $ilUser;
     // empty session variable for imported xhtml mobs
     unset($_SESSION["import_mob_xhtml"]);
     $presentation = $item->getPresentation();
     $duration = $item->getDuration();
     $now = getdate();
     $applet = NULL;
     $maxpoints = 0;
     $javacode = "";
     $javacodebase = "";
     $javaarchive = "";
     $params = array();
     $created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
     $answers = array();
     foreach ($presentation->order as $entry) {
         switch ($entry["type"]) {
             case "material":
                 $material = $presentation->material[$entry["index"]];
                 for ($i = 0; $i < $material->getMaterialCount(); $i++) {
                     $mat = $material->getMaterial($i);
                     if (strcmp($mat["type"], "mattext") == 0) {
                         $mattext = $mat["material"];
                         if (strlen($mattext->getLabel()) == 0 && strlen($this->object->QTIMaterialToString($item->getQuestiontext())) == 0) {
                             $item->setQuestiontext($mattext->getContent());
                         }
                         if (strcmp($mattext->getLabel(), "points") == 0) {
                             $maxpoints = $mattext->getContent();
                         } else {
                             if (strcmp($mattext->getLabel(), "java_code") == 0) {
                                 $javacode = $mattext->getContent();
                             } else {
                                 if (strcmp($mattext->getLabel(), "java_codebase") == 0) {
                                     $javacodebase = $mattext->getContent();
                                 } else {
                                     if (strcmp($mattext->getLabel(), "java_archive") == 0) {
                                         $javaarchive = $mattext->getContent();
                                     } else {
                                         if (strlen($mattext->getLabel()) > 0) {
                                             array_push($params, array("key" => $mattext->getLabel(), "value" => $mattext->getContent()));
                                         }
                                     }
                                 }
                             }
                         }
                     } elseif (strcmp($mat["type"], "matapplet") == 0) {
                         $applet = $mat["material"];
                     }
                 }
                 break;
         }
     }
     $feedbacksgeneric = array();
     foreach ($item->resprocessing as $resprocessing) {
         foreach ($resprocessing->respcondition as $respcondition) {
             foreach ($respcondition->displayfeedback as $feedbackpointer) {
                 if (strlen($feedbackpointer->getLinkrefid())) {
                     foreach ($item->itemfeedback as $ifb) {
                         if (strcmp($ifb->getIdent(), "response_allcorrect") == 0) {
                             // found a feedback for the identifier
                             if (count($ifb->material)) {
                                 foreach ($ifb->material as $material) {
                                     $feedbacksgeneric[1] = $material;
                                 }
                             }
                             if (count($ifb->flow_mat) > 0) {
                                 foreach ($ifb->flow_mat as $fmat) {
                                     if (count($fmat->material)) {
                                         foreach ($fmat->material as $material) {
                                             $feedbacksgeneric[1] = $material;
                                         }
                                     }
                                 }
                             }
                         } else {
                             if (strcmp($ifb->getIdent(), "response_onenotcorrect") == 0) {
                                 // found a feedback for the identifier
                                 if (count($ifb->material)) {
                                     foreach ($ifb->material as $material) {
                                         $feedbacksgeneric[0] = $material;
                                     }
                                 }
                                 if (count($ifb->flow_mat) > 0) {
                                     foreach ($ifb->flow_mat as $fmat) {
                                         if (count($fmat->material)) {
                                             foreach ($fmat->material as $material) {
                                                 $feedbacksgeneric[0] = $material;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $this->object->setTitle($item->getTitle());
     $this->object->setNrOfTries($item->getMaxattempts());
     $this->object->setComment($item->getComment());
     $this->object->setAuthor($item->getAuthor());
     $this->object->setOwner($ilUser->getId());
     $this->object->setQuestion($this->object->QTIMaterialToString($item->getQuestiontext()));
     $this->object->setObjId($questionpool_id);
     $this->object->setEstimatedWorkingTime($duration["h"], $duration["m"], $duration["s"]);
     $this->object->setJavaAppletFilename($applet->getUri());
     $this->object->setJavaWidth($applet->getWidth());
     $this->object->setJavaHeight($applet->getHeight());
     $this->object->setJavaCode($javacode);
     $this->object->setJavaCodebase($javacodebase);
     $this->object->setJavaArchive($javaarchive);
     $this->object->setPoints($maxpoints);
     foreach ($params as $pair) {
         $this->object->addParameter($pair["key"], $pair["value"]);
     }
     $this->object->saveToDb();
     if (count($item->suggested_solutions)) {
         foreach ($item->suggested_solutions as $suggested_solution) {
             $this->object->setSuggestedSolution($suggested_solution["solution"]->getContent(), $suggested_solution["gap_index"], true);
         }
         $this->object->saveToDb();
     }
     $javaapplet =& base64_decode($applet->getContent());
     $javapath = $this->object->getJavaPath();
     if (!file_exists($javapath)) {
         include_once "./Services/Utilities/classes/class.ilUtil.php";
         ilUtil::makeDirParents($javapath);
     }
     $javapath .= $this->object->getJavaAppletFilename();
     $fh = fopen($javapath, "wb");
     if ($fh == false) {
         //									global $ilErr;
         //									$ilErr->raiseError($this->object->lng->txt("error_save_image_file") . ": $php_errormsg", $ilErr->MESSAGE);
         //									return;
     } else {
         $javafile = fwrite($fh, $javaapplet);
         fclose($fh);
     }
     // handle the import of media objects in XHTML code
     foreach ($feedbacksgeneric as $correctness => $material) {
         $m = $this->object->QTIMaterialToString($material);
         $feedbacksgeneric[$correctness] = $m;
     }
     $questiontext = $this->object->getQuestion();
     if (is_array($_SESSION["import_mob_xhtml"])) {
         include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
         include_once "./Services/RTE/classes/class.ilRTE.php";
         foreach ($_SESSION["import_mob_xhtml"] as $mob) {
             if ($tst_id > 0) {
                 $importfile = $this->getTstImportArchivDirectory() . '/' . $mob["uri"];
             } else {
                 $importfile = $this->getQplImportArchivDirectory() . '/' . $mob["uri"];
             }
             $GLOBALS['ilLog']->write(__METHOD__ . ': import mob from dir: ' . $importfile);
             $media_object =& ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, FALSE);
             ilObjMediaObject::_saveUsage($media_object->getId(), "qpl:html", $this->object->getId());
             $questiontext = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $questiontext);
             foreach ($feedbacksgeneric as $correctness => $material) {
                 $feedbacksgeneric[$correctness] = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $material);
             }
         }
     }
     $this->object->setQuestion(ilRTE::_replaceMediaObjectImageSrc($questiontext, 1));
     foreach ($feedbacksgeneric as $correctness => $material) {
         $this->object->saveFeedbackGeneric($correctness, ilRTE::_replaceMediaObjectImageSrc($material, 1));
     }
     $this->object->saveToDb();
     if ($tst_id > 0) {
         $q_1_id = $this->object->getId();
         $question_id = $this->object->duplicate(true, null, null, null, $tst_id);
         $tst_object->questions[$question_counter++] = $question_id;
         $import_mapping[$item->getIdent()] = array("pool" => $q_1_id, "test" => $question_id);
     } else {
         $import_mapping[$item->getIdent()] = array("pool" => $this->object->getId(), "test" => 0);
     }
 }
 /**
  * Creates a question from a QTI file
  *
  * Receives parameters from a QTI parser and creates a valid ILIAS question object
  *
  * @param object $item The QTI item object
  * @param integer $questionpool_id The id of the parent questionpool
  * @param integer $tst_id The id of the parent test if the question is part of a test
  * @param object $tst_object A reference to the parent test object
  * @param integer $question_counter A reference to a question counter to count the questions of an imported question pool
  * @param array $import_mapping An array containing references to included ILIAS objects
  * @access public
  */
 function fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
 {
     global $ilUser;
     // empty session variable for imported xhtml mobs
     unset($_SESSION["import_mob_xhtml"]);
     $presentation = $item->getPresentation();
     $duration = $item->getDuration();
     $shuffle = 0;
     $idents = array();
     $now = getdate();
     $created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
     $gaps = array();
     foreach ($presentation->order as $entry) {
         switch ($entry["type"]) {
             case "response":
                 $response = $presentation->response[$entry["index"]];
                 if ($response->getResponseType() == RT_RESPONSE_STR) {
                     array_push($idents, $response->getIdent());
                 }
                 break;
         }
     }
     $responses = array();
     $feedbacksgeneric = array();
     foreach ($item->resprocessing as $resprocessing) {
         foreach ($resprocessing->respcondition as $respcondition) {
             $ident = "";
             $correctness = 1;
             $conditionvar = $respcondition->getConditionvar();
             foreach ($conditionvar->order as $order) {
                 switch ($order["field"]) {
                     case "varsubset":
                         $respident = $conditionvar->varsubset[$order["index"]]->getRespident();
                         $content = $conditionvar->varsubset[$order["index"]]->getContent();
                         if (!is_array($responses[$respident])) {
                             $responses[$respident] = array();
                         }
                         $vars = split(",", $content);
                         foreach ($vars as $var) {
                             array_push($responses[$respident], array("solution" => $var, "points" => ""));
                         }
                         break;
                 }
             }
             foreach ($respcondition->setvar as $setvar) {
                 if (strcmp($setvar->getVarname(), "matches") == 0 && $setvar->getAction() == ACTION_ADD) {
                     foreach ($responses[$respident] as $idx => $solutionarray) {
                         if (strlen($solutionarray["points"] == 0)) {
                             $responses[$respident][$idx]["points"] = $setvar->getContent();
                         }
                     }
                 }
             }
             foreach ($resprocessing->respcondition as $respcondition) {
                 foreach ($respcondition->displayfeedback as $feedbackpointer) {
                     if (strlen($feedbackpointer->getLinkrefid())) {
                         foreach ($item->itemfeedback as $ifb) {
                             if (strcmp($ifb->getIdent(), "response_allcorrect") == 0) {
                                 // found a feedback for the identifier
                                 if (count($ifb->material)) {
                                     foreach ($ifb->material as $material) {
                                         $feedbacksgeneric[1] = $material;
                                     }
                                 }
                                 if (count($ifb->flow_mat) > 0) {
                                     foreach ($ifb->flow_mat as $fmat) {
                                         if (count($fmat->material)) {
                                             foreach ($fmat->material as $material) {
                                                 $feedbacksgeneric[1] = $material;
                                             }
                                         }
                                     }
                                 }
                             } else {
                                 if (strcmp($ifb->getIdent(), "response_onenotcorrect") == 0) {
                                     // found a feedback for the identifier
                                     if (count($ifb->material)) {
                                         foreach ($ifb->material as $material) {
                                             $feedbacksgeneric[0] = $material;
                                         }
                                     }
                                     if (count($ifb->flow_mat) > 0) {
                                         foreach ($ifb->flow_mat as $fmat) {
                                             if (count($fmat->material)) {
                                                 foreach ($fmat->material as $material) {
                                                     $feedbacksgeneric[0] = $material;
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $this->object->setTitle($item->getTitle());
     $this->object->setNrOfTries($item->getMaxattempts());
     $this->object->setComment($item->getComment());
     $this->object->setAuthor($item->getAuthor());
     $this->object->setOwner($ilUser->getId());
     $this->object->setQuestion($this->object->QTIMaterialToString($item->getQuestiontext()));
     $this->object->setObjId($questionpool_id);
     $this->object->setEstimatedWorkingTime($duration["h"], $duration["m"], $duration["s"]);
     $textrating = $item->getMetadataEntry("textrating");
     if (strlen($textrating) == 0) {
         $textrating = "ci";
     }
     $this->object->setTextRating($textgap_rating);
     $this->object->setCorrectAnswers($item->getMetadataEntry("correctanswers"));
     $response = current($responses);
     $counter = 0;
     if (is_array($response)) {
         foreach ($response as $answer) {
             $this->object->addAnswer($answer["solution"], $answer["points"], $counter);
             $counter++;
         }
     }
     $this->object->saveToDb();
     if (count($item->suggested_solutions)) {
         foreach ($item->suggested_solutions as $suggested_solution) {
             $this->object->setSuggestedSolution($suggested_solution["solution"]->getContent(), $suggested_solution["gap_index"], true);
         }
         $this->object->saveToDb();
     }
     foreach ($feedbacksgeneric as $correctness => $material) {
         $m = $this->object->QTIMaterialToString($material);
         $feedbacksgeneric[$correctness] = $m;
     }
     // handle the import of media objects in XHTML code
     $questiontext = $this->object->getQuestion();
     if (is_array($_SESSION["import_mob_xhtml"])) {
         include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
         include_once "./Services/RTE/classes/class.ilRTE.php";
         foreach ($_SESSION["import_mob_xhtml"] as $mob) {
             if ($tst_id > 0) {
                 $importfile = $this->getTstImportArchivDirectory() . '/' . $mob["uri"];
             } else {
                 $importfile = $this->getQplImportArchivDirectory() . '/' . $mob["uri"];
             }
             $GLOBALS['ilLog']->write(__METHOD__ . ': import mob from dir: ' . $importfile);
             $media_object =& ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, FALSE);
             ilObjMediaObject::_saveUsage($media_object->getId(), "qpl:html", $this->object->getId());
             $questiontext = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $questiontext);
             foreach ($feedbacksgeneric as $correctness => $material) {
                 $feedbacksgeneric[$correctness] = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $material);
             }
         }
     }
     $this->object->setQuestion(ilRTE::_replaceMediaObjectImageSrc($questiontext, 1));
     foreach ($feedbacksgeneric as $correctness => $material) {
         $this->object->saveFeedbackGeneric($correctness, ilRTE::_replaceMediaObjectImageSrc($material, 1));
     }
     $this->object->saveToDb();
     if ($tst_id > 0) {
         $q_1_id = $this->object->getId();
         $question_id = $this->object->duplicate(true, null, null, null, $tst_id);
         $tst_object->questions[$question_counter++] = $question_id;
         $import_mapping[$item->getIdent()] = array("pool" => $q_1_id, "test" => $question_id);
     } else {
         $import_mapping[$item->getIdent()] = array("pool" => $this->object->getId(), "test" => 0);
     }
 }
Example #27
0
 /**
  * Additional tags for <head>
  *
  * @param object $oTopic
  *
  * @return array
  */
 protected function _getHeadTags($oTopic)
 {
     $aHeadTags = array();
     if (!$oTopic->getPublish()) {
         // Disable indexing of drafts
         $aHeadTags[] = array('meta', array('name' => 'robots', 'content' => 'noindex,nofollow'));
     } else {
         // Tags for social networks
         $aHeadTags[] = array('meta', array('property' => 'og:title', 'content' => $oTopic->getTitle()));
         $aHeadTags[] = array('meta', array('property' => 'og:url', 'content' => $oTopic->getUrl()));
         $aHeadTags[] = array('meta', array('property' => 'og:description', 'content' => E::ModuleViewer()->GetHtmlDescription()));
         $aHeadTags[] = array('meta', array('property' => 'og:site_name', 'content' => Config::Get('view.name')));
         $aHeadTags[] = array('meta', array('property' => 'og:type', 'content' => 'article'));
         $aHeadTags[] = array('meta', array('name' => 'twitter:card', 'content' => 'summary'));
         if ($oTopic->getPreviewImageUrl()) {
             $aHeadTags[] = array('meta', array('name' => 'og:image', 'content' => $oTopic->getPreviewImageUrl('700crop')));
         }
     }
     return $aHeadTags;
 }
Example #28
0
 /**
  * Gets the feed item data in a gallery feed
  *
  * @param object $item Object of an image or album
  * @return array
  */
 protected function getItemGallery($item)
 {
     if ($this->mode == "albums") {
         $albumobj = newAlbum($item['folder']);
         $totalimages = $albumobj->getNumImages();
         $itemlink = $this->host . $albumobj->getLink();
         $thumb = $albumobj->getAlbumThumbImage();
         $thumburl = '<img border="0" src="' . PROTOCOL . '://' . $this->host . html_encode(pathurlencode($thumb->getCustomImage($this->imagesize, NULL, NULL, NULL, NULL, NULL, NULL, TRUE))) . '" alt="' . html_encode($albumobj->getTitle($this->locale)) . '" />';
         $title = $albumobj->getTitle($this->locale);
         if (true || $this->sortorder == "latestupdated") {
             $filechangedate = filectime(ALBUM_FOLDER_SERVERPATH . internalToFilesystem($albumobj->name));
             $latestimage = query_single_row("SELECT mtime FROM " . prefix('images') . " WHERE albumid = " . $albumobj->getID() . " AND `show` = 1 ORDER BY id DESC");
             if ($latestimage && $this->sortorder == 'latestupdated') {
                 $count = db_count('images', "WHERE albumid = " . $albumobj->getID() . " AND mtime = " . $latestimage['mtime']);
             } else {
                 $count = $totalimages;
             }
             if ($count != 0) {
                 $imagenumber = sprintf(ngettext('%s (%u image)', '%s (%u images)', $count), $title, $count);
             } else {
                 $imagenumber = $title;
             }
             $feeditem['desc'] = '<a title="' . $title . '" href="' . PROTOCOL . '://' . $itemlink . '">' . $thumburl . '</a>' . '<p>' . html_encode($imagenumber) . '</p>' . $albumobj->getDesc($this->locale) . '<br />' . sprintf(gettext("Last update: %s"), zpFormattedDate(DATE_FORMAT, $filechangedate));
         } else {
             if ($totalimages != 0) {
                 $imagenumber = sprintf(ngettext('%s (%u image)', '%s (%u images)', $totalimages), $title, $totalimages);
             }
             $feeditem['desc'] = '<a title="' . html_encode($title) . '" href="' . PROTOCOL . '://' . $itemlink . '">' . $thumburl . '</a>' . $item->getDesc($this->locale) . '<br />' . sprintf(gettext("Date: %s"), zpFormattedDate(DATE_FORMAT, $item->get('mtime')));
         }
         $ext = getSuffix($thumb->localpath);
     } else {
         $ext = getSuffix($item->localpath);
         $albumobj = $item->getAlbum();
         $itemlink = $this->host . $item->getLink();
         $fullimagelink = $this->host . html_encode(pathurlencode($item->getFullImageURL()));
         $thumburl = '<img border="0" src="' . PROTOCOL . '://' . $this->host . html_encode(pathurlencode($item->getCustomImage($this->imagesize, NULL, NULL, NULL, NULL, NULL, NULL, TRUE))) . '" alt="' . $item->getTitle($this->locale) . '" /><br />';
         $title = $item->getTitle($this->locale);
         $albumtitle = $albumobj->getTitle($this->locale);
         $datecontent = '<br />Date: ' . zpFormattedDate(DATE_FORMAT, $item->get('mtime'));
         if ($ext == "flv" || $ext == "mp3" || $ext == "mp4" || $ext == "3gp" || $ext == "mov" and $this->mode != "album") {
             $feeditem['desc'] = '<a title="' . html_encode($title) . ' in ' . html_encode($albumobj->getTitle($this->locale)) . '" href="' . PROTOCOL . '://' . $itemlink . '">' . $thumburl . '</a>' . $item->getDesc($this->locale) . $datecontent;
         } else {
             $feeditem['desc'] = '<a title="' . html_encode($title) . ' in ' . html_encode($albumobj->getTitle($this->locale)) . '" href="' . PROTOCOL . '://' . $itemlink . '"><img src="' . PROTOCOL . '://' . $this->host . html_encode(pathurlencode($item->getCustomImage($this->imagesize, NULL, NULL, NULL, NULL, NULL, NULL, TRUE))) . '" alt="' . html_encode($title) . '" /></a>' . $item->getDesc($this->locale) . $datecontent;
         }
     }
     // title
     if ($this->mode != "albums") {
         $feeditem['title'] = sprintf('%1$s (%2$s)', $item->getTitle($this->locale), $albumobj->getTitle($this->locale));
     } else {
         $feeditem['title'] = $imagenumber;
     }
     //link
     $feeditem['link'] = PROTOCOL . '://' . $itemlink;
     // enclosure
     $feeditem['enclosure'] = '';
     if (getOption("RSS_enclosure") and $this->mode != "albums") {
         $feeditem['enclosure'] = '<enclosure url="' . PROTOCOL . '://' . $fullimagelink . '" type="' . getMimeString($ext) . '" length="' . filesize($item->localpath) . '" />';
     }
     //category
     if ($this->mode != "albums") {
         $feeditem['category'] = html_encode($albumobj->getTitle($this->locale));
     } else {
         $feeditem['category'] = html_encode($albumobj->getTitle($this->locale));
     }
     //media content
     $feeditem['media_content'] = '';
     $feeditem['media_thumbnail'] = '';
     if (getOption("RSS_mediarss") and $this->mode != "albums") {
         $feeditem['media_content'] = '<media:content url="' . PROTOCOL . '://' . $fullimagelink . '" type="image/jpeg" />';
         $feeditem['media_thumbnail'] = '<media:thumbnail url="' . PROTOCOL . '://' . $fullimagelink . '" width="' . $this->imagesize . '"	height="' . $this->imagesize . '" />';
     }
     //date
     if ($this->mode != "albums") {
         $feeditem['pubdate'] = date("r", strtotime($item->getDateTime()));
     } else {
         $feeditem['pubdate'] = date("r", strtotime($albumobj->getDateTime()));
     }
     return $feeditem;
 }
 /**
  * Creates a question from a QTI file
  *
  * Receives parameters from a QTI parser and creates a valid ILIAS question object
  *
  * @param object $item The QTI item object
  * @param integer $questionpool_id The id of the parent questionpool
  * @param integer $tst_id The id of the parent test if the question is part of a test
  * @param object $tst_object A reference to the parent test object
  * @param integer $question_counter A reference to a question counter to count the questions of an imported question pool
  * @param array $import_mapping An array containing references to included ILIAS objects
  * @access public
  */
 function fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
 {
     global $ilUser;
     // empty session variable for imported xhtml mobs
     unset($_SESSION["import_mob_xhtml"]);
     $presentation = $item->getPresentation();
     $duration = $item->getDuration();
     $now = getdate();
     $maxchars = 0;
     $points = 0;
     $upperlimit = 0;
     $lowerlimit = 0;
     $feedbacksgeneric = array();
     $created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
     foreach ($presentation->order as $entry) {
         switch ($entry["type"]) {
             case "response":
                 $response = $presentation->response[$entry["index"]];
                 $rendertype = $response->getRenderType();
                 switch (strtolower(get_class($rendertype))) {
                     case "ilqtirenderfib":
                         $maxchars = $rendertype->getMaxchars();
                         break;
                 }
                 break;
         }
     }
     foreach ($item->resprocessing as $resprocessing) {
         foreach ($resprocessing->respcondition as $respcondition) {
             $conditionvar = $respcondition->getConditionvar();
             foreach ($conditionvar->order as $order) {
                 switch ($order["field"]) {
                     case "varlte":
                         $upperlimit = $conditionvar->varlte[$order["index"]]->getContent();
                         break;
                     case "vargte":
                         $lowerlimit = $conditionvar->vargte[$order["index"]]->getContent();
                         break;
                 }
             }
             foreach ($respcondition->setvar as $setvar) {
                 $points = $setvar->getContent();
             }
             if (count($respcondition->displayfeedback)) {
                 foreach ($respcondition->displayfeedback as $feedbackpointer) {
                     if (strlen($feedbackpointer->getLinkrefid())) {
                         foreach ($item->itemfeedback as $ifb) {
                             if (strcmp($ifb->getIdent(), "response_allcorrect") == 0) {
                                 // found a feedback for the identifier
                                 if (count($ifb->material)) {
                                     foreach ($ifb->material as $material) {
                                         $feedbacksgeneric[1] = $material;
                                     }
                                 }
                                 if (count($ifb->flow_mat) > 0) {
                                     foreach ($ifb->flow_mat as $fmat) {
                                         if (count($fmat->material)) {
                                             foreach ($fmat->material as $material) {
                                                 $feedbacksgeneric[1] = $material;
                                             }
                                         }
                                     }
                                 }
                             } else {
                                 if (strcmp($ifb->getIdent(), "response_onenotcorrect") == 0) {
                                     // found a feedback for the identifier
                                     if (count($ifb->material)) {
                                         foreach ($ifb->material as $material) {
                                             $feedbacksgeneric[0] = $material;
                                         }
                                     }
                                     if (count($ifb->flow_mat) > 0) {
                                         foreach ($ifb->flow_mat as $fmat) {
                                             if (count($fmat->material)) {
                                                 foreach ($fmat->material as $material) {
                                                     $feedbacksgeneric[0] = $material;
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $this->object->setTitle($item->getTitle());
     $this->object->setNrOfTries($item->getMaxattempts());
     $this->object->setComment($item->getComment());
     $this->object->setAuthor($item->getAuthor());
     $this->object->setOwner($ilUser->getId());
     $this->object->setQuestion($this->object->QTIMaterialToString($item->getQuestiontext()));
     $this->object->setObjId($questionpool_id);
     $this->object->setEstimatedWorkingTime($duration["h"], $duration["m"], $duration["s"]);
     $this->object->setMaxChars($maxchars);
     $this->object->setPoints($points);
     $this->object->setLowerLimit($lowerlimit);
     $this->object->setUpperLimit($upperlimit);
     $this->object->saveToDb();
     if (count($item->suggested_solutions)) {
         foreach ($item->suggested_solutions as $suggested_solution) {
             $this->object->setSuggestedSolution($suggested_solution["solution"]->getContent(), $suggested_solution["gap_index"], true);
         }
         $this->object->saveToDb();
     }
     foreach ($feedbacksgeneric as $correctness => $material) {
         $m = $this->object->QTIMaterialToString($material);
         $feedbacksgeneric[$correctness] = $m;
     }
     // handle the import of media objects in XHTML code
     $questiontext = $this->object->getQuestion();
     if (is_array($_SESSION["import_mob_xhtml"])) {
         include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
         include_once "./Services/RTE/classes/class.ilRTE.php";
         foreach ($_SESSION["import_mob_xhtml"] as $mob) {
             if ($tst_id > 0) {
                 $importfile = $this->getTstImportArchivDirectory() . '/' . $mob["uri"];
             } else {
                 $importfile = $this->getQplImportArchivDirectory() . '/' . $mob["uri"];
             }
             $GLOBALS['ilLog']->write(__METHOD__ . ': import mob from dir: ' . $importfile);
             $media_object =& ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, FALSE);
             ilObjMediaObject::_saveUsage($media_object->getId(), "qpl:html", $this->object->getId());
             $questiontext = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $questiontext);
             foreach ($feedbacksgeneric as $correctness => $material) {
                 $feedbacksgeneric[$correctness] = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $material);
             }
         }
     }
     $this->object->setQuestion(ilRTE::_replaceMediaObjectImageSrc($questiontext, 1));
     foreach ($feedbacksgeneric as $correctness => $material) {
         $this->object->saveFeedbackGeneric($correctness, ilRTE::_replaceMediaObjectImageSrc($material, 1));
     }
     $this->object->saveToDb();
     if ($tst_id > 0) {
         $q_1_id = $this->object->getId();
         $question_id = $this->object->duplicate(true, null, null, null, $tst_id);
         $tst_object->questions[$question_counter++] = $question_id;
         $import_mapping[$item->getIdent()] = array("pool" => $q_1_id, "test" => $question_id);
     } else {
         $import_mapping[$item->getIdent()] = array("pool" => $this->object->getId(), "test" => 0);
     }
 }
Example #30
0
 /**
  * Render meta page (description/objectives at beginning)
  *
  * @param object $a_tpl template
  * @param object $a_sco SCO
  * @param string $a_asset_type asset type
  * @param string $a_mode mode
  */
 static function renderMetaPage($a_tpl, $a_sco, $a_asset_type = "", $mode = "")
 {
     global $lng;
     if ($a_sco->getType() != "sco" || $a_sco->getHideObjectivePage()) {
         return;
     }
     if ($a_asset_type != "entry_asset" && $a_asset_type != "final_asset") {
         $meta = new ilMD($a_sco->getSLMId(), $a_sco->getId(), $a_sco->getType());
         $desc_ids = $meta->getGeneral()->getDescriptionIds();
         $sco_description = $meta->getGeneral()->getDescription($desc_ids[0])->getDescription();
     }
     if ($mode != 'pdf') {
         // title
         if ($a_asset_type != "entry_asset" && $a_asset_type != "final_asset") {
             $a_tpl->setCurrentBlock("title");
             $a_tpl->setVariable("SCO_TITLE", $a_sco->getTitle());
             $a_tpl->parseCurrentBlock();
         }
     } else {
         // title
         $a_tpl->setCurrentBlock("pdf_title");
         $a_tpl->setVariable("SCO_TITLE", $a_sco->getTitle());
         $a_tpl->parseCurrentBlock();
         $a_tpl->touchBlock("pdf_break");
     }
     // sco description
     if (trim($sco_description) != "") {
         $a_tpl->setCurrentBlock("sco_desc");
         $a_tpl->setVariable("TXT_DESC", $lng->txt("description"));
         include_once "./Services/COPage/classes/class.ilPCParagraph.php";
         $a_tpl->setVariable("VAL_DESC", self::convertLists($sco_description));
         $a_tpl->parseCurrentBlock();
     }
     if ($a_asset_type == "sco") {
         // sco objective(s)
         $objs = $a_sco->getObjectives();
         if (count($objs) > 0) {
             foreach ($objs as $objective) {
                 $a_tpl->setCurrentBlock("sco_obj");
                 $a_tpl->setVariable("VAL_OBJECTIVE", self::convertLists($objective->getObjectiveID()));
                 $a_tpl->parseCurrentBlock();
             }
             $a_tpl->setCurrentBlock("sco_objs");
             $a_tpl->setVariable("TXT_OBJECTIVES", $lng->txt("sahs_objectives"));
             $a_tpl->parseCurrentBlock();
         }
     }
     $a_tpl->setCurrentBlock("meta_page");
     $a_tpl->parseCurrentBlock();
 }