function &loadDefaultsParams($asText) { global $mosConfig_absolute_path; $path = $this->getXmlPath(); $xmlDoc = new DOMIT_Lite_Document(); $xmlDoc->resolveErrors(true); $params = null; if ($xmlDoc->loadXML($path, false, true)) { $root =& $xmlDoc->documentElement; $tagName = $root->getTagName(); $isParamsFile = $tagName == 'mosinstall' || $tagName == 'install' || $tagName == 'mosparams'; if ($isParamsFile && $root->getAttribute('type') == 'xmap_ext') { $params =& $root->getElementsByPath('params', 1); } } $result = $asText ? '' : array(); if (is_object($params)) { foreach ($params->childNodes as $param) { $name = $param->getAttribute('name'); $label = $param->getAttribute('label'); $key = $name ? $name : $label; if ($label != '@spacer' && $name != '@spacer') { $value = str_replace("\n", '\\n', $param->getAttribute('default')); if ($asText) { $result .= "{$key}={$value}\n"; } else { $result[$key] = $value; } } } } return $result; }
/** * Main conversion/import function. Processes XML file */ function doConversion() { $kunena_db =& JFactory::getDBO(); require_once KUNENA_ROOT_PATH . DS . 'includes/domit/xml_domit_lite_include.php'; if (!$this->silent) { ?> <script language=JavaScript> function showDetail(srcElement) { var targetID, srcElement, targetElement, imgElementID, imgElement; targetID = srcElement.id + "_details"; imgElementID = srcElement.id + "_img"; targetElement = document.getElementById(targetID); imgElement = document.getElementById(imgElementID); if (targetElement.style.display == "none") { targetElement.style.display = ""; imgElement.src = "images/collapseall.png"; } else { targetElement.style.display = "none"; imgElement.src = "images/expandall.png"; } } </script> <style> .details { font-family: courier; background-color: #EEEEEE; border: 1px dashed #BBBBBB; padding-left: 10px; margin-left: 20px; margin-top: 5px; </style> <?php } $componentBaseDir = ''; $this->_converterDir = KUNENA_PATH_ADMIN . DS . $this->subdir; //initiate XML doc $xmlDoc = new DOMIT_Lite_Document(); $xmlDoc->loadXML($this->converterDir . DS . $this->xmlFileName, false, true); //load root element and check XML version (for future use) $root =& $xmlDoc->documentElement; $comUpgradeVersion = $root->getAttribute("version"); $importElement =& $root->firstChild; $versionNumber = $importElement->getAttribute("version"); $versionDate = $importElement->getAttribute("date"); //import mode, run import queries $importElement = $root->getElementsByPath('import', 1); if (!is_null($importElement)) { $this->processNode($importElement, 1); } if (!$this->silent) { ?> </table> <?php } }
/** * Loads a definition file. * @param string $file The name of the file you want to load. Relative to 'installers' directory. * @return boolean True if it has loaded the file successfuly */ function loadDefinition($file) { // Instanciate new parser object $xmlDoc = new DOMIT_Lite_Document(); $xmlDoc->resolveErrors(true); // Load XML file if (!$xmlDoc->loadXML(JPATH_COMPONENT_ADMINISTRATOR . DS . 'assets' . DS . 'installers' . DS . $file, false, true)) { return false; } $root =& $xmlDoc->documentElement; // Check if it is a valid description file if ($root->getTagName() != 'jpconfig') { return false; } elseif ($root->getAttribute('type') != 'installpack') { return false; } // Set basic elements $e =& $root->getElementsByPath('name', 1); $this->Name = $e->getText(); $e =& $root->getElementsByPath('package', 1); $this->Package = $e->getText(); $sqlDumpRoot =& $root->getElementsByPath('sqldump', 1); $this->SQLDumpMode = $sqlDumpRoot->getAttribute('mode'); // Get SQL filenames if ($sqlDumpRoot->hasChildNodes()) { $e = $sqlDumpRoot->getElementsByPath('basedump', 1); if (!is_null($e)) { $this->BaseDump = $e->getText(); } else { $this->BaseDump = ""; } $e = $sqlDumpRoot->getElementsByPath('sampledump', 1); if (!is_null($e)) { $this->SampleDump = $e->getText(); } else { $this->SampleDump = ""; } } // Get file list $this->fileList = array(); $flRoot =& $root->getElementsByPath('filelist', 1); if (!is_null($flRoot)) { if ($flRoot->hasChildNodes()) { $files = $flRoot->childNodes; foreach ($files as $file) { $this->fileList[] = $file->getText(); } } } return true; }
/** * @param string The URL option */ function showInstalledComponents($option) { global $database, $mosConfig_absolute_path; $query = "SELECT *" . "\n FROM #__components" . "\n WHERE parent = 0" . "\n AND iscore = 0" . "\n ORDER BY name"; $database->setQuery($query); $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 = $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; } $root =& $xmlDoc->documentElement; if ($root->getTagName() != 'mosinstall') { continue; } if ($root->getAttribute("type") != "component") { continue; } $element =& $root->getElementsByPath('creationDate', 1); $row->creationdate = $element ? $element->getText() : 'Unknown'; $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() : ''; $row->mosname = strtolower(str_replace(" ", "_", $row->name)); } } HTML_component::showInstalledComponents($rows, $option); }
function showInstalledMambots($_option) { global $database, $mosConfig_absolute_path; $query = "SELECT id, name, folder, element, client_id" . "\n FROM #__mambots" . "\n WHERE iscore = 0" . "\n ORDER BY folder, name"; $database->setQuery($query); $rows = $database->loadObjectList(); // path to mambot directory $mambotBaseDir = mosPathName(mosPathName($mosConfig_absolute_path) . "mambots"); $id = 0; $n = count($rows); for ($i = 0; $i < $n; $i++) { $row =& $rows[$i]; // xml file for module $xmlfile = $mambotBaseDir . "/" . $row->folder . '/' . $row->element . ".xml"; if (file_exists($xmlfile)) { $xmlDoc = new DOMIT_Lite_Document(); $xmlDoc->resolveErrors(true); if (!$xmlDoc->loadXML($xmlfile, false, true)) { continue; } $root =& $xmlDoc->documentElement; if ($root->getTagName() != 'mosinstall') { continue; } if ($root->getAttribute("type") != "mambot") { continue; } $element =& $root->getElementsByPath('creationDate', 1); $row->creationdate = $element ? $element->getText() : ''; $element =& $root->getElementsByPath('author', 1); $row->author = $element ? $element->getText() : ''; $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() : ''; } } HTML_mambot::showInstalledMambots($rows, $_option, $id, $xmlfile); }
/** * Returns component's version info from .xml file * * @return object Object with two fields: releaseVersion and releaseDate */ function getVersionInfo() { static $versionInfo; global $mainframe; if (!isset($versionInfo)) { $versionInfo = new StdClass(); $versionInfo->releaseVersion = 'x.x.x.x'; $versionInfo->releaseDate = date('Y'); $file = JCOMMENTS_ADMIN . DS . 'jcomments.xml'; if (!is_file($file)) { $file = JCOMMENTS_ADMIN . DS . 'jcomments10.xml'; if (!is_file($file)) { $file = JCOMMENTS_ADMIN . DS . 'jcomments15.xml'; if (!is_file($file)) { $file = JCOMMENTS_ADMIN . DS . 'manifest.xml'; } } } if (JCOMMENTS_JVERSION == '1.0') { require_once $mainframe->getCfg('absolute_path') . DS . 'includes' . DS . 'domit' . DS . 'xml_domit_lite_include.php'; $xmlDoc = new DOMIT_Lite_Document(); $xmlDoc->resolveErrors(false); if (is_file($file)) { if ($xmlDoc->loadXML($file, false, true)) { $root =& $xmlDoc->documentElement; if (($root->getTagName() == 'mosinstall' || $root->getTagName() == 'install') && $root->getAttribute("type") == "component") { $element =& $root->getElementsByPath('creationDate', 1); $versionInfo->releaseDate = $element ? $element->getText() : date('Y'); $element =& $root->getElementsByPath('version', 1); $versionInfo->releaseVersion = $element ? $element->getText() : ''; } } } } else { if (JCOMMENTS_JVERSION == '1.5') { $data = JApplicationHelper::parseXMLInstallFile($file); $versionInfo->releaseDate = $data['creationdate']; $versionInfo->releaseVersion = $data['version']; } } } return $versionInfo; }
function parseXMLFile($id, $xmlfile) { global $_DOCMAN; // XML library require_once JPATH_LIBRARIES . DS . 'domit' . DS . 'xml_domit_lite_include.php'; // Read the file to see if it's a valid template XML file $xmlDoc = new DOMIT_Lite_Document(); $xmlDoc->resolveErrors(true); if (!$xmlDoc->loadXML($xmlfile, false, true)) { return false; } $element =& $xmlDoc->documentElement; if ($element->getTagName() != ('install' || 'mosinstall')) { return false; } if ($element->getAttribute('type') != 'theme') { return false; } $row = new StdClass(); $row->id = $id; $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() : ''; $element =& $xmlDoc->getElementsByPath('description', 1); $row->description = $element ? trim($element->getText()) : ''; $row->mosname = strtolower(str_replace(' ', '_', $row->name)); // Get info from db if ($row->mosname == $_DOCMAN->getCfg('icon_theme')) { $row->published = 1; } else { $row->published = 0; } $row->checked_out = 0; return $row; }
/** * @param string The URL option */ function showInstalledModules($_option) { global $database, $mosConfig_absolute_path; $filter = mosGetParam($_POST, 'filter', ''); $select[] = mosHTML::makeOption('', 'All'); $select[] = mosHTML::makeOption('0', 'Site Modules'); $select[] = mosHTML::makeOption('1', 'Admin Modules'); $lists['filter'] = mosHTML::selectList($select, 'filter', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'value', 'text', $filter); if ($filter == NULL) { $and = ''; } else { if (!$filter) { $and = "\n AND client_id = 0"; } else { if ($filter) { $and = "\n AND client_id = 1"; } } } $query = "SELECT id, module, client_id" . "\n FROM #__modules" . "\n WHERE module LIKE 'mod_%' AND iscore='0'" . $and . "\n GROUP BY module, client_id" . "\n ORDER BY client_id, module"; $database->setQuery($query); $rows = $database->loadObjectList(); $n = count($rows); for ($i = 0; $i < $n; $i++) { $row =& $rows[$i]; // path to module directory if ($row->client_id == "1") { $moduleBaseDir = mosPathName(mosPathName($mosConfig_absolute_path) . "administrator/modules"); } else { $moduleBaseDir = mosPathName(mosPathName($mosConfig_absolute_path) . "modules"); } // xml file for module $xmlfile = $moduleBaseDir . "/" . $row->module . ".xml"; if (file_exists($xmlfile)) { $xmlDoc = new DOMIT_Lite_Document(); $xmlDoc->resolveErrors(true); if (!$xmlDoc->loadXML($xmlfile, false, true)) { continue; } $root =& $xmlDoc->documentElement; if ($root->getTagName() != 'mosinstall') { continue; } if ($root->getAttribute("type") != "module") { continue; } $element =& $root->getElementsByPath('creationDate', 1); $row->creationdate = $element ? $element->getText() : ''; $element =& $root->getElementsByPath('author', 1); $row->author = $element ? $element->getText() : ''; $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() : ''; } } HTML_module::showInstalledModules($rows, $_option, $xmlfile, $lists); }
/** * @param string The name of the control, or the default text area if a setup file is not found * @return string HTML */ function render($name = 'params') { if ($this->_path) { if (!is_object($this->_xmlElem)) { require_once JPATH_ROOT . DS . 'includes' . DS . 'domit' . DS . 'xml_domit_lite_include.php'; $xmlDoc = new DOMIT_Lite_Document(); $xmlDoc->resolveErrors(true); if ($xmlDoc->loadXML($this->_path, false, true)) { $root =& $xmlDoc->documentElement; $tagName = $root->getTagName(); $isParamsFile = $tagName == 'install' || $tagName == 'params' || $tagName == 'form'; if ($isParamsFile && $root->getAttribute('type') == $this->_type) { if ($params =& $root->getElementsByPath('params', 1)) { $this->_xmlElem =& $params; } } } } } if (is_object($this->_xmlElem)) { $html = array(); $html[] = '<table width="100%" class="paramlist">'; $element =& $this->_xmlElem; if ($description = $element->getAttribute('description')) { // add the params description to the display $html[] = '<tr><td colspan="2">' . $description . '</td></tr>'; } $this->_methods = get_class_methods(get_class($this)); foreach ($element->childNodes as $param) { $result = $this->renderParam($param, $name); $html[] = '<tr>'; $html[] = '<td width="40%" align="right" valign="top"><span class="editlinktip">' . $result[0] . '</span></td>'; $html[] = '<td>' . $result[1] . '</td>'; $html[] = '</tr>'; } $html[] = '</table>'; if (count($element->childNodes) < 1) { $html[] = "<tr><td colspan=\"2\"><i>" . _NO_PARAMS . "</i></td></tr>"; } return implode("\n", $html); } else { return "<textarea name=\"{$name}\" cols=\"40\" rows=\"10\" class=\"text_area\">{$this->_raw}</textarea>"; } }
function ReadMenuXML($type, $component = -1) { global $mosConfig_absolute_path; // XML library require_once $mosConfig_absolute_path . '/includes/domit/xml_domit_lite_include.php'; // xml file for module $xmlfile = $mosConfig_absolute_path . '/administrator/components/com_menus/' . $type . '/' . $type . '.xml'; $xmlDoc = new DOMIT_Lite_Document(); $xmlDoc->resolveErrors(true); if ($xmlDoc->loadXML($xmlfile, false, true)) { $root =& $xmlDoc->documentElement; if ($root->getTagName() == 'mosinstall' && ($root->getAttribute('type') == 'component' || $root->getAttribute('type') == 'menu')) { // Menu Type Name $element =& $root->getElementsByPath('name', 1); $name = $element ? trim($element->getText()) : ''; // Menu Type Description $element =& $root->getElementsByPath('description', 1); $descrip = $element ? trim($element->getText()) : ''; // Menu Type Group $element =& $root->getElementsByPath('group', 1); $group = $element ? trim($element->getText()) : ''; } } if ($component != -1 && $name == 'Component') { $name .= ' - ' . $component; } $row[0] = $name; $row[1] = $descrip; $row[2] = $group; return $row; }
/** * 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 editModule($option, $uid, $client) { global $database, $my, $mainframe; global $mosConfig_absolute_path; $lists = array(); $row = new mosModule($database); // load the row from the db table $row->load((int) $uid); // fail if checked out not by 'me' if ($row->isCheckedOut($my->id)) { mosErrorAlert("The module " . $row->title . " is currently being edited by another administrator"); } $row->content = htmlspecialchars($row->content); if ($uid) { $row->checkout($my->id); } // if a new record we must still prime the mosModule object with a default // position and the order; also add an extra item to the order list to // place the 'new' record in last position if desired if ($uid == 0) { $row->position = 'left'; $row->showtitle = true; //$row->ordering = $l; $row->published = 1; } if ($client == 'admin') { $where = "client_id = 1"; $lists['client_id'] = 1; $path = 'mod1_xml'; } else { $where = "client_id = 0"; $lists['client_id'] = 0; $path = 'mod0_xml'; } $query = "SELECT position, ordering, showtitle, title" . "\n FROM #__modules" . "\n WHERE {$where}" . "\n ORDER BY ordering"; $database->setQuery($query); if (!($orders = $database->loadObjectList())) { echo $database->stderr(); return false; } $query = "SELECT position, description" . "\n FROM #__template_positions" . "\n WHERE position != ''" . "\n ORDER BY position"; $database->setQuery($query); // hard code options for now $positions = $database->loadObjectList(); $orders2 = array(); $pos = array(); foreach ($positions as $position) { $orders2[$position->position] = array(); $pos[] = mosHTML::makeOption($position->position, $position->description); } $l = 0; $r = 0; for ($i = 0, $n = count($orders); $i < $n; $i++) { $ord = 0; if (array_key_exists($orders[$i]->position, $orders2)) { $ord = count(array_keys($orders2[$orders[$i]->position])) + 1; } $orders2[$orders[$i]->position][] = mosHTML::makeOption($ord, $ord . '::' . addslashes($orders[$i]->title)); } // build the html select list $pos_select = 'onchange="changeDynaList(\'ordering\',orders,document.adminForm.position.options[document.adminForm.position.selectedIndex].value, originalPos, originalOrder)"'; $active = $row->position ? $row->position : 'left'; $lists['position'] = mosHTML::selectList($pos, 'position', 'class="inputbox" size="1" ' . $pos_select, 'value', 'text', $active); // get selected pages for $lists['selections'] if ($uid) { $query = "SELECT menuid AS value" . "\n FROM #__modules_menu" . "\n WHERE moduleid = " . (int) $row->id; $database->setQuery($query); $lookup = $database->loadObjectList(); } else { $lookup = array(mosHTML::makeOption(0, 'All')); } if ($row->access == 99 || $row->client_id == 1 || $lists['client_id']) { $lists['access'] = 'Administrator<input type="hidden" name="access" value="99" />'; $lists['showtitle'] = 'N/A <input type="hidden" name="showtitle" value="1" />'; $lists['selections'] = 'N/A'; } else { if ($client == 'admin') { $lists['access'] = 'N/A'; $lists['selections'] = 'N/A'; } else { $lists['access'] = mosAdminMenus::Access($row); $lists['selections'] = mosAdminMenus::MenuLinks($lookup, 1, 1); } $lists['showtitle'] = mosHTML::yesnoRadioList('showtitle', 'class="inputbox"', $row->showtitle); } // build the html select list for published $lists['published'] = mosAdminMenus::Published($row); $row->description = ''; // XML library require_once $mosConfig_absolute_path . '/includes/domit/xml_domit_lite_include.php'; // xml file for module $xmlfile = $mainframe->getPath($path, $row->module); $xmlDoc = new DOMIT_Lite_Document(); $xmlDoc->resolveErrors(true); if ($xmlDoc->loadXML($xmlfile, false, true)) { $root =& $xmlDoc->documentElement; if ($root->getTagName() == 'mosinstall' && $root->getAttribute('type') == 'module') { $element =& $root->getElementsByPath('description', 1); $row->description = $element ? trim($element->getText()) : ''; } } // get params definitions $params = new mosParameters($row->params, $xmlfile, 'module'); HTML_modules::editModule($row, $orders2, $lists, $params, $option); }
function get_Version($directory) { global $mainframe; require_once JPATH_ROOT . DS . 'includes/domit/xml_domit_lite_include.php'; $componentBaseDir = $directory; $xmlDoc = new DOMIT_Lite_Document(); $xmlDoc->resolveErrors(true); if (!$xmlDoc->loadXML($directory, false, true)) { continue; } //echo $xmlDoc->documentElement; $root =& $xmlDoc->documentElement; $element =& $root->getElementsByPath('version', 1); $version = $element ? $element->getText() : ''; return $version; }
/** * 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; josSpoofCheck(); $uninstallret = ''; $sql = "SELECT *" . "\n FROM #__components" . "\n WHERE id = " . (int) $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" . "\n WHERE parent = " . (int) $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" . "\n WHERE id = " . (int) $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; $found = 0; 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; } $root =& $xmlDoc->documentElement; if ($root->getTagName() != 'mosinstall') { continue; } $found = 1; $query_element =& $root->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; } } } } if (!$found) { HTML_installer::showInstallMessage('XML File invalid', 'Uninstall - error', $this->returnTo($option, 'component', $client)); exit; } } else { /* HTML_installer::showInstallMessage( 'Não foi possível encontrar um arquivo XML de instalação em '.$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; }
function uploadft($option) { global $mtconf, $mainframe; $database =& JFactory::getDBO(); require_once $mtconf->getjconf('absolute_path') . '/includes/domit/xml_domit_lite_include.php'; $files = JRequest::get('files'); $filename = $files['userfile']['tmp_name']; if (!empty($filename)) { $xmlDoc = new DOMIT_Lite_Document(); $xmlDoc->resolveErrors(true); if (!$xmlDoc->loadXML($filename, true, false)) { return null; } $root =& $xmlDoc->documentElement; if ($root->getTagName() != 'fieldtype') { return null; } $useelements = $root->getAttribute('useelements'); $usesize = $root->getAttribute('usesize'); $taggable = $root->getAttribute('taggable'); // $usecolumns = $root->getAttribute( 'usecolumns' ); $version = $root->getElementsByPath('version', 1); $website = $root->getElementsByPath('website', 1); $desc = $root->getElementsByPath('description', 1); $field_type = $root->getElementsByPath('name', 1); $caption = $root->getElementsByPath('caption', 1); $class = $root->getElementsByPath('class', 1); $version = $version->getText(); $website = $website->getText(); $desc = $desc->getText(); $field_type = $field_type->getText(); $caption = $caption->getText(); $class = $class->getText(); if (empty($useelements)) { $useelements = 0; } if (empty($usesize)) { $usesize = 0; } if (empty($version)) { $version = '1.00'; } if (empty($field_type) || empty($caption) || empty($class)) { return null; } $database->setQuery('SELECT ft_id FROM #__mt_fieldtypes WHERE field_type = ' . $database->quote($field_type) . ' LIMIT 1'); $duplicate_ft_id = $database->loadResult(); if ($duplicate_ft_id > 0) { $ft_id = saveft2($field_type, $caption, $class, $useelements, $usesize, $taggable, $version, $website, $desc, $duplicate_ft_id); $database->setQuery("DELETE FROM #__mt_fieldtypes_att WHERE ft_id = " . $ft_id); $database->query(); } else { $ft_id = saveft2($field_type, $caption, $class, $useelements, $usesize, $taggable, $version, $website, $desc); } $attachments =& $root->getElementsByPath('attachments', 1); if (!is_null($attachments)) { $attachmentsChildNodes = $attachments->childNodes; $attachment = new mtFieldTypesAtt($database); foreach ($attachmentsChildNodes as $attachmentsChildNode) { $filename = $attachmentsChildNode->getElementsByPath('filename', 1); $filesize = $attachmentsChildNode->getElementsByPath('filesize', 1); $extension = $attachmentsChildNode->getElementsByPath('extension', 1); $ordering = $attachmentsChildNode->getElementsByPath('ordering', 1); $filedata = $attachmentsChildNode->getElementsByPath('filedata', 1); $filename = $filename->getText(); $filesize = $filesize->getText(); $extension = $extension->getText(); $ordering = $ordering->getText(); $filedata = $filedata->getText(); $database->setQuery('INSERT INTO #__mt_fieldtypes_att (ft_id, filename, filedata, filesize, extension, ordering) ' . ' VALUES(' . $database->quote($ft_id) . ', ' . $database->quote($filename) . ', ' . $database->quote(base64_decode($filedata)) . ', ' . $database->quote($filesize) . ', ' . $database->quote($extension) . ', ' . '\'9999\')'); $database->query(); $attachment->reorder('ft_id=' . $ft_id); } } if (is_null($duplicate_ft_id)) { # Create an unpublished custom field for the new field type $database->setQuery('INSERT INTO #__mt_customfields (field_type, caption, published, ordering, advanced_search, simple_search, iscore)' . "\n VALUES(" . $database->quote($field_type) . ", " . $database->quote($caption) . ", '0', '99', '0', '0', '0')"); $database->query(); $row = new mtCustomFields($database); $row->reorder('published >= 0'); $mainframe->redirect('index2.php?option=com_mtree&task=managefieldtypes', JText::_('Field type installation success')); } else { $mainframe->redirect('index2.php?option=com_mtree&task=managefieldtypes', JText::_('Field type upgraded successfully')); } } }
function install_template($option) { global $mtconf, $mainframe; $database =& JFactory::getDBO(); $files = JRequest::get('files'); $template = $files['template']['tmp_name']; require_once $mtconf->getjconf('absolute_path') . '/includes/domit/xml_domit_lite_include.php'; require_once $mtconf->getjconf('absolute_path') . '/administrator/includes/pcl/pclzip.lib.php'; require_once $mtconf->getjconf('absolute_path') . '/administrator/includes/pcl/pclerror.lib.php'; $zipfile = new PclZip($template); if (substr(PHP_OS, 0, 3) == 'WIN') { define('OS_WINDOWS', 1); } else { define('OS_WINDOWS', 0); } $tmp_install = JPath::clean($mtconf->getjconf('absolute_path') . '/media/' . uniqid('minstall_')); if (!$zipfile->extract(PCLZIP_OPT_PATH, $tmp_install)) { $mainframe->redirect('index2.php?option=com_mtree&task=templates', JText::_('Template installation failed')); } $tmp_xml = $tmp_install . '/templateDetails.xml'; if (file_exists($tmp_xml)) { $xmlDoc = new DOMIT_Lite_Document(); $xmlDoc->resolveErrors(true); if (!$xmlDoc->loadXML($tmp_xml, true, false)) { return false; } $root =& $xmlDoc->documentElement; $template_name = $root->getElementsByPath('name', 1); $template_name = $template_name->getText(); $database->setQuery('INSERT INTO #__mt_templates (tem_name) VALUES(' . $database->quote($template_name) . ')'); $database->query(); } else { rmdirr($tmp_install); $mainframe->redirect('index2.php?option=com_mtree&task=templates', JText::_('Template installation failed')); } if ($handle = opendir($tmp_install)) { $tmp_installdir = JPath::clean($mtconf->getjconf('absolute_path') . '/components/com_mtree/templates/' . $template_name); if (file_exists($tmp_installdir)) { rmdirr($tmp_install); $mainframe->redirect('index2.php?option=com_mtree&task=templates', JText::_('Template installation failed')); } mkdir($tmp_installdir, 0755); while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..') { copy($tmp_install . '/' . $file, $tmp_installdir . '/' . $file); } } closedir($handle); rmdirr($tmp_install); } $mainframe->redirect('index2.php?option=com_mtree&task=templates', JText::_('Template installation success')); }
function getExt() { return ""; $dir = JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'ext'; $arr = scandir($dir); $ret = array(); if (!empty($arr)) { foreach ($arr as $file) { if (is_dir($dir . DS . $file) && $file != '.' && $file != '..') { $arr = array(); $arr['path'] = $dir . DS . $file; $arr['enabled'] = file_exists($dir . DS . $file . DS . 'enabled.html'); $arr['name'] = $file; // params part here? if (file_exists($dir . DS . $file . DS . 'description.txt')) { $desc = file_get_contents($dir . DS . $file . DS . 'description.txt'); } else { $desc = ''; } $arr['desc'] = $desc; if (file_exists($dir . DS . $file . DS . 'extension.xml')) { $xmlDoc = new DOMIT_Lite_Document(); $xmlDoc->resolveErrors(true); if ($xmlDoc->loadXML($dir . DS . $file . DS . 'extension.xml', false, true)) { $root =& $xmlDoc->documentElement; $tagName = $root->getTagName(); $isParamsFile = $tagName == 'mosinstall' || $tagName == 'mosparams'; if ($isParamsFile && $root->getAttribute('type') == 'opext') { if ($params =& $root->getElementsByPath('params', 1)) { $element =& $params; } } $arr['params'] = $params; $desce =& $root->getElementsByPath('description', 1); $desc = $desce->getText(); if ($desc) { $arr['desc'] = (string) $desc; } $namee =& $root->getElementsByPath('name', 1); $name = $namee->getText(); if ($name) { $arr['nametxt'] = (string) $name; } } else { $app = JFactory::getApplication(); $app->enqueueMessage('OPC Extensions XML Error: ' . $xmlDoc->errorString); } } if (empty($arr['nametxt'])) { $arr['nametxt'] = $file; } $ret[] = $arr; } } } return $ret; }
function getXML($xmlfile, $element_name) { jimport( 'joomla.factory' ); jimport('domit.xml_domit_lite_include'); $xmlDoc = new DOMIT_Lite_Document(); $xmlDoc->resolveErrors(true); if (!@$xmlDoc->loadXML($xmlfile)) { return "Could not connect"; } $element = & $xmlDoc->documentElement; $element = & $xmlDoc->getElementsByPath($element_name, 1); $result = $element ? $element->getText() : ''; return $result; } ?>
/** * Retrieve joomla standard user parameters so that they can be displayed in user edit mode. * @param int $ui 1 for front-end, 2 for back-end * @param moscomprofilerUser $user the user being displayed * @param string $name Name of variable * @return array of user parameter attributes (title,value) */ function _getUserParams($ui, $user, $name = "params") { global $_CB_framework; $result = array(); // in case not Joomla if (class_exists("JUser")) { // Joomla 1.5 and 1.6: if ($user->id) { $juser = JUser::getInstance($user->id); } else { $juser = JUser::getInstance(); } if (checkJversion() == 2) { // Joomla 1.6: $result = array(); jimport('joomla.form.form'); JForm::addFormPath(JPATH_ADMINISTRATOR . '/components/com_users/models/forms'); $form = JForm::getInstance('com_users.params', 'user', array('load_data' => true)); $params = $juser->getParameters(true)->toArray(); if ($params) { foreach ($params as $k => $v) { $form->setValue($k, 'params', $v); } } $fields = $form->getFieldset('settings'); if ($fields) { foreach ($fields as $field) { $admin_field = strpos($field->name, 'admin') || strpos($field->name, 'help'); if ($admin_field && ($juser->authorise('canManageUsers') || !$user->id) || !$admin_field) { $result[] = array($field->label, $field->input, $field->description, $field->name); } } } } else { // Joomla 1.5: $params =& $juser->getParameters(true); // $result = $params->render( 'params' ); if (is_callable(array($params, "getParams"))) { $result = $params->getParams($name); //BBB new API submited to Jinx 17.4.2006. } else { foreach ($params->_xml->param as $param) { //BBB still needs core help... accessing private variable _xml . $result[] = $params->renderParam($param, $name); } } } } else { if (file_exists($_CB_framework->getCfg('absolute_path') . '/administrator/components/com_users/users.class.php')) { require_once $_CB_framework->getCfg('absolute_path') . '/administrator/components/com_users/users.class.php'; } if (class_exists('mosUserParameters')) { // Joomla 1.0 : global $mainframe; $file = $mainframe->getPath('com_xml', 'com_users'); $userParams = new mosUserParameters($user->params, $file, 'component'); if (isset($userParams->_path) && $userParams->_path) { // Joomla 1.0 if (!is_object($userParams->_xmlElem)) { require_once $_CB_framework->getCfg('absolute_path') . '/includes/domit/xml_domit_lite_include.php'; $xmlDoc = new DOMIT_Lite_Document(); $xmlDoc->resolveErrors(true); if ($xmlDoc->loadXML($userParams->_path, false, true)) { $root =& $xmlDoc->documentElement; $tagName = $root->getTagName(); $isParamsFile = $tagName == 'mosinstall' || $tagName == 'mosparams'; if ($isParamsFile && $root->getAttribute('type') == $userParams->_type) { $params =& $root->getElementsByPath('params', 1); if ($params) { $userParams->_xmlElem =& $params; } } } } } $result = array(); if (isset($userParams->_xmlElem) && is_object($userParams->_xmlElem)) { // Joomla 1.0 $element =& $userParams->_xmlElem; //$params = mosParseParams( $row->params ); $userParams->_methods = get_class_methods("mosUserParameters"); foreach ($element->childNodes as $param) { $result[] = $userParams->renderParam($param, $name); } } } } return $result; }
/** * @param string The name of the default text area is a setup file is not found * @return string HTML */ function render($name = 'params', $method = 'Standard') { if ($this->_path) { if (!is_object($this->_xmlElem)) { $xmlDoc = new DOMIT_Lite_Document(); $xmlDoc->resolveErrors(true); if ($xmlDoc->loadXML($this->_path, false, true)) { $element =& $xmlDoc->documentElement; if (($element->getTagName() == 'form' or $element->getTagName() == 'install') && $element->getAttribute("type") == $this->_type) { if ($element =& $xmlDoc->getElementsByPath('params', 1)) { $this->_xmlElem =& $element; } } } } } if (is_object($this->_xmlElem)) { return call_user_func(array($this, '_render' . $method), $this->_xmlElem, $name); } else { return "<textarea name=\"" . $name . "\" cols=\"40\" rows=\"10\" class=\"text_area\">" . $this->_raw . "</textarea>"; } }
/** * 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((int) $uid); // fail if checked out not by 'me' if ($row->isCheckedOut($my->id)) { mosErrorAlert("O módulo " . $row->title . " está, atualmente, a ser editado por outro administrador"); } 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'] = '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 = " . $database->Quote($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 . '" />Este plugin não pode ser reordenado'; } $lists['folder'] = '<input type="hidden" name="folder" value="' . $row->folder . '" />' . $row->folder; // 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)) { $root =& $xmlDoc->documentElement; if ($root->getTagName() == 'mosinstall' && $root->getAttribute('type') == 'mambot') { $element =& $root->getElementsByPath('description', 1); $row->description = $element ? trim($element->getText()) : ''; } } } 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 . '" />Os novos itens, por padrão, serão adicionados ao final da lista. A ordem pode ser alterada após este item serem salvos.'; } $lists['published'] = mosHTML::yesnoRadioList('published', 'class="inputbox"', $row->published); $path = $mosConfig_absolute_path . "/mambots/{$row->folder}/{$row->element}.xml"; if (!file_exists($path)) { $path = ''; } // get params definitions $params = new mosParameters($row->params, $path, 'mambot'); HTML_modules::editMambot($row, $lists, $params, $option); }
/** * Compiles a list of installed languages */ function viewLanguages($option) { global $languages; 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; } $root =& $xmlDoc->documentElement; if ($root->getTagName() != 'mosinstall') { continue; } if ($root->getAttribute("type") != "language") { continue; } $row = new StdClass(); $row->id = $rowid; $row->language = substr($xmlfile, 0, -4); $element =& $root->getElementsByPath('name', 1); $row->name = $element->getText(); $element =& $root->getElementsByPath('creationDate', 1); $row->creationdate = $element ? $element->getText() : 'Unknown'; $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() : ''; // 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); }
/** * @param string A file path * @return object A DOMIT XML document, or null if the file failed to parse */ function isPackageFile($p_file) { $xmlDoc = new DOMIT_Lite_Document(); $xmlDoc->resolveErrors(true); if (!$xmlDoc->loadXML($p_file, false, true)) { return null; } $root =& $xmlDoc->documentElement; if ($root->getTagName() != 'mosinstall') { return null; } // Set the type $this->installType($root->getAttribute('type')); $this->installFilename($p_file); return $xmlDoc; }
function loadInstalledPlugins(&$rows, &$xmlfile) { $database =& JFactory::getDBO(); if (!defined('DOMIT_INCLUDE_PATH')) { require_once JPATH_SITE . DS . 'libraries' . DS . 'domit' . DS . 'xml_domit_lite_parser.php'; } $query = "SELECT id, extension, published" . "\n FROM #__xmap_ext" . "\n WHERE extension not like '%.bak'" . "\n ORDER BY extension"; $database->setQuery($query); $rows = $database->loadObjectList(); $n = count($rows); for ($i = 0; $i < $n; $i++) { $row =& $rows[$i]; // path to module directory $extensionBaseDir = JPATH_COMPONENT_ADMINISTRATOR . DS . 'extensions' . DS; // xml file for module $xmlfile = $extensionBaseDir . $row->extension . ".xml"; if (file_exists($xmlfile)) { $xmlDoc = new DOMIT_Lite_Document(); $xmlDoc->resolveErrors(true); if (!$xmlDoc->loadXML($xmlfile, false, true)) { continue; } $root =& $xmlDoc->documentElement; if ($root->getTagName() != 'install' && $root->getTagName() != 'mosinstall') { continue; } if ($root->getAttribute("type") != "xmap_ext") { continue; } $element =& $root->getElementsByPath('name', 1); $row->name = $element ? $element->getText() : ''; $element =& $root->getElementsByPath('creationDate', 1); $row->creationdate = $element ? $element->getText() : ''; $element =& $root->getElementsByPath('author', 1); $row->author = $element ? $element->getText() : ''; $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() : ''; } else { echo "Missing file '{$xmlfile}'"; } } }
/** * 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); }
/** * Main upgrade function. Processes XML file */ function doUpgrade() { require_once KUNENA_ROOT_PATH . DS . 'includes/domit/xml_domit_lite_include.php'; if (!$this->silent) { ?> <script language=JavaScript> function showDetail(srcElement) { var targetID, srcElement, targetElement, imgElementID, imgElement; targetID = srcElement.id + "_details"; imgElementID = srcElement.id + "_img"; targetElement = document.getElementById(targetID); imgElement = document.getElementById(imgElementID); if (targetElement.style.display == "none") { targetElement.style.display = ""; imgElement.src = "images/collapseall.png"; } else { targetElement.style.display = "none"; imgElement.src = "images/expandall.png"; } } </script> <style> .details { font-family: courier; background-color: #EEEEEE; border: 1px dashed #BBBBBB; padding-left: 10px; margin-left: 20px; margin-top: 5px; </style> <?php } $componentBaseDir = KUNENA_ROOT_PATH_ADMIN . DS . 'components/'; $this->_upgradeDir = $componentBaseDir . $this->component . DS . $this->subdir; //get current version, check if version table exists $createVersionTable = 1; $upgrade = null; // Legacy enabler // Versions prior to 1.0.5 did not came with a version table inside the database // this would make the installer believe this is a fresh install. We need to perform // a 'manual' check if this is going to be an upgrade and if so create that table // and write a dummy version entry to force an upgrade. $kunena_db =& JFactory::getDBO(); $kunena_db->setQuery("SHOW TABLES LIKE " . $kunena_db->quote($kunena_db->getPrefix() . 'fb_messages')); $kunena_db->query(); check_dberror("Unable to search for messages table."); if ($kunena_db->getNumRows()) { // fb tables exist, now lets see if we have a version table $kunena_db->setQuery("SHOW TABLES LIKE " . $kunena_db->quote($this->versionTable)); $createVersionTable = $kunena_db->loadResult(); $createVersionTable = empty($createVersionTable); check_dberror("Unable to search for version table."); if ($createVersionTable) { //version table does not exist - this is a pre 1.0.5 install - lets create $this->createVersionTable(); // insert dummy version entry to force upgrade $this->insertDummyVersion(); $createVersionTable = 0; } } if (!$createVersionTable) { // lets see if we need to update the version table layout from it original $currentVersion = $this->getLatestVersion($this->versionTable); if (!is_object($currentVersion)) { // version table exisits, but we cannot retrieve the latest version // in this case we assume the table layout might have changed // backup old table and create new version table $this->backupVersionTable(); $this->dropVersionTable(); $this->createVersionTable(); // insert dummy version info to start with $this->insertDummyVersion(); } //check for latest version and date entry $currentVersion = $this->getLatestVersion($this->versionTable); if (!$currentVersion->version && !$currentVersion->versiondate) { //there was an error in retrieving the version and date, goto install mode $upgrade = 0; } else { //OK, no error, there is a version table and it also contains version and date information, switching to upgrade mode $upgrade = 1; } } //Create version table if ($createVersionTable == 1) { if (!$this->createVersionTable()) { $this->_error = "DB function failed with error number <b>" . $kunena_db->_errorNum . "</b><br/>"; $this->_error .= $kunena_db->getErrorMsg(); $img = "publish_x.png"; $this->_return = false; } else { $img = "tick.png"; } if (!$this->silent) { ?> <table class="adminlist"> <tr> <td>Creating version table</td> <td width="20"><a href="#" onMouseOver="return overlib('<?php echo $this->_error; ?> ', BELOW, RIGHT,WIDTH,300);" onmouseout="return nd();" ><img src="images/<?php echo $img; ?> " border="0"></a></td> </tr> </table> <?php } } //initiate XML doc $xmlDoc = new DOMIT_Lite_Document(); $xmlDoc->loadXML($this->_upgradeDir . DS . $this->xmlFileName, false, true); //load root element and check XML version (for future use) $root =& $xmlDoc->documentElement; $comUpgradeVersion = $root->getAttribute("version"); //here comes the real stuff if ($upgrade == 0) { $installElement =& $root->firstChild; $version = $installElement->getAttribute("version"); $versiondate = $installElement->getAttribute("versiondate"); $build = $installElement->getAttribute("build"); $versionname = $installElement->getAttribute("versionname"); if (!$this->silent) { ?> <div id="overDiv" style="position:absolute; visibility:hidden; z-index:10000;"></div> <script type="text/javascript" src="<?php echo JURI::root(); ?> /includes/js/overlib_mini.js"></script> <table class="adminlist"> <tr> <th colspan="2">Installing "<?php echo $this->component; ?> " (Version: <?php echo $version; ?> / Date: <?php echo $versiondate; ?> / Build: <?php echo $build; ?> / VersionName: <?php echo $versionname; ?> )</th> </tr> <?php } //install mode, run install queries $installElement = $root->getElementsByPath('install', 1); if (!is_null($installElement)) { $this->processNode($installElement, 1); } if (!$this->silent) { ?> </table> <?php } //Store version info and date in database $this->insertVersionData($version, $versiondate, $build, $versionname); } else { if (!$this->silent) { ?> <div id="overDiv" style="position:absolute; visibility:hidden; z-index:10000;"></div> <script type="text/javascript" src="<?php echo JURI::root(); ?> /includes/js/overlib_mini.js"></script> <table class="adminlist"> <tr> <th colspan="2">Upgrading "<?php echo $this->component; ?> " (Version: <?php echo @$currentVersion->version; ?> / Version Date: <?php echo @$currentVersion->versiondate; ?> / Install Date: <?php echo @$currentVersion->installdate; ?> / Build: <?php echo @$currentVersion->build; ?> / Version Name: <?php echo @$currentVersion->versionname; ?> )</th> </tr> <?php } //upgrade mode $upgradeElement = $root->getElementsByPath('upgrade', 1); if (!is_null($upgradeElement)) { //walk through the versions $numChildrenMain =& $upgradeElement->childCount; $childNodesMain =& $upgradeElement->childNodes; for ($k = 0; $k < $numChildrenMain; $k++) { $versionElement =& $childNodesMain[$k]; $version = $versionElement->getAttribute("version"); $versiondate = $versionElement->getAttribute("versiondate"); $build = $versionElement->getAttribute("build"); $versionname = $versionElement->getAttribute("versionname"); //when legacy version exists, just compare version, if date exists as well, compare date if ($currentVersion->versiondate && $versiondate > $currentVersion->versiondate or version_compare($version, $currentVersion->version, '>') or version_compare($version, $currentVersion->version, '==') && $build > $currentVersion->build) { //these instructions are for a newer version than the currently installed version if (!$this->silent) { ?> <tr> <td colspan="2"> </td> </tr> <tr> <th colspan="2">Version: <?php echo $version; ?> (Version Date: <?php echo $versiondate; ?> , Build: <?php echo $build; ?> , Version Name: <?php echo $versionname; ?> )</th> </tr> <?php } //Store version info and date in database $this->insertVersionData($version, $versiondate, $build, $versionname); $added_version = 1; $this->processNode($versionElement, $k); } //end if version newer check } //end version element loop if (!isset($added_version)) { $this->insertVersionData($version, $versiondate, $build, $versionname); } } //end if !is_null($upgradeElement) if (!$this->silent) { ?> </table> <?php } } //end main if upgrade or not return $this->_return; }
/** * Reads the JoomlaPack version information out of joomlapack.xml and defines two constants * */ function getJoomlaPackVersion() { require_once JPATH_SITE . DS . 'includes' . DS . 'domit' . DS . 'xml_domit_lite_include.php'; $xmlDoc = new DOMIT_Lite_Document(); $xmlDoc->resolveErrors(true); if ($xmlDoc->loadXML(JPATH_COMPONENT_ADMINISTRATOR . DS . 'joomlapack.xml', false, true)) { $root =& $xmlDoc->documentElement; $e =& $root->getElementsByPath('version', 1); define("_JP_VERSION", $e->getText()); $root =& $xmlDoc->documentElement; $e =& $root->getElementsByPath('creationDate', 1); define("_JP_DATE", $e->getText()); } else { define("_JP_VERSION", "1.2 Series SVN"); define("_JP_DATE", ""); } }