/** * @param string The URL option */ function showInstalledComponents($option) { global $database, $mosConfig_absolute_path; $database->setQuery("SELECT *" . "\n FROM #__components" . "\n WHERE parent = 0 AND iscore = 0" . "\n ORDER BY name"); $rows = $database->loadObjectList(); // Read the component dir to find components $componentBaseDir = mosPathName($mosConfig_absolute_path . '/administrator/components'); $componentDirs = mosReadDirectory($componentBaseDir); $n = count($rows); for ($i = 0; $i < $n; $i++) { $row =& $rows[$i]; $dirName = mosPathName($componentBaseDir . $row->option); $xmlFilesInDir = mosReadDirectory($dirName, '.xml$'); foreach ($xmlFilesInDir as $xmlfile) { // Read the file to see if it's a valid component XML file $parser =& new mosXMLDescription($dirName . $xmlfile); if ($parser->getType() != 'component') { continue; } $row->creationdate = $parser->getCreationDate('component'); $row->author = $parser->getAuthor('component'); $row->copyright = $parser->getCopyright('component'); $row->authorEmail = $parser->getAuthorEmail('component'); $row->authorUrl = $parser->getAuthorUrl('component'); $row->version = $parser->getVersion('component'); $row->mosname = strtolower(str_replace(" ", "_", $row->name)); } } HTML_component::showInstalledComponents($rows, $option); }
function mosReadDirectory($path, $filter = '.', $recurse = false, $fullpath = false) { $arr = array(); if (!@is_dir($path)) { return $arr; } $handle = opendir($path); while ($file = readdir($handle)) { $dir = mosPathName($path . '/' . $file, false); $isDir = is_dir($dir); if ($file != "." && $file != "..") { if (preg_match("/{$filter}/", $file)) { if ($fullpath) { $arr[] = trim(mosPathName($path . '/' . $file, false)); } else { $arr[] = trim($file); } } if ($recurse && $isDir) { $arr2 = mosReadDirectory($dir, $filter, $recurse, $fullpath); $arr = array_merge($arr, $arr2); } } } closedir($handle); asort($arr); return $arr; }
function render(&$renderer, &$request) { $rows = array(); $languageDir = mamboCore::get('mosConfig_absolute_path') . "/language/"; $xmlFilesInDir = mosReadDirectory($languageDir, '.xml$'); $rowid = 0; foreach ($xmlFilesInDir as $xmlfile) { // Read the file to see if it's a valid template XML file $parser =& new mosXMLDescription($languageDir . $xmlfile); if ($parser->getType() != 'language') { continue; } $row = new StdClass(); $row->id = $rowid; $row->language = substr($xmlfile, 0, -4); $row->name = $parser->getName('language'); $row->creationdate = $parser->getCreationDate('language'); $row->author = $parser->getAuthor('language'); $row->copyright = $parser->getCopyright('language'); $row->authorEmail = $parser->getAuthorEmail('language'); $row->authorUrl = $parser->getAuthorUrl('language'); $row->version = $parser->getVersion('language'); $row->checked_out = 0; $row->mosname = strtolower(str_replace(" ", "_", $row->name)); $row->published = mamboCore::get('mosConfig_locale') == $row->language ? 1 : 0; $rows[] = $row; $rowid++; } $renderer->addvar('rows', $rows); $renderer->addvar('content', $renderer->fetch('table.tpl.php')); $renderer->display('form.tpl.php'); }
/** * Process any legacy bots in the /mambots directory * * THIS FILE CAN BE **SAFELY REMOVED** IF YOU HAVE NO LEGACY MAMBOTS * @param object A content object * @param int A bit-wise mask of options * @param int The page number */ function botLegacyBots($published, &$row, &$params, $page = 0) { global $mosConfig_absolute_path; // process any legacy bots $bots = mosReadDirectory("{$mosConfig_absolute_path}/mambots", "\\.php\$"); sort($bots); foreach ($bots as $bot) { require "mambots/{$bot}"; } }
function createLanguage($iso639, $iso3166, $iso3166_3) { $locales = mamboLanguage::getLocales(); $default = $locales['locales'][$iso639]; $lang = $iso639; $lang .= strlen($iso3166) == 2 ? '_' . $iso3166 : ''; $language =& new mamboLanguage($lang); foreach ($default as $k => $v) { if (in_array($k, array_keys(get_class_vars(get_class($language))))) { $language->{$k} = $v; } } foreach ($_POST as $k => $v) { if (in_array($k, array_keys(get_class_vars(get_class($language))))) { $language->{$k} = $v; } } $language->name = $lang; $language->description = $language->title . ' Locale'; if (!empty($language->territory)) { $language->description .= ' For ' . $language->territory; } $language->locale = $lang . '.' . $language->charset . ',' . $lang . ',' . $iso639 . ',' . strtolower($language->title); $language->iso3166_3 = $iso3166_3; $language->creationdate = date('d-m-Y'); $language->author = 'Mambo Foundation Inc.'; $language->authorurl = 'http://www.mambo-foundation.org'; $language->authoremail = '*****@*****.**'; $language->copyright = 'Refer to copyright.php'; $language->license = 'http://www.gnu.org/copyleft/gpl.html GNU/GPL'; $language->setPlurals($_POST['plural_form']); $textdomain = rtrim($language->path, '\\/'); $dir = $textdomain . '/' . $language->name; $untranslated = $textdomain . '/untranslated'; $charset = $language->charset; $langfiles = mosReadDirectory($untranslated, '.pot$'); @mkdir($dir); @mkdir($dir . '/LC_MESSAGES'); //$gettext_admin = new PHPGettextAdmin(); foreach ($langfiles as $domain) { $domain = substr($domain, 0, -4); /*if (file_exists("$textdomain/glossary/$lang.$charset.po")) { copy("$textdomain/glossary/$lang.$charset.po", "$dir/$lang.po"); $gettext_admin->initialize_translation($domain, $textdomain, $lang, $charset); $gettext_admin->compile($lang, $textdomain, $charset); } else {*/ copy("{$untranslated}/{$domain}.pot", "{$dir}/{$domain}.po"); //} } //if (!file_exists("$textdomain/$lang/$lang.po")) { // @copy("$textdomain/glossary/untranslated.pot", "$textdomain/$lang/$lang.po"); //} $language->save(); }
/** * Process any legacy bots in the /mambots directory * * THIS FILE CAN BE **SAFELY REMOVED** IF YOU HAVE NO LEGACY MAMBOTS * @param object A content object * @param int A bit-wise mask of options * @param int The page number */ function botLegacyBots($published, &$row, &$params, $page = 0) { global $mosConfig_absolute_path; // check whether mambot has been unpublished if (!$published) { return true; } // process any legacy bots $bots = mosReadDirectory("{$mosConfig_absolute_path}/mambots", "\\.php\$"); sort($bots); foreach ($bots as $bot) { require $mosConfig_absolute_path . "/mambots/{$bot}"; } }
/** * @param string The URL option */ function showInstalledComponents($option) { global $database, $mosConfig_absolute_path; $database->setQuery("SELECT *" . "\n FROM #__components" . "\n WHERE parent = 0 AND iscore = 0" . "\n ORDER BY name"); $rows = $database->loadObjectList(); // Read the component dir to find components $componentBaseDir = mosPathName($mosConfig_absolute_path . '/administrator/components'); $componentDirs = mosReadDirectory($componentBaseDir); $id = 0; foreach ($rows as $row) { $dirName = $componentBaseDir . $row->option; $xmlFilesInDir = mosReadDirectory($dirName, '.xml'); foreach ($xmlFilesInDir as $xmlfile) { // Read the file to see if it's a valid component XML file $xmlDoc =& new DOMIT_Lite_Document(); $xmlDoc->resolveErrors(true); if (!$xmlDoc->loadXML($dirName . '/' . $xmlfile, false, true)) { continue; } $element =& $xmlDoc->documentElement; if ($element->getTagName() != 'mosinstall') { continue; } if ($element->getAttribute("type") != "component") { continue; } $element =& $xmlDoc->getElementsByPath('creationDate', 1); $row->creationdate = $element ? $element->getText() : 'Unknown'; $element =& $xmlDoc->getElementsByPath('author', 1); $row->author = $element ? $element->getText() : 'Unknown'; $element =& $xmlDoc->getElementsByPath('copyright', 1); $row->copyright = $element ? $element->getText() : ''; $element =& $xmlDoc->getElementsByPath('authorEmail', 1); $row->authorEmail = $element ? $element->getText() : ''; $element =& $xmlDoc->getElementsByPath('authorUrl', 1); $row->authorUrl = $element ? $element->getText() : ''; $element =& $xmlDoc->getElementsByPath('version', 1); $row->version = $element ? $element->getText() : ''; $row->mosname = strtolower(str_replace(" ", "_", $row->name)); $rows[$id] = $row; } $id++; } HTML_component::showInstalledComponents($rows, $option); }
/** * Compiles a list of installed, version 4.5+ templates * * Based on xml files found. If no xml file found the template * is ignored */ function viewTemplates($option, $client) { global $database, $mainframe; global $mosConfig_absolute_path, $mosConfig_list_limit; $limit = $mainframe->getUserStateFromRequest('viewlistlimit', 'limit', $mosConfig_list_limit); $limitstart = $mainframe->getUserStateFromRequest("view{$option}limitstart", 'limitstart', 0); if ($client == 'admin') { $templateBaseDir = mosPathName($mosConfig_absolute_path . '/administrator/templates'); } else { $templateBaseDir = mosPathName($mosConfig_absolute_path . '/templates'); } $rows = array(); // Read the template dir to find templates $templateDirs = mosReadDirectory($templateBaseDir); $id = intval($client == 'admin'); if ($client == 'admin') { $query = "SELECT template" . "\n FROM #__templates_menu" . "\n WHERE client_id = 1" . "\n AND menuid = 0"; $database->setQuery($query); } else { $query = "SELECT template" . "\n FROM #__templates_menu" . "\n WHERE client_id = 0" . "\n AND menuid = 0"; $database->setQuery($query); } $cur_template = $database->loadResult(); $rowid = 0; // Check that the directory contains an xml file foreach ($templateDirs as $templateDir) { $dirName = mosPathName($templateBaseDir . $templateDir); $xmlFilesInDir = mosReadDirectory($dirName, '.xml$'); foreach ($xmlFilesInDir as $xmlfile) { // Read the file to see if it's a valid template XML file $xmlDoc = new DOMIT_Lite_Document(); $xmlDoc->resolveErrors(true); if (!$xmlDoc->loadXML($dirName . $xmlfile, false, true)) { continue; } $root =& $xmlDoc->documentElement; if ($root->getTagName() != 'mosinstall') { continue; } if ($root->getAttribute('type') != 'template') { continue; } $row = new StdClass(); $row->id = $rowid; $row->directory = $templateDir; $element =& $root->getElementsByPath('name', 1); $row->name = $element->getText(); $element =& $root->getElementsByPath('creationDate', 1); $row->creationdate = $element ? $element->getText() : 'Nenhum'; $element =& $root->getElementsByPath('author', 1); $row->author = $element ? $element->getText() : 'Unknown'; $element =& $root->getElementsByPath('copyright', 1); $row->copyright = $element ? $element->getText() : ''; $element =& $root->getElementsByPath('authorEmail', 1); $row->authorEmail = $element ? $element->getText() : ''; $element =& $root->getElementsByPath('authorUrl', 1); $row->authorUrl = $element ? $element->getText() : ''; $element =& $root->getElementsByPath('version', 1); $row->version = $element ? $element->getText() : ''; // Get info from db if ($cur_template == $templateDir) { $row->published = 1; } else { $row->published = 0; } $row->checked_out = 0; $row->mosname = strtolower(str_replace(' ', '_', $row->name)); // check if template is assigned $query = "SELECT COUNT(*)" . "\n FROM #__templates_menu" . "\n WHERE client_id = 0" . "\n AND template = " . $database->Quote($row->directory) . "\n AND menuid != 0"; $database->setQuery($query); $row->assigned = $database->loadResult() ? 1 : 0; $rows[] = $row; $rowid++; } } require_once $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php'; $pageNav = new mosPageNav(count($rows), $limitstart, $limit); $rows = array_slice($rows, $pageNav->limitstart, $pageNav->limit); HTML_templates::showTemplates($rows, $pageNav, $option, $client); }
function attachement($mailingEdit, $lists, $show) { foreach ($mailingEdit->attachments as $attach => $k) { $mailingEdit->attachments[$attach] = basename($k); } $files = mosReadDirectory($GLOBALS['mosConfig_absolute_path'] . $GLOBALS[ACA . 'upload_url'], '\\.', true, true); echo '<select name="attachments[]" multiple="multiple" style="width: 100%;" size="10">'; if (sizeof($files) > 0) { foreach ($files as $file) { $file = basename($file); if (in_array($file, $mailingEdit->attachments)) { echo '<option selected="selected">' . $file . '</option>' . "\n"; } else { echo '<option>' . $file . '</option>' . "\n"; } } } echo '</select>'; ?> <script src="<?php echo $GLOBALS['mosConfig_live_site']; ?> /administrator/components/com_acajoom/classes/multifile.js"></script> <input id="my_file_element" type="file" name="file_1" > </input> <br /><b><?php echo _ACA_FILES; ?> :</b> <div id="files_list"></div> <script> var multi_selector = new MultiSelector( document.getElementById( 'files_list' ), 10 ); multi_selector.addElement( document.getElementById( 'my_file_element' ) ); </script> <?php }
/** * Compiles information to add or edit a module * @param string The current GET/POST option * @param integer The unique id of the record to edit */ function editMambot($option, $uid, $client) { global $database, $my, $mainframe; global $mosConfig_absolute_path; $lists = array(); $row = new mosMambot($database); // load the row from the db table $row->load($uid); // fail if checked out not by 'me' if ($row->checked_out && $row->checked_out != $my->id) { echo "<script>alert(" . sprintf(T_('The module %s is currently being edited by another administrator'), $row->title) . "); document.location.href='index2.php?option={$option}'</script>\n"; exit(0); } if ($client == 'admin') { $where = "client_id='1'"; } else { $where = "client_id='0'"; } // get list of groups if ($row->access == 99 || $row->client_id == 1) { $lists['access'] = T_('Administrator') . '<input type="hidden" name="access" value="99" />'; } else { // build the html select list for the group access $lists['access'] = mosAdminMenus::Access($row); } if ($uid) { $row->checkout($my->id); if ($row->ordering > -10000 && $row->ordering < 10000) { // build the html select list for ordering $query = "SELECT ordering AS value, name AS text" . "\n FROM #__mambots" . "\n WHERE folder='{$row->folder}'" . "\n AND published > 0" . "\n AND {$where}" . "\n AND ordering > -10000" . "\n AND ordering < 10000" . "\n ORDER BY ordering"; $order = mosGetOrderingList($query); $lists['ordering'] = mosHTML::selectList($order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval($row->ordering)); } else { $lists['ordering'] = '<input type="hidden" name="ordering" value="' . $row->ordering . '" />' . T_('This mambot cannot be reordered'); } $lists['folder'] = '<input type="hidden" name="folder" value="' . $row->folder . '" />' . $row->folder; // xml file for module $xmlfile = $mosConfig_absolute_path . '/mambots/' . $row->folder . '/' . $row->element . '.xml'; $xmlparser =& new mosXMLDescription($xmlfile); $row->description = T_($xmlparser->getDescription('mambot')); } else { $row->folder = ''; $row->ordering = 999; $row->published = 1; $row->description = ''; $folders = mosReadDirectory($mosConfig_absolute_path . '/mambots/'); $folders2 = array(); foreach ($folders as $folder) { if (is_dir($mosConfig_absolute_path . '/mambots/' . $folder) && $folder != 'CVS') { $folders2[] = mosHTML::makeOption($folder); } } $lists['folder'] = mosHTML::selectList($folders2, 'folder', 'class="inputbox" size="1"', 'value', 'text', null); $lists['ordering'] = '<input type="hidden" name="ordering" value="' . $row->ordering . '" />' . T_('New items default to the last place. Ordering can be changed after this item is saved.') . ''; } $lists['published'] = mosHTML::yesnoRadioList('published', 'class="inputbox"', $row->published); // get params definitions $params =& new mosAdminParameters($row->params, $mainframe->getPath('bot_xml', $row->folder . '/' . $row->element), 'mambot'); HTML_modules::editMambot($row, $lists, $params, $option); }
/** * Compiles a list of installed, version 4.5+ templates * * Based on xml files found. If no xml file found the template * is ignored */ function viewTemplates($option, $client) { global $database, $mainframe; global $mosConfig_absolute_path, $mosConfig_list_limit; $limit = $mainframe->getUserStateFromRequest('viewlistlimit', 'limit', $mosConfig_list_limit); $limitstart = $mainframe->getUserStateFromRequest("view{$option}limitstart", 'limitstart', 0); if ($client == 'admin') { $templateBaseDir = mosPathName($mosConfig_absolute_path . '/administrator/templates'); } else { $templateBaseDir = mosPathName($mosConfig_absolute_path . '/templates'); } $rows = array(); // Read the template dir to find templates $templateDirs = mosReadDirectory($templateBaseDir); $id = intval($client == 'admin'); if ($client == 'admin') { $database->setQuery("SELECT template FROM #__templates_menu WHERE client_id='1' AND menuid='0'"); } else { $database->setQuery("SELECT template FROM #__templates_menu WHERE client_id='0' AND menuid='0'"); } $cur_template = $database->loadResult(); $rowid = 0; // Check that the directory contains an xml file foreach ($templateDirs as $templateDir) { $dirName = mosPathName($templateBaseDir . $templateDir); $xmlFilesInDir = mosReadDirectory($dirName, '.xml$'); foreach ($xmlFilesInDir as $xmlfile) { // Read the file to see if it's a valid template XML file $parser =& new mosXMLDescription($dirName . $xmlfile); if ($parser->getType() != 'template') { continue; } $row = new StdClass(); $row->id = $rowid; $row->directory = $templateDir; $row->creationdate = $parser->getCreationDate('template'); $row->name = $parser->getName('template'); $row->author = $parser->getAuthor('template'); $row->copyright = $parser->getCopyright('template'); $row->authorEmail = $parser->getAuthorEmail('template'); $row->authorUrl = $parser->getAuthorUrl('template'); $row->version = $parser->getVersion('template'); /* $element = &$xmlDoc->getElementsByPath('name', 1 ); $row->name = $element->getText(); $element = &$xmlDoc->getElementsByPath('creationDate', 1); $row->creationdate = $element ? $element->getText() : 'Unknown'; $element = &$xmlDoc->getElementsByPath('author', 1); $row->author = $element ? $element->getText() : 'Unknown'; $element = &$xmlDoc->getElementsByPath('copyright', 1); $row->copyright = $element ? $element->getText() : ''; $element = &$xmlDoc->getElementsByPath('authorEmail', 1); $row->authorEmail = $element ? $element->getText() : ''; $element = &$xmlDoc->getElementsByPath('authorUrl', 1); $row->authorUrl = $element ? $element->getText() : ''; $element = &$xmlDoc->getElementsByPath('version', 1); $row->version = $element ? $element->getText() : ''; */ // Get info from db if ($cur_template == $templateDir) { $row->published = 1; } else { $row->published = 0; } $row->checked_out = 0; $row->mosname = strtolower(str_replace(' ', '_', $row->name)); // check if template is assigned $database->setQuery("SELECT count(*) FROM #__templates_menu WHERE client_id='0' AND template='{$row->directory}' AND menuid<>'0'"); $row->assigned = $database->loadResult() ? 1 : 0; $rows[] = $row; $rowid++; } } require_once $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php'; $pageNav = new mosPageNav(count($rows), $limitstart, $limit); $rows = array_slice($rows, $pageNav->limitstart, $pageNav->limit); HTML_templates::showTemplates($rows, $pageNav, $option, $client); }
function attachement($mailingEdit, $lists, $show) { foreach ($mailingEdit->attachments as $attach => $k) { $mailingEdit->attachments[$attach] = basename($k); } if (ACA_CMSTYPE) { // joomla 15 $path = ACA_JPATH_ROOT_NO_ADMIN . $GLOBALS[ACA . 'upload_url']; $arr = array(null); // Get the files and folders jimport('joomla.filesystem.folder'); $files2 = JFolder::files($path, '.', true, true); $folders = JFolder::folders($path, '.', true, true); // Merge files and folders into one array $files = array_merge($files2, $folders); // Sort them all asort($files); } else { //joomla 1x $files = mosReadDirectory(ACA_JPATH_ROOT_NO_ADMIN . $GLOBALS[ACA . 'upload_url'], '\\.', true, true); } //endif echo '<select name="attachments[]" multiple="multiple" style="width: 100%;" size="10">'; if (sizeof($files) > 0) { foreach ($files as $file) { $file = basename($file); if (in_array($file, $mailingEdit->attachments)) { echo '<option selected="selected">' . $file . '</option>' . "\n"; } else { echo '<option>' . $file . '</option>' . "\n"; } } } echo '</select>'; ?> <script src="<?php echo ACA_JPATH_LIVE; ?> /administrator/components/com_acajoom/classes/multifile.js"></script> <input id="my_file_element" type="file" name="file_1" > </input> <br /><b><?php echo _ACA_FILES; ?> :</b> <div id="files_list"></div> <script> var multi_selector = new MultiSelector( document.getElementById( 'files_list' ), 10 ); multi_selector.addElement( document.getElementById( 'my_file_element' ) ); </script> <?php }
function mosReadDirectory($path, $filter = '.', $recurse = false, $fullpath = false) { return mosReadDirectory($path, $filter, $recurse, $fullpath); }
/** * Component uninstall method * @param int The id of the module * @param string The URL option * @param int The client id */ function component_uninstall($cid, $option, $client = 0) { $database =& mamboDatabase::getInstance(); $sql = "SELECT * FROM #__components WHERE id={$cid}"; $database->setQuery($sql); if (!$database->loadObject($row)) { $message = new mosError($database->stderr(true), _MOS_ERROR_FATAL); HTML_installer::showInstallMessage($message, T_('Uninstall - error'), "index2.php?option={$option}&element=component"); exit; } if ($row->iscore) { $message = new mosError(sprintf(T_('Component %s is a core component, and can not be uninstalled.<br />You need to unpublish it if you don\'t want to use it'), $row->name), _MOS_ERROR_FATAL); HTML_installer::showInstallMessage($message, 'Uninstall - error', "index2.php?option={$option}&element=component"); exit; } // Try to find the XML file $here = mosPathName(mamboCore::get('mosConfig_absolute_path') . '/administrator/components/' . $row->option); $filesindir = mosReadDirectory($here, '.xml$'); if (count($filesindir) > 0) { $allerrors = new mosErrorSet(); foreach ($filesindir as $file) { $parser =& new mosUninstallXML($here . $file); $parser->uninstall(); $allerrors->mergeAnother($parser->errors); } $ret = $allerrors->getMaxLevel() < _MOS_ERROR_FATAL; HTML_installer::showInstallMessage($allerrors->getErrors(), T_('Uninstall component - ') . ($ret ? T_('Success') : T_('Error')), returnTo($option, 'component', $client)); } else { $com_name = $row->option; $dir = new mosDirectory(mosPathName(mamboCore::get('mosConfig_absolute_path') . '/components/' . $com_name)); $dir->deleteAll(); $dir = new mosDirectory(mosPathName(mamboCore::get('mosConfig_absolute_path') . '/administrator/components/' . $com_name)); $dir->deleteAll(); $sql = "DELETE FROM #__components WHERE `option`='{$com_name}'"; $database->setQuery($sql); $database->query(); $message = new mosError(T_('Uninstaller could not find XML file, but cleaned database'), _MOS_ERROR_WARN); HTML_installer::showInstallMessage($message, T_('Uninstall ') . T_('component - ') . T_('Success'), returnTo($option, 'component', $client)); } exit; }
/** * @param string The name of the form element * @param string The value of the element * @param object The xml element for the parameter * @param string The control name * @return string The html for the element */ function _form_filelist($name, $value, &$node, $control_name) { global $mosConfig_absolute_path; // path to images directory $path = $mosConfig_absolute_path . $node->getAttribute('directory'); $filter = $node->getAttribute('filter'); $files = mosReadDirectory($path, $filter); $options = array(); foreach ($files as $file) { $options[] = mosHTML::makeOption($file, $file); } if (!$node->getAttribute('hide_none')) { array_unshift($options, mosHTML::makeOption('-1', '- ' . 'Do Not Use' . ' -')); } if (!$node->getAttribute('hide_default')) { array_unshift($options, mosHTML::makeOption('', '- ' . 'Use Default' . ' -')); } return mosHTML::selectList($options, '' . $control_name . '[' . $name . ']', 'class="inputbox"', 'value', 'text', $value, "param{$name}"); }
static function imageList($name, &$active, $javascript = null, $directory = null) { global $mosConfig_absolute_path; if (!$javascript) { $javascript = "onchange=\"javascript:if (document.adminForm." . $name . ".options[selectedIndex].value!='') " . "{document.imagelib.src='../images/stories/' + document.adminForm." . $name . ".options[selectedIndex].value} else {document.imagelib.src='../images/blank.png'}\""; } if (!$directory) { $directory = '/images/stories'; } // inserted by Wonderer if (!file_exists($mosConfig_absolute_path . $directory)) { @mkdir($mosConfig_absolute_path . $directory, 0777) or die("Error of directory creating: [" . $mosConfig_absolute_path . $directory . "] "); } else { } // -- $imageFiles = mosReadDirectory($mosConfig_absolute_path . $directory); $images = array(mosHTML::makeOption('', _BOOKLIBRARY_A_SELECT_IMAGE)); foreach ($imageFiles as $file) { if (preg_match("/bmp|gif|jpg|jpeg|png/i", $file)) { $images[] = mosHTML::makeOption($file); } } $images = mosHTML::selectList($images, $name, 'id="' . $name . '" class="inputbox" size="1" ' . $javascript, 'value', 'text', $active); return $images; }
function JQ_editQuestion($id, $option, $qtype, $page, $course_id, $gqp = false) { global $JLMS_DB, $my, $JLMS_SESSION, $Itemid, $JLMS_CONFIG; if ($gqp && mosGetParam($_REQUEST, 'c_id')) { $query = "SELECT c_id FROM #__lms_quiz_t_question" . "\n WHERE c_id = '" . intval(mosGetParam($_REQUEST, 'c_id')) . "' AND course_id > 0 AND c_quiz_id > 0"; $JLMS_DB->setQuery($query); $c_id = $JLMS_DB->loadResult(); if ($c_id) { JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=quizzes&page=setup_gqp")); } } $row = new mos_JoomQuiz_Question($JLMS_DB); $row->load($id); $quiz_id = intval(mosGetParam($_REQUEST, 'quiz_id', $JLMS_SESSION->get('quiz_id', 0))); $JLMS_ACL =& JLMSFactory::getACL(); if (!$JLMS_ACL->CheckPermissions('quizzes', 'manage')) { if ($JLMS_ACL->CheckPermissions('quizzes', 'manage_pool')) { $quiz_id = -1; if ($id) { if ($row->c_quiz_id == 0) { } else { JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=quizzes&id={$course_id}&page=quizzes")); } } } } if ($id) { if ($row->c_quiz_id == 0) { $row->c_quiz_id = -1; } } elseif (mosGetParam($_REQUEST, 'level_id_0')) { $row->bind($_POST); /*Fix params (Max)*/ if (isset($row->params) && count($row->params)) { $row_params = $row->params; $row->params = ''; $i = 0; if (isset($row_params) && is_array($row_params) && count($row_params)) { foreach ($row_params as $key => $item) { $row->params .= $key . '=' . $item; if ($i < count($row_params)) { $row->params .= "\n"; } $i++; } } } /*Fix params (Max)*/ } else { // do stuff for new records $row->ordering = 0; $row->c_quiz_id = $quiz_id; //intval( mosGetParam( $_REQUEST, 'quiz_id', $JLMS_SESSION->get('quiz_id', 0 )) ); $row->c_type = intval(mosGetParam($_REQUEST, 'new_qtype_id', 1)); $row->c_question = "Enter question text here"; //$row->c_qcat = 0; } $params = new JLMSParameters($row->params); $params->def('disable_quest_feedback', 0); $params->def('survey_question', 0); $params->def('case_sensivity', 0); $lists = array(); $query = "SELECT c_id as value, c_category as text FROM #__lms_quiz_t_category WHERE course_id = '" . $course_id . "' AND is_quiz_cat = 0 order by c_category"; $JLMS_DB->setQuery($query); $jq_cats = array(); $jq_cats[] = mosHTML::makeOption(0, ' - ' . _JLMS_QUIZ_CAT_TYPE_QUEST . ' - '); $jq_cats = array_merge($jq_cats, $JLMS_DB->loadObjectList()); $lists['jq_categories'] = mosHTML::selectList($jq_cats, 'c_qcat', 'class="inputbox" size="1"', 'value', 'text', $row->c_qcat); $is_pool = false; if ($row->c_quiz_id == -1) { $is_pool = true; } $query = "SELECT a.ordering AS value, a.c_question AS text, a.c_type, a.c_id, a.c_pool, a.c_pool_gqp" . "\n FROM #__lms_quiz_t_question AS a" . "\n WHERE a.course_id = '" . $course_id . "' " . ($row->c_quiz_id ? "\n AND a.c_quiz_id = " . ($is_pool ? 0 : $row->c_quiz_id) : '') . "\n ORDER BY a.ordering, a.c_id"; //$text_new_order = _C M N_NEW_ITEM_FIRST; //if ( $id ) { if (true) { ### $chop = 30; $order = array(); $JLMS_DB->setQuery($query); $orders = $JLMS_DB->loadObjectList(); if (empty($orders)) { $order[] = mosHTML::makeOption(0, _JLMS_SB_FIRST_ITEM); } else { // QuestPool compatibility $q_from_pool = array(); foreach ($orders as $rowtmp) { if ($rowtmp->c_type == 20) { $q_from_pool[] = $rowtmp->c_pool; } } if (count($q_from_pool)) { $qp_ids = implode(',', $q_from_pool); $query = "SELECT a.* FROM #__lms_quiz_t_question as a" . "\n WHERE a.course_id = '" . $course_id . "' AND a.c_id IN ({$qp_ids})"; $JLMS_DB->setQuery($query); $orders2 = $JLMS_DB->loadObjectList(); for ($i = 0, $n = count($orders); $i < $n; $i++) { if ($orders[$i]->c_type == 20) { for ($j = 0, $m = count($orders2); $j < $m; $j++) { if ($orders[$i]->c_pool == $orders2[$j]->c_id) { $orders[$i]->text = $orders2[$j]->c_question; break; } } } } } // Global QuestPool compatibility $q_from_pool_gqp = array(); foreach ($orders as $rowtmp) { if ($rowtmp->c_type == 21) { $q_from_pool_gqp[] = $rowtmp->c_pool_gqp; } } if (count($q_from_pool_gqp)) { $qp_ids_gqp = implode(',', $q_from_pool_gqp); $query = "SELECT a.* FROM #__lms_quiz_t_question as a" . "\n WHERE a.course_id = 0 AND a.c_id IN ({$qp_ids_gqp})"; $JLMS_DB->setQuery($query); $orders2 = $JLMS_DB->loadObjectList(); for ($i = 0, $n = count($orders); $i < $n; $i++) { if ($orders[$i]->c_type == 21) { for ($j = 0, $m = count($orders2); $j < $m; $j++) { if ($orders[$i]->c_pool_gqp == $orders2[$j]->c_id) { $orders[$i]->text = $orders2[$j]->c_question; break; } } } } } $order[] = mosHTML::makeOption(0, '0 ' . _JLMS_SB_FIRST_ITEM); for ($i = 0, $n = count($orders); $i < $n; $i++) { $temp_txt = $orders[$i]->text; mosMakeHtmlSafe($temp_txt); $temp_txt = strip_tags($temp_txt); if (strlen($temp_txt) > $chop) { $text = substr($temp_txt, 0, $chop) . "..."; } else { $text = $temp_txt; } $order[] = mosHTML::makeOption($orders[$i]->c_id, $orders[$i]->value . ' (' . $text . ')'); } $order[] = mosHTML::makeOption(-1, $orders[$i - 1]->value + 1 . ' ' . _JLMS_SB_LAST_ITEM); } ### $ordering = mosHTML::selectList($order, 'q_ordering', 'class="inputbox" size="1"', 'value', 'text', intval($row->c_id ? $row->c_id : -1)); //set ordering to last element for new questions and without changes for existent questions } $lists['ordering'] = $ordering; $query = "SELECT c_id AS value, c_title AS text" . "\n FROM #__lms_quiz_t_quiz" . "\n WHERE course_id = '" . $course_id . "' " . "\n ORDER BY c_title"; $JLMS_DB->setQuery($query); $quizzes = array(); $quizzes[] = mosHTML::makeOption('-1', _JLMS_QUIZ_QUEST_POOL); $quizzes = array_merge($quizzes, $JLMS_DB->loadObjectList()); $quiz = mosHTML::selectList($quizzes, 'c_quiz_id', 'class="inputbox" size="1" ', 'value', 'text', intval($row->c_quiz_id)); $lists['quiz'] = $quiz; $lists['c_wrong_message'] = ''; $lists['c_right_message'] = ''; $query = "SELECT * FROM #__lms_quiz_t_question_fb WHERE quest_id = {$id}"; $JLMS_DB->SetQuery($query); $q_fbs = $JLMS_DB->LoadObjectList(); foreach ($q_fbs as $qfb) { if ($qfb->choice_id == -1) { $lists['c_wrong_message'] = $qfb->fb_text; } elseif (!$qfb->choice_id) { $lists['c_right_message'] = $qfb->fb_text; } } $JLMS_DB->SetQuery("SELECT c_qtype FROM #__lms_quiz_t_qtypes WHERE c_id = '" . $row->c_type . "'"); $qtype_str = $JLMS_DB->LoadResult(); $str = '_JLMS_QUIZ_QTYPE_' . $row->c_type; if (defined($str)) { $qtype_str = constant($str); } if (mosGetParam($_REQUEST, 'c_type')) { $row->c_type = mosGetParam($_REQUEST, 'c_type'); } //---------------------------------------kosmos if ($row->c_type == 21) { $javascript = 'onclick="read_filter();" onchange="javascript:write_filter();form.page.value=\'add_quest\';document.adminForm.submit();"'; } else { $javascript = 'onclick="read_filter();" onchange="javascript:write_filter();form.page.value=\'edit_quest_gqp\';document.adminForm.submit();"'; } //FLMS multicategories $levels = array(); //NEW MULTICAT if ($id) { $tmp_level = array(); $last_catid = 0; $i = 0; foreach ($_REQUEST as $key => $item) { if (preg_match('#level_id_(\\d+)#', $key, $result)) { if ($item) { $tmp_level[$i] = $result; $last_catid = $item; $i++; } } } if (!$i) { $query = "SELECT c_qcat FROM #__lms_quiz_t_question WHERE c_id = '" . $id . "'"; $JLMS_DB->setQuery($query); $last_catid = $JLMS_DB->loadResult(); } $tmp = array(); $tmp = JLMS_quiz_admin_class::JLMS_multicats($last_catid, $tmp); $tmp = array_reverse($tmp); $tmp_pop = $tmp; $tmp_p = array_pop($tmp_pop); if (count($tmp) && $tmp_p->catid) { $next = count($tmp); $tmp[$next] = new stdClass(); $tmp[$next]->catid = 0; $tmp[$next]->parent = $tmp_p->catid; } } else { $tmp_level = array(); $last_catid = 0; $exist_in_request = 0; $i = 0; foreach ($_REQUEST as $key => $item) { if (preg_match('#level_id_(\\d+)#', $key, $result)) { if (isset($item)) { $exist_in_request = 1; if ($item) { $tmp_level[$i] = $result; $last_catid = intval($item); $i++; } } } } if (!$last_catid && !$exist_in_request) { $last_catid = $JLMS_SESSION->get('S_last_catid'); } $JLMS_SESSION->set('S_last_catid', $last_catid); $tmp = array(); $tmp = JLMS_quiz_admin_class::JLMS_multicats($last_catid, $tmp); $tmp = array_reverse($tmp); $tmp_pop = $tmp; $tmp_p = array_pop($tmp_pop); if (count($tmp) && $tmp_p->catid) { $next = count($tmp); $tmp[$next] = new stdClass(); $tmp[$next]->catid = 0; $tmp[$next]->parent = isset($tmp_p->catid) ? $tmp_p->catid : 0; } } /* $query = "SELECT * FROM #__lms_gqp_cats_config ORDER BY id"; $JLMS_DB->setQuery($query); $levels = $JLMS_DB->loadObjectList(); */ if (count($levels) == 0) { for ($i = 0; $i < 15; $i++) { $num = $i + 1; if ($i > 0) { // $levels[$i]->cat_name = _JLMS_COURSES_COURSES_GROUPS; $levels[$i]->cat_name = 'Level #' . $num; } else { // $levels[$i]->cat_name = _JLMS_COURSES_COURSES_GROUPS; $levels[$i]->cat_name = 'Level #' . $num; } } } $level_id = array(); for ($i = 0; $i < count($levels); $i++) { if ($i == 0) { $level_id[$i] = intval(mosGetParam($_REQUEST, 'level_id_' . $i, 0)); $_REQUEST['level_id_' . $i] = $level_id[$i]; $JLMS_SESSION->set('GQP_level_id_' . $i, $level_id[$i]); } else { $level_id[$i] = intval(mosGetParam($_REQUEST, 'level_id_' . $i, $JLMS_SESSION->get('GQP_level_id_' . $i, 0))); $_REQUEST['level_id_' . $i] = $level_id[$i]; $JLMS_SESSION->set('GQP_level_id_' . $i, $level_id[$i]); } if ($i == 0) { $parent_id[$i] = 0; } else { $parent_id[$i] = $level_id[$i - 1]; } $query = "SELECT count(id) FROM `#__lms_gqp_cats` WHERE parent = '" . $parent_id[$i] . "' ORDER BY c_category"; $JLMS_DB->setQuery($query); $groups = $JLMS_DB->loadResult(); if ($groups == 0) { $level_id[$i] = 0; $JLMS_SESSION->set('GQP_level_id_' . $i, $level_id[$i]); } } for ($i = 0; $i < count($levels); $i++) { if ($i > 0 && $level_id[$i - 1] == 0) { $level_id[$i] = 0; $_REQUEST['level_id_' . $i] = $level_id[$i]; $JLMS_SESSION->set('GQP_level_id_' . $i, $level_id[$i]); $parent_id[$i] = 0; } elseif ($i == 0 && $level_id[$i] == 0) { $level_id[$i] = 0; $_REQUEST['level_id_' . $i] = $level_id[$i]; $JLMS_SESSION->set('GQP_level_id_' . $i, $level_id[$i]); $parent_id[$i] = 0; } } for ($i = 0; $i < count($levels); $i++) { if ($i == 0 || isset($tmp[$i]->parent) && $tmp[$i]->parent) { //(Max): extra requests $query = "SELECT * FROM `#__lms_gqp_cats` WHERE parent = '" . $tmp[$i]->parent . "' ORDER BY c_category"; $JLMS_DB->setQuery($query); $groups = $JLMS_DB->loadObjectList(); if ($tmp[$i]->parent && $i > 0 && count($groups)) { $type_level[$i][] = mosHTML::makeOption(0, ' '); foreach ($groups as $group) { $type_level[$i][] = mosHTML::makeOption($group->id, $group->c_category); } $lists['level_' . $i] = mosHTML::selectList($type_level[$i], 'level_id_' . $i, 'class="inputbox" size="1" style="width:266px;" ' . $javascript, 'value', 'text', $tmp[$i]->catid); } elseif ($i == 0) { $type_level[$i][] = mosHTML::makeOption(0, ' '); foreach ($groups as $group) { $type_level[$i][] = mosHTML::makeOption($group->id, $group->c_category); } $lists['level_' . $i] = mosHTML::selectList($type_level[$i], 'level_id_' . $i, 'class="inputbox" size="1" style="width:266px;" ' . $javascript, 'value', 'text', $tmp[$i]->catid); } } } $multicat = array(); $i = 0; foreach ($lists as $key => $item) { if (substr($key, 0, 6) == 'level_') { $multicat[] = $lists['level_' . $i]; $i++; } } $data = new stdClass(); $i = 0; foreach ($multicat as $m) { if (isset($level_id[$i])) { $str_preobj = 'level_' . $i; $data->{$str_preobj} = $level_id[$i]; } $i++; } $lists['data'] = $data; //---------------------------------------------- //echo $row->c_type; die; switch ($row->c_type) { case 1: case 12: if ($row->c_type == 12) { $query = "SELECT a.*, b.imgs_name FROM #__lms_quiz_t_choice as a, #__lms_quiz_images as b WHERE a.c_question_id = '" . $row->c_id . "' AND b.imgs_id = a.c_choice ORDER BY a.ordering"; } else { $query = "SELECT * FROM #__lms_quiz_t_choice WHERE c_question_id = '" . $row->c_id . "' ORDER BY ordering"; $lists['random_answers'] = mosHTML::yesnoradioList('params[random_answers]', '', $params->get('random_answers', 0)); } $JLMS_DB->SetQuery($query); $row->choices = array(); $row->choices = $JLMS_DB->LoadObjectList(); if ($row->c_type == 12) { $query = "SELECT imgs_id, imgs_name, c_id as i_id FROM #__lms_quiz_images WHERE course_id = '" . $course_id . "'"; $JLMS_DB->SetQuery($query); $row->images = array(); $row->images = $JLMS_DB->LoadObjectList(); } $q_om_type = $row->c_type; JLMS_quiz_admin_html_class::JQ_editQuest_MChoice($row, $lists, $option, $page, $course_id, $q_om_type, $qtype_str, $params, $id, $gqp, $levels); break; case 2: case 13: if ($row->c_type == 13) { $query = "SELECT a.*, b.imgs_name FROM #__lms_quiz_t_choice as a, #__lms_quiz_images as b WHERE a.c_question_id = '" . $row->c_id . "' AND b.imgs_id = a.c_choice ORDER BY a.ordering"; } else { $query = "SELECT * FROM #__lms_quiz_t_choice WHERE c_question_id = '" . $row->c_id . "' ORDER BY ordering"; $lists['random_answers'] = mosHTML::yesnoradioList('params[random_answers]', '', $params->get('random_answers', 0)); } $JLMS_DB->SetQuery($query); $row->choices = array(); $row->choices = $JLMS_DB->LoadObjectList(); if ($row->c_type == 13) { $query = "SELECT imgs_id, imgs_name, c_id as i_id FROM #__lms_quiz_images WHERE course_id = '" . $course_id . "'"; $JLMS_DB->SetQuery($query); $row->images = array(); $row->images = $JLMS_DB->LoadObjectList(); } $q_om_type = $row->c_type; JLMS_quiz_admin_html_class::JQ_editQuest_MChoice($row, $lists, $option, $page, $course_id, $q_om_type, $qtype_str, $params, $id, $gqp, $levels); break; case 3: $query = "SELECT * FROM #__lms_quiz_t_choice WHERE c_question_id = '" . $row->c_id . "' ORDER BY ordering"; $JLMS_DB->SetQuery($query); $row->choices = array(); $row->choices = $JLMS_DB->LoadObjectList(); $row->choice_true = 1; foreach ($row->choices as $eee) { if (strtolower($eee->c_choice) == "false" && $eee->c_right == 1) { $row->choice_true = 0; } } JLMS_quiz_admin_html_class::JQ_editQuest_TrueFalse($row, $lists, $option, $page, $course_id, 3, $qtype_str, $params, $id, $gqp, $levels); break; case 4: $query = "SELECT * FROM #__lms_quiz_t_matching WHERE c_question_id = '" . $row->c_id . "' ORDER BY ordering"; $JLMS_DB->SetQuery($query); $row->matching = array(); $row->matching = $JLMS_DB->LoadObjectList(); JLMS_quiz_admin_html_class::JQ_editQuest_MDragDrop($row, $lists, $option, $page, $course_id, 4, $qtype_str, $params, $id, $gqp, $levels); break; case 5: $query = "SELECT * FROM #__lms_quiz_t_matching WHERE c_question_id = '" . $row->c_id . "' ORDER BY ordering"; $JLMS_DB->SetQuery($query); $row->matching = array(); $row->matching = $JLMS_DB->LoadObjectList(); JLMS_quiz_admin_html_class::JQ_editQuest_MDragDrop($row, $lists, $option, $page, $course_id, 5, $qtype_str, $params, $id, $gqp, $levels); break; case 6: $query = "SELECT b.*,a.c_default FROM #__lms_quiz_t_blank as a, #__lms_quiz_t_text as b WHERE a.c_question_id = '" . $row->c_id . "' and b.c_blank_id = a.c_id ORDER BY b.ordering"; $JLMS_DB->SetQuery($query); $row->blank_data = array(); $row->blank_data = $JLMS_DB->LoadObjectList(); $query = "SELECT c_default FROM #__lms_quiz_t_blank WHERE c_question_id = '" . $row->c_id . "'"; $JLMS_DB->SetQuery($query); $lists['c_def'] = $JLMS_DB->LoadResult(); JLMS_quiz_admin_html_class::JQ_editQuest_Blank($row, $lists, $option, $page, $course_id, 6, $qtype_str, $params, $id, $gqp, $levels); break; case 7: $directory_js = $JLMS_CONFIG->get('live_site') . '/images/joomlaquiz/images/'; $directory = 'images/joomlaquiz/images/'; $javascript = "onchange=\"javascript:if (document.adminForm.c_image.options[selectedIndex].value!='') {" . " document.imagelib.src='{$directory}' + document.adminForm.c_image.options[selectedIndex].value; } else {" . " document.imagelib.src='" . $JLMS_CONFIG->get('live_site') . "/images/blank.png'}\""; $imageFiles = mosReadDirectory($JLMS_CONFIG->get('absolute_path') . '/' . $directory); $images = array(mosHTML::makeOption('', '- Select Image -')); foreach ($imageFiles as $file) { if (preg_match("/bmp|gif|jpg|png/i", $file)) { $images[] = mosHTML::makeOption($file); } } $lists['images'] = mosHTML::selectList($images, 'c_image', 'class="inputbox" size="1" ' . $javascript, 'value', 'text', $row->c_image); //$lists['images'] = mosAdminMenus::images('c_image', $row->c_image, $javascript, $directory); $query = "SELECT * FROM #__lms_quiz_t_hotspot WHERE c_question_id = '" . $row->c_id . "'"; $JLMS_DB->SetQuery($query); $row->hotspot_data = array(); $row->hotspot_data = $JLMS_DB->LoadObjectList(); JLMS_quiz_admin_html_class::JQ_editQuest_HotSpot($row, $lists, $option, $page, $course_id, 7, $qtype_str, $params, $id, $gqp, $levels); break; case 8: JLMS_quiz_admin_html_class::JQ_editQuest_Survey($row, $lists, $option, $page, $course_id, 8, $qtype_str, $params, $id, $gqp, $levels); break; case 9: $query = "SELECT * FROM #__lms_quiz_t_scale WHERE c_question_id = '" . $row->c_id . "' ORDER BY ordering"; $JLMS_DB->SetQuery($query); $row->scale = array(); $row->scale = $JLMS_DB->LoadObjectList(); JLMS_quiz_admin_html_class::JQ_editQuest_Scale($row, $lists, $option, $page, $course_id, 9, $qtype_str, $params, $id, $gqp, $levels); break; case 10: JLMS_quiz_admin_html_class::JQ_editQuest_Boilerplate($row, $lists, $option, $page, $course_id, 10, $qtype_str, $params, $id, $gqp, $levels); break; case 11: $query = "SELECT a.*, b.imgs_name as left_name, c.imgs_name as right_name FROM #__lms_quiz_t_matching as a, #__lms_quiz_images as b, #__lms_quiz_images as c WHERE a.c_question_id = '" . $row->c_id . "' AND b.imgs_id = a.c_left_text AND c.imgs_id = a.c_right_text ORDER BY a.ordering"; $JLMS_DB->SetQuery($query); $row->matching = array(); $row->matching = $JLMS_DB->LoadObjectList(); $query = "SELECT imgs_id, imgs_name, c_id as i_id FROM #__lms_quiz_images WHERE course_id = '" . $course_id . "'"; $JLMS_DB->SetQuery($query); $row->images = array(); $row->images = $JLMS_DB->LoadObjectList(); JLMS_quiz_admin_html_class::JQ_editQuest_MDragDrop2($row, $lists, $option, $page, $course_id, 11, $qtype_str, $params, $id, $gqp, $levels); break; case 20: //add question from pool $query = "SELECT a.c_id AS value, a.c_question AS text" . "\n FROM #__lms_quiz_t_question AS a" . "\n WHERE a.course_id = '" . $course_id . "' " . "\n AND a.c_quiz_id = 0" . "\n ORDER BY a.ordering"; $qp_array = array(); $JLMS_DB->setQuery($query); $qp_list = $JLMS_DB->loadObjectList(); $qp_array[] = mosHTML::makeOption(0, '- Select question -'); for ($i = 0, $n = count($qp_list); $i < $n; $i++) { if (strlen(strip_tags($qp_list[$i]->text)) > 30) { $text = substr(strip_tags($qp_list[$i]->text), 0, 30) . "..."; } else { $text = strip_tags($qp_list[$i]->text); } $qp_array[] = mosHTML::makeOption($qp_list[$i]->value, $text); } $pool_quests = mosHTML::selectList($qp_array, 'c_pool', 'class="inputbox" size="1"', 'value', 'text', intval($row->c_pool)); $lists['pool_quests'] = $pool_quests; JLMS_quiz_admin_html_class::JQ_editQuest_Pool($row, $lists, $option, $page, $course_id, 20, $qtype_str); break; case 21: //add question from pool if (!$row->c_id) { $limit = intval(mosGetParam($_GET, 'limit', $JLMS_SESSION->get('list_limit', $JLMS_CONFIG->get('list_limit')))); $JLMS_SESSION->set('list_limit', $limit); $limitstart = intval(mosGetParam($_REQUEST, 'limitstart', 0)); $qtype_id = mosGetParam($_REQUEST, 'qtype_id', 0); $query = "SELECT c_pool_gqp" . "\n FROM #__lms_quiz_t_question" . "\n WHERE c_pool_gqp > 0 AND c_quiz_id = {$quiz_id}"; $JLMS_DB->setQuery($query); $result_array = $JLMS_DB->loadResultArray(); $use_ids = implode(',', $result_array); if ($use_ids) { $sql_use_ids = "\n AND a.c_id NOT IN ( {$use_ids} )"; } else { $sql_use_ids = ''; } $str = ''; //NEW MUSLTICATS /* $tmp_level = array(); $last_catid = 0; if(isset($_REQUEST['category_filter']) && $_REQUEST['category_filter']){ $last_catid = $_REQUEST['category_filter']; } else { $i=0; foreach($_REQUEST as $key=>$item){ if(preg_match('#level_id_(\d+)#', $key, $result)){ if($item){ $tmp_level[$i] = $result; $last_catid = $item; $i++; } } } } */ $query = "SELECT * FROM #__lms_gqp_cats" . "\n ORDER BY id"; $JLMS_DB->setQuery($query); $all_cats = $JLMS_DB->loadObjectList(); $tmp_cats_filter = array(); $children = array(); foreach ($all_cats as $cat) { $pt = $cat->parent; $list = @$children[$pt] ? $children[$pt] : array(); array_push($list, $cat->id); $children[$pt] = $list; } $tmp_cats_filter[0] = $last_catid; $i = 1; foreach ($children as $key => $childs) { if ($last_catid == $key) { foreach ($children[$key] as $v) { if (!in_array($v, $tmp_cats_filter)) { $tmp_cats_filter[$i] = $v; $i++; } } } } foreach ($children as $key => $childs) { if (in_array($key, $tmp_cats_filter)) { foreach ($children[$key] as $v) { if (!in_array($v, $tmp_cats_filter)) { $tmp_cats_filter[$i] = $v; $i++; } } } } $tmp_cats_filter = array_unique($tmp_cats_filter); $catids = implode(",", $tmp_cats_filter); if ($last_catid && count($tmp_cats_filter)) { $str .= "\n AND a.c_qcat IN (" . $catids . ")"; } //NEW MUSLTICATS /*Old kosmosa for ($i=count($level_id);$i>-1;$i--) { if(isset($level_id[$i]) && $level_id[$i]) { $str = "\n AND d.cat_id = ".$level_id[$i]." AND d.level = $i"; break; } } */ $qp_array = array(); $query = "SELECT a.*, b.c_qtype as qtype_full, qc1.c_category" . "\n FROM #__lms_quiz_t_question AS a" . "\n LEFT JOIN #__lms_quiz_t_qtypes b ON b.c_id = a.c_type" . "\n LEFT JOIN #__lms_quiz_t_category as qc ON a.c_qcat = qc.c_id" . "\n LEFT JOIN #__lms_gqp_cats AS qc1 ON a.c_qcat = qc1.id" . "\n WHERE a.course_id = 0 " . "\n AND a.c_quiz_id = 0" . "\n AND a.published = 1" . ($str ? $str : ' ') . ($sql_use_ids ? $sql_use_ids : ' ') . ($qtype_id ? "\n AND a.c_type = '" . $qtype_id . "'" : '') . "\n GROUP BY a.c_id" . "\n ORDER BY a.ordering"; $JLMS_DB->setQuery($query); $JLMS_DB->query(); $total = $JLMS_DB->getNumRows(); require_once _JOOMLMS_FRONT_HOME . DS . "includes" . DS . "classes" . DS . "lms.pagination.php"; $pageNav = new JLMSPageNav($total, $limitstart, $limit); $JLMS_DB->setQuery($query, $pageNav->limitstart, $pageNav->limit); $rows = $JLMS_DB->loadObjectList(); //Tooltip Right Answer (Max - 15.04.2011) for ($i = 0; $i < count($rows); $i++) { if (in_array($rows[$i]->c_type, array(1, 2, 3))) { $right_answer = ''; $query = "SELECT c_choice" . "\n FROM" . "\n #__lms_quiz_t_choice" . "\n WHERE 1" . "\n AND c_right = 1" . "\n AND c_question_id = '" . $rows[$i]->c_id . "'"; $JLMS_DB->setQuery($query); $right_answer = $JLMS_DB->loadResult(); if (strlen($right_answer)) { $rows[$i]->right_answer = $right_answer; } } else { if (in_array($rows[$i]->c_type, array(20, 21))) { if ($rows[$i]->c_type == 20) { $select_field = "c_pool"; } else { if ($rows[$i]->c_type == 21) { $select_field = "c_pool_gqp"; } } $query = "SELECT " . $select_field . "\n FROM" . "\n #__lms_quiz_t_question" . "\n WHERE 1" . "\n AND c_id = '" . $rows[$i]->c_id . "'"; $JLMS_DB->setQuery($query); $question_id = $JLMS_DB->loadResult(); $right_answer = ''; if (intval($question_id)) { $query = "SELECT b.c_choice" . "\n FROM" . "\n #__lms_quiz_t_question as a" . "\n, #__lms_quiz_t_choice as b" . "\n WHERE 1" . "\n AND a.c_id = '" . $question_id . "'" . "\n AND b.c_question_id = '" . $question_id . "'" . "\n AND a.c_type IN (" . implode(',', array(1, 2, 3)) . ")" . "\n AND b.c_right = 1"; $JLMS_DB->setQuery($query); $right_answer = $JLMS_DB->loadResult(); } if (strlen($right_answer)) { $rows[$i]->right_answer = $right_answer; } } } } //Tooltip Right Answer (Max - 15.04.2011) /*old kosmosa if(mosGetParam($_REQUEST,'filter_id_0') || isset($_SESSION['GQP_filter_id_0'])) { for($i=0;$i<count($rows);$i++) { $new_level = $rows[$i]->level+1; $query = "SELECT b.c_category FROM #__lms_gqp_levels AS a, #__lms_gqp_cats AS b WHERE a.quest_id = '".$rows[$i]->c_id."' AND a.cat_id = b.id AND a.level = '".$new_level."'"; $JLMS_DB->SetQuery($query); $cat_name = $JLMS_DB->LoadResult(); if($cat_name) { $rows[$i]->c_category = $cat_name; } } } */ // $qp_array[] = mosHTML::makeOption( 0, '- Select question -' ); // for ($i=0, $n=count( $rows ); $i < $n; $i++) { // if (strlen($rows[$i]->text) > 30) { // $text = substr($rows[$i]->text,0,30)."..."; // } else { // $text = $qp_list[$i]->text; // } // $qp_array[] = mosHTML::makeOption( $qp_list[$i]->value, $text ); // } // $pool_quests = mosHTML::selectList( $qp_array, 'c_pool', 'class="inputbox" size="1"', 'value', 'text', intval( $row->c_pool ) ); // $lists['pool_quests'] = $pool_quests; $query = "SELECT c_id AS value, c_qtype AS text" . "\n FROM #__lms_quiz_t_qtypes" . "\n ORDER BY c_id"; $JLMS_DB->setQuery($query); $qtypes_lang = $JLMS_DB->loadObjectList(); for ($i = 0; $i < count($qtypes_lang); $i++) { $j = $i + 1; $str = '_JLMS_QUIZ_QTYPE_' . $j; if (defined($str)) { $qtypes_lang[$i]->value = $j; $qtypes_lang[$i]->text = constant($str); } } $qtypes[] = mosHTML::makeOption('0', _JLMS_SB_QUIZ_SELECT_QTYPE); $qtypes = array_merge($qtypes, $qtypes_lang); $qtype = mosHTML::selectList($qtypes, 'qtype_id', 'class="inputbox" style="width:200px" size="1" ' . $javascript, 'value', 'text', $qtype_id); $lists['qtype'] = $qtype; $lists['qtype_id'] = $qtype_id; $lists['published'] = mosHTML::yesnoradioList('published', '', 1); JLMS_quiz_admin_html_class::JQ_editQuest_Pool_GQP($row, $lists, $option, $page, $course_id, 21, $qtype_str, $rows, $pageNav, $levels); } else { // $query = "SELECT a.c_id AS value, a.c_question AS text" // . "\n FROM #__lms_quiz_t_question AS a " // . "\n , #__lms_gqp_levels d, #__lms_gqp_cats qc1" // . "\n WHERE a.course_id = 0 " // . "\n AND a.c_quiz_id = 0" // . "\n AND d.quest_id = a.c_id AND d.cat_id =qc1.id " // . "\n GROUP BY d.quest_id" // . "\n ORDER BY a.ordering" // ; // // $qp_array = array(); // $JLMS_DB->setQuery( $query ); // $qp_list = $JLMS_DB->loadObjectList(); // // $qp_array[] = mosHTML::makeOption( 0, '- Select question -' ); // // for ($i=0, $n=count( $qp_list ); $i < $n; $i++) { // if (strlen($qp_list[$i]->text) > 30) { // $text = substr($qp_list[$i]->text,0,30)."..."; // } else { // $text = $qp_list[$i]->text; // } // $qp_array[] = mosHTML::makeOption( $qp_list[$i]->value, $text ); // } // // $pool_quests = mosHTML::selectList( $qp_array, 'c_pool', 'class="inputbox" size="1"', 'value', 'text', intval( $row->c_pool_gqp ) ); // $lists['pool_quests'] = $pool_quests; // JLMS_quiz_admin_html_class::JQ_editQuest_Pool_gqp_edit($row, $lists, $option, $page, $course_id, 21, $qtype_str); } break; } }
function updateFiles() { $dir = $this->path . $this->name . '/'; $langfiles = mosReadDirectory($dir, '.po$'); set_time_limit(60); foreach ($langfiles as $lf) { $domain = substr($lf, 0, -3); $catalog = new PHPGettext_Catalog($domain, $this->path); $catalog->setproperty('lang', $this->name); $catalog->setproperty('mode', _MODE_PO_); $catalog->load(); $file['filename'] = "language/" . $this->name . '/' . $lf; $file['domain'] = $domain; $file['strings'] = count($catalog->strings); $file['percent'] = ''; $file['translated'] = 0; $file['fuzzy'] = 0; $file['filetype'] = 'po'; $pluralfuzz = false; foreach ($catalog->strings as $msg) { if (is_array($msg->msgstr)) { foreach ($msg->msgstr as $i) { $unt = empty($i); } if (!$unt) { $file['translated']++; } } if (!is_array($msg->msgstr) && !empty($msg->msgstr) && !$msg->is_fuzzy) { $file['translated']++; } if ($msg->is_fuzzy) { $file['fuzzy']++; } } $nonfuzzy = $file['strings'] - $file['fuzzy']; if (!$nonfuzzy) { $nonfuzzy = 1; } $file['percent'] = round($file['translated'] * 100 / $nonfuzzy, 2); unset($nonfuzzy); $this->files[] = $file; } $this->files[] = array('filename' => "language/" . $this->name . '.xml', 'domain' => "", 'strings' => "", 'percent' => "", 'translated' => 0, 'fuzzy' => 0, 'filetype' => 'xml'); $langfiles = mosReadDirectory($dir . 'LC_MESSAGES/', '.mo$'); set_time_limit(60); foreach ($langfiles as $lf) { $this->files[] = array('filename' => "language/" . $this->name . '/LC_MESSAGES/' . $lf, 'domain' => "", 'strings' => "", 'percent' => "", 'translated' => 0, 'fuzzy' => 0, 'filetype' => 'mo'); } if (file_exists($this->path . '/glossary/' . $this->name . "." . $this->charset . ".po")) { $this->files[] = array('filename' => "language/glossary/" . $this->name . "." . $this->charset . ".po", 'domain' => "", 'strings' => "", 'percent' => "", 'translated' => 0, 'fuzzy' => 0, 'filetype' => 'gl'); } }
function getHelpTOC($helpsearch) { global $mosConfig_absolute_path; $files = mosReadDirectory($mosConfig_absolute_path . '/help/', '.xml$'); require_once $mosConfig_absolute_path . '/includes/domit/xml_domit_lite_include.php'; $toc = array(); foreach ($files as $file) { $xmlDoc =& new DOMIT_Lite_Document(); if ($xmlDoc->loadXML($mosConfig_absolute_path . '/help/' . $file, false, true)) { $elem = $xmlDoc->getElementsByPath('title', 1); if ($elem) { if ($helpsearch) { if (strpos($xmlDoc->getText(), $helpsearch) !== false) { $toc[$file] = $elem->getText(); } } else { $toc[$file] = $elem->getText(); } } } } asort($toc); return $toc; }
function copy_dir($source, $dest) { // copy dir $ok = true; if (!@mkdir($dest, 0777)) { return false; } $itemlist = mosReadDirectory($source, '.', true, true); if (empty($itemlist)) { return false; } foreach ($itemlist as $file) { if ($file == ".." || $file == ".") { continue; } $new_dest = str_replace($source, $dest, $file); if (@is_dir($file)) { @mkdir($new_dest, 0777); } else { $ok = @copy($file, $new_dest); } } return $ok; }
/** * Custom install method * @param int The id of the module * @param string The URL option * @param int The client id */ function uninstall($cid, $option, $client = 0) { global $database, $mosConfig_absolute_path; $uninstallret = ""; $sql = "SELECT * FROM #__components WHERE id={$cid}"; $database->setQuery($sql); $row = null; if (!$database->loadObject($row)) { HTML_installer::showInstallMessage($database->stderr(true), 'Uninstall - error', $this->returnTo($option, 'component', $client)); exit; } if ($row->iscore) { HTML_installer::showInstallMessage("Component {$row->name} is a core component, and can not be uninstalled.<br />You need to unpublish it if you don't want to use it", 'Uninstall - error', $this->returnTo($option, 'component', $client)); exit; } // Delete entries in the DB $sql = "DELETE FROM #__components WHERE parent={$row->id}"; $database->setQuery($sql); if (!$database->query()) { HTML_installer::showInstallMessage($database->stderr(true), 'Uninstall - error', $this->returnTo($option, 'component', $client)); exit; } $sql = "DELETE FROM #__components WHERE id={$row->id}"; $database->setQuery($sql); if (!$database->query()) { HTML_installer::showInstallMessage($database->stderr(true), 'Uninstall - error', $this->returnTo($option, 'component', $client)); exit; } // Try to find the uninstall file $filesindir = mosReadDirectory($mosConfig_absolute_path . '/administrator/components/' . $row->option, 'uninstall'); if (count($filesindir) > 0) { $uninstall_file = $filesindir[0]; if (file_exists($mosConfig_absolute_path . '/administrator/components/' . $row->option . '/' . $uninstall_file)) { require_once $mosConfig_absolute_path . '/administrator/components/' . $row->option . '/' . $uninstall_file; $uninstallret = com_uninstall(); } } // Try to find the XML file $filesindir = mosReadDirectory(mosPathName($mosConfig_absolute_path . '/administrator/components/' . $row->option), '.xml$'); if (count($filesindir) > 0) { $ismosinstall = false; foreach ($filesindir as $file) { $xmlDoc =& new DOMIT_Lite_Document(); $xmlDoc->resolveErrors(true); if (!$xmlDoc->loadXML($mosConfig_absolute_path . "/administrator/components/" . $row->option . "/" . $file, false, true)) { return false; } $element =& $xmlDoc->documentElement; if ($element->getTagName() != 'mosinstall') { HTML_installer::showInstallMessage('XML File invalid', 'Uninstall - error', $this->returnTo($option, 'component', $client)); exit; } $query_element =& $xmlDoc->getElementsbyPath('uninstall/queries', 1); if (!is_null($query_element)) { $queries = $query_element->childNodes; foreach ($queries as $query) { $database->setQuery($query->getText()); if (!$database->query()) { HTML_installer::showInstallMessage($database->stderr(true), 'Uninstall - error', $this->returnTo($option, 'component', $client)); exit; } } } } } else { /* HTML_installer::showInstallMessage( 'Could not find XML Setup file in '.$mosConfig_absolute_path.'/administrator/components/'.$row->option, 'Uninstall - error', $option, 'component' ); exit(); */ } // Delete directories if (trim($row->option)) { $result = 0; $path = mosPathName($mosConfig_absolute_path . '/administrator/components/' . $row->option); if (is_dir($path)) { $result |= deldir($path); } $path = mosPathName($mosConfig_absolute_path . '/components/' . $row->option); if (is_dir($path)) { $result |= deldir($path); } return $result; } else { HTML_installer::showInstallMessage('Option field empty, cannot remove files', 'Uninstall - error', $option, 'component'); exit; } return $uninstallret; }
/** * Displays a selection list for menu item types */ function addMenuItem(&$cid, $menutype, $option, $task) { global $mosConfig_absolute_path; $types = array(); // list of directories $dirs = mosReadDirectory($mosConfig_absolute_path . '/administrator/components/com_menus'); // load files for menu types foreach ($dirs as $dir) { // needed within menu type .php files $type = $dir; $dir = $mosConfig_absolute_path . '/administrator/components/com_menus/' . $dir; if (is_dir($dir)) { $files = mosReadDirectory($dir, ".\\.menu\\.php\$"); foreach ($files as $file) { require_once "{$dir}/{$file}"; // type of menu type $types[]->type = $type; } } } $i = 0; foreach ($types as $type) { // pulls name and description from menu type xml $row = ReadMenuXML($type->type); $types[$i]->name = $row[0]; $types[$i]->descrip = $row[1]; $types[$i]->group = $row[2]; $i++; } // sort array of objects alphabetically by name of menu type SortArrayObjects($types, 'name', 1); // split into Content $i = 0; foreach ($types as $type) { if (strstr($type->group, 'Content')) { $types_content[] = $types[$i]; } $i++; } // split into Links $i = 0; foreach ($types as $type) { if (strstr($type->group, 'Link')) { $types_link[] = $types[$i]; } $i++; } // split into Component $i = 0; foreach ($types as $type) { if (strstr($type->group, 'Component')) { $types_component[] = $types[$i]; } $i++; } // split into Other $i = 0; foreach ($types as $type) { if (strstr($type->group, 'Other') || !$type->group) { $types_other[] = $types[$i]; } $i++; } HTML_menusections::addMenuItem($cid, $menutype, $option, $types_content, $types_component, $types_link, $types_other); }
/** * Compiles the help table of contents * @param string A specific keyword on which to filter the resulting list */ function getHelpTOC($helpsearch) { global $mosConfig_absolute_path; $helpurl = strval(mosGetParam($GLOBALS, 'mosConfig_helpurl', '')); $files = mosReadDirectory($mosConfig_absolute_path . '/help/', '\\.xml$|\\.html$'); require_once $mosConfig_absolute_path . '/includes/domit/xml_domit_lite_include.php'; $toc = array(); foreach ($files as $file) { $buffer = file_get_contents($mosConfig_absolute_path . '/help/' . $file); if (preg_match('#<title>(.*?)</title>#', $buffer, $m)) { $title = trim($m[1]); if ($title) { if ($helpurl) { // strip the extension $file = preg_replace('#\\.xml$|\\.html$#', '', $file); } if ($helpsearch) { if (strpos(strip_tags($buffer), $helpsearch) !== false) { $toc[$file] = $title; } } else { $toc[$file] = $title; } } } } asort($toc); return $toc; }
/** * @var string The name of the form element * @var string The value of the element * @var object The xml element for the parameter * @return string The html for the element */ function _form_imagelist($name, $value, &$node) { global $mosConfig_absolute_path; // path to images directory $path = $mosConfig_absolute_path . $node->getAttribute('directory'); $files = mosReadDirectory($path, '\\.png$|\\.gif$|\\.jpg$|\\.bmp$|\\.ico$'); $options = array(); foreach ($files as $file) { $options[] = mosHTML::makeOption($file, $file); } if (!$node->getAttribute('hide_none')) { array_unshift($options, mosHTML::makeOption('-1', '- Do not use an image -')); } if (!$node->getAttribute('hide_default')) { array_unshift($options, mosHTML::makeOption('', '- Use Default image -')); } return mosHTML::selectList($options, "params[{$name}]", "class=\"inputbox\"", 'value', 'text', $value); }
/** * Compiles a list of installed languages */ function viewLanguages($option) { global $languages, $adminLanguage; global $mainframe; global $mosConfig_lang, $mosConfig_absolute_path, $mosConfig_list_limit; $limit = $mainframe->getUserStateFromRequest("viewlistlimit", 'limit', $mosConfig_list_limit); $limitstart = $mainframe->getUserStateFromRequest("view{$option}limitstart", 'limitstart', 0); // get current languages $cur_language = $mosConfig_lang; $rows = array(); // Read the template dir to find templates $languageBaseDir = mosPathName(mosPathName($mosConfig_absolute_path) . "language"); $rowid = 0; $xmlFilesInDir = mosReadDirectory($languageBaseDir, ".xml"); $dirName = $languageBaseDir; foreach ($xmlFilesInDir as $xmlfile) { // Read the file to see if it's a valid template XML file $xmlDoc =& new DOMIT_Lite_Document(); $xmlDoc->resolveErrors(true); if (!$xmlDoc->loadXML($dirName . $xmlfile, false, true)) { continue; } $element =& $xmlDoc->documentElement; if ($element->getTagName() != 'mosinstall') { continue; } if ($element->getAttribute("type") != "language") { continue; } $row = new StdClass(); $row->id = $rowid; $row->language = substr($xmlfile, 0, -4); $element =& $xmlDoc->getElementsByPath('name', 1); $row->name = $element->getText(); $element =& $xmlDoc->getElementsByPath('creationDate', 1); $row->creationdate = $element ? $element->getText() : 'Unknown'; $element =& $xmlDoc->getElementsByPath('author', 1); $row->author = $element ? $element->getText() : 'Unknown'; $element =& $xmlDoc->getElementsByPath('copyright', 1); $row->copyright = $element ? $element->getText() : ''; $element =& $xmlDoc->getElementsByPath('authorEmail', 1); $row->authorEmail = $element ? $element->getText() : ''; $element =& $xmlDoc->getElementsByPath('authorUrl', 1); $row->authorUrl = $element ? $element->getText() : ''; $element =& $xmlDoc->getElementsByPath('version', 1); $row->version = $element ? $element->getText() : ''; // if current than set published if ($cur_language == $row->language) { $row->published = 1; } else { $row->published = 0; } $row->checked_out = 0; $row->mosname = strtolower(str_replace(" ", "_", $row->name)); $rows[] = $row; $rowid++; } require_once $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php'; $pageNav = new mosPageNav(count($rows), $limitstart, $limit); $rows = array_slice($rows, $pageNav->limitstart, $pageNav->limit); HTML_languages::showLanguages($cur_language, $rows, $pageNav, $option); }
/** * Zip & TarGzip Functions */ function archive_items($dir) { global $mosConfig_absolute_path; if (($GLOBALS["permissions"] & 01) != 01) { show_error($GLOBALS["error_msg"]["accessfunc"]); } if (!$GLOBALS["zip"] && !$GLOBALS["tgz"]) { show_error($GLOBALS["error_msg"]["miscnofunc"]); } $allowed_types = array('zip', 'tgz', 'tbz', 'tar'); $actionURL = str_replace("index2.php", "index3.php", make_link("arch", $dir, NULL)); // If we have something to archive, let's do it now if (isset($GLOBALS['__POST']["name"])) { $saveToDir = $GLOBALS['__POST']['saveToDir']; if (!file_exists(get_abs_dir($saveToDir))) { echo jx_scriptTag('', '$(\'loadingindicator\').style.display=\'none\';'); echo jx_alertBox('The Save-To Directory you have specified does not exist.'); die('The Save-To Directory you have specified does not exist.'); } if (!is_writable(get_abs_dir($saveToDir))) { echo jx_scriptTag('', '$(\'loadingindicator\').style.display=\'none\';'); echo jx_alertBox('Please specify a writable directory to save the archive to.'); die('Please specify a writable directory to save the archive to.'); } require_once _QUIXPLORER_PATH . '/libraries/Archive.php'; if (!in_array(strtolower($GLOBALS['__POST']["type"]), $allowed_types)) { echo 'Unknown Archive Format: ' . htmlspecialchars($GLOBALS['__POST']["type"]); jx_exit(); } while (@ob_end_clean()) { } header('Status: 200 OK'); echo '<?xml version="1.0" ?>' . "\n"; $files_per_step = 2500; $cnt = count($GLOBALS['__POST']["selitems"]); $abs_dir = get_abs_dir($dir); $name = basename(stripslashes($GLOBALS['__POST']["name"])); if ($name == "") { show_error($GLOBALS["error_msg"]["miscnoname"]); } $download = mosGetParam($_REQUEST, 'download', "n"); $startfrom = mosGetParam($_REQUEST, 'startfrom', 0); $archive_name = get_abs_item($saveToDir, $name); $fileinfo = pathinfo($archive_name); if (empty($fileinfo['extension'])) { $archive_name .= "." . $GLOBALS['__POST']["type"]; $fileinfo['extension'] = $GLOBALS['__POST']["type"]; } foreach ($allowed_types as $ext) { if ($GLOBALS['__POST']["type"] == $ext && @$fileinfo['extension'] != $ext) { $archive_name .= "." . $ext; } } for ($i = 0; $i < $cnt; $i++) { $selitem = stripslashes($GLOBALS['__POST']["selitems"][$i]); if (is_dir($abs_dir . "/" . $selitem)) { $items = mosReadDirectory($abs_dir . "/" . $selitem, '.', true, true); foreach ($items as $item) { if (is_dir($item) || !is_readable($item) || $item == $archive_name) { continue; } $v_list[] = $item; } } else { $v_list[] = $abs_dir . "/" . $selitem; } } $cnt_filelist = count($v_list); $remove_path = $GLOBALS["home_dir"]; if ($dir) { $remove_path .= $dir . $GLOBALS['separator']; } for ($i = $startfrom; $i < $cnt_filelist && $i < $startfrom + $files_per_step; $i++) { $filelist[] = File_Archive::read($v_list[$i], str_replace($remove_path, '', $v_list[$i])); } //echo '<strong>Starting from: '.$startfrom.'</strong><br />'; //echo '<strong>Files to process: '.$cnt_filelist.'</strong><br />'; //print_r( $filelist );exit; // Do some setup stuff ini_set('memory_limit', '128M'); @set_time_limit(0); error_reporting(E_ERROR | E_PARSE); $result = File_Archive::extract($filelist, $archive_name); if (PEAR::isError($result)) { echo $name . ": Failed saving Archive File. Error: " . $result->getMessage(); jx_exit(); } if ($cnt_filelist > $startfrom + $files_per_step) { echo "\n <script type=\"text/javascript\">document.archform.startfrom.value = '" . ($startfrom + $files_per_step) . "';</script>\n"; echo '<script type="text/javascript"> doArchiving( \'' . $actionURL . '\' );</script>'; printf($GLOBALS['messages']['processed_x_files'], $startfrom + $files_per_step, $cnt_filelist); } else { if ($GLOBALS['__POST']["type"] == 'tgz' || $GLOBALS['__POST']["type"] == 'tbz') { chmod($archive_name, 0644); } if ($download == "y") { echo '<script type="text/javascript">document.location=\'' . make_link('download', dirname($archive_name), basename($archive_name)) . '\';</script>'; } else { echo '<script type="text/javascript">document.location=\'' . str_replace("index3.php", "index2.php", make_link("list", $dir, NULL)) . '&mosmsg=The%20Archive%20File%20has%20been%20created\';</script>'; } } jx_exit(); } ?> <script type="text/javascript" src="components/com_joomlaxplorer/scripts/functions.js"></script> <script type="text/javascript"> function doArchiving( url ) { showLoadingIndicator( $('loadingindicator'), true ); $('loadingindicator').style.display = ''; var controller = new Ajax( url, { postBody: $('adminform'), evalScripts: true, update: 'statustext' } ); controller.request(); return false; }</script> <?php show_header($GLOBALS["messages"]["actarchive"]); ?> <br/> <form name="archform" method="post" action="<?php echo $actionURL; ?> " onsubmit="return doArchiving(this.action);" id="adminform"> <input type="hidden" name="no_html" value="1" /> <input type="hidden" name="startfrom" value="0" /> <?php $cnt = count($GLOBALS['__POST']["selitems"]); for ($i = 0; $i < $cnt; ++$i) { echo '<input type="hidden" name="selitems[]" value="' . stripslashes($GLOBALS['__POST']["selitems"][$i]) . '">'; } ?> <table class="adminform" style="width:600px;"> <tr><td colspan="2" style="text-align:center;display:none;" id="loadingindicator"><strong><?php echo $GLOBALS['messages']['creating_archive']; ?> </strong></td></tr> <tr><td colspan="2" style="font-weight:bold;text-align:center" id="statustext"> </td></tr> <tr><td><?php echo $GLOBALS['messages']['archive_name']; ?> :</td> <td align="left"> <input type="text" name="name" size="25" value="<?php echo $dir != '' ? basename($dir) : $GLOBALS['__POST']["selitems"][0]; ?> " /> </td> </tr> <tr><td><?php echo $GLOBALS["messages"]["typeheader"]; ?> :</td> <td align="left"> <select name="type"> <?php if (extension_loaded("zlib")) { echo '<option value="zip">Zip (' . $GLOBALS["messages"]['normal_compression'] . ')</option>' . "\n"; echo '<option value="tgz">Tar/Gz (' . $GLOBALS["messages"]['good_compression'] . ')</option>' . "\n"; } if (extension_loaded("bz2")) { echo '<option value="tbz">Tar/Bzip2 (' . $GLOBALS["messages"]['best_compression'] . ')</option>' . "\n"; } echo '<option value="" disabled="disabled"> - - - - - - -</option>' . "\n"; echo '<option value="tar">Tar (' . $GLOBALS["messages"]['no_compression'] . ')</option>' . "\n"; ?> </select> </td> </tr> <tr><td><?php echo $GLOBALS['messages']['archive_saveToDir']; ?> :</td> <td align="left"> <input type="text" name="saveToDir" size="50" value="<?php echo $dir; ?> " /> </td> </tr> <tr><td><?php echo $GLOBALS["messages"]["downlink"]; ?> ?:</td> <td align="left"> <input type="checkbox" checked="checked" name="download" value="y" /> </td> </tr> <tr> <td colspan="2" style="text-align:center;"> <input type="submit" value="<?php echo $GLOBALS["messages"]["btncreate"]; ?> "> <input type="button" value="<?php echo $GLOBALS["messages"]["btncancel"]; ?> " onclick="javascript:location='<?php echo make_link("list", $dir, NULL); ?> ';"> </td> </tr> <tr><td colspan="2"> </td></tr> </table> </form> <br/> <script type="text/javascript">if(document.archform) document.archform.name.focus();</script> <?php }
/** * Displays a selection list for menu item types */ function addMenuItem(&$cid, $menutype, $option) { global $database, $mosConfig_absolute_path; $types = array(); $dirs = mosReadDirectory($mosConfig_absolute_path . '/administrator/components/com_menus'); foreach ($dirs as $dir) { $dir = $mosConfig_absolute_path . '/administrator/components/com_menus/' . $dir; if (is_dir($dir)) { $files = mosReadDirectory($dir, ".\\.menu\\.php\$"); foreach ($files as $file) { require_once "{$dir}/{$file}"; } } } // renames menu names $i = 0; foreach ($types as $type) { $text = RenameMenu($type->value); $types[$i]->text = $text; $i++; } // sort array of objects SortArrayObjects($types, 'text', 1); $lists['select'] = mosHTML::selectList($types, 'type', 'class="inputbox" size="20"', 'value', 'text'); HTML_menusections::addMenuItem($cid, $lists, $menutype, $option); }
/** * Tries to find the package XML file * @return boolean True on success, False on error */ function findInstallFile() { $found = false; // Search the install dir for an xml file $files = mosReadDirectory($this->installDir(), '.xml$', true, true); if (count($files) > 0) { foreach ($files as $file) { $packagefile = $this->isPackageFile($file); if (!is_null($packagefile) && !$found) { $this->xmlDoc($packagefile); return true; } } $this->setError(1, 'ERROR: Could not find a Joomla! XML setup file in the package.'); return false; } else { $this->setError(1, 'ERROR: Could not find a Joomla! XML setup file in the package.'); return false; } }
/** * Compiles information to add or edit a module * @param string The current GET/POST option * @param integer The unique id of the record to edit */ function editMambot($option, $uid, $client) { global $database, $my, $mainframe, $adminLanguage; global $mosConfig_absolute_path; $lists = array(); $row = new mosMambot($database); // load the row from the db table $row->load($uid); // fail if checked out not by 'me' if ($row->checked_out && $row->checked_out != $my->id) { echo "<script>alert(\"" . $adminLanguage->A_COMP_CONTENT_MODULE . " " . $row->title . " " . $adminLanguage->A_COMP_MAMB_EDIT . "\"); document.location.href='index2.php?option={$option}'</script>\n"; exit(0); } if ($uid) { $row->checkout($my->id); } if ($client == 'admin') { $where = "client_id='1'"; } else { $where = "client_id='0'"; } if (!$uid) { $row->folder = ''; $row->ordering = 999; $row->published = 1; } // get list of groups if ($row->access == 99 || $row->client_id == 1) { $lists['access'] = 'Administrator<input type="hidden" name="access" value="99" />'; } else { // build the html select list for the group access $lists['access'] = mosAdminMenus::Access($row); } $lists['published'] = mosHTML::yesnoRadioList('published', 'class="inputbox"', $row->published); if ($uid) { if ($row->ordering > -10000 && $row->ordering < 10000) { // build the html select list for ordering $query = "SELECT ordering AS value, name AS text" . "\n FROM #__mambots" . "\n WHERE folder='{$row->folder}'" . "\n AND published > 0" . "\n AND {$where}" . "\n AND ordering > -10000" . "\n AND ordering < 10000" . "\n ORDER BY ordering"; $order = mosGetOrderingList($query); $lists['ordering'] = mosHTML::selectList($order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval($row->ordering)); } else { $lists['ordering'] = '<input type="hidden" name="ordering" value="' . $row->ordering . '" />This mambot cannot be reordered'; } $lists['folder'] = '<input type="hidden" name="folder" value="' . $row->folder . '" />' . $row->folder; } else { $lists['ordering'] = '<input type="hidden" name="ordering" value="' . $row->ordering . '" />New items default to the last place'; $folders = mosReadDirectory($mosConfig_absolute_path . '/mambots/'); $folders2 = array(); foreach ($folders as $folder) { if (is_dir($mosConfig_absolute_path . '/mambots/' . $folder)) { $folders2[] = mosHTML::makeOption($folder); } } $lists['folder'] = mosHTML::selectList($folders2, 'folder', 'class="inputbox" size="1"', 'value', 'text', null); } $row->description = ''; // XML library require_once $mosConfig_absolute_path . '/includes/domit/xml_domit_lite_include.php'; // xml file for module $xmlfile = $mosConfig_absolute_path . '/mambots/' . $row->folder . '/' . $row->element . '.xml'; $xmlDoc =& new DOMIT_Lite_Document(); $xmlDoc->resolveErrors(true); if ($xmlDoc->loadXML($xmlfile, false, true)) { $element =& $xmlDoc->documentElement; if ($element->getTagName() == 'mosinstall' && $element->getAttribute('type') == 'mambot') { $element =& $xmlDoc->getElementsByPath('description', 1); $row->description = $element ? trim($element->getText()) : ''; } } // get params definitions $params =& new mosParameters($row->params, $mainframe->getPath('bot_xml', $row->folder . '/' . $row->element), 'mambot'); HTML_modules::editMambot($row, $lists, $params, $option); }
/** * @param string The name of the form element * @param string The value of the element * @param object The xml element for the parameter * @param string The control name * @return string The html for the element */ function _form_filelist($name, $value, &$node, $control_name) { // path to images directory $path = JPATH_ROOT . $node->getAttribute('directory'); $filter = $node->getAttribute('filter'); $files = mosReadDirectory($path, $filter); $options = array(); foreach ($files as $file) { $options[] = JHTML::_('select.option', $file, $file); } if (!$node->getAttribute('hide_none')) { array_unshift($options, JHTML::_('select.option', '-1', '- ' . 'Do Not Use' . ' -')); } if (!$node->getAttribute('hide_default')) { array_unshift($options, JHTML::_('select.option', '', '- ' . 'Use Default' . ' -')); } return JHTML::_('select.genericlist', $options, '' . $control_name . '[' . $name . ']', 'class="inputbox"', 'value', 'text', $value, "param{$name}"); }